Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix: say "hasn't started yet" once per held hand-off (#5039)
Bugfixer 293fe0d39ebc3
diff --git a/server/host/wait-words.test.ts b/server/host/wait-words.test.tsindex d2153c1088..e8f4f053f6 100644--- a/server/host/wait-words.test.ts+++ b/server/host/wait-words.test.ts@@ -51,7 +51,7 @@ describe("a hand-off held a while", () => {const node = { id: "h", threadId: "t", botId: "b", lastProgressAt: 0, status: "queued" } as HandoffView;const notes = (over: Partial<QueuedNotesDeps> = {}, now = QUEUED_NOTE_AFTER_MS) => {const posted: string[] = [];- const note = createQueuedNotes({ now: () => now, language: () => undefined, botName: () => "Ops", parent: () => ({ threadId: "p" }) as HandoffView, post: (_p, _n, line) => posted.push(line), live: () => true,+ const note = createQueuedNotes({ now: () => now, language: () => undefined, botName: () => "Ops", parent: () => ({ threadId: "p" }) as HandoffView, post: (_p, _n, line) => posted.push(line), node: () => node,threadBusy: () => false, slots: () => ({ busy: [], limit: 16 }), groupTurn: () => false, waitsForComputer: () => false, behindPerson: () => undefined, ...over });return { note, posted };};@@ -72,6 +72,13 @@ describe("a hand-off held a while", () => {expect(room.posted).toEqual(["Ops hasn't started this yet: it's finishing a turn in a room."]);});+ it("says it once for each of several hand-offs held behind the same turn, however often the queue is checked", () => {+ const held = ["r1", "r2", "q"].map((id) => ({ ...node, id, status: id === "q" ? "queued" : "resume" }) as HandoffView);+ const { note, posted } = notes({ threadBusy: () => true, node: (id) => held.find((n) => n.id === id) });+ for (let tick = 0; tick < 4; tick++) for (const n of held) note(n);+ expect(posted).toHaveLength(3);+ });+it("stays quiet for a short hold, a room's own hand-off, a computer's wait and a person's open card, which say so themselves", () => {const busy = { threadBusy: () => true };for (const { over, at, row } of [diff --git a/server/host/wait-words.ts b/server/host/wait-words.tsindex 6c1ee360f3..8a3a7e24d6 100644--- a/server/host/wait-words.ts+++ b/server/host/wait-words.ts@@ -41,9 +41,13 @@ export interface QueuedNotesDeps extends Pick<QueuedReasonDeps, "botName" | "thrlanguage(threadId: string): string | undefined;parent(node: HandoffView): HandoffView | undefined;post(parent: HandoffView, node: HandoffView, line: string): void;- live(id: string): boolean;+ node(id: string): HandoffView | undefined;}+/** The runtime holds a resuming hand-off behind a busy turn too: counting only "queued" as still held let two such+ * hand-offs prune each other's note and post it again on every check. */+const stillHeld = (node: HandoffView | undefined): boolean => node?.status === "queued" || node?.status === "resume";+/** One line in the requester's chat once a hand-off has been held a while, naming the limit. A computer's wait and a person's* open card say so themselves. */export function createQueuedNotes(deps: QueuedNotesDeps) {@@ -59,7 +63,7 @@ export function createQueuedNotes(deps: QueuedNotesDeps) {: busy.length >= limit ? serverLine(language, "server.teammates.queued.slots", { bot, busy: busy.length, limit }): deps.groupTurn(node.botId) ? serverLine(language, "server.teammates.queued.room", { bot }) : undefined;if (!line) return;- for (const id of noted) if (!deps.live(id)) noted.delete(id);+ for (const id of noted) if (!stillHeld(deps.node(id))) noted.delete(id);noted.add(node.id);deps.post(parent, node, line);};diff --git a/server/index.ts b/server/index.tsindex bb50591773..d180b8f0d6 100644--- a/server/index.ts+++ b/server/index.ts@@ -3771,7 +3771,7 @@ function coordinationSystemInstructions(): string {const threadReadableFrom = (threadId: string) => (other: string): boolean => !proactive.fence.confines(other) && !botApiThread(other) && (CLOUD_TEAM ? teamHost.readableFrom(threadId)(other) : !CLOUD_HOME || cloudOwnerOnlyThread(other));const queuedDeps = { botName: (id: string) => store.bot(id)?.name, threadBusy, groupTurn: (id: string) => Boolean(activeGroupTurnForBot(id)), behindPerson: queuedBehindPerson,waitsForComputer: (node: HandoffView) => { const seat = parkedSeats.get(node.id); return Boolean(seat && !turnResources.free(seat)); },- slots: (id: string) => ({ busy: store.tasks(id).filter((task) => threadBusy(id, task.threadId)).map(({ threadId, title }) => ({ threadId, title })), limit: maxConcurrentChildThreads(cfg, botThreadsHost(cloudPlanTier.starter())) }) }; const queuedStatus = createQueuedReason(queuedDeps), queuedNotes = createQueuedNotes({ ...queuedDeps, now: Date.now, language: (threadId) => threadLanguage(threadId), parent: (node) => node.parentId ? coordinator.node(node.parentId) : undefined, live: (id) => coordinator.node(id)?.status === "queued", post: (parent, node, line) => { const bot = store.bot(node.botId), title = store.taskByThread(node.botId, node.threadId)?.title; store.appendMessage(parent.threadId, { role: "bot", kind: "activity", ...(bot ? { from: { botId: bot.id, name: bot.name, color: bot.color } } : {}), tool: { name: line, ok: true }, ...(title ? { threadRef: { botId: node.botId, threadId: node.threadId, title } } : {}) }); } });+ slots: (id: string) => ({ busy: store.tasks(id).filter((task) => threadBusy(id, task.threadId)).map(({ threadId, title }) => ({ threadId, title })), limit: maxConcurrentChildThreads(cfg, botThreadsHost(cloudPlanTier.starter())) }) }; const queuedStatus = createQueuedReason(queuedDeps), queuedNotes = createQueuedNotes({ ...queuedDeps, now: Date.now, language: (threadId) => threadLanguage(threadId), parent: (node) => node.parentId ? coordinator.node(node.parentId) : undefined, node: (id) => coordinator.node(id), post: (parent, node, line) => { const bot = store.bot(node.botId), title = store.taskByThread(node.botId, node.threadId)?.title; store.appendMessage(parent.threadId, { role: "bot", kind: "activity", ...(bot ? { from: { botId: bot.id, name: bot.name, color: bot.color } } : {}), tool: { name: line, ok: true }, ...(title ? { threadRef: { botId: node.botId, threadId: node.threadId, title } } : {}) }); } });const asksActingPerson = createAsksActingPerson({ team: Boolean(CLOUD_TEAM), requester: (threadId, generation) => actingPeople.requester(threadId, generation), askedPerson: (botId, threadId) => teamOwners.routing.askedPerson(botId, threadId) });const teammatePrompts = createTeammatePrompts({ store, asksActingPerson, outstandingDirect: (threadId) => coordinator.outstandingDirect(threadId), openPersonCard, queuedStatus, isUnattended, fullAccess: fullAccessForSource, startedOutside, guestDriven: cloudGuestDriven, confined: (threadId) => proactive.fence.confines(threadId), readableFrom: threadReadableFrom, waitingForPerson: (chief, teammates, readable) => questionRouting.waitingForPerson(chief, teammates, readable) });