Skip to content

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

Let a bot send archives (.zip, .tar.gz, .7z, ...) to the chat as downloads (#5842)

Milind Sonia6cd67c78610
diff --git a/server/bot-attachment.test.ts b/server/bot-attachment.test.ts
index 11a0029c6b..be801f9abe 100644
--- a/server/bot-attachment.test.ts
+++ b/server/bot-attachment.test.ts
@@ -111,7 +111,7 @@ describe("saveBotAttachment", () => {
});
it("names what is supported when the type is not", async () => {
- for (const name of ["page.html", "logo.svg", "run.exe", "bundle.zip", "noextension"]) {
+ for (const name of ["page.html", "logo.svg", "run.exe", "bundle.cab", "data.tar.zst", "noextension"]) {
writeFileSync(join(WORK, name), "x");
await expect(saveBotAttachment({ path: name, roots: [WORK] }), name).rejects.toMatchObject({
status: 415,
@@ -127,6 +127,46 @@ describe("saveBotAttachment", () => {
});
});
+describe("saveBotAttachment for an archive", () => {
+ // Typed by the name's last extension, like a person's upload: build.tar.gz is a .gz.
+ const archives: Array<[string, string, string]> = [
+ ["project.zip", "application/zip", ".zip"],
+ ["photos.rar", "application/vnd.rar", ".rar"],
+ ["dump.7z", "application/x-7z-compressed", ".7z"],
+ ["site.tar", "application/x-tar", ".tar"],
+ ["log.gz", "application/gzip", ".gz"],
+ ["src.tgz", "application/x-compressed-tar", ".tgz"],
+ ["data.bz2", "application/x-bzip2", ".bz2"],
+ ["db.xz", "application/x-xz", ".xz"],
+ ["build.tar.gz", "application/gzip", ".gz"],
+ ["BUNDLE.ZIP", "application/zip", ".zip"],
+ ["Release.TAR.GZ", "application/gzip", ".gz"],
+ ];
+
+ it.each(archives)("attaches %s as a plain file, stored as sent", async (name, mime, extension) => {
+ const bytes = Buffer.concat([Buffer.from([0x50, 0x4b, 0x03, 0x04]), Buffer.from(`not unpacked: ${name}`)]);
+ writeFileSync(join(WORK, name), bytes);
+ const saved = await saveBotAttachment({ path: name, roots: [WORK] });
+ expect(saved.attachment).toMatchObject({ kind: "file", mime });
+ if (saved.attachment.kind === "file") expect(saved.attachment.name.toLowerCase()).toBe(name.toLowerCase());
+ expect(saved.attachment.path.startsWith(ATTACHMENTS_DIR)).toBe(true);
+ expect(saved.attachment.path.endsWith(extension)).toBe(true);
+ expect(readFileSync(saved.attachment.path)).toEqual(bytes);
+ expect(saved.bytes).toBe(bytes.byteLength);
+ });
+
+ it("keeps the file size limit and the folder rules", async () => {
+ const big = join(WORK, "huge.zip");
+ writeFileSync(big, "PK");
+ truncateSync(big, FILE_MAX_BYTES + 1);
+ await expect(saveBotAttachment({ path: "huge.zip", roots: [WORK] })).rejects.toMatchObject({ status: 413, code: "file_too_large" });
+ rmSync(big);
+ writeFileSync(join(DATA_ROOT, "outside.zip"), "PK");
+ await expect(saveBotAttachment({ path: join(DATA_ROOT, "outside.zip"), roots: [WORK] })).rejects.toMatchObject({ status: 403 });
+ await expect(saveBotAttachment({ path: "../outside.zip", roots: [WORK] })).rejects.toMatchObject({ status: 403 });
+ });
+});
+
describe("saveBotAttachment for a file a turn saved outside its folders", () => {
// Where a person might ask for output: outside every root, not hidden.
const DESIGNS = join(DATA_ROOT, "Desktop", "designs", "2026-10-08_News");
@@ -198,8 +238,8 @@ describe("saveBotAttachment for a file a turn saved outside its folders", () =>
const since = Date.now();
const turn = { roots: [WORK], savedThisTurn: { since, refuse } };
await expect(saveBotAttachment({ path: DESIGNS, ...turn })).rejects.toMatchObject({ status: 400 });
- writeFileSync(join(DESIGNS, "bundle.zip"), "PK");
- await expect(saveBotAttachment({ path: join(DESIGNS, "bundle.zip"), ...turn })).rejects.toMatchObject({ status: 415 });
+ writeFileSync(join(DESIGNS, "bundle.cab"), "MSCF");
+ await expect(saveBotAttachment({ path: join(DESIGNS, "bundle.cab"), ...turn })).rejects.toMatchObject({ status: 415 });
const big = join(DESIGNS, "big.mp4");
writeFileSync(big, "x");
truncateSync(big, FILE_MAX_BYTES + 1);
diff --git a/server/bot-attachment.ts b/server/bot-attachment.ts
index 0259f2f49b..cce3dc723d 100644
--- a/server/bot-attachment.ts
+++ b/server/bot-attachment.ts
@@ -16,7 +16,8 @@ export type BotAttachment = NonNullable<Message["attachments"]>[number];
export const ATTACH_SUPPORTED_TYPES =
"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";
+ "pdf, Word/Excel/PowerPoint and OpenDocument files, csv, tsv, txt, md, json, rtf, " +
+ "and archives (zip, rar, 7z, tar, gz, tgz, bz2, xz)";
function statusError(status: number, message: string): Error & { status: number } {
return Object.assign(new Error(message), { status });
diff --git a/server/drivers/agents-bridge-wire.test.ts b/server/drivers/agents-bridge-wire.test.ts
index 9ba814978b..4319d15f68 100644
--- a/server/drivers/agents-bridge-wire.test.ts
+++ b/server/drivers/agents-bridge-wire.test.ts
@@ -84,34 +84,34 @@ const FULL = "skills+shared+voice+x+team+images+hosting";
* either: lock a saving in by lowering the number. A Chief's list is longer
* than another bot's only by the Chief-only names in find_tool's description. */
const BUDGET_BASELINE: Record<string, number> = {
- "default": 18331,
+ "default": 18379,
"voice": 19206,
- "shared": 18371,
+ "shared": 18419,
"shared+voice": 19246,
- "skills": 18358,
+ "skills": 18406,
"skills+voice": 19233,
- "skills+shared": 18398,
+ "skills+shared": 18446,
"skills+shared+voice": 19273,
- "non-chief": 18214,
+ "non-chief": 18262,
"voice+non-chief": 18995,
- "shared+non-chief": 18254,
+ "shared+non-chief": 18302,
"shared+voice+non-chief": 19035,
- "skills+non-chief": 18241,
+ "skills+non-chief": 18289,
"skills+voice+non-chief": 19022,
- "skills+shared+non-chief": 18281,
+ "skills+shared+non-chief": 18329,
"skills+shared+voice+non-chief": 19062,
"skills+shared+voice+cloud-home": 19289,
"skills+shared+voice+non-chief+cloud-home": 19078,
"skills+shared+voice+x": 19352,
"skills+shared+voice+x+team": 19352,
- "default+legacy-switches": 18331,
- "default+mausbot": 18383,
+ "default+legacy-switches": 18379,
+ "default+mausbot": 18431,
"skills+shared+voice+mausbot": 19325,
- "default+no-computer-pick": 17119,
+ "default+no-computer-pick": 17167,
"default+room": 17389,
"non-chief+room": 17272,
"skills+shared+voice+x+team+images": 19274,
- "default+images": 18347,
+ "default+images": 18395,
"skills+shared+voice+x+team+images+hosting": 20668,
"default+hosting": 19743,
};
diff --git a/server/drivers/agents-catalog-goldens/bridged.profiles.json b/server/drivers/agents-catalog-goldens/bridged.profiles.json
index 6fe033be99..d73fafe8b0 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": 18651,
- "sha256": "4a1fc605dc7ad4ea84ec2748221f94f44915a83ee9fea3c3d885fa2e1e10a05d",
+ "bytes": 18699,
+ "sha256": "cc64e6ddf60050cf5f548c88b50cc552b6c1e2079100c6e838d12299a1d9549d",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -23,8 +23,8 @@
]
},
"voice": {
- "bytes": 19432,
- "sha256": "a3c87a70ad905c9fdc8e2c7b2d0789f3b6b8a345ef7e15227fa99cc9d4f87dff",
+ "bytes": 19480,
+ "sha256": "c71c0918b96d845e1178b1a9db33d2cbed89d3430c1716550f3a88d908168e76",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -47,8 +47,8 @@
]
},
"shared": {
- "bytes": 18691,
- "sha256": "005bbe97fbac1974b152835d949c3483896b04a67dfd7cf414d90f2e594a53d8",
+ "bytes": 18739,
+ "sha256": "99b3426365f9738461c4ddc7d4276d3fb88c1bf2623b94dc11705b7f1988104c",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -70,8 +70,8 @@
]
},
"shared+voice": {
- "bytes": 19472,
- "sha256": "23763e33556753b7b1075a01037d7e66ace07c147ab7f951723b377c29cbae61",
+ "bytes": 19520,
+ "sha256": "9bfeec34cdc2ed0cf562da6d5f18d99c1ac8e19cab82fef47f338f04d5b977b1",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -94,8 +94,8 @@
]
},
"skills": {
- "bytes": 18678,
- "sha256": "a04a468b2cefd2c06dfbbd7af42356e9d60f4a64b4f888213b077023001f0c83",
+ "bytes": 18726,
+ "sha256": "c886893cd90e1230f40f714bcd01b240f29e7da964280955e07bf3577d143cde",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -117,8 +117,8 @@
]
},
"skills+voice": {
- "bytes": 19459,
- "sha256": "4c999c3e290d6ddce8d061558de4e5f2c7c23899ca7930f2c8fce1c19c0095bf",
+ "bytes": 19507,
+ "sha256": "b060b80fcacabcb9c50d6e2300ddf144cf63b513afb08ce7fe251da64df7db4d",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -141,8 +141,8 @@
]
},
"skills+shared": {
- "bytes": 18718,
- "sha256": "b298f8bab5135d3e92b69c175ec1e193cf1489bd1124cd435ef7971727ff29d1",
+ "bytes": 18766,
+ "sha256": "d7cfb7975c540d82aae61f2716002fbfa8221f0c75e6e188a50a63ebf740bfa9",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -164,8 +164,8 @@
]
},
"skills+shared+voice": {
- "bytes": 19499,
- "sha256": "0d4ee7d86841a2ec20a45a4b58cd5ed060ac0ecf04864840b405ffc19ef4fc19",
+ "bytes": 19547,
+ "sha256": "0675a8b109cf3014ead4c80cdef5df804c783c0007057657a28ce1a7ae7d0823",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -188,8 +188,8 @@
]
},
"non-chief": {
- "bytes": 18534,
- "sha256": "c23bd40198830815705adde77490bad0854e52ee58eb3534b2116bcdb2f75d93",
+ "bytes": 18582,
+ "sha256": "999d8d3d99715c8c5ef5471d12a3fb9ff7a8ab36cb98440683517191e8810ff1",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -211,8 +211,8 @@
]
},
"voice+non-chief": {
- "bytes": 19315,
- "sha256": "674d50bdf0770f120f18c0c790ab4ca13c764eb5d31623828f40d2d4f060d2a4",
+ "bytes": 19363,
+ "sha256": "41c1c3985160f5a60863054775a9b210de80ec4a9524368677cd2b89c0ac12f7",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -235,8 +235,8 @@
]
},
"shared+non-chief": {
- "bytes": 18574,
- "sha256": "fb9b82ac22ff2728c38a95cf2f008285bd7a5efed216d8b9ab862ec793660d35",
+ "bytes": 18622,
+ "sha256": "6a3c98a7b020aed0a19fea0c18d662d3c11c53dacd9be32a6da015af034d3744",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -258,8 +258,8 @@
]
},
"shared+voice+non-chief": {
- "bytes": 19355,
- "sha256": "416f1fdfb47b46e096238ed42cb084c919c1feddef9a256a4d31edaf7be7bd61",
+ "bytes": 19403,
+ "sha256": "1cd5df5d72cd493276ee864caeb30efa6cdc25216ad0a50ab1ad98dd78cea5bf",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -282,8 +282,8 @@
]
},
"skills+non-chief": {
- "bytes": 18561,
- "sha256": "37e9f6ec7623ebf345051d12661705fc4ae90b3c96b1bae704713333317ea618",
+ "bytes": 18609,
+ "sha256": "25632ee775de480c2bcc16afacbadfe5dc90cc89f91679a3b7a752138fff4b21",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -305,8 +305,8 @@
]
},
"skills+voice+non-chief": {
- "bytes": 19342,
- "sha256": "a455e0dd93b13b70d009d05753aba68421c70f53f3a746398f4c3b388f64db42",
+ "bytes": 19390,
+ "sha256": "4937c5f78a24083f72e1f2069c0e67136cbee1d588a74a2476b3e469e2c6c253",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -329,8 +329,8 @@
]
},
"skills+shared+non-chief": {
- "bytes": 18601,
- "sha256": "cf88076df94c7d4a2a4ad6f89d127fe6f263a567e613b6535950936d55531af2",
+ "bytes": 18649,
+ "sha256": "38d409956cb21c4d6103da779ca294a8a1dcb5e2dfa9b367db97d07454dd1b80",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -352,8 +352,8 @@
]
},
"skills+shared+voice+non-chief": {
- "bytes": 19382,
- "sha256": "e930f84a92cd6b39ca122d4abd7dd6944d8b90bd5e0e1a2c2ba4450b93589b03",
+ "bytes": 19430,
+ "sha256": "00a194f5e2cdf06cdcb19f97be4ed5016b3b3ddf1251f82def417b705d902dfe",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -376,8 +376,8 @@
]
},
"skills+shared+voice+cloud-home": {
- "bytes": 19515,
- "sha256": "6a742a734ce3a5ee4d3dc1a5547f8afd66d1385378a79dbdbf45ff6549ca8b01",
+ "bytes": 19563,
+ "sha256": "f12b01e009db507c850f556811a144ab9457fdbd8f31dac93fcf3a0c4c1a8d58",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -400,8 +400,8 @@
]
},
"skills+shared+voice+non-chief+cloud-home": {
- "bytes": 19398,
- "sha256": "bdf52d1787b9dc1a5b06e3f94ec1e3ea8228b2b6d47780c682d1850c2172638d",
+ "bytes": 19446,
+ "sha256": "27bd209e6cec8e9c46fccbd8aa77f7841e5a69cbdd7a7eda5889f64a19970bbc",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -424,8 +424,8 @@
]
},
"skills+shared+voice+x": {
- "bytes": 19560,
- "sha256": "6f854f04ccc6eac878b97c9062c5c0c3b7ef6c2fe3ded2a9ae70c0ca5e446d1c",
+ "bytes": 19608,
+ "sha256": "2d722e0214a70459cb00333069cf83eaf080bb1edc1744453a1124c1a7864d19",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -448,8 +448,8 @@
]
},
"skills+shared+voice+x+team": {
- "bytes": 19560,
- "sha256": "6f854f04ccc6eac878b97c9062c5c0c3b7ef6c2fe3ded2a9ae70c0ca5e446d1c",
+ "bytes": 19608,
+ "sha256": "2d722e0214a70459cb00333069cf83eaf080bb1edc1744453a1124c1a7864d19",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -472,8 +472,8 @@
]
},
"skills+shared+voice+x+team+images": {
- "bytes": 19576,
- "sha256": "2c89e7dbe68dd11f060d4eb66abda3443e4e9ca19cf937b8e0868578ee6b571f",
+ "bytes": 19624,
+ "sha256": "584c9c3348a971b728b067f5c9c461a4e8c5621b534f8e8921fb44a66a2c303e",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -496,8 +496,8 @@
]
},
"default+legacy-switches": {
- "bytes": 18651,
- "sha256": "4a1fc605dc7ad4ea84ec2748221f94f44915a83ee9fea3c3d885fa2e1e10a05d",
+ "bytes": 18699,
+ "sha256": "cc64e6ddf60050cf5f548c88b50cc552b6c1e2079100c6e838d12299a1d9549d",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -519,8 +519,8 @@
]
},
"default+mausbot": {
- "bytes": 18703,
- "sha256": "18c24f6e014e65cc6ac996fdf487afba006b6accf9b10ad36bdf204dd914e5ce",
+ "bytes": 18751,
+ "sha256": "eb6cc9a199b3dd4559901f4b8811d870cdcd3f1f7be6b02bada3b4ffaf621bfd",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -542,8 +542,8 @@
]
},
"skills+shared+voice+mausbot": {
- "bytes": 19551,
- "sha256": "e272c08e1601de93d22ca6795828cacc924a075153ee70574795ba46997e715b",
+ "bytes": 19599,
+ "sha256": "3f12d61f6e66b05da9a9e68cd1b20635e853a07e2a8712cd25a95fc47e65a557",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -566,8 +566,8 @@
]
},
"default+no-computer-pick": {
- "bytes": 17439,
- "sha256": "f92c4ae6bd4386cb0bfc179a7b898f5bb78c96f830d9550773eee7a47771722b",
+ "bytes": 17487,
+ "sha256": "7140b719a5131b605150a1eb26212f7252f53db2ec1e66997adfef01172579ed",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -588,8 +588,8 @@
]
},
"default+room": {
- "bytes": 17395,
- "sha256": "813ea4caaa07c73dadb291fefd794ac032f9f625e00e992cbdf7b9dfbf734195",
+ "bytes": 17443,
+ "sha256": "dc75a881741dbc7c8b1bebb060500d11ee2397fff2deec990de3266921babfe7",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -610,8 +610,8 @@
]
},
"non-chief+room": {
- "bytes": 17278,
- "sha256": "c2084e23c25ce918613687590e549dbd5245ab55571d46be827c365f8774fb9f",
+ "bytes": 17326,
+ "sha256": "7c2bc2bb735397dde3277b09806f1cddd3002602c6bf03a650b0a841c9c90fda",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -632,8 +632,8 @@
]
},
"default+images": {
- "bytes": 18667,
- "sha256": "4308160ad757679ad1fdcaedc8a5583d96538814698edd55877b69f7c48bedda",
+ "bytes": 18715,
+ "sha256": "f9b016ced20acabcb087215bcaa0f4301a85630240e3605f10312625e3c099e1",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -655,8 +655,8 @@
]
},
"skills+shared+voice+x+team+images+hosting": {
- "bytes": 20778,
- "sha256": "944e28419af23e66dfc4e2e37ad01f82f44c4434b2e21eea0932d000d216c0b1",
+ "bytes": 20826,
+ "sha256": "2eef23a68b32b8ed2212476805f900dc8e28559d1b181214ce9c45849b9aabc7",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -680,8 +680,8 @@
]
},
"default+hosting": {
- "bytes": 19853,
- "sha256": "2455feec30f89b22f013e89c901528c7fe30e4ca0f343134640eb915906a81a9",
+ "bytes": 19901,
+ "sha256": "eda419ddb831e818e5ed48a0794376012bebd79d8ead1bd2549e364cfe3694ae",
"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 fe18ae00cb..3bb7fc4bf4 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 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.",
+ "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, csv, tsv, txt, md, json, rtf, and archives (zip, rar, 7z, tar, gz, tgz, bz2, xz). 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 3bc2a6ed90..479e881c35 100644
--- a/server/drivers/agents-catalog-goldens/full.tools-list.json
+++ b/server/drivers/agents-catalog-goldens/full.tools-list.json
@@ -435,7 +435,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 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.",
+ "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, csv, tsv, txt, md, json, rtf, and archives (zip, rar, 7z, tar, gz, tgz, bz2, xz). 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 55ff4d6909..af0ff42564 100644
--- a/server/drivers/agents-catalog-goldens/profiles.json
+++ b/server/drivers/agents-catalog-goldens/profiles.json
@@ -1,7 +1,7 @@
{
"default": {
- "bytes": 64430,
- "sha256": "fdb7450572a3c61d6f4614f6b039e213c54b5564023d8ab4499ce29ad139b446",
+ "bytes": 64478,
+ "sha256": "52b5536ced2f5c6a7a07efc00350561e9cd045780bb4561230b0fb74da73d0ba",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -55,8 +55,8 @@
]
},
"voice": {
- "bytes": 65211,
- "sha256": "4c589a35da6368e1d307175bd5b549ac8c6cd121dcc0039aec4039457b1d1661",
+ "bytes": 65259,
+ "sha256": "54ac975fec1ffb542c748d9ba0c771e08701edc1e2ed8fc2c377a50c69a5ba5d",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -111,8 +111,8 @@
]
},
"shared": {
- "bytes": 66695,
- "sha256": "c4e0c297772bd3c0f88f98beed577d83308ab1fc2a35c62c972114b7bd48b467",
+ "bytes": 66743,
+ "sha256": "ec017b32059b24095de724725c056dbea4e9b31294ae6920352514dc2bc1f9ee",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -168,8 +168,8 @@
]
},
"shared+voice": {
- "bytes": 67476,
- "sha256": "50ed0fb42c0a4773a2f3ed3adf85d5831331ed665585f31639f7b1105693d3cd",
+ "bytes": 67524,
+ "sha256": "71c940d1067bafa300946716600192a530e1b745a75486c57df063579ec7c07b",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -226,8 +226,8 @@
]
},
"skills": {
- "bytes": 67506,
- "sha256": "6af3cabd8244e03d2a96b008c64d98f9f7eeb18d0aa91afe68a9cd8aa04ffc52",
+ "bytes": 67554,
+ "sha256": "b35e90e8bdf49d8e820d460a103b9177ad30c51f15be5624ece142261185ec21",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -283,8 +283,8 @@
]
},
"skills+voice": {
- "bytes": 68287,
- "sha256": "3c34d5963a8e399240983a8ec41aa8e06d2809f75d2c23fa9aa8f3f7f0966ca5",
+ "bytes": 68335,
+ "sha256": "765ca7a69b425362ac147010c68554587a0047f824e34c0c96f1453171454c3c",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -341,8 +341,8 @@
]
},
"skills+shared": {
- "bytes": 69771,
- "sha256": "7c457c19e711c5ac02feb06e5d0c90e5223d9532ad014016c8e1dbede300e8a4",
+ "bytes": 69819,
+ "sha256": "022aacc37d2a8585e04f97d83b0756243db00be531995a1dbbd5ba4d5b225965",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -400,8 +400,8 @@
]
},
"skills+shared+voice": {
- "bytes": 70552,
- "sha256": "952334bb5212777ee18e60c030967c62ad638712b3df783ace87f7488a72c30c",
+ "bytes": 70600,
+ "sha256": "6c9c25afb27b1ca4464717585588d9e501e01ab8486940cc02386cc9cf0352d0",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -460,8 +460,8 @@
]
},
"non-chief": {
- "bytes": 54933,
- "sha256": "51dcb7904b8548d31f6be1f38a3884d87a96901c9ba7a285cd2d8829f56e733b",
+ "bytes": 54981,
+ "sha256": "8f4747839dc8f2d1d0d0a9781c33f04e4ee73aa89837a727e52bd2fe5fdde5d2",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -508,8 +508,8 @@
]
},
"voice+non-chief": {
- "bytes": 55714,
- "sha256": "186c8e8bfa8e99d0e840c3a2c6555498ca48a371cac11e36a1c2ec82e7ac513a",
+ "bytes": 55762,
+ "sha256": "664d85a0f97f9a34d936d82789c826f716909b7bd190cd33f6c2cc91c2e7962d",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -557,8 +557,8 @@
]
},
"shared+non-chief": {
- "bytes": 57198,
- "sha256": "88258178bf9e365d56ca3d97203dbecad46b7d344ac9999e5764c2ef2074026f",
+ "bytes": 57246,
+ "sha256": "e249ace2419749500a7ceb8f5d19537dac26ef1a4ef7195523c05faee89cac13",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -607,8 +607,8 @@
]
},
"shared+voice+non-chief": {
- "bytes": 57979,
- "sha256": "f39cf7350c59cfc9974bae3a4e062d7e15bc3d73c504de3c8cd5821fa07c9e28",
+ "bytes": 58027,
+ "sha256": "ef9fe7814bb38cf330b542a62db361d6d12459a34c0021f474f02fe68af6ed31",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -658,8 +658,8 @@
]
},
"skills+non-chief": {
- "bytes": 58009,
- "sha256": "9319e3ff6d9823a120a3d12bcd6ba61f8d015a494e172bcd0d1c6d97ffe6b7bc",
+ "bytes": 58057,
+ "sha256": "8e7806b3384b9dfbec428162db0b03ea32a58fb7b7b1b460fdb9ea3032f76fbf",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -708,8 +708,8 @@
]
},
"skills+voice+non-chief": {
- "bytes": 58790,
- "sha256": "4c3b4e7ebbcfd7c4b3394590c511fc3a9c8fbc6b76b76f5a1209b14c42ed50bc",
+ "bytes": 58838,
+ "sha256": "089a2b90203f1fdc29398e51e301db875022eb661c1d73a7c50f71aff36de27b",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -759,8 +759,8 @@
]
},
"skills+shared+non-chief": {
- "bytes": 60274,
- "sha256": "cd8c050e5127ff9ef4142dc05ed12287c9106d1779a84af6eb5a80018b3718a9",
+ "bytes": 60322,
+ "sha256": "ae727dd03afe7d7cf78b1578cecb1db4528953e757ffe509afa3b72a37d5cce6",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -811,8 +811,8 @@
]
},
"skills+shared+voice+non-chief": {
- "bytes": 61055,
- "sha256": "64e9f61c07218ee328cef7b930d23943a8c0de02f5909423057f0425fd1addb0",
+ "bytes": 61103,
+ "sha256": "8a6e1e5ff7e270b17d9aef61cf771597196629b6385bb9a8c51d9ae92d12367e",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -864,8 +864,8 @@
]
},
"skills+shared+voice+cloud-home": {
- "bytes": 70318,
- "sha256": "99e384f91fb663f7abda8c6e1ed540e978105f403ef207eee5cb94df5d4dbc50",
+ "bytes": 70366,
+ "sha256": "64fe1c0b7643819b01a943724e26876ba690177f9d0bd6007f0536dbcd24eb50",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -924,8 +924,8 @@
]
},
"skills+shared+voice+non-chief+cloud-home": {
- "bytes": 60821,
- "sha256": "f044d3c2254a15d0a61731de291f462e8108b786f7ad4993714f1979fd0789ef",
+ "bytes": 60869,
+ "sha256": "0838a621aa0683c08632581856edd4674faa8753113a2664e9c46fb9430bb04b",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -977,8 +977,8 @@
]
},
"skills+shared+voice+x": {
- "bytes": 74391,
- "sha256": "daf4bc1ed1d34decc7a19bf3d6978dfcedb09ac4a3c2308ff85ad5905846efb6",
+ "bytes": 74439,
+ "sha256": "2e2a223d8ac9ec5e96778710b33e05d3e7315c0c0fcd4c375a6e53b96a7961b5",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1041,8 +1041,8 @@
]
},
"skills+shared+voice+x+team": {
- "bytes": 74391,
- "sha256": "daf4bc1ed1d34decc7a19bf3d6978dfcedb09ac4a3c2308ff85ad5905846efb6",
+ "bytes": 74439,
+ "sha256": "2e2a223d8ac9ec5e96778710b33e05d3e7315c0c0fcd4c375a6e53b96a7961b5",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1105,8 +1105,8 @@
]
},
"skills+shared+voice+x+team+images": {
- "bytes": 75164,
- "sha256": "6bb97a76748d2e61cb4591d2673bd13c045083198790e6a82d4188efb73e088e",
+ "bytes": 75212,
+ "sha256": "903a4f622cb76460dec251a206797f93f4defd58f75b9a11a2cc254694bc004a",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1170,8 +1170,8 @@
]
},
"default+legacy-switches": {
- "bytes": 64430,
- "sha256": "fdb7450572a3c61d6f4614f6b039e213c54b5564023d8ab4499ce29ad139b446",
+ "bytes": 64478,
+ "sha256": "52b5536ced2f5c6a7a07efc00350561e9cd045780bb4561230b0fb74da73d0ba",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1225,8 +1225,8 @@
]
},
"default+mausbot": {
- "bytes": 65081,
- "sha256": "c556266fc366834f22846a8ddb664ca478de990d10cef468ccb0a721e6b48d8e",
+ "bytes": 65129,
+ "sha256": "539e64204cbe6b7c8c3fb07751998b2b6398c091353d1ea32d3126a0343b2c00",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1282,8 +1282,8 @@
]
},
"skills+shared+voice+mausbot": {
- "bytes": 71203,
- "sha256": "7afcb75a26d575335c28e6c4a8fe4a4b288d7e9e4efd97bd54a9335d4c8dc917",
+ "bytes": 71251,
+ "sha256": "d4d62d43aaa53149f0a697109f063f5f0ed3db8b71435b168393b552a4448891",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1344,8 +1344,8 @@
]
},
"default+no-computer-pick": {
- "bytes": 63218,
- "sha256": "3ddfba221f672c3deb77ff0c1a6e7f32efc91b3a00de2841c5a07c11cf75d2a6",
+ "bytes": 63266,
+ "sha256": "47b26fa9cb56ce8430af524136bfc58f641a00f4be206801d15e9dfaeb0f12fd",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1398,8 +1398,8 @@
]
},
"default+room": {
- "bytes": 60720,
- "sha256": "0a5d012354fa5edf4f980d28aaa1812a5beb8750688ad48cd2ef81a6b0bd7f78",
+ "bytes": 60768,
+ "sha256": "98303d0cada2c1ab2dc56b27691b9b55b9249453c8dbb2cac91e95c3ff769688",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1448,8 +1448,8 @@
]
},
"non-chief+room": {
- "bytes": 51223,
- "sha256": "b1c6380e4601b13cf0ab4950724195e2f97a0381979793f1f7caeb7357b7be26",
+ "bytes": 51271,
+ "sha256": "ad3d3fdce1f7707b104c52af72c17b828b03b6ee3ce56af9d6ea7b2e37df7959",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1491,8 +1491,8 @@
]
},
"default+images": {
- "bytes": 65203,
- "sha256": "284f8213d22d8bae4f045dd9dd2cd356b0e99ab9f85f9c4f0bf3e3d01b5d76d0",
+ "bytes": 65251,
+ "sha256": "c532180a3714a01fb37c9ef4bca35f48a33e63090e618c7e278f02cf09d7ba9e",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1547,8 +1547,8 @@
]
},
"skills+shared+voice+x+team+images+hosting": {
- "bytes": 77027,
- "sha256": "9e80dbb89d28a24184ed8cba5e69c188ecc7835a52af7b3cb4578f95aa150adf",
+ "bytes": 77075,
+ "sha256": "2146573fb336f1dfe7305307b3fcf0a0ce45999fbfbe7c3c272095ceeb14448e",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1614,8 +1614,8 @@
]
},
"default+hosting": {
- "bytes": 66293,
- "sha256": "fdcfd8817fdb3946faf148b1dd0a72b0b4f0504f1ac096f1f03cce8fa2b06a49",
+ "bytes": 66341,
+ "sha256": "87e10d0febbf3f51e94ddc34d5d92f624c97de54a02cc18549c63a92a70db1db",
"tools": [
"tool_result_read",
"list_room_targets",
diff --git a/server/drivers/agents-catalog-wire.test.ts b/server/drivers/agents-catalog-wire.test.ts
index 0578e52529..c3147b26b4 100644
--- a/server/drivers/agents-catalog-wire.test.ts
+++ b/server/drivers/agents-catalog-wire.test.ts
@@ -85,13 +85,13 @@ const FULL = "skills+shared+voice+x+team+images+hosting";
/** Bytes when the budget was last set; a profile may move at most 2% either way (lower it to lock in a win). */
const BUDGET_BASELINE: Record<string, number> = {
- "default": 63197,
- "voice": 63978,
+ "default": 63245,
+ "voice": 64026,
"shared": 65462,
"shared+voice": 66243,
"skills": 66273,
"skills+voice": 67054,
- "skills+shared": 68443,
+ "skills+shared": 68491,
"skills+shared+voice": 69224,
"non-chief": 54087,
"voice+non-chief": 54868,
@@ -103,8 +103,8 @@ const BUDGET_BASELINE: Record<string, number> = {
"skills+shared+voice+non-chief": 60209,
"skills+shared+voice+cloud-home": 68990,
"skills+shared+voice+non-chief+cloud-home": 59975,
- "default+legacy-switches": 63197,
- "default+mausbot": 63848,
+ "default+legacy-switches": 63245,
+ "default+mausbot": 63896,
"skills+shared+voice+mausbot": 69875,
"skills+shared+voice+x": 73048,
"skills+shared+voice+x+team": 73048,
@@ -112,7 +112,7 @@ const BUDGET_BASELINE: Record<string, number> = {
"default+room": 59680,
"non-chief+room": 50526,
"skills+shared+voice+x+team+images": 73821,
- "default+images": 63970,
+ "default+images": 64018,
"skills+shared+voice+x+team+images+hosting": 75660,
"default+hosting": 65205,
};
diff --git a/server/drivers/agents-catalog.ts b/server/drivers/agents-catalog.ts
index 4aedc88cab..c2c858d340 100644
--- a/server/drivers/agents-catalog.ts
+++ b/server/drivers/agents-catalog.ts
@@ -376,7 +376,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 ${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.`,
+ `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, csv, tsv, txt, md, json, rtf, and archives (zip, rar, 7z, tar, gz, tgz, bz2, xz). 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 47bef2248a..d8cbb0aab8 100644
--- a/server/index.test.ts
+++ b/server/index.test.ts
@@ -13269,6 +13269,46 @@ describe("bot memory API", () => {
}
});
+ it("lets a bot send an archive, served only as a download", async () => {
+ const bot = (await api("POST", "/api/bots", {})).body.bot;
+ try {
+ const workspace = workspaceOf(bot.id);
+ mkdirSync(workspace, { recursive: true });
+ const tarball = Buffer.from([0x1f, 0x8b, 0x08, 0x00, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e]);
+ writeFileSync(join(workspace, "Site.TAR.GZ"), tarball);
+ writeFileSync(join(workspace, "bundle.cab"), "MSCF");
+ const token = await mintTestCapability(BASE, bot.id, bot.threadId);
+ const attach = (body: unknown) => fetch(`${BASE}/api/internal/attach-file`, {
+ method: "POST",
+ headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
+ body: JSON.stringify(body),
+ });
+
+ const attached = await attach({ path: "Site.TAR.GZ" });
+ expect(attached.status).toBe(200);
+ expect(await attached.json()).toMatchObject({ ok: true, name: "Site.TAR.gz", bytes: tarball.byteLength });
+ expect((await attach({ path: "bundle.cab" })).status).toBe(415);
+
+ const dump = await api("GET", `/api/threads/${bot.threadId}/export?format=json`);
+ const [message] = (dump.body.messages as Array<{ id: string; attachments?: Array<{ kind: string; path: string; mime: string; name?: string }> }>)
+ .filter((entry) => entry.attachments?.length);
+ expect(message!.attachments).toEqual([expect.objectContaining({ kind: "file", name: "Site.TAR.gz", mime: "application/gzip" })]);
+
+ const served = await fetch(`${BASE}/api/threads/${bot.threadId}/messages/${message!.id}/file`, {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ path: message!.attachments![0]!.path }),
+ });
+ expect(served.status).toBe(200);
+ expect(served.headers.get("content-type")).toBe("application/gzip");
+ expect(served.headers.get("content-disposition")).toMatch(/^attachment; filename="Site\.TAR\.gz"/);
+ expect(served.headers.get("x-content-type-options")).toBe("nosniff");
+ expect(Buffer.from(await served.arrayBuffer())).toEqual(tarball);
+ } finally {
+ await api("DELETE", `/api/bots/${bot.id}`);
+ }
+ });
+
it("delivers a file a host engine's turn saved outside its folders by copy, and nothing else from there", async () => {
const bot = (await api("POST", "/api/bots", {})).body.bot;
try {
diff --git a/server/message-file.test.ts b/server/message-file.test.ts
index 061e88d006..6dd57fcc22 100644
--- a/server/message-file.test.ts
+++ b/server/message-file.test.ts
@@ -16,6 +16,7 @@ import {
messageReferencesFile,
listMessageFolder,
messageFolderEntryName,
+ mimeFor,
openMessageFile,
openMessageFolderEntry,
} from "./message-file.ts";
@@ -471,6 +472,28 @@ describe("message-linked files", () => {
expect(header).not.toContain("\n");
});
+ it("types an archive by its extension alone and serves it as a download", async () => {
+ for (const [name, mime] of [
+ ["a.zip", "application/zip"], ["a.rar", "application/vnd.rar"], ["a.7z", "application/x-7z-compressed"],
+ ["a.tar", "application/x-tar"], ["a.gz", "application/gzip"], ["a.tgz", "application/x-compressed-tar"],
+ ["a.bz2", "application/x-bzip2"], ["a.xz", "application/x-xz"],
+ ["build.tar.gz", "application/gzip"], ["BUILD.ZIP", "application/zip"], ["Site.Tar.Gz", "application/gzip"],
+ ["a.cab", "application/octet-stream"], ["a.tar.zst", "application/octet-stream"], ["zip", "application/octet-stream"],
+ ] as const) expect(mimeFor(name), name).toBe(mime);
+ // Content never decides the type: zip bytes under a .txt name stay text, text under a .zip name stays an archive.
+ writeFileSync(join(workspace, "really-zip.txt"), "PK\x03\x04");
+ writeFileSync(join(workspace, "really-text.zip"), "hello");
+ for (const [name, mime] of [["really-zip.txt", "text/plain; charset=utf-8"], ["really-text.zip", "application/zip"]] as const) {
+ const opened = await openMessageFile(name, [workspace]);
+ await opened.handle.close();
+ expect(opened.mime).toBe(mime);
+ }
+ expect(messageFileDisposition("build.tar.gz")).toMatch(/^attachment; filename="build\.tar\.gz"/);
+ expect(messageFileDownloadName("build.tar.gz", "4e8d.gz")).toBe("build.tar.gz");
+ expect(messageFileDownloadName("BUILD.ZIP", "4e8d.zip")).toBe("BUILD.ZIP");
+ expect(messageFileDownloadName("setup.exe", "4e8d.zip")).toBe("setup.zip");
+ });
+
it("never lets a display name disguise the canonical file extension", () => {
expect(messageFileDownloadName("Quarterly report.pdf", "4e8d.pdf")).toBe("Quarterly report.pdf");
expect(messageFileDownloadName("setup.exe", "4e8d.pdf")).toBe("setup.pdf");
diff --git a/server/message-file.ts b/server/message-file.ts
index e39774fa35..449802ca53 100644
--- a/server/message-file.ts
+++ b/server/message-file.ts
@@ -367,6 +367,15 @@ export function mimeFor(path: string): string {
case ".odt": return "application/vnd.oasis.opendocument.text";
case ".ods": return "application/vnd.oasis.opendocument.spreadsheet";
case ".odp": return "application/vnd.oasis.opendocument.presentation";
+ // Archives are typed by name only and stay downloads: never previewed, never unpacked. foo.tar.gz is a .gz.
+ case ".zip": return "application/zip";
+ case ".rar": return "application/vnd.rar";
+ case ".7z": return "application/x-7z-compressed";
+ case ".tar": return "application/x-tar";
+ case ".gz": return "application/gzip";
+ case ".tgz": return "application/x-compressed-tar";
+ case ".bz2": return "application/x-bzip2";
+ case ".xz": return "application/x-xz";
default: return "application/octet-stream";
}
}