import type { SessionFailureSummary } from "./events.js"; import { type FreeCreditGap } from "./free-credit-gap.js"; /** * Known provider failure classes. Presentation only: the stored event keeps the * exact recorded text, which the banner offers behind a details toggle. * `suggestModel` points the user at the model picker when another model avoids * the failure. `retryUnhelpful` is reserved for rejected credentials: the same * request on the same model cannot succeed until the key is fixed, so Retry * returns only once another model is selected. Billing, access and limit * failures keep Retry because the condition can clear (a top-up, a verified * organization, a daily reset). */ type KnownFailure = { /** Closed analytics class (turn-failure-analytics.ts); never shown to people. */ kind: KnownFailureKind; message: string; retryUnhelpful: boolean; suggestModel: boolean; /** * Whole headline when another model can be chosen, for transient refusals * whose remedy reads as a choice. Otherwise " Choose another model below." * is appended to `message`. */ chooseModelMessage?: string | undefined; }; export type KnownFailureKind = "provider_credentials" | "provider_billing" | "provider_access" | "daily_limit" | "monthly_limit" | "provider_quota" | "rate_limited" | "provider_error"; /** Classify known provider text; unknown failures use a separate generic headline. */ export declare function classifyProviderFailure(recorded: string, failureCode?: string | null, quotaScope?: string | null): KnownFailure | null; /** Summarize recorded evidence without guessing a provider, expiry or reset time. */ export declare function failedSessionCopy(failure: SessionFailureSummary, creditExhausted?: boolean, modelChanged?: boolean, canChooseModel?: boolean, /** Free credit remains, but not for this model: name the gap instead of an empty workspace. */ freeCreditGap?: FreeCreditGap | null): { reason: string; unavailableModel: boolean; /** Rejected credentials: Retry on the same model cannot help; offer it again once the model changes. */ retryUnhelpful?: boolean | undefined; /** Exact recorded text for a details toggle, when the headline replaced it. */ detail?: string | undefined; /** A daily allowance is spent; the banner may name the deployment's free model. */ dailyLimit?: true | undefined; /** The compaction-failure headline; the timeline's own landmark can carry it instead. */ compaction?: true | undefined; }; export {};