Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Chat: a wait's note takes the name of the card that matches its whole line
luishron123aa3241abf6de
diff --git a/src/lib/automation-note.test.ts b/src/lib/automation-note.test.tsindex f0e5552d36..f4365e391b 100644--- a/src/lib/automation-note.test.ts+++ b/src/lib/automation-note.test.ts@@ -71,6 +71,14 @@ describe("automationNote", () => {expect(automationNote(line(text))?.wait).toBe("release [QA");});+ it("picks the wait whose card matches the whole line, not the longest name that starts it", () => {+ const build = waitCard("build", "prod] Check logs and notify."), prod = waitCard("build] prod", "Check logs");+ const waits = knownWaits([build, prod]);+ expect(automationNote(line(followUpLine("build", "prod] Check logs and notify.")), waits)).toEqual({ wait: "build", instructions: "prod] Check logs and notify." });+ expect(automationNote(line(followUpLine("build] prod", "Check logs")), waits)).toEqual({ wait: "build] prod", instructions: "Check logs" });+ expect(automationNote(line(followUpLine("build", "prod] Check logs and notify.", "restarted")), waits)).toMatchObject({ wait: "build", instructions: "prod] Check logs and notify.", resumed: "restart" });+ });+it("sends again the line a reply answers, and offers for editing only what the person typed", () => {const asked = typed("Tell me when the report is ready", { id: "asked" });const wait = line(followUpLine("the report", "Say it is ready."), { id: "wait" });diff --git a/src/lib/automation-note.ts b/src/lib/automation-note.tsindex f10a53addd..b9f396425e 100644--- a/src/lib/automation-note.ts+++ b/src/lib/automation-note.ts@@ -26,10 +26,13 @@ export function knownWaits(messages: readonly Pick<Message, "card">[]): KnownWai}// A label may itself hold "] ", where the text alone cannot tell it from the instructions: the wait's card can.+// The card that matches the whole line, second-start part aside, wins over one whose name and instructions only start it.function waitLabel(text: string, waits: readonly KnownWait[]): string | undefined {if (!text.startsWith(PREFIX)) return undefined;+ const body = text.slice(0, SECOND_START.exec(text)?.index ?? text.length).trim();const named = waits.filter((wait) => text.startsWith(`${PREFIX}${wait.label}] `)).sort((a, b) => b.label.length - a.label.length);- return (named.find((wait) => text.startsWith(`${PREFIX}${wait.label}] ${wait.followUp}`)) ?? named[0])?.label ?? WAIT_FINISHED.exec(text)?.[1];+ const said = (wait: KnownWait) => `${PREFIX}${wait.label}] ${wait.followUp}`;+ return (named.find((wait) => body === said(wait).trim()) ?? named.find((wait) => body.startsWith(said(wait))) ?? named[0])?.label ?? WAIT_FINISHED.exec(text)?.[1];}/** Only a line the server marked as started by an automation: the same words typed by a person stay theirs. */