Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(surface): a file on a computer lent to the server gets one route, shared_computer
AdityaUmalebb8f767ea2b5
diff --git a/server/surface.test.ts b/server/surface.test.tsindex e662e91696..98036e07d8 100644--- a/server/surface.test.ts+++ b/server/surface.test.ts@@ -446,6 +446,21 @@ describe("surfacePrompt", () => {expect(none).toContain("No place's tools can open apps, click, or inspect a screen this turn.");expect(surfacePrompt({ computer: "local", browser: false }, { lentToServer: lent })).toContain("Their Mac (Studio) is reached only through shared_computer");});++ // With This computer pickable too, the own-files line said the person's files are on this computer and never on a+ // shared computer: a file on the lent Mac got two routes, one of them the server host.+ it("gives a file on a computer lent to a self-hosted server one route, shared_computer", () => {+ const lent = [{ name: "Studio", platform: "darwin" as const }];+ const thisComputer = { bot: "Ada", platform: "linux" as const };+ const both = surfacePrompt({ computer: "vm", browser: false }, { canSelect: true, lentToServer: lent, thisComputer });+ expect(both).not.toContain("never one of the shared computers");+ expect(both).not.toContain("or \"my PC\") is on this computer");+ expect(both).toContain("A file or folder at a path of this computer (a path such as /home/…) is on this computer, which the Local VM cannot reach.");+ expect(both).toContain("A file or folder on their Mac (Studio) is on that computer: reach it only through shared_computer, as above. When they don't say which computer a file is on, ask in one line.");+ // Nothing lent: the own-files line is unchanged.+ expect(surfacePrompt({ computer: "vm", browser: false }, { canSelect: true, lentToServer: [], thisComputer }))+ .toBe(surfacePrompt({ computer: "vm", browser: false }, { canSelect: true, thisComputer }));+ });});describe("surface parsing", () => {diff --git a/server/surface.ts b/server/surface.tsindex 36f64da8c0..03db690597 100644--- a/server/surface.ts+++ b/server/surface.ts@@ -245,10 +245,17 @@ export function failedOnHostPath(command: unknown, result: { exitCode?: unknown;return Number(result.exitCode ?? 0) !== 0 && result.timedOut !== true && namesHostPath(command, platform);}-/** On a server where This computer can be picked: a host path or "my PC" is this computer, never the mounted place. */-function ownFilesSentence(own: { bot: string; botId?: string; platform: NodeJS.Platform }, place: Surface | null, canSelect: boolean): string {+/** On a server where This computer can be picked: a host path (or "my PC", when nothing is lent) is this computer, never the mounted place. */+function ownFilesSentence(own: { bot: string; botId?: string; platform: NodeJS.Platform }, place: Surface | null, canSelect: boolean,+ lent?: ReadonlyArray<{ name: string; platform: LentPlatform | null }>): string {const example = HOST_PATHS[own.platform]?.example;- return ` A file or folder on the person's own computer (${example ? `a path such as ${example}, ` : ""}their Desktop, Documents, Downloads or OneDrive, or "my PC") is on this computer${place ? `, which ${surfaceLabel(place)} cannot reach` : ""}, and it is never one of the shared computers. ${thisComputerSwitch({ place, bot: own.bot, canSelect, ...(own.botId ? { botId: own.botId } : {}) })}`;+ const unreachable = place ? `, which ${surfaceLabel(place)} cannot reach` : "";+ const switchLine = thisComputerSwitch({ place, bot: own.bot, canSelect, ...(own.botId ? { botId: own.botId } : {}) });+ // A person who lends this server a computer has their own files there too: "my PC" no longer names this computer.+ if (lent?.length) {+ return ` A file or folder at a path of this computer${example ? ` (a path such as ${example})` : ""} is on this computer${unreachable}. A file or folder on ${theirComputer(lent).theirs} is on that computer: reach it only through shared_computer, as above. When they don't say which computer a file is on, ask in one line. ${switchLine}`;+ }+ return ` A file or folder on the person's own computer (${example ? `a path such as ${example}, ` : ""}their Desktop, Documents, Downloads or OneDrive, or "my PC") is on this computer${unreachable}, and it is never one of the shared computers. ${switchLine}`;}/** A Cloud home without the shared-computer tools cannot reach the person's own computer at all. */@@ -343,7 +350,7 @@ export function surfacePrompt(text += ownComputerSentence(opts.lentToServer, computer);}if (opts.thisComputer && !opts.cloudHome && !reportBack && mounted.computer !== "local") {- text += ownFilesSentence(opts.thisComputer, mounted.computer, Boolean(opts.canSelect));+ text += ownFilesSentence(opts.thisComputer, mounted.computer, Boolean(opts.canSelect), opts.lentToServer);}return text + (opts.note ?? "");}