Skip to content

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

Only a personal installation may adopt an earlier Composio user

milind-sonie14cad81c1e9
diff --git a/docs/composio.md b/docs/composio.md
index 0f7157ac7c..d4978dd8ef 100644
--- a/docs/composio.md
+++ b/docs/composio.md
@@ -76,7 +76,7 @@ COMPOSIO_API_KEY=ak_your_project_key pnpm dev:server
The browser-only development UI can also save a key to the owner-only `~/.openmausbot/config.json` file. Using the environment variable is preferred for headless and shared development machines.
-OpenMausBot creates a stable random user identifier for the installation, stores the returned Session identifier, and reuses that Session across launches. No Gmail, GitHub, Slack, or other provider tokens are stored by OpenMausBot; Composio owns their connection lifecycle.
+OpenMausBot creates a stable random user identifier for the installation, stores the returned Session identifier, and reuses that Session across launches. A fresh personal installation that connects a project key uses the Composio user of an earlier OpenMausBot installation in that project when there is exactly one such user and it still has a live connection, so the apps connected there come back after a reinstall or on another computer. A Team Cloud never does this and does not even list the project's accounts, because every member's bots would then get that person's apps. No Gmail, GitHub, Slack, or other provider tokens are stored by OpenMausBot; Composio owns their connection lifecycle.
Sessions created by older OpenMausBot versions are upgraded in place by creating a multi-account Session for the same stable Composio user. Connected accounts belong to that user, so existing grants remain available while the new Session adds explicit multi-account routing. Each toolkit is capped at five usable accounts.
@@ -84,7 +84,7 @@ Sessions created by older OpenMausBot versions are upgraded in place by creating
Yes. Gmail, Google Calendar, Google Drive, and the other Google toolkits can each hold multiple labeled authorizations, and Slack can hold multiple labeled workspace/account authorizations. Accounts are scoped to the OpenMausBot installation's stable Composio user and appear by alias and connected-account ID in **Connected apps**.
-If a provider or restricted Composio project policy prevents another authorization, the safe fallback is a separate OpenMausBot installation/configuration with its own Composio user. Re-authorizing the same single-account Session is not a safe workaround: it can change which grant is selected. Do not share raw provider tokens or place them in bot prompts.
+If a provider or restricted Composio project policy prevents another authorization, the safe fallback is a separate OpenMausBot installation/configuration using its own Composio project key, which gives it its own Composio user; a second personal installation on the same project key picks up the earlier installation's user instead. Re-authorizing the same single-account Session is not a safe workaround: it can change which grant is selected. Do not share raw provider tokens or place them in bot prompts.
The hosted/managed connected-apps broker exposes the same account-aware response shape and account-specific removal routes as the self-hosted project-key mode; it does not send broker or provider credentials to the renderer.
diff --git a/server/composio-reuse.test.ts b/server/composio-reuse.test.ts
index aedfbab9fb..9e2c48d227 100644
--- a/server/composio-reuse.test.ts
+++ b/server/composio-reuse.test.ts
@@ -1,14 +1,16 @@
-// A fresh installation that connects a Composio project an earlier installation used picks up that installation's
-// Composio user, so the apps connected there come back without connecting each one again.
+// A fresh personal installation that connects a Composio project an earlier installation used picks up that installation's
+// Composio user, so the apps connected there come back without connecting each one again. A Team Cloud never looks.
import { createServer, type Server } from "node:http";
import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { prepareProjectSession } from "./composio.ts";
import { forgetProjectAuthConfigs } from "./composio-project.ts";
+import { createConfigRoutes, type ConfigRouteDeps } from "./routes/config.ts";
let api: Server;
let accounts: Array<Record<string, unknown>> = [];
let accountsDown = false;
+let sessionsRefused = false;
const accountQueries: URLSearchParams[] = [];
const sessionUsers: string[] = [];
@@ -33,6 +35,7 @@ beforeAll(async () => {
}
if (req.method === "POST" && url.pathname === "/api/v3.1/tool_router/session") {
sessionUsers.push(body.user_id);
+ if (sessionsRefused) return json(503, { error: { message: "sessions unavailable" } });
return json(201, {
session_id: `trs_${sessionUsers.length}`,
mcp: { type: "http", url: `https://app.composio.dev/tool_router/v3/trs_${sessionUsers.length}/mcp` },
@@ -54,12 +57,14 @@ beforeEach(() => {
forgetProjectAuthConfigs();
accounts = [];
accountsDown = false;
+ sessionsRefused = false;
accountQueries.length = 0;
sessionUsers.length = 0;
});
const account = (user_id: string, slug: string, status = "ACTIVE") => ({ id: `ca_${user_id}_${slug}`, user_id, status, toolkit: { slug } });
const NEW_USER = /^openmausbot_[0-9a-f-]{36}$/u;
+const prepareFresh = () => prepareProjectSession("ak_reuse", undefined, undefined, { reuseEarlierUser: true });
describe("a fresh installation connecting a project an earlier installation used", () => {
it("keeps the earlier installation's Composio user, so its connected apps come back", async () => {
@@ -69,7 +74,7 @@ describe("a fresh installation connecting a project an earlier installation used
account("openmausbot_earlier", "slack"),
account("someone_elses_app", "notion"),
];
- const prepared = await prepareProjectSession("ak_reuse");
+ const prepared = await prepareFresh();
expect(prepared.userId).toBe("openmausbot_earlier");
expect(sessionUsers).toEqual(["openmausbot_earlier"]);
expect(accountQueries.length).toBe(2);
@@ -78,14 +83,14 @@ describe("a fresh installation connecting a project an earlier installation used
it("reads only a few pages, and starts a new user when the project is too big to tell", async () => {
accounts = Array.from({ length: 30 }, (_, n) => account("openmausbot_earlier", `app${n}`));
- const prepared = await prepareProjectSession("ak_reuse");
+ const prepared = await prepareFresh();
expect(prepared.userId).toMatch(NEW_USER);
expect(accountQueries.length).toBe(4);
});
it("starts a new user when the project has no earlier installation's live connections", async () => {
accounts = [account("someone_elses_app", "notion"), account("openmausbot_gone", "gmail", "EXPIRED")];
- const prepared = await prepareProjectSession("ak_reuse");
+ const prepared = await prepareFresh();
expect(prepared.userId).toMatch(NEW_USER);
});
@@ -96,28 +101,83 @@ describe("a fresh installation connecting a project an earlier installation used
account("someone_elses_app", "notion"),
account("someone_elses_app", "slack"),
];
- const prepared = await prepareProjectSession("ak_reuse");
+ const prepared = await prepareFresh();
expect(prepared.userId).toMatch(NEW_USER);
expect(accountQueries.length).toBe(1);
});
it("starts a new user when another installation's connections have only expired", async () => {
accounts = [account("openmausbot_earlier", "gmail"), account("openmausbot_other", "github", "EXPIRED")];
- const prepared = await prepareProjectSession("ak_reuse");
+ const prepared = await prepareFresh();
expect(prepared.userId).toMatch(NEW_USER);
});
it("still connects, as a new user, when Composio can't list the project's connections", async () => {
accountsDown = true;
- const prepared = await prepareProjectSession("ak_reuse");
+ const prepared = await prepareFresh();
expect(prepared.userId).toMatch(NEW_USER);
expect(sessionUsers).toEqual([prepared.userId]);
});
it("never looks for another user when this installation already has one", async () => {
accounts = [account("openmausbot_earlier", "gmail")];
- const prepared = await prepareProjectSession("ak_reuse", { userId: "openmausbot_mine" });
+ const prepared = await prepareProjectSession("ak_reuse", { userId: "openmausbot_mine" }, undefined, { reuseEarlierUser: true });
expect(prepared.userId).toBe("openmausbot_mine");
expect(accountQueries).toEqual([]);
});
});
+
+describe("who may look for an earlier installation's user", () => {
+ const earlier = () => { accounts = [account("openmausbot_earlier", "gmail"), account("openmausbot_earlier", "slack")]; };
+
+ // Composio refuses the Session, so the route answers before it saves anything.
+ async function saveKeyThroughConfigRoute(teamCloud: boolean) {
+ sessionsRefused = true;
+ const replies: Array<{ status: number; body: unknown }> = [];
+ const deps = {
+ teamCloud,
+ cfg: {},
+ hostedModels: false,
+ cloudHome: false,
+ store: { bots: [] },
+ browserRuntime: { heldBy: () => false },
+ providerConfigBusy: { get: () => false, set: () => undefined },
+ localVmModeChangeBusy: { set: () => undefined },
+ computerProviderConfigTransitions: { add: () => undefined, delete: () => undefined },
+ } as unknown as ConfigRouteDeps;
+ await createConfigRoutes(deps)({
+ req: {},
+ res: {},
+ url: new URL("http://host/api/config"),
+ path: "/api/config",
+ method: "PUT",
+ auth: {},
+ json: (_res: unknown, status: number, body: unknown) => { replies.push({ status, body }); },
+ readBody: async () => ({ composio: { apiKey: "ak_reuse" } }),
+ } as unknown as Parameters<ReturnType<typeof createConfigRoutes>>[0]);
+ return replies;
+ }
+
+ it("does not look unless the caller asks, so setting up a Session later never adopts anyone", async () => {
+ earlier();
+ const prepared = await prepareProjectSession("ak_reuse");
+ expect(prepared.userId).toMatch(NEW_USER);
+ expect(accountQueries).toEqual([]);
+ });
+
+ it("makes no account listing on a Team Cloud, and starts a new user", async () => {
+ earlier();
+ const replies = await saveKeyThroughConfigRoute(true);
+ expect(replies.map((reply) => reply.status)).toEqual([400]);
+ expect(accountQueries).toEqual([]);
+ expect(sessionUsers).toHaveLength(1);
+ expect(sessionUsers[0]).toMatch(NEW_USER);
+ });
+
+ it("looks on a personal installation, and keeps the earlier user", async () => {
+ earlier();
+ await saveKeyThroughConfigRoute(false);
+ expect(accountQueries.length).toBeGreaterThan(0);
+ expect(sessionUsers).toEqual(["openmausbot_earlier"]);
+ });
+});
diff --git a/server/composio-session.ts b/server/composio-session.ts
index 2708d0ff71..37defb7d65 100644
--- a/server/composio-session.ts
+++ b/server/composio-session.ts
@@ -186,6 +186,7 @@ export async function prepareProjectSession(
apiKey: string,
current?: { apiKey?: string; userId?: string; sessionId?: string },
knownAuthConfigs?: AuthConfigMap,
+ options: { reuseEarlierUser?: boolean } = {},
): Promise<{ apiKey: string; userId: string; sessionId: string }> {
const trimmed = apiKey.trim();
if (!trimmed) throw new Error("Enter a Composio project API key");
@@ -207,8 +208,8 @@ export async function prepareProjectSession(
priorUserId = existing?.config?.user_id ?? priorUserId;
}
- // A fresh installation keeps the Composio user an earlier one connected apps with in this project.
- const userId = priorUserId ?? (await earlierInstallationUser(trimmed)) ?? `openmausbot_${randomUUID()}`;
+ // Security: the earlier user holds another installation's apps, so only a caller that says this server is one person's may look.
+ const userId = priorUserId ?? (options.reuseEarlierUser ? await earlierInstallationUser(trimmed) : null) ?? `openmausbot_${randomUUID()}`;
const sessionId = await createProjectSession(trimmed, userId, authConfigs);
return { apiKey: trimmed, userId, sessionId };
}
diff --git a/server/index.ts b/server/index.ts
index 2aee79bbd3..256007ab56 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -12392,7 +12392,7 @@ const postiz = createPostiz({ cfg: () => cfg, mcpOAuth, persistMcpServers: persi
store, cfg, registry, sessions, browserCleanup, browserLive, browserRuntime, usedBrowserSessions, decider,
sharedComputers, sharedComputerControl, closeBrowser, browserEngineSwitched,
hostedModels: Boolean(hostedModels),
- cloudHome: Boolean(CLOUD_HOME),
+ cloudHome: Boolean(CLOUD_HOME), teamCloud: CLOUD_TEAM !== null,
lendingEnabled: () => lendingEnabled() || ownerLends(), providerConfigs, localVmIdleMs, localVmIdles, localVmActiveThreads, localVmLifecycleBusy,
localVmImageBusy: { get: () => localVmImageBusy },
localVmModeChangeBusy: { set: (busy) => { localVmModeChangeBusy = busy; } },
diff --git a/server/routes/config.ts b/server/routes/config.ts
index 96c4f349e5..07abb6a270 100644
--- a/server/routes/config.ts
+++ b/server/routes/config.ts
@@ -73,6 +73,8 @@ export interface ConfigRouteDeps {
sharedComputerControl: Pick<SharedComputerControl, "close">;
hostedModels: boolean;
cloudHome: boolean;
+ /** Security: a Team Cloud never takes over another installation's Composio user, since every member's bots would then get that person's apps. */
+ teamCloud: boolean;
lendingEnabled(): boolean;
providerConfigs(): InstanceConfigMap;
localVmIdleMs(): number;
@@ -107,7 +109,7 @@ export interface ConfigRouteDeps {
export function createConfigRoutes(deps: ConfigRouteDeps): RouteHandler {
const {
store, cfg, registry, sessions, browserCleanup, browserLive, browserRuntime, usedBrowserSessions, decider,
- closeBrowser, browserEngineSwitched, sharedComputers, sharedComputerControl, hostedModels, cloudHome: CLOUD_HOME, lendingEnabled, providerConfigs,
+ closeBrowser, browserEngineSwitched, sharedComputers, sharedComputerControl, hostedModels, cloudHome: CLOUD_HOME, teamCloud, lendingEnabled, providerConfigs,
localVmIdleMs, localVmIdles, localVmActiveThreads, localVmLifecycleBusy, localVmImageBusy, localVmModeChangeBusy,
providerConfigBusy, computerProviderConfigTransitions, managedBoatOwners, providerOperationConflict,
perBotLocalVmCountForModeChange, checkedModelSelection, policyModelRefusal, browserSessionSpec, configStatus,
@@ -358,7 +360,7 @@ export function createConfigRoutes(deps: ConfigRouteDeps): RouteHandler {
if (requestedComposioKey !== undefined) {
if (requestedComposioKey.trim()) {
try {
- const prepared = await composio.prepareProjectSession(requestedComposioKey, cfg.composio);
+ const prepared = await composio.prepareProjectSession(requestedComposioKey, cfg.composio, undefined, { reuseEarlierUser: !teamCloud });
patch.composio = { ...patch.composio, ...prepared };
} catch (error) {
return json(res, 400, { error: error instanceof Error ? error.message : String(error) });