Skip to content

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

Using this module

Use the Context compaction module for using the public contracts and operations for this capability boundary. It exports 1 class, 2 interfaces.

Import from the package entrypoint

ts
import {
  DeterministicExtractiveContextCompactor,
} from '@codesoul-co/hypha-memory';

import type {
  ContextCompactionRequest,
  ContextCompactor,
} from '@codesoul-co/hypha-memory';

Usage patterns

  • Use the 2 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 1 class as constructable runtime implementations. Each symbol entry lists its constructor and public methods.

Public exports

SymbolKindSignatureDescription
DeterministicExtractiveContextCompactorclassnew DeterministicExtractiveContextCompactor(): DeterministicExtractiveContextCompactorDeterministic Extractive Context Compactor class with 3 public constructor or member entries; its exact declarations are listed below.
ContextCompactionRequestinterfaceinterface ContextCompactionRequestContext Compaction Request interface with 4 public fields or methods.
ContextCompactorinterfaceinterface ContextCompactorContext Compactor interface with 2 public fields or methods.

DeterministicExtractiveContextCompactor

Deterministic Extractive Context Compactor class with 3 public constructor or member entries; its exact declarations are listed below.

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

Declaration

text
export declare class DeterministicExtractiveContextCompactor implements ContextCompactor {
    readonly id = "context.compactor.extractive-v1";
    compact(request: ContextCompactionRequest): Promise<ContextItem | null>;
}

Public members

MemberKindSignatureDescription
compactmethodcompact(request: ContextCompactionRequest): Promise<ContextItem | null>Public method; parameters and return type are shown in the signature.
constructorconstructor(): DeterministicExtractiveContextCompactorCreates an instance of this class.
idpropertyreadonly id: "context.compactor.extractive-v1"Public property; its type, readonly modifier and optionality are shown in the signature.

ContextCompactionRequest

Context Compaction Request interface with 4 public fields or methods.

  • Kind: interface
  • Import: import type { ContextCompactionRequest } from '@codesoul-co/hypha-memory';
  • Source module: context-compaction

Declaration

text
export interface ContextCompactionRequest {
    items: ContextItem[];
    maxTokens: number;
    tokenizer: TokenEstimator;
    sourceId?: string;
}

Contract members

MemberKindSignatureDescription
itemspropertyitems: ContextItem[]Public property; its type, readonly modifier and optionality are shown in the signature.
maxTokenspropertymaxTokens: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
sourceIdpropertysourceId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
tokenizerpropertytokenizer: TokenEstimatorPublic property; its type, readonly modifier and optionality are shown in the signature.

ContextCompactor

Context Compactor interface with 2 public fields or methods.

  • Kind: interface
  • Import: import type { ContextCompactor } from '@codesoul-co/hypha-memory';
  • Source module: context-compaction

Declaration

text
export interface ContextCompactor {
    readonly id: string;
    compact(request: ContextCompactionRequest): Promise<ContextItem | null>;
}

Contract members

MemberKindSignatureDescription
compactmethodcompact(request: ContextCompactionRequest): Promise<ContextItem | null>Public method; parameters and return type are shown in the signature.
idpropertyreadonly id: stringPublic property; its type, readonly modifier and optionality are shown in the signature.