Skip to content

@codesoul-co/hypha-memory / index

模块用法

聚合 @codesoul-co/hypha-memory 的公共入口导出;应用应从包入口导入这些 Symbol,不应依赖内部文件路径。

从包入口导入

ts
import {
  MemoryManager,
  memoryProviderProfileSchema,
  memoryRetrievalPolicySchema,
  memorySpecDefinition,
  memorySpecDefinitions,
  memorySpecExample,
  memorySpecJsonSchema,
  memorySpecJsonSchemas,
} from '@codesoul-co/hypha-memory';

import type {
  ArtifactMeta,
  ArtifactRef,
  ArtifactStoreProvider,
  EmbeddingProvider,
  MemoryAuditOptions,
  MemoryAuditReport,
  MemoryManagerOptions,
  MemoryManagerRecoveryOptions,
} from '@codesoul-co/hypha-memory';

// 完整导出列表见下方。

使用要点

  • 29 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 1 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。
  • 1 个函数是该模块的直接操作入口;每个 overload 的必需/可选参数与返回类型均在下方列出。
  • 9 个常量/枚举提供稳定值、Schema、Definition 或默认配置;应复用这些导出,避免在应用中复制内部值。

运行时校验示例

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

declare function loadExternalInput(): unknown;
const input: unknown = loadExternalInput();
const parsed = memoryProviderProfileSchema.parse(input);

配置、网络请求或持久化数据等不可信输入应先通过 Runtime Schema,再传给只接受已校验契约的函数或类。

公共导出

Symbol种类签名说明
MemoryManagernew MemoryManager(provider: MemoryProvider | MemoryManagementProvider, options?: MemoryManagerOptions): MemoryManagerMemory Manager 类,共公开 16 个构造函数或成员;精确签名见本条目的声明与成员表。
memoryProviderProfileSchema常量const memoryProviderProfileSchema: z.ZodObject<{ id: z.ZodString; type: z.ZodEnum<["structured", "vector", "artifact", "hybrid"]>; providerRef: z.ZodString; configSchema: z.ZodOptional<z.ZodType<JsonSchema, z.ZodTypeDef, JsonSchema>>; }, "strip", z.ZodTypeAny, { id: string; type: "artifact" | "structured" | "vector" | "hybrid"; providerRef: string; configSchema?: JsonSchema | undefined; }, { id: string; type: "art...Memory Provider Profile 的运行时 Schema。
memoryRetrievalPolicySchema常量const memoryRetrievalPolicySchema: z.ZodObject<{ defaultTopK: z.ZodOptional<z.ZodNumber>; vectorWeight: z.ZodOptional<z.ZodNumber>; textWeight: z.ZodOptional<z.ZodNumber>; requireScope: z.ZodOptional<z.ZodBoolean>; allowedTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["working", "episodic", "semantic", "procedural", "artifact", "governance"]>, "many">>; }, "strip", z.ZodTypeAny, { defaultTopK?: number | undefined; vec...Memory Retrieval Policy 的运行时 Schema。
memorySpecDefinition常量const memorySpecDefinition: SpecSchemaDefinition<MemorySpec>Memory Spec 的运行时校验入口,组合 Parser、Example 与 JSON Schema。
memorySpecDefinitions常量const memorySpecDefinitions: readonly [SpecSchemaDefinition<MemorySpec>]index 模块导出的 Memory Spec Definitions 常量。
memorySpecExample常量const memorySpecExample: MemorySpecMemory Spec 的有效示例值。
memorySpecJsonSchema常量const memorySpecJsonSchema: JsonSchemaMemory Spec 的 JSON Schema。
memorySpecJsonSchemas常量const memorySpecJsonSchemas: Record<string, JsonSchema>index 模块导出的 Memory Spec JSON Schemas 常量。
memorySpecSchema常量const memorySpecSchema: z.ZodObject<{ id: z.ZodString; version: z.ZodString; } & { name: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; owner: z.ZodOptional<z.ZodString>; tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; createdAt: z.ZodOptional<z.ZodString>; updatedAt: z.ZodOptional<z.ZodString>; } & { providers: z.ZodArray<z.ZodObject<{ id: z.ZodString; type: z.ZodEnum<["structured", "v...Memory Spec 的运行时 Schema。
memoryTypeSchema常量const memoryTypeSchema: z.ZodEnum<["working", "episodic", "semantic", "procedural", "artifact", "governance"]>Memory Type 的运行时 Schema。
validateMemorySpec函数validateMemorySpec(input: unknown): MemorySpecValidate Memory Spec 函数,提供 1 个公开调用签名;参数与返回类型见下表。
ArtifactMeta接口interface ArtifactMetaArtifact Meta 接口,共包含 4 个公开字段或方法。
ArtifactRef接口interface ArtifactRefArtifact Ref 接口,共包含 3 个公开字段或方法。
ArtifactStoreProvider接口interface ArtifactStoreProviderArtifact Store Provider 接口,共包含 3 个公开字段或方法。
EmbeddingProvider接口interface EmbeddingProviderEmbedding Provider 接口,共包含 1 个公开字段或方法。
MemoryAuditOptions接口interface MemoryAuditOptionsMemory Audit Options 接口,共包含 2 个公开字段或方法。
MemoryAuditReport接口interface MemoryAuditReportMemory Audit Report 接口,共包含 3 个公开字段或方法。
MemoryManagerOptions接口interface MemoryManagerOptionsMemory Manager Options 接口,共包含 4 个公开字段或方法。
MemoryManagerRecoveryOptions接口interface MemoryManagerRecoveryOptionsMemory Manager Recovery Options 接口,共包含 5 个公开字段或方法。
MemoryProvider接口interface MemoryProviderMemory Provider 接口,共包含 7 个公开字段或方法。
MemoryProviderProfile接口interface MemoryProviderProfileMemory Provider Profile 接口,共包含 4 个公开字段或方法。
MemoryReadQuery接口interface MemoryReadQueryMemory Read Query 接口,共包含 3 个公开字段或方法。
MemoryRecord接口interface MemoryRecordMemory Record 接口,共包含 10 个公开字段或方法。
MemoryRetrievalPolicy接口interface MemoryRetrievalPolicyMemory Retrieval Policy 接口,共包含 5 个公开字段或方法。
MemoryScope接口interface MemoryScopeMemory Scope 接口,共包含 4 个公开字段或方法。
MemorySearchQuery接口interface MemorySearchQueryMemory Search Query 接口,共包含 4 个公开字段或方法。
MemorySearchResult接口interface MemorySearchResultMemory Search Result 接口,共包含 3 个公开字段或方法。
MemorySpec接口interface MemorySpec extends VersionedSpec, SpecMetadataMemory Spec 接口,共包含 23 个公开字段或方法。
MemorySummary接口interface MemorySummaryMemory Summary 接口,共包含 3 个公开字段或方法。
MemorySummaryOptions接口interface MemorySummaryOptionsMemory Summary Options 接口,共包含 2 个公开字段或方法。
MemoryTraceContext接口interface MemoryTraceContextMemory Trace Context 接口,共包含 7 个公开字段或方法。
MemoryWritePolicy接口interface MemoryWritePolicyMemory Write Policy 接口,共包含 4 个公开字段或方法。
MemoryWriteResult接口interface MemoryWriteResultMemory Write Result 接口,共包含 3 个公开字段或方法。
StructuredQuery接口interface StructuredQueryStructured Query 接口,共包含 3 个公开字段或方法。
StructuredStoreProvider接口interface StructuredStoreProviderStructured Store Provider 接口,共包含 7 个公开字段或方法。
VectorIndexProvider接口interface VectorIndexProviderVector Index Provider 接口,共包含 3 个公开字段或方法。
VectorQuery接口interface VectorQueryVector Query 接口,共包含 3 个公开字段或方法。
VectorRecord接口interface VectorRecordVector Record 接口,共包含 3 个公开字段或方法。
VectorSearchResult接口interface VectorSearchResultVector Search Result 接口,共包含 3 个公开字段或方法。
MemoryType类型type MemoryType = 'working' | 'episodic' | 'semantic' | 'procedural' | 'artifact' | 'governance'Memory Type 公共类型别名;完整类型表达式见声明。

MemoryManager

Memory Manager 类,共公开 16 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { MemoryManager } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export declare class MemoryManager {
    constructor(provider: MemoryProvider | MemoryManagementProvider, options?: MemoryManagerOptions);
    capabilities(): Promise<MemoryManagementCapabilities>;
    add(request: MemoryAddRequest): Promise<ManagedMemoryWriteResult>;
    read(scope: MemoryScope, query: MemoryReadQuery): Promise<MemoryRecord[]>;
    search(scope: MemoryScope, query: MemorySearchQuery): Promise<MemorySearchResult[]>;
    search(request: ManagedMemorySearchRequest): Promise<ManagedMemorySearchResult[]>;
    write(scope: MemoryScope, record: MemoryRecord, policy: MemoryWritePolicy): Promise<MemoryWriteResult>;
    update(scope: MemoryScope, recordId: string, patch: Partial<MemoryRecord>): Promise<void>;
    update(request: ManagedMemoryUpdateRequest): Promise<ManagedMemoryWriteResult>;
    get(request: MemoryGetRequest): Promise<ManagedMemoryRecord | null>;
    list(request: MemoryListRequest): Promise<MemoryListResult>;
    delete(request: ManagedMemoryDeleteRequest): Promise<ManagedMemoryDeleteResult>;
    history(request: MemoryHistoryRequest): Promise<MemoryVersion[]>;
    health(): Promise<ProviderHealth>;
    close(): Promise<void>;
    invalidate(scope: MemoryScope, recordId: string, reason: string): Promise<void>;
    summarize(scope: MemoryScope, options?: MemorySummaryOptions): Promise<MemorySummary>;
    audit(scope: MemoryScope, options?: MemoryAuditOptions): Promise<MemoryAuditReport>;
}

公开成员

成员种类签名说明
add方法add(request: MemoryAddRequest): Promise<ManagedMemoryWriteResult>公开方法;参数与返回类型以签名列为准。
audit方法audit(scope: MemoryScope, options?: MemoryAuditOptions): Promise<MemoryAuditReport>公开方法;参数与返回类型以签名列为准。
capabilities方法capabilities(): Promise<MemoryManagementCapabilities>公开方法;参数与返回类型以签名列为准。
close方法close(): Promise<void>公开方法;参数与返回类型以签名列为准。
constructor构造函数(provider: MemoryProvider | MemoryManagementProvider, options?: MemoryManagerOptions): MemoryManager创建该类的实例。
delete方法delete(request: ManagedMemoryDeleteRequest): Promise<ManagedMemoryDeleteResult>公开方法;参数与返回类型以签名列为准。
get方法get(request: MemoryGetRequest): Promise<ManagedMemoryRecord | null>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
history方法history(request: MemoryHistoryRequest): Promise<MemoryVersion[]>公开方法;参数与返回类型以签名列为准。
invalidate方法invalidate(scope: MemoryScope, recordId: string, reason: string): Promise<void>公开方法;参数与返回类型以签名列为准。
list方法list(request: MemoryListRequest): Promise<MemoryListResult>公开方法;参数与返回类型以签名列为准。
read方法read(scope: MemoryScope, query: MemoryReadQuery): Promise<MemoryRecord[]>公开方法;参数与返回类型以签名列为准。
search方法search(scope: MemoryScope, query: MemorySearchQuery): Promise<MemorySearchResult[]> | search(request: ManagedMemorySearchRequest): Promise<ManagedMemorySearchResult[]>公开方法;参数与返回类型以签名列为准。
summarize方法summarize(scope: MemoryScope, options?: MemorySummaryOptions): Promise<MemorySummary>公开方法;参数与返回类型以签名列为准。
update方法update(scope: MemoryScope, recordId: string, patch: Partial<MemoryRecord>): Promise<void> | update(request: ManagedMemoryUpdateRequest): Promise<ManagedMemoryWriteResult>公开方法;参数与返回类型以签名列为准。
write方法write(scope: MemoryScope, record: MemoryRecord, policy: MemoryWritePolicy): Promise<MemoryWriteResult>公开方法;参数与返回类型以签名列为准。

memoryProviderProfileSchema

Memory Provider Profile 的运行时 Schema。

  • 种类: 常量
  • 导入: import { memoryProviderProfileSchema } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export declare const memoryProviderProfileSchema: z.ZodObject<{ id: z.ZodString; type: z.ZodEnum<["structured", "vector", "artifact", "hybrid"]>; providerRef: z.ZodString; configSchema: z.ZodOptional<z.ZodType<JsonSchema, z.ZodTypeDef, JsonSchema>>; }, "strip", z.ZodTypeAny, { id: string; type: "artifact" | "structured" | "vector" | "hybrid"; providerRef: string; configSchema?: JsonSchema | undefined; }, { id: string; type: "artifact" | "structured" | "vector" | "hybrid"; providerRef: string; configSchema?: JsonSchema | undefined; }>;

memoryRetrievalPolicySchema

Memory Retrieval Policy 的运行时 Schema。

  • 种类: 常量
  • 导入: import { memoryRetrievalPolicySchema } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export declare const memoryRetrievalPolicySchema: z.ZodObject<{ defaultTopK: z.ZodOptional<z.ZodNumber>; vectorWeight: z.ZodOptional<z.ZodNumber>; textWeight: z.ZodOptional<z.ZodNumber>; requireScope: z.ZodOptional<z.ZodBoolean>; allowedTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["working", "episodic", "semantic", "procedural", "artifact", "governance"]>, "many">>; }, "strip", z.ZodTypeAny, { defaultTopK?: number | undefined; vectorWeight?: number | undefined; textWeight?: number | undefined; requireScope?: boolean | undefined; allowedTypes?: ("working" | "episodic" | "semantic" | "procedural" | "artifact" | "governance")[] | undefined; }, { defaultTopK?: number | undefined; vectorWeight?: number | undefined; textWeight?: number | undefined; requireScope?: boolean | undefined; allowedTypes?: ("working" | "episodic" | "semantic" | "procedural" | "artifact" | "governance")[] | undefined; }>;

memorySpecDefinition

Memory Spec 的运行时校验入口,组合 Parser、Example 与 JSON Schema。

  • 种类: 常量
  • 导入: import { memorySpecDefinition } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export declare const memorySpecDefinition: SpecSchemaDefinition<MemorySpec>;

memorySpecDefinitions

index 模块导出的 Memory Spec Definitions 常量。

  • 种类: 常量
  • 导入: import { memorySpecDefinitions } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export declare const memorySpecDefinitions: readonly [SpecSchemaDefinition<MemorySpec>];

memorySpecExample

Memory Spec 的有效示例值。

  • 种类: 常量
  • 导入: import { memorySpecExample } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export declare const memorySpecExample: MemorySpec;

memorySpecJsonSchema

Memory Spec 的 JSON Schema。

  • 种类: 常量
  • 导入: import { memorySpecJsonSchema } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export declare const memorySpecJsonSchema: JsonSchema;

memorySpecJsonSchemas

index 模块导出的 Memory Spec JSON Schemas 常量。

  • 种类: 常量
  • 导入: import { memorySpecJsonSchemas } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export declare const memorySpecJsonSchemas: Record<string, JsonSchema>;

memorySpecSchema

Memory Spec 的运行时 Schema。

  • 种类: 常量
  • 导入: import { memorySpecSchema } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
// 精确类型由包入口解析;完整编译器展开定义见源码链接。
export declare const memorySpecSchema: (typeof import('@codesoul-co/hypha-memory'))['memorySpecSchema'];

该常量的编译器展开类型已压缩;它的公共名称、顶层类型与源码位置仍保留在本条目中。相关输入/输出字段请使用同模块导出的接口、类型或 Runtime Schema。

memoryTypeSchema

Memory Type 的运行时 Schema。

  • 种类: 常量
  • 导入: import { memoryTypeSchema } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export declare const memoryTypeSchema: z.ZodEnum<["working", "episodic", "semantic", "procedural", "artifact", "governance"]>;

validateMemorySpec

Validate Memory Spec 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { validateMemorySpec } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export declare function validateMemorySpec(input: unknown): MemorySpec;

调用签名

text
validateMemorySpec(input: unknown): MemorySpec

参数

参数类型必需说明
inputunknown必需参数;接受的值由类型列定义。

返回值

  • 类型: MemorySpec
  • 说明: 返回值契约由上述类型定义。

ArtifactMeta

Artifact Meta 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ArtifactMeta } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface ArtifactMeta {
    contentType?: string;
    sizeBytes?: number;
    hash?: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
contentType属性contentType?: string公开属性;类型、只读和可选状态以签名列为准。
hash属性hash?: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
sizeBytes属性sizeBytes?: number公开属性;类型、只读和可选状态以签名列为准。

ArtifactRef

Artifact Ref 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ArtifactRef } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface ArtifactRef {
    id: string;
    path: string;
    meta?: ArtifactMeta;
}

契约成员

成员种类签名说明
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
meta属性meta?: ArtifactMeta公开属性;类型、只读和可选状态以签名列为准。
path属性path: string公开属性;类型、只读和可选状态以签名列为准。

ArtifactStoreProvider

Artifact Store Provider 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ArtifactStoreProvider } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface ArtifactStoreProvider {
    put(path: string, content: Buffer | string, meta?: ArtifactMeta): Promise<ArtifactRef>;
    get(ref: ArtifactRef): Promise<Buffer>;
    delete(ref: ArtifactRef): Promise<void>;
}

契约成员

成员种类签名说明
delete方法delete(ref: ArtifactRef): Promise<void>公开方法;参数与返回类型以签名列为准。
get方法get(ref: ArtifactRef): Promise<Buffer>公开方法;参数与返回类型以签名列为准。
put方法put(path: string, content: Buffer | string, meta?: ArtifactMeta): Promise<ArtifactRef>公开方法;参数与返回类型以签名列为准。

EmbeddingProvider

Embedding Provider 接口,共包含 1 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { EmbeddingProvider } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface EmbeddingProvider {
    embed(input: string[]): Promise<number[][]>;
}

契约成员

成员种类签名说明
embed方法embed(input: string[]): Promise<number[][]>公开方法;参数与返回类型以签名列为准。

MemoryAuditOptions

Memory Audit Options 接口,共包含 2 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryAuditOptions } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemoryAuditOptions {
    since?: string;
    until?: string;
}

契约成员

成员种类签名说明
since属性since?: string公开属性;类型、只读和可选状态以签名列为准。
until属性until?: string公开属性;类型、只读和可选状态以签名列为准。

MemoryAuditReport

Memory Audit Report 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryAuditReport } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemoryAuditReport {
    scope: MemoryScope;
    recordsChecked: number;
    missingProvenance: string[];
}

契约成员

成员种类签名说明
missingProvenance属性missingProvenance: string[]公开属性;类型、只读和可选状态以签名列为准。
recordsChecked属性recordsChecked: number公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: MemoryScope公开属性;类型、只读和可选状态以签名列为准。

MemoryManagerOptions

Memory Manager Options 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryManagerOptions } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemoryManagerOptions {
    trace?: TraceRecorder;
    traceContext?: MemoryTraceContext;
    now?: () => string;
    recovery?: MemoryManagerRecoveryOptions;
}

契约成员

成员种类签名说明
now方法now?(): string公开方法;参数与返回类型以签名列为准。
recovery属性recovery?: MemoryManagerRecoveryOptions公开属性;类型、只读和可选状态以签名列为准。
trace属性trace?: TraceRecorder公开属性;类型、只读和可选状态以签名列为准。
traceContext属性traceContext?: MemoryTraceContext公开属性;类型、只读和可选状态以签名列为准。

MemoryManagerRecoveryOptions

Memory Manager Recovery Options 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryManagerRecoveryOptions } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemoryManagerRecoveryOptions {
    providerId?: string;
    providerRevision?: string;
    specRevision?: string;
    policyRevision?: string;
    onFailure?: (failure: RecoveryFailure) => void | Promise<void>;
}

契约成员

成员种类签名说明
onFailure方法onFailure?(failure: RecoveryFailure): void | Promise<void>公开方法;参数与返回类型以签名列为准。
policyRevision属性policyRevision?: string公开属性;类型、只读和可选状态以签名列为准。
providerId属性providerId?: string公开属性;类型、只读和可选状态以签名列为准。
providerRevision属性providerRevision?: string公开属性;类型、只读和可选状态以签名列为准。
specRevision属性specRevision?: string公开属性;类型、只读和可选状态以签名列为准。

MemoryProvider

Memory Provider 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryProvider } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemoryProvider {
    read(scope: MemoryScope, query: MemoryReadQuery): Promise<MemoryRecord[]>;
    search(scope: MemoryScope, query: MemorySearchQuery): Promise<MemorySearchResult[]>;
    write(scope: MemoryScope, record: MemoryRecord, policy: MemoryWritePolicy): Promise<MemoryWriteResult>;
    update(scope: MemoryScope, recordId: string, patch: Partial<MemoryRecord>): Promise<void>;
    invalidate(scope: MemoryScope, recordId: string, reason: string): Promise<void>;
    summarize(scope: MemoryScope, options?: MemorySummaryOptions): Promise<MemorySummary>;
    audit(scope: MemoryScope, options?: MemoryAuditOptions): Promise<MemoryAuditReport>;
}

契约成员

成员种类签名说明
audit方法audit(scope: MemoryScope, options?: MemoryAuditOptions): Promise<MemoryAuditReport>公开方法;参数与返回类型以签名列为准。
invalidate方法invalidate(scope: MemoryScope, recordId: string, reason: string): Promise<void>公开方法;参数与返回类型以签名列为准。
read方法read(scope: MemoryScope, query: MemoryReadQuery): Promise<MemoryRecord[]>公开方法;参数与返回类型以签名列为准。
search方法search(scope: MemoryScope, query: MemorySearchQuery): Promise<MemorySearchResult[]>公开方法;参数与返回类型以签名列为准。
summarize方法summarize(scope: MemoryScope, options?: MemorySummaryOptions): Promise<MemorySummary>公开方法;参数与返回类型以签名列为准。
update方法update(scope: MemoryScope, recordId: string, patch: Partial<MemoryRecord>): Promise<void>公开方法;参数与返回类型以签名列为准。
write方法write(scope: MemoryScope, record: MemoryRecord, policy: MemoryWritePolicy): Promise<MemoryWriteResult>公开方法;参数与返回类型以签名列为准。

MemoryProviderProfile

Memory Provider Profile 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryProviderProfile } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemoryProviderProfile {
    id: string;
    type: 'structured' | 'vector' | 'artifact' | 'hybrid';
    providerRef: string;
    configSchema?: JsonSchema;
}

契约成员

成员种类签名说明
configSchema属性configSchema?: JsonSchema公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
providerRef属性providerRef: string公开属性;类型、只读和可选状态以签名列为准。
type属性type: "artifact" | "structured" | "vector" | "hybrid"公开属性;类型、只读和可选状态以签名列为准。

MemoryReadQuery

Memory Read Query 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryReadQuery } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemoryReadQuery {
    ids?: string[];
    type?: MemoryType;
    limit?: number;
}

契约成员

成员种类签名说明
ids属性ids?: string[]公开属性;类型、只读和可选状态以签名列为准。
limit属性limit?: number公开属性;类型、只读和可选状态以签名列为准。
type属性type?: MemoryType公开属性;类型、只读和可选状态以签名列为准。

MemoryRecord

Memory Record 接口,共包含 10 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryRecord } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemoryRecord<TValue = unknown> {
    id: string;
    type: MemoryType;
    value: TValue;
    source?: string;
    confidence?: number;
    provenance: Record<string, unknown>;
    visibility?: 'private' | 'workspace' | 'public';
    expiresAt?: string;
    createdAt: string;
    updatedAt?: string;
}

契约成员

成员种类签名说明
confidence属性confidence?: number公开属性;类型、只读和可选状态以签名列为准。
createdAt属性createdAt: string公开属性;类型、只读和可选状态以签名列为准。
expiresAt属性expiresAt?: string公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
provenance属性provenance: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
source属性source?: string公开属性;类型、只读和可选状态以签名列为准。
type属性type: MemoryType公开属性;类型、只读和可选状态以签名列为准。
updatedAt属性updatedAt?: string公开属性;类型、只读和可选状态以签名列为准。
value属性value: TValue公开属性;类型、只读和可选状态以签名列为准。
visibility属性visibility?: "workspace" | "private" | "public"公开属性;类型、只读和可选状态以签名列为准。

MemoryRetrievalPolicy

Memory Retrieval Policy 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryRetrievalPolicy } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemoryRetrievalPolicy {
    defaultTopK?: number;
    vectorWeight?: number;
    textWeight?: number;
    requireScope?: boolean;
    allowedTypes?: MemoryType[];
}

契约成员

成员种类签名说明
allowedTypes属性allowedTypes?: MemoryType[]公开属性;类型、只读和可选状态以签名列为准。
defaultTopK属性defaultTopK?: number公开属性;类型、只读和可选状态以签名列为准。
requireScope属性requireScope?: boolean公开属性;类型、只读和可选状态以签名列为准。
textWeight属性textWeight?: number公开属性;类型、只读和可选状态以签名列为准。
vectorWeight属性vectorWeight?: number公开属性;类型、只读和可选状态以签名列为准。

MemoryScope

Memory Scope 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryScope } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemoryScope {
    workspaceId?: string;
    sessionId?: string;
    runId?: string;
    userId?: string;
}

契约成员

成员种类签名说明
runId属性runId?: string公开属性;类型、只读和可选状态以签名列为准。
sessionId属性sessionId?: string公开属性;类型、只读和可选状态以签名列为准。
userId属性userId?: string公开属性;类型、只读和可选状态以签名列为准。
workspaceId属性workspaceId?: string公开属性;类型、只读和可选状态以签名列为准。

MemorySearchQuery

Memory Search Query 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemorySearchQuery } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemorySearchQuery {
    text?: string;
    vector?: number[];
    type?: MemoryType;
    topK?: number;
}

契约成员

成员种类签名说明
text属性text?: string公开属性;类型、只读和可选状态以签名列为准。
topK属性topK?: number公开属性;类型、只读和可选状态以签名列为准。
type属性type?: MemoryType公开属性;类型、只读和可选状态以签名列为准。
vector属性vector?: number[]公开属性;类型、只读和可选状态以签名列为准。

MemorySearchResult

Memory Search Result 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemorySearchResult } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemorySearchResult {
    record: MemoryRecord;
    score?: number;
    provenance: Record<string, unknown>;
}

契约成员

成员种类签名说明
provenance属性provenance: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
record属性record: MemoryRecord<unknown>公开属性;类型、只读和可选状态以签名列为准。
score属性score?: number公开属性;类型、只读和可选状态以签名列为准。

MemorySpec

Memory Spec 接口,共包含 23 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemorySpec } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemorySpec extends VersionedSpec, SpecMetadata {
    providers: MemoryProviderProfile[];
    memoryTypes: MemoryType[];
    structuredStoreRef?: string;
    vectorIndexRef?: string;
    artifactStoreRef?: string;
    embeddingProviderRef?: string;
    readPolicy?: string;
    writePolicy?: string;
    freshnessPolicy?: string;
    provenancePolicy?: 'required' | 'best_effort';
    retentionPolicy?: string;
    privacyPolicy?: string;
    retrievalStrategy?: string;
    retrievalPolicy?: MemoryRetrievalPolicy;
    writePolicyConfig?: MemoryWritePolicy;
}

契约成员

成员种类签名说明
artifactStoreRef属性artifactStoreRef?: string公开属性;类型、只读和可选状态以签名列为准。
createdAt属性createdAt?: string公开属性;类型、只读和可选状态以签名列为准。
description属性description?: string公开属性;类型、只读和可选状态以签名列为准。
embeddingProviderRef属性embeddingProviderRef?: string公开属性;类型、只读和可选状态以签名列为准。
freshnessPolicy属性freshnessPolicy?: string公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
memoryTypes属性memoryTypes: MemoryType[]公开属性;类型、只读和可选状态以签名列为准。
name属性name?: string公开属性;类型、只读和可选状态以签名列为准。
owner属性owner?: string公开属性;类型、只读和可选状态以签名列为准。
privacyPolicy属性privacyPolicy?: string公开属性;类型、只读和可选状态以签名列为准。
provenancePolicy属性provenancePolicy?: "required" | "best_effort"公开属性;类型、只读和可选状态以签名列为准。
providers属性providers: MemoryProviderProfile[]公开属性;类型、只读和可选状态以签名列为准。
readPolicy属性readPolicy?: string公开属性;类型、只读和可选状态以签名列为准。
retentionPolicy属性retentionPolicy?: string公开属性;类型、只读和可选状态以签名列为准。
retrievalPolicy属性retrievalPolicy?: MemoryRetrievalPolicy公开属性;类型、只读和可选状态以签名列为准。
retrievalStrategy属性retrievalStrategy?: string公开属性;类型、只读和可选状态以签名列为准。
structuredStoreRef属性structuredStoreRef?: string公开属性;类型、只读和可选状态以签名列为准。
tags属性tags?: string[]公开属性;类型、只读和可选状态以签名列为准。
updatedAt属性updatedAt?: string公开属性;类型、只读和可选状态以签名列为准。
vectorIndexRef属性vectorIndexRef?: string公开属性;类型、只读和可选状态以签名列为准。
version属性version: string公开属性;类型、只读和可选状态以签名列为准。
writePolicy属性writePolicy?: string公开属性;类型、只读和可选状态以签名列为准。
writePolicyConfig属性writePolicyConfig?: MemoryWritePolicy公开属性;类型、只读和可选状态以签名列为准。

MemorySummary

Memory Summary 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemorySummary } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemorySummary {
    scope: MemoryScope;
    recordCount: number;
    types: Partial<Record<MemoryType, number>>;
}

契约成员

成员种类签名说明
recordCount属性recordCount: number公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: MemoryScope公开属性;类型、只读和可选状态以签名列为准。
types属性types: Partial<Record<MemoryType, number>>公开属性;类型、只读和可选状态以签名列为准。

MemorySummaryOptions

Memory Summary Options 接口,共包含 2 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemorySummaryOptions } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemorySummaryOptions {
    type?: MemoryType;
    limit?: number;
}

契约成员

成员种类签名说明
limit属性limit?: number公开属性;类型、只读和可选状态以签名列为准。
type属性type?: MemoryType公开属性;类型、只读和可选状态以签名列为准。

MemoryTraceContext

Memory Trace Context 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryTraceContext } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemoryTraceContext {
    runId?: string;
    stepId?: string;
    sessionId?: string;
    userId?: string;
    agentId?: string;
    workspaceId?: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
agentId属性agentId?: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
runId属性runId?: string公开属性;类型、只读和可选状态以签名列为准。
sessionId属性sessionId?: string公开属性;类型、只读和可选状态以签名列为准。
stepId属性stepId?: string公开属性;类型、只读和可选状态以签名列为准。
userId属性userId?: string公开属性;类型、只读和可选状态以签名列为准。
workspaceId属性workspaceId?: string公开属性;类型、只读和可选状态以签名列为准。

MemoryWritePolicy

Memory Write Policy 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryWritePolicy } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemoryWritePolicy {
    allowLongTerm?: boolean;
    requireProvenance?: boolean;
    decision?: PolicyDecision;
    idempotencyKey?: string;
}

契约成员

成员种类签名说明
allowLongTerm属性allowLongTerm?: boolean公开属性;类型、只读和可选状态以签名列为准。
decision属性decision?: PolicyDecision公开属性;类型、只读和可选状态以签名列为准。
idempotencyKey属性idempotencyKey?: string公开属性;类型、只读和可选状态以签名列为准。
requireProvenance属性requireProvenance?: boolean公开属性;类型、只读和可选状态以签名列为准。

MemoryWriteResult

Memory Write Result 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryWriteResult } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface MemoryWriteResult {
    recordId: string;
    vectorIndexed?: boolean;
    artifactRef?: ArtifactRef;
}

契约成员

成员种类签名说明
artifactRef属性artifactRef?: ArtifactRef公开属性;类型、只读和可选状态以签名列为准。
recordId属性recordId: string公开属性;类型、只读和可选状态以签名列为准。
vectorIndexed属性vectorIndexed?: boolean公开属性;类型、只读和可选状态以签名列为准。

StructuredQuery

Structured Query 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { StructuredQuery } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface StructuredQuery {
    where?: Record<string, unknown>;
    limit?: number;
    orderBy?: string;
}

契约成员

成员种类签名说明
limit属性limit?: number公开属性;类型、只读和可选状态以签名列为准。
orderBy属性orderBy?: string公开属性;类型、只读和可选状态以签名列为准。
where属性where?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。

StructuredStoreProvider

Structured Store Provider 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { StructuredStoreProvider } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface StructuredStoreProvider {
    get<T>(table: string, id: string): Promise<T | null>;
    insert<T extends {
        id: string;
    }>(table: string, record: T): Promise<void>;
    update<T>(table: string, id: string, patch: Partial<T>): Promise<void>;
    compareAndSet?<T>(table: string, id: string, expected: Partial<T>, patch: Partial<T>): Promise<boolean>;
    delete(table: string, id: string): Promise<void>;
    query<T>(table: string, query: StructuredQuery): Promise<T[]>;
    transaction<T>(fn: (tx: StructuredStoreProvider) => Promise<T>): Promise<T>;
}

契约成员

成员种类签名说明
compareAndSet方法compareAndSet?<T>(table: string, id: string, expected: Partial<T>, patch: Partial<T>): Promise<boolean>公开方法;参数与返回类型以签名列为准。
delete方法delete(table: string, id: string): Promise<void>公开方法;参数与返回类型以签名列为准。
get方法get<T>(table: string, id: string): Promise<T | null>公开方法;参数与返回类型以签名列为准。
insert方法insert<T extends { id: string; }>(table: string, record: T): Promise<void>公开方法;参数与返回类型以签名列为准。
query方法query<T>(table: string, query: StructuredQuery): Promise<T[]>公开方法;参数与返回类型以签名列为准。
transaction方法transaction<T>(fn: (tx: StructuredStoreProvider) => Promise<T>): Promise<T>公开方法;参数与返回类型以签名列为准。
update方法update<T>(table: string, id: string, patch: Partial<T>): Promise<void>公开方法;参数与返回类型以签名列为准。

VectorIndexProvider

Vector Index Provider 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { VectorIndexProvider } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface VectorIndexProvider {
    upsert(records: VectorRecord[]): Promise<void>;
    search(query: VectorQuery): Promise<VectorSearchResult[]>;
    delete(ids: string[]): Promise<void>;
}

契约成员

成员种类签名说明
delete方法delete(ids: string[]): Promise<void>公开方法;参数与返回类型以签名列为准。
search方法search(query: VectorQuery): Promise<VectorSearchResult[]>公开方法;参数与返回类型以签名列为准。
upsert方法upsert(records: VectorRecord[]): Promise<void>公开方法;参数与返回类型以签名列为准。

VectorQuery

Vector Query 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { VectorQuery } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface VectorQuery {
    vector: number[];
    topK: number;
    filter?: Record<string, unknown>;
}

契约成员

成员种类签名说明
filter属性filter?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
topK属性topK: number公开属性;类型、只读和可选状态以签名列为准。
vector属性vector: number[]公开属性;类型、只读和可选状态以签名列为准。

VectorRecord

Vector Record 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { VectorRecord } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface VectorRecord {
    id: string;
    vector: number[];
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
vector属性vector: number[]公开属性;类型、只读和可选状态以签名列为准。

VectorSearchResult

Vector Search Result 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { VectorSearchResult } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export interface VectorSearchResult {
    id: string;
    score: number;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
score属性score: number公开属性;类型、只读和可选状态以签名列为准。

MemoryType

Memory Type 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { MemoryType } from '@codesoul-co/hypha-memory';
  • 源码模块: index

声明

text
export type MemoryType = 'working' | 'episodic' | 'semantic' | 'procedural' | 'artifact' | 'governance';