From d3694a53836d08a2f784a715ed351f65047a09fb Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Thu, 27 Aug 2026 14:24:41 -0400 Subject: [PATCH] refactor(core): share read media types (#45597) Reuse the reader-owned media MIME set in the read tool leaf while preserving both ingestion and unsupported-base64 validation boundaries. --- packages/core/src/tool/plugin/read.ts | 7 +++++-- packages/core/src/tool/read-filesystem.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/core/src/tool/plugin/read.ts b/packages/core/src/tool/plugin/read.ts index 33ad8d1e884..c3ebf622e02 100644 --- a/packages/core/src/tool/plugin/read.ts +++ b/packages/core/src/tool/plugin/read.ts @@ -15,7 +15,6 @@ import { Environment } from "../../environment/index.js" export const name = "read" const FILENAME = "AGENTS.md" -const SUPPORTED_MEDIA_MIMES = new Set(["image/jpeg", "image/png", "image/gif", "image/webp", "application/pdf"]) const LocationInput = Schema.Struct({ path: Schema.String.annotate({ description: "File or directory to read" }), offset: ReadToolFileSystem.PageInput.fields.offset.annotate({ @@ -104,7 +103,11 @@ export const Plugin = { Effect.catch(() => Effect.void), Effect.catchDefect(() => Effect.void), ) - if (content.type === "file" && content.encoding === "base64" && !SUPPORTED_MEDIA_MIMES.has(content.mime)) + if ( + content.type === "file" && + content.encoding === "base64" && + !ReadToolFileSystem.MEDIA_MIMES.has(content.mime) + ) return yield* Effect.fail(new ReadToolFileSystem.BinaryFileError({ resource })) return content }).pipe( diff --git a/packages/core/src/tool/read-filesystem.ts b/packages/core/src/tool/read-filesystem.ts index 0ad899a2e30..9eb523d20a1 100644 --- a/packages/core/src/tool/read-filesystem.ts +++ b/packages/core/src/tool/read-filesystem.ts @@ -18,7 +18,7 @@ const FIRST_CHUNK = 256 * 1024 const MAX_LINE_LENGTH = 2_000 const TREE_BASE = 6 const MAX_LINE_SUFFIX = `... (line truncated to ${MAX_LINE_LENGTH} chars)` -const MEDIA_MIMES = new Set(["image/png", "image/jpeg", "image/gif", "image/webp", "application/pdf"]) +export const MEDIA_MIMES = new Set(["image/png", "image/jpeg", "image/gif", "image/webp", "application/pdf"]) export class BinaryFileError extends Schema.TaggedError()("ReadTool.BinaryFileError", { resource: Schema.String,