Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(tool-gateway): add the document content-type check web_fetch imports so the module loads

oversteppingdbab14fb6cea
diff --git a/api/_lib/tool-gateway/documents.js b/api/_lib/tool-gateway/documents.js
new file mode 100644
index 000000000..885591670
--- /dev/null
+++ b/api/_lib/tool-gateway/documents.js
@@ -0,0 +1,26 @@
+// Document content types, shared by web_fetch and parse_document.
+//
+// web_fetch reads HTML and text. A binary document (PDF, Office, OpenDocument,
+// RTF) decoded as UTF-8 is noise, so web_fetch uses this check to point the
+// caller at parse_document instead of returning half-read bytes.
+
+const DOCUMENT_TYPES = new Set([
+ 'application/pdf',
+ 'application/msword',
+ 'application/vnd.ms-excel',
+ 'application/vnd.ms-powerpoint',
+ 'application/rtf',
+ 'text/rtf',
+]);
+
+const DOCUMENT_PREFIXES = [
+ 'application/vnd.openxmlformats-officedocument.',
+ 'application/vnd.oasis.opendocument.',
+];
+
+/** True when a Content-Type header names a binary document rather than a page. */
+export function isDocumentContentType(contentType) {
+ const type = String(contentType || '').split(';')[0].trim().toLowerCase();
+ if (!type) return false;
+ return DOCUMENT_TYPES.has(type) || DOCUMENT_PREFIXES.some((p) => type.startsWith(p));
+}