openfox 2.0.14 → 2.0.16

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 (30) hide show
  1. package/dist/{chat-handler-ITXCBFJK.js → chat-handler-PC6OVDUR.js} +8 -6
  2. package/dist/{chunk-7GJ6XYAF.js → chunk-63UEI4AF.js} +20 -16
  3. package/dist/{chunk-4U45A7B3.js → chunk-DQ6SV26Y.js} +111 -45
  4. package/dist/{chunk-3QB2RMX2.js → chunk-F4PMNP7S.js} +2 -2
  5. package/dist/{chunk-TIKQWNYK.js → chunk-J7KOV4ST.js} +2 -2
  6. package/dist/{chunk-4ZTQO5JP.js → chunk-JO6RF2U2.js} +463 -15
  7. package/dist/{chunk-LNEBVOH6.js → chunk-OUK5IW26.js} +6 -6
  8. package/dist/{chunk-PP6VQXQW.js → chunk-SNQT7LNU.js} +2 -1
  9. package/dist/{chunk-4W2Z4B5U.js → chunk-WOTBK3QQ.js} +36 -41
  10. package/dist/{chunk-5BDVM6YI.js → chunk-YD6NDTKF.js} +1 -1
  11. package/dist/cli/dev.js +1 -1
  12. package/dist/cli/index.js +1 -1
  13. package/dist/{config-YFHA5MWV.js → config-Z66BQTNX.js} +2 -2
  14. package/dist/{orchestrator-VP74KOXI.js → orchestrator-3SB2BMQ7.js} +7 -5
  15. package/dist/package.json +3 -2
  16. package/dist/{processor-CCXZYLX6.js → processor-KWPYXPL7.js} +8 -6
  17. package/dist/{protocol-BE5dRtYw.d.ts → protocol-BC1QSQ-Y.d.ts} +7 -1
  18. package/dist/{protocol-YYWMFR35.js → protocol-BKNLAEPJ.js} +3 -3
  19. package/dist/{provider-QUJQLVOM.js → provider-YBTRC77Y.js} +3 -3
  20. package/dist/{serve-GA2UIHHB.js → serve-HZXJXK6T.js} +9 -9
  21. package/dist/server/index.d.ts +19 -1
  22. package/dist/server/index.js +8 -7
  23. package/dist/{server-EA6W7YIC.js → server-RYKKAOFF.js} +10 -8
  24. package/dist/shared/index.d.ts +2 -2
  25. package/dist/shared/index.js +1 -1
  26. package/dist/{tools-DUC54GEH.js → tools-Y7ZGLK7A.js} +6 -4
  27. package/dist/web/assets/{index-D0qVcBva.js → index-BMz5-yAf.js} +31 -31
  28. package/dist/web/index.html +1 -1
  29. package/dist/web/sw.js +1 -1
  30. package/package.json +3 -2
@@ -5,16 +5,17 @@ import {
5
5
  generateSessionName,
6
6
  getSessionMessageCount,
7
7
  needsNameGenerationCheck
8
- } from "./chunk-TIKQWNYK.js";
8
+ } from "./chunk-J7KOV4ST.js";
9
9
  import {
10
10
  runChatTurn
11
- } from "./chunk-7GJ6XYAF.js";
12
- import "./chunk-4ZTQO5JP.js";
11
+ } from "./chunk-63UEI4AF.js";
12
+ import "./chunk-JO6RF2U2.js";
13
13
  import "./chunk-XAMAYRDA.js";
14
14
  import "./chunk-L7TDUIQY.js";
15
15
  import "./chunk-DL6ZILAF.js";
16
16
  import "./chunk-PBGOZMVY.js";
17
17
  import "./chunk-VRGRAQDG.js";
18
+ import "./chunk-NWO6GRYE.js";
18
19
  import {
19
20
  getEventStore
20
21
  } from "./chunk-SYG2ENUQ.js";
@@ -23,11 +24,12 @@ import {
23
24
  createChatMessageMessage,
24
25
  createPhaseChangedMessage,
25
26
  createSessionRunningMessage
26
- } from "./chunk-3QB2RMX2.js";
27
+ } from "./chunk-F4PMNP7S.js";
27
28
  import "./chunk-EU3WWTFH.js";
28
29
  import "./chunk-RFNEDBVO.js";
29
30
  import "./chunk-FBGWG4N6.js";
30
- import "./chunk-5BDVM6YI.js";
31
+ import "./chunk-YD6NDTKF.js";
32
+ import "./chunk-SNQT7LNU.js";
31
33
  import "./chunk-CQGTEGKL.js";
32
34
  import "./chunk-Z4SWOUWC.js";
33
35
  import {
@@ -162,4 +164,4 @@ export {
162
164
  startChatSession,
163
165
  stopSessionExecution
164
166
  };
165
- //# sourceMappingURL=chat-handler-ITXCBFJK.js.map
167
+ //# sourceMappingURL=chat-handler-PC6OVDUR.js.map
@@ -1,17 +1,20 @@
1
1
  import {
2
2
  PathAccessDeniedError,
3
3
  assembleAgentRequest,
4
+ computeDynamicContextHash,
4
5
  createAssemblyResult,
6
+ createToolRegistry,
5
7
  findAgentById,
6
8
  getAllInstructions,
7
9
  getConversationMessages,
8
10
  getEnabledSkillMetadata,
9
11
  getSubAgents,
12
+ getToolFingerprint,
10
13
  getToolRegistryForAgent,
11
14
  loadAllAgentsDefault,
12
15
  processEventsForConversation,
13
16
  runTopLevelAgentLoop
14
- } from "./chunk-4ZTQO5JP.js";
17
+ } from "./chunk-JO6RF2U2.js";
15
18
  import {
16
19
  TurnMetrics,
17
20
  WORKFLOW_KICKOFF_PROMPT,
@@ -36,17 +39,6 @@ import {
36
39
  logger
37
40
  } from "./chunk-K44MW7JJ.js";
38
41
 
39
- // src/server/chat/dynamic-context.ts
40
- import { createHash } from "crypto";
41
- function computeDynamicContextHash(instructionContent, skills, toolFingerprint) {
42
- const dynamicInputs = JSON.stringify({
43
- instructions: instructionContent,
44
- skills: skills.map((s) => s.id).sort(),
45
- ...toolFingerprint ? { tools: toolFingerprint } : {}
46
- });
47
- return createHash("sha256").update(dynamicInputs).digest("hex");
48
- }
49
-
50
42
  // src/server/chat/orchestrator.ts
51
43
  async function buildRetryPatterns() {
52
44
  const { getSetting, SETTINGS_KEYS } = await import("./settings-6XX56F3F.js");
@@ -238,17 +230,30 @@ async function runAgentTurn(options, turnMetrics, agentId, append, callbacks) {
238
230
  onMessage: options.onMessage,
239
231
  assembleRequest: (input) => {
240
232
  const cached = options.sessionManager.getCachedPrompt(options.sessionId);
241
- const toolFingerprint = input.promptTools.map((t) => `${t.function.name}:${JSON.stringify(t.function.parameters)}`).sort().join("|");
233
+ const liveTools = createToolRegistry().definitions;
234
+ const toolFingerprint = getToolFingerprint(liveTools);
242
235
  if (cached) {
243
236
  const currentHash = computeDynamicContextHash(instructionContent ?? "", skills, toolFingerprint);
244
237
  if (cached.hash !== currentHash) {
238
+ logger.debug("assembleRequest: hash mismatch", {
239
+ sessionId: options.sessionId,
240
+ cachedHash: cached.hash,
241
+ currentHash,
242
+ cachedTools: cached.tools.map((t) => t.function.name),
243
+ liveTools: liveTools.map((t) => t.function.name)
244
+ });
245
245
  options.sessionManager.setDynamicContextChanged(options.sessionId, true);
246
+ options.sessionManager.setDebugDump(options.sessionId, {
247
+ cachedPrompt: cached.systemPrompt.slice(0, 5e3),
248
+ cachedTools: cached.tools.map((t) => t.function.name),
249
+ liveTools: liveTools.map((t) => t.function.name)
250
+ });
246
251
  }
247
252
  return createAssemblyResult({
248
253
  systemPrompt: cached.systemPrompt,
249
254
  messages: input.messages,
250
255
  injectedFiles: input.injectedFiles,
251
- requestTools: cached.tools.length > 0 ? cached.tools : input.promptTools,
256
+ requestTools: cached.tools.length > 0 ? cached.tools : liveTools,
252
257
  toolChoice: input.toolChoice
253
258
  });
254
259
  }
@@ -311,9 +316,8 @@ function buildSnapshot(sessionManager, sessionId, _lastStats) {
311
316
  }
312
317
 
313
318
  export {
314
- computeDynamicContextHash,
315
319
  runChatTurn,
316
320
  runAgentTurn,
317
321
  injectWorkflowKickoffIfNeeded
318
322
  };
319
- //# sourceMappingURL=chunk-7GJ6XYAF.js.map
323
+ //# sourceMappingURL=chunk-63UEI4AF.js.map
@@ -21,10 +21,7 @@ import {
21
21
  tokenFromPassword,
22
22
  verifyPassword,
23
23
  workflowExists
24
- } from "./chunk-4W2Z4B5U.js";
25
- import {
26
- createMcpTools
27
- } from "./chunk-NWO6GRYE.js";
24
+ } from "./chunk-WOTBK3QQ.js";
28
25
  import {
29
26
  agentExists,
30
27
  createToolRegistry,
@@ -59,9 +56,12 @@ import {
59
56
  saveItemToDir,
60
57
  saveSkill,
61
58
  saveSkillToProject,
59
+ setMcpConfigMode,
60
+ setMcpManagerForTools,
62
61
  setMcpTools,
62
+ setNotifyMcpServersChanged,
63
63
  skillExists
64
- } from "./chunk-4ZTQO5JP.js";
64
+ } from "./chunk-JO6RF2U2.js";
65
65
  import {
66
66
  getProject
67
67
  } from "./chunk-XAMAYRDA.js";
@@ -69,6 +69,9 @@ import {
69
69
  getPathSeparator,
70
70
  isAbsolutePath
71
71
  } from "./chunk-PBGOZMVY.js";
72
+ import {
73
+ createMcpTools
74
+ } from "./chunk-NWO6GRYE.js";
72
75
  import {
73
76
  createSession,
74
77
  deleteSession,
@@ -94,12 +97,18 @@ import {
94
97
  updateSessionProvider,
95
98
  updateSessionRunning
96
99
  } from "./chunk-SYG2ENUQ.js";
100
+ import {
101
+ createContextStateMessage
102
+ } from "./chunk-F4PMNP7S.js";
97
103
  import {
98
104
  EventEmitter
99
105
  } from "./chunk-EU3WWTFH.js";
100
106
  import {
101
107
  initDatabase
102
108
  } from "./chunk-FBGWG4N6.js";
109
+ import {
110
+ createServerMessage
111
+ } from "./chunk-YD6NDTKF.js";
103
112
  import {
104
113
  getGlobalConfigDir
105
114
  } from "./chunk-CQGTEGKL.js";
@@ -1447,6 +1456,7 @@ function createMockLLMClient() {
1447
1456
  // src/server/mcp/manager.ts
1448
1457
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
1449
1458
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
1459
+ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
1450
1460
  function estimateToolTokens(toolName, description, inputSchema) {
1451
1461
  const def = {
1452
1462
  type: "function",
@@ -1490,10 +1500,18 @@ var McpManager = class {
1490
1500
  ...entry.config.env ? { env: entry.config.env } : {},
1491
1501
  stderr: "pipe"
1492
1502
  });
1493
- await client.connect(transport);
1503
+ } else if (entry.config.transport === "http") {
1504
+ if (!entry.config.url) throw new Error("url is required for http transport");
1505
+ const httpOpts = {};
1506
+ if (entry.config.headers) {
1507
+ httpOpts.requestInit = { headers: entry.config.headers };
1508
+ }
1509
+ transport = new StreamableHTTPClientTransport(new URL(entry.config.url), httpOpts);
1494
1510
  } else {
1495
- throw new Error("Only stdio transport is supported in this version");
1511
+ throw new Error(`Unsupported transport: ${entry.config.transport}`);
1496
1512
  }
1513
+ if (!transport) throw new Error("Failed to create transport");
1514
+ await client.connect(transport);
1497
1515
  const { tools: mcpTools } = await client.listTools();
1498
1516
  const disabledSet = new Set(entry.config.disabledTools ?? []);
1499
1517
  const tools = mcpTools.map((t) => {
@@ -2228,7 +2246,8 @@ var LANGUAGES = [
2228
2246
  extensions: [".sql"],
2229
2247
  serverCommand: "sql-language-server",
2230
2248
  serverArgs: ["up", "--method", "stdio"],
2231
- rootPatterns: []
2249
+ rootPatterns: [],
2250
+ installHint: "npm install -g sql-language-server"
2232
2251
  },
2233
2252
  // GraphQL
2234
2253
  {
@@ -2464,6 +2483,8 @@ var LspManager = class {
2464
2483
  // language ids we've tried and failed
2465
2484
  serverPromises = /* @__PURE__ */ new Map();
2466
2485
  // pending server starts
2486
+ dismissedHints = /* @__PURE__ */ new Set();
2487
+ // hints already shown this session
2467
2488
  constructor(workdir, sessionId) {
2468
2489
  this.workdir = workdir;
2469
2490
  this.sessionId = sessionId;
@@ -2584,6 +2605,22 @@ var LspManager = class {
2584
2605
  }
2585
2606
  return true;
2586
2607
  }
2608
+ /**
2609
+ * Get installation hint for a file's language server, if it's not installed.
2610
+ * Returns the hint once per session; subsequent calls return null
2611
+ * to avoid spamming the user on every edit.
2612
+ */
2613
+ getInstallHint(path) {
2614
+ const config4 = detectLanguage(path);
2615
+ if (!config4?.installHint) {
2616
+ return null;
2617
+ }
2618
+ if (this.unavailableServers.has(config4.id) && !this.dismissedHints.has(config4.id)) {
2619
+ this.dismissedHints.add(config4.id);
2620
+ return config4.installHint;
2621
+ }
2622
+ return null;
2623
+ }
2587
2624
  /**
2588
2625
  * Shutdown all LSP servers.
2589
2626
  */
@@ -2642,6 +2679,7 @@ var SessionManager = class {
2642
2679
  providerManager;
2643
2680
  cachedPromptStore = /* @__PURE__ */ new Map();
2644
2681
  dynamicContextChangedStore = /* @__PURE__ */ new Map();
2682
+ debugDumpStore = /* @__PURE__ */ new Map();
2645
2683
  constructor(providerManager) {
2646
2684
  this.providerManager = providerManager;
2647
2685
  }
@@ -3197,6 +3235,12 @@ var SessionManager = class {
3197
3235
  setDynamicContextChanged(sessionId, changed) {
3198
3236
  this.dynamicContextChangedStore.set(sessionId, changed);
3199
3237
  }
3238
+ setDebugDump(sessionId, dump) {
3239
+ this.debugDumpStore.set(sessionId, dump);
3240
+ }
3241
+ clearDebugDump(sessionId) {
3242
+ this.debugDumpStore.delete(sessionId);
3243
+ }
3200
3244
  getDynamicContextChanged(sessionId) {
3201
3245
  return this.dynamicContextChangedStore.get(sessionId) ?? false;
3202
3246
  }
@@ -3238,6 +3282,7 @@ var SessionManager = class {
3238
3282
  }
3239
3283
  const state = getSessionState(sessionId, maxTokens);
3240
3284
  const dynamicContextChanged = this.getDynamicContextChanged(sessionId);
3285
+ const debugDump = this.debugDumpStore.get(sessionId);
3241
3286
  if (!state) {
3242
3287
  return {
3243
3288
  currentTokens: 0,
@@ -3245,10 +3290,11 @@ var SessionManager = class {
3245
3290
  compactionCount: 0,
3246
3291
  dangerZone: false,
3247
3292
  canCompact: false,
3248
- dynamicContextChanged
3293
+ dynamicContextChanged,
3294
+ ...debugDump ? { debugDump } : {}
3249
3295
  };
3250
3296
  }
3251
- return { ...state.contextState, dynamicContextChanged };
3297
+ return { ...state.contextState, dynamicContextChanged, ...debugDump ? { debugDump } : {} };
3252
3298
  }
3253
3299
  // ============================================================================
3254
3300
  // LSP Manager
@@ -3339,7 +3385,6 @@ var SessionManager = class {
3339
3385
  });
3340
3386
  }
3341
3387
  if (!this.dynamicContextChangedStore.has(dbSession.id) && eventState.contextState.dynamicContextChanged) {
3342
- this.dynamicContextChangedStore.set(dbSession.id, true);
3343
3388
  }
3344
3389
  return {
3345
3390
  ...dbSession,
@@ -3899,7 +3944,7 @@ import { Router as Router6 } from "express";
3899
3944
  import { spawn as spawn2 } from "child_process";
3900
3945
 
3901
3946
  // src/constants.ts
3902
- var VERSION = "2.0.14";
3947
+ var VERSION = "2.0.16";
3903
3948
 
3904
3949
  // src/server/routes/auto-update.ts
3905
3950
  var updateInProgress = false;
@@ -4064,6 +4109,8 @@ async function createServerHandle(config4) {
4064
4109
  );
4065
4110
  const toolRegistry = createToolRegistry();
4066
4111
  const mcpManager = new McpManager();
4112
+ setMcpManagerForTools(mcpManager);
4113
+ setMcpConfigMode(config4.mode ?? "production");
4067
4114
  const mcpServers = config4.mcpServers ?? {};
4068
4115
  Promise.all(
4069
4116
  Object.entries(mcpServers).map(
@@ -4071,12 +4118,14 @@ async function createServerHandle(config4) {
4071
4118
  logger.warn("Failed to connect MCP server on startup", { name, error: String(err) });
4072
4119
  })
4073
4120
  )
4074
- ).then(() => {
4121
+ ).then(async () => {
4075
4122
  const mcpTools = createMcpTools(mcpManager);
4076
4123
  if (mcpTools.length > 0) {
4077
4124
  setMcpTools(mcpTools);
4078
4125
  logger.info("MCP tools registered", { count: mcpTools.length });
4079
4126
  }
4127
+ const { signalMcpReady } = await import("./server-RYKKAOFF.js");
4128
+ signalMcpReady();
4080
4129
  });
4081
4130
  const app = express();
4082
4131
  app.use(cors());
@@ -4266,7 +4315,7 @@ async function createServerHandle(config4) {
4266
4315
  app.get("/api/sessions/:id", async (req, res) => {
4267
4316
  const { getEventStore: getEventStore2 } = await import("./events-4K52FKPR.js");
4268
4317
  const { buildMessagesFromStoredEvents } = await import("./folding-QIBNKYA6.js");
4269
- const { getPendingQuestionsForSession } = await import("./tools-DUC54GEH.js");
4318
+ const { getPendingQuestionsForSession } = await import("./tools-Y7ZGLK7A.js");
4270
4319
  const session = sessionManager.getSession(req.params.id);
4271
4320
  if (!session) {
4272
4321
  return res.status(404).json({ error: "Session not found" });
@@ -4309,7 +4358,7 @@ async function createServerHandle(config4) {
4309
4358
  return res.status(400).json({ error: "providerId is required" });
4310
4359
  }
4311
4360
  sessionManager.setSessionProvider(sessionId, providerId, model ?? "auto");
4312
- const { loadGlobalConfig, saveGlobalConfig, setDefaultModelSelection } = await import("./config-YFHA5MWV.js");
4361
+ const { loadGlobalConfig, saveGlobalConfig, setDefaultModelSelection } = await import("./config-Z66BQTNX.js");
4313
4362
  const globalConfig = await loadGlobalConfig(config4.mode ?? "production");
4314
4363
  const updatedConfig = setDefaultModelSelection(globalConfig, providerId, model ?? "auto");
4315
4364
  await saveGlobalConfig(config4.mode ?? "production", updatedConfig);
@@ -4397,15 +4446,15 @@ async function createServerHandle(config4) {
4397
4446
  if (!callId || approved === void 0) {
4398
4447
  return res.status(400).json({ error: "callId and approved are required" });
4399
4448
  }
4400
- const { providePathConfirmation } = await import("./tools-DUC54GEH.js");
4449
+ const { providePathConfirmation } = await import("./tools-Y7ZGLK7A.js");
4401
4450
  const result = providePathConfirmation(callId, approved, alwaysAllow);
4402
4451
  if (!result.found) {
4403
4452
  return res.status(404).json({ error: "No pending path confirmation with that ID" });
4404
4453
  }
4405
4454
  const { getEventStore: getEventStore2 } = await import("./events-4K52FKPR.js");
4406
4455
  const { buildMessagesFromStoredEvents, foldPendingConfirmations } = await import("./folding-QIBNKYA6.js");
4407
- const { createSessionStateMessage } = await import("./protocol-YYWMFR35.js");
4408
- const { getPendingQuestionsForSession } = await import("./tools-DUC54GEH.js");
4456
+ const { createSessionStateMessage } = await import("./protocol-BKNLAEPJ.js");
4457
+ const { getPendingQuestionsForSession } = await import("./tools-Y7ZGLK7A.js");
4409
4458
  const eventStore = getEventStore2();
4410
4459
  const events = eventStore.getEvents(sessionId);
4411
4460
  const messages = buildMessagesFromStoredEvents(events);
@@ -4426,7 +4475,7 @@ async function createServerHandle(config4) {
4426
4475
  if (!skip && typeof answer !== "string") {
4427
4476
  return res.status(400).json({ error: "answer is required when not skipping" });
4428
4477
  }
4429
- const { provideAnswer } = await import("./tools-DUC54GEH.js");
4478
+ const { provideAnswer } = await import("./tools-Y7ZGLK7A.js");
4430
4479
  const found = provideAnswer(callId, answer ?? "", skip ?? false);
4431
4480
  if (!found) {
4432
4481
  return res.status(404).json({ error: "No pending question with that ID" });
@@ -4462,8 +4511,8 @@ async function createServerHandle(config4) {
4462
4511
  if (!session) {
4463
4512
  return res.status(404).json({ error: "Session not found" });
4464
4513
  }
4465
- const { stopSessionExecution } = await import("./chat-handler-ITXCBFJK.js");
4466
- const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-DUC54GEH.js");
4514
+ const { stopSessionExecution } = await import("./chat-handler-PC6OVDUR.js");
4515
+ const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-Y7ZGLK7A.js");
4467
4516
  const queuedMessages = sessionManager.getQueueState(sessionId);
4468
4517
  sessionManager.clearMessageQueue(sessionId);
4469
4518
  stopSessionExecution(sessionId, sessionManager);
@@ -4574,7 +4623,7 @@ async function createServerHandle(config4) {
4574
4623
  let visionFallback;
4575
4624
  let globalWorkdir;
4576
4625
  try {
4577
- const { loadGlobalConfig, getVisionFallback } = await import("./config-YFHA5MWV.js");
4626
+ const { loadGlobalConfig, getVisionFallback } = await import("./config-Z66BQTNX.js");
4578
4627
  const globalConfig = await loadGlobalConfig(config4.mode ?? "production");
4579
4628
  const fallback = getVisionFallback(globalConfig);
4580
4629
  if (fallback) {
@@ -4740,7 +4789,7 @@ async function createServerHandle(config4) {
4740
4789
  return res.status(400).json({ error: "name, url, and backend are required" });
4741
4790
  }
4742
4791
  try {
4743
- const { loadGlobalConfig, saveGlobalConfig, addProvider, setDefaultModelSelection } = await import("./config-YFHA5MWV.js");
4792
+ const { loadGlobalConfig, saveGlobalConfig, addProvider, setDefaultModelSelection } = await import("./config-Z66BQTNX.js");
4744
4793
  const globalConfig = await loadGlobalConfig(config4.mode ?? "production");
4745
4794
  const providerBackend = backend;
4746
4795
  const configWithProvider = addProvider(globalConfig, {
@@ -4775,7 +4824,7 @@ async function createServerHandle(config4) {
4775
4824
  app.post("/api/init/config", async (req, res) => {
4776
4825
  const { workdir, visionFallback } = req.body;
4777
4826
  try {
4778
- const { loadGlobalConfig, saveGlobalConfig } = await import("./config-YFHA5MWV.js");
4827
+ const { loadGlobalConfig, saveGlobalConfig } = await import("./config-Z66BQTNX.js");
4779
4828
  const globalConfig = await loadGlobalConfig(config4.mode ?? "production");
4780
4829
  const updatedConfig = {
4781
4830
  ...globalConfig,
@@ -4803,7 +4852,7 @@ async function createServerHandle(config4) {
4803
4852
  });
4804
4853
  app.delete("/api/providers/:id", async (req, res) => {
4805
4854
  const { id } = req.params;
4806
- const { loadGlobalConfig, saveGlobalConfig, removeProvider } = await import("./config-YFHA5MWV.js");
4855
+ const { loadGlobalConfig, saveGlobalConfig, removeProvider } = await import("./config-Z66BQTNX.js");
4807
4856
  const globalConfig = await loadGlobalConfig(config4.mode ?? "production");
4808
4857
  const updatedConfig = removeProvider(globalConfig, id);
4809
4858
  await saveGlobalConfig(config4.mode ?? "production", updatedConfig);
@@ -4814,7 +4863,7 @@ async function createServerHandle(config4) {
4814
4863
  const { id } = req.params;
4815
4864
  const { isLocal } = req.body;
4816
4865
  try {
4817
- const { loadGlobalConfig, saveGlobalConfig, updateProvider } = await import("./config-YFHA5MWV.js");
4866
+ const { loadGlobalConfig, saveGlobalConfig, updateProvider } = await import("./config-Z66BQTNX.js");
4818
4867
  const globalConfig = await loadGlobalConfig(config4.mode ?? "production");
4819
4868
  const provider = globalConfig.providers.find((p) => p.id === id);
4820
4869
  if (!provider) {
@@ -4842,7 +4891,7 @@ async function createServerHandle(config4) {
4842
4891
  models: modelConfigs
4843
4892
  } = req.body;
4844
4893
  try {
4845
- const { loadGlobalConfig, saveGlobalConfig, updateProvider } = await import("./config-YFHA5MWV.js");
4894
+ const { loadGlobalConfig, saveGlobalConfig, updateProvider } = await import("./config-Z66BQTNX.js");
4846
4895
  const globalConfig = await loadGlobalConfig(config4.mode ?? "production");
4847
4896
  const provider = globalConfig.providers.find((p) => p.id === id);
4848
4897
  if (!provider) {
@@ -4879,7 +4928,7 @@ async function createServerHandle(config4) {
4879
4928
  return res.status(400).json({ error: result.error });
4880
4929
  }
4881
4930
  const llmClient = getLLMClient();
4882
- const { loadGlobalConfig, saveGlobalConfig, setDefaultModelSelection } = await import("./config-YFHA5MWV.js");
4931
+ const { loadGlobalConfig, saveGlobalConfig, setDefaultModelSelection } = await import("./config-Z66BQTNX.js");
4883
4932
  const globalConfig = await loadGlobalConfig(config4.mode ?? "production");
4884
4933
  const updatedConfig = setDefaultModelSelection(globalConfig, id, llmClient.getModel());
4885
4934
  await saveGlobalConfig(config4.mode ?? "production", updatedConfig);
@@ -4906,7 +4955,7 @@ async function createServerHandle(config4) {
4906
4955
  });
4907
4956
  async function rebuildMcpTools() {
4908
4957
  const { createMcpTools: createMcpTools2 } = await import("./tool-adapter-B7QP6NLA.js");
4909
- const { setMcpTools: setMcpTools2 } = await import("./tools-DUC54GEH.js");
4958
+ const { setMcpTools: setMcpTools2 } = await import("./tools-Y7ZGLK7A.js");
4910
4959
  const mcpTools = createMcpTools2(mcpManager);
4911
4960
  setMcpTools2(mcpTools);
4912
4961
  }
@@ -4915,17 +4964,26 @@ async function createServerHandle(config4) {
4915
4964
  res.json({ servers });
4916
4965
  });
4917
4966
  app.post("/api/mcp/servers/test", async (req, res) => {
4918
- const { name, command, args, env } = req.body;
4919
- if (!command) {
4920
- return res.status(400).json({ error: "command is required" });
4967
+ const { name, transport, command, args, env, url, headers } = req.body;
4968
+ if (transport !== void 0 && transport !== "stdio" && transport !== "http") {
4969
+ return res.status(400).json({ error: `Invalid transport '${transport}'. Must be 'stdio' or 'http'.` });
4970
+ }
4971
+ if (transport !== "http" && !command) {
4972
+ return res.status(400).json({ error: "command is required for stdio transport" });
4973
+ }
4974
+ if (transport === "http" && !url) {
4975
+ return res.status(400).json({ error: "url is required for http transport" });
4921
4976
  }
4922
4977
  try {
4923
4978
  const testManager = new McpManager();
4979
+ const resolvedTransport = transport === "http" ? "http" : "stdio";
4924
4980
  const testConfig = {
4925
- transport: "stdio",
4926
- command,
4981
+ transport: resolvedTransport,
4982
+ ...command ? { command } : {},
4927
4983
  ...args && args.length > 0 ? { args } : {},
4928
- ...env && Object.keys(env).length > 0 ? { env } : {}
4984
+ ...env && Object.keys(env).length > 0 ? { env } : {},
4985
+ ...url ? { url } : {},
4986
+ ...headers && Object.keys(headers).length > 0 ? { headers } : {}
4929
4987
  };
4930
4988
  await testManager.addServer(name ?? "test", testConfig);
4931
4989
  const server = testManager.getServer(name ?? "test");
@@ -4940,21 +4998,26 @@ async function createServerHandle(config4) {
4940
4998
  }
4941
4999
  });
4942
5000
  app.post("/api/mcp/servers", async (req, res) => {
4943
- const { name, transport, command, args, env, url } = req.body;
5001
+ const { name, transport, command, args, env, url, headers } = req.body;
4944
5002
  if (!name) {
4945
5003
  return res.status(400).json({ error: "name is required" });
4946
5004
  }
5005
+ if (transport !== void 0 && transport !== "stdio" && transport !== "http") {
5006
+ return res.status(400).json({ error: `Invalid transport '${transport}'. Must be 'stdio' or 'http'.` });
5007
+ }
4947
5008
  try {
5009
+ const resolvedTransport = transport === "http" ? "http" : "stdio";
4948
5010
  const serverCfg = {
4949
- transport: transport ?? "stdio",
5011
+ transport: resolvedTransport,
4950
5012
  ...command ? { command } : {},
4951
5013
  ...args && args.length > 0 ? { args } : {},
4952
5014
  ...env && Object.keys(env).length > 0 ? { env } : {},
4953
- ...url ? { url } : {}
5015
+ ...url ? { url } : {},
5016
+ ...headers && Object.keys(headers).length > 0 ? { headers } : {}
4954
5017
  };
4955
5018
  await mcpManager.addServer(name, serverCfg);
4956
5019
  const server = mcpManager.getServer(name);
4957
- const { loadGlobalConfig, saveGlobalConfig } = await import("./config-YFHA5MWV.js");
5020
+ const { loadGlobalConfig, saveGlobalConfig } = await import("./config-Z66BQTNX.js");
4958
5021
  const globalConfig = await loadGlobalConfig(config4.mode ?? "production");
4959
5022
  const updatedMcpServers = { ...globalConfig.mcpServers ?? {}, [name]: serverCfg };
4960
5023
  await saveGlobalConfig(config4.mode ?? "production", {
@@ -4980,7 +5043,7 @@ async function createServerHandle(config4) {
4980
5043
  return res.status(404).json({ error: `MCP server '${name}' not found` });
4981
5044
  }
4982
5045
  mcpManager.removeServer(name);
4983
- const { loadGlobalConfig, saveGlobalConfig } = await import("./config-YFHA5MWV.js");
5046
+ const { loadGlobalConfig, saveGlobalConfig } = await import("./config-Z66BQTNX.js");
4984
5047
  const globalConfig = await loadGlobalConfig(config4.mode ?? "production");
4985
5048
  const updatedMcpServers = { ...globalConfig.mcpServers ?? {} };
4986
5049
  delete updatedMcpServers[name];
@@ -5005,7 +5068,7 @@ async function createServerHandle(config4) {
5005
5068
  await mcpManager.setToolEnabled(name, toolName, enabled);
5006
5069
  const server = mcpManager.getServer(name);
5007
5070
  if (server) {
5008
- const { loadGlobalConfig, saveGlobalConfig } = await import("./config-YFHA5MWV.js");
5071
+ const { loadGlobalConfig, saveGlobalConfig } = await import("./config-Z66BQTNX.js");
5009
5072
  const globalConfig = await loadGlobalConfig(config4.mode ?? "production");
5010
5073
  const mcpServers2 = { ...globalConfig.mcpServers ?? {} };
5011
5074
  const serverCfg = mcpServers2[name];
@@ -5190,8 +5253,6 @@ async function createServerHandle(config4) {
5190
5253
  });
5191
5254
  }
5192
5255
  const httpServer = createHttpServer(app);
5193
- const { setMcpManagerForWs } = await import("./server-EA6W7YIC.js");
5194
- setMcpManagerForWs(mcpManager);
5195
5256
  const wssExports = createWebSocketServer(
5196
5257
  httpServer,
5197
5258
  config4,
@@ -5201,7 +5262,12 @@ async function createServerHandle(config4) {
5201
5262
  providerManager
5202
5263
  );
5203
5264
  const wss = wssExports.wss;
5204
- const { QueueProcessor } = await import("./processor-CCXZYLX6.js");
5265
+ setNotifyMcpServersChanged((sessionId) => {
5266
+ wssExports.broadcastAll(createServerMessage("mcp.servers.changed", {}));
5267
+ const state = sessionManager.getContextState(sessionId);
5268
+ wssExports.broadcastForSession(sessionId, createContextStateMessage(state));
5269
+ });
5270
+ const { QueueProcessor } = await import("./processor-KWPYXPL7.js");
5205
5271
  const queueProcessor = new QueueProcessor({
5206
5272
  sessionManager,
5207
5273
  providerManager,
@@ -5276,4 +5342,4 @@ export {
5276
5342
  createServerHandle,
5277
5343
  createServer
5278
5344
  };
5279
- //# sourceMappingURL=chunk-4U45A7B3.js.map
5345
+ //# sourceMappingURL=chunk-DQ6SV26Y.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createServerMessage,
3
3
  isClientMessage
4
- } from "./chunk-5BDVM6YI.js";
4
+ } from "./chunk-YD6NDTKF.js";
5
5
 
6
6
  // src/server/ws/protocol.ts
7
7
  function enrichMessagesWithToolResults(messages) {
@@ -339,4 +339,4 @@ export {
339
339
  createQueueStateMessage,
340
340
  storedEventToServerMessage
341
341
  };
342
- //# sourceMappingURL=chunk-3QB2RMX2.js.map
342
+ //# sourceMappingURL=chunk-F4PMNP7S.js.map
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  createContextStateMessage,
11
11
  createSessionStateMessage
12
- } from "./chunk-3QB2RMX2.js";
12
+ } from "./chunk-F4PMNP7S.js";
13
13
  import {
14
14
  getPendingQuestionsForSession
15
15
  } from "./chunk-EU3WWTFH.js";
@@ -154,4 +154,4 @@ export {
154
154
  needsNameGenerationCheck,
155
155
  applyGeneratedSessionName
156
156
  };
157
- //# sourceMappingURL=chunk-TIKQWNYK.js.map
157
+ //# sourceMappingURL=chunk-J7KOV4ST.js.map