(metadata: unknown)
| 338 | } |
| 339 | |
| 340 | function 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 | |
| 352 | function dataUrlImage(attachment: ToolAttachment) { |
| 353 | const match = stringValue(attachment.url)?.match(/^data:([^;,]+)(?:;[^,]*)*;base64,(.*)$/) |
no test coverage detected