Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
feat: let a bot ask the person to reset its stuck cloud computer
AdityaUmale0b39d3969bdc
diff --git a/server/drivers/agents-call.test.ts b/server/drivers/agents-call.test.tsindex 8f575656a8..011d199631 100644--- a/server/drivers/agents-call.test.ts+++ b/server/drivers/agents-call.test.ts@@ -579,3 +579,31 @@ describe("blank optional arguments", () => {]);});});++describe("reset_cloud_computer", () => {+ it("posts the why, and for a Chief the bot it names, and returns the route's text or refusal", async () => {+ const calls: Array<{ path: string; method?: string; body: unknown }> = [];+ const reply = (ok: boolean) => context({+ client: {+ api: async () => ({}),+ apiResponse: async (path, init) => {+ calls.push({ path, method: init?.method, body: JSON.parse(String(init?.body)) });+ return ok ? { ok: true, status: 200, body: { text: "A card is now in this conversation." } } : { ok: false, status: 403, body: { error: "not yours" } };+ },+ },+ });+ expect(await callTool("reset_cloud_computer", { why: "Stuck starting." }, reply(true))).toEqual({ text: "A card is now in this conversation." });+ expect(await callTool("reset_cloud_computer", { why: "Stuck.", for_bot_id: " bot-b " }, reply(false))).toEqual({ text: "not yours", isError: true });+ expect(calls).toEqual([+ { path: "/api/internal/cloud-computer/reset", method: "POST", body: { why: "Stuck starting." } },+ { path: "/api/internal/cloud-computer/reset", method: "POST", body: { why: "Stuck.", targetBotId: "bot-b" } },+ ]);+ });++ it("is mounted only where a cloud computer can be had, and names another bot only for a Chief", () => {+ const tool = (env: Record<string, string>) => availableTools(catalogProfileFromEnv(env)).find((entry) => entry.name === "reset_cloud_computer");+ expect(tool({})).toBeUndefined();+ expect(Object.keys(tool({ OMB_MEETINGS: "1" })?.inputSchema.properties ?? {})).toEqual(["why"]);+ expect(Object.keys(tool({ OMB_MEETINGS: "1", OMB_CHIEF_OF_STAFF: "1" })?.inputSchema.properties ?? {})).toEqual(["why", "for_bot_id"]);+ });+});diff --git a/server/drivers/agents-call.ts b/server/drivers/agents-call.tsindex 683fe5e17a..ca948db6ba 100644--- a/server/drivers/agents-call.ts+++ b/server/drivers/agents-call.ts@@ -412,6 +412,14 @@ export async function callTool(called: string, input: Json, context: ToolCallCon});return { text: JSON.stringify(result) };}+ if (name === "reset_cloud_computer") {+ const forBotId = String(args.for_bot_id ?? "").trim();+ const r = await apiResponse("/api/internal/cloud-computer/reset", {+ method: "POST", body: JSON.stringify({ why: args.why, ...(forBotId ? { targetBotId: forBotId } : {}) }),+ });+ if (!r.ok) return { text: String(r.body.error ?? `reset_cloud_computer failed (HTTP ${r.status}).`), isError: true };+ return { text: String(r.body.text ?? "") };+ }if (name === "list_threads") {const query = new URLSearchParams({ fromBotId: BOT_ID, fromThreadId: THREAD_ID });const r = await api(`/api/internal/threads?${query.toString()}`);diff --git a/server/drivers/agents-catalog-profile.ts b/server/drivers/agents-catalog-profile.tsindex 6c4065120e..d997d5dd05 100644--- a/server/drivers/agents-catalog-profile.ts+++ b/server/drivers/agents-catalog-profile.ts@@ -28,7 +28,7 @@ export interface CatalogProfile {/** A room's thread: the wait tools are not mounted, since a room holds no wait. */room?: boolean;imageGeneration?: boolean;- /** A cloud computer can be had here (Boat): the meeting tools are mounted. */+ /** A cloud computer can be had here (Boat): the meeting tools and reset_cloud_computer are mounted. */meetings?: boolean;/** The plan's included app hosting reaches this server: publish_app is mounted. */appHosting?: boolean;diff --git a/server/drivers/agents-catalog.ts b/server/drivers/agents-catalog.tsindex c030009ce0..84af5fb2bb 100644--- a/server/drivers/agents-catalog.ts+++ b/server/drivers/agents-catalog.ts@@ -270,6 +270,20 @@ const TOOL_DEFINITIONS = [description: "auto = suitable configured computer, cloud = the bot's cloud computer or self-hosted VPS, vm = isolated Local VM, local = user's own desktop, browser = built-in browser. Omit to list." },} },},+ {+ name: "reset_cloud_computer",+ description:+ "Ask the person to reset your cloud computer when it is stuck (starting for a long time, or not responding): a card asks them to Allow, and on Allow it is deleted, with everything saved on it, once you are not working; your next turn makes a fresh one. Use it only for a stuck computer, never to tidy up. After calling it, end your turn: you are not resumed, and the card shows how it went." + CHIEF_PROFILE_TARGET,+ inputSchema: {+ type: "object",+ additionalProperties: false,+ properties: {+ why: { type: "string", description: "One sentence for the card: what is wrong with the computer." },+ for_bot_id: { type: "string", description: "Chief of Staff only: the bot whose cloud computer to reset, from list_bots." },+ },+ required: ["why"],+ },+ },{name: "list_threads",description:@@ -907,7 +921,7 @@ const VOICE_TOOL_NAMES = new Set(["send_voice_note"]);const CHIEF_ONLY_TOOL_NAMES = new Set(["create_bot", "list_team_setup", "list_team_library", "propose_team_setup", "propose_bot_deletion", "manage_room", "retry_thread",]);-const CHIEF_TARGET_TOOL_NAMES = new Set(["propose_profile", "propose_model"]);+const CHIEF_TARGET_TOOL_NAMES = new Set(["propose_profile", "propose_model", "reset_cloud_computer"]);const WATCHER_TOOL_NAMES = new Set(["create_options_card"]);const LOCAL_VM_TOOL_NAMES = new Set(["vm_exec"]);@@ -942,7 +956,7 @@ function catalogTools(profile: CatalogProfile) {(profile.computerSelection === true || tool.name !== "select_computer") &&(profile.room !== true || !ROOM_REFUSED_TOOL_NAMES.has(tool.name)) &&(profile.imageGeneration === true || !IMAGE_TOOL_NAMES.has(tool.name)) && (profile.appHosting === true || !HOSTING_TOOL_NAMES.has(tool.name)) &&- (profile.meetings === true || !MEETING_TOOL_NAMES.has(tool.name)));+ (profile.meetings === true || (!MEETING_TOOL_NAMES.has(tool.name) && tool.name !== "reset_cloud_computer")));const AUTHORING_TOOLS = profile.skillAuthoring? BOT_SCOPED_TOOLS: BOT_SCOPED_TOOLS.filter((tool) => !SKILL_TOOL_NAMES.has(tool.name));diff --git a/server/host/cloud-computer-reset-asks.test.ts b/server/host/cloud-computer-reset-asks.test.tsnew file mode 100644index 0000000000..ea6278ace0--- /dev/null+++ b/server/host/cloud-computer-reset-asks.test.ts@@ -0,0 +1,158 @@+import { describe, expect, it, vi } from "vitest";++import { createCloudComputerResetAsks, RESET_CLOUD_COMPUTER_TOOL, RESET_RETRIES, RESET_RETRY_MS } from "./cloud-computer-reset-asks.ts";+import type { BotRecord } from "../store.ts";++type Line = { id: string; role: string; kind: string; card?: Record<string, any>; from?: unknown };++const bot = (id: string, name: string) => ({ id, name, color: "blue" }) as unknown as BotRecord;+const ada = bot("bot-a", "Ada"), chief = bot("chief", "Chief"), bea = bot("bot-b", "Bea");++function setup(options: { refusal?: (from: BotRecord, target: BotRecord) => string | null; reset?: () => Promise<any> } = {}) {+ const lines = new Map<string, Line[]>();+ const store = {+ bot: (id: string) => [ada, chief, bea].find((candidate) => candidate.id === id),+ groupByThread: () => undefined,+ messagesFor: (threadId: string) => lines.get(threadId) ?? [],+ appendMessage: (threadId: string, message: Omit<Line, "id">) => {+ const line = { ...message, id: `m${(lines.get(threadId)?.length ?? 0) + 1}` };+ lines.set(threadId, [...(lines.get(threadId) ?? []), line]);+ return line;+ },+ patchMessage: (threadId: string, id: string, patch: Partial<Line>) => {+ const line = lines.get(threadId)?.find((candidate) => candidate.id === id);+ if (line) Object.assign(line, patch);+ return Boolean(line);+ },+ };+ const timers: Array<() => void> = [];+ const reset = vi.fn(options.reset ?? (async () => ({ ok: true })));+ const asks = createCloudComputerResetAsks({+ store: store as never,+ refusal: options.refusal ?? (() => null),+ reset,+ setTimer: (run, ms) => { expect(ms).toBe(RESET_RETRY_MS); timers.push(run); },+ openCards: () => [...lines.entries()].flatMap(([threadId, list]) => list.filter((line) => line.card?.tool === RESET_CLOUD_COMPUTER_TOOL).map((line) => ({ threadId, messageId: line.id }))),+ });+ const call = async (sender: BotRecord, body: Record<string, unknown>) => {+ const res = { status: 0, body: {} as Record<string, any> };+ await asks.internal({+ method: "POST", path: "/api/internal/cloud-computer/reset", res: {} as never, sender, threadId: "t1", readBody: async () => body,+ json: ((_res: unknown, status: number, sent: Record<string, unknown>) => { res.status = status; res.body = sent; }) as never,+ });+ return res;+ };+ const card = () => lines.get("t1")?.at(-1)?.card;+ const flush = () => new Promise((resolve) => setTimeout(resolve, 0));+ return { asks, call, card, reset, timers, flush, lines };+}++describe("a bot asking for its cloud computer to be reset", () => {+ it("shows the person a card and tells the bot to end its turn, resetting nothing yet", async () => {+ const { call, card, reset } = setup();+ const res = await call(ada, { why: "It has been starting for 20 minutes." });+ expect(res.status).toBe(200);+ expect(res.body.text).toContain("End this turn");+ expect(card()).toMatchObject({ title: "Reset Ada's cloud desktop?", options: ["Allow", "Deny"], requestType: "permission", tool: RESET_CLOUD_COMPUTER_TOOL });+ expect(card()?.subtitle).toContain("It has been starting for 20 minutes.");+ expect(card()?.subtitle).toContain("files and browser sign-ins");+ expect(reset).not.toHaveBeenCalled();+ });++ it("does nothing on Deny", async () => {+ const { asks, call, card, reset, flush } = setup();+ await call(ada, {});+ expect(asks.answer(card()!.requestId, "deny")).toBe(true);+ await flush();+ expect(reset).not.toHaveBeenCalled();+ expect(card()?.answered).toBe("deny");+ });++ it("resets on Allow and says so on the card", async () => {+ const { asks, call, card, reset, flush } = setup();+ await call(ada, {});+ expect(asks.answer(card()!.requestId, "allow")).toBe(true);+ await flush();+ expect(reset).toHaveBeenCalledWith("bot-a");+ expect(card()).toMatchObject({ answered: "allow" });+ expect(card()?.subtitle).toContain("Reset: a fresh cloud desktop starts with Ada's next message.");+ });++ it("waits for the asking turn to end: a computer in use is retried, then reset", async () => {+ let busy = true;+ const { asks, call, card, reset, timers, flush } = setup({+ reset: async () => {+ if (busy) throw Object.assign(new Error("this cloud computer is in use — stop its bot's work first"), { status: 409 });+ return { ok: true };+ },+ });+ await call(ada, {});+ asks.answer(card()!.requestId, "allow");+ await flush();+ expect(card()?.subtitle).toContain("Waiting for Ada to finish its work");+ expect(timers).toHaveLength(1);+ busy = false;+ timers.shift()!();+ await flush();+ expect(reset).toHaveBeenCalledTimes(2);+ expect(card()?.subtitle).toContain("Reset: a fresh cloud desktop");+ });++ it("gives up on a computer that stays in use, and resets nothing", async () => {+ const { asks, call, card, timers, flush } = setup({+ reset: async () => { throw Object.assign(new Error("this cloud computer is in use — stop its bot's work first"), { status: 409 }); },+ });+ await call(ada, {});+ asks.answer(card()!.requestId, "allow");+ await flush();+ for (let i = 0; i < RESET_RETRIES; i += 1) { timers.shift()!(); await flush(); }+ expect(timers).toHaveLength(0);+ expect(card()?.subtitle).toContain("Not reset: this cloud computer is in use");+ });++ it("reports any other failure without retrying", async () => {+ const { asks, call, card, timers, flush } = setup({ reset: async () => { throw Object.assign(new Error("Could not reach boat.dev"), { status: 503 }); } });+ await call(ada, {});+ asks.answer(card()!.requestId, "allow");+ await flush();+ expect(timers).toHaveLength(0);+ expect(card()?.subtitle).toContain("Not reset: Could not reach boat.dev");+ });++ it("lets a Chief ask for a bot it manages and refuses what the rule refuses", async () => {+ const refusal = (from: BotRecord, target: BotRecord) => from.id === target.id || (from.id === "chief" && target.id === "bot-a") ? null : "not yours";+ const { asks, call, card, reset, flush } = setup({ refusal });+ expect(await call(ada, { targetBotId: "bot-b" })).toMatchObject({ status: 403, body: { error: "not yours" } });+ expect(card()).toBeUndefined();+ const asked = await call(chief, { targetBotId: "bot-a" });+ expect(asked.status).toBe(200);+ expect(asked.body.text).toContain("reset Ada's cloud computer");+ asks.answer(card()!.requestId, "allow");+ await flush();+ expect(reset).toHaveBeenCalledWith("bot-a");+ expect((await call(chief, { targetBotId: "nobody" })).status).toBe(404);+ });++ it("keeps one open card per computer", async () => {+ const { call } = setup();+ await call(ada, {});+ expect((await call(ada, {})).status).toBe(409);+ });++ it("is not one of its cards for an unknown request", () => {+ expect(setup().asks.answer("other", "allow")).toBe(false);+ });++ it("closes a card left open by a previous run", async () => {+ const first = setup();+ await first.call(ada, {});+ const fresh = createCloudComputerResetAsks({+ store: { messagesFor: (id: string) => first.lines.get(id) ?? [], patchMessage: (threadId: string, id: string, patch: Partial<Line>) => Object.assign(first.lines.get(threadId)!.find((line) => line.id === id)!, patch) } as never,+ refusal: () => null, reset: vi.fn(),+ openCards: () => [{ threadId: "t1", messageId: "m1" }],+ });+ expect(fresh.dismissStale()).toBe(1);+ expect(first.card()).toMatchObject({ expired: true, options: [] });+ expect(fresh.answer(first.card()!.requestId, "allow")).toBe(false);+ });+});diff --git a/server/host/cloud-computer-reset-asks.ts b/server/host/cloud-computer-reset-asks.tsnew file mode 100644index 0000000000..41c97dab0d--- /dev/null+++ b/server/host/cloud-computer-reset-asks.ts@@ -0,0 +1,124 @@+// A bot asks the person to reset a stuck cloud computer (its own, or as a Chief one of a bot it manages): a card+// in the chat, and on Allow the computer is deleted the way Settings does, once its bot is not working.+import type { ServerResponse } from "node:http";++import { newId } from "../contracts.ts";+import type { json as sendJson } from "../harness/http.ts";+import { optionCardsForTools } from "../message-db.ts";+import { PASS } from "../routes/table.ts";+import { serverLine, type ServerLineKey } from "../server-lines.ts";+import type { BotRecord, Store } from "../store.ts";++export const RESET_CLOUD_COMPUTER_TOOL = "reset_cloud_computer";+const PATH = "/api/internal/cloud-computer/reset";+/** The turn that asked holds its own computer until it ends: Allow waits up to this long for it. */+export const RESET_RETRY_MS = 5_000;+export const RESET_RETRIES = 36;+const WHY_LIMIT = 300;++type Reset = { ok: boolean; pending?: true; missing?: true };+type Ask = { threadId: string; messageId: string; targetId: string; targetName: string; subtitle: string };+type Reply = { status: number; body: Record<string, unknown> };++export interface CloudComputerResetAsksDeps {+ store: Pick<Store, "appendMessage" | "patchMessage" | "messagesFor" | "bot" | "groupByThread">;+ /** Why `from` may not ask to reset `target`'s cloud computer, in words for the bot; null when it may. */+ refusal(from: BotRecord, target: BotRecord): string | null;+ /** Deletes the bot's own cloud computer; throws with status 409 while it is in use. */+ reset(botId: string): Promise<Reset>;+ /** Cards a previous run left open; defaults to the message database. */+ openCards?(): Array<{ threadId: string; messageId: string }>;+ setTimer?(run: () => void, ms: number): void;+ /** The language of the person the conversation is for. */+ language?(threadId: string): string | undefined;+}++const inUse = (error: unknown) =>+ (error as { status?: unknown } | null)?.status === 409 && /in use/i.test(error instanceof Error ? error.message : "");++export function createCloudComputerResetAsks(deps: CloudComputerResetAsksDeps) {+ const { store } = deps;+ const asks = new Map<string, Ask>();+ const later = deps.setTimer ?? ((run: () => void, ms: number) => { setTimeout(run, ms).unref?.(); });++ const words = (threadId: string, key: ServerLineKey, params: Record<string, string>) => serverLine(deps.language?.(threadId), key, params);++ function show(ask: Ask, line: string, answered?: "allow" | "deny"): void {+ const card = store.messagesFor(ask.threadId).find((message) => message.id === ask.messageId)?.card;+ if (!card) return;+ store.patchMessage(ask.threadId, ask.messageId, { card: { ...card, ...(answered ? { answered } : {}), subtitle: line ? `${ask.subtitle}\n${line}` : ask.subtitle } });+ }++ async function run(ask: Ask, tries: number): Promise<void> {+ try {+ const result = await deps.reset(ask.targetId);+ const key = result.missing ? "server.cloudReset.missing" : result.pending ? "server.cloudReset.pending" : "server.cloudReset.done";+ show(ask, words(ask.threadId, key, { name: ask.targetName }));+ } catch (error) {+ if (inUse(error) && tries < RESET_RETRIES) {+ if (tries === 0) show(ask, words(ask.threadId, "server.cloudReset.waiting", { name: ask.targetName }));+ later(() => void run(ask, tries + 1), RESET_RETRY_MS);+ return;+ }+ show(ask, words(ask.threadId, "server.cloudReset.failed", { reason: error instanceof Error ? error.message : String(error) }));+ }+ }++ /** A bot's call: shows the card. `targetBotId` names another bot, for a Chief. */+ function propose(from: BotRecord, threadId: string, body: Record<string, unknown>): Reply {+ const targetId = typeof body.targetBotId === "string" && body.targetBotId.trim() ? body.targetBotId.trim() : from.id;+ const target = store.bot(targetId);+ if (!target) return { status: 404, body: { error: "No bot has that id. Use list_bots for teammate ids." } };+ const refused = deps.refusal(from, target);+ if (refused) return { status: 403, body: { error: refused } };+ for (const ask of asks.values()) {+ if (ask.targetId === target.id) return { status: 409, body: { error: `A card asking to reset ${target.name}'s cloud computer is already waiting for the person. End this turn.` } };+ }+ const why = typeof body.why === "string" ? body.why.trim().slice(0, WHY_LIMIT) : "";+ const subtitle = [why, words(threadId, "server.cloudReset.what", { name: target.name })].filter(Boolean).join("\n");+ const room = store.groupByThread(threadId);+ const requestId = newId();+ const message = store.appendMessage(threadId, {+ role: "bot",+ kind: "options",+ ...(room ? { from: { botId: from.id, name: from.name, color: from.color } } : {}),+ card: { title: words(threadId, "server.cloudReset.title", { name: target.name }), subtitle, options: ["Allow", "Deny"], requestId, requestType: "permission", tool: RESET_CLOUD_COMPUTER_TOOL },+ });+ asks.set(requestId, { threadId, messageId: message.id, targetId: target.id, targetName: target.name, subtitle });+ const whose = target.id === from.id ? "your" : `${target.name}'s`;+ return { status: 200, body: { text: `A card asking the person to reset ${whose} cloud computer is now in this conversation. End this turn now and say in one line that it waits for them. On Allow the computer is deleted once ${target.name} is not working, and ${target.name}'s next turn makes a fresh one. You are not resumed: the card shows how it went.` } };+ }++ return {+ /** A tap on the card; false when the card is not one of these. */+ answer(requestId: string, behavior: string | undefined): boolean {+ const ask = asks.get(requestId);+ if (!ask) return false;+ asks.delete(requestId);+ if (behavior !== "allow") { show(ask, "", "deny"); return true; }+ show(ask, words(ask.threadId, "server.cloudReset.resetting", { name: ask.targetName }), "allow");+ void run(ask, 0);+ return true;+ },++ /** A card a previous run left open has nothing behind it now: closed at startup. */+ dismissStale(): number {+ let closed = 0;+ for (const { threadId, messageId } of (deps.openCards ?? (() => optionCardsForTools([RESET_CLOUD_COMPUTER_TOOL])))()) {+ const card = store.messagesFor(threadId).find((message) => message.id === messageId)?.card;+ if (!card || card.answered || card.dismissed || card.expired || asks.has(card.requestId ?? "")) continue;+ if (store.patchMessage(threadId, messageId, { card: { ...card, expired: true, options: [] } })) closed += 1;+ }+ return closed;+ },++ /** POST /api/internal/cloud-computer/reset: { targetBotId?, why? } from a bot's turn. */+ async internal(args: { method: string; path: string; res: ServerResponse; json: typeof sendJson; sender: BotRecord; threadId: string; readBody(): Promise<unknown> }): Promise<typeof PASS | void> {+ if (args.path !== PATH) return PASS;+ if (args.method !== "POST") return void args.json(args.res, 405, { error: "POST only" });+ const body = await args.readBody();+ const reply = propose(args.sender, args.threadId, body && typeof body === "object" && !Array.isArray(body) ? body as Record<string, unknown> : {});+ return void args.json(args.res, reply.status, reply.body);+ },+ };+}diff --git a/server/index.ts b/server/index.tsindex 02ba7f2c8a..0aa748daef 100644--- a/server/index.ts+++ b/server/index.ts@@ -424,7 +424,7 @@ import { createLocalVmUpdater, LOCAL_VM_UPDATING_PROBLEM, recoverLocalVms, VPS_Oimport { keepInstalledAppsBeforeRemove } from "./local-vm-profiles.ts";import { localVmStopReason, recordLocalVmIdleStop } from "./local-vm-stop-reason.ts";import { ComputerIdleTimer } from "./computer-idle.ts";-import { CLOUD_COMPUTER_DID_NOT_START, CLOUD_COMPUTER_START_BUDGET_MS, CLOUD_COMPUTER_STARTING, createCloudComputerPower } from "./host/cloud-computer-power.ts"; import { resetBotCloudComputer } from "./host/cloud-computer-reset.ts";+import { CLOUD_COMPUTER_DID_NOT_START, CLOUD_COMPUTER_START_BUDGET_MS, CLOUD_COMPUTER_STARTING, createCloudComputerPower } from "./host/cloud-computer-power.ts"; import { resetBotCloudComputer } from "./host/cloud-computer-reset.ts"; import { createCloudComputerResetAsks } from "./host/cloud-computer-reset-asks.ts";import { LocalVmLease, LocalVmLeasePool } from "./local-vm-lease.ts";import { LocalVmSeatPool, type LocalVmSeatHolder } from "./local-vm-seat-pool.ts";import { createLoopGuard, loopGuardSettings } from "./host/loop-guard.ts"; import { createPersonFirst } from "./host/person-first.ts"; import { createRunOwners, runActorOf } from "./host/run-owner.ts";@@ -9595,11 +9595,13 @@ const ROOM_POST_MAX_CHARS = 4_000;const approvalBus: YourComputerBus = { store, notify };-const { quotaSwitch, harnessCardOutcome } = createQuotaSwitchHost({ store, coordinator, registry, turnStops, hostedModels, providerConfigs, policyModelRefusal, checkedTaskModelSwitch, threadBusy, directRequestOwners, startOrQueueDirectMessage, takeover: limitTakeover, ownCards: (requestId, behavior) => computerAsks?.asks.answer(requestId, behavior) ?? false });+// A bot's ask to reset a stuck cloud computer: its own, or as a Chief one of a bot it manages; Settings' reset on Allow.+const cloudComputerResets = createCloudComputerResetAsks({ language: threadLanguage, store, refusal: (from, target) => target.id !== from.id && !(chiefLevel(from) && canManage(from, target)) ? "You can ask to reset only your own cloud computer; a Chief of Staff can also ask for a bot in a department it manages." : !boat.boatConfigured(cfg) || target.computer !== "cloud" || target.cloudBackend === "vps" || inheritedTeamComputer(target) ? `${target.name} has no cloud computer of its own to reset here.` : null, reset: async (botId) => { if (boatLifecycleBusyBots.has(botId)) throw Object.assign(new Error("this bot's cloud computer is being changed — wait for it to finish"), { status: 409 }); return resetBotCloudComputer(cfg, botId, managedBoatOwners(), claimManagedBoatMutation); } });+const { quotaSwitch, harnessCardOutcome } = createQuotaSwitchHost({ store, coordinator, registry, turnStops, hostedModels, providerConfigs, policyModelRefusal, checkedTaskModelSwitch, threadBusy, directRequestOwners, startOrQueueDirectMessage, takeover: limitTakeover, ownCards: (requestId, behavior) => (computerAsks?.asks.answer(requestId, behavior) ?? false) || cloudComputerResets.answer(requestId, behavior) });// Consent cards live only in memory: settle every card still open on disk, or it locks the composer forever.{- const stale = dismissLeftoverPeerCards(store) + dismissStaleYourComputerCards(store) + (computerAsks?.asks.dismissStale() ?? 0);+ const stale = dismissLeftoverPeerCards(store) + dismissStaleYourComputerCards(store) + (computerAsks?.asks.dismissStale() ?? 0) + cloudComputerResets.dismissStale();if (stale) console.log(`approvals: dismissed ${stale} card(s) left by a previous run`);}@@ -12982,7 +12984,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {throw Object.assign(new Error(TURN_ENDED_REFUSAL), { status: 401 });}};- const botFolders = async () => ({ roots: messageFileRootsForThread(internalSender.id, internalCapability.threadId).filter((root) => root !== ATTACHMENTS_DIR), vmWorkspace: (await attachmentVmForTurn(internalCapability))?.workspaceDir ?? null }); if (await lentMcp.route({ method, path, req, res, json, turn: internalCapability, readBody: readInternalBody }) !== PASS || await internalToolRoutes({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, folders: botFolders }) !== PASS || await waitRoutes({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, ...waitTurnChecks(internalCapability, internalSender) }) !== PASS || await teamMessages.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody }) !== PASS || await devsReports.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody }) !== PASS || (computerAsks && await computerAsks.internal({ method, path, res, json, turn: internalCapability, readBody: readInternalBody }) !== PASS) || await meetingsHost.internal({ method, path, res, json, readBody: readInternalBody, bot: internalSender, threadId: internalCapability.threadId, active: () => internalCapabilityIsActive(internalCapability) }) !== PASS || await imageTools.internal({ method, path, res, json, readBody: readInternalBody, threadId: internalCapability.threadId, requireActive: requireActiveInternalCapability, personTurn: turnOrigin(internalCapability).kind === "user" || (Boolean(roomRun(internalCapability.generation)?.requestMessageId) && guestDrivenTurns.get(internalCapability.threadId) !== internalCapability.generation) }) !== PASS) return; const callSignal = turnCallSignals.signal(internalCapability, res); if (await publishedPages.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, requireActive: requireActiveInternalCapability, signal: callSignal, folders: botFolders, post: (text, publishedPage, bundle) => { const source = connectorThread(internalSender.id, internalCapability.threadId); return !source ? null : (bundle && publishedPages.show({ threadId: internalCapability.threadId, card: publishedPage, bundle, bot: internalSender })) || store.appendMessage(internalCapability.threadId, { role: "bot", kind: "text", text, publishedPage, ...(source.group ? { from: { botId: internalSender.id, name: internalSender.name, color: internalSender.color } } : {}) }).id; } }) !== PASS) return;+ const botFolders = async () => ({ roots: messageFileRootsForThread(internalSender.id, internalCapability.threadId).filter((root) => root !== ATTACHMENTS_DIR), vmWorkspace: (await attachmentVmForTurn(internalCapability))?.workspaceDir ?? null }); if (await lentMcp.route({ method, path, req, res, json, turn: internalCapability, readBody: readInternalBody }) !== PASS || await internalToolRoutes({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, folders: botFolders }) !== PASS || await waitRoutes({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, ...waitTurnChecks(internalCapability, internalSender) }) !== PASS || await teamMessages.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody }) !== PASS || await devsReports.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody }) !== PASS || (computerAsks && await computerAsks.internal({ method, path, res, json, turn: internalCapability, readBody: readInternalBody }) !== PASS) || await cloudComputerResets.internal({ method, path, res, json, sender: internalSender, threadId: internalCapability.threadId, readBody: readInternalBody }) !== PASS || await meetingsHost.internal({ method, path, res, json, readBody: readInternalBody, bot: internalSender, threadId: internalCapability.threadId, active: () => internalCapabilityIsActive(internalCapability) }) !== PASS || await imageTools.internal({ method, path, res, json, readBody: readInternalBody, threadId: internalCapability.threadId, requireActive: requireActiveInternalCapability, personTurn: turnOrigin(internalCapability).kind === "user" || (Boolean(roomRun(internalCapability.generation)?.requestMessageId) && guestDrivenTurns.get(internalCapability.threadId) !== internalCapability.generation) }) !== PASS) return; const callSignal = turnCallSignals.signal(internalCapability, res); if (await publishedPages.internal({ method, path, res, json, botId: internalSender.id, threadId: internalCapability.threadId, readBody: readInternalBody, requireActive: requireActiveInternalCapability, signal: callSignal, folders: botFolders, post: (text, publishedPage, bundle) => { const source = connectorThread(internalSender.id, internalCapability.threadId); return !source ? null : (bundle && publishedPages.show({ threadId: internalCapability.threadId, card: publishedPage, bundle, bot: internalSender })) || store.appendMessage(internalCapability.threadId, { role: "bot", kind: "text", text, publishedPage, ...(source.group ? { from: { botId: internalSender.id, name: internalSender.name, color: internalSender.color } } : {}) }).id; } }) !== PASS) return;const delegatedThisTurn = (taskId: string) => {(internalCapability.delegatedThisTurn ??= new Set()).add(taskId);};diff --git a/src/components/ApprovalCard.tsx b/src/components/ApprovalCard.tsxindex 914b460b4a..84aa782ab7 100644--- a/src/components/ApprovalCard.tsx+++ b/src/components/ApprovalCard.tsx@@ -126,6 +126,7 @@ export function toolLabel(tool?: string): string {stage_skill: "approval.tool.enableSkill",update_skill: "approval.tool.updateSkill",update_profile: "approval.tool.updateProfile",+ reset_cloud_computer: "approval.tool.resetCloudComputer",// ACP drivers may send the protocol's toolCall kind as the tool, so every kind maps to a phrase ("shell" is// execute; "tool" is no kind at all).shell: "approval.tool.runCommand",diff --git a/src/locales/de.json b/src/locales/de.jsonindex 2ccdf09135..94c126b8c6 100644--- a/src/locales/de.json+++ b/src/locales/de.json@@ -158,6 +158,14 @@"server.mcp.card.cleared": "Gespeicherte Werte werden gelöscht: {items}.","server.mcp.card.usedBy": "Wird von {names} genutzt.","server.mcp.card.usedByNone": "Kein anderer Bot nutzt ihn.",+ "server.cloudReset.title": "Cloud-Desktop von {name} zurücksetzen?",+ "server.cloudReset.what": "Er wird mit seinen Dateien und Browser-Anmeldungen gelöscht, und mit der nächsten Nachricht von {name} startet ein neuer. Das lässt sich nicht rückgängig machen.",+ "server.cloudReset.resetting": "Cloud-Desktop von {name} wird zurückgesetzt.",+ "server.cloudReset.waiting": "Warte, bis {name} seine Arbeit beendet hat, dann wird zurückgesetzt.",+ "server.cloudReset.done": "Zurückgesetzt: Mit der nächsten Nachricht von {name} startet ein neuer Cloud-Desktop.",+ "server.cloudReset.pending": "Zurücksetzen gestartet. Der alte Cloud-Desktop wird noch gelöscht; sobald er weg ist, startet mit der nächsten Nachricht von {name} ein neuer.",+ "server.cloudReset.missing": "Nichts zurückzusetzen: {name} hat gerade keinen Cloud-Desktop. Mit der nächsten Nachricht startet einer.",+ "server.cloudReset.failed": "Nicht zurückgesetzt: {reason}","server.mcp.card.newClientSecret": "neues OAuth-Client-Secret","server.mcp.card.keyExpired": "Der Schlüssel ist abgelaufen, bevor das beantwortet wurde.","server.mcp.card.gone": "{name} gibt es nicht mehr.",diff --git a/src/locales/en.json b/src/locales/en.jsonindex b0687a0571..faf3dfb2ae 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -290,6 +290,14 @@"server.mcp.card.cleared": "Clears the saved {items}.","server.mcp.card.usedBy": "Used by {names}.","server.mcp.card.usedByNone": "No other bot uses it.",+ "server.cloudReset.title": "Reset {name}'s cloud desktop?",+ "server.cloudReset.what": "It is deleted with its files and browser sign-ins, and a fresh one starts with {name}'s next message. This cannot be undone.",+ "server.cloudReset.resetting": "Resetting {name}'s cloud desktop.",+ "server.cloudReset.waiting": "Waiting for {name} to finish its work before resetting.",+ "server.cloudReset.done": "Reset: a fresh cloud desktop starts with {name}'s next message.",+ "server.cloudReset.pending": "Reset started. The old cloud desktop is still being deleted; a fresh one starts with {name}'s next message once it is gone.",+ "server.cloudReset.missing": "Nothing to reset: {name} has no cloud desktop now. One starts with its next message.",+ "server.cloudReset.failed": "Not reset: {reason}","server.mcp.card.newClientSecret": "new OAuth client secret","server.mcp.card.keyExpired": "The key expired before this was answered.","server.mcp.card.gone": "{name} no longer exists.",@@ -994,6 +1002,7 @@"approval.tool.enableSkill": "enable a learned skill","approval.tool.updateSkill": "update a learned skill","approval.tool.updateProfile": "update its profile",+ "approval.tool.resetCloudComputer": "reset a cloud desktop","approval.tool.deleteFile": "delete a file","approval.tool.think": "think","approval.tool.takeAction": "take an action",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex c8eb641d0d..c316c26546 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -969,6 +969,7 @@"approval.tool.enableSkill": "ativar uma habilidade aprendida","approval.tool.updateSkill": "atualizar uma habilidade aprendida","approval.tool.updateProfile": "atualizar o próprio perfil",+ "approval.tool.resetCloudComputer": "redefinir um desktop na nuvem","approval.tool.deleteFile": "excluir um arquivo","approval.tool.think": "pensar","approval.tool.takeAction": "executar uma ação",diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.jsonindex 9b1f02466e..3bec613551 100644--- a/src/locales/source-hashes.json+++ b/src/locales/source-hashes.json@@ -2662,6 +2662,14 @@"server.mcp.card.cleared": "d161202e56397fcf8c80df6a1b6020801a3d1a2e8eda2e8e593e96c88230b43f","server.mcp.card.usedBy": "cd9bc7ed73f73d4299ac83758c2c11c9c94d7a3bb263d9cf19f11303a89fe809","server.mcp.card.usedByNone": "e92c1c2ed4fcbb0ce6cbae06883d6a9a65bbc78eef599ee8419da6be826f502c",+ "server.cloudReset.title": "14ae704c302b4d1f0cf94b614c6a7b6c892357dd877aa182e2474934f92b8252",+ "server.cloudReset.what": "2f901af1e4d8be98a234e5392bf9384ed53d65d24a27015d87178c5e5be23b26",+ "server.cloudReset.resetting": "597df4ff607d90ba995ba3a6406f224813211de4805d085989273e04dd533538",+ "server.cloudReset.waiting": "9c9d4b3784d64dd5ae8106c9587561ad928a7fc1d2c46830a2b80db5a95d4611",+ "server.cloudReset.done": "27e4089cf08c6d6097f59d79515c7da826cf3e1cff34e03d76cb8f0cbfa161fd",+ "server.cloudReset.pending": "cae5248026f571c7a73a8b7319a8ae7b276ebd6b2ed3615572086f0e9b2ca36d",+ "server.cloudReset.missing": "b9e1c7f96e043bc6150f46302c0c3b8a9db3d67c44d9253f0b3a82f3a404f107",+ "server.cloudReset.failed": "b3ad7ca9b0db2a9a162e07fb9277b26352af0df7d087871000a9a5ea38992c81","server.mcp.card.newClientSecret": "3a292997500ffe2e683dbd68c64793f654b8962b9c33d06058cc13b2f93728f7","server.mcp.card.keyExpired": "a042da6fc541944d38462d0d286c50df6de1ddb685c8a87a9449c44c01e97788","server.mcp.card.gone": "a014f2ad78507fc71d59cfe9b10efef4c41e77bf2ac3bf7ecf23f1d0d4a0f8f6",@@ -36473,7 +36481,8 @@"backup.importAction": "ea94509e38cf6d6427db3a1b5a3b5816cba1e8f89b08f9739f6077ade188163c","computer.reset.button": "196d09c7f7dc0290cc84c7a01347ae3f9a50067925490e7a0b9e262fa2add7f7","computer.reset.confirm": "49ee8910d29a1da38e3b3dd2518685d77c45bd5fbb248f44566c2d7b721765f9",- "computer.reset.pending": "cae5248026f571c7a73a8b7319a8ae7b276ebd6b2ed3615572086f0e9b2ca36d"+ "computer.reset.pending": "cae5248026f571c7a73a8b7319a8ae7b276ebd6b2ed3615572086f0e9b2ca36d",+ "approval.tool.resetCloudComputer": "c977d1d3b7504d9176231a7d8a521f553f5347292f3ccaa13857d1b1d5214f7f"},"zh": {"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",