import type { AgentConfig } from '../../types/agentConfig.js'; import type { WorkingMemoryBlockSpec, WorkingMemoryConfig } from '../../types/grounding.js'; import type { Session } from '../../types/session.js'; import type { AnyTool } from '../../types/effectTool.js'; import { type MemoryBlockScope, type PersistentMemoryStore } from '../../memory/blocks/types.js'; export interface LoadedWorkingMemoryBlock { scope: MemoryBlockScope; key: string; content: string; } export interface WiredWorkingMemory { promptSection: string | undefined; memoryBlockTool: AnyTool; } /** * The one place a working-memory store is obtained, and therefore the one place * layer 1 belongs. Every store handed out here validates its owner and block key * before touching a backend. * * It is wrapped here rather than inside each backend class deliberately: a * backend constructed directly stays as permissive as it always was (its own * layers 2/3 make it collision-safe regardless), while everything that goes * through the framework — `wireWorkingMemory`, the `memory_block` tool, and any * consumer calling this exported function — gets the reject-and-throw guarantee. */ export declare function resolveWorkingMemoryStore(config: WorkingMemoryConfig, harnessDefault?: PersistentMemoryStore): PersistentMemoryStore; /** * The owner a block is stored under, or `undefined` when there is nobody to * store it for. * * There is deliberately no fallback. This previously returned `'anonymous'` * when a session had no `userId`, which made every such session share one * owner — so one visitor's USER block loaded into the next visitor's system * prompt. `userId` is optional on `chatRouter` and the OpenAI-compat endpoint, * so that was reachable on any hosted chat surface that did not pass one. * * `runtime/grounding/memory.ts` already fails closed on a missing `userId` for * preload and ingest. This now matches it: absent owner means the block does * not exist for this session, not that it belongs to everyone. * * `agent` scope is unaffected — `agentId` is always present. */ export declare function resolveWorkingMemoryOwner(scope: MemoryBlockScope, agentId: string, userId: string | undefined): string | undefined; export declare function loadWorkingMemoryBlocks(store: PersistentMemoryStore, autoLoad: WorkingMemoryBlockSpec[], resolveOwner: (scope: MemoryBlockScope) => string | undefined): Promise; export declare function formatWorkingMemorySection(blocks: LoadedWorkingMemoryBlock[], autoLoad: WorkingMemoryBlockSpec[]): string | undefined; /** Test seam: the warn-once caches are process-global by design. */ export declare function resetWorkingMemoryWarningsForTests(): void; export declare function wireWorkingMemory(agent: AgentConfig, session: Session, harnessDefaultStore?: PersistentMemoryStore): Promise;