Skip to content

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

fix(connectors): rework #5203 so the apps' sandbox opens at Full access, no switch

milind-soni016535f75012
diff --git a/server/connector-advertisement.test.ts b/server/connector-advertisement.test.ts
index 80e6613429..cd25351ca3 100644
--- a/server/connector-advertisement.test.ts
+++ b/server/connector-advertisement.test.ts
@@ -138,18 +138,17 @@ describe("tools/list frame filtering", () => {
});
});
-describe("app sandbox switch", () => {
- it("offers the sandbox tools only to a bot with app grants whose switch is on", () => {
+describe("the apps' sandbox", () => {
+ it("is offered to a bot with app grants only while its turn runs at Full access", () => {
const gmail = grants({ gmail: { tools: "*" } });
- expect(advertisedGrants({ connectorTools: gmail })).toBe(gmail);
- expect(advertisedGrants({ connectorTools: gmail, appSandbox: false })).toBe(gmail);
- expect(advertisedGrants({ appSandbox: true })).toBeUndefined();
- const on = advertisedGrants({ connectorTools: gmail, appSandbox: true })!;
+ expect(advertisedGrants(gmail, false)).toBe(gmail);
+ expect(advertisedGrants(undefined, true)).toBeUndefined();
+ const full = advertisedGrants(gmail, true)!;
expect(gmail).toEqual({ gmail: { tools: "*" } });
for (const tool of ["COMPOSIO_REMOTE_WORKBENCH", "COMPOSIO_REMOTE_BASH_TOOL", "GMAIL_SEND_EMAIL"]) {
- expect(connectorToolAdvertised(tool, on)).toBe(true);
+ expect(connectorToolAdvertised(tool, full)).toBe(true);
expect(connectorToolAdvertised(tool, gmail)).toBe(tool === "GMAIL_SEND_EMAIL");
}
- expect(connectorToolAdvertised("SLACK_POST_MESSAGE", on)).toBe(false);
+ expect(connectorToolAdvertised("SLACK_POST_MESSAGE", full)).toBe(false);
});
});
diff --git a/server/connector-advertisement.ts b/server/connector-advertisement.ts
index c14d699181..33a0e92089 100644
--- a/server/connector-advertisement.ts
+++ b/server/connector-advertisement.ts
@@ -23,10 +23,11 @@ export const CONNECTOR_META_TOOLS: readonly string[] = [
"COMPOSIO_WAIT_FOR_CONNECTIONS",
];
-/** What a bot's tools/list offers: its grants, and the sandbox's code tools while its sandbox switch is on. */
-export function advertisedGrants(bot: { connectorTools?: Record<string, ConnectorToolGrant>; appSandbox?: boolean }): Record<string, ConnectorToolGrant> | undefined {
- if (bot.connectorTools === undefined || bot.appSandbox !== true) return bot.connectorTools;
- return { ...bot.connectorTools, [APP_SANDBOX_SERVICE]: { tools: [...APP_SANDBOX_TOOLS] } };
+/** What a bot's tools/list offers: its grants, and the apps' sandbox's code tools while its turn runs at Full access (the
+ * relay judges each call again). */
+export function advertisedGrants(grants: Record<string, ConnectorToolGrant> | undefined, fullAccess: boolean): Record<string, ConnectorToolGrant> | undefined {
+ if (grants === undefined || !fullAccess) return grants;
+ return { ...grants, [APP_SANDBOX_SERVICE]: { tools: [...APP_SANDBOX_TOOLS] } };
}
const CONNECTION_TOOL_SUFFIXES = ["_MANAGE_CONNECTIONS", "_WAIT_FOR_CONNECTIONS"];
diff --git a/server/connector-verdict.test.ts b/server/connector-verdict.test.ts
index fe0058cbad..fb5c01385e 100644
--- a/server/connector-verdict.test.ts
+++ b/server/connector-verdict.test.ts
@@ -2,6 +2,8 @@ import { describe, expect, it } from "vitest";
import type { ConnectorToolGrant } from "../shared/wire.ts";
import {
+ APP_SANDBOX_REFUSAL,
+ appSandboxRule,
COMPOSIO_MULTI_EXECUTE_TOOL,
connectorCallFromFrame,
connectorRefusalText,
@@ -71,6 +73,28 @@ describe("connectorCallFromFrame", () => {
});
});
+describe("appSandboxRule", () => {
+ it("opens only a direct call to the apps' sandbox, and only while the turn runs at Full access", () => {
+ let full = true;
+ const level = () => full;
+ for (const name of ["COMPOSIO_REMOTE_WORKBENCH", "COMPOSIO_REMOTE_BASH_TOOL"]) {
+ const rule = appSandboxRule(toolsCall(name, { code: "print(1)" }), level);
+ expect(rule.open()).toBe(true);
+ expect(rule.refusal).toBe(APP_SANDBOX_REFUSAL);
+ }
+ const direct = appSandboxRule(toolsCall("COMPOSIO_REMOTE_WORKBENCH", {}), level);
+ full = false;
+ expect(direct.open(), "asked again at dispatch: the level dropped meanwhile").toBe(false);
+ full = true;
+ const wrapped = appSandboxRule(multiExecute({ tools: [{ tool_slug: "COMPOSIO_REMOTE_WORKBENCH", arguments: {} }] }), level);
+ expect(wrapped.open()).toBe(false);
+ expect(wrapped.refusal).not.toBe(APP_SANDBOX_REFUSAL);
+ expect(appSandboxRule(toolsCall("COMPOSIO_SEARCH_TOOLS", {}), level).open()).toBe(false);
+ expect(appSandboxRule({ method: "tools/list" }, level).open()).toBe(false);
+ expect(appSandboxRule(null, level).open()).toBe(false);
+ });
+});
+
describe("serviceSlugFor", () => {
it("maps a tool name to its service slug", () => {
expect(serviceSlugFor("GMAIL_SEND_EMAIL")).toBe("gmail");
@@ -181,9 +205,10 @@ describe("refusal text", () => {
expect(text).not.toContain("GMAIL");
});
- it("points a refused sandbox call at the bot's sandbox switch", () => {
+ it("tells a bot whose batch wraps the apps' sandbox that it runs only at Full access, by a direct call", () => {
const text = connectorRefusalText(evaluateConnectorTools(["COMPOSIO_REMOTE_WORKBENCH"], { gmail: { tools: "*" } }).denials);
- expect(text).toContain("Run code in the apps' sandbox");
+ expect(text).toBe(APP_SANDBOX_REFUSAL);
+ expect(text).toContain("Full access");
expect(connectorRefusalText([
{ tool: "COMPOSIO_REMOTE_WORKBENCH", service: "composio", onGrantedService: false },
{ tool: "NOTION_CREATE_PAGE", service: "notion", onGrantedService: false },
diff --git a/server/connector-verdict.ts b/server/connector-verdict.ts
index 4d6fd4d945..737901168e 100644
--- a/server/connector-verdict.ts
+++ b/server/connector-verdict.ts
@@ -4,17 +4,35 @@
import { CONNECTOR_TOOL_NAME_PATTERN, type ConnectorToolGrant } from "../shared/wire.ts";
import { EMAIL_SLUG } from "../shared/email.ts";
-/** The connected apps' sandbox: Composio's code tools. Code run there can reach any connected app, so a bot with per-app
- * grants gets them only when its person turns on "Run code in the apps' sandbox"; each run still asks below Full access. */
+/** The connected apps' sandbox: Composio's code tools. Code run there can reach any connected app, past a bot's per-app
+ * grants and scopes, so a bot that has either runs it only at Full access, and only by a direct call. */
export const APP_SANDBOX_TOOLS: readonly string[] = ["COMPOSIO_REMOTE_WORKBENCH", "COMPOSIO_REMOTE_BASH_TOOL"];
/** The service Composio's own tools are named for (COMPOSIO_REMOTE_WORKBENCH → composio). */
export const APP_SANDBOX_SERVICE = "composio";
-/** A bot with per-app grants asked to run code in the apps' sandbox while its switch is off. */
-export const APP_SANDBOX_REFUSAL = "This call was not performed. A bot runs code in the connected apps' sandbox only by calling "
- + "COMPOSIO_REMOTE_WORKBENCH or COMPOSIO_REMOTE_BASH_TOOL directly (never inside COMPOSIO_MULTI_EXECUTE_TOOL), and only once the person "
- + "turns on \"Run code in the apps' sandbox\" in its settings, under Access → Connected apps. If that tool is not offered to you, ask them.";
+/** A bot with per-app grants asked to run code in the apps' sandbox below Full access, or inside a batch. */
+export const APP_SANDBOX_REFUSAL = "This call was not performed. A bot with its own connected-app grants runs code in the apps' "
+ + "sandbox only at Full access, and only by calling COMPOSIO_REMOTE_WORKBENCH or COMPOSIO_REMOTE_BASH_TOOL directly (never inside "
+ + "COMPOSIO_MULTI_EXECUTE_TOOL). Use a direct app tool, or tell the person this needs Full access.";
+
+const OPAQUE_CODE_REFUSAL = "OpenMausBot cannot verify this code against this bot's tool grants. Use a direct app tool.";
+
+/** A tools/call frame that calls the apps' sandbox directly. */
+function appSandboxCall(frame: unknown): boolean {
+ if (!frame || typeof frame !== "object" || Array.isArray(frame)) return false;
+ const { method, params } = frame as { method?: unknown; params?: unknown };
+ const name = params && typeof params === "object" && !Array.isArray(params) ? (params as { name?: unknown }).name : undefined;
+ return method === "tools/call" && typeof name === "string" && APP_SANDBOX_TOOLS.includes(name);
+}
+
+/** The relay's rule for the apps' sandbox: a direct call to it passes a bot's per-app grants and scopes only while the turn
+ * runs at Full access, judged again each time it is asked (at dispatch too). `refusal` is what a bot with grants is told
+ * when code it sent cannot be checked against them. */
+export function appSandboxRule(frame: unknown, fullAccess: () => boolean): { open(): boolean; refusal: string } {
+ const direct = appSandboxCall(frame);
+ return { open: () => direct && fullAccess(), refusal: direct ? APP_SANDBOX_REFUSAL : OPAQUE_CODE_REFUSAL };
+}
/** The only Composio meta-tool whose arguments name target tools. */
export const COMPOSIO_MULTI_EXECUTE_TOOL = "COMPOSIO_MULTI_EXECUTE_TOOL";
@@ -140,7 +158,7 @@ export function evaluateConnectorTools(
/** Never lists what the bot could have called instead: enumerating adjacent grants teaches the model to probe. */
export function connectorRefusalText(denials: ConnectorDenial[]): string {
- if (denials.every((denial) => APP_SANDBOX_TOOLS.includes(denial.tool))) return APP_SANDBOX_REFUSAL;
+ if (denials.length && denials.every((denial) => APP_SANDBOX_TOOLS.includes(denial.tool))) return APP_SANDBOX_REFUSAL;
const named = denials.map((denial) => '"' + denial.tool + '"').join(", ");
const one = denials.length === 1;
return [
diff --git a/server/host/team-connections-host.test.ts b/server/host/team-connections-host.test.ts
index 8397e89193..82fd6bef47 100644
--- a/server/host/team-connections-host.test.ts
+++ b/server/host/team-connections-host.test.ts
@@ -34,7 +34,7 @@ const ROSTER = [
{ person: ADA, email: "[email protected]", role: "member" as const }, { person: CLEO, email: "[email protected]", role: "member" as const },
];
-function setup(options: { team?: boolean; requester?: Record<string, string>; servers?: Record<string, unknown>; roster?: typeof ROSTER } = {}) {
+function setup(options: { team?: boolean; requester?: Record<string, string>; servers?: Record<string, unknown>; roster?: typeof ROSTER; fullAccess?: (botId: string, threadId: string) => boolean } = {}) {
const dataDir = mkdtempSync(join(tmpdir(), "omb-team-connections-"));
const requester = { "ada-chat": ADA, "cleo-chat": CLEO, "room-chat": ADA, "main-chat": ADA, "work-chat": ADA, "ada-work": ADA, "cleo-work": CLEO, ...options.requester };
const cfg = { mcpServers: options.servers ?? {
@@ -64,6 +64,7 @@ function setup(options: { team?: boolean; requester?: Record<string, string>; se
})),
isOwnerLive: () => true,
...(options.roster ? { roster: () => options.roster! } : {}),
+ ...(options.fullAccess ? { fullAccess: options.fullAccess } : {}),
brokerUrl: () => ADA_ACCESS.url,
composio: composio as never,
});
@@ -219,6 +220,21 @@ describe("apps each person connects", () => {
expect(await host.callRefusal({ threadId: "cleo-chat", generation: "gen-1" }, [{ slug: "GMAIL_FETCH_EMAILS" }]), "Cleo's chat never reaches Ada's Gmail").toMatch(/Connect your Gmail/);
});
+ it("offers a bot with app grants the apps' sandbox only in a turn at Full access", async () => {
+ const { host, composio } = setup({ fullAccess: (_botId, threadId) => threadId === "work-chat" });
+ const scout = { id: "scout", name: "Scout", connectorTools: { gmail: { tools: "*" as const } } };
+ await host.appsIntegrations(scout, "main-chat", "g1");
+ await host.appsIntegrations(scout, "work-chat", "g2");
+ await host.appsIntegrations({ id: "mausbot", name: "MausBot" }, "work-chat", "g3");
+ const offered = composio.mcpIntegration.mock.calls.map(([, context]) => context as typeof context & { connectorTools?: unknown })
+ .filter((context) => !context.as).map((context) => context.connectorTools);
+ expect(offered).toEqual([
+ { gmail: { tools: "*" } },
+ { gmail: { tools: "*" }, composio: { tools: ["COMPOSIO_REMOTE_WORKBENCH", "COMPOSIO_REMOTE_BASH_TOOL"] } },
+ undefined,
+ ]);
+ });
+
it("refuses a person's app through the team's bridge, and a team app through her own", async () => {
const { host, dataDir } = setup({ requester: { "main-chat": "" } });
adaConnected(host, dataDir);
diff --git a/server/host/team-connections-host.ts b/server/host/team-connections-host.ts
index 728c46eb4a..0ce63e13d0 100644
--- a/server/host/team-connections-host.ts
+++ b/server/host/team-connections-host.ts
@@ -23,7 +23,7 @@ import { appLabel, ConnectionScopes, PeopleConnections, personAppOf, SCOPES_FILE
import { APP_TOOL_NAMES_ENV, APP_TOOLS_ENV, appToolsFor } from "../connector-app-tools.ts";
import type { ConnectorScopes } from "../../shared/connector-scopes.ts";
-type Bot = { id: string; name: string; connectorTools?: Parameters<typeof Composio.mcpIntegration>[1]["connectorTools"]; connectorScopes?: ConnectorScopes; appSandbox?: boolean };
+type Bot = { id: string; name: string; connectorTools?: Parameters<typeof Composio.mcpIntegration>[1]["connectorTools"]; connectorScopes?: ConnectorScopes };
type Integration = { command: string; args: string[]; env: Record<string, string> };
type McpBot = { id: string; name: string; mcpServers?: string[] };
@@ -55,6 +55,8 @@ export interface TeamConnectionsHostDeps {
onPersonChanged?(person: string, kind: "app" | "mcp", id: string): void;
/** The connected-apps service a member's own installation is made on; null: none here. */
brokerUrl(): string | null;
+ /** Whether this bot's turn in this conversation runs at Full access: its tools/list then offers the apps' sandbox. */
+ fullAccess?(botId: string, threadId: string): boolean;
composio: Pick<typeof Composio, "configured" | "mcpIntegration" | "connectedServices" | "verifiedConnectedServiceSlugs" | "authorizeService" | "removeService">;
}
@@ -239,7 +241,7 @@ export function createTeamConnectionsHost(deps: TeamConnectionsHostDeps) {
async appsIntegrations(bot: Bot, threadId: string, generation: string, names: "dotted" | "plain" = "plain"): Promise<{ composio?: Integration; composioOwn?: Integration }> {
const cfg = deps.cfg();
const out: { composio?: Integration; composioOwn?: Integration } = {};
- const base = { harnessUrl: deps.harnessUrl, botId: bot.id, threadId, connectorTools: advertisedGrants(bot) };
+ const base = { harnessUrl: deps.harnessUrl, botId: bot.id, threadId, connectorTools: advertisedGrants(bot.connectorTools, deps.fullAccess?.(bot.id, threadId) === true) };
const shared = await deps.composio.mcpIntegration(cfg, { ...base, commsToken: deps.mint({ botId: bot.id, threadId, generation }) });
if (shared) out.composio = await withAppTools(shared, bot, names);
const person = personApps().length ? turnPerson(threadId, generation) : null;
diff --git a/server/index.ts b/server/index.ts
index 1adb81375d..c28b25d201 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -116,7 +116,7 @@ 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 * as composio from "./composio.ts";
-import { APP_SANDBOX_REFUSAL, APP_SANDBOX_TOOLS, connectorCallFromFrame, connectorRefusalText, connectorScopeRefusalText, connectorUnrecognizedText, evaluateConnectorTools } from "./connector-verdict.ts";
+import { appSandboxRule, connectorCallFromFrame, connectorRefusalText, connectorScopeRefusalText, connectorUnrecognizedText, evaluateConnectorTools } from "./connector-verdict.ts";
import { connectorCardDescription, connectorCardText, signInCardText } from "./connector-card-text.ts";
import { BOT_PAUSED_CODE } from "../shared/bot-limit.ts"; import { createStarterAwake } from "./host/starter-awake.ts"; import { createStarterCaps } from "./host/starter-caps.ts"; import { createStarterAwakeRoutes } from "./routes/starter-awake.ts"; import { chiefOfStaffSystemPrompt } from "./chief-of-staff.ts"; import { chiefLevel, readTeamRolesWith } from "./chief-level.ts"; import { defaultBotRefusal, ensureDefaultBot } from "./default-bot.ts";
import { buildRecall, recallRooms, recallThreadIds, withRecalled } from "./recall.ts";
@@ -1381,7 +1381,7 @@ const mcpOAuth = new McpOAuthManager({
const teamConnections = createTeamConnectionsHost({ team: CLOUD_TEAM, dataDir: DATA_DIR, cfg: () => cfg, adminOrigin: CLOUD_HOME?.adminOrigin ?? null, harnessUrl: `http://127.0.0.1:${PORT}`, audienceOf: teamHost.audienceOf,
requester: (threadId, generation) => actingPeople.requester(threadId, generation), personName: (person) => teamHost.personName(person), roster: () => (teamOwners.people?.list() ?? []).map((member) => ({ person: personKey({ id: "", email: member.email }), email: member.email, role: member.role })),
mint: (capability) => mintInternalCapability({ ...capability, depth: 0, kind: "connectors", skillAuthoring: false, createdBots: 0, openedThreads: 0 }), mcpOAuth, isOwnerLive: (owner) => sessions.isLive(owner) || isCardOwnerLive(store, owner), onSettled: (name, phase, owner) => mcpSignInCards.settled(name, phase, owner), onRefresh: (person, name, outcome) => connectionHealth.refreshed(person, name, outcome), onPersonChanged: (person, kind, id) => connectionHealth.connectedAgain({ kind, id, person }),
- botMcp: (bot) => mcpServersHost.mounted(bot), brokerUrl: () => (CLOUD_TEAM ? cloudConnectedAppsBrokerUrl() || null : null), composio }); teamConnections.primeApps(); const connectionHealth = createConnectionHealthHost({ dataDir: CLOUD_TEAM ? DATA_DIR : null, mcpServers: () => cfg.mcpServers ?? {}, mcpOAuth, connections: teamConnections, bots: () => store.bots, botServers: (bot) => Object.keys(mcpServersHost.mounted(bot)), roster: () => teamOwners.people?.list() ?? [], personKey: (email) => personKey({ id: "", email }), personName: (email) => teamHost.people.profile(personKey({ id: "", email })).name || null, test: (name, signal) => mcpConfig.test(name, { signal, person: () => null }), asleep: () => cloudPowerNow()?.sleeping() ?? false, wokeAt: () => cloudPowerNow()?.sleptUntil() ?? null }); if (CLOUD_TEAM) connectionHealth.start();
+ botMcp: (bot) => mcpServersHost.mounted(bot), brokerUrl: () => (CLOUD_TEAM ? cloudConnectedAppsBrokerUrl() || null : null), fullAccess: fullAccessForSource, composio }); teamConnections.primeApps(); const connectionHealth = createConnectionHealthHost({ dataDir: CLOUD_TEAM ? DATA_DIR : null, mcpServers: () => cfg.mcpServers ?? {}, mcpOAuth, connections: teamConnections, bots: () => store.bots, botServers: (bot) => Object.keys(mcpServersHost.mounted(bot)), roster: () => teamOwners.people?.list() ?? [], personKey: (email) => personKey({ id: "", email }), personName: (email) => teamHost.people.profile(personKey({ id: "", email })).name || null, test: (name, signal) => mcpConfig.test(name, { signal, person: () => null }), asleep: () => cloudPowerNow()?.sleeping() ?? false, wokeAt: () => cloudPowerNow()?.sleptUntil() ?? null }); if (CLOUD_TEAM) connectionHealth.start();
// OpenCode reads provider keys (ANTHROPIC_API_KEY, OPENAI_API_KEY, …) from its environment. Wired before the first catalog probe below.
let openCodeOrganisationManaged = (): boolean => false;
const openCodeKeysAllowed = (): boolean => openCodeProviderKeysAllowed({
@@ -14460,10 +14460,10 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {
: [];
if (proactive.fence.refusesConnectorCall(currentSender, internalCapability.threadId, body)) return refuseOutbound(READ_AND_DRAFT_REFUSAL);
const scopeRefusal = managedPolicy.appsCallRefusal(connectorCalls, serviceSlugs) ?? await teamConnections.callRefusal(internalCapability, connectorCalls); if (scopeRefusal) return refuseOutbound(scopeRefusal);
- const sandboxCall = rpc?.method === "tools/call" && typeof rpcParams?.name === "string" && APP_SANDBOX_TOOLS.includes(rpcParams.name);
- const sandboxOn = (bot: Pick<BotRecord, "appSandbox">) => sandboxCall && bot.appSandbox === true; // the apps' sandbox runs code only while the bot's switch is on
- if (sandboxCall && currentSender.connectorTools !== undefined && !sandboxOn(currentSender)) return refuseOutbound(APP_SANDBOX_REFUSAL);
- const access = connectorAccessDecision(currentSender.connectorScopes, sandboxOn(currentSender) ? [] : connectorCalls, serviceSlugs);
+ // A room turn can run at a Chief's delegated level, which only the room handoff carries.
+ const sendsFreely = () => roomTurnLevels.forRequest(internalCapability.threadId, internalCapability.botId,
+ () => sourceApprovalMode(internalCapability.botId, internalCapability.threadId)) === "full"; const sandbox = appSandboxRule(body, sendsFreely);
+ const access = connectorAccessDecision(currentSender.connectorScopes, sandbox.open() ? [] : connectorCalls, serviceSlugs);
if (!access.ok) {
const described = describeTool(access.slug);
const appName = described.app ?? access.toolkit;
@@ -14474,10 +14474,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {
return refuseOutbound(connectorScopeRefusalText(call, access.reason, currentSender.name, appName, described.label));
}
const opaque = connectorCalls.some(call => call.slug === "COMPOSIO_PROXY_EXECUTE");
- if (opaque && currentSender.connectorTools !== undefined && !sandboxOn(currentSender)) return refuseOutbound("OpenMausBot cannot verify this code against this bot's tool grants. Use a direct app tool.");
- // A room turn can run at a Chief's delegated level, which only the room handoff carries.
- const sendsFreely = () => roomTurnLevels.forRequest(internalCapability.threadId, internalCapability.botId,
- () => sourceApprovalMode(internalCapability.botId, internalCapability.threadId)) === "full";
+ if (opaque && currentSender.connectorTools !== undefined && !sandbox.open()) return refuseOutbound(sandbox.refusal);
const fullAccess = outboundTool !== null && sendsFreely();
const held: OutboundHoldAnswer = outboundTool
? await outboundHold.hold({
@@ -14504,8 +14501,8 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {
requireActiveInternalCapability();
const fresh = store.bot(internalCapability.botId);
if (!fresh || fresh.composio === false || !composio.configured(cfg) || managedPolicy.appsCallRefusal(connectorCalls, serviceSlugs)) refuseDispatch("Connected apps were disabled while this call waited.");
- const freshAccess = connectorAccessDecision(fresh.connectorScopes, sandboxOn(fresh) ? [] : connectorCalls, serviceSlugs);
- if (!freshAccess.ok || (opaque && fresh.connectorTools !== undefined && !sandboxOn(fresh)) ||
+ const freshAccess = connectorAccessDecision(fresh.connectorScopes, sandbox.open() ? [] : connectorCalls, serviceSlugs);
+ if (!freshAccess.ok || (opaque && fresh.connectorTools !== undefined && !sandbox.open()) ||
(call.kind === "tools" && !evaluateConnectorTools(call.names, fresh.connectorTools, serviceSlugs).allowed) ||
(call.kind === "unrecognized" && fresh.connectorTools !== undefined)) {
refuseDispatch("This bot's connected-app permissions changed. The call was not run.");
diff --git a/server/routes/bot-patch.ts b/server/routes/bot-patch.ts
index 491d3155cf..bbbff5621b 100644
--- a/server/routes/bot-patch.ts
+++ b/server/routes/bot-patch.ts
@@ -287,11 +287,6 @@ export function createBotPatchRoutes(deps: BotPatchRouteDeps): RouteHandler {
if (body.voiceNoteEveryReply !== null && typeof body.voiceNoteEveryReply !== "boolean") return json(res, 400, { error: "voiceNoteEveryReply must be true, false or null" });
patch.voiceNoteEveryReply = body.voiceNoteEveryReply ?? undefined;
}
- // Lets the bot run code that reaches every connected app: an admin decision, kept off a member editor's list.
- if (body.appSandbox !== undefined) {
- if (typeof body.appSandbox !== "boolean") return json(res, 400, { error: "appSandbox must be true or false" });
- patch.appSandbox = body.appSandbox;
- }
// Spends the Cloud plan's monthly X research calls: an admin decision too.
if (body.xResearch !== undefined) {
if (typeof body.xResearch !== "boolean") return json(res, 400, { error: "xResearch must be true or false" });
@@ -603,7 +598,6 @@ export function createBotPatchRoutes(deps: BotPatchRouteDeps): RouteHandler {
if (loosened.includes("managedSections") && auth.kind === "loopback" && !DESKTOP_MANAGED && store.bots.some(bot => bot.busy)) {
return json(res, 409, userError("serverError.department.stopBots"));
}
- if (body.appSandbox === true && existingBot?.appSandbox !== true) loosened.push("appSandbox");
if (section !== undefined && sectionKey(existingBot?.section) !== sectionKey(section)) loosened.push("section");
if (Array.isArray(patch.alwaysAllow) && patch.alwaysAllow.some((key) => !(existingBot?.alwaysAllow ?? []).includes(key))) {
loosened.push("alwaysAllow");
diff --git a/server/trust-controls.e2e.test.ts b/server/trust-controls.e2e.test.ts
index 6be778b9d7..c90bc512d0 100644
--- a/server/trust-controls.e2e.test.ts
+++ b/server/trust-controls.e2e.test.ts
@@ -19,6 +19,7 @@ let draftBot: any;
let draftHelper: any;
let outboundPolicyBot: any;
let noRuleBot: any;
+let sandboxBot: any;
const gmailDrafts = new Map<string, Record<string, unknown>>();
let brokerOrigin = "";
const relayed: unknown[] = [];
@@ -112,11 +113,14 @@ beforeAll(async () => {
const noRuleCreated = await fetch(fixture.info.url + "/api/bots", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ name: "Full no sending rule fixture" }) });
expect(noRuleCreated.status).toBe(201);
noRuleBot = (await noRuleCreated.json() as any).bot;
+ const sandboxCreated = await fetch(fixture.info.url + "/api/bots", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ name: "Full sandbox fixture" }) });
+ expect(sandboxCreated.status).toBe(201);
+ sandboxBot = (await sandboxCreated.json() as any).bot;
await waitForExit(fixture.child, { signal: "SIGTERM" });
const botsFile = join(fixture.info.dataDir, "bots.json");
const bots = JSON.parse(readFileSync(botsFile, "utf8"));
const saved = bots.find((row: any) => row.id === fullBot.id);
- for (const full of [saved, ...[draftBot, draftHelper, outboundPolicyBot, noRuleBot].map(bot => bots.find((row: any) => row.id === bot.id))]) {
+ for (const full of [saved, ...[draftBot, draftHelper, outboundPolicyBot, noRuleBot, sandboxBot].map(bot => bots.find((row: any) => row.id === bot.id))]) {
full.approvalMode = "full";
full.autoApprove = false;
for (const task of full.tasks) { task.approvalMode = "full"; task.autoApprove = false; }
@@ -519,28 +523,31 @@ it("still asks before arbitrary workbench code under Send without asking", async
expect(relayed).toHaveLength(before);
});
-it("runs sandbox code for a bot with app grants only after its sandbox switch is on, never inside a batch, and still asks", async () => {
- const b = await bot("Sandbox switch");
+it("runs sandbox code for a bot with app grants only at Full access, only by a direct call", async () => {
+ const b = sandboxBot;
expect((await api("PATCH", `/api/bots/${b.id}`, { connectorTools: { gmail: { tools: "*" } } })).status).toBe(200);
const token = await mint(b.id, b.threadId);
const before = relayed.length;
const code = { code_to_execute: "print(1)" };
const wrapped = () => relay(token, "COMPOSIO_MULTI_EXECUTE_TOOL", { tools: [{ tool_slug: "COMPOSIO_REMOTE_WORKBENCH", arguments: code }] });
- const off = await relay(token, "COMPOSIO_REMOTE_WORKBENCH", code);
- expect(off.body.result.isError).toBe(true);
- expect(JSON.stringify(off.body.result)).toContain("Run code in the apps' sandbox");
- expect((await wrapped()).body.result.isError).toBe(true);
- expect((await api("PATCH", `/api/bots/${b.id}`, { appSandbox: "yes" })).status).toBe(400);
- expect((await api("PATCH", `/api/bots/${b.id}`, { appSandbox: true }, member)).status).toBe(403);
- expect((await api("PATCH", `/api/bots/${b.id}`, { appSandbox: true })).status).toBe(200);
- const held = relay(token, "COMPOSIO_REMOTE_WORKBENCH", code);
- const card = await pending(b.threadId);
- expect(relayed).toHaveLength(before);
- await api("POST", `/api/threads/${b.threadId}/respond`, { requestId: card.card.requestId, behavior: "allow" });
- expect((await held).body.result.isError).not.toBe(true);
+ const cardCount = (await cards(b.threadId)).filter(row => row.card?.outboundRequest).length;
+ expect((await relay(token, "COMPOSIO_REMOTE_WORKBENCH", code)).body.result.isError).not.toBe(true);
+ expect(relayed).toHaveLength(before + 1);
+ expect((await cards(b.threadId)).filter(row => row.card?.outboundRequest), "Full access runs it without a card").toHaveLength(cardCount);
+ const batched = await wrapped();
+ expect(batched.body.result.isError).toBe(true);
+ expect(JSON.stringify(batched.body.result)).toContain("only at Full access");
expect(relayed).toHaveLength(before + 1);
- expect((await wrapped()).body.result.isError).toBe(true);
+ const low = await bot("Sandbox below Full access");
+ expect((await api("PATCH", `/api/bots/${low.id}`, { connectorTools: { gmail: { tools: "*" } } })).status).toBe(200);
+ const lowToken = await mint(low.id, low.threadId);
+ for (const name of ["COMPOSIO_REMOTE_WORKBENCH", "COMPOSIO_REMOTE_BASH_TOOL"]) {
+ const below = await relay(lowToken, name, { command: "echo 1" });
+ expect(below.body.result.isError).toBe(true);
+ expect(JSON.stringify(below.body.result)).toContain("only at Full access");
+ }
expect(relayed).toHaveLength(before + 1);
+ expect((await cards(low.threadId)).filter(row => row.card?.outboundRequest), "refused outright, never asked").toHaveLength(0);
});
it("tells a scoped bot its multi-execute arguments were unreadable, not that it lacks access", async () => {
diff --git a/shared/wire.ts b/shared/wire.ts
index 719087120d..040adb47ea 100644
--- a/shared/wire.ts
+++ b/shared/wire.ts
@@ -348,9 +348,6 @@ export interface WireBot extends DefaultBotFields, BotAccessFields {
* actions), which spend the workspace's treg balance.
* Absent/false = off: the person turns it on per bot. */
xResearch?: boolean;
- /** Whether this bot may run code in the connected apps' sandbox (Composio's workbench and bash tools), for jobs such as
- * uploading a file to Google Drive. Absent/false = off; a bot with no per-app tool grants already has every tool. */
- appSandbox?: boolean;
/** Whether this bot uses native memory. Absent/true = enabled. */
memoryEnabled?: boolean;
/** Queue direct-chat messages behind outstanding delegated work. */
diff --git a/src/components/bot-settings/AccessSection.test.ts b/src/components/bot-settings/AccessSection.test.ts
index 5c863aaab7..f8cd3b3fa4 100644
--- a/src/components/bot-settings/AccessSection.test.ts
+++ b/src/components/bot-settings/AccessSection.test.ts
@@ -14,14 +14,12 @@ const fixture = vi.hoisted(() => ({
instances: [] as unknown[],
capabilities: { host: { homeDir: undefined } as { homeDir: undefined; platform?: string }, localComputer: { available: false, reasonCode: "unsupported" } },
apps: { phase: "loading", apps: [], connectedSlugs: [] } as import("./useBotApps").BotApps,
- ownerOrAdmin: true as boolean | null,
}));
vi.mock("@/state/store", async (importOriginal) => {
const original = await importOriginal<typeof import("@/state/store")>();
return { ...original, useStore: () => ({ state: { ...original.initialState, config: fixture.config ?? original.initialState.config, instances: fixture.instances as typeof original.initialState.instances }, dispatch: fixture.dispatch }) };
});
// The connected-apps list (Composio accounts plus the native Email connection) is seeded per test.
-vi.mock("@/lib/use-owner-or-admin", () => ({ useOwnerOrAdmin: () => fixture.ownerOrAdmin }));
vi.mock("./useBotApps", async (importOriginal) => ({
...await importOriginal<typeof import("./useBotApps")>(),
useBotApps: () => fixture.apps,
@@ -43,7 +41,6 @@ beforeEach(() => {
vi.stubGlobal("window", {});
fixture.dispatch.mockReset();
fixture.mcpError = false;
- fixture.ownerOrAdmin = true;
fixture.servers = null;
fixture.config = null;
fixture.instances = [];
@@ -424,31 +421,6 @@ describe("AccessSection per-app scopes", () => {
const html = render(makeBot({ connectorScopes: { apps: { gmail: "write" } } }));
expect(html).not.toContain("Limit this bot to specific apps");
});
-
- it("offers the sandbox switch, off by default, only to a bot with its own app grants", () => {
- fixture.apps = { phase: "ready", connectedSlugs: ["gmail"], apps: [app("gmail", "Gmail")] };
- const SANDBOX = /aria-label="Run code in the apps&#x27; sandbox"[^>]*aria-checked="(true|false)"|aria-checked="(true|false)"[^>]*aria-label="Run code in the apps&#x27; sandbox"/;
- const off = render(makeBot({ connectorTools: { gmail: { tools: "*" } } }));
- expect(off.match(SANDBOX)?.slice(1).find(Boolean)).toBe("false");
- expect(off).toContain("Off: this bot uses only the app tools above.");
- const on = render(makeBot({ connectorTools: { gmail: { tools: "*" } }, appSandbox: true }));
- expect(on.match(SANDBOX)?.slice(1).find(Boolean)).toBe("true");
- expect(on).toContain("below Full access it asks you first each time.");
- expect(render(makeBot())).not.toContain("data-app-sandbox");
- });
-
- it("keeps an enabled sandbox switch while the app list is unknown or apps are off, and hides it from editors", () => {
- const grants = { connectorTools: { gmail: { tools: "*" as const } } };
- fixture.apps = { phase: "unknown", apps: [], connectedSlugs: [] };
- expect(render(makeBot({ ...grants, appSandbox: true }))).toContain("data-app-sandbox");
- expect(render(makeBot(grants))).not.toContain("data-app-sandbox");
- fixture.apps = { phase: "ready", connectedSlugs: ["gmail"], apps: [app("gmail", "Gmail")] };
- const appsOff = { ...makeDerived(), connectedAppsEnabled: false };
- expect(render(makeBot({ ...grants, appSandbox: true, composio: false }), appsOff)).toContain("data-app-sandbox");
- expect(render(makeBot({ ...grants, composio: false }), appsOff)).not.toContain("data-app-sandbox");
- fixture.ownerOrAdmin = false;
- expect(render(makeBot({ ...grants, appSandbox: true }))).not.toContain("data-app-sandbox");
- });
});
describe("AccessSection parts", () => {
diff --git a/src/components/bot-settings/AccessSection.tsx b/src/components/bot-settings/AccessSection.tsx
index 3a40782718..d42382cce4 100644
--- a/src/components/bot-settings/AccessSection.tsx
+++ b/src/components/bot-settings/AccessSection.tsx
@@ -24,7 +24,6 @@ import { ToolBudgetLine } from "./ToolBudgetLine";
import { useCloudPlan } from "../ProIntroduction";
import { xResearchAction } from "@/lib/cloud-plan";
import { useBotApps } from "./useBotApps";
-import { useOwnerOrAdmin } from "@/lib/use-owner-or-admin";
import {
classifyConnectorTool,
connectorServiceAccess,
@@ -507,19 +506,6 @@ function ResearchCard({ bot, patch }: { bot: Bot; patch: (patch: { xResearch: bo
);
}
-/** Lets a bot with per-app grants run code in the connected apps' sandbox, which some app jobs need (a Google Drive upload). */
-function AppSandboxRow({ on, onChange }: { on: boolean; onChange: (on: boolean) => void }) {
- return (
- <div className="mt-3 flex items-center justify-between gap-4 border-t border-hairline/40 pt-3">
- <div>
- <div className="text-[14px] font-medium text-ink">{t("botAccess.apps.sandbox.title")}</div>
- <div className="mt-0.5 text-[13px] text-ink-secondary">{t(on ? "botAccess.apps.sandbox.on" : "botAccess.apps.sandbox.off")}</div>
- </div>
- <Switch checked={on} aria-label={t("botAccess.apps.sandbox.title")} onClick={() => onChange(!on)} data-app-sandbox="" />
- </div>
- );
-}
-
function RecordStepsRow({ on, browserOn, myChrome, onChange }: { on: boolean; browserOn: boolean; myChrome: boolean; onChange: (on: boolean) => void }) {
return (
<div className="mt-3 flex items-center justify-between gap-4 border-t border-hairline/40 pt-3">
@@ -712,7 +698,6 @@ export function AccessSection({
// The same list the Vault tab shows: Composio's connected accounts plus the native Email connection.
const apps = useBotApps(bot);
const inventoryReady = apps.phase === "ready";
- const ownerOrAdmin = useOwnerOrAdmin();
const connectedSlugs = apps.connectedSlugs;
const appLabels = Object.fromEntries(apps.apps.map((app) => [app.slug, app.label]));
@@ -784,11 +769,6 @@ export function AccessSection({
<ConnectorToolsGrants bot={bot} patch={patch} slugs={connectedSlugs} />
</>
)}
- {/* Only an owner or admin may change it (the server refuses an editor). An enabled switch stays shown while the
- app list is unknown or connected apps are off, so it can always be turned off. */}
- {ownerOrAdmin === true && bot.connectorTools !== undefined && (bot.appSandbox === true || (connectedAppsEnabled && inventoryReady)) && (
- <AppSandboxRow on={bot.appSandbox === true} onChange={(appSandbox) => patch({ appSandbox })} />
- )}
{connectedAppsEnabled && connectedAppsConfigured && (
<button
type="button"
diff --git a/src/components/bot-settings/useBotSettingsDerived.ts b/src/components/bot-settings/useBotSettingsDerived.ts
index 5bc03bb13d..d10ed5bb3c 100644
--- a/src/components/bot-settings/useBotSettingsDerived.ts
+++ b/src/components/bot-settings/useBotSettingsDerived.ts
@@ -34,7 +34,6 @@ export type BotPatch = Partial<
| "replyStyle"
| "memoryEnabled"
| "xResearch"
- | "appSandbox"
| "voice"
| "chiefOfStaff"
| "managedSections"
diff --git a/src/locales/en.json b/src/locales/en.json
index 0cf04c3a07..676994cb67 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -6840,9 +6840,6 @@
"botAccess.apps.allow": "Allow this bot to use connected apps",
"botAccess.apps.connectFirst": "Connect apps in App Settings first",
"botAccess.apps.modelUnsupportedShort": "This model cannot use connected apps",
- "botAccess.apps.sandbox.title": "Run code in the apps' sandbox",
- "botAccess.apps.sandbox.on": "This bot can run code with your connected apps, for jobs like uploading a file to Google Drive. That code can reach any connected app; below Full access it asks you first each time.",
- "botAccess.apps.sandbox.off": "Off: this bot uses only the app tools above. Turn on for jobs that need code, like uploading a file to Google Drive.",
"botAccess.browser.title": "Browser",
"botAccess.browser.windowsUnavailable": "Not available on this Windows machine yet: install the browser with `openmausbot browser install`.",
"botAccess.browser.disabledInSettings": "The built-in browser is switched off under App Settings → Devices.",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index c410dbd86c..6ccccd5d3e 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -6547,9 +6547,6 @@
"botAccess.apps.none": "Nenhum app conectado tem ferramentas permitidas. Expanda um app para dar acesso a ferramentas.",
"botAccess.apps.enabled": "Permita que este bot use seus apps conectados, como Gmail, Calendar e Slack.",
"botAccess.apps.disabled": "Mantenha este bot sem acesso aos apps conectados.",
- "botAccess.apps.sandbox.title": "Executar código no sandbox dos apps",
- "botAccess.apps.sandbox.on": "Este bot pode executar código com seus apps conectados, para tarefas como enviar um arquivo ao Google Drive. Esse código alcança qualquer app conectado; abaixo de “Acesso total”, ele pede sua permissão a cada vez.",
- "botAccess.apps.sandbox.off": "Desligado: este bot usa só as ferramentas de apps acima. Ligue para tarefas que precisam de código, como enviar um arquivo ao Google Drive.",
"botAccess.apps.allow": "Permitir que este bot use apps conectados",
"botAccess.apps.connectFirst": "Conecte primeiro os apps nas Configurações do app",
"botAccess.apps.modelUnsupportedShort": "Este modelo não pode usar apps conectados",
diff --git a/src/state/bot-patch-queue.ts b/src/state/bot-patch-queue.ts
index e1a7d9a2b3..db30ec53ec 100644
--- a/src/state/bot-patch-queue.ts
+++ b/src/state/bot-patch-queue.ts
@@ -28,7 +28,6 @@ export type BotUpdatePatch = Partial<
| "voiceNotes"
| "voiceNoteEveryReply"
| "xResearch"
- | "appSandbox"
| "pinned"
| "hidden"
| "sidebarHidden"
diff --git a/src/state/store.tsx b/src/state/store.tsx
index d8ff655d27..90b09a9b2f 100644
--- a/src/state/store.tsx
+++ b/src/state/store.tsx
@@ -309,7 +309,7 @@ export interface Bot extends DefaultBotFields, Pick<WireBot, "mascotFaceColor" |
speakReplies?: boolean;
replyStyle?: import("../../shared/wire").WireBot["replyStyle"];
voice?: string;
- voiceNotes?: boolean; xResearch?: boolean; appSandbox?: boolean; voiceNoteEveryReply?: boolean | null; // null or absent: follows the Voice setting
+ voiceNotes?: boolean; xResearch?: boolean; voiceNoteEveryReply?: boolean | null; // null or absent: follows the Voice setting
memoryEnabled?: boolean;
pinned?: boolean;
hidden?: boolean;