/**
 * Per-step context budget guard for the AI-SDK agent loop.
 *
 * Pre-call budgeting (`checkContextBudget` + compaction) runs ONCE before
 * dispatch and only sees the input/session conversation. The AI-SDK tool loop
 * then appends assistant turns and tool results on every step — growth the
 * pre-call pipeline never sees, which is how long agentic runs overflow the
 * model's real context window mid-loop (provider 400s after dozens of tool
 * calls). The googleVertex native loops already guard this via
 * `createContextGuard`; this module brings the AI-SDK path (every provider
 * that delegates to `generateText`) to parity — and goes one step further:
 * instead of stopping the loop, it deterministically reclaims budget so the
 * loop can CONTINUE.
 *
 * Wired in `GenerationHandler.callGenerateText` through
 * `experimental_prepareStep`, whose result may replace the step's `messages`.
 * The guard operates on `ModelMessage[]` natively (no lossy ChatMessage
 * round-trip) and never makes LLM calls:
 *
 *   Stage 1 — truncate OLD tool outputs to head/tail previews
 *             (`generateToolOutputPreview`), oldest first, outside the
 *             protected recent tail.
 *   Stage 2 — drop the oldest complete tool exchanges (assistant tool-call
 *             message + its following tool-result messages, as a unit, so
 *             call/result pairing stays intact), replacing them with a single
 *             elision note.
 *
 * The system prompt and tool definitions ride OUTSIDE the step messages (the
 * handler hoists system into generateText's `system` option), so their cost is
 * passed in as `fixedOverheadTokens`. The first user message (the task) and
 * the most recent messages are never touched.
 */
import type { ModelMessage, StepBudgetGuardConfig } from "../types/index.js";
/** Estimate the token cost of a step's message array. */
export declare function estimateStepMessagesTokens(messages: readonly ModelMessage[], provider?: string): number;
/**
 * Estimate the fixed per-request overhead: hoisted system prompt + tool
 * definitions. Mirrors `checkContextBudget`'s categories for the pieces that
 * do not live in the step messages.
 */
export declare function estimateFixedOverheadTokens(system: unknown, tools: Record<string, unknown> | undefined, provider?: string): number;
/**
 * Create a per-step budget guard. Returns a function that, given the step's
 * messages (and optionally the REAL input-token count the provider reported
 * for the previous step), returns a compacted replacement array when the
 * projected request exceeds the threshold — or `undefined` when no change is
 * needed.
 *
 * Two dynamic behaviours:
 *  - the available-input budget is re-resolved on EVERY invocation, so
 *    runtime window discovery (`/model/info`, overflow self-healing) that
 *    lands mid-loop takes effect immediately instead of the guard staying
 *    frozen on the value captured at loop start;
 *  - usage feedback calibrates the estimator: the ratio between the real
 *    prompt tokens of the previous step and this guard's own estimate for
 *    what that step sent scales later estimates (only UP — underestimates
 *    overflow, overestimates merely compact earlier), eliminating the
 *    char-based estimator's drift on dense code/diff content without
 *    shipping a tokenizer.
 */
export declare function createStepBudgetGuard(config: StepBudgetGuardConfig): (messages: readonly ModelMessage[], observedInputTokensLastStep?: number) => ModelMessage[] | undefined;
