export type RawHttpRequestDump = { provider: string; api: string; model: string; method?: string; url?: string; headers?: Record; body?: unknown; diagnostics?: Record; }; export type CapturedHttpErrorResponse = { status: number; headers?: Headers; bodyText?: string; bodyJson?: unknown; }; /** Whether `message` (from a 400 response) signals an unavailable/unknown model. */ export declare function isModelUnavailableError(message: string, error: unknown): boolean; /** Actionable guidance for selecting an available model/provider. */ export declare function formatModelUnavailableGuidance(dump: RawHttpRequestDump | undefined): string; /** Directory holding the retained HTTP 400 dumps. */ export declare function httpRequestDumpDir(): string; /** * Drop the oldest dumps beyond the cap. Best-effort: diagnostics must never turn * a request failure into a second failure, so every step swallows its error. * * File names are `${Date.now()}-${hash}.json`, so a lexical sort is chronological * for the millisecond timestamps this writer produces. */ export declare function pruneHttpRequestDumps(dir?: string): Promise; export declare function appendRawHttpRequestDumpFor400(message: string, error: unknown, dump: RawHttpRequestDump | undefined): Promise; /** * Name the failed connection when the request never produced an HTTP status. * * Bun raises DNS and socket failures as a bare `Error` whose message is a * standalone hint ("Was there a typo in the url or port?", "Unable to connect. * Is the computer able to access the url?") while the actionable facts live on * `code` and `path`. Those properties are dropped when only `message` reaches * the assistant message, so a provider outage, a local DNS failure, and a * mistyped custom base URL all render as the same context-free sentence. * Appending the code and the target URL tells the user which host failed and * whether the fault is theirs. */ export declare function appendTransportFailureContext(message: string, error: unknown, rawRequestDump: RawHttpRequestDump | undefined): string; export declare function finalizeErrorMessage(error: unknown, rawRequestDump: RawHttpRequestDump | undefined, capturedErrorResponse?: CapturedHttpErrorResponse): Promise; export declare function withHttpStatus(error: unknown, status: number): Error; /** * Rewrite error message for GitHub Copilot request failures. * Must run AFTER finalizeErrorMessage since it replaces the message entirely. * * 400 `model_not_supported` = Copilot routing rollout gap for our OAuth client. * A preview model (gpt-5.3-OpenAI code backend, gpt-5.4*, ...) flaps between 200 and * 400 because only some of Copilot's backends have the model. After the * in-request retry exhausts, surface guidance rather than the raw error. * 401 = token invalid/expired → credential removal is safe, prompt re-login. * 403 = token valid but access denied (plan, model policy, org restriction) → * do NOT reuse the auth-failed string (which triggers credential removal). */ export declare function rewriteCopilotError(errorMessage: string, error: unknown, provider: string): string;