Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Cancel every room turn before awaiting their interrupts together
AdityaUmaleab78593e2977
diff --git a/server/routes/bot-lifecycle.ts b/server/routes/bot-lifecycle.tsindex 3b11affbd6..cea6bab91a 100644--- a/server/routes/bot-lifecycle.ts+++ b/server/routes/bot-lifecycle.ts@@ -45,12 +45,14 @@ export function createBotLifecycleRoutes(deps: BotLifecycleRouteDeps): RouteHand}await routines!.cancelRun(routineRun.id);}- for (const groupTurn of groupTurnsForBot(bot.id)) {+ const groupTurns = groupTurnsForBot(bot.id);+ for (const groupTurn of groupTurns) {cancelGroupTurnOperations(groupTurn.group.id, groupTurn.threadId);revokeInternalCapabilitiesForThread(groupTurn.threadId);- await runningTurnInstance(bot, groupTurn.threadId)?.adapter.interruptTurn(groupTurn.threadId).catch(() => {});- closeOpenApprovals(groupTurn.threadId);}+ await Promise.allSettled(groupTurns.map((groupTurn) =>+ runningTurnInstance(bot, groupTurn.threadId)?.adapter.interruptTurn(groupTurn.threadId)));+ for (const groupTurn of groupTurns) closeOpenApprovals(groupTurn.threadId);}),);return json(res, 200, { ok: true });diff --git a/server/routes/bot-patch.ts b/server/routes/bot-patch.tsindex ff6932a872..31cb3fbb40 100644--- a/server/routes/bot-patch.ts+++ b/server/routes/bot-patch.ts@@ -678,12 +678,14 @@ export function createBotPatchRoutes(deps: BotPatchRouteDeps): RouteHandler {await interruptAllDirectThreads(existingBot.id);const routine = routines!.activeBotRunForBot(existingBot.id);if (routine) await routines!.cancelRun(routine.id);- for (const groupTurn of groupTurnsForBot(existingBot.id)) {+ const groupTurns = groupTurnsForBot(existingBot.id);+ for (const groupTurn of groupTurns) {cancelGroupTurnOperations(groupTurn.group.id, groupTurn.threadId);revokeInternalCapabilitiesForThread(groupTurn.threadId);- await runningTurnInstance(existingBot, groupTurn.threadId)?.adapter.interruptTurn(groupTurn.threadId).catch(() => {});- closeOpenApprovals(groupTurn.threadId);}+ await Promise.allSettled(groupTurns.map((groupTurn) =>+ runningTurnInstance(existingBot, groupTurn.threadId)?.adapter.interruptTurn(groupTurn.threadId)));+ for (const groupTurn of groupTurns) closeOpenApprovals(groupTurn.threadId);}const chiefMovedSections =Boolean(existingBot?.chiefOfStaff) &&