fix: detect attachment mime from file contents (#23291)

This commit is contained in:
Kit Langton
2026-04-18 11:59:08 -04:00
committed by GitHub
parent dd8c424806
commit 9918f389e7
6 changed files with 198 additions and 77 deletions
+2 -4
View File
@@ -4,6 +4,7 @@ import { HttpClient, HttpClientRequest } from "effect/unstable/http"
import * as Tool from "./tool"
import TurndownService from "turndown"
import DESCRIPTION from "./webfetch.txt"
import { isImageAttachment } from "@/util/media"
const MAX_RESPONSE_SIZE = 5 * 1024 * 1024 // 5MB
const DEFAULT_TIMEOUT = 30 * 1000 // 30 seconds
@@ -104,10 +105,7 @@ export const WebFetchTool = Tool.define(
const mime = contentType.split(";")[0]?.trim().toLowerCase() || ""
const title = `${params.url} (${contentType})`
// Check if response is an image
const isImage = mime.startsWith("image/") && mime !== "image/svg+xml" && mime !== "image/vnd.fastbidsheet"
if (isImage) {
if (isImageAttachment(mime)) {
const base64Content = Buffer.from(arrayBuffer).toString("base64")
return {
title,