import { CURATION_COMPACTION_DIGEST_SYSTEM_PROMPT, CURATION_DIGEST_SYSTEM_PROMPT, CURATION_RELEVANCE_SYSTEM_PROMPT } from "../provider-prompt-contracts.ts"; export { CURATION_COMPACTION_DIGEST_SYSTEM_PROMPT, CURATION_DIGEST_SYSTEM_PROMPT, CURATION_RELEVANCE_SYSTEM_PROMPT }; /** * Brain-assisted context curation (see docs/model-router-rework/brain-context-curation-design.md): * a SIDECAR curator that consumes reports the context pipeline already produces and feeds back * small, typed advisories. It is never a pipeline stage: every consumer must behave byte-for-byte * identically when a result is absent (missing digest -> today's stub; missing relevance -> * today's enforcement decision). The curator itself is provider-free — the completion executor is * injected per drain, so it works against any registered local model and faux providers in tests. * * Memory bounds are explicit: the queue and result map are both capped, and drops are counted in * telemetry rather than silent. Results are keyed for idempotency (digests by the GC record's * content hash, relevance by the audit item id), so re-enqueueing the same work is free. */ export declare function parseCompactionChunkDigest(text: string): string | undefined; export interface PreDigestResult { text: string; totalChunks: number; digested: number; failed: number; } /** * Compaction pre-digest (design surface 3): shrink the conversation text sent to the frontier * summarizer by digesting OLD chunks locally, keeping the recent tail verbatim. Chunk digestion * is mechanical extraction — the frontier model still writes the summary. Partial assist, never * partial loss: any chunk whose digest fails (parse/timeout) passes through verbatim. */ export declare function preDigestConversationText(args: { text: string; complete: CurationComplete; signal?: AbortSignal; chunkChars?: number; keepRecentChars?: number; }): Promise; export interface CurationJob { kind: "stub_digest" | "relevance"; /** Idempotency key: digest jobs use the GC record's content hash, relevance jobs the item id. */ key: string; /** Bounded chunk the local model must actually be able to process (sliced on enqueue). */ content: string; /** Relevance jobs only: the goal/intent line the chunk is judged against. */ goal?: string; } export interface CurationResult { key: string; kind: CurationJob["kind"]; ok: boolean; /** Raw model-parsed digest (stub_digest jobs only): human-readable, NOT fenced. Kept as-is for * logging/audit (e.g. the session's brain-curation entry) — never render this into a provider * prompt; use `fencedDigest` (via getDigest) for that. */ digest?: string; /** The same digest fenced in the untrusted-content boundary, wrapped exactly ONCE here at store * time (not at every context-gc render), so the fence's nonce is fixed for the life of this * result — every render of it is then byte-identical, keeping the provider's prompt-prefix cache * warm. This is what getDigest() returns and what context-gc renders verbatim into a packed stub. */ fencedDigest?: string; relevant?: boolean; confidence?: number; ms: number; } export interface CurationTelemetrySnapshot { jobsRun: number; parseFailures: number; droppedJobs: number; /** Times a computed digest was actually RENDERED into a GC stub on a real turn — the * pays-for-itself proxy: every serve is packed content the frontier model got a semantic * handle on without re-running tools. */ digestsServed: number; /** Chars processed locally (an honest proxy for frontier tokens NOT spent on this work). */ localChars: number; queued: number; resultsHeld: number; } export type CurationComplete = (input: { systemPrompt: string; userPrompt: string; signal?: AbortSignal; }) => Promise<{ text: string; costUsd: number; stopReason: string; }>; export declare const CURATION_RELEVANCE_MIN_CONFIDENCE = 0.8; export declare function parseCurationDigest(text: string): string | undefined; export declare function parseCurationRelevance(text: string): { relevant: boolean; confidence: number; } | undefined; export declare class BrainCurator { private readonly _queue; private readonly _results; private _jobsRun; private _parseFailures; private _droppedJobs; private _localChars; private _digestsServed; private _draining; enqueue(job: CurationJob): void; /** Returns the digest already fenced in the untrusted-content boundary — callers must render it * verbatim into a provider prompt, never re-wrap it (see CurationResult.fencedDigest for why). */ getDigest(key: string): string | undefined; /** Callers report when a digest was rendered into a real (sent) prompt stub. */ noteDigestServed(): void; getRelevance(key: string): { relevant: boolean; confidence: number; } | undefined; hasWork(): boolean; get isDraining(): boolean; telemetry(): CurationTelemetrySnapshot; /** * Run up to `maxJobs` queued jobs through the injected local-model completer. Single-flight: * a concurrent drain call returns [] immediately rather than double-running jobs. Every call * is wall-clock bounded; a failed/unparseable job is recorded as a not-ok result (so it is * not retried forever) and counted in telemetry. */ drain(args: { complete: CurationComplete; maxJobs: number; signal?: AbortSignal; now?: () => number; }): Promise; private _storeResult; } //# sourceMappingURL=brain-curator.d.ts.map