import type { ModelRegistry } from "../config/model-registry.js"; import type { Settings } from "../config/settings.js"; import type { MemoryBackendSaveInput, MemoryBackendSaveResult } from "../memory-backend/types.js"; import type { AgentSession } from "../session/agent-session.js"; import { type MemoryThread } from "./storage.js"; /** * Start the background memory startup pipeline. * * Skips for ephemeral sessions, subagent sessions, disabled settings, or DB failures. */ export declare function startMemoryStartupTask(options: { session: AgentSession; settings: Settings; modelRegistry: ModelRegistry; agentDir: string; taskDepth: number; }): void; interface MemoryInstructionSession { sessionManager: Pick; agent?: { state: { messages: readonly unknown[]; }; }; } /** * Drop the per-session memory instruction snapshot after explicit memory state * changes that must affect the active conversation immediately, such as * `/memory clear`. */ export declare function clearMemoryToolDeveloperInstructionsCache(session: MemoryInstructionSession | undefined): void; /** * Refresh the active session's consolidated-memory snapshot after startup maintenance. * * Startup may finish after the first prompt build and write `memory_summary.md`. * The session adopts that summary only while it holds no messages: once a * request went out, signed thinking is bound to the prompt it carried, so the * new summary waits for the next session, whose cache key (session file) differs. * It must not reread `learned.md`, because a `learn` call racing with startup * belongs to the next session's memory prompt, not the active prompt-cache prefix. */ export declare function refreshMemoryToolDeveloperInstructionsCacheAfterStartup(session: MemoryInstructionSession, agentDir: string, cwd: string, settings: Settings): Promise; /** * Build memory usage instructions for prompt injection. * * `cwd` is the session's project directory, the same scope consolidation and * `learn` write to; never `settings.getCwd()`, which an embedding host may pin * to one directory for sessions spanning several projects. */ export declare function buildMemoryToolDeveloperInstructions(agentDir: string, cwd: string, settings: Settings, session?: MemoryInstructionSession): Promise; /** * Clear the persisted memory state and generated artifacts of one project. */ export declare function clearMemoryData(agentDir: string, cwd: string): Promise; /** * Force-enqueue global consolidation maintenance work. */ export declare function enqueueMemoryConsolidation(agentDir: string, cwd: string, sourceUpdatedAt?: number): void; /** @internal Exported for unit-testing. */ export declare function collectThreads(session: AgentSession, currentThreadId?: string): Promise; /** * Build the stage-1 `response_items_json` payload for a rollout file. * * Equivalent to `truncateByApproxTokens(JSON.stringify(persistableMessages), tokenLimit)`, but * streams the rollout in byte windows and serializes messages from the front and back only until * the head/tail budgets fill. Peak memory is bounded by the window size plus the largest single * JSONL record (a record spanning windows is carried until its newline), not by rollout size. */ export declare function buildStage1RolloutItems(rolloutPath: string, tokenLimit: number): Promise; export declare function getMemoryRoot(agentDir: string, cwd: string): string; /** * Append one lesson to the project's `learned.md` (newest-first, deduped, * capped, secret-redacted, injection-neutralized). The file backs the `learn` * tool when `memory.backend` is `local`. */ export declare function saveLearnedLesson(agentDir: string, cwd: string, input: MemoryBackendSaveInput): Promise; export {};