Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(agents): same-turn assignment_status wording follows the hand-off's reply mode (#7180)
Santhi Prakashfda74938d195
diff --git a/server/coordinator.ts b/server/coordinator.tsindex b9d6bc593d..06a85c3fd9 100644--- a/server/coordinator.ts+++ b/server/coordinator.ts@@ -263,6 +263,13 @@ export interface CoordinatorOptions {wrote?: () => void;}+/** The outcome clause for the same-turn "finish your response" answer about an assignment this turn handed out, from its+ * reply mode — the same wording the coordinate_bots receipt gives. */+export const sameTurnReturns = (reply: Reply | undefined): string =>+ reply === "none" ? "nothing comes back from it"+ : reply === "poll" ? "read its result with assignment_status"+ : "its result returns to this conversation and resumes you";+export function createCoordinator(options: CoordinatorOptions): Coordinator {return new RuntimeCoordinator(options);}diff --git a/server/index.ts b/server/index.tsindex be7439d9aa..e8b6257185 100644--- a/server/index.ts+++ b/server/index.ts@@ -24,7 +24,7 @@ import { LentComputers, provenRequestPerson, SharedComputers, sharedComputerOperimport { cloudHomeLendingRefusal, cloudHomeOwnTurnRefusal, createCloudRoutineAuthors, ownerOnlyConversation } from "./cloud-lending.ts"; import { createOwnHome, oneOwner, selfHostedPersonName } from "./own-home.ts"; import { createPlacesElsewhere } from "./places-elsewhere.ts"; import { createPlacesElsewhereRoutes } from "./routes/places-elsewhere.ts"; import { assertRoomFolder } from "./room-folder.ts"; import { cloudConnectedAppsBrokerUrl, startCloudHomeConnectedApps, stopCloudHomeConnectedApps } from "./cloud-connected-apps.ts"; import { createTeamConnectionsHost } from "./host/team-connections-host.ts"; import { createCloudLendingTurns } from "./host/cloud-lending-turns.ts"; import { createTeamConnectionRoutes } from "./routes/team-connections.ts";import { botMemoryFiles, createLendingMemory } from "./lending-memory.ts";import { SharedComputerControl } from "./shared-computer-control.ts";-import { STATUS_REPLY_TIMEOUT_MS } from "./runtime/status-reply.ts"; import { createCoordinator, type ComposedTurn, type CoordinateBotsCall, type Coordinator, type HandoffOpener, type HandoffOptions, type HandoffView, type HostTurnResult } from "./coordinator.ts";+import { STATUS_REPLY_TIMEOUT_MS } from "./runtime/status-reply.ts"; import { createCoordinator, sameTurnReturns, type ComposedTurn, type CoordinateBotsCall, type Coordinator, type HandoffOpener, type HandoffOptions, type HandoffView, type HostTurnResult } from "./coordinator.ts";import { queuedBehindPersonText, turnWaitedOnPerson, UnansweredApprovals } from "./waiting-on-person.ts";import { createPersonWaits } from "./host/person-waits.ts"; import { askToolName, createAskCards } from "./host/ask-cards.ts"; import { createQuestionRouting } from "./host/question-routing.ts"; import { workThreadFor } from "./host/work-thread.ts"; import { leaveThreadPost, postToThread, threadWaitsOn, unreadThreadPosts } from "./host/thread-posts.ts"; import { anyCardLive, closedByStop, resumableCards as cardsWaitedOn } from "./host/resumable-cards.ts"; import { createMcpChat } from "./host/mcp-chat.ts"; import { isCardOwnerLive, isMcpSignInCard } from "./host/mcp-sign-in-cards.ts"; import { createConnectCardSettle } from "./host/connect-card-settle.ts";import { assertRequestTarget, guardedRequestPath, requestConflict, requestNeedsInput } from "./guarded-requests.ts";@@ -13658,7 +13658,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {return json(res, 200, { outstanding });}if (internalCapability.delegatedThisTurn?.has(id)) {- return json(res, 409, { error: `Assignment ${id} was handed out during this turn. Finish your response now so the teammate can work; its result returns to this conversation and resumes you. Do not check or wait for it until a later turn.`, sentThisTurn: true });+ return json(res, 409, { error: `Assignment ${id} was handed out during this turn. Finish your response now so the teammate can work; ${sameTurnReturns(coordinator.status(id)?.assignment.reply)}. Do not check or wait for it until a later turn.`, sentThisTurn: true });}const waitMs = Math.min(Math.max(Number(url.searchParams.get("wait_ms")) || 0, 0), 240_000);const deadline = Date.now() + waitMs;diff --git a/server/post-to-room.test.ts b/server/post-to-room.test.tsindex 898cc8a52a..99d8aba5f3 100644--- a/server/post-to-room.test.ts+++ b/server/post-to-room.test.ts@@ -774,4 +774,23 @@ describe("limits counted per turn on a bearer that outlives the turn", () => {expect(field(later.body, "assignment", "id")).toBe(requestId);expect(field(later.body, "assignment", "botId")).toBe(to.id);}, 40_000);++ it("tells a same-turn one-way (reply: none) hand-off that nothing comes back", async () => {+ const from = await makeBot("One Way Delegator", "One way delegations");+ const to = await makeBot("One Way Delegate", "One way delegations");+ const token = await startTurn(from.id, from.threadId);+ const delegated = await asTurn(token, "POST", "/api/internal/coordinate-bots", {+ botIds: [to.id], message: "File the note.", reply: "none",+ });+ expect(delegated.status, JSON.stringify(delegated.body)).toBe(200);+ const receipts = Array.isArray(delegated.body.receipts) ? delegated.body.receipts : [];+ const requestId = str(field(receipts[0] as Record<string, unknown>, "requestId"));+ expect(requestId).not.toBe("");+ const early = await asTurn(token, "GET", `/api/internal/assignment-status?id=${requestId}`);+ expect(early.status).toBe(409);+ expect(early.body.sentThisTurn).toBe(true);+ expect(str(early.body.error)).toContain(`Assignment ${requestId} was handed out during this turn`);+ expect(str(early.body.error)).toContain("nothing comes back from it");+ expect(str(early.body.error)).not.toContain("resumes you");+ }, 40_000);});