Skip to content

@codesoul-co/hypha-memory / lifecycle-contracts

模块用法

用于声明并运行时校验契约。Lifecycle contracts 模块公开 20 接口、2 类型。

从包入口导入

ts
import type {
  EpisodicRecordInput,
  ExtractedMemoryCandidate,
  ExtractedMemoryEvidence,
  MemoryExtractionBatch,
  MemoryExtractionCursor,
  MemoryExtractionJob,
  MemoryExtractionProfileSpec,
  MemoryExtractionRequest,
} from '@codesoul-co/hypha-memory';

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

使用要点

  • 22 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。

公共导出

Symbol种类签名说明
EpisodicRecordInput接口interface EpisodicRecordInputEpisodic Record Input 接口,共包含 14 个公开字段或方法。
ExtractedMemoryCandidate接口interface ExtractedMemoryCandidateExtracted Memory Candidate 接口,共包含 20 个公开字段或方法。
ExtractedMemoryEvidence接口interface ExtractedMemoryEvidenceExtracted Memory Evidence 接口,共包含 4 个公开字段或方法。
MemoryExtractionBatch接口interface MemoryExtractionBatchMemory Extraction Batch 接口,共包含 9 个公开字段或方法。
MemoryExtractionCursor接口interface MemoryExtractionCursorMemory Extraction Cursor 接口,共包含 6 个公开字段或方法。
MemoryExtractionJob接口interface MemoryExtractionJobMemory Extraction Job 接口,共包含 16 个公开字段或方法。
MemoryExtractionProfileSpec接口interface MemoryExtractionProfileSpecMemory Extraction Profile Spec 接口,共包含 14 个公开字段或方法。
MemoryExtractionRequest接口interface MemoryExtractionRequestMemory Extraction Request 接口,共包含 9 个公开字段或方法。
MemoryExtractionSourceAdapter接口interface MemoryExtractionSourceAdapterMemory Extraction Source Adapter 接口,共包含 4 个公开字段或方法。
MemoryExtractionSourceBatch接口interface MemoryExtractionSourceBatchMemory Extraction Source Batch 接口,共包含 3 个公开字段或方法。
MemoryExtractionSourceRef接口interface MemoryExtractionSourceRefMemory Extraction Source Ref 接口,共包含 15 个公开字段或方法。
MemoryExtractionStageSpec接口interface MemoryExtractionStageSpecMemory Extraction Stage Spec 接口,共包含 6 个公开字段或方法。
MemoryExtractor接口interface MemoryExtractorMemory Extractor 接口,共包含 3 个公开字段或方法。
MemoryMaintenanceApplyRequest接口interface MemoryMaintenanceApplyRequestMemory Maintenance Apply Request 接口,共包含 3 个公开字段或方法。
MemoryMaintenanceDecision接口interface MemoryMaintenanceDecisionMemory Maintenance Decision 接口,共包含 18 个公开字段或方法。
MemoryMaintenancePlanner接口interface MemoryMaintenancePlannerMemory Maintenance Planner 接口,共包含 3 个公开字段或方法。
MemoryMaintenancePlanRequest接口interface MemoryMaintenancePlanRequestMemory Maintenance Plan Request 接口,共包含 5 个公开字段或方法。
MemoryMaintenancePolicySpec接口interface MemoryMaintenancePolicySpecMemory Maintenance Policy Spec 接口,共包含 8 个公开字段或方法。
NormalizedExtractionInput接口interface NormalizedExtractionInputNormalized Extraction Input 接口,共包含 3 个公开字段或方法。
TruthAssertion接口interface TruthAssertionTruth Assertion 接口,共包含 11 个公开字段或方法。
MemoryExtractionSourceType类型type MemoryExtractionSourceType = 'conversation' | 'truth' | 'episodic_record' | 'runtime_event' | 'tool_observation' | 'artifact' | 'structured_record' | 'custom'Memory Extraction Source Type 公共类型别名;完整类型表达式见声明。
MemoryMaintenanceAction类型type MemoryMaintenanceAction = 'create' | 'noop' | 'reuse' | 'update' | 'merge' | 'supersede' | 'invalidate' | 'reject' | 'require_review'Memory Maintenance Action 公共类型别名;完整类型表达式见声明。

EpisodicRecordInput

Episodic Record Input 接口,共包含 14 个公开字段或方法。

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

声明

text
export interface EpisodicRecordInput {
    episodeId: string;
    title?: string;
    startAt: string;
    endAt?: string;
    actors?: string[];
    goal?: string;
    actions?: string[];
    observations?: string[];
    outcome?: unknown;
    success?: boolean;
    failureCode?: string;
    causalEventIds?: string[];
    artifactRefs?: string[];
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
actions属性actions?: string[]公开属性;类型、只读和可选状态以签名列为准。
actors属性actors?: string[]公开属性;类型、只读和可选状态以签名列为准。
artifactRefs属性artifactRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
causalEventIds属性causalEventIds?: string[]公开属性;类型、只读和可选状态以签名列为准。
endAt属性endAt?: string公开属性;类型、只读和可选状态以签名列为准。
episodeId属性episodeId: string公开属性;类型、只读和可选状态以签名列为准。
failureCode属性failureCode?: string公开属性;类型、只读和可选状态以签名列为准。
goal属性goal?: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
observations属性observations?: string[]公开属性;类型、只读和可选状态以签名列为准。
outcome属性outcome?: unknown公开属性;类型、只读和可选状态以签名列为准。
startAt属性startAt: string公开属性;类型、只读和可选状态以签名列为准。
success属性success?: boolean公开属性;类型、只读和可选状态以签名列为准。
title属性title?: string公开属性;类型、只读和可选状态以签名列为准。

ExtractedMemoryCandidate

Extracted Memory Candidate 接口,共包含 20 个公开字段或方法。

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

声明

text
export interface ExtractedMemoryCandidate {
    candidateId: string;
    type: ManagedMemoryType;
    content: unknown;
    canonicalText: string;
    summary?: string;
    confidence: number;
    importance?: number;
    canonicalKey?: string;
    subject?: string;
    predicate?: string;
    object?: unknown;
    temporal?: {
        observedAt?: string;
        validFrom?: string;
        validTo?: string;
        temporalConfidence?: number;
    };
    entities?: MemoryEntityRef[];
    relations?: MemoryRelation[];
    sensitive?: boolean;
    authority?: MemoryExtractionSourceRef['authority'];
    evidence: ExtractedMemoryEvidence[];
    extractionRationale?: string;
    extractionProfileRevision: string;
    sourceHash: string;
}

契约成员

成员种类签名说明
authority属性authority?: "verified" | "unverified" | "user_asserted" | "system_observed" | "authoritative"公开属性;类型、只读和可选状态以签名列为准。
candidateId属性candidateId: string公开属性;类型、只读和可选状态以签名列为准。
canonicalKey属性canonicalKey?: string公开属性;类型、只读和可选状态以签名列为准。
canonicalText属性canonicalText: string公开属性;类型、只读和可选状态以签名列为准。
confidence属性confidence: number公开属性;类型、只读和可选状态以签名列为准。
content属性content: unknown公开属性;类型、只读和可选状态以签名列为准。
entities属性entities?: MemoryEntityRef[]公开属性;类型、只读和可选状态以签名列为准。
evidence属性evidence: ExtractedMemoryEvidence[]公开属性;类型、只读和可选状态以签名列为准。
extractionProfileRevision属性extractionProfileRevision: string公开属性;类型、只读和可选状态以签名列为准。
extractionRationale属性extractionRationale?: string公开属性;类型、只读和可选状态以签名列为准。
importance属性importance?: number公开属性;类型、只读和可选状态以签名列为准。
object属性object?: unknown公开属性;类型、只读和可选状态以签名列为准。
predicate属性predicate?: string公开属性;类型、只读和可选状态以签名列为准。
relations属性relations?: MemoryRelation[]公开属性;类型、只读和可选状态以签名列为准。
sensitive属性sensitive?: boolean公开属性;类型、只读和可选状态以签名列为准。
sourceHash属性sourceHash: string公开属性;类型、只读和可选状态以签名列为准。
subject属性subject?: string公开属性;类型、只读和可选状态以签名列为准。
summary属性summary?: string公开属性;类型、只读和可选状态以签名列为准。
temporal属性temporal?: { observedAt?: string; validFrom?: string; validTo?: string; temporalConfidence?: number; }公开属性;类型、只读和可选状态以签名列为准。
type属性type: ManagedMemoryType公开属性;类型、只读和可选状态以签名列为准。

ExtractedMemoryEvidence

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

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

声明

text
export interface ExtractedMemoryEvidence {
    sourceRef: MemoryExtractionSourceRef;
    sourceSpan?: {
        messageId?: string;
        eventId?: string;
        artifactRef?: string;
        start?: number;
        end?: number;
        quoteHash?: string;
    };
    supportType: 'direct' | 'derived' | 'contradicting';
    confidence?: number;
}

契约成员

成员种类签名说明
confidence属性confidence?: number公开属性;类型、只读和可选状态以签名列为准。
sourceRef属性sourceRef: MemoryExtractionSourceRef公开属性;类型、只读和可选状态以签名列为准。
sourceSpan属性sourceSpan?: { messageId?: string; eventId?: string; artifactRef?: string; start?: number; end?: number; quoteHash?: string; }公开属性;类型、只读和可选状态以签名列为准。
supportType属性supportType: "derived" | "direct" | "contradicting"公开属性;类型、只读和可选状态以签名列为准。

MemoryExtractionBatch

Memory Extraction Batch 接口,共包含 9 个公开字段或方法。

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

声明

text
export interface MemoryExtractionBatch {
    id: string;
    jobId: string;
    sourceRefs: MemoryExtractionSourceRef[];
    candidates: ExtractedMemoryCandidate[];
    rejectedCandidates: MemoryRejectedItem[];
    sourceHash: string;
    extractorVersion: string;
    modelObservationRef?: string;
    createdAt: string;
}

契约成员

成员种类签名说明
candidates属性candidates: ExtractedMemoryCandidate[]公开属性;类型、只读和可选状态以签名列为准。
createdAt属性createdAt: string公开属性;类型、只读和可选状态以签名列为准。
extractorVersion属性extractorVersion: string公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
jobId属性jobId: string公开属性;类型、只读和可选状态以签名列为准。
modelObservationRef属性modelObservationRef?: string公开属性;类型、只读和可选状态以签名列为准。
rejectedCandidates属性rejectedCandidates: MemoryRejectedItem[]公开属性;类型、只读和可选状态以签名列为准。
sourceHash属性sourceHash: string公开属性;类型、只读和可选状态以签名列为准。
sourceRefs属性sourceRefs: MemoryExtractionSourceRef[]公开属性;类型、只读和可选状态以签名列为准。

MemoryExtractionCursor

Memory Extraction Cursor 接口,共包含 6 个公开字段或方法。

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

声明

text
export interface MemoryExtractionCursor {
    sourceType: MemoryExtractionSourceType;
    sourceId: string;
    sequence?: number;
    timestamp?: string;
    sourceHash?: string;
    opaqueCursor?: string;
}

契约成员

成员种类签名说明
opaqueCursor属性opaqueCursor?: string公开属性;类型、只读和可选状态以签名列为准。
sequence属性sequence?: number公开属性;类型、只读和可选状态以签名列为准。
sourceHash属性sourceHash?: string公开属性;类型、只读和可选状态以签名列为准。
sourceId属性sourceId: string公开属性;类型、只读和可选状态以签名列为准。
sourceType属性sourceType: MemoryExtractionSourceType公开属性;类型、只读和可选状态以签名列为准。
timestamp属性timestamp?: string公开属性;类型、只读和可选状态以签名列为准。

MemoryExtractionJob

Memory Extraction Job 接口,共包含 16 个公开字段或方法。

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

声明

text
export interface MemoryExtractionJob {
    id: string;
    operationId: string;
    scopeHash: string;
    profileRef: MemoryContractSpecRef;
    profileRevision: string;
    sourceRefs: MemoryExtractionSourceRef[];
    status: 'queued' | 'running' | 'awaiting_review' | 'completed' | 'partial' | 'failed' | 'cancelled';
    cursorBefore?: MemoryExtractionCursor;
    cursorAfter?: MemoryExtractionCursor;
    attempts: number;
    leaseOwner?: string;
    leaseExpiresAt?: string;
    lastError?: NormalizedMemoryError;
    createdAt: string;
    startedAt?: string;
    completedAt?: string;
}

契约成员

成员种类签名说明
attempts属性attempts: number公开属性;类型、只读和可选状态以签名列为准。
completedAt属性completedAt?: string公开属性;类型、只读和可选状态以签名列为准。
createdAt属性createdAt: string公开属性;类型、只读和可选状态以签名列为准。
cursorAfter属性cursorAfter?: MemoryExtractionCursor公开属性;类型、只读和可选状态以签名列为准。
cursorBefore属性cursorBefore?: MemoryExtractionCursor公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
lastError属性lastError?: NormalizedMemoryError公开属性;类型、只读和可选状态以签名列为准。
leaseExpiresAt属性leaseExpiresAt?: string公开属性;类型、只读和可选状态以签名列为准。
leaseOwner属性leaseOwner?: string公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId: string公开属性;类型、只读和可选状态以签名列为准。
profileRef属性profileRef: MemoryContractSpecRef公开属性;类型、只读和可选状态以签名列为准。
profileRevision属性profileRevision: string公开属性;类型、只读和可选状态以签名列为准。
scopeHash属性scopeHash: string公开属性;类型、只读和可选状态以签名列为准。
sourceRefs属性sourceRefs: MemoryExtractionSourceRef[]公开属性;类型、只读和可选状态以签名列为准。
startedAt属性startedAt?: string公开属性;类型、只读和可选状态以签名列为准。
status属性status: "completed" | "queued" | "running" | "cancelled" | "failed" | "partial" | "awaiting_review"公开属性;类型、只读和可选状态以签名列为准。

MemoryExtractionProfileSpec

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

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

声明

text
export interface MemoryExtractionProfileSpec {
    id: string;
    version: string;
    revision?: string;
    acceptedSourceTypes: MemoryExtractionSourceType[];
    outputMemoryTypes: ManagedMemoryType[];
    extractor: {
        type: 'deterministic';
        extractorRef: MemoryContractSpecRef;
    } | {
        type: 'model';
        modelProfileRef: MemoryContractSpecRef;
        promptTemplateRef: MemoryContractSpecRef;
    } | {
        type: 'provider';
        providerRef: MemoryContractSpecRef;
    } | {
        type: 'hybrid';
        stages: MemoryExtractionStageSpec[];
    };
    conversation?: {
        maxMessagesPerWindow: number;
        overlapMessages?: number;
        includeSystemMessages?: boolean;
        includeToolMessages?: boolean;
        extractionTrigger: 'each_turn' | 'window' | 'run_end' | 'session_idle' | 'manual';
    };
    episodic?: {
        boundary: 'run' | 'workflow_state' | 'task' | 'time_window' | 'custom';
        includeFailedEpisodes?: boolean;
        includeIntermediateObservations?: boolean;
    };
    truth?: {
        minimumAuthority: TruthAssertion['authority'];
        requireEvidence?: boolean;
        preserveValidityInterval?: boolean;
    };
    sensitiveDataPolicyRef?: MemoryContractSpecRef;
    candidateValidation: {
        minConfidence: number;
        requireCanonicalText: boolean;
        requireEvidence: boolean;
        maxCandidatesPerJob?: number;
        rejectInstructionLikeContent?: boolean;
    };
    writePolicyRef: MemoryContractSpecRef;
    maintenancePolicyRef: MemoryContractSpecRef;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
acceptedSourceTypes属性acceptedSourceTypes: MemoryExtractionSourceType[]公开属性;类型、只读和可选状态以签名列为准。
candidateValidation属性candidateValidation: { minConfidence: number; requireCanonicalText: boolean; requireEvidence: boolean; maxCandidatesPerJob?: number; rejectInstructionLikeContent?: boolean; }公开属性;类型、只读和可选状态以签名列为准。
conversation属性conversation?: { maxMessagesPerWindow: number; overlapMessages?: number; includeSystemMessages?: boolean; includeToolMessages?: boolean; extractionTrigger: "each_turn" | "window" | "run_end" | "session_idle" | "manual"; }公开属性;类型、只读和可选状态以签名列为准。
episodic属性episodic?: { boundary: "run" | "workflow_state" | "task" | "time_window" | "custom"; includeFailedEpisodes?: boolean; includeIntermediateObservations?: boolean; }公开属性;类型、只读和可选状态以签名列为准。
extractor属性extractor: { type: "deterministic"; extractorRef: MemoryContractSpecRef; } | { type: "model"; modelProfileRef: MemoryContractSpecRef; promptTemplateRef: MemoryContractSpecRef; } | { type: "provider"; providerRef: MemoryContractSpecRef; } | { type: "hybrid"; stages: MemoryExtractionStageSpec[]; }公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
maintenancePolicyRef属性maintenancePolicyRef: MemoryContractSpecRef公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
outputMemoryTypes属性outputMemoryTypes: ManagedMemoryType[]公开属性;类型、只读和可选状态以签名列为准。
revision属性revision?: string公开属性;类型、只读和可选状态以签名列为准。
sensitiveDataPolicyRef属性sensitiveDataPolicyRef?: MemoryContractSpecRef公开属性;类型、只读和可选状态以签名列为准。
truth属性truth?: { minimumAuthority: TruthAssertion["authority"]; requireEvidence?: boolean; preserveValidityInterval?: boolean; }公开属性;类型、只读和可选状态以签名列为准。
version属性version: string公开属性;类型、只读和可选状态以签名列为准。
writePolicyRef属性writePolicyRef: MemoryContractSpecRef公开属性;类型、只读和可选状态以签名列为准。

MemoryExtractionRequest

Memory Extraction Request 接口,共包含 9 个公开字段或方法。

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

声明

text
export interface MemoryExtractionRequest {
    operationId: string;
    principal: MemoryPrincipal;
    scope: ManagedMemoryScope;
    profileRef: MemoryContractSpecRef;
    sources: MemoryExtractionSourceRef[];
    mode: 'sync' | 'async';
    force?: boolean;
    idempotencyKey?: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
force属性force?: boolean公开属性;类型、只读和可选状态以签名列为准。
idempotencyKey属性idempotencyKey?: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
mode属性mode: "sync" | "async"公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId: string公开属性;类型、只读和可选状态以签名列为准。
principal属性principal: MemoryPrincipal公开属性;类型、只读和可选状态以签名列为准。
profileRef属性profileRef: MemoryContractSpecRef公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: ManagedMemoryScope公开属性;类型、只读和可选状态以签名列为准。
sources属性sources: MemoryExtractionSourceRef[]公开属性;类型、只读和可选状态以签名列为准。

MemoryExtractionSourceAdapter

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

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

声明

text
export interface MemoryExtractionSourceAdapter<T = unknown> {
    readonly type: MemoryExtractionSourceType;
    load(refs: MemoryExtractionSourceRef[], cursor?: MemoryExtractionCursor): Promise<MemoryExtractionSourceBatch<T>>;
    normalize(batch: MemoryExtractionSourceBatch<T>): Promise<NormalizedExtractionInput[]>;
    health(): Promise<ProviderHealth>;
}

契约成员

成员种类签名说明
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
load方法load(refs: MemoryExtractionSourceRef[], cursor?: MemoryExtractionCursor): Promise<MemoryExtractionSourceBatch<T>>公开方法;参数与返回类型以签名列为准。
normalize方法normalize(batch: MemoryExtractionSourceBatch<T>): Promise<NormalizedExtractionInput[]>公开方法;参数与返回类型以签名列为准。
type属性readonly type: MemoryExtractionSourceType公开属性;类型、只读和可选状态以签名列为准。

MemoryExtractionSourceBatch

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

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

声明

text
export interface MemoryExtractionSourceBatch<T = unknown> {
    sourceRefs: MemoryExtractionSourceRef[];
    items: Array<{
        sourceRef: MemoryExtractionSourceRef;
        value: T;
    }>;
    nextCursor?: MemoryExtractionCursor;
}

契约成员

成员种类签名说明
items属性items: { sourceRef: MemoryExtractionSourceRef; value: T; }[]公开属性;类型、只读和可选状态以签名列为准。
nextCursor属性nextCursor?: MemoryExtractionCursor公开属性;类型、只读和可选状态以签名列为准。
sourceRefs属性sourceRefs: MemoryExtractionSourceRef[]公开属性;类型、只读和可选状态以签名列为准。

MemoryExtractionSourceRef

Memory Extraction Source Ref 接口,共包含 15 个公开字段或方法。

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

声明

text
export interface MemoryExtractionSourceRef {
    type: MemoryExtractionSourceType;
    sourceId: string;
    sourceVersion?: string;
    sourceHash?: string;
    sessionId?: string;
    runId?: string;
    messageIds?: string[];
    eventIds?: string[];
    artifactRefs?: string[];
    observedAt?: string;
    validFrom?: string;
    validTo?: string;
    authority?: 'unverified' | 'user_asserted' | 'system_observed' | 'verified' | 'authoritative';
    trustScore?: number;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
artifactRefs属性artifactRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
authority属性authority?: "verified" | "unverified" | "user_asserted" | "system_observed" | "authoritative"公开属性;类型、只读和可选状态以签名列为准。
eventIds属性eventIds?: string[]公开属性;类型、只读和可选状态以签名列为准。
messageIds属性messageIds?: string[]公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
observedAt属性observedAt?: string公开属性;类型、只读和可选状态以签名列为准。
runId属性runId?: string公开属性;类型、只读和可选状态以签名列为准。
sessionId属性sessionId?: string公开属性;类型、只读和可选状态以签名列为准。
sourceHash属性sourceHash?: string公开属性;类型、只读和可选状态以签名列为准。
sourceId属性sourceId: string公开属性;类型、只读和可选状态以签名列为准。
sourceVersion属性sourceVersion?: string公开属性;类型、只读和可选状态以签名列为准。
trustScore属性trustScore?: number公开属性;类型、只读和可选状态以签名列为准。
type属性type: MemoryExtractionSourceType公开属性;类型、只读和可选状态以签名列为准。
validFrom属性validFrom?: string公开属性;类型、只读和可选状态以签名列为准。
validTo属性validTo?: string公开属性;类型、只读和可选状态以签名列为准。

MemoryExtractionStageSpec

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

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

声明

text
export interface MemoryExtractionStageSpec {
    id: string;
    type: 'normalize' | 'classify' | 'extract' | 'validate' | 'enrich' | 'custom';
    handlerRef: MemoryContractSpecRef;
    optional?: boolean;
    timeoutMs?: number;
    retryPolicy?: Record<string, unknown>;
}

契约成员

成员种类签名说明
handlerRef属性handlerRef: MemoryContractSpecRef公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
optional属性optional?: boolean公开属性;类型、只读和可选状态以签名列为准。
retryPolicy属性retryPolicy?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
timeoutMs属性timeoutMs?: number公开属性;类型、只读和可选状态以签名列为准。
type属性type: "custom" | "validate" | "normalize" | "classify" | "extract" | "enrich"公开属性;类型、只读和可选状态以签名列为准。

MemoryExtractor

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

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

声明

text
export interface MemoryExtractor {
    readonly id: string;
    extract(inputs: NormalizedExtractionInput[], profile: MemoryExtractionProfileSpec): Promise<ExtractedMemoryCandidate[]>;
    health(): Promise<ProviderHealth>;
}

契约成员

成员种类签名说明
extract方法extract(inputs: NormalizedExtractionInput[], profile: MemoryExtractionProfileSpec): Promise<ExtractedMemoryCandidate[]>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
id属性readonly id: string公开属性;类型、只读和可选状态以签名列为准。

MemoryMaintenanceApplyRequest

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

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

声明

text
export interface MemoryMaintenanceApplyRequest {
    decision: MemoryMaintenanceDecision;
    candidate: ExtractedMemoryCandidate;
    scope: ManagedMemoryScope;
}

契约成员

成员种类签名说明
candidate属性candidate: ExtractedMemoryCandidate公开属性;类型、只读和可选状态以签名列为准。
decision属性decision: MemoryMaintenanceDecision公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: ManagedMemoryScope公开属性;类型、只读和可选状态以签名列为准。

MemoryMaintenanceDecision

Memory Maintenance Decision 接口,共包含 18 个公开字段或方法。

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

声明

text
export interface MemoryMaintenanceDecision {
    id: string;
    operationId: string;
    candidateId: string;
    scopeHash: string;
    action: MemoryMaintenanceAction;
    targetMemoryIds: string[];
    expectedRevisions: Record<string, number>;
    duplicateScore?: number;
    conflictScore?: number;
    authorityComparison?: 'candidate_higher' | 'existing_higher' | 'equal' | 'unknown';
    mergedContent?: unknown;
    patch?: MemoryPatch;
    relationsToCreate?: MemoryRelation[];
    recordsToInvalidate?: string[];
    reasonCode: 'NEW_FACT' | 'EXACT_DUPLICATE' | 'SEMANTIC_DUPLICATE' | 'ADDITIONAL_EVIDENCE' | 'FACT_CORRECTION' | 'TEMPORAL_UPDATE' | 'AUTHORITY_OVERRIDE' | 'CONFLICT_REQUIRES_REVIEW' | 'LOW_CONFIDENCE' | 'POLICY_REJECTED' | 'CUSTOM';
    explanation?: string;
    policyRevision: string;
    createdAt: string;
}

契约成员

成员种类签名说明
action属性action: MemoryMaintenanceAction公开属性;类型、只读和可选状态以签名列为准。
authorityComparison属性authorityComparison?: "unknown" | "candidate_higher" | "existing_higher" | "equal"公开属性;类型、只读和可选状态以签名列为准。
candidateId属性candidateId: string公开属性;类型、只读和可选状态以签名列为准。
conflictScore属性conflictScore?: number公开属性;类型、只读和可选状态以签名列为准。
createdAt属性createdAt: string公开属性;类型、只读和可选状态以签名列为准。
duplicateScore属性duplicateScore?: number公开属性;类型、只读和可选状态以签名列为准。
expectedRevisions属性expectedRevisions: Record<string, number>公开属性;类型、只读和可选状态以签名列为准。
explanation属性explanation?: string公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
mergedContent属性mergedContent?: unknown公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId: string公开属性;类型、只读和可选状态以签名列为准。
patch属性patch?: MemoryPatch公开属性;类型、只读和可选状态以签名列为准。
policyRevision属性policyRevision: string公开属性;类型、只读和可选状态以签名列为准。
reasonCode属性reasonCode: "CUSTOM" | "NEW_FACT" | "EXACT_DUPLICATE" | "SEMANTIC_DUPLICATE" | "ADDITIONAL_EVIDENCE" | "FACT_CORRECTION" | "TEMPORAL_UPDATE" | "AUTHORITY_OVERRIDE" | "CONFLICT_REQUIRES_REVIEW" | "LOW_CONFIDENCE" | "POLICY_REJECTED"公开属性;类型、只读和可选状态以签名列为准。
recordsToInvalidate属性recordsToInvalidate?: string[]公开属性;类型、只读和可选状态以签名列为准。
relationsToCreate属性relationsToCreate?: MemoryRelation[]公开属性;类型、只读和可选状态以签名列为准。
scopeHash属性scopeHash: string公开属性;类型、只读和可选状态以签名列为准。
targetMemoryIds属性targetMemoryIds: string[]公开属性;类型、只读和可选状态以签名列为准。

MemoryMaintenancePlanner

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

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

声明

text
export interface MemoryMaintenancePlanner {
    plan(request: MemoryMaintenancePlanRequest): Promise<MemoryMaintenanceDecision>;
    apply(request: MemoryMaintenanceApplyRequest): Promise<ManagedMemoryWriteResult>;
    explain(decisionId: string): Promise<MemoryMaintenanceDecision | null>;
}

契约成员

成员种类签名说明
apply方法apply(request: MemoryMaintenanceApplyRequest): Promise<ManagedMemoryWriteResult>公开方法;参数与返回类型以签名列为准。
explain方法explain(decisionId: string): Promise<MemoryMaintenanceDecision | null>公开方法;参数与返回类型以签名列为准。
plan方法plan(request: MemoryMaintenancePlanRequest): Promise<MemoryMaintenanceDecision>公开方法;参数与返回类型以签名列为准。

MemoryMaintenancePlanRequest

Memory Maintenance Plan Request 接口,共包含 5 个公开字段或方法。

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

声明

text
export interface MemoryMaintenancePlanRequest {
    operationId: string;
    scope: ManagedMemoryScope;
    candidate: ExtractedMemoryCandidate;
    existingRecords: ManagedMemoryRecord[];
    policy: MemoryMaintenancePolicySpec;
}

契约成员

成员种类签名说明
candidate属性candidate: ExtractedMemoryCandidate公开属性;类型、只读和可选状态以签名列为准。
existingRecords属性existingRecords: ManagedMemoryRecord<unknown>[]公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId: string公开属性;类型、只读和可选状态以签名列为准。
policy属性policy: MemoryMaintenancePolicySpec公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: ManagedMemoryScope公开属性;类型、只读和可选状态以签名列为准。

MemoryMaintenancePolicySpec

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

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

声明

text
export interface MemoryMaintenancePolicySpec {
    id: string;
    version: string;
    revision?: string;
    preWriteRetrieval: {
        enabled: boolean;
        exactKeyLookup: boolean;
        semanticLookup?: boolean;
        maxCandidates: number;
        semanticThreshold?: number;
        includeSuperseded?: boolean;
        includeInvalidated?: boolean;
    };
    duplicateResolution: 'reuse_existing' | 'increase_support' | 'create_version' | 'require_review';
    updateResolution: 'patch_current' | 'create_version' | 'supersede' | 'require_review';
    conflictResolution: 'keep_both_marked' | 'prefer_authoritative' | 'prefer_verified' | 'prefer_latest' | 'invalidate_old' | 'require_review';
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
conflictResolution属性conflictResolution: "prefer_latest" | "prefer_verified" | "require_review" | "keep_both_marked" | "prefer_authoritative" | "invalidate_old"公开属性;类型、只读和可选状态以签名列为准。
duplicateResolution属性duplicateResolution: "reuse_existing" | "increase_support" | "create_version" | "require_review"公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
preWriteRetrieval属性preWriteRetrieval: { enabled: boolean; exactKeyLookup: boolean; semanticLookup?: boolean; maxCandidates: number; semanticThreshold?: number; includeSuperseded?: boolean; includeInvalidated?: boolean; }公开属性;类型、只读和可选状态以签名列为准。
revision属性revision?: string公开属性;类型、只读和可选状态以签名列为准。
updateResolution属性updateResolution: "create_version" | "require_review" | "patch_current" | "supersede"公开属性;类型、只读和可选状态以签名列为准。
version属性version: string公开属性;类型、只读和可选状态以签名列为准。

NormalizedExtractionInput

Normalized Extraction Input 接口,共包含 3 个公开字段或方法。

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

声明

text
export interface NormalizedExtractionInput {
    sourceRef: MemoryExtractionSourceRef;
    value: unknown;
    canonicalText?: string;
}

契约成员

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

TruthAssertion

Truth Assertion 接口,共包含 11 个公开字段或方法。

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

声明

text
export interface TruthAssertion {
    assertionId: string;
    subject: string;
    predicate: string;
    object: unknown;
    authority: 'user_confirmed' | 'human_reviewed' | 'system_of_record' | 'policy_defined';
    confidence: number;
    validFrom?: string;
    validTo?: string;
    supersedesAssertionId?: string;
    evidenceRefs: string[];
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
assertionId属性assertionId: string公开属性;类型、只读和可选状态以签名列为准。
authority属性authority: "user_confirmed" | "human_reviewed" | "system_of_record" | "policy_defined"公开属性;类型、只读和可选状态以签名列为准。
confidence属性confidence: number公开属性;类型、只读和可选状态以签名列为准。
evidenceRefs属性evidenceRefs: string[]公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
object属性object: unknown公开属性;类型、只读和可选状态以签名列为准。
predicate属性predicate: string公开属性;类型、只读和可选状态以签名列为准。
subject属性subject: string公开属性;类型、只读和可选状态以签名列为准。
supersedesAssertionId属性supersedesAssertionId?: string公开属性;类型、只读和可选状态以签名列为准。
validFrom属性validFrom?: string公开属性;类型、只读和可选状态以签名列为准。
validTo属性validTo?: string公开属性;类型、只读和可选状态以签名列为准。

MemoryExtractionSourceType

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

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

声明

text
export type MemoryExtractionSourceType = 'conversation' | 'truth' | 'episodic_record' | 'runtime_event' | 'tool_observation' | 'artifact' | 'structured_record' | 'custom';

MemoryMaintenanceAction

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

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

声明

text
export type MemoryMaintenanceAction = 'create' | 'noop' | 'reuse' | 'update' | 'merge' | 'supersede' | 'invalidate' | 'reject' | 'require_review';