Skip to content

@codesoul-co/hypha-memory / index-outbox

模块用法

用于使用该功能边界的公共契约与操作。Index outbox 模块公开 3 类、8 接口。

从包入口导入

ts
import {
  IndexOutboxWorker,
  InMemoryLocalVectorStoreAdapter,
  LegacyVectorIndexStoreAdapter,
} from '@codesoul-co/hypha-memory';

import type {
  IndexOutboxWorkerEvent,
  IndexOutboxWorkerOptions,
  IndexOutboxWorkerRunResult,
  ManagedVectorPoint,
  ManagedVectorSearchRequest,
  ManagedVectorSearchResult,
  ManagedVectorStoreAdapter,
  ManagedVectorWriteOptions,
} from '@codesoul-co/hypha-memory';

使用要点

  • 8 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 3 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。

公共导出

Symbol种类签名说明
IndexOutboxWorkernew IndexOutboxWorker(options: IndexOutboxWorkerOptions): IndexOutboxWorkerIndex Outbox Worker 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。
InMemoryLocalVectorStoreAdapternew InMemoryLocalVectorStoreAdapter(id?: string): InMemoryLocalVectorStoreAdapterIn Memory Local Vector Store Adapter 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。
LegacyVectorIndexStoreAdapternew LegacyVectorIndexStoreAdapter(id: string, provider: VectorIndexProvider): LegacyVectorIndexStoreAdapterLegacy Vector Index Store Adapter 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。
IndexOutboxWorkerEvent接口interface IndexOutboxWorkerEventIndex Outbox Worker Event 接口,共包含 7 个公开字段或方法。
IndexOutboxWorkerOptions接口interface IndexOutboxWorkerOptionsIndex Outbox Worker Options 接口,共包含 14 个公开字段或方法。
IndexOutboxWorkerRunResult接口interface IndexOutboxWorkerRunResultIndex Outbox Worker Run Result 接口,共包含 4 个公开字段或方法。
ManagedVectorPoint接口interface ManagedVectorPointManaged Vector Point 接口,共包含 3 个公开字段或方法。
ManagedVectorSearchRequest接口interface ManagedVectorSearchRequestManaged Vector Search Request 接口,共包含 4 个公开字段或方法。
ManagedVectorSearchResult接口interface ManagedVectorSearchResultManaged Vector Search Result 接口,共包含 3 个公开字段或方法。
ManagedVectorStoreAdapter接口interface ManagedVectorStoreAdapterManaged Vector Store Adapter 接口,共包含 5 个公开字段或方法。
ManagedVectorWriteOptions接口interface ManagedVectorWriteOptionsManaged Vector Write Options 接口,共包含 2 个公开字段或方法。

IndexOutboxWorker

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

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

声明

text
export declare class IndexOutboxWorker {
    constructor(options: IndexOutboxWorkerOptions);
    runOnce(): Promise<IndexOutboxWorkerRunResult>;
    start(): void;
    stop(): void;
    drain(): Promise<void>;
    stopAndDrain(): Promise<void>;
}

公开成员

成员种类签名说明
constructor构造函数(options: IndexOutboxWorkerOptions): IndexOutboxWorker创建该类的实例。
drain方法drain(): Promise<void>公开方法;参数与返回类型以签名列为准。
runOnce方法runOnce(): Promise<IndexOutboxWorkerRunResult>公开方法;参数与返回类型以签名列为准。
start方法start(): void公开方法;参数与返回类型以签名列为准。
stop方法stop(): void公开方法;参数与返回类型以签名列为准。
stopAndDrain方法stopAndDrain(): Promise<void>公开方法;参数与返回类型以签名列为准。

InMemoryLocalVectorStoreAdapter

In Memory Local Vector Store Adapter 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。

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

声明

text
export declare class InMemoryLocalVectorStoreAdapter implements ManagedVectorStoreAdapter {
    readonly id: string;
    constructor(id?: string);
    upsert(points: ManagedVectorPoint[], options?: ManagedVectorWriteOptions): Promise<void>;
    delete(ids: string[], options?: ManagedVectorWriteOptions): Promise<void>;
    search(request: ManagedVectorSearchRequest): Promise<ManagedVectorSearchResult[]>;
    health(): Promise<ProviderHealth>;
}

公开成员

成员种类签名说明
constructor构造函数(id?: string): InMemoryLocalVectorStoreAdapter创建该类的实例。
delete方法delete(ids: string[], options?: ManagedVectorWriteOptions): Promise<void>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
id属性readonly id: string公开属性;类型、只读和可选状态以签名列为准。
search方法search(request: ManagedVectorSearchRequest): Promise<ManagedVectorSearchResult[]>公开方法;参数与返回类型以签名列为准。
upsert方法upsert(points: ManagedVectorPoint[], options?: ManagedVectorWriteOptions): Promise<void>公开方法;参数与返回类型以签名列为准。

LegacyVectorIndexStoreAdapter

Legacy Vector Index Store Adapter 类,共公开 6 个构造函数或成员;精确签名见本条目的声明与成员表。

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

声明

text
export declare class LegacyVectorIndexStoreAdapter implements ManagedVectorStoreAdapter {
    readonly id: string;
    constructor(id: string, provider: VectorIndexProvider);
    upsert(points: ManagedVectorPoint[], options?: ManagedVectorWriteOptions): Promise<void>;
    delete(ids: string[], options?: ManagedVectorWriteOptions): Promise<void>;
    search(request: ManagedVectorSearchRequest): Promise<ManagedVectorSearchResult[]>;
    health(): Promise<ProviderHealth>;
}

公开成员

成员种类签名说明
constructor构造函数(id: string, provider: VectorIndexProvider): LegacyVectorIndexStoreAdapter创建该类的实例。
delete方法delete(ids: string[], options?: ManagedVectorWriteOptions): Promise<void>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
id属性readonly id: string公开属性;类型、只读和可选状态以签名列为准。
search方法search(request: ManagedVectorSearchRequest): Promise<ManagedVectorSearchResult[]>公开方法;参数与返回类型以签名列为准。
upsert方法upsert(points: ManagedVectorPoint[], options?: ManagedVectorWriteOptions): Promise<void>公开方法;参数与返回类型以签名列为准。

IndexOutboxWorkerEvent

Index Outbox Worker Event 接口,共包含 7 个公开字段或方法。

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

声明

text
export interface IndexOutboxWorkerEvent {
    type: 'memory.index.started' | 'memory.index.completed' | 'memory.index.partial' | 'memory.index.failed';
    operationId: string;
    outboxId: string;
    memoryId: string;
    memoryVersionId: string;
    scopeHash: string;
    error?: NormalizedMemoryError;
}

契约成员

成员种类签名说明
error属性error?: NormalizedMemoryError公开属性;类型、只读和可选状态以签名列为准。
memoryId属性memoryId: string公开属性;类型、只读和可选状态以签名列为准。
memoryVersionId属性memoryVersionId: string公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId: string公开属性;类型、只读和可选状态以签名列为准。
outboxId属性outboxId: string公开属性;类型、只读和可选状态以签名列为准。
scopeHash属性scopeHash: string公开属性;类型、只读和可选状态以签名列为准。
type属性type: "memory.index.started" | "memory.index.completed" | "memory.index.partial" | "memory.index.failed"公开属性;类型、只读和可选状态以签名列为准。

IndexOutboxWorkerOptions

Index Outbox Worker Options 接口,共包含 14 个公开字段或方法。

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

声明

text
export interface IndexOutboxWorkerOptions {
    ownerId: string;
    outboxStore: MemoryIndexOutboxStore;
    recordStore: ManagedMemoryRecordStore;
    embeddingProvider: EmbeddingProvider;
    vectorStores: ManagedVectorStoreAdapter[];
    batchSize?: number;
    leaseMs?: number;
    renewalMs?: number;
    maxAttempts?: number;
    retryDelayMs?: number;
    pollIntervalMs?: number;
    now?: () => Date;
    onEvent?: (event: IndexOutboxWorkerEvent) => void | Promise<void>;
    onError?: (error: NormalizedMemoryError) => void | Promise<void>;
}

契约成员

成员种类签名说明
batchSize属性batchSize?: number公开属性;类型、只读和可选状态以签名列为准。
embeddingProvider属性embeddingProvider: EmbeddingProvider公开属性;类型、只读和可选状态以签名列为准。
leaseMs属性leaseMs?: number公开属性;类型、只读和可选状态以签名列为准。
maxAttempts属性maxAttempts?: number公开属性;类型、只读和可选状态以签名列为准。
now方法now?(): Date公开方法;参数与返回类型以签名列为准。
onError方法onError?(error: NormalizedMemoryError): void | Promise<void>公开方法;参数与返回类型以签名列为准。
onEvent方法onEvent?(event: IndexOutboxWorkerEvent): void | Promise<void>公开方法;参数与返回类型以签名列为准。
outboxStore属性outboxStore: MemoryIndexOutboxStore公开属性;类型、只读和可选状态以签名列为准。
ownerId属性ownerId: string公开属性;类型、只读和可选状态以签名列为准。
pollIntervalMs属性pollIntervalMs?: number公开属性;类型、只读和可选状态以签名列为准。
recordStore属性recordStore: ManagedMemoryRecordStore公开属性;类型、只读和可选状态以签名列为准。
renewalMs属性renewalMs?: number公开属性;类型、只读和可选状态以签名列为准。
retryDelayMs属性retryDelayMs?: number公开属性;类型、只读和可选状态以签名列为准。
vectorStores属性vectorStores: ManagedVectorStoreAdapter[]公开属性;类型、只读和可选状态以签名列为准。

IndexOutboxWorkerRunResult

Index Outbox Worker Run Result 接口,共包含 4 个公开字段或方法。

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

声明

text
export interface IndexOutboxWorkerRunResult {
    leased: number;
    completed: number;
    failed: number;
    deadLettered: number;
}

契约成员

成员种类签名说明
completed属性completed: number公开属性;类型、只读和可选状态以签名列为准。
deadLettered属性deadLettered: number公开属性;类型、只读和可选状态以签名列为准。
failed属性failed: number公开属性;类型、只读和可选状态以签名列为准。
leased属性leased: number公开属性;类型、只读和可选状态以签名列为准。

ManagedVectorPoint

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

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

声明

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

契约成员

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

ManagedVectorSearchRequest

Managed Vector Search Request 接口,共包含 4 个公开字段或方法。

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

声明

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

契约成员

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

ManagedVectorSearchResult

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

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

声明

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

契约成员

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

ManagedVectorStoreAdapter

Managed Vector Store Adapter 接口,共包含 5 个公开字段或方法。

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

声明

text
export interface ManagedVectorStoreAdapter {
    readonly id: string;
    upsert(points: ManagedVectorPoint[], options?: ManagedVectorWriteOptions): Promise<void>;
    delete(ids: string[], options?: ManagedVectorWriteOptions): Promise<void>;
    search(request: ManagedVectorSearchRequest): Promise<ManagedVectorSearchResult[]>;
    health(): Promise<ProviderHealth>;
}

契约成员

成员种类签名说明
delete方法delete(ids: string[], options?: ManagedVectorWriteOptions): Promise<void>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
id属性readonly id: string公开属性;类型、只读和可选状态以签名列为准。
search方法search(request: ManagedVectorSearchRequest): Promise<ManagedVectorSearchResult[]>公开方法;参数与返回类型以签名列为准。
upsert方法upsert(points: ManagedVectorPoint[], options?: ManagedVectorWriteOptions): Promise<void>公开方法;参数与返回类型以签名列为准。

ManagedVectorWriteOptions

Managed Vector Write Options 接口,共包含 2 个公开字段或方法。

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

声明

text
export interface ManagedVectorWriteOptions {
    fencingToken?: number;
    memoryRevision?: number;
}

契约成员

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