Skip to content

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

Fence harness routes for work from My Cloud while commands are off

milind-soni6bf967b03d5b
diff --git a/server/bot-link.e2e.test.ts b/server/bot-link.e2e.test.ts
index 971e95cd5d..1b8347e3b6 100644
--- a/server/bot-link.e2e.test.ts
+++ b/server/bot-link.e2e.test.ts
@@ -155,8 +155,9 @@ it("a bot on the computer and a bot on the person's own server hand each other w
expect(withFiles.some((message) => message.attachments?.some((file: any) => file.name === "orders.csv"))).toBe(true);
expect(withFiles.some((message) => message.roomRequest?.phase === "result" && message.attachments?.some((file: any) => file.name === "totals.txt"))).toBe(true);
- // And the other way, over the same link.
- computer.plan(writer.id, { reply: "Writer drafted the summary." });
+ // And the other way, over the same link. Writer also tries to add a tool server and to write outside its folder.
+ computer.plan(writer.id, { steps: [{ tool: "mcp_server", arguments: { action: "add", name: "planted", url: "https://example.invalid/mcp" }, expectError: true }],
+ approve: { tool_name: "Write", input: { file_path: join(computer.dataDir, "..", "planted.txt"), content: "x" } }, reply: "Writer drafted the summary." });
home.plan(atlas.id,
{ steps: [{ tool: "coordinate_bots", arguments: { bot_ids: ["Writer"], request_key: "draft", message: "Draft the weekly summary." } }], reply: "Asked Writer." },
{ reply: "Writer drafted it." });
@@ -169,6 +170,8 @@ it("a bot on the computer and a bot on the person's own server hand each other w
const drafted = computer.providerTurns().filter((turn) => turn.botId === writer.id).at(-1);
expect(drafted).toMatchObject({ permissionMode: "acceptEdits", restricted: true });
expect(JSON.stringify(drafted.prompt)).toContain("Running commands on this computer is off for work from My Cloud");
+ expect(JSON.stringify(drafted.evidence)).toContain("it may not change settings, add tools, or start or schedule work outside this conversation");
+ expect(drafted.approval).toMatchObject({ behavior: "deny" });
const workHere = (await computer.api("GET", "/api/bots")).bots.find((bot: any) => bot.id === writer.id).tasks.find((task: any) => /Atlas/.test(task.title ?? ""));
expect(workHere, "the work's own thread on the computer").toBeTruthy();
expect((await computer.messages(workHere.threadId)).filter((message) => message.kind === "options")).toEqual([]);
diff --git a/server/bot-link/far-side.test.ts b/server/bot-link/far-side.test.ts
index 16dd3ac8a3..eb418e9a01 100644
--- a/server/bot-link/far-side.test.ts
+++ b/server/bot-link/far-side.test.ts
@@ -9,7 +9,7 @@ import { afterEach, describe, expect, it } from "vitest";
import { createCoordinator, type Coordinator, type CoordinatorHost, type HandoffView } from "../coordinator.ts";
import type { SendTurnInput } from "../contracts.ts";
import { removeTempDir } from "../testing/cleanup.ts";
-import { createLinkLimits, LINK_ACTION_DENIED, LINK_COMMANDS_MESSAGE, LINK_COMMANDS_OFF, LINK_ENGINE_REFUSAL, linkLevel } from "./far-side.ts";
+import { createLinkLimits, LINK_ACTION_DENIED, LINK_COMMANDS_MESSAGE, LINK_COMMANDS_OFF, LINK_ENGINE_REFUSAL, linkLevel, linkRouteRefused } from "./far-side.ts";
import { createBotLink, type BotLink } from "./link.ts";
import { peerKey, type Frame } from "./protocol.ts";
@@ -169,6 +169,18 @@ describe("what a limited turn's engine is given", () => {
expect(linkLevel("edits", "geminiAgent")).toBe("edits");
});
+ it("reaches no harness route that changes this computer's setup or starts work later, and keeps handing work on and memory", () => {
+ for (const refused of ["POST /api/internal/mcp-servers", "POST /api/internal/trigger-requests", "POST /api/internal/waits", "POST /api/internal/create-bot",
+ "POST /api/internal/computer/mcp", "POST /api/internal/post-to-room", "POST /api/internal/routines", "PATCH /api/internal/app-settings"]) {
+ const [method, path] = refused.split(" ") as [string, string];
+ expect(linkRouteRefused(method, path), refused).toBe(true);
+ }
+ for (const kept of ["POST /api/internal/coordinate-bots", "GET /api/internal/assignment-status", "POST /api/internal/memory", "POST /api/internal/connectors/mcp", "POST /api/internal/email/mcp"]) {
+ const [method, path] = kept.split(" ") as [string, string];
+ expect(linkRouteRefused(method, path), kept).toBe(false);
+ }
+ });
+
it("answers its permission requests at the capped level only while that turn runs", () => {
limits.begin("thread-1", true, "claudeAgent");
expect(limits.held("thread-1")?.level("full")).toBe("edits");
diff --git a/server/bot-link/far-side.ts b/server/bot-link/far-side.ts
index 8c4e8e3740..93f75d14e5 100644
--- a/server/bot-link/far-side.ts
+++ b/server/bot-link/far-side.ts
@@ -11,6 +11,7 @@
// "confined") refuse such work with a line back to the sender, rather than run it at the bot's own level.
import type { ApprovalMode } from "../../shared/approval-mode.ts";
import type { SendTurnInput } from "../contracts.ts";
+import { outsideRouteRefused } from "../host/outside-fence.ts";
import { LINK_PREFIX } from "./protocol.ts";
/** What the bot is told, and how a refusal ends. */
@@ -19,6 +20,8 @@ export const LINK_COMMANDS_OFF = "Running commands on this computer is off for w
export const LINK_ENGINE_REFUSAL = "This bot's AI can't work on this computer without running commands, and running commands on this computer is off for work from My Cloud, so this was not started. The person can turn on \"Let Clouds run commands on this computer\" from the OpenMausBot icon, or give this bot an AI that can work without them.";
/** An action such work asked for that it may not take. */
export const LINK_ACTION_DENIED = "Not allowed for work from My Cloud while running commands on this computer is off.";
+/** A harness route such work may not use. */
+export const LINK_ROUTE_REFUSAL = "Work from My Cloud can't do that on this computer while running commands here is off: it may not change settings, add tools, or start or schedule work outside this conversation. Finish what you can here and say plainly what the person would need to do.";
/** The desktop's word on the grant, over Electron's private parent port (electron/link-commands-fact.mjs). */
export const LINK_COMMANDS_MESSAGE = "openmausbot:link-commands";
@@ -27,6 +30,23 @@ export const LINK_COMMANDS_MESSAGE = "openmausbot:link-commands";
* and writes files). The harness's own team tools, connected apps, email and hooks stay. */
const NOT_LENT = ["localComputer", "browser", "phone", "device", "custom", "mcpApps", "customResultBudgets", "data"] as const;
+/** Of the routes a confined turn may reach (host/outside-fence.ts), the ones that would change this computer's setup or
+ * start work later outside this conversation's lineage, where it would run at a bot's own level; and the integrations'
+ * own routes, which such a turn is never given. Handing work on stays: it keeps the lineage. */
+const LATER_OR_SETUP: ReadonlySet<string> = new Set([
+ "POST /api/internal/threads", "POST /api/internal/post-to-room", "POST /api/internal/retry-thread", "POST /api/internal/trigger-requests",
+ "POST /api/internal/manage-room", "POST /api/internal/waits", "POST /api/internal/profile-requests", "POST /api/internal/model-requests",
+ "POST /api/internal/team-setup-requests", "POST /api/internal/bot-deletion-requests", "POST /api/internal/create-bot",
+ "POST /api/internal/skills/stage", "POST /api/internal/mcp-servers", "POST /api/internal/shared-computers", "POST /api/internal/connectors/request",
+ "POST /api/internal/browser/mcp", "POST /api/internal/computer/mcp", "GET /api/internal/computer-control", "POST /api/internal/computer-control",
+ "POST /api/internal/computer/journal", "POST /api/internal/data/mcp",
+]);
+
+/** Whether a limited turn is refused this harness route: every route a confined turn is, and LATER_OR_SETUP. */
+export function linkRouteRefused(method: string, path: string): boolean {
+ return outsideRouteRefused(method, path) || LATER_OR_SETUP.has(`${method.toUpperCase()} ${path}`);
+}
+
export interface LinkLimitsDeps {
/** This server is a Cloud, or the side of the link that computers ask: work from a computer runs in its own place, so
* nothing is limited here. Asked each time, since the link can be turned on or off. */
diff --git a/server/index.ts b/server/index.ts
index 537f716f1d..7405e75fea 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -572,7 +572,7 @@ import { PhoneSecretBridge, PhoneSecretSubmissionRegistry } from "./phone-secret
// Keep these two last, so loading the route table leaves module start-up order as is.
import { gzipTunnelReplies, json, onJsonBody, parsedBodyOf, readBody } from "./harness/http.ts";
import { holdBodyDeadline } from "./body-deadline.ts";
-import { createNoAiNotice } from "./host/no-ai-notice.ts"; import { PASS, ROUTES, dispatchRoutes } from "./routes/table.ts"; import { createBotLinkHost } from "./host/bot-link-host.ts"; import { createLinkLimits, LINK_ACTION_DENIED, LINK_COMMANDS_OFF, LINK_ENGINE_REFUSAL } from "./bot-link/far-side.ts"; import { followRoomMentions } from "./host/bot-link-rooms.ts"; import { standInAmong, standInWriteRefusal } from "./host/stand-in-guard.ts"; import { isBotLinkHeldPath, linkSessionRefusal } from "./routes/bot-link.ts"; import { createSecretCards } from "./host/secret-cards.ts"; import { createInternalCredentialRequestRoutes, createSecretCardRoutes } from "./routes/secret-cards.ts"; import { applyIncludedPagesMessage, pagesAccess, pagesNotOffered } from "./pages/access.ts"; import { createPublishedPages } from "./pages/service.ts"; import { createInternalToolRoutes } from "./routes/internal-tools.ts"; import { createHelperSuggestionRoutes } from "./routes/helper-suggestion.ts"; import { createXConnectorRoutes } from "./routes/x-connector.ts"; import { createMoveFreeze, switchAutomationsOff } from "./move-freeze.ts"; import { createMoveFreezeRoutes } from "./routes/move-freeze.ts"; import { createMoveWaits } from "./move-waits.ts"; import { assertBotHere, botMoveRefusal, createBotMoves } from "./bot-moves.ts"; import { createBotMoveRoutes } from "./routes/bot-moves.ts"; import { createTeamMoveIn, moveInRefusal } from "./team-move-in.ts";
+import { createNoAiNotice } from "./host/no-ai-notice.ts"; import { PASS, ROUTES, dispatchRoutes } from "./routes/table.ts"; import { createBotLinkHost } from "./host/bot-link-host.ts"; import { createLinkLimits, LINK_ACTION_DENIED, LINK_COMMANDS_OFF, LINK_ENGINE_REFUSAL, LINK_ROUTE_REFUSAL, linkRouteRefused } from "./bot-link/far-side.ts"; import { followRoomMentions } from "./host/bot-link-rooms.ts"; import { standInAmong, standInWriteRefusal } from "./host/stand-in-guard.ts"; import { isBotLinkHeldPath, linkSessionRefusal } from "./routes/bot-link.ts"; import { createSecretCards } from "./host/secret-cards.ts"; import { createInternalCredentialRequestRoutes, createSecretCardRoutes } from "./routes/secret-cards.ts"; import { applyIncludedPagesMessage, pagesAccess, pagesNotOffered } from "./pages/access.ts"; import { createPublishedPages } from "./pages/service.ts"; import { createInternalToolRoutes } from "./routes/internal-tools.ts"; import { createHelperSuggestionRoutes } from "./routes/helper-suggestion.ts"; import { createXConnectorRoutes } from "./routes/x-connector.ts"; import { createMoveFreeze, switchAutomationsOff } from "./move-freeze.ts"; import { createMoveFreezeRoutes } from "./routes/move-freeze.ts"; import { createMoveWaits } from "./move-waits.ts"; import { assertBotHere, botMoveRefusal, createBotMoves } from "./bot-moves.ts"; import { createBotMoveRoutes } from "./routes/bot-moves.ts"; import { createTeamMoveIn, moveInRefusal } from "./team-move-in.ts";
import { createHostedSlackRoutes } from "./routes/hosted-slack.ts";
import { createBotPresetRoutes } from "./routes/bot-presets.ts"; import { createWorkspaceBannerRoutes, workspaceBannerStore, workspaceBannerSummary } from "./routes/workspace-banner.ts";
import { createBotMemoryRoutes } from "./routes/bot-memory.ts"; import { createBotLibraryRoutes } from "./routes/bot-library.ts";
@@ -12735,7 +12735,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {
return json(res, 403, { error: "an external runtime can only list its peers, hand them work with coordinate_bots and read assignment_status" });
}
if (proactive.fence.refusesRoute(internalSender, internalCapability.threadId, method, path)) return json(res, 403, { error: READ_AND_DRAFT_REFUSAL }); if (botApiThread(internalCapability.threadId) && botApiRouteRefused(method, path)) return json(res, 403, { error: BOT_API_REFUSAL });
- if (cloudGuestDriven(internalCapability.threadId) && outsideRouteRefused(method, path)) return json(res, 403, { error: OUTSIDE_REFUSAL });
+ if (cloudGuestDriven(internalCapability.threadId) && outsideRouteRefused(method, path)) return json(res, 403, { error: OUTSIDE_REFUSAL }); if (linkLimits.held(internalCapability.threadId) && linkRouteRefused(method, path)) return json(res, 403, { error: LINK_ROUTE_REFUSAL });
const requiredCapabilityKind = path === "/api/internal/hook"
? "hooks"
: path === "/api/internal/browser/mcp"