( result: FormattedExecuteInput, output: readonly ExecuteOutputItem[], )
| 434 | }; |
| 435 | |
| 436 | const toMcpOutputResult = ( |
| 437 | result: FormattedExecuteInput, |
| 438 | output: readonly ExecuteOutputItem[], |
| 439 | ): McpToolResult => { |
| 440 | const formatted = formatExecuteResult(result); |
| 441 | const content = output.flatMap(outputItemContent); |
| 442 | const extraText: string[] = []; |
| 443 | if (result.error) { |
| 444 | extraText.push(formatted.text); |
| 445 | } else if (result.logs && result.logs.length > 0) { |
| 446 | extraText.push(`Logs:\n${result.logs.join("\n")}`); |
| 447 | } |
| 448 | content.push(...extraText.map((text): ContentBlock => ({ type: "text", text }))); |
| 449 | |
| 450 | return { |
| 451 | content, |
| 452 | structuredContent: formatted.structured, |
| 453 | isError: formatted.isError || undefined, |
| 454 | }; |
| 455 | }; |
| 456 | |
| 457 | const toMcpResult = (result: FormattedExecuteInput): McpToolResult => { |
| 458 | if (result.output && result.output.length > 0) return toMcpOutputResult(result, result.output); |
no test coverage detected