(block: Anthropic.Messages.ToolUseBlockParam)
| 19 | * This allows the conversation to be summarized without requiring the tools parameter. |
| 20 | */ |
| 21 | export function toolUseToText(block: Anthropic.Messages.ToolUseBlockParam): string { |
| 22 | let input: string |
| 23 | if (typeof block.input === "object" && block.input !== null) { |
| 24 | input = Object.entries(block.input) |
| 25 | .map(([key, value]) => { |
| 26 | const formattedValue = |
| 27 | typeof value === "object" && value !== null ? JSON.stringify(value, null, 2) : String(value) |
| 28 | return `${key}: ${formattedValue}` |
| 29 | }) |
| 30 | .join("\n") |
| 31 | } else { |
| 32 | input = String(block.input) |
| 33 | } |
| 34 | return `[Tool Use: ${block.name}]\n${input}` |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Converts a tool_result block to a text representation. |
no test coverage detected