(args, context: ToolUseContext)
| 284 | |
| 285 | export function getComputerUseMCPToolOverrides(toolName: string): ComputerUseMCPToolOverrides { |
| 286 | const call: CallOverride = async (args, context: ToolUseContext) => { |
| 287 | currentToolUseContext = context; |
| 288 | const { dispatch } = getOrBind(); |
| 289 | |
| 290 | const { telemetry, ...result } = await dispatch(toolName, args); |
| 291 | |
| 292 | if (telemetry?.error_kind) { |
| 293 | logForDebugging(`[Computer Use MCP] ${toolName} error_kind=${telemetry.error_kind}`); |
| 294 | } |
| 295 | |
| 296 | // MCP content blocks → Anthropic API blocks. CU only produces text and |
| 297 | // pre-sized JPEG (executor.ts computeTargetDims → targetImageSize), so |
| 298 | // unlike the generic MCP path there's no resize needed — the MCP image |
| 299 | // shape just maps to the API's base64-source shape. The package's result |
| 300 | // type admits audio/resource too, but CU's handleToolCall never emits |
| 301 | // those; the fallthrough coerces them to empty text. |
| 302 | const data = Array.isArray(result.content) |
| 303 | ? result.content.map(item => |
| 304 | item.type === 'image' |
| 305 | ? { |
| 306 | type: 'image' as const, |
| 307 | source: { |
| 308 | type: 'base64' as const, |
| 309 | media_type: item.mimeType ?? detectImageFormatFromBase64(item.data), |
| 310 | data: item.data, |
| 311 | }, |
| 312 | } |
| 313 | : { |
| 314 | type: 'text' as const, |
| 315 | text: item.type === 'text' ? item.text : '', |
| 316 | }, |
| 317 | ) |
| 318 | : result.content; |
| 319 | return { data }; |
| 320 | }; |
| 321 | |
| 322 | return { |
| 323 | ...getComputerUseMCPRenderingOverrides(toolName), |
nothing calls this directly
no test coverage detected