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