memorix 1.8.3 → 1.8.5

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 (74) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/CLAUDE.md +3 -0
  3. package/README.md +4 -4
  4. package/README.zh-CN.md +5 -3
  5. package/dist/cli/index.js +1544 -635
  6. package/dist/dashboard/static/app.js +29 -885
  7. package/dist/dashboard/static/index.html +1 -5
  8. package/dist/dashboard/static/style.css +36 -503
  9. package/dist/index.d.ts +4 -4
  10. package/dist/index.js +214 -73
  11. package/dist/memcode/index.js +28035 -169
  12. package/dist/memcode-runtime/CHANGELOG.md +53 -0
  13. package/dist/sdk.js +30 -14
  14. package/docs/1.8.0-RELEASE-CANDIDATE-SPEC.md +22 -16
  15. package/docs/AGENT_OPERATOR_PLAYBOOK.md +2 -2
  16. package/docs/API_REFERENCE.md +10 -8
  17. package/docs/DASHBOARD.md +23 -0
  18. package/docs/DEVELOPMENT.md +2 -2
  19. package/docs/DOCKER.md +6 -3
  20. package/docs/INTEGRATIONS.md +1 -1
  21. package/docs/MODULES.md +46 -20
  22. package/docs/PERFORMANCE.md +1 -1
  23. package/docs/README.md +8 -7
  24. package/docs/SETUP.md +3 -3
  25. package/package.json +11 -11
  26. package/plugins/antigravity/memorix/plugin.json +1 -1
  27. package/plugins/antigravity/memorix/rules/memorix.md +5 -0
  28. package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
  29. package/plugins/claude/memorix/skills/memorix-memory/SKILL.md +3 -0
  30. package/plugins/claude/memorix/skills/memorix-mini-skills/SKILL.md +2 -0
  31. package/plugins/claude/memorix/skills/memorix-orchestrate/SKILL.md +2 -0
  32. package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
  33. package/plugins/codebuddy/memorix/skills/memorix-memory/SKILL.md +3 -0
  34. package/plugins/codebuddy/memorix/skills/memorix-mini-skills/SKILL.md +2 -0
  35. package/plugins/codebuddy/memorix/skills/memorix-orchestrate/SKILL.md +2 -0
  36. package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
  37. package/plugins/codex/memorix/skills/memorix-memory/SKILL.md +3 -0
  38. package/plugins/codex/memorix/skills/memorix-mini-skills/SKILL.md +2 -0
  39. package/plugins/codex/memorix/skills/memorix-orchestrate/SKILL.md +2 -0
  40. package/plugins/copilot/memorix/plugin.json +1 -1
  41. package/plugins/copilot/memorix/skills/memorix-memory/SKILL.md +3 -0
  42. package/plugins/copilot/memorix/skills/memorix-mini-skills/SKILL.md +2 -0
  43. package/plugins/copilot/memorix/skills/memorix-orchestrate/SKILL.md +2 -0
  44. package/plugins/cursor/memorix/skills/memorix-memory/SKILL.md +3 -0
  45. package/plugins/cursor/memorix/skills/memorix-mini-skills/SKILL.md +2 -0
  46. package/plugins/cursor/memorix/skills/memorix-orchestrate/SKILL.md +2 -0
  47. package/plugins/gemini/memorix/GEMINI.md +5 -0
  48. package/plugins/gemini/memorix/gemini-extension.json +1 -1
  49. package/plugins/hermes/memorix/plugin.yaml +7 -1
  50. package/plugins/omp/memorix/package.json +1 -1
  51. package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
  52. package/plugins/pi/memorix/package.json +1 -1
  53. package/plugins/pi/memorix/skills/memorix-memory/SKILL.md +3 -0
  54. package/plugins/pi/memorix/skills/memorix-mini-skills/SKILL.md +2 -0
  55. package/plugins/pi/memorix/skills/memorix-orchestrate/SKILL.md +2 -0
  56. package/server.json +2 -2
  57. package/src/cli/command-guide.ts +52 -1
  58. package/src/cli/commands/background.ts +166 -6
  59. package/src/cli/commands/serve-http.ts +74 -86
  60. package/src/cli/commands/serve.ts +95 -93
  61. package/src/cli/index.ts +1 -1
  62. package/src/dashboard/static/index.html +1 -5
  63. package/src/dashboard/static/style.css +36 -503
  64. package/src/hooks/installers/index.ts +3 -0
  65. package/src/hooks/official-skills.ts +13 -6
  66. package/src/memory/graph.ts +2 -2
  67. package/src/server/mcp-diagnostics.ts +9 -7
  68. package/src/server/mcp-discovery.ts +0 -1
  69. package/src/server/modern-mcp-bridge.ts +108 -0
  70. package/src/server/stdio-startup-gate.ts +41 -2
  71. package/src/server/tool-profile.ts +7 -6
  72. package/src/server.ts +1 -1
  73. package/src/store/orama-store.ts +2 -2
  74. package/src/wiki/types.ts +2 -2
package/dist/cli/index.js CHANGED
@@ -3232,7 +3232,7 @@ ${import_picocolors.default.gray(m3)} ${s4}
3232
3232
 
3233
3233
  // src/cli/version.ts
3234
3234
  function getCliVersion() {
3235
- return true ? "1.8.3" : pkg.version;
3235
+ return true ? "1.8.5" : pkg.version;
3236
3236
  }
3237
3237
  var init_version = __esm({
3238
3238
  "src/cli/version.ts"() {
@@ -38645,8 +38645,8 @@ var init_uploads = __esm({
38645
38645
  init_shims();
38646
38646
  checkFileSupport = () => {
38647
38647
  if (typeof File === "undefined") {
38648
- const { process: process3 } = globalThis;
38649
- const isOldNode = typeof process3?.versions?.node === "string" && parseInt(process3.versions.node.split(".")) < 20;
38648
+ const { process: process2 } = globalThis;
38649
+ const isOldNode = typeof process2?.versions?.node === "string" && parseInt(process2.versions.node.split(".")) < 20;
38650
38650
  throw new Error("`File` is not defined as a global, which is required for file uploads." + (isOldNode ? " Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`." : ""));
38651
38651
  }
38652
38652
  };
@@ -65035,8 +65035,8 @@ var init_uploads4 = __esm({
65035
65035
  init_shims2();
65036
65036
  checkFileSupport2 = () => {
65037
65037
  if (typeof File === "undefined") {
65038
- const { process: process3 } = globalThis;
65039
- const isOldNode = typeof process3?.versions?.node === "string" && parseInt(process3.versions.node.split(".")) < 20;
65038
+ const { process: process2 } = globalThis;
65039
+ const isOldNode = typeof process2?.versions?.node === "string" && parseInt(process2.versions.node.split(".")) < 20;
65040
65040
  throw new Error("`File` is not defined as a global, which is required for file uploads." + (isOldNode ? " Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`." : ""));
65041
65041
  }
65042
65042
  };
@@ -79311,15 +79311,15 @@ var require_streams = __commonJS({
79311
79311
  var POOL_SIZE2 = 65536;
79312
79312
  if (!globalThis.ReadableStream) {
79313
79313
  try {
79314
- const process3 = __require("process");
79315
- const { emitWarning } = process3;
79314
+ const process2 = __require("process");
79315
+ const { emitWarning } = process2;
79316
79316
  try {
79317
- process3.emitWarning = () => {
79317
+ process2.emitWarning = () => {
79318
79318
  };
79319
79319
  Object.assign(globalThis, __require("stream/web"));
79320
- process3.emitWarning = emitWarning;
79320
+ process2.emitWarning = emitWarning;
79321
79321
  } catch (error40) {
79322
- process3.emitWarning = emitWarning;
79322
+ process2.emitWarning = emitWarning;
79323
79323
  throw error40;
79324
79324
  }
79325
79325
  } catch (error40) {
@@ -83960,7 +83960,7 @@ var require_logging_utils = __commonJS({
83960
83960
  exports.setBackend = setBackend;
83961
83961
  exports.log = log;
83962
83962
  var events_1 = __require("events");
83963
- var process3 = __importStar(__require("process"));
83963
+ var process2 = __importStar(__require("process"));
83964
83964
  var util2 = __importStar(__require("util"));
83965
83965
  var colours_1 = require_colours();
83966
83966
  var LogSeverity;
@@ -84017,7 +84017,7 @@ var require_logging_utils = __commonJS({
84017
84017
  this.cached = /* @__PURE__ */ new Map();
84018
84018
  this.filters = [];
84019
84019
  this.filtersSet = false;
84020
- let nodeFlag = (_a6 = process3.env[exports.env.nodeEnables]) !== null && _a6 !== void 0 ? _a6 : "*";
84020
+ let nodeFlag = (_a6 = process2.env[exports.env.nodeEnables]) !== null && _a6 !== void 0 ? _a6 : "*";
84021
84021
  if (nodeFlag === "all") {
84022
84022
  nodeFlag = "*";
84023
84023
  }
@@ -84057,7 +84057,7 @@ var require_logging_utils = __commonJS({
84057
84057
  return (fields, ...args) => {
84058
84058
  var _a6;
84059
84059
  const nscolour = `${colours_1.Colours.green}${namespace}${colours_1.Colours.reset}`;
84060
- const pid = `${colours_1.Colours.yellow}${process3.pid}${colours_1.Colours.reset}`;
84060
+ const pid = `${colours_1.Colours.yellow}${process2.pid}${colours_1.Colours.reset}`;
84061
84061
  let level;
84062
84062
  switch (fields.severity) {
84063
84063
  case LogSeverity.ERROR:
@@ -84105,8 +84105,8 @@ var require_logging_utils = __commonJS({
84105
84105
  }
84106
84106
  setFilters() {
84107
84107
  var _a6;
84108
- const existingFilters = (_a6 = process3.env["NODE_DEBUG"]) !== null && _a6 !== void 0 ? _a6 : "";
84109
- process3.env["NODE_DEBUG"] = `${existingFilters}${existingFilters ? "," : ""}${this.filters.join(",")}`;
84108
+ const existingFilters = (_a6 = process2.env["NODE_DEBUG"]) !== null && _a6 !== void 0 ? _a6 : "";
84109
+ process2.env["NODE_DEBUG"] = `${existingFilters}${existingFilters ? "," : ""}${this.filters.join(",")}`;
84110
84110
  }
84111
84111
  };
84112
84112
  function getDebugBackend(debugPkg) {
@@ -84159,7 +84159,7 @@ var require_logging_utils = __commonJS({
84159
84159
  }
84160
84160
  function log(namespace, parent) {
84161
84161
  if (!cachedBackend) {
84162
- const enablesFlag = process3.env[exports.env.nodeEnables];
84162
+ const enablesFlag = process2.env[exports.env.nodeEnables];
84163
84163
  if (!enablesFlag) {
84164
84164
  return exports.placeholder;
84165
84165
  }
@@ -111728,8 +111728,8 @@ var init_node = __esm({
111728
111728
  checkFileSupport3 = () => {
111729
111729
  var _a6;
111730
111730
  if (typeof File === "undefined") {
111731
- const { process: process3 } = globalThis;
111732
- const isOldNode = typeof ((_a6 = process3 === null || process3 === void 0 ? void 0 : process3.versions) === null || _a6 === void 0 ? void 0 : _a6.node) === "string" && parseInt(process3.versions.node.split(".")) < 20;
111731
+ const { process: process2 } = globalThis;
111732
+ const isOldNode = typeof ((_a6 = process2 === null || process2 === void 0 ? void 0 : process2.versions) === null || _a6 === void 0 ? void 0 : _a6.node) === "string" && parseInt(process2.versions.node.split(".")) < 20;
111733
111733
  throw new Error("`File` is not defined as a global, which is required for file uploads." + (isOldNode ? " Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`." : ""));
111734
111734
  }
111735
111735
  };
@@ -192804,6 +192804,9 @@ var init_official_skills = __esm({
192804
192804
  '| Specific past decision, bug, file, or change | `memorix_search` | `memorix memory search --query "<topic>"` |',
192805
192805
  "| Need the full source for a search hit | `memorix_detail` | `memorix memory detail --id <id>` |",
192806
192806
  "| Need the sequence around one memory | `memorix_timeline` | `memorix memory timeline --id <id>` |",
192807
+ "| Check source and freshness for a memory | `memorix_evidence` | `memorix evidence list|get|events` |",
192808
+ "| Record whether a memory helped, conflicted, or was corrected | `memorix_feedback` | `memorix feedback record|show|audit` |",
192809
+ "| Inspect or import controlled media | `memorix_media` | `memorix media import|attach|list|show|status` |",
192807
192810
  '| Learned reusable project knowledge | `memorix_store` | `memorix memory store --type <type> --entity <name> --title "<title>" "<text>"` |',
192808
192811
  "| Task or bug is complete/outdated | `memorix_resolve` | `memorix memory resolve --ids <ids>` |",
192809
192812
  "",
@@ -192934,6 +192937,8 @@ var init_official_skills = __esm({
192934
192937
  "",
192935
192938
  "Promote memories into mini-skills only when they are reusable instructions, not just historical notes.",
192936
192939
  "",
192940
+ "The standard setup uses the `lite` MCP profile. `memorix_skills` and `memorix_promote` are full-profile tools, so use the CLI fallback unless the current server was explicitly started with `MEMORIX_MODE=full` or `--mode full`. Do not probe hidden MCP tools repeatedly.",
192941
+ "",
192937
192942
  "## Tool Router",
192938
192943
  "",
192939
192944
  "| Situation | Prefer | CLI fallback |",
@@ -192969,15 +192974,17 @@ var init_official_skills = __esm({
192969
192974
  "| Situation | Prefer | CLI fallback |",
192970
192975
  "|---|---|---|",
192971
192976
  '| Run managed subagent execution | CLI | `memorix orchestrate --goal "<goal>" --agents claude:1,codex:1` |',
192972
- "| Register coordination identity | `team_manage` action `join` | `memorix team join --agentType <agent>` |",
192973
- "| Create or inspect tasks | `team_task` | `memorix task create|list|claim|complete` |",
192974
- "| Send or read coordination messages | `team_message` | `memorix message send|broadcast|inbox` |",
192975
- "| Share structured handoff | `memorix_handoff` | `memorix handoff send` |",
192976
- "| Avoid file conflicts | `team_file_lock` | `memorix lock lock|unlock|status` |",
192977
- "| Poll joined coordination state | `memorix_poll` | `memorix poll` |",
192977
+ "| Register coordination identity when team MCP tools are available | `team_manage` action `join` | `memorix team join --agentType <agent>` |",
192978
+ "| Create or inspect tasks when team MCP tools are available | `team_task` | `memorix task create|list|claim|complete` |",
192979
+ "| Send or read coordination messages when team MCP tools are available | `team_message` | `memorix message send|broadcast|inbox` |",
192980
+ "| Share structured handoff when team MCP tools are available | `memorix_handoff` | `memorix handoff send` |",
192981
+ "| Avoid file conflicts when team MCP tools are available | `team_file_lock` | `memorix lock lock|unlock|status` |",
192982
+ "| Poll joined coordination state when team MCP tools are available | `memorix_poll` | `memorix poll` |",
192978
192983
  "",
192979
192984
  "## Boundaries",
192980
192985
  "",
192986
+ "The standard setup uses the `lite` MCP profile. Coordination MCP tools are exposed only by `team` or `full`; use the CLI fallback for ordinary installations, or explicitly start the server with `--mode team`. Do not probe unavailable team tools in a loop.",
192987
+ "",
192981
192988
  "- For ordinary memory, do not join coordination state.",
192982
192989
  "- For production multi-agent execution, prefer `memorix orchestrate` so the main process owns planning, dispatch, retries, and verification gates.",
192983
192990
  "- `memorix orchestrate` uses the current checkout for single-worker runs and task worktrees for parallel runs. Use `--isolated` to force worktree isolation, `--no-worktree` to disable it, `--allow-dirty` to run with uncommitted changes, and `--no-auto-merge` to preserve task worktrees for manual review.",
@@ -194141,7 +194148,10 @@ alwaysApply: true
194141
194148
  "| `memorix_store` | Save something worth persisting |",
194142
194149
  '| `memorix_store_reasoning` | Save the "why" behind a decision |',
194143
194150
  "| `memorix_resolve` | Mark completed/outdated memories |",
194144
- "| `memorix_session_start` | Load session context (handoff, orchestration coordination) |"
194151
+ "| `memorix_session_start` | Load session context (handoff, orchestration coordination) |",
194152
+ "| `memorix_evidence` | Check a memory source, freshness, and verification state |",
194153
+ "| `memorix_feedback` | Record whether a memory helped, conflicted, or was corrected |",
194154
+ "| `memorix_media` | Inspect or import controlled local media |"
194145
194155
  ].join("\n");
194146
194156
  }
194147
194157
  async function uninstallHooks(agent, projectRoot, global2 = false) {
@@ -205684,16 +205694,24 @@ function resolveToolProfile(opts) {
205684
205694
  return normalize(opts.explicit) ?? normalize(opts.envValue) ?? opts.fallback;
205685
205695
  }
205686
205696
  function describeProfile(profile) {
205697
+ const count3 = countToolsInProfile(profile);
205687
205698
  switch (profile) {
205688
205699
  case "micro":
205689
- return "micro (agent-ready context + bounded recovery/media, ~9 tools)";
205700
+ return `micro (agent-ready context + bounded recovery/media, ${count3} tools)`;
205690
205701
  case "lite":
205691
- return "lite (core memory + sessions, ~18 tools)";
205702
+ return `lite (core memory + sessions, ${count3} tools)`;
205692
205703
  case "team":
205693
- return "team (lite + coordination tools + dashboard + knowledge workspace, ~26 tools)";
205704
+ return `team (lite + coordination tools + dashboard + knowledge workspace, ${count3} tools)`;
205694
205705
  case "full":
205695
- return "full (all tools including advanced / KG-compat)";
205706
+ return `full (all tools including advanced / KG-compat, ${count3} tools)`;
205707
+ }
205708
+ }
205709
+ function countToolsInProfile(profile) {
205710
+ let n3 = 0;
205711
+ for (const name of Object.keys(TOOL_PROFILES)) {
205712
+ if (isToolInProfile(name, profile)) n3++;
205696
205713
  }
205714
+ return n3;
205697
205715
  }
205698
205716
  var TOOL_PROFILES;
205699
205717
  var init_tool_profile = __esm({
@@ -205768,14 +205786,13 @@ var init_tool_profile = __esm({
205768
205786
  function getMcpServerInfo() {
205769
205787
  return {
205770
205788
  name: "memorix",
205771
- version: true ? "1.8.3" : "1.0.1"
205789
+ version: true ? "1.8.5" : "1.0.1"
205772
205790
  };
205773
205791
  }
205774
205792
  function createMcpDiscoverResult(capabilities, serverInfo) {
205775
205793
  return {
205776
205794
  resultType: "complete",
205777
205795
  supportedVersions: [
205778
- MCP_MODERN_PROTOCOL_VERSION,
205779
205796
  MCP_LEGACY_PROTOCOL_VERSION,
205780
205797
  MCP_OLDEST_LEGACY_PROTOCOL_VERSION
205781
205798
  ],
@@ -205792,12 +205809,11 @@ function createMcpDiscoverResult(capabilities, serverInfo) {
205792
205809
  function createMcpStartupDiscoverResult(serverInfo) {
205793
205810
  return createMcpDiscoverResult({ tools: { listChanged: true } }, serverInfo);
205794
205811
  }
205795
- var MCP_MODERN_PROTOCOL_VERSION, MCP_LEGACY_PROTOCOL_VERSION, MCP_OLDEST_LEGACY_PROTOCOL_VERSION, MCP_SERVER_DISCOVER_METHOD, MCP_SERVER_INFO_META_KEY;
205812
+ var MCP_LEGACY_PROTOCOL_VERSION, MCP_OLDEST_LEGACY_PROTOCOL_VERSION, MCP_SERVER_DISCOVER_METHOD, MCP_SERVER_INFO_META_KEY;
205796
205813
  var init_mcp_discovery = __esm({
205797
205814
  "src/server/mcp-discovery.ts"() {
205798
205815
  "use strict";
205799
205816
  init_esm_shims();
205800
- MCP_MODERN_PROTOCOL_VERSION = "2026-07-28";
205801
205817
  MCP_LEGACY_PROTOCOL_VERSION = "2025-11-25";
205802
205818
  MCP_OLDEST_LEGACY_PROTOCOL_VERSION = "2024-11-05";
205803
205819
  MCP_SERVER_DISCOVER_METHOD = "server/discover";
@@ -205837,7 +205853,17 @@ var init_stdio_startup_gate = __esm({
205837
205853
  this.fail(new Error(`stdio input chunk exceeded ${this.maxBufferSize} bytes`));
205838
205854
  return;
205839
205855
  }
205840
- this.input.write(chunk);
205856
+ this.pendingInput += typeof chunk === "string" ? chunk : chunk.toString("utf8");
205857
+ let newline2 = this.pendingInput.indexOf("\n");
205858
+ while (newline2 >= 0 && !this.stopped) {
205859
+ const line = this.pendingInput.slice(0, newline2 + 1);
205860
+ this.pendingInput = this.pendingInput.slice(newline2 + 1);
205861
+ this.handleReadyLine(line);
205862
+ newline2 = this.pendingInput.indexOf("\n");
205863
+ }
205864
+ if (!this.stopped && Buffer.byteLength(this.pendingInput, "utf8") > this.maxBufferSize) {
205865
+ this.fail(new Error(`stdio input exceeded ${this.maxBufferSize} bytes`));
205866
+ }
205841
205867
  return;
205842
205868
  }
205843
205869
  const text2 = typeof chunk === "string" ? chunk : chunk.toString("utf8");
@@ -205936,6 +205962,24 @@ var init_stdio_startup_gate = __esm({
205936
205962
  this.queuedMessages.push(line);
205937
205963
  this.queuedBytes += bytes;
205938
205964
  }
205965
+ handleReadyLine(line) {
205966
+ const parsed = this.parseLine(line);
205967
+ if (parsed && !("error" in parsed) && this.isDiscoveryRequest(parsed.message)) {
205968
+ const response = {
205969
+ jsonrpc: "2.0",
205970
+ id: parsed.message.id,
205971
+ result: createMcpStartupDiscoverResult(this.serverInfo)
205972
+ };
205973
+ try {
205974
+ this.stdout.write(`${JSON.stringify(response)}
205975
+ `);
205976
+ } catch (error40) {
205977
+ this.fail(error40 instanceof Error ? error40 : new Error(String(error40)));
205978
+ }
205979
+ return;
205980
+ }
205981
+ this.input.write(line);
205982
+ }
205939
205983
  parseLine(line) {
205940
205984
  const trimmed = line.endsWith("\n") ? line.slice(0, -1).replace(/\r$/, "") : line;
205941
205985
  if (!trimmed.trim()) return null;
@@ -205974,7 +206018,8 @@ var init_stdio_startup_gate = __esm({
205974
206018
  if (message.method !== MCP_SERVER_DISCOVER_METHOD) return false;
205975
206019
  if (!Object.prototype.hasOwnProperty.call(message, "id")) return false;
205976
206020
  const params = message.params;
205977
- return params === void 0 || typeof params === "object" && params !== null && !Array.isArray(params);
206021
+ if (params === void 0) return true;
206022
+ return typeof params === "object" && params !== null && !Array.isArray(params) && !Object.prototype.hasOwnProperty.call(params, "_meta");
205978
206023
  }
205979
206024
  isValidRequestId(id) {
205980
206025
  return id === null || typeof id === "string" || typeof id === "number" && Number.isFinite(id);
@@ -206053,6 +206098,297 @@ var init_mcp_root_path = __esm({
206053
206098
  }
206054
206099
  });
206055
206100
 
206101
+ // node_modules/zod/v4/mini/parse.js
206102
+ var init_parse8 = __esm({
206103
+ "node_modules/zod/v4/mini/parse.js"() {
206104
+ "use strict";
206105
+ init_esm_shims();
206106
+ init_core3();
206107
+ }
206108
+ });
206109
+
206110
+ // node_modules/zod/v4/mini/schemas.js
206111
+ function object2(shape, params) {
206112
+ const def = {
206113
+ type: "object",
206114
+ get shape() {
206115
+ util_exports.assignProp(this, "shape", { ...shape });
206116
+ return this.shape;
206117
+ },
206118
+ ...util_exports.normalizeParams(params)
206119
+ };
206120
+ return new ZodMiniObject(def);
206121
+ }
206122
+ var ZodMiniType, ZodMiniObject;
206123
+ var init_schemas4 = __esm({
206124
+ "node_modules/zod/v4/mini/schemas.js"() {
206125
+ "use strict";
206126
+ init_esm_shims();
206127
+ init_core3();
206128
+ init_core3();
206129
+ init_parse8();
206130
+ ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
206131
+ if (!inst._zod)
206132
+ throw new Error("Uninitialized schema in ZodMiniType.");
206133
+ $ZodType.init(inst, def);
206134
+ inst.def = def;
206135
+ inst.parse = (data, params) => parse2(inst, data, params, { callee: inst.parse });
206136
+ inst.safeParse = (data, params) => safeParse(inst, data, params);
206137
+ inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
206138
+ inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
206139
+ inst.check = (...checks) => {
206140
+ return inst.clone(
206141
+ {
206142
+ ...def,
206143
+ checks: [
206144
+ ...def.checks ?? [],
206145
+ ...checks.map((ch2) => typeof ch2 === "function" ? { _zod: { check: ch2, def: { check: "custom" }, onattach: [] } } : ch2)
206146
+ ]
206147
+ }
206148
+ // { parent: true }
206149
+ );
206150
+ };
206151
+ inst.clone = (_def, params) => clone2(inst, _def, params);
206152
+ inst.brand = () => inst;
206153
+ inst.register = ((reg, meta) => {
206154
+ reg.add(inst, meta);
206155
+ return inst;
206156
+ });
206157
+ });
206158
+ ZodMiniObject = /* @__PURE__ */ $constructor("ZodMiniObject", (inst, def) => {
206159
+ $ZodObject.init(inst, def);
206160
+ ZodMiniType.init(inst, def);
206161
+ util_exports.defineLazy(inst, "shape", () => def.shape);
206162
+ });
206163
+ }
206164
+ });
206165
+
206166
+ // node_modules/zod/v4/mini/checks.js
206167
+ var init_checks3 = __esm({
206168
+ "node_modules/zod/v4/mini/checks.js"() {
206169
+ "use strict";
206170
+ init_esm_shims();
206171
+ }
206172
+ });
206173
+
206174
+ // node_modules/zod/v4/mini/iso.js
206175
+ var init_iso2 = __esm({
206176
+ "node_modules/zod/v4/mini/iso.js"() {
206177
+ "use strict";
206178
+ init_esm_shims();
206179
+ }
206180
+ });
206181
+
206182
+ // node_modules/zod/v4/mini/coerce.js
206183
+ var init_coerce2 = __esm({
206184
+ "node_modules/zod/v4/mini/coerce.js"() {
206185
+ "use strict";
206186
+ init_esm_shims();
206187
+ }
206188
+ });
206189
+
206190
+ // node_modules/zod/v4/mini/external.js
206191
+ var init_external3 = __esm({
206192
+ "node_modules/zod/v4/mini/external.js"() {
206193
+ "use strict";
206194
+ init_esm_shims();
206195
+ init_core3();
206196
+ init_parse8();
206197
+ init_schemas4();
206198
+ init_checks3();
206199
+ init_core3();
206200
+ init_locales();
206201
+ init_iso2();
206202
+ init_coerce2();
206203
+ }
206204
+ });
206205
+
206206
+ // node_modules/zod/v4/mini/index.js
206207
+ var init_mini = __esm({
206208
+ "node_modules/zod/v4/mini/index.js"() {
206209
+ "use strict";
206210
+ init_esm_shims();
206211
+ init_external3();
206212
+ }
206213
+ });
206214
+
206215
+ // node_modules/zod/v4-mini/index.js
206216
+ var init_v4_mini = __esm({
206217
+ "node_modules/zod/v4-mini/index.js"() {
206218
+ "use strict";
206219
+ init_esm_shims();
206220
+ init_mini();
206221
+ }
206222
+ });
206223
+
206224
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
206225
+ function isZ4Schema(s4) {
206226
+ const schema = s4;
206227
+ return !!schema._zod;
206228
+ }
206229
+ function objectFromShape(shape) {
206230
+ const values = Object.values(shape);
206231
+ if (values.length === 0)
206232
+ return object2({});
206233
+ const allV4 = values.every(isZ4Schema);
206234
+ const allV3 = values.every((s4) => !isZ4Schema(s4));
206235
+ if (allV4)
206236
+ return object2(shape);
206237
+ if (allV3)
206238
+ return objectType(shape);
206239
+ throw new Error("Mixed Zod versions detected in object shape.");
206240
+ }
206241
+ function safeParse4(schema, data) {
206242
+ if (isZ4Schema(schema)) {
206243
+ const result2 = safeParse(schema, data);
206244
+ return result2;
206245
+ }
206246
+ const v3Schema = schema;
206247
+ const result = v3Schema.safeParse(data);
206248
+ return result;
206249
+ }
206250
+ async function safeParseAsync3(schema, data) {
206251
+ if (isZ4Schema(schema)) {
206252
+ const result2 = await safeParseAsync(schema, data);
206253
+ return result2;
206254
+ }
206255
+ const v3Schema = schema;
206256
+ const result = await v3Schema.safeParseAsync(data);
206257
+ return result;
206258
+ }
206259
+ function getObjectShape(schema) {
206260
+ if (!schema)
206261
+ return void 0;
206262
+ let rawShape;
206263
+ if (isZ4Schema(schema)) {
206264
+ const v4Schema = schema;
206265
+ rawShape = v4Schema._zod?.def?.shape;
206266
+ } else {
206267
+ const v3Schema = schema;
206268
+ rawShape = v3Schema.shape;
206269
+ }
206270
+ if (!rawShape)
206271
+ return void 0;
206272
+ if (typeof rawShape === "function") {
206273
+ try {
206274
+ return rawShape();
206275
+ } catch {
206276
+ return void 0;
206277
+ }
206278
+ }
206279
+ return rawShape;
206280
+ }
206281
+ function normalizeObjectSchema(schema) {
206282
+ if (!schema)
206283
+ return void 0;
206284
+ if (typeof schema === "object") {
206285
+ const asV3 = schema;
206286
+ const asV4 = schema;
206287
+ if (!asV3._def && !asV4._zod) {
206288
+ const values = Object.values(schema);
206289
+ if (values.length > 0 && values.every((v6) => typeof v6 === "object" && v6 !== null && (v6._def !== void 0 || v6._zod !== void 0 || typeof v6.parse === "function"))) {
206290
+ return objectFromShape(schema);
206291
+ }
206292
+ }
206293
+ }
206294
+ if (isZ4Schema(schema)) {
206295
+ const v4Schema = schema;
206296
+ const def = v4Schema._zod?.def;
206297
+ if (def && (def.type === "object" || def.shape !== void 0)) {
206298
+ return schema;
206299
+ }
206300
+ } else {
206301
+ const v3Schema = schema;
206302
+ if (v3Schema.shape !== void 0) {
206303
+ return schema;
206304
+ }
206305
+ }
206306
+ return void 0;
206307
+ }
206308
+ function getDotPath(path48) {
206309
+ if (path48.length === 0) {
206310
+ return "object root";
206311
+ }
206312
+ return path48.reduce((acc, seg, index) => {
206313
+ if (index === 0) {
206314
+ return String(seg);
206315
+ }
206316
+ if (typeof seg === "number") {
206317
+ return `${acc}[${seg}]`;
206318
+ }
206319
+ return `${acc}.${seg}`;
206320
+ }, "");
206321
+ }
206322
+ function getParseErrorMessage(error40) {
206323
+ if (error40 && typeof error40 === "object") {
206324
+ if ("issues" in error40 && Array.isArray(error40.issues) && error40.issues.length > 0) {
206325
+ return error40.issues.map((i4) => {
206326
+ if (!i4.path?.length) {
206327
+ return i4.message;
206328
+ }
206329
+ return `${i4.message} at ${getDotPath(i4.path)}`;
206330
+ }).join("\n");
206331
+ }
206332
+ if ("message" in error40 && typeof error40.message === "string") {
206333
+ return error40.message;
206334
+ }
206335
+ try {
206336
+ return JSON.stringify(error40);
206337
+ } catch {
206338
+ return String(error40);
206339
+ }
206340
+ }
206341
+ return String(error40);
206342
+ }
206343
+ function getSchemaDescription(schema) {
206344
+ return schema.description;
206345
+ }
206346
+ function isSchemaOptional(schema) {
206347
+ if (isZ4Schema(schema)) {
206348
+ const v4Schema = schema;
206349
+ return v4Schema._zod?.def?.type === "optional";
206350
+ }
206351
+ const v3Schema = schema;
206352
+ if (typeof schema.isOptional === "function") {
206353
+ return schema.isOptional();
206354
+ }
206355
+ return v3Schema._def?.typeName === "ZodOptional";
206356
+ }
206357
+ function getLiteralValue(schema) {
206358
+ if (isZ4Schema(schema)) {
206359
+ const v4Schema = schema;
206360
+ const def2 = v4Schema._zod?.def;
206361
+ if (def2) {
206362
+ if (def2.value !== void 0)
206363
+ return def2.value;
206364
+ if (Array.isArray(def2.values) && def2.values.length > 0) {
206365
+ return def2.values[0];
206366
+ }
206367
+ }
206368
+ }
206369
+ const v3Schema = schema;
206370
+ const def = v3Schema._def;
206371
+ if (def) {
206372
+ if (def.value !== void 0)
206373
+ return def.value;
206374
+ if (Array.isArray(def.values) && def.values.length > 0) {
206375
+ return def.values[0];
206376
+ }
206377
+ }
206378
+ const directValue = schema.value;
206379
+ if (directValue !== void 0)
206380
+ return directValue;
206381
+ return void 0;
206382
+ }
206383
+ var init_zod_compat = __esm({
206384
+ "node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js"() {
206385
+ "use strict";
206386
+ init_esm_shims();
206387
+ init_v3();
206388
+ init_v4_mini();
206389
+ }
206390
+ });
206391
+
206056
206392
  // node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
206057
206393
  var types_exports3 = {};
206058
206394
  __export(types_exports3, {
@@ -207772,422 +208108,6 @@ var init_types8 = __esm({
207772
208108
  }
207773
208109
  });
207774
208110
 
207775
- // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
207776
- function deserializeMessage(line) {
207777
- return JSONRPCMessageSchema.parse(JSON.parse(line));
207778
- }
207779
- function serializeMessage(message) {
207780
- return JSON.stringify(message) + "\n";
207781
- }
207782
- var STDIO_DEFAULT_MAX_BUFFER_SIZE, ReadBuffer;
207783
- var init_stdio = __esm({
207784
- "node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js"() {
207785
- "use strict";
207786
- init_esm_shims();
207787
- init_types8();
207788
- STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
207789
- ReadBuffer = class {
207790
- constructor(options) {
207791
- this._maxBufferSize = options?.maxBufferSize ?? STDIO_DEFAULT_MAX_BUFFER_SIZE;
207792
- }
207793
- append(chunk) {
207794
- const newSize = (this._buffer?.length ?? 0) + chunk.length;
207795
- if (newSize > this._maxBufferSize) {
207796
- this.clear();
207797
- throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
207798
- }
207799
- this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
207800
- }
207801
- readMessage() {
207802
- if (!this._buffer) {
207803
- return null;
207804
- }
207805
- const index = this._buffer.indexOf("\n");
207806
- if (index === -1) {
207807
- return null;
207808
- }
207809
- const line = this._buffer.toString("utf8", 0, index).replace(/\r$/, "");
207810
- this._buffer = this._buffer.subarray(index + 1);
207811
- return deserializeMessage(line);
207812
- }
207813
- clear() {
207814
- this._buffer = void 0;
207815
- }
207816
- };
207817
- }
207818
- });
207819
-
207820
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
207821
- var stdio_exports = {};
207822
- __export(stdio_exports, {
207823
- StdioServerTransport: () => StdioServerTransport
207824
- });
207825
- import process2 from "process";
207826
- var StdioServerTransport;
207827
- var init_stdio2 = __esm({
207828
- "node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js"() {
207829
- "use strict";
207830
- init_esm_shims();
207831
- init_stdio();
207832
- StdioServerTransport = class {
207833
- constructor(_stdin = process2.stdin, _stdout = process2.stdout, options) {
207834
- this._stdin = _stdin;
207835
- this._stdout = _stdout;
207836
- this._started = false;
207837
- this._ondata = (chunk) => {
207838
- try {
207839
- this._readBuffer.append(chunk);
207840
- this.processReadBuffer();
207841
- } catch (error40) {
207842
- this.onerror?.(error40);
207843
- this.close().catch(() => {
207844
- });
207845
- }
207846
- };
207847
- this._onerror = (error40) => {
207848
- this.onerror?.(error40);
207849
- };
207850
- this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
207851
- }
207852
- /**
207853
- * Starts listening for messages on stdin.
207854
- */
207855
- async start() {
207856
- if (this._started) {
207857
- throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");
207858
- }
207859
- this._started = true;
207860
- this._stdin.on("data", this._ondata);
207861
- this._stdin.on("error", this._onerror);
207862
- }
207863
- processReadBuffer() {
207864
- while (true) {
207865
- try {
207866
- const message = this._readBuffer.readMessage();
207867
- if (message === null) {
207868
- break;
207869
- }
207870
- this.onmessage?.(message);
207871
- } catch (error40) {
207872
- this.onerror?.(error40);
207873
- }
207874
- }
207875
- }
207876
- async close() {
207877
- this._stdin.off("data", this._ondata);
207878
- this._stdin.off("error", this._onerror);
207879
- const remainingDataListeners = this._stdin.listenerCount("data");
207880
- if (remainingDataListeners === 0) {
207881
- this._stdin.pause();
207882
- }
207883
- this._readBuffer.clear();
207884
- this.onclose?.();
207885
- }
207886
- send(message) {
207887
- return new Promise((resolve6) => {
207888
- const json4 = serializeMessage(message);
207889
- if (this._stdout.write(json4)) {
207890
- resolve6();
207891
- } else {
207892
- this._stdout.once("drain", resolve6);
207893
- }
207894
- });
207895
- }
207896
- };
207897
- }
207898
- });
207899
-
207900
- // node_modules/zod/v4/mini/parse.js
207901
- var init_parse8 = __esm({
207902
- "node_modules/zod/v4/mini/parse.js"() {
207903
- "use strict";
207904
- init_esm_shims();
207905
- init_core3();
207906
- }
207907
- });
207908
-
207909
- // node_modules/zod/v4/mini/schemas.js
207910
- function object2(shape, params) {
207911
- const def = {
207912
- type: "object",
207913
- get shape() {
207914
- util_exports.assignProp(this, "shape", { ...shape });
207915
- return this.shape;
207916
- },
207917
- ...util_exports.normalizeParams(params)
207918
- };
207919
- return new ZodMiniObject(def);
207920
- }
207921
- var ZodMiniType, ZodMiniObject;
207922
- var init_schemas4 = __esm({
207923
- "node_modules/zod/v4/mini/schemas.js"() {
207924
- "use strict";
207925
- init_esm_shims();
207926
- init_core3();
207927
- init_core3();
207928
- init_parse8();
207929
- ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
207930
- if (!inst._zod)
207931
- throw new Error("Uninitialized schema in ZodMiniType.");
207932
- $ZodType.init(inst, def);
207933
- inst.def = def;
207934
- inst.parse = (data, params) => parse2(inst, data, params, { callee: inst.parse });
207935
- inst.safeParse = (data, params) => safeParse(inst, data, params);
207936
- inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
207937
- inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
207938
- inst.check = (...checks) => {
207939
- return inst.clone(
207940
- {
207941
- ...def,
207942
- checks: [
207943
- ...def.checks ?? [],
207944
- ...checks.map((ch2) => typeof ch2 === "function" ? { _zod: { check: ch2, def: { check: "custom" }, onattach: [] } } : ch2)
207945
- ]
207946
- }
207947
- // { parent: true }
207948
- );
207949
- };
207950
- inst.clone = (_def, params) => clone2(inst, _def, params);
207951
- inst.brand = () => inst;
207952
- inst.register = ((reg, meta) => {
207953
- reg.add(inst, meta);
207954
- return inst;
207955
- });
207956
- });
207957
- ZodMiniObject = /* @__PURE__ */ $constructor("ZodMiniObject", (inst, def) => {
207958
- $ZodObject.init(inst, def);
207959
- ZodMiniType.init(inst, def);
207960
- util_exports.defineLazy(inst, "shape", () => def.shape);
207961
- });
207962
- }
207963
- });
207964
-
207965
- // node_modules/zod/v4/mini/checks.js
207966
- var init_checks3 = __esm({
207967
- "node_modules/zod/v4/mini/checks.js"() {
207968
- "use strict";
207969
- init_esm_shims();
207970
- }
207971
- });
207972
-
207973
- // node_modules/zod/v4/mini/iso.js
207974
- var init_iso2 = __esm({
207975
- "node_modules/zod/v4/mini/iso.js"() {
207976
- "use strict";
207977
- init_esm_shims();
207978
- }
207979
- });
207980
-
207981
- // node_modules/zod/v4/mini/coerce.js
207982
- var init_coerce2 = __esm({
207983
- "node_modules/zod/v4/mini/coerce.js"() {
207984
- "use strict";
207985
- init_esm_shims();
207986
- }
207987
- });
207988
-
207989
- // node_modules/zod/v4/mini/external.js
207990
- var init_external3 = __esm({
207991
- "node_modules/zod/v4/mini/external.js"() {
207992
- "use strict";
207993
- init_esm_shims();
207994
- init_core3();
207995
- init_parse8();
207996
- init_schemas4();
207997
- init_checks3();
207998
- init_core3();
207999
- init_locales();
208000
- init_iso2();
208001
- init_coerce2();
208002
- }
208003
- });
208004
-
208005
- // node_modules/zod/v4/mini/index.js
208006
- var init_mini = __esm({
208007
- "node_modules/zod/v4/mini/index.js"() {
208008
- "use strict";
208009
- init_esm_shims();
208010
- init_external3();
208011
- }
208012
- });
208013
-
208014
- // node_modules/zod/v4-mini/index.js
208015
- var init_v4_mini = __esm({
208016
- "node_modules/zod/v4-mini/index.js"() {
208017
- "use strict";
208018
- init_esm_shims();
208019
- init_mini();
208020
- }
208021
- });
208022
-
208023
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
208024
- function isZ4Schema(s4) {
208025
- const schema = s4;
208026
- return !!schema._zod;
208027
- }
208028
- function objectFromShape(shape) {
208029
- const values = Object.values(shape);
208030
- if (values.length === 0)
208031
- return object2({});
208032
- const allV4 = values.every(isZ4Schema);
208033
- const allV3 = values.every((s4) => !isZ4Schema(s4));
208034
- if (allV4)
208035
- return object2(shape);
208036
- if (allV3)
208037
- return objectType(shape);
208038
- throw new Error("Mixed Zod versions detected in object shape.");
208039
- }
208040
- function safeParse4(schema, data) {
208041
- if (isZ4Schema(schema)) {
208042
- const result2 = safeParse(schema, data);
208043
- return result2;
208044
- }
208045
- const v3Schema = schema;
208046
- const result = v3Schema.safeParse(data);
208047
- return result;
208048
- }
208049
- async function safeParseAsync3(schema, data) {
208050
- if (isZ4Schema(schema)) {
208051
- const result2 = await safeParseAsync(schema, data);
208052
- return result2;
208053
- }
208054
- const v3Schema = schema;
208055
- const result = await v3Schema.safeParseAsync(data);
208056
- return result;
208057
- }
208058
- function getObjectShape(schema) {
208059
- if (!schema)
208060
- return void 0;
208061
- let rawShape;
208062
- if (isZ4Schema(schema)) {
208063
- const v4Schema = schema;
208064
- rawShape = v4Schema._zod?.def?.shape;
208065
- } else {
208066
- const v3Schema = schema;
208067
- rawShape = v3Schema.shape;
208068
- }
208069
- if (!rawShape)
208070
- return void 0;
208071
- if (typeof rawShape === "function") {
208072
- try {
208073
- return rawShape();
208074
- } catch {
208075
- return void 0;
208076
- }
208077
- }
208078
- return rawShape;
208079
- }
208080
- function normalizeObjectSchema(schema) {
208081
- if (!schema)
208082
- return void 0;
208083
- if (typeof schema === "object") {
208084
- const asV3 = schema;
208085
- const asV4 = schema;
208086
- if (!asV3._def && !asV4._zod) {
208087
- const values = Object.values(schema);
208088
- if (values.length > 0 && values.every((v6) => typeof v6 === "object" && v6 !== null && (v6._def !== void 0 || v6._zod !== void 0 || typeof v6.parse === "function"))) {
208089
- return objectFromShape(schema);
208090
- }
208091
- }
208092
- }
208093
- if (isZ4Schema(schema)) {
208094
- const v4Schema = schema;
208095
- const def = v4Schema._zod?.def;
208096
- if (def && (def.type === "object" || def.shape !== void 0)) {
208097
- return schema;
208098
- }
208099
- } else {
208100
- const v3Schema = schema;
208101
- if (v3Schema.shape !== void 0) {
208102
- return schema;
208103
- }
208104
- }
208105
- return void 0;
208106
- }
208107
- function getDotPath(path48) {
208108
- if (path48.length === 0) {
208109
- return "object root";
208110
- }
208111
- return path48.reduce((acc, seg, index) => {
208112
- if (index === 0) {
208113
- return String(seg);
208114
- }
208115
- if (typeof seg === "number") {
208116
- return `${acc}[${seg}]`;
208117
- }
208118
- return `${acc}.${seg}`;
208119
- }, "");
208120
- }
208121
- function getParseErrorMessage(error40) {
208122
- if (error40 && typeof error40 === "object") {
208123
- if ("issues" in error40 && Array.isArray(error40.issues) && error40.issues.length > 0) {
208124
- return error40.issues.map((i4) => {
208125
- if (!i4.path?.length) {
208126
- return i4.message;
208127
- }
208128
- return `${i4.message} at ${getDotPath(i4.path)}`;
208129
- }).join("\n");
208130
- }
208131
- if ("message" in error40 && typeof error40.message === "string") {
208132
- return error40.message;
208133
- }
208134
- try {
208135
- return JSON.stringify(error40);
208136
- } catch {
208137
- return String(error40);
208138
- }
208139
- }
208140
- return String(error40);
208141
- }
208142
- function getSchemaDescription(schema) {
208143
- return schema.description;
208144
- }
208145
- function isSchemaOptional(schema) {
208146
- if (isZ4Schema(schema)) {
208147
- const v4Schema = schema;
208148
- return v4Schema._zod?.def?.type === "optional";
208149
- }
208150
- const v3Schema = schema;
208151
- if (typeof schema.isOptional === "function") {
208152
- return schema.isOptional();
208153
- }
208154
- return v3Schema._def?.typeName === "ZodOptional";
208155
- }
208156
- function getLiteralValue(schema) {
208157
- if (isZ4Schema(schema)) {
208158
- const v4Schema = schema;
208159
- const def2 = v4Schema._zod?.def;
208160
- if (def2) {
208161
- if (def2.value !== void 0)
208162
- return def2.value;
208163
- if (Array.isArray(def2.values) && def2.values.length > 0) {
208164
- return def2.values[0];
208165
- }
208166
- }
208167
- }
208168
- const v3Schema = schema;
208169
- const def = v3Schema._def;
208170
- if (def) {
208171
- if (def.value !== void 0)
208172
- return def.value;
208173
- if (Array.isArray(def.values) && def.values.length > 0) {
208174
- return def.values[0];
208175
- }
208176
- }
208177
- const directValue = schema.value;
208178
- if (directValue !== void 0)
208179
- return directValue;
208180
- return void 0;
208181
- }
208182
- var init_zod_compat = __esm({
208183
- "node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js"() {
208184
- "use strict";
208185
- init_esm_shims();
208186
- init_v3();
208187
- init_v4_mini();
208188
- }
208189
- });
208190
-
208191
208111
  // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
208192
208112
  function isTerminal(status) {
208193
208113
  return status === "completed" || status === "failed" || status === "cancelled";
@@ -216241,6 +216161,783 @@ var init_ajv_provider = __esm({
216241
216161
  }
216242
216162
  });
216243
216163
 
216164
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/client.js
216165
+ var ExperimentalClientTasks;
216166
+ var init_client3 = __esm({
216167
+ "node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/client.js"() {
216168
+ "use strict";
216169
+ init_esm_shims();
216170
+ init_types8();
216171
+ ExperimentalClientTasks = class {
216172
+ constructor(_client) {
216173
+ this._client = _client;
216174
+ }
216175
+ /**
216176
+ * Calls a tool and returns an AsyncGenerator that yields response messages.
216177
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
216178
+ *
216179
+ * This method provides streaming access to tool execution, allowing you to
216180
+ * observe intermediate task status updates for long-running tool calls.
216181
+ * Automatically validates structured output if the tool has an outputSchema.
216182
+ *
216183
+ * @example
216184
+ * ```typescript
216185
+ * const stream = client.experimental.tasks.callToolStream({ name: 'myTool', arguments: {} });
216186
+ * for await (const message of stream) {
216187
+ * switch (message.type) {
216188
+ * case 'taskCreated':
216189
+ * console.log('Tool execution started:', message.task.taskId);
216190
+ * break;
216191
+ * case 'taskStatus':
216192
+ * console.log('Tool status:', message.task.status);
216193
+ * break;
216194
+ * case 'result':
216195
+ * console.log('Tool result:', message.result);
216196
+ * break;
216197
+ * case 'error':
216198
+ * console.error('Tool error:', message.error);
216199
+ * break;
216200
+ * }
216201
+ * }
216202
+ * ```
216203
+ *
216204
+ * @param params - Tool call parameters (name and arguments)
216205
+ * @param resultSchema - Zod schema for validating the result (defaults to CallToolResultSchema)
216206
+ * @param options - Optional request options (timeout, signal, task creation params, etc.)
216207
+ * @returns AsyncGenerator that yields ResponseMessage objects
216208
+ *
216209
+ * @experimental
216210
+ */
216211
+ async *callToolStream(params, resultSchema = CallToolResultSchema, options) {
216212
+ const clientInternal = this._client;
216213
+ const optionsWithTask = {
216214
+ ...options,
216215
+ // We check if the tool is known to be a task during auto-configuration, but assume
216216
+ // the caller knows what they're doing if they pass this explicitly
216217
+ task: options?.task ?? (clientInternal.isToolTask(params.name) ? {} : void 0)
216218
+ };
216219
+ const stream2 = clientInternal.requestStream({ method: "tools/call", params }, resultSchema, optionsWithTask);
216220
+ const validator = clientInternal.getToolOutputValidator(params.name);
216221
+ for await (const message of stream2) {
216222
+ if (message.type === "result" && validator) {
216223
+ const result = message.result;
216224
+ if (!result.structuredContent && !result.isError) {
216225
+ yield {
216226
+ type: "error",
216227
+ error: new McpError(ErrorCode.InvalidRequest, `Tool ${params.name} has an output schema but did not return structured content`)
216228
+ };
216229
+ return;
216230
+ }
216231
+ if (result.structuredContent) {
216232
+ try {
216233
+ const validationResult = validator(result.structuredContent);
216234
+ if (!validationResult.valid) {
216235
+ yield {
216236
+ type: "error",
216237
+ error: new McpError(ErrorCode.InvalidParams, `Structured content does not match the tool's output schema: ${validationResult.errorMessage}`)
216238
+ };
216239
+ return;
216240
+ }
216241
+ } catch (error40) {
216242
+ if (error40 instanceof McpError) {
216243
+ yield { type: "error", error: error40 };
216244
+ return;
216245
+ }
216246
+ yield {
216247
+ type: "error",
216248
+ error: new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error40 instanceof Error ? error40.message : String(error40)}`)
216249
+ };
216250
+ return;
216251
+ }
216252
+ }
216253
+ }
216254
+ yield message;
216255
+ }
216256
+ }
216257
+ /**
216258
+ * Gets the current status of a task.
216259
+ *
216260
+ * @param taskId - The task identifier
216261
+ * @param options - Optional request options
216262
+ * @returns The task status
216263
+ *
216264
+ * @experimental
216265
+ */
216266
+ async getTask(taskId, options) {
216267
+ return this._client.getTask({ taskId }, options);
216268
+ }
216269
+ /**
216270
+ * Retrieves the result of a completed task.
216271
+ *
216272
+ * @param taskId - The task identifier
216273
+ * @param resultSchema - Zod schema for validating the result
216274
+ * @param options - Optional request options
216275
+ * @returns The task result
216276
+ *
216277
+ * @experimental
216278
+ */
216279
+ async getTaskResult(taskId, resultSchema, options) {
216280
+ return this._client.getTaskResult({ taskId }, resultSchema, options);
216281
+ }
216282
+ /**
216283
+ * Lists tasks with optional pagination.
216284
+ *
216285
+ * @param cursor - Optional pagination cursor
216286
+ * @param options - Optional request options
216287
+ * @returns List of tasks with optional next cursor
216288
+ *
216289
+ * @experimental
216290
+ */
216291
+ async listTasks(cursor, options) {
216292
+ return this._client.listTasks(cursor ? { cursor } : void 0, options);
216293
+ }
216294
+ /**
216295
+ * Cancels a running task.
216296
+ *
216297
+ * @param taskId - The task identifier
216298
+ * @param options - Optional request options
216299
+ *
216300
+ * @experimental
216301
+ */
216302
+ async cancelTask(taskId, options) {
216303
+ return this._client.cancelTask({ taskId }, options);
216304
+ }
216305
+ /**
216306
+ * Sends a request and returns an AsyncGenerator that yields response messages.
216307
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
216308
+ *
216309
+ * This method provides streaming access to request processing, allowing you to
216310
+ * observe intermediate task status updates for task-augmented requests.
216311
+ *
216312
+ * @param request - The request to send
216313
+ * @param resultSchema - Zod schema for validating the result
216314
+ * @param options - Optional request options (timeout, signal, task creation params, etc.)
216315
+ * @returns AsyncGenerator that yields ResponseMessage objects
216316
+ *
216317
+ * @experimental
216318
+ */
216319
+ requestStream(request, resultSchema, options) {
216320
+ return this._client.requestStream(request, resultSchema, options);
216321
+ }
216322
+ };
216323
+ }
216324
+ });
216325
+
216326
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
216327
+ function assertToolsCallTaskCapability(requests, method, entityName) {
216328
+ if (!requests) {
216329
+ throw new Error(`${entityName} does not support task creation (required for ${method})`);
216330
+ }
216331
+ switch (method) {
216332
+ case "tools/call":
216333
+ if (!requests.tools?.call) {
216334
+ throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
216335
+ }
216336
+ break;
216337
+ default:
216338
+ break;
216339
+ }
216340
+ }
216341
+ function assertClientRequestTaskCapability(requests, method, entityName) {
216342
+ if (!requests) {
216343
+ throw new Error(`${entityName} does not support task creation (required for ${method})`);
216344
+ }
216345
+ switch (method) {
216346
+ case "sampling/createMessage":
216347
+ if (!requests.sampling?.createMessage) {
216348
+ throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
216349
+ }
216350
+ break;
216351
+ case "elicitation/create":
216352
+ if (!requests.elicitation?.create) {
216353
+ throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
216354
+ }
216355
+ break;
216356
+ default:
216357
+ break;
216358
+ }
216359
+ }
216360
+ var init_helpers2 = __esm({
216361
+ "node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js"() {
216362
+ "use strict";
216363
+ init_esm_shims();
216364
+ }
216365
+ });
216366
+
216367
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
216368
+ function applyElicitationDefaults(schema, data) {
216369
+ if (!schema || data === null || typeof data !== "object")
216370
+ return;
216371
+ if (schema.type === "object" && schema.properties && typeof schema.properties === "object") {
216372
+ const obj = data;
216373
+ const props = schema.properties;
216374
+ for (const key of Object.keys(props)) {
216375
+ const propSchema = props[key];
216376
+ if (obj[key] === void 0 && Object.prototype.hasOwnProperty.call(propSchema, "default")) {
216377
+ obj[key] = propSchema.default;
216378
+ }
216379
+ if (obj[key] !== void 0) {
216380
+ applyElicitationDefaults(propSchema, obj[key]);
216381
+ }
216382
+ }
216383
+ }
216384
+ if (Array.isArray(schema.anyOf)) {
216385
+ for (const sub of schema.anyOf) {
216386
+ if (typeof sub !== "boolean") {
216387
+ applyElicitationDefaults(sub, data);
216388
+ }
216389
+ }
216390
+ }
216391
+ if (Array.isArray(schema.oneOf)) {
216392
+ for (const sub of schema.oneOf) {
216393
+ if (typeof sub !== "boolean") {
216394
+ applyElicitationDefaults(sub, data);
216395
+ }
216396
+ }
216397
+ }
216398
+ }
216399
+ function getSupportedElicitationModes(capabilities) {
216400
+ if (!capabilities) {
216401
+ return { supportsFormMode: false, supportsUrlMode: false };
216402
+ }
216403
+ const hasFormCapability = capabilities.form !== void 0;
216404
+ const hasUrlCapability = capabilities.url !== void 0;
216405
+ const supportsFormMode = hasFormCapability || !hasFormCapability && !hasUrlCapability;
216406
+ const supportsUrlMode = hasUrlCapability;
216407
+ return { supportsFormMode, supportsUrlMode };
216408
+ }
216409
+ var Client;
216410
+ var init_client4 = __esm({
216411
+ "node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js"() {
216412
+ "use strict";
216413
+ init_esm_shims();
216414
+ init_protocol();
216415
+ init_types8();
216416
+ init_ajv_provider();
216417
+ init_zod_compat();
216418
+ init_client3();
216419
+ init_helpers2();
216420
+ Client = class extends Protocol {
216421
+ /**
216422
+ * Initializes this client with the given name and version information.
216423
+ */
216424
+ constructor(_clientInfo, options) {
216425
+ super(options);
216426
+ this._clientInfo = _clientInfo;
216427
+ this._cachedToolOutputValidators = /* @__PURE__ */ new Map();
216428
+ this._cachedKnownTaskTools = /* @__PURE__ */ new Set();
216429
+ this._cachedRequiredTaskTools = /* @__PURE__ */ new Set();
216430
+ this._listChangedDebounceTimers = /* @__PURE__ */ new Map();
216431
+ this._capabilities = options?.capabilities ?? {};
216432
+ this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
216433
+ if (options?.listChanged) {
216434
+ this._pendingListChangedConfig = options.listChanged;
216435
+ }
216436
+ }
216437
+ /**
216438
+ * Set up handlers for list changed notifications based on config and server capabilities.
216439
+ * This should only be called after initialization when server capabilities are known.
216440
+ * Handlers are silently skipped if the server doesn't advertise the corresponding listChanged capability.
216441
+ * @internal
216442
+ */
216443
+ _setupListChangedHandlers(config2) {
216444
+ if (config2.tools && this._serverCapabilities?.tools?.listChanged) {
216445
+ this._setupListChangedHandler("tools", ToolListChangedNotificationSchema, config2.tools, async () => {
216446
+ const result = await this.listTools();
216447
+ return result.tools;
216448
+ });
216449
+ }
216450
+ if (config2.prompts && this._serverCapabilities?.prompts?.listChanged) {
216451
+ this._setupListChangedHandler("prompts", PromptListChangedNotificationSchema, config2.prompts, async () => {
216452
+ const result = await this.listPrompts();
216453
+ return result.prompts;
216454
+ });
216455
+ }
216456
+ if (config2.resources && this._serverCapabilities?.resources?.listChanged) {
216457
+ this._setupListChangedHandler("resources", ResourceListChangedNotificationSchema, config2.resources, async () => {
216458
+ const result = await this.listResources();
216459
+ return result.resources;
216460
+ });
216461
+ }
216462
+ }
216463
+ /**
216464
+ * Access experimental features.
216465
+ *
216466
+ * WARNING: These APIs are experimental and may change without notice.
216467
+ *
216468
+ * @experimental
216469
+ */
216470
+ get experimental() {
216471
+ if (!this._experimental) {
216472
+ this._experimental = {
216473
+ tasks: new ExperimentalClientTasks(this)
216474
+ };
216475
+ }
216476
+ return this._experimental;
216477
+ }
216478
+ /**
216479
+ * Registers new capabilities. This can only be called before connecting to a transport.
216480
+ *
216481
+ * The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).
216482
+ */
216483
+ registerCapabilities(capabilities) {
216484
+ if (this.transport) {
216485
+ throw new Error("Cannot register capabilities after connecting to transport");
216486
+ }
216487
+ this._capabilities = mergeCapabilities(this._capabilities, capabilities);
216488
+ }
216489
+ /**
216490
+ * Override request handler registration to enforce client-side validation for elicitation.
216491
+ */
216492
+ setRequestHandler(requestSchema, handler) {
216493
+ const shape = getObjectShape(requestSchema);
216494
+ const methodSchema = shape?.method;
216495
+ if (!methodSchema) {
216496
+ throw new Error("Schema is missing a method literal");
216497
+ }
216498
+ const methodValue = getLiteralValue(methodSchema);
216499
+ if (typeof methodValue !== "string") {
216500
+ throw new Error("Schema method literal must be a string");
216501
+ }
216502
+ const method = methodValue;
216503
+ if (method === "elicitation/create") {
216504
+ const wrappedHandler = async (request, extra) => {
216505
+ const validatedRequest = safeParse4(ElicitRequestSchema, request);
216506
+ if (!validatedRequest.success) {
216507
+ const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
216508
+ throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation request: ${errorMessage}`);
216509
+ }
216510
+ const { params } = validatedRequest.data;
216511
+ params.mode = params.mode ?? "form";
216512
+ const { supportsFormMode, supportsUrlMode } = getSupportedElicitationModes(this._capabilities.elicitation);
216513
+ if (params.mode === "form" && !supportsFormMode) {
216514
+ throw new McpError(ErrorCode.InvalidParams, "Client does not support form-mode elicitation requests");
216515
+ }
216516
+ if (params.mode === "url" && !supportsUrlMode) {
216517
+ throw new McpError(ErrorCode.InvalidParams, "Client does not support URL-mode elicitation requests");
216518
+ }
216519
+ const result = await Promise.resolve(handler(request, extra));
216520
+ if (params.task) {
216521
+ const taskValidationResult = safeParse4(CreateTaskResultSchema, result);
216522
+ if (!taskValidationResult.success) {
216523
+ const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
216524
+ throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
216525
+ }
216526
+ return taskValidationResult.data;
216527
+ }
216528
+ const validationResult = safeParse4(ElicitResultSchema, result);
216529
+ if (!validationResult.success) {
216530
+ const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
216531
+ throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation result: ${errorMessage}`);
216532
+ }
216533
+ const validatedResult = validationResult.data;
216534
+ const requestedSchema = params.mode === "form" ? params.requestedSchema : void 0;
216535
+ if (params.mode === "form" && validatedResult.action === "accept" && validatedResult.content && requestedSchema) {
216536
+ if (this._capabilities.elicitation?.form?.applyDefaults) {
216537
+ try {
216538
+ applyElicitationDefaults(requestedSchema, validatedResult.content);
216539
+ } catch {
216540
+ }
216541
+ }
216542
+ }
216543
+ return validatedResult;
216544
+ };
216545
+ return super.setRequestHandler(requestSchema, wrappedHandler);
216546
+ }
216547
+ if (method === "sampling/createMessage") {
216548
+ const wrappedHandler = async (request, extra) => {
216549
+ const validatedRequest = safeParse4(CreateMessageRequestSchema, request);
216550
+ if (!validatedRequest.success) {
216551
+ const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
216552
+ throw new McpError(ErrorCode.InvalidParams, `Invalid sampling request: ${errorMessage}`);
216553
+ }
216554
+ const { params } = validatedRequest.data;
216555
+ const result = await Promise.resolve(handler(request, extra));
216556
+ if (params.task) {
216557
+ const taskValidationResult = safeParse4(CreateTaskResultSchema, result);
216558
+ if (!taskValidationResult.success) {
216559
+ const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
216560
+ throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
216561
+ }
216562
+ return taskValidationResult.data;
216563
+ }
216564
+ const hasTools = params.tools || params.toolChoice;
216565
+ const resultSchema = hasTools ? CreateMessageResultWithToolsSchema : CreateMessageResultSchema;
216566
+ const validationResult = safeParse4(resultSchema, result);
216567
+ if (!validationResult.success) {
216568
+ const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
216569
+ throw new McpError(ErrorCode.InvalidParams, `Invalid sampling result: ${errorMessage}`);
216570
+ }
216571
+ return validationResult.data;
216572
+ };
216573
+ return super.setRequestHandler(requestSchema, wrappedHandler);
216574
+ }
216575
+ return super.setRequestHandler(requestSchema, handler);
216576
+ }
216577
+ assertCapability(capability, method) {
216578
+ if (!this._serverCapabilities?.[capability]) {
216579
+ throw new Error(`Server does not support ${capability} (required for ${method})`);
216580
+ }
216581
+ }
216582
+ async connect(transport, options) {
216583
+ await super.connect(transport);
216584
+ if (transport.sessionId !== void 0) {
216585
+ return;
216586
+ }
216587
+ try {
216588
+ const result = await this.request({
216589
+ method: "initialize",
216590
+ params: {
216591
+ protocolVersion: LATEST_PROTOCOL_VERSION,
216592
+ capabilities: this._capabilities,
216593
+ clientInfo: this._clientInfo
216594
+ }
216595
+ }, InitializeResultSchema, options);
216596
+ if (result === void 0) {
216597
+ throw new Error(`Server sent invalid initialize result: ${result}`);
216598
+ }
216599
+ if (!SUPPORTED_PROTOCOL_VERSIONS.includes(result.protocolVersion)) {
216600
+ throw new Error(`Server's protocol version is not supported: ${result.protocolVersion}`);
216601
+ }
216602
+ this._serverCapabilities = result.capabilities;
216603
+ this._serverVersion = result.serverInfo;
216604
+ if (transport.setProtocolVersion) {
216605
+ transport.setProtocolVersion(result.protocolVersion);
216606
+ }
216607
+ this._instructions = result.instructions;
216608
+ await this.notification({
216609
+ method: "notifications/initialized"
216610
+ });
216611
+ if (this._pendingListChangedConfig) {
216612
+ this._setupListChangedHandlers(this._pendingListChangedConfig);
216613
+ this._pendingListChangedConfig = void 0;
216614
+ }
216615
+ } catch (error40) {
216616
+ void this.close();
216617
+ throw error40;
216618
+ }
216619
+ }
216620
+ /**
216621
+ * After initialization has completed, this will be populated with the server's reported capabilities.
216622
+ */
216623
+ getServerCapabilities() {
216624
+ return this._serverCapabilities;
216625
+ }
216626
+ /**
216627
+ * After initialization has completed, this will be populated with information about the server's name and version.
216628
+ */
216629
+ getServerVersion() {
216630
+ return this._serverVersion;
216631
+ }
216632
+ /**
216633
+ * After initialization has completed, this may be populated with information about the server's instructions.
216634
+ */
216635
+ getInstructions() {
216636
+ return this._instructions;
216637
+ }
216638
+ assertCapabilityForMethod(method) {
216639
+ switch (method) {
216640
+ case "logging/setLevel":
216641
+ if (!this._serverCapabilities?.logging) {
216642
+ throw new Error(`Server does not support logging (required for ${method})`);
216643
+ }
216644
+ break;
216645
+ case "prompts/get":
216646
+ case "prompts/list":
216647
+ if (!this._serverCapabilities?.prompts) {
216648
+ throw new Error(`Server does not support prompts (required for ${method})`);
216649
+ }
216650
+ break;
216651
+ case "resources/list":
216652
+ case "resources/templates/list":
216653
+ case "resources/read":
216654
+ case "resources/subscribe":
216655
+ case "resources/unsubscribe":
216656
+ if (!this._serverCapabilities?.resources) {
216657
+ throw new Error(`Server does not support resources (required for ${method})`);
216658
+ }
216659
+ if (method === "resources/subscribe" && !this._serverCapabilities.resources.subscribe) {
216660
+ throw new Error(`Server does not support resource subscriptions (required for ${method})`);
216661
+ }
216662
+ break;
216663
+ case "tools/call":
216664
+ case "tools/list":
216665
+ if (!this._serverCapabilities?.tools) {
216666
+ throw new Error(`Server does not support tools (required for ${method})`);
216667
+ }
216668
+ break;
216669
+ case "completion/complete":
216670
+ if (!this._serverCapabilities?.completions) {
216671
+ throw new Error(`Server does not support completions (required for ${method})`);
216672
+ }
216673
+ break;
216674
+ case "initialize":
216675
+ break;
216676
+ case "ping":
216677
+ break;
216678
+ }
216679
+ }
216680
+ assertNotificationCapability(method) {
216681
+ switch (method) {
216682
+ case "notifications/roots/list_changed":
216683
+ if (!this._capabilities.roots?.listChanged) {
216684
+ throw new Error(`Client does not support roots list changed notifications (required for ${method})`);
216685
+ }
216686
+ break;
216687
+ case "notifications/initialized":
216688
+ break;
216689
+ case "notifications/cancelled":
216690
+ break;
216691
+ case "notifications/progress":
216692
+ break;
216693
+ }
216694
+ }
216695
+ assertRequestHandlerCapability(method) {
216696
+ if (!this._capabilities) {
216697
+ return;
216698
+ }
216699
+ switch (method) {
216700
+ case "sampling/createMessage":
216701
+ if (!this._capabilities.sampling) {
216702
+ throw new Error(`Client does not support sampling capability (required for ${method})`);
216703
+ }
216704
+ break;
216705
+ case "elicitation/create":
216706
+ if (!this._capabilities.elicitation) {
216707
+ throw new Error(`Client does not support elicitation capability (required for ${method})`);
216708
+ }
216709
+ break;
216710
+ case "roots/list":
216711
+ if (!this._capabilities.roots) {
216712
+ throw new Error(`Client does not support roots capability (required for ${method})`);
216713
+ }
216714
+ break;
216715
+ case "tasks/get":
216716
+ case "tasks/list":
216717
+ case "tasks/result":
216718
+ case "tasks/cancel":
216719
+ if (!this._capabilities.tasks) {
216720
+ throw new Error(`Client does not support tasks capability (required for ${method})`);
216721
+ }
216722
+ break;
216723
+ case "ping":
216724
+ break;
216725
+ }
216726
+ }
216727
+ assertTaskCapability(method) {
216728
+ assertToolsCallTaskCapability(this._serverCapabilities?.tasks?.requests, method, "Server");
216729
+ }
216730
+ assertTaskHandlerCapability(method) {
216731
+ if (!this._capabilities) {
216732
+ return;
216733
+ }
216734
+ assertClientRequestTaskCapability(this._capabilities.tasks?.requests, method, "Client");
216735
+ }
216736
+ async ping(options) {
216737
+ return this.request({ method: "ping" }, EmptyResultSchema, options);
216738
+ }
216739
+ async complete(params, options) {
216740
+ return this.request({ method: "completion/complete", params }, CompleteResultSchema, options);
216741
+ }
216742
+ async setLoggingLevel(level, options) {
216743
+ return this.request({ method: "logging/setLevel", params: { level } }, EmptyResultSchema, options);
216744
+ }
216745
+ async getPrompt(params, options) {
216746
+ return this.request({ method: "prompts/get", params }, GetPromptResultSchema, options);
216747
+ }
216748
+ async listPrompts(params, options) {
216749
+ return this.request({ method: "prompts/list", params }, ListPromptsResultSchema, options);
216750
+ }
216751
+ async listResources(params, options) {
216752
+ return this.request({ method: "resources/list", params }, ListResourcesResultSchema, options);
216753
+ }
216754
+ async listResourceTemplates(params, options) {
216755
+ return this.request({ method: "resources/templates/list", params }, ListResourceTemplatesResultSchema, options);
216756
+ }
216757
+ async readResource(params, options) {
216758
+ return this.request({ method: "resources/read", params }, ReadResourceResultSchema, options);
216759
+ }
216760
+ async subscribeResource(params, options) {
216761
+ return this.request({ method: "resources/subscribe", params }, EmptyResultSchema, options);
216762
+ }
216763
+ async unsubscribeResource(params, options) {
216764
+ return this.request({ method: "resources/unsubscribe", params }, EmptyResultSchema, options);
216765
+ }
216766
+ /**
216767
+ * Calls a tool and waits for the result. Automatically validates structured output if the tool has an outputSchema.
216768
+ *
216769
+ * For task-based execution with streaming behavior, use client.experimental.tasks.callToolStream() instead.
216770
+ */
216771
+ async callTool(params, resultSchema = CallToolResultSchema, options) {
216772
+ if (this.isToolTaskRequired(params.name)) {
216773
+ throw new McpError(ErrorCode.InvalidRequest, `Tool "${params.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);
216774
+ }
216775
+ const result = await this.request({ method: "tools/call", params }, resultSchema, options);
216776
+ const validator = this.getToolOutputValidator(params.name);
216777
+ if (validator) {
216778
+ if (!result.structuredContent && !result.isError) {
216779
+ throw new McpError(ErrorCode.InvalidRequest, `Tool ${params.name} has an output schema but did not return structured content`);
216780
+ }
216781
+ if (result.structuredContent) {
216782
+ try {
216783
+ const validationResult = validator(result.structuredContent);
216784
+ if (!validationResult.valid) {
216785
+ throw new McpError(ErrorCode.InvalidParams, `Structured content does not match the tool's output schema: ${validationResult.errorMessage}`);
216786
+ }
216787
+ } catch (error40) {
216788
+ if (error40 instanceof McpError) {
216789
+ throw error40;
216790
+ }
216791
+ throw new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error40 instanceof Error ? error40.message : String(error40)}`);
216792
+ }
216793
+ }
216794
+ }
216795
+ return result;
216796
+ }
216797
+ isToolTask(toolName) {
216798
+ if (!this._serverCapabilities?.tasks?.requests?.tools?.call) {
216799
+ return false;
216800
+ }
216801
+ return this._cachedKnownTaskTools.has(toolName);
216802
+ }
216803
+ /**
216804
+ * Check if a tool requires task-based execution.
216805
+ * Unlike isToolTask which includes 'optional' tools, this only checks for 'required'.
216806
+ */
216807
+ isToolTaskRequired(toolName) {
216808
+ return this._cachedRequiredTaskTools.has(toolName);
216809
+ }
216810
+ /**
216811
+ * Cache validators for tool output schemas.
216812
+ * Called after listTools() to pre-compile validators for better performance.
216813
+ */
216814
+ cacheToolMetadata(tools) {
216815
+ this._cachedToolOutputValidators.clear();
216816
+ this._cachedKnownTaskTools.clear();
216817
+ this._cachedRequiredTaskTools.clear();
216818
+ for (const tool of tools) {
216819
+ if (tool.outputSchema) {
216820
+ const toolValidator = this._jsonSchemaValidator.getValidator(tool.outputSchema);
216821
+ this._cachedToolOutputValidators.set(tool.name, toolValidator);
216822
+ }
216823
+ const taskSupport = tool.execution?.taskSupport;
216824
+ if (taskSupport === "required" || taskSupport === "optional") {
216825
+ this._cachedKnownTaskTools.add(tool.name);
216826
+ }
216827
+ if (taskSupport === "required") {
216828
+ this._cachedRequiredTaskTools.add(tool.name);
216829
+ }
216830
+ }
216831
+ }
216832
+ /**
216833
+ * Get cached validator for a tool
216834
+ */
216835
+ getToolOutputValidator(toolName) {
216836
+ return this._cachedToolOutputValidators.get(toolName);
216837
+ }
216838
+ async listTools(params, options) {
216839
+ const result = await this.request({ method: "tools/list", params }, ListToolsResultSchema, options);
216840
+ this.cacheToolMetadata(result.tools);
216841
+ return result;
216842
+ }
216843
+ /**
216844
+ * Set up a single list changed handler.
216845
+ * @internal
216846
+ */
216847
+ _setupListChangedHandler(listType, notificationSchema, options, fetcher) {
216848
+ const parseResult = ListChangedOptionsBaseSchema.safeParse(options);
216849
+ if (!parseResult.success) {
216850
+ throw new Error(`Invalid ${listType} listChanged options: ${parseResult.error.message}`);
216851
+ }
216852
+ if (typeof options.onChanged !== "function") {
216853
+ throw new Error(`Invalid ${listType} listChanged options: onChanged must be a function`);
216854
+ }
216855
+ const { autoRefresh, debounceMs } = parseResult.data;
216856
+ const { onChanged } = options;
216857
+ const refresh = async () => {
216858
+ if (!autoRefresh) {
216859
+ onChanged(null, null);
216860
+ return;
216861
+ }
216862
+ try {
216863
+ const items = await fetcher();
216864
+ onChanged(null, items);
216865
+ } catch (e5) {
216866
+ const error40 = e5 instanceof Error ? e5 : new Error(String(e5));
216867
+ onChanged(error40, null);
216868
+ }
216869
+ };
216870
+ const handler = () => {
216871
+ if (debounceMs) {
216872
+ const existingTimer = this._listChangedDebounceTimers.get(listType);
216873
+ if (existingTimer) {
216874
+ clearTimeout(existingTimer);
216875
+ }
216876
+ const timer = setTimeout(refresh, debounceMs);
216877
+ this._listChangedDebounceTimers.set(listType, timer);
216878
+ } else {
216879
+ refresh();
216880
+ }
216881
+ };
216882
+ this.setNotificationHandler(notificationSchema, handler);
216883
+ }
216884
+ async sendRootsListChanged() {
216885
+ return this.notification({ method: "notifications/roots/list_changed" });
216886
+ }
216887
+ };
216888
+ }
216889
+ });
216890
+
216891
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/inMemory.js
216892
+ var InMemoryTransport;
216893
+ var init_inMemory = __esm({
216894
+ "node_modules/@modelcontextprotocol/sdk/dist/esm/inMemory.js"() {
216895
+ "use strict";
216896
+ init_esm_shims();
216897
+ InMemoryTransport = class _InMemoryTransport {
216898
+ constructor() {
216899
+ this._messageQueue = [];
216900
+ }
216901
+ /**
216902
+ * Creates a pair of linked in-memory transports that can communicate with each other. One should be passed to a Client and one to a Server.
216903
+ */
216904
+ static createLinkedPair() {
216905
+ const clientTransport = new _InMemoryTransport();
216906
+ const serverTransport = new _InMemoryTransport();
216907
+ clientTransport._otherTransport = serverTransport;
216908
+ serverTransport._otherTransport = clientTransport;
216909
+ return [clientTransport, serverTransport];
216910
+ }
216911
+ async start() {
216912
+ while (this._messageQueue.length > 0) {
216913
+ const queuedMessage = this._messageQueue.shift();
216914
+ this.onmessage?.(queuedMessage.message, queuedMessage.extra);
216915
+ }
216916
+ }
216917
+ async close() {
216918
+ const other = this._otherTransport;
216919
+ this._otherTransport = void 0;
216920
+ await other?.close();
216921
+ this.onclose?.();
216922
+ }
216923
+ /**
216924
+ * Sends a message with optional auth info.
216925
+ * This is useful for testing authentication scenarios.
216926
+ */
216927
+ async send(message, options) {
216928
+ if (!this._otherTransport) {
216929
+ throw new Error("Not connected");
216930
+ }
216931
+ if (this._otherTransport.onmessage) {
216932
+ this._otherTransport.onmessage(message, { authInfo: options?.authInfo });
216933
+ } else {
216934
+ this._otherTransport._messageQueue.push({ message, extra: { authInfo: options?.authInfo } });
216935
+ }
216936
+ }
216937
+ };
216938
+ }
216939
+ });
216940
+
216244
216941
  // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
216245
216942
  var ExperimentalServerTasks;
216246
216943
  var init_server = __esm({
@@ -216462,47 +217159,6 @@ var init_server = __esm({
216462
217159
  }
216463
217160
  });
216464
217161
 
216465
- // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
216466
- function assertToolsCallTaskCapability(requests, method, entityName) {
216467
- if (!requests) {
216468
- throw new Error(`${entityName} does not support task creation (required for ${method})`);
216469
- }
216470
- switch (method) {
216471
- case "tools/call":
216472
- if (!requests.tools?.call) {
216473
- throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
216474
- }
216475
- break;
216476
- default:
216477
- break;
216478
- }
216479
- }
216480
- function assertClientRequestTaskCapability(requests, method, entityName) {
216481
- if (!requests) {
216482
- throw new Error(`${entityName} does not support task creation (required for ${method})`);
216483
- }
216484
- switch (method) {
216485
- case "sampling/createMessage":
216486
- if (!requests.sampling?.createMessage) {
216487
- throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
216488
- }
216489
- break;
216490
- case "elicitation/create":
216491
- if (!requests.elicitation?.create) {
216492
- throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
216493
- }
216494
- break;
216495
- default:
216496
- break;
216497
- }
216498
- }
216499
- var init_helpers2 = __esm({
216500
- "node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js"() {
216501
- "use strict";
216502
- init_esm_shims();
216503
- }
216504
- });
216505
-
216506
217162
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
216507
217163
  var Server;
216508
217164
  var init_server2 = __esm({
@@ -266277,6 +266933,81 @@ var init_server4 = __esm({
266277
266933
  }
266278
266934
  });
266279
266935
 
266936
+ // src/server/modern-mcp-bridge.ts
266937
+ var modern_mcp_bridge_exports = {};
266938
+ __export(modern_mcp_bridge_exports, {
266939
+ createModernMcpBridge: () => createModernMcpBridge
266940
+ });
266941
+ import {
266942
+ fromJsonSchema,
266943
+ McpServer as ModernMcpServer
266944
+ } from "@modelcontextprotocol/server";
266945
+ async function createModernMcpBridge(options) {
266946
+ const { createMemorixServer: createMemorixServer2 } = await Promise.resolve().then(() => (init_server4(), server_exports2));
266947
+ const legacy = await createMemorixServer2(
266948
+ options.projectRoot,
266949
+ void 0,
266950
+ void 0,
266951
+ {
266952
+ ...options,
266953
+ allowUntrackedFallback: options.allowUntrackedFallback ?? false,
266954
+ deferProjectInitUntilBound: options.deferProjectInitUntilBound ?? true,
266955
+ deferProjectRuntimeInit: options.deferProjectRuntimeInit ?? true
266956
+ }
266957
+ );
266958
+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
266959
+ const legacyClient = new Client({
266960
+ name: "memorix-modern-bridge",
266961
+ version: getMcpServerInfo().version
266962
+ });
266963
+ await legacy.server.connect(serverTransport);
266964
+ await legacyClient.connect(clientTransport);
266965
+ const listed = await legacyClient.listTools();
266966
+ const modern = new ModernMcpServer(getMcpServerInfo());
266967
+ for (const tool of listed.tools) {
266968
+ modern.registerTool(
266969
+ tool.name,
266970
+ {
266971
+ ...tool.title ? { title: tool.title } : {},
266972
+ ...tool.description ? { description: tool.description } : {},
266973
+ inputSchema: fromJsonSchema(tool.inputSchema)
266974
+ },
266975
+ async (args) => await legacyClient.callTool({
266976
+ name: tool.name,
266977
+ arguments: args
266978
+ })
266979
+ );
266980
+ }
266981
+ const bridge = modern;
266982
+ bridge.memorix = {
266983
+ projectId: legacy.projectId,
266984
+ deferredInit: legacy.deferredInit,
266985
+ switchProject: legacy.switchProject,
266986
+ isExplicitlyBound: legacy.isExplicitlyBound,
266987
+ handleTransportClose: legacy.handleTransportClose
266988
+ };
266989
+ let closed = false;
266990
+ const modernClose = modern.close.bind(modern);
266991
+ modern.close = async () => {
266992
+ if (closed) return;
266993
+ closed = true;
266994
+ await modernClose();
266995
+ await legacyClient.close().catch(() => void 0);
266996
+ await legacy.server.close().catch(() => void 0);
266997
+ legacy.handleTransportClose();
266998
+ };
266999
+ return bridge;
267000
+ }
267001
+ var init_modern_mcp_bridge = __esm({
267002
+ "src/server/modern-mcp-bridge.ts"() {
267003
+ "use strict";
267004
+ init_esm_shims();
267005
+ init_client4();
267006
+ init_inMemory();
267007
+ init_mcp_discovery();
267008
+ }
267009
+ });
267010
+
266280
267011
  // src/cli/commands/serve-shared.ts
266281
267012
  var serve_shared_exports = {};
266282
267013
  __export(serve_shared_exports, {
@@ -266630,6 +267361,14 @@ var init_serve = __esm({
266630
267361
  }
266631
267362
  },
266632
267363
  run: async ({ args }) => {
267364
+ const { serveStdio, StdioServerTransport } = await import("@modelcontextprotocol/server/stdio");
267365
+ const { createModernMcpBridge: createModernMcpBridge2 } = await Promise.resolve().then(() => (init_modern_mcp_bridge(), modern_mcp_bridge_exports));
267366
+ const { detectProject: detectProject2, findGitInSubdirs: findGitInSubdirs2, isSystemDirectory: isSystemDirectory2 } = await Promise.resolve().then(() => (init_detector(), detector_exports));
267367
+ const { homedir: homedir36 } = await import("os");
267368
+ const { writeLastProjectRoot: writeLastProjectRoot2 } = await Promise.resolve().then(() => (init_launch_root(), launch_root_exports));
267369
+ const { resolveServeProject: resolveServeProject2 } = await Promise.resolve().then(() => (init_serve_shared(), serve_shared_exports));
267370
+ let stdioHandle;
267371
+ let stdinEndedBeforeHandle = false;
266633
267372
  const startupGate = new StdioStartupGate({
266634
267373
  stdin: process.stdin,
266635
267374
  stdout: process.stdout,
@@ -266639,16 +267378,17 @@ var init_serve = __esm({
266639
267378
  process.exit(1);
266640
267379
  },
266641
267380
  onEnd: () => {
266642
- console.error("[memorix] stdin closed \u2014 exiting");
266643
- process.exitCode = 0;
267381
+ console.error("[memorix] stdin closed - exiting");
267382
+ if (stdioHandle) {
267383
+ void stdioHandle.close().catch((error40) => {
267384
+ console.error(`[memorix] stdio close error: ${error40 instanceof Error ? error40.message : String(error40)}`);
267385
+ });
267386
+ } else {
267387
+ stdinEndedBeforeHandle = true;
267388
+ }
266644
267389
  }
266645
267390
  });
266646
267391
  startupGate.start();
266647
- const { StdioServerTransport: StdioServerTransport2 } = await Promise.resolve().then(() => (init_stdio2(), stdio_exports));
266648
- const { createMemorixServer: createMemorixServer2 } = await Promise.resolve().then(() => (init_server4(), server_exports2));
266649
- const { detectProject: detectProject2, findGitInSubdirs: findGitInSubdirs2, isSystemDirectory: isSystemDirectory2 } = await Promise.resolve().then(() => (init_detector(), detector_exports));
266650
- const { homedir: homedir36 } = await import("os");
266651
- const { resolveServeProject: resolveServeProject2 } = await Promise.resolve().then(() => (init_serve_shared(), serve_shared_exports));
266652
267392
  let safeCwd;
266653
267393
  try {
266654
267394
  safeCwd = process.cwd();
@@ -266665,70 +267405,82 @@ var init_serve = __esm({
266665
267405
  },
266666
267406
  { detectProject: detectProject2, findGitInSubdirs: findGitInSubdirs2, isSystemDirectory: isSystemDirectory2 }
266667
267407
  );
266668
- for (const message of resolution.messages) {
266669
- console.error(message);
266670
- }
267408
+ for (const message of resolution.messages) console.error(message);
266671
267409
  if (!resolution.detectedProject) {
266672
267410
  console.error(`[memorix] [WARN] ${resolution.error}`);
266673
- console.error(`[memorix] Starting in deferred-binding mode \u2014 project will bind via MCP roots or memorix_session_start.`);
266674
- console.error(`[memorix] For non-git directories, use --allow-untracked to enable untracked/ fallback.`);
267411
+ console.error("[memorix] Starting in deferred-binding mode - bind with memorix_session_start(projectRoot=...) when needed.");
267412
+ console.error("[memorix] For non-git directories, use --allow-untracked to enable untracked/ fallback.");
266675
267413
  }
266676
267414
  const detected = resolution.detectedProject;
266677
267415
  const projectRoot = resolution.projectRoot;
266678
- if (detected) {
266679
- const { writeLastProjectRoot: writeLastProjectRoot2 } = await Promise.resolve().then(() => (init_launch_root(), launch_root_exports));
266680
- writeLastProjectRoot2(detected.rootPath);
266681
- }
267416
+ if (detected) writeLastProjectRoot2(detected.rootPath);
266682
267417
  const allowUntracked = args["allow-untracked"] ?? false;
266683
- const toolProfile = resolveToolProfile({ explicit: args.mode, envValue: process.env.MEMORIX_MODE, fallback: "micro" });
266684
- const serverOptions = detected ? { toolProfile, deferProjectRuntimeInit: true } : { allowUntrackedFallback: allowUntracked, deferProjectInitUntilBound: !allowUntracked, deferProjectRuntimeInit: true, toolProfile };
266685
- const { server, projectId, deferredInit, switchProject } = await createMemorixServer2(projectRoot, void 0, void 0, serverOptions);
266686
- const transport = new StdioServerTransport2(startupGate.input, process.stdout);
266687
- await server.connect(transport);
266688
- startupGate.markReady();
266689
- console.error(`[memorix] MCP Server running on stdio (project: ${projectId})`);
266690
- console.error(`[memorix] Project root: ${detected?.rootPath ?? projectRoot}`);
266691
- const tryRootsSwitch = async () => {
266692
- try {
266693
- const { roots } = await server.server.listRoots();
266694
- if (!roots || roots.length === 0) return;
266695
- for (const root of roots) {
266696
- if (!root.uri.startsWith("file://")) continue;
266697
- const rootPath = mcpFileUriToPath(root.uri);
266698
- if (!rootPath) continue;
266699
- const rootDetected = detectProject2(rootPath);
266700
- if (rootDetected) {
266701
- const switched = await switchProject(rootPath);
267418
+ const toolProfile = resolveToolProfile({
267419
+ explicit: args.mode,
267420
+ envValue: process.env.MEMORIX_MODE,
267421
+ fallback: "micro"
267422
+ });
267423
+ const transport = new StdioServerTransport(startupGate.input, process.stdout);
267424
+ const createBridge = async () => {
267425
+ const bridge = await createModernMcpBridge2({
267426
+ projectRoot,
267427
+ allowUntrackedFallback: allowUntracked,
267428
+ deferProjectInitUntilBound: !allowUntracked,
267429
+ deferProjectRuntimeInit: true,
267430
+ toolProfile
267431
+ });
267432
+ const tryRootsSwitch = async () => {
267433
+ try {
267434
+ if (bridge.memorix.isExplicitlyBound()) return;
267435
+ const { roots } = await bridge.server.listRoots();
267436
+ for (const root of roots ?? []) {
267437
+ if (!root.uri.startsWith("file://")) continue;
267438
+ const rootPath = mcpFileUriToPath(root.uri);
267439
+ if (!rootPath) continue;
267440
+ const switched = await bridge.memorix.switchProject(rootPath, "mcp-roots");
266702
267441
  if (switched) {
266703
- console.error(`[memorix] [UPDATED] Project updated via MCP roots: ${rootDetected.id}`);
267442
+ console.error(`[memorix] [UPDATED] Project updated via MCP roots: ${rootPath}`);
267443
+ return;
266704
267444
  }
266705
- return;
266706
- }
266707
- const subGit = findGitInSubdirs2(rootPath);
266708
- if (subGit) {
266709
- const switched = await switchProject(subGit);
266710
- if (switched) {
267445
+ const subGit = findGitInSubdirs2(rootPath);
267446
+ if (subGit && await bridge.memorix.switchProject(subGit, "mcp-roots")) {
266711
267447
  console.error(`[memorix] [UPDATED] Project updated via MCP roots (subdir): ${subGit}`);
267448
+ return;
266712
267449
  }
266713
- return;
266714
267450
  }
267451
+ } catch (error40) {
267452
+ console.error(`[memorix] MCP roots not available (${error40 instanceof Error ? error40.message : "unsupported"})`);
266715
267453
  }
266716
- } catch (err) {
266717
- console.error(`[memorix] MCP roots not available (${err.message ?? "unsupported"})`);
266718
- }
266719
- };
266720
- try {
266721
- const { RootsListChangedNotificationSchema: RootsListChangedNotificationSchema2 } = await Promise.resolve().then(() => (init_types8(), types_exports3));
266722
- server.server.setNotificationHandler(RootsListChangedNotificationSchema2, async () => {
266723
- console.error(`[memorix] Roots changed \u2014 re-detecting project...`);
267454
+ };
267455
+ bridge.server.setNotificationHandler("notifications/roots/list_changed", async () => {
266724
267456
  await tryRootsSwitch();
266725
267457
  });
266726
- } catch {
267458
+ const deferredInitTimer = setTimeout(() => {
267459
+ bridge.memorix.deferredInit().catch((error40) => {
267460
+ console.error(`[memorix] Deferred init error: ${error40 instanceof Error ? error40.message : String(error40)}`);
267461
+ });
267462
+ }, 5e3);
267463
+ deferredInitTimer.unref?.();
267464
+ const originalClose = bridge.close.bind(bridge);
267465
+ bridge.close = async () => {
267466
+ clearTimeout(deferredInitTimer);
267467
+ await originalClose();
267468
+ };
267469
+ return bridge;
267470
+ };
267471
+ stdioHandle = serveStdio(createBridge, {
267472
+ transport,
267473
+ legacy: "serve",
267474
+ onerror: (error40) => console.error(`[memorix] stdio MCP error: ${error40.message}`)
267475
+ });
267476
+ startupGate.markReady();
267477
+ if (stdinEndedBeforeHandle) {
267478
+ void stdioHandle.close().catch((error40) => {
267479
+ console.error(`[memorix] stdio close error: ${error40 instanceof Error ? error40.message : String(error40)}`);
267480
+ });
266727
267481
  }
266728
- const deferredInitTimer = setTimeout(() => {
266729
- deferredInit().catch((e5) => console.error(`[memorix] Deferred init error:`, e5));
266730
- }, 5e3);
266731
- deferredInitTimer.unref?.();
267482
+ console.error(`[memorix] MCP Server running on stdio (profile: ${toolProfile}, project: ${detected?.id ?? "deferred"})`);
267483
+ console.error(`[memorix] Project root: ${detected?.rootPath ?? projectRoot}`);
266732
267484
  Promise.resolve().then(() => (init_update_checker(), update_checker_exports)).then((m6) => m6.checkForUpdates()).catch(() => {
266733
267485
  });
266734
267486
  }
@@ -266745,15 +267497,17 @@ function getMcpDiagnostics() {
266745
267497
  legacy: LEGACY_MCP_PROTOCOL_VERSION,
266746
267498
  discovery: "supported",
266747
267499
  versionlessRequests: "legacy-compatible",
266748
- modernResultMetadata: "discovery-only",
266749
- statelessRequests: "compatibility-only",
267500
+ modernResultMetadata: "supported",
267501
+ statelessRequests: "supported",
266750
267502
  statefulStreamableHttp: "supported"
266751
267503
  },
266752
267504
  capabilities: {
266753
267505
  tasks: "unsupported",
266754
267506
  polling: "unsupported",
266755
- subscriptions: "unsupported",
266756
- listCache: "unsupported",
267507
+ subscriptions: "supported",
267508
+ // The protocol envelope is emitted, but TTL is intentionally zero until
267509
+ // Memorix can invalidate a durable per-project list cache correctly.
267510
+ listCache: "protocol-hints-only",
266757
267511
  explicitProjectHandle: "supported"
266758
267512
  }
266759
267513
  };
@@ -269042,6 +269796,7 @@ var init_serve_http = __esm({
269042
269796
  init_retention();
269043
269797
  init_visibility();
269044
269798
  init_mcp_diagnostics();
269799
+ init_mcp_discovery();
269045
269800
  init_port();
269046
269801
  init_mcp_root_path();
269047
269802
  DEFAULT_SESSION_TIMEOUT_MS = 12 * 60 * 60 * 1e3;
@@ -269086,6 +269841,9 @@ var init_serve_http = __esm({
269086
269841
  const { homedir: homedir36 } = await import("os");
269087
269842
  const { McpBindingStore: McpBindingStore2 } = await Promise.resolve().then(() => (init_mcp_binding_store(), mcp_binding_store_exports));
269088
269843
  const { MemoryFeedbackStore: MemoryFeedbackStore2 } = await Promise.resolve().then(() => (init_feedback(), feedback_exports));
269844
+ const { createModernMcpBridge: createModernMcpBridge2 } = await Promise.resolve().then(() => (init_modern_mcp_bridge(), modern_mcp_bridge_exports));
269845
+ const { createMcpHandler } = await import("@modelcontextprotocol/server");
269846
+ const { toNodeHandler } = await import("@modelcontextprotocol/node");
269089
269847
  let configuredDefaults = {};
269090
269848
  try {
269091
269849
  const { getServerConfig: getServerConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
@@ -269140,6 +269898,27 @@ var init_serve_http = __esm({
269140
269898
  }
269141
269899
  const statelessBindingStore = new McpBindingStore2();
269142
269900
  await statelessBindingStore.init(persistMod.getBaseDataDir());
269901
+ const modernMcpHandler = createMcpHandler(async ({ requestInfo }) => {
269902
+ const handleId = requestInfo?.headers.get("mcp-project-handle") ?? void 0;
269903
+ const persisted = handleId ? statelessBindingStore.touch(handleId) : void 0;
269904
+ const requestedRoot = requestInfo?.headers.get("mcp-project-root") ?? void 0;
269905
+ const root = persisted?.projectRoot ?? requestedRoot ?? projectRoot;
269906
+ return createModernMcpBridge2({
269907
+ projectRoot: root,
269908
+ allowUntrackedFallback: false,
269909
+ deferProjectInitUntilBound: true,
269910
+ deferProjectRuntimeInit: true,
269911
+ dashboardMode: "control-plane",
269912
+ dashboardPort: port,
269913
+ toolProfile
269914
+ });
269915
+ }, {
269916
+ // Legacy requests are routed to the existing sessionful implementation
269917
+ // below; this handler is strict modern-only by construction.
269918
+ legacy: "reject",
269919
+ responseMode: "auto"
269920
+ });
269921
+ const modernNodeHandler = toNodeHandler(modernMcpHandler);
269143
269922
  const sessions = /* @__PURE__ */ new Map();
269144
269923
  const sessionLastActivity = /* @__PURE__ */ new Map();
269145
269924
  const expiredSessions = /* @__PURE__ */ new Map();
@@ -269281,87 +270060,38 @@ var init_serve_http = __esm({
269281
270060
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
269282
270061
  res.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, Mcp-Session-Id, Mcp-Project-Handle, Mcp-Project-Root, Mcp-Stateless, Last-Event-Id");
269283
270062
  res.setHeader("Access-Control-Expose-Headers", "Mcp-Session-Id, Mcp-Project-Handle, Mcp-Protocol-Version, Mcp-Method, Mcp-Name");
269284
- res.setHeader("Mcp-Protocol-Version", req.headers["mcp-protocol-version"] || CURRENT_MCP_PROTOCOL_VERSION);
270063
+ res.setHeader("Mcp-Protocol-Version", MCP_SDK_COMPAT_PROTOCOL_VERSION);
269285
270064
  res.setHeader("Mcp-Method", req.method || "UNKNOWN");
269286
270065
  res.setHeader("Mcp-Name", MCP_SERVER_NAME);
269287
270066
  }
269288
- async function handleStatelessPost(req, res, body) {
269289
- const handleId = typeof req.headers["mcp-project-handle"] === "string" ? req.headers["mcp-project-handle"] : void 0;
269290
- const persisted = handleId ? statelessBindingStore.touch(handleId) : void 0;
269291
- if (handleId && !persisted) {
269292
- res.writeHead(404, { "Content-Type": "application/json" });
269293
- res.end(JSON.stringify({ jsonrpc: "2.0", error: { code: -32001, message: "MCP project handle not found or expired; initialize again." }, id: null }));
269294
- return;
269295
- }
269296
- const requestedRoot = typeof req.headers["mcp-project-root"] === "string" ? req.headers["mcp-project-root"] : void 0;
269297
- const root = persisted?.projectRoot ?? requestedRoot ?? projectRoot;
269298
- if (!persisted && !isInitializeRequest2(body) && !isServerDiscoverRequest(body)) {
269299
- res.writeHead(400, { "Content-Type": "application/json" });
269300
- res.end(JSON.stringify({ jsonrpc: "2.0", error: { code: -32e3, message: "Stateless MCP requests require Mcp-Project-Handle; initialize first." }, id: null }));
269301
- return;
269302
- }
269303
- const { createMemorixServer: createMemorixServer3 } = await Promise.resolve().then(() => (init_server4(), server_exports2));
269304
- const { createProjectBindingController: createProjectBindingController3 } = await Promise.resolve().then(() => (init_request_context(), request_context_exports));
269305
- const binding = createProjectBindingController3(root);
269306
- const { server, projectId, handleTransportClose } = await createMemorixServer3(
269307
- root,
269308
- void 0,
269309
- void 0,
269310
- {
269311
- allowUntrackedFallback: false,
269312
- deferProjectInitUntilBound: true,
269313
- deferProjectRuntimeInit: true,
269314
- dashboardMode: "control-plane",
269315
- dashboardPort: port,
269316
- toolProfile,
269317
- projectBinding: binding
269318
- }
269319
- );
269320
- const transport = new StreamableHTTPServerTransport2({
269321
- // No Mcp-Session-Id: the protocol state is carried by our explicit
269322
- // durable project handle and reconstructed on every request.
269323
- sessionIdGenerator: void 0,
269324
- enableJsonResponse: true
269325
- });
269326
- try {
269327
- await server.connect(transport);
269328
- let effectiveHandle = persisted;
269329
- if (!effectiveHandle && projectId !== "__unresolved__") {
269330
- effectiveHandle = statelessBindingStore.create({
269331
- projectId,
269332
- projectRoot: root,
269333
- dataDir: await persistMod.getProjectDataDir(projectId)
269334
- });
269335
- }
269336
- if (effectiveHandle) res.setHeader("Mcp-Project-Handle", effectiveHandle.handleId);
269337
- const sdkBody = body && typeof body === "object" ? JSON.parse(JSON.stringify(body)) : body;
269338
- const sdkRequest = sdkBody;
269339
- if (sdkRequest && typeof sdkRequest === "object" && sdkRequest.method === "initialize" && sdkRequest.params) {
269340
- sdkRequest.params.protocolVersion = MCP_SDK_COMPAT_PROTOCOL_VERSION;
269341
- }
269342
- if (req.headers["mcp-protocol-version"]) {
269343
- req.headers["mcp-protocol-version"] = MCP_SDK_COMPAT_PROTOCOL_VERSION;
269344
- for (let i4 = 0; i4 < req.rawHeaders.length; i4 += 2) {
269345
- if (req.rawHeaders[i4].toLowerCase() === "mcp-protocol-version") {
269346
- req.rawHeaders[i4 + 1] = MCP_SDK_COMPAT_PROTOCOL_VERSION;
269347
- break;
269348
- }
269349
- }
269350
- }
269351
- patchMcpResponse(res);
269352
- await transport.handleRequest(req, res, sdkBody);
269353
- } finally {
269354
- handleTransportClose();
269355
- await transport.close().catch(() => void 0);
269356
- }
269357
- }
269358
270067
  async function handlePost(req, res) {
269359
270068
  const sessionId = req.headers["mcp-session-id"];
269360
270069
  const body = await parseBody(req);
270070
+ const params = body && typeof body === "object" && !Array.isArray(body) ? body.params : void 0;
270071
+ const claimlessDiscovery = !sessionId && isServerDiscoverRequest(body) && !req.headers["mcp-protocol-version"] && !req.headers["mcp-method"] && req.headers["mcp-stateless"] !== "true" && (params === void 0 || typeof params === "object" && params !== null && !Array.isArray(params) && !Object.prototype.hasOwnProperty.call(params, "_meta"));
270072
+ if (claimlessDiscovery) {
270073
+ res.writeHead(200, { "Content-Type": "application/json" });
270074
+ res.end(JSON.stringify({
270075
+ jsonrpc: "2.0",
270076
+ id: body.id ?? null,
270077
+ result: createMcpStartupDiscoverResult(getMcpServerInfo())
270078
+ }));
270079
+ return;
270080
+ }
269361
270081
  const requestedProtocol = req.headers["mcp-protocol-version"];
269362
270082
  const statelessRequested = req.headers["mcp-stateless"] === "true" || requestedProtocol === CURRENT_MCP_PROTOCOL_VERSION || typeof req.headers["mcp-project-handle"] === "string" || isServerDiscoverRequest(body);
269363
270083
  if (!sessionId && statelessRequested) {
269364
- await handleStatelessPost(req, res, body);
270084
+ const handleId = typeof req.headers["mcp-project-handle"] === "string" ? req.headers["mcp-project-handle"] : void 0;
270085
+ if (handleId && !statelessBindingStore.touch(handleId)) {
270086
+ res.writeHead(404, { "Content-Type": "application/json" });
270087
+ res.end(JSON.stringify({
270088
+ jsonrpc: "2.0",
270089
+ error: { code: -32001, message: "MCP project handle not found or expired; initialize again." },
270090
+ id: null
270091
+ }));
270092
+ return;
270093
+ }
270094
+ await modernNodeHandler(req, res, body);
269365
270095
  return;
269366
270096
  }
269367
270097
  if (sessionId && sessions.has(sessionId)) {
@@ -270323,6 +271053,7 @@ var init_serve_http = __esm({
270323
271053
  sendJson2({ error: err instanceof Error ? err.message : "Unknown error" }, 500);
270324
271054
  }
270325
271055
  }
271056
+ let httpReadyAt = null;
270326
271057
  const httpServer = createServer3(async (req, res) => {
270327
271058
  setCorsHeaders(req, res);
270328
271059
  if (req.method === "OPTIONS") {
@@ -270337,9 +271068,13 @@ var init_serve_http = __esm({
270337
271068
  res.end(JSON.stringify({
270338
271069
  status: "ok",
270339
271070
  mode: "control-plane",
271071
+ profile: toolProfile,
270340
271072
  port,
270341
271073
  uptime: Math.round(process.uptime()),
270342
271074
  pid: process.pid,
271075
+ projectId: defaultProject?.id ?? "__unresolved__",
271076
+ projectName: defaultProject?.name ?? null,
271077
+ readyAt: httpReadyAt,
270343
271078
  embedding: getEmbeddingRuntimeHealth2()
270344
271079
  }));
270345
271080
  return;
@@ -270406,6 +271141,7 @@ var init_serve_http = __esm({
270406
271141
  httpServer.keepAliveTimeout = 6e4;
270407
271142
  httpServer.headersTimeout = 65e3;
270408
271143
  httpServer.listen(port, host, () => {
271144
+ httpReadyAt = (/* @__PURE__ */ new Date()).toISOString();
270409
271145
  try {
270410
271146
  const memorixDir = (process.env.HOME || process.env.USERPROFILE || "").replace(/\\/g, "/") + "/.memorix";
270411
271147
  mkdirSync12(memorixDir, { recursive: true });
@@ -275007,6 +275743,9 @@ function getStateFilePath() {
275007
275743
  function getLogFilePath() {
275008
275744
  return getMemorixDir() + "/background.log";
275009
275745
  }
275746
+ function getBackgroundLockPath() {
275747
+ return getMemorixDir() + "/background.lock";
275748
+ }
275010
275749
  function parseBoundedPositiveInteger(value, fallback, label, maximum) {
275011
275750
  const raw = value ?? String(fallback);
275012
275751
  if (!/^[0-9]+$/u.test(raw)) {
@@ -275170,25 +275909,82 @@ async function startWindowsBackgroundService(options) {
275170
275909
  });
275171
275910
  }
275172
275911
  async function healthCheck(port, timeoutMs = 3e3) {
275912
+ const controller = new AbortController();
275913
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
275173
275914
  try {
275174
- const controller = new AbortController();
275175
- const timer = setTimeout(() => controller.abort(), timeoutMs);
275176
275915
  const res = await fetch(`http://127.0.0.1:${port}/health`, {
275177
275916
  signal: controller.signal
275178
275917
  });
275179
- clearTimeout(timer);
275180
275918
  if (!res.ok) return { ok: false, error: `HTTP ${res.status}` };
275181
275919
  const data = await res.json();
275182
275920
  return { ok: true, data };
275183
275921
  } catch (err) {
275184
275922
  return { ok: false, error: err instanceof Error ? err.message : "Unknown error" };
275923
+ } finally {
275924
+ clearTimeout(timer);
275185
275925
  }
275186
275926
  }
275187
275927
  async function isPortInUse(port) {
275188
275928
  const health = await healthCheck(port, 1500);
275189
275929
  return health.ok;
275190
275930
  }
275191
- async function doStart(port) {
275931
+ async function acquireBackgroundLock(lockPath, staleMs = BACKGROUND_LOCK_STALE_MS, timeoutMs = BACKGROUND_LOCK_ACQUIRE_TIMEOUT_MS) {
275932
+ const lockDir = path44.dirname(lockPath);
275933
+ if (!fs26.existsSync(lockDir)) fs26.mkdirSync(lockDir, { recursive: true });
275934
+ const deadline = Date.now() + timeoutMs;
275935
+ while (Date.now() < deadline) {
275936
+ try {
275937
+ const fd = fs26.openSync(lockPath, "wx");
275938
+ const token = `${process.pid}:${randomBytes2(12).toString("hex")}`;
275939
+ fs26.writeSync(fd, JSON.stringify({ pid: process.pid, acquiredAt: Date.now(), token }));
275940
+ const heartbeat = setInterval(() => {
275941
+ try {
275942
+ const now3 = /* @__PURE__ */ new Date();
275943
+ fs26.futimesSync(fd, now3, now3);
275944
+ } catch {
275945
+ }
275946
+ }, BACKGROUND_LOCK_HEARTBEAT_MS);
275947
+ heartbeat.unref();
275948
+ return { fd, acquired: true, path: lockPath, token, heartbeat };
275949
+ } catch (err) {
275950
+ if (!(err && err.code === "EEXIST")) throw err;
275951
+ try {
275952
+ if (Date.now() - fs26.statSync(lockPath).mtimeMs > staleMs) {
275953
+ let ownerAlive = false;
275954
+ try {
275955
+ const raw = fs26.readFileSync(lockPath, "utf8");
275956
+ const owner = JSON.parse(raw);
275957
+ ownerAlive = typeof owner.pid === "number" && owner.pid > 0 && isProcessRunning(owner.pid);
275958
+ } catch {
275959
+ }
275960
+ if (!ownerAlive) {
275961
+ fs26.unlinkSync(lockPath);
275962
+ continue;
275963
+ }
275964
+ }
275965
+ } catch {
275966
+ }
275967
+ await new Promise((resolve6) => setTimeout(resolve6, 200));
275968
+ }
275969
+ }
275970
+ throw new Error(
275971
+ `Another Memorix background start is still in progress (${lockPath}). Wait a few seconds and retry; no second control plane was started.`
275972
+ );
275973
+ }
275974
+ function releaseBackgroundLock(lock) {
275975
+ if (!lock.acquired) return;
275976
+ if (lock.heartbeat) clearInterval(lock.heartbeat);
275977
+ try {
275978
+ if (lock.fd !== null) fs26.closeSync(lock.fd);
275979
+ } catch {
275980
+ }
275981
+ try {
275982
+ const current = JSON.parse(fs26.readFileSync(lock.path, "utf8"));
275983
+ if (current.token === lock.token) fs26.unlinkSync(lock.path);
275984
+ } catch {
275985
+ }
275986
+ }
275987
+ async function doStartUnlocked(port) {
275192
275988
  const state = loadState();
275193
275989
  if (state) {
275194
275990
  if (isProcessRunning(state.pid)) {
@@ -275341,6 +276137,14 @@ async function doStart(port) {
275341
276137
  ].join("\n");
275342
276138
  process.stderr.write(footer + "\n");
275343
276139
  }
276140
+ async function doStart(port) {
276141
+ const lock = await acquireBackgroundLock(getBackgroundLockPath());
276142
+ try {
276143
+ await doStartUnlocked(port);
276144
+ } finally {
276145
+ releaseBackgroundLock(lock);
276146
+ }
276147
+ }
275344
276148
  async function doStop() {
275345
276149
  const state = loadState();
275346
276150
  if (!state) {
@@ -275400,11 +276204,22 @@ async function doStop() {
275400
276204
  }
275401
276205
  console.log("[OK] Control plane stopped.");
275402
276206
  }
275403
- async function doStatus() {
276207
+ async function doStatus(asJson = false) {
275404
276208
  const state = loadState();
275405
276209
  if (!state) {
275406
276210
  const portHealth = await healthCheck(3211, 2e3);
275407
276211
  if (portHealth.ok) {
276212
+ if (asJson) {
276213
+ console.log(JSON.stringify({
276214
+ status: "unmanaged",
276215
+ managed: false,
276216
+ port: 3211,
276217
+ dashboard: "http://127.0.0.1:3211/",
276218
+ mcp: "http://127.0.0.1:3211/mcp",
276219
+ health: portHealth.data ?? null
276220
+ }, null, 2));
276221
+ return;
276222
+ }
275408
276223
  console.log("");
275409
276224
  console.log("No background control plane is registered,");
275410
276225
  console.log('but a Memorix instance IS running on port 3211 (likely a foreground "memorix serve-http").');
@@ -275424,6 +276239,10 @@ async function doStatus() {
275424
276239
  console.log(' 2. Run "memorix background start"');
275425
276240
  console.log("");
275426
276241
  } else {
276242
+ if (asJson) {
276243
+ console.log(JSON.stringify({ status: "stopped", managed: false, port: 3211 }, null, 2));
276244
+ return;
276245
+ }
275427
276246
  console.log("No background control plane is registered.");
275428
276247
  console.log("");
275429
276248
  console.log("Start one with: memorix background start");
@@ -275434,6 +276253,30 @@ async function doStatus() {
275434
276253
  const health = running ? await healthCheck(state.port) : { ok: false, error: "Process not running" };
275435
276254
  const pidMismatch = health.ok && health.data?.pid && health.data.pid !== state.pid;
275436
276255
  const probablyReused = running && !health.ok;
276256
+ const status = health.ok && !pidMismatch ? "running" : pidMismatch ? "pid-mismatch" : probablyReused ? "pid-reused" : running ? "starting" : "stopped";
276257
+ if (asJson) {
276258
+ if (pidMismatch || probablyReused || !running) {
276259
+ clearState();
276260
+ try {
276261
+ fs26.unlinkSync(getMemorixDir() + "/background.ready");
276262
+ } catch {
276263
+ }
276264
+ }
276265
+ console.log(JSON.stringify({
276266
+ status,
276267
+ managed: true,
276268
+ pid: state.pid,
276269
+ port: state.port,
276270
+ startedAt: state.startedAt,
276271
+ instance: state.instanceToken ? `${state.instanceToken.slice(0, 8)}\u2026` : null,
276272
+ dashboard: `http://127.0.0.1:${state.port}/`,
276273
+ mcp: `http://127.0.0.1:${state.port}/mcp`,
276274
+ logFile: normalizePath3(state.logFile),
276275
+ health: health.ok ? health.data ?? null : null,
276276
+ error: health.ok ? null : health.error ?? (running ? "Health check failed" : "Process not running")
276277
+ }, null, 2));
276278
+ return;
276279
+ }
275437
276280
  console.log("");
275438
276281
  console.log("Memorix Background Control Plane");
275439
276282
  console.log("================================");
@@ -275453,6 +276296,9 @@ async function doStatus() {
275453
276296
  console.log(` PID: ${d4.pid ?? "unknown"}`);
275454
276297
  console.log(` Uptime: ${d4.uptime ?? 0}s`);
275455
276298
  console.log(` Mode: ${d4.mode ?? "unknown"}`);
276299
+ console.log(` Profile: ${d4.profile ?? "unknown"}`);
276300
+ console.log(` Project: ${d4.projectId ?? "unresolved"}${d4.projectName ? ` (${d4.projectName})` : ""}`);
276301
+ console.log(` Ready at: ${d4.readyAt ?? "unknown"}`);
275456
276302
  }
275457
276303
  if (pidMismatch) {
275458
276304
  console.log("");
@@ -275546,7 +276392,7 @@ function doLogs(follow, lines) {
275546
276392
  console.log(tail.join("\n"));
275547
276393
  }
275548
276394
  }
275549
- var background_default, _testing3;
276395
+ var BACKGROUND_LOCK_STALE_MS, BACKGROUND_LOCK_ACQUIRE_TIMEOUT_MS, BACKGROUND_LOCK_HEARTBEAT_MS, background_default, _testing3;
275550
276396
  var init_background = __esm({
275551
276397
  "src/cli/commands/background.ts"() {
275552
276398
  "use strict";
@@ -275554,6 +276400,9 @@ var init_background = __esm({
275554
276400
  init_dist2();
275555
276401
  init_port();
275556
276402
  init_launch_root();
276403
+ BACKGROUND_LOCK_STALE_MS = 15e3;
276404
+ BACKGROUND_LOCK_ACQUIRE_TIMEOUT_MS = 1e4;
276405
+ BACKGROUND_LOCK_HEARTBEAT_MS = 2e3;
275557
276406
  background_default = defineCommand({
275558
276407
  meta: {
275559
276408
  name: "background",
@@ -275576,6 +276425,11 @@ var init_background = __esm({
275576
276425
  alias: "n",
275577
276426
  description: "Number of log lines to show (default: 50)",
275578
276427
  required: false
276428
+ },
276429
+ json: {
276430
+ type: "boolean",
276431
+ description: "Emit a machine-readable status receipt",
276432
+ required: false
275579
276433
  }
275580
276434
  },
275581
276435
  run: async ({ args }) => {
@@ -275590,7 +276444,7 @@ var init_background = __esm({
275590
276444
  await doStop();
275591
276445
  break;
275592
276446
  case "status":
275593
- await doStatus();
276447
+ await doStatus(!!args.json);
275594
276448
  break;
275595
276449
  case "restart":
275596
276450
  await doRestart(port);
@@ -275616,6 +276470,7 @@ var init_background = __esm({
275616
276470
  console.log(" --port <port> HTTP port (default: 3211)");
275617
276471
  console.log(' --follow, -f Follow log output in real-time (for "logs")');
275618
276472
  console.log(" --lines, -n Number of log lines to show (default: 50)");
276473
+ console.log(' --json Emit a machine-readable status receipt (for "status")');
275619
276474
  console.log("");
275620
276475
  console.log("Mode distinction:");
275621
276476
  console.log(" Quick Mode = stdio / single project / zero friction");
@@ -275637,7 +276492,10 @@ var init_background = __esm({
275637
276492
  formatBackgroundCommandError,
275638
276493
  resolveBackgroundCliEntry,
275639
276494
  resolveBackgroundCliEntryFrom,
275640
- resolveBackgroundCwd
276495
+ resolveBackgroundCwd,
276496
+ acquireBackgroundLock,
276497
+ releaseBackgroundLock,
276498
+ getBackgroundLockPath
275641
276499
  };
275642
276500
  }
275643
276501
  });
@@ -286003,6 +286861,10 @@ var GUIDES = {
286003
286861
  usage: [
286004
286862
  "memorix codegraph status",
286005
286863
  "memorix codegraph refresh",
286864
+ "memorix codegraph init",
286865
+ "memorix codegraph sync",
286866
+ "memorix codegraph diff [--from <snapshot>] [--to <snapshot>]",
286867
+ "memorix codegraph impact --path <relative-source-path>",
286006
286868
  'memorix codegraph context-pack --task "trace the auth flow" [--limit 20]'
286007
286869
  ]
286008
286870
  },
@@ -286021,10 +286883,57 @@ var GUIDES = {
286021
286883
  usage: [
286022
286884
  "memorix knowledge init [--mode local|versioned]",
286023
286885
  "memorix knowledge status",
286886
+ "memorix knowledge claims",
286887
+ 'memorix knowledge review --id <claim-id> --review approved|rejected --detail "..."',
286024
286888
  "memorix knowledge compile",
286025
286889
  "memorix knowledge lint",
286026
- "memorix knowledge workflow list"
286027
- ]
286890
+ "memorix knowledge apply --proposal <id> [--force]",
286891
+ "memorix knowledge workflow import|list",
286892
+ 'memorix knowledge workflow select --task "prepare a release"',
286893
+ "memorix knowledge workflow preview|apply --id <workflow-id> --agent codex",
286894
+ 'memorix knowledge workflow run --id <workflow-id> --task "..." --outcome passed'
286895
+ ],
286896
+ notes: ["Claims need source review before they can become maintained Knowledge Workspace pages."]
286897
+ },
286898
+ evidence: {
286899
+ summary: "Inspect the source, freshness, and verification state behind project memories.",
286900
+ usage: [
286901
+ 'memorix evidence list [--query "auth"] [--limit 20]',
286902
+ "memorix evidence get --id 42",
286903
+ "memorix evidence sync",
286904
+ 'memorix evidence stale --paths src/server.ts,tests/server.test.ts --reason "source changed"',
286905
+ "memorix evidence events --id 42"
286906
+ ],
286907
+ notes: ["Evidence cards point back to observations and source files; they are not a second memory store."]
286908
+ },
286909
+ feedback: {
286910
+ summary: "Record and inspect whether a memory helped, conflicted, or was corrected.",
286911
+ usage: [
286912
+ "memorix feedback record --id 42 --signal verification-success --source test:run-1",
286913
+ "memorix feedback show --id 42",
286914
+ "memorix feedback audit --id 42 [--limit 100]"
286915
+ ],
286916
+ notes: ["Feedback changes the candidate score through an auditable event; it does not rewrite the original memory."]
286917
+ },
286918
+ formation: {
286919
+ summary: "Inspect Memory Formation quality metrics collected by the runtime.",
286920
+ usage: ["memorix formation metrics"],
286921
+ notes: ["Metrics are empty until the formation pipeline has processed observations."]
286922
+ },
286923
+ media: {
286924
+ summary: "Import, inspect, derive, embed, and clean controlled local media assets.",
286925
+ usage: [
286926
+ "memorix media import --path ./diagram.png",
286927
+ 'memorix media attach --asset <asset-id> --title "Architecture diagram"',
286928
+ "memorix media list --kind image",
286929
+ "memorix media show --asset <asset-id>",
286930
+ "memorix media derive-pdf|derive-audio --asset <asset-id> [--attach]",
286931
+ "memorix media embed|similar --asset <asset-id>",
286932
+ 'memorix media generate image|video --prompt "..."',
286933
+ "memorix media status|cancel --job <media-job-id>",
286934
+ "memorix media cleanup [--max-bytes <limit>]"
286935
+ ],
286936
+ notes: ["Media generation is explicit and provider-gated; importing a file does not automatically send it to a model."]
286028
286937
  },
286029
286938
  reasoning: {
286030
286939
  summary: "Capture and retrieve engineering decision rationale.",
@@ -286517,7 +287426,7 @@ var main2 = defineCommand({
286517
287426
  console.error(" integrate Install one IDE integration into the current repo");
286518
287427
  console.error(" status Show project info + stats");
286519
287428
  console.error(" dashboard Open standalone dashboard (read-mostly)");
286520
- console.error(" hooks Open legacy hook installer menu");
287429
+ console.error(" hooks Install, inspect, or remove agent hooks");
286521
287430
  console.error(" cleanup Remove old memories");
286522
287431
  console.error(" purge Retire all memories (project by default, --all for everything)");
286523
287432
  console.error(" sync Rules/workspace sync plus interactive wizard");