Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(goals): a one-on-one goal waits for its teammates and never shows its envelope
heimixiebec5c9ed0fbaa
diff --git a/server/group-goal-run-one-on-one.e2e.test.ts b/server/group-goal-run-one-on-one.e2e.test.tsindex b912d369bf..0f05c8eb50 100644--- a/server/group-goal-run-one-on-one.e2e.test.ts+++ b/server/group-goal-run-one-on-one.e2e.test.ts@@ -93,6 +93,11 @@ beforeAll(async () => {}),patient: fixture("patient", { FAKE_CLAUDE_MODE: "hang", FAKE_CLAUDE_FINISH_GATE: patientGate }),crash: fixture("crash", { FAKE_CLAUDE_MODE: "exit-early" }),+ stray: fixture("stray", {+ FAKE_CLAUDE_MODE: "happy",+ FAKE_CLAUDE_REPLIES: JSON.stringify([`Coder finished it.+${envelope({ status: "completed", detail: "Done." })}`]),+ }),routine: fixture("routine", {FAKE_CLAUDE_MODE: "happy",FAKE_CLAUDE_REPLIES: JSON.stringify([`Reviewed.\n${envelope({ status: "completed", detail: "Scheduled review done." })}`]),@@ -166,6 +171,16 @@ describe("one-on-one goal runs (a room of one)", () => {expect((await messagesIn(bot.threadId)).filter((message) => message.kind === "goal.run")).toHaveLength(1);});+ it("hides an envelope written in a turn outside the goal's own, such as a teammate's result waking the lead", async () => {+ const bot = await newBot("Stray", "stray");+ const sent = await api("POST", `/api/bots/${bot.id}/messages`, { text: "Coder replied", threadId: bot.threadId });+ expect(sent.status).toBe(202);+ const replies = async () => (await messagesIn(bot.threadId))+ .filter((message) => message.kind === "text" && message.role === "bot" && message.requestMessageId === sent.body.message.id).map((message) => message.text);+ await expect.poll(replies, { timeout: hostTimeout(15_000) }).toEqual(["Coder finished it."]);+ expect(JSON.stringify(await messagesIn(bot.threadId))).not.toContain("openmaus-goal");+ });+it("Stop ends the goal on its card and no turn starts after the interrupted one", async () => {const bot = await newBot("Stopper", "slow");expect((await sendGoal(bot, "Keep going")).status).toBe(202);diff --git a/server/group-goal-run.ts b/server/group-goal-run.tsindex 60d4f6fc5b..8e57aab470 100644--- a/server/group-goal-run.ts+++ b/server/group-goal-run.ts@@ -36,7 +36,8 @@ export function groupGoalCompletionTurnId(const bounded = (value: unknown, max: number): string =>typeof value === "string" ? value.trim().slice(0, max) : "";-function visibleCoordinatorText(text: string): string {+/** A reply without its private goal envelopes; a turn outside the goal's own (a teammate's result waking the lead) can write one too. */+export function visibleCoordinatorText(text: string): string {let visible = text;for (;;) {const closeAt = visible.indexOf(GROUP_GOAL_CONTROL_CLOSE);diff --git a/server/host/one-on-one-goals.ts b/server/host/one-on-one-goals.tsindex fc56fab1ea..0262347585 100644--- a/server/host/one-on-one-goals.ts+++ b/server/host/one-on-one-goals.ts@@ -16,7 +16,7 @@ export interface OneOnOneGoalDeps {store: Pick<Store, "appendMessage" | "bot" | "onChange" | "taskByThread" | "titleTaskFromFirstMessage">;cards: GoalCards;turns: GoalTurns;- /** startTurn would admit a turn in this conversation now. */+ /** startTurn would admit a turn in this conversation now, and no teammate it handed work to is still working on it. */canStart(botId: string, threadId: string): boolean;startTurn(botId: string, text: string, opts: {threadId: string;diff --git a/server/index.ts b/server/index.tsindex d0723dcff7..f53f133e27 100644--- a/server/index.ts+++ b/server/index.ts@@ -224,7 +224,7 @@ import { MCP_OAUTH_CALLBACK_PATH, McpOAuthManager } from "./mcp-oauth.ts";import {GROUP_GOAL_WAIT_MAX_MS,groupGoalCompletionTurnId,- parseGroupGoalDecision,+ parseGroupGoalDecision, visibleCoordinatorText,runGoalRun,selectGroupGoalCoordinator,type GoalStepOutcome,@@ -3562,7 +3562,7 @@ function activeGroupSpeaker(groupId: string): { botId: string; name: string; colconst goalTurns = createGoalTurns({ retireProviderTurn });const goalCards = createGoalCards({ store, routines: () => routines, notify, routineSourceOwner, routineSourceThread });const oneOnOneGoals = createOneOnOneGoals({- store, cards: goalCards, turns: goalTurns, canStart: canAdmitDirectTurn, startTurn, isUnattended,+ store, cards: goalCards, turns: goalTurns, canStart: (botId, threadId) => canAdmitDirectTurn(botId, threadId) && !threadsAwaitingTeammates().has(threadId), startTurn, isUnattended,});function groupIsWorking(group: GroupRecord): boolean {@@ -6423,7 +6423,7 @@ bus.subscribe((event: RuntimeEvent) => {break;case "item.completed":if (event.itemType === "assistant_text") {- pushAssistantText(event.text, event.turnId);+ const shown = event.text.includes("openmaus-goal>") ? visibleCoordinatorText(event.text) : event.text; if (shown) pushAssistantText(shown, event.turnId);} else if (event.itemType === "assistant_image") {try {const decoded = decodeGeneratedImage(event.data);