(file: ToolFileValue)
| 299 | file.mimeType.split(";")[0]?.trim().toLowerCase() ?? ""; |
| 300 | |
| 301 | const toolFileKind = (file: ToolFileValue): "image" | "audio" | "text" | "resource" => { |
| 302 | const mimeType = normalizedMimeType(file); |
| 303 | if (mimeType.startsWith("image/")) return "image"; |
| 304 | if (mimeType.startsWith("audio/")) return "audio"; |
| 305 | if ( |
| 306 | mimeType.startsWith("text/") || |
| 307 | mimeType === "application/json" || |
| 308 | mimeType.endsWith("+json") || |
| 309 | mimeType === "application/xml" || |
| 310 | mimeType.endsWith("+xml") || |
| 311 | mimeType === "application/javascript" || |
| 312 | mimeType === "application/x-javascript" || |
| 313 | mimeType === "application/yaml" || |
| 314 | mimeType === "application/x-yaml" |
| 315 | ) { |
| 316 | return "text"; |
| 317 | } |
| 318 | return "resource"; |
| 319 | }; |
| 320 | |
| 321 | const bytesFromBase64 = (base64: string): Uint8Array => { |
| 322 | const binary = atob(base64); |
no test coverage detected