Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(attachments): one 100 MB limit for a sent or attached file, previews stay 25 MB (#4838)

Milind Soni66ccb6da6058
diff --git a/docs/self-hosting.md b/docs/self-hosting.md
index c8e9476f2f..4d795a1a89 100644
--- a/docs/self-hosting.md
+++ b/docs/self-hosting.md
@@ -946,6 +946,12 @@ folder holds 512 MB. A team fills that sooner: set
`OMB_ATTACHMENTS_MAX_BYTES` in the server's environment and restart, for
example `OMB_ATTACHMENTS_MAX_BYTES=4294967296` for 4 GB.
+One file can be up to 100 MB, whether a person sends it or a bot attaches it;
+that setting does not change it. It matches Cloudflare's upload ceiling, so a
+tunnel carries it too. A video or audio file over 25 MB does not play inside
+the chat, but it still downloads, and so does a file a bot links to, up to
+500 MB.
+
## Putting a proxy in front
Any reverse proxy works, given three things:
diff --git a/server/attachments.test.ts b/server/attachments.test.ts
index d4bcbb21bb..9086118c6a 100644
--- a/server/attachments.test.ts
+++ b/server/attachments.test.ts
@@ -48,6 +48,7 @@ const {
DEFAULT_ATTACHMENTS_MAX_BYTES,
FILE_MAX_BYTES,
IMAGE_MAX_BYTES,
+ PREVIEW_MAX_BYTES,
__resetAttachmentAccountingForTests,
attachmentStorageUsage,
attachmentsMaxBytes,
@@ -200,7 +201,7 @@ describe("saveAudio", () => {
it("rejects other audio mimes, empty bodies, and oversize bodies", () => {
expect(() => saveAudio(Buffer.from("x"), "audio/ogg")).toThrow(/unsupported audio type/);
expect(() => saveAudio(Buffer.alloc(0), "audio/mpeg")).toThrow(/empty/);
- expect(() => saveAudio(Buffer.alloc(FILE_MAX_BYTES + 1), "audio/mpeg")).toThrow(/exceeds/);
+ expect(() => saveAudio(Buffer.alloc(PREVIEW_MAX_BYTES + 1), "audio/mpeg")).toThrow(/exceeds/);
});
it("rejects at the aggregate ceiling without leaving partials and releases its reservation", () => {
@@ -602,6 +603,18 @@ describe("shared files", () => {
expect(readdirSync(ATTACHMENTS_DIR)).toEqual([]);
});
+ it("keeps a file larger than a preview: only what is read whole stays at the preview size", async () => {
+ const bytes = PREVIEW_MAX_BYTES + 1;
+ async function* reel() {
+ yield Buffer.alloc(PREVIEW_MAX_BYTES);
+ yield Buffer.from("x");
+ }
+ const saved = await saveFile(reel(), "reel.mp4", "video/mp4", { expectedBytes: bytes });
+ expect(saved).toMatchObject({ name: "reel.mp4", mime: "video/mp4", bytes });
+ expect(statSync(saved.path).size).toBe(bytes);
+ expect(FILE_MAX_BYTES).toBeGreaterThan(PREVIEW_MAX_BYTES);
+ });
+
it("deduplicates concurrent and later file retries by upload ID", async () => {
const makeChunks = async function* () {
yield Buffer.from("same ");
diff --git a/server/attachments.ts b/server/attachments.ts
index 69bc67cc27..072380e8ca 100644
--- a/server/attachments.ts
+++ b/server/attachments.ts
@@ -12,11 +12,11 @@ import {
} from "node:fs";
import { link, open, unlink } from "node:fs/promises";
import { basename, dirname, extname, join, resolve } from "node:path";
-import { FILE_MAX_BYTES } from "../shared/upload-limits.ts";
+import { FILE_MAX_BYTES, PREVIEW_MAX_BYTES } from "../shared/upload-limits.ts";
import { DATA_DIR } from "./config.ts";
import { boxUploadsDir } from "./bot-box/plan.ts";
-export { FILE_MAX_BYTES } from "../shared/upload-limits.ts";
+export { FILE_MAX_BYTES, PREVIEW_MAX_BYTES } from "../shared/upload-limits.ts";
export const ATTACHMENTS_DIR = join(DATA_DIR, "attachments");
export const IMAGE_MAX_BYTES = 10 * 1024 * 1024;
@@ -644,8 +644,9 @@ export function saveAudio(bytes: Buffer, mime: string): SavedAttachment {
throw Object.assign(new Error("unsupported audio type"), { status: 400 });
}
if (bytes.byteLength === 0) throw Object.assign(new Error("empty audio"), { status: 400 });
- if (bytes.byteLength > FILE_MAX_BYTES) {
- throw Object.assign(new Error(`audio exceeds ${FILE_MAX_BYTES} bytes`), { status: 413 });
+ // Saved from memory and served whole by readAttachment, so held to the preview size, not the streamed store limit.
+ if (bytes.byteLength > PREVIEW_MAX_BYTES) {
+ throw Object.assign(new Error(`audio exceeds ${PREVIEW_MAX_BYTES} bytes`), { status: 413 });
}
ensureAttachmentsDir();
const reservation = new AttachmentReservation();
diff --git a/server/bot-attachment.test.ts b/server/bot-attachment.test.ts
index a522c276c9..11a0029c6b 100644
--- a/server/bot-attachment.test.ts
+++ b/server/bot-attachment.test.ts
@@ -8,7 +8,7 @@ import { afterAll, beforeAll, describe, expect, it } from "vitest";
const DATA_ROOT = mkdtempSync(join(tmpdir(), "omb-bot-attachment-"));
process.env.OMB_DATA_DIR = join(DATA_ROOT, "data");
const { attachForTurn, deliveredCopy, guestWorkspaceToHost, saveBotAttachment } = await import("./bot-attachment.ts");
-const { ATTACHMENTS_DIR } = await import("./attachments.ts");
+const { ATTACHMENTS_DIR, FILE_MAX_BYTES, PREVIEW_MAX_BYTES } = await import("./attachments.ts");
const WORK = join(DATA_ROOT, "work");
const VM_HOME = join(DATA_ROOT, "vm-home");
@@ -86,6 +86,20 @@ describe("saveBotAttachment", () => {
expect(readFileSync(saved.attachment.path, "utf8")).toBe("%PDF-1.4 fake");
});
+ it("attaches a VM video over the preview size, up to the same limit a person's upload has", async () => {
+ // A bot on a VM has no link to fall back on: attaching is the only way its video reaches the chat.
+ const guest = { root: "/home/cua/workspace", host: VM_HOME };
+ const reel = join(VM_HOME, "reports", "reel.mp4");
+ writeFileSync(reel, "x");
+ truncateSync(reel, PREVIEW_MAX_BYTES + 1);
+ const saved = await saveBotAttachment({ path: "/home/cua/workspace/reports/reel.mp4", roots: [WORK], guest });
+ expect(saved).toMatchObject({ bytes: PREVIEW_MAX_BYTES + 1, attachment: { kind: "file", mime: "video/mp4", name: "reel.mp4" } });
+ truncateSync(reel, FILE_MAX_BYTES + 1);
+ await expect(saveBotAttachment({ path: "/home/cua/workspace/reports/reel.mp4", roots: [WORK], guest }))
+ .rejects.toMatchObject({ status: 413, code: "file_too_large", errorParams: { limit: "100 MB", name: "reel.mp4" } });
+ rmSync(reel);
+ });
+
it("does not let a guest path or a name reach outside its folder", async () => {
writeFileSync(join(DATA_ROOT, "secret.pdf"), "secret");
const guest = { root: "/home/cua/workspace", host: VM_HOME };
@@ -188,7 +202,7 @@ describe("saveBotAttachment for a file a turn saved outside its folders", () =>
await expect(saveBotAttachment({ path: join(DESIGNS, "bundle.zip"), ...turn })).rejects.toMatchObject({ status: 415 });
const big = join(DESIGNS, "big.mp4");
writeFileSync(big, "x");
- truncateSync(big, 25 * 1024 * 1024 + 1);
+ truncateSync(big, FILE_MAX_BYTES + 1);
await expect(saveBotAttachment({ path: big, ...turn })).rejects.toMatchObject({ status: 413 });
await expect(saveBotAttachment({ path: "nope.pdf", ...turn })).rejects.toMatchObject({ status: 404 });
await expect(saveBotAttachment({ path: join(DESIGNS, "nope.pdf"), ...turn })).rejects.toMatchObject({ status: 404 });
diff --git a/server/bot-attachment.ts b/server/bot-attachment.ts
index 50cdaa6076..d8e8b894a7 100644
--- a/server/bot-attachment.ts
+++ b/server/bot-attachment.ts
@@ -56,13 +56,14 @@ export interface SaveBotAttachmentInput {
savedThisTurn?: { since: number; refuse: readonly string[] };
}
-/** Only the roots' outside_workspace refusal falls through, so a missing or oversized file in the folder says exactly that. */
+/** Only the roots' outside_workspace refusal falls through, so a missing or oversized file in the folder says exactly that.
+ * Opened at the store's limit, not the preview one: the copy streams, and a person may send the same size. */
async function openSource(path: string, roots: readonly string[], savedThisTurn: SaveBotAttachmentInput["savedThisTurn"]): Promise<OpenedMessageFile> {
try {
- return await openMessageFile(path, roots);
+ return await openMessageFile(path, roots, FILE_MAX_BYTES);
} catch (error) {
if (!savedThisTurn || (error as { code?: unknown } | null)?.code !== "outside_workspace") throw error;
- return openFileSavedSince(path, savedThisTurn);
+ return openFileSavedSince(path, savedThisTurn, FILE_MAX_BYTES);
}
}
diff --git a/server/browser-upload-security.test.ts b/server/browser-upload-security.test.ts
index 32f5c4a701..fbff7e457a 100644
--- a/server/browser-upload-security.test.ts
+++ b/server/browser-upload-security.test.ts
@@ -2,6 +2,7 @@ import * as fs from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, expect, it, vi } from "vitest";
+import { FILE_MAX_BYTES } from "../shared/upload-limits.ts";
const hooks = vi.hoisted(() => ({
beforeRead: null as ((input: number) => void) | null,
@@ -122,7 +123,7 @@ it.skipIf(process.platform === "win32")("rejects an oversized sparse file before
dirs.push(base);
const source = join(base, "large.bin");
fs.writeFileSync(source, "");
- fs.truncateSync(source, 25 * 1024 * 1024 + 1);
+ fs.truncateSync(source, FILE_MAX_BYTES + 1);
let read = false;
hooks.beforeRead = () => { read = true; };
await expect(async () => namedUploadPaths([{ file: source, name: "Large.bin" }], join(base, "uploads"))).rejects.toThrow(/limit/i);
diff --git a/server/browser-upload.ts b/server/browser-upload.ts
index 27dc437432..b463d52328 100644
--- a/server/browser-upload.ts
+++ b/server/browser-upload.ts
@@ -4,7 +4,7 @@ import { homedir } from "node:os";
import { basename, isAbsolute, join, relative } from "node:path";
import { promisify } from "node:util";
-import { BROWSER_UPLOAD_MAX_BYTES, FILE_MAX_BYTES } from "../shared/upload-limits.ts";
+import { BROWSER_UPLOAD_MAX_BYTES, FILE_MAX_BYTES, limitMegabytes } from "../shared/upload-limits.ts";
import { safeFileName } from "./browser/cdp/downloads.ts";
import { inSecretFolder, SECRET_FILE_REFUSAL } from "./secret-folder.ts";
@@ -93,7 +93,7 @@ function openUpload(source: string): { input: number; size: number } {
if (process.platform === "linux" && readlinkSync(`/proc/self/fd/${input}`) !== source) throw new BrowserUploadRefusal(`${source} changed while staging the upload.`);
const file = fstatSync(input, { bigint: true });
if (!file.isFile()) throw new BrowserUploadRefusal(`${source} is not a file.`);
- if (file.size > BigInt(FILE_MAX_BYTES)) throw new BrowserUploadRefusal("Uploads are limited to 25 MiB per file.");
+ if (file.size > BigInt(FILE_MAX_BYTES)) throw new BrowserUploadRefusal(`Uploads are limited to ${limitMegabytes(FILE_MAX_BYTES)} MiB per file.`);
return { input, size: Number(file.size) };
} catch (error) {
closeSync(input);
diff --git a/server/cloud-send-chats.ts b/server/cloud-send-chats.ts
index 6158ce3616..3ca7f5b862 100644
--- a/server/cloud-send-chats.ts
+++ b/server/cloud-send-chats.ts
@@ -3,7 +3,9 @@
// /api/cloud-send/chats/rows); My Cloud adds them as Bring newer chats adds a copy's (cloud-chat-merge.ts): only what it
// lacks, never replacing or deleting anything. A conversation's history therefore goes once, and then only what is new.
// Admin scope (request-auth's default) on both sides.
-import { lstat, open, readFile } from "node:fs/promises";
+import { createReadStream } from "node:fs";
+import { lstat, open } from "node:fs/promises";
+import { pipeline } from "node:stream/promises";
import { join } from "node:path";
import { z } from "zod";
@@ -390,7 +392,8 @@ export async function cloudSendChatsRoute(deps: CloudSendChatsDeps, { req, res,
const stat = await lstat(file).catch(() => null);
if (!stat?.isFile() || stat.size > FILE_MAX_BYTES) { json(res, 404, { error: "no such attachment" }); return true; }
res.writeHead(200, { "content-type": "application/octet-stream", "content-length": String(stat.size) });
- res.end(await readFile(file));
+ // Streamed, never read whole: a stored file may be as large as FILE_MAX_BYTES.
+ await pipeline(createReadStream(file, { start: 0, end: Math.max(0, stat.size - 1) }), res).catch(() => res.destroy());
return true;
}
// My Cloud's side: an attachment a sent row names, kept under its own name; one already here is the same upload.
diff --git a/server/cloud-send.e2e.test.ts b/server/cloud-send.e2e.test.ts
index 876d09f2d0..f3a3480ff1 100644
--- a/server/cloud-send.e2e.test.ts
+++ b/server/cloud-send.e2e.test.ts
@@ -45,6 +45,10 @@ it("My Cloud keeps an attachment a sent row names under its own name, once, and
expect((await post(Buffer.from("something else"))).status, "one already here is the same upload").toBe(200);
expect((await fx.onCloud("POST", "/api/cloud-send/chats/attachments", { names: [name] })).body).toEqual({ missing: [] });
expect(Buffer.from(await (await fetch(`${fx.cloudBase}/api/attachments/${name}`, { headers: { ...fx.edge, authorization: `Bearer ${fx.owner}` } })).arrayBuffer())).toEqual(DOT);
+ // Read back as the move reads this computer's copy: streamed, with the length it declares.
+ const kept = await fetch(`${fx.cloudBase}/api/cloud-send/chats/attachment/${name}`, { headers: { ...fx.edge, authorization: `Bearer ${fx.owner}` } });
+ expect(kept.headers.get("content-length")).toBe(String(DOT.byteLength));
+ expect(Buffer.from(await kept.arrayBuffer())).toEqual(DOT);
expect((await fetch(`${fx.cloudBase}/api/cloud-send/chats/attachment/..%2Fescape.png`, { method: "POST", body: DOT, headers: { ...fx.edge, authorization: `Bearer ${fx.owner}` } })).status).toBe(404);
});
diff --git a/server/drivers/agents-catalog-goldens/bridged.profiles.json b/server/drivers/agents-catalog-goldens/bridged.profiles.json
index bb00e62161..bdb42ee817 100644
--- a/server/drivers/agents-catalog-goldens/bridged.profiles.json
+++ b/server/drivers/agents-catalog-goldens/bridged.profiles.json
@@ -1,7 +1,7 @@
{
"default": {
- "bytes": 17644,
- "sha256": "5090ecd9c6137b31bcd5a1359b9d9744c844dcb81c8668fd2fd6d949c8b65bcb",
+ "bytes": 17645,
+ "sha256": "2fbe02b309cc140a36959571f1fec3a58179fbbc26361ffbb5a93da6c8ff868e",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -22,8 +22,8 @@
]
},
"voice": {
- "bytes": 18425,
- "sha256": "fd74da1767a418274194cc8885e7ad7549e62093ba7c192aade7adfc2d98fd61",
+ "bytes": 18426,
+ "sha256": "e69a2f444dad1f4e0ed76ab47b8bccc45fe683f9a741518f66d97aa0f7e18575",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -45,8 +45,8 @@
]
},
"shared": {
- "bytes": 17684,
- "sha256": "294134f7cc0beaf8c4e53dfe7c01ba38804d6e21a79d1f396cba3e3069981701",
+ "bytes": 17685,
+ "sha256": "01de1e7ba6e5f783e4dbfb00d63323a05a9c92a7874b7665368ad539868b599b",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -67,8 +67,8 @@
]
},
"shared+voice": {
- "bytes": 18465,
- "sha256": "5dd9cc6723823a78b38f07d5003fa3622dc514d4320e6ed599c53de1d86e8f76",
+ "bytes": 18466,
+ "sha256": "f55d19b8065b54a1c281187d43bf89fd6381fdec566a5c1f5023240ad3b9766c",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -90,8 +90,8 @@
]
},
"skills": {
- "bytes": 17671,
- "sha256": "fc0fcd5426d7d236c586c655ac643765edca85d5305cc777ae6ea8ca87b31bf1",
+ "bytes": 17672,
+ "sha256": "bd414114559470a16e6d453958e6d550641f42072435fa73654f3fecd3147d9e",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -112,8 +112,8 @@
]
},
"skills+voice": {
- "bytes": 18452,
- "sha256": "3cf21ea8338d3235aaac2d7ed4f32e0a9f92c0ac2c97d3709bb1a3d723423bb8",
+ "bytes": 18453,
+ "sha256": "82cd88d4b5f03307f44bdfcac934d64638ecb4d25295fed6d7b1296b24b3bfbb",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -135,8 +135,8 @@
]
},
"skills+shared": {
- "bytes": 17711,
- "sha256": "dccd058983b27eb8d7792a05d54a39a7cc111e8d4ad9db424a80360a51da0738",
+ "bytes": 17712,
+ "sha256": "a27faab98b5f8a47abfa4aa3414a79a4cdb9f3dd339c98419603b8633eba637c",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -157,8 +157,8 @@
]
},
"skills+shared+voice": {
- "bytes": 18492,
- "sha256": "ee82a7d07262a865442222885f600e38f3e791bb75535f32a92f13d6f31c683e",
+ "bytes": 18493,
+ "sha256": "2a6e8c7660aec4c2ba4af213f6a3d0f4157db4510d5c242d39a661b52f2a8a11",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -180,8 +180,8 @@
]
},
"non-chief": {
- "bytes": 17527,
- "sha256": "d4c62cbdf7f5aaaba628f85d569a4028da01650b6f9de7acd6037bec8dd20c27",
+ "bytes": 17528,
+ "sha256": "b876738e4cfe41c5c3dedfdf4d46ec5147c458de554afaed689c9486f289ba35",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -202,8 +202,8 @@
]
},
"voice+non-chief": {
- "bytes": 18308,
- "sha256": "4e46aaa447113cf8435d2d4bc67cb6d6797ef6b1a3368c932e17294016862c31",
+ "bytes": 18309,
+ "sha256": "d163200607e835111a9f2c8e533024072a18bcef83ca0397cd83487c0a09ba25",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -225,8 +225,8 @@
]
},
"shared+non-chief": {
- "bytes": 17567,
- "sha256": "f9ce8bc9f7edb6a9c507e9e5a0c949b511a9f90383baa00df73579a5263fa63e",
+ "bytes": 17568,
+ "sha256": "5e1523dad12d78d9d790abe23adbe395c0fb46a636da3e4ad3fbe6f6f49ebbac",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -247,8 +247,8 @@
]
},
"shared+voice+non-chief": {
- "bytes": 18348,
- "sha256": "efb263e5c4048e8e5fa5ebe3be06ecaa0621d37c31c9c9b28eae622595243340",
+ "bytes": 18349,
+ "sha256": "5090b777e0c501615d5137a6e4c6f2c722243ec8eb9761dbc4c0801ac8e3ad20",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -270,8 +270,8 @@
]
},
"skills+non-chief": {
- "bytes": 17554,
- "sha256": "cf27e2c01a4e602ba50971eccfe61173416df312977e47d269a3fc5fcba884a7",
+ "bytes": 17555,
+ "sha256": "ce446259013cc318f7f61343bca9b87d92f9d9f0d4a88a242c7e4dea80cd5c73",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -292,8 +292,8 @@
]
},
"skills+voice+non-chief": {
- "bytes": 18335,
- "sha256": "24f23319091af2d6ef7cfec605ae00178b9cb47faa4479f15ef82105bc244b7d",
+ "bytes": 18336,
+ "sha256": "52b48a7eb1578f64ed48a8c0ec0e4a4e988d2169dd62a0f454fedc34f9513d15",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -315,8 +315,8 @@
]
},
"skills+shared+non-chief": {
- "bytes": 17594,
- "sha256": "7467cefc956b23b1ad97a8bf100644ae4ae8469ff0d7015743c24485a4f24815",
+ "bytes": 17595,
+ "sha256": "92c6dc71bb885e531697e48ace1be84cc1502539913dd481f984f6fa3fce8e38",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -337,8 +337,8 @@
]
},
"skills+shared+voice+non-chief": {
- "bytes": 18375,
- "sha256": "5573dbe2b3575faf2fae6ed1ba1ed93455dfe039d2ab524f3d4cbea14a145b8b",
+ "bytes": 18376,
+ "sha256": "82900315658b28668f66cc0fd60cb035e1222586b7c114985059ba6928aafeb6",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -360,8 +360,8 @@
]
},
"skills+shared+voice+cloud-home": {
- "bytes": 18508,
- "sha256": "b0843a2650e036aab1feb5da265ab2f346dce719f270bf89257a202d71c57eca",
+ "bytes": 18509,
+ "sha256": "70e5714d5211d048fd3f0c3f9bed0763610daed790bdfc820c219ae1d59b9fd9",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -383,8 +383,8 @@
]
},
"skills+shared+voice+non-chief+cloud-home": {
- "bytes": 18391,
- "sha256": "e01ec8c6e1988c6f7f772ed3d712d2cd4917507a37600f03533552433361e826",
+ "bytes": 18392,
+ "sha256": "aebb8bc66e4e4b4d67456ccd6634442f6ed037926669b6c232c251e823d4d839",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -406,8 +406,8 @@
]
},
"skills+shared+voice+escalations": {
- "bytes": 18510,
- "sha256": "97be60787e449fde725a5ce89220dc90e7e7976fcd0d7b6c5acc7872318ce275",
+ "bytes": 18511,
+ "sha256": "6a454692fa544ab7fcd95562372224f12226a1daad3707a7736110089fb5c8e9",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -429,8 +429,8 @@
]
},
"skills+shared+voice+escalations+x": {
- "bytes": 18571,
- "sha256": "e9e781628580536fa845a7f1bbd79be173e66d23db6e37a1fe218f4a9828f0b8",
+ "bytes": 18572,
+ "sha256": "5fa4901bfe23955ac6ee0cce63ad27f2c83f005cf6c5763ab6058b7e97791332",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -452,8 +452,8 @@
]
},
"skills+shared+voice+escalations+x+team": {
- "bytes": 18571,
- "sha256": "e9e781628580536fa845a7f1bbd79be173e66d23db6e37a1fe218f4a9828f0b8",
+ "bytes": 18572,
+ "sha256": "5fa4901bfe23955ac6ee0cce63ad27f2c83f005cf6c5763ab6058b7e97791332",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -475,8 +475,8 @@
]
},
"skills+shared+voice+escalations+x+team+images": {
- "bytes": 18587,
- "sha256": "e49ff362d0bc716ec5d2f52dc7c86416d1bff65ef6fc602b94d74676c34448b5",
+ "bytes": 18588,
+ "sha256": "f38b2edaee35285c64a76ceb62f97abd1f4ee19e522ad5b9be4c360c779ebdde",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -498,8 +498,8 @@
]
},
"default+legacy-switches": {
- "bytes": 17644,
- "sha256": "5090ecd9c6137b31bcd5a1359b9d9744c844dcb81c8668fd2fd6d949c8b65bcb",
+ "bytes": 17645,
+ "sha256": "2fbe02b309cc140a36959571f1fec3a58179fbbc26361ffbb5a93da6c8ff868e",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -520,8 +520,8 @@
]
},
"default+mausbot": {
- "bytes": 17696,
- "sha256": "2b2d9d3945709d75cb5154250810c7d5b3ef9c5fb98a725ff2687ff926028c7e",
+ "bytes": 17697,
+ "sha256": "f9228f83719e9e304ff0c64013494c6aea524d1ccebb2118fdde601d45becd89",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -542,8 +542,8 @@
]
},
"skills+shared+voice+mausbot": {
- "bytes": 18544,
- "sha256": "dca263bb4f3445f35493e87b109c1014fbe5a88a77ef5697a532f932d3278ad3",
+ "bytes": 18545,
+ "sha256": "fe8f4ad46a8a0ff56de681137dcae6f851554da0b242bd660d5814e8ae22cd10",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -565,8 +565,8 @@
]
},
"default+no-computer-pick": {
- "bytes": 16432,
- "sha256": "7c5b5e7d66a24df48359a472522d669a38da585491edfeca3095c4edaea07a3f",
+ "bytes": 16433,
+ "sha256": "21708436ff3f01218494aa8c1d27768bdb3419a08a545e0141888457a9b3ad02",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -586,8 +586,8 @@
]
},
"default+room": {
- "bytes": 16395,
- "sha256": "547705b1cf4a7c9ed097885dfabcdb678a917d6e3bc0066a1fa127273aa2a59f",
+ "bytes": 16396,
+ "sha256": "d21e6a394354cec8c4f2570c8f986d4c29395b262c01f6cb1f269e1219a0c0d5",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -607,8 +607,8 @@
]
},
"non-chief+room": {
- "bytes": 16278,
- "sha256": "8681ae12c57fb4d854d38e118d67ca840d0d88104e1635608d3751027fd1e08a",
+ "bytes": 16279,
+ "sha256": "4bddde56e548a8fe91cc2da07a99b0560906fe5bdbf72408cbd91914602e58ef",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -628,8 +628,8 @@
]
},
"default+images": {
- "bytes": 17660,
- "sha256": "60230243e86af7ed58e8ad2b479aa1624d06de21188e7fc7e8d4b7c387e50aac",
+ "bytes": 17661,
+ "sha256": "a9ef6a3875b9873f924a1c398eeab12028eb324e2a0e6431bc3835b37867897b",
"tools": [
"tool_result_read",
"list_room_targets",
diff --git a/server/drivers/agents-catalog-goldens/bridged.tools-list.json b/server/drivers/agents-catalog-goldens/bridged.tools-list.json
index cb40e2d067..7e942ba27a 100644
--- a/server/drivers/agents-catalog-goldens/bridged.tools-list.json
+++ b/server/drivers/agents-catalog-goldens/bridged.tools-list.json
@@ -158,7 +158,7 @@
},
{
"name": "attach_file",
- "description": "Attach a finished file to the chat so the user can preview and download it: an image, video, audio clip, PDF, spreadsheet, slide deck or other document you made. Pass its path: a path inside your computer's /home/cua/workspace (for example /home/cua/workspace/report.pdf), or a file in your working folder. Do this instead of pasting a VM path as a link; a path inside a VM cannot be opened from chat. Supported: images (png, jpg, gif, webp), video (mp4, webm, mov), audio (mp3, m4a, aac, wav, ogg, opus, flac), pdf, Word/Excel/PowerPoint and OpenDocument files, and csv, tsv, txt, md, json, rtf. Up to 25 MB (images 10 MB). Finish writing the file first, then call this directly: it reports an error if the file is missing, so you do not need to list or open the folder to check.",
+ "description": "Attach a finished file to the chat so the user can preview and download it: an image, video, audio clip, PDF, spreadsheet, slide deck or other document you made. Pass its path: a path inside your computer's /home/cua/workspace (for example /home/cua/workspace/report.pdf), or a file in your working folder. Do this instead of pasting a VM path as a link; a path inside a VM cannot be opened from chat. Supported: images (png, jpg, gif, webp), video (mp4, webm, mov), audio (mp3, m4a, aac, wav, ogg, opus, flac), pdf, Word/Excel/PowerPoint and OpenDocument files, and csv, tsv, txt, md, json, rtf. Up to 100 MB (images 10 MB). Finish writing the file first, then call this directly: it reports an error if the file is missing, so you do not need to list or open the folder to check.",
"inputSchema": {
"type": "object",
"additionalProperties": false,
diff --git a/server/drivers/agents-catalog-goldens/full.tools-list.json b/server/drivers/agents-catalog-goldens/full.tools-list.json
index 54cf884bc0..eadcba1963 100644
--- a/server/drivers/agents-catalog-goldens/full.tools-list.json
+++ b/server/drivers/agents-catalog-goldens/full.tools-list.json
@@ -394,7 +394,7 @@
},
{
"name": "attach_file",
- "description": "Attach a finished file to the chat so the user can preview and download it: an image, video, audio clip, PDF, spreadsheet, slide deck or other document you made. Pass its path: a path inside your computer's /home/cua/workspace (for example /home/cua/workspace/report.pdf), or a file in your working folder. Do this instead of pasting a VM path as a link; a path inside a VM cannot be opened from chat. Supported: images (png, jpg, gif, webp), video (mp4, webm, mov), audio (mp3, m4a, aac, wav, ogg, opus, flac), pdf, Word/Excel/PowerPoint and OpenDocument files, and csv, tsv, txt, md, json, rtf. Up to 25 MB (images 10 MB). Finish writing the file first, then call this directly: it reports an error if the file is missing, so you do not need to list or open the folder to check.",
+ "description": "Attach a finished file to the chat so the user can preview and download it: an image, video, audio clip, PDF, spreadsheet, slide deck or other document you made. Pass its path: a path inside your computer's /home/cua/workspace (for example /home/cua/workspace/report.pdf), or a file in your working folder. Do this instead of pasting a VM path as a link; a path inside a VM cannot be opened from chat. Supported: images (png, jpg, gif, webp), video (mp4, webm, mov), audio (mp3, m4a, aac, wav, ogg, opus, flac), pdf, Word/Excel/PowerPoint and OpenDocument files, and csv, tsv, txt, md, json, rtf. Up to 100 MB (images 10 MB). Finish writing the file first, then call this directly: it reports an error if the file is missing, so you do not need to list or open the folder to check.",
"inputSchema": {
"type": "object",
"additionalProperties": false,
diff --git a/server/drivers/agents-catalog-goldens/profiles.json b/server/drivers/agents-catalog-goldens/profiles.json
index d9cdbc9091..13bfb2a70c 100644
--- a/server/drivers/agents-catalog-goldens/profiles.json
+++ b/server/drivers/agents-catalog-goldens/profiles.json
@@ -1,7 +1,7 @@
{
"default": {
- "bytes": 59743,
- "sha256": "532fab3bbe9701447074a5bfa52ed8c7144a0fe93b63abce30446a8e8f240bfb",
+ "bytes": 59744,
+ "sha256": "f800173ad146c80a1d1636f16c6c448c3f81f4494871c4a1e9a1d5cb931db029",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -51,8 +51,8 @@
]
},
"voice": {
- "bytes": 60524,
- "sha256": "fd281d5c50b06709be9dd22a1454ba0ff84652c115cf493a99e1a7d7c29110f8",
+ "bytes": 60525,
+ "sha256": "3542a61d8a11af96f907b036bd811d82801cc5e42db9d6cf04a3de2ff6bac60c",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -103,8 +103,8 @@
]
},
"shared": {
- "bytes": 62008,
- "sha256": "1d440d4586e916e04767a3cc987880a1df28df5a36f555608cb8680e4e559834",
+ "bytes": 62009,
+ "sha256": "10a1329d86ca4b524455e8068ec26872a57da142fafb964724352529551c7b4d",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -156,8 +156,8 @@
]
},
"shared+voice": {
- "bytes": 62789,
- "sha256": "50260954740cf90ce6a6c5c73b9844b4c9f16ec80b9a504d20b29c2ace6d7a20",
+ "bytes": 62790,
+ "sha256": "6bee018e3b2650dd3ffbf75d9393be65937996c0faf3f565e0e5b048811c5c14",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -210,8 +210,8 @@
]
},
"skills": {
- "bytes": 62819,
- "sha256": "cde60922617919479d52eb9d7922c56057e2e282583b568d77efad353b809135",
+ "bytes": 62820,
+ "sha256": "7b69149e5b321b5870029a05e31653dc2a06b49a6673dfb6d18682abc47478dd",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -263,8 +263,8 @@
]
},
"skills+voice": {
- "bytes": 63600,
- "sha256": "b46b3d845e76c54469f97e07073845e14b1a2001951633fb58b95dec6c5775aa",
+ "bytes": 63601,
+ "sha256": "d68f569967495bc4615af034223fb3f35f1d66b29503d067abfba1d76119df55",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -317,8 +317,8 @@
]
},
"skills+shared": {
- "bytes": 65084,
- "sha256": "a0075d79dc54c1edf0260780c1a86328b55115c2e85a522728f3ecc5e824642c",
+ "bytes": 65085,
+ "sha256": "18df446ea3730c5f83135a275914a054aea572ead40de091787cab93dd62a7c4",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -372,8 +372,8 @@
]
},
"skills+shared+voice": {
- "bytes": 65865,
- "sha256": "9b08114eab04586bbfcea3441bc837f614bba8427dfa1270258475dfe3acf481",
+ "bytes": 65866,
+ "sha256": "147e622071bdc3a6c6359c2f0867445a31f829a46be25d018a5abace20b06828",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -428,8 +428,8 @@
]
},
"non-chief": {
- "bytes": 50527,
- "sha256": "4c7f68254bf471874334660b2bb82717b98bc651868848c900039bcb881cbe3a",
+ "bytes": 50528,
+ "sha256": "887988da88b0936067719aa829e21397158a00ab12c088537d98405e72f131c9",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -472,8 +472,8 @@
]
},
"voice+non-chief": {
- "bytes": 51308,
- "sha256": "cc54e5d30f2878c098a845ab1d2bdcbcf366e08f11817378e6a9a5a31af16a60",
+ "bytes": 51309,
+ "sha256": "3f4e9d8a5793f451cf271b71dbb2f232c03600111b5db26895f9b4250d621a95",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -517,8 +517,8 @@
]
},
"shared+non-chief": {
- "bytes": 52792,
- "sha256": "d664d3dedcdbbedf135505f328636883583c22ffb402f54ba30e3808a270f9ae",
+ "bytes": 52793,
+ "sha256": "2a839a380601bb7c6a0958dce572806f0ebcbf62da4b0402b2d2ad5af4434bd2",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -563,8 +563,8 @@
]
},
"shared+voice+non-chief": {
- "bytes": 53573,
- "sha256": "8de7dc962dd91fca0b15c010fa07b87776ebc1c439f8ebab5ed240b0c9b35529",
+ "bytes": 53574,
+ "sha256": "c50347d301c3c725191e9528656cbf45b5ca45eababbadf280d784e97d94eb52",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -610,8 +610,8 @@
]
},
"skills+non-chief": {
- "bytes": 53603,
- "sha256": "00d5be73d4d2c9a5201db5017d22eda078fef4f874445bcc9ed92a0adc21c201",
+ "bytes": 53604,
+ "sha256": "d01bbf71e160df9d831fdfb8cc895e23ffd450abcda860b229123b4c879c04ed",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -656,8 +656,8 @@
]
},
"skills+voice+non-chief": {
- "bytes": 54384,
- "sha256": "da9908f5c4ad97f2d4d5d9fc154eac9fa5b6418f65c0b6c20ef328cdd2dd52b9",
+ "bytes": 54385,
+ "sha256": "2fd3de4a7a30bc49a75352bab2e65a4a6573edc66c3b6343237a7b62a6087222",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -703,8 +703,8 @@
]
},
"skills+shared+non-chief": {
- "bytes": 55868,
- "sha256": "0fa7d16d83aee411535c75cc5b786b521bfa6d9a6c593e206b6b9ef1fcac057b",
+ "bytes": 55869,
+ "sha256": "6742406ff4816bf241d69fe40009c2b3bfc79ce86181b61316628e4ff79f7f96",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -751,8 +751,8 @@
]
},
"skills+shared+voice+non-chief": {
- "bytes": 56649,
- "sha256": "da830626dc33f67b9eec0e34510167839889664169dc937a4ca237ac11c86399",
+ "bytes": 56650,
+ "sha256": "cccb89a47ba0b2416aed9318eac7d13b9c9f28657674a42697d888ce3103e987",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -800,8 +800,8 @@
]
},
"skills+shared+voice+cloud-home": {
- "bytes": 65631,
- "sha256": "b3cf52f277a1ed93fef3053d4dbea61cd1c565cf267d0ad9dd1591cc5c83b25f",
+ "bytes": 65632,
+ "sha256": "d6fc3ddd122067841110cddba5b0a97f091e90f32221187580888055b3c00abd",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -856,8 +856,8 @@
]
},
"skills+shared+voice+non-chief+cloud-home": {
- "bytes": 56415,
- "sha256": "46ab9b7c13418188453af6546a8d11969a75ed4ca013d6d26f41affbf263802f",
+ "bytes": 56416,
+ "sha256": "69e8e67096a525e1263b5342a673503228fd08a0e7e3e7233d136aec75a2e10a",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -905,8 +905,8 @@
]
},
"skills+shared+voice+escalations": {
- "bytes": 66695,
- "sha256": "2f1f2666eaac2b1819fa6326094621d75a4d9078e9c992e6a4b1d473462f1d5e",
+ "bytes": 66696,
+ "sha256": "91c45b9cc2a7cfd4e6574b5b33d51062104cf4f0d84276c838cd36e7f7a2bda1",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -962,8 +962,8 @@
]
},
"skills+shared+voice+escalations+x": {
- "bytes": 70534,
- "sha256": "3c7f085796f05eeff4be4dce7e8a426d84e87b5266d73e0a47f0ebbee81f45c6",
+ "bytes": 70535,
+ "sha256": "416c0514136afd8c8c272f3bdd0f714bfb6da36f5266f9da0db6de13e855dd42",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1023,8 +1023,8 @@
]
},
"skills+shared+voice+escalations+x+team": {
- "bytes": 70534,
- "sha256": "3c7f085796f05eeff4be4dce7e8a426d84e87b5266d73e0a47f0ebbee81f45c6",
+ "bytes": 70535,
+ "sha256": "416c0514136afd8c8c272f3bdd0f714bfb6da36f5266f9da0db6de13e855dd42",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1084,8 +1084,8 @@
]
},
"skills+shared+voice+escalations+x+team+images": {
- "bytes": 71307,
- "sha256": "f326fcd99ffc38315a5ca61b3a141eef13b7f57a833ac23fcd549618e2f847e2",
+ "bytes": 71308,
+ "sha256": "7984d5e85a4d04792d6c3a5bdcee7bcff20f1e6cd6bd73acd71eca07b5792fda",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1146,8 +1146,8 @@
]
},
"default+legacy-switches": {
- "bytes": 59743,
- "sha256": "532fab3bbe9701447074a5bfa52ed8c7144a0fe93b63abce30446a8e8f240bfb",
+ "bytes": 59744,
+ "sha256": "f800173ad146c80a1d1636f16c6c448c3f81f4494871c4a1e9a1d5cb931db029",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1197,8 +1197,8 @@
]
},
"default+mausbot": {
- "bytes": 60394,
- "sha256": "80c79d3adb70bd040e5d07b26c13435b411da3ab305f30e225a887882ab829e0",
+ "bytes": 60395,
+ "sha256": "0678fd1ae34e3fb657597d7ab5d1c184cab5b691ef9878260a15cbef9e6a18f4",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1250,8 +1250,8 @@
]
},
"skills+shared+voice+mausbot": {
- "bytes": 66516,
- "sha256": "be69b1c388cbe604e5b1fa247bbb60f099b4081524450aefac20c5c272abcd4f",
+ "bytes": 66517,
+ "sha256": "7bceadf0db2c942a948fce4ab5cde49de206e76e17466c1c08ea8e95b967e775",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1308,8 +1308,8 @@
]
},
"default+no-computer-pick": {
- "bytes": 58531,
- "sha256": "a4595d7b1c50a3099fe48a6ab9ec88d7d9b660e69766a4785e9499e6f5229980",
+ "bytes": 58532,
+ "sha256": "ad151fa18232a667bd7c45c70164e0414127454cf6b0ffbb46003b68c9f22797",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1358,8 +1358,8 @@
]
},
"default+room": {
- "bytes": 56887,
- "sha256": "5f8e1ff4b22e2d7bfd7daa6857a92a6eddc3e19024e58b680c872952690021fe",
+ "bytes": 56888,
+ "sha256": "c6922408bf0e10230c20163ce6206e734693611e27e6280f148d950fb634bcd7",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1405,8 +1405,8 @@
]
},
"non-chief+room": {
- "bytes": 47671,
- "sha256": "16b83632bfd3a4b9097d44ddd9c29428671d1762214501d0aff5f66aad425741",
+ "bytes": 47672,
+ "sha256": "52e5cb6ffeb60b87c36c941b8cc273d9588f7f1d45efe7dae975c9b495a54a68",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1445,8 +1445,8 @@
]
},
"default+images": {
- "bytes": 60516,
- "sha256": "a47b009009dd2dc49a21dd552bfca0bf252db7bbe0a9db3957ed4c13d2597006",
+ "bytes": 60517,
+ "sha256": "4d141adc06a6d909349a57be5d04339f9dfef79c32abcfa6418209ce2b46f6a7",
"tools": [
"tool_result_read",
"list_room_targets",
diff --git a/server/drivers/agents-catalog.ts b/server/drivers/agents-catalog.ts
index 17b9eb2461..e7e2479492 100644
--- a/server/drivers/agents-catalog.ts
+++ b/server/drivers/agents-catalog.ts
@@ -2,6 +2,7 @@
import { CREDENTIAL_TARGETS } from "../../shared/credential-request.ts";
import { EMAIL_CREDENTIAL } from "../../shared/email.ts";
import { OPTIONS_CARD_LIMITS, WATCHER_OPTIONS_CARD_BOT_ID } from "../../shared/options-card.ts";
+import { FILE_MAX_BYTES, limitMegabytes } from "../../shared/upload-limits.ts";
import { agentToolAnnotations } from "../agent-tool-policy.ts";
import { CHAT_CARD_TOOL_DEFINITIONS } from "./agents-chat-card-tools.ts";
import { DEVS_TOOL_DEFINITIONS } from "./agents-devs-tools.ts";
@@ -331,7 +332,7 @@ const TOOL_DEFINITIONS = [
{
name: "attach_file",
description:
- "Attach a finished file to the chat so the user can preview and download it: an image, video, audio clip, PDF, spreadsheet, slide deck or other document you made. Pass its path: a path inside your computer's /home/cua/workspace (for example /home/cua/workspace/report.pdf), or a file in your working folder. Do this instead of pasting a VM path as a link; a path inside a VM cannot be opened from chat. Supported: images (png, jpg, gif, webp), video (mp4, webm, mov), audio (mp3, m4a, aac, wav, ogg, opus, flac), pdf, Word/Excel/PowerPoint and OpenDocument files, and csv, tsv, txt, md, json, rtf. Up to 25 MB (images 10 MB). Finish writing the file first, then call this directly: it reports an error if the file is missing, so you do not need to list or open the folder to check.",
+ `Attach a finished file to the chat so the user can preview and download it: an image, video, audio clip, PDF, spreadsheet, slide deck or other document you made. Pass its path: a path inside your computer's /home/cua/workspace (for example /home/cua/workspace/report.pdf), or a file in your working folder. Do this instead of pasting a VM path as a link; a path inside a VM cannot be opened from chat. Supported: images (png, jpg, gif, webp), video (mp4, webm, mov), audio (mp3, m4a, aac, wav, ogg, opus, flac), pdf, Word/Excel/PowerPoint and OpenDocument files, and csv, tsv, txt, md, json, rtf. Up to ${limitMegabytes(FILE_MAX_BYTES)} MB (images 10 MB). Finish writing the file first, then call this directly: it reports an error if the file is missing, so you do not need to list or open the folder to check.`,
inputSchema: {
type: "object",
additionalProperties: false,
diff --git a/server/index.test.ts b/server/index.test.ts
index cf3e4ad26f..519f33bf84 100644
--- a/server/index.test.ts
+++ b/server/index.test.ts
@@ -10066,7 +10066,7 @@ describe("harness HTTP API", () => {
});
it.skipIf(process.platform === "win32").each([
- { mode: "size", sizes: [25 * 1024 * 1024 + 1], message: "Uploads are limited to 25 MiB per file.", status: 200 },
+ { mode: "size", sizes: [FILE_MAX_BYTES + 1], message: "Uploads are limited to 100 MiB per file.", status: 200 },
{ mode: "batch", sizes: Array(5).fill(21 * 1024 * 1024) as number[], message: "Uploads are limited to 100 MiB per batch.", status: 200 },
{ mode: "changed", sizes: [1024], message: expect.stringContaining("changed while staging"), status: 200 },
{ mode: "stop", sizes: [1024], message: expect.stringContaining("turn has already ended"), status: 401 },
diff --git a/server/message-file.ts b/server/message-file.ts
index 2da259248a..8051f479c7 100644
--- a/server/message-file.ts
+++ b/server/message-file.ts
@@ -8,10 +8,11 @@ import { fileURLToPath, pathToFileURL } from "node:url";
import { fromMarkdown } from "mdast-util-from-markdown";
import { windowsPathDestinations } from "../shared/markdown-windows-paths.ts";
+import { PREVIEW_MAX_BYTES } from "../shared/upload-limits.ts";
import { inSecretFolder, SECRET_FILE_REFUSAL } from "./secret-folder.ts";
import { userErrorThrown } from "./user-errors.ts";
-export const MESSAGE_FILE_MAX_BYTES = 25 * 1024 * 1024;
+export const MESSAGE_FILE_MAX_BYTES = PREVIEW_MAX_BYTES;
/** Saving a linked file streams it to the person, so it may be larger than anything read into memory or previewed. */
export const MESSAGE_FILE_DOWNLOAD_MAX_BYTES = 500 * 1024 * 1024;
@@ -444,6 +445,7 @@ const SAVED_SINCE_SLACK_MS = 2_000;
export async function openFileSavedSince(
href: string,
options: { since: number; refuse: readonly string[] },
+ maxBytes = MESSAGE_FILE_MAX_BYTES,
): Promise<OpenedMessageFile> {
const requested = referencedPath(href, false, false);
if (!isAbsolute(requested) || requested.startsWith("\\\\") || requested.startsWith("//")) throw outsideWorkspace();
@@ -459,7 +461,7 @@ export async function openFileSavedSince(
if (hidden || refused.some((root) => containedBy(root, canonical))) {
throw statusError(403, "files in hidden folders or in the app's own data can't be attached", "outside_workspace");
}
- const file = await openMessageFile(canonical, [dirname(canonical)]);
+ const file = await openMessageFile(canonical, [dirname(canonical)], maxBytes);
const opened = await file.handle.stat().catch(async (error: unknown) => {
await file.handle.close().catch(() => undefined);
throw error;
diff --git a/shared/upload-limits.ts b/shared/upload-limits.ts
index d44f218c8f..b29f06f6c1 100644
--- a/shared/upload-limits.ts
+++ b/shared/upload-limits.ts
@@ -1,3 +1,11 @@
-/** Below Cloudflare's transport ceiling; a local inbox, not unbounded storage. */
-export const FILE_MAX_BYTES = 25 * 1024 * 1024;
+/** One file kept in the attachment store: sent in a message by a person, or attached by a bot. It streams to disk on
+ * the way in and back out on download, so this is a transport limit, not a memory one: Cloudflare's 100 MB request
+ * ceiling, which a tunnel or a Cloud on your own server sits behind. The same number holds on every surface. */
+export const FILE_MAX_BYTES = 100 * 1024 * 1024;
+/** Anything read whole into memory: an inline image or a video or audio preview in the browser, a voice note served
+ * from memory. Larger files still save and download; they just do not play inline. */
+export const PREVIEW_MAX_BYTES = 25 * 1024 * 1024;
export const BROWSER_UPLOAD_MAX_BYTES = 100 * 1024 * 1024;
+const MEGABYTE = 1024 * 1024;
+/** A limit in the same whole megabytes the person reads elsewhere ("100 MB"). */
+export const limitMegabytes = (bytes: number): number => Math.round(bytes / MEGABYTE);
diff --git a/src/components/AttachmentGallery.test.ts b/src/components/AttachmentGallery.test.ts
index a302b678dc..cdd200f8ab 100644
--- a/src/components/AttachmentGallery.test.ts
+++ b/src/components/AttachmentGallery.test.ts
@@ -1,7 +1,7 @@
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { afterEach, describe, expect, it, vi } from "vitest";
-import { FILE_MAX_BYTES } from "@/lib/composer-attachments";
+import { PREVIEW_MAX_BYTES } from "@/lib/composer-attachments";
import { AttachmentGallery, collectMessageFiles, isAudioAttachment, isVideoAttachment, loadMessageAudio, loadMessageVideo, MessageAttachmentGallery, splitMessageAttachments } from "./AttachmentGallery";
const message = { threadId: "thread/one", messageId: "message two" };
@@ -88,10 +88,10 @@ describe("audio attachments", () => {
it("enforces the size limit with and without Content-Length", async () => {
vi.stubGlobal("fetch", vi.fn(async () => new Response("audio", {
- headers: { "content-type": "audio/mpeg", "content-length": String(FILE_MAX_BYTES + 1) },
+ headers: { "content-type": "audio/mpeg", "content-length": String(PREVIEW_MAX_BYTES + 1) },
})));
await expect(loadMessageAudio(clip, message, new AbortController().signal)).rejects.toThrow("25 MB");
- vi.stubGlobal("fetch", vi.fn(async () => new Response(new Uint8Array(FILE_MAX_BYTES + 1), { headers: { "content-type": "audio/mpeg" } })));
+ vi.stubGlobal("fetch", vi.fn(async () => new Response(new Uint8Array(PREVIEW_MAX_BYTES + 1), { headers: { "content-type": "audio/mpeg" } })));
await expect(loadMessageAudio(clip, message, new AbortController().signal)).rejects.toThrow("25 MB");
});
});
@@ -211,13 +211,13 @@ describe("explicit local video preview", () => {
it("enforces the video size limit with and without Content-Length", async () => {
vi.stubGlobal("fetch", vi.fn(async () => new Response("video", {
- headers: { "content-type": "video/mp4", "content-length": String(FILE_MAX_BYTES + 1) },
+ headers: { "content-type": "video/mp4", "content-length": String(PREVIEW_MAX_BYTES + 1) },
})));
await expect(loadMessageVideo(file, message, new AbortController().signal)).rejects.toMatchObject({
code: "file_too_large",
message: "This file is 25.1 MB, over the 25 MB preview limit. You can still download it below.",
});
- vi.stubGlobal("fetch", vi.fn(async () => new Response(new Uint8Array(FILE_MAX_BYTES + 1), { headers: { "content-type": "video/mp4" } })));
+ vi.stubGlobal("fetch", vi.fn(async () => new Response(new Uint8Array(PREVIEW_MAX_BYTES + 1), { headers: { "content-type": "video/mp4" } })));
await expect(loadMessageVideo(file, message, new AbortController().signal)).rejects.toMatchObject({
code: "file_too_large",
message: "Preview is limited to 25 MB.",
diff --git a/src/components/AttachmentGallery.tsx b/src/components/AttachmentGallery.tsx
index dd6b572e08..c9d057a78b 100644
--- a/src/components/AttachmentGallery.tsx
+++ b/src/components/AttachmentGallery.tsx
@@ -3,7 +3,7 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { fromMarkdown } from "mdast-util-from-markdown";
import { ChevronDown, ChevronUp, Download, Film, LoaderCircle, Music, Play, X } from "lucide-react";
-import { attachmentBasename, FILE_MAX_BYTES, type TranscriptFileAttachment, type TranscriptImageAttachment } from "@/lib/composer-attachments";
+import { attachmentBasename, PREVIEW_MAX_BYTES, type TranscriptFileAttachment, type TranscriptImageAttachment } from "@/lib/composer-attachments";
import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
import { windowsPathDestinations } from "../../shared/markdown-windows-paths";
@@ -190,7 +190,7 @@ async function readMessageVideo(
throw new Error(t("attach.videoUnavailable"));
}
const declared = Number(response.headers.get("content-length"));
- if (declared > FILE_MAX_BYTES) {
+ if (declared > PREVIEW_MAX_BYTES) {
await response.body?.cancel();
throw previewTooLarge(declared);
}
@@ -206,7 +206,7 @@ async function readMessageVideo(
if (done) break;
size += value.byteLength;
// Bytes read so far are not the file size, so this says only the preview limit; still no Retry.
- if (size > FILE_MAX_BYTES) throw Object.assign(new Error(t("attach.fileTooLarge")), { code: "file_too_large" });
+ if (size > PREVIEW_MAX_BYTES) throw Object.assign(new Error(t("attach.fileTooLarge")), { code: "file_too_large" });
chunks.push(new Uint8Array(value));
progress();
}
@@ -223,7 +223,7 @@ function megabytes(bytes: number): string {
/** Only the inline player reads the whole file into memory; the download below still saves it. */
export function previewTooLarge(bytes: number): Error {
- const message = t("attach.previewTooLarge", { size: megabytes(bytes), limit: megabytes(FILE_MAX_BYTES) });
+ const message = t("attach.previewTooLarge", { size: megabytes(bytes), limit: megabytes(PREVIEW_MAX_BYTES) });
return Object.assign(new Error(message), { code: "file_too_large" });
}
@@ -337,7 +337,7 @@ async function readMessageAudio(
throw new Error(t("attach.audioUnavailable"));
}
const declared = Number(response.headers.get("content-length"));
- if (declared > FILE_MAX_BYTES) {
+ if (declared > PREVIEW_MAX_BYTES) {
await response.body?.cancel();
throw new Error(t("attach.fileTooLarge"));
}
@@ -351,7 +351,7 @@ async function readMessageAudio(
const { value, done } = await reader.read();
if (done) break;
size += value.byteLength;
- if (size > FILE_MAX_BYTES) throw new Error(t("attach.fileTooLarge"));
+ if (size > PREVIEW_MAX_BYTES) throw new Error(t("attach.fileTooLarge"));
chunks.push(new Uint8Array(value));
progress();
}
diff --git a/src/lib/composer-attachments.test.ts b/src/lib/composer-attachments.test.ts
index d7806acefc..fec40fbe57 100644
--- a/src/lib/composer-attachments.test.ts
+++ b/src/lib/composer-attachments.test.ts
@@ -9,12 +9,14 @@ import {
clipboardImageFiles,
composeMessage,
documentMime,
+ FILE_MAX_BYTES,
fileAttachment,
fileAttachmentFromFile,
handoffAttachmentImagePreview,
imageAttachmentFromFile,
isImageFile,
optimisticImageAttachment,
+ PREVIEW_MAX_BYTES,
releaseAttachmentImagePreview,
splitTranscriptAttachments,
type ImageAttachment,
@@ -511,17 +513,34 @@ describe("private document intake", () => {
}
});
+ /** A file that reports a size without holding the bytes in the test. */
+ const sized = (name: string, type: string, size: number) => Object.defineProperty(new File([new Uint8Array(3)], name, { type }), "size", { value: size });
+
it("rejects oversized audio before uploading", async () => {
const fetch = vi.spyOn(globalThis, "fetch");
try {
- const file = new File([new Uint8Array(25 * 1024 * 1024 + 1)], "large.opus", { type: "audio/opus" });
- await expect(fileAttachmentFromFile(file)).rejects.toMatchObject({ status: 413 });
+ await expect(fileAttachmentFromFile(sized("large.opus", "audio/opus", FILE_MAX_BYTES + 1))).rejects.toMatchObject({
+ status: 413, problem: { kind: "too-large", name: "large.opus", limitMb: 100 },
+ });
expect(fetch).not.toHaveBeenCalled();
} finally {
fetch.mockRestore();
}
});
+ it("sends a file over the preview size: the composer takes what the server keeps", async () => {
+ const fetch = vi.spyOn(globalThis, "fetch").mockResolvedValue(new Response(JSON.stringify({
+ path: "/private/attachments/big.pdf", name: "Scan.pdf", bytes: PREVIEW_MAX_BYTES + 1,
+ }), { status: 201, headers: { "content-type": "application/json" } }));
+ try {
+ const file = sized("Scan.pdf", "application/pdf", PREVIEW_MAX_BYTES + 1);
+ await expect(fileAttachmentFromFile(file)).resolves.toMatchObject({ kind: "file", name: "Scan.pdf", size: PREVIEW_MAX_BYTES + 1 });
+ expect(fetch).toHaveBeenCalledWith(expect.stringMatching(/^\/api\/files\?/), expect.objectContaining({ method: "POST", body: file }));
+ } finally {
+ fetch.mockRestore();
+ }
+ });
+
it("recognises supported documents by declared mime or filename", () => {
expect(documentMime({ name: "notes.bin", type: "text/markdown; charset=utf-8" })).toBe("text/markdown");
expect(documentMime({ name: "REPORT.PDF", type: "" })).toBe("application/pdf");
diff --git a/src/lib/composer-attachments.ts b/src/lib/composer-attachments.ts
index d9f1c5be76..18f025b7d7 100644
--- a/src/lib/composer-attachments.ts
+++ b/src/lib/composer-attachments.ts
@@ -1,5 +1,6 @@
import { isCitationAttachment, serializeCitation, type CitationAttachment } from "./citations.ts";
import { randomUuid } from "./random-uuid.ts";
+import { FILE_MAX_BYTES } from "../../shared/upload-limits.ts";
export { dataContextFor, type DataContext, type DataViewContext } from "../../shared/data-context.ts";
export type PasteAttachment = {
@@ -91,7 +92,8 @@ export function fileAttachment(name: string, path: string, size: number): FileAt
/** Must match the server's IMAGE_MAX_BYTES. */
export const IMAGE_MAX_BYTES = 10 * 1024 * 1024;
-export const FILE_MAX_BYTES = 25 * 1024 * 1024;
+/** One limit for a sent file on every surface; previews read whole stay at PREVIEW_MAX_BYTES. */
+export { FILE_MAX_BYTES, PREVIEW_MAX_BYTES } from "../../shared/upload-limits.ts";
/** Must match the server's TURN_IMAGE_MAX_COUNT: a message carrying more images is refused at send. */
export const TURN_IMAGE_MAX_COUNT = 10;