import { type SessionCompactionState } from "../../session/models/session-compaction"; import type { CoreCompactionContext, CoreCompactionMode, CoreSessionConfig } from "../../types/config"; export interface ContextPipelinePrepareTurnInput { agentId: string; conversationId: string; parentAgentId: string | null; iteration: number; messages: CoreCompactionContext["messages"]; apiMessages: CoreCompactionContext["messages"]; abortSignal: AbortSignal; systemPrompt: string; tools: unknown[]; model: CoreCompactionContext["model"]; emitStatusNotice?: (message: string, metadata?: Record) => void; } export interface ContextPipelinePrepareTurnResult { messages: CoreCompactionContext["messages"]; systemPrompt?: string; } export type ContextPipelinePrepareTurn = (context: ContextPipelinePrepareTurnInput) => Promise; export interface ContextCompactionPrepareTurnOptions { mode?: CoreCompactionMode; manualTargetRatio?: number; } /** * Build the `prepareTurn` callback used by the agent runtime to compact the * transcript before each model request. * * Telemetry: emits `task.compaction_executed` on a successful compaction and * `task.compaction_skipped` when the configured strategy returns `undefined`. * Telemetry is keyed by `config.sessionId` (falling back to the per-turn * `conversationId`) and tagged with `provider` / `modelId`. * * Known gap: compactions performed via plugin `registerMessageBuilder()` or * via the `beforeModel` runtime hook bypass this wrapper entirely, so they * do not emit compaction telemetry. If we want coverage there too, the * plugin/hook pipelines must be instrumented separately. */ export declare function createContextCompactionPrepareTurn(config: Pick, options?: ContextCompactionPrepareTurnOptions): ((context: ContextPipelinePrepareTurnInput) => Promise) | undefined; export declare function createCompactionStateAwarePrepareTurn(input: { compact?: ContextPipelinePrepareTurn; getState?: () => SessionCompactionState | undefined; saveState?: (state: SessionCompactionState) => void | Promise; }): ContextPipelinePrepareTurn;