import { type GenerationAttemptMode, type GenerationAttemptOutcome, type GenerationAttemptReason, type ProviderId } from "../types.js"; import type { OperationUsageSnapshot } from "./operation-usage.js"; import type { ContextUsageSnapshot } from "./token-usage.js"; export declare const CONTEXT_SNAPSHOT_VERSION: 1; export type ContextSnapshotScope = "provider-request" | "assembled-request" | "message-history" | "unknown"; export type ContextSnapshotPrecision = "provider-exact" | "estimate" | "unknown"; export type ContextLimitSource = "session-override" | "model-catalog" | "configured-trigger" | "provider-reported" | "unknown"; export interface ContextSnapshotLimit { readonly source: ContextLimitSource; readonly tokens?: number | undefined; } export type ContextSnapshotHeadroom = { readonly kind: "known"; readonly remainingTokens: number; readonly effectiveTriggerTokens?: number | undefined; readonly outputReserveTokens?: number | undefined; readonly safetyMarginTokens?: number | undefined; } | { readonly kind: "unknown"; }; export type ContextSnapshotCache = { readonly kind: "unknown"; } | { readonly kind: "reported"; readonly readTokens?: number | undefined; readonly creationTokens?: number | undefined; readonly uncachedTokens?: number | undefined; }; export type ContextSnapshotReasoning = { readonly kind: "unknown"; } | { readonly kind: "reported"; readonly outputTokens?: number | undefined; readonly inputArtifactTokens?: number | undefined; }; export type ContextAttemptReference = { readonly kind: "unavailable"; } | { readonly kind: "generation"; readonly sequence: number; readonly provider: ProviderId; readonly model: string; readonly mode: GenerationAttemptMode; readonly reason: GenerationAttemptReason; readonly outcome: GenerationAttemptOutcome; }; export interface ContextSnapshotV1 { readonly version: typeof CONTEXT_SNAPSHOT_VERSION; readonly contextTokens: number; readonly lastCompletionTokens: number; readonly sessionPromptTokens: number; readonly sessionCompletionTokens: number; readonly scope: ContextSnapshotScope; readonly precision: ContextSnapshotPrecision; readonly limit: ContextSnapshotLimit; readonly headroom: ContextSnapshotHeadroom; readonly cache: ContextSnapshotCache; readonly reasoning: ContextSnapshotReasoning; readonly attempt: ContextAttemptReference; readonly observedAt: number; } export interface CreateContextSnapshotInput { readonly contextTokens: number; readonly lastCompletionTokens?: number | undefined; readonly sessionPromptTokens?: number | undefined; readonly sessionCompletionTokens?: number | undefined; readonly scope: ContextSnapshotScope; readonly precision: ContextSnapshotPrecision; readonly limit?: ContextSnapshotLimit | undefined; readonly headroom?: ContextSnapshotHeadroom | undefined; readonly cache?: ContextSnapshotCache | undefined; readonly reasoning?: ContextSnapshotReasoning | undefined; readonly attempt?: ContextAttemptReference | undefined; readonly observedAt?: number | undefined; } export declare function createContextSnapshot(input: CreateContextSnapshotInput): ContextSnapshotV1; export declare function toLegacyContextUsage(snapshot: ContextSnapshotV1): ContextUsageSnapshot; export declare function contextLimitFromSessionOverride(tokens: number | undefined): ContextSnapshotLimit; export declare function withContextSnapshotLimit(snapshot: ContextSnapshotV1, limit: ContextSnapshotLimit): ContextSnapshotV1; export declare function contextSnapshotFromLegacy(snapshot: ContextUsageSnapshot, limit: ContextSnapshotLimit, observedAt?: number | undefined): ContextSnapshotV1; export declare function isContextSnapshotV1(value: unknown): value is ContextSnapshotV1; export declare function contextAttemptFromOperationUsage(operationUsage: OperationUsageSnapshot | undefined): ContextAttemptReference;