MCPcopy Create free account
hub / github.com/block/buzz / buildImageContent

Function buildImageContent

desktop/src/features/agents/ui/agentSessionImageContent.ts:14–40  ·  view source on GitHub ↗
(
  item: ToolItem,
  descriptor: AgentActivityDescriptor,
)

Source from the content-addressed store, hash-verified

12};
13
14export function buildImageContent(
15 item: ToolItem,
16 descriptor: AgentActivityDescriptor,
17): ImageToolContent | null {
18 if (descriptor.renderClass !== "image") {
19 return null;
20 }
21
22 const source = getToolString(item.args, ["source"]);
23 if (!source) {
24 return null;
25 }
26
27 const trimmed = source.trim();
28 if (
29 !trimmed.startsWith("data:image/") &&
30 !trimmed.startsWith("http://") &&
31 !trimmed.startsWith("https://")
32 ) {
33 return null;
34 }
35
36 return {
37 src: trimmed,
38 title: descriptor.preview ?? descriptor.object ?? null,
39 };
40}

Calls 1

getToolStringFunction · 0.90

Tested by

no test coverage detected