MCPcopy Create free account
hub / github.com/anomalyco/opencode / readDisplayText

Function readDisplayText

packages/opencode/src/acp/tool.ts:340–350  ·  view source on GitHub ↗
(metadata: unknown)

Source from the content-addressed store, hash-verified

338}
339
340function readDisplayText(metadata: unknown) {
341 if (!metadata || typeof metadata !== "object") return undefined
342 const display = (metadata as Record<string, unknown>).display
343 if (!display || typeof display !== "object") return undefined
344 const info = display as Record<string, unknown>
345 if (info.type === "file") return stringValue(info.text)
346 if (info.type === "directory" && Array.isArray(info.entries)) {
347 return info.entries.filter((item): item is string => typeof item === "string").join("\n")
348 }
349 return undefined
350}
351
352function dataUrlImage(attachment: ToolAttachment) {
353 const match = stringValue(attachment.url)?.match(/^data:([^;,]+)(?:;[^,]*)*;base64,(.*)$/)

Callers 1

completedToolContentFunction · 0.85

Calls 1

stringValueFunction · 0.70

Tested by

no test coverage detected