import type { RuntimeContext } from "../runtime/state/context.js"; import type { ExtractionResult, ForgetResult } from "../runtime/memory/index.js"; import type { MemoryConfig } from "../runtime/memory/types.js"; import type { StateStack } from "../runtime/state/stateStack.js"; import type { ThreadStore } from "../runtime/state/threadStore.js"; /** * std::memory TS implementations for the context-injected builtins * registered in `lib/codegenBuiltins/contextInjected.ts`. Each * function takes the per-run `RuntimeContext` as its first argument, * followed by the caller's local `StateStack` and `ThreadStore` * (unused here — needed by other context-injected builtins like * `std::thread`'s `getCost`/`*Message`). The agency-side wrappers in * `stdlib/memory.agency` call them without any of these prefix args; * the TypeScript builder prepends `__ctx`, `__stateStack`, and * `__threads` at every context-injected call site. * * If no memory frame is active (neither `agency.json` nor a code-side * `enableMemory(...)` has set one), every function is a no-op: * side-effecting helpers resolve to `undefined`, * `__internal_recall` to `""`, and the prompt-build helpers return * `""` so the agency-side guard short-circuits. */ export declare function __internal_setMemoryId(ctx: RuntimeContext, _stack: StateStack, _threads: ThreadStore, id: string): Promise; export declare function __internal_shouldRunMemory(ctx: RuntimeContext, _stack: StateStack, _threads: ThreadStore): boolean; export declare function __internal_buildExtractionPrompt(ctx: RuntimeContext, _stack: StateStack, _threads: ThreadStore, content: string): Promise; export declare function __internal_applyExtractionResult(ctx: RuntimeContext, _stack: StateStack, _threads: ThreadStore, result: ExtractionResult): Promise; export declare function __internal_buildForgetPrompt(ctx: RuntimeContext, _stack: StateStack, _threads: ThreadStore, query: string): Promise; export declare function __internal_applyForgetResult(ctx: RuntimeContext, _stack: StateStack, _threads: ThreadStore, result: ForgetResult): Promise; export declare function __internal_remember(ctx: RuntimeContext, _stack: StateStack, _threads: ThreadStore, content: string): Promise; export declare function __internal_recall(ctx: RuntimeContext, _stack: StateStack, _threads: ThreadStore, query: string): Promise; export declare function __internal_forget(ctx: RuntimeContext, _stack: StateStack, _threads: ThreadStore, query: string): Promise; export declare function _setMemoryId(id: string): Promise; export declare function _getMemoryId(): string; export declare function _shouldRunMemory(): boolean; export declare function _buildExtractionPrompt(content: string): Promise; export declare function _applyExtractionResult(result: ExtractionResult): Promise; export declare function _buildForgetPrompt(query: string): Promise; export declare function _applyForgetResult(result: ForgetResult): Promise; export declare function _remember(content: string): Promise; export declare function _recall(query: string): Promise; export declare function _forget(query: string): Promise; /** * Push a memory frame onto the current branch's stateStack. * * Process-wide stores are cached by absolute realpath'd dir, so * multiple calls with the same dir share one underlying store. * Repeating the same dir as the current top frame is a no-op (so the * common `static const _ = enableMemory(...)` plus an * `enableMemory(...)` in `main()` is safe). Pushing a different dir * stacks the new frame on top — pop it with `disableMemory()`. * * Auto-creates the dir if missing. Resolves `dir` against * `process.cwd()`, the same as `agency.json`'s `memory.dir` and * every path-taking stdlib function. */ export declare function _enableMemory(config: MemoryConfig): Promise; /** Pop the top memory frame from the current branch's stateStack. * Frame-scoped: a `disableMemory()` inside a fork branch only * affects that branch. Pops the JSON-seeded bottom frame too — * library authors should avoid calling this casually. */ export declare function _disableMemory(): void; /** * Push a memory frame, returning whether the push actually happened * (false on same-dir dedup). The Agency-side `memory({...}) as { ... }` * block pairs this with `_popMemoryFrame()` so a no-op push doesn't * unbalance the pop — mirrors the `_pushGuard`/`_popGuard` count * pattern in std::thread. Returns `false` and is a no-op outside any * runtime frame (consistent with `_enableMemory`). * * Lives in TS rather than as a thin wrapper around `_enableMemory` * because Agency callers need the boolean to decide whether to pop. */ export declare function _pushMemoryFrame(config: MemoryConfig): boolean; /** Pop the top memory frame. Counterpart to `_pushMemoryFrame`; the * Agency-side `memory(){}` block calls this only when `_pushMemoryFrame` * returned true so dedup-no-op pushes don't accidentally pop the * caller's frame. */ export declare function _popMemoryFrame(): void;