{"version":3,"file":"tool-execution-error.mjs","names":[],"sources":["../../../../../../../ai/src/errors/tool-execution-error.ts"],"sourcesContent":["import { AIError, type AIErrorOptions } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\n\n/**\n * Payload passed to `ToolExecutionError` — identifies which tool\n * failed and, when applicable, which trip it was dispatched from.\n */\nexport type ToolExecutionErrorOptions = AIErrorOptions & {\n  toolName: string;\n  tripIndex?: number;\n};\n\n/**\n * A registered tool's `execute()` threw during dispatch — the tool\n * code itself failed (not its input schema). The model's request was\n * valid; the implementation crashed.\n *\n * Carries `toolName` so consumers can branch on which tool failed\n * without regex-parsing the message, and `tripIndex` to correlate\n * with the `LLMTrip` entry in `result.report.trips`.\n *\n * @example\n * if (result.error instanceof ToolExecutionError) {\n *   metrics.increment(\"tool.failure\", { tool: result.error.toolName });\n * }\n */\nexport class ToolExecutionError extends AIError {\n  public static readonly defaultCategory: ErrorCategory = \"tool\";\n\n  public readonly toolName: string;\n  public readonly tripIndex?: number;\n\n  public constructor(message: string, options: ToolExecutionErrorOptions) {\n    super(\"TOOL_EXEC_FAILED\", message, options);\n    this.name = \"ToolExecutionError\";\n    this.toolName = options.toolName;\n    this.tripIndex = options.tripIndex;\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,IAAa,qBAAb,cAAwC,QAAQ;;yBACU;;CAKxD,AAAO,YAAY,SAAiB,SAAoC;EACtE,MAAM,oBAAoB,SAAS,OAAO;EAC1C,KAAK,OAAO;EACZ,KAAK,WAAW,QAAQ;EACxB,KAAK,YAAY,QAAQ;CAC3B;AACF"}