openfox 2.0.129 → 2.0.130

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 (101) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +2 -0
  3. package/dist/CHANGELOG.md +32 -0
  4. package/dist/auth-D3WLIBTG.js +19 -0
  5. package/dist/{auto-config-454YE6KC.js → auto-config-5VSNLVNI.js} +6 -5
  6. package/dist/{backend-4YPEC3J2.js → backend-NDBY3DAQ.js} +4 -2
  7. package/dist/{chat-handler-TH6JBO6G.js → chat-handler-4WCKNCQV.js} +32 -32
  8. package/dist/chunk-25DAVVTP.js +395 -0
  9. package/dist/{chunk-ISE55FOR.js → chunk-2AI7VYPN.js} +11 -1
  10. package/dist/{chunk-2COZT3YI.js → chunk-2OMXXCJJ.js} +24 -24
  11. package/dist/{chunk-OHTBWA7L.js → chunk-35GQEIH2.js} +13 -13
  12. package/dist/{chunk-N2Q3KYWM.js → chunk-3DZSHRXE.js} +7 -2
  13. package/dist/chunk-3OBZ55SX.js +7 -0
  14. package/dist/{chunk-ZIL6VKLU.js → chunk-64N4CZFT.js} +2 -2
  15. package/dist/{chunk-66MG44TF.js → chunk-6QZVAOSA.js} +2 -2
  16. package/dist/{chunk-6LX43YRA.js → chunk-7ET46SNE.js} +4 -4
  17. package/dist/{chunk-YJD5A375.js → chunk-AYCB32NI.js} +5 -5
  18. package/dist/{chunk-GIJUWPRQ.js → chunk-CGCEAKG5.js} +2 -2
  19. package/dist/{auth-GTGIGX5X.js → chunk-CQGJ5RWB.js} +4 -4
  20. package/dist/{chunk-JQMQ4DGC.js → chunk-CYQUM42E.js} +76 -32
  21. package/dist/{chunk-P6GTPKE5.js → chunk-DHDIKVRT.js} +278 -16
  22. package/dist/{chunk-ZXWJ6JTL.js → chunk-DI5GTIAU.js} +1154 -196
  23. package/dist/chunk-DQTN4B33.js +235 -0
  24. package/dist/{chunk-RV5G7QQU.js → chunk-DQTXXHD2.js} +3 -3
  25. package/dist/{chunk-MYNNMV75.js → chunk-DYIDDGMN.js} +54 -36
  26. package/dist/{chunk-DABWCAXS.js → chunk-EUOWCVU6.js} +19 -6
  27. package/dist/{chunk-7RIEI2TE.js → chunk-EVVWDRM5.js} +45 -16
  28. package/dist/{chunk-ATWOXI52.js → chunk-HCYSGLY2.js} +1 -1
  29. package/dist/{chunk-KBESUA3W.js → chunk-JHA2SPCU.js} +2 -2
  30. package/dist/{chunk-ZIYETXOW.js → chunk-JKRMMNUR.js} +4 -4
  31. package/dist/{chunk-H6YIVK67.js → chunk-JSONBGSY.js} +24 -4
  32. package/dist/{chunk-HO7A7TMF.js → chunk-KHKRHGA6.js} +15 -5
  33. package/dist/{chunk-K2QKX4ZJ.js → chunk-OA2FURC3.js} +8 -2
  34. package/dist/{chunk-ZFNBATE3.js → chunk-OXMOKQPW.js} +3 -2
  35. package/dist/{chunk-567L5OJ6.js → chunk-P57IBMK4.js} +2 -2
  36. package/dist/{session-status-6Q5B5PEN.js → chunk-T3S5MTMD.js} +2 -3
  37. package/dist/{chunk-7ZMOP5LS.js → chunk-TS5WKTFB.js} +18 -1
  38. package/dist/{chunk-PBFGJFGC.js → chunk-UV6IH6HK.js} +32 -10
  39. package/dist/{chunk-26WS7AH6.js → chunk-VJNA5AOB.js} +39 -7
  40. package/dist/{chunk-IJFKJ5D6.js → chunk-VUIXQ6X4.js} +4 -4
  41. package/dist/{chunk-L24A6GZ7.js → chunk-X24XN2M2.js} +84 -56
  42. package/dist/{chunk-AQBRI7TM.js → chunk-X3FHIDLT.js} +2 -2
  43. package/dist/chunk-YNMP647F.js +24 -0
  44. package/dist/{chunk-7YP4O4XE.js → chunk-ZRCRGPGT.js} +2 -2
  45. package/dist/cli/dev.js +1 -1
  46. package/dist/cli/index.js +1 -1
  47. package/dist/client-26RSMUAX.js +16 -0
  48. package/dist/{client-pure-GU2SV3DD.js → client-pure-FLKP6PTI.js} +2 -2
  49. package/dist/{compactor-WKFNTUXL.js → compactor-HYBSSFKP.js} +14 -14
  50. package/dist/dynamic-context-2VLACYK4.js +50 -0
  51. package/dist/{events-GMHRX4LF.js → events-D33QXGSX.js} +7 -7
  52. package/dist/{folding-7K2GRPF4.js → folding-QOKBKUU6.js} +5 -5
  53. package/dist/{http-client-ROVNSHF6.js → http-client-MGAJTGPR.js} +3 -3
  54. package/dist/launch-KFENN5GS.js +53 -0
  55. package/dist/{manager-NOKJQTTF.js → manager-VRHX7BVI.js} +4 -4
  56. package/dist/mcp-YU7AM3UV.js +120 -0
  57. package/dist/{model-catalog-ZLOWTQA7.js → model-catalog-2PCKTYGW.js} +2 -2
  58. package/dist/{oauth-provider-DGBC2YM6.js → oauth-provider-VHUS2KEG.js} +8 -2
  59. package/dist/{orchestrator-E6GIZGEN.js → orchestrator-PLTAEOMR.js} +30 -30
  60. package/dist/package.json +1 -1
  61. package/dist/{path-security-UDZ7UVWK.js → path-security-4WQJGU3Z.js} +11 -11
  62. package/dist/{platform-EMKWQTZX.js → platform-MWWJ6OKV.js} +3 -3
  63. package/dist/plugins-registry.json +12 -0
  64. package/dist/{processor-7RDR675X.js → processor-K4WHZKE6.js} +31 -31
  65. package/dist/{profiles-HXGJIPF2.js → profiles-EBCVFYG7.js} +2 -2
  66. package/dist/{protocol-DMneA8mx.d.ts → protocol-BMUoqwYH.d.ts} +2 -1
  67. package/dist/{protocol-TS3GVTT3.js → protocol-Y7MRKRUO.js} +3 -3
  68. package/dist/provider/index.d.ts +4 -4
  69. package/dist/{provider-DXEICEIE.js → provider-CVM33XHW.js} +10 -10
  70. package/dist/{provider-manager-PU7RS2TK.js → provider-manager-7NL5EQLG.js} +10 -10
  71. package/dist/{registry-Z4GVYFTV.js → registry-KFFZFIZT.js} +3 -3
  72. package/dist/{serve-Z5ITDPCQ.js → serve-KQAPXO5X.js} +42 -40
  73. package/dist/server/index.d.ts +18 -3
  74. package/dist/server/index.js +39 -37
  75. package/dist/server-RPKVKMDD.js +56 -0
  76. package/dist/{service-INQWTYY2.js → service-7TLOSFAO.js} +12 -12
  77. package/dist/{session-overrides-4WAD3X5Q.js → session-overrides-U573CU2V.js} +5 -5
  78. package/dist/session-status-UFO5IFI7.js +10 -0
  79. package/dist/{sessions-D7VRCHQY.js → sessions-LUVWWRFO.js} +4 -4
  80. package/dist/{settings-VOWWO4VG.js → settings-LMAMF2X7.js} +2 -2
  81. package/dist/shared/index.d.ts +3 -3
  82. package/dist/shared/index.js +1 -1
  83. package/dist/skill-defaults/browser/SKILL.md +20 -1
  84. package/dist/{tasks-SE3DOPVP.js → tasks-FA6Z52H2.js} +12 -12
  85. package/dist/{tools-6XUSIJN2.js → tools-SSPC3UQZ.js} +34 -34
  86. package/dist/{types-PAKlAzp9.d.ts → types-BIkpxjaj.d.ts} +11 -2
  87. package/dist/{types-BWuVnaBw.d.ts → types-CoY8Ka1C.d.ts} +1 -1
  88. package/dist/{update-EJUI6PSV.js → update-QRGK67DB.js} +2 -2
  89. package/dist/web/assets/{index-CGKd7WLQ.js → index-0PVQNOfW.js} +88 -88
  90. package/dist/web/assets/{index-CbX8veVW.css → index-Ds94aclE.css} +1 -1
  91. package/dist/web/index.html +2 -2
  92. package/dist/web/sw.js +1 -1
  93. package/package.json +1 -1
  94. package/plugins-registry.json +12 -0
  95. package/dist/chunk-HIRDDCPD.js +0 -7
  96. package/dist/chunk-PHP7PLFX.js +0 -151
  97. package/dist/chunk-RSB4AR2A.js +0 -108
  98. package/dist/client-RZGGDGUA.js +0 -16
  99. package/dist/dynamic-context-ZVE733UI.js +0 -28
  100. package/dist/launch-5ARSU7EM.js +0 -53
  101. package/dist/server-MUJ7EHEI.js +0 -56
@@ -0,0 +1,235 @@
1
+ import {
2
+ clearMcpOAuthEntry,
3
+ clearMcpOAuthTokens,
4
+ readMcpOAuthEntry,
5
+ saveMcpOAuthClientInformation,
6
+ saveMcpOAuthCodeVerifier,
7
+ saveMcpOAuthState,
8
+ saveMcpOAuthTokens
9
+ } from "./chunk-IJ53Y77N.js";
10
+ import {
11
+ logger
12
+ } from "./chunk-K44MW7JJ.js";
13
+
14
+ // src/server/mcp/oauth-provider.ts
15
+ import { randomBytes } from "crypto";
16
+ import {
17
+ discoverAuthorizationServerMetadata,
18
+ discoverOAuthProtectedResourceMetadata
19
+ } from "@modelcontextprotocol/sdk/client/auth.js";
20
+ function persistentStorage(serverName, serverUrl) {
21
+ return {
22
+ read: () => readMcpOAuthEntry(serverName, serverUrl),
23
+ saveClientInformation: (info) => saveMcpOAuthClientInformation(serverName, serverUrl, info),
24
+ saveTokens: (tokens) => saveMcpOAuthTokens(serverName, serverUrl, tokens),
25
+ saveCodeVerifier: (verifier) => saveMcpOAuthCodeVerifier(serverName, serverUrl, verifier),
26
+ saveState: (state) => saveMcpOAuthState(serverName, serverUrl, state),
27
+ clearTokens: () => clearMcpOAuthTokens(serverName, serverUrl),
28
+ clearAll: () => clearMcpOAuthEntry(serverName)
29
+ };
30
+ }
31
+ function memoryStorage() {
32
+ let entry = {};
33
+ return {
34
+ read: async () => entry,
35
+ saveClientInformation: async (info) => {
36
+ entry.clientInformation = info;
37
+ },
38
+ saveTokens: async (tokens) => {
39
+ entry.tokens = tokens;
40
+ },
41
+ saveCodeVerifier: async (verifier) => {
42
+ entry.codeVerifier = verifier;
43
+ },
44
+ saveState: async (state) => {
45
+ entry.state = state;
46
+ },
47
+ clearTokens: async () => {
48
+ delete entry.tokens;
49
+ },
50
+ clearAll: async () => {
51
+ entry = {};
52
+ }
53
+ };
54
+ }
55
+ var CALLBACK_PATH = "/api/mcp/oauth/callback";
56
+ var serverPort = 10369;
57
+ function setMcpOAuthServerPort(port) {
58
+ serverPort = port;
59
+ }
60
+ function getMcpOAuthRedirectUri() {
61
+ const publicUrl = process.env["OPENFOX_PUBLIC_URL"];
62
+ if (!publicUrl) return `http://127.0.0.1:${serverPort}${CALLBACK_PATH}`;
63
+ let base;
64
+ try {
65
+ base = new URL(publicUrl);
66
+ } catch {
67
+ throw new Error("OPENFOX_PUBLIC_URL is not a valid URL");
68
+ }
69
+ if (base.protocol !== "http:" && base.protocol !== "https:") {
70
+ throw new Error("OPENFOX_PUBLIC_URL must be an http or https URL");
71
+ }
72
+ base.pathname = `${base.pathname.replace(/\/+$/, "")}${CALLBACK_PATH}`;
73
+ base.search = "";
74
+ base.hash = "";
75
+ return base.toString();
76
+ }
77
+ var McpOAuthProvider = class _McpOAuthProvider {
78
+ constructor(serverName, serverUrl, redirectUri = getMcpOAuthRedirectUri(), storage = persistentStorage(serverName, serverUrl)) {
79
+ this.serverName = serverName;
80
+ this.serverUrl = serverUrl;
81
+ this.redirectUri = redirectUri;
82
+ this.storage = storage;
83
+ }
84
+ serverName;
85
+ serverUrl;
86
+ redirectUri;
87
+ storage;
88
+ authorizationUrl = null;
89
+ /** Kept for log context and for callers that need the identity of the server being probed. */
90
+ get name() {
91
+ return this.serverName;
92
+ }
93
+ get url() {
94
+ return this.serverUrl;
95
+ }
96
+ get redirectUrl() {
97
+ return this.redirectUri;
98
+ }
99
+ get clientMetadata() {
100
+ return {
101
+ client_name: "OpenFox",
102
+ redirect_uris: [this.redirectUri],
103
+ grant_types: ["authorization_code", "refresh_token"],
104
+ response_types: ["code"]
105
+ };
106
+ }
107
+ /** Set once the SDK has built an authorization URL, null while the stored tokens still work. */
108
+ get pendingAuthorizationUrl() {
109
+ return this.authorizationUrl;
110
+ }
111
+ async state() {
112
+ const value = randomBytes(32).toString("base64url");
113
+ await this.storage.saveState(value);
114
+ return value;
115
+ }
116
+ async clientInformation() {
117
+ const entry = await this.storage.read();
118
+ return entry?.clientInformation;
119
+ }
120
+ async saveClientInformation(clientInformation) {
121
+ await this.storage.saveClientInformation(clientInformation);
122
+ }
123
+ async tokens() {
124
+ const entry = await this.storage.read();
125
+ return entry?.tokens;
126
+ }
127
+ async saveTokens(tokens) {
128
+ await this.storage.saveTokens(tokens);
129
+ }
130
+ redirectToAuthorization(authorizationUrl) {
131
+ this.authorizationUrl = authorizationUrl;
132
+ }
133
+ async saveCodeVerifier(codeVerifier) {
134
+ await this.storage.saveCodeVerifier(codeVerifier);
135
+ }
136
+ async codeVerifier() {
137
+ const entry = await this.storage.read();
138
+ if (!entry?.codeVerifier) {
139
+ throw new Error("No stored PKCE verifier for this server, start the authorization again");
140
+ }
141
+ return entry.codeVerifier;
142
+ }
143
+ /** Lets the SDK recover on its own when the server rejects the stored client or grant. */
144
+ async invalidateCredentials(scope) {
145
+ if (scope === "discovery") return;
146
+ if (scope === "all" || scope === "client") {
147
+ await this.storage.clearAll();
148
+ return;
149
+ }
150
+ await this.storage.clearTokens();
151
+ }
152
+ /**
153
+ * A provider whose reads and writes never reach the store.
154
+ *
155
+ * The transport runs one of these on every connection, and a connection happens to receive a 401
156
+ * exactly when no valid token exists — the same moment an explicit authorization may be pending.
157
+ * Letting that probe run against the store would overwrite the pending state and verifier with its
158
+ * own, and the browser callback would then no longer match anything. The probe still gets a full
159
+ * SDK flow against its private copy, so a 401 during a plain reconnect stays a plain failure.
160
+ */
161
+ static forBackgroundProbe(serverName, serverUrl) {
162
+ return new _McpOAuthProvider(serverName, serverUrl, getMcpOAuthRedirectUri(), memoryStorage());
163
+ }
164
+ };
165
+ async function buildOAuthProbeUrl(provider) {
166
+ try {
167
+ const resource = await discoverOAuthProtectedResourceMetadata(provider.url);
168
+ const authorizationServerUrl = resource?.authorization_servers?.[0] ?? provider.url;
169
+ const metadata = await discoverAuthorizationServerMetadata(authorizationServerUrl);
170
+ if (!metadata?.authorization_endpoint) return void 0;
171
+ const client = await provider.clientInformation();
172
+ if (!client) return void 0;
173
+ const url = new URL(metadata.authorization_endpoint);
174
+ url.searchParams.set("client_id", client.client_id);
175
+ return url;
176
+ } catch {
177
+ return void 0;
178
+ }
179
+ }
180
+ var STALE_CLIENT_STATUSES = /* @__PURE__ */ new Set([401, 403]);
181
+ function isUnknownClientBody(body) {
182
+ const lowered = body.toLowerCase();
183
+ return lowered.includes("unrecognized client") || lowered.includes("unknown client") || lowered.includes("invalid client") || lowered.includes("client not found") || lowered.includes("client_id not found");
184
+ }
185
+ var PROBE_TIMEOUT_MS = 5e3;
186
+ var probeCache = /* @__PURE__ */ new Map();
187
+ var PROBE_TTL_MS = 10 * 60 * 1e3;
188
+ function resetProbeCache() {
189
+ probeCache.clear();
190
+ }
191
+ async function rejectStaleOAuthClient(provider, fetchImpl = fetch) {
192
+ const client = await provider.clientInformation();
193
+ if (!client) return;
194
+ const cacheKey = `${provider.name}:${provider.url}:${client.client_id}`;
195
+ const cached = probeCache.get(cacheKey);
196
+ if (cached && cached.expiresAt > Date.now()) {
197
+ if (cached.result) await provider.invalidateCredentials("client");
198
+ return;
199
+ }
200
+ const authorizationUrl = await buildOAuthProbeUrl(provider);
201
+ if (!authorizationUrl) return;
202
+ let response;
203
+ try {
204
+ response = await fetchImpl(authorizationUrl, {
205
+ redirect: "manual",
206
+ signal: AbortSignal.timeout(PROBE_TIMEOUT_MS)
207
+ });
208
+ } catch {
209
+ return;
210
+ }
211
+ const body = await response.text().catch(() => "");
212
+ let stale = STALE_CLIENT_STATUSES.has(response.status);
213
+ if (!stale && (response.status === 400 || response.status === 422)) {
214
+ stale = isUnknownClientBody(body);
215
+ }
216
+ probeCache.set(cacheKey, { result: stale, expiresAt: Date.now() + PROBE_TTL_MS });
217
+ if (stale) {
218
+ logger.warn("Discarding an OAuth client the authorization server no longer recognizes", {
219
+ server: provider.name,
220
+ status: response.status,
221
+ body: body.slice(0, 200)
222
+ });
223
+ await provider.invalidateCredentials("client");
224
+ }
225
+ }
226
+
227
+ export {
228
+ setMcpOAuthServerPort,
229
+ getMcpOAuthRedirectUri,
230
+ McpOAuthProvider,
231
+ buildOAuthProbeUrl,
232
+ resetProbeCache,
233
+ rejectStaleOAuthClient
234
+ };
235
+ //# sourceMappingURL=chunk-DQTN4B33.js.map
@@ -11,11 +11,11 @@ import {
11
11
  } from "./chunk-I72ACQ6R.js";
12
12
  import {
13
13
  getPlatformShell
14
- } from "./chunk-66MG44TF.js";
14
+ } from "./chunk-6QZVAOSA.js";
15
15
  import {
16
16
  SETTINGS_KEYS,
17
17
  getSetting
18
- } from "./chunk-N2Q3KYWM.js";
18
+ } from "./chunk-3DZSHRXE.js";
19
19
 
20
20
  // src/server/utils/shell.ts
21
21
  import { spawn } from "child_process";
@@ -214,4 +214,4 @@ export {
214
214
  getSessionProcesses2 as getSessionProcesses,
215
215
  getProcessLogs
216
216
  };
217
- //# sourceMappingURL=chunk-RV5G7QQU.js.map
217
+ //# sourceMappingURL=chunk-DQTXXHD2.js.map
@@ -2,45 +2,52 @@ import {
2
2
  generateSessionNameForSession,
3
3
  getSessionMessageCount,
4
4
  needsNameGeneration
5
- } from "./chunk-OHTBWA7L.js";
5
+ } from "./chunk-35GQEIH2.js";
6
6
  import {
7
7
  launchWorkflowRun
8
- } from "./chunk-2COZT3YI.js";
8
+ } from "./chunk-2OMXXCJJ.js";
9
9
  import {
10
10
  runChatTurn
11
- } from "./chunk-7RIEI2TE.js";
11
+ } from "./chunk-EVVWDRM5.js";
12
12
  import {
13
13
  devServerManager
14
- } from "./chunk-L24A6GZ7.js";
14
+ } from "./chunk-X24XN2M2.js";
15
15
  import {
16
- applyDynamicContext,
17
- computeSessionHash,
18
- computeUnifiedDiff
19
- } from "./chunk-PHP7PLFX.js";
16
+ gitSpawnEnv
17
+ } from "./chunk-J7GAZGZT.js";
20
18
  import {
21
19
  appendCompactionPrompt
22
- } from "./chunk-IJFKJ5D6.js";
20
+ } from "./chunk-VUIXQ6X4.js";
23
21
  import {
24
22
  hasRecentLLMFailure,
25
23
  interruptLLMRetryWait
26
- } from "./chunk-6LX43YRA.js";
24
+ } from "./chunk-7ET46SNE.js";
27
25
  import {
28
26
  onProcessEvent
29
- } from "./chunk-RV5G7QQU.js";
27
+ } from "./chunk-DQTXXHD2.js";
30
28
  import {
31
29
  killProcessTree
32
30
  } from "./chunk-I72ACQ6R.js";
33
31
  import {
34
- gitSpawnEnv
35
- } from "./chunk-J7GAZGZT.js";
32
+ applyDynamicContext,
33
+ computeSessionHash,
34
+ computeUnifiedDiff
35
+ } from "./chunk-25DAVVTP.js";
36
+ import {
37
+ getPendingQuestionsForSession,
38
+ provideAnswer
39
+ } from "./chunk-JURM3RPZ.js";
36
40
  import {
37
41
  combineEventsWithSnapshot,
38
42
  getEventStore
39
- } from "./chunk-YJD5A375.js";
43
+ } from "./chunk-AYCB32NI.js";
40
44
  import {
41
45
  buildMessagesFromStoredEvents,
42
46
  foldPendingConfirmations
43
- } from "./chunk-ZIYETXOW.js";
47
+ } from "./chunk-JKRMMNUR.js";
48
+ import {
49
+ getRuntimeConfig
50
+ } from "./chunk-JHA2SPCU.js";
44
51
  import {
45
52
  createChatErrorMessage,
46
53
  createChatMessageMessage,
@@ -55,26 +62,19 @@ import {
55
62
  parseClientMessage,
56
63
  serializeServerMessage,
57
64
  storedEventToServerMessage
58
- } from "./chunk-567L5OJ6.js";
65
+ } from "./chunk-P57IBMK4.js";
59
66
  import {
60
67
  getPlatformShell
61
- } from "./chunk-66MG44TF.js";
62
- import {
63
- getPendingQuestionsForSession,
64
- provideAnswer
65
- } from "./chunk-JURM3RPZ.js";
66
- import {
67
- getRuntimeConfig
68
- } from "./chunk-KBESUA3W.js";
68
+ } from "./chunk-6QZVAOSA.js";
69
69
  import {
70
70
  getMaxVisibleItems
71
- } from "./chunk-N2Q3KYWM.js";
71
+ } from "./chunk-3DZSHRXE.js";
72
72
  import {
73
73
  logger
74
74
  } from "./chunk-K44MW7JJ.js";
75
75
  import {
76
76
  createServerMessage
77
- } from "./chunk-ATWOXI52.js";
77
+ } from "./chunk-HCYSGLY2.js";
78
78
 
79
79
  // src/server/ws/server.ts
80
80
  import { WebSocketServer, WebSocket as WebSocket2 } from "ws";
@@ -434,6 +434,20 @@ async function tokenFromPassword(password) {
434
434
  });
435
435
  return sign;
436
436
  }
437
+ async function currentSessionToken() {
438
+ const auth = getAuthConfig();
439
+ if (!auth?.encryptedPassword) return null;
440
+ const privateKey = await loadPrivateKey();
441
+ try {
442
+ const password = privateDecrypt(
443
+ { key: privateKey, padding: 1 },
444
+ Buffer.from(auth.encryptedPassword, "base64")
445
+ ).toString();
446
+ return await tokenFromPassword(password);
447
+ } catch {
448
+ return null;
449
+ }
450
+ }
437
451
  async function isValidToken(token) {
438
452
  if (!cachedAuth?.encryptedPassword) return false;
439
453
  const privateKey = await loadPrivateKey();
@@ -1299,19 +1313,21 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
1299
1313
  }
1300
1314
  const session = sessionManager.requireSession(sessionId);
1301
1315
  try {
1302
- const { buildCachedPrompt } = await import("./dynamic-context-ZVE733UI.js");
1303
- const allAgents = await import("./registry-Z4GVYFTV.js");
1316
+ const { buildCachedPrompt, computePreviewToolDiff } = await import("./dynamic-context-2VLACYK4.js");
1317
+ const allAgents = await import("./registry-KFFZFIZT.js");
1304
1318
  const agentDef = allAgents.findAgentById(session.mode, await allAgents.loadAllAgentsDefault()) ?? allAgents.findAgentById("planner", await allAgents.loadAllAgentsDefault());
1305
1319
  const modelName = session.providerModel ?? _providerManager?.getCurrentModel();
1306
- const { systemPrompt: newPrompt, hash: newHash } = await buildCachedPrompt(
1307
- sessionManager,
1308
- sessionId,
1309
- agentDef,
1310
- modelName
1311
- );
1320
+ const {
1321
+ systemPrompt: newPrompt,
1322
+ tools: newTools,
1323
+ hash: newHash
1324
+ } = await buildCachedPrompt(sessionManager, sessionId, agentDef, modelName);
1312
1325
  const oldCached = sessionManager.getCachedPrompt(sessionId);
1313
1326
  const oldPrompt = oldCached?.systemPrompt;
1314
1327
  const diff = oldPrompt ? computeUnifiedDiff(oldPrompt, newPrompt) : [];
1328
+ const { getToolRegistryForAgent } = await import("./tools-SSPC3UQZ.js");
1329
+ const unfilteredTools = getToolRegistryForAgent(agentDef).definitions;
1330
+ const toolDiff = computePreviewToolDiff(oldCached?.tools, unfilteredTools, newTools);
1315
1331
  send({
1316
1332
  type: "context.preview",
1317
1333
  payload: {
@@ -1319,7 +1335,8 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
1319
1335
  newPrompt,
1320
1336
  oldHash: oldCached?.hash,
1321
1337
  newHash,
1322
- diff
1338
+ diff,
1339
+ ...toolDiff.length > 0 ? { toolDiff } : {}
1323
1340
  },
1324
1341
  id: message.id
1325
1342
  });
@@ -1620,8 +1637,9 @@ export {
1620
1637
  hasPassword,
1621
1638
  verifyPassword,
1622
1639
  tokenFromPassword,
1640
+ currentSessionToken,
1623
1641
  isValidToken,
1624
1642
  signalMcpReady,
1625
1643
  createWebSocketServer
1626
1644
  };
1627
- //# sourceMappingURL=chunk-MYNNMV75.js.map
1645
+ //# sourceMappingURL=chunk-DYIDDGMN.js.map
@@ -589,7 +589,7 @@ function convertTools(tools) {
589
589
  }
590
590
  }));
591
591
  }
592
- async function buildChatCompletionCreateParams(model, request, profile, capabilities, reasoningEffort, isStreaming, thinkingField, sendReasoningInMessages) {
592
+ async function buildChatCompletionCreateParams(model, request, profile, capabilities, reasoningEffort, isStreaming, thinkingField, sendReasoningInMessages, apiProtocol) {
593
593
  const userVisionOverride = request.modelSettings?.supportsVision;
594
594
  const modelSupportsVision = userVisionOverride ?? profile.supportsVision ?? false;
595
595
  const convertedMessages = await convertMessages(
@@ -608,7 +608,7 @@ async function buildChatCompletionCreateParams(model, request, profile, capabili
608
608
  ...request.tools?.length ? { tools: convertTools(request.tools) } : {},
609
609
  ...request.toolChoice ? { tool_choice: request.toolChoice } : {},
610
610
  temperature,
611
- max_tokens: maxTokens,
611
+ ...capabilities.usesMaxCompletionTokens ? { max_completion_tokens: maxTokens } : { max_tokens: maxTokens },
612
612
  ...topP !== void 0 && { top_p: topP },
613
613
  stream: isStreaming,
614
614
  ...isStreaming ? { stream_options: { include_usage: true } } : {}
@@ -621,7 +621,10 @@ async function buildChatCompletionCreateParams(model, request, profile, capabili
621
621
  ;
622
622
  params["num_ctx"] = request.modelSettings.numCtx;
623
623
  }
624
- const resolvedEffort = reasoningEffort ?? request.reasoningEffort;
624
+ let resolvedEffort = reasoningEffort ?? request.reasoningEffort;
625
+ if (request.tools?.length && apiProtocol !== "responses" && profile.apiProtocol === "responses") {
626
+ resolvedEffort = "none";
627
+ }
625
628
  const queryParams = request.modelSettings?.queryParams;
626
629
  const hasQueryParams = queryParams && Object.keys(queryParams).length > 0;
627
630
  const hasExplicitModelSettings = hasQueryParams || !!request.modelSettings?.chatTemplateKwargs;
@@ -686,7 +689,16 @@ async function buildChatCompletionCreateParams(model, request, profile, capabili
686
689
  return { params, modelParams };
687
690
  }
688
691
  async function buildCreateParamsFromInput(input, isStreaming) {
689
- const { model, request, profile, capabilities, reasoningEffort, thinkingField, sendReasoningInMessages } = input;
692
+ const {
693
+ model,
694
+ request,
695
+ profile,
696
+ capabilities,
697
+ reasoningEffort,
698
+ thinkingField,
699
+ sendReasoningInMessages,
700
+ apiProtocol
701
+ } = input;
690
702
  return buildChatCompletionCreateParams(
691
703
  model,
692
704
  request,
@@ -695,7 +707,8 @@ async function buildCreateParamsFromInput(input, isStreaming) {
695
707
  reasoningEffort,
696
708
  isStreaming,
697
709
  thinkingField,
698
- sendReasoningInMessages
710
+ sendReasoningInMessages,
711
+ apiProtocol
699
712
  );
700
713
  }
701
714
  var buildNonStreamingCreateParams = (input) => buildCreateParamsFromInput(input, false);
@@ -735,4 +748,4 @@ export {
735
748
  buildStreamingCreateParams,
736
749
  mapFinishReason
737
750
  };
738
- //# sourceMappingURL=chunk-DABWCAXS.js.map
751
+ //# sourceMappingURL=chunk-EUOWCVU6.js.map
@@ -4,42 +4,45 @@ import {
4
4
  getToolRegistryForAgent,
5
5
  processEventsForConversation,
6
6
  runTopLevelAgentLoop
7
- } from "./chunk-L24A6GZ7.js";
7
+ } from "./chunk-X24XN2M2.js";
8
+ import {
9
+ TurnMetrics,
10
+ createChatDoneEvent,
11
+ createMessageStartEvent
12
+ } from "./chunk-7ET46SNE.js";
8
13
  import {
9
14
  buildCachedPrompt,
15
+ checkToolChangesAndInject,
10
16
  computeDynamicContextHash,
11
17
  getToolFingerprint
12
- } from "./chunk-PHP7PLFX.js";
18
+ } from "./chunk-25DAVVTP.js";
13
19
  import {
14
20
  getAllInstructions,
15
21
  getEnabledSkillMetadata
16
- } from "./chunk-ZIL6VKLU.js";
17
- import {
18
- TurnMetrics,
19
- createChatDoneEvent,
20
- createMessageStartEvent
21
- } from "./chunk-6LX43YRA.js";
22
+ } from "./chunk-64N4CZFT.js";
22
23
  import {
23
24
  buildAgentReminder,
24
- buildAgentSmallReminder
25
- } from "./chunk-GIJUWPRQ.js";
25
+ buildAgentSmallReminder,
26
+ buildTopLevelSystemPrompt
27
+ } from "./chunk-CGCEAKG5.js";
26
28
  import {
27
29
  PathAccessDeniedError
28
- } from "./chunk-26WS7AH6.js";
30
+ } from "./chunk-VJNA5AOB.js";
29
31
  import {
30
32
  getCurrentContextWindowId,
31
33
  getCurrentWindowMessageOptions,
32
34
  getEventStore
33
- } from "./chunk-YJD5A375.js";
35
+ } from "./chunk-AYCB32NI.js";
34
36
  import {
35
37
  buildSnapshotFromSessionState
36
- } from "./chunk-ZIYETXOW.js";
38
+ } from "./chunk-JKRMMNUR.js";
37
39
  import {
38
40
  findAgentById,
39
41
  getRuntimeConfig,
42
+ getSubAgents,
40
43
  loadAllAgentsDefault,
41
44
  resolveDefaultAgentId
42
- } from "./chunk-KBESUA3W.js";
45
+ } from "./chunk-JHA2SPCU.js";
43
46
  import {
44
47
  logger
45
48
  } from "./chunk-K44MW7JJ.js";
@@ -49,7 +52,7 @@ import {
49
52
 
50
53
  // src/server/chat/orchestrator.ts
51
54
  async function buildRetryPatterns() {
52
- const { getSetting, SETTINGS_KEYS } = await import("./settings-VOWWO4VG.js");
55
+ const { getSetting, SETTINGS_KEYS } = await import("./settings-LMAMF2X7.js");
53
56
  const raw = getSetting(SETTINGS_KEYS.RETRY_PATTERNS);
54
57
  if (!raw) {
55
58
  const oldXmlProtection = getSetting("llm.disableXmlProtection");
@@ -244,6 +247,27 @@ async function runAgentTurn(options, turnMetrics, agentId, append, callbacks) {
244
247
  const runtimeConfig = getRuntimeConfig();
245
248
  const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
246
249
  const skills = await getEnabledSkillMetadata(configDir, options.sessionManager.getProjectWorkdir(options.sessionId));
250
+ if (!options.warmup) {
251
+ const modelName = agentLlmClient.getModel();
252
+ await checkToolChangesAndInject(
253
+ options.sessionManager,
254
+ options.sessionId,
255
+ agentDef,
256
+ {
257
+ modelName,
258
+ instructionContent: instructionContent ?? "",
259
+ skills,
260
+ buildNewSystemPrompt: () => buildTopLevelSystemPrompt(
261
+ session.workdir,
262
+ instructionContent || void 0,
263
+ skills,
264
+ getSubAgents(allAgents),
265
+ modelName
266
+ )
267
+ },
268
+ append
269
+ );
270
+ }
247
271
  return runTopLevelAgentLoop(
248
272
  {
249
273
  mode: agentId,
@@ -291,6 +315,7 @@ async function runAgentTurn(options, turnMetrics, agentId, append, callbacks) {
291
315
  agentLlmClient.getModel()
292
316
  );
293
317
  options.sessionManager.setCachedPrompt(options.sessionId, result.systemPrompt, result.tools, result.hash);
318
+ options.sessionManager.setAnnouncedPromptHash(options.sessionId, result.promptHash);
294
319
  return createAssemblyResult({
295
320
  systemPrompt: result.systemPrompt,
296
321
  messages: input.messages,
@@ -302,6 +327,10 @@ async function runAgentTurn(options, turnMetrics, agentId, append, callbacks) {
302
327
  getToolRegistry: () => getToolRegistryForAgent(agentDef, options.sessionId),
303
328
  getConversationMessages: buildGetConversationMessages(options.sessionId, resolveAgentClient, append),
304
329
  injectAgentReminder: () => injectAgentReminder(options.sessionId, agentDef),
330
+ rebuildCachedContext: async () => {
331
+ const { applyDynamicContext } = await import("./dynamic-context-2VLACYK4.js");
332
+ await applyDynamicContext(options.sessionManager, options.sessionId, agentLlmClient.getModel());
333
+ },
305
334
  ...options.initialCompacting ? { initialCompacting: true } : {},
306
335
  ...callbacks?.injectKickoff ? { injectKickoff: callbacks.injectKickoff } : {},
307
336
  ...callbacks?.onToolExecuted ? { onToolExecuted: callbacks.onToolExecuted } : {},
@@ -329,4 +358,4 @@ export {
329
358
  runChatTurn,
330
359
  runAgentTurn
331
360
  };
332
- //# sourceMappingURL=chunk-7RIEI2TE.js.map
361
+ //# sourceMappingURL=chunk-EVVWDRM5.js.map
@@ -26,4 +26,4 @@ export {
26
26
  isClientMessage,
27
27
  isServerMessage
28
28
  };
29
- //# sourceMappingURL=chunk-ATWOXI52.js.map
29
+ //# sourceMappingURL=chunk-HCYSGLY2.js.map
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  SETTINGS_KEYS,
9
9
  getSetting
10
- } from "./chunk-N2Q3KYWM.js";
10
+ } from "./chunk-3DZSHRXE.js";
11
11
  import {
12
12
  logger
13
13
  } from "./chunk-K44MW7JJ.js";
@@ -352,4 +352,4 @@ export {
352
352
  getOverrideAgentIds,
353
353
  resolveDefaultAgentId
354
354
  };
355
- //# sourceMappingURL=chunk-KBESUA3W.js.map
355
+ //# sourceMappingURL=chunk-JHA2SPCU.js.map
@@ -1,9 +1,9 @@
1
+ import {
2
+ resolveDefaultAgentId
3
+ } from "./chunk-JHA2SPCU.js";
1
4
  import {
2
5
  normalizeAskOptions
3
6
  } from "./chunk-LCLH6ZUL.js";
4
- import {
5
- resolveDefaultAgentId
6
- } from "./chunk-KBESUA3W.js";
7
7
 
8
8
  // src/server/events/apply-events.ts
9
9
  function markComplete(msg, reason) {
@@ -965,4 +965,4 @@ export {
965
965
  buildSnapshot,
966
966
  buildSnapshotFromSessionState
967
967
  };
968
- //# sourceMappingURL=chunk-ZIYETXOW.js.map
968
+ //# sourceMappingURL=chunk-JKRMMNUR.js.map