Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(chat): preserve handed-on questions beyond result summaries
Afloatd184bc6f9bad
diff --git a/server/coordinator.ts b/server/coordinator.tsindex 5425be54cd..b6b81d7ac5 100644--- a/server/coordinator.ts+++ b/server/coordinator.ts@@ -94,6 +94,7 @@ export interface BeginTurnRequest {export interface HostTurnResult {ok: boolean;text: string;+ question?: string | null;evidence?: TurnEvidence;cap?: { note: string; handoffPath?: string };cards?: { question: string; ids: string[] };diff --git a/server/host/acting-person.test.ts b/server/host/acting-person.test.tsindex 75058116bf..eddbb92305 100644--- a/server/host/acting-person.test.ts+++ b/server/host/acting-person.test.ts@@ -6,6 +6,7 @@ import { describe, expect, it } from "vitest";import { OUTSIDE, workOriginSchema, type WorkOrigin } from "../peer-provenance.ts";import { personKey } from "../person-key.ts";import { createActingPeople, HandedPeople, onlyTheirs, privateHandBack, withPerson, type ActingLine, type DirectRequest, type RoomRun } from "./acting-person.ts";+import { handoffReply } from "../runtime-coordinator.ts";const ADA = personKey({ id: "", email: "[email protected]" });const BEN = personKey({ id: "", email: "[email protected]" });@@ -227,6 +228,21 @@ describe("what work in one person's private chat hands back", () => {expect(privateHandBack(done, place(ADA))).toBe(done);expect(privateHandBack(done, { child: null, parent: null, bot: "Helper", person: "them" })).toBe(done);});++ it("redacts an explicit question even when its line lies beyond the summary", () => {+ const outcome = { ok: true, ...handoffReply(`${"x".repeat(12_001)}\nNEEDS INPUT: Forward the salary review to Ben?\nDefault: Forward it`) };+ const safe = privateHandBack(outcome, place(null));+ expect(safe).toEqual({ ok: true, text: "NEEDS INPUT: Helper has a question for Ada, in Helper's chat with Ada.",+ question: "Helper has a question for Ada, in Helper's chat with Ada.", privateQuestion: true });+ expect(JSON.stringify(safe)).not.toContain("salary");+ expect(privateHandBack(outcome, place(BEN))).toEqual(safe);+ expect(privateHandBack(outcome, place(ADA))).toBe(outcome);+ });++ it("keeps an explicit absence of a question when the shortened summary ends on one", () => {+ const outcome = { ok: true, text: "NEEDS INPUT: Forward the salary review to Ben?", question: null };+ expect(privateHandBack(outcome, place(null))).toEqual({ ok: true, text: "Done. The result is in Helper's chat with Ada.", question: null });+ });});describe("handing on for the desktop app's own window", () => {diff --git a/server/host/acting-person.ts b/server/host/acting-person.tsindex daeec30545..ce0de6775d 100644--- a/server/host/acting-person.ts+++ b/server/host/acting-person.ts@@ -13,7 +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";+import { handoffQuestion } from "../runtime-coordinator.ts";export const HANDED_PEOPLE_FILE = "handed-people.json";@@ -172,7 +172,7 @@ export function createActingPeople(deps: ActingPeopleDeps) {export type ActingPeople = ReturnType<typeof createActingPeople>;-type HandedBack = { ok: boolean; text: string; evidence?: unknown; cards?: { question: string; ids: string[] }; privateQuestion?: boolean; approvalAsk?: string };+type HandedBack = { ok: boolean; text: string; question?: string | null; evidence?: unknown; cards?: { question: string; ids: string[] }; privateQuestion?: boolean; approvalAsk?: string };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. */@@ -187,10 +187,11 @@ export function privateHandBack<T extends HandedBack>(outcome: T, place: Place &const where = `${place.bot}'s chat with ${place.person}`;const question = `${place.bot} has a question for ${place.person}, in ${where}.`;const { evidence: _evidence, ...rest } = outcome;- const asks = needsInputQuestion(outcome.text) !== undefined;+ const asks = handoffQuestion(outcome) !== undefined;return {...rest,text: asks ? `NEEDS INPUT: ${question}` : `${outcome.ok ? "Done" : "It stopped before it finished"}. The result is in ${where}.`,+ ...(outcome.question === undefined ? {} : { question: asks ? question : null }),...(outcome.cards ? { cards: { ...outcome.cards, question } } : {}),...(outcome.approvalAsk ? { approvalAsk: question } : {}),...(asks || outcome.cards || outcome.approvalAsk ? { privateQuestion: true } : {}),diff --git a/server/host/ask-cards.test.ts b/server/host/ask-cards.test.tsindex 644aa79e21..82499d453f 100644--- a/server/host/ask-cards.test.ts+++ b/server/host/ask-cards.test.ts@@ -1,6 +1,8 @@import { describe, expect, it, vi } from "vitest";-import { createCoordinator, type HandoffView } from "../coordinator.ts";+import { createCoordinator, type HandoffView, type HostTurnResult } from "../coordinator.ts";+import { handoffReply } from "../runtime-coordinator.ts";+import { privateHandBack } from "./acting-person.ts";import type { Notification } from "../notify.ts";import type { RequestAuth } from "../request-auth.ts";import type { BotRecord, Message } from "../store.ts";@@ -256,11 +258,12 @@ describe("nothing stale waits on the person", () => {});describe("a handed-on turn owns its question", () => {- it.each(["", "The drafts are ready.\n"])("keeps one answerable card after a reply-none requester finishes, with prefix %j", async (prefix) => {+ it.each([0, 20, 11_995, 12_001])("keeps one answerable card after a reply-none requester finishes, with %i leading characters", async (prefixLength) => {+ const prefix = prefixLength ? `${"x".repeat(prefixLength)}\n` : "";const w = world();- let markParked!: () => void;+ let markFirstSettled!: () => void;let markCompleted!: () => void;- const parked = new Promise<void>((resolve) => { markParked = resolve; });+ const firstSettled = new Promise<void>((resolve) => { markFirstSettled = resolve; });const completed = new Promise<void>((resolve) => { markCompleted = resolve; });const parents: Array<HandoffView["status"] | undefined> = [];const assigners: Array<string | undefined> = [];@@ -269,8 +272,8 @@ describe("a handed-on turn owns its question", () => {validate: () => undefined, busy: () => false, chiefOf: () => false,levelOf: () => ({ level: "ask" }), names: () => ({ assignee: "Ledger", requester: "Scout" }),changed: () => {},- report: (node) => { if (node.parentId && node.status === "completed") markCompleted(); },- park: (node, question) => { w.cards.park(node, question); markParked(); },+ report: (node) => { if (node.parentId && node.status === "completed") { markFirstSettled(); markCompleted(); } },+ park: (node, question) => { w.cards.park(node, question); markFirstSettled(); },run: async (node, _resumed, _signal, composed) => {turns.push(composed.turn);if (composed.turn === "answered") return { ok: true, text: "Used the chosen wording." };@@ -279,7 +282,7 @@ describe("a handed-on turn owns its question", () => {const text = `${prefix}NEEDS INPUT: ${QUESTION}`;w.store.appendMessage(node.threadId, { role: "bot", kind: "text", text, turnId: "handed-turn" });if (!coordinator.assignerOf(node.threadId)) w.cards.ownQuestion(node.botId, node.threadId, "handed-turn");- return { ok: true, text };+ return { ok: true, ...handoffReply(text) };},} });w.deps.node = (id) => coordinator.node(id);@@ -291,11 +294,14 @@ describe("a handed-on turn owns its question", () => {const child = coordinator.enqueue(source, root.id, undefined, { botId: "ledger", threadId: "work" }, "Prepare a footer", { reply: "none" }).node;coordinator.endTurn(root.id, { ok: true, text: "The teammate has the work." });coordinator.tick();- await parked;+ await firstSettled;expect(parents).toEqual(["completed"]);expect(assigners).toEqual([undefined]);+ expect(coordinator.node(child.id)?.status).toBe("waiting");const requestId = `needs-input-${child.id}-1`;expect(w.rows("work").filter((row) => row.card).map((row) => row.card!.requestId)).toEqual([requestId]);+ expect(w.rows("work").find((row) => row.card)?.text).toBe(QUESTION);+ expect(w.rows("work").find((row) => row.card)?.card?.subtitle).toBe(QUESTION);expect(w.notified.map((notification) => notification.kind)).toEqual(["question"]);expect(coordinator.runningIn("work")).toEqual([]);@@ -329,6 +335,116 @@ describe("a handed-on turn owns its question", () => {});});+describe("questions carried separately from a bounded handoff summary", () => {+ type ReplyCase = {+ label: string; text: string; question?: string; default?: string; full?: boolean; outside?: boolean;+ legacy?: boolean; privateReply?: boolean; ok?: boolean; approvalAsk?: string;+ };+ const longQuestion = `${"Q".repeat(12_050)}?`;+ const longDefault = "D".repeat(12_050);+ const privateQuestion = "Forward the salary review to Ben?";+ const safeQuestion = "Ledger has a question for Ada, in Ledger's chat with Ada.";+ const falseEnding = `${"x".repeat(11_970)}\nNEEDS INPUT: ${"Q".repeat(16)}`;+ const cases: ReplyCase[] = [+ { label: "a default beyond a long question", text: `NEEDS INPUT: ${longQuestion}\nDefault: Keep the original`,+ question: `${longQuestion}\nDefault: Keep the original`, default: "Keep the original", full: true },+ { label: "a long default", text: `NEEDS INPUT: Which draft?\nDefault: ${longDefault}`,+ question: `Which draft?\nDefault: ${longDefault}`, default: longDefault, full: true },+ { label: "a person-only request beyond the stored question", text: `NEEDS INPUT: ${longQuestion} Which of your accounts should I use?\nDefault: Pick the first`,+ question: `${longQuestion} Which of your accounts should I use?\nDefault: Pick the first`, full: true },+ { label: "a private question beyond the summary", text: `${"x".repeat(12_001)}\nNEEDS INPUT: ${privateQuestion}\nDefault: Forward it`,+ question: safeQuestion, full: true, privateReply: true },+ { label: "an outside request at Full access", text: `NEEDS INPUT: ${QUESTION}\nDefault: Keep the original`,+ question: `${QUESTION}\nDefault: Keep the original`, full: true, outside: true },+ { label: "a summary cut immediately after an earlier question", text: `${falseEnding}\nResolved it with the existing wording.` },+ { label: "an ordinary long summary", text: "Work is complete. ".repeat(1_000) },+ { label: "a tail that explicitly asks nothing", text: `${"x".repeat(12_001)}\nNEEDS INPUT: none` },+ { label: "a host that still returns only text", text: `NEEDS INPUT: ${QUESTION}`, question: QUESTION, legacy: true },+ { label: "an unanswered approval on a failed turn", text: "The command did not run.", ok: false,+ approvalAsk: "Approve the pending command?", question: "Approve the pending command?" },+ { label: "a failed turn with a textual question", text: `NEEDS INPUT: ${QUESTION}`, ok: false },+ ];++ it.each(cases)("preserves routing for $label", async (fixture) => {+ const w = world({ privateThreads: fixture.privateReply ? ["work"] : [] });+ let markSettled!: () => void;+ const settled = new Promise<void>((resolve) => { markSettled = resolve; });+ const parked: Array<{ node: HandoffView; question: string }> = [];+ let sent!: HostTurnResult;+ const coordinator = createCoordinator({ dataDir: ":memory:", now: () => 1_000, host: {+ validate: () => undefined, busy: () => false, chiefOf: () => false,+ levelOf: () => ({ level: fixture.full ? "full" : "ask" }), names: () => ({ assignee: "Ledger", requester: "Scout" }),+ changed: () => {}, report: (node) => { if (node.parentId) markSettled(); },+ park: (node, question) => { parked.push({ node, question }); w.cards.park(node, question); markSettled(); },+ run: async (node) => {+ const outcome: HostTurnResult = { ok: fixture.ok ?? true, ...(fixture.legacy ? { text: fixture.text } : handoffReply(fixture.text)),+ ...(fixture.approvalAsk ? { approvalAsk: fixture.approvalAsk } : {}) };+ sent = fixture.privateReply ? privateHandBack(outcome, { child: "ada", parent: null, bot: "Ledger", person: "Ada" }) : outcome;+ w.store.appendMessage(node.threadId, { role: "bot", kind: "text", text: fixture.text, turnId: "handed-turn" });+ if (sent.ok && !coordinator.assignerOf(node.threadId)) w.cards.ownQuestion(node.botId, node.threadId, "handed-turn");+ return sent;+ },+ } });+ w.deps.node = (id) => coordinator.node(id);+ w.deps.runningIn = (threadId) => coordinator.runningIn(threadId);+ w.deps.answerNode = (id, text) => coordinator.answerNode(id, text);+ try {+ const source = { botId: "scout", threadId: "inbox" };+ const root = coordinator.beginTurn({ id: "requester-turn", address: source, brief: "Prepare a footer", level: fixture.full ? "full" : "ask",+ origin: fixture.outside ? { kind: "outside" } : { kind: "user", request: "Prepare a footer" } });+ const child = coordinator.enqueue(source, root.id, undefined, { botId: "ledger", threadId: "work" }, "Prepare a footer", { reply: "none" }).node;+ coordinator.endTurn(root.id, { ok: true, text: "The teammate has the work." });+ coordinator.tick();+ await settled;+ const cards = w.rows("work").filter((row) => row.card);+ expect(sent.text.length).toBeLessThanOrEqual(12_000);+ if (!fixture.privateReply) expect(sent.text).toBe(fixture.text.slice(0, 12_000));+ if (fixture.question === undefined) {+ expect(parked).toEqual([]);+ expect(cards).toEqual([]);+ expect(coordinator.node(child.id)?.status).toBe(fixture.ok === false ? "failed" : "completed");+ } else {+ expect(parked).toHaveLength(1);+ expect(cards).toHaveLength(1);+ expect(parked[0]!.question).toBe(fixture.question.slice(0, 12_000));+ expect(parked[0]!.node.decide).toEqual(fixture.default ? { default: fixture.default.slice(0, 12_000) } : undefined);+ expect(coordinator.node(child.id)?.status).toBe(fixture.default ? "queued" : "waiting");+ if (fixture.default) expect(coordinator.node(child.id)?.answer).toBe(fixture.default.slice(0, 12_000));+ }+ if (fixture.privateReply) {+ expect(sent.question).toBe(safeQuestion);+ expect(sent.privateQuestion).toBe(true);+ expect(JSON.stringify(sent)).not.toContain("salary");+ expect(cards[0]?.text).toBe(privateQuestion);+ expect(cards[0]?.card?.subtitle).toBe(privateQuestion);+ expect(cards[0]?.card?.options).toEqual(["Forward it"]);+ expect(JSON.stringify(coordinator.node(child.id))).not.toContain("salary");+ expect(JSON.stringify(w.rows("inbox"))).not.toContain("salary");+ expect(JSON.stringify(w.notified)).not.toContain("salary");+ expect(w.cards.answerParked("work", cards[0]!.card!.requestId!, "Keep it private")).toBe(true);+ expect(coordinator.node(child.id)?.answer).toBe("Keep it private");+ }+ } finally {+ coordinator.close();+ }+ });++ it.each([+ { label: "an earlier execution", startedAt: 2_000 },+ { label: "a shared conversation", shared: true },+ { label: "a room", groupId: "room" },+ ] as Array<{ label: string; startedAt?: number; shared?: boolean; groupId?: string }>)("keeps the supplied card question for $label", (fixture) => {+ const threadId = fixture.groupId ? "room" : "work";+ const w = world({ privateThreads: fixture.shared ? [] : [threadId] });+ w.store.appendMessage(threadId, { role: "bot", kind: "text", text: `NEEDS INPUT: ${QUESTION}`,+ ...(fixture.groupId ? { from: { botId: "ledger", name: "Ledger", color: "teal" } } : {}) });+ const node = w.node({ threadId, ...(fixture.startedAt ? { startedAt: fixture.startedAt } : {}),+ ...(fixture.groupId ? { groupId: fixture.groupId } : {}) });+ w.cards.park(node, safeQuestion);+ expect(w.rows(threadId).find((row) => row.card)?.card?.subtitle).toBe(safeQuestion);+ });+});+describe("how an open question card settles", () => {const parked = () => {const w = world();diff --git a/server/host/ask-cards.ts b/server/host/ask-cards.tsindex 0ab66195ff..d7c5353b67 100644--- a/server/host/ask-cards.ts+++ b/server/host/ask-cards.ts@@ -185,14 +185,16 @@ export function createAskCards(deps: AskCardsDeps) {function questionCard(node: HandoffView, question: string, card: Partial<OptionCardData> = {}): boolean {const requestId = `${OPEN_QUESTION}${node.id}-${node.executions}`;if (store.messagesFor(node.threadId).some((message) => message.card?.requestId === requestId)) return false;- const asked = withDefault(question);+ const since = node.startedAt ?? node.createdAt;+ const asking = askersLines(node).findLast((message) => message.role === "bot" && message.kind === "text" && message.at >= since+ && needsInputQuestion(message.text ?? "") !== undefined);+ const parent = node.parentId && !node.groupId ? deps.node(node.parentId) : undefined;+ const localQuestion = asking && parent && deps.keptPrivate(node.threadId, parent.threadId) ? needsInputQuestion(asking.text!) : undefined;+ const asked = withDefault(localQuestion ?? question);const bot = store.bot(node.botId);const options = asked.default && !card.answeredBy ? [asked.default] : [];const full: OptionCardData = { title: "Your bot has a question", subtitle: asked.question, options, requestId, requestType: "question", ...card };const from = node.groupId && bot ? { from: { botId: bot.id, name: bot.name, color: bot.color } } : {};- const since = node.startedAt ?? node.createdAt;- const asking = askersLines(node).findLast((message) => message.role === "bot" && message.kind === "text" && message.at >= since- && needsInputQuestion(message.text ?? "") !== undefined);const before = asking ? beforeQuestion(asking.text!) : "";if (asking && !before) {store.patchMessage(node.threadId, asking.id, { kind: "options", text: asked.question, card: full });diff --git a/server/index.ts b/server/index.tsindex e47c5e1562..e7537386d8 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, sameTurnReturns, 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 { handoffReply } from "./runtime-coordinator.ts";import { queuedBehindPersonText, turnWaitedOnPerson, UnansweredApprovals } from "./waiting-on-person.ts";import { createPersonWaits } from "./host/person-waits.ts"; import { askToolName, createAskCards, settleRequestCard } from "./host/ask-cards.ts"; import { createQuestionRouting } from "./host/question-routing.ts"; import { besideBusy, workThreadFor } from "./host/work-thread.ts"; import { finishHandedThread, keepHandedThread, reopenHandedThread } from "./host/finished-work.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";@@ -5016,8 +5016,8 @@ bus.subscribe((event: RuntimeEvent) => {message.role === "bot" && message.kind === "text" && message.turnId === event.turnId)?.text : undefined;const text = event.ok ? reply || event.stopReason || "The bot finished without a text reply": stoppedTurnText(event.threadId, event.turnId, undefined, event.stopReason);- const stop = event.ok ? undefined : turnStops.read(event.threadId, event.turnId), handoffPath = stop?.handoffPath, failure = stop?.cause ?? stop?.error;- const outcome: DirectTurnOutcome = { ok: event.ok, text: unansweredApprovals.annotate(event.threadId, event.turnId, text.slice(0, 12_000), event.ok), ...approvalAsk(store.botByThread(event.threadId)?.id, event.threadId, event.turnId),+ const summary = handoffReply(text), stop = event.ok ? undefined : turnStops.read(event.threadId, event.turnId), handoffPath = stop?.handoffPath, failure = stop?.cause ?? stop?.error;+ const outcome: DirectTurnOutcome = { ok: event.ok, ...summary, text: unansweredApprovals.annotate(event.threadId, event.turnId, summary.text, event.ok), ...approvalAsk(store.botByThread(event.threadId)?.id, event.threadId, event.turnId),...(handoffPath ? { cap: { note: STEP_CAP_NOTE, handoffPath } } : {}), ...(event.ok ? {} : { failure: { text: failure ?? "", stopReason: event.stopReason } }) };const owner = directFollowupTurns.complete(event.threadId, event.turnId, outcome);if (owner) {diff --git a/server/runtime-coordinator.ts b/server/runtime-coordinator.tsindex 80477147aa..99c6293cea 100644--- a/server/runtime-coordinator.ts+++ b/server/runtime-coordinator.ts@@ -94,6 +94,14 @@ export function needsInputQuestion(text: string): string | undefined {return question || undefined;}+export function handoffReply(text: string): Pick<HostTurnResult, "text" | "question"> {+ return { text: text.slice(0, BRIEF_MAX), question: needsInputQuestion(text) ?? null };+}++export function handoffQuestion(result: Pick<HostTurnResult, "text" | "question">): string | undefined {+ return result.question === undefined ? needsInputQuestion(result.text) : result.question ?? undefined;+}+export function view(a: Assignment, parent?: Assignment): HandoffView {const groupId = a.assignee.destination.groupId;const status: HandoffView["status"] = hostFirstTurn(a) ? "source" : a.status === "needs_input" ? "waiting" : a.status;@@ -691,7 +699,7 @@ export class RuntimeCoordinator implements Coordinator {if (signal.aborted) return { kind: "failed", outcome: "stopped", text: result.text };if (result.cap) return { kind: "continue", text: result.text, note: result.cap.note, ...(result.cap.handoffPath ? { handoffPath: result.cap.handoffPath } : {}), ...evidence(result) };if (result.cards) return { kind: "needs_input", question: result.cards.question, cards: result.cards.ids, ...evidence(result) };- const question = root ? undefined : needsInputQuestion(result.text);+ const question = root ? undefined : handoffQuestion(result);if (!root && a.origin.kind === "person" && result.approvalAsk && !result.stalled && question === undefined) return { kind: "needs_input", question: result.approvalAsk, ...evidence(result) };if (!result.ok) return { kind: "failed", outcome: result.stalled ? "stalled" : "provider_error", text: result.text, ...(result.failure ? { failure: result.failure } : {}), ...evidence(result) };if (question === undefined) return { kind: "completed", text: result.text, ...(await this.statusOnly(a, parent, input.turn, result, signal) ? { statusOnly: true } : {}), ...evidence(result) };