Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(bot-box): give own-folder turns their conversation's uploads
AdityaUmale27f2ad3a2262
diff --git a/.install.log b/.install.lognew file mode 100644index 0000000000..f544604ce1--- /dev/null+++ b/.install.log@@ -0,0 +1,104 @@+Scope: all 3 workspace projects+Lockfile is up to date, resolution step is skipped+Progress: resolved 1, reused 0, downloaded 0, added 0+Packages: +1006++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Progress: resolved 1006, reused 1005, downloaded 0, added 851+Progress: resolved 1006, reused 1005, downloaded 0, added 1006, done++dependencies:++ @1password/sdk 0.5.0++ @clack/prompts 1.7.0++ @codemirror/lang-sql 6.10.0++ @codemirror/language 6.13.1++ @codemirror/state 6.7.6++ @duckdb/node-api 1.5.6-r.1++ @fishaudio/agent-client 1.0.0++ @fontsource-variable/geist 5.3.0++ @fontsource-variable/geist-mono 5.3.0++ @fontsource-variable/inter 5.3.0++ @hpke/core 1.9.0++ @lezer/highlight 1.2.5++ @muse-code/sdk 1.4.6++ @novnc/novnc 1.7.0++ @resvg/resvg-js 2.6.2++ @tanstack/react-virtual 3.14.13++ @trycua/cua-driver 0.45.4++ ag-grid-community 36.2.0++ ag-grid-react 36.2.0++ ajv 8.20.0++ ajv-formats 3.0.1++ clsx 2.1.1++ codemirror 6.0.2++ croner 10.0.1++ imapflow 2.10.0++ jmespath 0.16.0++ jose 6.2.10++ katex 0.16.47++ lucide-react 0.539.0++ mailparser 3.14.1++ mdast-util-from-markdown 2.0.3++ mermaid 12.1.0++ nodemailer 10.3.1++ papaparse 5.7.0++ posthog-js 1.415.6++ qrcode-terminal 0.12.0++ qrcode.react 4.2.0++ react 19.2.8++ react-dom 19.2.8++ react-markdown 10.1.0++ rehype-katex 7.0.1++ remark-gfm 4.0.1++ remark-math 6.0.0++ shiki 4.4.3++ sucrase 3.35.1++ tailwind-merge 3.6.0++ tar 7.5.22++ tldts 7.4.18++ undici 8.11.2++ vega 6.4.0++ vega-embed 7.3.0++ vega-interpreter 2.3.2++ vega-lite 6.5.0++ vega-themes 3.0.0++ ws 8.22.0++ yaml 2.9.0++ zod 4.6.7++devDependencies:++ @modelcontextprotocol/ext-apps 2.0.3++ @tailwindcss/vite 4.3.3++ @types/jmespath 0.15.2++ @types/node 26.2.0++ @types/novnc__novnc 1.6.0++ @types/papaparse 5.5.2++ @types/qrcode-terminal 0.12.2++ @types/react 19.2.18++ @types/react-dom 19.2.4++ @types/ws 8.18.2++ @typescript/typescript6 6.0.2++ @vitejs/plugin-react 4.7.0++ electron 43.7.9++ electron-builder 26.15.3++ electron-updater 6.8.9++ esbuild 0.28.2++ happy-dom 21.0.4++ oxlint 1.80.0++ tailwindcss 4.3.3++ typebox 1.3.7++ typescript 7.0.2++ vite 7.3.6++ vitest 4.1.11++ wrangler 4.123.0++. prepare$ node scripts/install-git-hooks.mjs+. prepare: Done+╭ Warning ─────────────────────────────────────────────────────────────────────╮+│ │+│ Ignored build scripts: [email protected], [email protected], │+│ [email protected]. │+│ Run "pnpm approve-builds" to pick which dependencies should be allowed │+│ to run scripts. │+│ │+╰──────────────────────────────────────────────────────────────────────────────╯+Done in 2.6s using pnpm v10.33.0diff --git a/server/bot-box/plan.ts b/server/bot-box/plan.tsindex 67b6ee240d..b7f5669106 100644--- a/server/bot-box/plan.ts+++ b/server/bot-box/plan.ts@@ -148,6 +148,14 @@ export function taskWorkspaceIds(cwd: string, dataDir: string): { botId: string;return { botId: rel[0]!, threadId: rel[1]! };}+/** The conversation whose uploads a box in `cwd` sees: a conversation folder's own, or for a turn working in its bot's own+ * folder (workspaces/<bot>: a room, a bot whose folder is its own), that turn's conversation. Null for any other folder. */+export function uploadsConversation(cwd: string, dataDir: string, turn?: { botId: string; threadId: string } | null): { botId: string; threadId: string } | null {+ const ids = taskWorkspaceIds(cwd, dataDir);+ if (ids || !turn || !ID.test(turn.botId) || !ID.test(turn.threadId)) return ids;+ return cwd === join(dataDir, "workspaces", turn.botId) ? { botId: turn.botId, threadId: turn.threadId } : null;+}+/** The server-owned folder holding a conversation's uploads for its boxes (server/box-attachments.ts), bound read-only. */export function boxUploadsDir(dataDir: string, botId: string, threadId: string): string {return join(dataDir, "box-uploads", botId, threadId);@@ -281,9 +289,13 @@ export function planBox(setup: BoxSetup, request: BoxRequest): BoxPlan {mounts.push({ kind: mutate.has("engines-rw") ? "bind" : "ro", source: engines, target: engines, optional: true });}// The person's uploads for this conversation, after every read-write line: readable, but never writable or swappable.- if (ids) {+ // A turn in its bot's own folder sees only its own conversation's: a process there is never shared with another+ // conversation (procs.ts sharedBoxScope), so this holds for one started for several of them too.+ const turnIds = !ids && cwd && request.conversationFolder ? taskWorkspaceIds(resolve(request.conversationFolder), dataDir) : null;+ const uploadsOf = ids ?? (turnIds && turnIds.botId === botId ? uploadsConversation(cwd!, dataDir, turnIds) : null);+ if (uploadsOf) {const shown = scoped ? [...scoped.rw, ...scoped.ro].filter((id) => ID.test(id)).map((id) => boxUploadsDir(dataDir, threads!, id))- : [threads ? join(dataDir, "box-uploads", threads) : boxUploadsDir(dataDir, ids.botId, ids.threadId)];+ : [threads ? join(dataDir, "box-uploads", threads) : boxUploadsDir(dataDir, uploadsOf.botId, uploadsOf.threadId)];for (const folder of shown) mounts.push({ kind: "ro", source: folder, target: folder, optional: true });}// The team's conversations a non-team shared process may read, and the team's folder, after every read-write line too.diff --git a/server/bot-box/turn-bot-folder.test.ts b/server/bot-box/turn-bot-folder.test.tsindex 99b52b9532..4c6cd24d64 100644--- a/server/bot-box/turn-bot-folder.test.ts+++ b/server/bot-box/turn-bot-folder.test.ts@@ -13,7 +13,7 @@ import { boxedSpawn, sharedBoxScope } from "../procs.ts";import { removeTempDir } from "../testing/cleanup.ts";import { ensureTaskWorkspace, workspaceDir } from "../workspace.ts";import { botBox, type WrappedSpawn } from "./box.ts";-import { visibleInBox, type BoxRequest } from "./plan.ts";+import { boxUploadsDir, visibleInBox, type BoxRequest } from "./plan.ts";const BOT = "bot-with-project", OTHER = "bot-other";const turn = { botId: BOT, threadId: "t1" };@@ -103,6 +103,19 @@ describe.skipIf(process.platform === "win32")("a turn's box in a configured projexpect(runInTurn({ botId: BOT, threadId: "t3" }, () => sharedBoxScope(project))).toBe(mine);});+ it("gives a turn in its bot's own folder (a room's) its own conversation's uploads read-only, and keeps conversations' processes apart", () => {+ const plan = runInTurn(turn, () => spawnIn(workspaceDir(BOT)));+ expect(plan.botId).toBe(BOT);+ expect(visibleInBox(plan, join(boxUploadsDir(DATA_DIR, BOT, "t1"), "notes.md"))).toBe("ro");+ expect(visibleInBox(plan, join(boxUploadsDir(DATA_DIR, BOT, "t2"), "notes.md"))).toBe("none");+ const shared = runInTurn(turn, () => spawnIn(workspaceDir(BOT), { botThreads: true }));+ expect(visibleInBox(shared, join(boxUploadsDir(DATA_DIR, BOT, "t1"), "notes.md"))).toBe("ro");+ expect(visibleInBox(shared, join(boxUploadsDir(DATA_DIR, BOT, "t2"), "notes.md"))).toBe("none");+ const first = runInTurn(turn, () => sharedBoxScope(workspaceDir(BOT)));+ expect(runInTurn({ botId: BOT, threadId: "t2" }, () => sharedBoxScope(workspaceDir(BOT)))).not.toBe(first);+ expect(runInTurn(turn, () => sharedBoxScope(workspaceDir(BOT)))).toBe(first);+ });+it("keeps the conversation folder out of a process the bot's conversations share", () => {const plan = runInTurn(turn, () => spawnIn(project, { botThreads: true }));expect(visibleInBox(plan, workspaceDir(BOT))).toBe("rw");diff --git a/server/box-attachments.linux.test.ts b/server/box-attachments.linux.test.tsindex bdd9082c96..b1e299eec7 100644--- a/server/box-attachments.linux.test.ts+++ b/server/box-attachments.linux.test.ts@@ -8,7 +8,7 @@ import { afterAll, describe, expect, it } from "vitest";import { defaultCodeRoots } from "./bot-box/box.ts";import { detectBox } from "./bot-box/detect.ts";-import { boxUploadsDir, bwrapArgs, planBox } from "./bot-box/plan.ts";+import { boxUploadsDir, bwrapArgs, planBox, type BoxRequest } from "./bot-box/plan.ts";import { attachmentsForBox } from "./box-attachments.ts";const detection = detectBox({ env: { ...process.env, OMB_BOT_BOX: "1" } });@@ -21,14 +21,14 @@ const cwd = join(dataDir, "task-workspaces", "bot-a", "t-1");const env = { PATH: "/usr/bin:/bin", HOME: home };/** What `cat` prints for the tag's path inside a box for this conversation, or null when it can't read it. */-function readInBox(tag: string): string | null {+function readInBox(tag: string, more: Partial<BoxRequest> = {}): string | null {const path = /path="([^"]*)"/.exec(tag)![1]!;- const run = runInBox(["/usr/bin/cat", path]);+ const run = runInBox(["/usr/bin/cat", path], more);return run.status === 0 ? run.stdout : null;}-function runInBox(argv: string[]): { status: number | null; stdout: string } {- const plan = planBox({ dataDir, home, codeRoots: defaultCodeRoots(), engineRoots: [], bridges: [] }, { command: argv[0]!, args: [], cwd, env });+function runInBox(argv: string[], more: Partial<BoxRequest> = {}): { status: number | null; stdout: string } {+ const plan = planBox({ dataDir, home, codeRoots: defaultCodeRoots(), engineRoots: [], bridges: [] }, { command: argv[0]!, args: [], cwd, env, ...more });return spawnSync(detection.tools!.bwrap, [...bwrapArgs(plan), "--", ...argv], { env, encoding: "utf8" });}@@ -42,10 +42,24 @@ describe.skipIf(!available)(`an attached file inside a real box (${available ? "const tag = `<attached-file path="${upload}" name="notes.md" />`;expect(readInBox(tag)).toBeNull();- expect(readInBox(attachmentsForBox(tag, cwd, true, dataDir, uploads))).toBe("quarterly notes\n");+ expect(readInBox(attachmentsForBox(tag, cwd, undefined, true, dataDir, uploads))).toBe("quarterly notes\n");// Read-only: the bot can neither change the upload nor swap the folder for a link.const shown = boxUploadsDir(dataDir, "bot-a", "t-1");expect(runInBox(["/usr/bin/sh", "-c", `echo x > ${join(shown, "5c1e0d2a.md")}`]).status).not.toBe(0);expect(runInBox(["/usr/bin/sh", "-c", `rm -rf ${shown} && ln -s /tmp ${shown}`]).status).not.toBe(0);});++ it("is readable from a turn in its bot's own folder (a room's), and only from that conversation's box", () => {+ const own = join(dataDir, "workspaces", "bot-a");+ mkdirSync(uploads, { recursive: true });+ mkdirSync(own, { recursive: true });+ const upload = join(uploads, "9d4f7a1b.md");+ writeFileSync(upload, "room notes\n");+ const tag = `<attached-file path="${upload}" name="notes.md" />`;+ const room = (threadId: string): Partial<BoxRequest> => ({ cwd: own, botId: "bot-a", conversationFolder: join(dataDir, "task-workspaces", "bot-a", threadId) });++ const given = attachmentsForBox(tag, own, { botId: "bot-a", threadId: "room-1" }, true, dataDir, uploads);+ expect(readInBox(given, room("room-1"))).toBe("room notes\n");+ expect(readInBox(given, room("room-2"))).toBeNull();+ });});diff --git a/server/box-attachments.test.ts b/server/box-attachments.test.tsindex b74b3f853d..d6773464f6 100644--- a/server/box-attachments.test.ts+++ b/server/box-attachments.test.ts@@ -20,7 +20,7 @@ describe("attachmentsForBox", () => {mkdirSync(cwd, { recursive: true });});afterEach(() => rmSync(root, { recursive: true, force: true }));- const run = (text: string, at: string | undefined = cwd, boxed = true) => attachmentsForBox(text, at, boxed, dataDir, uploads);+ const run = (text: string, at: string | undefined = cwd, boxed = true) => attachmentsForBox(text, at, undefined, boxed, dataDir, uploads);it("puts each upload in the conversation's read-only uploads folder and points the engine there", () => {const upload = join(uploads, "1f0c2a.md");@@ -60,7 +60,7 @@ describe("attachmentsForBox", () => {const dir = join(root, "a&b", "attachments");mkdirSync(dir, { recursive: true });writeFileSync(join(dir, "x.md"), "x");- const out = attachmentsForBox(`<attached-file path="${join(root, "a&b", "attachments", "x.md")}" name="x.md" />`, cwd, true, dataDir, dir);+ const out = attachmentsForBox(`<attached-file path="${join(root, "a&b", "attachments", "x.md")}" name="x.md" />`, cwd, undefined, true, dataDir, dir);expect(out).toBe(`<attached-file path="${join(shown, "x.md")}" name="x.md" />`);});@@ -78,7 +78,7 @@ describe("attachmentsForBox", () => {writeFileSync(upload, "x");const text = `<attached-file path="${upload}" name="a.md" />`;expect(run(text, cwd, false)).toBe(text);- expect(attachmentsForBox(text, undefined, true, dataDir, uploads)).toBe(text);+ expect(attachmentsForBox(text, undefined, undefined, true, dataDir, uploads)).toBe(text);expect(run(text, join(dataDir, "workspaces", "bot"))).toBe(text);expect(existsSync(shown)).toBe(false);});@@ -104,4 +104,26 @@ describe("attachmentsForBox", () => {expect(at).toBeGreaterThan(targets(cwd).indexOf(cwd));expect(targets(join(dataDir, "task-workspaces", "bot", "other"))).not.toContain(shown);});++ it("gives a turn in its bot's own folder (a room's) its own conversation's uploads, and no other's", () => {+ const own = join(dataDir, "workspaces", "bot"), room = boxUploadsDir(dataDir, "bot", "room");+ mkdirSync(own, { recursive: true });+ const upload = join(uploads, "r1.md");+ writeFileSync(upload, "room notes");+ const text = `<attached-file path="${upload}" name="r1.md" />`;++ expect(attachmentsForBox(text, own, { botId: "bot", threadId: "room" }, true, dataDir, uploads)).toBe(`<attached-file path="${join(room, "r1.md")}" name="r1.md" />`);+ expect(readFileSync(join(room, "r1.md"), "utf8")).toBe("room notes");+ expect(attachmentsForBox(text, join(dataDir, "workspaces", "other"), { botId: "bot", threadId: "room" }, true, dataDir, uploads)).toBe(text);++ const setup = { dataDir, home: root, codeRoots: [], engineRoots: [], bridges: [] };+ const mounts = (more: object) => planBox(setup, { command: "/usr/bin/true", args: [], cwd: own, env: {}, botId: "bot", conversationFolder: join(dataDir, "task-workspaces", "bot", "room"), ...more }).mounts;+ expect(mounts({})).toContainEqual({ kind: "ro", source: room, target: room, optional: true });+ expect(mounts({}).map((mount) => ("target" in mount ? mount.target : null))).not.toContain(shown);+ // A process started for several conversations there serves only this one (procs.ts sharedBoxScope), so it gets the+ // same, never every conversation's; a box of another bot gets none.+ expect(mounts({ botThreads: true })).toContainEqual({ kind: "ro", source: room, target: room, optional: true });+ expect(mounts({ botThreads: true })).not.toContainEqual(expect.objectContaining({ target: join(dataDir, "box-uploads", "bot") }));+ expect(mounts({ botId: "other" })).not.toContainEqual(expect.objectContaining({ target: room }));+ });});diff --git a/server/box-attachments.ts b/server/box-attachments.tsindex 9199cec731..bde58f7ee1 100644--- a/server/box-attachments.ts+++ b/server/box-attachments.ts@@ -3,7 +3,7 @@ import { basename, dirname, join, resolve } from "node:path";import { decodeAttachmentAttribute, escapeAttribute } from "../src/lib/composer-attachments.ts";import { ATTACHMENTS_DIR } from "./attachments.ts";import { botBox } from "./bot-box/box.ts";-import { boxUploadsDir, taskWorkspaceIds } from "./bot-box/plan.ts";+import { boxUploadsDir, uploadsConversation } from "./bot-box/plan.ts";import { DATA_DIR } from "./config.ts";const TAG = /(<attached-(?:file|image)[\t ]+path=")([^"\r\n]*)(")/g;@@ -14,11 +14,11 @@ const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;* Each upload the text names is linked into the conversation's uploads folder (plan.ts boxUploadsDir), which the server* owns and every box of the conversation sees read-only, and the path is rewritten to it. The bot can read the upload but* never write it or swap the folder for a link. Only the text sent to the engine changes; with the box off, or a working- * folder that is not a conversation's own, nothing does.+ * folder that is neither a conversation's own nor `turn`'s bot's own folder (a room's), nothing does.*/-export function attachmentsForBox(text: string, cwd: string | undefined, boxed = botBox.enabled(), dataDir = DATA_DIR, attachmentsDir = ATTACHMENTS_DIR): string {+export function attachmentsForBox(text: string, cwd: string | undefined, turn?: { botId: string; threadId: string }, boxed = botBox.enabled(), dataDir = DATA_DIR, attachmentsDir = ATTACHMENTS_DIR): string {if (!boxed || !cwd || !text.includes("<attached-")) return text;- const ids = taskWorkspaceIds(resolve(cwd), resolve(dataDir));+ const ids = uploadsConversation(resolve(cwd), resolve(dataDir), turn);if (!ids) return text;const uploads = resolve(attachmentsDir), shown = boxUploadsDir(resolve(dataDir), ids.botId, ids.threadId);return text.replace(TAG, (tag, open: string, raw: string, close: string) => {diff --git a/server/host/handoff-files.test.ts b/server/host/handoff-files.test.tsindex 7f57bca121..42bfcf98b0 100644--- a/server/host/handoff-files.test.ts+++ b/server/host/handoff-files.test.ts@@ -347,7 +347,7 @@ describe("receiving", () => {expect(targets).toContain(cwd);expect(targets.some((target) => target === work || target === folderOf("ana", "t-ana") || target === ATTACHMENTS_DIR)).toBe(false);expect(text).toContain(join(cwd, "inbox", "ana", "a1", "report.pdf"));- const boxed = attachmentsForBox(text, cwd, true, DATA, ATTACHMENTS_DIR);+ const boxed = attachmentsForBox(text, cwd, undefined, true, DATA, ATTACHMENTS_DIR);const shown = join(boxUploadsDir(DATA, "ben", "t-ben"), basename(staged.files[0]!.path));expect(boxed).toContain(`<attached-image path="${shown}" name="chart.png" />`);expect(readFileSync(shown).equals(PNG)).toBe(true);diff --git a/server/index.ts b/server/index.tsindex 2785c558d7..915be2785f 100644--- a/server/index.ts+++ b/server/index.ts@@ -8341,7 +8341,7 @@ async function beginTurn(threadId,botId: bot.id,startupRecovery,- text: withTurnClock(clock, withRecalled(recalled, (posted?.text ?? "") + attachmentsForBox(dispatchContext.turnText, cwd) + shareNote.text + devsReports.note(threadId, Boolean(integrations.agents)) + settingNudges.note(threadId, { tools: Boolean(integrations.agents) && personLine && !opts?.unattended, owner: phones.turnOwner({ botId: bot.id, threadId, generation: dispatchClaimId }) !== null && !cloudGuestDriven(threadId), model: `${instanceId}/${model}` }))),+ text: withTurnClock(clock, withRecalled(recalled, (posted?.text ?? "") + attachmentsForBox(dispatchContext.turnText, cwd, { botId: bot.id, threadId }) + shareNote.text + devsReports.note(threadId, Boolean(integrations.agents)) + settingNudges.note(threadId, { tools: Boolean(integrations.agents) && personLine && !opts?.unattended, owner: phones.turnOwner({ botId: bot.id, threadId, generation: dispatchClaimId }) !== null && !cloudGuestDriven(threadId), model: `${instanceId}/${model}` }))),...(recalled ? { recalled } : {}),images: dispatchContext.images, videos: dispatchContext.videos,approvalMode: approvalModeForTurn(bot, commsDepth > 0, threadId),@@ -8353,7 +8353,7 @@ async function beginTurn(variant,resumeCursor: dispatchContext.resumeCursor,sessionReset: dispatchContext.sessionReset,- ...(dispatchContext.recoveryText !== undefined ? { recoveryText: withTurnClock(clock, (posted?.text ?? "") + attachmentsForBox(dispatchContext.recoveryText, cwd) + shareNote.text) } : {}),+ ...(dispatchContext.recoveryText !== undefined ? { recoveryText: withTurnClock(clock, (posted?.text ?? "") + attachmentsForBox(dispatchContext.recoveryText, cwd, { botId: bot.id, threadId }) + shareNote.text) } : {}),transcript,system: prompt.text,systemStable: prompt.stable,@@ -10206,7 +10206,7 @@ async function runClaimedGroupMemberTurn(threadId, botId: readyBot.id, claimId: internalGeneration, instance, guestConfined: roomGuestConfined, reset: Boolean(roomReset), hooks: Boolean(integrations.hooks),context: () => ({ ...roomMemberContexts.forThread(threadId)?.[readyBot.id], compactAt: nativeCompactTokens(instance, roomSelection.model) }),config: [roomSystem.stable, cwd, roomSelection, turnApprovalMode, roomToolScope, roomUserMcp, integrations],- window: roomWindow, tail: roomTail, wrap: (body) => withTurnClock(clock, withRecalled(roomRecalled, roomPick + attachmentsForBox(body, cwd) + roomShareNote.text + devsReports.note(threadId, Boolean(integrations.agents)))),+ window: roomWindow, tail: roomTail, wrap: (body) => withTurnClock(clock, withRecalled(roomRecalled, roomPick + attachmentsForBox(body, cwd, { botId: readyBot.id, threadId }) + roomShareNote.text + devsReports.note(threadId, Boolean(integrations.agents)))),});guardTurnDispatch(roomShareNote.after(instance.adapter.sendTurn({...roomSession.send,diff --git a/server/procs.ts b/server/procs.tsindex 72a7f75296..cf2ebc6880 100644--- a/server/procs.ts+++ b/server/procs.ts@@ -313,12 +313,13 @@ export function boxedSpawn(resolved: ResolvedSpawn, opts: CliSpawnOptions, owner}/** A configured project folder can lie inside another bot's folder, so a turn working there still needs its own bot's- * folder and conversation folder in its box. */+ * folder and conversation folder in its box. A turn in its bot's own folder (a room's) needs its conversation's too, for+ * that conversation's uploads (server/box-attachments.ts). */function projectFolderTurn(cwd: string | undefined): { botId: string; conversationFolder: string } | null {const dataDir = botBox.startOptions()?.dataDir, turn = currentTurn();if (!cwd || !dataDir || !turn?.botId) return null;const full = resolve(cwd), workspaces = join(resolve(dataDir), "workspaces"), conversations = join(resolve(dataDir), "task-workspaces");- if (under(full, conversations) || dirname(full) === workspaces || full === workspaces) return null;+ if (under(full, conversations) || (dirname(full) === workspaces && basename(full) !== turn.botId) || full === workspaces) return null;return { botId: turn.botId, conversationFolder: join(conversations, turn.botId, turn.threadId) };}@@ -337,9 +338,11 @@ export function sharedBoxScope(cwd: string): string | null {if (!botBox.enabled()) return null;const parent = dirname(resolve(cwd));if (basename(dirname(parent)) !== "task-workspaces") {- // Another bot's turn in the same project folder has that bot's folder in its box, so it never shares this process.+ // Another bot's turn in the same project folder has that bot's folder in its box, so it never shares this process;+ // nor does another conversation's turn in the bot's own folder, whose box has only its own conversation's uploads.const turn = projectFolderTurn(cwd);- return turn ? `${resolve(cwd)}#${turn.botId}` : resolve(cwd);+ if (!turn) return resolve(cwd);+ return `${resolve(cwd)}#${basename(resolve(cwd)) === turn.botId ? turn.conversationFolder : turn.botId}`;}const threadId = engineHomes.thread(), conversationBot = engineHomes.bot();const threads = botBox.sharedThreadsKey({ cwd, ...(threadId ? { threadId } : {}), ...(conversationBot ? { conversationBot } : {}) });