export declare const CONNECT_ERROR_CODES: readonly ["canceled", "unknown", "invalid_argument", "deadline_exceeded", "not_found", "already_exists", "permission_denied", "resource_exhausted", "failed_precondition", "aborted", "out_of_range", "unimplemented", "internal", "unavailable", "data_loss", "unauthenticated"]; export type ConnectErrorCode = (typeof CONNECT_ERROR_CODES)[number]; export interface RpcTarget { readonly service: string; readonly method: string; } export declare function rpcLabel(target: RpcTarget): string; /** * Upper bound on how much of a server-supplied message is kept. A Connect envelope normally * carries one sentence; anything longer is a stack trace or an HTML page and only wastes the * model's context. */ export declare const MAX_SERVER_MESSAGE_CHARS = 500; /** * Removes credentials from text that came out of the HTTP layer. Node's fetch echoes a rejected * header value back in its error message, so an "invalid header value" failure would otherwise * carry the whole bearer token into a tool result. */ export declare function scrubSecrets(text: string, secrets?: readonly string[]): string; /** An error Depot returned as a Connect error envelope, or one synthesised from an HTTP status. */ export declare class DepotApiError extends Error { readonly code: ConnectErrorCode; readonly httpStatus: number; readonly rpc: string; readonly serverMessage: string | undefined; readonly retryable: boolean; /** Parsed from a `Retry-After` response header, when Depot sent one. */ readonly retryAfterMs: number | undefined; constructor(options: { code: ConnectErrorCode; httpStatus: number; rpc: string; serverMessage?: string | undefined; retryAfterMs?: number | undefined; /** Overrides the code-derived default, for failures that retrying cannot fix. */ retryable?: boolean | undefined; }); } /** A request that never produced an HTTP response: DNS failure, TLS failure, timeout, offline. */ export declare class DepotTransportError extends Error { readonly rpc: string; readonly retryable = true; /** True when the request was cut short by the per-request timeout rather than by the network. */ readonly timedOut: boolean; /** * @param secrets Values that must never appear in the message; the token, at minimum. Only the * message is scrubbed: `cause` keeps the original error for stderr diagnostics and must not * be forwarded to the client. */ constructor(rpc: string, cause: unknown, secrets?: readonly string[]); } export type DepotRequestError = DepotApiError | DepotTransportError; export declare function isDepotRequestError(value: unknown): value is DepotRequestError; /** * `Retry-After` is either a delay in seconds or an HTTP-date. Returns milliseconds, or * undefined when the header is absent or unparseable. */ export declare function parseRetryAfter(header: string | null | undefined, now?: number): number | undefined; export declare function parseConnectError(target: RpcTarget, httpStatus: number, rawBody: string, retryAfterMs?: number, secrets?: readonly string[]): DepotApiError; /** * Turn a failed request into something an agent can act on, rather than a raw error envelope. * Never includes the token or any request header. */ export declare function formatDepotError(error: unknown): string; //# sourceMappingURL=errors.d.ts.map