Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(sign-in): settle an older sign-in card when a later turn goes on with the site (#6285)
CI fixture88c29487a7d9
diff --git a/server/host/handoff-requests.test.ts b/server/host/handoff-requests.test.tsindex 1035997058..d9fbb106e9 100644--- a/server/host/handoff-requests.test.ts+++ b/server/host/handoff-requests.test.ts@@ -167,7 +167,7 @@ describe("a bot hands one step to the person", () => {await w.requests.request(BOT, "work", ask);const rows = w.rows();rows.push({ id: "step", at: 2_000_000, role: "bot", kind: "activity", tool: { name: "agent_browser_open", ok: true, input: "https://github.com/" } } as Message);- w.settle.verified("dachs", "work", 0);+ w.settle.verified("dachs", "work");expect(signInOutcome(w.rows()[0]!.signIn!)).toBeNull();});});diff --git a/server/host/sign-in-settle.test.ts b/server/host/sign-in-settle.test.tsindex 84db1419fd..774752da3f 100644--- a/server/host/sign-in-settle.test.ts+++ b/server/host/sign-in-settle.test.ts@@ -74,9 +74,17 @@ describe("a sign-in settled without the person pressing Done", () => {w.add({ kind: "activity", tool: { name: "browser_open", ok: true, input: JSON.stringify({ url: "https://www.notion.so/workspace" }) } });w.add(card("github.com"));w.add({ kind: "activity", tool: { name: "browser_open", ok: false, input: JSON.stringify({ url: "https://github.com/login" }) } });- w.settle.verified("dachs", "work", 0);+ w.settle.verified("dachs", "work");expect(w.rows().filter((row) => row.signIn).map((row) => [row.signIn!.site, row.signIn!.done ?? false])).toEqual([["notion.so", true], ["github.com", false]]);});++ it("is done once the bot goes on with that site in a later turn: the card the person never answered clears too", () => {+ const w = world();+ w.add(card());+ w.add({ kind: "activity", at: 2_000_000, tool: { name: "browser_open", ok: true, input: JSON.stringify({ url: "https://www.notion.so/workspace" }) } });+ w.settle.verified("dachs", "work");+ expect(w.rows().filter((row) => row.signIn).map((row) => [row.signIn!.site, row.signIn!.done ?? false])).toEqual([["notion.so", true]]);+ });});describe("the computer a sign-in card lent the person", () => {@@ -90,7 +98,7 @@ describe("the computer a sign-in card lent the person", () => {if (path === "answered elsewhere") w.settle.answeredElsewhere({ id: "as_1", threadId: "work", botId: "dachs", cards: ["m1"] } as HandoffView);if (path === "verified") {w.add({ kind: "activity", tool: { name: "browser_open", ok: true, input: JSON.stringify({ url: "https://www.notion.so/workspace" }) } });- w.settle.verified("dachs", "work", 0);+ w.settle.verified("dachs", "work");}return w.handedBackKeys.includes(key);};diff --git a/server/host/sign-in-settle.ts b/server/host/sign-in-settle.tsindex 46f6931d89..d19fc6989e 100644--- a/server/host/sign-in-settle.ts+++ b/server/host/sign-in-settle.ts@@ -116,14 +116,16 @@ export function createSignInSettle(deps: SignInSettleDeps) {if (bot) answered(bot, node.threadId, node.cards ?? []);};- /** The bot asked for a sign-in, then went on with that site in the same turn: the sign-in went through. */- const verified = (botId: string, threadId: string, since: number): void => {+ /** The bot asked for a sign-in, then went on with that site — in the asking turn or a later one: the sign-in went+ * through, so the card stops waiting on the person. A newer request for the site supersedes the older card, so the+ * one this settles is the site's only open ask. */+ const verified = (botId: string, threadId: string): void => {const bot = store.bot(botId);if (!bot) return;const path = store.activePath(threadId);path.forEach((message, index) => {const card = message.signIn;- if (message.kind !== "signin" || !card || isHandoff(card) || message.at < since || card.stopped || !signInWaits(card)) return;+ if (message.kind !== "signin" || !card || isHandoff(card) || card.stopped || !signInWaits(card)) return;const site = card.site.toLowerCase();const used = path.slice(index + 1).some((row) => row.kind === "activity" && row.tool?.ok === true && (row.tool.input ?? "").toLowerCase().includes(site));if (!used) return;diff --git a/server/index.ts b/server/index.tsindex 1dfb5fbf7e..1756a1a20f 100644--- a/server/index.ts+++ b/server/index.ts@@ -1961,7 +1961,7 @@ function hostTurnResult(node: HandoffView | undefined, generation: string, outcocomputerParks.delete(generation);if (!node) return outcome;const result: DirectTurnOutcome = { ...outcome, evidence: { ...outcome.evidence, ...turnEvidence(turnRows(node)) } };- if (outcome.ok && !node.groupId) signInSettle.verified(node.botId, node.threadId, node.startedAt ?? node.createdAt);+ if (outcome.ok && !node.groupId) signInSettle.verified(node.botId, node.threadId);const cards = resumableCards(node.threadId, node.createdAt, node.groupId ? node.botId : undefined).filter((card) => !coordinator.active().some((other) => other.id !== node.id && other.threadId === node.threadId && other.status === "waiting" && other.cards?.includes(card.id)));if (result.stalled) stopCards(node.threadId, new Set(cards.map((card) => card.id)));if (node.goalRunId) return result;