/** * The turn's memory hooks: recall before the model runs, capture after it * answers, from `@lobu/plugin-memory` itself. * * GUEST code, so the same portability rules as `workspace.ts` apply: no `node:` * import, no host module, no root `@lobu/core` import. * * Nothing here reimplements a hook. `createMemoryPlugin` owns the recall query, * the `` block the model reads, the capture shape and its * 2,000-character bound. Two isolate-specific pieces are supplied here: * * 1. The INVOKER. The guest's MCP caller avoids importing the Node-bound * `@lobu/core` root and posts to `{gateway}/mcp/lobu/tools/{name}` under * the same bearer as every other tool call on this turn. * * 2. The SETTLE. `agentEnd` starts the `save_memory` write and returns * without waiting, which is correct on a runtime that outlives the turn and * silently lossy on one that does not: this isolate is disposed the moment * `runAgentTurn` resolves. `runTurnMemory` therefore awaits the plugin's * `settle()` before returning, so the capture actually reaches the gateway. */ import type { PluginLogger } from '@lobu/plugin-api'; /** What the guest needs from a turn to run its memory hooks. */ export interface TurnMemoryContext { gatewayUrl: string; credential: string; agentId: string; conversationId: string; /** * The MCP server `search_memory` and `save_memory` are mounted on. The * plugin names `lobu` internally; the producer states which server that is * for this turn, and the invoker below routes to it. */ mcpId: string; /** * One MCP tool call, as the guest already makes them. Injected rather than * imported so this module carries no second transport: `guest-entry.ts` owns * the one `POST /mcp/{id}/tools/{name}` and its timeout mapping. */ callTool: (mcpId: string, toolName: string, args: Record, options?: { timeoutMs?: number; }) => Promise; /** Where a hook's own diagnostics go. The host redacts and budgets them. */ logger: PluginLogger; } /** The memory used by ONE turn, from recall through capture. */ export interface TurnMemory { /** * The recall block to prepend to this turn's prompt, or `''`. Never throws: * a memory server that is down must not cost the user their answer. */ recall(prompt: string, messages: readonly unknown[]): Promise; /** * Capture the exchange, and WAIT for it. Called after the turn produced its * answer and before the isolate is disposed. Never throws. */ capture(messages: readonly unknown[], error?: string): Promise; } export declare function createTurnMemoryHooks(context: TurnMemoryContext): TurnMemory; //# sourceMappingURL=memory.d.ts.map