(file: ToolFileValue)
| 338 | file.mimeType.split(";")[0]?.trim().toLowerCase() ?? ""; |
| 339 | |
| 340 | const toolFileKind = (file: ToolFileValue): "image" | "audio" | "text" | "resource" => { |
| 341 | const mimeType = normalizedMimeType(file); |
| 342 | if (mimeType.startsWith("image/")) return "image"; |
| 343 | if (mimeType.startsWith("audio/")) return "audio"; |
| 344 | if ( |
| 345 | mimeType.startsWith("text/") || |
| 346 | mimeType === "application/json" || |
| 347 | mimeType.endsWith("+json") || |
| 348 | mimeType === "application/xml" || |
| 349 | mimeType.endsWith("+xml") || |
| 350 | mimeType === "application/javascript" || |
| 351 | mimeType === "application/x-javascript" || |
| 352 | mimeType === "application/yaml" || |
| 353 | mimeType === "application/x-yaml" |
| 354 | ) { |
| 355 | return "text"; |
| 356 | } |
| 357 | return "resource"; |
| 358 | }; |
| 359 | |
| 360 | const bytesFromBase64 = (base64: string): Uint8Array => { |
| 361 | const binary = atob(base64); |
no test coverage detected