openfox 1.6.79 → 1.6.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,17 +2,17 @@ import {
2
2
  maybeAutoCompactContext,
3
3
  performManualContextCompaction,
4
4
  resolveCompactionStatsIdentity
5
- } from "./chunk-UCZSBKG7.js";
5
+ } from "./chunk-42TLGPX4.js";
6
6
  import "./chunk-OXI26S7U.js";
7
7
  import "./chunk-CMQCO27Y.js";
8
8
  import "./chunk-DL6ZILAF.js";
9
9
  import "./chunk-PBGOZMVY.js";
10
10
  import "./chunk-VRGRAQDG.js";
11
11
  import "./chunk-CUDAT6SS.js";
12
- import "./chunk-RJRG2VER.js";
12
+ import "./chunk-LHKXWUEK.js";
13
13
  import "./chunk-KIOUKC3Z.js";
14
14
  import "./chunk-TS5XFQ2D.js";
15
- import "./chunk-STYHKCG7.js";
15
+ import "./chunk-UF6D2IPO.js";
16
16
  import "./chunk-BJYPTN5S.js";
17
17
  import "./chunk-NDJ6FKSP.js";
18
18
  import "./chunk-CQGTEGKL.js";
@@ -24,4 +24,4 @@ export {
24
24
  performManualContextCompaction,
25
25
  resolveCompactionStatsIdentity
26
26
  };
27
- //# sourceMappingURL=auto-compaction-KTA6H4HP.js.map
27
+ //# sourceMappingURL=auto-compaction-JSO3ZWSE.js.map
@@ -5,11 +5,11 @@ import {
5
5
  generateSessionName,
6
6
  getSessionMessageCount,
7
7
  needsNameGenerationCheck
8
- } from "./chunk-2IZMUXMP.js";
8
+ } from "./chunk-A5W6JUYZ.js";
9
9
  import {
10
10
  runChatTurn
11
- } from "./chunk-BG7QCFGG.js";
12
- import "./chunk-UCZSBKG7.js";
11
+ } from "./chunk-SJHWJAJA.js";
12
+ import "./chunk-42TLGPX4.js";
13
13
  import "./chunk-OXI26S7U.js";
14
14
  import "./chunk-CMQCO27Y.js";
15
15
  import "./chunk-DL6ZILAF.js";
@@ -18,14 +18,14 @@ import "./chunk-VRGRAQDG.js";
18
18
  import "./chunk-CUDAT6SS.js";
19
19
  import {
20
20
  getEventStore
21
- } from "./chunk-RJRG2VER.js";
21
+ } from "./chunk-LHKXWUEK.js";
22
22
  import "./chunk-KIOUKC3Z.js";
23
23
  import "./chunk-TS5XFQ2D.js";
24
24
  import {
25
25
  createChatMessageMessage,
26
26
  createPhaseChangedMessage,
27
27
  createSessionRunningMessage
28
- } from "./chunk-STYHKCG7.js";
28
+ } from "./chunk-UF6D2IPO.js";
29
29
  import "./chunk-BJYPTN5S.js";
30
30
  import "./chunk-NDJ6FKSP.js";
31
31
  import "./chunk-CQGTEGKL.js";
@@ -61,7 +61,7 @@ async function startChatSession(sessionId, content, deps, options) {
61
61
  sessionManager.setRunning(sessionId, true);
62
62
  broadcastForSession(sessionId, createSessionRunningMessage(true));
63
63
  try {
64
- const { maybeAutoCompactContext } = await import("./auto-compaction-KTA6H4HP.js");
64
+ const { maybeAutoCompactContext } = await import("./auto-compaction-JSO3ZWSE.js");
65
65
  await maybeAutoCompactContext({
66
66
  sessionManager,
67
67
  sessionId,
@@ -113,8 +113,11 @@ async function startChatSession(sessionId, content, deps, options) {
113
113
  if (activeAgents.get(sessionId) === controller) {
114
114
  activeAgents.delete(sessionId);
115
115
  }
116
- sessionManager.setRunning(sessionId, false);
117
- broadcastForSession(sessionId, createSessionRunningMessage(false));
116
+ try {
117
+ sessionManager.setRunning(sessionId, false);
118
+ broadcastForSession(sessionId, createSessionRunningMessage(false));
119
+ } catch {
120
+ }
118
121
  finalizeTurnCompletion(sessionId, sessionManager, broadcastForSession);
119
122
  throw error;
120
123
  }
@@ -172,4 +175,4 @@ export {
172
175
  startChatSession,
173
176
  stopSessionExecution
174
177
  };
175
- //# sourceMappingURL=chat-handler-EKAO6CIB.js.map
178
+ //# sourceMappingURL=chat-handler-RN662HKM.js.map
@@ -2,7 +2,7 @@ import {
2
2
  createVerifierNudgeConfig,
3
3
  runBuilderTurn,
4
4
  runChatTurn
5
- } from "./chunk-BG7QCFGG.js";
5
+ } from "./chunk-SJHWJAJA.js";
6
6
  import {
7
7
  TurnMetrics,
8
8
  agentExists,
@@ -37,7 +37,7 @@ import {
37
37
  setSkillEnabled,
38
38
  skillExists,
39
39
  spawnShellProcess
40
- } from "./chunk-UCZSBKG7.js";
40
+ } from "./chunk-42TLGPX4.js";
41
41
  import {
42
42
  getProject
43
43
  } from "./chunk-CMQCO27Y.js";
@@ -87,7 +87,7 @@ import {
87
87
  updateSessionProvider,
88
88
  updateSessionRunning,
89
89
  updateSessionSummary
90
- } from "./chunk-RJRG2VER.js";
90
+ } from "./chunk-LHKXWUEK.js";
91
91
  import {
92
92
  initDatabase
93
93
  } from "./chunk-KIOUKC3Z.js";
@@ -108,7 +108,7 @@ import {
108
108
  parseClientMessage,
109
109
  serializeServerMessage,
110
110
  storedEventToServerMessage
111
- } from "./chunk-STYHKCG7.js";
111
+ } from "./chunk-UF6D2IPO.js";
112
112
  import {
113
113
  EventEmitter,
114
114
  provideAnswer
@@ -2287,17 +2287,6 @@ function resolveStatsIdentity(llmClient, getActiveProvider) {
2287
2287
  model
2288
2288
  };
2289
2289
  }
2290
- function buildSessionState(sessionManager, sessionId) {
2291
- const session = sessionManager.getSession(sessionId);
2292
- if (!session) {
2293
- return { session: null, messages: [], pendingConfirmations: [] };
2294
- }
2295
- const eventStore = getEventStore();
2296
- const events = eventStore.getEvents(sessionId);
2297
- const messages = events.length > 0 ? buildMessagesFromStoredEvents(events) : [];
2298
- const pendingConfirmations = foldPendingConfirmations(events);
2299
- return { session, messages, pendingConfirmations };
2300
- }
2301
2290
  function addUserMessageAndBroadcast(sessionManager, sessionId, message, broadcastFn) {
2302
2291
  const userMessage = sessionManager.addMessage(sessionId, {
2303
2292
  role: "user",
@@ -2342,6 +2331,7 @@ function processQueueAndRestartTurn(sessionManager, sessionId, drainFn, queueMod
2342
2331
  return true;
2343
2332
  }
2344
2333
  var activeAgents = /* @__PURE__ */ new Map();
2334
+ var MAX_SEND_QUEUE_SIZE = 1e3;
2345
2335
  function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvider, sessionManager, providerManager) {
2346
2336
  const wss = new WebSocketServer({ server: httpServer });
2347
2337
  const clients = /* @__PURE__ */ new Map();
@@ -2408,6 +2398,37 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2408
2398
  }
2409
2399
  }
2410
2400
  };
2401
+ function enqueueSend(client, data, seq) {
2402
+ if (client.sendQueue.length >= MAX_SEND_QUEUE_SIZE) {
2403
+ logger.warn("WebSocket send queue full, dropping message", {
2404
+ queueSize: client.sendQueue.length,
2405
+ sessionId: client.activeSessionId
2406
+ });
2407
+ return;
2408
+ }
2409
+ client.sendQueue.push({ data, seq });
2410
+ processSendQueue(client);
2411
+ }
2412
+ function processSendQueue(client) {
2413
+ if (client.isSending || client.sendQueue.length === 0) {
2414
+ return;
2415
+ }
2416
+ client.isSending = true;
2417
+ const item = client.sendQueue.shift();
2418
+ if (client.ws.readyState === WebSocket2.OPEN) {
2419
+ client.ws.send(item.data, (err) => {
2420
+ if (err) {
2421
+ logger.debug("WebSocket send error", { error: err });
2422
+ }
2423
+ client.isSending = false;
2424
+ client.lastSentSeq = item.seq;
2425
+ processSendQueue(client);
2426
+ });
2427
+ } else {
2428
+ client.isSending = false;
2429
+ processSendQueue(client);
2430
+ }
2431
+ }
2411
2432
  const llmForSession = (sessionId) => getSessionLLMClient?.(sessionId) ?? getLLMClient();
2412
2433
  const statsForSession = (sessionId) => getSessionStatsIdentity?.(sessionId) ?? resolveStatsIdentity(getLLMClient(), getActiveProvider);
2413
2434
  function cleanupAfterTurn(sessionId, controller, sendFn, setRunningOnEarlyReturn) {
@@ -2464,47 +2485,12 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2464
2485
  cleanupAfterTurn(sessionId, controller, broadcastForSession, false);
2465
2486
  });
2466
2487
  }
2467
- sessionManager.subscribe((event) => {
2468
- const sessionId = "sessionId" in event ? event.sessionId : "session" in event ? event.session.id : null;
2469
- if (!sessionId) return;
2470
- for (const [ws, client] of clients) {
2471
- if (ws.readyState !== WebSocket2.OPEN) continue;
2472
- if (event.type === "session_created") {
2473
- const session = sessionManager.getSession(sessionId);
2474
- if (session) {
2475
- const { messages, pendingConfirmations } = buildSessionState(sessionManager, sessionId);
2476
- ws.send(
2477
- serializeServerMessage({
2478
- ...createSessionStateMessage(session, messages, pendingConfirmations),
2479
- sessionId
2480
- })
2481
- );
2482
- }
2483
- continue;
2484
- }
2485
- if (isSubscribedToSession(client, sessionId)) {
2486
- if (event.type === "session_updated") {
2487
- const { session, messages, pendingConfirmations } = buildSessionState(sessionManager, sessionId);
2488
- if (session) {
2489
- ws.send(
2490
- serializeServerMessage({
2491
- ...createSessionStateMessage(session, messages, pendingConfirmations),
2492
- sessionId
2493
- })
2494
- );
2495
- }
2496
- }
2497
- if (event.type === "running_changed") {
2498
- ws.send(serializeServerMessage({ ...createSessionRunningMessage(event.isRunning), sessionId }));
2499
- }
2500
- }
2501
- }
2502
- });
2503
2488
  const broadcastAll = (msg) => {
2504
2489
  const serialized = serializeServerMessage(msg);
2505
- for (const [clientWs] of clients) {
2490
+ for (const [clientWs, client] of clients) {
2506
2491
  if (clientWs.readyState === WebSocket2.OPEN) {
2507
- clientWs.send(serialized);
2492
+ const seq = client.lastSentSeq + 1;
2493
+ enqueueSend(client, serialized, seq);
2508
2494
  }
2509
2495
  }
2510
2496
  };
@@ -2532,7 +2518,8 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2532
2518
  for (const [clientWs, client] of clients) {
2533
2519
  if (client.activeSessionId === sessionId) {
2534
2520
  if (clientWs.readyState === WebSocket2.OPEN) {
2535
- clientWs.send(serializeServerMessage(msg));
2521
+ const seq = client.lastSentSeq + 1;
2522
+ enqueueSend(client, serializeServerMessage(msg), seq);
2536
2523
  }
2537
2524
  }
2538
2525
  }
@@ -2550,7 +2537,14 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2550
2537
  }
2551
2538
  }
2552
2539
  logger.debug("WebSocket client connected");
2553
- clients.set(ws, { ws, activeSessionId: null, globalSubscription: null });
2540
+ clients.set(ws, {
2541
+ ws,
2542
+ activeSessionId: null,
2543
+ globalSubscription: null,
2544
+ sendQueue: [],
2545
+ isSending: false,
2546
+ lastSentSeq: 0
2547
+ });
2554
2548
  const eventStore = getEventStore();
2555
2549
  const { iterator: globalIterator, unsubscribe: globalUnsubscribe } = eventStore.subscribeAll();
2556
2550
  clients.get(ws).globalSubscription = globalUnsubscribe;
@@ -2560,7 +2554,12 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2560
2554
  if (ws.readyState !== WebSocket2.OPEN) break;
2561
2555
  const serverMsg = storedEventToServerMessage(storedEvent);
2562
2556
  if (serverMsg) {
2563
- ws.send(serializeServerMessage({ ...serverMsg, seq: storedEvent.seq, sessionId: storedEvent.sessionId }));
2557
+ const client = clients.get(ws);
2558
+ enqueueSend(
2559
+ client,
2560
+ serializeServerMessage({ ...serverMsg, seq: storedEvent.seq, sessionId: storedEvent.sessionId }),
2561
+ storedEvent.seq
2562
+ );
2564
2563
  }
2565
2564
  }
2566
2565
  } catch (error) {
@@ -2570,7 +2569,13 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2570
2569
  ws.on("message", async (data) => {
2571
2570
  const message = parseClientMessage(data.toString());
2572
2571
  if (!message) {
2573
- ws.send(serializeServerMessage(createErrorMessage("INVALID_MESSAGE", "Invalid message format")));
2572
+ const client2 = clients.get(ws);
2573
+ const seq = client2.lastSentSeq + 1;
2574
+ enqueueSend(
2575
+ client2,
2576
+ serializeServerMessage(createErrorMessage("INVALID_MESSAGE", "Invalid message format")),
2577
+ seq
2578
+ );
2574
2579
  return;
2575
2580
  }
2576
2581
  if (message.type.startsWith("terminal.")) {
@@ -2593,14 +2598,19 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2593
2598
  llmForSession,
2594
2599
  statsForSession,
2595
2600
  startTurnWithCompletionChain,
2596
- cleanupAfterTurn
2601
+ cleanupAfterTurn,
2602
+ enqueueSend
2597
2603
  );
2598
2604
  } catch (error) {
2599
2605
  logger.error("Error handling client message", { error, type: message.type });
2600
- ws.send(
2606
+ const client2 = clients.get(ws);
2607
+ const seq = client2.lastSentSeq + 1;
2608
+ enqueueSend(
2609
+ client2,
2601
2610
  serializeServerMessage(
2602
2611
  createErrorMessage("INTERNAL_ERROR", error instanceof Error ? error.message : "Unknown error", message.id)
2603
- )
2612
+ ),
2613
+ seq
2604
2614
  );
2605
2615
  }
2606
2616
  });
@@ -2611,6 +2621,10 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2611
2621
  client.globalSubscription();
2612
2622
  }
2613
2623
  unsubscribeAllFromTerminal(ws);
2624
+ if (client) {
2625
+ client.sendQueue = [];
2626
+ client.isSending = false;
2627
+ }
2614
2628
  clients.delete(ws);
2615
2629
  });
2616
2630
  ws.on("error", (error) => {
@@ -2632,10 +2646,11 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2632
2646
  broadcastForSession
2633
2647
  };
2634
2648
  }
2635
- async function handleClientMessage(ws, client, message, _getLLMClient, _getActiveProvider, sessionManager, _broadcastForSession, _providerManager, _getSessionLLMClient, _getSessionStatsIdentity, llmForSession, statsForSession, _startTurnWithCompletionChain, cleanupAfterTurn) {
2649
+ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiveProvider, sessionManager, _broadcastForSession, _providerManager, _getSessionLLMClient, _getSessionStatsIdentity, llmForSession, statsForSession, _startTurnWithCompletionChain, cleanupAfterTurn, enqueueSendFn) {
2636
2650
  const send = (msg) => {
2637
2651
  if (ws.readyState === WebSocket2.OPEN) {
2638
- ws.send(serializeServerMessage(msg));
2652
+ const seq = client.lastSentSeq + 1;
2653
+ enqueueSendFn(client, serializeServerMessage(msg), seq);
2639
2654
  }
2640
2655
  };
2641
2656
  const sendForSession = (sessionId, msg) => {
@@ -5242,7 +5257,7 @@ function createTerminalRoutes() {
5242
5257
  }
5243
5258
 
5244
5259
  // src/constants.ts
5245
- var VERSION = "1.6.79";
5260
+ var VERSION = "1.6.81";
5246
5261
 
5247
5262
  // src/server/index.ts
5248
5263
  var __dirname2 = dirname5(fileURLToPath4(import.meta.url));
@@ -5370,9 +5385,49 @@ async function createServerHandle(config) {
5370
5385
  if (!name || !workdir) {
5371
5386
  return res.status(400).json({ error: "name and workdir are required" });
5372
5387
  }
5373
- const { createDirectoryWithGit } = await import("./project-creator-VD7MLOWE.js");
5374
- const project = await createDirectoryWithGit(name, workdir);
5375
- res.status(201).json({ project });
5388
+ const { createDirectoryWithGit } = await import("./project-creator-GPOIXKX4.js");
5389
+ try {
5390
+ const project = await createDirectoryWithGit(name, workdir);
5391
+ res.status(201).json({ project });
5392
+ } catch (err) {
5393
+ const eaccError = err;
5394
+ return res.status(403).json({
5395
+ error: eaccError.message || "Unknown error",
5396
+ code: eaccError.code || "UNKNOWN",
5397
+ path: workdir
5398
+ });
5399
+ }
5400
+ });
5401
+ app.post("/api/projects/check-permissions", async (req, res) => {
5402
+ const { path: targetPath } = req.body;
5403
+ if (!targetPath) {
5404
+ return res.status(400).json({ error: "path is required" });
5405
+ }
5406
+ const { checkPermissions } = await import("./permissions-Z2IIV2V7.js");
5407
+ const result = await checkPermissions(targetPath);
5408
+ if (result.success) {
5409
+ res.json(result);
5410
+ } else {
5411
+ const status = result.status ?? 500;
5412
+ res.status(status).json({ error: result.error });
5413
+ }
5414
+ });
5415
+ app.post("/api/projects/fix-permissions", async (req, res) => {
5416
+ const { path: targetPath, action } = req.body;
5417
+ if (!targetPath) {
5418
+ return res.status(400).json({ error: "path is required" });
5419
+ }
5420
+ if (!["group", "ownership", "join_group", "join_group_and_group"].includes(action)) {
5421
+ return res.status(400).json({ error: 'action must be "group", "ownership", "join_group", or "join_group_and_group"' });
5422
+ }
5423
+ const { fixPermissions } = await import("./permissions-Z2IIV2V7.js");
5424
+ const result = await fixPermissions(targetPath, action);
5425
+ if (result.success) {
5426
+ res.json(result);
5427
+ } else {
5428
+ const status = result.status ?? 500;
5429
+ res.status(status).json(result);
5430
+ }
5376
5431
  });
5377
5432
  app.get("/api/projects/:id", async (req, res) => {
5378
5433
  const { getProject: getProject2 } = await import("./projects-XLMSDFTQ.js");
@@ -5404,7 +5459,7 @@ async function createServerHandle(config) {
5404
5459
  res.json({ success: true });
5405
5460
  });
5406
5461
  app.get("/api/sessions", async (req, res) => {
5407
- const { getRecentUserPromptsForSession } = await import("./events-ND5GZBT2.js");
5462
+ const { getRecentUserPromptsForSession } = await import("./events-QDUOJQML.js");
5408
5463
  const projectId = req.query["projectId"];
5409
5464
  const limit = Math.min(parseInt(req.query["limit"]) || 20, 100);
5410
5465
  const offset = parseInt(req.query["offset"]) || 0;
@@ -5437,7 +5492,7 @@ async function createServerHandle(config) {
5437
5492
  res.status(201).json({ session });
5438
5493
  });
5439
5494
  app.get("/api/sessions/:id", async (req, res) => {
5440
- const { getEventStore: getEventStore2 } = await import("./events-ND5GZBT2.js");
5495
+ const { getEventStore: getEventStore2 } = await import("./events-QDUOJQML.js");
5441
5496
  const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-XIKR6AFM.js");
5442
5497
  const session = sessionManager.getSession(req.params.id);
5443
5498
  if (!session) {
@@ -5468,7 +5523,7 @@ async function createServerHandle(config) {
5468
5523
  res.json({ success: true });
5469
5524
  });
5470
5525
  app.post("/api/sessions/:id/provider", async (req, res) => {
5471
- const { getEventStore: getEventStore2 } = await import("./events-ND5GZBT2.js");
5526
+ const { getEventStore: getEventStore2 } = await import("./events-QDUOJQML.js");
5472
5527
  const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-XIKR6AFM.js");
5473
5528
  const sessionId = req.params.id;
5474
5529
  const session = sessionManager.getSession(sessionId);
@@ -5506,7 +5561,7 @@ async function createServerHandle(config) {
5506
5561
  res.json({ success: true });
5507
5562
  });
5508
5563
  app.put("/api/sessions/:id/mode", async (req, res) => {
5509
- const { getEventStore: getEventStore2 } = await import("./events-ND5GZBT2.js");
5564
+ const { getEventStore: getEventStore2 } = await import("./events-QDUOJQML.js");
5510
5565
  const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-XIKR6AFM.js");
5511
5566
  const sessionId = req.params.id;
5512
5567
  const session = sessionManager.getSession(sessionId);
@@ -5559,14 +5614,14 @@ async function createServerHandle(config) {
5559
5614
  if (!callId || approved === void 0) {
5560
5615
  return res.status(400).json({ error: "callId and approved are required" });
5561
5616
  }
5562
- const { providePathConfirmation } = await import("./tools-W6OPDFQV.js");
5617
+ const { providePathConfirmation } = await import("./tools-Y3S6BHBZ.js");
5563
5618
  const result = providePathConfirmation(callId, approved, alwaysAllow);
5564
5619
  if (!result.found) {
5565
5620
  return res.status(404).json({ error: "No pending path confirmation with that ID" });
5566
5621
  }
5567
- const { getEventStore: getEventStore2 } = await import("./events-ND5GZBT2.js");
5622
+ const { getEventStore: getEventStore2 } = await import("./events-QDUOJQML.js");
5568
5623
  const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2, foldPendingConfirmations: foldPendingConfirmations2 } = await import("./folding-XIKR6AFM.js");
5569
- const { createSessionStateMessage: createSessionStateMessage2 } = await import("./protocol-4CTV7OZC.js");
5624
+ const { createSessionStateMessage: createSessionStateMessage2 } = await import("./protocol-IXFNYZEX.js");
5570
5625
  const eventStore = getEventStore2();
5571
5626
  const events = eventStore.getEvents(sessionId);
5572
5627
  const messages = buildMessagesFromStoredEvents2(events);
@@ -5583,7 +5638,7 @@ async function createServerHandle(config) {
5583
5638
  if (!callId || !answer) {
5584
5639
  return res.status(400).json({ error: "callId and answer are required" });
5585
5640
  }
5586
- const { provideAnswer: provideAnswer2 } = await import("./tools-W6OPDFQV.js");
5641
+ const { provideAnswer: provideAnswer2 } = await import("./tools-Y3S6BHBZ.js");
5587
5642
  const found = provideAnswer2(callId, answer);
5588
5643
  if (!found) {
5589
5644
  return res.status(404).json({ error: "No pending question with that ID" });
@@ -5619,14 +5674,14 @@ async function createServerHandle(config) {
5619
5674
  if (!session) {
5620
5675
  return res.status(404).json({ error: "Session not found" });
5621
5676
  }
5622
- const { stopSessionExecution } = await import("./chat-handler-EKAO6CIB.js");
5623
- const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-W6OPDFQV.js");
5677
+ const { stopSessionExecution } = await import("./chat-handler-RN662HKM.js");
5678
+ const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-Y3S6BHBZ.js");
5624
5679
  stopSessionExecution(sessionId, sessionManager);
5625
5680
  abortSession(sessionId);
5626
5681
  cancelQuestionsForSession(sessionId, "Session stopped by user");
5627
5682
  cancelPathConfirmationsForSession(sessionId, "Session stopped by user");
5628
5683
  sessionManager.clearMessageQueue(sessionId);
5629
- const eventStore = (await import("./events-ND5GZBT2.js")).getEventStore();
5684
+ const eventStore = (await import("./events-QDUOJQML.js")).getEventStore();
5630
5685
  eventStore.append(sessionId, { type: "running.changed", data: { isRunning: false } });
5631
5686
  res.json({ success: true });
5632
5687
  });
@@ -5640,7 +5695,7 @@ async function createServerHandle(config) {
5640
5695
  if (typeof messageIndex !== "number" || messageIndex < 0) {
5641
5696
  return res.status(400).json({ error: "messageIndex must be a non-negative number" });
5642
5697
  }
5643
- const { truncateSessionMessages } = await import("./events-ND5GZBT2.js");
5698
+ const { truncateSessionMessages } = await import("./events-QDUOJQML.js");
5644
5699
  truncateSessionMessages(sessionId, messageIndex);
5645
5700
  res.json({ success: true });
5646
5701
  });
@@ -6108,7 +6163,7 @@ async function createServerHandle(config) {
6108
6163
  providerManager
6109
6164
  );
6110
6165
  const wss = wssExports.wss;
6111
- const { QueueProcessor } = await import("./processor-O35Q3EZT.js");
6166
+ const { QueueProcessor } = await import("./processor-3A32D5MI.js");
6112
6167
  const queueProcessor = new QueueProcessor({
6113
6168
  sessionManager,
6114
6169
  providerManager,
@@ -6183,4 +6238,4 @@ export {
6183
6238
  createServerHandle,
6184
6239
  createServer
6185
6240
  };
6186
- //# sourceMappingURL=chunk-3JU4NOQD.js.map
6241
+ //# sourceMappingURL=chunk-2MHHSLNY.js.map
@@ -32,7 +32,7 @@ import {
32
32
  import {
33
33
  getCurrentContextWindowId,
34
34
  getEventStore
35
- } from "./chunk-RJRG2VER.js";
35
+ } from "./chunk-LHKXWUEK.js";
36
36
  import {
37
37
  buildContextMessagesFromEventHistory,
38
38
  foldContextState,
@@ -50,7 +50,7 @@ import {
50
50
  createChatToolOutputMessage,
51
51
  createChatVisionFallbackMessage,
52
52
  createQueueStateMessage
53
- } from "./chunk-STYHKCG7.js";
53
+ } from "./chunk-UF6D2IPO.js";
54
54
  import {
55
55
  AskUserInterrupt,
56
56
  askUserTool
@@ -2946,12 +2946,17 @@ async function executeToolBatch(assistantMsgId, toolCalls, ctx) {
2946
2946
  let criteriaChanged = false;
2947
2947
  let returnValueContent;
2948
2948
  let returnValueResult;
2949
- let session = ctx.sessionManager.requireSession(ctx.sessionId);
2949
+ const session = ctx.sessionManager.requireSession(ctx.sessionId);
2950
+ if (ctx.signal?.aborted) {
2951
+ throw new Error("Aborted");
2952
+ }
2950
2953
  for (const toolCall of toolCalls) {
2954
+ eventStore.append(ctx.sessionId, createToolCallEvent(assistantMsgId, toolCall));
2955
+ }
2956
+ const executeTool = async (toolCall, index) => {
2951
2957
  if (ctx.signal?.aborted) {
2952
2958
  throw new Error("Aborted");
2953
2959
  }
2954
- eventStore.append(ctx.sessionId, createToolCallEvent(assistantMsgId, toolCall));
2955
2960
  if (toolCall.parseError) {
2956
2961
  const toolResult2 = {
2957
2962
  success: false,
@@ -2960,14 +2965,14 @@ async function executeToolBatch(assistantMsgId, toolCalls, ctx) {
2960
2965
  truncated: false
2961
2966
  };
2962
2967
  ctx.turnMetrics.addToolTime(toolResult2.durationMs);
2963
- eventStore.append(ctx.sessionId, createToolResultEvent(assistantMsgId, toolCall.id, toolResult2));
2964
- toolMessages.push({
2965
- role: "tool",
2968
+ const event = createToolResultEvent(assistantMsgId, toolCall.id, toolResult2);
2969
+ return {
2970
+ toolCall,
2971
+ toolResult: toolResult2,
2966
2972
  content: `Error: ${toolResult2.error}`,
2967
- source: "history",
2968
- toolCallId: toolCall.id
2969
- });
2970
- continue;
2973
+ index,
2974
+ event
2975
+ };
2971
2976
  }
2972
2977
  const onProgress = ctx.onMessage ? createToolProgressHandler(assistantMsgId, toolCall.id, ctx.onMessage) : void 0;
2973
2978
  const toolContext = {
@@ -3018,28 +3023,40 @@ async function executeToolBatch(assistantMsgId, toolCalls, ctx) {
3018
3023
  }
3019
3024
  }
3020
3025
  ctx.turnMetrics.addToolTime(toolResult.durationMs);
3021
- eventStore.append(ctx.sessionId, createToolResultEvent(assistantMsgId, toolCall.id, toolResult));
3022
3026
  ctx.onToolExecuted?.(toolCall, toolResult);
3023
3027
  if (toolCall.name === "return_value" && !toolCall.parseError) {
3024
3028
  returnValueContent = toolCall.arguments["content"];
3025
3029
  returnValueResult = toolCall.arguments["result"];
3026
3030
  }
3027
- toolMessages.push({
3028
- role: "tool",
3029
- content: stripAnsi(
3030
- toolResult.success ? toolResult.output ?? "Success" : toolResult.output ? `${toolResult.output}
3031
+ const content = stripAnsi(
3032
+ toolResult.success ? toolResult.output ?? "Success" : toolResult.output ? `${toolResult.output}
3031
3033
 
3032
3034
  Error: ${toolResult.error}` : `Error: ${toolResult.error}`
3033
- ),
3035
+ );
3036
+ return {
3037
+ toolCall,
3038
+ toolResult,
3039
+ content,
3040
+ index,
3041
+ event: createToolResultEvent(assistantMsgId, toolCall.id, toolResult)
3042
+ };
3043
+ };
3044
+ const executionPromises = toolCalls.map((toolCall, index) => executeTool(toolCall, index));
3045
+ const results = await Promise.all(executionPromises);
3046
+ results.sort((a, b) => a.index - b.index);
3047
+ for (const result of results) {
3048
+ eventStore.append(ctx.sessionId, result.event);
3049
+ toolMessages.push({
3050
+ role: "tool",
3051
+ content: result.content,
3034
3052
  source: "history",
3035
- toolCallId: toolCall.id
3053
+ toolCallId: result.toolCall.id
3036
3054
  });
3037
- const updatedSession = ctx.sessionManager.requireSession(ctx.sessionId);
3038
- if (JSON.stringify(updatedSession.criteria) !== JSON.stringify(session.criteria)) {
3039
- eventStore.append(ctx.sessionId, { type: "criteria.set", data: { criteria: updatedSession.criteria } });
3040
- session = updatedSession;
3041
- criteriaChanged = true;
3042
- }
3055
+ }
3056
+ const updatedSession = ctx.sessionManager.requireSession(ctx.sessionId);
3057
+ if (JSON.stringify(updatedSession.criteria) !== JSON.stringify(session.criteria)) {
3058
+ eventStore.append(ctx.sessionId, { type: "criteria.set", data: { criteria: updatedSession.criteria } });
3059
+ criteriaChanged = true;
3043
3060
  }
3044
3061
  return { toolMessages, criteriaChanged, returnValueContent, returnValueResult };
3045
3062
  }
@@ -3684,7 +3701,7 @@ var callSubAgentTool = {
3684
3701
  };
3685
3702
  }
3686
3703
  try {
3687
- const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-W6OPDFQV.js");
3704
+ const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-Y3S6BHBZ.js");
3688
3705
  const toolRegistry = getToolRegistryForAgent2(agentDef);
3689
3706
  const turnMetrics = new TurnMetrics();
3690
3707
  const result = await executeSubAgent({
@@ -4873,4 +4890,4 @@ export {
4873
4890
  getToolRegistryForAgent,
4874
4891
  createToolRegistry
4875
4892
  };
4876
- //# sourceMappingURL=chunk-UCZSBKG7.js.map
4893
+ //# sourceMappingURL=chunk-42TLGPX4.js.map
@@ -190,7 +190,7 @@ async function runCli(options) {
190
190
  if (!configExists) {
191
191
  await runNetworkSetup(mode);
192
192
  }
193
- const { runServe } = await import("./serve-55GF3KJW.js");
193
+ const { runServe } = await import("./serve-D4NO4GJF.js");
194
194
  const serveOptions = { mode };
195
195
  if (values.port) serveOptions.port = parseInt(values.port);
196
196
  if (values["no-browser"] === true) serveOptions.openBrowser = false;
@@ -202,4 +202,4 @@ async function runCli(options) {
202
202
  export {
203
203
  runCli
204
204
  };
205
- //# sourceMappingURL=chunk-HOD7GVQ5.js.map
205
+ //# sourceMappingURL=chunk-6FOC2GAY.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getEventStore,
3
3
  updateSessionMetadata
4
- } from "./chunk-RJRG2VER.js";
4
+ } from "./chunk-LHKXWUEK.js";
5
5
  import {
6
6
  buildMessagesFromStoredEvents,
7
7
  foldPendingConfirmations
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  createContextStateMessage,
11
11
  createSessionStateMessage
12
- } from "./chunk-STYHKCG7.js";
12
+ } from "./chunk-UF6D2IPO.js";
13
13
  import {
14
14
  logger
15
15
  } from "./chunk-K44MW7JJ.js";
@@ -143,4 +143,4 @@ export {
143
143
  needsNameGenerationCheck,
144
144
  applyGeneratedSessionName
145
145
  };
146
- //# sourceMappingURL=chunk-2IZMUXMP.js.map
146
+ //# sourceMappingURL=chunk-A5W6JUYZ.js.map