MCPcopy Index your code
hub / github.com/codeaashu/claude-code / buildImageToolResult

Function buildImageToolResult

src/tools/BashTool/utils.ts:71–91  ·  view source on GitHub ↗
(
  stdout: string,
  toolUseID: string,
)

Source from the content-addressed store, hash-verified

69 * Returns null if parse fails so callers can fall through to text handling.
70 */
71export function buildImageToolResult(
72 stdout: string,
73 toolUseID: string,
74): ToolResultBlockParam | null {
75 const parsed = parseDataUri(stdout)
76 if (!parsed) return null
77 return {
78 tool_use_id: toolUseID,
79 type: 'tool_result',
80 content: [
81 {
82 type: 'image',
83 source: {
84 type: 'base64',
85 media_type: parsed.mediaType as Base64ImageSource['media_type'],
86 data: parsed.data,
87 },
88 },
89 ],
90 }
91}
92
93// Cap file reads to 20 MB — any image data URI larger than this is
94// well beyond what the API accepts (5 MB base64) and would OOM if read

Calls 1

parseDataUriFunction · 0.85

Tested by

no test coverage detected