(args, context: ToolUseContext)
| 247 | }; |
| 248 | export function getComputerUseMCPToolOverrides(toolName: string): ComputerUseMCPToolOverrides { |
| 249 | const call: CallOverride = async (args, context: ToolUseContext) => { |
| 250 | currentToolUseContext = context; |
| 251 | const { |
| 252 | dispatch |
| 253 | } = getOrBind(); |
| 254 | const { |
| 255 | telemetry, |
| 256 | ...result |
| 257 | } = await dispatch(toolName, args); |
| 258 | if (telemetry?.error_kind) { |
| 259 | logForDebugging(`[Computer Use MCP] ${toolName} error_kind=${telemetry.error_kind}`); |
| 260 | } |
| 261 | |
| 262 | // MCP content blocks → Anthropic API blocks. CU only produces text and |
| 263 | // pre-sized JPEG (executor.ts computeTargetDims → targetImageSize), so |
| 264 | // unlike the generic MCP path there's no resize needed — the MCP image |
| 265 | // shape just maps to the API's base64-source shape. The package's result |
| 266 | // type admits audio/resource too, but CU's handleToolCall never emits |
| 267 | // those; the fallthrough coerces them to empty text. |
| 268 | const data = Array.isArray(result.content) ? result.content.map(item => item.type === 'image' ? { |
| 269 | type: 'image' as const, |
| 270 | source: { |
| 271 | type: 'base64' as const, |
| 272 | media_type: item.mimeType ?? 'image/jpeg', |
| 273 | data: item.data |
| 274 | } |
| 275 | } : { |
| 276 | type: 'text' as const, |
| 277 | text: item.type === 'text' ? item.text : '' |
| 278 | }) : result.content; |
| 279 | return { |
| 280 | data |
| 281 | }; |
| 282 | }; |
| 283 | return { |
| 284 | ...getComputerUseMCPRenderingOverrides(toolName), |
| 285 | call |
nothing calls this directly
no test coverage detected