/** * Compaction support: summarizer model selection (#30 cost guard), request-auth resolution * with session-model fallback, and window-adapted compaction settings. * * This is the policy half of compaction. CompactionController owns detection, execution, retry, * persistence, notification, and cancellation; AgentSession keeps compatibility delegations at * established regression seams. */ import { type CompactionSettings } from "@caupulican/pi-agent-core/compaction/compaction"; import type { ThinkingLevel } from "@caupulican/pi-agent-core/types"; import type { Api, Model } from "@caupulican/pi-ai"; import type { ModelRegistry } from "./model-registry.ts"; import type { RequestAuth } from "./request-auth.ts"; import type { ModelFitnessReport } from "./research/model-fitness.ts"; import type { SettingsManager } from "./settings-manager.ts"; export interface CompactionSupportDeps { getModel(): Model | undefined; getSettingsManager(): SettingsManager; getModelRegistry(): ModelRegistry; /** True when the agent's streamFn is (or wraps) the raw streamSimple — auth must be explicit then. */ isRawStream(): boolean; /** Host auth resolution that THROWS with a user-actionable message when no key exists. */ getRequiredRequestAuth(model: Model): Promise; isModelExhausted(ref: string): boolean; getStoredFitnessReport(ref: string): ModelFitnessReport | undefined; /** Estimated tokens of the summarization input (live context; over-estimates, which is safe). */ estimateSummarizationInputTokens(): number; emitWarning(message: string): void; /** * The same readiness/residency gate every other isolated consumer uses * (LocalRuntimeController.ensureIsolatedModelReady) before this model is used for an * out-of-band call. No-ops for a non-managed-local model (checked internally by the gate); * throws with a user-actionable reason when a managed-local model cannot be made ready. */ ensureModelReady(model: Model): Promise; } export declare class CompactionSupport { private readonly deps; private lastSelectionReason; constructor(deps: CompactionSupportDeps); getLastSelectionReason(): string | undefined; getAdaptedSettings(): CompactionSettings; getRequestAuth(model: Model): Promise; /** * Readiness/residency gate a candidate summarizer model right before it is handed back for * use. A no-op for a non-managed-local model (checked internally by * {@link CompactionSupportDeps.ensureModelReady}); a managed-local model that cannot be made * ready (server down, model missing, residency refused) returns its failure reason instead of * throwing, so callers can still try the next candidate in the existing auth-fallback ladder * rather than aborting resolution outright. */ private readinessFailure; /** * Resolve the summarizer model AND its request auth for auto-compaction. The cheap auxiliary * model (#30) can be nominally available yet fail key resolution at request time (expired * OAuth, revoked key) — or, for a managed-local model, fail the readiness/residency gate ( * server down, model not installed, residency refused). Falling back to the session model keeps * auto-compaction working in exactly the situations where manual /compact works; only when * neither resolves do we fail — and then with a concrete message instead of a silent no-op or a * bypass of the readiness gate. */ resolveModelAndAuth(compactionModel: Model, sessionModel: Model): Promise<{ model: Model; apiKey?: string; headers?: Record; failure?: string; }>; private getExplicitCompactionModelSetting; private modelRef; private resolveConfiguredModel; private selectConfiguredModel; private effectiveContextWindow; private modelWithEffectiveWindow; private resolveDefaultModel; private modelsAreEqual; /** * Resolve the model used to SUMMARIZE during compaction. Selection: * - an explicit `compaction.model` setting wins, but only if its provider is authed (else fall back); * - `"auto"`/unset follows the model router's configured cheap model when the router is enabled; * - otherwise the session model is used (safe default). */ resolveModel(sessionModel: Model): Model; /** Default compaction should never inherit expensive session thinking. */ resolveThinkingLevel(sessionThinkingLevel: ThinkingLevel | undefined, compactionModel: Model, sessionModel: Model): ThinkingLevel | undefined; } //# sourceMappingURL=compaction-support.d.ts.map