import { WorkflowError } from "@automatalabs/shared-types"; import type { AuthMethod } from "@agentclientprotocol/sdk"; import type { Backend, ProviderErrorMetadata } from "./backend.js"; import type { TypedSessionFailure } from "./typed-failures.js"; export declare const ACP_AUTH_REQUIRED_ERROR_CODE = -32000; export interface ErrorMapContext { label?: string; backendId?: string; backend?: Backend; providerErrorMetadata?: ProviderErrorMetadata; authMethods?: readonly AuthMethod[]; } export declare function errorText(error: unknown): string; /** Map any thrown error from the run path onto a seam-level WorkflowError. */ export declare function mapThrownError(error: unknown, labelOrContext?: string | ErrorMapContext): WorkflowError; /** * Map a NEGOTIATED codex-acp typed session failure (see typed-failures.ts) onto the same seam * contract `mapThrownError` produces for the legacy channel. The typed payload is the PRIMARY * signal: `category` (plus `actions`, the finest recoverability signal now that `retryable` is * gone) selects the code and recoverability, so nothing here reads provider prose. `actions` still * ride `details` (machine-readable) and the message suffix (human-readable) as well. * * The codes and why (categories per the server's `SESSION_FAILURE_POLICY`): * • access -> AUTH_REQUIRED. Auth / sign-in (the former `auth_required`). * Byte-equivalent to the legacy path, where the server raised `RequestError.authRequired` * (-32000); the machine surface (`authContext`) and message shape use the same helpers. * • limit -> PROVIDER_USAGE_LIMIT, EXCEPT a context/budget ceiling. `limit` * collapses rate/quota (the two conditions CodexBackend.classifyProviderError already walls on, * `usageLimitExceeded` and an HTTP 429) with context/budget exhaustion. The former resume * ("non-recoverable => the engine PAUSES and resumes", stronger than retrying back into the * same wall); the latter cannot clear on resume, and the server flags exactly those with a * `new_session` action, so they fail fast instead of pausing into an unwinnable loop. * `providerCode` carries the typed category; the raw `codexErrorInfo` discriminant the legacy * path reported is deliberately withheld from this sanitized channel. * • request -> AGENT_EXECUTION_ERROR non-recoverable. The request itself was * rejected (the former policy_denied / bad_request): re-running it changes nothing. * • connection | service | anything else -> AGENT_EXECUTION_ERROR with * `recoverable = actions.includes("retry")`. Transport loss and provider/overload/internal * faults the server still marks `retry` are retried; anything it does not is a hard stop. An * UNRECOGNIZED category from a newer server lands here too and is classified by `actions` alone. */ export declare function mapTypedSessionFailure(failure: TypedSessionFailure, context?: ErrorMapContext): WorkflowError; //# sourceMappingURL=errors-map.d.ts.map