Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(team): honor explicit representative wait decisions
Afloatc538daed083e
diff --git a/server/host/representative-wait.test.ts b/server/host/representative-wait.test.tsnew file mode 100644index 0000000000..f7461fe649--- /dev/null+++ b/server/host/representative-wait.test.ts@@ -0,0 +1,30 @@+import { describe, expect, it } from "vitest";++import { createRepresentative, readAnswer, type Question } from "./representative.ts";++describe("an explicit representative wait", () => {+ it.each([+ '{"wait":true,"answer":"Ben is free on Friday."}',+ '{"answer":"Ben is free on Friday.","wait":true}',+ ])("takes precedence over a draft answer in %s", (raw) => {+ expect(readAnswer(raw, "Ben")).toBeNull();+ });++ it("does not return an answer the model has marked as waiting for the person", async () => {+ const input: Question = {+ person: { key: "p_ben", name: "Ben" }, bot: { id: "bens-chief" },+ team: "Acme", asker: "Cleo", question: "Is Ben free on Friday?", shared: { notes: [], work: [] },+ };+ const assistant = createRepresentative({+ busy: async () => [], generate: async () => '{"wait":true,"answer":"Ben is free on Friday."}',+ timeZone: () => "UTC", now: () => Date.UTC(2026, 9, 27),+ });+ expect(await assistant.answer(input)).toBeNull();+ });++ it("continues to accept an ordinary answer and an explicitly false wait", () => {+ expect(readAnswer('{"answer":"Ben is busy."}', "Ben")).toBe("Ben is busy.");+ expect(readAnswer('{"answer":"Ben is busy.","wait":false}', "Ben")).toBe("Ben is busy.");+ expect(readAnswer('{"wait":true}', "Ben")).toBeNull();+ });+});diff --git a/server/host/representative.ts b/server/host/representative.tsindex a8a2a18c27..ff42ce17b2 100644--- a/server/host/representative.ts+++ b/server/host/representative.ts@@ -125,7 +125,10 @@ export function readAnswer(raw: string, name: string): string | null {if (!json) return null;let parsed: unknown;try { parsed = JSON.parse(json); } catch { return null; }- const answer = parsed && typeof parsed === "object" ? (parsed as { answer?: unknown }).answer : undefined;+ if (!parsed || typeof parsed !== "object") return null;+ const response = parsed as { answer?: unknown; wait?: unknown };+ if (response.wait === true) return null;+ const answer = response.answer;if (typeof answer !== "string") return null;const text = oneLine(answer, MAX_ANSWER);return text && !commits(text, name) ? text : null;