import type { TSchema } from "typebox"; /** Truncate a long error to head + "[N characters truncated]" + tail (design/64 §11.2, CC parity). */ export declare function truncateError(s: string): string; /** * Format a thrown tool error into model-facing text (design/64 §11.1/§11.2): a shell/exec error becomes * `Exit code N` + stderr + stdout; a plain Error becomes its message (+ any captured streams); anything * else is stringified. The result is truncated to {@link MAX_ERROR_CHARS}. An AbortError is reported as an * interruption. */ export declare function formatToolError(error: unknown): string; /** * A typed, read-side fold of a `TaskResult.errorCode` into the failure CLASS it belongs to (design/80 * D-G data contract; the WorkerReport "errorClass" small-slice). A terminal `errorCode` (1.37+) is a * **dotted namespace** (`budget.precall` / `budget.exceeded` / `limit.max_turns` / `output.invalid` …) * so a consumer can prefix-match a whole CLASS — but every aggregator/consumer hand-rolls * `errorCode.startsWith("budget.")` (types.ts:707 documents this very pattern), which silently * mis-classifies any code that does NOT follow the convention and drifts as new prefixes are added. * This is the single shared folder. * * - `budget` — the cost/token budget gate fired (`budget.precall` / `budget.exceeded`). * - `limit` — a hard run limit fired (`limit.max_turns` / `limit.timeout`). * - `output` — the structured/answer output was rejected (`output.invalid` / `output.degenerate`). * - `suspend` — the suspend-loop cap fired (`suspend.loop`); a TERMINAL failure, distinct from a * resumable `suspended` status (which carries no errorCode). * - `review` — a review-pause terminal (`review.pending`). * - `unexpected` — a nested orchestrator mapped an unexpected durable pause to failed * (`unexpected.suspended` / `unexpected.needs_review`, design/45 §11 Q6 / design/80 D-B). * - `oracle` — a verifier/oracle invariant breach (`oracle.unprotected`). * - `resume` — a post-CAS resume/restore infrastructure failure (`resume.env_failed` / * `resume.tool_unavailable`, design/45/49); a RETRYABLE basis (the work is still pending, * the checkpoint is reopenable) — distinct from a logical failure, so consumers can retry. * - `config` — a task-spec / assembly rejection raised in `prepare()` (`config.egress_requires_write_effect` * / `config.reserved_tool_name`); a deterministic configuration error (re-running the same * spec re-fails) — never retryable, surfaces a malformed request. * - `conflict` — a cross-instance optimistic-lock loss (flat `"conflict"`, unchanged 1.36 code). * - `brain` — a model/transport failure lifted from the brain (flat `auth` / `rate_limit` / * `invalid_request` / `server` / `network` / `http`; see brain/errors.ts). * - `aborted` — a step was aborted (flat `"aborted"`). * - `unknown` — no code, or a code outside every known class (the safe catch-all). */ export type WorkerErrorClass = "budget" | "limit" | "output" | "suspend" | "review" | "unexpected" | "oracle" | "resume" | "config" | "conflict" | "brain" | "aborted" | "unknown"; /** * Fold a {@link "../core/types.js".TaskResult}.`errorCode` into its typed {@link WorkerErrorClass} (design/80 * D-G). PURE and DERIVED — it reads an existing code, never produces or changes one; an unknown / missing * code folds to `"unknown"` (never throws). Replaces scattered `errorCode.startsWith("budget.")` consumer * code with one tested folder so the class taxonomy lives in exactly one place. * * SCOPE: this folds a TERMINAL `TaskResult.errorCode` only — i.e. every OUR dotted prefix that the runner can * assemble into a failed task outcome (`budget.`/`limit.`/`output.`/`suspend.`/`review.`/`unexpected.`/ * `oracle.`/`resume.`/`config.`) plus the flat 1.36 codes. Operation-level dotted codes that are surfaced to * a *caller* and never become a task outcome are deliberately OUT of scope: `steering.*` * (`steering.not_running`/`steering.invalid_content`, rejected to the `steer()` caller) and `mcp.*` * (`mcp.server_unavailable`, an `onWarn` warning code) — neither reaches `TaskResult.errorCode`, so a caller * will never pass them here. A genuinely unmapped code → `"unknown"` (which therefore means "known-but-foreign * or no code", e.g. a leaked fs/Node code, NOT "an OUR terminal class we forgot to add"). */ export declare function errorClassOf(errorCode: string | undefined): WorkerErrorClass; /** * Convert a TypeBox/JSON-Schema error path (`/todos/0/activeForm`) into a readable accessor * (`todos[0].activeForm`), CC `formatValidationPath` parity. Numeric segments become `[i]`, named * segments become `.name`. Empty path → "" (the root object). */ export declare function formatValidationPath(path: string): string; /** * Turn a schema-validation failure into a human-readable message (design/64 §11.3 / §16.4). Reports the * parameter NAME + the expected type only — never an absolute path, stack trace, or filesystem context, so * a validation message can't leak internals (§16.4). Examples: * - "The required parameter `todos` is missing." * - "The parameter `questions[0].options` is invalid: Expected array." */ export declare function formatZodValidationError(schema: TSchema, value: unknown): string; //# sourceMappingURL=tool-errors.d.ts.map