@miniaxolotl/grove 1.11.0 → 1.11.1

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.
package/dist/cli.js CHANGED
@@ -6,10 +6,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
+ }) : x)(function(x) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
9
15
  var __esm = (fn, res) => function __init() {
10
16
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
17
  };
12
- var __commonJS = (cb, mod) => function __require() {
18
+ var __commonJS = (cb, mod) => function __require2() {
13
19
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
20
  };
15
21
  var __export = (target, all) => {
@@ -37,7 +43,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
37
43
  var define_GROVE_TELEMETRY_default;
38
44
  var init_define_GROVE_TELEMETRY = __esm({
39
45
  "<define:__GROVE_TELEMETRY__>"() {
40
- define_GROVE_TELEMETRY_default = { enabled: true, revision: "22e76b4dd002be8f2debf13d7d9ea3dfb80484b6", version: "1.11.0", component: "cli", key: "phc_AqVrjhk7W2X2pFjyngY7uWxcSSRREfJhgr8mBmKbXYEh", cliDsn: "https://3f6d0711b5890dea4ce8e6ccf2a1a7fd@o4511632209346560.ingest.us.sentry.io/4512290791620608", apiDsn: "https://4524e8910e318110277babdfe818999b@o4511632209346560.ingest.us.sentry.io/4512290791489536" };
46
+ define_GROVE_TELEMETRY_default = { enabled: true, revision: "ad1b9fe27941b0dc370ee3a0c4742dd6215e9f41", version: "1.11.1", component: "cli", key: "phc_AqVrjhk7W2X2pFjyngY7uWxcSSRREfJhgr8mBmKbXYEh", cliDsn: "https://3f6d0711b5890dea4ce8e6ccf2a1a7fd@o4511632209346560.ingest.us.sentry.io/4512290791620608", apiDsn: "https://4524e8910e318110277babdfe818999b@o4511632209346560.ingest.us.sentry.io/4512290791489536" };
41
47
  }
42
48
  });
43
49
 
@@ -2192,11 +2198,11 @@ var require_codegen = __commonJS({
2192
2198
  const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
2193
2199
  return `${varKind} ${this.name}${rhs};` + _n;
2194
2200
  }
2195
- optimizeNames(names, constants2) {
2201
+ optimizeNames(names, constants3) {
2196
2202
  if (!names[this.name.str])
2197
2203
  return;
2198
2204
  if (this.rhs)
2199
- this.rhs = optimizeExpr(this.rhs, names, constants2);
2205
+ this.rhs = optimizeExpr(this.rhs, names, constants3);
2200
2206
  return this;
2201
2207
  }
2202
2208
  get names() {
@@ -2213,10 +2219,10 @@ var require_codegen = __commonJS({
2213
2219
  render({ _n }) {
2214
2220
  return `${this.lhs} = ${this.rhs};` + _n;
2215
2221
  }
2216
- optimizeNames(names, constants2) {
2222
+ optimizeNames(names, constants3) {
2217
2223
  if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
2218
2224
  return;
2219
- this.rhs = optimizeExpr(this.rhs, names, constants2);
2225
+ this.rhs = optimizeExpr(this.rhs, names, constants3);
2220
2226
  return this;
2221
2227
  }
2222
2228
  get names() {
@@ -2277,8 +2283,8 @@ var require_codegen = __commonJS({
2277
2283
  optimizeNodes() {
2278
2284
  return `${this.code}` ? this : void 0;
2279
2285
  }
2280
- optimizeNames(names, constants2) {
2281
- this.code = optimizeExpr(this.code, names, constants2);
2286
+ optimizeNames(names, constants3) {
2287
+ this.code = optimizeExpr(this.code, names, constants3);
2282
2288
  return this;
2283
2289
  }
2284
2290
  get names() {
@@ -2307,12 +2313,12 @@ var require_codegen = __commonJS({
2307
2313
  }
2308
2314
  return nodes.length > 0 ? this : void 0;
2309
2315
  }
2310
- optimizeNames(names, constants2) {
2316
+ optimizeNames(names, constants3) {
2311
2317
  const { nodes } = this;
2312
2318
  let i = nodes.length;
2313
2319
  while (i--) {
2314
2320
  const n = nodes[i];
2315
- if (n.optimizeNames(names, constants2))
2321
+ if (n.optimizeNames(names, constants3))
2316
2322
  continue;
2317
2323
  subtractNames(names, n.names);
2318
2324
  nodes.splice(i, 1);
@@ -2365,12 +2371,12 @@ var require_codegen = __commonJS({
2365
2371
  return void 0;
2366
2372
  return this;
2367
2373
  }
2368
- optimizeNames(names, constants2) {
2374
+ optimizeNames(names, constants3) {
2369
2375
  var _a2;
2370
- this.else = (_a2 = this.else) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names, constants2);
2371
- if (!(super.optimizeNames(names, constants2) || this.else))
2376
+ this.else = (_a2 = this.else) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names, constants3);
2377
+ if (!(super.optimizeNames(names, constants3) || this.else))
2372
2378
  return;
2373
- this.condition = optimizeExpr(this.condition, names, constants2);
2379
+ this.condition = optimizeExpr(this.condition, names, constants3);
2374
2380
  return this;
2375
2381
  }
2376
2382
  get names() {
@@ -2393,10 +2399,10 @@ var require_codegen = __commonJS({
2393
2399
  render(opts) {
2394
2400
  return `for(${this.iteration})` + super.render(opts);
2395
2401
  }
2396
- optimizeNames(names, constants2) {
2397
- if (!super.optimizeNames(names, constants2))
2402
+ optimizeNames(names, constants3) {
2403
+ if (!super.optimizeNames(names, constants3))
2398
2404
  return;
2399
- this.iteration = optimizeExpr(this.iteration, names, constants2);
2405
+ this.iteration = optimizeExpr(this.iteration, names, constants3);
2400
2406
  return this;
2401
2407
  }
2402
2408
  get names() {
@@ -2432,10 +2438,10 @@ var require_codegen = __commonJS({
2432
2438
  render(opts) {
2433
2439
  return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
2434
2440
  }
2435
- optimizeNames(names, constants2) {
2436
- if (!super.optimizeNames(names, constants2))
2441
+ optimizeNames(names, constants3) {
2442
+ if (!super.optimizeNames(names, constants3))
2437
2443
  return;
2438
- this.iterable = optimizeExpr(this.iterable, names, constants2);
2444
+ this.iterable = optimizeExpr(this.iterable, names, constants3);
2439
2445
  return this;
2440
2446
  }
2441
2447
  get names() {
@@ -2477,11 +2483,11 @@ var require_codegen = __commonJS({
2477
2483
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
2478
2484
  return this;
2479
2485
  }
2480
- optimizeNames(names, constants2) {
2486
+ optimizeNames(names, constants3) {
2481
2487
  var _a2, _b;
2482
- super.optimizeNames(names, constants2);
2483
- (_a2 = this.catch) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names, constants2);
2484
- (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants2);
2488
+ super.optimizeNames(names, constants3);
2489
+ (_a2 = this.catch) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names, constants3);
2490
+ (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants3);
2485
2491
  return this;
2486
2492
  }
2487
2493
  get names() {
@@ -2782,7 +2788,7 @@ var require_codegen = __commonJS({
2782
2788
  function addExprNames(names, from) {
2783
2789
  return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
2784
2790
  }
2785
- function optimizeExpr(expr, names, constants2) {
2791
+ function optimizeExpr(expr, names, constants3) {
2786
2792
  if (expr instanceof code_1.Name)
2787
2793
  return replaceName(expr);
2788
2794
  if (!canOptimize(expr))
@@ -2797,14 +2803,14 @@ var require_codegen = __commonJS({
2797
2803
  return items;
2798
2804
  }, []));
2799
2805
  function replaceName(n) {
2800
- const c = constants2[n.str];
2806
+ const c = constants3[n.str];
2801
2807
  if (c === void 0 || names[n.str] !== 1)
2802
2808
  return n;
2803
2809
  delete names[n.str];
2804
2810
  return c;
2805
2811
  }
2806
2812
  function canOptimize(e) {
2807
- return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants2[c.str] !== void 0);
2813
+ return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants3[c.str] !== void 0);
2808
2814
  }
2809
2815
  }
2810
2816
  function subtractNames(names, from) {
@@ -8650,6 +8656,516 @@ var require_dist = __commonJS({
8650
8656
  }
8651
8657
  });
8652
8658
 
8659
+ // node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
8660
+ var require_windows = __commonJS({
8661
+ "node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module2) {
8662
+ init_define_GROVE_TELEMETRY();
8663
+ module2.exports = isexe;
8664
+ isexe.sync = sync;
8665
+ var fs = __require("fs");
8666
+ function checkPathExt(path, options) {
8667
+ var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
8668
+ if (!pathext) {
8669
+ return true;
8670
+ }
8671
+ pathext = pathext.split(";");
8672
+ if (pathext.indexOf("") !== -1) {
8673
+ return true;
8674
+ }
8675
+ for (var i = 0; i < pathext.length; i++) {
8676
+ var p = pathext[i].toLowerCase();
8677
+ if (p && path.substr(-p.length).toLowerCase() === p) {
8678
+ return true;
8679
+ }
8680
+ }
8681
+ return false;
8682
+ }
8683
+ function checkStat(stat4, path, options) {
8684
+ if (!stat4.isSymbolicLink() && !stat4.isFile()) {
8685
+ return false;
8686
+ }
8687
+ return checkPathExt(path, options);
8688
+ }
8689
+ function isexe(path, options, cb) {
8690
+ fs.stat(path, function(er, stat4) {
8691
+ cb(er, er ? false : checkStat(stat4, path, options));
8692
+ });
8693
+ }
8694
+ function sync(path, options) {
8695
+ return checkStat(fs.statSync(path), path, options);
8696
+ }
8697
+ }
8698
+ });
8699
+
8700
+ // node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
8701
+ var require_mode = __commonJS({
8702
+ "node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module2) {
8703
+ init_define_GROVE_TELEMETRY();
8704
+ module2.exports = isexe;
8705
+ isexe.sync = sync;
8706
+ var fs = __require("fs");
8707
+ function isexe(path, options, cb) {
8708
+ fs.stat(path, function(er, stat4) {
8709
+ cb(er, er ? false : checkStat(stat4, options));
8710
+ });
8711
+ }
8712
+ function sync(path, options) {
8713
+ return checkStat(fs.statSync(path), options);
8714
+ }
8715
+ function checkStat(stat4, options) {
8716
+ return stat4.isFile() && checkMode(stat4, options);
8717
+ }
8718
+ function checkMode(stat4, options) {
8719
+ var mod = stat4.mode;
8720
+ var uid = stat4.uid;
8721
+ var gid = stat4.gid;
8722
+ var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
8723
+ var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
8724
+ var u = parseInt("100", 8);
8725
+ var g = parseInt("010", 8);
8726
+ var o = parseInt("001", 8);
8727
+ var ug = u | g;
8728
+ var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
8729
+ return ret;
8730
+ }
8731
+ }
8732
+ });
8733
+
8734
+ // node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
8735
+ var require_isexe = __commonJS({
8736
+ "node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module2) {
8737
+ init_define_GROVE_TELEMETRY();
8738
+ var fs = __require("fs");
8739
+ var core;
8740
+ if (process.platform === "win32" || global.TESTING_WINDOWS) {
8741
+ core = require_windows();
8742
+ } else {
8743
+ core = require_mode();
8744
+ }
8745
+ module2.exports = isexe;
8746
+ isexe.sync = sync;
8747
+ function isexe(path, options, cb) {
8748
+ if (typeof options === "function") {
8749
+ cb = options;
8750
+ options = {};
8751
+ }
8752
+ if (!cb) {
8753
+ if (typeof Promise !== "function") {
8754
+ throw new TypeError("callback not provided");
8755
+ }
8756
+ return new Promise(function(resolve2, reject) {
8757
+ isexe(path, options || {}, function(er, is) {
8758
+ if (er) {
8759
+ reject(er);
8760
+ } else {
8761
+ resolve2(is);
8762
+ }
8763
+ });
8764
+ });
8765
+ }
8766
+ core(path, options || {}, function(er, is) {
8767
+ if (er) {
8768
+ if (er.code === "EACCES" || options && options.ignoreErrors) {
8769
+ er = null;
8770
+ is = false;
8771
+ }
8772
+ }
8773
+ cb(er, is);
8774
+ });
8775
+ }
8776
+ function sync(path, options) {
8777
+ try {
8778
+ return core.sync(path, options || {});
8779
+ } catch (er) {
8780
+ if (options && options.ignoreErrors || er.code === "EACCES") {
8781
+ return false;
8782
+ } else {
8783
+ throw er;
8784
+ }
8785
+ }
8786
+ }
8787
+ }
8788
+ });
8789
+
8790
+ // node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
8791
+ var require_which = __commonJS({
8792
+ "node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module2) {
8793
+ init_define_GROVE_TELEMETRY();
8794
+ var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
8795
+ var path = __require("path");
8796
+ var COLON = isWindows ? ";" : ":";
8797
+ var isexe = require_isexe();
8798
+ var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
8799
+ var getPathInfo = (cmd, opt) => {
8800
+ const colon = opt.colon || COLON;
8801
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
8802
+ // windows always checks the cwd first
8803
+ ...isWindows ? [process.cwd()] : [],
8804
+ ...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
8805
+ "").split(colon)
8806
+ ];
8807
+ const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
8808
+ const pathExt = isWindows ? pathExtExe.split(colon) : [""];
8809
+ if (isWindows) {
8810
+ if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
8811
+ pathExt.unshift("");
8812
+ }
8813
+ return {
8814
+ pathEnv,
8815
+ pathExt,
8816
+ pathExtExe
8817
+ };
8818
+ };
8819
+ var which = (cmd, opt, cb) => {
8820
+ if (typeof opt === "function") {
8821
+ cb = opt;
8822
+ opt = {};
8823
+ }
8824
+ if (!opt)
8825
+ opt = {};
8826
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
8827
+ const found = [];
8828
+ const step = (i) => new Promise((resolve2, reject) => {
8829
+ if (i === pathEnv.length)
8830
+ return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
8831
+ const ppRaw = pathEnv[i];
8832
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
8833
+ const pCmd = path.join(pathPart, cmd);
8834
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
8835
+ resolve2(subStep(p, i, 0));
8836
+ });
8837
+ const subStep = (p, i, ii) => new Promise((resolve2, reject) => {
8838
+ if (ii === pathExt.length)
8839
+ return resolve2(step(i + 1));
8840
+ const ext = pathExt[ii];
8841
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
8842
+ if (!er && is) {
8843
+ if (opt.all)
8844
+ found.push(p + ext);
8845
+ else
8846
+ return resolve2(p + ext);
8847
+ }
8848
+ return resolve2(subStep(p, i, ii + 1));
8849
+ });
8850
+ });
8851
+ return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
8852
+ };
8853
+ var whichSync = (cmd, opt) => {
8854
+ opt = opt || {};
8855
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
8856
+ const found = [];
8857
+ for (let i = 0; i < pathEnv.length; i++) {
8858
+ const ppRaw = pathEnv[i];
8859
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
8860
+ const pCmd = path.join(pathPart, cmd);
8861
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
8862
+ for (let j = 0; j < pathExt.length; j++) {
8863
+ const cur = p + pathExt[j];
8864
+ try {
8865
+ const is = isexe.sync(cur, { pathExt: pathExtExe });
8866
+ if (is) {
8867
+ if (opt.all)
8868
+ found.push(cur);
8869
+ else
8870
+ return cur;
8871
+ }
8872
+ } catch (ex) {
8873
+ }
8874
+ }
8875
+ }
8876
+ if (opt.all && found.length)
8877
+ return found;
8878
+ if (opt.nothrow)
8879
+ return null;
8880
+ throw getNotFoundError(cmd);
8881
+ };
8882
+ module2.exports = which;
8883
+ which.sync = whichSync;
8884
+ }
8885
+ });
8886
+
8887
+ // node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
8888
+ var require_path_key = __commonJS({
8889
+ "node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js"(exports, module2) {
8890
+ "use strict";
8891
+ init_define_GROVE_TELEMETRY();
8892
+ var pathKey = (options = {}) => {
8893
+ const environment = options.env || process.env;
8894
+ const platform2 = options.platform || process.platform;
8895
+ if (platform2 !== "win32") {
8896
+ return "PATH";
8897
+ }
8898
+ return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
8899
+ };
8900
+ module2.exports = pathKey;
8901
+ module2.exports.default = pathKey;
8902
+ }
8903
+ });
8904
+
8905
+ // node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
8906
+ var require_resolveCommand = __commonJS({
8907
+ "node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module2) {
8908
+ "use strict";
8909
+ init_define_GROVE_TELEMETRY();
8910
+ var path = __require("path");
8911
+ var which = require_which();
8912
+ var getPathKey = require_path_key();
8913
+ function resolveCommandAttempt(parsed, withoutPathExt) {
8914
+ const env = parsed.options.env || process.env;
8915
+ const cwd = process.cwd();
8916
+ const hasCustomCwd = parsed.options.cwd != null;
8917
+ const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
8918
+ if (shouldSwitchCwd) {
8919
+ try {
8920
+ process.chdir(parsed.options.cwd);
8921
+ } catch (err) {
8922
+ }
8923
+ }
8924
+ let resolved;
8925
+ try {
8926
+ resolved = which.sync(parsed.command, {
8927
+ path: env[getPathKey({ env })],
8928
+ pathExt: withoutPathExt ? path.delimiter : void 0
8929
+ });
8930
+ } catch (e) {
8931
+ } finally {
8932
+ if (shouldSwitchCwd) {
8933
+ process.chdir(cwd);
8934
+ }
8935
+ }
8936
+ if (resolved) {
8937
+ resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
8938
+ }
8939
+ return resolved;
8940
+ }
8941
+ function resolveCommand(parsed) {
8942
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
8943
+ }
8944
+ module2.exports = resolveCommand;
8945
+ }
8946
+ });
8947
+
8948
+ // node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
8949
+ var require_escape = __commonJS({
8950
+ "node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js"(exports, module2) {
8951
+ "use strict";
8952
+ init_define_GROVE_TELEMETRY();
8953
+ var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
8954
+ function escapeCommand(arg) {
8955
+ arg = arg.replace(metaCharsRegExp, "^$1");
8956
+ return arg;
8957
+ }
8958
+ function escapeArgument(arg, doubleEscapeMetaChars) {
8959
+ arg = `${arg}`;
8960
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
8961
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
8962
+ arg = `"${arg}"`;
8963
+ arg = arg.replace(metaCharsRegExp, "^$1");
8964
+ if (doubleEscapeMetaChars) {
8965
+ arg = arg.replace(metaCharsRegExp, "^$1");
8966
+ }
8967
+ return arg;
8968
+ }
8969
+ module2.exports.command = escapeCommand;
8970
+ module2.exports.argument = escapeArgument;
8971
+ }
8972
+ });
8973
+
8974
+ // node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
8975
+ var require_shebang_regex = __commonJS({
8976
+ "node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js"(exports, module2) {
8977
+ "use strict";
8978
+ init_define_GROVE_TELEMETRY();
8979
+ module2.exports = /^#!(.*)/;
8980
+ }
8981
+ });
8982
+
8983
+ // node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
8984
+ var require_shebang_command = __commonJS({
8985
+ "node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js"(exports, module2) {
8986
+ "use strict";
8987
+ init_define_GROVE_TELEMETRY();
8988
+ var shebangRegex = require_shebang_regex();
8989
+ module2.exports = (string4 = "") => {
8990
+ const match = string4.match(shebangRegex);
8991
+ if (!match) {
8992
+ return null;
8993
+ }
8994
+ const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
8995
+ const binary = path.split("/").pop();
8996
+ if (binary === "env") {
8997
+ return argument;
8998
+ }
8999
+ return argument ? `${binary} ${argument}` : binary;
9000
+ };
9001
+ }
9002
+ });
9003
+
9004
+ // node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
9005
+ var require_readShebang = __commonJS({
9006
+ "node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module2) {
9007
+ "use strict";
9008
+ init_define_GROVE_TELEMETRY();
9009
+ var fs = __require("fs");
9010
+ var shebangCommand = require_shebang_command();
9011
+ function readShebang(command) {
9012
+ const size = 150;
9013
+ const buffer = Buffer.alloc(size);
9014
+ let fd;
9015
+ try {
9016
+ fd = fs.openSync(command, "r");
9017
+ fs.readSync(fd, buffer, 0, size, 0);
9018
+ fs.closeSync(fd);
9019
+ } catch (e) {
9020
+ }
9021
+ return shebangCommand(buffer.toString());
9022
+ }
9023
+ module2.exports = readShebang;
9024
+ }
9025
+ });
9026
+
9027
+ // node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
9028
+ var require_parse = __commonJS({
9029
+ "node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module2) {
9030
+ "use strict";
9031
+ init_define_GROVE_TELEMETRY();
9032
+ var path = __require("path");
9033
+ var resolveCommand = require_resolveCommand();
9034
+ var escape2 = require_escape();
9035
+ var readShebang = require_readShebang();
9036
+ var isWin = process.platform === "win32";
9037
+ var isExecutableRegExp = /\.(?:com|exe)$/i;
9038
+ var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
9039
+ function detectShebang(parsed) {
9040
+ parsed.file = resolveCommand(parsed);
9041
+ const shebang = parsed.file && readShebang(parsed.file);
9042
+ if (shebang) {
9043
+ parsed.args.unshift(parsed.file);
9044
+ parsed.command = shebang;
9045
+ return resolveCommand(parsed);
9046
+ }
9047
+ return parsed.file;
9048
+ }
9049
+ function parseNonShell(parsed) {
9050
+ if (!isWin) {
9051
+ return parsed;
9052
+ }
9053
+ const commandFile = detectShebang(parsed);
9054
+ const needsShell = !isExecutableRegExp.test(commandFile);
9055
+ if (parsed.options.forceShell || needsShell) {
9056
+ const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
9057
+ parsed.command = path.normalize(parsed.command);
9058
+ parsed.command = escape2.command(parsed.command);
9059
+ parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
9060
+ const shellCommand = [parsed.command].concat(parsed.args).join(" ");
9061
+ parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
9062
+ parsed.command = process.env.comspec || "cmd.exe";
9063
+ parsed.options.windowsVerbatimArguments = true;
9064
+ }
9065
+ return parsed;
9066
+ }
9067
+ function parse5(command, args, options) {
9068
+ if (args && !Array.isArray(args)) {
9069
+ options = args;
9070
+ args = null;
9071
+ }
9072
+ args = args ? args.slice(0) : [];
9073
+ options = Object.assign({}, options);
9074
+ const parsed = {
9075
+ command,
9076
+ args,
9077
+ options,
9078
+ file: void 0,
9079
+ original: {
9080
+ command,
9081
+ args
9082
+ }
9083
+ };
9084
+ return options.shell ? parsed : parseNonShell(parsed);
9085
+ }
9086
+ module2.exports = parse5;
9087
+ }
9088
+ });
9089
+
9090
+ // node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
9091
+ var require_enoent = __commonJS({
9092
+ "node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js"(exports, module2) {
9093
+ "use strict";
9094
+ init_define_GROVE_TELEMETRY();
9095
+ var isWin = process.platform === "win32";
9096
+ function notFoundError(original, syscall) {
9097
+ return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
9098
+ code: "ENOENT",
9099
+ errno: "ENOENT",
9100
+ syscall: `${syscall} ${original.command}`,
9101
+ path: original.command,
9102
+ spawnargs: original.args
9103
+ });
9104
+ }
9105
+ function hookChildProcess(cp, parsed) {
9106
+ if (!isWin) {
9107
+ return;
9108
+ }
9109
+ const originalEmit = cp.emit;
9110
+ cp.emit = function(name, arg1) {
9111
+ if (name === "exit") {
9112
+ const err = verifyENOENT(arg1, parsed);
9113
+ if (err) {
9114
+ return originalEmit.call(cp, "error", err);
9115
+ }
9116
+ }
9117
+ return originalEmit.apply(cp, arguments);
9118
+ };
9119
+ }
9120
+ function verifyENOENT(status, parsed) {
9121
+ if (isWin && status === 1 && !parsed.file) {
9122
+ return notFoundError(parsed.original, "spawn");
9123
+ }
9124
+ return null;
9125
+ }
9126
+ function verifyENOENTSync(status, parsed) {
9127
+ if (isWin && status === 1 && !parsed.file) {
9128
+ return notFoundError(parsed.original, "spawnSync");
9129
+ }
9130
+ return null;
9131
+ }
9132
+ module2.exports = {
9133
+ hookChildProcess,
9134
+ verifyENOENT,
9135
+ verifyENOENTSync,
9136
+ notFoundError
9137
+ };
9138
+ }
9139
+ });
9140
+
9141
+ // node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
9142
+ var require_cross_spawn = __commonJS({
9143
+ "node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports, module2) {
9144
+ "use strict";
9145
+ init_define_GROVE_TELEMETRY();
9146
+ var cp = __require("child_process");
9147
+ var parse5 = require_parse();
9148
+ var enoent = require_enoent();
9149
+ function spawn4(command, args, options) {
9150
+ const parsed = parse5(command, args, options);
9151
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
9152
+ enoent.hookChildProcess(spawned, parsed);
9153
+ return spawned;
9154
+ }
9155
+ function spawnSync(command, args, options) {
9156
+ const parsed = parse5(command, args, options);
9157
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
9158
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
9159
+ return result;
9160
+ }
9161
+ module2.exports = spawn4;
9162
+ module2.exports.spawn = spawn4;
9163
+ module2.exports.sync = spawnSync;
9164
+ module2.exports._parse = parse5;
9165
+ module2.exports._enoent = enoent;
9166
+ }
9167
+ });
9168
+
8653
9169
  // packages/mcp/src/cli.ts
8654
9170
  init_define_GROVE_TELEMETRY();
8655
9171
  import { createServer } from "node:http";
@@ -10263,8 +10779,8 @@ function emoji() {
10263
10779
  }
10264
10780
  var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
10265
10781
  var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
10266
- var mac = (delimiter) => {
10267
- const escapedDelim = escapeRegex(delimiter ?? ":");
10782
+ var mac = (delimiter2) => {
10783
+ const escapedDelim = escapeRegex(delimiter2 ?? ":");
10268
10784
  return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
10269
10785
  };
10270
10786
  var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
@@ -24081,7 +24597,23 @@ var ApiClient = class {
24081
24597
  redirect: "error",
24082
24598
  cache: "no-store"
24083
24599
  });
24084
- const result = await response.json();
24600
+ let result;
24601
+ try {
24602
+ result = await response.json();
24603
+ } catch (error48) {
24604
+ if (signal.aborted || !(error48 instanceof SyntaxError)) throw error48;
24605
+ throw new GroveError(
24606
+ "invalid_response",
24607
+ "Invalid Grove API response",
24608
+ response.ok ? 502 : response.status
24609
+ );
24610
+ }
24611
+ if (!result || typeof result !== "object" || Array.isArray(result) || typeof result.success !== "boolean" || !result.success && (!result.error || typeof result.error.code !== "string" || typeof result.error.message !== "string"))
24612
+ throw new GroveError(
24613
+ "invalid_response",
24614
+ "Invalid Grove API response",
24615
+ response.ok ? 502 : response.status
24616
+ );
24085
24617
  if (!response.ok || !result.success) {
24086
24618
  const error48 = !result.success ? result.error : void 0;
24087
24619
  throw new GroveError(
@@ -24099,6 +24631,7 @@ var ApiClient = class {
24099
24631
  completed = true;
24100
24632
  return result.data;
24101
24633
  } catch (error48) {
24634
+ options.signal?.throwIfAborted();
24102
24635
  if (error48 instanceof GroveError) throw error48;
24103
24636
  throw new GroveError(
24104
24637
  signal.aborted ? "timeout" : "unreachable",
@@ -31132,15 +31665,15 @@ function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
31132
31665
  });
31133
31666
  }
31134
31667
  function addUncaughtExceptionListener(captureFn, onFatalFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
31135
- const process3 = globalThis.process;
31136
- if (!process3) return;
31137
- if ("strict" === mode) return void process3.on("uncaughtExceptionMonitor", (error48, origin) => captureUncaughtException(captureFn, error48, origin));
31138
- process3.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
31668
+ const process4 = globalThis.process;
31669
+ if (!process4) return;
31670
+ if ("strict" === mode) return void process4.on("uncaughtExceptionMonitor", (error48, origin) => captureUncaughtException(captureFn, error48, origin));
31671
+ process4.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
31139
31672
  }
31140
31673
  function addUnhandledRejectionListener(captureFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
31141
- const process3 = globalThis.process;
31142
- if (!process3 || "throw" === mode || "strict" === mode || "warn-with-error-code" === mode) return;
31143
- process3.on("unhandledRejection", (reason) => {
31674
+ const process4 = globalThis.process;
31675
+ if (!process4 || "throw" === mode || "strict" === mode || "warn-with-error-code" === mode) return;
31676
+ process4.on("unhandledRejection", (reason) => {
31144
31677
  captureFn(reason, {
31145
31678
  mechanism: {
31146
31679
  type: "onunhandledrejection",
@@ -35933,8 +36466,8 @@ function isBrowser() {
35933
36466
  return typeof window !== "undefined" && (!isNodeEnv() || isElectronNodeRenderer());
35934
36467
  }
35935
36468
  function isElectronNodeRenderer() {
35936
- const process3 = GLOBAL_OBJ.process;
35937
- return process3?.type === "renderer";
36469
+ const process4 = GLOBAL_OBJ.process;
36470
+ return process4?.type === "renderer";
35938
36471
  }
35939
36472
 
35940
36473
  // node_modules/.pnpm/@sentry+core@11.8.0/node_modules/@sentry/core/build/esm/tracing/spans/envelope.js
@@ -40237,9 +40770,14 @@ async function atomicJson(path, value) {
40237
40770
  }
40238
40771
  async function readConfig() {
40239
40772
  try {
40240
- return JSON.parse(
40773
+ const value = JSON.parse(
40241
40774
  await readFile(join3(configDirectory(), "config.json"), "utf8")
40242
40775
  );
40776
+ const record2 = (entry) => !!entry && typeof entry === "object" && !Array.isArray(entry);
40777
+ const strings = (entry) => record2(entry) && Object.values(entry).every((item) => typeof item === "string");
40778
+ if (!record2(value) || value.origin !== void 0 && typeof value.origin !== "string" || value.paused !== void 0 && typeof value.paused !== "boolean" || value.generation !== void 0 && (!Number.isSafeInteger(value.generation) || Number(value.generation) < 0) || value.origins !== void 0 && !strings(value.origins) || value.accounts !== void 0 && (!record2(value.accounts) || !Object.values(value.accounts).every(strings)))
40779
+ throw new Error("Invalid local configuration");
40780
+ return value;
40243
40781
  } catch (error48) {
40244
40782
  if (error48.code === "ENOENT") return {};
40245
40783
  throw new GroveError(
@@ -40367,6 +40905,21 @@ function credentialPath(origin, agent, accountId) {
40367
40905
  `credentials-${hash2(`${origin}|${agent}|${accountId}`)}.json`
40368
40906
  );
40369
40907
  }
40908
+ var credentialAuthSchema = external_exports.object({
40909
+ key: external_exports.string().trim().min(1).optional(),
40910
+ tokens: OAuthTokensSchema.extend({
40911
+ access_token: external_exports.string().trim().min(1),
40912
+ token_type: external_exports.string().trim().min(1),
40913
+ refresh_token: external_exports.string().trim().min(1).optional()
40914
+ }).optional(),
40915
+ expiresAt: external_exports.number().nonnegative().optional(),
40916
+ client: OAuthClientInformationSchema.extend({
40917
+ client_id: external_exports.string().trim().min(1)
40918
+ }).optional(),
40919
+ redirectUrl: external_exports.url().optional()
40920
+ }).refine(
40921
+ (value) => !!value.key || !!(value.tokens && value.client && value.redirectUrl)
40922
+ );
40370
40923
  async function loadCredentials(origin, agent) {
40371
40924
  const accountId = (await readConfig()).accounts?.[origin]?.[agent];
40372
40925
  if (!accountId)
@@ -40375,20 +40928,37 @@ async function loadCredentials(origin, agent) {
40375
40928
  `Run grove login --client ${agent} --url ${origin}`,
40376
40929
  401
40377
40930
  );
40931
+ let value;
40378
40932
  try {
40379
- const value = JSON.parse(
40933
+ value = JSON.parse(
40380
40934
  await readFile(credentialPath(origin, agent, accountId), "utf8")
40381
40935
  );
40382
- if (value.origin !== origin || value.agent !== agent || value.accountId !== accountId)
40383
- throw new Error();
40384
- return value;
40385
- } catch {
40936
+ } catch (error48) {
40937
+ if (error48.code !== "ENOENT")
40938
+ throw new GroveError(
40939
+ "credential_store_unavailable",
40940
+ "Grove credentials could not be read. Check local store permissions and integrity; no credentials were changed.",
40941
+ 503
40942
+ );
40386
40943
  throw new GroveError(
40387
40944
  "sign_in_required",
40388
- "Grove credentials are missing or invalid; sign in again",
40945
+ "Grove credentials are missing; sign in again",
40389
40946
  401
40390
40947
  );
40391
40948
  }
40949
+ if (!value || value.origin !== origin || value.agent !== agent || value.accountId !== accountId)
40950
+ throw new GroveError(
40951
+ "sign_in_required",
40952
+ "Grove credential identity does not match; sign in again",
40953
+ 401
40954
+ );
40955
+ if (!credentialAuthSchema.safeParse(value).success)
40956
+ throw new GroveError(
40957
+ "credential_store_unavailable",
40958
+ "Grove credentials are incomplete or damaged. Check local store integrity; no credentials were changed.",
40959
+ 503
40960
+ );
40961
+ return value;
40392
40962
  }
40393
40963
  async function saveCredentials(value) {
40394
40964
  await withStoreLock(async () => {
@@ -50381,7 +50951,7 @@ function applyEdits(text, edits) {
50381
50951
  // packages/grove-claude-plugin/package.json
50382
50952
  var package_default = {
50383
50953
  name: "@miniaxolotl/grove-claude-plugin",
50384
- version: "1.11.0",
50954
+ version: "1.11.1",
50385
50955
  type: "module",
50386
50956
  description: "Grove private memory tools and skills for Claude Code",
50387
50957
  license: "MIT",
@@ -50408,7 +50978,7 @@ var package_default = {
50408
50978
  // packages/grove-codex-plugin/package.json
50409
50979
  var package_default2 = {
50410
50980
  name: "@miniaxolotl/grove-codex-plugin",
50411
- version: "1.11.0",
50981
+ version: "1.11.1",
50412
50982
  type: "module",
50413
50983
  description: "Grove private memory tools and skills for Codex",
50414
50984
  license: "MIT",
@@ -50770,7 +51340,7 @@ async function connectAgent(options, login2) {
50770
51340
  else {
50771
51341
  const prompt = verified.capabilities.includes("memory:write") ? verified.grant?.personal ? "Use Grove to remember that I prefer concise answers in my personal memories." : "Use Grove to save a confirmed decision in an allowed project." : "Recall my available memories from Grove.";
50772
51342
  console.log(
50773
- `You're connected to Grove.
51343
+ `Grove API access verified. Host activation is not yet verified.
50774
51344
  ${activation.message}
50775
51345
  Ask your agent: "${prompt}"`
50776
51346
  );
@@ -50825,6 +51395,1085 @@ async function selectAgent(interactive) {
50825
51395
  }
50826
51396
  }
50827
51397
 
51398
+ // packages/mcp/src/doctor.ts
51399
+ init_define_GROVE_TELEMETRY();
51400
+ import { stat as stat3 } from "node:fs/promises";
51401
+ import { fileURLToPath } from "node:url";
51402
+
51403
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
51404
+ init_define_GROVE_TELEMETRY();
51405
+
51406
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/client.js
51407
+ init_define_GROVE_TELEMETRY();
51408
+ var ExperimentalClientTasks = class {
51409
+ constructor(_client) {
51410
+ this._client = _client;
51411
+ }
51412
+ /**
51413
+ * Calls a tool and returns an AsyncGenerator that yields response messages.
51414
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
51415
+ *
51416
+ * This method provides streaming access to tool execution, allowing you to
51417
+ * observe intermediate task status updates for long-running tool calls.
51418
+ * Automatically validates structured output if the tool has an outputSchema.
51419
+ *
51420
+ * @example
51421
+ * ```typescript
51422
+ * const stream = client.experimental.tasks.callToolStream({ name: 'myTool', arguments: {} });
51423
+ * for await (const message of stream) {
51424
+ * switch (message.type) {
51425
+ * case 'taskCreated':
51426
+ * console.log('Tool execution started:', message.task.taskId);
51427
+ * break;
51428
+ * case 'taskStatus':
51429
+ * console.log('Tool status:', message.task.status);
51430
+ * break;
51431
+ * case 'result':
51432
+ * console.log('Tool result:', message.result);
51433
+ * break;
51434
+ * case 'error':
51435
+ * console.error('Tool error:', message.error);
51436
+ * break;
51437
+ * }
51438
+ * }
51439
+ * ```
51440
+ *
51441
+ * @param params - Tool call parameters (name and arguments)
51442
+ * @param resultSchema - Zod schema for validating the result (defaults to CallToolResultSchema)
51443
+ * @param options - Optional request options (timeout, signal, task creation params, etc.)
51444
+ * @returns AsyncGenerator that yields ResponseMessage objects
51445
+ *
51446
+ * @experimental
51447
+ */
51448
+ async *callToolStream(params, resultSchema = CallToolResultSchema, options) {
51449
+ const clientInternal = this._client;
51450
+ const optionsWithTask = {
51451
+ ...options,
51452
+ // We check if the tool is known to be a task during auto-configuration, but assume
51453
+ // the caller knows what they're doing if they pass this explicitly
51454
+ task: options?.task ?? (clientInternal.isToolTask(params.name) ? {} : void 0)
51455
+ };
51456
+ const stream = clientInternal.requestStream({ method: "tools/call", params }, resultSchema, optionsWithTask);
51457
+ const validator = clientInternal.getToolOutputValidator(params.name);
51458
+ for await (const message of stream) {
51459
+ if (message.type === "result" && validator) {
51460
+ const result = message.result;
51461
+ if (!result.structuredContent && !result.isError) {
51462
+ yield {
51463
+ type: "error",
51464
+ error: new McpError(ErrorCode.InvalidRequest, `Tool ${params.name} has an output schema but did not return structured content`)
51465
+ };
51466
+ return;
51467
+ }
51468
+ if (result.structuredContent) {
51469
+ try {
51470
+ const validationResult = validator(result.structuredContent);
51471
+ if (!validationResult.valid) {
51472
+ yield {
51473
+ type: "error",
51474
+ error: new McpError(ErrorCode.InvalidParams, `Structured content does not match the tool's output schema: ${validationResult.errorMessage}`)
51475
+ };
51476
+ return;
51477
+ }
51478
+ } catch (error48) {
51479
+ if (error48 instanceof McpError) {
51480
+ yield { type: "error", error: error48 };
51481
+ return;
51482
+ }
51483
+ yield {
51484
+ type: "error",
51485
+ error: new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error48 instanceof Error ? error48.message : String(error48)}`)
51486
+ };
51487
+ return;
51488
+ }
51489
+ }
51490
+ }
51491
+ yield message;
51492
+ }
51493
+ }
51494
+ /**
51495
+ * Gets the current status of a task.
51496
+ *
51497
+ * @param taskId - The task identifier
51498
+ * @param options - Optional request options
51499
+ * @returns The task status
51500
+ *
51501
+ * @experimental
51502
+ */
51503
+ async getTask(taskId, options) {
51504
+ return this._client.getTask({ taskId }, options);
51505
+ }
51506
+ /**
51507
+ * Retrieves the result of a completed task.
51508
+ *
51509
+ * @param taskId - The task identifier
51510
+ * @param resultSchema - Zod schema for validating the result
51511
+ * @param options - Optional request options
51512
+ * @returns The task result
51513
+ *
51514
+ * @experimental
51515
+ */
51516
+ async getTaskResult(taskId, resultSchema, options) {
51517
+ return this._client.getTaskResult({ taskId }, resultSchema, options);
51518
+ }
51519
+ /**
51520
+ * Lists tasks with optional pagination.
51521
+ *
51522
+ * @param cursor - Optional pagination cursor
51523
+ * @param options - Optional request options
51524
+ * @returns List of tasks with optional next cursor
51525
+ *
51526
+ * @experimental
51527
+ */
51528
+ async listTasks(cursor, options) {
51529
+ return this._client.listTasks(cursor ? { cursor } : void 0, options);
51530
+ }
51531
+ /**
51532
+ * Cancels a running task.
51533
+ *
51534
+ * @param taskId - The task identifier
51535
+ * @param options - Optional request options
51536
+ *
51537
+ * @experimental
51538
+ */
51539
+ async cancelTask(taskId, options) {
51540
+ return this._client.cancelTask({ taskId }, options);
51541
+ }
51542
+ /**
51543
+ * Sends a request and returns an AsyncGenerator that yields response messages.
51544
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
51545
+ *
51546
+ * This method provides streaming access to request processing, allowing you to
51547
+ * observe intermediate task status updates for task-augmented requests.
51548
+ *
51549
+ * @param request - The request to send
51550
+ * @param resultSchema - Zod schema for validating the result
51551
+ * @param options - Optional request options (timeout, signal, task creation params, etc.)
51552
+ * @returns AsyncGenerator that yields ResponseMessage objects
51553
+ *
51554
+ * @experimental
51555
+ */
51556
+ requestStream(request, resultSchema, options) {
51557
+ return this._client.requestStream(request, resultSchema, options);
51558
+ }
51559
+ };
51560
+
51561
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
51562
+ function applyElicitationDefaults(schema, data) {
51563
+ if (!schema || data === null || typeof data !== "object")
51564
+ return;
51565
+ if (schema.type === "object" && schema.properties && typeof schema.properties === "object") {
51566
+ const obj = data;
51567
+ const props = schema.properties;
51568
+ for (const key of Object.keys(props)) {
51569
+ const propSchema = props[key];
51570
+ if (obj[key] === void 0 && Object.prototype.hasOwnProperty.call(propSchema, "default")) {
51571
+ obj[key] = propSchema.default;
51572
+ }
51573
+ if (obj[key] !== void 0) {
51574
+ applyElicitationDefaults(propSchema, obj[key]);
51575
+ }
51576
+ }
51577
+ }
51578
+ if (Array.isArray(schema.anyOf)) {
51579
+ for (const sub of schema.anyOf) {
51580
+ if (typeof sub !== "boolean") {
51581
+ applyElicitationDefaults(sub, data);
51582
+ }
51583
+ }
51584
+ }
51585
+ if (Array.isArray(schema.oneOf)) {
51586
+ for (const sub of schema.oneOf) {
51587
+ if (typeof sub !== "boolean") {
51588
+ applyElicitationDefaults(sub, data);
51589
+ }
51590
+ }
51591
+ }
51592
+ }
51593
+ function getSupportedElicitationModes(capabilities2) {
51594
+ if (!capabilities2) {
51595
+ return { supportsFormMode: false, supportsUrlMode: false };
51596
+ }
51597
+ const hasFormCapability = capabilities2.form !== void 0;
51598
+ const hasUrlCapability = capabilities2.url !== void 0;
51599
+ const supportsFormMode = hasFormCapability || !hasFormCapability && !hasUrlCapability;
51600
+ const supportsUrlMode = hasUrlCapability;
51601
+ return { supportsFormMode, supportsUrlMode };
51602
+ }
51603
+ var Client2 = class extends Protocol {
51604
+ /**
51605
+ * Initializes this client with the given name and version information.
51606
+ */
51607
+ constructor(_clientInfo, options) {
51608
+ super(options);
51609
+ this._clientInfo = _clientInfo;
51610
+ this._cachedToolOutputValidators = /* @__PURE__ */ new Map();
51611
+ this._cachedKnownTaskTools = /* @__PURE__ */ new Set();
51612
+ this._cachedRequiredTaskTools = /* @__PURE__ */ new Set();
51613
+ this._listChangedDebounceTimers = /* @__PURE__ */ new Map();
51614
+ this._capabilities = options?.capabilities ?? {};
51615
+ this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
51616
+ if (options?.listChanged) {
51617
+ this._pendingListChangedConfig = options.listChanged;
51618
+ }
51619
+ }
51620
+ /**
51621
+ * Set up handlers for list changed notifications based on config and server capabilities.
51622
+ * This should only be called after initialization when server capabilities are known.
51623
+ * Handlers are silently skipped if the server doesn't advertise the corresponding listChanged capability.
51624
+ * @internal
51625
+ */
51626
+ _setupListChangedHandlers(config2) {
51627
+ if (config2.tools && this._serverCapabilities?.tools?.listChanged) {
51628
+ this._setupListChangedHandler("tools", ToolListChangedNotificationSchema, config2.tools, async () => {
51629
+ const result = await this.listTools();
51630
+ return result.tools;
51631
+ });
51632
+ }
51633
+ if (config2.prompts && this._serverCapabilities?.prompts?.listChanged) {
51634
+ this._setupListChangedHandler("prompts", PromptListChangedNotificationSchema, config2.prompts, async () => {
51635
+ const result = await this.listPrompts();
51636
+ return result.prompts;
51637
+ });
51638
+ }
51639
+ if (config2.resources && this._serverCapabilities?.resources?.listChanged) {
51640
+ this._setupListChangedHandler("resources", ResourceListChangedNotificationSchema, config2.resources, async () => {
51641
+ const result = await this.listResources();
51642
+ return result.resources;
51643
+ });
51644
+ }
51645
+ }
51646
+ /**
51647
+ * Access experimental features.
51648
+ *
51649
+ * WARNING: These APIs are experimental and may change without notice.
51650
+ *
51651
+ * @experimental
51652
+ */
51653
+ get experimental() {
51654
+ if (!this._experimental) {
51655
+ this._experimental = {
51656
+ tasks: new ExperimentalClientTasks(this)
51657
+ };
51658
+ }
51659
+ return this._experimental;
51660
+ }
51661
+ /**
51662
+ * Registers new capabilities. This can only be called before connecting to a transport.
51663
+ *
51664
+ * The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).
51665
+ */
51666
+ registerCapabilities(capabilities2) {
51667
+ if (this.transport) {
51668
+ throw new Error("Cannot register capabilities after connecting to transport");
51669
+ }
51670
+ this._capabilities = mergeCapabilities(this._capabilities, capabilities2);
51671
+ }
51672
+ /**
51673
+ * Override request handler registration to enforce client-side validation for elicitation.
51674
+ */
51675
+ setRequestHandler(requestSchema, handler) {
51676
+ const shape = getObjectShape(requestSchema);
51677
+ const methodSchema = shape?.method;
51678
+ if (!methodSchema) {
51679
+ throw new Error("Schema is missing a method literal");
51680
+ }
51681
+ const methodValue = getLiteralValue(methodSchema);
51682
+ if (typeof methodValue !== "string") {
51683
+ throw new Error("Schema method literal must be a string");
51684
+ }
51685
+ const method = methodValue;
51686
+ if (method === "elicitation/create") {
51687
+ const wrappedHandler = async (request, extra) => {
51688
+ const validatedRequest = safeParse3(ElicitRequestSchema, request);
51689
+ if (!validatedRequest.success) {
51690
+ const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
51691
+ throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation request: ${errorMessage}`);
51692
+ }
51693
+ const { params } = validatedRequest.data;
51694
+ params.mode = params.mode ?? "form";
51695
+ const { supportsFormMode, supportsUrlMode } = getSupportedElicitationModes(this._capabilities.elicitation);
51696
+ if (params.mode === "form" && !supportsFormMode) {
51697
+ throw new McpError(ErrorCode.InvalidParams, "Client does not support form-mode elicitation requests");
51698
+ }
51699
+ if (params.mode === "url" && !supportsUrlMode) {
51700
+ throw new McpError(ErrorCode.InvalidParams, "Client does not support URL-mode elicitation requests");
51701
+ }
51702
+ const result = await Promise.resolve(handler(request, extra));
51703
+ if (params.task) {
51704
+ const taskValidationResult = safeParse3(CreateTaskResultSchema, result);
51705
+ if (!taskValidationResult.success) {
51706
+ const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
51707
+ throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
51708
+ }
51709
+ return taskValidationResult.data;
51710
+ }
51711
+ const validationResult = safeParse3(ElicitResultSchema, result);
51712
+ if (!validationResult.success) {
51713
+ const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
51714
+ throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation result: ${errorMessage}`);
51715
+ }
51716
+ const validatedResult = validationResult.data;
51717
+ const requestedSchema = params.mode === "form" ? params.requestedSchema : void 0;
51718
+ if (params.mode === "form" && validatedResult.action === "accept" && validatedResult.content && requestedSchema) {
51719
+ if (this._capabilities.elicitation?.form?.applyDefaults) {
51720
+ try {
51721
+ applyElicitationDefaults(requestedSchema, validatedResult.content);
51722
+ } catch {
51723
+ }
51724
+ }
51725
+ }
51726
+ return validatedResult;
51727
+ };
51728
+ return super.setRequestHandler(requestSchema, wrappedHandler);
51729
+ }
51730
+ if (method === "sampling/createMessage") {
51731
+ const wrappedHandler = async (request, extra) => {
51732
+ const validatedRequest = safeParse3(CreateMessageRequestSchema, request);
51733
+ if (!validatedRequest.success) {
51734
+ const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
51735
+ throw new McpError(ErrorCode.InvalidParams, `Invalid sampling request: ${errorMessage}`);
51736
+ }
51737
+ const { params } = validatedRequest.data;
51738
+ const result = await Promise.resolve(handler(request, extra));
51739
+ if (params.task) {
51740
+ const taskValidationResult = safeParse3(CreateTaskResultSchema, result);
51741
+ if (!taskValidationResult.success) {
51742
+ const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
51743
+ throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
51744
+ }
51745
+ return taskValidationResult.data;
51746
+ }
51747
+ const hasTools = params.tools || params.toolChoice;
51748
+ const resultSchema = hasTools ? CreateMessageResultWithToolsSchema : CreateMessageResultSchema;
51749
+ const validationResult = safeParse3(resultSchema, result);
51750
+ if (!validationResult.success) {
51751
+ const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
51752
+ throw new McpError(ErrorCode.InvalidParams, `Invalid sampling result: ${errorMessage}`);
51753
+ }
51754
+ return validationResult.data;
51755
+ };
51756
+ return super.setRequestHandler(requestSchema, wrappedHandler);
51757
+ }
51758
+ return super.setRequestHandler(requestSchema, handler);
51759
+ }
51760
+ assertCapability(capability, method) {
51761
+ if (!this._serverCapabilities?.[capability]) {
51762
+ throw new Error(`Server does not support ${capability} (required for ${method})`);
51763
+ }
51764
+ }
51765
+ async connect(transport, options) {
51766
+ await super.connect(transport);
51767
+ if (transport.sessionId !== void 0) {
51768
+ return;
51769
+ }
51770
+ try {
51771
+ const result = await this.request({
51772
+ method: "initialize",
51773
+ params: {
51774
+ protocolVersion: LATEST_PROTOCOL_VERSION,
51775
+ capabilities: this._capabilities,
51776
+ clientInfo: this._clientInfo
51777
+ }
51778
+ }, InitializeResultSchema, options);
51779
+ if (result === void 0) {
51780
+ throw new Error(`Server sent invalid initialize result: ${result}`);
51781
+ }
51782
+ if (!SUPPORTED_PROTOCOL_VERSIONS.includes(result.protocolVersion)) {
51783
+ throw new Error(`Server's protocol version is not supported: ${result.protocolVersion}`);
51784
+ }
51785
+ this._serverCapabilities = result.capabilities;
51786
+ this._serverVersion = result.serverInfo;
51787
+ if (transport.setProtocolVersion) {
51788
+ transport.setProtocolVersion(result.protocolVersion);
51789
+ }
51790
+ this._instructions = result.instructions;
51791
+ await this.notification({
51792
+ method: "notifications/initialized"
51793
+ });
51794
+ if (this._pendingListChangedConfig) {
51795
+ this._setupListChangedHandlers(this._pendingListChangedConfig);
51796
+ this._pendingListChangedConfig = void 0;
51797
+ }
51798
+ } catch (error48) {
51799
+ void this.close();
51800
+ throw error48;
51801
+ }
51802
+ }
51803
+ /**
51804
+ * After initialization has completed, this will be populated with the server's reported capabilities.
51805
+ */
51806
+ getServerCapabilities() {
51807
+ return this._serverCapabilities;
51808
+ }
51809
+ /**
51810
+ * After initialization has completed, this will be populated with information about the server's name and version.
51811
+ */
51812
+ getServerVersion() {
51813
+ return this._serverVersion;
51814
+ }
51815
+ /**
51816
+ * After initialization has completed, this may be populated with information about the server's instructions.
51817
+ */
51818
+ getInstructions() {
51819
+ return this._instructions;
51820
+ }
51821
+ assertCapabilityForMethod(method) {
51822
+ switch (method) {
51823
+ case "logging/setLevel":
51824
+ if (!this._serverCapabilities?.logging) {
51825
+ throw new Error(`Server does not support logging (required for ${method})`);
51826
+ }
51827
+ break;
51828
+ case "prompts/get":
51829
+ case "prompts/list":
51830
+ if (!this._serverCapabilities?.prompts) {
51831
+ throw new Error(`Server does not support prompts (required for ${method})`);
51832
+ }
51833
+ break;
51834
+ case "resources/list":
51835
+ case "resources/templates/list":
51836
+ case "resources/read":
51837
+ case "resources/subscribe":
51838
+ case "resources/unsubscribe":
51839
+ if (!this._serverCapabilities?.resources) {
51840
+ throw new Error(`Server does not support resources (required for ${method})`);
51841
+ }
51842
+ if (method === "resources/subscribe" && !this._serverCapabilities.resources.subscribe) {
51843
+ throw new Error(`Server does not support resource subscriptions (required for ${method})`);
51844
+ }
51845
+ break;
51846
+ case "tools/call":
51847
+ case "tools/list":
51848
+ if (!this._serverCapabilities?.tools) {
51849
+ throw new Error(`Server does not support tools (required for ${method})`);
51850
+ }
51851
+ break;
51852
+ case "completion/complete":
51853
+ if (!this._serverCapabilities?.completions) {
51854
+ throw new Error(`Server does not support completions (required for ${method})`);
51855
+ }
51856
+ break;
51857
+ case "initialize":
51858
+ break;
51859
+ case "ping":
51860
+ break;
51861
+ }
51862
+ }
51863
+ assertNotificationCapability(method) {
51864
+ switch (method) {
51865
+ case "notifications/roots/list_changed":
51866
+ if (!this._capabilities.roots?.listChanged) {
51867
+ throw new Error(`Client does not support roots list changed notifications (required for ${method})`);
51868
+ }
51869
+ break;
51870
+ case "notifications/initialized":
51871
+ break;
51872
+ case "notifications/cancelled":
51873
+ break;
51874
+ case "notifications/progress":
51875
+ break;
51876
+ }
51877
+ }
51878
+ assertRequestHandlerCapability(method) {
51879
+ if (!this._capabilities) {
51880
+ return;
51881
+ }
51882
+ switch (method) {
51883
+ case "sampling/createMessage":
51884
+ if (!this._capabilities.sampling) {
51885
+ throw new Error(`Client does not support sampling capability (required for ${method})`);
51886
+ }
51887
+ break;
51888
+ case "elicitation/create":
51889
+ if (!this._capabilities.elicitation) {
51890
+ throw new Error(`Client does not support elicitation capability (required for ${method})`);
51891
+ }
51892
+ break;
51893
+ case "roots/list":
51894
+ if (!this._capabilities.roots) {
51895
+ throw new Error(`Client does not support roots capability (required for ${method})`);
51896
+ }
51897
+ break;
51898
+ case "tasks/get":
51899
+ case "tasks/list":
51900
+ case "tasks/result":
51901
+ case "tasks/cancel":
51902
+ if (!this._capabilities.tasks) {
51903
+ throw new Error(`Client does not support tasks capability (required for ${method})`);
51904
+ }
51905
+ break;
51906
+ case "ping":
51907
+ break;
51908
+ }
51909
+ }
51910
+ assertTaskCapability(method) {
51911
+ assertToolsCallTaskCapability(this._serverCapabilities?.tasks?.requests, method, "Server");
51912
+ }
51913
+ assertTaskHandlerCapability(method) {
51914
+ if (!this._capabilities) {
51915
+ return;
51916
+ }
51917
+ assertClientRequestTaskCapability(this._capabilities.tasks?.requests, method, "Client");
51918
+ }
51919
+ async ping(options) {
51920
+ return this.request({ method: "ping" }, EmptyResultSchema, options);
51921
+ }
51922
+ async complete(params, options) {
51923
+ return this.request({ method: "completion/complete", params }, CompleteResultSchema, options);
51924
+ }
51925
+ async setLoggingLevel(level, options) {
51926
+ return this.request({ method: "logging/setLevel", params: { level } }, EmptyResultSchema, options);
51927
+ }
51928
+ async getPrompt(params, options) {
51929
+ return this.request({ method: "prompts/get", params }, GetPromptResultSchema, options);
51930
+ }
51931
+ async listPrompts(params, options) {
51932
+ return this.request({ method: "prompts/list", params }, ListPromptsResultSchema, options);
51933
+ }
51934
+ async listResources(params, options) {
51935
+ return this.request({ method: "resources/list", params }, ListResourcesResultSchema, options);
51936
+ }
51937
+ async listResourceTemplates(params, options) {
51938
+ return this.request({ method: "resources/templates/list", params }, ListResourceTemplatesResultSchema, options);
51939
+ }
51940
+ async readResource(params, options) {
51941
+ return this.request({ method: "resources/read", params }, ReadResourceResultSchema, options);
51942
+ }
51943
+ async subscribeResource(params, options) {
51944
+ return this.request({ method: "resources/subscribe", params }, EmptyResultSchema, options);
51945
+ }
51946
+ async unsubscribeResource(params, options) {
51947
+ return this.request({ method: "resources/unsubscribe", params }, EmptyResultSchema, options);
51948
+ }
51949
+ /**
51950
+ * Calls a tool and waits for the result. Automatically validates structured output if the tool has an outputSchema.
51951
+ *
51952
+ * For task-based execution with streaming behavior, use client.experimental.tasks.callToolStream() instead.
51953
+ */
51954
+ async callTool(params, resultSchema = CallToolResultSchema, options) {
51955
+ if (this.isToolTaskRequired(params.name)) {
51956
+ throw new McpError(ErrorCode.InvalidRequest, `Tool "${params.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);
51957
+ }
51958
+ const result = await this.request({ method: "tools/call", params }, resultSchema, options);
51959
+ const validator = this.getToolOutputValidator(params.name);
51960
+ if (validator) {
51961
+ if (!result.structuredContent && !result.isError) {
51962
+ throw new McpError(ErrorCode.InvalidRequest, `Tool ${params.name} has an output schema but did not return structured content`);
51963
+ }
51964
+ if (result.structuredContent) {
51965
+ try {
51966
+ const validationResult = validator(result.structuredContent);
51967
+ if (!validationResult.valid) {
51968
+ throw new McpError(ErrorCode.InvalidParams, `Structured content does not match the tool's output schema: ${validationResult.errorMessage}`);
51969
+ }
51970
+ } catch (error48) {
51971
+ if (error48 instanceof McpError) {
51972
+ throw error48;
51973
+ }
51974
+ throw new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error48 instanceof Error ? error48.message : String(error48)}`);
51975
+ }
51976
+ }
51977
+ }
51978
+ return result;
51979
+ }
51980
+ isToolTask(toolName) {
51981
+ if (!this._serverCapabilities?.tasks?.requests?.tools?.call) {
51982
+ return false;
51983
+ }
51984
+ return this._cachedKnownTaskTools.has(toolName);
51985
+ }
51986
+ /**
51987
+ * Check if a tool requires task-based execution.
51988
+ * Unlike isToolTask which includes 'optional' tools, this only checks for 'required'.
51989
+ */
51990
+ isToolTaskRequired(toolName) {
51991
+ return this._cachedRequiredTaskTools.has(toolName);
51992
+ }
51993
+ /**
51994
+ * Cache validators for tool output schemas.
51995
+ * Called after listTools() to pre-compile validators for better performance.
51996
+ */
51997
+ cacheToolMetadata(tools) {
51998
+ this._cachedToolOutputValidators.clear();
51999
+ this._cachedKnownTaskTools.clear();
52000
+ this._cachedRequiredTaskTools.clear();
52001
+ for (const tool of tools) {
52002
+ if (tool.outputSchema) {
52003
+ const toolValidator = this._jsonSchemaValidator.getValidator(tool.outputSchema);
52004
+ this._cachedToolOutputValidators.set(tool.name, toolValidator);
52005
+ }
52006
+ const taskSupport = tool.execution?.taskSupport;
52007
+ if (taskSupport === "required" || taskSupport === "optional") {
52008
+ this._cachedKnownTaskTools.add(tool.name);
52009
+ }
52010
+ if (taskSupport === "required") {
52011
+ this._cachedRequiredTaskTools.add(tool.name);
52012
+ }
52013
+ }
52014
+ }
52015
+ /**
52016
+ * Get cached validator for a tool
52017
+ */
52018
+ getToolOutputValidator(toolName) {
52019
+ return this._cachedToolOutputValidators.get(toolName);
52020
+ }
52021
+ async listTools(params, options) {
52022
+ const result = await this.request({ method: "tools/list", params }, ListToolsResultSchema, options);
52023
+ this.cacheToolMetadata(result.tools);
52024
+ return result;
52025
+ }
52026
+ /**
52027
+ * Set up a single list changed handler.
52028
+ * @internal
52029
+ */
52030
+ _setupListChangedHandler(listType, notificationSchema, options, fetcher) {
52031
+ const parseResult = ListChangedOptionsBaseSchema.safeParse(options);
52032
+ if (!parseResult.success) {
52033
+ throw new Error(`Invalid ${listType} listChanged options: ${parseResult.error.message}`);
52034
+ }
52035
+ if (typeof options.onChanged !== "function") {
52036
+ throw new Error(`Invalid ${listType} listChanged options: onChanged must be a function`);
52037
+ }
52038
+ const { autoRefresh, debounceMs } = parseResult.data;
52039
+ const { onChanged } = options;
52040
+ const refresh = async () => {
52041
+ if (!autoRefresh) {
52042
+ onChanged(null, null);
52043
+ return;
52044
+ }
52045
+ try {
52046
+ const items = await fetcher();
52047
+ onChanged(null, items);
52048
+ } catch (e) {
52049
+ const error48 = e instanceof Error ? e : new Error(String(e));
52050
+ onChanged(error48, null);
52051
+ }
52052
+ };
52053
+ const handler = () => {
52054
+ if (debounceMs) {
52055
+ const existingTimer = this._listChangedDebounceTimers.get(listType);
52056
+ if (existingTimer) {
52057
+ clearTimeout(existingTimer);
52058
+ }
52059
+ const timer = setTimeout(refresh, debounceMs);
52060
+ this._listChangedDebounceTimers.set(listType, timer);
52061
+ } else {
52062
+ refresh();
52063
+ }
52064
+ };
52065
+ this.setNotificationHandler(notificationSchema, handler);
52066
+ }
52067
+ async sendRootsListChanged() {
52068
+ return this.notification({ method: "notifications/roots/list_changed" });
52069
+ }
52070
+ };
52071
+
52072
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
52073
+ init_define_GROVE_TELEMETRY();
52074
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
52075
+ import process3 from "node:process";
52076
+ import { PassThrough } from "node:stream";
52077
+ var DEFAULT_INHERITED_ENV_VARS = process3.platform === "win32" ? [
52078
+ "APPDATA",
52079
+ "HOMEDRIVE",
52080
+ "HOMEPATH",
52081
+ "LOCALAPPDATA",
52082
+ "PATH",
52083
+ "PROCESSOR_ARCHITECTURE",
52084
+ "SYSTEMDRIVE",
52085
+ "SYSTEMROOT",
52086
+ "TEMP",
52087
+ "USERNAME",
52088
+ "USERPROFILE",
52089
+ "PROGRAMFILES"
52090
+ ] : (
52091
+ /* list inspired by the default env inheritance of sudo */
52092
+ ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER"]
52093
+ );
52094
+ function getDefaultEnvironment() {
52095
+ const env = {};
52096
+ for (const key of DEFAULT_INHERITED_ENV_VARS) {
52097
+ const value = process3.env[key];
52098
+ if (value === void 0) {
52099
+ continue;
52100
+ }
52101
+ if (value.startsWith("()")) {
52102
+ continue;
52103
+ }
52104
+ env[key] = value;
52105
+ }
52106
+ return env;
52107
+ }
52108
+ var StdioClientTransport = class {
52109
+ constructor(server) {
52110
+ this._stderrStream = null;
52111
+ this._serverParams = server;
52112
+ this._readBuffer = new ReadBuffer({ maxBufferSize: server.maxBufferSize });
52113
+ if (server.stderr === "pipe" || server.stderr === "overlapped") {
52114
+ this._stderrStream = new PassThrough();
52115
+ }
52116
+ }
52117
+ /**
52118
+ * Starts the server process and prepares to communicate with it.
52119
+ */
52120
+ async start() {
52121
+ if (this._process) {
52122
+ throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
52123
+ }
52124
+ return new Promise((resolve2, reject) => {
52125
+ this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
52126
+ // merge default env with server env because mcp server needs some env vars
52127
+ env: {
52128
+ ...getDefaultEnvironment(),
52129
+ ...this._serverParams.env
52130
+ },
52131
+ stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
52132
+ shell: false,
52133
+ windowsHide: process3.platform === "win32",
52134
+ cwd: this._serverParams.cwd
52135
+ });
52136
+ this._process.on("error", (error48) => {
52137
+ reject(error48);
52138
+ this.onerror?.(error48);
52139
+ });
52140
+ this._process.on("spawn", () => {
52141
+ resolve2();
52142
+ });
52143
+ this._process.on("close", (_code) => {
52144
+ this._process = void 0;
52145
+ this.onclose?.();
52146
+ });
52147
+ this._process.stdin?.on("error", (error48) => {
52148
+ this.onerror?.(error48);
52149
+ });
52150
+ this._process.stdout?.on("data", (chunk) => {
52151
+ try {
52152
+ this._readBuffer.append(chunk);
52153
+ this.processReadBuffer();
52154
+ } catch (error48) {
52155
+ this.onerror?.(error48);
52156
+ this.close().catch(() => {
52157
+ });
52158
+ }
52159
+ });
52160
+ this._process.stdout?.on("error", (error48) => {
52161
+ this.onerror?.(error48);
52162
+ });
52163
+ if (this._stderrStream && this._process.stderr) {
52164
+ this._process.stderr.pipe(this._stderrStream);
52165
+ }
52166
+ });
52167
+ }
52168
+ /**
52169
+ * The stderr stream of the child process, if `StdioServerParameters.stderr` was set to "pipe" or "overlapped".
52170
+ *
52171
+ * If stderr piping was requested, a PassThrough stream is returned _immediately_, allowing callers to
52172
+ * attach listeners before the start method is invoked. This prevents loss of any early
52173
+ * error output emitted by the child process.
52174
+ */
52175
+ get stderr() {
52176
+ if (this._stderrStream) {
52177
+ return this._stderrStream;
52178
+ }
52179
+ return this._process?.stderr ?? null;
52180
+ }
52181
+ /**
52182
+ * The child process pid spawned by this transport.
52183
+ *
52184
+ * This is only available after the transport has been started.
52185
+ */
52186
+ get pid() {
52187
+ return this._process?.pid ?? null;
52188
+ }
52189
+ processReadBuffer() {
52190
+ while (true) {
52191
+ try {
52192
+ const message = this._readBuffer.readMessage();
52193
+ if (message === null) {
52194
+ break;
52195
+ }
52196
+ this.onmessage?.(message);
52197
+ } catch (error48) {
52198
+ this.onerror?.(error48);
52199
+ }
52200
+ }
52201
+ }
52202
+ async close() {
52203
+ if (this._process) {
52204
+ const processToClose = this._process;
52205
+ this._process = void 0;
52206
+ const closePromise = new Promise((resolve2) => {
52207
+ processToClose.once("close", () => {
52208
+ resolve2();
52209
+ });
52210
+ });
52211
+ try {
52212
+ processToClose.stdin?.end();
52213
+ } catch {
52214
+ }
52215
+ await Promise.race([closePromise, new Promise((resolve2) => setTimeout(resolve2, 2e3).unref())]);
52216
+ if (processToClose.exitCode === null) {
52217
+ try {
52218
+ processToClose.kill("SIGTERM");
52219
+ } catch {
52220
+ }
52221
+ await Promise.race([closePromise, new Promise((resolve2) => setTimeout(resolve2, 2e3).unref())]);
52222
+ }
52223
+ if (processToClose.exitCode === null) {
52224
+ try {
52225
+ processToClose.kill("SIGKILL");
52226
+ } catch {
52227
+ }
52228
+ }
52229
+ }
52230
+ this._readBuffer.clear();
52231
+ }
52232
+ send(message) {
52233
+ return new Promise((resolve2) => {
52234
+ if (!this._process?.stdin) {
52235
+ throw new Error("Not connected");
52236
+ }
52237
+ const json2 = serializeMessage(message);
52238
+ if (this._process.stdin.write(json2)) {
52239
+ resolve2();
52240
+ } else {
52241
+ this._process.stdin.once("drain", resolve2);
52242
+ }
52243
+ });
52244
+ }
52245
+ };
52246
+
52247
+ // lib/integration-core/src/diagnostics.ts
52248
+ init_define_GROVE_TELEMETRY();
52249
+ import { access, stat as stat2 } from "node:fs/promises";
52250
+ import { constants as constants2 } from "node:fs";
52251
+ import { delimiter, isAbsolute as isAbsolute4, join as join5 } from "node:path";
52252
+ async function findExecutable(command) {
52253
+ const suffixes = process.platform === "win32" ? (process.env.PATHEXT || ".EXE;.COM;.CMD;.BAT").split(";") : [""];
52254
+ for (const directory of (process.env.PATH ?? "").split(delimiter)) {
52255
+ if (!isAbsolute4(directory)) continue;
52256
+ for (const suffix of suffixes) {
52257
+ const path = join5(directory, `${command}${suffix}`);
52258
+ try {
52259
+ if (!(await stat2(path)).isFile()) continue;
52260
+ await access(
52261
+ path,
52262
+ process.platform === "win32" ? constants2.F_OK : constants2.X_OK
52263
+ );
52264
+ return path;
52265
+ } catch {
52266
+ }
52267
+ }
52268
+ }
52269
+ return null;
52270
+ }
52271
+
52272
+ // packages/mcp/src/doctor.ts
52273
+ var codes = /* @__PURE__ */ new Set([
52274
+ "not_configured",
52275
+ "invalid_config",
52276
+ "invalid_endpoint",
52277
+ "sign_in_required",
52278
+ "unauthorized",
52279
+ "connection_revoked",
52280
+ "timeout",
52281
+ "unreachable",
52282
+ "invalid_response",
52283
+ "credential_store_unavailable",
52284
+ "awaiting_grant",
52285
+ "api_version_unsupported"
52286
+ ]);
52287
+ var safeCode = (error48) => error48 instanceof GroveError && codes.has(error48.code) ? error48.code : "unavailable";
52288
+ async function diagnose(client, probe = false, originOverride) {
52289
+ const checks = [];
52290
+ const add = (id, status, code, message, context3 = "cli") => checks.push({ id, status, code, message, context: context3 });
52291
+ const clientExecutable = await findExecutable(client);
52292
+ add(
52293
+ "client",
52294
+ clientExecutable ? "passed" : "failed",
52295
+ clientExecutable ? "client_found" : "client_missing",
52296
+ clientExecutable ? `Client executable found on this CLI's PATH; ${client} was not started.` : `Install ${client} and make its executable available on PATH. This CLI cannot inspect the agent host's environment.`
52297
+ );
52298
+ const runtimeReady = Number(process.versions.node.split(".")[0]) >= 22;
52299
+ add(
52300
+ "runtime",
52301
+ runtimeReady ? "passed" : "failed",
52302
+ runtimeReady ? "runtime_available" : "runtime_unsupported",
52303
+ "The Grove CLI requires Node 22+ or a compatible Bun runtime. This does not verify the agent host's PATH."
52304
+ );
52305
+ const executable = fileURLToPath(new URL("./cli.js", import.meta.url));
52306
+ let artifactReady = false;
52307
+ try {
52308
+ artifactReady = (await stat3(executable)).isFile();
52309
+ } catch {
52310
+ }
52311
+ add(
52312
+ "artifact",
52313
+ artifactReady ? "passed" : "failed",
52314
+ artifactReady ? "artifact_found" : "artifact_missing",
52315
+ artifactReady ? "Packaged Grove CLI entrypoint exists." : "Reinstall the Grove package; its prebuilt entrypoint is missing."
52316
+ );
52317
+ let origin;
52318
+ try {
52319
+ await readConfig();
52320
+ origin = await configuredOrigin(originOverride, client);
52321
+ add(
52322
+ "configuration",
52323
+ "passed",
52324
+ "configuration_readable",
52325
+ "Local endpoint selection is readable; unrelated agent configuration is not changed."
52326
+ );
52327
+ if (!(process.env.GROVE_API_KEY && process.env.GROVE_API_URL && apiOrigin(process.env.GROVE_API_URL) === origin))
52328
+ await loadCredentials(origin, client);
52329
+ add(
52330
+ "credentials",
52331
+ "passed",
52332
+ "credentials_present",
52333
+ "Credentials exist locally; validity requires an explicit API probe."
52334
+ );
52335
+ } catch (error48) {
52336
+ add(
52337
+ "credentials",
52338
+ "failed",
52339
+ safeCode(error48),
52340
+ "Check the selected Grove endpoint and credential store. Run grove login only if sign-in is actually required; no credentials were removed."
52341
+ );
52342
+ }
52343
+ if (probe && runtimeReady && artifactReady) {
52344
+ const connection = new Client2({ name: "grove-doctor", version: "1" });
52345
+ const env = { GROVE_TELEMETRY: "0" };
52346
+ for (const name of [
52347
+ "HOME",
52348
+ "USERPROFILE",
52349
+ "PATH",
52350
+ "SystemRoot",
52351
+ "TMP",
52352
+ "TEMP",
52353
+ "TMPDIR",
52354
+ "XDG_CONFIG_HOME",
52355
+ "GROVE_CONFIG_HOME",
52356
+ "GROVE_API_URL",
52357
+ "GROVE_API_KEY",
52358
+ "GROVE_PRIVATE"
52359
+ ])
52360
+ if (process.env[name] !== void 0) env[name] = process.env[name];
52361
+ if (process.versions.bun) env.BUN_BE_BUN = "1";
52362
+ const transport = new StdioClientTransport({
52363
+ command: process.execPath,
52364
+ args: [executable, "mcp", "--stdio", "--client", client],
52365
+ env,
52366
+ stderr: "pipe"
52367
+ });
52368
+ transport.stderr?.on("data", () => {
52369
+ });
52370
+ try {
52371
+ const signal = AbortSignal.timeout(5e3);
52372
+ await connection.connect(transport, { signal, timeout: 5e3 });
52373
+ const tools = (await connection.listTools({}, { signal, timeout: 5e3 })).tools;
52374
+ if (tools.map((tool) => tool.name).sort().join(",") !== "forget,memories,recall,remember")
52375
+ throw new Error("Unexpected tool catalog");
52376
+ add(
52377
+ "bridge",
52378
+ "passed",
52379
+ "bridge_initialized",
52380
+ "A separate packaged bridge initialized and listed four tools; no memory tool was invoked.",
52381
+ "bridge_probe"
52382
+ );
52383
+ } catch {
52384
+ add(
52385
+ "bridge",
52386
+ "failed",
52387
+ "bridge_start_failed",
52388
+ "The packaged bridge did not initialize within its startup budget. Check runtime and package integrity.",
52389
+ "bridge_probe"
52390
+ );
52391
+ } finally {
52392
+ await connection.close();
52393
+ await transport.close();
52394
+ }
52395
+ } else {
52396
+ add(
52397
+ "bridge",
52398
+ "skipped",
52399
+ "probe_not_run",
52400
+ "Use --probe to start only Grove's packaged bridge; this is not a live-host check.",
52401
+ "bridge_probe"
52402
+ );
52403
+ }
52404
+ if (probe && origin) {
52405
+ try {
52406
+ const endpoint = origin;
52407
+ const api = new ApiClient(
52408
+ endpoint,
52409
+ (signal) => bearer(endpoint, client, signal),
52410
+ 5e3,
52411
+ {
52412
+ disabled: () => true,
52413
+ completed: () => {
52414
+ }
52415
+ }
52416
+ );
52417
+ const me = await api.request("/v1/me");
52418
+ if (!me || typeof me.accountId !== "string" || !Array.isArray(me.capabilities) || !me.capabilities.every(
52419
+ (capability) => typeof capability === "string"
52420
+ ) || typeof me.apiVersion !== "number")
52421
+ throw new GroveError(
52422
+ "invalid_response",
52423
+ "Invalid Grove API identity response",
52424
+ 502
52425
+ );
52426
+ if (me.apiVersion !== 1)
52427
+ throw new GroveError(
52428
+ "api_version_unsupported",
52429
+ "This Grove API version is not supported by the installed CLI",
52430
+ 409
52431
+ );
52432
+ if (!me.capabilities.length)
52433
+ throw new GroveError(
52434
+ "awaiting_grant",
52435
+ "Approve this agent's access in Grove Connections",
52436
+ 403
52437
+ );
52438
+ add(
52439
+ "api",
52440
+ "passed",
52441
+ "api_access_verified",
52442
+ "Authenticated API access works from this CLI; host activation is not verified."
52443
+ );
52444
+ } catch (error48) {
52445
+ add(
52446
+ "api",
52447
+ "failed",
52448
+ safeCode(error48),
52449
+ "API verification failed. Check sign-in, grant and endpoint availability; configuration is preserved."
52450
+ );
52451
+ }
52452
+ } else {
52453
+ add(
52454
+ "api",
52455
+ "skipped",
52456
+ "probe_not_run",
52457
+ "No API request made. Use --probe for an authenticated read-only check."
52458
+ );
52459
+ }
52460
+ add(
52461
+ "host",
52462
+ "unknown",
52463
+ "host_not_verified",
52464
+ client === "opencode" ? "Check Grove in OpenCode's /mcps. OpenCode reuses its runtime; a local probe does not verify the running session." : `Check Grove in ${client}'s plugin/MCP interface. Its host needs Node 22+ on PATH; optional hooks require host trust.`,
52465
+ "host"
52466
+ );
52467
+ return {
52468
+ schemaVersion: 1,
52469
+ client,
52470
+ observedAt: (/* @__PURE__ */ new Date()).toISOString(),
52471
+ status: checks.some((check2) => check2.status === "failed") ? "attention" : "ok",
52472
+ hostVerified: false,
52473
+ checks
52474
+ };
52475
+ }
52476
+
50828
52477
  // packages/mcp/src/cli.ts
50829
52478
  var help = `Grove \u2014 private memory across your agents
50830
52479
 
@@ -50832,6 +52481,7 @@ var help = `Grove \u2014 private memory across your agents
50832
52481
  grove init --url <origin> --client opencode|claude|codex
50833
52482
  grove login --url <origin> --client <client> [--key-stdin | --no-browser]
50834
52483
  grove status [--client <client>] [--json]
52484
+ grove doctor --client opencode|claude|codex [--probe] [--json]
50835
52485
  grove project [--client <client>]
50836
52486
  grove logout [--client <client>]
50837
52487
  grove pause | resume
@@ -50985,6 +52635,7 @@ async function main() {
50985
52635
  stdio: { type: "boolean" },
50986
52636
  "key-stdin": { type: "boolean" },
50987
52637
  "no-browser": { type: "boolean" },
52638
+ probe: { type: "boolean" },
50988
52639
  help: { type: "boolean", short: "h" },
50989
52640
  version: { type: "boolean", short: "v" }
50990
52641
  }
@@ -51002,6 +52653,30 @@ async function main() {
51002
52653
  console.log(help);
51003
52654
  return;
51004
52655
  }
52656
+ if (values.probe && command !== "doctor")
52657
+ throw new GroveError(
52658
+ "invalid_command",
52659
+ "--probe is only available with grove doctor"
52660
+ );
52661
+ if (command === "doctor") {
52662
+ const agent2 = agentSchema.safeParse(values.client);
52663
+ if (!agent2.success || positionals.length !== 1)
52664
+ throw new GroveError(
52665
+ "invalid_client",
52666
+ "Choose grove doctor --client opencode, claude or codex"
52667
+ );
52668
+ const report = await diagnose(agent2.data, !!values.probe, values.url);
52669
+ console.log(
52670
+ values.json ? JSON.stringify(report) : [
52671
+ `Grove diagnostics: ${report.status} (running host not verified)`,
52672
+ ...report.checks.map(
52673
+ (check2) => `${check2.id}: ${check2.status} (${check2.code}) [${check2.context}] \u2014 ${check2.message}`
52674
+ )
52675
+ ].join("\n")
52676
+ );
52677
+ if (report.status === "attention") process.exitCode = 1;
52678
+ return;
52679
+ }
51005
52680
  if (command === "telemetry") {
51006
52681
  const action = positionals[1] ?? "status";
51007
52682
  if (!["status", "enable", "disable"].includes(action) || positionals.length > 2)