(cause: Cause.Cause<unknown>)
| 672 | }); |
| 673 | |
| 674 | const toMcpFailureResult = (cause: Cause.Cause<unknown>): McpToolResult => { |
| 675 | const correlationId = newCorrelationId(); |
| 676 | const defect = Cause.findDefect(cause); |
| 677 | const nativeElicitationFailed = |
| 678 | Result.isSuccess(defect) && |
| 679 | Predicate.isTagged("McpNativeElicitationTransportError")(defect.success); |
| 680 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: best-effort defect logging must tolerate non-serializable causes |
| 681 | try { |
| 682 | console.error( |
| 683 | `[executor:mcp] execute defect correlation_id=${correlationId}`, |
| 684 | Cause.pretty(cause), |
| 685 | ); |
| 686 | } catch { |
| 687 | /* ignore logger failures */ |
| 688 | } |
| 689 | const text = nativeElicitationFailed |
| 690 | ? `Native elicitation transport failed [${correlationId}]. Reconnect the MCP client and try again.` |
| 691 | : `Internal tool error [${correlationId}]`; |
| 692 | return { |
| 693 | content: [{ type: "text", text: `Error: ${text}` }], |
| 694 | structuredContent: { |
| 695 | status: "error", |
| 696 | error: text, |
| 697 | ...(nativeElicitationFailed ? { errorCode: "native_elicitation_transport_failed" } : {}), |
| 698 | }, |
| 699 | isError: true, |
| 700 | }; |
| 701 | }; |
| 702 | |
| 703 | const recoveryText = |
| 704 | "To recover, run the execute tool again with the original code; if it pauses, a fresh executionId will be issued."; |
no test coverage detected