import { type Server } from "node:http"; import type { MemoryBlock, MemoryCompletedTurn, MemoryCompletedTurnResult, MemoryLoadOptions, MemoryStore, MemoryWriteResult } from "@mono-agent/agent-contracts"; import { type MemoryRecallRuntimeExtension, type RecallCapableStore } from "./memory-recall.js"; export interface SharedRecallStore extends MemoryStore, RecallCapableStore { /** Optional local-store telemetry hook; it must not alter relevance. */ recordAccess?(ids: readonly string[]): void; } export interface MemoryRetrievalServiceOptions { readonly maxBytes?: number; readonly source?: string; } export interface SharedMemoryRecallRuntimeExtensionOptions { /** Best-effort diagnostic when the loopback tool endpoint cannot start. */ readonly onUnavailable?: (error: unknown) => void; /** Test seam for simulating endpoint startup failures. */ readonly listen?: (server: Server) => Promise; } interface SharedRecallHit { readonly score: number; readonly record: { readonly id: string; readonly text: string; readonly type?: "task" | "event" | "note"; readonly status?: "open" | "done" | "scheduled" | "migrated" | "dropped" | "invalidated"; readonly isInsight?: boolean; }; } /** * One configured-harness read path for automatic context and MemoryRecall. * * Each normalized query in a turn asks the configured backend for a bounded * superset once. Automatic recall and the MCP tool then slice that same promise, * so an identical query performs at most one embedding/search operation. The * cache is explicitly released by the harness after the whole logical turn. */ export declare class MemoryRetrievalService implements MemoryStore { private readonly store; private readonly maxBytes; private readonly source; private readonly turns; readonly persistCompletedTurn?: (turn: MemoryCompletedTurn) => Promise; constructor(store: SharedRecallStore, options?: MemoryRetrievalServiceOptions); load(conversationId: string, query?: string, options?: MemoryLoadOptions): Promise; recallForTurn(turnId: string, query: string, options?: { readonly topK?: number; readonly trackAccess?: boolean; readonly expandHops?: 0 | 1; }): Promise; releaseTurn(turnId: string): void; releaseAllTurns(): void; supportsGraphExpansion(): boolean; recordAccessIdsForTurn(turnId: string, ids: readonly string[]): void; appendHostSummary(conversationId: string, summary: string): Promise; scheduleCapture(conversationId: string, text: string): void; flush(): Promise; private turnCache; private recordServed; } /** Create a per-turn loopback MCP endpoint over the shared in-process service. */ export declare function createSharedMemoryRecallRuntimeExtension(service: MemoryRetrievalService, options?: SharedMemoryRecallRuntimeExtensionOptions): (input: { readonly runId: string; }) => Promise; export declare function isSharedRecallStore(store: MemoryStore | undefined): store is SharedRecallStore; export declare function normalizeMemoryRecallQuery(query: string): string; export {}; //# sourceMappingURL=memory-retrieval.d.ts.map