openfox 2.0.61 → 2.0.63

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 (40) hide show
  1. package/README.md +14 -0
  2. package/dist/{chat-handler-6DRGMDXZ.js → chat-handler-WNARPARQ.js} +11 -11
  3. package/dist/{chunk-KX4C5Q5J.js → chunk-5OPZLQDV.js} +196 -114
  4. package/dist/{chunk-S5DWUGKZ.js → chunk-FGG4KRFX.js} +6 -6
  5. package/dist/{chunk-ZHSCXD75.js → chunk-IVJYQZSN.js} +65 -6
  6. package/dist/{chunk-LHTVTDQQ.js → chunk-N5JF4RYJ.js} +362 -92
  7. package/dist/{chunk-GJU35MDV.js → chunk-OESYKZCM.js} +2 -2
  8. package/dist/{chunk-JKLPWTUN.js → chunk-QBYQ7KDX.js} +9 -4
  9. package/dist/{chunk-NVPVDDQZ.js → chunk-QJ5FH5DP.js} +14 -10
  10. package/dist/{chunk-H774GQJW.js → chunk-RYIREJAW.js} +234 -40
  11. package/dist/{chunk-AA4G4DGK.js → chunk-W4PUAODY.js} +34 -44
  12. package/dist/{chunk-43UFGATL.js → chunk-WGAAQASA.js} +31 -9
  13. package/dist/{chunk-6VDCH5ML.js → chunk-X5YCWKNS.js} +4 -4
  14. package/dist/cli/dev.js +1 -1
  15. package/dist/cli/index.js +1 -1
  16. package/dist/{client-KRFGMNGN.js → client-LAKW7TA5.js} +3 -3
  17. package/dist/{compactor-Q33AJPCQ.js → compactor-I3N56PSJ.js} +4 -4
  18. package/dist/{config-GMQUPNBY.js → config-EUMVEFHU.js} +2 -2
  19. package/dist/{orchestrator-AHCSLBB3.js → orchestrator-OIBLY5QJ.js} +14 -14
  20. package/dist/package.json +6 -1
  21. package/dist/{processor-45VWLZIV.js → processor-27VCKRGB.js} +13 -12
  22. package/dist/protocol-Cq66hdDX.d.ts +375 -0
  23. package/dist/provider/index.d.ts +129 -0
  24. package/dist/provider/index.js +1 -0
  25. package/dist/{provider-LBYBC5AG.js → provider-GYOW4OWQ.js} +7 -9
  26. package/dist/{provider-manager-ABEUYU3K.js → provider-manager-HRHNF73A.js} +4 -5
  27. package/dist/{serve-V44O2QE6.js → serve-HB222ARV.js} +15 -16
  28. package/dist/server/index.d.ts +5 -87
  29. package/dist/server/index.js +12 -13
  30. package/dist/{server-JDB2QVKP.js → server-XDC7R2IX.js} +10 -14
  31. package/dist/shared/index.d.ts +3 -2
  32. package/dist/{tools-7QUMO5DJ.js → tools-W2FFSF4N.js} +7 -7
  33. package/dist/types-CDZakn7f.d.ts +89 -0
  34. package/dist/{protocol-J7khRG62.d.ts → types-akHmgvBk.d.ts} +17 -373
  35. package/dist/web/assets/{index-BGkyTfuQ.css → index-DvPmgi8F.css} +1 -1
  36. package/dist/web/assets/{index-CETZPQXr.js → index-bSaZSLjg.js} +74 -73
  37. package/dist/web/index.html +2 -2
  38. package/dist/web/sw.js +1 -1
  39. package/package.json +6 -1
  40. package/dist/chunk-M3RB4IF6.js +0 -114
package/README.md CHANGED
@@ -81,6 +81,20 @@ openfox provider remove # Remove provider
81
81
  - **LSP Integration**: Immediate feedback on code validity
82
82
  - **Real-Time Metrics**: Prefill time, generation speed, context usage
83
83
 
84
+ ## Plugins
85
+
86
+ OpenFox supports provider plugins loaded from the `plugins` directory inside its configuration folder. Plugins can add authentication methods, transports, provider presets, and model discovery without adding provider-specific code to the OpenFox core.
87
+
88
+ Default plugin directories:
89
+
90
+ - macOS: `~/Library/Application Support/openfox/plugins`
91
+ - Linux: `${XDG_CONFIG_HOME:-~/.config}/openfox/plugins`
92
+ - Windows: `%APPDATA%\openfox\plugins`
93
+
94
+ Restart OpenFox after installing or updating a plugin.
95
+
96
+ To authenticate with a ChatGPT Plus or Pro account, you can install the [`openfox-chatgpt`](https://github.com/arthurlacoste/openfox-chatgpt) plugin.
97
+
84
98
  ## Screenshots
85
99
 
86
100
  _Homepage — Project overview and session history_
@@ -2,15 +2,20 @@ import {
2
2
  buildRunChatTurnParams,
3
3
  finalizeTurnCompletion,
4
4
  generateSessionNameForSession
5
- } from "./chunk-NVPVDDQZ.js";
5
+ } from "./chunk-QJ5FH5DP.js";
6
6
  import {
7
7
  runChatTurn
8
- } from "./chunk-ZHSCXD75.js";
9
- import "./chunk-KX4C5Q5J.js";
8
+ } from "./chunk-IVJYQZSN.js";
9
+ import "./chunk-5OPZLQDV.js";
10
+ import "./chunk-X5YCWKNS.js";
10
11
  import "./chunk-LBGHZLLH.js";
11
12
  import "./chunk-BGTEIA2S.js";
12
13
  import "./chunk-PK2RMVMB.js";
13
14
  import "./chunk-NWO6GRYE.js";
15
+ import {
16
+ getEventStore
17
+ } from "./chunk-AIJE3RYH.js";
18
+ import "./chunk-TMUBLQFC.js";
14
19
  import {
15
20
  createChatMessageMessage,
16
21
  createPhaseChangedMessage,
@@ -19,20 +24,15 @@ import {
19
24
  import "./chunk-EU3WWTFH.js";
20
25
  import "./chunk-SVSKQYFH.js";
21
26
  import "./chunk-YQ3SOPBI.js";
22
- import "./chunk-6VDCH5ML.js";
23
- import {
24
- getEventStore
25
- } from "./chunk-AIJE3RYH.js";
26
- import "./chunk-TMUBLQFC.js";
27
27
  import "./chunk-ZPIZLTWU.js";
28
28
  import "./chunk-J2GP3J3X.js";
29
+ import "./chunk-V4IE7HJY.js";
29
30
  import "./chunk-YHEQTVFV.js";
30
31
  import "./chunk-Z6W4YHJB.js";
31
32
  import "./chunk-K44MW7JJ.js";
32
33
  import "./chunk-YD6NDTKF.js";
33
- import "./chunk-43UFGATL.js";
34
+ import "./chunk-WGAAQASA.js";
34
35
  import "./chunk-CQGTEGKL.js";
35
- import "./chunk-V4IE7HJY.js";
36
36
  import "./chunk-5WRI5ZAA.js";
37
37
 
38
38
  // src/server/session/chat-handler.ts
@@ -154,4 +154,4 @@ export {
154
154
  startChatSession,
155
155
  stopSessionExecution
156
156
  };
157
- //# sourceMappingURL=chat-handler-6DRGMDXZ.js.map
157
+ //# sourceMappingURL=chat-handler-WNARPARQ.js.map
@@ -1,3 +1,16 @@
1
+ import {
2
+ COMPACTION_PROMPT,
3
+ TurnMetrics,
4
+ buildBasePrompt,
5
+ computeEffectiveTools,
6
+ consumeStreamGenerator,
7
+ createChatDoneEvent,
8
+ createMessageDoneEvent,
9
+ createMessageStartEvent,
10
+ createToolCallEvent,
11
+ createToolResultEvent,
12
+ streamLLMPure
13
+ } from "./chunk-X5YCWKNS.js";
1
14
  import {
2
15
  startInspectProxy
3
16
  } from "./chunk-LBGHZLLH.js";
@@ -18,6 +31,22 @@ import {
18
31
  import {
19
32
  createMcpTools
20
33
  } from "./chunk-NWO6GRYE.js";
34
+ import {
35
+ getCurrentContextWindowId,
36
+ getCurrentWindowMessageOptions,
37
+ getEventStore,
38
+ getRuntimeConfig
39
+ } from "./chunk-AIJE3RYH.js";
40
+ import {
41
+ buildContextMessagesFromEventHistory,
42
+ foldContextState,
43
+ handleMessageDelta,
44
+ handleMessageThinking,
45
+ handleToolCall,
46
+ handleToolResult,
47
+ reorderToolMessages,
48
+ stripOrphanedToolCalls
49
+ } from "./chunk-TMUBLQFC.js";
21
50
  import {
22
51
  createChatDoneMessage,
23
52
  createChatMessageMessage,
@@ -39,48 +68,18 @@ import {
39
68
  getProject
40
69
  } from "./chunk-YQ3SOPBI.js";
41
70
  import {
42
- COMPACTION_PROMPT,
43
- TurnMetrics,
44
- buildBasePrompt,
45
- buildTopLevelSystemPrompt,
46
- computeEffectiveTools,
47
- consumeStreamGenerator,
48
- createChatDoneEvent,
49
- createMessageDoneEvent,
50
- createMessageStartEvent,
51
- createToolCallEvent,
52
- createToolResultEvent,
53
- streamLLMPure
54
- } from "./chunk-6VDCH5ML.js";
55
- import {
56
- getCurrentContextWindowId,
57
- getCurrentWindowMessageOptions,
58
- getEventStore,
59
- getRuntimeConfig
60
- } from "./chunk-AIJE3RYH.js";
61
- import {
62
- buildContextMessagesFromEventHistory,
63
- foldContextState,
64
- handleMessageDelta,
65
- handleMessageThinking,
66
- handleToolCall,
67
- handleToolResult,
68
- reorderToolMessages,
69
- stripOrphanedToolCalls
70
- } from "./chunk-TMUBLQFC.js";
71
+ modelSupportsVision
72
+ } from "./chunk-V4IE7HJY.js";
71
73
  import {
72
74
  logger
73
75
  } from "./chunk-K44MW7JJ.js";
74
76
  import {
75
77
  loadGlobalConfig,
76
78
  saveGlobalConfig
77
- } from "./chunk-43UFGATL.js";
79
+ } from "./chunk-WGAAQASA.js";
78
80
  import {
79
81
  getGlobalConfigDir
80
82
  } from "./chunk-CQGTEGKL.js";
81
- import {
82
- modelSupportsVision
83
- } from "./chunk-V4IE7HJY.js";
84
83
 
85
84
  // src/server/tools/read.ts
86
85
  import { readFile as readFile2, stat, readdir } from "fs/promises";
@@ -91,8 +90,11 @@ var OUTPUT_LIMITS = {
91
90
  read_file: {
92
91
  maxLines: 2e3,
93
92
  maxBytes: 1e5,
94
- maxImageBytes: 2097152
93
+ maxImageBytes: 2097152,
95
94
  // 2MB for images
95
+ maxPdfPages: 50,
96
+ maxFileBytes: 20971520
97
+ // 20MB general file safety limit
96
98
  },
97
99
  run_command: {
98
100
  maxLines: 2e3,
@@ -224,7 +226,7 @@ function looksLikeRegex(str) {
224
226
  return /[*?+[\]\\]/.test(str);
225
227
  }
226
228
  function isPlaceholderToken(str) {
227
- return str.includes("__URL__") || str.includes("__FILEURL__") || str.includes("__SED__");
229
+ return str.includes("__URL__") || str.includes("__FILEURL__") || str.includes("__SED__") || str.includes("__COMMIT_MSG__");
228
230
  }
229
231
  function extractAbsolutePathsFromCommand(command) {
230
232
  if (!command.trim()) {
@@ -236,6 +238,10 @@ function extractAbsolutePathsFromCommand(command) {
236
238
  sanitized = sanitized.replace(/s\/[^/]*\/[^/]*\/[gip]*/g, " __SED__ ");
237
239
  sanitized = sanitized.replace(/s\|[^|]*\|[^|]*\|[gip]*/g, " __SED__ ");
238
240
  sanitized = sanitized.replace(/s:[^:]*:[^:]*:[gip]*/g, " __SED__ ");
241
+ sanitized = sanitized.replace(
242
+ /git\s+commit\b.*?(?:-(?:[a-zA-Z]*m)(?=\s)|--message)\s+(["'])(?:(?!\1).)*\1/g,
243
+ (match2) => match2.replace(/\/[^\s"'|&;<>`()]+/g, " __COMMIT_MSG__ ")
244
+ );
239
245
  const fileUrlMatches = command.matchAll(/file:\/\/([^\s'"]+)/g);
240
246
  for (const match2 of fileUrlMatches) {
241
247
  const filePath = match2[1];
@@ -816,6 +822,67 @@ function stringToUtf32(str, littleEndian) {
816
822
 
817
823
  // src/server/tools/read.ts
818
824
  import { fileTypeFromBuffer } from "file-type";
825
+
826
+ // src/server/tools/pdf-utils.ts
827
+ import { getDocument } from "pdfjs-dist/legacy/build/pdf.mjs";
828
+ var PDF_HEADER = Buffer.from("%PDF");
829
+ function isPdfBuffer(buffer) {
830
+ return buffer.length > 4 && buffer.subarray(0, 4).equals(PDF_HEADER);
831
+ }
832
+ function isPasswordError(err) {
833
+ const message = err instanceof Error ? err.message : String(err);
834
+ return message.toLowerCase().includes("password") || message.toLowerCase().includes("encrypt");
835
+ }
836
+ function formatPdfErrorMessage(err) {
837
+ if (isPasswordError(err)) {
838
+ return "This PDF is password-protected. Unlock it with an external tool first.";
839
+ }
840
+ return `Failed to read PDF: ${err instanceof Error ? err.message : String(err)}`;
841
+ }
842
+ function processPdfContent(text, maxBytes) {
843
+ let output = text;
844
+ let truncated = false;
845
+ if (output.length > maxBytes) {
846
+ output = output.slice(0, maxBytes) + "\n\n[Output truncated due to size limit]";
847
+ truncated = true;
848
+ }
849
+ const isScanned = output.replace(/\[Page \d+\/\d+\]\n/g, "").trim().length === 0;
850
+ return { output, truncated, isScanned };
851
+ }
852
+ async function extractPdfText(buffer) {
853
+ const doc = await getDocument({ data: Uint8Array.from(buffer) }).promise;
854
+ const pageCount = doc.numPages;
855
+ const rawMeta = await doc.getMetadata();
856
+ const info = rawMeta.info;
857
+ const title = info?.["Title"] || null;
858
+ const author = info?.["Author"] || null;
859
+ const pages = [];
860
+ const limitedPageCount = Math.min(pageCount, OUTPUT_LIMITS.read_file.maxPdfPages);
861
+ try {
862
+ for (let i = 1; i <= limitedPageCount; i++) {
863
+ const page = await doc.getPage(i);
864
+ try {
865
+ const content = await page.getTextContent();
866
+ const pageText = content.items.map((item) => "str" in item ? item.str : "").join(" ");
867
+ pages.push(`[Page ${i}/${pageCount}]
868
+ ${pageText}`);
869
+ } finally {
870
+ page.cleanup();
871
+ }
872
+ }
873
+ } finally {
874
+ doc.cleanup();
875
+ }
876
+ let text = pages.join("\n\n");
877
+ if (pageCount > limitedPageCount) {
878
+ text += `
879
+
880
+ [PDF has ${pageCount} pages, showing first ${limitedPageCount}. Use a shell command to process more.]`;
881
+ }
882
+ return { text, pageCount, title, author };
883
+ }
884
+
885
+ // src/server/tools/read.ts
819
886
  async function detectImageType(buffer, filePath) {
820
887
  const fileType = await fileTypeFromBuffer(buffer);
821
888
  const imageMimeTypes = ["image/png", "image/jpeg", "image/gif", "image/webp", "image/bmp", "image/svg+xml"];
@@ -869,7 +936,7 @@ var readFileTool = createTool(
869
936
  type: "function",
870
937
  function: {
871
938
  name: "read_file",
872
- description: "Read the contents of a file or list directory contents. For text files: returns file content. For images (PNG, JPEG, GIF, WebP, BMP, SVG): returns base64-encoded data with MIME type metadata. For directories: returns a tree-formatted listing of entries with file sizes.",
939
+ description: "Read the contents of a file or list directory contents. For text files: returns file content. For images (PNG, JPEG, GIF, WebP, BMP, SVG): returns base64-encoded data with MIME type metadata. For PDF files: extracts text content page by page. For directories: returns a tree-formatted listing of entries with file sizes.",
873
940
  parameters: {
874
941
  type: "object",
875
942
  properties: {
@@ -901,6 +968,11 @@ var readFileTool = createTool(
901
968
  const listing = await listDirectory(fullPath, args.path);
902
969
  return helpers.success(listing);
903
970
  }
971
+ if (stats.size > OUTPUT_LIMITS.read_file.maxFileBytes) {
972
+ return helpers.error(
973
+ `File size (${stats.size} bytes) exceeds maximum file size (20MB). Use shell command to process large files.`
974
+ );
975
+ }
904
976
  if (stats.size > OUTPUT_LIMITS.read_file.maxImageBytes) {
905
977
  return helpers.error(
906
978
  `File size (${stats.size} bytes) exceeds image size limit (2MB). Use shell command to process large files.`
@@ -928,6 +1000,42 @@ var readFileTool = createTool(
928
1000
  }
929
1001
  });
930
1002
  }
1003
+ if (isPdfBuffer(rawBuffer)) {
1004
+ try {
1005
+ const { text, pageCount, title, author } = await extractPdfText(rawBuffer);
1006
+ const { output: output2, truncated: truncated2, isScanned } = processPdfContent(text, OUTPUT_LIMITS.read_file.maxBytes);
1007
+ const contentHash3 = await computeFileHash(fullPath);
1008
+ if (contentHash3) {
1009
+ context.sessionManager.recordFileRead(context.sessionId, fullPath, contentHash3);
1010
+ }
1011
+ if (isScanned) {
1012
+ return helpers.success(
1013
+ `[PDF: ${args.path} \u2014 This PDF has no text layer (scanned or image-only). Use a shell command with OCR to extract text.]`,
1014
+ false,
1015
+ {
1016
+ metadata: {
1017
+ format: "pdf",
1018
+ pageCount,
1019
+ title,
1020
+ author,
1021
+ path: fullPath
1022
+ }
1023
+ }
1024
+ );
1025
+ }
1026
+ return helpers.success(output2, truncated2, {
1027
+ metadata: {
1028
+ format: "pdf",
1029
+ pageCount,
1030
+ title,
1031
+ author,
1032
+ path: fullPath
1033
+ }
1034
+ });
1035
+ } catch (err) {
1036
+ return helpers.error(formatPdfErrorMessage(err));
1037
+ }
1038
+ }
931
1039
  const { encoding, confidence } = detectEncoding(rawBuffer);
932
1040
  const content = decodeContent(rawBuffer, encoding);
933
1041
  const lines = content.split("\n");
@@ -2757,7 +2865,7 @@ ${CONTINUE_PROMPT}` : CONTINUE_PROMPT;
2757
2865
  sessionManager.setCurrentContextSize(sessionId, result.usage.promptTokens);
2758
2866
  if (!compacting) {
2759
2867
  const contextState2 = sessionManager.getContextState(sessionId);
2760
- const { shouldCompact, appendCompactionPrompt } = await import("./compactor-Q33AJPCQ.js");
2868
+ const { shouldCompact, appendCompactionPrompt } = await import("./compactor-I3N56PSJ.js");
2761
2869
  if (shouldCompact(contextState2.currentTokens, contextState2.maxTokens, runtimeConfig.context.compactionThreshold)) {
2762
2870
  appendCompactionPrompt(sessionId, append);
2763
2871
  compacting = true;
@@ -3114,7 +3222,7 @@ async function describeImageFromDataUrl(dataUrl, visionModel, options) {
3114
3222
  import { createHash as createHash2 } from "crypto";
3115
3223
  async function loadVisionModelFromGlobalConfig() {
3116
3224
  try {
3117
- const { loadGlobalConfig: loadGlobalConfig2, getVisionFallback } = await import("./config-GMQUPNBY.js");
3225
+ const { loadGlobalConfig: loadGlobalConfig2, getVisionFallback } = await import("./config-EUMVEFHU.js");
3118
3226
  const runtimeConfig = getRuntimeConfig();
3119
3227
  const mode = runtimeConfig.mode ?? "production";
3120
3228
  const globalConfig = await loadGlobalConfig2(mode);
@@ -3658,7 +3766,7 @@ var callSubAgentTool = {
3658
3766
  };
3659
3767
  }
3660
3768
  try {
3661
- const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-7QUMO5DJ.js");
3769
+ const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-W2FFSF4N.js");
3662
3770
  const toolRegistry = getToolRegistryForAgent2(agentDef);
3663
3771
  const turnMetrics = new TurnMetrics();
3664
3772
  const result = await executeSubAgent({
@@ -3818,7 +3926,7 @@ var webFetchTool = createTool(
3818
3926
  type: "function",
3819
3927
  function: {
3820
3928
  name: "web_fetch",
3821
- description: "Fetch content from a URL and return it as text, markdown, or HTML. Use this to retrieve and analyze web content such as documentation, API references, or web pages.",
3929
+ description: "Fetch content from a URL and return it as text, markdown, or HTML. For PDF URLs, extracts text content page by page. Use this to retrieve and analyze web content such as documentation, API references, or web pages.",
3822
3930
  parameters: {
3823
3931
  type: "object",
3824
3932
  properties: {
@@ -3880,6 +3988,40 @@ var webFetchTool = createTool(
3880
3988
  }
3881
3989
  });
3882
3990
  }
3991
+ const rawBuffer = Buffer.from(arrayBuffer);
3992
+ const isPdfResponse = mime === "application/pdf" || isPdfBuffer(rawBuffer);
3993
+ if (isPdfResponse) {
3994
+ try {
3995
+ const { text, pageCount, title, author } = await extractPdfText(rawBuffer);
3996
+ const { output: output2, truncated: truncated2, isScanned } = processPdfContent(text, OUTPUT_LIMITS.web_fetch.maxBytes);
3997
+ if (isScanned) {
3998
+ return helpers.success(
3999
+ "[PDF: This PDF has no text layer (scanned or image-only). Use an external tool with OCR to extract text.]",
4000
+ false,
4001
+ {
4002
+ metadata: {
4003
+ format: "pdf",
4004
+ pageCount,
4005
+ title,
4006
+ author,
4007
+ url
4008
+ }
4009
+ }
4010
+ );
4011
+ }
4012
+ return helpers.success(output2, truncated2, {
4013
+ metadata: {
4014
+ format: "pdf",
4015
+ pageCount,
4016
+ title,
4017
+ author,
4018
+ url
4019
+ }
4020
+ });
4021
+ } catch (err) {
4022
+ return helpers.error(formatPdfErrorMessage(err));
4023
+ }
4024
+ }
3883
4025
  const rawContent = new TextDecoder().decode(arrayBuffer);
3884
4026
  let output;
3885
4027
  switch (format) {
@@ -4446,64 +4588,6 @@ These processes run independently of agent turns and persist across session comp
4446
4588
  }
4447
4589
  );
4448
4590
 
4449
- // src/server/chat/dynamic-context.ts
4450
- import { createHash as createHash3 } from "crypto";
4451
- function computeDynamicContextHash(instructionContent, skills, toolFingerprint) {
4452
- const dynamicInputs = JSON.stringify({
4453
- instructions: instructionContent,
4454
- skills: skills.map((s) => s.id).sort(),
4455
- ...toolFingerprint ? { tools: toolFingerprint } : {}
4456
- });
4457
- return createHash3("sha256").update(dynamicInputs).digest("hex");
4458
- }
4459
- function getToolFingerprint(tools) {
4460
- return tools.map((t) => `${t.function.name}:${JSON.stringify(t.function.parameters)}`).sort().join("|");
4461
- }
4462
- async function loadSessionContext(sessionManager, sessionId) {
4463
- const session = sessionManager.requireSession(sessionId);
4464
- const { content: instructionContent } = await getAllInstructions(session.workdir, session.projectId);
4465
- const runtimeConfig = getRuntimeConfig();
4466
- const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
4467
- const skills = await getEnabledSkillMetadata(configDir, runtimeConfig.workdir);
4468
- return { instructionContent: instructionContent ?? "", skills };
4469
- }
4470
- function resolveAgentDef2(sessionManager, sessionId) {
4471
- return loadAllAgentsDefault().then((allAgents) => {
4472
- const session = sessionManager.requireSession(sessionId);
4473
- return findAgentById(session.mode, allAgents) ?? findAgentById("planner", allAgents);
4474
- });
4475
- }
4476
- async function buildCachedPrompt(sessionManager, sessionId, agentDef) {
4477
- const { instructionContent, skills } = await loadSessionContext(sessionManager, sessionId);
4478
- const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-7QUMO5DJ.js");
4479
- const tools = getToolRegistryForAgent2(agentDef).definitions;
4480
- const toolFingerprint = getToolFingerprint(tools);
4481
- const allAgents = await loadAllAgentsDefault();
4482
- const subAgentDefs = getSubAgents(allAgents);
4483
- const session = sessionManager.requireSession(sessionId);
4484
- const systemPrompt = buildTopLevelSystemPrompt(session.workdir, instructionContent || void 0, skills, subAgentDefs);
4485
- const hash = computeDynamicContextHash(instructionContent, skills, toolFingerprint);
4486
- return { systemPrompt, tools, hash };
4487
- }
4488
- async function computeSessionHash(sessionManager, sessionId) {
4489
- const { instructionContent, skills } = await loadSessionContext(sessionManager, sessionId);
4490
- const agentDef = await resolveAgentDef2(sessionManager, sessionId);
4491
- const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-7QUMO5DJ.js");
4492
- const tools = getToolRegistryForAgent2(agentDef).definitions;
4493
- const toolFingerprint = getToolFingerprint(tools);
4494
- return computeDynamicContextHash(instructionContent, skills, toolFingerprint);
4495
- }
4496
- async function applyDynamicContext(sessionManager, sessionId) {
4497
- const session = sessionManager.requireSession(sessionId);
4498
- const allAgents = await loadAllAgentsDefault();
4499
- const agentDef = findAgentById(session.mode, allAgents) ?? findAgentById("planner", allAgents);
4500
- const { systemPrompt, tools, hash } = await buildCachedPrompt(sessionManager, sessionId, agentDef);
4501
- sessionManager.setCachedPrompt(sessionId, systemPrompt, tools, hash);
4502
- sessionManager.setDynamicContextChanged(sessionId, false);
4503
- sessionManager.clearDebugDump(sessionId);
4504
- logger.debug("applyDynamicContext done", { sessionId, hash, toolCount: tools.length });
4505
- }
4506
-
4507
4591
  // src/server/tools/mcp-config.ts
4508
4592
  var mcpManagerForTools = null;
4509
4593
  var mcpConfigMode = "production";
@@ -4598,8 +4682,13 @@ var mcpConfigTool = createTool(
4598
4682
  const updated = updater(mcpServers);
4599
4683
  await saveGlobalConfig(mcpConfigMode, { ...globalConfig, mcpServers: updated }, mcpConfigPath);
4600
4684
  }
4685
+ const APPLY_PROMPT_MESSAGE = 'The user must click "Update system prompt" to apply changes.';
4686
+ function notifyContextChanged(sessionId) {
4687
+ context.sessionManager.setDynamicContextChanged(sessionId, true);
4688
+ mcpNotifyChanged?.(sessionId);
4689
+ }
4601
4690
  async function rebuildTools() {
4602
- const { setMcpTools: setMcpTools2 } = await import("./tools-7QUMO5DJ.js");
4691
+ const { setMcpTools: setMcpTools2 } = await import("./tools-W2FFSF4N.js");
4603
4692
  const mcpTools = createMcpTools(mcpManagerForTools);
4604
4693
  setMcpTools2(mcpTools);
4605
4694
  }
@@ -4650,11 +4739,10 @@ var mcpConfigTool = createTool(
4650
4739
  });
4651
4740
  await mcpManagerForTools.addServer(args.name, serverCfg);
4652
4741
  await rebuildTools();
4653
- await applyDynamicContext(context.sessionManager, context.sessionId);
4654
- mcpNotifyChanged?.(context.sessionId);
4742
+ notifyContextChanged(context.sessionId);
4655
4743
  const server = mcpManagerForTools.getServer(args.name);
4656
4744
  const toolCount = server?.tools.length ?? 0;
4657
- return helpers.success(`Added MCP server "${args.name}" (${toolCount} tools discovered).`);
4745
+ return helpers.success(`Added MCP server "${args.name}" (${toolCount} tools discovered). ${APPLY_PROMPT_MESSAGE}`);
4658
4746
  }
4659
4747
  if (args.action === "remove") {
4660
4748
  if (!args.name) return helpers.error("Missing required field: name");
@@ -4664,9 +4752,8 @@ var mcpConfigTool = createTool(
4664
4752
  });
4665
4753
  mcpManagerForTools.removeServer(args.name);
4666
4754
  await rebuildTools();
4667
- await applyDynamicContext(context.sessionManager, context.sessionId);
4668
- mcpNotifyChanged?.(context.sessionId);
4669
- return helpers.success(`Removed MCP server "${args.name}".`);
4755
+ notifyContextChanged(context.sessionId);
4756
+ return helpers.success(`Removed MCP server "${args.name}". ${APPLY_PROMPT_MESSAGE}`);
4670
4757
  }
4671
4758
  if (args.action === "toggle-tool") {
4672
4759
  if (!args.name) return helpers.error("Missing required field: name");
@@ -4690,10 +4777,9 @@ var mcpConfigTool = createTool(
4690
4777
  });
4691
4778
  await mcpManagerForTools.setToolEnabled(args.name, args.toolName, args.enabled);
4692
4779
  await rebuildTools();
4693
- await applyDynamicContext(context.sessionManager, context.sessionId);
4694
- mcpNotifyChanged?.(context.sessionId);
4780
+ notifyContextChanged(context.sessionId);
4695
4781
  return helpers.success(
4696
- `Tool "${args.toolName}" ${args.enabled ? "enabled" : "disabled"} on server "${args.name}".`
4782
+ `Tool "${args.toolName}" ${args.enabled ? "enabled" : "disabled"} on server "${args.name}". ${APPLY_PROMPT_MESSAGE}`
4697
4783
  );
4698
4784
  }
4699
4785
  return helpers.error("Unexpected error");
@@ -5362,6 +5448,7 @@ export {
5362
5448
  getDefaultAgentIds,
5363
5449
  isDefaultAgent,
5364
5450
  findAgentById,
5451
+ getSubAgents,
5365
5452
  getTopLevelAgents,
5366
5453
  agentExists,
5367
5454
  saveAgent,
@@ -5392,11 +5479,6 @@ export {
5392
5479
  executeSubAgent,
5393
5480
  devServerManager,
5394
5481
  stepDoneTool,
5395
- computeDynamicContextHash,
5396
- getToolFingerprint,
5397
- buildCachedPrompt,
5398
- computeSessionHash,
5399
- applyDynamicContext,
5400
5482
  setMcpManagerForTools,
5401
5483
  setMcpConfigMode,
5402
5484
  setMcpConfigPath,
@@ -5410,4 +5492,4 @@ export {
5410
5492
  getToolRegistryForAgent,
5411
5493
  createToolRegistry
5412
5494
  };
5413
- //# sourceMappingURL=chunk-KX4C5Q5J.js.map
5495
+ //# sourceMappingURL=chunk-5OPZLQDV.js.map
@@ -39,7 +39,7 @@ Options:
39
39
  }
40
40
  async function runNetworkSetup(mode) {
41
41
  const { loadAuthConfig, saveAuthConfig, encryptPassword } = await import("./auth-YY5PJYSC.js");
42
- const { saveGlobalConfig } = await import("./config-GMQUPNBY.js");
42
+ const { saveGlobalConfig } = await import("./config-EUMVEFHU.js");
43
43
  const { getAuthKeyPath } = await import("./paths-F27V3S4I.js");
44
44
  const existingAuth = await loadAuthConfig(mode);
45
45
  if (existingAuth) {
@@ -106,7 +106,7 @@ async function runNetworkSetup(mode) {
106
106
  console.log("\u2713 Configuration saved!\n");
107
107
  }
108
108
  async function runConfig(mode) {
109
- const { loadGlobalConfig, getActiveProvider, getDefaultModel } = await import("./config-GMQUPNBY.js");
109
+ const { loadGlobalConfig, getActiveProvider, getDefaultModel } = await import("./config-EUMVEFHU.js");
110
110
  const { getGlobalConfigPath } = await import("./paths-F27V3S4I.js");
111
111
  const config = await loadGlobalConfig(mode);
112
112
  const configPath = getGlobalConfigPath(mode);
@@ -164,7 +164,7 @@ async function runCli(options) {
164
164
  break;
165
165
  }
166
166
  case "provider": {
167
- const { runProviderCommand } = await import("./provider-LBYBC5AG.js");
167
+ const { runProviderCommand } = await import("./provider-GYOW4OWQ.js");
168
168
  const [, subcommand] = positionals;
169
169
  await runProviderCommand(mode, subcommand);
170
170
  break;
@@ -203,12 +203,12 @@ async function runCli(options) {
203
203
  break;
204
204
  }
205
205
  default: {
206
- const { configFileExists } = await import("./config-GMQUPNBY.js");
206
+ const { configFileExists } = await import("./config-EUMVEFHU.js");
207
207
  const configExists = await configFileExists(mode);
208
208
  if (!configExists) {
209
209
  await runNetworkSetup(mode);
210
210
  }
211
- const { runServe } = await import("./serve-V44O2QE6.js");
211
+ const { runServe } = await import("./serve-HB222ARV.js");
212
212
  const serveOptions = { mode };
213
213
  if (values.port) serveOptions.port = parseInt(values.port);
214
214
  if (values["no-browser"] === true) serveOptions.openBrowser = false;
@@ -220,4 +220,4 @@ async function runCli(options) {
220
220
  export {
221
221
  runCli
222
222
  };
223
- //# sourceMappingURL=chunk-S5DWUGKZ.js.map
223
+ //# sourceMappingURL=chunk-FGG4KRFX.js.map