/** * Maps `ScaiError` (and unknown thrown values) onto the MCP * `CallToolResult` error envelope shape consumed by every tool handler. * * Envelope: * - `isError: true` * - `content[0]`: text composed as "What happened. Why. Next." * - `structuredContent`: typed `{ code, exitCode, what, why, hint, docsUri? }` * * Both the text body and the structured content flow through * `redactStructured` so secrets that leaked into error messages never * cross the wire. */ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; import { type Remediation, type ScaiErrorCode } from "../shared/errors.js"; export interface ToolErrorEnvelope { code: ScaiErrorCode; exitCode: number; what: string; why: string; hint?: string; next: string; /** * Machine-actionable remediation when the error carries one — lets the * agent route the failure (`actor`: act itself / hand to a human / * retry) without parsing the prose `next` line. */ remediation?: Remediation; docsUri?: string; } export declare const toolResultFromError: (error: unknown) => CallToolResult;