( result: FormattedExecuteInput, output: readonly ExecuteOutputItem[], )
| 566 | }; |
| 567 | |
| 568 | const toMcpOutputResult = ( |
| 569 | result: FormattedExecuteInput, |
| 570 | output: readonly ExecuteOutputItem[], |
| 571 | ): McpToolResult => { |
| 572 | const formatted = formatExecuteResult(result); |
| 573 | const content = output.flatMap(outputItemContent); |
| 574 | const extraText: string[] = []; |
| 575 | if (result.error) { |
| 576 | extraText.push(formatted.text); |
| 577 | } else if (result.logs && result.logs.length > 0) { |
| 578 | extraText.push(`Logs:\n${result.logs.join("\n")}`); |
| 579 | } |
| 580 | content.push(...extraText.map((text): ContentBlock => ({ type: "text", text }))); |
| 581 | |
| 582 | return { |
| 583 | content, |
| 584 | structuredContent: formatted.structured, |
| 585 | isError: formatted.isError || undefined, |
| 586 | }; |
| 587 | }; |
| 588 | |
| 589 | const toMcpResult = (result: FormattedExecuteInput): McpToolResult => { |
| 590 | if (result.output && result.output.length > 0) return toMcpOutputResult(result, result.output); |
no test coverage detected