@@ -10,14 +10,15 @@ import DESCRIPTION from "./read.txt"
1010import { InstanceState } from "@/effect/instance-state"
1111import { assertExternalDirectoryEffect } from "./external-directory"
1212import { Instruction } from "../session/instruction"
13- import { isImageAttachment , isPdfAttachment , sniffAttachmentMime } from "@/util/media"
13+ import { isPdfAttachment , sniffAttachmentMime } from "@/util/media"
1414
1515const DEFAULT_READ_LIMIT = 2000
1616const MAX_LINE_LENGTH = 2000
1717const MAX_LINE_SUFFIX = `... (line truncated to ${ MAX_LINE_LENGTH } chars)`
1818const MAX_BYTES = 50 * 1024
1919const MAX_BYTES_LABEL = `${ MAX_BYTES / 1024 } KB`
2020const SAMPLE_BYTES = 4096
21+ const SUPPORTED_IMAGE_MIMES = new Set ( [ "image/jpeg" , "image/png" , "image/gif" , "image/webp" ] )
2122
2223// `offset` and `limit` were originally `z.coerce.number()` — the runtime
2324// coercion was useful when the tool was called from a shell but serves no
@@ -220,7 +221,9 @@ export const ReadTool = Tool.define(
220221 const sample = yield * readSample ( filepath , Number ( stat . size ) , SAMPLE_BYTES )
221222
222223 const mime = sniffAttachmentMime ( sample , AppFileSystem . mimeType ( filepath ) )
223- if ( isImageAttachment ( mime ) || isPdfAttachment ( mime ) ) {
224+ const isImage = SUPPORTED_IMAGE_MIMES . has ( mime )
225+
226+ if ( isImage || isPdfAttachment ( mime ) ) {
224227 const bytes = yield * fs . readFile ( filepath )
225228 const msg = isPdfAttachment ( mime ) ? "PDF read successfully" : "Image read successfully"
226229 return {
0 commit comments