openfox 1.6.101 → 1.6.103

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 (32) hide show
  1. package/dist/{auto-compaction-JSXVY2CJ.js → auto-compaction-7LMAY5JV.js} +7 -7
  2. package/dist/{chat-handler-45TB6QWI.js → chat-handler-ZJVIM7U4.js} +10 -10
  3. package/dist/{chunk-DCYDTDWO.js → chunk-6WZI6F6G.js} +20 -4
  4. package/dist/{chunk-SBQ36AOQ.js → chunk-IZC2EZ4D.js} +4 -4
  5. package/dist/{chunk-MBLZSLPH.js → chunk-J335KZ6U.js} +4 -3
  6. package/dist/{chunk-SCAFZ75C.js → chunk-LGN6IXGS.js} +180 -37
  7. package/dist/{chunk-UTBDR6KM.js → chunk-MEYDERUX.js} +1 -1
  8. package/dist/{chunk-NASF624P.js → chunk-PDPXHSNZ.js} +7 -5
  9. package/dist/{chunk-L6LTCUCO.js → chunk-PQOK4XCX.js} +2 -2
  10. package/dist/{chunk-TYIHIHJF.js → chunk-PSJIT5LZ.js} +3 -1
  11. package/dist/{chunk-C5U6NRAY.js → chunk-RCQOHFAN.js} +2 -2
  12. package/dist/{chunk-5LYWA56Z.js → chunk-RYEZ7LDX.js} +60 -7
  13. package/dist/cli/dev.js +25 -1
  14. package/dist/cli/index.js +25 -1
  15. package/dist/{events-JP746DV3.js → events-OKTZRT3Y.js} +3 -3
  16. package/dist/{folding-EQPDQKQS.js → folding-Z3OMWNOE.js} +2 -2
  17. package/dist/{orchestrator-RRO2XLYZ.js → orchestrator-5EYWRAZ2.js} +8 -8
  18. package/dist/package.json +3 -1
  19. package/dist/{processor-C4KLV5SV.js → processor-XJYCHNV6.js} +7 -7
  20. package/dist/{protocol-BkFgSJVU.d.ts → protocol-CdVNdXi8.d.ts} +5 -1
  21. package/dist/{protocol-SVQYBN2X.js → protocol-TNC6MCJV.js} +3 -3
  22. package/dist/{serve-5B36ZPK3.js → serve-NWPJO6J7.js} +9 -9
  23. package/dist/server/index.d.ts +10 -1
  24. package/dist/server/index.js +8 -8
  25. package/dist/{settings-4334IX63.js → settings-VRAOAPLA.js} +2 -2
  26. package/dist/shared/index.d.ts +2 -2
  27. package/dist/shared/index.js +1 -1
  28. package/dist/{tools-AGVKG553.js → tools-WFIYKFBE.js} +7 -7
  29. package/dist/web/assets/{index-Du9Uz0qZ.js → index-DcGVOFte.js} +61 -61
  30. package/dist/web/index.html +1 -1
  31. package/dist/web/sw.js +1 -1
  32. package/package.json +3 -1
@@ -2,19 +2,19 @@ import {
2
2
  maybeAutoCompactContext,
3
3
  performManualContextCompaction,
4
4
  resolveCompactionStatsIdentity
5
- } from "./chunk-5LYWA56Z.js";
6
- import "./chunk-TYIHIHJF.js";
5
+ } from "./chunk-RYEZ7LDX.js";
6
+ import "./chunk-PSJIT5LZ.js";
7
7
  import "./chunk-XAMAYRDA.js";
8
8
  import "./chunk-DL6ZILAF.js";
9
9
  import "./chunk-PBGOZMVY.js";
10
10
  import "./chunk-VRGRAQDG.js";
11
11
  import "./chunk-HGAMIPFO.js";
12
- import "./chunk-MBLZSLPH.js";
12
+ import "./chunk-J335KZ6U.js";
13
13
  import "./chunk-FBGWG4N6.js";
14
- import "./chunk-DCYDTDWO.js";
15
- import "./chunk-C5U6NRAY.js";
14
+ import "./chunk-6WZI6F6G.js";
15
+ import "./chunk-RCQOHFAN.js";
16
16
  import "./chunk-BJYPTN5S.js";
17
- import "./chunk-UTBDR6KM.js";
17
+ import "./chunk-MEYDERUX.js";
18
18
  import "./chunk-CQGTEGKL.js";
19
19
  import "./chunk-CGZHLM3K.js";
20
20
  import "./chunk-SZKEGZIB.js";
@@ -24,4 +24,4 @@ export {
24
24
  performManualContextCompaction,
25
25
  resolveCompactionStatsIdentity
26
26
  };
27
- //# sourceMappingURL=auto-compaction-JSXVY2CJ.js.map
27
+ //# sourceMappingURL=auto-compaction-7LMAY5JV.js.map
@@ -5,12 +5,12 @@ import {
5
5
  generateSessionName,
6
6
  getSessionMessageCount,
7
7
  needsNameGenerationCheck
8
- } from "./chunk-SBQ36AOQ.js";
8
+ } from "./chunk-IZC2EZ4D.js";
9
9
  import {
10
10
  runChatTurn
11
- } from "./chunk-NASF624P.js";
12
- import "./chunk-5LYWA56Z.js";
13
- import "./chunk-TYIHIHJF.js";
11
+ } from "./chunk-PDPXHSNZ.js";
12
+ import "./chunk-RYEZ7LDX.js";
13
+ import "./chunk-PSJIT5LZ.js";
14
14
  import "./chunk-XAMAYRDA.js";
15
15
  import "./chunk-DL6ZILAF.js";
16
16
  import "./chunk-PBGOZMVY.js";
@@ -18,16 +18,16 @@ import "./chunk-VRGRAQDG.js";
18
18
  import "./chunk-HGAMIPFO.js";
19
19
  import {
20
20
  getEventStore
21
- } from "./chunk-MBLZSLPH.js";
21
+ } from "./chunk-J335KZ6U.js";
22
22
  import "./chunk-FBGWG4N6.js";
23
- import "./chunk-DCYDTDWO.js";
23
+ import "./chunk-6WZI6F6G.js";
24
24
  import {
25
25
  createChatMessageMessage,
26
26
  createPhaseChangedMessage,
27
27
  createSessionRunningMessage
28
- } from "./chunk-C5U6NRAY.js";
28
+ } from "./chunk-RCQOHFAN.js";
29
29
  import "./chunk-BJYPTN5S.js";
30
- import "./chunk-UTBDR6KM.js";
30
+ import "./chunk-MEYDERUX.js";
31
31
  import "./chunk-CQGTEGKL.js";
32
32
  import "./chunk-CGZHLM3K.js";
33
33
  import "./chunk-SZKEGZIB.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-JSXVY2CJ.js");
64
+ const { maybeAutoCompactContext } = await import("./auto-compaction-7LMAY5JV.js");
65
65
  await maybeAutoCompactContext({
66
66
  sessionManager,
67
67
  sessionId,
@@ -175,4 +175,4 @@ export {
175
175
  startChatSession,
176
176
  stopSessionExecution
177
177
  };
178
- //# sourceMappingURL=chat-handler-45TB6QWI.js.map
178
+ //# sourceMappingURL=chat-handler-ZJVIM7U4.js.map
@@ -631,11 +631,14 @@ function foldSessionState(events, initialWindowId, maxTokens, initialMessages) {
631
631
  maxTokens,
632
632
  compactionCount: contextResult.compactionCount,
633
633
  dangerZone: false,
634
- canCompact: false
634
+ canCompact: false,
635
+ dynamicContextChanged: false
635
636
  };
636
637
  const contextState = baseContextState.compactionCount !== contextResult.compactionCount || baseContextState.maxTokens !== maxTokens ? { ...baseContextState, compactionCount: contextResult.compactionCount, maxTokens } : { ...baseContextState, maxTokens };
637
638
  let messageReminderMode;
638
639
  let snapshotReminderMode;
640
+ let cachedSystemPrompt;
641
+ let dynamicContextHash;
639
642
  for (let i = events.length - 1; i >= 0; i--) {
640
643
  const event = events[i];
641
644
  if (event.type === "message.start") {
@@ -656,6 +659,12 @@ function foldSessionState(events, initialWindowId, maxTokens, initialMessages) {
656
659
  mode: snapshotData.lastModeWithReminder
657
660
  };
658
661
  }
662
+ if (snapshotData.cachedSystemPrompt && !cachedSystemPrompt) {
663
+ cachedSystemPrompt = snapshotData.cachedSystemPrompt;
664
+ }
665
+ if (snapshotData.dynamicContextHash && !dynamicContextHash) {
666
+ dynamicContextHash = snapshotData.dynamicContextHash;
667
+ }
659
668
  }
660
669
  }
661
670
  let lastModeWithReminder;
@@ -760,6 +769,8 @@ function foldSessionState(events, initialWindowId, maxTokens, initialMessages) {
760
769
  currentContextWindowId: contextResult.currentContextWindowId,
761
770
  readFiles: contextResult.readFiles,
762
771
  ...lastModeWithReminder !== void 0 && { lastModeWithReminder },
772
+ ...cachedSystemPrompt !== void 0 && { cachedSystemPrompt },
773
+ ...dynamicContextHash !== void 0 && { dynamicContextHash },
763
774
  pendingConfirmations,
764
775
  ...sessionInit !== void 0 && { sessionInit },
765
776
  ...sessionTitle !== void 0 && { sessionTitle },
@@ -783,6 +794,8 @@ function buildSnapshot(foldedState, latestSeq, snapshotAt = Date.now()) {
783
794
  todos: foldedState.todos,
784
795
  readFiles: foldedState.readFiles,
785
796
  ...foldedState.lastModeWithReminder !== void 0 && { lastModeWithReminder: foldedState.lastModeWithReminder },
797
+ ...foldedState.cachedSystemPrompt !== void 0 && { cachedSystemPrompt: foldedState.cachedSystemPrompt },
798
+ ...foldedState.dynamicContextHash !== void 0 && { dynamicContextHash: foldedState.dynamicContextHash },
786
799
  snapshotSeq: latestSeq,
787
800
  snapshotAt,
788
801
  ...foldedState.sessionInit !== void 0 && { sessionInit: foldedState.sessionInit },
@@ -828,7 +841,8 @@ function buildSnapshotFromSessionState(input) {
828
841
  maxTokens: foldedState.contextState.maxTokens,
829
842
  compactionCount: session.executionState?.compactionCount ?? foldedState.contextState.compactionCount,
830
843
  dangerZone: foldedState.contextState.dangerZone,
831
- canCompact: foldedState.contextState.canCompact
844
+ canCompact: foldedState.contextState.canCompact,
845
+ dynamicContextChanged: foldedState.contextState.dynamicContextChanged
832
846
  },
833
847
  currentContextWindowId: foldedState.currentContextWindowId,
834
848
  todos: foldedState.todos,
@@ -836,7 +850,9 @@ function buildSnapshotFromSessionState(input) {
836
850
  snapshotSeq: latestSeq,
837
851
  snapshotAt,
838
852
  ...foldedState.sessionInit !== void 0 && { sessionInit: foldedState.sessionInit },
839
- ...foldedState.lastModeWithReminder !== void 0 && { lastModeWithReminder: foldedState.lastModeWithReminder }
853
+ ...foldedState.lastModeWithReminder !== void 0 && { lastModeWithReminder: foldedState.lastModeWithReminder },
854
+ ...input.cachedSystemPrompt !== void 0 ? { cachedSystemPrompt: input.cachedSystemPrompt } : foldedState.cachedSystemPrompt !== void 0 ? { cachedSystemPrompt: foldedState.cachedSystemPrompt } : {},
855
+ ...input.dynamicContextHash !== void 0 ? { dynamicContextHash: input.dynamicContextHash } : foldedState.dynamicContextHash !== void 0 ? { dynamicContextHash: foldedState.dynamicContextHash } : {}
840
856
  };
841
857
  }
842
858
  function getMessagesForWindow(messages, windowId) {
@@ -878,4 +894,4 @@ export {
878
894
  getMessagesForWindow,
879
895
  buildContextMessagesFromMessages
880
896
  };
881
- //# sourceMappingURL=chunk-DCYDTDWO.js.map
897
+ //# sourceMappingURL=chunk-6WZI6F6G.js.map
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  getEventStore,
3
3
  updateSessionMetadata
4
- } from "./chunk-MBLZSLPH.js";
4
+ } from "./chunk-J335KZ6U.js";
5
5
  import {
6
6
  buildMessagesFromStoredEvents,
7
7
  foldPendingConfirmations
8
- } from "./chunk-DCYDTDWO.js";
8
+ } from "./chunk-6WZI6F6G.js";
9
9
  import {
10
10
  createContextStateMessage,
11
11
  createSessionStateMessage
12
- } from "./chunk-C5U6NRAY.js";
12
+ } from "./chunk-RCQOHFAN.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-SBQ36AOQ.js.map
146
+ //# sourceMappingURL=chunk-IZC2EZ4D.js.map
@@ -9,7 +9,7 @@ import {
9
9
  foldSessionState,
10
10
  spreadOptionalMessageFields,
11
11
  stripPromptContextMessages
12
- } from "./chunk-DCYDTDWO.js";
12
+ } from "./chunk-6WZI6F6G.js";
13
13
  import {
14
14
  getRuntimeConfig
15
15
  } from "./chunk-CGZHLM3K.js";
@@ -1072,7 +1072,7 @@ function emitContextCompacted(sessionId, closedWindowId, newWindowId, beforeToke
1072
1072
  }
1073
1073
  });
1074
1074
  }
1075
- function emitContextState(sessionId, currentTokens, maxTokens, compactionCount, dangerZone, canCompact, subAgentId) {
1075
+ function emitContextState(sessionId, currentTokens, maxTokens, compactionCount, dangerZone, canCompact, subAgentId, dynamicContextChanged) {
1076
1076
  const eventStore = getEventStore();
1077
1077
  eventStore.append(sessionId, {
1078
1078
  type: "context.state",
@@ -1082,6 +1082,7 @@ function emitContextState(sessionId, currentTokens, maxTokens, compactionCount,
1082
1082
  compactionCount,
1083
1083
  dangerZone,
1084
1084
  canCompact,
1085
+ dynamicContextChanged: dynamicContextChanged ?? false,
1085
1086
  ...subAgentId !== void 0 && { subAgentId }
1086
1087
  }
1087
1088
  });
@@ -1267,4 +1268,4 @@ export {
1267
1268
  compactContext,
1268
1269
  getRecentUserPromptsForSession
1269
1270
  };
1270
- //# sourceMappingURL=chunk-MBLZSLPH.js.map
1271
+ //# sourceMappingURL=chunk-J335KZ6U.js.map
@@ -2,11 +2,13 @@ import {
2
2
  createVerifierNudgeConfig,
3
3
  runBuilderTurn,
4
4
  runChatTurn
5
- } from "./chunk-NASF624P.js";
5
+ } from "./chunk-PDPXHSNZ.js";
6
6
  import {
7
7
  TurnMetrics,
8
8
  agentExists,
9
+ buildTopLevelSystemPrompt,
9
10
  checkAborted,
11
+ computeDynamicContextHash,
10
12
  createMessageStartEvent,
11
13
  createToolRegistry,
12
14
  deleteAgent,
@@ -18,9 +20,12 @@ import {
18
20
  executeSubAgent,
19
21
  findAgentById,
20
22
  findSkillById,
23
+ getAllInstructions,
21
24
  getDefaultAgentIds,
22
25
  getDefaultIds,
23
26
  getDefaultSkillIds,
27
+ getEnabledSkillMetadata,
28
+ getSubAgents,
24
29
  getToolRegistryForAgent,
25
30
  getTopLevelAgents,
26
31
  isDefaultAgent,
@@ -46,7 +51,7 @@ import {
46
51
  saveSkillToProject,
47
52
  skillExists,
48
53
  spawnShellProcess
49
- } from "./chunk-5LYWA56Z.js";
54
+ } from "./chunk-RYEZ7LDX.js";
50
55
  import {
51
56
  getProject
52
57
  } from "./chunk-XAMAYRDA.js";
@@ -95,14 +100,14 @@ import {
95
100
  updateSessionMetadata,
96
101
  updateSessionProvider,
97
102
  updateSessionRunning
98
- } from "./chunk-MBLZSLPH.js";
103
+ } from "./chunk-J335KZ6U.js";
99
104
  import {
100
105
  initDatabase
101
106
  } from "./chunk-FBGWG4N6.js";
102
107
  import {
103
108
  buildMessagesFromStoredEvents,
104
109
  foldPendingConfirmations
105
- } from "./chunk-DCYDTDWO.js";
110
+ } from "./chunk-6WZI6F6G.js";
106
111
  import {
107
112
  createChatErrorMessage,
108
113
  createChatMessageMessage,
@@ -117,7 +122,7 @@ import {
117
122
  parseClientMessage,
118
123
  serializeServerMessage,
119
124
  storedEventToServerMessage
120
- } from "./chunk-C5U6NRAY.js";
125
+ } from "./chunk-RCQOHFAN.js";
121
126
  import {
122
127
  EventEmitter,
123
128
  provideAnswer
@@ -127,7 +132,7 @@ import {
127
132
  } from "./chunk-VUQCQXXJ.js";
128
133
  import {
129
134
  createServerMessage
130
- } from "./chunk-UTBDR6KM.js";
135
+ } from "./chunk-MEYDERUX.js";
131
136
  import {
132
137
  getGlobalConfigDir
133
138
  } from "./chunk-CQGTEGKL.js";
@@ -2881,9 +2886,34 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
2881
2886
  if (branch) moduleStartGitPolling(session.workdir);
2882
2887
  }
2883
2888
  ensureEventStoreSubscription(session.id);
2884
- const contextState = sessionManager.getContextState(session.id);
2885
- send(createContextStateMessage(contextState));
2886
2889
  send({ type: "ack", payload: { sessionId: session.id }, id: message.id });
2890
+ const sendContextState = () => {
2891
+ const contextState = sessionManager.getContextState(session.id);
2892
+ send(createContextStateMessage(contextState));
2893
+ };
2894
+ sendContextState();
2895
+ const cachedHash = sessionManager.getCachedPrompt(session.id)?.hash;
2896
+ if (cachedHash) {
2897
+ ;
2898
+ (async () => {
2899
+ try {
2900
+ const { content: instructionContent } = await getAllInstructions(session.workdir, session.projectId);
2901
+ const runtimeConfig = getRuntimeConfig();
2902
+ const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
2903
+ const skills = await getEnabledSkillMetadata(configDir, runtimeConfig.workdir);
2904
+ const dynamicInputs = JSON.stringify({
2905
+ instructions: instructionContent,
2906
+ skills: skills.map((s) => s.id).sort()
2907
+ });
2908
+ const currentHash = createHash2("sha256").update(dynamicInputs).digest("hex");
2909
+ if (currentHash !== cachedHash) {
2910
+ sessionManager.setDynamicContextChanged(session.id, true);
2911
+ sendContextState();
2912
+ }
2913
+ } catch {
2914
+ }
2915
+ })();
2916
+ }
2887
2917
  break;
2888
2918
  }
2889
2919
  // =========================================================================
@@ -2933,6 +2963,88 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
2933
2963
  })();
2934
2964
  break;
2935
2965
  }
2966
+ case "context.checkDynamic": {
2967
+ if (!client.activeSessionId) {
2968
+ send(createErrorMessage("NO_SESSION", "No active session", message.id));
2969
+ return;
2970
+ }
2971
+ const sessionId = client.activeSessionId;
2972
+ const session = sessionManager.requireSession(sessionId);
2973
+ (async () => {
2974
+ try {
2975
+ const { content: instructionContent } = await getAllInstructions(session.workdir, session.projectId);
2976
+ const runtimeConfig = getRuntimeConfig();
2977
+ const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
2978
+ const skills = await getEnabledSkillMetadata(configDir, runtimeConfig.workdir);
2979
+ const currentHash = computeDynamicContextHash(instructionContent, skills);
2980
+ const cachedHash = sessionManager.getCachedPrompt(sessionId)?.hash;
2981
+ if (cachedHash) {
2982
+ if (currentHash !== cachedHash) {
2983
+ if (!sessionManager.getDynamicContextChanged(sessionId)) {
2984
+ sessionManager.setDynamicContextChanged(sessionId, true);
2985
+ const newContextState = sessionManager.getContextState(sessionId);
2986
+ sendForSession(sessionId, createContextStateMessage(newContextState));
2987
+ }
2988
+ } else if (sessionManager.getDynamicContextChanged(sessionId)) {
2989
+ sessionManager.setDynamicContextChanged(sessionId, false);
2990
+ const newContextState = sessionManager.getContextState(sessionId);
2991
+ sendForSession(sessionId, createContextStateMessage(newContextState));
2992
+ }
2993
+ }
2994
+ send({ type: "ack", payload: {}, id: message.id });
2995
+ } catch (error) {
2996
+ logger.error("Failed to check dynamic context", { error, sessionId });
2997
+ send({ type: "ack", payload: {}, id: message.id });
2998
+ }
2999
+ })();
3000
+ break;
3001
+ }
3002
+ case "context.applyDynamic": {
3003
+ if (!client.activeSessionId) {
3004
+ send(createErrorMessage("NO_SESSION", "No active session", message.id));
3005
+ return;
3006
+ }
3007
+ const sessionId = client.activeSessionId;
3008
+ const session = sessionManager.requireSession(sessionId);
3009
+ if (session.isRunning) {
3010
+ send(createErrorMessage("SESSION_RUNNING", "Cannot apply dynamic context while session is running", message.id));
3011
+ return;
3012
+ }
3013
+ ;
3014
+ (async () => {
3015
+ try {
3016
+ const { content: instructionContent } = await getAllInstructions(session.workdir, session.projectId);
3017
+ const runtimeConfig = getRuntimeConfig();
3018
+ const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
3019
+ const skills = await getEnabledSkillMetadata(configDir, runtimeConfig.workdir);
3020
+ const dynamicHash = computeDynamicContextHash(instructionContent, skills);
3021
+ const allAgents = await loadAllAgentsDefault();
3022
+ const subAgentDefs = getSubAgents(allAgents);
3023
+ const systemPrompt = buildTopLevelSystemPrompt(
3024
+ session.workdir,
3025
+ instructionContent || void 0,
3026
+ skills,
3027
+ subAgentDefs
3028
+ );
3029
+ sessionManager.setCachedPrompt(sessionId, systemPrompt, dynamicHash);
3030
+ sessionManager.setDynamicContextChanged(sessionId, false);
3031
+ const newContextState = sessionManager.getContextState(sessionId);
3032
+ sendForSession(sessionId, createContextStateMessage(newContextState));
3033
+ send({ type: "ack", payload: {}, id: message.id });
3034
+ } catch (error) {
3035
+ logger.error("Failed to apply dynamic context", { error, sessionId });
3036
+ sendForSession(
3037
+ sessionId,
3038
+ createChatErrorMessage(
3039
+ `Failed to apply dynamic context: ${error instanceof Error ? error.message : "Unknown error"}`,
3040
+ true
3041
+ )
3042
+ );
3043
+ send({ type: "ack", payload: {}, id: message.id });
3044
+ }
3045
+ })();
3046
+ break;
3047
+ }
2936
3048
  // =========================================================================
2937
3049
  // Runner (Auto-Loop)
2938
3050
  // =========================================================================
@@ -4111,6 +4223,8 @@ var SessionManager = class {
4111
4223
  events = new EventEmitter();
4112
4224
  activeSessionId = null;
4113
4225
  providerManager;
4226
+ cachedPromptStore = /* @__PURE__ */ new Map();
4227
+ dynamicContextChangedStore = /* @__PURE__ */ new Map();
4114
4228
  constructor(providerManager) {
4115
4229
  this.providerManager = providerManager;
4116
4230
  }
@@ -4448,6 +4562,7 @@ ${summary}`, {
4448
4562
  const state = getSessionState(sessionId, this.providerManager.getCurrentModelContext());
4449
4563
  const maxTokens = this.providerManager.getCurrentModelContext();
4450
4564
  const compactionCount = state?.contextState.compactionCount ?? 0;
4565
+ const dynamicContextChanged = this.getDynamicContextChanged(sessionId);
4451
4566
  emitContextState(
4452
4567
  sessionId,
4453
4568
  promptTokens,
@@ -4455,7 +4570,8 @@ ${summary}`, {
4455
4570
  compactionCount,
4456
4571
  isInDangerZone(promptTokens, maxTokens),
4457
4572
  canCompact(promptTokens, maxTokens),
4458
- subAgentId
4573
+ subAgentId,
4574
+ dynamicContextChanged
4459
4575
  );
4460
4576
  logger.debug("Context state updated", { sessionId, promptTokens, maxTokens, subAgentId });
4461
4577
  }
@@ -4668,6 +4784,18 @@ ${summary}`, {
4668
4784
  updateExecutionState(sessionId, updates) {
4669
4785
  logger.debug("updateExecutionState called", { sessionId, updates });
4670
4786
  }
4787
+ setCachedPrompt(sessionId, systemPrompt, hash) {
4788
+ this.cachedPromptStore.set(sessionId, { systemPrompt, hash });
4789
+ }
4790
+ getCachedPrompt(sessionId) {
4791
+ return this.cachedPromptStore.get(sessionId);
4792
+ }
4793
+ setDynamicContextChanged(sessionId, changed) {
4794
+ this.dynamicContextChangedStore.set(sessionId, changed);
4795
+ }
4796
+ getDynamicContextChanged(sessionId) {
4797
+ return this.dynamicContextChangedStore.get(sessionId) ?? false;
4798
+ }
4671
4799
  /**
4672
4800
  * @deprecated Use addMessage + compactContext instead
4673
4801
  */
@@ -4722,16 +4850,18 @@ ${summary}`,
4722
4850
  maxTokens = providerManager.getCurrentModelContext();
4723
4851
  }
4724
4852
  const state = getSessionState(sessionId, maxTokens);
4853
+ const dynamicContextChanged = this.getDynamicContextChanged(sessionId);
4725
4854
  if (!state) {
4726
4855
  return {
4727
4856
  currentTokens: 0,
4728
4857
  maxTokens,
4729
4858
  compactionCount: 0,
4730
4859
  dangerZone: false,
4731
- canCompact: false
4860
+ canCompact: false,
4861
+ dynamicContextChanged
4732
4862
  };
4733
4863
  }
4734
- return state.contextState;
4864
+ return { ...state.contextState, dynamicContextChanged };
4735
4865
  }
4736
4866
  // ============================================================================
4737
4867
  // LSP Manager
@@ -4813,6 +4943,17 @@ ${summary}`,
4813
4943
  return msg;
4814
4944
  });
4815
4945
  const isRunning = dbSession.isRunning;
4946
+ const hasCachedPrompt = this.cachedPromptStore.has(dbSession.id);
4947
+ const cachedData = this.cachedPromptStore.get(dbSession.id);
4948
+ if (!hasCachedPrompt && eventState.cachedSystemPrompt && eventState.dynamicContextHash) {
4949
+ this.cachedPromptStore.set(dbSession.id, {
4950
+ systemPrompt: eventState.cachedSystemPrompt,
4951
+ hash: eventState.dynamicContextHash
4952
+ });
4953
+ }
4954
+ if (!this.dynamicContextChangedStore.has(dbSession.id) && eventState.contextState.dynamicContextChanged) {
4955
+ this.dynamicContextChangedStore.set(dbSession.id, true);
4956
+ }
4816
4957
  return {
4817
4958
  ...dbSession,
4818
4959
  mode: eventState.mode,
@@ -4822,8 +4963,10 @@ ${summary}`,
4822
4963
  criteria: eventState.criteria,
4823
4964
  contextWindows: [],
4824
4965
  // Derived from events, not stored separately
4825
- executionState: eventState.lastModeWithReminder ? {
4826
- lastModeWithReminder: eventState.lastModeWithReminder
4966
+ executionState: eventState.lastModeWithReminder || eventState.cachedSystemPrompt || hasCachedPrompt ? {
4967
+ lastModeWithReminder: eventState.lastModeWithReminder,
4968
+ cachedSystemPrompt: cachedData?.systemPrompt ?? eventState.cachedSystemPrompt,
4969
+ dynamicContextHash: cachedData?.hash ?? eventState.dynamicContextHash
4827
4970
  } : null
4828
4971
  };
4829
4972
  }
@@ -5365,7 +5508,7 @@ import { Router as Router6 } from "express";
5365
5508
  import { spawn as spawn4 } from "child_process";
5366
5509
 
5367
5510
  // src/constants.ts
5368
- var VERSION = "1.6.101";
5511
+ var VERSION = "1.6.103";
5369
5512
 
5370
5513
  // src/server/routes/auto-update.ts
5371
5514
  var updateInProgress = false;
@@ -5662,7 +5805,7 @@ async function createServerHandle(config4) {
5662
5805
  res.json({ project });
5663
5806
  });
5664
5807
  app.get("/api/sessions", async (req, res) => {
5665
- const { getRecentUserPromptsForSession } = await import("./events-JP746DV3.js");
5808
+ const { getRecentUserPromptsForSession } = await import("./events-OKTZRT3Y.js");
5666
5809
  const projectId = req.query["projectId"];
5667
5810
  const limit = Math.min(parseInt(req.query["limit"]) || 20, 100);
5668
5811
  const offset = parseInt(req.query["offset"]) || 0;
@@ -5695,8 +5838,8 @@ async function createServerHandle(config4) {
5695
5838
  res.status(201).json({ session });
5696
5839
  });
5697
5840
  app.get("/api/sessions/:id", async (req, res) => {
5698
- const { getEventStore: getEventStore2 } = await import("./events-JP746DV3.js");
5699
- const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-EQPDQKQS.js");
5841
+ const { getEventStore: getEventStore2 } = await import("./events-OKTZRT3Y.js");
5842
+ const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-Z3OMWNOE.js");
5700
5843
  const session = sessionManager.getSession(req.params.id);
5701
5844
  if (!session) {
5702
5845
  return res.status(404).json({ error: "Session not found" });
@@ -5726,8 +5869,8 @@ async function createServerHandle(config4) {
5726
5869
  res.json({ success: true });
5727
5870
  });
5728
5871
  app.post("/api/sessions/:id/provider", async (req, res) => {
5729
- const { getEventStore: getEventStore2 } = await import("./events-JP746DV3.js");
5730
- const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-EQPDQKQS.js");
5872
+ const { getEventStore: getEventStore2 } = await import("./events-OKTZRT3Y.js");
5873
+ const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-Z3OMWNOE.js");
5731
5874
  const sessionId = req.params.id;
5732
5875
  const session = sessionManager.getSession(sessionId);
5733
5876
  if (!session) {
@@ -5764,8 +5907,8 @@ async function createServerHandle(config4) {
5764
5907
  res.json({ success: true });
5765
5908
  });
5766
5909
  app.put("/api/sessions/:id/mode", async (req, res) => {
5767
- const { getEventStore: getEventStore2 } = await import("./events-JP746DV3.js");
5768
- const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-EQPDQKQS.js");
5910
+ const { getEventStore: getEventStore2 } = await import("./events-OKTZRT3Y.js");
5911
+ const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-Z3OMWNOE.js");
5769
5912
  const sessionId = req.params.id;
5770
5913
  const session = sessionManager.getSession(sessionId);
5771
5914
  if (!session) {
@@ -5821,14 +5964,14 @@ async function createServerHandle(config4) {
5821
5964
  if (!callId || approved === void 0) {
5822
5965
  return res.status(400).json({ error: "callId and approved are required" });
5823
5966
  }
5824
- const { providePathConfirmation } = await import("./tools-AGVKG553.js");
5967
+ const { providePathConfirmation } = await import("./tools-WFIYKFBE.js");
5825
5968
  const result = providePathConfirmation(callId, approved, alwaysAllow);
5826
5969
  if (!result.found) {
5827
5970
  return res.status(404).json({ error: "No pending path confirmation with that ID" });
5828
5971
  }
5829
- const { getEventStore: getEventStore2 } = await import("./events-JP746DV3.js");
5830
- const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2, foldPendingConfirmations: foldPendingConfirmations2 } = await import("./folding-EQPDQKQS.js");
5831
- const { createSessionStateMessage: createSessionStateMessage2 } = await import("./protocol-SVQYBN2X.js");
5972
+ const { getEventStore: getEventStore2 } = await import("./events-OKTZRT3Y.js");
5973
+ const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2, foldPendingConfirmations: foldPendingConfirmations2 } = await import("./folding-Z3OMWNOE.js");
5974
+ const { createSessionStateMessage: createSessionStateMessage2 } = await import("./protocol-TNC6MCJV.js");
5832
5975
  const eventStore = getEventStore2();
5833
5976
  const events = eventStore.getEvents(sessionId);
5834
5977
  const messages = buildMessagesFromStoredEvents2(events);
@@ -5845,7 +5988,7 @@ async function createServerHandle(config4) {
5845
5988
  if (!callId || !answer) {
5846
5989
  return res.status(400).json({ error: "callId and answer are required" });
5847
5990
  }
5848
- const { provideAnswer: provideAnswer2 } = await import("./tools-AGVKG553.js");
5991
+ const { provideAnswer: provideAnswer2 } = await import("./tools-WFIYKFBE.js");
5849
5992
  const found = provideAnswer2(callId, answer);
5850
5993
  if (!found) {
5851
5994
  return res.status(404).json({ error: "No pending question with that ID" });
@@ -5881,14 +6024,14 @@ async function createServerHandle(config4) {
5881
6024
  if (!session) {
5882
6025
  return res.status(404).json({ error: "Session not found" });
5883
6026
  }
5884
- const { stopSessionExecution } = await import("./chat-handler-45TB6QWI.js");
5885
- const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-AGVKG553.js");
6027
+ const { stopSessionExecution } = await import("./chat-handler-ZJVIM7U4.js");
6028
+ const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-WFIYKFBE.js");
5886
6029
  stopSessionExecution(sessionId, sessionManager);
5887
6030
  abortSession(sessionId);
5888
6031
  cancelQuestionsForSession(sessionId, "Session stopped by user");
5889
6032
  cancelPathConfirmationsForSession(sessionId, "Session stopped by user");
5890
6033
  sessionManager.clearMessageQueue(sessionId);
5891
- const eventStore = (await import("./events-JP746DV3.js")).getEventStore();
6034
+ const eventStore = (await import("./events-OKTZRT3Y.js")).getEventStore();
5892
6035
  eventStore.append(sessionId, { type: "running.changed", data: { isRunning: false } });
5893
6036
  res.json({ success: true });
5894
6037
  });
@@ -5902,7 +6045,7 @@ async function createServerHandle(config4) {
5902
6045
  if (typeof messageIndex !== "number" || messageIndex < 0) {
5903
6046
  return res.status(400).json({ error: "messageIndex must be a non-negative number" });
5904
6047
  }
5905
- const { truncateSessionMessages } = await import("./events-JP746DV3.js");
6048
+ const { truncateSessionMessages } = await import("./events-OKTZRT3Y.js");
5906
6049
  truncateSessionMessages(sessionId, messageIndex);
5907
6050
  res.json({ success: true });
5908
6051
  });
@@ -5920,7 +6063,7 @@ async function createServerHandle(config4) {
5920
6063
  if (!msg) {
5921
6064
  return res.status(400).json({ error: "Message not found at this index" });
5922
6065
  }
5923
- const { truncateSessionMessages } = await import("./events-JP746DV3.js");
6066
+ const { truncateSessionMessages } = await import("./events-OKTZRT3Y.js");
5924
6067
  truncateSessionMessages(sessionId, messageIndex - 1);
5925
6068
  sessionManager.queueMessage(sessionId, "asap", msg.content, msg.attachments, msg.messageKind);
5926
6069
  res.json({ success: true });
@@ -5952,7 +6095,7 @@ async function createServerHandle(config4) {
5952
6095
  res.json({ accepted: true });
5953
6096
  });
5954
6097
  app.get("/api/settings", async (req, res) => {
5955
- const { getSetting, SETTINGS_DEFAULTS } = await import("./settings-4334IX63.js");
6098
+ const { getSetting, SETTINGS_DEFAULTS } = await import("./settings-VRAOAPLA.js");
5956
6099
  const keysParam = req.query["keys"];
5957
6100
  if (!keysParam) {
5958
6101
  return res.status(400).json({ error: "keys query parameter is required" });
@@ -5965,19 +6108,19 @@ async function createServerHandle(config4) {
5965
6108
  res.json(result);
5966
6109
  });
5967
6110
  app.get("/api/settings/:key", async (req, res) => {
5968
- const { getSetting, SETTINGS_DEFAULTS } = await import("./settings-4334IX63.js");
6111
+ const { getSetting, SETTINGS_DEFAULTS } = await import("./settings-VRAOAPLA.js");
5969
6112
  const key = req.params.key;
5970
6113
  const value = getSetting(key) ?? SETTINGS_DEFAULTS[key] ?? null;
5971
6114
  res.json({ key, value });
5972
6115
  });
5973
6116
  app.get("/api/settings/:key", async (req, res) => {
5974
- const { getSetting, SETTINGS_DEFAULTS } = await import("./settings-4334IX63.js");
6117
+ const { getSetting, SETTINGS_DEFAULTS } = await import("./settings-VRAOAPLA.js");
5975
6118
  const key = req.params.key;
5976
6119
  const value = getSetting(key) ?? SETTINGS_DEFAULTS[key] ?? null;
5977
6120
  res.json({ key, value });
5978
6121
  });
5979
6122
  app.put("/api/settings/:key", async (req, res) => {
5980
- const { setSetting } = await import("./settings-4334IX63.js");
6123
+ const { setSetting } = await import("./settings-VRAOAPLA.js");
5981
6124
  const key = req.params.key;
5982
6125
  const { value } = req.body;
5983
6126
  if (value === void 0) {
@@ -6397,7 +6540,7 @@ async function createServerHandle(config4) {
6397
6540
  providerManager
6398
6541
  );
6399
6542
  const wss = wssExports.wss;
6400
- const { QueueProcessor } = await import("./processor-C4KLV5SV.js");
6543
+ const { QueueProcessor } = await import("./processor-XJYCHNV6.js");
6401
6544
  const queueProcessor = new QueueProcessor({
6402
6545
  sessionManager,
6403
6546
  providerManager,
@@ -6469,4 +6612,4 @@ export {
6469
6612
  createServerHandle,
6470
6613
  createServer
6471
6614
  };
6472
- //# sourceMappingURL=chunk-SCAFZ75C.js.map
6615
+ //# sourceMappingURL=chunk-LGN6IXGS.js.map
@@ -26,4 +26,4 @@ export {
26
26
  isClientMessage,
27
27
  isServerMessage
28
28
  };
29
- //# sourceMappingURL=chunk-UTBDR6KM.js.map
29
+ //# sourceMappingURL=chunk-MEYDERUX.js.map