Skip to content

@codesoul-co/hypha-memory / hindsight-local-client

模块用法

用于把外部或本地 Provider 绑定到 Hypha Port。Hindsight local client 模块公开 1 类、2 常量、2 函数、1 接口。

从包入口导入

ts
import {
  HindsightLocalMemoryBankClient,
  HINDSIGHT_LOCAL_PROTOCOL,
  HINDSIGHT_LOCAL_VERSION,
  bankIdForScope,
  documentIdForOperation,
} from '@codesoul-co/hypha-memory';

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

使用要点

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

公共导出

Symbol种类签名说明
HindsightLocalMemoryBankClientnew HindsightLocalMemoryBankClient(options: HindsightLocalMemoryBankClientOptions): HindsightLocalMemoryBankClientNative adapter for Hindsight Self-hosted HTTP API 0.8.
HINDSIGHT_LOCAL_PROTOCOL常量const HINDSIGHT_LOCAL_PROTOCOL: "hindsight.http.v0.8"hindsight-local-client 模块导出的 HINDSIGHT LOCAL PROTOCOL 常量。
HINDSIGHT_LOCAL_VERSION常量const HINDSIGHT_LOCAL_VERSION: "0.8.5"hindsight-local-client 模块导出的 HINDSIGHT LOCAL VERSION 常量。
bankIdForScope函数bankIdForScope(scope: ManagedMemoryScope): stringBank ID For Scope 函数,提供 1 个公开调用签名;参数与返回类型见下表。
documentIdForOperation函数documentIdForOperation(operationId: string): stringDocument ID For Operation 函数,提供 1 个公开调用签名;参数与返回类型见下表。
HindsightLocalMemoryBankClientOptions接口interface HindsightLocalMemoryBankClientOptionsHindsight Local Memory Bank Client Options 接口,共包含 12 个公开字段或方法。

HindsightLocalMemoryBankClient

Native adapter for Hindsight Self-hosted HTTP API 0.8.

  • 种类: 类
  • 导入: import { HindsightLocalMemoryBankClient } from '@codesoul-co/hypha-memory';
  • 源码模块: hindsight-local-client

声明

text
export declare class HindsightLocalMemoryBankClient implements ExternalMemoryClient {
    readonly protocol: "hindsight.http.v0.8";
    constructor(options: HindsightLocalMemoryBankClientOptions);
    capabilities(signal?: AbortSignal): Promise<Partial<MemoryManagementCapabilities>>;
    add(request: MemoryAddRequest, signal?: AbortSignal): Promise<ManagedMemoryWriteResult>;
    reconcileOperation(operationId: string, signal?: AbortSignal): Promise<ManagedMemoryWriteResult | null>;
    search(request: ManagedMemorySearchRequest, signal?: AbortSignal): Promise<ManagedMemorySearchResult[]>;
    get(request: MemoryGetRequest, signal?: AbortSignal): Promise<ManagedMemoryRecord | null>;
    list(request: MemoryListRequest, signal?: AbortSignal): Promise<MemoryListResult>;
    update(request: ManagedMemoryUpdateRequest, signal?: AbortSignal): Promise<ManagedMemoryWriteResult>;
    delete(request: ManagedMemoryDeleteRequest, signal?: AbortSignal): Promise<ManagedMemoryDeleteResult>;
    history(request: MemoryHistoryRequest, signal?: AbortSignal): Promise<MemoryVersion[]>;
    health(signal?: AbortSignal): Promise<ProviderHealth>;
    close(): Promise<void>;
}

公开成员

成员种类签名说明
add方法add(request: MemoryAddRequest, signal?: AbortSignal): Promise<ManagedMemoryWriteResult>公开方法;参数与返回类型以签名列为准。
capabilities方法capabilities(signal?: AbortSignal): Promise<Partial<MemoryManagementCapabilities>>公开方法;参数与返回类型以签名列为准。
close方法close(): Promise<void>公开方法;参数与返回类型以签名列为准。
constructor构造函数(options: HindsightLocalMemoryBankClientOptions): HindsightLocalMemoryBankClient创建该类的实例。
delete方法delete(request: ManagedMemoryDeleteRequest, signal?: AbortSignal): Promise<ManagedMemoryDeleteResult>公开方法;参数与返回类型以签名列为准。
get方法get(request: MemoryGetRequest, signal?: AbortSignal): Promise<ManagedMemoryRecord | null>公开方法;参数与返回类型以签名列为准。
health方法health(signal?: AbortSignal): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
history方法history(request: MemoryHistoryRequest, signal?: AbortSignal): Promise<MemoryVersion[]>公开方法;参数与返回类型以签名列为准。
list方法list(request: MemoryListRequest, signal?: AbortSignal): Promise<MemoryListResult>公开方法;参数与返回类型以签名列为准。
protocol属性readonly protocol: "hindsight.http.v0.8"公开属性;类型、只读和可选状态以签名列为准。
reconcileOperation方法reconcileOperation(operationId: string, signal?: AbortSignal): Promise<ManagedMemoryWriteResult | null>公开方法;参数与返回类型以签名列为准。
search方法search(request: ManagedMemorySearchRequest, signal?: AbortSignal): Promise<ManagedMemorySearchResult[]>公开方法;参数与返回类型以签名列为准。
update方法update(request: ManagedMemoryUpdateRequest, signal?: AbortSignal): Promise<ManagedMemoryWriteResult>公开方法;参数与返回类型以签名列为准。

HINDSIGHT_LOCAL_PROTOCOL

hindsight-local-client 模块导出的 HINDSIGHT LOCAL PROTOCOL 常量。

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

声明

text
export declare const HINDSIGHT_LOCAL_PROTOCOL: "hindsight.http.v0.8";

HINDSIGHT_LOCAL_VERSION

hindsight-local-client 模块导出的 HINDSIGHT LOCAL VERSION 常量。

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

声明

text
export declare const HINDSIGHT_LOCAL_VERSION: "0.8.5";

bankIdForScope

Bank ID For Scope 函数,提供 1 个公开调用签名;参数与返回类型见下表。

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

声明

text
export declare function bankIdForScope(scope: ManagedMemoryScope): string;

调用签名

text
bankIdForScope(scope: ManagedMemoryScope): string

参数

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

返回值

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

documentIdForOperation

Document ID For Operation 函数,提供 1 个公开调用签名;参数与返回类型见下表。

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

声明

text
export declare function documentIdForOperation(operationId: string): string;

调用签名

text
documentIdForOperation(operationId: string): string

参数

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

返回值

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

HindsightLocalMemoryBankClientOptions

Hindsight Local Memory Bank Client Options 接口,共包含 12 个公开字段或方法。

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

声明

text
export interface HindsightLocalMemoryBankClientOptions {
    baseUrl: string;
    bearerToken?: string;
    fetch?: Mem0HttpFetch;
    providerId?: string;
    mappingStore?: ExternalMemoryMappingStore;
    mappingProfile?: ExternalMemoryMappingRuntimeProfile;
    operationStore?: ExternalProviderOperationStore;
    operationProfile?: ExternalMemoryMappingRuntimeProfile;
    profileRef?: MemoryContractSpecRef;
    operationDeadlineMs?: number;
    now?: () => Date;
    expectedApiVersion?: string;
}

契约成员

成员种类签名说明
baseUrl属性baseUrl: string公开属性;类型、只读和可选状态以签名列为准。
bearerToken属性bearerToken?: string公开属性;类型、只读和可选状态以签名列为准。
expectedApiVersion属性expectedApiVersion?: string公开属性;类型、只读和可选状态以签名列为准。
fetch方法fetch?(url: string, init?: { method?: string; headers?: Record<string, string>; body?: string; signal?: AbortSignal; }): Promise<import("/Users/erwin/Downloads/codespace/Hypha/packages/memory/dist/mem0-rest-client").Mem0HttpResponse>公开方法;参数与返回类型以签名列为准。
mappingProfile属性mappingProfile?: ExternalMemoryMappingRuntimeProfile公开属性;类型、只读和可选状态以签名列为准。
mappingStore属性mappingStore?: ExternalMemoryMappingStore公开属性;类型、只读和可选状态以签名列为准。
now方法now?(): Date公开方法;参数与返回类型以签名列为准。
operationDeadlineMs属性operationDeadlineMs?: number公开属性;类型、只读和可选状态以签名列为准。
operationProfile属性operationProfile?: ExternalMemoryMappingRuntimeProfile公开属性;类型、只读和可选状态以签名列为准。
operationStore属性operationStore?: ExternalProviderOperationStore公开属性;类型、只读和可选状态以签名列为准。
profileRef属性profileRef?: MemoryContractSpecRef公开属性;类型、只读和可选状态以签名列为准。
providerId属性providerId?: string公开属性;类型、只读和可选状态以签名列为准。