Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(chief): add the no-cloud-computer note after an approved create_bot
AdityaUmalec8f1a7ce05f3
diff --git a/server/drivers/agents-call.ts b/server/drivers/agents-call.tsindex e6521b4a22..1e5ef9811f 100644--- a/server/drivers/agents-call.ts+++ b/server/drivers/agents-call.ts@@ -5,6 +5,7 @@ import { CREDENTIAL_TARGETS, isCredentialTargetId } from "../../shared/credentiaimport { rankSkills } from "../../shared/skill-fit.ts";import { isSkillSwitchAction, skillSwitchVerb } from "../../shared/skill-request.ts";import { EMAIL_CREDENTIAL } from "../../shared/email.ts";+import { noCloudComputerNote } from "../../shared/team-setup.ts";import { peerName } from "../peer-roster.ts";import { callCardTool, CARD_TOOL_NAMES } from "./agents-call-cards.ts";@@ -534,9 +535,7 @@ export async function callTool(called: string, input: Json, context: ToolCallCon}if (!r.id) return completedProposalResult(r, `creating @${botName}`) ?? { text: `@${botName} was not created.`, isError: true };const created = r.name ?? botName;- const noComputer = r.noCloudComputerYet === true- ? ` @${created} has no cloud computer yet: work you hand it runs without one until the person writes to it in its own chat, which sets one up. If its first job needs a computer, tell the person that in one line.`- : "";+ const noComputer = r.noCloudComputerYet === true ? noCloudComputerNote(String(created)) : "";return {text: `Created @${created} in ${r.section ?? "General"} [id: ${r.id}].${r.modelSelection ? ` Model: ${JSON.stringify(r.modelSelection)}.` : ""} Assign work with coordinate_bots.${noComputer}`,};diff --git a/server/index.ts b/server/index.tsindex b0558f20b1..ff17f1d3f9 100644--- a/server/index.ts+++ b/server/index.ts@@ -465,7 +465,7 @@ import { buildBotOverview, type BotOverview, connectedAppsFacts } from "./bot-ovimport { ProfileRequestService } from "./profile-requests.ts";import { ModelRequestService } from "./model-requests.ts";import { TeamSetupError, TeamSetupRequestService } from "./team-setup-requests.ts";-import type { TeamSetupRequest } from "../shared/team-setup.ts";+import { teamSetupDecisionText as decisionText, type TeamSetupRequest } from "../shared/team-setup.ts";import { profileRevision, profileSnapshot } from "./profile-revision.ts";import { flushAllProfileHistory, flushProfileHistory, readHistory, recordProfileChange, soulChanges } from "./profile-versions.ts";import { TeamMemory, TEAM_MEMORY_KINDS, type TeamMemoryKind } from "./team-memory.ts";@@ -1922,8 +1922,8 @@ const computerParks = new Map<string, string>();const parkedSeats = new Map<string, string>();const COMPUTER_FREE_NOTE = "OpenMausBot computer update: the computer this conversation waited for is free again. Continue the task that parked waiting for it.";const STEP_CAP_NOTE = "Your previous turn stopped at the step limit; continue from where it stopped.";-const teamSetupDecisionText = (request: TeamSetupRequest): string =>- `OpenMausBot team setup decision ${request.requestId}: ${JSON.stringify(request.result)}. Report this exact result and continue the user's already requested work. Do not ask for confirmation again or repeat this setup/deletion. A denied or cancelled operation did not authorize any substitute action. Existing thread models were not changed.`;+const lacksCloudComputer = (bot: BotRecord | null | undefined): boolean => !!bot && boat.boatConfigured(cfg) && bot.cloudBackend !== "vps" && !inheritedTeamComputer(bot);+const teamSetupDecisionText = (request: TeamSetupRequest): string => decisionText(request, (id) => lacksCloudComputer(store.bot(id)));const connectionUpdateText = (labels: readonly string[]): string =>`OpenMausBot connection update: the user securely connected ${labels.join(", ")}. Continue the task that paused for this connection. Do not ask them to connect it again.`;@@ -14241,7 +14241,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {section: created.section || "General",model: created.modelSelection.model,modelSelection: created.modelSelection, ...(botNameClash.warning(created.name) ? { warning: botNameClash.warning(created.name) } : {}),- ...(paused ? { paused } : {}), ...(boat.boatConfigured(cfg) && created.cloudBackend !== "vps" && !inheritedTeamComputer(created) ? { noCloudComputerYet: true } : {}),+ ...(paused ? { paused } : {}), ...(lacksCloudComputer(created) ? { noCloudComputerYet: true } : {}),});}if (method === "POST" && (path === "/api/internal/create-room" || path === "/api/internal/manage-room")) {diff --git a/shared/team-setup.test.ts b/shared/team-setup.test.tsnew file mode 100644index 0000000000..643b3acf8c--- /dev/null+++ b/shared/team-setup.test.ts@@ -0,0 +1,30 @@+import { describe, expect, it } from "vitest";+import { teamSetupDecisionText, type TeamSetupRequest } from "./team-setup.ts";++const request = (result: TeamSetupRequest["result"]): TeamSetupRequest => ({+ version: 1, requestId: "req-1", botId: "chief", threadId: "t1", reason: "", createdAt: 0, requesterRevision: "r",+ operations: [], newTeams: [], ...(result ? { result } : {}),+});++describe("teamSetupDecisionText", () => {+ it("tells the Chief when a bot created after approval has no cloud computer yet", () => {+ const text = teamSetupDecisionText(request({ state: "applied", newTeams: [], bots: [+ { id: "b1", name: "Pixel", action: "created" },+ { id: "b2", name: "Covered", action: "created" },+ { id: "b3", name: "Old", action: "updated" },+ ] }), (id) => id !== "b2");+ expect(text).toContain("team setup decision req-1:");+ expect(text).toContain("@Pixel has no cloud computer yet");+ expect(text).not.toContain("@Covered has no cloud computer");+ expect(text).not.toContain("@Old has no cloud computer");+ });++ it("adds nothing for a denied setup or when every new bot has a computer", () => {+ const denied = teamSetupDecisionText(request({ state: "denied", newTeams: [], bots: [{ id: "b1", name: "Pixel", action: "created" }] }), () => true);+ const covered = teamSetupDecisionText(request({ state: "applied", newTeams: [], bots: [{ id: "b1", name: "Pixel", action: "created" }] }), () => false);+ for (const text of [denied, covered]) {+ expect(text).not.toContain("no cloud computer");+ expect(text.endsWith("Existing thread models were not changed.")).toBe(true);+ }+ });+});diff --git a/shared/team-setup.ts b/shared/team-setup.tsindex 7d249078b5..d430010c6e 100644--- a/shared/team-setup.ts+++ b/shared/team-setup.ts@@ -52,3 +52,14 @@ export interface TeamSetupUndo {before: Array<{ botId: string; fields: TeamSetupFields; managedSections?: string[] | null }>;revisions: Record<string, string>;}++/** Told to a Chief about a bot it just made that has no cloud computer of its own yet. */+export function noCloudComputerNote(name: string): string {+ return ` @${name} has no cloud computer yet: work you hand it runs without one until the person writes to it in its own chat, which sets one up. If its first job needs a computer, tell the person that in one line.`;+}++/** The Chief's resumed turn once its team setup card is decided. `lacksComputer` names newly created bots with no cloud computer yet. */+export function teamSetupDecisionText(request: TeamSetupRequest, lacksComputer: (botId: string) => boolean): string {+ const bare = request.result?.state === "applied" ? request.result.bots.filter((bot) => bot.action === "created" && lacksComputer(bot.id)) : [];+ return `OpenMausBot team setup decision ${request.requestId}: ${JSON.stringify(request.result)}. Report this exact result and continue the user's already requested work. Do not ask for confirmation again or repeat this setup/deletion. A denied or cancelled operation did not authorize any substitute action. Existing thread models were not changed.${bare.map((bot) => noCloudComputerNote(bot.name)).join("")}`;+}