openfox 1.6.43 → 1.6.45

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.
Files changed (42) hide show
  1. package/dist/{auto-compaction-U2TKRF6E.js → auto-compaction-2AI46SNC.js} +9 -9
  2. package/dist/{chat-handler-TJWYGO3G.js → chat-handler-ITVOWLJR.js} +13 -13
  3. package/dist/{chunk-P6GUT2QQ.js → chunk-4DNPYFL4.js} +3 -3
  4. package/dist/{chunk-Y6HBEACI.js → chunk-53DUI4MS.js} +1 -1
  5. package/dist/{chunk-BHSTSA7U.js → chunk-BF7JQWEL.js} +4 -4
  6. package/dist/{chunk-KSASIV4B.js → chunk-F2VWCCMC.js} +5 -5
  7. package/dist/{chunk-NBBX64KC.js → chunk-FBUTQPJ6.js} +5 -4
  8. package/dist/{chunk-LIMBYVO4.js → chunk-G6JKXYFE.js} +1 -58
  9. package/dist/{chunk-O2BOWZKC.js → chunk-GQZGIMJO.js} +4 -2
  10. package/dist/{chunk-QFOT3J6I.js → chunk-GY4TRYOG.js} +10 -8
  11. package/dist/{chunk-DZHZ3UUR.js → chunk-HSSXBW6N.js} +2 -14
  12. package/dist/{chunk-PYBB34ZK.js → chunk-HYIQFRYJ.js} +9 -6
  13. package/dist/{chunk-TFG2XU3K.js → chunk-KBEOYUA3.js} +6 -6
  14. package/dist/{chunk-S3U4EG6C.js → chunk-RB576RLK.js} +72 -111
  15. package/dist/{chunk-VCVHYZZS.js → chunk-SMK6HIR5.js} +40 -21
  16. package/dist/{chunk-CJNQGEYG.js → chunk-VCALN543.js} +2 -2
  17. package/dist/{chunk-D4ZLSV6P.js → chunk-WNZIUQ2L.js} +8 -6
  18. package/dist/{chunk-YVQ6DP5Y.js → chunk-ZSQFDQPH.js} +5 -23
  19. package/dist/cli/dev.js +1 -1
  20. package/dist/cli/index.js +1 -1
  21. package/dist/{config-ACVEHBKG.js → config-3TU54V4X.js} +5 -5
  22. package/dist/{events-FHPSSSE4.js → events-DFDD4BRS.js} +3 -7
  23. package/dist/{folding-NEZWWL7K.js → folding-JSQFCDZO.js} +2 -4
  24. package/dist/{orchestrator-M2XGDN3F.js → orchestrator-7ZXXNEEC.js} +14 -10
  25. package/dist/package.json +1 -1
  26. package/dist/{processor-ISY5OU5E.js → processor-6CITCUJR.js} +12 -11
  27. package/dist/{protocol-Ct6VfOIJ.d.ts → protocol-B4lesmg5.d.ts} +8 -15
  28. package/dist/{protocol-YNVBDNL7.js → protocol-IWXXOGWM.js} +3 -7
  29. package/dist/{provider-RLQMVV2Z.js → provider-J4G7XBDP.js} +7 -7
  30. package/dist/{serve-5EPE72XL.js → serve-BCRWEL5U.js} +15 -15
  31. package/dist/server/index.d.ts +11 -11
  32. package/dist/server/index.js +13 -13
  33. package/dist/{settings-TWK27GYE.js → settings-NI4ITGV6.js} +2 -2
  34. package/dist/shared/index.d.ts +2 -2
  35. package/dist/shared/index.js +1 -1
  36. package/dist/{tools-EVB6JNKF.js → tools-K7TJWICQ.js} +9 -9
  37. package/dist/{vision-fallback-QJ26DCEF.js → vision-fallback-HXPTLQHN.js} +2 -2
  38. package/dist/web/assets/{index-BqUNWNpD.js → index-Bl-fM2P0.js} +55 -55
  39. package/dist/web/assets/{index-CuARFUOg.css → index-DzPKzXc0.css} +1 -1
  40. package/dist/web/index.html +2 -2
  41. package/dist/web/sw.js +1 -1
  42. package/package.json +1 -1
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  generateSessionName,
3
3
  needsNameGeneration
4
- } from "./chunk-BHSTSA7U.js";
4
+ } from "./chunk-BF7JQWEL.js";
5
5
  import {
6
6
  createVerifierNudgeConfig,
7
7
  runBuilderTurn,
8
8
  runChatTurn
9
- } from "./chunk-VCVHYZZS.js";
9
+ } from "./chunk-SMK6HIR5.js";
10
10
  import {
11
11
  TurnMetrics,
12
12
  agentExists,
@@ -47,7 +47,7 @@ import {
47
47
  setSkillEnabled,
48
48
  skillExists,
49
49
  spawnShellProcess
50
- } from "./chunk-QFOT3J6I.js";
50
+ } from "./chunk-GY4TRYOG.js";
51
51
  import {
52
52
  getPathSeparator,
53
53
  getPlatformShell,
@@ -60,18 +60,18 @@ import {
60
60
  import {
61
61
  createProviderManager,
62
62
  parseDefaultModelSelection
63
- } from "./chunk-PYBB34ZK.js";
63
+ } from "./chunk-HYIQFRYJ.js";
64
64
  import {
65
65
  SessionNotFoundError,
66
66
  createLLMClient,
67
67
  detectModel,
68
68
  getLlmStatus
69
- } from "./chunk-KSASIV4B.js";
69
+ } from "./chunk-F2VWCCMC.js";
70
70
  import {
71
71
  detectBackend,
72
72
  getBackendDisplayName,
73
73
  getModelProfile
74
- } from "./chunk-D4ZLSV6P.js";
74
+ } from "./chunk-WNZIUQ2L.js";
75
75
  import {
76
76
  createSession,
77
77
  deleteSession,
@@ -80,7 +80,6 @@ import {
80
80
  emitContextState,
81
81
  emitCriteriaSet,
82
82
  emitCriterionUpdated,
83
- emitModeChanged,
84
83
  emitPhaseChanged,
85
84
  emitRunningChanged,
86
85
  emitSessionInitialized,
@@ -97,12 +96,12 @@ import {
97
96
  updateSessionProvider,
98
97
  updateSessionRunning,
99
98
  updateSessionSummary
100
- } from "./chunk-YVQ6DP5Y.js";
99
+ } from "./chunk-ZSQFDQPH.js";
101
100
  import {
102
101
  buildContextMessagesFromEventHistory,
103
102
  buildMessagesFromStoredEvents,
104
103
  foldPendingConfirmations
105
- } from "./chunk-LIMBYVO4.js";
104
+ } from "./chunk-G6JKXYFE.js";
106
105
  import {
107
106
  createChatErrorMessage,
108
107
  createChatMessageMessage,
@@ -118,7 +117,7 @@ import {
118
117
  parseClientMessage,
119
118
  serializeServerMessage,
120
119
  storedEventToServerMessage
121
- } from "./chunk-DZHZ3UUR.js";
120
+ } from "./chunk-HSSXBW6N.js";
122
121
  import {
123
122
  EventEmitter,
124
123
  cancelQuestionsForSession,
@@ -132,7 +131,7 @@ import {
132
131
  } from "./chunk-B7E3BICY.js";
133
132
  import {
134
133
  createServerMessage
135
- } from "./chunk-Y6HBEACI.js";
134
+ } from "./chunk-53DUI4MS.js";
136
135
  import {
137
136
  getGlobalConfigDir
138
137
  } from "./chunk-R4HADRYO.js";
@@ -2297,14 +2296,15 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2297
2296
  };
2298
2297
  const llmForSession = (sessionId) => getSessionLLMClient?.(sessionId) ?? getLLMClient();
2299
2298
  const statsForSession = (sessionId) => getSessionStatsIdentity?.(sessionId) ?? resolveStatsIdentity(getLLMClient(), getActiveProvider);
2300
- function startTurnWithCompletionChain(sessionId, controller) {
2299
+ function startTurnWithCompletionChain(sessionId, controller, agentId) {
2301
2300
  runChatTurn({
2302
2301
  sessionManager,
2303
2302
  sessionId,
2304
2303
  llmClient: llmForSession(sessionId),
2305
2304
  statsIdentity: statsForSession(sessionId),
2306
2305
  signal: controller.signal,
2307
- onMessage: (msg) => broadcastForSession(sessionId, msg)
2306
+ onMessage: (msg) => broadcastForSession(sessionId, msg),
2307
+ ...agentId ? { agentId } : {}
2308
2308
  }).catch((error) => {
2309
2309
  if (error instanceof Error && error.message === "Aborted") {
2310
2310
  return;
@@ -2319,7 +2319,7 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2319
2319
  const nextAsap = asapMsgs[0];
2320
2320
  if (nextAsap) {
2321
2321
  for (const remaining of asapMsgs.slice(1)) {
2322
- sessionManager.queueMessage(sessionId, "asap", remaining.content, remaining.attachments, remaining.messageKind);
2322
+ sessionManager.queueMessage(sessionId, "asap", remaining.content, remaining.attachments, remaining.messageKind, remaining.agentId);
2323
2323
  }
2324
2324
  broadcastForSession(sessionId, createQueueStateMessage(sessionManager.getQueueState(sessionId)));
2325
2325
  const userMessagePayload = {
@@ -2331,14 +2331,14 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2331
2331
  broadcastForSession(sessionId, createChatMessageMessage(userMessage));
2332
2332
  const newController = new AbortController();
2333
2333
  activeAgents.set(sessionId, newController);
2334
- startTurnWithCompletionChain(sessionId, newController);
2334
+ startTurnWithCompletionChain(sessionId, newController, nextAsap.agentId);
2335
2335
  return;
2336
2336
  }
2337
2337
  const completionMsgs = sessionManager.drainCompletionMessages(sessionId);
2338
2338
  const next = completionMsgs[0];
2339
2339
  if (next) {
2340
2340
  for (const remaining of completionMsgs.slice(1)) {
2341
- sessionManager.queueMessage(sessionId, "completion", remaining.content, remaining.attachments);
2341
+ sessionManager.queueMessage(sessionId, "completion", remaining.content, remaining.attachments, void 0, remaining.agentId);
2342
2342
  }
2343
2343
  broadcastForSession(sessionId, createQueueStateMessage(sessionManager.getQueueState(sessionId)));
2344
2344
  const userMessage = sessionManager.addMessage(sessionId, {
@@ -2349,7 +2349,7 @@ function createWebSocketServer(httpServer, config, getLLMClient, getActiveProvid
2349
2349
  broadcastForSession(sessionId, createChatMessageMessage(userMessage));
2350
2350
  const newController = new AbortController();
2351
2351
  activeAgents.set(sessionId, newController);
2352
- startTurnWithCompletionChain(sessionId, newController);
2352
+ startTurnWithCompletionChain(sessionId, newController, next.agentId);
2353
2353
  return;
2354
2354
  }
2355
2355
  sessionManager.clearMessageQueue(sessionId);
@@ -2691,7 +2691,7 @@ async function handleClientMessage(ws, client, message, getLLMClient, getActiveP
2691
2691
  logger.warn("Session name generation failed", { sessionId, error: error instanceof Error ? error.message : error });
2692
2692
  });
2693
2693
  }
2694
- startTurnWithCompletionChain(sessionId, controller);
2694
+ startTurnWithCompletionChain(sessionId, controller, message.payload.agentId);
2695
2695
  } catch (error) {
2696
2696
  if (activeAgents.get(sessionId) === controller) {
2697
2697
  activeAgents.delete(sessionId);
@@ -2807,9 +2807,7 @@ ${content}` : workflowInfo;
2807
2807
  (async () => {
2808
2808
  let controller = null;
2809
2809
  try {
2810
- sessionManager.setMode(sessionId, "builder");
2811
2810
  sessionManager.setPhase(sessionId, "build");
2812
- eventStore.append(sessionId, { type: "mode.changed", data: { mode: "builder", auto: false, reason: "Criteria accepted" } });
2813
2811
  eventStore.append(sessionId, { type: "phase.changed", data: { phase: "build" } });
2814
2812
  controller = new AbortController();
2815
2813
  const existingController = activeAgents.get(sessionId);
@@ -2829,6 +2827,7 @@ ${content}` : workflowInfo;
2829
2827
  llmClient: llmForSession(sessionId),
2830
2828
  statsIdentity: statsForSession(sessionId),
2831
2829
  injectBuilderKickoff: !hasAcceptMessage,
2830
+ agentId: "builder",
2832
2831
  ...acceptPayload2?.workflowId ? { workflowId: acceptPayload2.workflowId } : {},
2833
2832
  ...hasAcceptMessage ? { userMessage: { content: hasAcceptContent ? acceptPayload2.content : "", ...hasAcceptAttachments ? { attachments: acceptAttachments } : {} } } : {},
2834
2833
  signal: controller.signal,
@@ -2986,10 +2985,6 @@ ${content}` : workflowInfo;
2986
2985
  });
2987
2986
  return;
2988
2987
  }
2989
- if (session.mode !== "builder") {
2990
- send(createErrorMessage("INVALID_MODE", "Runner can only be launched in builder mode", message.id));
2991
- return;
2992
- }
2993
2988
  const launchPayloadEarly = message.payload;
2994
2989
  const pendingCriteria = session.criteria.filter((c) => c.status.type !== "passed");
2995
2990
  if (!launchPayloadEarly?.workflowId && pendingCriteria.length === 0) {
@@ -4165,6 +4160,28 @@ function canCompact(currentTokens, maxTokens) {
4165
4160
  }
4166
4161
 
4167
4162
  // src/server/session/manager.ts
4163
+ function mapSnapshotMessage(m) {
4164
+ const msg = {
4165
+ id: m.id,
4166
+ role: m.role,
4167
+ content: m.content,
4168
+ timestamp: new Date(m.timestamp).toISOString()
4169
+ };
4170
+ if (m.thinkingContent !== void 0) msg.thinkingContent = m.thinkingContent;
4171
+ if (m.toolCalls !== void 0) msg.toolCalls = m.toolCalls;
4172
+ if (m.segments !== void 0) msg.segments = m.segments;
4173
+ if (m.stats !== void 0) msg.stats = m.stats;
4174
+ if (m.partial !== void 0) msg.partial = m.partial;
4175
+ if (m.isStreaming !== void 0) msg.isStreaming = m.isStreaming;
4176
+ if (m.subAgentId !== void 0) msg.subAgentId = m.subAgentId;
4177
+ if (m.subAgentType !== void 0) msg.subAgentType = m.subAgentType;
4178
+ if (m.isSystemGenerated !== void 0) msg.isSystemGenerated = m.isSystemGenerated;
4179
+ if (m.messageKind !== void 0) msg.messageKind = m.messageKind;
4180
+ if (m.contextWindowId !== void 0) msg.contextWindowId = m.contextWindowId;
4181
+ if (m.isCompactionSummary !== void 0) msg.isCompactionSummary = m.isCompactionSummary;
4182
+ if (m.promptContext !== void 0) msg.promptContext = m.promptContext;
4183
+ return msg;
4184
+ }
4168
4185
  var SessionManager = class {
4169
4186
  events = new EventEmitter();
4170
4187
  activeSessionId = null;
@@ -4274,22 +4291,6 @@ var SessionManager = class {
4274
4291
  // ============================================================================
4275
4292
  // State Changes (emit events + notify subscribers)
4276
4293
  // ============================================================================
4277
- /**
4278
- * Change session mode. Emits mode.changed event.
4279
- */
4280
- setMode(sessionId, toMode) {
4281
- const session = this.requireSession(sessionId);
4282
- const fromMode = session.mode;
4283
- if (fromMode === toMode) {
4284
- return session;
4285
- }
4286
- logger.debug("Changing session mode", { sessionId, from: fromMode, to: toMode });
4287
- emitModeChanged(sessionId, toMode, false);
4288
- const updatedSession = this.requireSession(sessionId);
4289
- this.emit({ type: "mode_changed", sessionId, from: fromMode, to: toMode });
4290
- this.emit({ type: "session_updated", session: updatedSession });
4291
- return updatedSession;
4292
- }
4293
4294
  /**
4294
4295
  * Change session phase. Emits phase.changed event.
4295
4296
  */
@@ -4451,26 +4452,7 @@ var SessionManager = class {
4451
4452
  getCurrentWindowMessages(sessionId) {
4452
4453
  const state = getSessionState(sessionId);
4453
4454
  if (!state) return [];
4454
- return state.messages.filter((m) => m.contextWindowId === state.currentContextWindowId).map((m) => {
4455
- const msg = {
4456
- id: m.id,
4457
- role: m.role,
4458
- content: m.content,
4459
- timestamp: new Date(m.timestamp).toISOString()
4460
- };
4461
- if (m.thinkingContent !== void 0) msg.thinkingContent = m.thinkingContent;
4462
- if (m.toolCalls !== void 0) msg.toolCalls = m.toolCalls;
4463
- if (m.segments !== void 0) msg.segments = m.segments;
4464
- if (m.stats !== void 0) msg.stats = m.stats;
4465
- if (m.partial !== void 0) msg.partial = m.partial;
4466
- if (m.isStreaming !== void 0) msg.isStreaming = m.isStreaming;
4467
- if (m.contextWindowId !== void 0) msg.contextWindowId = m.contextWindowId;
4468
- if (m.isSystemGenerated !== void 0) msg.isSystemGenerated = m.isSystemGenerated;
4469
- if (m.messageKind !== void 0) msg.messageKind = m.messageKind;
4470
- if (m.isCompactionSummary !== void 0) msg.isCompactionSummary = m.isCompactionSummary;
4471
- if (m.promptContext !== void 0) msg.promptContext = m.promptContext;
4472
- return msg;
4473
- });
4455
+ return state.messages.filter((m) => m.contextWindowId === state.currentContextWindowId).map(mapSnapshotMessage);
4474
4456
  }
4475
4457
  /**
4476
4458
  * Compact context. Delegates to EventStore.
@@ -4615,7 +4597,7 @@ ${summary}`, {
4615
4597
  // Message Queue (runtime state, transient while agent is running)
4616
4598
  // ============================================================================
4617
4599
  messageQueues = /* @__PURE__ */ new Map();
4618
- queueMessage(sessionId, mode, content, attachments, messageKind) {
4600
+ queueMessage(sessionId, mode, content, attachments, messageKind, agentId) {
4619
4601
  const queue = this.messageQueues.get(sessionId) ?? [];
4620
4602
  const msg = {
4621
4603
  queueId: crypto.randomUUID(),
@@ -4623,6 +4605,7 @@ ${summary}`, {
4623
4605
  content,
4624
4606
  ...attachments ? { attachments } : {},
4625
4607
  ...messageKind ? { messageKind } : {},
4608
+ ...agentId ? { agentId } : {},
4626
4609
  queuedAt: (/* @__PURE__ */ new Date()).toISOString()
4627
4610
  };
4628
4611
  queue.push(msg);
@@ -4830,7 +4813,6 @@ ${summary}`,
4830
4813
  if (!eventState) {
4831
4814
  return {
4832
4815
  ...dbSession,
4833
- mode: "planner",
4834
4816
  phase: "plan",
4835
4817
  isRunning: false,
4836
4818
  messages: [],
@@ -4863,14 +4845,13 @@ ${summary}`,
4863
4845
  });
4864
4846
  return {
4865
4847
  ...dbSession,
4866
- mode: eventState.mode,
4867
4848
  phase: eventState.phase,
4868
4849
  isRunning: eventState.isRunning,
4869
4850
  messages,
4870
4851
  criteria: eventState.criteria,
4871
4852
  contextWindows: [],
4872
4853
  // Derived from events, not stored separately
4873
- executionState: eventState.lastModeWithReminder ? { lastModeWithReminder: eventState.lastModeWithReminder } : null
4854
+ executionState: null
4874
4855
  };
4875
4856
  }
4876
4857
  };
@@ -5479,7 +5460,7 @@ function createTerminalRoutes() {
5479
5460
  }
5480
5461
 
5481
5462
  // src/constants.ts
5482
- var VERSION = "1.6.43";
5463
+ var VERSION = "1.6.45";
5483
5464
 
5484
5465
  // src/server/index.ts
5485
5466
  var __dirname2 = dirname5(fileURLToPath4(import.meta.url));
@@ -5640,7 +5621,7 @@ async function createServerHandle(config) {
5640
5621
  res.json({ success: true });
5641
5622
  });
5642
5623
  app.get("/api/sessions", async (req, res) => {
5643
- const { getRecentUserPromptsForSession } = await import("./events-FHPSSSE4.js");
5624
+ const { getRecentUserPromptsForSession } = await import("./events-DFDD4BRS.js");
5644
5625
  const projectId = req.query["projectId"];
5645
5626
  const limit = Math.min(parseInt(req.query["limit"]) || 20, 100);
5646
5627
  const offset = parseInt(req.query["offset"]) || 0;
@@ -5673,8 +5654,8 @@ async function createServerHandle(config) {
5673
5654
  res.status(201).json({ session });
5674
5655
  });
5675
5656
  app.get("/api/sessions/:id", async (req, res) => {
5676
- const { getEventStore: getEventStore2 } = await import("./events-FHPSSSE4.js");
5677
- const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-NEZWWL7K.js");
5657
+ const { getEventStore: getEventStore2 } = await import("./events-DFDD4BRS.js");
5658
+ const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-JSQFCDZO.js");
5678
5659
  const session = sessionManager.getSession(req.params.id);
5679
5660
  if (!session) {
5680
5661
  return res.status(404).json({ error: "Session not found" });
@@ -5704,8 +5685,8 @@ async function createServerHandle(config) {
5704
5685
  res.json({ success: true });
5705
5686
  });
5706
5687
  app.post("/api/sessions/:id/provider", async (req, res) => {
5707
- const { getEventStore: getEventStore2 } = await import("./events-FHPSSSE4.js");
5708
- const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-NEZWWL7K.js");
5688
+ const { getEventStore: getEventStore2 } = await import("./events-DFDD4BRS.js");
5689
+ const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-JSQFCDZO.js");
5709
5690
  const sessionId = req.params.id;
5710
5691
  const session = sessionManager.getSession(sessionId);
5711
5692
  if (!session) {
@@ -5716,7 +5697,7 @@ async function createServerHandle(config) {
5716
5697
  return res.status(400).json({ error: "providerId is required" });
5717
5698
  }
5718
5699
  sessionManager.setSessionProvider(sessionId, providerId, model ?? "auto");
5719
- const { loadGlobalConfig, saveGlobalConfig, setDefaultModelSelection } = await import("./config-ACVEHBKG.js");
5700
+ const { loadGlobalConfig, saveGlobalConfig, setDefaultModelSelection } = await import("./config-3TU54V4X.js");
5720
5701
  const globalConfig = await loadGlobalConfig(config.mode ?? "production");
5721
5702
  const updatedConfig = setDefaultModelSelection(globalConfig, providerId, model ?? "auto");
5722
5703
  await saveGlobalConfig(config.mode ?? "production", updatedConfig);
@@ -5741,26 +5722,6 @@ async function createServerHandle(config) {
5741
5722
  sessionManager.setCriteria(sessionId, criteria);
5742
5723
  res.json({ success: true });
5743
5724
  });
5744
- app.put("/api/sessions/:id/mode", async (req, res) => {
5745
- const { getEventStore: getEventStore2 } = await import("./events-FHPSSSE4.js");
5746
- const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-NEZWWL7K.js");
5747
- const sessionId = req.params.id;
5748
- const session = sessionManager.getSession(sessionId);
5749
- if (!session) {
5750
- return res.status(404).json({ error: "Session not found" });
5751
- }
5752
- const { mode } = req.body;
5753
- if (!mode || !["planner", "builder"].includes(mode)) {
5754
- return res.status(400).json({ error: 'mode is required and must be "planner" or "builder"' });
5755
- }
5756
- sessionManager.setMode(sessionId, mode);
5757
- const eventStore = getEventStore2();
5758
- eventStore.append(sessionId, { type: "mode.changed", data: { mode, auto: false } });
5759
- const events = eventStore.getEvents(sessionId);
5760
- const messages = buildMessagesFromStoredEvents2(events);
5761
- const updatedSession = sessionManager.getSession(sessionId);
5762
- res.json({ session: updatedSession, messages });
5763
- });
5764
5725
  app.put("/api/sessions/:id/danger-level", async (req, res) => {
5765
5726
  const sessionId = req.params.id;
5766
5727
  const session = sessionManager.getSession(sessionId);
@@ -5781,14 +5742,14 @@ async function createServerHandle(config) {
5781
5742
  if (!callId || approved === void 0) {
5782
5743
  return res.status(400).json({ error: "callId and approved are required" });
5783
5744
  }
5784
- const { providePathConfirmation: providePathConfirmation2 } = await import("./tools-EVB6JNKF.js");
5745
+ const { providePathConfirmation: providePathConfirmation2 } = await import("./tools-K7TJWICQ.js");
5785
5746
  const result = providePathConfirmation2(callId, approved, alwaysAllow);
5786
5747
  if (!result.found) {
5787
5748
  return res.status(404).json({ error: "No pending path confirmation with that ID" });
5788
5749
  }
5789
- const { getEventStore: getEventStore2 } = await import("./events-FHPSSSE4.js");
5790
- const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2, foldPendingConfirmations: foldPendingConfirmations2 } = await import("./folding-NEZWWL7K.js");
5791
- const { createSessionStateMessage: createSessionStateMessage2 } = await import("./protocol-YNVBDNL7.js");
5750
+ const { getEventStore: getEventStore2 } = await import("./events-DFDD4BRS.js");
5751
+ const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2, foldPendingConfirmations: foldPendingConfirmations2 } = await import("./folding-JSQFCDZO.js");
5752
+ const { createSessionStateMessage: createSessionStateMessage2 } = await import("./protocol-IWXXOGWM.js");
5792
5753
  const eventStore = getEventStore2();
5793
5754
  const events = eventStore.getEvents(sessionId);
5794
5755
  const messages = buildMessagesFromStoredEvents2(events);
@@ -5806,7 +5767,7 @@ async function createServerHandle(config) {
5806
5767
  if (!callId || !answer) {
5807
5768
  return res.status(400).json({ error: "callId and answer are required" });
5808
5769
  }
5809
- const { provideAnswer: provideAnswer2 } = await import("./tools-EVB6JNKF.js");
5770
+ const { provideAnswer: provideAnswer2 } = await import("./tools-K7TJWICQ.js");
5810
5771
  const found = provideAnswer2(callId, answer);
5811
5772
  if (!found) {
5812
5773
  return res.status(404).json({ error: "No pending question with that ID" });
@@ -5819,11 +5780,11 @@ async function createServerHandle(config) {
5819
5780
  if (!session) {
5820
5781
  return res.status(404).json({ error: "Session not found" });
5821
5782
  }
5822
- const { content, attachments, messageKind } = req.body;
5783
+ const { content, attachments, messageKind, agentId } = req.body;
5823
5784
  if (!content?.trim()) {
5824
5785
  return res.status(400).json({ error: "content is required" });
5825
5786
  }
5826
- sessionManager.queueMessage(sessionId, "asap", content, attachments, messageKind);
5787
+ sessionManager.queueMessage(sessionId, "asap", content, attachments, messageKind, agentId);
5827
5788
  res.json({ success: true, queueState: sessionManager.getQueueState(sessionId) });
5828
5789
  });
5829
5790
  app.delete("/api/sessions/:id/queue/:queueId", (req, res) => {
@@ -5842,14 +5803,14 @@ async function createServerHandle(config) {
5842
5803
  if (!session) {
5843
5804
  return res.status(404).json({ error: "Session not found" });
5844
5805
  }
5845
- const { stopSessionExecution } = await import("./chat-handler-TJWYGO3G.js");
5846
- const { cancelQuestionsForSession: cancelQuestionsForSession2, cancelPathConfirmationsForSession: cancelPathConfirmationsForSession2 } = await import("./tools-EVB6JNKF.js");
5806
+ const { stopSessionExecution } = await import("./chat-handler-ITVOWLJR.js");
5807
+ const { cancelQuestionsForSession: cancelQuestionsForSession2, cancelPathConfirmationsForSession: cancelPathConfirmationsForSession2 } = await import("./tools-K7TJWICQ.js");
5847
5808
  stopSessionExecution(sessionId, sessionManager);
5848
5809
  abortSession(sessionId);
5849
5810
  cancelQuestionsForSession2(sessionId, "Session stopped by user");
5850
5811
  cancelPathConfirmationsForSession2(sessionId, "Session stopped by user");
5851
5812
  sessionManager.clearMessageQueue(sessionId);
5852
- const eventStore = (await import("./events-FHPSSSE4.js")).getEventStore();
5813
+ const eventStore = (await import("./events-DFDD4BRS.js")).getEventStore();
5853
5814
  eventStore.append(sessionId, { type: "running.changed", data: { isRunning: false } });
5854
5815
  res.json({ success: true });
5855
5816
  });
@@ -5880,13 +5841,13 @@ async function createServerHandle(config) {
5880
5841
  res.json({ accepted: true });
5881
5842
  });
5882
5843
  app.get("/api/settings/:key", async (req, res) => {
5883
- const { getSetting, SETTINGS_DEFAULTS } = await import("./settings-TWK27GYE.js");
5844
+ const { getSetting, SETTINGS_DEFAULTS } = await import("./settings-NI4ITGV6.js");
5884
5845
  const key = req.params.key;
5885
5846
  const value = getSetting(key) ?? SETTINGS_DEFAULTS[key] ?? null;
5886
5847
  res.json({ key, value });
5887
5848
  });
5888
5849
  app.put("/api/settings/:key", async (req, res) => {
5889
- const { setSetting } = await import("./settings-TWK27GYE.js");
5850
+ const { setSetting } = await import("./settings-NI4ITGV6.js");
5890
5851
  const key = req.params.key;
5891
5852
  const { value } = req.body;
5892
5853
  if (value === void 0) {
@@ -5901,7 +5862,7 @@ async function createServerHandle(config) {
5901
5862
  let visionFallback;
5902
5863
  let globalWorkdir;
5903
5864
  try {
5904
- const { loadGlobalConfig, getVisionFallback } = await import("./config-ACVEHBKG.js");
5865
+ const { loadGlobalConfig, getVisionFallback } = await import("./config-3TU54V4X.js");
5905
5866
  const globalConfig = await loadGlobalConfig(config.mode ?? "production");
5906
5867
  const fallback = getVisionFallback(globalConfig);
5907
5868
  if (fallback) {
@@ -5980,7 +5941,7 @@ async function createServerHandle(config) {
5980
5941
  return res.status(400).json({ error: "name, url, and backend are required" });
5981
5942
  }
5982
5943
  try {
5983
- const { loadGlobalConfig, saveGlobalConfig, addProvider, setDefaultModelSelection } = await import("./config-ACVEHBKG.js");
5944
+ const { loadGlobalConfig, saveGlobalConfig, addProvider, setDefaultModelSelection } = await import("./config-3TU54V4X.js");
5984
5945
  const globalConfig = await loadGlobalConfig(config.mode ?? "production");
5985
5946
  const providerBackend = backend;
5986
5947
  const configWithProvider = addProvider(globalConfig, {
@@ -6013,7 +5974,7 @@ async function createServerHandle(config) {
6013
5974
  app.post("/api/init/config", async (req, res) => {
6014
5975
  const { workdir, visionFallback } = req.body;
6015
5976
  try {
6016
- const { loadGlobalConfig, saveGlobalConfig } = await import("./config-ACVEHBKG.js");
5977
+ const { loadGlobalConfig, saveGlobalConfig } = await import("./config-3TU54V4X.js");
6017
5978
  const globalConfig = await loadGlobalConfig(config.mode ?? "production");
6018
5979
  const updatedConfig = {
6019
5980
  ...globalConfig,
@@ -6041,7 +6002,7 @@ async function createServerHandle(config) {
6041
6002
  });
6042
6003
  app.delete("/api/providers/:id", async (req, res) => {
6043
6004
  const { id } = req.params;
6044
- const { loadGlobalConfig, saveGlobalConfig, removeProvider } = await import("./config-ACVEHBKG.js");
6005
+ const { loadGlobalConfig, saveGlobalConfig, removeProvider } = await import("./config-3TU54V4X.js");
6045
6006
  const globalConfig = await loadGlobalConfig(config.mode ?? "production");
6046
6007
  const updatedConfig = removeProvider(globalConfig, id);
6047
6008
  await saveGlobalConfig(config.mode ?? "production", updatedConfig);
@@ -6061,7 +6022,7 @@ async function createServerHandle(config) {
6061
6022
  return res.status(400).json({ error: result.error });
6062
6023
  }
6063
6024
  const llmClient = getLLMClient();
6064
- const { loadGlobalConfig, saveGlobalConfig, setDefaultModelSelection } = await import("./config-ACVEHBKG.js");
6025
+ const { loadGlobalConfig, saveGlobalConfig, setDefaultModelSelection } = await import("./config-3TU54V4X.js");
6065
6026
  const globalConfig = await loadGlobalConfig(config.mode ?? "production");
6066
6027
  const updatedConfig = setDefaultModelSelection(globalConfig, id, llmClient.getModel());
6067
6028
  await saveGlobalConfig(config.mode ?? "production", updatedConfig);
@@ -6092,7 +6053,7 @@ async function createServerHandle(config) {
6092
6053
  if (!result.success) {
6093
6054
  return res.status(400).json({ error: result.error });
6094
6055
  }
6095
- const { loadGlobalConfig, saveGlobalConfig } = await import("./config-ACVEHBKG.js");
6056
+ const { loadGlobalConfig, saveGlobalConfig } = await import("./config-3TU54V4X.js");
6096
6057
  const globalConfig = await loadGlobalConfig(config.mode ?? "production");
6097
6058
  const updatedProviders = providerManager.getProviders();
6098
6059
  const updatedConfig = {
@@ -6302,7 +6263,7 @@ async function createServerHandle(config) {
6302
6263
  providerManager
6303
6264
  );
6304
6265
  const wss = wssExports.wss;
6305
- const { QueueProcessor } = await import("./processor-ISY5OU5E.js");
6266
+ const { QueueProcessor } = await import("./processor-6CITCUJR.js");
6306
6267
  const queueProcessor = new QueueProcessor({
6307
6268
  sessionManager,
6308
6269
  providerManager,
@@ -6375,4 +6336,4 @@ export {
6375
6336
  createServerHandle,
6376
6337
  createServer
6377
6338
  };
6378
- //# sourceMappingURL=chunk-S3U4EG6C.js.map
6339
+ //# sourceMappingURL=chunk-RB576RLK.js.map
@@ -13,14 +13,14 @@ import {
13
13
  getToolRegistryForAgent,
14
14
  loadAllAgentsDefault,
15
15
  runTopLevelAgentLoop
16
- } from "./chunk-QFOT3J6I.js";
16
+ } from "./chunk-GY4TRYOG.js";
17
17
  import {
18
18
  getCurrentContextWindowId,
19
19
  getEventStore
20
- } from "./chunk-YVQ6DP5Y.js";
20
+ } from "./chunk-ZSQFDQPH.js";
21
21
  import {
22
22
  buildSnapshotFromSessionState
23
- } from "./chunk-LIMBYVO4.js";
23
+ } from "./chunk-G6JKXYFE.js";
24
24
  import {
25
25
  logger
26
26
  } from "./chunk-PNBH3RAX.js";
@@ -72,17 +72,16 @@ async function runChatTurn(options) {
72
72
  const { sessionManager, sessionId } = options;
73
73
  const eventStore = getEventStore();
74
74
  const statsIdentity = resolveStatsIdentity(options);
75
- const session = sessionManager.requireSession(sessionId);
76
- const mode = session.mode;
77
- logger.debug("Starting chat turn", { sessionId, mode });
75
+ const agentId = options.agentId ?? "planner";
76
+ logger.debug("Starting chat turn", { sessionId, agentId });
78
77
  const turnMetrics = new TurnMetrics();
79
78
  try {
80
- if (mode === "builder") {
79
+ if (agentId === "builder") {
81
80
  await runBuilderTurn(options, turnMetrics);
82
81
  } else {
83
- await runGenericAgentTurn(options, turnMetrics, mode);
82
+ await runGenericAgentTurn(options, turnMetrics, agentId);
84
83
  }
85
- const snapshot = buildSnapshot(sessionManager, sessionId, turnMetrics.buildStats(statsIdentity, mode));
84
+ const snapshot = buildSnapshot(sessionManager, sessionId, turnMetrics.buildStats(statsIdentity, agentId));
86
85
  const snapshotEvent = eventStore.append(sessionId, { type: "turn.snapshot", data: snapshot });
87
86
  const deletedCount = eventStore.cleanupOldEvents(sessionId);
88
87
  if (deletedCount > 0) {
@@ -110,7 +109,7 @@ async function runChatTurn(options) {
110
109
  if (error instanceof Error && error.message === "Aborted") {
111
110
  return;
112
111
  }
113
- logger.error("Chat turn error", { sessionId, mode, error });
112
+ logger.error("Chat turn error", { sessionId, agentId, error });
114
113
  const errorMsgId = crypto.randomUUID();
115
114
  eventStore.append(sessionId, {
116
115
  type: "chat.error",
@@ -129,18 +128,39 @@ async function runChatTurn(options) {
129
128
  eventStore.append(sessionId, { type: "running.changed", data: { isRunning: false } });
130
129
  }
131
130
  }
132
- function injectModeReminderIfNeeded(sessionManager, sessionId, agentId, allAgents, onMessage) {
133
- const eventStore = getEventStore();
134
- const session = sessionManager.requireSession(sessionId);
135
- const lastModeReminder = session.executionState?.lastModeWithReminder;
136
- if (lastModeReminder === agentId) {
137
- return;
131
+ function hasReminderInCurrentWindow(events, currentWindowId, keyword) {
132
+ for (let i = events.length - 1; i >= 0; i--) {
133
+ const event = events[i];
134
+ if (event?.type !== "message.start") continue;
135
+ const data = event.data;
136
+ if (data?.role !== "user") continue;
137
+ if (data?.messageKind !== "auto-prompt") continue;
138
+ if (!data?.content?.includes("<system-reminder>")) continue;
139
+ if (!data.content.includes(keyword)) continue;
140
+ if (currentWindowId && data.contextWindowId && data.contextWindowId !== currentWindowId) {
141
+ continue;
142
+ }
143
+ if (currentWindowId && !data.contextWindowId) {
144
+ continue;
145
+ }
146
+ return true;
138
147
  }
148
+ return false;
149
+ }
150
+ function injectModeReminderIfNeeded(_sessionManager, sessionId, agentId, allAgents, _onMessage) {
151
+ const eventStore = getEventStore();
152
+ const currentWindowId = getCurrentContextWindowId(sessionId);
139
153
  const agentDef = findAgentById(agentId, allAgents);
140
154
  if (!agentDef) return;
155
+ const modeKeywordMatch = agentDef.prompt.match(/#\s*(.+Mode)/);
156
+ const keyword = modeKeywordMatch ? modeKeywordMatch[1] ?? agentId : agentId;
157
+ const events = eventStore.getEvents(sessionId);
158
+ if (hasReminderInCurrentWindow(events, currentWindowId, keyword)) {
159
+ return;
160
+ }
141
161
  const reminderContent = buildAgentReminder(agentDef);
142
162
  const reminderMsgId = crypto.randomUUID();
143
- const currentWindowMessageOptions = getCurrentContextWindowId(sessionId) ? { contextWindowId: getCurrentContextWindowId(sessionId) } : void 0;
163
+ const currentWindowMessageOptions = currentWindowId ? { contextWindowId: currentWindowId } : void 0;
144
164
  eventStore.append(sessionId, {
145
165
  type: "message.start",
146
166
  data: {
@@ -161,9 +181,6 @@ function injectModeReminderIfNeeded(sessionManager, sessionId, agentId, allAgent
161
181
  type: "message.done",
162
182
  data: { messageId: reminderMsgId }
163
183
  });
164
- sessionManager.updateExecutionState(sessionId, {
165
- lastModeWithReminder: agentId
166
- });
167
184
  }
168
185
  async function runGenericAgentTurn(options, turnMetrics, agentId) {
169
186
  const statsIdentity = resolveStatsIdentity(options);
@@ -289,8 +306,10 @@ function buildSnapshot(sessionManager, sessionId, lastStats) {
289
306
  export {
290
307
  createVerifierNudgeConfig,
291
308
  runChatTurn,
309
+ hasReminderInCurrentWindow,
310
+ injectModeReminderIfNeeded,
292
311
  filterToolRegistryForStepDone,
293
312
  runBuilderTurn,
294
313
  runVerifierTurn
295
314
  };
296
- //# sourceMappingURL=chunk-VCVHYZZS.js.map
315
+ //# sourceMappingURL=chunk-SMK6HIR5.js.map
@@ -29,7 +29,7 @@ function isVisionFallbackEnabled() {
29
29
  async function ensureVisionFallbackConfigLoaded() {
30
30
  if (configLoaded) return;
31
31
  try {
32
- const { loadGlobalConfig, getVisionFallback } = await import("./config-ACVEHBKG.js");
32
+ const { loadGlobalConfig, getVisionFallback } = await import("./config-3TU54V4X.js");
33
33
  const { getRuntimeConfig } = await import("./runtime-config-2XJJIMSC.js");
34
34
  const runtimeConfig = getRuntimeConfig();
35
35
  const mode = runtimeConfig.mode ?? "production";
@@ -135,4 +135,4 @@ export {
135
135
  describeImage,
136
136
  describeImageFromDataUrl
137
137
  };
138
- //# sourceMappingURL=chunk-CJNQGEYG.js.map
138
+ //# sourceMappingURL=chunk-VCALN543.js.map