import { type LanguageModel, type TelemetryOptions } from "ai"; import { type HarnessSession, type StepResult, type ToolLoopHarnessConfig } from "#harness/types.js"; import { type HarnessModelMessage } from "#harness/messages.js"; import type { HistoryViewProjector } from "#shared/history-view.js"; import type { Publish } from "#harness/session-machine/commit.js"; import type { SessionAuthContext } from "#channel/types.js"; import type { Step } from "#harness/step/context.js"; import { type TurnPosition } from "#harness/session-machine/view.js"; /** * Processes the step result: extracts input requests, decides whether to * park, continue the tool loop, or terminate. */ /** What a step needs from the machine after its model call. */ /** `session.compact()`: summarizes the history now, then the session waits. */ export declare function compactHistory(step: Step): Promise; export declare function replaceSessionHistory(session: HarnessSession, history: HarnessModelMessage[]): HarnessSession; /** * Runs the compaction pipeline once if the session's input-token estimate * is over the configured threshold. Mutates neither input; returns the new * messages array and (possibly updated) session. * * Kept in the tool-loop (rather than the AI SDK's `prepareStep` hook) so * the compacted messages flow through the same `messages` variable the * harness uses to rebuild `session.history` after the step. */ export declare function maybeCompact(input: { readonly abortSignal?: AbortSignal; readonly auth: SessionAuthContext | null; /** A manual compaction runs between turns, so no turn's usage reports its summary calls. */ readonly betweenTurns?: boolean; readonly emissionState: TurnPosition; readonly force?: boolean; readonly historyProjector?: HistoryViewProjector; readonly messages: HarnessModelMessage[]; readonly model: LanguageModel; readonly publish: Publish; /** Model-visible prompt used only to decide whether durable history needs compaction. */ readonly promptMessages?: readonly HarnessModelMessage[]; readonly requestEnvelopeTokens?: number; readonly resolveModel: ToolLoopHarnessConfig["resolveModel"]; readonly runtimeIdentity?: ToolLoopHarnessConfig["runtimeIdentity"]; readonly session: HarnessSession; readonly telemetry?: TelemetryOptions; }): Promise<{ readonly compacted: boolean; /** The summary failed; `session` still counts the summary calls that finished. */ readonly failure?: { readonly error: unknown; }; readonly messages: HarnessModelMessage[]; readonly session: HarnessSession; }>;