Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge pull request #5123 from AdityaUmale/fix/mail-1a1bd0ca-steer-own-thread
milind-soni0a6f58e26181
diff --cc server/host/question-routing.tsindex 48f4ae3742,cca94a1ceb..ee92fc8e9f--- a/server/host/question-routing.ts+++ b/server/host/question-routing.ts@@@ -94,9 -92,10 +94,10 @@@ export function createQuestionRouting(d* that question, or when it goes to the thread (`threadId`) where work the sender handed on in an earlier turn waits on* a question (not on a sign-in only the person can do). Otherwise, to the thread where such work is running, it is* handed to that running turn. Work handed out in this very turn (`sentThisTurn`) stays apart: a second assignment is its- * own. Undefined when it goes into no work; a failed receipt when `answers` names work that no longer asks. */+ * own. When the sender chose `threadId` itself (`selected`: a report-back thread it steers), a question it carries from another+ * thread does not take the message. Undefined when it goes into no work; a failed receipt when `answers` names work that no longer asks. */async function relay(input: { sender: BotRecord; senderThreadId: string; senderNode?: HandoffView; target: BotRecord; message: string; answers?: string;- threadId?: string; sentThisTurn?: ReadonlySet<string>; lends?: boolean }): Promise<PeerDeliveryReceipt | undefined> {- threadId?: string; selected?: boolean; sentThisTurn?: ReadonlySet<string> }): Promise<PeerDeliveryReceipt | undefined> {++ threadId?: string; selected?: boolean; sentThisTurn?: ReadonlySet<string>; lends?: boolean }): Promise<PeerDeliveryReceipt | undefined> {const { sender, target, message } = input;const waiting = waitingOn(target).filter((one) => deps.mayReach(input.senderThreadId, one.threadId));const ownWork = (node: HandoffView | undefined): node is HandoffView => node !== undefined && node.threadId === input.threadIddiff --cc server/index.tsindex 3a3cd34bdf,b8f3371f2a..f80ff103fd--- a/server/index.ts+++ b/server/index.ts@@@ -13766,8 -13799,8 +13766,8 @@@ const handleRequest = async (req: Incomif (forPerson) { if (forPerson.outcome === "failed") refused.push(forPerson.detail); else answeredForPerson.add(forPerson); receipts.push(forPerson); continue; }const continued = room || fresh ? undefined : workThreadFor(store, { botId: target.botId, botName: recipient.name, fromBotId: internalSender.id, fromThreadId: address.threadId, thread: call.thread, notice: mode === "notify",answering: coordinator.answersTo(internalCapability.roomHandoffId ?? generation), also: (task) => !CLOUD_TEAM || threadStarters.get(task.threadId) === opener, reach: (task) => outsideLineage.mayReach(address.threadId, task.threadId) });- const relayed = EXTERNAL || (!call.answers && (room || fresh || mode === "consult")) ? undefined : await questionRouting.relay({ sender: internalSender, senderThreadId: address.threadId,+ const relayed = EXTERNAL || (!call.answers && (room || fresh || mode === "consult")) ? undefined : await questionRouting.relay({ lends, sender: internalSender, senderThreadId: address.threadId,- senderNode: coordinator.node(internalCapability.roomHandoffId ?? generation), target: recipient, message: call.message, ...(call.answers ? { answers: call.answers } : {}), ...(continued ? { threadId: continued.threadId } : {}),+ senderNode: coordinator.node(internalCapability.roomHandoffId ?? generation), target: recipient, message: call.message, ...(call.answers ? { answers: call.answers } : {}), ...(continued ? { threadId: continued.threadId, ...(steersOwn ? { selected: true } : {}) } : {}),...(internalCapability.delegatedThisTurn ? { sentThisTurn: internalCapability.delegatedThisTurn } : {}) });if (relayed) { if (relayed.outcome === "failed") refused.push(relayed.detail); receipts.push(relayed); continue; }const lane = room && lanes ? roomJobs.openLane(room, target.threadId, target.botId, internalSender, call.message) : undefined;@@@ -13787,10 -13820,10 +13787,10 @@@const routed = lane ? { botId: target.botId, threadId: lane.threadId } : target;outsideLineage.carry(address.threadId, routed.threadId);const { node, duplicate } = coordinator.enqueue(address, generation, internalCapability.roomHandoffId, routed, call.message, {- mode, reply, thread: lane || fresh ? "new" : "standing", rework: call.rework, ...(lane ? {} : { requestBatchKey }), ...(call.ownThread ? { ownThread: true } : {}),- mode, reply, thread: lane || fresh || steersOwn ? "new" : "standing", approvalGranted, rework: call.rework, ...(lane ? {} : { requestBatchKey }), ...(call.ownThread || steersOwn ? { ownThread: true } : {}),++ mode, reply, thread: lane || fresh || steersOwn ? "new" : "standing", rework: call.rework, ...(lane ? {} : { requestBatchKey }), ...(call.ownThread || steersOwn ? { ownThread: true } : {}),...(call.doneWhen ? { doneWhen: call.doneWhen } : {}),});- usageTrace.link(node.id, node.parentId, { threadId: internalCapability.threadId, turnId: liveTurnByThread.get(internalCapability.threadId) ?? "" }); if (!duplicate) actingPeople.handOn(internalCapability, node);+ usageTrace.link(node.id, node.parentId, { threadId: internalCapability.threadId, turnId: liveTurnByThread.get(internalCapability.threadId) ?? "" }); if (!duplicate) { actingPeople.handOn(internalCapability, node, lends); if (!lends && !room && !lane) handedInUnproven(routed.threadId); }if (duplicate && createdThread) store.deleteTask(target.botId, createdThread);else if (createdThread) {threadStarters.set(createdThread, opener);