Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Keep a tagged teammate's answer on the person's request, with its files and Regenerate on the right reply
Bugfixer 24a86e7375993
diff --git a/server/direct-coordination.e2e.test.ts b/server/direct-coordination.e2e.test.tsindex a6eba2ee4c..63970e74e1 100644--- a/server/direct-coordination.e2e.test.ts+++ b/server/direct-coordination.e2e.test.ts@@ -175,6 +175,8 @@ it("shows a tagged teammate's answer in the asker's chat under its own name", ()expect(said).toContainEqual(expect.objectContaining({ role: "bot", kind: "text", text: "Yes, the latest PHP version is fine for us.",from: expect.objectContaining({ botId: f.chief.id, name: "Clive" }) }));expect(said.filter((message: any) => message.roomRequest?.phase === "result")).toHaveLength(1);+ const request = said.find((message: any) => message.role === "user" && message.text.startsWith("@Clive"));+ expect(said.find((message: any) => message.from?.botId === f.chief.id && message.kind === "text").requestMessageId).toBe(request.id);}), 45_000);it.each([false, true])("starts independent work immediately and frees the Chief while waiting (source fails: %s)", fail => fixture(async f => {diff --git a/server/index.ts b/server/index.tsindex abb675f840..219268771f 100644--- a/server/index.ts+++ b/server/index.ts@@ -3911,9 +3911,11 @@ const handedLines: HandedLineDeps | undefined = CLOUD_TEAM ? undefined : { storeif (store.messagesFor(parent.threadId).some(m => m.roomRequest?.id === child.id && m.roomRequest.phase === "result")) return;const problem = roomHandoffProblem(child, parent);const source = store.bot(parent.botId);+ const owner = directRequestOwners.get(parent.threadId);const answer = problem || !source ? null- : taggedAnswerRow(child, parent, bot, (botId) => taggedTeammates(parent.text, personalReach.peers(store.bots, source, parent.threadId)).some((one) => one.id === botId));- store.appendMessage(parent.threadId, answer ?? {+ : taggedAnswerRow(child, parent, bot, (botId) => taggedTeammates(parent.text, personalReach.peers(store.bots, source, parent.threadId)).some((one) => one.id === botId),+ owner && !owner.stopped && owner.generations.has(parent.id) ? owner.messageId : undefined);+ store.appendMessage(parent.threadId, answer ? { ...answer, ...handoffFiles.returnedWith(child, parent) } : {role: "bot", kind: "activity",roomRequest: { id: child.id, phase: "result" }, ...handoffFiles.returnedWith(child, parent),from: bot ? { botId: bot.id, name: bot.name, color: bot.color } : undefined,@@ -8277,7 +8279,7 @@ async function beginTurn({ id: "playbooks", label: "Playbooks", text: packagePlaybooks },{ id: "webhook", label: "Webhook provenance", text: opts?.automationSource === "webhook" ? WEBHOOK_PROMPT : opts?.automationSource === "api" ? (botApiThread(threadId) ? BOT_API_PROMPT : BOT_API_OWNER_PROMPT) : "" },{ id: "automation-reply", label: "Automation reply", text: opts?.automationSource && automationReports.reportsElsewhere(threadId) ? AUTOMATION_REPLY_PROMPT : "" },- { id: "mentions", label: "Mentions", text: (tagged.length ? `The user named these existing teammates: ${tagged.map(b => `${peerName(b.name)} (${b.id})`).join(", ")}. Use coordinate_bots when their contribution is needed; do not substitute native helper agents for these bots.${commsDepth === 0 ? TAGGED_ANSWER_PROMPT : ""}` : "") + placesElsewhere.mentioned(providerText, store.bots, botLink.reaches) },+ { id: "mentions", label: "Mentions", text: (tagged.length ? `The user named these existing teammates: ${tagged.map(b => `${peerName(b.name)} (${b.id})`).join(", ")}. Use coordinate_bots when their contribution is needed; do not substitute native helper agents for these bots.${commsDepth === 0 && !store.groupByThread(threadId) ? TAGGED_ANSWER_PROMPT : ""}` : "") + placesElsewhere.mentioned(providerText, store.bots, botLink.reaches) },].filter((part) => (apiFenced ? BOT_API_PARTS.has(part.id) : !confined || READ_AND_DRAFT_PARTS.has(part.id))), integrations.agents, { replyStyle: liveBot?.replyStyle ?? bot.replyStyle, rules: cfg.everyBotRules, pagesOff: (liveBot ?? bot).toolsOff?.includes("pages") }); setup.lap("prompt");turnPromptBytes.set(threadId, { stable: Buffer.byteLength(prompt.stable), volatile: Buffer.byteLength(prompt.volatile) });// Recall rides in front of this turn's message, never the system prompt, whose volatile half is re-sent whole on any change.diff --git a/server/tagged-answer.test.ts b/server/tagged-answer.test.tsindex b4a2e5986b..04d43b5749 100644--- a/server/tagged-answer.test.ts+++ b/server/tagged-answer.test.ts@@ -27,6 +27,12 @@ describe("a teammate tagged in another bot's one-to-one chat", () => {});describe("the tagged teammate's reply", () => {+ it("belongs to the person's request, so Stop still finds that request", () => {+ expect(taggedAnswerRow(answered, wesChat, chief, is("chief"), "u1")?.requestMessageId).toBe("u1");+ expect(taggedAnswerRow(answered, wesChat, chief, is("chief"))).not.toHaveProperty("requestMessageId");+ });++it("hides secrets like the teammate row does", () => {const key = "sk-ant-api03-" + "x".repeat(40);expect(taggedAnswerRow({ ...answered, result: `key ${key}` }, wesChat, chief, is("chief"))?.text).not.toContain(key);diff --git a/server/tagged-answer.ts b/server/tagged-answer.tsindex 1e016b365e..10a9f8d4e6 100644--- a/server/tagged-answer.ts+++ b/server/tagged-answer.ts@@ -13,10 +13,12 @@ export function taggedAnswerRow(parent: Pick<HandoffView, "botId" | "groupId" | "parentId">,bot: Pick<WireBot, "id" | "name" | "color"> | null | undefined,tagged: (botId: string) => boolean,+ requestMessageId?: string,): Omit<Message, "id" | "at"> | null {if (!bot || parent.groupId || parent.parentId || child.botId === parent.botId || child.mode !== "consult" || child.status !== "completed") return null;const text = tagged(child.botId) ? redactSecretsInText(child.result.trim()) : "";- return text ? { role: "bot", kind: "text", text, from: { botId: bot.id, name: bot.name, color: bot.color }, roomRequest: { id: child.id, phase: "result" } } : null;+ return text ? { role: "bot", kind: "text", text, from: { botId: bot.id, name: bot.name, color: bot.color }, roomRequest: { id: child.id, phase: "result" },+ ...(requestMessageId ? { requestMessageId } : {}) } : null;}/** The line the chat's own bot reads when it is told the people it tagged: their answer is already in the chat. */diff --git a/src/components/ChatView.automation.test.ts b/src/components/ChatView.automation.test.tsindex 4a28b3a1be..0c29401d18 100644--- a/src/components/ChatView.automation.test.ts+++ b/src/components/ChatView.automation.test.ts@@ -137,6 +137,16 @@ describe("an automation's line in the chat", () => {expect(caption("run-gone")?.querySelector("button")).toBeNull();});+ it("never moves Regenerate onto an earlier request's answer when only a tagged teammate answered the latest (#8096)", async () => {+ const chief = { botId: "chief", name: "Chief", color: "red" as const };+ const asked: Message = { id: "u2", parentId: "m2", role: "user", kind: "text", text: "@Chief and the budget?", at: at(3) };+ await draw(transcript([asked, { id: "c2", parentId: "u2", role: "bot", kind: "text", text: "$4.20 today.", at: at(4), from: chief }]));+ expect(await regenerateOffers()).toEqual([]);+ await draw(transcript([asked, { id: "c2", parentId: "u2", role: "bot", kind: "text", text: "$4.20 today.", at: at(4), from: chief },+ { id: "p2", parentId: "c2", role: "bot", kind: "text", text: "That is under budget.", at: at(5), turnId: "t2", turnTerminal: true }]));+ expect(await regenerateOffers()).toEqual(["p2"]);+ });+it("never offers Regenerate on a report, which would branch the person's chat away from it", async () => {await draw(transcript([]));expect(await regenerateOffers()).toEqual(["m2"]);diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsxindex c63e070cd8..e7c565eeb6 100644--- a/src/components/ChatView.tsx+++ b/src/components/ChatView.tsx@@ -781,7 +781,18 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal});const lastBotTextId = useMemo(- () => [...messages].reverse().find((m) => m.role === "bot" && m.kind === "text" && (!m.from || m.from.botId === bot.id))?.id,+ () => {+ // A teammate's tagged answer is not this bot's reply: Regenerate stays on this bot's answer to the same request, or none.+ let skippedTeammate = false;+ for (let i = messages.length - 1; i >= 0; i--) {+ const m = messages[i]!;+ if (skippedTeammate && m.role === "user") return undefined;+ if (m.role !== "bot" || m.kind !== "text") continue;+ if (!m.from || m.from.botId === bot.id) return m.id;+ skippedTeammate = true;+ }+ return undefined;+ },[messages, bot.id],); const unreadDivider = useUnreadDivider({ threadId: bot.threadId, messages: chatMessages, following });