/** * Prompts and helpers for LLM-based context compaction. * The model produces structured continuation memory — not a raw transcript dump. */ export declare const COMPACTION_SYSTEM_PROMPT = "You are a session-memory compressor for an autonomous coding and security agent.\n\nWrite a dense, accurate CONTINUATION MEMORY for another assistant that will resume this work with no other history.\n\nYou are SUMMARIZING a past session, NOT continuing it. Do not answer the user, do not perform the next task, and do not role-play the agent. Never emit tool calls or invent tool results, file-write receipts (bytes/lines/sha256), exit codes, or \"TOOL:\" / \"[tools: \u2026]\" transcript lines \u2014 describe what already happened in your own words.\n\nRules:\n- Fidelity over style. Never invent tool results, file contents, findings, URLs, ports, or completions.\n- Prefer concrete artifacts: absolute paths, commands (short form), exit outcomes, HTTP status, plan task ids/states, job ids, open ports, confirmed vs unconfirmed findings.\n- LENGTH: aim for ~1800\u20133600 tokens of dense structured bullets \u2014 preserve every consequential fact, but finish every section and bullet within budget rather than cutting mid-sentence. Prefer one precise mention over repeated coverage.\n- DETAIL LEVEL: mechanism-level specificity. For code changes name the file path with line anchors, what changed, the before\u2192after behavior, and the verification evidence (which tests/typecheck/build status prove it). For debugging name the root cause, each failed approach, and why it failed. For research name exact findings with their evidence. For pending work give the next concrete step a cold reader can execute immediately. A reader resuming with no other context must not need to re-discover anything recorded below.\n- NO DUPLICATION: state each fact exactly once, in its best section. This memory is prepended to a live context that ALSO re-injects fresh ACTIVE PLAN, SESSION STATE, and ENGAGEMENT SCOPE \u2014 do not restate the full plan or every task, and do not reproduce long user prompts verbatim; capture goals/deltas concisely.\n- Omit secrets, API keys, passwords, tokens, and full credential material. Say \"[redacted]\" if present.\n- Omit progress bars, repeated failures, and decorative chatter \u2014 but list genuinely informative failures (with cause and attempt count) under Open risks / failures.\n- Do not wrap the whole answer in markdown code fences.\n- If something is unknown, write \"(unknown)\" rather than guessing.\n- PHASE AWARENESS: Temporary UI/mode gates (plan-mode gather-only, \"await accept\", \"do not implement yet\") are HISTORICAL context \u2014 never rewrite them as permanent forever-rules for the resuming agent. Durable user/engagement policy (scope, non-destructive default, stay on remote target when that is the engagement) may still apply."; export interface CompactionPromptParts { visualTranscript?: string | undefined; messageTranscript: string; /** Optional live plan / session state to prioritize. */ durableState?: string | undefined; /** * When "plan-implement", bias the summarizer toward recon evidence and * remaining work so agent mode can execute the accepted plan. */ purpose?: "default" | "plan-implement" | undefined; } /** User message fed to the summarizer model. */ export declare function buildCompactionUserPrompt(parts: CompactionPromptParts): string; export declare function buildDirectCompactionPrompt(input: { readonly durableState?: string | undefined; readonly purpose?: "default" | "plan-implement" | undefined; }): string; /** Soft cap for transcript fed to the summarizer (chars). */ export declare const COMPACTION_TRANSCRIPT_CHAR_BUDGET = 48000; /** * A compaction is a compression operation, not a reasoning task. The final * memory is required to carry mechanism-level detail (per the prompts above), * so its allowance must comfortably exceed the ~1400–2400 token target while * still discouraging hidden reasoning blowout. */ export declare const COMPACTION_MAX_COMPLETION_TOKENS = 12288; export declare const COMPACTION_INPUT_SAFETY_TOKENS = 4096; export declare function compactionSinglePassInputBudget(contextLimitTokens: number): number; export declare const COMPACTION_MAP_MAX_COMPLETION_TOKENS = 16384; export declare const COMPACTION_CHUNK_CHAR_BUDGET = 64000; export declare const MAX_COMPACTION_CHUNKS = 8; /** * Split the transcript into ordered chunks that together contain every * character of the input. Boundaries prefer blank lines so a message is not cut * mid-record when that is avoidable. */ export declare function chunkTranscriptForCompaction(transcript: string, chunkChars?: number, maxChunks?: number): string[]; /** Map-stage prompt: summarize one ordered region of the session. */ export declare function buildCompactionChunkPrompt(input: { readonly chunk: string; readonly index: number; readonly total: number; readonly purpose?: "default" | "plan-implement" | undefined; }): string; /** Reduce-stage prompt: merge ordered region memories into one memory. */ export declare function buildCompactionReducePrompt(input: { readonly partials: readonly string[]; readonly durableState?: string | undefined; readonly purpose?: "default" | "plan-implement" | undefined; }): string; /** Prefer head goals + tail recency when the transcript is huge. */ export declare function trimTranscriptForCompaction(transcript: string, budget?: number): string; export declare function normalizeCompactionSummary(summary: string): string; export declare function looksLikeIncompleteCompactionSummary(summary: string): boolean; export declare function isCompactionCompletionTruncated(response: { finishReason?: string | undefined; usage?: { completionTokens?: number | undefined; } | undefined; }, maxTokens: number): boolean; export declare function buildCompactionRetryPrompt(prompt: string, reason: "truncated" | "incomplete" | "reasoning-only" | "replayed"): string; export declare function looksLikeTranscriptReplay(summary: string): boolean;