Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
The You menu's MausBot Cloud row says Sign in for anyone signed out here
milind-soni2e3153da2658
diff --git a/electron/accounts-main.mjs b/electron/accounts-main.mjsindex 188345023d..a3816fb1db 100644--- a/electron/accounts-main.mjs+++ b/electron/accounts-main.mjs@@ -40,15 +40,14 @@ export function createAccountLeave({ saved, persist, session, mine, leaveWindow,* leave: ReturnType<typeof createAccountLeave>,* show(): Promise<unknown>,* tell(): void,- * clean?(): boolean,- * }} deps `clean`: the clean workspace runs (clean-workspace.mjs). `ownPage`: this app's own page in the window, or the rail's. `placePage`: the page of a place of the person's own+ * }} deps `ownPage`: this app's own page in the window, or the rail's. `placePage`: the page of a place of the person's own* or their team's, which may offer the sheet. `holdSheet`: the rail's page stays up for the sheet, even for someone who hid* the rail. `leaving`: the home window lets go of what it was doing for this account; `leave`: createAccountLeave's;* `show`: the window goes where it belongs now; `tell`: this app's pages read the list again.*/-export function installAccounts({ ipcMain, ownPage, placePage, account, client, holdSheet, tellSheet, leaving, leave, show, tell, clean = () => false }) {+export function installAccounts({ ipcMain, ownPage, placePage, account, client, holdSheet, tellSheet, leaving, leave, show, tell }) {let sheetPending = false, queue = Promise.resolve();- const view = () => ({ ...accountsView(account()?.state()), ...(clean() ? { clean: true } : {}) });+ const view = () => accountsView(account()?.state());const serial = (work) => { const run = queue.then(work, work); queue = run.catch(() => {}); return run; };const own = (channel, handler) => ipcMain.handle(channel, (event, ...args) => {if (!ownPage(event)) throw new Error(`${channel} is only available on this app's own page`);diff --git a/electron/accounts-main.node-test.mjs b/electron/accounts-main.node-test.mjsindex 55853a02c7..1270b13c19 100644--- a/electron/accounts-main.node-test.mjs+++ b/electron/accounts-main.node-test.mjs@@ -143,14 +143,3 @@ test("a My Cloud saved by hand is the account's only while the sign-in names it;assert.equal(withoutPlaces(changed, [byHand]).activeId, "local");assert.equal(withoutPlaces(changed, []), changed, "nothing to remove: the same list");});--test("the view says when the clean workspace runs, for the You menu's Sign in; nothing changes otherwise", async () => {- const handlers = new Map();- let clean = true;- const client = { state: () => ({ status: "signed-out" }) };- installAccounts({ ipcMain: { handle: (channel, handler) => handlers.set(channel, handler) }, ownPage: () => true, placePage: () => true, account: () => client, client: () => client, clean: () => clean,- holdSheet() {}, tellSheet() {}, leaving() {}, leave: { places: () => [], finish: async () => [] }, show: async () => {}, tell() {} });- assert.deepEqual(await handlers.get("accounts:list")({}), { active: null, others: [], clean: true });- clean = false;- assert.deepEqual(await handlers.get("accounts:list")({}), { active: null, others: [] });-});diff --git a/electron/cloud-account.d.mts b/electron/cloud-account.d.mtsindex 8af5360fb5..ffcfe742b0 100644--- a/electron/cloud-account.d.mts+++ b/electron/cloud-account.d.mts@@ -174,8 +174,7 @@ export interface CloudAccountBridge {}/** Who is signed in on this device, as the You menu shows it. `signIn`: this account's sign-in has ended here. */export interface AccountRow { id: string; email: string; signIn?: true }-/** `clean`: the clean workspace runs on this computer, whose line asks the person to sign in. */-export interface AccountsView { active: AccountRow | null; others: AccountRow[]; clean?: true }+export interface AccountsView { active: AccountRow | null; others: AccountRow[] }/** This app's own pages only: main refuses any other page. Absent on an older app. */export interface AccountsBridge {list(): Promise<AccountsView>;diff --git a/electron/main.mjs b/electron/main.mjsindex 338dd50a41..182e4e4a5f 100644--- a/electron/main.mjs+++ b/electron/main.mjs@@ -2688,7 +2688,7 @@ const chromeRail = createChromeRail({ createView: options => new WebContentsViewchromeRail.install(ipcMain);function railChanged() { chromeRail.refresh(); rail.changed(); }const accountPages = [() => (mainWindow && !mainWindow.isDestroyed() && senderIsLocal({ sender: mainWindow.webContents }) ? mainWindow.webContents : null), () => ({ send: channel => chromeRail.send(channel) })];-const accounts = installAccounts({ ipcMain, clean: () => cleanWorkspace.active(), ownPage: event => chromeRail.owns(event) || cloudPageAsking(event) === "local", placePage: event => cloudPageAsking(event) !== null || ownCloudPage(event) !== null || homeWindow.homePage(event) || (Boolean(ownHome?.home()) && activeEnvironment(environmentsState)?.origin === ownHome.home().origin && workspaceSenderAllowed(event, mainWindow?.webContents, environmentsState, rendererOrigin())), account: () => (app.isPackaged && !desktopRemoteAccess ? cloudAccount : null), client: ensureCloudAccount, holdSheet: open => chromeRail.holdOpen(open), tellSheet: () => chromeRail.send("accounts:open-sheet"), leaving: () => homeWindow.accountLeaving(), leave: createAccountLeave({ saved: () => environmentsState, persist: persistEnvironments, session: () => session.defaultSession, mine: () => myCloud(), leaveWindow: () => (mainWindow && !mainWindow.isDestroyed() && !senderIsLocal({ sender: mainWindow.webContents }) ? navigateMainWindow(rendererOrigin()) : null), settled: () => computerSharing?.goodbyesDone(), log: slog }), show: () => showHome(), tell: () => { for (const page of accountPages) page()?.send("accounts:changed"); } });+const accounts = installAccounts({ ipcMain, ownPage: event => chromeRail.owns(event) || cloudPageAsking(event) === "local", placePage: event => cloudPageAsking(event) !== null || ownCloudPage(event) !== null || homeWindow.homePage(event) || (Boolean(ownHome?.home()) && activeEnvironment(environmentsState)?.origin === ownHome.home().origin && workspaceSenderAllowed(event, mainWindow?.webContents, environmentsState, rendererOrigin())), account: () => (app.isPackaged && !desktopRemoteAccess ? cloudAccount : null), client: ensureCloudAccount, holdSheet: open => chromeRail.holdOpen(open), tellSheet: () => chromeRail.send("accounts:open-sheet"), leaving: () => homeWindow.accountLeaving(), leave: createAccountLeave({ saved: () => environmentsState, persist: persistEnvironments, session: () => session.defaultSession, mine: () => myCloud(), leaveWindow: () => (mainWindow && !mainWindow.isDestroyed() && !senderIsLocal({ sender: mainWindow.webContents }) ? navigateMainWindow(rendererOrigin()) : null), settled: () => computerSharing?.goodbyesDone(), log: slog }), show: () => showHome(), tell: () => { for (const page of accountPages) page()?.send("accounts:changed"); } });const rail = installCloudRail({ ipcMain, clipboard, openCloud: openOwnCloud, account: () => (app.isPackaged && !desktopRemoteAccess ? cloudAccount : null),guard: handler => (event, ...args) => (chromeRail.owns(event) ? handler(event, ...args) : workspaceOnly(handler)(event, ...args)),lists: event => chromeRail.owns(event), trusted: event => chromeRail.owns(event) || senderIsLocal(event), beside: () => chromeRail.shown(),diff --git a/src/components/AccountMenu.test.ts b/src/components/AccountMenu.test.tsindex 27de9c3164..44deaf9766 100644--- a/src/components/AccountMenu.test.ts+++ b/src/components/AccountMenu.test.ts@@ -25,9 +25,8 @@ it("another place's page shows no address, only the row that asks main for the sexpect(openSheet).toHaveBeenCalled();});-it("the MausBot Cloud row says Sign in only while the clean workspace's line asks for it", () => {- expect(cloudRowLabel({ active: null, others: [], clean: true })).toBe("Sign in");- expect(cloudRowLabel({ active: null, others: [] })).toBe("MausBot Cloud");- expect(cloudRowLabel({ active: { id: "b", email: "[email protected]" }, others: [], clean: true })).toBe("MausBot Cloud");+it("the MausBot Cloud row says Sign in while nobody is signed in here; any other page keeps its name", () => {+ expect(cloudRowLabel({ active: null, others: [] })).toBe("Sign in");+ expect(cloudRowLabel({ active: { id: "b", email: "[email protected]" }, others: [] })).toBe("MausBot Cloud");expect(cloudRowLabel(null)).toBe("MausBot Cloud");});diff --git a/src/components/AccountMenu.tsx b/src/components/AccountMenu.tsxindex 1d471b7f29..d37a16e12a 100644--- a/src/components/AccountMenu.tsx+++ b/src/components/AccountMenu.tsx@@ -40,10 +40,10 @@ export function useAccounts(): AccountsAccess {};}-/** The You menu's row for the MausBot Cloud page: with the clean workspace open and nobody signed in, the line there asks the person- * to sign in, and this row is how. */+/** The You menu's row for the MausBot Cloud page, on this app's own page: Sign in while nobody is signed in here, so whoever was+ * told to sign in finds the words. Any other page knows nothing of who is signed in. */export function cloudRowLabel(view: AccountsView | null): string {- return t(view?.clean && !view.active ? "accounts.signIn" : "settings.section.cloudAccount");+ return t(view && !view.active ? "accounts.signIn" : "settings.section.cloudAccount");}/** The You menu's last rows. On another page, one row that opens the sheet. Signed out: nothing, as Settings has the sign-in. */