import type { AiMiddleware, RemembersSpec } from './types.js'; import type { UserMemoryLookup } from './memory.js'; export interface MemoryInjectOptions { /** * Override the {@link UserMemory} lookup. Defaults to the module-level * `resolveUserMemory()` registry that `AiProvider` writes to from * `AiConfig.memory`. Tests pass a closure to inject a fake. */ lookup?: UserMemoryLookup; /** * Approximate-tokens estimator used for `injectTokenBudget`. Defaults * to `Math.ceil(text.length / 4)` — fine for English-heavy facts; pass * a tiktoken-backed estimator if you need accuracy. */ estimateTokens?: (text: string) => number; } /** * Pre-prompt {@link AiMiddleware} that consults a {@link UserMemory}, picks * facts relevant to the latest user input, and prepends them to the * agent's system message as a fenced `…` * block. Auto-installed by `Agent.prompt` / `Agent.stream` when * `Agent.remembers()` returns `{ inject: 'auto', … }`; can also be * dropped into `Agent.middleware()` manually. * * Runs in `onStart` (async) — `onConfig` is sync and `recall()` is not. * Mutates `ctx.messages[0]` (the system message) in place; the agent * loop's `messages` array is the same reference, so the model sees the * augmented prompt on the very next provider call. * * Skips silently when: * - no `UserMemory` is registered (lookup returns `undefined`) * - no user message exists in `ctx.messages` (continuation flow where * the trailing message is `tool` / `assistant`) * - `recall()` returns no facts * - the rendered block doesn't fit even one fact under * `spec.injectTokenBudget` */ export declare function withMemoryInject(spec: RemembersSpec, opts?: MemoryInjectOptions): AiMiddleware; //# sourceMappingURL=memory-inject.d.ts.map