frizz-server 0.15.53 → 0.15.54

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 (96) hide show
  1. package/dist/claude-agent-broker.js +169 -32
  2. package/dist/dev-child.js +507 -113
  3. package/package.json +1 -1
  4. package/runtime/cc-worker/lib/frizz-tools.mjs +138 -26
  5. package/web-dist/assets/{abnfDiagram-VCTEODGH-C5-n-yX3.js → abnfDiagram-VCTEODGH-60tR6m6W.js} +1 -1
  6. package/web-dist/assets/architecture-7GRP2DOG-Sz6NSKcw.js +1 -0
  7. package/web-dist/assets/{architectureDiagram-5GKGNRK7-v9eLyom7.js → architectureDiagram-5GKGNRK7-BkVtlnlf.js} +1 -1
  8. package/web-dist/assets/{blockDiagram-I7D4REHJ-De0HKZV7.js → blockDiagram-I7D4REHJ-DlYmcXj7.js} +1 -1
  9. package/web-dist/assets/{c4Diagram-7LVT6UL2-DQFZ6NeQ.js → c4Diagram-7LVT6UL2-BVkk1o2q.js} +1 -1
  10. package/web-dist/assets/channel-CHoDmp0D.js +1 -0
  11. package/web-dist/assets/{chunk-2E4U76K2-Cec1rhm9.js → chunk-2E4U76K2-CQayNXdN.js} +1 -1
  12. package/web-dist/assets/{chunk-4HAMMTFA-DYmlzCrb.js → chunk-4HAMMTFA-BQfSiIk8.js} +1 -1
  13. package/web-dist/assets/{chunk-75Z2AOVW-D4PgvSWX.js → chunk-75Z2AOVW-CVYDSc2i.js} +1 -1
  14. package/web-dist/assets/{chunk-CLGD4ZFX-BCRaJRgH.js → chunk-CLGD4ZFX-kiC8BECf.js} +1 -1
  15. package/web-dist/assets/{chunk-DU6HZSFF-CXuOpgv7.js → chunk-DU6HZSFF-Dh3eMNB1.js} +1 -1
  16. package/web-dist/assets/{chunk-F27PBJKO-Cij7-KWq.js → chunk-F27PBJKO-Cgk_e8Qp.js} +1 -1
  17. package/web-dist/assets/{chunk-GMAD6QVW-Vfi9Qodg.js → chunk-GMAD6QVW-CfPQYPSy.js} +1 -1
  18. package/web-dist/assets/{chunk-GVQU2GXP-eAwOwPRP.js → chunk-GVQU2GXP--AyZ3Hdp.js} +1 -1
  19. package/web-dist/assets/{chunk-IMKFNOWR-jBkoemYF.js → chunk-IMKFNOWR-BvmF4pSb.js} +1 -1
  20. package/web-dist/assets/{chunk-L3NEJ4N5-Xttgzyc5.js → chunk-L3NEJ4N5-0CEQDQlt.js} +1 -1
  21. package/web-dist/assets/{chunk-OSK3NFVY-DR9jXn3P.js → chunk-OSK3NFVY-BGQx5cpJ.js} +1 -1
  22. package/web-dist/assets/{chunk-P2QGCYS3-Cpc3emFn.js → chunk-P2QGCYS3-DjK4Ukle.js} +1 -1
  23. package/web-dist/assets/{chunk-POPQ4Y6H-CuScFkWc.js → chunk-POPQ4Y6H-CnKzeNvL.js} +1 -1
  24. package/web-dist/assets/{chunk-PWAF6VOD-CIdwTlgR.js → chunk-PWAF6VOD-jccWzZMG.js} +1 -1
  25. package/web-dist/assets/{chunk-SHT3W25Y-Yb5paoPg.js → chunk-SHT3W25Y-RB6wBqMi.js} +1 -1
  26. package/web-dist/assets/{chunk-SVP7TREG-x8diHpMs.js → chunk-SVP7TREG-fbiX-oy5.js} +1 -1
  27. package/web-dist/assets/{chunk-TICWLB2K-DHsuW_jr.js → chunk-TICWLB2K-C7_LnR8U.js} +1 -1
  28. package/web-dist/assets/{chunk-TLUHSLCS-BwiXM_E2.js → chunk-TLUHSLCS-joZSA-Su.js} +2 -2
  29. package/web-dist/assets/classDiagram-ZZMXUADV-BwC8qzol.js +1 -0
  30. package/web-dist/assets/classDiagram-v2-VYDZK3BY-BwC8qzol.js +1 -0
  31. package/web-dist/assets/{cynefin-OW5HDTMX-Cs2PLbXO.js → cynefin-OW5HDTMX-DbrlwUVr.js} +1 -1
  32. package/web-dist/assets/{cynefinDiagram-5FMLGOSQ-DThGVJ4q.js → cynefinDiagram-5FMLGOSQ-B2CvZXjU.js} +1 -1
  33. package/web-dist/assets/{dagre-GXQ25YYZ-D4QLKHYZ.js → dagre-GXQ25YYZ-CYJutr3h.js} +1 -1
  34. package/web-dist/assets/{diagram-S7CK7UJ4-C-oieh0l.js → diagram-S7CK7UJ4-ClJgtc_A.js} +1 -1
  35. package/web-dist/assets/{diagram-UQ7AKVKN-BRTaSxi8.js → diagram-UQ7AKVKN-Dzzc2AV8.js} +1 -1
  36. package/web-dist/assets/{diagram-VSXAHHWV-B01NfoBK.js → diagram-VSXAHHWV-BQjCeD1w.js} +1 -1
  37. package/web-dist/assets/{diagram-VX7I27RA-CIi0wWLy.js → diagram-VX7I27RA-DBSk4ezX.js} +1 -1
  38. package/web-dist/assets/{diagram-Z3DM3KII-Bj0bns7N.js → diagram-Z3DM3KII-BzJWxRO-.js} +1 -1
  39. package/web-dist/assets/{ebnfDiagram-PWID7BFC-DJWjvFhA.js → ebnfDiagram-PWID7BFC-Ilj46-1V.js} +1 -1
  40. package/web-dist/assets/{erDiagram-RLTQ6QDP-OArCjKyL.js → erDiagram-RLTQ6QDP-Bz16i8Le.js} +1 -1
  41. package/web-dist/assets/eventmodeling-NTZA5JFV-DYqgZFXg.js +1 -0
  42. package/web-dist/assets/flowDiagram-HODETNUW-DPm1z06j.js +1 -0
  43. package/web-dist/assets/{ganttDiagram-EL5Y4UJY-Sh-yF7Pk.js → ganttDiagram-EL5Y4UJY-B45cswyo.js} +1 -1
  44. package/web-dist/assets/{gitGraph-4MIJSDKK-diOiZ9jR.js → gitGraph-4MIJSDKK-CSyOk207.js} +1 -1
  45. package/web-dist/assets/{gitGraphDiagram-WWUBYQGX-CUUUaPk1.js → gitGraphDiagram-WWUBYQGX-DTfJYE88.js} +1 -1
  46. package/web-dist/assets/{index-C7R3M7gN.js → index-B7C7zwGI.js} +47 -47
  47. package/web-dist/assets/index-BNn8gDgZ.css +2 -0
  48. package/web-dist/assets/{info-A6RAGUB7-RybBrr2w.js → info-A6RAGUB7-BxgC--z3.js} +1 -1
  49. package/web-dist/assets/{infoDiagram-27XIBGKW-Cph6Zwcq.js → infoDiagram-27XIBGKW-BhJxPw0d.js} +1 -1
  50. package/web-dist/assets/{ishikawaDiagram-5VMMS53U-BANgLDpg.js → ishikawaDiagram-5VMMS53U-B4uOoNl6.js} +1 -1
  51. package/web-dist/assets/{journeyDiagram-3NMN7TZE-DI-v8VTL.js → journeyDiagram-3NMN7TZE-E1cpX8Zh.js} +1 -1
  52. package/web-dist/assets/{kanban-definition-UXKFOSKX-Bzf950KK.js → kanban-definition-UXKFOSKX-CLCqGZaO.js} +1 -1
  53. package/web-dist/assets/{line--92Un6e-.js → line-D4YOxj2A.js} +1 -1
  54. package/web-dist/assets/{mermaid-parser.core-tLBuwbpU.js → mermaid-parser.core-CI_hCipX.js} +3 -3
  55. package/web-dist/assets/{mermaid.core-eLZc0PEp.js → mermaid.core-TBRjJPdU.js} +3 -3
  56. package/web-dist/assets/{mindmap-definition-YA3MSWOX-4_2Ouyga.js → mindmap-definition-YA3MSWOX-C8dMFTze.js} +1 -1
  57. package/web-dist/assets/{packet-AYTQ26CC-DpTDZ1kf.js → packet-AYTQ26CC-wiotbGtO.js} +1 -1
  58. package/web-dist/assets/{pegDiagram-XKGWAZYB-CHCMV4dR.js → pegDiagram-XKGWAZYB-C3hPCxJN.js} +1 -1
  59. package/web-dist/assets/{pie-WAS4IAKB-DCAUr7Sl.js → pie-WAS4IAKB-mMmNlgxH.js} +1 -1
  60. package/web-dist/assets/{pieDiagram-E7YTZNPT-ClmhRIOi.js → pieDiagram-E7YTZNPT-_BZAqwG7.js} +1 -1
  61. package/web-dist/assets/{quadrantDiagram-AXDQQJYC-C5-AhbaK.js → quadrantDiagram-AXDQQJYC-D4D56jhg.js} +1 -1
  62. package/web-dist/assets/{radar-RG4KPBEZ-BcqJ67Ci.js → radar-RG4KPBEZ-lBxKtBg1.js} +1 -1
  63. package/web-dist/assets/{railroad-74A4TZTK-BfVmIesg.js → railroad-74A4TZTK-CsSd3VR4.js} +1 -1
  64. package/web-dist/assets/railroad-abnf-HS5TGJTU-Dm55RVIf.js +1 -0
  65. package/web-dist/assets/railroad-ebnf-LZEXJU2U-BWb5OekZ.js +1 -0
  66. package/web-dist/assets/railroad-peg-WCYAUIDC-ZMHpjeRF.js +1 -0
  67. package/web-dist/assets/{railroadDiagram-O6MQD6OU-BV06urHq.js → railroadDiagram-O6MQD6OU-Th6g174U.js} +1 -1
  68. package/web-dist/assets/{requirementDiagram-BXWQKSXE-B0kxzubq.js → requirementDiagram-BXWQKSXE-D7pxtmmL.js} +1 -1
  69. package/web-dist/assets/{sankeyDiagram-P5KCCOFB-DjBlKiUQ.js → sankeyDiagram-P5KCCOFB-p5SoQoVY.js} +1 -1
  70. package/web-dist/assets/{sequenceDiagram-WJ2MYXX4-BHxYt7aE.js → sequenceDiagram-WJ2MYXX4-oNRTLIdc.js} +1 -1
  71. package/web-dist/assets/{stateDiagram-D77RDMKH-DUMg8VxQ.js → stateDiagram-D77RDMKH-DI9DxX4Y.js} +1 -1
  72. package/web-dist/assets/stateDiagram-v2-MP3YSRHH-BqIm-gME.js +1 -0
  73. package/web-dist/assets/{swimlanes-42K2YHIH-yb-iMsnc.js → swimlanes-42K2YHIH-DEQbdCsz.js} +1 -1
  74. package/web-dist/assets/swimlanesDiagram-VR7AAH4N-BrTbasxm.js +8 -0
  75. package/web-dist/assets/threadSurfaces-Bmm69aB4.js +145 -0
  76. package/web-dist/assets/{timeline-definition-24CTP7MA-DNW8iOn2.js → timeline-definition-24CTP7MA-CkfRsc_R.js} +1 -1
  77. package/web-dist/assets/{treeView-Q6P3EWNA-CuVRJqXc.js → treeView-Q6P3EWNA-DqoctESh.js} +1 -1
  78. package/web-dist/assets/{treemap-WGGIJYW6-CqAS1nJa.js → treemap-WGGIJYW6-mTc2J0pl.js} +1 -1
  79. package/web-dist/assets/{vennDiagram-4TSXK5OY-CayuoPm-.js → vennDiagram-4TSXK5OY-BmfPoTOH.js} +1 -1
  80. package/web-dist/assets/{wardley-WFR3VGLG-DLBjtOPH.js → wardley-WFR3VGLG-BBPuwAzz.js} +1 -1
  81. package/web-dist/assets/{wardleyDiagram-VM6X3IG4-VjTKjARS.js → wardleyDiagram-VM6X3IG4-xFLi_TZH.js} +1 -1
  82. package/web-dist/assets/{xychartDiagram-S5SC5T6Z-VztC2hoJ.js → xychartDiagram-S5SC5T6Z-BK53kLG3.js} +1 -1
  83. package/web-dist/index.html +2 -2
  84. package/web-dist/assets/architecture-7GRP2DOG-BXfsnnri.js +0 -1
  85. package/web-dist/assets/channel-CbqV-FJf.js +0 -1
  86. package/web-dist/assets/classDiagram-ZZMXUADV-ChpFNZ6-.js +0 -1
  87. package/web-dist/assets/classDiagram-v2-VYDZK3BY-ChpFNZ6-.js +0 -1
  88. package/web-dist/assets/eventmodeling-NTZA5JFV-DnLS-G1o.js +0 -1
  89. package/web-dist/assets/flowDiagram-HODETNUW-DxBcq7hK.js +0 -1
  90. package/web-dist/assets/index-C2agpmfX.css +0 -2
  91. package/web-dist/assets/railroad-abnf-HS5TGJTU-DmdHOz1X.js +0 -1
  92. package/web-dist/assets/railroad-ebnf-LZEXJU2U-pF0K7xke.js +0 -1
  93. package/web-dist/assets/railroad-peg-WCYAUIDC-D-df90Rl.js +0 -1
  94. package/web-dist/assets/stateDiagram-v2-MP3YSRHH-W4P30iTw.js +0 -1
  95. package/web-dist/assets/swimlanesDiagram-VR7AAH4N-CY1l7luM.js +0 -8
  96. package/web-dist/assets/threadSurfaces-i506BiUf.js +0 -143
@@ -30065,6 +30065,7 @@ var CLAUDE_BROKER_CAPABILITY_RENAME = "rename-v1";
30065
30065
  var CLAUDE_BROKER_CAPABILITY_LIST_SKILLS = "list-skills-v1";
30066
30066
  var CLAUDE_BROKER_CAPABILITY_INPUT_ACK = "input-ack-v1";
30067
30067
  var CLAUDE_BROKER_CAPABILITY_MCP = "mcp-v1";
30068
+ var CLAUDE_BROKER_CAPABILITY_MCP_RELOAD = "mcp-reload-v1";
30068
30069
  var CLAUDE_SEND_NOW_OUTCOMES = ["stopped", "delivering", "nothing_waiting"];
30069
30070
  var CLAUDE_INPUT_DROP_DIAGNOSTIC_PREFIX = "input dropped, the agent never received it";
30070
30071
  var ClaudeAgentSdkProtocolError = class extends Error {
@@ -30775,6 +30776,24 @@ var RealClaudeQueryHandle = class {
30775
30776
  this.assertOpen();
30776
30777
  await this.awaitOpenControl(this.sdkQuery.reconnectMcpServer(exactText(name, "reconnectMcpServer.name", 256)));
30777
30778
  }
30779
+ // Not gated on ready(), like mcpServerStatus: a reload reaches a thread at rest as well as mid-turn. The
30780
+ // servers ride the control channel on the CLI's stdin, never its argv, so the credentials in them stay
30781
+ // out of `ps` exactly as the launch file keeps them (writeMcpConfigFile).
30782
+ async setMcpServers(servers) {
30783
+ this.assertOpen();
30784
+ const result = objectValue(await this.awaitOpenControl(this.sdkQuery.setMcpServers(servers)), "setMcpServers");
30785
+ const errors = {};
30786
+ const rawErrors = result.errors && typeof result.errors === "object" && !Array.isArray(result.errors) ? result.errors : {};
30787
+ for (const [name, message] of Object.entries(rawErrors).slice(0, 256)) {
30788
+ const key = safeText(name, "setMcpServers.errors.name", 256);
30789
+ if (key) errors[key] = safeText(typeof message === "string" ? message : String(message), "setMcpServers.errors.message", 2e3);
30790
+ }
30791
+ return {
30792
+ added: boundedStringArray(Array.isArray(result.added) ? result.added : [], "setMcpServers.added", 256, 256),
30793
+ removed: boundedStringArray(Array.isArray(result.removed) ? result.removed : [], "setMcpServers.removed", 256, 256),
30794
+ errors
30795
+ };
30796
+ }
30778
30797
  // `mcpAuthenticate` is present at runtime in @anthropic-ai/claude-agent-sdk 0.3.303 (the
30779
30798
  // `mcp_authenticate` control request) but absent from its `.d.ts`, so — like cancelAsyncMessage — it
30780
30799
  // is PROBED: an SDK bump that drops it fails here, with a reason, instead of as "not a function".
@@ -31929,13 +31948,20 @@ function leaseRuntime(bin, role, pid = process.pid) {
31929
31948
  import { readFileSync as readFileSync3 } from "node:fs";
31930
31949
  import { homedir as homedir2 } from "node:os";
31931
31950
  import { join as join5 } from "node:path";
31932
- function readJsonObject(path) {
31951
+ function readJsonObject(path, invalid) {
31952
+ let text;
31933
31953
  try {
31934
- const parsed = JSON.parse(readFileSync3(path, "utf8"));
31935
- return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
31954
+ text = readFileSync3(path, "utf8");
31936
31955
  } catch {
31937
31956
  return void 0;
31938
31957
  }
31958
+ try {
31959
+ const parsed = JSON.parse(text);
31960
+ if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
31961
+ } catch {
31962
+ }
31963
+ invalid?.push(path);
31964
+ return void 0;
31939
31965
  }
31940
31966
  function objectField(source, key) {
31941
31967
  const value = source?.[key];
@@ -32033,34 +32059,79 @@ function userScopeRemoteServers(account, cwd, env) {
32033
32059
  }
32034
32060
  return out;
32035
32061
  }
32036
- function projectMcpServers(cwd, options = {}) {
32062
+ function projectMcpServerPlan(cwd, options = {}) {
32037
32063
  const env = options.env ?? process.env;
32038
32064
  const home = options.home ?? homedir2();
32039
32065
  const configOverride = options.claudeConfigDir ?? (env.CLAUDE_CONFIG_DIR?.trim() ? env.CLAUDE_CONFIG_DIR.trim() : void 0);
32040
32066
  const accountFile = configOverride ? join5(configOverride, ".claude.json") : join5(home, ".claude.json");
32041
32067
  const userSettingsFile = join5(configOverride ?? join5(home, ".claude"), "settings.json");
32042
- const account = readJsonObject(accountFile);
32043
- const out = userScopeRemoteServers(account, cwd, env);
32044
- const declared = objectField(readJsonObject(join5(cwd, ".mcp.json")), "mcpServers");
32045
- if (!declared) return out;
32068
+ const invalid = [];
32069
+ const account = readJsonObject(accountFile, invalid);
32070
+ const servers = userScopeRemoteServers(account, cwd, env);
32071
+ const unapproved = [];
32072
+ const declared = objectField(readJsonObject(join5(cwd, ".mcp.json"), invalid), "mcpServers");
32073
+ if (!declared) return { servers, unapproved, invalid };
32046
32074
  const approval = collectApproval([
32047
- readJsonObject(join5(cwd, ".claude", "settings.json")),
32048
- readJsonObject(join5(cwd, ".claude", "settings.local.json")),
32049
- readJsonObject(userSettingsFile),
32075
+ readJsonObject(join5(cwd, ".claude", "settings.json"), invalid),
32076
+ readJsonObject(join5(cwd, ".claude", "settings.local.json"), invalid),
32077
+ readJsonObject(userSettingsFile, invalid),
32050
32078
  objectField(objectField(account, "projects"), cwd)
32051
32079
  ]);
32052
32080
  for (const [name, raw] of Object.entries(declared)) {
32053
32081
  if (approval.disabled.has(name)) continue;
32054
- if (!approval.all && !approval.enabled.has(name)) continue;
32082
+ if (!approval.all && !approval.enabled.has(name)) {
32083
+ unapproved.push(name);
32084
+ continue;
32085
+ }
32055
32086
  const server = normalizeMcpServer(raw, env);
32056
- if (server) out[name] = server;
32087
+ if (server) servers[name] = server;
32057
32088
  }
32058
- return out;
32089
+ return { servers, unapproved, invalid };
32059
32090
  }
32060
32091
  function workerMcpServers(project, frizz) {
32061
32092
  return { ...project ?? {}, ...frizz ?? {} };
32062
32093
  }
32063
32094
 
32095
+ // packages/server/src/backend/mcp-reload-plan.ts
32096
+ function mcpDefinitionKey(server) {
32097
+ const sorted = (value) => {
32098
+ if (Array.isArray(value)) return value.map(sorted);
32099
+ if (value && typeof value === "object") {
32100
+ return Object.fromEntries(Object.keys(value).sort().map((key) => [key, sorted(value[key])]));
32101
+ }
32102
+ return value;
32103
+ };
32104
+ return JSON.stringify(sorted(server));
32105
+ }
32106
+ function planMcpReload(previous, next, mountStdio) {
32107
+ const mounts = {};
32108
+ const added = [];
32109
+ const changed = [];
32110
+ const minted = [];
32111
+ let unchanged = 0;
32112
+ for (const [name, definition] of Object.entries(next)) {
32113
+ const before = previous.definitions[name];
32114
+ const heldMount = previous.mounts[name];
32115
+ if (before && heldMount && mcpDefinitionKey(before) === mcpDefinitionKey(definition)) {
32116
+ mounts[name] = heldMount;
32117
+ unchanged += 1;
32118
+ continue;
32119
+ }
32120
+ if (before) changed.push(name);
32121
+ else added.push(name);
32122
+ if (mountStdio && (definition.type === void 0 || definition.type === "stdio")) {
32123
+ const mounted = mountStdio(name, definition);
32124
+ minted.push(mounted);
32125
+ mounts[name] = mounted;
32126
+ } else {
32127
+ mounts[name] = definition;
32128
+ }
32129
+ }
32130
+ const removed = Object.keys(previous.definitions).filter((name) => !(name in next));
32131
+ const stale = Object.entries(previous.mounts).filter(([name, mount]) => mounts[name] !== mount).map(([, mount]) => mount);
32132
+ return { mounts, added, removed, changed, unchanged, minted, stale };
32133
+ }
32134
+
32064
32135
  // packages/server/src/backend/lazy-mcp-host.ts
32065
32136
  import { spawn as spawn2 } from "node:child_process";
32066
32137
  import { createHash as createHash2, randomBytes } from "node:crypto";
@@ -32435,6 +32506,19 @@ function startLazyMcpHost(options) {
32435
32506
  }
32436
32507
  return out;
32437
32508
  },
32509
+ async release(mounts) {
32510
+ const prefix = `http://127.0.0.1:${port}/mcp/`;
32511
+ const closing = [];
32512
+ for (const mount of mounts) {
32513
+ if (!mount.url.startsWith(prefix)) continue;
32514
+ const slot = mount.url.slice(prefix.length);
32515
+ const server = servers.get(slot);
32516
+ if (!server) continue;
32517
+ servers.delete(slot);
32518
+ closing.push(server.close());
32519
+ }
32520
+ await Promise.all(closing);
32521
+ },
32438
32522
  running: () => [...servers.values()].filter((server) => server.isRunning).map((server) => server.name),
32439
32523
  async close() {
32440
32524
  await Promise.all([...servers.values()].map((server) => server.close()));
@@ -32824,18 +32908,21 @@ async function recordObservedClaudeQuota(info, where) {
32824
32908
  }
32825
32909
 
32826
32910
  // packages/server/src/backend/claude-agent-broker.ts
32827
- var BROKER_CAPABILITIES = [CLAUDE_BROKER_CAPABILITY_SUBAGENT_STEER, CLAUDE_BROKER_CAPABILITY_CANCEL_INPUT, CLAUDE_BROKER_CAPABILITY_STOP_TASK, CLAUDE_BROKER_CAPABILITY_RELOAD_PLUGINS, CLAUDE_BROKER_CAPABILITY_RENAME, CLAUDE_BROKER_CAPABILITY_LIST_SKILLS, CLAUDE_BROKER_CAPABILITY_INPUT_ACK, CLAUDE_BROKER_CAPABILITY_MCP];
32911
+ var BROKER_CAPABILITIES = [CLAUDE_BROKER_CAPABILITY_SUBAGENT_STEER, CLAUDE_BROKER_CAPABILITY_CANCEL_INPUT, CLAUDE_BROKER_CAPABILITY_STOP_TASK, CLAUDE_BROKER_CAPABILITY_RELOAD_PLUGINS, CLAUDE_BROKER_CAPABILITY_RENAME, CLAUDE_BROKER_CAPABILITY_LIST_SKILLS, CLAUDE_BROKER_CAPABILITY_INPUT_ACK, CLAUDE_BROKER_CAPABILITY_MCP, CLAUDE_BROKER_CAPABILITY_MCP_RELOAD];
32828
32912
  var IDLE_EXIT_MS = 6 * 60 * 60 * 1e3;
32829
32913
  var PERMISSION_SHOW_HOLD_MS = 250;
32830
32914
  var REACHABILITY_CHECK_MS = 3e4;
32831
32915
  var REACHABILITY_STRIKES = 2;
32832
32916
  var EVENT_ERROR_TOLERANCE = 5;
32833
- function mountLazily(project, frizz, host, context) {
32917
+ function withoutFrizzNames(servers, frizz) {
32918
+ if (!frizz) return servers;
32919
+ return Object.fromEntries(Object.entries(servers).filter(([name]) => !(name in frizz)));
32920
+ }
32921
+ var isStdio = (server) => server.type === void 0 || server.type === "stdio";
32922
+ function mountLazily(project, host, context) {
32834
32923
  if (!host) return project;
32835
32924
  const stdio = {};
32836
- for (const [name, server] of Object.entries(project)) {
32837
- if ((server.type === void 0 || server.type === "stdio") && !(frizz && name in frizz)) stdio[name] = server;
32838
- }
32925
+ for (const [name, server] of Object.entries(project)) if (isStdio(server)) stdio[name] = server;
32839
32926
  return { ...project, ...host.mount(stdio, context) };
32840
32927
  }
32841
32928
  function runClaudeBroker(config, options = {}) {
@@ -32880,6 +32967,19 @@ function runClaudeBroker(config, options = {}) {
32880
32967
  reload: () => handle.reloadPlugins(),
32881
32968
  log: (message) => writeDiagnostic?.({ kind: "stderr", message: `[plugin-sync] ${message}`, truncated: false })
32882
32969
  }) : void 0;
32970
+ const lazyMcpContext = {
32971
+ cwd: config.cwd,
32972
+ // What the CLI itself would have spawned the server with: the env the factory hands it, after
32973
+ // the same sanitizing (no inherited NODE_OPTIONS, no nub shim on PATH).
32974
+ env: sanitizeProviderChildEnvironment(env),
32975
+ log: (message) => writeDiagnostic?.({ kind: "stderr", message: `[lazy-mcp] ${message}`, truncated: false })
32976
+ };
32977
+ const launchDefinitions = withoutFrizzNames(projectMcpServerPlan(config.cwd, { env }).servers, config.mcpServers);
32978
+ let mcpSurface = {
32979
+ definitions: launchDefinitions,
32980
+ mounts: mountLazily(launchDefinitions, options.lazyMcpHost, lazyMcpContext),
32981
+ adopted: false
32982
+ };
32883
32983
  const handle = factory.start({
32884
32984
  cwd: config.cwd,
32885
32985
  session: config.resume ? { kind: "resume", sessionId: config.sessionId } : { kind: "new", sessionId: config.sessionId },
@@ -32895,19 +32995,11 @@ function runClaudeBroker(config, options = {}) {
32895
32995
  // The WHOLE MCP surface of this thread, and STRICT so the CLI discovers nothing else: the project's
32896
32996
  // approved `.mcp.json` (and the operator's remote user-scope servers) under the frizz mount, which
32897
32997
  // wins a name collision. Read at every fork, not once per project, so a `.mcp.json` edit reaches the
32898
- // next dispatch the way it reaches the next plain `claude`. project-mcp-servers.ts has the reasons.
32899
- // Stdio servers are not started here: the lazy host stands in for each one and starts the real
32900
- // command on the first tool call (lazy-mcp-host.ts has the measurement that motivated it).
32901
- mcpServers: workerMcpServers(
32902
- mountLazily(projectMcpServers(config.cwd, { env }), config.mcpServers, options.lazyMcpHost, {
32903
- cwd: config.cwd,
32904
- // What the CLI itself would have spawned the server with: the env the factory hands it, after
32905
- // the same sanitizing (no inherited NODE_OPTIONS, no nub shim on PATH).
32906
- env: sanitizeProviderChildEnvironment(env),
32907
- log: (message) => writeDiagnostic?.({ kind: "stderr", message: `[lazy-mcp] ${message}`, truncated: false })
32908
- }),
32909
- config.mcpServers
32910
- ),
32998
+ // next dispatch the way it reaches the next plain `claude` — and an MCP reload brings it into this one.
32999
+ // project-mcp-servers.ts has the reasons. Stdio servers are not started here: the lazy host stands in
33000
+ // for each one and starts the real command on the first tool call (lazy-mcp-host.ts has the
33001
+ // measurement that motivated it).
33002
+ mcpServers: workerMcpServers(mcpSurface.mounts, config.mcpServers),
32911
33003
  strictMcpConfig: true,
32912
33004
  allowedTools: config.allowedTools,
32913
33005
  // Claude Code's own schedulers are taken away (BROKER_DISALLOWED_TOOLS has the reason). AskUserQuestion
@@ -32997,6 +33089,45 @@ function runClaudeBroker(config, options = {}) {
32997
33089
  (end) => shutdown(0, end.reason, end.detail),
32998
33090
  (error) => shutdown(0, "event-pump-failed", error instanceof Error ? error.message : String(error))
32999
33091
  );
33092
+ let mcpReloading = Promise.resolve();
33093
+ const reloadMcp = () => {
33094
+ const run = mcpReloading.catch(() => {
33095
+ }).then(async () => {
33096
+ const read = projectMcpServerPlan(config.cwd, { env });
33097
+ if (read.invalid.length > 0) {
33098
+ throw new Error(`Nothing was reloaded: ${read.invalid.join(", ")} ${read.invalid.length === 1 ? "is" : "are"} not valid JSON. Fix it and reload again.`);
33099
+ }
33100
+ const host = options.lazyMcpHost;
33101
+ const plan = planMcpReload(
33102
+ mcpSurface,
33103
+ withoutFrizzNames(read.servers, config.mcpServers),
33104
+ host ? (name, server2) => host.mount({ [name]: server2 }, lazyMcpContext)[name] : void 0
33105
+ );
33106
+ let result;
33107
+ try {
33108
+ if (!mcpSurface.adopted) {
33109
+ if (Object.keys(mcpSurface.mounts).length > 0) await handle.setMcpServers(mcpSurface.mounts);
33110
+ mcpSurface = { ...mcpSurface, adopted: true };
33111
+ }
33112
+ result = await handle.setMcpServers(plan.mounts);
33113
+ } catch (error) {
33114
+ await host?.release(plan.minted).catch(() => {
33115
+ });
33116
+ throw error;
33117
+ }
33118
+ mcpSurface = { definitions: withoutFrizzNames(read.servers, config.mcpServers), mounts: plan.mounts, adopted: true };
33119
+ await host?.release(plan.stale.filter((mount) => !isStdio(mount))).catch(() => {
33120
+ });
33121
+ writeDiagnostic?.({
33122
+ kind: "stderr",
33123
+ message: `[mcp-reload] added=${plan.added.join(",") || "-"} removed=${plan.removed.join(",") || "-"} changed=${plan.changed.join(",") || "-"} unchanged=${plan.unchanged} errors=${Object.keys(result.errors).join(",") || "-"}`,
33124
+ truncated: false
33125
+ });
33126
+ return { added: plan.added, removed: plan.removed, changed: plan.changed, unchanged: plan.unchanged, errors: result.errors, unapproved: read.unapproved };
33127
+ });
33128
+ mcpReloading = run;
33129
+ return run;
33130
+ };
33000
33131
  const armIdle = () => {
33001
33132
  if (client || closed) return;
33002
33133
  clearTimeout(idleTimer);
@@ -33106,6 +33237,12 @@ function runClaudeBroker(config, options = {}) {
33106
33237
  () => write(sock, { t: "mcp-reconnect-result", requestId }),
33107
33238
  (error) => write(sock, { t: "mcp-reconnect-result", requestId, error: error instanceof Error ? error.message : String(error) })
33108
33239
  );
33240
+ } else if (msg.t === "mcp-reload") {
33241
+ const requestId = msg.requestId;
33242
+ void reloadMcp().then(
33243
+ (reload) => write(sock, { t: "mcp-reload-result", requestId, reload }),
33244
+ (error) => write(sock, { t: "mcp-reload-result", requestId, error: error instanceof Error ? error.message : String(error) })
33245
+ );
33109
33246
  } else if (msg.t === "set-mode") void handle.setPermissionMode(msg.mode).catch(() => {
33110
33247
  });
33111
33248
  }