Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Default bot: allow demoting to a regular bot via PATCH defaultBot:null
Manuel4fbefab03d46
diff --git a/server/default-bot.test.ts b/server/default-bot.test.tsindex e05f72bc8e..e86f6673b2 100644--- a/server/default-bot.test.ts+++ b/server/default-bot.test.ts@@ -233,6 +233,19 @@ describe("MausBot, every person's helper", () => {expect(new Store(selection).bot(maus.id)?.sidebarHidden).toBe(false);});+ it("demotes to a regular bot on defaultBot: null, then it can be deleted", () => {+ const store = new Store(selection);+ const maus = boot(store)!;+ const other = store.createBot({ name: "Writer" });+ expect(defaultBotPatchRefusal(maus, { defaultBot: {} })).toMatch(/only be cleared/);+ expect(defaultBotPatchRefusal(maus, { defaultBot: null })).toBeNull();+ expect(defaultBotPatchRefusal(other, { defaultBot: null })).toBeNull();+ store.patchBot(maus.id, { defaultBot: undefined });+ expect(store.bot(maus.id)?.defaultBot).toBeUndefined();+ expect(() => store.deleteBot(maus.id)).not.toThrow();+ expect(store.bot(maus.id)).toBeNull();+ });+it("is never made twice for one place, even once its mark is gone", () => {const store = new Store(selection);const maus = boot(store)!;diff --git a/server/default-bot.ts b/server/default-bot.tsindex 41f440d679..7868d30f7b 100644--- a/server/default-bot.ts+++ b/server/default-bot.ts@@ -21,10 +21,12 @@ export function defaultBotRefusal(name: string): string {return `${name} can't be deleted or archived. To take it off the sidebar, choose Hide in its menu, or turn off "Show ${name} in the sidebar" in Settings → General.`;}-/** Why a PATCH may not change this bot so, or null. */+/** Why a PATCH may not change this bot so, or null. `defaultBot: null` demotes the bot to a regular one and is always+ * allowed on a default bot; any other `defaultBot` value is refused — the flag is set at creation, never by PATCH. */export function defaultBotPatchRefusal(bot: BotRecord | null, body: Record<string, unknown>): string | null {for (const key of ["sidebarHidden", "welcomed"]) if (body[key] !== undefined && typeof body[key] !== "boolean") return `${key} must be true or false`;if ((body.sidebarHidden !== undefined || body.welcomed !== undefined) && !bot?.defaultBot) return "Only MausBot is hidden this way; archive or delete other bots.";+ if (body.defaultBot !== undefined && body.defaultBot !== null) return "defaultBot can only be cleared (null), never set by a patch";return body.hidden === true && bot?.defaultBot ? defaultBotRefusal(bot.name) : null;}diff --git a/server/routes/bot-patch.ts b/server/routes/bot-patch.tsindex 6791a72ee7..3366a211ff 100644--- a/server/routes/bot-patch.ts+++ b/server/routes/bot-patch.ts@@ -201,6 +201,8 @@ export function createBotPatchRoutes(deps: BotPatchRouteDeps): RouteHandler {for (const key of ["unread", "cloudBackend", "color", "mascotExpression", "mascotBody", "pinned", "hidden", "sidebarHidden", "welcomed"] as const) {if (body[key] !== undefined) patch[key] = body[key];}+ // null clears the default-bot mark, demoting the bot to a regular (deletable) one.+ if (body.defaultBot === null && existingBot?.defaultBot) patch.defaultBot = undefined;const computerSpecified = Object.prototype.hasOwnProperty.call(body, "computer");let requestedComputer = existingBot?.computer;if (computerSpecified) {diff --git a/src/components/DefaultBotControls.tsx b/src/components/DefaultBotControls.tsxindex 14f98c3fff..9e34e934a6 100644--- a/src/components/DefaultBotControls.tsx+++ b/src/components/DefaultBotControls.tsx@@ -1,4 +1,4 @@-import { EyeOff } from "lucide-react";+import { EyeOff, UserMinus } from "lucide-react";import { cn } from "@/lib/cn";import { t } from "@/lib/i18n";@@ -30,6 +30,28 @@ export function HideDefaultBotItem({ bot, onDone, className = "flex w-full items);}+/** Demotes the default bot to a regular bot: the mark is cleared server-side, so it can then be archived or deleted. */+export function DemoteDefaultBotItem({ bot, onDone, className = "flex w-full items-center gap-3 px-3.5 py-2 text-left text-[14px]" }: { bot: Bot; onDone: () => void; className?: string }) {+ const { dispatch } = useStore();+ return (+ <button+ type="button"+ role="menuitem"+ data-default-bot-demote=""+ onClick={() => {+ dispatch({ type: "updateBot", botId: bot.id, patch: { defaultBot: null } });+ dispatch({ type: "notice", notice: { kind: "note", botName: null, text: t("defaultBot.demoted", { name: bot.name }) } });+ onDone();+ }}+ title={t("defaultBot.demoteHint")}+ className={cn(className, "text-ink hover:bg-menu-hover")}+ >+ <UserMinus size={16} className="text-ink-secondary" />+ {t("defaultBot.demote")}+ </button>+ );+}+/** Settings → General: whether the viewer's own MausBot has a row in the sidebar. */export function DefaultBotSidebarRow({ simple = false }: { simple?: boolean }) {const { state, dispatch } = useStore();diff --git a/src/components/SidebarBotMenu.tsx b/src/components/SidebarBotMenu.tsxindex 6b21a7ad70..ffdef65c96 100644--- a/src/components/SidebarBotMenu.tsx+++ b/src/components/SidebarBotMenu.tsx@@ -7,7 +7,7 @@ import { useHeldMenuMotion } from "./MenuMotion";import { t } from "@/lib/i18n";import { copyText } from "@/lib/copy-text";import { allThreadRows, BotDeleteMenuItem, useDeleteAllThreads } from "./BotMenuDelete";-import { HideDefaultBotItem } from "./DefaultBotControls";+import { DemoteDefaultBotItem, HideDefaultBotItem } from "./DefaultBotControls";import { navigateThreadMenu } from "./BotProjects";import { useOwnerOrAdmin } from "@/lib/use-owner-or-admin";import { userBotMenu } from "@/lib/own-team-bot";@@ -285,7 +285,7 @@ export function BotContextMenu({);const threads = [divider("threads"), newThread, viewThreads, setMain];const moreRow = flyoutButton("more", moreRef, <MoreHorizontal size={16} className="text-ink-secondary" />, t("sidebar.bot.more"));- const leave = bot.defaultBot ? [<HideDefaultBotItem key="hide" bot={bot} onDone={onClose} className={MENU_ITEM} />] : member ? ownDelete() : [+ const leave = bot.defaultBot ? [<HideDefaultBotItem key="hide" bot={bot} onDone={onClose} className={MENU_ITEM} />, <DemoteDefaultBotItem key="demote" bot={bot} onDone={onClose} className={MENU_ITEM} />] : member ? ownDelete() : [item(<Archive size={16} className="text-ink-secondary" />, t("sidebar.bot.archive"), () => onArchive(bot), { disabled: archiveBlocked, hint: archiveHint }),<BotDeleteMenuItem key="delete" deleting={deleting} className={MENU_ITEM} onClick={() => { onClose(); onDelete(bot); }} />,];@@ -430,7 +430,7 @@ export function BotContextMenu({void copyText(bot.threadId);}),divider("d3"), ...moveToTeam.items(bot, item), ...moveToCloud.items(bot, item),- ...(bot.defaultBot ? [<HideDefaultBotItem key="hide" bot={bot} onDone={onClose} className={MENU_ITEM} />] : member ? ownDelete() : [+ ...(bot.defaultBot ? [<HideDefaultBotItem key="hide" bot={bot} onDone={onClose} className={MENU_ITEM} />, <DemoteDefaultBotItem key="demote" bot={bot} onDone={onClose} className={MENU_ITEM} />] : member ? ownDelete() : [item(<Archive size={16} className="text-ink-secondary" />, t("sidebar.bot.archive"), () => onArchive(bot), { disabled: archiveBlocked, hint: archiveHint }),<BotDeleteMenuItem key="delete" deleting={deleting} className={MENU_ITEM} onClick={() => { onClose(); onDelete(bot); }} />,]),diff --git a/src/locales/en.json b/src/locales/en.jsonindex a310f7f335..19be41f294 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -7286,6 +7286,9 @@"defaultBot.hide": "Hide from sidebar","defaultBot.hideHint": "It keeps working. Show it again in Settings → General.","defaultBot.hidden": "{name} is off the sidebar. Show it again in Settings → General.",+ "defaultBot.demote": "Make this a regular bot",+ "defaultBot.demoteHint": "Removes the built-in protection: it can then be archived or deleted like any other bot.",+ "defaultBot.demoted": "{name} is now a regular bot — archive or delete it from this menu.","defaultBot.show.title": "Show {name} in the sidebar","defaultBot.show.subtitle": "Your helper for everything in the app. Hidden, it keeps working and search still finds it.","teamMove.blockedDefault": "{name} stays here: everyone on a team gets their own",diff --git a/src/state/bot-patch-queue.test.ts b/src/state/bot-patch-queue.test.tsindex 98533a2df5..9dd4d7559d 100644--- a/src/state/bot-patch-queue.test.ts+++ b/src/state/bot-patch-queue.test.ts@@ -164,6 +164,7 @@ describe("bot patch queue", () => {connectorTools: patch.connectorTools ?? undefined,connectorScopes: patch.connectorScopes ?? undefined,phoneApps: patch.phoneApps ?? undefined,+ defaultBot: patch.defaultBot ?? undefined,});},reconcile: async () => bot(),diff --git a/src/state/bot-patch-queue.ts b/src/state/bot-patch-queue.tsindex 16ca92f362..173a1a1d9e 100644--- a/src/state/bot-patch-queue.ts+++ b/src/state/bot-patch-queue.ts@@ -49,6 +49,8 @@ export type BotUpdatePatch = Partial<connectorTools?: Bot["connectorTools"] | null;connectorScopes?: Bot["connectorScopes"] | null;phoneApps?: Bot["phoneApps"] | null;+ /** null demotes a default bot to a regular one; the server clears the mark. Body only: bot state drops the field. */+ defaultBot?: Bot["defaultBot"] | null;/** The server's proof the local-auto warning was shown: wire-only, never folded into bot state. */acknowledgeLocalAuto?: boolean;applyToAllThreads?: boolean;@@ -61,13 +63,14 @@ export type BotUpdatePatch = Partial<export type BotStatePatch = Omit<BotUpdatePatch,- "computer" | "connectorTools" | "connectorScopes" | "phoneApps" | "acknowledgeLocalAuto" | "applyToAllThreads" | "keepThreadModels" | "threadId" | "mainThreadChoice"+ "computer" | "connectorTools" | "connectorScopes" | "phoneApps" | "defaultBot" | "acknowledgeLocalAuto" | "applyToAllThreads" | "keepThreadModels" | "threadId" | "mainThreadChoice"> & {mainThreadId?: string;computer?: Bot["computer"];connectorTools?: Bot["connectorTools"];connectorScopes?: Bot["connectorScopes"];phoneApps?: Bot["phoneApps"];+ defaultBot?: Bot["defaultBot"];};interface BotPatchQueueEntry {@@ -126,11 +129,14 @@ const stateOverlay = (patch: BotUpdatePatch): BotStatePatch => {connectorTools,connectorScopes,phoneApps,+ defaultBot,...fields} = patch;const normalized: BotStatePatch = { ...fields };if (computer === null) normalized.computer = undefined;else if (computer !== undefined) normalized.computer = computer;+ if (defaultBot === null) normalized.defaultBot = undefined;+ else if (defaultBot !== undefined) normalized.defaultBot = defaultBot;if (connectorTools === null) normalized.connectorTools = undefined;else if (connectorTools !== undefined) normalized.connectorTools = connectorTools;if (connectorScopes === null) normalized.connectorScopes = undefined;diff --git a/src/state/store.tsx b/src/state/store.tsxindex f1f4ab7af2..518d54f25b 100644--- a/src/state/store.tsx+++ b/src/state/store.tsx@@ -1562,7 +1562,6 @@ export function reducer(state: AppState, action: Action): AppState {? withMascotMotion(state, action.botId, "customize"): state;const target = animated.bots.find((bot) => bot.id === action.botId);- const next = action.patch.chiefOfStaff ? { ...animated, bots: withOneChief(animated.bots, { ...target, ...action.patch, id: action.botId }) } : animated;const {acknowledgeLocalAuto: _localAck,applyToAllThreads: _allThreads,@@ -1570,11 +1569,15 @@ export function reducer(state: AppState, action: Action): AppState {computer,connectorTools,connectorScopes, phoneApps,+ defaultBot,...rest} = action.patch;+ const next = action.patch.chiefOfStaff ? { ...animated, bots: withOneChief(animated.bots, { ...target, ...rest, id: action.botId }) } : animated;const botPatch: Partial<Bot> = { ...rest, ...(phoneApps !== undefined && { phoneApps: phoneApps ?? undefined }), ...(typeof mainThreadChoice === "string" && { mainThreadId: mainThreadChoice }) };if (computer === null) botPatch.computer = undefined;else if (computer !== undefined) botPatch.computer = computer;+ if (defaultBot === null) botPatch.defaultBot = undefined;+ else if (defaultBot !== undefined) botPatch.defaultBot = defaultBot;if (connectorTools === null) botPatch.connectorTools = undefined;else if (connectorTools !== undefined) botPatch.connectorTools = connectorTools;if (connectorScopes === null) botPatch.connectorScopes = undefined;