import type { AgentTool } from '@earendil-works/pi-agent-core'; import type { MemoryRuntime } from '../../agent-runtime/memory-runtime.js'; import type { MemoryProvider, MemoryProviderInitOptions } from './provider.js'; import type { UnderstandingCandidate } from './understanding/types.js'; import type { MemoryDeleteRequest, MemoryListRequest, MemoryReadRequest, MemoryReadResult, MemorySearchRequest, MemorySearchResult, MemoryUpdateRequest, MemoryWriteRequest, MemoryWriteResult, MemoryRecord, MemorySignal, MemoryKind } from './types.js'; export type MemorySearchStrategy = 'local-first' | 'external-first' | 'fanout' | 'local-only' | 'external-only'; export type MemoryWriteStrategy = 'local-first' | 'external-first' | 'write-through' | 'local-only' | 'external-only'; export interface MemoryRoutingOptions { searchStrategy?: MemorySearchStrategy; writeStrategy?: MemoryWriteStrategy; replicateTo?: string[]; } export interface MemoryManagerOptions extends MemoryRoutingOptions { loadProviders?: () => Promise; writePolicy?: MemoryWritePolicy; memoryRuntime?: MemoryRuntime; } export interface MemoryWritePolicy { allowExternalWrites?: boolean; allowedProviderIds?: string[]; autoWriteKinds?: MemoryKind[]; } export declare class MemoryManager { private providers; private toolToProvider; private readonly routing; private readonly loadProviders?; private readonly writePolicy; private pluginProvidersLoaded; private readonly understanding; private readonly memoryRuntime?; private readonly lastTurnSourceItem; private readonly sessionContexts; constructor(options?: MemoryManagerOptions); addProvider(provider: MemoryProvider): void; get providersList(): MemoryProvider[]; /** Static instructions contributed by external memory providers. */ buildExternalSystemPrompt(): string; queuePrefetchAll(query: string, options?: { sessionId?: string; }): void; syncAll(userContent: string, assistantContent: string, options?: { sessionId?: string; }): Promise; captureTurnUnderstanding(userContent: string, assistantContent: string, options?: { agentId?: string; sessionId?: string; turnId?: string; workspaceId?: string; projectId?: string; correctionTargetRecordIds?: string[]; }): Promise; syncProvidersForTurn(userContent: string, assistantContent: string, options?: { sessionId?: string; }): Promise; applyUnderstandingCandidates(candidates: UnderstandingCandidate[], context?: { agentId?: string; sessionKey?: string; workspaceId?: string; projectId?: string; sourceItemId?: string; sourceItemIds?: string[]; sourceText?: string; source?: MemoryRecord['source']; reviewSource?: 'turn' | 'background'; }): Promise; getExternalToolEntries(): Array<{ providerId: string; tool: AgentTool; }>; handleToolCall(toolName: string, args: Record): Promise; search(request: MemorySearchRequest): Promise; read(request: MemoryReadRequest): Promise; get(id: string): Promise; list(request: MemoryListRequest): Promise; write(request: MemoryWriteRequest): Promise; update(request: MemoryUpdateRequest): Promise; delete(request: MemoryDeleteRequest): Promise; private canReadRecord; recordSignal(signal: MemorySignal): void; initializeAll(sessionId: string, options?: MemoryProviderInitOptions): Promise; private loadPluginProvidersOnce; shutdownAll(): Promise; private providersForSearch; private providersForWrite; private writeWithStrategy; private providerAllowedForWrite; private trace; }