Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Cloud: the app says when a turn can't run commands, and that a move to another computer keeps the files (#6869)
Milind Soni60ec719636b6
diff --git a/server/automation-reports.ts b/server/automation-reports.tsindex b22b642d53..2162e9106e 100644--- a/server/automation-reports.ts+++ b/server/automation-reports.ts@@ -114,8 +114,8 @@ export interface AutomationReportDeps {brief?(run: RoutineRun, turnId?: string): void;/** The language a line in this conversation is written in (server/server-lines.ts); absent, English. */threadLanguage?(threadId: string): string | undefined;- /** A line the app adds under a completed run's reply, in the language of the chat it reports to, taken once- * (host/refused-lending.ts): it is said even when the bot's reply is quiet. */+ /** A line the app adds under a run's reply or its failure line, in the language of the chat it reports to, taken once+ * (host/refused-lending.ts, host/no-terminal.ts): it is said even when the bot's reply is quiet. */notes?: { has(runId: string): boolean; take(runId: string, language: string | undefined): string | null };}@@ -241,7 +241,7 @@ export function createAutomationReports(deps: AutomationReportDeps) {const source = line.kind === "reply" ? replyOf(run, line.messageId) : undefined;const language = deps.threadLanguage?.(target.threadId);const said: RunReply = line.kind === "reply" ? withNote(read(run, source), deps.notes?.take(run.id, language) ?? null)- : { quiet: false, text: line.detail ? serverLine(language, run.partial ? "server.runs.partlyDoneWhy" : "server.runs.didNotFinishWhy", { detail: line.detail }) : serverLine(language, "server.runs.didNotFinish") };+ : withNote({ quiet: false, text: line.detail ? serverLine(language, run.partial ? "server.runs.partlyDoneWhy" : "server.runs.didNotFinishWhy", { detail: line.detail }) : serverLine(language, "server.runs.didNotFinish") }, deps.notes?.take(run.id, language) ?? null);const recovered = said.quiet && lastSaidFailed(run, target.threadId);if (said.quiet && !recovered) {deps.routines()?.noteReport(run.id, { state: "quiet" });diff --git a/server/host/no-terminal.test.ts b/server/host/no-terminal.test.tsnew file mode 100644index 0000000000..5fd5798d73--- /dev/null+++ b/server/host/no-terminal.test.ts@@ -0,0 +1,184 @@+import { describe, expect, it } from "vitest";++import { addServerLinePacks } from "../server-lines.ts";+import { createNoTerminal, modelSwitchNotice, triedCommand, type NoTerminalDeps, type TurnReach } from "./no-terminal.ts";++const REFUSED = "{\"ok\":false,\"result\":\"The requested tool was not advertised for this turn\"}";+const T0 = 1_000_000;+const reach: TurnReach = { ownShell: false, computerMounted: false, sharedTools: false, canSelect: false };+type Bot = { desk: boolean };+type Line = { role?: string; kind: string; at: number; text?: string; tool?: { name: string; ok?: boolean; output?: string } };++function host(over: Partial<Omit<NoTerminalDeps<Bot>, "lines">> & { lines?: Line[] } = {}) {+ const { lines = [], ...deps } = over;+ return createNoTerminal<Bot>({ cloudHome: true, lines: () => lines, cloudDesktop: (bot) => bot.desk, ...deps });+}+const noDesk: Bot = { desk: false }, desk: Bot = { desk: true };+const prompt = { model: "gpt-5-mini", routine: false };++describe("a turn's context on My Cloud (server/host/no-terminal.ts)", () => {+ it("a chat-only model with nothing to run commands on is told so, and the ways out are only the true ones", () => {+ const text = host().turn("t1", noDesk, reach, prompt);+ expect(text).toBe(" You can't run commands this turn: on My Cloud this model (gpt-5-mini) has no terminal of its own, and no cloud desktop is in use. Nothing is broken."+ + " If the work needs a command, don't try another way or give another reason: say gpt-5-mini can't run commands on My Cloud, and that a model with a terminal, such as Claude or Codex can.");+ expect(host().turn("t1", desk, reach, prompt)).toContain("such as Claude or Codex, or the cloud desktop, can.");+ expect(host().turn("t1", noDesk, reach, { ...prompt, routine: true })).toMatch(/Do the parts that need no command and say which step was not done, without giving a reason for it\.$/u);+ });++ it("must-fix 1: a turn that may move, with the cloud desktop open to this bot, is told to select it, never not to look for another way", () => {+ const text = host().turn("t1", desk, { ...reach, canSelect: true }, prompt);+ expect(text).toBe(" This turn has no terminal: on My Cloud this model (gpt-5-mini) can't run commands itself. To run one, call select_computer with surface \"cloud\": the request moves to the cloud desktop, where exec runs it.");+ expect(text).not.toContain("another way");+ // Computer access Off, a tool scope or policy that leaves it out, or none set up: no way out but a model, and it says so.+ expect(host().turn("t1", noDesk, { ...reach, canSelect: true }, prompt)).toContain("don't try another way");+ });++ it("says nothing where commands can run, or where a lent computer's terminal is the computer's to explain, or off My Cloud", () => {+ expect(host().turn("t1", desk, { ...reach, ownShell: true }, prompt)).toBe("");+ expect(host().turn("t1", desk, { ...reach, computerMounted: true }, prompt)).toBe("");+ // A lent computer that lends its terminal, online or not: when it is off, that is the reason, and the bot may say it.+ expect(host({ lentTerminal: () => true }).turn("t1", noDesk, { ...reach, sharedTools: true }, prompt)).toBe("");+ expect(host({ lentTerminal: () => false }).turn("t1", noDesk, { ...reach, sharedTools: true }, prompt)).toContain("You can't run commands");+ expect(host({ cloudHome: false }).turn("t1", noDesk, reach, prompt), "a team's Cloud and the desktop app").toBe("");+ });+});++describe("the rule for the app's sentence on a routine run", () => {+ it("is a shell tool, by any of its names, refused because this turn has none", () => {+ for (const name of ["exec", "bash", "computer_exec", "mcp__computer__exec", "vm_exec", "agents_vm_exec", "run_command", "shell", "python"]) {+ expect(triedCommand({ name, ok: false, output: REFUSED }), name).toBe(true);+ }+ });+ it("never a call that worked, one still running, a command that ran and failed, an app's tool that shares a name, or select_computer", () => {+ expect(triedCommand({ name: "exec", ok: true, output: "{}" })).toBe(false);+ expect(triedCommand({ name: "exec" })).toBe(false);+ expect(triedCommand({ name: "exec", ok: false, output: "{\"ok\":false,\"result\":\"exit code 1\"}" })).toBe(false);+ for (const name of ["agents_list_routines", "gmail.search_emails", "shared_computer", "postgres_execute", "x_command", "agents_select_computer"]) {+ expect(triedCommand({ name, ok: false, output: REFUSED }), name).toBe(false);+ }+ });+});++describe("a routine run's line ends with the app's sentence", () => {+ const refused: Line = { kind: "activity", at: T0 + 2, tool: { name: "exec", ok: false, output: REFUSED } };+ const said = (text: string): Line => ({ role: "bot", kind: "text", at: T0 + 3, text });+ const runOf = (status = "completed", routineId = "r1") => ({ routineId, threadId: "t1", startedAt: T0, status });+ const SENTENCE = "This run couldn't run commands: gpt-5-mini has no terminal on My Cloud. To run them, this routine needs a model with a terminal, such as Claude or Codex.";++ it("Case A: a run with no terminal whose bot tried its script, under its reply; and under the line saying it failed", () => {+ const one = host({ lines: [refused, said("No execution environment was mounted.")], run: () => runOf() });+ one.turn("t1", noDesk, reach, { ...prompt, routine: true }, T0 + 1);+ expect(one.notes.has("run")).toBe(false);+ expect(one.notes.take("run", undefined)).toBe(SENTENCE);+ const failed = host({ lines: [refused], run: () => runOf("failed") });+ failed.turn("t1", desk, reach, { ...prompt, routine: true }, T0 + 1);+ expect(failed.notes.take("run", undefined)).toBe(SENTENCE.replace("Claude or Codex.", "Claude or Codex, or to run on the cloud desktop."));+ });++ it("says it once per routine and model, never makes a line by itself, and never for a quiet run", () => {+ const lines = [refused, said("Couldn't run sync.py.")];+ let run = runOf();+ const h = host({ lines, run: () => run });+ h.turn("t1", noDesk, reach, prompt, T0 + 1);+ expect(h.notes.take("run", undefined)).toBe(SENTENCE);+ h.turn("t1", noDesk, reach, prompt, T0 + 1);+ expect(h.notes.take("run", undefined), "the same routine on the same model again").toBeNull();+ h.turn("t1", noDesk, reach, { ...prompt, model: "other-model" }, T0 + 1);+ expect(h.notes.take("run", undefined), "on another model").toContain("other-model has no terminal");+ run = runOf("completed", "r2");+ const quiet = host({ lines: [refused, said("Checked.\nNOTHING NEW")], run: () => run });+ quiet.turn("t1", noDesk, reach, prompt, T0 + 1);+ expect(quiet.notes.has("run")).toBe(false);+ expect(quiet.notes.take("run", undefined), "a quiet run").toBeNull();+ const silent = host({ lines: [refused], run: () => run });+ silent.turn("t1", noDesk, reach, prompt, T0 + 1);+ expect(silent.notes.take("run", undefined), "a run that said nothing").toBeNull();+ });++ it("names the model the run's own turn ran on, and asks for a model, never for the bot's to change (a routine can have its own)", () => {+ const h = host({ lines: [refused, said("Couldn't.")], run: () => runOf() });+ h.turn("t1", noDesk, reach, { ...prompt, model: "routine-own-model" }, T0 + 1);+ const text = h.notes.take("run", undefined)!;+ expect(text).toContain("routine-own-model has no terminal on My Cloud");+ expect(text).not.toMatch(/switch/iu);+ });++ it("adds nothing when no command was tried, a turn could run them, the call came before this run, or off My Cloud", () => {+ const tried = [refused, said("Done.")];+ const none = host({ lines: [said("Filed.")], run: () => runOf() });+ none.turn("t1", noDesk, reach, prompt, T0 + 1);+ expect(none.notes.take("run", undefined)).toBeNull();+ const shell = host({ lines: tried, run: () => runOf() });+ shell.turn("t1", noDesk, { ...reach, ownShell: true }, prompt, T0 + 1);+ expect(shell.notes.take("run", undefined)).toBeNull();+ const before = host({ lines: [{ ...refused, at: T0 - 5 }, said("Done.")], run: () => runOf() });+ before.turn("t1", noDesk, reach, prompt, T0 + 1);+ expect(before.notes.take("run", undefined)).toBeNull();+ const stale = host({ lines: tried, run: () => runOf() });+ stale.turn("t1", noDesk, reach, prompt, T0 - 10);+ expect(stale.notes.take("run", undefined)).toBeNull();+ const desktop = host({ cloudHome: false, lines: tried, run: () => runOf() });+ desktop.turn("t1", noDesk, reach, prompt, T0 + 1);+ expect(desktop.notes.take("run", undefined)).toBeNull();+ });++ it("reads in the language of the chat it reports to", () => {+ addServerLinePacks({ xx: { "server.reach.runNoTerminal": "· {model}" } });+ const h = host({ lines: [refused, said("Couldn't.")], run: () => runOf() });+ h.turn("t1", noDesk, reach, prompt, T0 + 1);+ expect(h.notes.take("run", "xx")).toBe("· gpt-5-mini");+ });+});++describe("switching a bot to a model with no terminal says so once, only where it is true", () => {+ const engines: Record<string, { model: string; shell: boolean }> = { claude: { model: "Claude", shell: true }, compat: { model: "gpt-5-mini", shell: false } };+ function switcher(over: Partial<Omit<NoTerminalDeps<Bot>, "lines">> = {}) {+ const notices: Array<[string, string]> = [];+ const h = host({+ engine: (selection) => engines[selection.instanceId], bot: () => ({ name: "Ledger" }), noComputer: () => true, lentTerminal: () => false,+ routines: () => [{ runOn: "maus" }, { runOn: "cloud" }, { runOn: "maus", modelSelection: { instanceId: "claude" } }, {}],+ notice: (threadId, text) => notices.push([threadId, text]), ...over,+ });+ return { h, notices };+ }+ const claude = { instanceId: "claude", model: "sonnet" }, compat = { instanceId: "compat", model: "gpt-5-mini" };++ it("names the routines that follow the bot's model and lose commands, in the conversation it was switched from", () => {+ const { h, notices } = switcher();+ h.modelSwitched("b1", "t1", claude, compat, true);+ expect(notices).toEqual([["t1", "gpt-5-mini can't run commands on My Cloud by itself. Ledger has 2 routines; they will only be able to do work that needs no commands."]]);+ h.modelSwitched("b1", "t2", compat, claude, true);+ h.modelSwitched("b1", "t3", compat, compat, true);+ expect(notices, "back to a terminal, or no change").toHaveLength(1);+ });++ it("must-fix 2: says nothing where the bot's work still has a computer that runs commands", () => {+ // Works on the cloud desktop, a VPS on Auto, a team's computer, a chat pinned to the cloud desktop (turnSurfacePlan).+ for (const noComputer of [() => false, (_botId: string, threadId?: string) => threadId === undefined]) {+ const { h, notices } = switcher({ noComputer });+ h.modelSwitched("b1", "t1", claude, compat, true);+ expect(notices).toEqual([]);+ }+ // A lent computer that lends its terminal.+ const lent = switcher({ lentTerminal: () => true });+ lent.h.modelSwitched("b1", "t1", claude, compat, true);+ expect(lent.notices).toEqual([]);+ });++ it("a conversation's own model reads as this chat only, and counts no routines", () => {+ const { h, notices } = switcher();+ h.modelSwitched("b1", "t4", claude, compat, false);+ expect(notices).toEqual([["t4", "In this chat, gpt-5-mini can't run commands on My Cloud by itself, so scripts and programs can't run here."]]);+ });++ it("says nothing when nothing is lost", () => {+ const base = { bot: "Ledger", model: "gpt-5-mini", hadShell: true, sameEngine: false, ownFolder: false, routines: 0, chatOnly: false };+ expect(modelSwitchNotice(base, undefined)).toBe("gpt-5-mini can't run commands on My Cloud by itself, so Ledger can't run scripts or programs here anymore.");+ expect(modelSwitchNotice({ ...base, hadShell: false }, undefined), "chat to chat with nothing to run").toBeNull();+ expect(modelSwitchNotice({ ...base, hadShell: false, sameEngine: true, routines: 3 }, undefined), "another model of the same chat engine").toBeNull();+ expect(modelSwitchNotice({ ...base, routines: 1 }, undefined)).toContain("Ledger has a routine; it will only");+ const desktop = switcher({ cloudHome: false });+ desktop.h.modelSwitched("b1", "t1", claude, compat, true);+ expect(desktop.notices).toEqual([]);+ });+});diff --git a/server/host/no-terminal.ts b/server/host/no-terminal.tsnew file mode 100644index 0000000000..502bd8610c--- /dev/null+++ b/server/host/no-terminal.ts@@ -0,0 +1,156 @@+// A bot on a chat-only model (openai-compat and the other chat engines) has no shell of its own, and on My Cloud nothing+// gives it one by default: vm_exec is left out there (drivers/agents-catalog.ts), the chat runtime has only the tools its+// MCP servers bring, and the cloud desktop's exec is mounted only on a turn whose place is the cloud desktop. Left to+// itself such a bot explained a script it could not run in its own words ("no execution environment was mounted") and+// the run read as fine. So the app says it: the turn's context states the real reason (or, on a turn that may move, that+// the cloud desktop runs commands), a routine run that tried a command ends with the app's own sentence, once per routine+// and model, and switching a bot to such a model says once, in its chat, what that takes away. Each sentence shows only+// where it is true; anything less certain shows nothing. Team Clouds and the desktop app are left as they were.+import { readRunReply } from "../automation-reports.ts";+import { serverLine } from "../server-lines.ts";++/** What a turn has for running commands, as it is about to start. */+export interface TurnReach {+ /** The engine runs commands itself (its own folder and shell: workspace.ts supportsWorkspaceFiles). */+ ownShell: boolean;+ /** A cloud desktop or VPS is mounted for this turn, whose tools include exec. */+ computerMounted: boolean;+ /** This turn has shared_computer, so a computer the person lends could run a command for it. */+ sharedTools: boolean;+ /** This turn may move its request with select_computer (a person's own request, not a hand-off or a run). */+ canSelect: boolean;+}++/** For the model only (English, as every prompt part). */+export function noTerminalPrompt(input: { model: string; cloudDesktop: boolean; routine: boolean }): string {+ const why = ` You can't run commands this turn: on My Cloud this model (${input.model}) has no terminal of its own, and no cloud desktop is in use. Nothing is broken.`;+ if (input.routine) return `${why} Do the parts that need no command and say which step was not done, without giving a reason for it.`;+ return `${why} If the work needs a command, don't try another way or give another reason: say ${input.model} can't run commands on My Cloud, and that a model with a terminal, such as Claude or Codex${input.cloudDesktop ? ", or the cloud desktop," : ""} can.`;+}++/** For a turn that may move to the cloud desktop: the way to run a command is to go there. */+export function selectCloudPrompt(model: string): string {+ return ` This turn has no terminal: on My Cloud this model (${model}) can't run commands itself. To run one, call select_computer with surface "cloud": the request moves to the cloud desktop, where exec runs it.`;+}++/** A shell tool by the names models reach for, bare or behind the prefix of the server that has one (computer_exec,+ * mcp__computer__exec, agents_vm_exec). */+const COMMAND_TOOL = /^(?:computer_|agents_|vm_)?(?:exec|vm_exec|bash|sh|zsh|shell|terminal|run_command|run_shell|run_script|execute_command|python3?|powershell)$/iu;+/** What the chat runtime answers a call to a tool this turn was not given (drivers/chat-mcp-tools.ts). */+const NOT_OFFERED = "not advertised for this turn";+const lastPart = (name: string) => name.trim().split(/__|\.|\s/u).filter(Boolean).at(-1) ?? "";++/** The rule for the app's sentence: the bot called a shell tool and it was refused because this turn has none (the+ * runtime's own "not advertised" answer, so an app's tool that merely shares a name and failed for its own reason, or a+ * command that ran and failed, never counts). */+export function triedCommand(tool: { name?: string; ok?: boolean; output?: string } | undefined): boolean {+ if (!tool?.name || tool.ok !== false) return false;+ return COMMAND_TOOL.test(lastPart(tool.name)) && (tool.output ?? "").includes(NOT_OFFERED);+}++type Line = { role?: string; kind?: string; at?: number; text?: string; tool?: { name?: string; ok?: boolean; output?: string } };+type Run = { routineId: string; threadId?: string; startedAt?: number; status?: string };+type Selection = { instanceId: string; model?: string };++export interface NoTerminalDeps<Bot> {+ /** A personal Cloud home (My Cloud). */+ cloudHome: boolean;+ /** The cloud desktop is a place this bot (as its turn runs it) may use now: Computer access is on, its tool scope and+ * the managed policy allow it, its model can work there, and one is set up. */+ cloudDesktop?(bot: Bot): boolean;+ /** The lines of a conversation, oldest first. */+ lines(threadId: string): readonly Line[];+ /** A routine run by its id. */+ run?(runId: string): Run | undefined;+ /** A computer the person lends lends its terminal, online or not: whatever happens then is that computer's to say. */+ lentTerminal?(): boolean;+ /** For a model switch: the engine a selection runs on (its model's name, and whether it has a shell of its own). */+ engine?(selection: Selection): { model: string; shell: boolean } | undefined;+ /** The bot's name and the folder it was set to work in, if any. */+ bot?(botId: string): { name: string; cwd?: string } | undefined;+ /** The bot's routines, paused ones too. */+ routines?(botId: string): ReadonlyArray<{ runOn?: string; modelSelection?: Selection }>;+ /** With no computer of its own and no lent terminal, the bot's work runs where no command can (turnSurfacePlan): not+ * on the cloud desktop it works on, a VPS on Auto, a team's computer, or (with `threadId`) a chat pinned there. */+ noComputer?(botId: string, threadId?: string): boolean;+ language?(threadId: string): string | undefined;+ /** Writes the app's own one line into a conversation. */+ notice?(threadId: string, text: string): void;+}++const FLAGS_KEPT = 2_000;++export function createNoTerminal<Bot>(deps: NoTerminalDeps<Bot>) {+ /** Conversations whose latest turn started with no way to run commands, with the model and place that turn had. */+ const flagged = new Map<string, { at: number; model: string; cloudDesktop: boolean }>();+ /** Routine and model pairs the app has said it for, so a routine that runs every hour says it once. */+ const said = new Set<string>();++ /** The app's sentence for a run, null unless a turn of it had no way to run commands, the bot then tried one, its+ * reply says something, and this routine on this model was not told before. */+ const noteFor = (run: Run, language: string | undefined): { key: string; text: string } | null => {+ const turn = run.threadId ? flagged.get(run.threadId) : undefined, started = run.startedAt ?? 0;+ if (!turn || turn.at < started || said.has(`${run.routineId}\0${turn.model}`)) return null;+ const lines = deps.lines(run.threadId!).filter((line) => (line.at ?? Number.POSITIVE_INFINITY) >= started);+ if (!lines.some((line) => line.kind === "activity" && triedCommand(line.tool))) return null;+ const key = turn.cloudDesktop ? "server.reach.runNoTerminalCloud" : "server.reach.runNoTerminal";+ return { key: `${run.routineId}\0${turn.model}`, text: serverLine(language, key, { model: turn.model }) };+ };++ return {+ /** A turn is starting: its context line, empty when it can run commands or this is not My Cloud. */+ turn(threadId: string, bot: Bot, reach: TurnReach, prompt: { model: string; routine: boolean }, now = Date.now()): string {+ flagged.delete(threadId);+ if (!deps.cloudHome || reach.ownShell || reach.computerMounted || (reach.sharedTools && deps.lentTerminal?.())) return "";+ const cloudDesktop = deps.cloudDesktop?.(bot) === true;+ if (reach.canSelect && cloudDesktop) return selectCloudPrompt(prompt.model);+ flagged.set(threadId, { at: now, model: prompt.model, cloudDesktop });+ // Newest last: the oldest conversations' flags go first, long after any run of theirs was reported.+ for (const oldest of flagged.keys()) { if (flagged.size <= FLAGS_KEPT) break; flagged.delete(oldest); }+ return noTerminalPrompt({ ...prompt, cloudDesktop });+ },+ /** The app's line under a run's line (automation-reports.ts notes): under its reply, or under the line saying it+ * failed. It never makes a line by itself: a completed run that said nothing gets none, so the person is never+ * pushed the note alone. */+ notes: {+ has: (_runId: string): boolean => false,+ take(runId: string, language: string | undefined): string | null {+ const run = deps.run?.(runId), note = run ? noteFor(run, language) : null;+ if (!run?.threadId || !note) return null;+ const reply = deps.lines(run.threadId).findLast((line) => line.role === "bot" && line.kind === "text" && (line.at ?? 0) >= (run.startedAt ?? 0));+ if (run.status !== "failed" && readRunReply(reply?.text ?? "").quiet) return null;+ said.add(note.key);+ return note.text;+ },+ },+ /** A model switch, from `before` to `after`, seen in `threadId`. `routinesFollow`: the bot's own model changed, so its+ * routines run on the new one; otherwise only this chat's did. */+ modelSwitched(botId: string, threadId: string, before: Selection, after: Selection, routinesFollow: boolean): void {+ if (!deps.cloudHome || (before.instanceId === after.instanceId && before.model === after.model)) return;+ const bot = deps.bot?.(botId), was = deps.engine?.(before), now = deps.engine?.(after);+ if (!bot || !now || now.shell || deps.lentTerminal?.()) return;+ // Where the bot (or this chat) works on the cloud desktop, a VPS or a team's computer, exec is still there.+ if (!deps.noComputer?.(botId, threadId) || (routinesFollow && !deps.noComputer(botId))) return;+ // A routine on the cloud desktop has exec there; one with a model of its own keeps that model.+ const routines = routinesFollow ? (deps.routines?.(botId) ?? []).filter((routine) => routine.runOn !== "cloud" && !routine.modelSelection).length : 0;+ const text = modelSwitchNotice({ bot: bot.name, model: now.model, hadShell: was?.shell === true, sameEngine: before.instanceId === after.instanceId,+ ownFolder: Boolean(bot.cwd), routines, chatOnly: !routinesFollow }, deps.language?.(threadId));+ if (text) deps.notice?.(threadId, text);+ },+ };+}++export type NoTerminal = ReturnType<typeof createNoTerminal>;++/** The line a switch to a model with no terminal shows once, where the bot's work has no computer to run commands on;+ * null when the switch takes nothing away: from another model of the same chat engine, or with nothing to run. */+export function modelSwitchNotice(input: {+ bot: string; model: string; hadShell: boolean; sameEngine: boolean; ownFolder: boolean; routines: number; chatOnly: boolean;+}, language: string | undefined): string | null {+ if (input.sameEngine && !input.hadShell) return null;+ if (input.chatOnly) return input.hadShell || input.ownFolder ? serverLine(language, "server.reach.modelNoTerminalChat", { model: input.model }) : null;+ if (input.routines > 0) {+ return serverLine(language, input.routines === 1 ? "server.reach.modelNoTerminalRoutine" : "server.reach.modelNoTerminalRoutines", { model: input.model, bot: input.bot, count: input.routines });+ }+ return input.hadShell || input.ownFolder ? serverLine(language, "server.reach.modelNoTerminal", { model: input.model, bot: input.bot }) : null;+}diff --git a/server/host/place-move.test.ts b/server/host/place-move.test.tsnew file mode 100644index 0000000000..f30cb0d3bb--- /dev/null+++ b/server/host/place-move.test.ts@@ -0,0 +1,45 @@+import { describe, expect, it } from "vitest";++import { changesMachine, createPlaceMoves, placeMoveForBot, placeMoveLine } from "./place-move.ts";++describe("a move between a Cloud and its cloud desktop keeps the files (server/host/place-move.ts)", () => {+ it("Case B: My Cloud to a new cloud desktop tells the bot its files are on My Cloud, not lost, and how to copy one", () => {+ expect(placeMoveForBot({ from: undefined, to: "cloud", home: "my-cloud", fresh: true, folder: "/data/task-workspaces/b1/t1" }))+ .toBe(" The cloud desktop is another machine with its own disk. It is new, so it starts empty. Your files on My Cloud are still there, not lost."+ + " To use a file from My Cloud, copy it there with copy_to_computer (from: a path relative to your working folder, /data/task-workspaces/b1/t1).");+ expect(placeMoveLine({ from: undefined, to: "cloud", home: "my-cloud", fresh: true, bot: "Ledger" }, undefined))+ .toBe("Ledger now works on the cloud desktop, a new one that starts empty. Its files on My Cloud are still there; nothing was lost.");+ expect(placeMoveLine({ from: "browser", to: "cloud", home: "my-cloud", bot: "Ledger" }, undefined))+ .toBe("Ledger now works on the cloud desktop, a different machine from My Cloud. Its files on My Cloud are still there; nothing was lost.");+ });++ it("should-fix 5: a self-hosted VPS gets no copy tools and is never new", () => {+ const text = placeMoveForBot({ from: undefined, to: "cloud", home: "my-cloud", vps: true, fresh: true });+ expect(text).toBe(" The cloud desktop is another machine with its own disk. Your files on My Cloud are still there, not lost.");+ expect(placeMoveLine({ from: undefined, to: "cloud", home: "my-cloud", vps: true, fresh: true, bot: "Ledger" }, undefined)).not.toContain("starts empty");+ });++ it("the reverse says the cloud desktop's files stay there; a team's Cloud is this Cloud", () => {+ expect(placeMoveForBot({ from: "cloud", to: "browser", home: "my-cloud" })).toBe(" My Cloud is another machine with its own disk. Your files on the cloud desktop are still there, not lost. Files you made on the cloud desktop stay there.");+ expect(placeMoveLine({ from: "cloud", to: "browser", home: "team-cloud", bot: "Ledger" }, undefined))+ .toBe("Ledger now works on this Cloud, a different machine from the cloud desktop. Its files on the cloud desktop are still there; nothing was lost.");+ });++ it("should-fix 8: the desktop app says nothing new on any move, and nothing is said where the files stay", () => {+ expect(changesMachine({ from: "local", to: "vm", home: null })).toBe(false);+ expect(changesMachine({ from: undefined, to: "cloud", home: null })).toBe(false);+ expect(placeMoveForBot({ from: "local", to: "vm", home: null })).toBe("");+ expect(placeMoveLine({ from: undefined, to: "vm", home: null, bot: "Ledger" }, undefined)).toBeNull();+ expect(placeMoveForBot({ from: undefined, to: "browser", home: "my-cloud" })).toBe("");+ expect(placeMoveForBot({ from: undefined, to: "cloud", home: "my-cloud" })).not.toContain("starts empty");+ });++ it("writes the person's line only when told the request continued there", () => {+ const notices: string[] = [];+ const moves = createPlaceMoves({ home: "my-cloud", folder: () => "/w", vps: () => false, language: () => undefined, notice: (_threadId, text) => notices.push(text) });+ expect(moves.forBot("b1", "t1", undefined, "cloud", true)).toContain("(from: a path relative to your working folder, /w)");+ expect(notices).toEqual([]);+ moves.continued({ id: "b1", name: "Ledger" }, "t1", undefined, "cloud", true);+ expect(notices).toEqual(["Ledger now works on the cloud desktop, a new one that starts empty. Its files on My Cloud are still there; nothing was lost."]);+ });+});diff --git a/server/host/place-move.ts b/server/host/place-move.tsnew file mode 100644index 0000000000..6fb59d29d9--- /dev/null+++ b/server/host/place-move.ts@@ -0,0 +1,92 @@+// On a Cloud, a conversation moving between the Cloud itself and the cloud desktop (with select_computer) moves the work,+// never its files: the cloud desktop is another machine with its own disk. A bot that searched a new cloud desktop and+// found nothing used to report the person's files gone, so the move says what it is, to the bot in the message that+// continues the request and to the person in one line of the chat once the request continues there. The desktop app is+// left as it was: its Local VM's folder is this computer's own (container-computer.ts), so nothing there is elsewhere.+import { serverLine } from "../server-lines.ts";+import type { Surface } from "../surface.ts";++/** A personal Cloud (My Cloud) or a team's. */+export type CloudHome = "my-cloud" | "team-cloud";++export interface PlaceMove {+ /** The place the turn that chose the move had mounted; nothing, or the built-in browser, is the Cloud itself. */+ from: Surface | undefined;+ to: Surface;+ /** The Cloud this runs on; null on the desktop app, where a move says nothing new. */+ home: CloudHome | null;+ /** The cloud desktop is a self-hosted VPS: no copy tools, and a move never makes one. */+ vps?: boolean;+ /** The move creates this cloud desktop: it starts empty. */+ fresh?: boolean;+ /** The folder the copy tools read and write on the Cloud (the conversation's working folder). */+ folder?: string;+}++const onCloud = (place: Surface | undefined) => place === "cloud";++/** Whether the move lands on another machine's disk: only between the Cloud and its cloud desktop. */+export function changesMachine(move: Pick<PlaceMove, "from" | "to" | "home">): boolean {+ return move.home !== null && onCloud(move.from) !== onCloud(move.to);+}++/** What the bot is told beside "The computer selection is now …"; empty when the files stay where the work goes. */+export function placeMoveForBot(move: PlaceMove): string {+ if (!changesMachine(move)) return "";+ const home = move.home === "my-cloud" ? "My Cloud" : "this Cloud";+ const [from, to] = onCloud(move.to) ? [home, "the cloud desktop"] : ["the cloud desktop", home];+ const fresh = move.fresh && !move.vps && onCloud(move.to) ? " It is new, so it starts empty." : "";+ const copy = move.vps ? "" : onCloud(move.to)+ ? ` To use a file from ${home}, copy it there with copy_to_computer (from: a path relative to your working folder${move.folder ? `, ${move.folder}` : ""}).`+ : " Files you made on the cloud desktop stay there.";+ return ` ${to[0]!.toUpperCase()}${to.slice(1)} is another machine with its own disk.${fresh} Your files on ${from} are still there, not lost.${copy}`;+}++/** The person's one line for the move, in their language; null when the files stay where the work goes. */+export function placeMoveLine(move: PlaceMove & { bot: string }, language: string | undefined): string | null {+ if (!changesMachine(move)) return null;+ const home = serverLine(language, move.home === "my-cloud" ? "server.reach.place.myCloud" : "server.reach.place.thisCloud");+ const desktop = serverLine(language, "server.reach.place.cloudDesktop");+ const [from, to] = onCloud(move.to) ? [home, desktop] : [desktop, home];+ return serverLine(language, move.fresh && !move.vps && onCloud(move.to) ? "server.reach.placeMovedNew" : "server.reach.placeMoved", { bot: move.bot, from, to });+}++/** A request a turn is moving with select_computer, continued on its new place once the turn ends (server/index.ts). */+export interface ComputerSelection<Opts, Outcome, Source, Data> {+ generation: string;+ botId: string;+ /** None for a teammate's hand-off, which moves only to the browser and continues with `handoff.opts`. */+ source?: Source;+ text: string;+ dataContext?: Data;+ handoff?: { opts: Opts; outcome?: Outcome };+ mounted?: Surface;+ selected?: Surface;+ /** The move creates the cloud desktop it goes to. */+ fresh?: boolean;+ previousSurface?: Surface;+}++export interface PlaceMovesDeps {+ home: CloudHome | null;+ /** The conversation's working folder, where the copy tools read and write. */+ folder(botId: string, threadId: string): string | undefined;+ /** The bot's cloud desktop is a self-hosted VPS. */+ vps(botId: string): boolean;+ language(threadId: string): string | undefined;+ notice(threadId: string, text: string): void;+}++export function createPlaceMoves(deps: PlaceMovesDeps) {+ const move = (botId: string, threadId: string, from: Surface | undefined, to: Surface, fresh?: boolean): PlaceMove =>+ ({ from, to, home: deps.home, vps: deps.vps(botId), fresh, folder: deps.folder(botId, threadId) });+ return {+ /** The bot's words beside "The computer selection is now …". */+ forBot: (botId: string, threadId: string, from: Surface | undefined, to: Surface, fresh?: boolean): string => placeMoveForBot(move(botId, threadId, from, to, fresh)),+ /** The request continues on its new place: the person's one line, when the files stayed behind. */+ continued(bot: { id: string; name: string }, threadId: string, from: Surface | undefined, to: Surface, fresh?: boolean): void {+ const line = placeMoveLine({ ...move(bot.id, threadId, from, to, fresh), bot: bot.name }, deps.language(threadId));+ if (line) deps.notice(threadId, line);+ },+ };+}diff --git a/server/index.ts b/server/index.tsindex 26cecfb5c4..7c2da44b17 100644--- a/server/index.ts+++ b/server/index.ts@@ -47,7 +47,7 @@ import { escapeAttribute } from "../src/lib/composer-attachments.ts";import { isPendingSignInRequest, normalizeSignInSite, signInCardWaits, signInOutcome, signInResumePrompt } from "../shared/sign-in-request.ts";import { createRoomTurnLevels } from "./room-turn-level.ts";-import { createSignInSettle } from "./host/sign-in-settle.ts"; import { createPersonLanguages, THIS_COMPUTER } from "./host/person-languages.ts"; import "./server-line-packs.ts"; import { conversationLanguage, serverLine, setConversationLanguage } from "./server-lines.ts";+import { createSignInSettle } from "./host/sign-in-settle.ts"; import { createNoTerminal } from "./host/no-terminal.ts"; import { createPlaceMoves, type ComputerSelection } from "./host/place-move.ts"; import { createPersonLanguages, THIS_COMPUTER } from "./host/person-languages.ts"; import "./server-line-packs.ts"; import { conversationLanguage, serverLine, setConversationLanguage } from "./server-lines.ts";import { RoomMemberLock } from "./room-member-lock.ts";import { approvalHeldNote, approvalHeldReason, approvalModeForOrigin, autoVerdict, deliverFullAccessApproval, undeliveredApprovalTool } from "./auto-approve.ts"; import { readsOwnFiles } from "./own-file-reads.ts";import { bindSafetyFloor, denyAtSafetyFloor, heldAtSafetyFloor, safetyFloorOn } from "./safety-floor-gate.ts";@@ -1610,16 +1610,7 @@ const internalCapabilities = new Map<string, InternalCapability>(); const lateToconst activeInternalGenerationByThread = new Map<string, string>();const turnCallSignals = createTurnCallSignals(internalCapabilityIsActive);const internalGenerationByProviderTurn = new ProviderTurnGenerationRegistry();-const computerSelectionTurns = new Map<string, {- generation: string;- botId: string;- source?: Message; // none for a teammate's hand-off, which moves only to the browser and continues with `handoff.opts`- text: string;- dataContext?: DataContext; handoff?: { opts: Parameters<typeof startTurn>[2]; outcome?: DirectTurnOutcome };- mounted?: Surface;- selected?: Surface;- previousSurface?: Surface;-}>();+const computerSelectionTurns = new Map<string, ComputerSelection<Parameters<typeof startTurn>[2], DirectTurnOutcome, Message, DataContext>>();// Standing bearer tokens for bots running outside this server (external-runtimes.json, mode 600): peer comms on one thread only; missing bindings fail closed.const EXTERNAL_RUNTIME_GENERATION = "external-runtime";const EXTERNAL_RUNTIMES_FILE = join(DATA_DIR, "external-runtimes.json");@@ -5543,8 +5534,13 @@ function isUnattended(botId?: string | null, threadId?: string): boolean {}const reviewAnswerThreads = new Set<string>(); const firstHourHooks = createFirstHourHooks({ dataDir: DATA_DIR, personal: Boolean(CLOUD_PERSONAL) });+const activityNotice = (threadId: string, text: string) => { store.appendMessage(threadId, { role: "bot", kind: "activity", tool: { name: `notice: ${text}`, ok: true } }); }; const noTerminal = createNoTerminal({ cloudHome: CLOUD_PERSONAL, lines: (threadId) => store.messagesFor(threadId), run: (runId) => routines?.listRuns().find((run) => run.id === runId), language: threadLanguage, notice: activityNotice,+ cloudDesktop: (bot: BotRecord) => bot.computer !== "off" && bot.cloudBackend !== "vps" && boat.boatConfigured(cfg) && canWorkOnCloud(cloudEngine(registry.get(bot.modelSelection.instanceId))) && !computerPlaceRefusal("box") && !cloudPlaceRefusal(cloudEngine(registry.get(bot.modelSelection.instanceId), bot.modelSelection.model), "works-on", bot.name) && !computerToolsRefusal(toolScopeForTurn(bot.id), "works-on", bot.name),+ lentTerminal: () => sharedComputers.known(CLOUD_HOME_LENDER).some((lent) => lent.lent && lent.scopes.terminal), noComputer: (botId, threadId) => { const bot = store.bot(botId), place = bot && turnSurfacePlan(bot, undefined, threadId).computer; return Boolean(bot) && place !== "cloud" && !(place === undefined && bot!.cloudBackend === "vps") && !inheritedTeamComputer(bot!); },+ engine: (selection) => { const instance = registry.get(selection.instanceId); return instance ? { model: cloudEngine(instance, selection.model).name, shell: supportsWorkspaceFiles(instance.driverKind) } : undefined; }, bot: (botId) => store.bot(botId) ?? undefined, routines: (botId) => routines?.listRoutines().filter((routine) => routine.botId === botId) ?? [] });+const placeMoves = createPlaceMoves({ home: CLOUD_PERSONAL ? "my-cloud" : CLOUD_HOME ? "team-cloud" : null, folder: (botId, threadId) => messageFileRootsForThread(botId, threadId)[0], vps: (botId) => store.bot(botId)?.cloudBackend === "vps", language: threadLanguage, notice: activityNotice });let routines: RoutineManager | null = null;-const automationReports = createAutomationReports({ store, routines: () => routines, busy: threadBusy, wrote: markTaskContextExternallyUpdated, brief: (run, turnId) => proactive.runSettled(run, turnId), threadLanguage, notes: refusedLending.notes,+const automationReports = createAutomationReports({ store, routines: () => routines, busy: threadBusy, wrote: markTaskContextExternallyUpdated, brief: (run, turnId) => proactive.runSettled(run, turnId), threadLanguage, notes: { has: (id) => refusedLending.notes.has(id) || noTerminal.notes.has(id), take: (id, language) => [refusedLending.notes.take(id, language), noTerminal.notes.take(id, language)].filter(Boolean).join("\n\n") || null },notify: (kind, bot, threadId, detail) => notify(buildNotification(kind, bot, threadId, detail, { avatarUrl: bot.avatarUrl }), { routine: true }) });const proactive = createProactive({ store, cfg, composio, registry, dataDir: DATA_DIR, ideas: (botId) => memoryUpkeep.ideas(botId), ...firstHourHooks.proactive, team: Boolean(HOSTED_WORKSPACE || CLOUD_TEAM), frozen: moveFreeze.frozen, routines: () => routines, mainThread: botMainThread, threadBusy, notify, helpers: { decider, extractor }, cloud: Boolean(CLOUD_HOME || HOSTED_WORKSPACE || CLOUD_TEAM),engineName: (instanceId) => engineName(instanceId), hostTimeZone: () => (CLOUD_HOME ? undefined : hostTimeZone()), decide: (row) => appendDecision(DATA_DIR, row), stale: shouldIgnoreProviderEvent, release: (threadId) => watchdog.setWaitingOnHuman(threadId, false),@@ -6049,12 +6045,12 @@ function browserSelectable(bot: BotRecord): boolean {}/** Continues this request on `surface` once its turn ends; false when this turn cannot switch, or already switches elsewhere. */-function selectTurnPlace(turn: { botId: string; threadId: string; generation: string }, surface: Surface): boolean {+function selectTurnPlace(turn: { botId: string; threadId: string; generation: string }, surface: Surface, fresh = false): boolean {const source = computerSelectionTurns.get(turn.threadId);const bot = store.projectBotForTask(turn.botId, turn.threadId);if (!source || source.generation !== turn.generation || !bot || bot.computer === "off" || (source.handoff && surface !== "browser")) return false;if (source.selected) return source.selected === surface;- source.selected = surface;+ source.selected = surface; source.fresh = fresh;source.previousSurface = store.taskByThread(bot.id, bot.threadId)?.surface;return true;}@@ -6076,8 +6072,8 @@ function continueComputerSelection(threadId: string, generation: string | undefiif (hasQueuedSteeredMessages(bot.id, threadId)) { giveUp(); drainQueuedSends(); return; }if (selection.source && store.activePath(threadId).findLast(message => message.role === "user" && message.kind === "text")?.id !== selection.source.id) return;store.patchTask(bot.id, threadId, { surface, surfaceSource: "auto" });- const text = `The computer selection is now ${surfaceLabel(surface)}. Continue the ${selection.handoff ? "handed-off" : "user's original"} request using the tools mounted for this turn; verify the result before claiming success.\n\n${selection.text}`;- if (selection.handoff) directCoordinationSettlers.delete(generation!); /* the continuing turn owns the hand-off's result */ void startTurn(bot.id, text, selection.handoff ? { ...selection.handoff.opts, threadId, computerSelectionContinuation: true } : { threadId, userMessage: selection.source, computerSelectionContinuation: true, dataContext: selection.dataContext }).catch(error => {+ const text = `The computer selection is now ${surfaceLabel(surface)}.${placeMoves.forBot(bot.id, threadId, selection.mounted, surface, selection.fresh)} Continue the ${selection.handoff ? "handed-off" : "user's original"} request using the tools mounted for this turn; verify the result before claiming success.\n\n${selection.text}`;+ if (selection.handoff) directCoordinationSettlers.delete(generation!); /* the continuing turn owns the hand-off's result */ void startTurn(bot.id, text, selection.handoff ? { ...selection.handoff.opts, threadId, computerSelectionContinuation: true } : { threadId, userMessage: selection.source, computerSelectionContinuation: true, dataContext: selection.dataContext }).then(() => placeMoves.continued(bot, threadId, selection.mounted, surface, selection.fresh)).catch(error => {const why = `Could not continue on ${surfaceLabel(surface)}: ${error instanceof Error ? error.message : String(error)}`; selection.handoff?.opts?.coordination?.settle({ ok: false, text: why });if (store.taskByThread(bot.id, threadId)) store.appendMessage(threadId, { role: "bot", kind: "activity", tool: { name: why, ok: false } }); });});@@ -8274,7 +8270,7 @@ async function beginTurn(}) },{ id: "files", label: "File locations", text: worksInWorkspace ? workspaceLocationsPrompt(bot.id, cwd, liveBot?.cwd ?? bot.cwd, { attachFile: Boolean(integrations.agents) && !CLOUD_HOME && !HOSTED_WORKSPACE }) + teamFilesHost.promptLine(bot.id) : "" },{ id: "shell", label: "Long-running commands", text: worksInWorkspace ? longCommandsPrompt(computerPromptKind) : "" },- { id: "computer", label: "Computer", text: computerPrompt(computerPromptKind) },+ { id: "computer", label: "Computer", text: computerPrompt(computerPromptKind) + noTerminal.turn(threadId, bot, { ownShell: worksInWorkspace, computerMounted: computerKind !== null, sharedTools: Boolean(integrations.agents && lendingEnabled()), canSelect: Boolean(computerSelectionTurns.get(threadId) && !computerSelectionTurns.get(threadId)?.handoff) }, { model: cloudEngine(instance, bot.modelSelection.model).name, routine: opts?.automationSource !== undefined }) },{ id: "team-computer", label: "Team computer", text: teamComputerPrompt(teamComputer) },{ id: "plan", label: "Surface", text: surfacePrompt({ computer: mountedComputer, browser: Boolean(integrations.browser) }, { pinned: plan.pinned, note: plan.note + vpsUnavailableNote + vmUpdateNote + (computerSkipped && plan.computer !== "off" ? computerSkippedNote(redactSecretsInText(computerSkipped)) : "") + (computerSelectionTurns.get(threadId)?.handoff && !integrations.browser ? HANDOFF_BROWSER_NOTE : ""), canSelect: computerSelectionTurns.has(threadId) && !computerSelectionTurns.get(threadId)?.handoff, selectionRules: !selectionRulesStable, cloudHome: Boolean(CLOUD_HOME), botOpened: plan.botOpened, ownComputer: CLOUD_HOME && integrations.agents && lendingEnabled() ? sharedComputers.known(CLOUD_HOME_LENDER) : undefined, thisComputer: !CLOUD_HOME && bot.computer !== "off" && !inheritedTeamComputer(bot) && shouldMountLocalComputer({ requested: "local", providerSupportsLocal: instance.adapter.capabilities.localComputerMcp === true }) ? { bot: bot.name, botId: bot.id, platform: process.platform } : undefined }) }, { id: "computer-selection", label: "Choosing a computer", text: selectionRulesStable ? computerSelectionPrompt({ cloudHome: Boolean(CLOUD_HOME) }) : "" },{ id: "cloud-home", label: "My Cloud", text: CLOUD_HOME ? cloudHomePrompt(Boolean(integrations.agents) && lendingEnabled(), syncedFolders(DATA_DIR), sharedComputers.known(CLOUD_HOME_LENDER), CLOUD_PERSONAL) + firstHourHooks.prompt(bot.id, threadId) : "" }, phoneLinkPart(),@@ -12031,14 +12027,14 @@ ROUTES.push(createBotCreateRoutes({}), createTeamOwnerRoutes({ team: CLOUD_TEAM, people: teamOwners.people, store, presence: teamPresence.of, record: (auth, row) => appendAdminAction(DATA_DIR, { ...row, actor: decisionActorFor(auth) }), sees: (auth, botId) => visibleTo(viewerFor(auth)).bot(botId), publicBot,profileOf: (email) => teamHost.people.profile(personKey({ id: "", email })) }));ROUTES.push(createBotSettingsRoutes({- store, cfg, registry, commandAllowlist, commandAllowlistDrivers: COMMAND_ALLOWLIST_DRIVERS,+ store, cfg, registry, commandAllowlist, commandAllowlistDrivers: COMMAND_ALLOWLIST_DRIVERS, modelSwitched: noTerminal.modelSwitched,cloudHome: Boolean(CLOUD_HOME), cloudOwnerProfileFields: CLOUD_OWNER_PROFILE_FIELDS,hostedModels, supportsApprovalMode, directTurnBots, broadcast, notificationListed, wireBot, cloudOwnerSession, storedAvatarExists,requestedTaskBot, threadBusy, activeGroupTurnForBot, checkedModelSelection, engineSwitchNeedsAsk, readCursor,canManageCommandAllowlist, commandAllowlistResponse, cardAnswerRefusal, threadRead: teamMessages.seen, levelOf, personMarkThread: personRooms.personMarkThread,}));const botOrderRoutes = createBotOrderRoutes({ store, visibleFor: (auth) => visibleTo(viewerFor(auth)), ...(botOrders ? { own: { person: botOrders.personOf, order: botOrders, told: (person, botIds) => broadcast({ kind: "bots.order", botIds }, { person }) } } : {}) }); ROUTES.push(createGroupOrderRoutes({ store, visibleFor: (auth) => visibleTo(viewerFor(auth)) }), botOrderRoutes, createBotAccessRoutes({ team: CLOUD_TEAM, people: teamOwners.people, store, levelOf, wireBot, publicGroupState, broadcast, audienceChanged, record: (auth, row) => appendAdminAction(DATA_DIR, { ...row, actor: decisionActorFor(auth) }), shared: createShareNotice({ people: () => teamOwners.people?.list() ?? [], profileName: (email) => teamHost.people.profile(personKey({ id: "", email })).name, store: () => store, inbox: () => teamMessages.inbox }) }), accessRequests.routes);-const botPatchRoutes = createBotPatchRoutes({ turnBots: directTurnBots,+const botPatchRoutes = createBotPatchRoutes({ turnBots: directTurnBots, modelSwitched: noTerminal.modelSwitched,store, cfg, registry, sessions, browserRuntime, browserLive, memoryUpkeep, cacheKeepWarm, hostedModels, supportsApprovalMode,routines: () => routines, activeVpsThreads,hostedWorkspace: HOSTED_WORKSPACE, hostedFullAccessRefusal: HOSTED_FULL_ACCESS_REFUSAL, desktopManaged: DESKTOP_MANAGED,@@ -12153,7 +12149,7 @@ ROUTES.push(createChannelRoutes({rejectDeletedThreadSkillStages,}));const taskRoutes = createTaskRoutes({- store, threadRead: teamMessages.seen,+ store, threadRead: teamMessages.seen, modelSwitched: noTerminal.modelSwitched,cloudHome: Boolean(CLOUD_HOME),desktopManaged: DESKTOP_MANAGED,hostedWorkspace: HOSTED_WORKSPACE,@@ -12871,7 +12867,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {? "This computer is already selected. Use its mounted tools.": "This computer is already selected. It starts on its first call; use its mounted tools." });}- if (!selectTurnPlace(internalCapability, option.surface)) return json(res, 409, { error: "A computer switch is already pending. End this turn to continue there." });+ if (!selectTurnPlace(internalCapability, option.surface, option.canCreate && !option.ready && !option.canStart)) return json(res, 409, { error: "A computer switch is already pending. End this turn to continue there." });return json(res, 200, { status: "pending", surface: option.surface,message: `End this turn now without using the previous computer tools. OpenMausBot will continue the original request on ${option.label} with a fresh tool connection.` });}diff --git a/server/no-terminal.e2e.test.ts b/server/no-terminal.e2e.test.tsnew file mode 100644index 0000000000..80f4291a05--- /dev/null+++ b/server/no-terminal.e2e.test.ts@@ -0,0 +1,239 @@+// A real server booted as a Cloud home, with a chat-only model (openai-compat, against an in-process stub that records+// what it is sent) beside Claude (the fake CLI, which dumps its turn). Case A as it happened: a bot moved to a chat-only+// model runs its routine, tries to run its script, and tells the person in its own words; the app says the real reason.+import { randomBytes } from "node:crypto";+import { spawn, type ChildProcess } from "node:child_process";+import { createServer, type Server } from "node:http";+import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { dirname, join } from "node:path";+import { fileURLToPath, pathToFileURL } from "node:url";+import { afterAll, beforeAll, expect, it } from "vitest";+import { cloudPairingSignature } from "./cloud-home.ts";+import { removeTempDir, waitForExit } from "./testing/cleanup.ts";+import { hostTimeout } from "./testing/host-timeout.ts";+import { freePortBlock } from "./testing/ports.ts";+import { isTitleCall } from "./testing/title-call.ts";++const SERVER_DIR = dirname(fileURLToPath(import.meta.url));+const HOST = "omb-t-0123456789ab.fly.dev";+const secret = randomBytes(32).toString("base64url");+const NO_TERMINAL = "You can't run commands this turn: on My Cloud this model (fixture-model) has no terminal of its own, and no cloud desktop is in use.";+const SELECT_CLOUD = "This turn has no terminal: on My Cloud this model (fixture-model) can't run commands itself. To run one, call select_computer with surface \"cloud\"";+const SENTENCE = "This run couldn't run commands: fixture-model has no terminal on My Cloud. To run them, this routine needs a model with a terminal, such as Claude or Codex, or to run on the cloud desktop.";+const BOT_SAID = "No execution environment was mounted, so sync.py did not run.";+let home = "", base = "", log = "", owner = "", claudeDump = "";+let child: ChildProcess;+let upstream: Server;+/** The tool the Case A run looked at after its refused command. */+let looked: string | undefined;++type ChatRequest = { messages: Array<{ role: string; content?: unknown }>; tools?: Array<{ function: { name: string } }> };+const requests: ChatRequest[] = [];+const frame = (delta: unknown, finish_reason: string | null) => `data: ${JSON.stringify({ choices: [{ index: 0, delta, finish_reason }] })}\n\n`;+const said = (request: ChatRequest, role: string) => request.messages.filter((message) => message.role === role).map((message) => (typeof message.content === "string" ? message.content : JSON.stringify(message.content))).join("\n");++async function api(method: string, path: string, options: { body?: unknown; token?: string } = {}) {+ const response = await fetch(`${base}${path}`, {+ method,+ headers: {+ host: HOST, "x-forwarded-for": "203.0.113.9", "x-forwarded-proto": "https", origin: `https://${HOST}`,+ ...(options.token ? { authorization: `Bearer ${options.token}` } : {}),+ ...(options.body === undefined ? {} : { "content-type": "application/json" }),+ },+ body: options.body === undefined ? undefined : JSON.stringify(options.body),+ });+ return { status: response.status, body: await response.json().catch(() => null) as any };+}++async function adminPairing(): Promise<string> {+ const body = JSON.stringify({ label: "OpenMausBot app (Cloud)", ttlSeconds: 300 });+ const timestamp = String(Math.floor(Date.now() / 1000)), nonce = randomBytes(16).toString("base64url");+ const response = await fetch(`${base}/api/cloud/pairing`, { method: "POST", headers: {+ host: HOST, "x-forwarded-for": "203.0.113.9", "x-forwarded-proto": "https", "content-type": "application/json",+ "x-omb-cloud-timestamp": timestamp, "x-omb-cloud-nonce": nonce, "x-omb-cloud-signature": `v1=${cloudPairingSignature(secret, timestamp, nonce, body)}`,+ }, body });+ const granted = await response.json() as { code: string };+ const paired = await api("POST", "/api/auth/pair", { body: { code: granted.code } });+ expect(paired.status, JSON.stringify(paired.body)).toBe(200);+ return paired.body.token;+}++beforeAll(async () => {+ home = mkdtempSync(join(tmpdir(), "omb-no-terminal-"));+ const dataDir = join(home, ".openmausbot");+ mkdirSync(dataDir, { recursive: true });+ claudeDump = join(home, "claude-turn.json");+ upstream = createServer(async (req, res) => {+ res.setHeader("content-type", "application/json");+ if (req.url?.endsWith("/models")) return res.end(JSON.stringify({ data: [{ id: "fixture-model" }] }));+ if (req.method === "GET") { res.statusCode = 404; return res.end(); }+ let raw = "";+ for await (const chunk of req) raw += chunk;+ const request = JSON.parse(raw || "{}") as ChatRequest;+ if (isTitleCall(request)) { res.statusCode = 500; return res.end(); }+ requests.push(request);+ res.writeHead(200, { "content-type": "text/event-stream" });+ // Case A: the routine's run reaches for a shell to run its script; refused, it looks at something else that works (as the+ // bot did, finding its project files), then explains in its own words. "Run lint.py" stops right after the refusal.+ const user = said(request, "user"), tools = request.messages.filter((message) => message.role === "tool").length;+ const script = user.includes("Run sync.py") || user.includes("Run lint.py");+ if (script && tools === 0) {+ const call = { index: 0, id: "exec-call", type: "function", function: { name: "exec", arguments: JSON.stringify({ command: "python3 sync.py" }) } };+ return res.end(frame({ tool_calls: [call] }, "tool_calls") + "data: [DONE]\n\n");+ }+ if (user.includes("Run sync.py") && tools === 1) {+ const names = (request.tools ?? []).map((tool) => tool.function.name), direct = names.find((name) => name.endsWith("list_bots")), bridge = names.find((name) => name.endsWith("use_tool"));+ looked = direct ?? bridge;+ const call = { index: 0, id: "look-call", type: "function", function: direct ? { name: direct, arguments: "{}" } : { name: bridge, arguments: JSON.stringify({ name: "list_bots", arguments: {} }) } };+ return res.end(frame({ tool_calls: [call] }, "tool_calls") + "data: [DONE]\n\n");+ }+ res.end(frame({ content: script ? BOT_SAID : "Filed three invoices." }, "stop") + "data: [DONE]\n\n");+ });+ await new Promise<void>((resolve) => upstream.listen(0, "127.0.0.1", resolve));+ const upstreamPort = (upstream.address() as { port: number }).port;+ writeFileSync(join(dataDir, "config.json"), JSON.stringify({+ openaiCompat: { key: "fixture-key", url: `http://127.0.0.1:${upstreamPort}/v1`, model: "fixture-model" },+ instances: { claude: { driver: "claudeAgent", displayName: "Claude", config: { cli: join(SERVER_DIR, "testing", "fake-claude-cli.ts") }, environment: { FAKE_CLAUDE_DUMP: claudeDump } } },+ }));+ writeFileSync(join(dataDir, "host-memory.json"), JSON.stringify({ totalBytes: 64 * 1024 ** 3, availableBytes: 60 * 1024 ** 3, swapFreeBytes: 0, oomKills: 0, fullStall10: 0 }));+ const port = await freePortBlock([0, 1]);+ base = `http://127.0.0.1:${port}`;+ const offlinePrelude = `data:text/javascript,${encodeURIComponent('const real = globalThis.fetch; globalThis.fetch = async (url, init) => String(url).startsWith("http://127.0.0.1:") ? real(url, init) : new Response("offline fixture", { status: 503 });')}`;+ const memoryGate = pathToFileURL(join(SERVER_DIR, "testing", "memory-gate-hooks.mjs")).href;+ child = spawn(process.execPath, ["--import", offlinePrelude, "--import", memoryGate, join(SERVER_DIR, "index.ts")], {+ cwd: join(SERVER_DIR, ".."),+ env: {+ PATH: process.env.PATH, ...(process.env.SystemRoot ? { SystemRoot: process.env.SystemRoot } : {}),+ HOME: dataDir, USERPROFILE: dataDir, OMB_DATA_DIR: dataDir, OMB_TEST_MEMORY_GATE: "1", OMB_PORT: String(port), OMB_WEBHOOK_PORT: String(port + 1),+ OMB_CLOUD_ROLE: "home", OMB_CLOUD_MACHINE_ID: "3f9c2a4e-8b1d-4c6e-9a7f-2d5e8c1b0a93", OMB_CLOUD_ADMIN_URL: "https://cloud.example.test",+ OMB_CLOUD_BOOTSTRAP_SECRET: secret, OMB_PUBLIC_URL: `https://${HOST}`,+ // A cloud desktop is set up (the Admin's relay; nothing here starts one), so the app may offer it.+ OMB_CLOUD_BOAT_URL: "http://127.0.0.1:9/relay/api/box/v1", OMB_CLOUD_BOAT_TOKEN: "fixture-included",+ },+ stdio: ["ignore", "pipe", "pipe"],+ });+ child.stdout?.on("data", (chunk) => { log += chunk; });+ child.stderr?.on("data", (chunk) => { log += chunk; });+ const deadline = Date.now() + 20_000;+ for (;;) {+ if (child.exitCode !== null) throw new Error(`the Cloud home exited:\n${log}`);+ try { if ((await fetch(`${base}/api/health`)).ok) break; } catch {}+ if (Date.now() > deadline) throw new Error(`the Cloud home did not start:\n${log}`);+ await new Promise((resolve) => setTimeout(resolve, 100));+ }+ owner = await adminPairing();+}, hostTimeout(40_000));++afterAll(async () => {+ if (child) await waitForExit(child, { signal: "SIGTERM" });+ if (upstream) await new Promise<void>((resolve) => upstream.close(() => resolve()));+ if (home) await removeTempDir(home);+});++const newBot = async (name: string, instanceId: string, model: string) => {+ const made = await api("POST", "/api/bots", { token: owner, body: { name, modelSelection: { instanceId, model } } });+ expect(made.status, JSON.stringify(made.body)).toBe(201);+ return made.body.bot as { id: string; threadId: string };+};+const chat = async (threadId: string) => (await api("GET", `/api/threads/${threadId}/messages`, { token: owner })).body.messages as Array<{ kind: string; text?: string; tool?: { name: string }; automation?: { routineId: string } }>;+const runs = async () => (await api("GET", "/api/routines", { token: owner })).body.runs as Array<{ id: string; routineId: string; status: string; error?: string }>;+const routineFor = async (botId: string, prompt: string) => {+ const made = await api("POST", "/api/routines", { token: owner, body: { name: prompt.slice(0, 20), prompt, botId, enabled: false, schedule: { type: "interval", everyMinutes: 60, anchorAt: Date.now() + 3_600_000 } } });+ expect(made.status, JSON.stringify(made.body)).toBe(201);+ return made.body.routine.id as string;+};+const runNow = async (routineId: string) => {+ expect((await api("POST", `/api/routines/${routineId}/run`, { token: owner })).status).toBe(201);+ let run: { status: string; error?: string } | undefined;+ await expect.poll(async () => (run = (await runs()).find((row) => row.routineId === routineId))?.status, { timeout: hostTimeout(20_000) }).toMatch(/^(completed|failed)$/u);+ return run!;+};++it("switching a bot with a routine from Claude to a chat-only model says once, in its chat, what its routine will no longer do", async () => {+ const bot = await newBot("Ledger", "claude", "claude-sonnet-5");+ await routineFor(bot.id, "Run sync.py from the project folder.");+ const notices = async () => (await chat(bot.threadId)).filter((line) => line.tool?.name.startsWith("notice: "));+ const moved = await api("PATCH", `/api/bots/${bot.id}`, { token: owner, body: { modelSelection: { instanceId: "openaiCompat", model: "fixture-model" } } });+ expect(moved.status, JSON.stringify(moved.body)).toBe(200);+ expect((await notices()).map((line) => line.tool!.name)).toEqual(["notice: fixture-model can't run commands on My Cloud by itself. Ledger has a routine; it will only be able to do work that needs no commands."]);+ // Back to Claude, which has a terminal: nothing more.+ expect((await api("PATCH", `/api/bots/${bot.id}`, { token: owner, body: { modelSelection: { instanceId: "claude", model: "claude-sonnet-5" } } })).status).toBe(200);+ expect(await notices()).toHaveLength(1);+ // Must-fix 2: a bot that works on the cloud desktop keeps exec there, so its switch says nothing.+ const desk = await newBot("Desk", "claude", "claude-sonnet-5");+ await routineFor(desk.id, "Run sync.py from the project folder.");+ const onDesk = await api("PATCH", `/api/bots/${desk.id}`, { token: owner, body: { computer: "cloud" } });+ expect(onDesk.status, JSON.stringify(onDesk.body)).toBe(200);+ expect((await api("PATCH", `/api/bots/${desk.id}`, { token: owner, body: { modelSelection: { instanceId: "openaiCompat", model: "fixture-model" } } })).status).toBe(200);+ expect((await chat(desk.threadId)).filter((line) => line.tool?.name.startsWith("notice: "))).toEqual([]);+ // A bot with nothing to run moving between chat-only models: nothing either.+ const plain = await newBot("Notes", "openaiCompat", "fixture-model");+ expect((await api("PATCH", `/api/bots/${plain.id}`, { token: owner, body: { modelSelection: { instanceId: "openaiCompat", model: "other-model" } } })).status).toBe(200);+ expect((await chat(plain.threadId)).filter((line) => line.tool?.name.startsWith("notice: "))).toEqual([]);+}, hostTimeout(60_000));++it("Case A: the chat-only bot's routine is told it can't run commands, tries, and its line in the chat ends with the app's own reason; the run stays completed", async () => {+ const bot = await newBot("Syncer", "openaiCompat", "fixture-model");+ const sync = await routineFor(bot.id, "Run sync.py from the project folder.");+ requests.length = 0;+ const synced = await runNow(sync);+ expect(synced.status, `no terminal alone never fails a run: ${synced.error}\n${JSON.stringify(await chat(bot.threadId))}`).toBe("completed");+ const system = said(requests[0]!, "system");+ expect(system).toContain(NO_TERMINAL);+ expect(system).toContain("Do the parts that need no command and say which step was not done, without giving a reason for it.");+ expect(system, "a run may not move, so it is never told to").not.toContain("select_computer with surface");+ let line: string | undefined;+ await expect.poll(async () => (line = (await chat(bot.threadId)).find((message) => message.automation?.routineId === sync)?.text), { timeout: hostTimeout(15_000) }).toBeTruthy();+ // The run went on after the refusal with a call that worked, as the bot did, so it ended completed.+ expect(looked).toBeTruthy();+ const answers = requests.flatMap((request) => request.messages.filter((message) => message.role === "tool").map((message) => String(message.content)));+ expect(answers.some((answer) => answer.includes("not advertised for this turn")), JSON.stringify(answers)).toBe(true);+ expect(answers.some((answer) => answer.startsWith("{\"ok\":true")), JSON.stringify(answers)).toBe(true);+ expect(line).toBe(`${BOT_SAID}\n\n${SENTENCE}`);+ // Should-fix 4: the same routine on the same model says it once; its next run's line is the bot's alone.+ expect((await runNow(sync)).status).toBe("completed");+ await expect.poll(async () => (await chat(bot.threadId)).filter((message) => message.automation?.routineId === sync).map((message) => message.text), { timeout: hostTimeout(15_000) })+ .toEqual([`${BOT_SAID}\n\n${SENTENCE}`, BOT_SAID]);++ // Should-fix 3: a run that stops on the refused call fails as before (the bot's reply is no proof), and the line saying+ // so carries the real reason too.+ const lint = await routineFor(bot.id, "Run lint.py from the project folder.");+ expect((await runNow(lint)).status).toBe("failed");+ await expect.poll(async () => (await chat(bot.threadId)).find((message) => message.automation?.routineId === lint)?.text, { timeout: hostTimeout(15_000) })+ .toBe(`This run was partly done: Stopped because the tool call “exec” failed. The bot's reply isn't proof the work was done; the failed step shows the error.\n\n${SENTENCE}`);++ // A routine that needs no command, on the same bot: the bot's words alone.+ const invoices = await routineFor(bot.id, "File the new invoices.");+ expect((await runNow(invoices)).status).toBe("completed");+ await expect.poll(async () => (await chat(bot.threadId)).find((message) => message.automation?.routineId === invoices)?.text, { timeout: hostTimeout(15_000) }).toBe("Filed three invoices.");+}, hostTimeout(90_000));++it("must-fix 1: the person's own chat, which may move, is told to select the cloud desktop; with Computer access Off it is not offered", async () => {+ const bot = await newBot("Chatter", "openaiCompat", "fixture-model");+ const ask = async (text: string) => {+ requests.length = 0;+ expect((await api("POST", `/api/bots/${bot.id}/messages`, { token: owner, body: { text, threadId: bot.threadId } })).status).toBe(202);+ await expect.poll(() => requests.some((request) => said(request, "user").includes(text)), { timeout: hostTimeout(20_000) }).toBe(true);+ await expect.poll(async () => (await api("GET", "/api/bots", { token: owner })).body.bots.find((one: { id: string }) => one.id === bot.id)?.busy, { timeout: hostTimeout(20_000) }).toBe(false);+ return said(requests.find((request) => said(request, "user").includes(text))!, "system");+ };+ const open = await ask("Run the build.");+ expect(open).toContain(SELECT_CLOUD);+ expect(open).not.toContain("don't try another way");+ expect((await api("PATCH", `/api/bots/${bot.id}`, { token: owner, body: { computer: "off" } })).status).toBe(200);+ const off = await ask("Run the tests.");+ expect(off).toContain(NO_TERMINAL);+ expect(off).not.toContain("select_computer with surface \"cloud\"");+ expect(off).not.toContain("or the cloud desktop");+}, hostTimeout(60_000));++it("a bot on Claude, which runs commands itself, is told nothing of the kind", async () => {+ const bot = await newBot("Builder", "claude", "claude-sonnet-5");+ expect((await api("POST", `/api/bots/${bot.id}/messages`, { token: owner, body: { text: "Run the build.", threadId: bot.threadId } })).status).toBe(202);+ let dump: { systemPrompt?: string } | undefined;+ await expect.poll(() => { try { dump = JSON.parse(readFileSync(claudeDump, "utf8")); return typeof dump?.systemPrompt === "string"; } catch { return false; } }, { timeout: hostTimeout(20_000) }).toBe(true);+ expect(dump!.systemPrompt).toContain("My Cloud");+ expect(dump!.systemPrompt).not.toContain("You can't run commands this turn");+ expect(dump!.systemPrompt).not.toContain("This turn has no terminal");+}, hostTimeout(60_000));diff --git a/server/routes/bot-patch.ts b/server/routes/bot-patch.tsindex d46c787ba1..81601fac6b 100644--- a/server/routes/bot-patch.ts+++ b/server/routes/bot-patch.ts@@ -90,6 +90,8 @@ export interface BotPatchRouteDeps {chiefChanged?(changed: readonly BotRecord[]): void;/** The bots of the turns now running, each with the grants its turn reads. */turnBots?: { values(): Iterable<BotRecord> };+ /** A bot's model changed, from `before` to `after`, seen in `threadId` (host/no-terminal.ts says there what it takes away). */+ modelSwitched?(botId: string, threadId: string, before: ModelSelection, after: ModelSelection, routinesFollow: boolean): void;}export function createBotPatchRoutes(deps: BotPatchRouteDeps): RouteHandler {@@ -713,6 +715,7 @@ export function createBotPatchRoutes(deps: BotPatchRouteDeps): RouteHandler {if (computerSpecified && requestedComputer !== undefined) store.clearAutoSurfacePins(m[1], requestedComputer);if (normalizedSelection && movedTask) store.patchTask(bot.id, movedTask.threadId, { modelSelection: undefined,...hostedModels?.resetTask(movedTask.modelSelection, normalizedSelection) });+ if (normalizedSelection && existingBot) deps.modelSwitched?.(bot.id, movedTask?.threadId ?? existingBot.threadId, movedTask?.modelSelection ?? existingBot.modelSelection, normalizedSelection, true);if (existingBot) {settleBrowserChange(bot, { browserProfile: beforeBrowserProfile, browser: beforeBrowserEnabled }, { closeForBot: (id) => browserLive.closeForBot(id), forgetTemporaryBrowser });}diff --git a/server/routes/bot-settings.ts b/server/routes/bot-settings.tsindex 8daf5beec3..611680b2f9 100644--- a/server/routes/bot-settings.ts+++ b/server/routes/bot-settings.ts@@ -55,6 +55,8 @@ export interface BotSettingsRouteDeps {/** A Team Cloud: marks a bot's shared conversation read or unread for this person alone (host/room-reads.ts); false* for a private chat, which keeps its one mark. */personMarkThread?(auth: RequestAuth, threadId: string, unread: boolean): boolean;+ /** A bot's model changed (host/no-terminal.ts). */+ modelSwitched?(botId: string, threadId: string, before: ModelSelection, after: ModelSelection, routinesFollow: boolean): void;}export function createBotSettingsRoutes(deps: BotSettingsRouteDeps): RouteHandler {@@ -162,6 +164,7 @@ export function createBotSettingsRoutes(deps: BotSettingsRouteDeps): RouteHandleif (!bot) return json(res, 404, { error: "no such bot" });store.patchTask(bot.id, selected.threadId, { modelSelection: undefined,...hostedModels?.resetTask(selected.modelSelection, checked.selection) });+ deps.modelSwitched?.(bot.id, selected.threadId, selected.modelSelection, checked.selection, true);return json(res, 200, { bot: wireBot(bot) });}m = path.match(/^\/api\/bots\/([\w-]+)\/read$/);diff --git a/server/routes/tasks.ts b/server/routes/tasks.tsindex c8a686e82a..b21b2a27be 100644--- a/server/routes/tasks.ts+++ b/server/routes/tasks.ts@@ -74,6 +74,8 @@ export interface TaskRouteDeps {rejectDeletedThreadSkillStages(cleanups: Array<{ botId: string; stagedId: string }>): void;/** A person opened this conversation (a Team Cloud's Needs you lines for them there are done). */threadRead?(auth: RequestAuth, threadId: string): void;+ /** A conversation's model changed (host/no-terminal.ts); `routinesFollow`: the bot's own model changed with it. */+ modelSwitched?(botId: string, threadId: string, before: ModelSelection, after: ModelSelection, routinesFollow: boolean): void;}/** `deleteTasks`: the same deletion for the server's own use (a person leaving a Team Cloud, host/team-member-left.ts). */@@ -407,6 +409,7 @@ export function createTaskRoutes(deps: TaskRouteDeps): RouteHandler & { deleteTa? store.switchTaskModel(m[1], m[2], patch.modelSelection, body.updateBotDefault === true, body.resetApprovalToAsk === true,{ ...patch, ...hostedModels?.resetTask(current.modelSelection, patch.modelSelection) })!: store.patchTask(m[1], m[2], patch)!;+ if (patch.modelSelection) deps.modelSwitched?.(m[1], m[2], current.modelSelection, patch.modelSelection, body.updateBotDefault === true);return json(res, 200, { task: wireTask(task, store.bot(m[1])!.modelSelection), bot: publicBot(store.bot(m[1])!) } satisfies TaskResponse);}if (m && method === "DELETE") {diff --git a/src/locales/de.json b/src/locales/de.jsonindex 208ce72436..a0a6f4a900 100644--- a/src/locales/de.json+++ b/src/locales/de.json@@ -4022,6 +4022,17 @@"server.rooms.linkedFailed": "{bot} konnte von {place} aus nicht antworten.","server.rooms.linkedMissing": "{bot} gibt es auf {place} nicht mehr und kann hier deshalb nicht antworten. Entferne diesen Bot aus den Mitgliedern dieses Raums.","server.rooms.linkedEnded": "{place} hat sich 30 Tage lang nicht verbunden, deshalb wurde die Verbindung dorthin beendet. Nicht mehr in diesem Raum: {bots}.",+ "server.reach.runNoTerminal": "Diese Ausführung konnte keine Befehle ausführen: {model} hat auf My Cloud kein Terminal. Dafür braucht diese Routine ein Modell mit Terminal, etwa Claude oder Codex.",+ "server.reach.runNoTerminalCloud": "Diese Ausführung konnte keine Befehle ausführen: {model} hat auf My Cloud kein Terminal. Dafür braucht diese Routine ein Modell mit Terminal, etwa Claude oder Codex, oder muss auf dem Cloud-Desktop laufen.",+ "server.reach.modelNoTerminal": "{model} kann auf My Cloud allein keine Befehle ausführen, daher kann {bot} hier keine Skripte oder Programme mehr ausführen.",+ "server.reach.modelNoTerminalChat": "In diesem Chat kann {model} auf My Cloud allein keine Befehle ausführen, daher laufen hier keine Skripte oder Programme.",+ "server.reach.modelNoTerminalRoutine": "{model} kann auf My Cloud allein keine Befehle ausführen. {bot} hat eine Routine; sie kann nur noch Arbeit erledigen, die keine Befehle braucht.",+ "server.reach.modelNoTerminalRoutines": "{model} kann auf My Cloud allein keine Befehle ausführen. {bot} hat {count} Routinen; sie können nur noch Arbeit erledigen, die keine Befehle braucht.",+ "server.reach.placeMoved": "{bot} arbeitet jetzt auf {to}, einer anderen Maschine als {from}. Seine Dateien auf {from} sind noch da; nichts ging verloren.",+ "server.reach.placeMovedNew": "{bot} arbeitet jetzt auf {to}, einem neuen, der leer beginnt. Seine Dateien auf {from} sind noch da; nichts ging verloren.",+ "server.reach.place.myCloud": "My Cloud",+ "server.reach.place.thisCloud": "dieser Cloud",+ "server.reach.place.cloudDesktop": "dem Cloud-Desktop","announcements.title": "Ankündigungen","announcements.new": "Neue Ankündigungen","room.members.far.place": "auf {place}",diff --git a/src/locales/en.json b/src/locales/en.jsonindex e18b46d990..5b4144f95f 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -10664,6 +10664,17 @@"server.meetings.end.speech_unavailable": "I couldn't get speech-to-text for this meeting, so I didn't join.","server.meetings.card.settingUp": "Setting up transcription (one-time, about a minute)…","server.meetings.card.speechStopped": "Transcription stopped: {problem}",+ "server.reach.runNoTerminal": "This run couldn't run commands: {model} has no terminal on My Cloud. To run them, this routine needs a model with a terminal, such as Claude or Codex.",+ "server.reach.runNoTerminalCloud": "This run couldn't run commands: {model} has no terminal on My Cloud. To run them, this routine needs a model with a terminal, such as Claude or Codex, or to run on the cloud desktop.",+ "server.reach.modelNoTerminal": "{model} can't run commands on My Cloud by itself, so {bot} can't run scripts or programs here anymore.",+ "server.reach.modelNoTerminalChat": "In this chat, {model} can't run commands on My Cloud by itself, so scripts and programs can't run here.",+ "server.reach.modelNoTerminalRoutine": "{model} can't run commands on My Cloud by itself. {bot} has a routine; it will only be able to do work that needs no commands.",+ "server.reach.modelNoTerminalRoutines": "{model} can't run commands on My Cloud by itself. {bot} has {count} routines; they will only be able to do work that needs no commands.",+ "server.reach.placeMoved": "{bot} now works on {to}, a different machine from {from}. Its files on {from} are still there; nothing was lost.",+ "server.reach.placeMovedNew": "{bot} now works on {to}, a new one that starts empty. Its files on {from} are still there; nothing was lost.",+ "server.reach.place.myCloud": "My Cloud",+ "server.reach.place.thisCloud": "this Cloud",+ "server.reach.place.cloudDesktop": "the cloud desktop","settings.section.phoneDevices": "Phone & devices","devices.pair": "Pair a device","devices.paired": "Paired",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex 4d7274656b..6f8cfee6ce 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -11095,6 +11095,17 @@"server.rooms.linkedFailed": "{bot} não conseguiu responder a partir de {place}.","server.rooms.linkedMissing": "{bot} não está mais em {place}, então não pode responder aqui. Remova-o dos membros deste grupo.","server.rooms.linkedEnded": "{place} não se conecta há 30 dias, então a ligação com ele terminou. Não está mais neste grupo: {bots}.",+ "server.reach.runNoTerminal": "Esta execução não conseguiu executar comandos: {model} não tem terminal no My Cloud. Para executá-los, esta rotina precisa de um modelo com terminal, como Claude ou Codex.",+ "server.reach.runNoTerminalCloud": "Esta execução não conseguiu executar comandos: {model} não tem terminal no My Cloud. Para executá-los, esta rotina precisa de um modelo com terminal, como Claude ou Codex, ou rodar no desktop na nuvem.",+ "server.reach.modelNoTerminal": "{model} não consegue executar comandos no My Cloud sozinho, então {bot} não pode mais executar scripts ou programas aqui.",+ "server.reach.modelNoTerminalChat": "Neste chat, {model} não consegue executar comandos no My Cloud sozinho, então scripts e programas não podem rodar aqui.",+ "server.reach.modelNoTerminalRoutine": "{model} não consegue executar comandos no My Cloud sozinho. {bot} tem uma rotina; ela só poderá fazer o trabalho que não precisa de comandos.",+ "server.reach.modelNoTerminalRoutines": "{model} não consegue executar comandos no My Cloud sozinho. {bot} tem {count} rotinas; elas só poderão fazer o trabalho que não precisa de comandos.",+ "server.reach.placeMoved": "{bot} agora trabalha em outra máquina: {to} (antes: {from}). Nada foi perdido: os arquivos dele continuam no lugar anterior, {from}.",+ "server.reach.placeMovedNew": "{bot} agora trabalha em outra máquina: {to}, nova e vazia. Nada foi perdido: os arquivos dele continuam no lugar anterior, {from}.",+ "server.reach.place.myCloud": "My Cloud",+ "server.reach.place.thisCloud": "este Cloud",+ "server.reach.place.cloudDesktop": "o desktop na nuvem","room.members.far.place": "em {place}","room.members.far.off": "Ligação desligada","room.members.far.missing": "Não está mais disponível",diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.jsonindex 90e4afc789..9b54b67fa7 100644--- a/src/locales/zh-tw.json+++ b/src/locales/zh-tw.json@@ -10116,6 +10116,17 @@"server.burst.cancelled": "平行處理已取消。","server.burst.partFailed": "未完成({reason})","server.burst.partsHeader": "這次平行處理的各部分結果(依完成順序):{task}",+ "server.reach.runNoTerminal": "這次執行無法執行指令:{model} 在 My Cloud 上沒有終端機。要執行指令,這個例行工作需要有終端機的模型,例如 Claude 或 Codex。",+ "server.reach.runNoTerminalCloud": "這次執行無法執行指令:{model} 在 My Cloud 上沒有終端機。要執行指令,這個例行工作需要有終端機的模型,例如 Claude 或 Codex,或在雲端桌面上執行。",+ "server.reach.modelNoTerminal": "{model} 無法單獨在 My Cloud 上執行指令,所以 {bot} 無法再在這裡執行指令碼或程式。",+ "server.reach.modelNoTerminalChat": "在這個聊天中,{model} 無法單獨在 My Cloud 上執行指令,所以這裡無法執行指令碼或程式。",+ "server.reach.modelNoTerminalRoutine": "{model} 無法單獨在 My Cloud 上執行指令。{bot} 有一個例行工作;它只能完成不需要指令的工作。",+ "server.reach.modelNoTerminalRoutines": "{model} 無法單獨在 My Cloud 上執行指令。{bot} 有 {count} 個例行工作;它們只能完成不需要指令的工作。",+ "server.reach.placeMoved": "{bot} 現在在{to}上工作,這是與{from}不同的機器。它在{from}上的檔案仍然在那裡,沒有遺失任何東西。",+ "server.reach.placeMovedNew": "{bot} 現在在{to}上工作,這是一台新的、從空白開始的機器。它在{from}上的檔案仍然在那裡,沒有遺失任何東西。",+ "server.reach.place.myCloud": "My Cloud",+ "server.reach.place.thisCloud": "這個 Cloud",+ "server.reach.place.cloudDesktop": "雲端桌面","announcements.title": "公告","announcements.new": "新公告","composer.command.burstDesc": "同時執行一項工作的多個部分,再彙整結果",diff --git a/src/locales/zh.json b/src/locales/zh.jsonindex aad28da700..e32eadbceb 100644--- a/src/locales/zh.json+++ b/src/locales/zh.json@@ -10057,6 +10057,17 @@"server.rooms.linkedFailed": "{bot} 无法从 {place} 回复。","server.rooms.linkedMissing": "{bot} 已不在 {place} 上,所以无法在这里回复。请把它从这个群组聊天的成员中移除。","server.rooms.linkedEnded": "{place} 已有 30 天没有连接,与它的连接已结束。已不在这个群组聊天中:{bots}。",+ "server.reach.runNoTerminal": "这次执行无法运行命令:{model} 在 My Cloud 上没有终端。要运行命令,这个例行任务需要有终端的模型,例如 Claude 或 Codex。",+ "server.reach.runNoTerminalCloud": "这次执行无法运行命令:{model} 在 My Cloud 上没有终端。要运行命令,这个例行任务需要有终端的模型,例如 Claude 或 Codex,或者在云端桌面上运行。",+ "server.reach.modelNoTerminal": "{model} 无法单独在 My Cloud 上运行命令,所以 {bot} 无法再在这里运行脚本或程序。",+ "server.reach.modelNoTerminalChat": "在这个聊天中,{model} 无法单独在 My Cloud 上运行命令,所以这里无法运行脚本或程序。",+ "server.reach.modelNoTerminalRoutine": "{model} 无法单独在 My Cloud 上运行命令。{bot} 有一个例行任务;它只能完成不需要命令的工作。",+ "server.reach.modelNoTerminalRoutines": "{model} 无法单独在 My Cloud 上运行命令。{bot} 有 {count} 个例行任务;它们只能完成不需要命令的工作。",+ "server.reach.placeMoved": "{bot} 现在在{to}上工作,这是与{from}不同的机器。它在{from}上的文件仍然在那里,没有丢失任何东西。",+ "server.reach.placeMovedNew": "{bot} 现在在{to}上工作,这是一台新的、从空白开始的机器。它在{from}上的文件仍然在那里,没有丢失任何东西。",+ "server.reach.place.myCloud": "My Cloud",+ "server.reach.place.thisCloud": "这个 Cloud",+ "server.reach.place.cloudDesktop": "云端桌面","announcements.title": "公告","announcements.new": "新公告","room.members.far.place": "位于 {place}",