Skip to content

@codesoul-co/hypha-memory / context-builder

Using this module

Use the Context builder module for using the public contracts and operations for this capability boundary. It exports 4 classes.

Import from the package entrypoint

ts
import {
  CalibratedCharacterTokenEstimator,
  DefaultContextInjectionGateway,
  DefaultMemoryContextBuilder,
  MetadataContextItemPolicyEvaluator,
} from '@codesoul-co/hypha-memory';

Usage patterns

  • The module exposes 4 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.

Public exports

SymbolKindSignatureDescription
CalibratedCharacterTokenEstimatorclassnew CalibratedCharacterTokenEstimator(charactersPerToken?: number): CalibratedCharacterTokenEstimatorCalibrated Character Token Estimator class with 3 public constructor or member entries; its exact declarations are listed below.
DefaultContextInjectionGatewayclassnew DefaultContextInjectionGateway(now?: () => string, artifactStore?: ContextArtifactStore | undefined): DefaultContextInjectionGatewayDefault Context Injection Gateway class with 2 public constructor or member entries; its exact declarations are listed below.
DefaultMemoryContextBuilderclassnew DefaultMemoryContextBuilder(tokenizer?: TokenEstimator, now?: () => string, compactor?: ContextCompactor, policy?: ContextItemPolicyEvaluator, artifactStore?: ContextArtifactStore | undefined): DefaultMemoryContextBuilderDefault Memory Context Builder class with 3 public constructor or member entries; its exact declarations are listed below.
MetadataContextItemPolicyEvaluatorclassnew MetadataContextItemPolicyEvaluator(): MetadataContextItemPolicyEvaluatorMetadata Context Item Policy Evaluator class with 2 public constructor or member entries; its exact declarations are listed below.

CalibratedCharacterTokenEstimator

Calibrated Character Token Estimator class with 3 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { CalibratedCharacterTokenEstimator } from '@codesoul-co/hypha-memory';
  • Source module: context-builder

Declaration

text
export declare class CalibratedCharacterTokenEstimator implements TokenEstimator {
    readonly id = "tokenizer.calibrated-character-v1";
    constructor(charactersPerToken?: number);
    estimate(text: string): number;
}

Public members

MemberKindSignatureDescription
constructorconstructor(charactersPerToken?: number): CalibratedCharacterTokenEstimatorCreates an instance of this class.
estimatemethodestimate(text: string): numberPublic method; parameters and return type are shown in the signature.
idpropertyreadonly id: "tokenizer.calibrated-character-v1"Public property; its type, readonly modifier and optionality are shown in the signature.

DefaultContextInjectionGateway

Default Context Injection Gateway class with 2 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { DefaultContextInjectionGateway } from '@codesoul-co/hypha-memory';
  • Source module: context-builder

Declaration

text
export declare class DefaultContextInjectionGateway implements ContextInjectionGateway {
    constructor(now?: () => string, artifactStore?: ContextArtifactStore | undefined);
    buildEnvelope(bundle: ContextBundle, profile: ContextProfileSpec): Promise<ContextEnvelope>;
}

Public members

MemberKindSignatureDescription
buildEnvelopemethodbuildEnvelope(bundle: ContextBundle, profile: ContextProfileSpec): Promise<ContextEnvelope>Public method; parameters and return type are shown in the signature.
constructorconstructor(now?: () => string, artifactStore?: ContextArtifactStore | undefined): DefaultContextInjectionGatewayCreates an instance of this class.

DefaultMemoryContextBuilder

Default Memory Context Builder class with 3 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { DefaultMemoryContextBuilder } from '@codesoul-co/hypha-memory';
  • Source module: context-builder

Declaration

text
export declare class DefaultMemoryContextBuilder implements MemoryContextBuilder {
    constructor(tokenizer?: TokenEstimator, now?: () => string, compactor?: ContextCompactor, policy?: ContextItemPolicyEvaluator, artifactStore?: ContextArtifactStore | undefined);
    build(request: ContextBuildInput): Promise<ContextBundle>;
    explain(contextHash: string): Promise<ContextBuildExplanation | null>;
}

Public members

MemberKindSignatureDescription
buildmethodbuild(request: ContextBuildInput): Promise<ContextBundle>Public method; parameters and return type are shown in the signature.
constructorconstructor(tokenizer?: TokenEstimator, now?: () => string, compactor?: ContextCompactor, policy?: ContextItemPolicyEvaluator, artifactStore?: ContextArtifactStore | undefined): DefaultMemoryContextBuilderCreates an instance of this class.
explainmethodexplain(contextHash: string): Promise<ContextBuildExplanation | null>Public method; parameters and return type are shown in the signature.

MetadataContextItemPolicyEvaluator

Metadata Context Item Policy Evaluator class with 2 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { MetadataContextItemPolicyEvaluator } from '@codesoul-co/hypha-memory';
  • Source module: context-builder

Declaration

text
export declare class MetadataContextItemPolicyEvaluator implements ContextItemPolicyEvaluator {
    evaluate(input: ContextItemPolicyInput): Promise<{
            allowed: boolean;
            reason?: string;
        }>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(): MetadataContextItemPolicyEvaluatorCreates an instance of this class.
evaluatemethodevaluate(input: ContextItemPolicyInput): Promise<{ allowed: boolean; reason?: string; }>Public method; parameters and return type are shown in the signature.