openfox 2.0.129 → 2.0.131

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 (113) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +2 -0
  3. package/dist/CHANGELOG.md +44 -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-RAIMQU7F.js} +35 -35
  8. package/dist/{chunk-ISE55FOR.js → chunk-2AI7VYPN.js} +11 -1
  9. package/dist/{chunk-HO7A7TMF.js → chunk-55DGZIZ6.js} +15 -5
  10. package/dist/{chunk-L24A6GZ7.js → chunk-5AI3LHRQ.js} +85 -57
  11. package/dist/{chunk-ZFNBATE3.js → chunk-6EZDW4JS.js} +3 -2
  12. package/dist/{chunk-ZXWJ6JTL.js → chunk-6MUSEPV7.js} +1197 -225
  13. package/dist/{chunk-OHTBWA7L.js → chunk-6SUBBT2M.js} +13 -13
  14. package/dist/{chunk-6LX43YRA.js → chunk-7ET46SNE.js} +4 -4
  15. package/dist/{chunk-GIJUWPRQ.js → chunk-7JVBDBXE.js} +2 -2
  16. package/dist/{chunk-MYNNMV75.js → chunk-7LGMQ5KS.js} +54 -36
  17. package/dist/{chunk-ZIL6VKLU.js → chunk-BKMWZTNO.js} +3 -3
  18. package/dist/chunk-BMBOSVRM.js +7 -0
  19. package/dist/{auth-GTGIGX5X.js → chunk-CQGJ5RWB.js} +4 -4
  20. package/dist/{chunk-3B232XG4.js → chunk-DPFET73G.js} +2 -2
  21. package/dist/chunk-DQTN4B33.js +235 -0
  22. package/dist/{chunk-KBESUA3W.js → chunk-ELYHHEYL.js} +3 -3
  23. package/dist/{chunk-DABWCAXS.js → chunk-EUOWCVU6.js} +19 -6
  24. package/dist/{chunk-YJD5A375.js → chunk-FGNJMKDV.js} +5 -5
  25. package/dist/{chunk-ATWOXI52.js → chunk-HCYSGLY2.js} +1 -1
  26. package/dist/{chunk-OYBUJIC3.js → chunk-JU757HVI.js} +5 -1
  27. package/dist/{chunk-AQBRI7TM.js → chunk-KWAHD2JA.js} +13 -8
  28. package/dist/{chunk-N2Q3KYWM.js → chunk-LQKXJPKP.js} +8 -3
  29. package/dist/{chunk-EHFIUXWZ.js → chunk-LW6MMSTD.js} +2 -2
  30. package/dist/{chunk-ZIYETXOW.js → chunk-M5T4RDPJ.js} +4 -4
  31. package/dist/{chunk-66MG44TF.js → chunk-MGEYAYGU.js} +2 -2
  32. package/dist/{chunk-RV5G7QQU.js → chunk-MQMPIXON.js} +3 -3
  33. package/dist/{chunk-K2QKX4ZJ.js → chunk-OA2FURC3.js} +8 -2
  34. package/dist/{chunk-567L5OJ6.js → chunk-P57IBMK4.js} +2 -2
  35. package/dist/{chunk-P6GTPKE5.js → chunk-QJG5K3X2.js} +278 -16
  36. package/dist/{chunk-2COZT3YI.js → chunk-RQPHGBWI.js} +24 -24
  37. package/dist/chunk-SVALN5KE.js +394 -0
  38. package/dist/{session-status-6Q5B5PEN.js → chunk-T3S5MTMD.js} +2 -3
  39. package/dist/{chunk-7YP4O4XE.js → chunk-TACWRDDC.js} +3 -3
  40. package/dist/{chunk-7ZMOP5LS.js → chunk-TS5WKTFB.js} +18 -1
  41. package/dist/{chunk-PBFGJFGC.js → chunk-UV6IH6HK.js} +32 -10
  42. package/dist/{chunk-7RIEI2TE.js → chunk-WCM5ZW5N.js} +52 -17
  43. package/dist/{chunk-Y3BSBKHY.js → chunk-XE6UC5Z3.js} +2 -2
  44. package/dist/{chunk-26WS7AH6.js → chunk-Y6ZGHOKM.js} +39 -7
  45. package/dist/chunk-YNMP647F.js +24 -0
  46. package/dist/{chunk-H6YIVK67.js → chunk-ZCFQOC3C.js} +26 -6
  47. package/dist/{chunk-IJFKJ5D6.js → chunk-ZL4IAFF3.js} +4 -4
  48. package/dist/{chunk-JQMQ4DGC.js → chunk-ZVHUISW7.js} +76 -32
  49. package/dist/cli/dev.js +1 -1
  50. package/dist/cli/index.js +1 -1
  51. package/dist/client-E6QLHPHD.js +16 -0
  52. package/dist/{client-pure-GU2SV3DD.js → client-pure-FLKP6PTI.js} +2 -2
  53. package/dist/compactor-OEJAA2YP.js +32 -0
  54. package/dist/dynamic-context-Y555VDLA.js +52 -0
  55. package/dist/{events-GMHRX4LF.js → events-ZJPRGVL2.js} +9 -9
  56. package/dist/{folding-7K2GRPF4.js → folding-QRZOHY2I.js} +7 -7
  57. package/dist/http-client-P4XTKAZA.js +11 -0
  58. package/dist/{inspect-proxy-UKPU3Z64.js → inspect-proxy-A3OROWPG.js} +4 -4
  59. package/dist/launch-Y4H7FDU2.js +53 -0
  60. package/dist/{manager-NOKJQTTF.js → manager-TMBFBCQL.js} +5 -5
  61. package/dist/mcp-YU7AM3UV.js +120 -0
  62. package/dist/{model-catalog-ZLOWTQA7.js → model-catalog-2PCKTYGW.js} +2 -2
  63. package/dist/{oauth-provider-DGBC2YM6.js → oauth-provider-VHUS2KEG.js} +8 -2
  64. package/dist/orchestrator-SQN2SJ2A.js +64 -0
  65. package/dist/package.json +1 -1
  66. package/dist/{path-security-UDZ7UVWK.js → path-security-CBACXAMS.js} +13 -13
  67. package/dist/{platform-EMKWQTZX.js → platform-5LQXOZO3.js} +4 -4
  68. package/dist/plugins-registry.json +12 -0
  69. package/dist/{processor-7RDR675X.js → processor-MEHODYNE.js} +34 -34
  70. package/dist/{profiles-HXGJIPF2.js → profiles-EBCVFYG7.js} +2 -2
  71. package/dist/{project-creator-JF3YVQAH.js → project-creator-6AGQTNXB.js} +3 -3
  72. package/dist/{projects-TPSLCJP2.js → projects-5U37RUTL.js} +3 -3
  73. package/dist/{protocol-DMneA8mx.d.ts → protocol-BMUoqwYH.d.ts} +2 -1
  74. package/dist/{protocol-TS3GVTT3.js → protocol-Y7MRKRUO.js} +3 -3
  75. package/dist/provider/index.d.ts +4 -4
  76. package/dist/{provider-DXEICEIE.js → provider-6YRII4IV.js} +11 -11
  77. package/dist/{provider-manager-PU7RS2TK.js → provider-manager-URNJBK5Q.js} +11 -11
  78. package/dist/{registry-Z4GVYFTV.js → registry-CMSSZHDC.js} +5 -5
  79. package/dist/{serve-Z5ITDPCQ.js → serve-NPADSJG7.js} +45 -43
  80. package/dist/server/index.d.ts +28 -4
  81. package/dist/server/index.js +42 -40
  82. package/dist/server-5TY22HDN.js +56 -0
  83. package/dist/service-VPXGREXF.js +27 -0
  84. package/dist/{session-overrides-4WAD3X5Q.js → session-overrides-OECQYRDK.js} +7 -7
  85. package/dist/session-status-UFO5IFI7.js +10 -0
  86. package/dist/{sessions-D7VRCHQY.js → sessions-NMPX5ICI.js} +6 -6
  87. package/dist/{settings-VOWWO4VG.js → settings-MDCRNQBY.js} +3 -3
  88. package/dist/shared/index.d.ts +3 -3
  89. package/dist/shared/index.js +1 -1
  90. package/dist/skill-defaults/browser/SKILL.md +20 -1
  91. package/dist/{tasks-SE3DOPVP.js → tasks-MNPXK2S5.js} +14 -14
  92. package/dist/{tools-6XUSIJN2.js → tools-6BDT5YMT.js} +37 -37
  93. package/dist/{types-PAKlAzp9.d.ts → types-BIkpxjaj.d.ts} +11 -2
  94. package/dist/{types-BWuVnaBw.d.ts → types-CoY8Ka1C.d.ts} +1 -1
  95. package/dist/{update-EJUI6PSV.js → update-XKCOBE47.js} +2 -2
  96. package/dist/web/assets/{index-CGKd7WLQ.js → index-Bx5r3aJx.js} +88 -88
  97. package/dist/web/assets/{index-CbX8veVW.css → index-Y300llHY.css} +1 -1
  98. package/dist/web/index.html +2 -2
  99. package/dist/web/sw.js +1 -1
  100. package/dist/{workspace-6CUE26YA.js → workspace-LM646OHC.js} +4 -4
  101. package/package.json +1 -1
  102. package/plugins-registry.json +12 -0
  103. package/dist/chunk-HIRDDCPD.js +0 -7
  104. package/dist/chunk-PHP7PLFX.js +0 -151
  105. package/dist/chunk-RSB4AR2A.js +0 -108
  106. package/dist/client-RZGGDGUA.js +0 -16
  107. package/dist/compactor-WKFNTUXL.js +0 -32
  108. package/dist/dynamic-context-ZVE733UI.js +0 -28
  109. package/dist/http-client-ROVNSHF6.js +0 -11
  110. package/dist/launch-5ARSU7EM.js +0 -53
  111. package/dist/orchestrator-E6GIZGEN.js +0 -64
  112. package/dist/server-MUJ7EHEI.js +0 -56
  113. package/dist/service-INQWTYY2.js +0 -27
@@ -1,27 +1,27 @@
1
+ import {
2
+ getPendingQuestionsForSession
3
+ } from "./chunk-JURM3RPZ.js";
1
4
  import {
2
5
  combineEventsWithSnapshot,
3
6
  getEventStore
4
- } from "./chunk-YJD5A375.js";
7
+ } from "./chunk-FGNJMKDV.js";
5
8
  import {
6
9
  buildMessagesFromStoredEvents,
7
10
  foldPendingConfirmations
8
- } from "./chunk-ZIYETXOW.js";
11
+ } from "./chunk-M5T4RDPJ.js";
9
12
  import {
10
13
  updateSessionMetadata
11
- } from "./chunk-AQBRI7TM.js";
14
+ } from "./chunk-KWAHD2JA.js";
15
+ import {
16
+ getRuntimeConfig
17
+ } from "./chunk-ELYHHEYL.js";
12
18
  import {
13
19
  createContextStateMessage,
14
20
  createSessionStateMessage
15
- } from "./chunk-567L5OJ6.js";
16
- import {
17
- getPendingQuestionsForSession
18
- } from "./chunk-JURM3RPZ.js";
19
- import {
20
- getRuntimeConfig
21
- } from "./chunk-KBESUA3W.js";
21
+ } from "./chunk-P57IBMK4.js";
22
22
  import {
23
23
  getMaxVisibleItems
24
- } from "./chunk-N2Q3KYWM.js";
24
+ } from "./chunk-LQKXJPKP.js";
25
25
  import {
26
26
  logger
27
27
  } from "./chunk-K44MW7JJ.js";
@@ -162,7 +162,7 @@ async function generateSessionNameForSession(sessionId, userMessage, deps, signa
162
162
  client = deps.getLLMClient();
163
163
  client.setModel(providerConfig.model);
164
164
  } else if (providerConfig) {
165
- const { createLLMClient } = await import("./client-RZGGDGUA.js");
165
+ const { createLLMClient } = await import("./client-E6QLHPHD.js");
166
166
  client = createLLMClient(
167
167
  {
168
168
  llm: {
@@ -216,4 +216,4 @@ export {
216
216
  needsNameGeneration,
217
217
  generateSessionNameForSession
218
218
  };
219
- //# sourceMappingURL=chunk-OHTBWA7L.js.map
219
+ //# sourceMappingURL=chunk-6SUBBT2M.js.map
@@ -3,13 +3,13 @@ import {
3
3
  } from "./chunk-J2GP3J3X.js";
4
4
  import {
5
5
  getModelProfile
6
- } from "./chunk-7ZMOP5LS.js";
6
+ } from "./chunk-TS5WKTFB.js";
7
7
  import {
8
8
  getBackendCapabilities
9
- } from "./chunk-PBFGJFGC.js";
9
+ } from "./chunk-UV6IH6HK.js";
10
10
  import {
11
11
  buildModelParams
12
- } from "./chunk-DABWCAXS.js";
12
+ } from "./chunk-EUOWCVU6.js";
13
13
  import {
14
14
  logger
15
15
  } from "./chunk-K44MW7JJ.js";
@@ -518,4 +518,4 @@ export {
518
518
  createChatDoneEvent,
519
519
  consumeStreamGenerator
520
520
  };
521
- //# sourceMappingURL=chunk-6LX43YRA.js.map
521
+ //# sourceMappingURL=chunk-7ET46SNE.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getPlatformShell
3
- } from "./chunk-66MG44TF.js";
3
+ } from "./chunk-MGEYAYGU.js";
4
4
 
5
5
  // src/server/tools/tool-policy.ts
6
6
  var ALWAYS_ALLOWED = /* @__PURE__ */ new Set(["step_done"]);
@@ -246,4 +246,4 @@ export {
246
246
  buildAgentSmallReminder,
247
247
  COMPACTION_PROMPT
248
248
  };
249
- //# sourceMappingURL=chunk-GIJUWPRQ.js.map
249
+ //# sourceMappingURL=chunk-7JVBDBXE.js.map
@@ -2,45 +2,52 @@ import {
2
2
  generateSessionNameForSession,
3
3
  getSessionMessageCount,
4
4
  needsNameGeneration
5
- } from "./chunk-OHTBWA7L.js";
5
+ } from "./chunk-6SUBBT2M.js";
6
6
  import {
7
7
  launchWorkflowRun
8
- } from "./chunk-2COZT3YI.js";
8
+ } from "./chunk-RQPHGBWI.js";
9
9
  import {
10
10
  runChatTurn
11
- } from "./chunk-7RIEI2TE.js";
11
+ } from "./chunk-WCM5ZW5N.js";
12
12
  import {
13
13
  devServerManager
14
- } from "./chunk-L24A6GZ7.js";
14
+ } from "./chunk-5AI3LHRQ.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-ZL4IAFF3.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-MQMPIXON.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-SVALN5KE.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-FGNJMKDV.js";
40
44
  import {
41
45
  buildMessagesFromStoredEvents,
42
46
  foldPendingConfirmations
43
- } from "./chunk-ZIYETXOW.js";
47
+ } from "./chunk-M5T4RDPJ.js";
48
+ import {
49
+ getRuntimeConfig
50
+ } from "./chunk-ELYHHEYL.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-MGEYAYGU.js";
69
69
  import {
70
70
  getMaxVisibleItems
71
- } from "./chunk-N2Q3KYWM.js";
71
+ } from "./chunk-LQKXJPKP.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-Y555VDLA.js");
1317
+ const allAgents = await import("./registry-CMSSZHDC.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-6BDT5YMT.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-7LGMQ5KS.js.map
@@ -5,13 +5,13 @@ import {
5
5
  } from "./chunk-OSXPQSLW.js";
6
6
  import {
7
7
  getProject
8
- } from "./chunk-3B232XG4.js";
8
+ } from "./chunk-DPFET73G.js";
9
9
  import {
10
10
  SETTINGS_KEYS,
11
11
  deleteSetting,
12
12
  getSetting,
13
13
  setSetting
14
- } from "./chunk-N2Q3KYWM.js";
14
+ } from "./chunk-LQKXJPKP.js";
15
15
 
16
16
  // src/server/context/instructions.ts
17
17
  import { readFile, access } from "fs/promises";
@@ -440,4 +440,4 @@ export {
440
440
  deleteSkill,
441
441
  deleteProjectSkill
442
442
  };
443
- //# sourceMappingURL=chunk-ZIL6VKLU.js.map
443
+ //# sourceMappingURL=chunk-BKMWZTNO.js.map
@@ -0,0 +1,7 @@
1
+ // src/constants.ts
2
+ var VERSION = "2.0.131";
3
+
4
+ export {
5
+ VERSION
6
+ };
7
+ //# sourceMappingURL=chunk-BMBOSVRM.js.map
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  getAuthConfigPath
3
3
  } from "./chunk-CQGTEGKL.js";
4
- import "./chunk-YLJ4XMA6.js";
5
4
 
6
5
  // src/cli/auth.ts
7
6
  import { readFile, writeFile, mkdir, access } from "fs/promises";
@@ -40,12 +39,13 @@ function hashPassword(password) {
40
39
  function verifyPassword(password, hash) {
41
40
  return hashPassword(password) === hash;
42
41
  }
42
+
43
43
  export {
44
+ saveAuthConfig,
45
+ loadAuthConfig,
44
46
  authConfigExists,
45
47
  encryptPassword,
46
48
  hashPassword,
47
- loadAuthConfig,
48
- saveAuthConfig,
49
49
  verifyPassword
50
50
  };
51
- //# sourceMappingURL=auth-GTGIGX5X.js.map
51
+ //# sourceMappingURL=chunk-CQGJ5RWB.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getDatabase
3
- } from "./chunk-OYBUJIC3.js";
3
+ } from "./chunk-JU757HVI.js";
4
4
 
5
5
  // src/server/db/projects.ts
6
6
  function createProject(name, workdir) {
@@ -144,4 +144,4 @@ export {
144
144
  toggleStar,
145
145
  getProjectDefaultAgent
146
146
  };
147
- //# sourceMappingURL=chunk-3B232XG4.js.map
147
+ //# sourceMappingURL=chunk-DPFET73G.js.map
@@ -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
@@ -3,11 +3,11 @@ import {
3
3
  } from "./chunk-OSXPQSLW.js";
4
4
  import {
5
5
  getProjectDefaultAgent
6
- } from "./chunk-3B232XG4.js";
6
+ } from "./chunk-DPFET73G.js";
7
7
  import {
8
8
  SETTINGS_KEYS,
9
9
  getSetting
10
- } from "./chunk-N2Q3KYWM.js";
10
+ } from "./chunk-LQKXJPKP.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-ELYHHEYL.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
@@ -6,16 +6,16 @@ import {
6
6
  foldSessionState,
7
7
  spreadOptionalMessageFields,
8
8
  trimSnapshotStreamingOutput
9
- } from "./chunk-ZIYETXOW.js";
9
+ } from "./chunk-M5T4RDPJ.js";
10
10
  import {
11
11
  updateSessionMessageCount
12
- } from "./chunk-AQBRI7TM.js";
12
+ } from "./chunk-KWAHD2JA.js";
13
13
  import {
14
14
  getRuntimeConfig
15
- } from "./chunk-KBESUA3W.js";
15
+ } from "./chunk-ELYHHEYL.js";
16
16
  import {
17
17
  SETTINGS_KEYS
18
- } from "./chunk-N2Q3KYWM.js";
18
+ } from "./chunk-LQKXJPKP.js";
19
19
  import {
20
20
  logger
21
21
  } from "./chunk-K44MW7JJ.js";
@@ -1465,4 +1465,4 @@ export {
1465
1465
  truncateSessionMessages,
1466
1466
  getRecentUserPromptsForSession
1467
1467
  };
1468
- //# sourceMappingURL=chunk-YJD5A375.js.map
1468
+ //# sourceMappingURL=chunk-FGNJMKDV.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