Skip to content

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

fix(computer): tell a Boat bot that a saved VPS is not chosen for it

AdityaUmalec9801811ab9d
diff --git a/server/cloud-backend.test.ts b/server/cloud-backend.test.ts
index c72c09b5a6..917e30f1b9 100644
--- a/server/cloud-backend.test.ts
+++ b/server/cloud-backend.test.ts
@@ -9,6 +9,7 @@ import {
cloudBackendChangeError,
vpsAliasResourceChangeError,
vpsBotAliasChangeError,
+ vpsNotChosenReason,
} from "./cloud-backend.ts";
describe("cloud backend switching", () => {
@@ -47,3 +48,16 @@ describe("cloud backend switching", () => {
expect(vpsBotAliasChangeError(false, false)).toBeNull();
});
});
+
+describe("vpsNotChosenReason", () => {
+ it("points a Boat bot at the saved VPS it could use instead", () => {
+ const reason = vpsNotChosenReason("Scout", "production-vps");
+ expect(reason).toContain("production-vps");
+ expect(reason).toContain("Self-hosted VPS");
+ expect(reason).toContain("Scout's Bot settings, Access section");
+ });
+
+ it("says nothing when no VPS is set up", () => {
+ expect(vpsNotChosenReason("Scout", null)).toBeNull();
+ });
+});
diff --git a/server/cloud-backend.ts b/server/cloud-backend.ts
index 835bc3ec92..824529d2c4 100644
--- a/server/cloud-backend.ts
+++ b/server/cloud-backend.ts
@@ -15,6 +15,13 @@ export function vpsLeftBehindNotice(done: "Moved" | "Deleted", alias: string, co
`When ${alias} is back, remove it with: docker -H ssh://${alias} rm -f ${containerName}`;
}
+/** Why a bot that gets its cloud computer from Boat can't have one while a self-hosted VPS is saved but not chosen for it. */
+export function vpsNotChosenReason(botName: string, vpsAlias: string | null): string | null {
+ return vpsAlias ? `${botName}'s cloud computer comes from Boat, which is not available here. The self-hosted VPS ${vpsAlias} is set up ` +
+ `but not chosen for ${botName}: ask the person to choose Self-hosted VPS as the cloud backend in ${botName}'s Bot settings, ` +
+ `Access section, then select cloud again.` : null;
+}
+
export function cloudBackendChangeError(botBusy: boolean, activeVpsThread: boolean): string | null {
return botBusy || activeVpsThread ? CLOUD_BACKEND_CHANGE_ERROR : null;
}
diff --git a/server/index.ts b/server/index.ts
index f6b4a3b2e4..ab50895699 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -113,7 +113,7 @@ import type { TeamComputersPayload } from "../shared/team-computer.ts";
import { boatCreateRecoverySnapshot } from "./boat-create-idempotency.ts";
import { boatDeletionSnapshot } from "./boat-delete-journal.ts";
import { liveDecisionRefusal } from "../shared/live-approval.ts"; import type { PersonWaitKind } from "../shared/person-wait.ts";
-import { vpsLeftBehindNotice } from "./cloud-backend.ts";
+import { vpsLeftBehindNotice, vpsNotChosenReason } from "./cloud-backend.ts";
import * as composio from "./composio.ts";
import { appSandboxRule, connectorCallFromFrame, connectorRefusalText, connectorScopeRefusalText, connectorUnrecognizedText, evaluateConnectorTools } from "./connector-verdict.ts";
import { signInCardText } from "./connector-card-text.ts";
@@ -6031,8 +6031,8 @@ async function selectableComputers(bot: BotRecord) {
canStart = lifecycle === "wake";
canCreate = lifecycle === "provision";
} else {
- reason = (cloudPlaceRefusal(cloudEngine(instance, bot.modelSelection.model), "works-on", bot.name)
- ?? boatNotConfigured(bot, "works-on")).message;
+ reason = cloudPlaceRefusal(cloudEngine(instance, bot.modelSelection.model), "works-on", bot.name)?.message
+ ?? vpsNotChosenReason(bot.name, vpsSshAliasForBot(cfg, bot)) ?? boatNotConfigured(bot, "works-on").message;
}
} else if (surface === "vm" && caps?.computerMcp) {
const target = localVmTargetForStatus(bot.id);
diff --git a/server/vps-routing.test.ts b/server/vps-routing.test.ts
index 294fe47088..8d1ce5c27d 100644
--- a/server/vps-routing.test.ts
+++ b/server/vps-routing.test.ts
@@ -439,6 +439,27 @@ createServer(socket => socket.end()).listen(port, '127.0.0.1');
}
}, 30_000);
+ it("tells a Boat bot without Boat that the saved VPS is not chosen for it, instead of only asking for Boat", async () => {
+ await api("PUT", "/api/config", { vps: { sshAlias: "production-vps" } });
+ const bot = (await api("POST", "/api/bots")).body.bot;
+ try {
+ rmSync(gateFile, { force: true }); rmSync(`${acpDump}.mcp.json`, { force: true });
+ await api("PATCH", `/api/bots/${bot.id}`, { browser: false, computer: null, modelSelection: { instanceId: "vps", model: "fake-model" } });
+ expect((await api("POST", `/api/bots/${bot.id}/messages`, { text: "Use the remote computer" })).status).toBe(202);
+ await until(async () => existsSync(`${acpDump}.mcp.json`), "the turn");
+ const agents = JSON.parse(readFileSync(`${acpDump}.mcp.json`, "utf8")).find((tool: { name: string }) => tool.name === "agents");
+ const token = agents.env.find((entry: { name: string }) => entry.name === "OMB_COMMS_TOKEN").value;
+ const availability = await (await fetch(`${BASE}/api/internal/computer/select`, { headers: { authorization: `Bearer ${token}` } })).json() as any;
+ const cloud = availability.options.find((option: any) => option.surface === "cloud");
+ expect(cloud.available).toBe(false);
+ expect(cloud.reason).toContain("production-vps");
+ expect(cloud.reason).toContain("Self-hosted VPS");
+ } finally {
+ writeFileSync(gateFile, "open");
+ await api("POST", `/api/bots/${bot.id}/interrupt`, {});
+ }
+ }, 30_000);
+
it.each(["stopped", "missing", "stopped-during-turn"])(
"lets Auto discover a %s VPS and start or create it through its chat tool",
async state => {