( result: FormattedExecuteInput, output: readonly ExecuteOutputItem[], )
| 395 | }; |
| 396 | |
| 397 | const toMcpOutputResult = ( |
| 398 | result: FormattedExecuteInput, |
| 399 | output: readonly ExecuteOutputItem[], |
| 400 | ): McpToolResult => { |
| 401 | const formatted = formatExecuteResult(result); |
| 402 | const content = output.flatMap(outputItemContent); |
| 403 | const extraText: string[] = []; |
| 404 | if (result.error) { |
| 405 | extraText.push(formatted.text); |
| 406 | } else if (result.logs && result.logs.length > 0) { |
| 407 | extraText.push(`Logs:\n${result.logs.join("\n")}`); |
| 408 | } |
| 409 | content.push(...extraText.map((text): ContentBlock => ({ type: "text", text }))); |
| 410 | |
| 411 | return { |
| 412 | content, |
| 413 | structuredContent: formatted.structured, |
| 414 | isError: formatted.isError || undefined, |
| 415 | }; |
| 416 | }; |
| 417 | |
| 418 | const toMcpResult = (result: FormattedExecuteInput): McpToolResult => { |
| 419 | if (result.output && result.output.length > 0) return toMcpOutputResult(result, result.output); |
no test coverage detected