import type { SessionEvent, SessionStatus } from "@opengeni/sdk"; import { type OpenGeniText } from "../messages/runtime.js"; /** * Finite same-turn provider recovery, projected for people. Presentation only: * the worker owns retry authority, pacing and the recovery budget. The worker * (`apps/worker/src/activities/agent-turn/provider-recovery-copy.ts`) writes * the same exhausted sentence into `turn.failed.error`; keep the two in step. */ export type ProviderRecoveryCondition = "overloaded" | "unavailable" | "unresponsive" | "rate_limited"; export type ProviderRecoveryFacts = { /** Recorded worker failure code (`provider_unavailable`, `mcp_transport_timeout`, ...). */ code: string; condition: ProviderRecoveryCondition | null; /** Display label of the affected model, when the route was recorded. */ modelLabel: string | null; /** Display label of the serving provider, when the route was recorded. */ providerLabel: string | null; /** Automatic retries scheduled (live) or spent (exhausted). */ attempt: number | null; /** Finite automatic retry budget. */ maxAttempts: number | null; /** True when the model route itself is affected, so another model may help. */ modelRoute: boolean; /** True while the turn waits for its sandbox to be saved and replaced. It * has no retry budget: it resumes as soon as the successor box is ready. */ sandboxWait?: boolean; /** Recorded lifecycle fence of a sandbox wait (`capture_in_progress`, * `rotation_in_progress`, `provider_recovery_in_progress`), when known. */ sandboxTransition?: string | null; }; /** * Read a retryable `turn.recovery.requested` payload or an exhausted * `turn.failed` payload. Returns null for every other recovery reason (human * Retry, worker shutdown, credential rotation, capacity waits, ...). */ export declare function parseProviderRecovery(payload: unknown): ProviderRecoveryFacts | null; /** One present-tense clause naming what is unavailable, without a trailing period. */ export declare function providerRecoverySubject(t: OpenGeniText, facts: ProviderRecoveryFacts): string; /** Live status while the same turn waits for its next automatic retry. */ export declare function providerRecoveryRetryingText(t: OpenGeniText, facts: ProviderRecoveryFacts): string; /** Terminal sentence once the automatic budget is spent. */ export declare function providerRecoveryExhaustedText(t: OpenGeniText, facts: ProviderRecoveryFacts): string; /** * The active turn's current automatic provider retry, or null. Only a * `recovering`, unpaused session qualifies, and only the newest boundary of its * exact active turn counts, so merged or replayed pages never borrow another * turn's diagnosis. */ export declare function currentProviderRecovery(session: { id: string; status: SessionStatus | null | undefined; activeTurnId: string | null | undefined; effectiveControl?: { state: string; } | null | undefined; }, events: readonly SessionEvent[]): ProviderRecoveryFacts | null;