Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Chief answers for the person: remove a duplicate import, keep server/index.ts in its ratchet

Doğukaan Kılıçarslan0caeb3aeeeec
diff --git a/server/host/teammate-prompts.test.ts b/server/host/teammate-prompts.test.ts
index 44cbbe0037..e74927d526 100644
--- a/server/host/teammate-prompts.test.ts
+++ b/server/host/teammate-prompts.test.ts
@@ -2,7 +2,7 @@ import { describe, expect, it, vi } from "vitest";
import type { BotRecord } from "../store.ts";
import { LONG_WAIT_MS, waitedWords } from "./long-waits.ts";
-import { createAsksActingPerson, createAsksActingPerson, createTeammatePrompts, type TeammatePromptDeps } from "./teammate-prompts.ts";
+import { createAsksActingPerson, createTeammatePrompts, type TeammatePromptDeps } from "./teammate-prompts.ts";
vi.mock("../peer-roster.ts", () => ({ canManage: () => true }));
diff --git a/server/host/teammate-prompts.ts b/server/host/teammate-prompts.ts
index 37803bbaf1..434f23df51 100644
--- a/server/host/teammate-prompts.ts
+++ b/server/host/teammate-prompts.ts
@@ -28,6 +28,15 @@ export interface TeammatePromptDeps {
now?(): number;
}
+/** What a coordinate_bots call tells the bot to do next. */
+export function coordinateResultMessage(reply: "none" | "poll" | "resume", answeredOnly: boolean): string {
+ if (reply === "none") return "Sent one way. Nothing comes back and nothing resumes you; continue your turn.";
+ if (answeredOnly) return "Answered for the person. Nothing comes back and nothing resumes you; continue your turn and tell the person what you answered.";
+ return reply === "poll"
+ ? "Handed to the coordinator. Read each result with assignment_status (id: a receipt's requestId, or rootId for the whole call), long-polling with wait_ms."
+ : "End your turn after sending all work. These actual teammates will reply and resume you automatically. Do not poll or wait.";
+}
+
/** Security invariant: on a team a Chief answers a teammate's question only for the person it is for, and only in a turn that person drives.
* A room's turn names its person only through its generation. */
export function createAsksActingPerson(deps: {
diff --git a/server/index.ts b/server/index.ts
index 5e6466cfb7..5d23286f8d 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -296,7 +296,7 @@ import { createLiveApprovalMode } from "./host/live-approval.ts";
import { CONSENT_RULE, escapeNotes, labelledLine, OUTSIDE, peerLineText, peerProvenanceNote, reportNote, requestWorkOrigin, type WorkOrigin } from "./peer-provenance.ts"; import { lineNote, PROVENANCE_PROMPT } from "./provenance-label.ts"; import { openRoomThread } from "./host/room-new-thread.ts"; import { createLineLabels } from "./host/line-labels.ts";
import { decideRoomPost, emptyRoomPostBudget, type RoomPostAttempt, type RoomPostBudget } from "./room-post-budget.ts";
import { messagePages, pageSize, slimMessage } from "./host/message-pages.ts";
-import { createAsksActingPerson, createAsksActingPerson, createTeammatePrompts } from "./host/teammate-prompts.ts"; import { createMausBotOwnChat } from "./host/mausbot-own-chat.ts"; import { moveMemoryLayer } from "./memory-move.ts";
+import { coordinateResultMessage, createAsksActingPerson, createTeammatePrompts } from "./host/teammate-prompts.ts"; import { createMausBotOwnChat } from "./host/mausbot-own-chat.ts"; import { moveMemoryLayer } from "./memory-move.ts";
import { createQueuedReason } from "./host/queued-reason.ts";
import { ReplayBuffer } from "./host/sse-replay.ts";
import {
@@ -13936,13 +13936,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {
const lead = destination && sent ? roomJobs.describeRoomJobs(destination, roomThreadId!, receipts,
{ senderId: internalSender.id, returns, lanes, awaited: reply !== "none" }) : "";
if (EXTERNAL) coordinator.endTurn(generation, { ok: sent, text: sent ? "" : refused.join("; ") });
- const message = reply === "none"
- ? "Sent one way. Nothing comes back and nothing resumes you; continue your turn."
- : answeredOnly
- ? "Answered for the person. Nothing comes back and nothing resumes you; continue your turn and tell the person what you answered."
- : reply === "poll"
- ? "Handed to the coordinator. Read each result with assignment_status (id: a receipt's requestId, or rootId for the whole call), long-polling with wait_ms."
- : "End your turn after sending all work. These actual teammates will reply and resume you automatically. Do not poll or wait.";
+ const message = coordinateResultMessage(reply, answeredOnly);
return { status: sent ? 200 : 409, body: { receipts, ...(sent ? { message: lead ? `${lead} ${message}` : message } : { error: refused.join("; ") }),
...(EXTERNAL && sent ? { rootId: generation } : {}) } };
};