(file: ToolFileValue)
| 581 | file.mimeType.split(";")[0]?.trim().toLowerCase() ?? ""; |
| 582 | |
| 583 | const toolFileKind = (file: ToolFileValue): "image" | "audio" | "text" | "resource" => { |
| 584 | const mimeType = normalizedMimeType(file); |
| 585 | if (mimeType.startsWith("image/")) return "image"; |
| 586 | if (mimeType.startsWith("audio/")) return "audio"; |
| 587 | if ( |
| 588 | mimeType.startsWith("text/") || |
| 589 | mimeType === "application/json" || |
| 590 | mimeType.endsWith("+json") || |
| 591 | mimeType === "application/xml" || |
| 592 | mimeType.endsWith("+xml") || |
| 593 | mimeType === "application/javascript" || |
| 594 | mimeType === "application/x-javascript" || |
| 595 | mimeType === "application/yaml" || |
| 596 | mimeType === "application/x-yaml" |
| 597 | ) { |
| 598 | return "text"; |
| 599 | } |
| 600 | return "resource"; |
| 601 | }; |
| 602 | |
| 603 | const bytesFromBase64 = (base64: string): Uint8Array => { |
| 604 | const binary = atob(base64); |
no test coverage detected