Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(runtime): a NEEDS INPUT line that says "none" asks nothing
AdityaUmale27333c386609
diff --git a/server/host/acting-person.test.ts b/server/host/acting-person.test.tsindex 5d7168a671..472da9dbcc 100644--- a/server/host/acting-person.test.ts+++ b/server/host/acting-person.test.ts@@ -219,6 +219,7 @@ describe("what work in one person's private chat hands back", () => {const asked = privateHandBack({ ok: true, text: "Found two.\nNEEDS INPUT: Forward the salary review to Ben?", cards: { question: "Forward the salary review to Ben?", ids: ["c1"] } }, place(null));expect(asked).toEqual({ ok: true, text: "NEEDS INPUT: Helper has a question for Ada, in Helper's chat with Ada.", cards: { question: "Helper has a question for Ada, in Helper's chat with Ada.", ids: ["c1"] }, privateQuestion: true });expect(privateHandBack({ ok: true, text: "Found two.\nNEEDS INPUT: Forward it to Ben?" }, place(null)), "only she can answer it").toMatchObject({ privateQuestion: true });+ expect(privateHandBack({ ok: true, text: "Found two.\nNEEDS INPUT: 无" }, place(null)), "a line that asks nothing").toEqual({ ok: true, text: "Done. The result is in Helper's chat with Ada." });});it("hands everything back into her own private chat, and anything from a chat others read already", () => {diff --git a/server/host/acting-person.ts b/server/host/acting-person.tsindex a5d74a92f7..c3e71f603e 100644--- a/server/host/acting-person.ts+++ b/server/host/acting-person.ts@@ -13,6 +13,7 @@ import { z } from "zod";import { writeFileAtomic } from "../atomic.ts";import { answeredByPerson } from "../cloud-lending.ts";import type { WorkOrigin } from "../peer-provenance.ts";+import { needsInputQuestion } from "../runtime-coordinator.ts";export const HANDED_PEOPLE_FILE = "handed-people.json";@@ -166,7 +167,7 @@ type Place = { child: string | null; parent: string | null };/** Work in one person's private chat, for a requester whose chat is not that one: its words stay with that person. */export const keptPrivate = (place: Place): boolean => Boolean(place.child) && place.parent !== place.child;-const lastLineAsks = (text: string) => /^needs input:/i.test(text.trimEnd().split(/\r?\n/).at(-1)?.trim() ?? "");+const lastLineAsks = (text: string) => needsInputQuestion(text.trimEnd().split(/\r?\n/).at(-1) ?? "") !== undefined;/** What work that ran in one person's private chat hands back to a place others read: where its result is, never the* result, which may hold what their own apps brought back or their private notes (a private chat never reaches a room:diff --git a/server/runtime-coordinator.test.ts b/server/runtime-coordinator.test.tsindex a26c24052a..bf7053d5a4 100644--- a/server/runtime-coordinator.test.ts+++ b/server/runtime-coordinator.test.ts@@ -183,6 +183,15 @@ describe("needsInputQuestion", () => {expect(needsInputQuestion("")).toBeUndefined();expect(needsInputQuestion("Done.")).toBeUndefined();});++ it("reads a NEEDS INPUT line that only says there is nothing to ask, in any language, as no question", () => {+ for (const none of ["无", "无。", "没有", "无需", "none", "None.", "N/A", "nothing", "nil", "-", "なし", "없음", "нет", "ninguna", "aucune", "keine"]) {+ expect(needsInputQuestion(`Imported all 8 guides.\nNEEDS INPUT: ${none}`), none).toBeUndefined();+ }+ expect(needsInputQuestion("Imported all 8 guides.\nNEEDS INPUT: 无\nDefault: 结单")).toBeUndefined();+ expect(needsInputQuestion("NEEDS INPUT: None of the regions work; which one should I try?")).toBe("None of the regions work; which one should I try?");+ expect(needsInputQuestion("NEEDS INPUT: 无法登录,用哪个账号?")).toBe("无法登录,用哪个账号?");+ });});describe("RuntimeCoordinator: the requesting turn and its tree", () => {@@ -805,6 +814,16 @@ describe("RuntimeCoordinator: the run adapter", () => {expect(w.coordinator.node(node.id)).toMatchObject({ status: "completed", result: "builder done" });});+ it("completes a turn whose NEEDS INPUT line says there is nothing to ask, and reports it once", async () => {+ const w = world((node) => node.botId === "builder" ? { ok: true, text: "Imported all 8 guides.\nNEEDS INPUT: 无" } : undefined);+ const { node } = send(w, chief, "gen-1", undefined, builder, "Import the guides");+ w.coordinator.tick(); await flush();+ w.coordinator.tick(); await flush();+ expect(w.host.parks).toHaveLength(0);+ expect(w.coordinator.node(node.id)).toMatchObject({ status: "completed", result: "Imported all 8 guides.\nNEEDS INPUT: 无" });+ expect(w.host.runs.filter(run => run.node.id === node.id)).toHaveLength(1);+ });+it("resumes the requester with a teammate's NEEDS INPUT question while its other teammate still works", async () => {let asked = false;const w = world((node) => {diff --git a/server/runtime-coordinator.ts b/server/runtime-coordinator.tsindex 47f087225e..e9ad64cee8 100644--- a/server/runtime-coordinator.ts+++ b/server/runtime-coordinator.ts@@ -34,6 +34,9 @@ const requestKey = (root: Assignment): string => root.origin.kind === "person" ?const BRIEF_MAX = 12_000;const RUNTIME_DEPTH = /^Assignment depth limit reached/;const NEEDS_INPUT = /^needs input:/i;+/** A NEEDS INPUT line whose whole value says there is nothing to ask ("none", "无", …) asks nothing. */+const NOTHING_TO_ASK = new Set(["none", "nothing", "n/a", "nil", "-", "—", "无", "無", "没有", "沒有", "无需", "暂无", "なし", "없음", "нет",+ "ninguna", "ninguno", "nada", "aucune", "aucun", "rien", "keine", "nichts", "nenhuma", "nenhum", "không", "ไม่มี"]);/** Per-turn stalls belong to the host's watchdog: this only keeps the runtime's window out of its way. */const TURN_STALL_MS = 24 * 60 * 60_000;@@ -85,7 +88,9 @@ export function needsInputQuestion(text: string): string | undefined {const at = /^default:/i.test(lines[last]!.trim()) ? filled(last - 1) : last;const line = at < 0 ? "" : lines[at]!.trim();if (!NEEDS_INPUT.test(line)) return undefined;- const question = [line.slice("NEEDS INPUT:".length), ...lines.slice(at + 1)].join("\n").trim();+ const value = line.slice("NEEDS INPUT:".length).trim();+ if (NOTHING_TO_ASK.has(value.replace(/[.!。!]+$/u, "").toLowerCase())) return undefined;+ const question = [value, ...lines.slice(at + 1)].join("\n").trim();return question || undefined;}