openfox 2.0.119 → 2.0.121

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 (87) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/CHANGELOG.md +27 -0
  3. package/dist/agent-defaults/code-reviewer.agent.md +3 -8
  4. package/dist/{chat-handler-M54IWF5Y.js → chat-handler-A5ORR5BB.js} +28 -29
  5. package/dist/{chunk-LNNBLB6G.js → chunk-2N7KFNMY.js} +3 -3
  6. package/dist/{chunk-XZGQZ42D.js → chunk-5A4YN6I7.js} +5 -5
  7. package/dist/{chunk-UNNCD7A3.js → chunk-5QTERLHH.js} +6 -6
  8. package/dist/{chunk-SE62ZBNX.js → chunk-62GUO2EG.js} +6 -4
  9. package/dist/{chunk-YHAE2SJI.js → chunk-6A2VIV36.js} +4 -4
  10. package/dist/{chunk-VUQCQXXJ.js → chunk-7OHXF5GW.js} +6 -3
  11. package/dist/{chunk-3PG65AXG.js → chunk-DIALH34K.js} +2 -2
  12. package/dist/{chunk-AESOGRFK.js → chunk-EZ67GBEO.js} +2 -2
  13. package/dist/{chunk-AIFZNTUJ.js → chunk-F2IM5J4I.js} +4 -4
  14. package/dist/{chunk-HD6Y77RO.js → chunk-FGVMRFDW.js} +2 -2
  15. package/dist/{chunk-W7VIYHPQ.js → chunk-GJL3QSMP.js} +3 -2
  16. package/dist/{chunk-ZTOG6LJD.js → chunk-I22B6KWV.js} +3 -3
  17. package/dist/{chunk-JOCR4CF4.js → chunk-J3IJJ55E.js} +5 -5
  18. package/dist/{chunk-J6KFWVZ3.js → chunk-J77SLE3M.js} +3 -3
  19. package/dist/{chunk-XZ2WAI66.js → chunk-KD7JTG42.js} +237 -199
  20. package/dist/{chunk-2FCLCUVR.js → chunk-LSEHJ2WI.js} +3 -3
  21. package/dist/{chunk-3KBRMBTP.js → chunk-LWXLNE6M.js} +2 -2
  22. package/dist/{chunk-5PT4UMRR.js → chunk-NYQKSKDB.js} +9 -1
  23. package/dist/{chunk-5FAPM2GM.js → chunk-O63CDVNI.js} +4 -4
  24. package/dist/chunk-OBB3JYMK.js +7 -0
  25. package/dist/{chunk-M6X6AIEG.js → chunk-OXANSWVZ.js} +2 -2
  26. package/dist/{chunk-LTYL6ZGH.js → chunk-POTCPZJF.js} +2 -2
  27. package/dist/{chunk-O6DU226D.js → chunk-RMOKNQAS.js} +2 -2
  28. package/dist/{chunk-KLQEL2DZ.js → chunk-SLW3KKPP.js} +26 -8
  29. package/dist/{chunk-V5XWUVF5.js → chunk-TR4DQZIG.js} +123 -49
  30. package/dist/{chunk-U6JMRMBW.js → chunk-UJRWYZHM.js} +9 -3
  31. package/dist/{chunk-6DDB67FN.js → chunk-VUANU5A5.js} +17 -17
  32. package/dist/{chunk-AVQCOSOF.js → chunk-W3WZ54KP.js} +16 -16
  33. package/dist/{chunk-27NABDXB.js → chunk-Y7FGHKBW.js} +2 -2
  34. package/dist/{chunk-EQ5CGNOT.js → chunk-YBOU4ZFD.js} +3 -3
  35. package/dist/{chunk-VFS7TFA7.js → chunk-YDDBPKVP.js} +21 -16
  36. package/dist/{chunk-XB7IXMUI.js → chunk-ZELEYSTY.js} +51 -46
  37. package/dist/cli/dev.js +1 -1
  38. package/dist/cli/index.js +1 -1
  39. package/dist/{client-R4PI64IL.js → client-JKPDMJ7S.js} +6 -6
  40. package/dist/{compactor-F6XMYVHL.js → compactor-MKD3CAFM.js} +13 -13
  41. package/dist/{dynamic-context-NXQ2TFAZ.js → dynamic-context-KPZECHZH.js} +9 -9
  42. package/dist/{events-KDFMBVP5.js → events-6P4TDTSD.js} +8 -8
  43. package/dist/{folding-RTGU63BW.js → folding-3LA2WX2B.js} +6 -6
  44. package/dist/http-client-IKOARXI7.js +11 -0
  45. package/dist/{inspect-proxy-WPEDMCG7.js → inspect-proxy-IDLUAQH5.js} +4 -4
  46. package/dist/launch-YWXQQWZN.js +52 -0
  47. package/dist/{manager-EMLSLMMT.js → manager-NFKTUR64.js} +5 -5
  48. package/dist/{orchestrator-MNON5G7R.js → orchestrator-SM3IHZFP.js} +31 -32
  49. package/dist/package.json +1 -1
  50. package/dist/{path-security-L4AJJN2V.js → path-security-JUF56IB6.js} +10 -10
  51. package/dist/{platform-ECDDYMAR.js → platform-FM57ZJHA.js} +4 -4
  52. package/dist/{processor-OZSK7RUD.js → processor-EUJRA5GW.js} +40 -41
  53. package/dist/{profiles-GYHXBWPV.js → profiles-3YLLEJ2B.js} +2 -2
  54. package/dist/{project-creator-PMQ65NKN.js → project-creator-J4ITWDZI.js} +3 -3
  55. package/dist/{projects-NDPNOV6D.js → projects-FHRTSV6N.js} +3 -3
  56. package/dist/{protocol-D5kJLGWy.d.ts → protocol-BLin669D.d.ts} +1 -1
  57. package/dist/provider/index.d.ts +4 -4
  58. package/dist/{provider-7YF42S7C.js → provider-TAFJCWVP.js} +7 -7
  59. package/dist/{provider-manager-FJIPQJMX.js → provider-manager-EDJN6ARI.js} +7 -7
  60. package/dist/{registry-5QL3BOWN.js → registry-37GL3DAP.js} +5 -5
  61. package/dist/{serve-V34QG72C.js → serve-DEY45HQS.js} +32 -33
  62. package/dist/server/index.d.ts +40 -8
  63. package/dist/server/index.js +31 -32
  64. package/dist/server-EIRLWSBZ.js +55 -0
  65. package/dist/{service-ZKH465DA.js → service-HX5NFX2D.js} +9 -9
  66. package/dist/{session-overrides-CWBKPHMF.js → session-overrides-EOKSZO2X.js} +7 -7
  67. package/dist/{sessions-I7ELDIIP.js → sessions-XFNU4DZ6.js} +8 -6
  68. package/dist/{settings-FGXQHKUH.js → settings-SYYDPV43.js} +3 -3
  69. package/dist/shared/index.d.ts +6 -5
  70. package/dist/shared/index.js +1 -1
  71. package/dist/{tasks-I766NBPW.js → tasks-A25JQ4TV.js} +9 -9
  72. package/dist/{tools-ZJXDZLRH.js → tools-YGJXEEBI.js} +23 -24
  73. package/dist/{types-B5CI_Ql3.d.ts → types-B5_9KtfJ.d.ts} +1 -1
  74. package/dist/{types-CZlj7ufS.d.ts → types-DeQIEC1U.d.ts} +2 -0
  75. package/dist/{update-C3YVPKCR.js → update-CE3XSZXE.js} +2 -2
  76. package/dist/web/assets/{index-BlYcAqzD.js → index-oiZlWLY7.js} +84 -84
  77. package/dist/web/index.html +1 -1
  78. package/dist/web/sw.js +1 -1
  79. package/dist/workflow-defaults/default.workflow.json +3 -3
  80. package/dist/{workspace-IQLLHMYR.js → workspace-ZNZFEONU.js} +4 -4
  81. package/package.json +1 -1
  82. package/dist/chunk-EW25UQG3.js +0 -7
  83. package/dist/chunk-JLAR2CMV.js +0 -72
  84. package/dist/http-client-IPUW2MSW.js +0 -11
  85. package/dist/launch-I5XBYRSJ.js +0 -53
  86. package/dist/model-overrides-7F2EOA4U.js +0 -21
  87. package/dist/server-XZQLWIVD.js +0 -56
@@ -16,20 +16,27 @@ import {
16
16
  terminalManager,
17
17
  tokenFromPassword,
18
18
  verifyPassword
19
- } from "./chunk-XB7IXMUI.js";
19
+ } from "./chunk-ZELEYSTY.js";
20
20
  import {
21
21
  TEMPLATE_VARIABLES
22
- } from "./chunk-AVQCOSOF.js";
22
+ } from "./chunk-W3WZ54KP.js";
23
+ import {
24
+ openFolder
25
+ } from "./chunk-WLJJRX22.js";
23
26
  import {
24
27
  createToolRegistry,
25
28
  devServerManager,
29
+ getAgentModelOverride,
30
+ getAgentModelOverrides,
26
31
  getBuiltInToolNames,
32
+ resolveLLMClientForAgent,
33
+ setAgentModelOverride,
27
34
  setMcpConfigMode,
28
35
  setMcpConfigPath,
29
36
  setMcpManagerForTools,
30
37
  setMcpTools,
31
38
  setNotifyMcpServersChanged
32
- } from "./chunk-V5XWUVF5.js";
39
+ } from "./chunk-TR4DQZIG.js";
33
40
  import {
34
41
  deleteOwnedSkill,
35
42
  deleteProjectSkill,
@@ -48,15 +55,7 @@ import {
48
55
  setSkillEnabled,
49
56
  skillExists,
50
57
  updateOwnedSkill
51
- } from "./chunk-2FCLCUVR.js";
52
- import {
53
- openFolder
54
- } from "./chunk-WLJJRX22.js";
55
- import {
56
- ALWAYS_ALLOWED,
57
- ALWAYS_ALLOWED_FOR_SUBAGENTS,
58
- TOP_LEVEL_ONLY_TOOLS
59
- } from "./chunk-27NABDXB.js";
58
+ } from "./chunk-LSEHJ2WI.js";
60
59
  import {
61
60
  createMcpTools
62
61
  } from "./chunk-JE7LW7Y6.js";
@@ -75,7 +74,7 @@ import {
75
74
  validateRef,
76
75
  validateWorkspaceName,
77
76
  workspaceExists
78
- } from "./chunk-O6DU226D.js";
77
+ } from "./chunk-RMOKNQAS.js";
79
78
  import {
80
79
  commandExists,
81
80
  deleteCommand,
@@ -102,11 +101,23 @@ import {
102
101
  saveWorkflow,
103
102
  saveWorkflowToProject,
104
103
  workflowExists
105
- } from "./chunk-5FAPM2GM.js";
104
+ } from "./chunk-O63CDVNI.js";
106
105
  import {
107
106
  getSessionDisabledServers,
108
107
  setSessionDisabledServers
109
- } from "./chunk-EQ5CGNOT.js";
108
+ } from "./chunk-YBOU4ZFD.js";
109
+ import {
110
+ createContextStateMessage,
111
+ toClientSession
112
+ } from "./chunk-XAAEP5XM.js";
113
+ import {
114
+ EventEmitter
115
+ } from "./chunk-JURM3RPZ.js";
116
+ import {
117
+ ALWAYS_ALLOWED,
118
+ ALWAYS_ALLOWED_FOR_SUBAGENTS,
119
+ TOP_LEVEL_ONLY_TOOLS
120
+ } from "./chunk-Y7FGHKBW.js";
110
121
  import {
111
122
  emitAssistantMessageStart,
112
123
  emitContextState,
@@ -123,7 +134,7 @@ import {
123
134
  getEventStore,
124
135
  getSessionState,
125
136
  initEventStore
126
- } from "./chunk-JOCR4CF4.js";
137
+ } from "./chunk-J3IJJ55E.js";
127
138
  import {
128
139
  clearWorkflowExecution,
129
140
  createSession,
@@ -144,30 +155,18 @@ import {
144
155
  updateSessionMessageCount,
145
156
  updateSessionMetadata,
146
157
  updateSessionProvider,
158
+ updateSessionProviderActive,
147
159
  updateSessionRunning,
148
160
  updateSessionWorkdir,
149
161
  updateWorkflowExecutionStatus
150
- } from "./chunk-KLQEL2DZ.js";
151
- import {
152
- createContextStateMessage,
153
- toClientSession
154
- } from "./chunk-XAAEP5XM.js";
162
+ } from "./chunk-SLW3KKPP.js";
155
163
  import {
156
164
  getPathSeparator,
157
165
  isAbsolutePath
158
- } from "./chunk-AESOGRFK.js";
159
- import {
160
- EventEmitter
161
- } from "./chunk-JURM3RPZ.js";
162
- import {
163
- getAgentModelOverride,
164
- getAgentModelOverrides,
165
- resolveLLMClientForAgent,
166
- setAgentModelOverride
167
- } from "./chunk-JLAR2CMV.js";
166
+ } from "./chunk-EZ67GBEO.js";
168
167
  import {
169
168
  VERSION
170
- } from "./chunk-EW25UQG3.js";
169
+ } from "./chunk-OBB3JYMK.js";
171
170
  import {
172
171
  agentExists,
173
172
  deleteAgent,
@@ -184,7 +183,7 @@ import {
184
183
  saveAgent,
185
184
  saveAgentToProject,
186
185
  setRuntimeConfig
187
- } from "./chunk-LNNBLB6G.js";
186
+ } from "./chunk-2N7KFNMY.js";
188
187
  import {
189
188
  findFileByInternalId,
190
189
  pathExists
@@ -193,16 +192,16 @@ import {
193
192
  getProject,
194
193
  getProjectByWorkdir,
195
194
  updateProject
196
- } from "./chunk-3PG65AXG.js";
195
+ } from "./chunk-DIALH34K.js";
197
196
  import {
198
197
  createProviderManager,
199
198
  detectModel,
200
199
  getLlmStatus,
201
200
  parseDefaultModelSelection
202
- } from "./chunk-U6JMRMBW.js";
201
+ } from "./chunk-UJRWYZHM.js";
203
202
  import {
204
203
  getModelProfile
205
- } from "./chunk-W7VIYHPQ.js";
204
+ } from "./chunk-GJL3QSMP.js";
206
205
  import {
207
206
  getBackendDisplayName
208
207
  } from "./chunk-AZHWLLPP.js";
@@ -212,15 +211,15 @@ import {
212
211
  import {
213
212
  SessionNotFoundError,
214
213
  WorkspaceInUseError
215
- } from "./chunk-LTYL6ZGH.js";
214
+ } from "./chunk-POTCPZJF.js";
216
215
  import {
217
216
  deleteSetting,
218
217
  getSetting,
219
218
  setSetting
220
- } from "./chunk-HD6Y77RO.js";
219
+ } from "./chunk-FGVMRFDW.js";
221
220
  import {
222
221
  initDatabase
223
- } from "./chunk-5PT4UMRR.js";
222
+ } from "./chunk-NYQKSKDB.js";
224
223
  import {
225
224
  logger,
226
225
  setLogLevel
@@ -2782,15 +2781,43 @@ var SessionManager = class {
2782
2781
  }
2783
2782
  return resolved.client;
2784
2783
  }
2785
- getCurrentModelSettings(sessionId) {
2784
+ /**
2785
+ * Resolve the effective provider/model for a session.
2786
+ *
2787
+ * Precedence: agent model override > session preference > global default.
2788
+ * The session preference is the user's sticky manual pick (written only by an
2789
+ * explicit pick) — agent overrides and the effective model are never written
2790
+ * into it. The global default comes from config (pure), never from the provider
2791
+ * manager's active state, so a stale override never lingers.
2792
+ *
2793
+ * When `agentId` is omitted, the current session mode's agent override applies.
2794
+ */
2795
+ resolveEffectiveProviderModel(sessionId, agentId) {
2796
+ const dbSession = getSession(sessionId);
2797
+ if (dbSession?.providerManual && dbSession?.providerManualActive && dbSession.providerId && dbSession.providerModel) {
2798
+ return { providerId: dbSession.providerId, model: dbSession.providerModel };
2799
+ }
2800
+ const mode = agentId ?? dbSession?.mode ?? void 0;
2801
+ const override = mode ? getAgentModelOverride(mode) : void 0;
2802
+ if (override) {
2803
+ return { providerId: override.providerId, model: override.model };
2804
+ }
2805
+ if (dbSession?.providerId && dbSession?.providerModel) {
2806
+ return { providerId: dbSession.providerId, model: dbSession.providerModel };
2807
+ }
2808
+ const { providerId, model } = parseDefaultModelSelection(this.providerManager.getDefaultModelSelection());
2809
+ if (providerId && model) {
2810
+ return { providerId, model };
2811
+ }
2812
+ return { providerId: null, model: null };
2813
+ }
2814
+ getCurrentModelSettings(sessionId, agentId) {
2786
2815
  let providerId;
2787
2816
  let model;
2788
2817
  if (sessionId) {
2789
- const session = this.getSession(sessionId);
2790
- if (session?.providerId && session?.providerModel) {
2791
- providerId = session.providerId;
2792
- model = session.providerModel;
2793
- }
2818
+ const effective = this.resolveEffectiveProviderModel(sessionId, agentId);
2819
+ providerId = effective.providerId ?? void 0;
2820
+ model = effective.model ?? void 0;
2794
2821
  }
2795
2822
  if (!providerId || !model) {
2796
2823
  model = this.providerManager.getCurrentModel();
@@ -2799,15 +2826,39 @@ var SessionManager = class {
2799
2826
  if (!model || !providerId) return void 0;
2800
2827
  return this.providerManager.getModelSettings(providerId, model);
2801
2828
  }
2802
- getCurrentModelContext() {
2829
+ getCurrentModelContext(sessionId, agentId) {
2830
+ if (sessionId) {
2831
+ const { providerId, model } = this.resolveEffectiveProviderModel(sessionId, agentId);
2832
+ const sessionContext = this.resolveModelContext(providerId, model);
2833
+ if (sessionContext !== void 0) return sessionContext;
2834
+ }
2803
2835
  return this.providerManager.getCurrentModelContext();
2804
2836
  }
2805
- getModelCompactionThreshold(sessionId) {
2806
- const session = this.getSession(sessionId);
2807
- const providerId = session?.providerId ?? this.providerManager.getActiveProviderId();
2808
- const modelId = session?.providerModel ?? this.providerManager.getCurrentModel();
2809
- if (!providerId || !modelId) return void 0;
2810
- return this.providerManager.getProviders().find((provider) => provider.id === providerId)?.models.find((model) => model.id === modelId)?.compactionThreshold;
2837
+ /**
2838
+ * Resolve the context window for a session's own provider/model, if set.
2839
+ * Exact match first, then fuzzy match (spaces/dashes/underscores variations).
2840
+ * Returns undefined when the session has no model or no matching config —
2841
+ * callers fall back to the global default context.
2842
+ */
2843
+ resolveModelContext(providerId, providerModel) {
2844
+ if (!providerId || !providerModel) return void 0;
2845
+ const provider = this.providerManager.getProviders().find((p) => p.id === providerId);
2846
+ if (!provider) return void 0;
2847
+ let modelConfig = provider.models.find((m) => m.id === providerModel);
2848
+ if (!modelConfig) {
2849
+ const normalize = (s) => s.toLowerCase().replace(/[-_\s]+/g, "");
2850
+ const sessionModelNormalized = normalize(providerModel);
2851
+ modelConfig = provider.models.find((m) => {
2852
+ const modelIdNormalized = normalize(m.id);
2853
+ return modelIdNormalized === sessionModelNormalized || modelIdNormalized.includes(sessionModelNormalized) || sessionModelNormalized.includes(modelIdNormalized);
2854
+ });
2855
+ }
2856
+ return modelConfig?.contextWindow;
2857
+ }
2858
+ getModelCompactionThreshold(sessionId, agentId) {
2859
+ const { providerId, model } = this.resolveEffectiveProviderModel(sessionId, agentId);
2860
+ if (!providerId || !model) return void 0;
2861
+ return this.providerManager.getProviders().find((provider) => provider.id === providerId)?.models.find((modelConfig) => modelConfig.id === model)?.compactionThreshold;
2811
2862
  }
2812
2863
  /**
2813
2864
  * Get the effective working directory for a session.
@@ -3037,6 +3088,7 @@ var SessionManager = class {
3037
3088
  }
3038
3089
  logger.debug("Changing session mode", { sessionId, from: fromMode, to: toMode });
3039
3090
  emitModeChanged(sessionId, toMode, false);
3091
+ this.setSessionProviderActive(sessionId, !getAgentModelOverride(toMode));
3040
3092
  const updatedSession = this.requireSession(sessionId);
3041
3093
  this.emit({ type: "mode_changed", sessionId, from: fromMode, to: toMode });
3042
3094
  this.emit({ type: "session_updated", session: updatedSession });
@@ -3106,13 +3158,24 @@ var SessionManager = class {
3106
3158
  /**
3107
3159
  * Set session provider/model. Updates DB directly.
3108
3160
  */
3109
- setSessionProvider(sessionId, providerId, providerModel) {
3161
+ setSessionProvider(sessionId, providerId, providerModel, providerManual) {
3110
3162
  logger.debug("Setting session provider", { sessionId, providerId, providerModel });
3111
- updateSessionProvider(sessionId, providerId, providerModel);
3163
+ updateSessionProvider(sessionId, providerId, providerModel, providerManual);
3112
3164
  const updatedSession = this.requireSession(sessionId);
3113
3165
  this.emit({ type: "session_updated", session: updatedSession });
3114
3166
  return updatedSession;
3115
3167
  }
3168
+ /**
3169
+ * Toggle whether the manual pick is currently active (does NOT emit — used as
3170
+ * part of larger operations such as mode switches, which emit their own event).
3171
+ * Selecting an agent with a model override deactivates the manual pick so the
3172
+ * agent's override (its label) wins; a fresh pick or a non-override agent
3173
+ * reactivates it.
3174
+ */
3175
+ setSessionProviderActive(sessionId, active) {
3176
+ logger.debug("Setting session provider manual-active", { sessionId, active });
3177
+ updateSessionProviderActive(sessionId, active);
3178
+ }
3116
3179
  // ============================================================================
3117
3180
  // Workflow Execution
3118
3181
  // ============================================================================
@@ -3447,11 +3510,12 @@ var SessionManager = class {
3447
3510
  * Stores promptTokens + completionTokens so the tracked size reflects the
3448
3511
  * true context occupancy — the last call's output is re-fed into the next
3449
3512
  * request as an assistant message, so it must count toward the budget.
3450
- * maxTokens comes from providerManager.getCurrentModelContext() - the currently selected model's limit.
3513
+ * maxTokens comes from the session model's context window (falling back to
3514
+ * the currently selected model's limit).
3451
3515
  */
3452
3516
  setCurrentContextSize(sessionId, promptTokens, completionTokens = 0, subAgentId) {
3453
- const state = getSessionState(sessionId, this.providerManager.getCurrentModelContext());
3454
- const maxTokens = this.providerManager.getCurrentModelContext();
3517
+ const state = getSessionState(sessionId, this.getCurrentModelContext(sessionId));
3518
+ const maxTokens = this.getCurrentModelContext(sessionId);
3455
3519
  const currentTokens = promptTokens + completionTokens;
3456
3520
  const compactionCount = state?.contextState.compactionCount ?? 0;
3457
3521
  const dynamicContextChanged = this.getDynamicContextChanged(sessionId);
@@ -3725,29 +3789,9 @@ var SessionManager = class {
3725
3789
  * Get the current context state for a session.
3726
3790
  */
3727
3791
  getContextState(sessionId) {
3728
- const session = this.getSession(sessionId);
3729
3792
  const providerManager = this.providerManager;
3730
- let maxTokens;
3731
- if (session?.providerId && session.providerModel) {
3732
- const providers = providerManager.getProviders();
3733
- const provider = providers.find((p) => p.id === session.providerId);
3734
- if (provider) {
3735
- let modelConfig = provider.models.find((m) => m.id === session.providerModel);
3736
- if (!modelConfig && session.providerModel) {
3737
- const normalize = (s) => s.toLowerCase().replace(/[-_\s]+/g, "");
3738
- const sessionModelNormalized = normalize(session.providerModel);
3739
- modelConfig = provider.models.find((m) => {
3740
- const modelIdNormalized = normalize(m.id);
3741
- return modelIdNormalized === sessionModelNormalized || modelIdNormalized.includes(sessionModelNormalized) || sessionModelNormalized.includes(modelIdNormalized);
3742
- });
3743
- }
3744
- maxTokens = modelConfig?.contextWindow ?? providerManager.getCurrentModelContext();
3745
- } else {
3746
- maxTokens = providerManager.getCurrentModelContext();
3747
- }
3748
- } else {
3749
- maxTokens = providerManager.getCurrentModelContext();
3750
- }
3793
+ const { providerId, model } = this.resolveEffectiveProviderModel(sessionId);
3794
+ const maxTokens = providerId && model ? this.resolveModelContext(providerId, model) ?? providerManager.getCurrentModelContext() : providerManager.getCurrentModelContext();
3751
3795
  const state = getSessionState(sessionId, maxTokens);
3752
3796
  const dynamicContextChanged = this.getDynamicContextChanged(sessionId);
3753
3797
  const debugDump = this.debugDumpStore.get(sessionId);
@@ -4016,7 +4060,7 @@ All file and git operations should use this directory.
4016
4060
  * Build a full Session object from DB session + EventStore state
4017
4061
  */
4018
4062
  buildSessionFromDb(dbSession) {
4019
- const maxTokens = this.providerManager.getCurrentModelContext();
4063
+ const maxTokens = this.resolveModelContext(dbSession.providerId, dbSession.providerModel) ?? this.providerManager.getCurrentModelContext();
4020
4064
  const eventState = getSessionState(dbSession.id, maxTokens, dbSession.mode);
4021
4065
  if (!eventState) {
4022
4066
  return {
@@ -5947,7 +5991,7 @@ async function createServerHandle(config3) {
5947
5991
  toolRegistry = createToolRegistry();
5948
5992
  logger.info("MCP tools registered", { count: mcpTools.length });
5949
5993
  }
5950
- const { signalMcpReady } = await import("./server-XZQLWIVD.js");
5994
+ const { signalMcpReady } = await import("./server-EIRLWSBZ.js");
5951
5995
  signalMcpReady();
5952
5996
  });
5953
5997
  const app = express();
@@ -6030,7 +6074,7 @@ async function createServerHandle(config3) {
6030
6074
  res.json({ tools });
6031
6075
  });
6032
6076
  app.get("/api/projects", async (_req, res) => {
6033
- const { listProjects: listProjects2 } = await import("./projects-NDPNOV6D.js");
6077
+ const { listProjects: listProjects2 } = await import("./projects-FHRTSV6N.js");
6034
6078
  const projects = listProjects2();
6035
6079
  res.json({ projects });
6036
6080
  });
@@ -6039,7 +6083,7 @@ async function createServerHandle(config3) {
6039
6083
  if (!name || !workdir) {
6040
6084
  return res.status(400).json({ error: "name and workdir are required" });
6041
6085
  }
6042
- const { createDirectoryWithGit } = await import("./project-creator-PMQ65NKN.js");
6086
+ const { createDirectoryWithGit } = await import("./project-creator-J4ITWDZI.js");
6043
6087
  try {
6044
6088
  const project = await createDirectoryWithGit(name, workdir);
6045
6089
  res.status(201).json({ project });
@@ -6084,7 +6128,7 @@ async function createServerHandle(config3) {
6084
6128
  }
6085
6129
  });
6086
6130
  app.get("/api/projects/:id", async (req, res) => {
6087
- const { getProject: getProject2 } = await import("./projects-NDPNOV6D.js");
6131
+ const { getProject: getProject2 } = await import("./projects-FHRTSV6N.js");
6088
6132
  const project = getProject2(req.params.id);
6089
6133
  if (!project) {
6090
6134
  return res.status(404).json({ error: "Project not found" });
@@ -6092,7 +6136,7 @@ async function createServerHandle(config3) {
6092
6136
  res.json({ project });
6093
6137
  });
6094
6138
  app.get("/api/projects/:id/open-folder", async (req, res) => {
6095
- const { getProject: getProject2 } = await import("./projects-NDPNOV6D.js");
6139
+ const { getProject: getProject2 } = await import("./projects-FHRTSV6N.js");
6096
6140
  const project = getProject2(req.params.id);
6097
6141
  if (!project) {
6098
6142
  return res.status(404).json({ error: "Project not found" });
@@ -6106,7 +6150,7 @@ async function createServerHandle(config3) {
6106
6150
  }
6107
6151
  });
6108
6152
  app.put("/api/projects/:id", async (req, res) => {
6109
- const { updateProject: updateProject2 } = await import("./projects-NDPNOV6D.js");
6153
+ const { updateProject: updateProject2 } = await import("./projects-FHRTSV6N.js");
6110
6154
  const { name, customInstructions, dangerLevel, defaultAgent } = req.body;
6111
6155
  const updates = {};
6112
6156
  if (name !== void 0) updates.name = name;
@@ -6120,7 +6164,7 @@ async function createServerHandle(config3) {
6120
6164
  res.json({ project: updated });
6121
6165
  });
6122
6166
  app.delete("/api/projects/:id", async (req, res) => {
6123
- const { getProject: getProject2, deleteProject } = await import("./projects-NDPNOV6D.js");
6167
+ const { getProject: getProject2, deleteProject } = await import("./projects-FHRTSV6N.js");
6124
6168
  const project = getProject2(req.params.id);
6125
6169
  if (!project) {
6126
6170
  return res.status(404).json({ error: "Project not found" });
@@ -6129,7 +6173,7 @@ async function createServerHandle(config3) {
6129
6173
  res.json({ success: true });
6130
6174
  });
6131
6175
  app.put("/api/projects/:id/star", async (req, res) => {
6132
- const { toggleStar } = await import("./projects-NDPNOV6D.js");
6176
+ const { toggleStar } = await import("./projects-FHRTSV6N.js");
6133
6177
  const { isStarred } = req.body;
6134
6178
  if (typeof isStarred !== "boolean") {
6135
6179
  return res.status(400).json({ error: "isStarred is required and must be a boolean" });
@@ -6143,9 +6187,9 @@ async function createServerHandle(config3) {
6143
6187
  const sessionFavoriteRouter = express.Router();
6144
6188
  registerSessionFavoriteRoute(sessionFavoriteRouter, sessionManager);
6145
6189
  app.use("/api", sessionFavoriteRouter);
6146
- const { createTasksService } = await import("./service-ZKH465DA.js");
6147
- const { registerTaskRoutes } = await import("./tasks-I766NBPW.js");
6148
- const { setTasksService } = await import("./tools-ZJXDZLRH.js");
6190
+ const { createTasksService } = await import("./service-HX5NFX2D.js");
6191
+ const { registerTaskRoutes } = await import("./tasks-A25JQ4TV.js");
6192
+ const { setTasksService } = await import("./tools-YGJXEEBI.js");
6149
6193
  const tasksService = createTasksService({
6150
6194
  sessionManager,
6151
6195
  config: config3,
@@ -6158,26 +6202,26 @@ async function createServerHandle(config3) {
6158
6202
  registerTaskRoutes(tasksRouter, tasksService);
6159
6203
  app.use("/api", tasksRouter);
6160
6204
  app.get("/api/projects/:id/branches", async (req, res) => {
6161
- const { getProject: getProject2 } = await import("./projects-NDPNOV6D.js");
6205
+ const { getProject: getProject2 } = await import("./projects-FHRTSV6N.js");
6162
6206
  const project = getProject2(req.params.id);
6163
6207
  if (!project) return res.status(404).json({ error: "Project not found" });
6164
- const { listBranches } = await import("./workspace-IQLLHMYR.js");
6208
+ const { listBranches } = await import("./workspace-ZNZFEONU.js");
6165
6209
  const branches = await listBranches(project.workdir);
6166
6210
  res.json({ branches });
6167
6211
  });
6168
6212
  app.post("/api/projects/:id/checkout", async (req, res) => {
6169
- const { getProject: getProject2 } = await import("./projects-NDPNOV6D.js");
6213
+ const { getProject: getProject2 } = await import("./projects-FHRTSV6N.js");
6170
6214
  const project = getProject2(req.params.id);
6171
6215
  if (!project) return res.status(404).json({ error: "Project not found" });
6172
6216
  const { branch } = req.body;
6173
6217
  if (!branch || typeof branch !== "string") return res.status(400).json({ error: "branch is required" });
6174
- const { checkoutBranch, isGitRepository } = await import("./workspace-IQLLHMYR.js");
6218
+ const { checkoutBranch, isGitRepository } = await import("./workspace-ZNZFEONU.js");
6175
6219
  if (!await isGitRepository(project.workdir)) {
6176
6220
  return res.status(400).json({ error: "Project is not a git repository" });
6177
6221
  }
6178
6222
  try {
6179
6223
  await checkoutBranch(project.workdir, branch);
6180
- const { updateSessionBranch: updateSessionBranch2 } = await import("./sessions-I7ELDIIP.js");
6224
+ const { updateSessionBranch: updateSessionBranch2 } = await import("./sessions-XFNU4DZ6.js");
6181
6225
  const allSessions = sessionManager.listSessions();
6182
6226
  for (const s of allSessions) {
6183
6227
  if (sessionManager.getEffectiveWorkdir(s.id) === project.workdir) {
@@ -6191,12 +6235,12 @@ async function createServerHandle(config3) {
6191
6235
  }
6192
6236
  });
6193
6237
  app.post("/api/projects/:id/checkout-new", async (req, res) => {
6194
- const { getProject: getProject2 } = await import("./projects-NDPNOV6D.js");
6238
+ const { getProject: getProject2 } = await import("./projects-FHRTSV6N.js");
6195
6239
  const project = getProject2(req.params.id);
6196
6240
  if (!project) return res.status(404).json({ error: "Project not found" });
6197
6241
  const { name, sourceBranch } = req.body;
6198
6242
  if (!name || typeof name !== "string") return res.status(400).json({ error: "name is required" });
6199
- const { createBranch, resolveAndValidateSourceBranch: resolveAndValidateSourceBranch2, validateRef: validateRef2, getDefaultBranch, isGitRepository } = await import("./workspace-IQLLHMYR.js");
6243
+ const { createBranch, resolveAndValidateSourceBranch: resolveAndValidateSourceBranch2, validateRef: validateRef2, getDefaultBranch, isGitRepository } = await import("./workspace-ZNZFEONU.js");
6200
6244
  if (!await isGitRepository(project.workdir)) {
6201
6245
  return res.status(400).json({ error: "Project is not a git repository" });
6202
6246
  }
@@ -6213,7 +6257,7 @@ async function createServerHandle(config3) {
6213
6257
  );
6214
6258
  }
6215
6259
  await createBranch(project.workdir, name, sb);
6216
- const { updateSessionBranch: updateSessionBranch2 } = await import("./sessions-I7ELDIIP.js");
6260
+ const { updateSessionBranch: updateSessionBranch2 } = await import("./sessions-XFNU4DZ6.js");
6217
6261
  const allSessions = sessionManager.listSessions();
6218
6262
  for (const s of allSessions) {
6219
6263
  if (sessionManager.getEffectiveWorkdir(s.id) === project.workdir) {
@@ -6230,7 +6274,7 @@ async function createServerHandle(config3) {
6230
6274
  const session = sessionManager.getSession(req.params.id);
6231
6275
  if (!session) return res.status(404).json({ error: "Session not found" });
6232
6276
  const effectiveWorkdir = sessionManager.getEffectiveWorkdir(req.params.id);
6233
- const { listBranches, getDefaultBranch } = await import("./workspace-IQLLHMYR.js");
6277
+ const { listBranches, getDefaultBranch } = await import("./workspace-ZNZFEONU.js");
6234
6278
  const [branches, defaultBranch] = await Promise.all([
6235
6279
  listBranches(effectiveWorkdir),
6236
6280
  getDefaultBranch(session.workdir)
@@ -6244,8 +6288,8 @@ async function createServerHandle(config3) {
6244
6288
  const { branch } = req.body;
6245
6289
  if (!branch || typeof branch !== "string") return res.status(400).json({ error: "branch is required" });
6246
6290
  const effectiveWorkdir = sessionManager.getEffectiveWorkdir(req.params.id);
6247
- const { checkoutBranch, validateRef: validateRef2 } = await import("./workspace-IQLLHMYR.js");
6248
- const { updateSessionBranch: updateSessionBranch2 } = await import("./sessions-I7ELDIIP.js");
6291
+ const { checkoutBranch, validateRef: validateRef2 } = await import("./workspace-ZNZFEONU.js");
6292
+ const { updateSessionBranch: updateSessionBranch2 } = await import("./sessions-XFNU4DZ6.js");
6249
6293
  try {
6250
6294
  await validateRef2(effectiveWorkdir, branch);
6251
6295
  await checkoutBranch(effectiveWorkdir, branch);
@@ -6287,16 +6331,16 @@ All file and git operations should use this branch.
6287
6331
  const { name, sourceBranch } = req.body;
6288
6332
  if (!name || typeof name !== "string") return res.status(400).json({ error: "name is required" });
6289
6333
  const effectiveWorkdir = sessionManager.getEffectiveWorkdir(req.params.id);
6290
- const { validateRef: validateRef2 } = await import("./workspace-IQLLHMYR.js");
6291
- const { updateSessionBranch: updateSessionBranch2 } = await import("./sessions-I7ELDIIP.js");
6334
+ const { validateRef: validateRef2 } = await import("./workspace-ZNZFEONU.js");
6335
+ const { updateSessionBranch: updateSessionBranch2 } = await import("./sessions-XFNU4DZ6.js");
6292
6336
  try {
6293
6337
  await validateRef2(effectiveWorkdir, name);
6294
6338
  if (sourceBranch) {
6295
- const { resolveAndValidateSourceBranch: resolveAndValidateSourceBranch2, createBranch } = await import("./workspace-IQLLHMYR.js");
6339
+ const { resolveAndValidateSourceBranch: resolveAndValidateSourceBranch2, createBranch } = await import("./workspace-ZNZFEONU.js");
6296
6340
  const sb = await resolveAndValidateSourceBranch2(effectiveWorkdir, sourceBranch, session.workdir);
6297
6341
  await createBranch(effectiveWorkdir, name, sb);
6298
6342
  } else {
6299
- const { createBranch, getDefaultBranch, resolveAndValidateSourceBranch: resolveAndValidateSourceBranch2 } = await import("./workspace-IQLLHMYR.js");
6343
+ const { createBranch, getDefaultBranch, resolveAndValidateSourceBranch: resolveAndValidateSourceBranch2 } = await import("./workspace-ZNZFEONU.js");
6300
6344
  const defaultBranch = await getDefaultBranch(session.workdir);
6301
6345
  const sb = await resolveAndValidateSourceBranch2(effectiveWorkdir, defaultBranch, session.workdir);
6302
6346
  await createBranch(effectiveWorkdir, name, sb);
@@ -6334,17 +6378,17 @@ All file and git operations should use this branch.
6334
6378
  }
6335
6379
  });
6336
6380
  app.get("/api/projects/:id/workspaces", async (req, res) => {
6337
- const { getProject: getProject2 } = await import("./projects-NDPNOV6D.js");
6381
+ const { getProject: getProject2 } = await import("./projects-FHRTSV6N.js");
6338
6382
  const project = getProject2(req.params.id);
6339
6383
  if (!project) return res.status(404).json({ error: "Project not found" });
6340
- const { listWorkspaces } = await import("./workspace-IQLLHMYR.js");
6384
+ const { listWorkspaces } = await import("./workspace-ZNZFEONU.js");
6341
6385
  const all = await listWorkspaces(project.name, project.workdir);
6342
6386
  const workspacesList = all.filter((ws) => ws.path !== project.workdir);
6343
6387
  res.json({ workspaces: workspacesList });
6344
6388
  });
6345
6389
  app.get("/api/sessions", async (req, res) => {
6346
- const { getRecentUserPromptsForSession } = await import("./events-KDFMBVP5.js");
6347
- const { getPendingConfirmationsBySession } = await import("./path-security-L4AJJN2V.js");
6390
+ const { getRecentUserPromptsForSession } = await import("./events-6P4TDTSD.js");
6391
+ const { getPendingConfirmationsBySession } = await import("./path-security-JUF56IB6.js");
6348
6392
  const projectId = req.query["projectId"];
6349
6393
  const rawLimit = req.query["limit"];
6350
6394
  const offset = parseInt(req.query["offset"]) || 0;
@@ -6399,7 +6443,7 @@ All file and git operations should use this branch.
6399
6443
  disabledServers = mcpManager.getAllServers().filter((s) => s.config.disabled).map((s) => s.name);
6400
6444
  }
6401
6445
  if (disabledServers.length > 0) {
6402
- const { setSessionDisabledServers: setSessionDisabledServers2 } = await import("./session-overrides-CWBKPHMF.js");
6446
+ const { setSessionDisabledServers: setSessionDisabledServers2 } = await import("./session-overrides-EOKSZO2X.js");
6403
6447
  setSessionDisabledServers2(session.id, disabledServers);
6404
6448
  }
6405
6449
  } catch {
@@ -6436,7 +6480,7 @@ All file and git operations should use this branch.
6436
6480
  if (!target || typeof target !== "string") return res.status(400).json({ error: "target is required" });
6437
6481
  const project = sessionManager.getProject(session.projectId);
6438
6482
  if (!project) return res.status(404).json({ error: "Project not found" });
6439
- const { isGitRepository } = await import("./workspace-IQLLHMYR.js");
6483
+ const { isGitRepository } = await import("./workspace-ZNZFEONU.js");
6440
6484
  if (!await isGitRepository(project.workdir)) {
6441
6485
  return res.status(400).json({ error: "Project is not a git repository" });
6442
6486
  }
@@ -6454,7 +6498,7 @@ All file and git operations should use this branch.
6454
6498
  if (!target || typeof target !== "string") return res.status(400).json({ error: "target is required" });
6455
6499
  const project = sessionManager.getProject(session.projectId);
6456
6500
  if (!project) return res.status(404).json({ error: "Project not found" });
6457
- const { isGitRepository } = await import("./workspace-IQLLHMYR.js");
6501
+ const { isGitRepository } = await import("./workspace-ZNZFEONU.js");
6458
6502
  if (!await isGitRepository(project.workdir)) {
6459
6503
  return res.status(400).json({ error: "Project is not a git repository" });
6460
6504
  }
@@ -6472,23 +6516,14 @@ All file and git operations should use this branch.
6472
6516
  }
6473
6517
  });
6474
6518
  app.get("/api/sessions/:id", async (req, res) => {
6475
- const { getEventStore: getEventStore2, combineEventsWithSnapshot } = await import("./events-KDFMBVP5.js");
6476
- const { buildMessagesFromStoredEvents, foldPendingConfirmations } = await import("./folding-RTGU63BW.js");
6477
- const { getPendingQuestionsForSession } = await import("./tools-ZJXDZLRH.js");
6478
- const { getMaxVisibleItems } = await import("./settings-FGXQHKUH.js");
6479
- const { getAgentModelOverride: getAgentModelOverride2 } = await import("./model-overrides-7F2EOA4U.js");
6480
- const { updateSessionProvider: updateSessionProvider2 } = await import("./sessions-I7ELDIIP.js");
6481
- let session = sessionManager.getSession(req.params.id);
6519
+ const { getEventStore: getEventStore2, combineEventsWithSnapshot } = await import("./events-6P4TDTSD.js");
6520
+ const { buildMessagesFromStoredEvents, foldPendingConfirmations } = await import("./folding-3LA2WX2B.js");
6521
+ const { getPendingQuestionsForSession } = await import("./tools-YGJXEEBI.js");
6522
+ const { getMaxVisibleItems } = await import("./settings-SYYDPV43.js");
6523
+ const session = sessionManager.getSession(req.params.id);
6482
6524
  if (!session) {
6483
6525
  return res.status(404).json({ error: "Session not found" });
6484
6526
  }
6485
- if (!session.providerId && session.mode) {
6486
- const override = getAgentModelOverride2(session.mode);
6487
- if (override) {
6488
- updateSessionProvider2(session.id, override.providerId, override.model);
6489
- session = sessionManager.getSession(session.id);
6490
- }
6491
- }
6492
6527
  const eventStore = getEventStore2();
6493
6528
  const { snapshot, events: eventsSinceSnapshot } = eventStore.getEventsSinceSnapshot(req.params.id);
6494
6529
  const events = combineEventsWithSnapshot(req.params.id, snapshot, eventsSinceSnapshot);
@@ -6512,9 +6547,9 @@ All file and git operations should use this branch.
6512
6547
  });
6513
6548
  app.get("/api/sessions/:id/status", async (req, res) => {
6514
6549
  const { projectSessionStatus } = await import("./session-status-6Q5B5PEN.js");
6515
- const { getPendingQuestionsForSession } = await import("./tools-ZJXDZLRH.js");
6516
- const { getEventStore: getEventStore2, combineEventsWithSnapshot } = await import("./events-KDFMBVP5.js");
6517
- const { foldPendingConfirmations } = await import("./folding-RTGU63BW.js");
6550
+ const { getPendingQuestionsForSession } = await import("./tools-YGJXEEBI.js");
6551
+ const { getEventStore: getEventStore2, combineEventsWithSnapshot } = await import("./events-6P4TDTSD.js");
6552
+ const { foldPendingConfirmations } = await import("./folding-3LA2WX2B.js");
6518
6553
  const sessionId = req.params["id"];
6519
6554
  if (!sessionId) {
6520
6555
  return res.status(400).json({ error: "Session id is required" });
@@ -6544,8 +6579,8 @@ All file and git operations should use this branch.
6544
6579
  if (!session) {
6545
6580
  return res.status(404).json({ error: "Session not found" });
6546
6581
  }
6547
- const { stopSessionExecution } = await import("./chat-handler-M54IWF5Y.js");
6548
- const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-ZJXDZLRH.js");
6582
+ const { stopSessionExecution } = await import("./chat-handler-A5ORR5BB.js");
6583
+ const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-YGJXEEBI.js");
6549
6584
  sessionManager.clearMessageQueue(sessionId);
6550
6585
  stopSessionExecution(sessionId, sessionManager);
6551
6586
  abortSession(sessionId);
@@ -6574,9 +6609,9 @@ All file and git operations should use this branch.
6574
6609
  res.json({ success: true });
6575
6610
  });
6576
6611
  app.post("/api/sessions/:id/provider", async (req, res) => {
6577
- const { getEventStore: getEventStore2, combineEventsWithSnapshot: combineEv } = await import("./events-KDFMBVP5.js");
6578
- const { buildMessagesFromStoredEvents } = await import("./folding-RTGU63BW.js");
6579
- const { getMaxVisibleItems } = await import("./settings-FGXQHKUH.js");
6612
+ const { getEventStore: getEventStore2, combineEventsWithSnapshot: combineEv } = await import("./events-6P4TDTSD.js");
6613
+ const { buildMessagesFromStoredEvents } = await import("./folding-3LA2WX2B.js");
6614
+ const { getMaxVisibleItems } = await import("./settings-SYYDPV43.js");
6580
6615
  const sessionId = req.params.id;
6581
6616
  const session = sessionManager.getSession(sessionId);
6582
6617
  if (!session) {
@@ -6588,7 +6623,8 @@ All file and git operations should use this branch.
6588
6623
  }
6589
6624
  const provider = providerManager.getProviders().find((p) => p.id === providerId);
6590
6625
  const resolvedModel = model ?? provider?.models?.[0]?.id ?? "auto";
6591
- sessionManager.setSessionProvider(sessionId, providerId, resolvedModel);
6626
+ sessionManager.setSessionProvider(sessionId, providerId, resolvedModel, true);
6627
+ sessionManager.setSessionProviderActive(sessionId, true);
6592
6628
  const contextState = sessionManager.getContextState(sessionId);
6593
6629
  const eventStore = getEventStore2();
6594
6630
  const { snapshot, events: eventsSinceSnapshot } = eventStore.getEventsSinceSnapshot(sessionId);
@@ -6598,6 +6634,25 @@ All file and git operations should use this branch.
6598
6634
  const updatedSession = sessionManager.getSession(sessionId);
6599
6635
  res.json({ session: toClientSession(updatedSession), messages, hiddenCount, contextState });
6600
6636
  });
6637
+ app.delete("/api/sessions/:id/provider", async (req, res) => {
6638
+ const { getEventStore: getEventStore2, combineEventsWithSnapshot: combineEv } = await import("./events-6P4TDTSD.js");
6639
+ const { buildMessagesFromStoredEvents } = await import("./folding-3LA2WX2B.js");
6640
+ const { getMaxVisibleItems } = await import("./settings-SYYDPV43.js");
6641
+ const sessionId = req.params.id;
6642
+ const session = sessionManager.getSession(sessionId);
6643
+ if (!session) {
6644
+ return res.status(404).json({ error: "Session not found" });
6645
+ }
6646
+ sessionManager.setSessionProvider(sessionId, null, null, false);
6647
+ sessionManager.setSessionProviderActive(sessionId, true);
6648
+ const eventStore = getEventStore2();
6649
+ const { snapshot, events: eventsSinceSnapshot } = eventStore.getEventsSinceSnapshot(sessionId);
6650
+ const events = combineEv(sessionId, snapshot, eventsSinceSnapshot);
6651
+ const maxVisibleItems = getMaxVisibleItems();
6652
+ const { messages, hiddenCount } = buildMessagesFromStoredEvents(events, maxVisibleItems || void 0);
6653
+ const updatedSession = sessionManager.getSession(sessionId);
6654
+ res.json({ session: toClientSession(updatedSession), messages, hiddenCount });
6655
+ });
6601
6656
  app.post("/api/default-model", async (req, res) => {
6602
6657
  const { providerId, model } = req.body;
6603
6658
  if (!providerId || !model) {
@@ -6689,11 +6744,9 @@ All file and git operations should use this branch.
6689
6744
  res.json({ success: true });
6690
6745
  });
6691
6746
  app.put("/api/sessions/:id/mode", async (req, res) => {
6692
- const { getEventStore: getEventStore2, combineEventsWithSnapshot: combineEv } = await import("./events-KDFMBVP5.js");
6693
- const { buildMessagesFromStoredEvents } = await import("./folding-RTGU63BW.js");
6694
- const { getMaxVisibleItems } = await import("./settings-FGXQHKUH.js");
6695
- const { getAgentModelOverride: getAgentModelOverride2 } = await import("./model-overrides-7F2EOA4U.js");
6696
- const { updateSessionProvider: updateSessionProvider2 } = await import("./sessions-I7ELDIIP.js");
6747
+ const { getEventStore: getEventStore2, combineEventsWithSnapshot: combineEv } = await import("./events-6P4TDTSD.js");
6748
+ const { buildMessagesFromStoredEvents } = await import("./folding-3LA2WX2B.js");
6749
+ const { getMaxVisibleItems } = await import("./settings-SYYDPV43.js");
6697
6750
  const sessionId = req.params.id;
6698
6751
  const session = sessionManager.getSession(sessionId);
6699
6752
  if (!session) {
@@ -6709,22 +6762,6 @@ All file and git operations should use this branch.
6709
6762
  return res.status(400).json({ error: `Invalid mode. Must be one of: ${topLevelIds.join(", ")}` });
6710
6763
  }
6711
6764
  sessionManager.setMode(sessionId, mode);
6712
- const override = getAgentModelOverride2(mode);
6713
- if (override) {
6714
- updateSessionProvider2(sessionId, override.providerId, override.model);
6715
- } else {
6716
- updateSessionProvider2(sessionId, null, null);
6717
- const { providerId: defaultProviderId, model: defaultModel } = parseDefaultModelSelection(
6718
- config3.defaultModelSelection
6719
- );
6720
- if (defaultProviderId && defaultModel) {
6721
- const currentActiveProviderId = providerManager.getActiveProviderId();
6722
- const currentModel = providerManager.getCurrentModel();
6723
- if (currentActiveProviderId !== defaultProviderId || currentModel !== defaultModel) {
6724
- await providerManager.activateProvider(defaultProviderId, { model: defaultModel });
6725
- }
6726
- }
6727
- }
6728
6765
  const eventStore = getEventStore2();
6729
6766
  const { snapshot, events: eventsSinceSnapshot } = eventStore.getEventsSinceSnapshot(sessionId);
6730
6767
  const events = combineEv(sessionId, snapshot, eventsSinceSnapshot);
@@ -6795,7 +6832,7 @@ All file and git operations should use this branch.
6795
6832
  if (alwaysAllow !== void 0 && typeof alwaysAllow !== "boolean") {
6796
6833
  return res.status(400).json({ error: "alwaysAllow must be a boolean if provided" });
6797
6834
  }
6798
- const { providePathConfirmation, getConfirmationSessionId } = await import("./tools-ZJXDZLRH.js");
6835
+ const { providePathConfirmation, getConfirmationSessionId } = await import("./tools-YGJXEEBI.js");
6799
6836
  const pendingSessionId = getConfirmationSessionId(callId);
6800
6837
  if (!pendingSessionId) {
6801
6838
  return res.status(404).json({ error: "No pending path confirmation with that ID" });
@@ -6807,11 +6844,11 @@ All file and git operations should use this branch.
6807
6844
  if (!result.found) {
6808
6845
  return res.status(404).json({ error: "No pending path confirmation with that ID" });
6809
6846
  }
6810
- const { getEventStore: getEventStore2, combineEventsWithSnapshot: combineEvents } = await import("./events-KDFMBVP5.js");
6811
- const { buildMessagesFromStoredEvents, foldPendingConfirmations } = await import("./folding-RTGU63BW.js");
6847
+ const { getEventStore: getEventStore2, combineEventsWithSnapshot: combineEvents } = await import("./events-6P4TDTSD.js");
6848
+ const { buildMessagesFromStoredEvents, foldPendingConfirmations } = await import("./folding-3LA2WX2B.js");
6812
6849
  const { createSessionStateMessage } = await import("./protocol-TLODRZSB.js");
6813
- const { getPendingQuestionsForSession } = await import("./tools-ZJXDZLRH.js");
6814
- const { getMaxVisibleItems } = await import("./settings-FGXQHKUH.js");
6850
+ const { getPendingQuestionsForSession } = await import("./tools-YGJXEEBI.js");
6851
+ const { getMaxVisibleItems } = await import("./settings-SYYDPV43.js");
6815
6852
  const eventStore = getEventStore2();
6816
6853
  const { snapshot, events: eventsSinceSnapshot } = eventStore.getEventsSinceSnapshot(sessionId);
6817
6854
  const events = combineEvents(sessionId, snapshot, eventsSinceSnapshot);
@@ -6848,7 +6885,7 @@ All file and git operations should use this branch.
6848
6885
  if (!skip && typeof answer !== "string") {
6849
6886
  return res.status(400).json({ error: "answer is required when not skipping" });
6850
6887
  }
6851
- const { provideAnswer } = await import("./tools-ZJXDZLRH.js");
6888
+ const { provideAnswer } = await import("./tools-YGJXEEBI.js");
6852
6889
  const found = provideAnswer(callId, answer ?? "", skip ?? false);
6853
6890
  if (!found) {
6854
6891
  return res.status(404).json({ error: "No pending question with that ID" });
@@ -6881,7 +6918,7 @@ All file and git operations should use this branch.
6881
6918
  if (!session) {
6882
6919
  return res.status(404).json({ error: "Session not found" });
6883
6920
  }
6884
- const { getSetting: getSetting2, SETTINGS_KEYS } = await import("./settings-FGXQHKUH.js");
6921
+ const { getSetting: getSetting2, SETTINGS_KEYS } = await import("./settings-SYYDPV43.js");
6885
6922
  if (getSetting2(SETTINGS_KEYS.CACHE_WARMING) !== "true") {
6886
6923
  return res.json({ success: false, reason: "disabled" });
6887
6924
  }
@@ -6891,15 +6928,16 @@ All file and git operations should use this branch.
6891
6928
  if (sessionManager.isWarmedUp(sessionId)) {
6892
6929
  return res.json({ success: false, reason: "already_warmed" });
6893
6930
  }
6894
- if (session.providerId && session.providerModel) {
6931
+ const effective = sessionManager.resolveEffectiveProviderModel(sessionId);
6932
+ if (effective.providerId && effective.model) {
6895
6933
  const currentActiveProviderId = providerManager.getActiveProviderId();
6896
6934
  const currentModel = providerManager.getCurrentModel();
6897
- if (currentActiveProviderId !== session.providerId || currentModel !== session.providerModel) {
6898
- const result = await providerManager.activateProvider(session.providerId, { model: session.providerModel });
6935
+ if (currentActiveProviderId !== effective.providerId || currentModel !== effective.model) {
6936
+ const result = await providerManager.activateProvider(effective.providerId, { model: effective.model });
6899
6937
  if (!result.success) {
6900
6938
  logger.error("Failed to activate session provider for warmup", {
6901
6939
  sessionId,
6902
- providerId: session.providerId,
6940
+ providerId: effective.providerId,
6903
6941
  error: result.error
6904
6942
  });
6905
6943
  }
@@ -6913,7 +6951,7 @@ All file and git operations should use this branch.
6913
6951
  backend: activeProvider?.backend ?? llmClient.getBackend(),
6914
6952
  model: llmClient.getModel()
6915
6953
  };
6916
- const { runAgentTurn, TurnMetrics } = await import("./orchestrator-MNON5G7R.js");
6954
+ const { runAgentTurn, TurnMetrics } = await import("./orchestrator-SM3IHZFP.js");
6917
6955
  runAgentTurn(
6918
6956
  {
6919
6957
  sessionManager,
@@ -6951,15 +6989,15 @@ All file and git operations should use this branch.
6951
6989
  if (!session) {
6952
6990
  return res.status(404).json({ error: "Session not found" });
6953
6991
  }
6954
- const { stopSessionExecution } = await import("./chat-handler-M54IWF5Y.js");
6955
- const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-ZJXDZLRH.js");
6992
+ const { stopSessionExecution } = await import("./chat-handler-A5ORR5BB.js");
6993
+ const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-YGJXEEBI.js");
6956
6994
  const queuedMessages = sessionManager.getQueueState(sessionId);
6957
6995
  sessionManager.clearMessageQueue(sessionId);
6958
6996
  stopSessionExecution(sessionId, sessionManager);
6959
6997
  abortSession(sessionId);
6960
6998
  cancelQuestionsForSession(sessionId, "Session stopped by user");
6961
6999
  cancelPathConfirmationsForSession(sessionId, "Session stopped by user");
6962
- const eventStore = (await import("./events-KDFMBVP5.js")).getEventStore();
7000
+ const eventStore = (await import("./events-6P4TDTSD.js")).getEventStore();
6963
7001
  eventStore.append(sessionId, { type: "running.changed", data: { isRunning: false } });
6964
7002
  res.json({ success: true, queuedMessages });
6965
7003
  });
@@ -6973,7 +7011,7 @@ All file and git operations should use this branch.
6973
7011
  if (typeof messageIndex !== "number" || messageIndex < 0) {
6974
7012
  return res.status(400).json({ error: "messageIndex must be a non-negative number" });
6975
7013
  }
6976
- const { truncateSessionMessages } = await import("./events-KDFMBVP5.js");
7014
+ const { truncateSessionMessages } = await import("./events-6P4TDTSD.js");
6977
7015
  truncateSessionMessages(sessionId, messageIndex);
6978
7016
  res.json({ success: true });
6979
7017
  });
@@ -6993,8 +7031,8 @@ All file and git operations should use this branch.
6993
7031
  if (attachments !== void 0 && !Array.isArray(attachments)) {
6994
7032
  return res.status(400).json({ error: "attachments must be an array if provided" });
6995
7033
  }
6996
- const { getEventStore: getEventStore2 } = await import("./events-KDFMBVP5.js");
6997
- const { buildMessagesFromStoredEvents } = await import("./folding-RTGU63BW.js");
7034
+ const { getEventStore: getEventStore2 } = await import("./events-6P4TDTSD.js");
7035
+ const { buildMessagesFromStoredEvents } = await import("./folding-3LA2WX2B.js");
6998
7036
  const eventStore = getEventStore2();
6999
7037
  const events = eventStore.getEvents(sessionId);
7000
7038
  const { messages } = buildMessagesFromStoredEvents(events);
@@ -7006,7 +7044,7 @@ All file and git operations should use this branch.
7006
7044
  if (msg.role !== "user" || msg.isSystemGenerated) {
7007
7045
  return res.status(400).json({ error: "Can only replay user messages" });
7008
7046
  }
7009
- const { truncateSessionMessages } = await import("./events-KDFMBVP5.js");
7047
+ const { truncateSessionMessages } = await import("./events-6P4TDTSD.js");
7010
7048
  truncateSessionMessages(sessionId, msgIndex - 1);
7011
7049
  sessionManager.queueMessage(
7012
7050
  sessionId,
@@ -7068,7 +7106,7 @@ All file and git operations should use this branch.
7068
7106
  res.json({ accepted: true });
7069
7107
  });
7070
7108
  app.get("/api/settings", async (req, res) => {
7071
- const { getSetting: getSetting2, SETTINGS_DEFAULTS } = await import("./settings-FGXQHKUH.js");
7109
+ const { getSetting: getSetting2, SETTINGS_DEFAULTS } = await import("./settings-SYYDPV43.js");
7072
7110
  const keysParam = req.query["keys"];
7073
7111
  if (!keysParam) {
7074
7112
  return res.status(400).json({ error: "keys query parameter is required" });
@@ -7081,19 +7119,19 @@ All file and git operations should use this branch.
7081
7119
  res.json(result);
7082
7120
  });
7083
7121
  app.get("/api/settings/:key", async (req, res) => {
7084
- const { getSetting: getSetting2, SETTINGS_DEFAULTS } = await import("./settings-FGXQHKUH.js");
7122
+ const { getSetting: getSetting2, SETTINGS_DEFAULTS } = await import("./settings-SYYDPV43.js");
7085
7123
  const key = req.params.key;
7086
7124
  const value = getSetting2(key) ?? SETTINGS_DEFAULTS[key] ?? null;
7087
7125
  res.json({ key, value });
7088
7126
  });
7089
7127
  app.get("/api/settings/:key", async (req, res) => {
7090
- const { getSetting: getSetting2, SETTINGS_DEFAULTS } = await import("./settings-FGXQHKUH.js");
7128
+ const { getSetting: getSetting2, SETTINGS_DEFAULTS } = await import("./settings-SYYDPV43.js");
7091
7129
  const key = req.params.key;
7092
7130
  const value = getSetting2(key) ?? SETTINGS_DEFAULTS[key] ?? null;
7093
7131
  res.json({ key, value });
7094
7132
  });
7095
7133
  app.put("/api/settings/:key", async (req, res) => {
7096
- const { setSetting: setSetting2 } = await import("./settings-FGXQHKUH.js");
7134
+ const { setSetting: setSetting2 } = await import("./settings-SYYDPV43.js");
7097
7135
  const key = req.params.key;
7098
7136
  const { value } = req.body;
7099
7137
  if (value === void 0) {
@@ -7120,7 +7158,7 @@ All file and git operations should use this branch.
7120
7158
  }
7121
7159
  });
7122
7160
  app.get("/api/tools/shells", async (_req, res) => {
7123
- const { listAvailableShells } = await import("./platform-ECDDYMAR.js");
7161
+ const { listAvailableShells } = await import("./platform-FM57ZJHA.js");
7124
7162
  res.json({ shells: listAvailableShells() });
7125
7163
  });
7126
7164
  app.get("/api/config", async (_req, res) => {
@@ -7211,7 +7249,7 @@ All file and git operations should use this branch.
7211
7249
  }));
7212
7250
  }
7213
7251
  app.post("/api/proxy/test", async (_req, res) => {
7214
- const { getSetting: getSetting2, SETTINGS_KEYS } = await import("./settings-FGXQHKUH.js");
7252
+ const { getSetting: getSetting2, SETTINGS_KEYS } = await import("./settings-SYYDPV43.js");
7215
7253
  const proxyUrl = getSetting2(SETTINGS_KEYS.PROXY_URL);
7216
7254
  if (!proxyUrl) {
7217
7255
  return res.status(400).json({ success: false, error: "No proxy URL configured" });
@@ -7303,7 +7341,7 @@ All file and git operations should use this branch.
7303
7341
  }
7304
7342
  });
7305
7343
  app.post("/api/proxy/test", async (_req, res) => {
7306
- const { getSetting: getSetting2, SETTINGS_KEYS } = await import("./settings-FGXQHKUH.js");
7344
+ const { getSetting: getSetting2, SETTINGS_KEYS } = await import("./settings-SYYDPV43.js");
7307
7345
  const proxyUrl = getSetting2(SETTINGS_KEYS.PROXY_URL);
7308
7346
  if (!proxyUrl) {
7309
7347
  return res.status(400).json({ success: false, error: "No proxy URL configured" });
@@ -7330,8 +7368,8 @@ All file and git operations should use this branch.
7330
7368
  const backend = req.query["backend"];
7331
7369
  if (!url) return res.status(400).json({ error: "url is required" });
7332
7370
  try {
7333
- const { fetchModelsWithContext } = await import("./provider-manager-FJIPQJMX.js");
7334
- const { getModelProfile: getModelProfile2 } = await import("./profiles-GYHXBWPV.js");
7371
+ const { fetchModelsWithContext } = await import("./provider-manager-EDJN6ARI.js");
7372
+ const { getModelProfile: getModelProfile2 } = await import("./profiles-3YLLEJ2B.js");
7335
7373
  const models = await fetchModelsWithContext(
7336
7374
  url,
7337
7375
  apiKey,
@@ -7398,10 +7436,10 @@ All file and git operations should use this branch.
7398
7436
  });
7399
7437
  return res.json({ success: true, message: { content: response2.content }, raw: response2 });
7400
7438
  }
7401
- const { getModelProfile: getModelProfile2 } = await import("./profiles-GYHXBWPV.js");
7439
+ const { getModelProfile: getModelProfile2 } = await import("./profiles-3YLLEJ2B.js");
7402
7440
  const { getBackendCapabilities } = await import("./backend-67OLCS5O.js");
7403
7441
  const { buildNonStreamingCreateParams } = await import("./client-pure-QSY7TJGK.js");
7404
- const { OpenAIHttpClient } = await import("./http-client-IPUW2MSW.js");
7442
+ const { OpenAIHttpClient } = await import("./http-client-IKOARXI7.js");
7405
7443
  const { ensureVersionPrefix } = await import("./url-utils-C5BM7NF7.js");
7406
7444
  const profile = getModelProfile2(model);
7407
7445
  const capabilities = getBackendCapabilities(backend || "unknown");
@@ -7754,7 +7792,7 @@ All file and git operations should use this branch.
7754
7792
  });
7755
7793
  async function rebuildMcpTools() {
7756
7794
  const { createMcpTools: createMcpTools2 } = await import("./tool-adapter-FJAFLDZA.js");
7757
- const { setMcpTools: setMcpTools2 } = await import("./tools-ZJXDZLRH.js");
7795
+ const { setMcpTools: setMcpTools2 } = await import("./tools-YGJXEEBI.js");
7758
7796
  const mcpTools = createMcpTools2(mcpManager);
7759
7797
  setMcpTools2(mcpTools);
7760
7798
  toolRegistry = createToolRegistry();
@@ -8135,7 +8173,7 @@ All file and git operations should use this branch.
8135
8173
  res.status(400).json({ error: error instanceof Error ? error.message : String(error) });
8136
8174
  }
8137
8175
  });
8138
- const { listProjects } = await import("./projects-NDPNOV6D.js");
8176
+ const { listProjects } = await import("./projects-FHRTSV6N.js");
8139
8177
  const allProjects = listProjects();
8140
8178
  const projectDir = allProjects.find(
8141
8179
  (p) => p.workdir === config3.workdir || config3.workdir && p.workdir.startsWith(config3.workdir + "/")
@@ -8162,13 +8200,13 @@ All file and git operations should use this branch.
8162
8200
  })
8163
8201
  );
8164
8202
  app.get("/api/sessions/:id/background-processes", async (req, res) => {
8165
- const { getSessionProcesses } = await import("./manager-EMLSLMMT.js");
8203
+ const { getSessionProcesses } = await import("./manager-NFKTUR64.js");
8166
8204
  const sessionId = req.params.id;
8167
8205
  const processes = getSessionProcesses(sessionId);
8168
8206
  res.json({ processes });
8169
8207
  });
8170
8208
  app.post("/api/sessions/:id/background-process/:processId/stop", async (req, res) => {
8171
- const { stopProcess } = await import("./manager-EMLSLMMT.js");
8209
+ const { stopProcess } = await import("./manager-NFKTUR64.js");
8172
8210
  const sessionId = req.params.id;
8173
8211
  const processId = req.params.processId;
8174
8212
  const session = sessionManager.getSession(sessionId);
@@ -8308,13 +8346,13 @@ All file and git operations should use this branch.
8308
8346
  );
8309
8347
  const wss = wssExports.wss;
8310
8348
  deferTasksBroadcast = (projectId, payload) => wssExports.broadcastForProject(projectId, "", { type: "tasks.update", payload });
8311
- const { launchWorkflowRun, abortRunnerRun } = await import("./launch-I5XBYRSJ.js");
8349
+ const { launchWorkflowRun, abortRunnerRun } = await import("./launch-YWXQQWZN.js");
8312
8350
  deferTasksLaunchWorkflow = (sessionId, launch) => {
8313
- const session = sessionManager.getSession(sessionId);
8351
+ const effective = sessionManager.resolveEffectiveProviderModel(sessionId);
8314
8352
  let llmClient = getLLMClient();
8315
- if (session?.providerId && session.providerModel) {
8316
- const resolvedModel = providerManager.resolveModel(session.providerId, session.providerModel);
8317
- llmClient = getLLMClientForProvider(session.providerId, resolvedModel ?? session.providerModel) ?? getLLMClient();
8353
+ if (effective.providerId && effective.model) {
8354
+ const resolvedModel = providerManager.resolveModel(effective.providerId, effective.model);
8355
+ llmClient = getLLMClientForProvider(effective.providerId, resolvedModel ?? effective.model) ?? getLLMClient();
8318
8356
  }
8319
8357
  const provider = providerManager.getActiveProvider();
8320
8358
  const controller = new AbortController();
@@ -8346,7 +8384,7 @@ All file and git operations should use this branch.
8346
8384
  const state = sessionManager.getContextState(sessionId);
8347
8385
  wssExports.broadcastForSession(sessionId, createContextStateMessage(state));
8348
8386
  });
8349
- const { QueueProcessor } = await import("./processor-OZSK7RUD.js");
8387
+ const { QueueProcessor } = await import("./processor-EUJRA5GW.js");
8350
8388
  const queueProcessor = new QueueProcessor({
8351
8389
  sessionManager,
8352
8390
  providerManager,
@@ -8390,7 +8428,7 @@ All file and git operations should use this branch.
8390
8428
  void (async () => {
8391
8429
  await devServerManager.stopAll();
8392
8430
  await mcpManager.disconnectAll();
8393
- const { stopAllInspectProxies } = await import("./inspect-proxy-WPEDMCG7.js");
8431
+ const { stopAllInspectProxies } = await import("./inspect-proxy-IDLUAQH5.js");
8394
8432
  stopAllInspectProxies();
8395
8433
  const { cleanupAllProcesses } = await import("./store-JYPZ2RXB.js");
8396
8434
  cleanupAllProcesses();
@@ -8432,4 +8470,4 @@ export {
8432
8470
  createServerHandle,
8433
8471
  createServer
8434
8472
  };
8435
- //# sourceMappingURL=chunk-XZ2WAI66.js.map
8473
+ //# sourceMappingURL=chunk-KD7JTG42.js.map