@swmansion/argent 0.35.1-next.3 → 0.35.1-next.30

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 (55) hide show
  1. package/README.md +16 -15
  2. package/bin/argent-android-devtools-0.4.0.apk +0 -0
  3. package/bin/darwin/argent-macos-helper +0 -0
  4. package/bin/darwin/ax-service +0 -0
  5. package/bin/darwin/tvos-ax-service +0 -0
  6. package/bin/darwin/tvos-hid-daemon +0 -0
  7. package/bin/network-inspector/network-inspector.jar +0 -0
  8. package/bin/tcp/ax-service +0 -0
  9. package/dist/cli-cmds.mjs +1810 -1656
  10. package/dist/client.js +267 -250
  11. package/dist/fatal-handlers.js +7 -1
  12. package/dist/fatal-handlers.js.map +1 -1
  13. package/dist/installer-help.js +2 -1
  14. package/dist/installer-help.js.map +1 -1
  15. package/dist/installer.mjs +768 -550
  16. package/dist/mcp-server.mjs +1312 -1184
  17. package/dist/tool-args.generated.d.ts +355 -317
  18. package/dist/tool-server.cjs +103409 -101978
  19. package/dylibs/libArgentAudio.dylib +0 -0
  20. package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
  21. package/dylibs/libKeyboardPatch.dylib +0 -0
  22. package/dylibs/libNativeDevtoolsIos.dylib +0 -0
  23. package/dylibs/macos/libArgentInjectionBootstrap.dylib +0 -0
  24. package/dylibs/macos/libNativeDevtoolsMacos.dylib +0 -0
  25. package/dylibs/tcp/argent-audio-feeder +0 -0
  26. package/dylibs/tcp/libArgentAudio.dylib +0 -0
  27. package/dylibs/tcp/libArgentInjectionBootstrap.dylib +0 -0
  28. package/dylibs/tcp/libKeyboardPatch.dylib +0 -0
  29. package/dylibs/tcp/libNativeDevtoolsIos.dylib +0 -0
  30. package/dylibs/tvos/libArgentInjectionBootstrap.dylib +0 -0
  31. package/dylibs/tvos/libKeyboardPatch.dylib +0 -0
  32. package/dylibs/tvos/libNativeDevtoolsIos.dylib +0 -0
  33. package/package.json +2 -2
  34. package/skills/argent-android-emulator-setup/SKILL.md +2 -2
  35. package/skills/argent-create-e2e/SKILL.md +1 -1
  36. package/skills/argent-create-e2e/references/e2e-yaml.md +25 -2
  37. package/skills/argent-create-e2e/references/live-authoring.md +9 -0
  38. package/skills/argent-device-interact/SKILL.md +21 -94
  39. package/skills/argent-device-interact/references/advanced.md +64 -0
  40. package/skills/argent-ios-device-interact/SKILL.md +1 -1
  41. package/skills/argent-ios-device-setup/SKILL.md +1 -1
  42. package/skills/argent-ios-simulator-setup/SKILL.md +1 -1
  43. package/skills/argent-lens/SKILL.md +1 -1
  44. package/skills/argent-macos-app-interact/SKILL.md +1 -1
  45. package/skills/argent-metro-debugger/SKILL.md +1 -1
  46. package/skills/argent-native-profiler/SKILL.md +1 -1
  47. package/skills/argent-qa-e2e/SKILL.md +1 -1
  48. package/skills/argent-react-native-app-workflow/SKILL.md +1 -1
  49. package/skills/argent-react-native-optimization/SKILL.md +1 -1
  50. package/skills/argent-react-native-profiler/SKILL.md +1 -1
  51. package/skills/argent-screen-recording/SKILL.md +1 -1
  52. package/skills/argent-screenshot-diff/SKILL.md +1 -1
  53. package/skills/argent-settings-permissions/SKILL.md +1 -1
  54. package/skills/argent-test-ui-flow/SKILL.md +1 -1
  55. package/skills/argent-tv-interact/SKILL.md +1 -1
@@ -2990,7 +2990,7 @@ var require_compile = __commonJS({
2990
2990
  const schOrFunc = root.refs[ref];
2991
2991
  if (schOrFunc)
2992
2992
  return schOrFunc;
2993
- let _sch = resolve12.call(this, root, ref);
2993
+ let _sch = resolve13.call(this, root, ref);
2994
2994
  if (_sch === void 0) {
2995
2995
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
2996
2996
  const { schemaId } = this.opts;
@@ -3017,7 +3017,7 @@ var require_compile = __commonJS({
3017
3017
  function sameSchemaEnv(s1, s2) {
3018
3018
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
3019
3019
  }
3020
- function resolve12(root, ref) {
3020
+ function resolve13(root, ref) {
3021
3021
  let sch;
3022
3022
  while (typeof (sch = this.refs[ref]) == "string")
3023
3023
  ref = sch;
@@ -3235,8 +3235,8 @@ var require_utils = __commonJS({
3235
3235
  }
3236
3236
  return ind;
3237
3237
  }
3238
- function removeDotSegments(path18) {
3239
- let input = path18;
3238
+ function removeDotSegments(path19) {
3239
+ let input = path19;
3240
3240
  const output = [];
3241
3241
  let nextSlash = -1;
3242
3242
  let len = 0;
@@ -3488,8 +3488,8 @@ var require_schemes = __commonJS({
3488
3488
  wsComponent.secure = void 0;
3489
3489
  }
3490
3490
  if (wsComponent.resourceName) {
3491
- const [path18, query] = wsComponent.resourceName.split("?");
3492
- wsComponent.path = path18 && path18 !== "/" ? path18 : void 0;
3491
+ const [path19, query] = wsComponent.resourceName.split("?");
3492
+ wsComponent.path = path19 && path19 !== "/" ? path19 : void 0;
3493
3493
  wsComponent.query = query;
3494
3494
  wsComponent.resourceName = void 0;
3495
3495
  }
@@ -3648,7 +3648,7 @@ var require_fast_uri = __commonJS({
3648
3648
  }
3649
3649
  return uri;
3650
3650
  }
3651
- function resolve12(baseURI, relativeURI, options) {
3651
+ function resolve13(baseURI, relativeURI, options) {
3652
3652
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3653
3653
  const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
3654
3654
  schemelessOptions.skipEscape = true;
@@ -3906,7 +3906,7 @@ var require_fast_uri = __commonJS({
3906
3906
  var fastUri = {
3907
3907
  SCHEMES,
3908
3908
  normalize: normalize3,
3909
- resolve: resolve12,
3909
+ resolve: resolve13,
3910
3910
  resolveComponent,
3911
3911
  equal,
3912
3912
  serialize,
@@ -9697,7 +9697,7 @@ var require_compile2 = __commonJS({
9697
9697
  const schOrFunc = root.refs[ref];
9698
9698
  if (schOrFunc)
9699
9699
  return schOrFunc;
9700
- let _sch = resolve12.call(this, root, ref);
9700
+ let _sch = resolve13.call(this, root, ref);
9701
9701
  if (_sch === void 0) {
9702
9702
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
9703
9703
  const { schemaId } = this.opts;
@@ -9724,7 +9724,7 @@ var require_compile2 = __commonJS({
9724
9724
  function sameSchemaEnv(s1, s2) {
9725
9725
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
9726
9726
  }
9727
- function resolve12(root, ref) {
9727
+ function resolve13(root, ref) {
9728
9728
  let sch;
9729
9729
  while (typeof (sch = this.refs[ref]) == "string")
9730
9730
  ref = sch;
@@ -12590,6 +12590,398 @@ var require_dist = __commonJS({
12590
12590
  }
12591
12591
  });
12592
12592
 
12593
+ // ../../node_modules/dotenv/dist/index.cjs
12594
+ var require_dist2 = __commonJS({
12595
+ "../../node_modules/dotenv/dist/index.cjs"(exports, module) {
12596
+ var j = (e, n) => () => {
12597
+ try {
12598
+ return n || e((n = { exports: {} }).exports, n), n.exports;
12599
+ } catch (t) {
12600
+ throw n = 0, t;
12601
+ }
12602
+ };
12603
+ var k = j((xe, U) => {
12604
+ function G(e) {
12605
+ return typeof e == "string" ? !["false", "0", "no", "off", ""].includes(e.toLowerCase()) : !!e;
12606
+ }
12607
+ function Y(e = process.env) {
12608
+ let n = {};
12609
+ for (let t of ["ENCODING", "PATH", "QUIET", "DEBUG", "OVERRIDE", "FAST"]) {
12610
+ let o = e[`DOTENV_${t}`] != null ? e[`DOTENV_${t}`] : e[`DOTENV_CONFIG_${t}`];
12611
+ o != null && (n[t.toLowerCase()] = t === "ENCODING" || t === "PATH" ? o : G(o));
12612
+ }
12613
+ return n;
12614
+ }
12615
+ U.exports = { parseBoolean: G, optionsFromEnv: Y };
12616
+ });
12617
+ var N = j((ye, x) => {
12618
+ var z = __require("fs"), I = __require("path"), Z = __require("os"), { URL: ee, fileURLToPath: te } = __require("url"), { parseBoolean: $, optionsFromEnv: B } = k(), re = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg, b = new Uint8Array(256);
12619
+ for (let e = 48; e <= 57; e++) b[e] = 1;
12620
+ for (let e = 65; e <= 90; e++) b[e] = 1;
12621
+ for (let e = 97; e <= 122; e++) b[e] = 1;
12622
+ b[45] = 1;
12623
+ b[46] = 1;
12624
+ b[95] = 1;
12625
+ function ne(e) {
12626
+ let n = {}, t = e.toString();
12627
+ t = t.replace(/\r\n?/mg, `
12628
+ `);
12629
+ let o;
12630
+ for (; (o = re.exec(t)) != null; ) {
12631
+ let r = o[1], s = o[2] || "";
12632
+ s = s.trim();
12633
+ let i = s[0];
12634
+ s = s.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), i === '"' && (s = s.replace(/\\n/g, `
12635
+ `), s = s.replace(/\\r/g, "\r")), n[r] = s;
12636
+ }
12637
+ return n;
12638
+ }
12639
+ function w(e) {
12640
+ return e <= 32 ? e === 32 || e >= 9 && e <= 13 : e >= 160 && (e === 160 || e === 5760 || e >= 8192 && e <= 8202 || e === 8232 || e === 8233 || e === 8239 || e === 8287 || e === 12288 || e === 65279);
12641
+ }
12642
+ function q(e) {
12643
+ return e === 10 || e === 8232 || e === 8233;
12644
+ }
12645
+ function oe(e) {
12646
+ let n = {}, t = typeof e == "string" ? e : e.toString();
12647
+ t.indexOf("\r") !== -1 && (t = t.replace(/\r\n?/g, `
12648
+ `));
12649
+ let o = t.length, r = 0;
12650
+ for (; r < o; ) {
12651
+ let s = t.charCodeAt(r);
12652
+ for (; r < o && w(s); ) r++, s = t.charCodeAt(r);
12653
+ if (r >= o) break;
12654
+ if (s === 35) {
12655
+ for (; r < o && !q(t.charCodeAt(r)); ) r++;
12656
+ continue;
12657
+ }
12658
+ let i = -1;
12659
+ if (s === 101 && r + 6 < o && t.charCodeAt(r + 1) === 120 && t.charCodeAt(r + 2) === 112 && t.charCodeAt(r + 3) === 111 && t.charCodeAt(r + 4) === 114 && t.charCodeAt(r + 5) === 116) {
12660
+ let v = t.charCodeAt(r + 6);
12661
+ if (w(v)) {
12662
+ let u = r + 7;
12663
+ for (; u < o && w(t.charCodeAt(u)); ) u++;
12664
+ b[t.charCodeAt(u)] && (i = r + 6, r = u);
12665
+ } else s = t.charCodeAt(r);
12666
+ }
12667
+ let l = r, d = 0;
12668
+ for (; r < o && (d = t.charCodeAt(r), b[d]); ) r++;
12669
+ if (r === l) {
12670
+ for (; r < o && !q(t.charCodeAt(r)); ) r++;
12671
+ continue;
12672
+ }
12673
+ let h = t.slice(l, r), f = r;
12674
+ if (r >= o && (d = 0), w(d)) do
12675
+ r++, d = r < o ? t.charCodeAt(r) : 0;
12676
+ while (w(d));
12677
+ if (d === 61) r++;
12678
+ else if (d === 58 && r === f && r + 1 < o && w(t.charCodeAt(r + 1))) r += 2;
12679
+ else {
12680
+ for (r = i === -1 ? f : i; r < o && !q(t.charCodeAt(r)); ) r++;
12681
+ continue;
12682
+ }
12683
+ let c = r, a = r;
12684
+ for (; a < o && w(t.charCodeAt(a)); ) a++;
12685
+ let g = t.charCodeAt(a), p, y = false;
12686
+ if (g === 39 || g === 34 || g === 96) {
12687
+ let v = t[a], u = t.indexOf(v, a + 1), m = -1, C = -1;
12688
+ for (; u !== -1; ) {
12689
+ let O = t.charCodeAt(u - 1) === 92, E = u + 1;
12690
+ for (; E < o && !q(t.charCodeAt(E)) && w(t.charCodeAt(E)); ) E++;
12691
+ if ((E === o || q(t.charCodeAt(E)) || t.charCodeAt(E) === 35) && (m = u, C = E), !O) break;
12692
+ u = t.indexOf(v, u + 1);
12693
+ }
12694
+ if (m !== -1) {
12695
+ if (p = t.slice(a + 1, m), r = C, t.charCodeAt(r) === 35) for (; r < o && !q(t.charCodeAt(r)); ) r++;
12696
+ y = true;
12697
+ }
12698
+ }
12699
+ if (!y) {
12700
+ let v = t.indexOf(`
12701
+ `, c);
12702
+ v === -1 && (v = o);
12703
+ let u;
12704
+ if (o < 4096) u = t.indexOf("#", c), (u === -1 || u > v) && (u = v);
12705
+ else for (u = c; u < v && t.charCodeAt(u) !== 35; ) u++;
12706
+ let m = c, C = u;
12707
+ for (; m < C && w(t.charCodeAt(m)); ) m++;
12708
+ for (; C > m && w(t.charCodeAt(C - 1)); ) C--;
12709
+ let O = t.charCodeAt(m);
12710
+ if (p = t.slice(m, C), p.includes("\u2028") || p.includes("\u2029") ? p = p.replace(/^(['"`])([\s\S]*)\1$/mg, "$2") : C - m >= 2 && (O === 39 || O === 34 || O === 96) && t.charCodeAt(C - 1) === O && (p = t.slice(m + 1, C - 1)), r = u, u < v) for (; r < o && !q(t.charCodeAt(r)); ) r++;
12711
+ }
12712
+ g === 34 && (y || a < r) && p.indexOf("\\") !== -1 && (p = p.replace(/\\n/g, `
12713
+ `).replace(/\\r/g, "\r")), n[h] = p;
12714
+ }
12715
+ return n;
12716
+ }
12717
+ function se(e, n) {
12718
+ return n && $(n.fast) ? oe(e) : ne(e);
12719
+ }
12720
+ function T(e) {
12721
+ console.log(`\u2506 ${e}`);
12722
+ }
12723
+ function ie(e) {
12724
+ console.error(`\u25C7 ${e}`);
12725
+ }
12726
+ function V(e) {
12727
+ return e[0] === "~" ? I.join(Z.homedir(), e.slice(1)) : e;
12728
+ }
12729
+ function ce(e = {}) {
12730
+ let n = { ...e };
12731
+ for (let t of Object.keys(n)) n[t] === void 0 && delete n[t];
12732
+ return { ...B(), ...n };
12733
+ }
12734
+ function ae(e) {
12735
+ e = ce(e);
12736
+ let n = I.resolve(process.cwd(), ".env"), t = "utf8", o = process.env;
12737
+ e && e.processEnv != null && (o = e.processEnv);
12738
+ let r = $(e && e.debug);
12739
+ e && e.encoding ? t = e.encoding : r && T("no encoding is specified (UTF-8 is used by default)");
12740
+ let s = [n];
12741
+ if (e && e.path) if (!Array.isArray(e.path)) s = [V(e.path)];
12742
+ else {
12743
+ s = [];
12744
+ for (let c of e.path) s.push(V(c));
12745
+ }
12746
+ let i, l = {}, d = { fast: e.fast };
12747
+ for (let c of s) try {
12748
+ let a = A.parse(z.readFileSync(c, { encoding: t }), d);
12749
+ A.populate(l, a, e);
12750
+ } catch (a) {
12751
+ r && T(`failed to load ${c} ${a.message}`), i = a;
12752
+ }
12753
+ let h = A.populate(o, l, e), f = $(Object.prototype.hasOwnProperty.call(e, "quiet") ? e.quiet : B(o).quiet);
12754
+ if (r || !f) {
12755
+ let c = Object.keys(h).length, a = [];
12756
+ for (let g of s) try {
12757
+ let p = I.relative(process.cwd(), g instanceof ee ? te(g) : g);
12758
+ a.push(p);
12759
+ } catch (p) {
12760
+ r && T(`failed to load ${g} ${p.message}`), i = p;
12761
+ }
12762
+ ie(`injected env (${c}) from ${a.join(",")}`);
12763
+ }
12764
+ return i ? { parsed: l, error: i } : { parsed: l };
12765
+ }
12766
+ function le(e) {
12767
+ return A.configDotenv(e);
12768
+ }
12769
+ function fe(e, n, t = {}) {
12770
+ let o = $(t && t.debug), r = $(t && t.override), s = {};
12771
+ if (e === null || typeof e != "object" || n === null || typeof n != "object") {
12772
+ let i = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
12773
+ throw i.code = "OBJECT_REQUIRED", i;
12774
+ }
12775
+ for (let i of Object.keys(n)) Object.prototype.hasOwnProperty.call(e, i) ? (r === true && (e[i] = n[i], s[i] = n[i]), o && T(r === true ? `"${i}" is already defined and WAS overwritten` : `"${i}" is already defined and was NOT overwritten`)) : (e[i] = n[i], s[i] = n[i]);
12776
+ return s;
12777
+ }
12778
+ var A = { configDotenv: ae, config: le, parse: se, populate: fe };
12779
+ x.exports.configDotenv = A.configDotenv;
12780
+ x.exports.config = A.config;
12781
+ x.exports.parse = A.parse;
12782
+ x.exports.populate = A.populate;
12783
+ x.exports = A;
12784
+ });
12785
+ var M = j((Te, W) => {
12786
+ var _ = __require("child_process"), ue = __require("fs"), L = __require("path");
12787
+ function de(e) {
12788
+ let n = ['"'], t = 0;
12789
+ for (let o of e) {
12790
+ if (o === "\\") {
12791
+ t++;
12792
+ continue;
12793
+ }
12794
+ o === '"' ? n.push("\\".repeat(t * 2 + 1), '"') : n.push("\\".repeat(t), o), t = 0;
12795
+ }
12796
+ return n.push("\\".repeat(t * 2), '"'), n.join("");
12797
+ }
12798
+ function H(e, n = 1) {
12799
+ for (let t = 0; t < n; t++) {
12800
+ let o = [];
12801
+ for (let r of e) {
12802
+ let s = r.charCodeAt(0), i = s >= 48 && s <= 57 || s >= 65 && s <= 90 || s >= 97 && s <= 122, l = "\\/:._-".includes(r);
12803
+ !i && !l && s < 128 && o.push("^"), o.push(r);
12804
+ }
12805
+ e = o.join("");
12806
+ }
12807
+ return e;
12808
+ }
12809
+ function P(e, n) {
12810
+ let t = Object.keys(e).reverse().find((o) => o.toUpperCase() === n);
12811
+ return t === void 0 ? void 0 : e[t];
12812
+ }
12813
+ function pe(e, n, t) {
12814
+ let o = (P(n, "PATHEXT") || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean), s = o.some((l) => e.toLowerCase().endsWith(l.toLowerCase())) ? ["", ...o] : [...o, ""], i = /[\\/]/.test(e) ? [t] : [t, ...(P(n, "PATH") || "").split(";")];
12815
+ for (let l of i) for (let d of s) {
12816
+ let h = L.resolve(t, l.replace(/^"|"$/g, ""), e + d);
12817
+ try {
12818
+ if (ue.statSync(h).isFile()) return h;
12819
+ } catch {
12820
+ }
12821
+ }
12822
+ }
12823
+ function he(e, n, t) {
12824
+ if (process.platform !== "win32") return _.spawn(e, n, t);
12825
+ let o = t.env || process.env, r = pe(e, o, t.cwd || process.cwd());
12826
+ if (r && /\.(?:exe|com)$/i.test(r)) return _.spawn(r, n, t);
12827
+ let s = /\.(?:bat|cmd)$/i.test(r || e), i = [H(L.normalize(r || e))];
12828
+ for (let d of n) i.push(H(de(d), s ? 2 : 1));
12829
+ let l = i.join(" ");
12830
+ return _.spawn(P(o, "COMSPEC") || "cmd.exe", ["/d", "/v:off", "/s", "/c", `"${l}"`], { ...t, windowsVerbatimArguments: true });
12831
+ }
12832
+ W.exports = he;
12833
+ });
12834
+ var X = j(($e, F) => {
12835
+ var ge = __require("fs"), me = __require("os"), Q = __require("path"), ve = __require("child_process"), Ce = M(), R = N(), { optionsFromEnv: J } = k();
12836
+ function D() {
12837
+ console.log(["Usage: dotenv run [--help] [-q|--quiet] [--debug] [--override] [--fast] [-f|--file <paths>] [--] <command> [args...]", "", "Run a command with environment variables from a .env file.", "Place dotenv options before the command; all following arguments go to the command.", "", "Options:", " -f, --file <paths> .env paths, comma-separated or repeated (default: .env)", " -q, --quiet suppress the injected env message", " --debug enable debug logging", " --override override existing environment variables", " --fast use the faster character-scanner parser", "", "Environment variables (DOTENV_CONFIG_* names remain as fallbacks):", " DOTENV_PATH, DOTENV_ENCODING, DOTENV_QUIET,", " DOTENV_DEBUG, DOTENV_OVERRIDE,", " DOTENV_FAST"].join(`
12838
+ `));
12839
+ }
12840
+ function we(e) {
12841
+ let n = [], t = false, o, r, s, i, l = -1;
12842
+ for (let h = 0; h < e.length; h++) {
12843
+ let f = e[h];
12844
+ if (f === "--") {
12845
+ l = h + 1;
12846
+ break;
12847
+ }
12848
+ if (f === "--help" || f === "-h") return { help: true };
12849
+ if (f === "--quiet" || f === "-q") {
12850
+ o = true;
12851
+ continue;
12852
+ }
12853
+ if (f === "--debug") {
12854
+ r = true;
12855
+ continue;
12856
+ }
12857
+ if (f === "--override") {
12858
+ s = true;
12859
+ continue;
12860
+ }
12861
+ if (f === "--fast") {
12862
+ i = true;
12863
+ continue;
12864
+ }
12865
+ if (f === "-f" || f === "--file" || f.startsWith("-f=") || f.startsWith("--file=")) {
12866
+ let c = f.indexOf("="), a = c === -1 ? f : f.slice(0, c), g = c === -1 ? e[++h] : f.slice(c + 1);
12867
+ if (!g || g === "--") return { error: `${a} requires a path` };
12868
+ let p = g.split(",").map((y) => y.trim()).filter(Boolean);
12869
+ if (p.length === 0) return { error: `${a} requires a path` };
12870
+ n.push(...p), t = true;
12871
+ continue;
12872
+ }
12873
+ if (f.startsWith("-")) return { error: `unknown option: ${f}` };
12874
+ l = h;
12875
+ break;
12876
+ }
12877
+ let d = l === -1 ? [] : e.slice(l);
12878
+ return { paths: n, pathSet: t, quiet: o, debug: r, override: s, fast: i, command: d };
12879
+ }
12880
+ function Ae(e) {
12881
+ return e[0] === "~" ? Q.join(me.homedir(), e.slice(1)) : e;
12882
+ }
12883
+ function Ee(e) {
12884
+ let n = J(), t = { encoding: n.encoding || "utf8", quiet: n.quiet, debug: n.debug === true, override: n.override === true, fast: n.fast === true, paths: [".env"], defaultPath: true };
12885
+ return n.path != null && (t.paths = [n.path], t.defaultPath = false), e.pathSet && (t.paths = e.paths, t.defaultPath = false), e.quiet != null && (t.quiet = e.quiet), e.debug != null && (t.debug = e.debug), e.override != null && (t.override = e.override), e.fast != null && (t.fast = e.fast), t;
12886
+ }
12887
+ function be(e) {
12888
+ let n = {}, t = [], o = { override: e.override, debug: e.debug };
12889
+ for (let s of e.paths) {
12890
+ let i = Q.resolve(process.cwd(), Ae(s));
12891
+ try {
12892
+ let l = R.parse(ge.readFileSync(i, { encoding: e.encoding }), { fast: e.fast });
12893
+ R.populate(n, l, o), t.push(s);
12894
+ } catch (l) {
12895
+ if (e.debug && console.log(`\u2506 failed to load ${s} ${l.message}`), !(e.defaultPath && l.code === "ENOENT")) throw l;
12896
+ }
12897
+ }
12898
+ return { injected: R.populate(process.env, n, o), loadedPaths: t };
12899
+ }
12900
+ function K(e) {
12901
+ let n = e[0];
12902
+ if (n === "--help" || n === "-h") {
12903
+ D();
12904
+ return;
12905
+ }
12906
+ if (n !== "run") {
12907
+ D(), process.exitCode = 1;
12908
+ return;
12909
+ }
12910
+ let t = we(e.slice(1));
12911
+ if (t.help) {
12912
+ D();
12913
+ return;
12914
+ }
12915
+ if (t.error) {
12916
+ console.error(`dotenv: ${t.error}`), D(), process.exitCode = 1;
12917
+ return;
12918
+ }
12919
+ if (t.command.length === 0) {
12920
+ D(), process.exitCode = 1;
12921
+ return;
12922
+ }
12923
+ let o = Ee(t);
12924
+ try {
12925
+ let c = be(o);
12926
+ if (!(o.quiet == null ? J().quiet : o.quiet)) {
12927
+ let g = `\u25C7 injected env (${Object.keys(c.injected).length})`;
12928
+ c.loadedPaths.length > 0 && (g += ` from ${c.loadedPaths.join(", ")}`), console.error(g);
12929
+ }
12930
+ } catch (c) {
12931
+ console.error(`dotenv: ${c.message}`), process.exitCode = 1;
12932
+ return;
12933
+ }
12934
+ let r = !!process.stdin.isTTY, s = process.platform !== "win32" && !r, i = Ce(t.command[0], t.command.slice(1), { stdio: "inherit", detached: s }), l = /* @__PURE__ */ new Map(), d = 0;
12935
+ function h(c) {
12936
+ if (!(!i.pid || i.exitCode !== null || i.signalCode !== null)) {
12937
+ if (process.platform === "win32") {
12938
+ ve.spawnSync("taskkill", ["/pid", String(i.pid), "/T", "/F"], { stdio: "ignore" });
12939
+ return;
12940
+ }
12941
+ try {
12942
+ process.kill(s ? -i.pid : i.pid, c);
12943
+ } catch (a) {
12944
+ if (a.code !== "ESRCH") throw a;
12945
+ }
12946
+ }
12947
+ }
12948
+ function f() {
12949
+ for (let [c, a] of l) process.removeListener(c, a);
12950
+ }
12951
+ for (let c of ["SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT"]) {
12952
+ let a = () => {
12953
+ if (c === "SIGINT") {
12954
+ if (d++, r && process.platform !== "win32" && d === 1) return;
12955
+ if (d > 1) {
12956
+ h(d === 2 ? "SIGTERM" : "SIGKILL");
12957
+ return;
12958
+ }
12959
+ }
12960
+ h(c);
12961
+ };
12962
+ l.set(c, a), process.on(c, a);
12963
+ }
12964
+ i.on("error", function(c) {
12965
+ f(), console.error(`dotenv: ${c.message}`), process.exitCode = 1;
12966
+ }), i.on("exit", function(c, a) {
12967
+ f(), typeof c == "number" ? process.exit(c) : (setInterval(() => {
12968
+ }, 1e3), process.kill(process.pid, a));
12969
+ });
12970
+ }
12971
+ F.exports = K;
12972
+ __require.main === F && K(process.argv.slice(2));
12973
+ });
12974
+ var S = N();
12975
+ var qe = X();
12976
+ module.exports = S;
12977
+ module.exports.config = S.config;
12978
+ module.exports.configDotenv = S.configDotenv;
12979
+ module.exports.parse = S.parse;
12980
+ module.exports.populate = S.populate;
12981
+ __require.main === module && qe(process.argv.slice(2));
12982
+ }
12983
+ });
12984
+
12593
12985
  // ../../node_modules/yaml/dist/nodes/identity.js
12594
12986
  var require_identity = __commonJS({
12595
12987
  "../../node_modules/yaml/dist/nodes/identity.js"(exports) {
@@ -12667,17 +13059,17 @@ var require_visit = __commonJS({
12667
13059
  visit.BREAK = BREAK;
12668
13060
  visit.SKIP = SKIP;
12669
13061
  visit.REMOVE = REMOVE;
12670
- function visit_(key, node2, visitor, path18) {
12671
- const ctrl = callVisitor(key, node2, visitor, path18);
13062
+ function visit_(key, node2, visitor, path19) {
13063
+ const ctrl = callVisitor(key, node2, visitor, path19);
12672
13064
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
12673
- replaceNode(key, path18, ctrl);
12674
- return visit_(key, ctrl, visitor, path18);
13065
+ replaceNode(key, path19, ctrl);
13066
+ return visit_(key, ctrl, visitor, path19);
12675
13067
  }
12676
13068
  if (typeof ctrl !== "symbol") {
12677
13069
  if (identity.isCollection(node2)) {
12678
- path18 = Object.freeze(path18.concat(node2));
13070
+ path19 = Object.freeze(path19.concat(node2));
12679
13071
  for (let i = 0; i < node2.items.length; ++i) {
12680
- const ci = visit_(i, node2.items[i], visitor, path18);
13072
+ const ci = visit_(i, node2.items[i], visitor, path19);
12681
13073
  if (typeof ci === "number")
12682
13074
  i = ci - 1;
12683
13075
  else if (ci === BREAK)
@@ -12688,13 +13080,13 @@ var require_visit = __commonJS({
12688
13080
  }
12689
13081
  }
12690
13082
  } else if (identity.isPair(node2)) {
12691
- path18 = Object.freeze(path18.concat(node2));
12692
- const ck = visit_("key", node2.key, visitor, path18);
13083
+ path19 = Object.freeze(path19.concat(node2));
13084
+ const ck = visit_("key", node2.key, visitor, path19);
12693
13085
  if (ck === BREAK)
12694
13086
  return BREAK;
12695
13087
  else if (ck === REMOVE)
12696
13088
  node2.key = null;
12697
- const cv = visit_("value", node2.value, visitor, path18);
13089
+ const cv = visit_("value", node2.value, visitor, path19);
12698
13090
  if (cv === BREAK)
12699
13091
  return BREAK;
12700
13092
  else if (cv === REMOVE)
@@ -12715,17 +13107,17 @@ var require_visit = __commonJS({
12715
13107
  visitAsync.BREAK = BREAK;
12716
13108
  visitAsync.SKIP = SKIP;
12717
13109
  visitAsync.REMOVE = REMOVE;
12718
- async function visitAsync_(key, node2, visitor, path18) {
12719
- const ctrl = await callVisitor(key, node2, visitor, path18);
13110
+ async function visitAsync_(key, node2, visitor, path19) {
13111
+ const ctrl = await callVisitor(key, node2, visitor, path19);
12720
13112
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
12721
- replaceNode(key, path18, ctrl);
12722
- return visitAsync_(key, ctrl, visitor, path18);
13113
+ replaceNode(key, path19, ctrl);
13114
+ return visitAsync_(key, ctrl, visitor, path19);
12723
13115
  }
12724
13116
  if (typeof ctrl !== "symbol") {
12725
13117
  if (identity.isCollection(node2)) {
12726
- path18 = Object.freeze(path18.concat(node2));
13118
+ path19 = Object.freeze(path19.concat(node2));
12727
13119
  for (let i = 0; i < node2.items.length; ++i) {
12728
- const ci = await visitAsync_(i, node2.items[i], visitor, path18);
13120
+ const ci = await visitAsync_(i, node2.items[i], visitor, path19);
12729
13121
  if (typeof ci === "number")
12730
13122
  i = ci - 1;
12731
13123
  else if (ci === BREAK)
@@ -12736,13 +13128,13 @@ var require_visit = __commonJS({
12736
13128
  }
12737
13129
  }
12738
13130
  } else if (identity.isPair(node2)) {
12739
- path18 = Object.freeze(path18.concat(node2));
12740
- const ck = await visitAsync_("key", node2.key, visitor, path18);
13131
+ path19 = Object.freeze(path19.concat(node2));
13132
+ const ck = await visitAsync_("key", node2.key, visitor, path19);
12741
13133
  if (ck === BREAK)
12742
13134
  return BREAK;
12743
13135
  else if (ck === REMOVE)
12744
13136
  node2.key = null;
12745
- const cv = await visitAsync_("value", node2.value, visitor, path18);
13137
+ const cv = await visitAsync_("value", node2.value, visitor, path19);
12746
13138
  if (cv === BREAK)
12747
13139
  return BREAK;
12748
13140
  else if (cv === REMOVE)
@@ -12769,23 +13161,23 @@ var require_visit = __commonJS({
12769
13161
  }
12770
13162
  return visitor;
12771
13163
  }
12772
- function callVisitor(key, node2, visitor, path18) {
13164
+ function callVisitor(key, node2, visitor, path19) {
12773
13165
  if (typeof visitor === "function")
12774
- return visitor(key, node2, path18);
13166
+ return visitor(key, node2, path19);
12775
13167
  if (identity.isMap(node2))
12776
- return visitor.Map?.(key, node2, path18);
13168
+ return visitor.Map?.(key, node2, path19);
12777
13169
  if (identity.isSeq(node2))
12778
- return visitor.Seq?.(key, node2, path18);
13170
+ return visitor.Seq?.(key, node2, path19);
12779
13171
  if (identity.isPair(node2))
12780
- return visitor.Pair?.(key, node2, path18);
13172
+ return visitor.Pair?.(key, node2, path19);
12781
13173
  if (identity.isScalar(node2))
12782
- return visitor.Scalar?.(key, node2, path18);
13174
+ return visitor.Scalar?.(key, node2, path19);
12783
13175
  if (identity.isAlias(node2))
12784
- return visitor.Alias?.(key, node2, path18);
13176
+ return visitor.Alias?.(key, node2, path19);
12785
13177
  return void 0;
12786
13178
  }
12787
- function replaceNode(key, path18, node2) {
12788
- const parent = path18[path18.length - 1];
13179
+ function replaceNode(key, path19, node2) {
13180
+ const parent = path19[path19.length - 1];
12789
13181
  if (identity.isCollection(parent)) {
12790
13182
  parent.items[key] = node2;
12791
13183
  } else if (identity.isPair(parent)) {
@@ -13397,10 +13789,10 @@ var require_Collection = __commonJS({
13397
13789
  var createNode = require_createNode();
13398
13790
  var identity = require_identity();
13399
13791
  var Node = require_Node();
13400
- function collectionFromPath(schema, path18, value) {
13792
+ function collectionFromPath(schema, path19, value) {
13401
13793
  let v = value;
13402
- for (let i = path18.length - 1; i >= 0; --i) {
13403
- const k = path18[i];
13794
+ for (let i = path19.length - 1; i >= 0; --i) {
13795
+ const k = path19[i];
13404
13796
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
13405
13797
  const a = [];
13406
13798
  a[k] = v;
@@ -13419,7 +13811,7 @@ var require_Collection = __commonJS({
13419
13811
  sourceObjects: /* @__PURE__ */ new Map()
13420
13812
  });
13421
13813
  }
13422
- var isEmptyPath = (path18) => path18 == null || typeof path18 === "object" && !!path18[Symbol.iterator]().next().done;
13814
+ var isEmptyPath = (path19) => path19 == null || typeof path19 === "object" && !!path19[Symbol.iterator]().next().done;
13423
13815
  var Collection = class extends Node.NodeBase {
13424
13816
  constructor(type, schema) {
13425
13817
  super(type);
@@ -13449,11 +13841,11 @@ var require_Collection = __commonJS({
13449
13841
  * be a Pair instance or a `{ key, value }` object, which may not have a key
13450
13842
  * that already exists in the map.
13451
13843
  */
13452
- addIn(path18, value) {
13453
- if (isEmptyPath(path18))
13844
+ addIn(path19, value) {
13845
+ if (isEmptyPath(path19))
13454
13846
  this.add(value);
13455
13847
  else {
13456
- const [key, ...rest] = path18;
13848
+ const [key, ...rest] = path19;
13457
13849
  const node2 = this.get(key, true);
13458
13850
  if (identity.isCollection(node2))
13459
13851
  node2.addIn(rest, value);
@@ -13467,8 +13859,8 @@ var require_Collection = __commonJS({
13467
13859
  * Removes a value from the collection.
13468
13860
  * @returns `true` if the item was found and removed.
13469
13861
  */
13470
- deleteIn(path18) {
13471
- const [key, ...rest] = path18;
13862
+ deleteIn(path19) {
13863
+ const [key, ...rest] = path19;
13472
13864
  if (rest.length === 0)
13473
13865
  return this.delete(key);
13474
13866
  const node2 = this.get(key, true);
@@ -13482,8 +13874,8 @@ var require_Collection = __commonJS({
13482
13874
  * scalar values from their surrounding node; to disable set `keepScalar` to
13483
13875
  * `true` (collections are always returned intact).
13484
13876
  */
13485
- getIn(path18, keepScalar) {
13486
- const [key, ...rest] = path18;
13877
+ getIn(path19, keepScalar) {
13878
+ const [key, ...rest] = path19;
13487
13879
  const node2 = this.get(key, true);
13488
13880
  if (rest.length === 0)
13489
13881
  return !keepScalar && identity.isScalar(node2) ? node2.value : node2;
@@ -13501,8 +13893,8 @@ var require_Collection = __commonJS({
13501
13893
  /**
13502
13894
  * Checks if the collection includes a value with the key `key`.
13503
13895
  */
13504
- hasIn(path18) {
13505
- const [key, ...rest] = path18;
13896
+ hasIn(path19) {
13897
+ const [key, ...rest] = path19;
13506
13898
  if (rest.length === 0)
13507
13899
  return this.has(key);
13508
13900
  const node2 = this.get(key, true);
@@ -13512,8 +13904,8 @@ var require_Collection = __commonJS({
13512
13904
  * Sets a value in this collection. For `!!set`, `value` needs to be a
13513
13905
  * boolean to add/remove the item from the set.
13514
13906
  */
13515
- setIn(path18, value) {
13516
- const [key, ...rest] = path18;
13907
+ setIn(path19, value) {
13908
+ const [key, ...rest] = path19;
13517
13909
  if (rest.length === 0) {
13518
13910
  this.set(key, value);
13519
13911
  } else {
@@ -16028,9 +16420,9 @@ var require_Document = __commonJS({
16028
16420
  this.contents.add(value);
16029
16421
  }
16030
16422
  /** Adds a value to the document. */
16031
- addIn(path18, value) {
16423
+ addIn(path19, value) {
16032
16424
  if (assertCollection(this.contents))
16033
- this.contents.addIn(path18, value);
16425
+ this.contents.addIn(path19, value);
16034
16426
  }
16035
16427
  /**
16036
16428
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -16105,14 +16497,14 @@ var require_Document = __commonJS({
16105
16497
  * Removes a value from the document.
16106
16498
  * @returns `true` if the item was found and removed.
16107
16499
  */
16108
- deleteIn(path18) {
16109
- if (Collection.isEmptyPath(path18)) {
16500
+ deleteIn(path19) {
16501
+ if (Collection.isEmptyPath(path19)) {
16110
16502
  if (this.contents == null)
16111
16503
  return false;
16112
16504
  this.contents = null;
16113
16505
  return true;
16114
16506
  }
16115
- return assertCollection(this.contents) ? this.contents.deleteIn(path18) : false;
16507
+ return assertCollection(this.contents) ? this.contents.deleteIn(path19) : false;
16116
16508
  }
16117
16509
  /**
16118
16510
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -16127,10 +16519,10 @@ var require_Document = __commonJS({
16127
16519
  * scalar values from their surrounding node; to disable set `keepScalar` to
16128
16520
  * `true` (collections are always returned intact).
16129
16521
  */
16130
- getIn(path18, keepScalar) {
16131
- if (Collection.isEmptyPath(path18))
16522
+ getIn(path19, keepScalar) {
16523
+ if (Collection.isEmptyPath(path19))
16132
16524
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
16133
- return identity.isCollection(this.contents) ? this.contents.getIn(path18, keepScalar) : void 0;
16525
+ return identity.isCollection(this.contents) ? this.contents.getIn(path19, keepScalar) : void 0;
16134
16526
  }
16135
16527
  /**
16136
16528
  * Checks if the document includes a value with the key `key`.
@@ -16141,10 +16533,10 @@ var require_Document = __commonJS({
16141
16533
  /**
16142
16534
  * Checks if the document includes a value at `path`.
16143
16535
  */
16144
- hasIn(path18) {
16145
- if (Collection.isEmptyPath(path18))
16536
+ hasIn(path19) {
16537
+ if (Collection.isEmptyPath(path19))
16146
16538
  return this.contents !== void 0;
16147
- return identity.isCollection(this.contents) ? this.contents.hasIn(path18) : false;
16539
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path19) : false;
16148
16540
  }
16149
16541
  /**
16150
16542
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -16161,13 +16553,13 @@ var require_Document = __commonJS({
16161
16553
  * Sets a value in this document. For `!!set`, `value` needs to be a
16162
16554
  * boolean to add/remove the item from the set.
16163
16555
  */
16164
- setIn(path18, value) {
16165
- if (Collection.isEmptyPath(path18)) {
16556
+ setIn(path19, value) {
16557
+ if (Collection.isEmptyPath(path19)) {
16166
16558
  this.contents = value;
16167
16559
  } else if (this.contents == null) {
16168
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path18), value);
16560
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path19), value);
16169
16561
  } else if (assertCollection(this.contents)) {
16170
- this.contents.setIn(path18, value);
16562
+ this.contents.setIn(path19, value);
16171
16563
  }
16172
16564
  }
16173
16565
  /**
@@ -18128,9 +18520,9 @@ var require_cst_visit = __commonJS({
18128
18520
  visit.BREAK = BREAK;
18129
18521
  visit.SKIP = SKIP;
18130
18522
  visit.REMOVE = REMOVE;
18131
- visit.itemAtPath = (cst, path18) => {
18523
+ visit.itemAtPath = (cst, path19) => {
18132
18524
  let item = cst;
18133
- for (const [field, index] of path18) {
18525
+ for (const [field, index] of path19) {
18134
18526
  const tok = item?.[field];
18135
18527
  if (tok && "items" in tok) {
18136
18528
  item = tok.items[index];
@@ -18139,23 +18531,23 @@ var require_cst_visit = __commonJS({
18139
18531
  }
18140
18532
  return item;
18141
18533
  };
18142
- visit.parentCollection = (cst, path18) => {
18143
- const parent = visit.itemAtPath(cst, path18.slice(0, -1));
18144
- const field = path18[path18.length - 1][0];
18534
+ visit.parentCollection = (cst, path19) => {
18535
+ const parent = visit.itemAtPath(cst, path19.slice(0, -1));
18536
+ const field = path19[path19.length - 1][0];
18145
18537
  const coll = parent?.[field];
18146
18538
  if (coll && "items" in coll)
18147
18539
  return coll;
18148
18540
  throw new Error("Parent collection not found");
18149
18541
  };
18150
- function _visit(path18, item, visitor) {
18151
- let ctrl = visitor(item, path18);
18542
+ function _visit(path19, item, visitor) {
18543
+ let ctrl = visitor(item, path19);
18152
18544
  if (typeof ctrl === "symbol")
18153
18545
  return ctrl;
18154
18546
  for (const field of ["key", "value"]) {
18155
18547
  const token = item[field];
18156
18548
  if (token && "items" in token) {
18157
18549
  for (let i = 0; i < token.items.length; ++i) {
18158
- const ci = _visit(Object.freeze(path18.concat([[field, i]])), token.items[i], visitor);
18550
+ const ci = _visit(Object.freeze(path19.concat([[field, i]])), token.items[i], visitor);
18159
18551
  if (typeof ci === "number")
18160
18552
  i = ci - 1;
18161
18553
  else if (ci === BREAK)
@@ -18166,10 +18558,10 @@ var require_cst_visit = __commonJS({
18166
18558
  }
18167
18559
  }
18168
18560
  if (typeof ctrl === "function" && field === "key")
18169
- ctrl = ctrl(item, path18);
18561
+ ctrl = ctrl(item, path19);
18170
18562
  }
18171
18563
  }
18172
- return typeof ctrl === "function" ? ctrl(item, path18) : ctrl;
18564
+ return typeof ctrl === "function" ? ctrl(item, path19) : ctrl;
18173
18565
  }
18174
18566
  exports.visit = visit;
18175
18567
  }
@@ -19869,7 +20261,7 @@ var require_public_api = __commonJS({
19869
20261
  });
19870
20262
 
19871
20263
  // ../../node_modules/yaml/dist/index.js
19872
- var require_dist2 = __commonJS({
20264
+ var require_dist3 = __commonJS({
19873
20265
  "../../node_modules/yaml/dist/index.js"(exports) {
19874
20266
  "use strict";
19875
20267
  var composer = require_composer();
@@ -19920,398 +20312,6 @@ var require_dist2 = __commonJS({
19920
20312
  }
19921
20313
  });
19922
20314
 
19923
- // ../../node_modules/dotenv/dist/index.cjs
19924
- var require_dist3 = __commonJS({
19925
- "../../node_modules/dotenv/dist/index.cjs"(exports, module) {
19926
- var j = (e, n) => () => {
19927
- try {
19928
- return n || e((n = { exports: {} }).exports, n), n.exports;
19929
- } catch (t) {
19930
- throw n = 0, t;
19931
- }
19932
- };
19933
- var k = j((xe, U) => {
19934
- function G(e) {
19935
- return typeof e == "string" ? !["false", "0", "no", "off", ""].includes(e.toLowerCase()) : !!e;
19936
- }
19937
- function Y(e = process.env) {
19938
- let n = {};
19939
- for (let t of ["ENCODING", "PATH", "QUIET", "DEBUG", "OVERRIDE", "FAST"]) {
19940
- let o = e[`DOTENV_${t}`] != null ? e[`DOTENV_${t}`] : e[`DOTENV_CONFIG_${t}`];
19941
- o != null && (n[t.toLowerCase()] = t === "ENCODING" || t === "PATH" ? o : G(o));
19942
- }
19943
- return n;
19944
- }
19945
- U.exports = { parseBoolean: G, optionsFromEnv: Y };
19946
- });
19947
- var N = j((ye, x) => {
19948
- var z = __require("fs"), I = __require("path"), Z = __require("os"), { URL: ee, fileURLToPath: te } = __require("url"), { parseBoolean: $, optionsFromEnv: B } = k(), re = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg, b = new Uint8Array(256);
19949
- for (let e = 48; e <= 57; e++) b[e] = 1;
19950
- for (let e = 65; e <= 90; e++) b[e] = 1;
19951
- for (let e = 97; e <= 122; e++) b[e] = 1;
19952
- b[45] = 1;
19953
- b[46] = 1;
19954
- b[95] = 1;
19955
- function ne(e) {
19956
- let n = {}, t = e.toString();
19957
- t = t.replace(/\r\n?/mg, `
19958
- `);
19959
- let o;
19960
- for (; (o = re.exec(t)) != null; ) {
19961
- let r = o[1], s = o[2] || "";
19962
- s = s.trim();
19963
- let i = s[0];
19964
- s = s.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), i === '"' && (s = s.replace(/\\n/g, `
19965
- `), s = s.replace(/\\r/g, "\r")), n[r] = s;
19966
- }
19967
- return n;
19968
- }
19969
- function w(e) {
19970
- return e <= 32 ? e === 32 || e >= 9 && e <= 13 : e >= 160 && (e === 160 || e === 5760 || e >= 8192 && e <= 8202 || e === 8232 || e === 8233 || e === 8239 || e === 8287 || e === 12288 || e === 65279);
19971
- }
19972
- function q(e) {
19973
- return e === 10 || e === 8232 || e === 8233;
19974
- }
19975
- function oe(e) {
19976
- let n = {}, t = typeof e == "string" ? e : e.toString();
19977
- t.indexOf("\r") !== -1 && (t = t.replace(/\r\n?/g, `
19978
- `));
19979
- let o = t.length, r = 0;
19980
- for (; r < o; ) {
19981
- let s = t.charCodeAt(r);
19982
- for (; r < o && w(s); ) r++, s = t.charCodeAt(r);
19983
- if (r >= o) break;
19984
- if (s === 35) {
19985
- for (; r < o && !q(t.charCodeAt(r)); ) r++;
19986
- continue;
19987
- }
19988
- let i = -1;
19989
- if (s === 101 && r + 6 < o && t.charCodeAt(r + 1) === 120 && t.charCodeAt(r + 2) === 112 && t.charCodeAt(r + 3) === 111 && t.charCodeAt(r + 4) === 114 && t.charCodeAt(r + 5) === 116) {
19990
- let v = t.charCodeAt(r + 6);
19991
- if (w(v)) {
19992
- let u = r + 7;
19993
- for (; u < o && w(t.charCodeAt(u)); ) u++;
19994
- b[t.charCodeAt(u)] && (i = r + 6, r = u);
19995
- } else s = t.charCodeAt(r);
19996
- }
19997
- let l = r, d = 0;
19998
- for (; r < o && (d = t.charCodeAt(r), b[d]); ) r++;
19999
- if (r === l) {
20000
- for (; r < o && !q(t.charCodeAt(r)); ) r++;
20001
- continue;
20002
- }
20003
- let h = t.slice(l, r), f = r;
20004
- if (r >= o && (d = 0), w(d)) do
20005
- r++, d = r < o ? t.charCodeAt(r) : 0;
20006
- while (w(d));
20007
- if (d === 61) r++;
20008
- else if (d === 58 && r === f && r + 1 < o && w(t.charCodeAt(r + 1))) r += 2;
20009
- else {
20010
- for (r = i === -1 ? f : i; r < o && !q(t.charCodeAt(r)); ) r++;
20011
- continue;
20012
- }
20013
- let c = r, a = r;
20014
- for (; a < o && w(t.charCodeAt(a)); ) a++;
20015
- let g = t.charCodeAt(a), p, y = false;
20016
- if (g === 39 || g === 34 || g === 96) {
20017
- let v = t[a], u = t.indexOf(v, a + 1), m = -1, C = -1;
20018
- for (; u !== -1; ) {
20019
- let O = t.charCodeAt(u - 1) === 92, E = u + 1;
20020
- for (; E < o && !q(t.charCodeAt(E)) && w(t.charCodeAt(E)); ) E++;
20021
- if ((E === o || q(t.charCodeAt(E)) || t.charCodeAt(E) === 35) && (m = u, C = E), !O) break;
20022
- u = t.indexOf(v, u + 1);
20023
- }
20024
- if (m !== -1) {
20025
- if (p = t.slice(a + 1, m), r = C, t.charCodeAt(r) === 35) for (; r < o && !q(t.charCodeAt(r)); ) r++;
20026
- y = true;
20027
- }
20028
- }
20029
- if (!y) {
20030
- let v = t.indexOf(`
20031
- `, c);
20032
- v === -1 && (v = o);
20033
- let u;
20034
- if (o < 4096) u = t.indexOf("#", c), (u === -1 || u > v) && (u = v);
20035
- else for (u = c; u < v && t.charCodeAt(u) !== 35; ) u++;
20036
- let m = c, C = u;
20037
- for (; m < C && w(t.charCodeAt(m)); ) m++;
20038
- for (; C > m && w(t.charCodeAt(C - 1)); ) C--;
20039
- let O = t.charCodeAt(m);
20040
- if (p = t.slice(m, C), p.includes("\u2028") || p.includes("\u2029") ? p = p.replace(/^(['"`])([\s\S]*)\1$/mg, "$2") : C - m >= 2 && (O === 39 || O === 34 || O === 96) && t.charCodeAt(C - 1) === O && (p = t.slice(m + 1, C - 1)), r = u, u < v) for (; r < o && !q(t.charCodeAt(r)); ) r++;
20041
- }
20042
- g === 34 && (y || a < r) && p.indexOf("\\") !== -1 && (p = p.replace(/\\n/g, `
20043
- `).replace(/\\r/g, "\r")), n[h] = p;
20044
- }
20045
- return n;
20046
- }
20047
- function se(e, n) {
20048
- return n && $(n.fast) ? oe(e) : ne(e);
20049
- }
20050
- function T(e) {
20051
- console.log(`\u2506 ${e}`);
20052
- }
20053
- function ie(e) {
20054
- console.error(`\u25C7 ${e}`);
20055
- }
20056
- function V(e) {
20057
- return e[0] === "~" ? I.join(Z.homedir(), e.slice(1)) : e;
20058
- }
20059
- function ce(e = {}) {
20060
- let n = { ...e };
20061
- for (let t of Object.keys(n)) n[t] === void 0 && delete n[t];
20062
- return { ...B(), ...n };
20063
- }
20064
- function ae(e) {
20065
- e = ce(e);
20066
- let n = I.resolve(process.cwd(), ".env"), t = "utf8", o = process.env;
20067
- e && e.processEnv != null && (o = e.processEnv);
20068
- let r = $(e && e.debug);
20069
- e && e.encoding ? t = e.encoding : r && T("no encoding is specified (UTF-8 is used by default)");
20070
- let s = [n];
20071
- if (e && e.path) if (!Array.isArray(e.path)) s = [V(e.path)];
20072
- else {
20073
- s = [];
20074
- for (let c of e.path) s.push(V(c));
20075
- }
20076
- let i, l = {}, d = { fast: e.fast };
20077
- for (let c of s) try {
20078
- let a = A.parse(z.readFileSync(c, { encoding: t }), d);
20079
- A.populate(l, a, e);
20080
- } catch (a) {
20081
- r && T(`failed to load ${c} ${a.message}`), i = a;
20082
- }
20083
- let h = A.populate(o, l, e), f = $(Object.prototype.hasOwnProperty.call(e, "quiet") ? e.quiet : B(o).quiet);
20084
- if (r || !f) {
20085
- let c = Object.keys(h).length, a = [];
20086
- for (let g of s) try {
20087
- let p = I.relative(process.cwd(), g instanceof ee ? te(g) : g);
20088
- a.push(p);
20089
- } catch (p) {
20090
- r && T(`failed to load ${g} ${p.message}`), i = p;
20091
- }
20092
- ie(`injected env (${c}) from ${a.join(",")}`);
20093
- }
20094
- return i ? { parsed: l, error: i } : { parsed: l };
20095
- }
20096
- function le(e) {
20097
- return A.configDotenv(e);
20098
- }
20099
- function fe(e, n, t = {}) {
20100
- let o = $(t && t.debug), r = $(t && t.override), s = {};
20101
- if (e === null || typeof e != "object" || n === null || typeof n != "object") {
20102
- let i = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
20103
- throw i.code = "OBJECT_REQUIRED", i;
20104
- }
20105
- for (let i of Object.keys(n)) Object.prototype.hasOwnProperty.call(e, i) ? (r === true && (e[i] = n[i], s[i] = n[i]), o && T(r === true ? `"${i}" is already defined and WAS overwritten` : `"${i}" is already defined and was NOT overwritten`)) : (e[i] = n[i], s[i] = n[i]);
20106
- return s;
20107
- }
20108
- var A = { configDotenv: ae, config: le, parse: se, populate: fe };
20109
- x.exports.configDotenv = A.configDotenv;
20110
- x.exports.config = A.config;
20111
- x.exports.parse = A.parse;
20112
- x.exports.populate = A.populate;
20113
- x.exports = A;
20114
- });
20115
- var M = j((Te, W) => {
20116
- var _ = __require("child_process"), ue = __require("fs"), L = __require("path");
20117
- function de(e) {
20118
- let n = ['"'], t = 0;
20119
- for (let o of e) {
20120
- if (o === "\\") {
20121
- t++;
20122
- continue;
20123
- }
20124
- o === '"' ? n.push("\\".repeat(t * 2 + 1), '"') : n.push("\\".repeat(t), o), t = 0;
20125
- }
20126
- return n.push("\\".repeat(t * 2), '"'), n.join("");
20127
- }
20128
- function H(e, n = 1) {
20129
- for (let t = 0; t < n; t++) {
20130
- let o = [];
20131
- for (let r of e) {
20132
- let s = r.charCodeAt(0), i = s >= 48 && s <= 57 || s >= 65 && s <= 90 || s >= 97 && s <= 122, l = "\\/:._-".includes(r);
20133
- !i && !l && s < 128 && o.push("^"), o.push(r);
20134
- }
20135
- e = o.join("");
20136
- }
20137
- return e;
20138
- }
20139
- function P(e, n) {
20140
- let t = Object.keys(e).reverse().find((o) => o.toUpperCase() === n);
20141
- return t === void 0 ? void 0 : e[t];
20142
- }
20143
- function pe(e, n, t) {
20144
- let o = (P(n, "PATHEXT") || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean), s = o.some((l) => e.toLowerCase().endsWith(l.toLowerCase())) ? ["", ...o] : [...o, ""], i = /[\\/]/.test(e) ? [t] : [t, ...(P(n, "PATH") || "").split(";")];
20145
- for (let l of i) for (let d of s) {
20146
- let h = L.resolve(t, l.replace(/^"|"$/g, ""), e + d);
20147
- try {
20148
- if (ue.statSync(h).isFile()) return h;
20149
- } catch {
20150
- }
20151
- }
20152
- }
20153
- function he(e, n, t) {
20154
- if (process.platform !== "win32") return _.spawn(e, n, t);
20155
- let o = t.env || process.env, r = pe(e, o, t.cwd || process.cwd());
20156
- if (r && /\.(?:exe|com)$/i.test(r)) return _.spawn(r, n, t);
20157
- let s = /\.(?:bat|cmd)$/i.test(r || e), i = [H(L.normalize(r || e))];
20158
- for (let d of n) i.push(H(de(d), s ? 2 : 1));
20159
- let l = i.join(" ");
20160
- return _.spawn(P(o, "COMSPEC") || "cmd.exe", ["/d", "/v:off", "/s", "/c", `"${l}"`], { ...t, windowsVerbatimArguments: true });
20161
- }
20162
- W.exports = he;
20163
- });
20164
- var X = j(($e, F) => {
20165
- var ge = __require("fs"), me = __require("os"), Q = __require("path"), ve = __require("child_process"), Ce = M(), R = N(), { optionsFromEnv: J } = k();
20166
- function D() {
20167
- console.log(["Usage: dotenv run [--help] [-q|--quiet] [--debug] [--override] [--fast] [-f|--file <paths>] [--] <command> [args...]", "", "Run a command with environment variables from a .env file.", "Place dotenv options before the command; all following arguments go to the command.", "", "Options:", " -f, --file <paths> .env paths, comma-separated or repeated (default: .env)", " -q, --quiet suppress the injected env message", " --debug enable debug logging", " --override override existing environment variables", " --fast use the faster character-scanner parser", "", "Environment variables (DOTENV_CONFIG_* names remain as fallbacks):", " DOTENV_PATH, DOTENV_ENCODING, DOTENV_QUIET,", " DOTENV_DEBUG, DOTENV_OVERRIDE,", " DOTENV_FAST"].join(`
20168
- `));
20169
- }
20170
- function we(e) {
20171
- let n = [], t = false, o, r, s, i, l = -1;
20172
- for (let h = 0; h < e.length; h++) {
20173
- let f = e[h];
20174
- if (f === "--") {
20175
- l = h + 1;
20176
- break;
20177
- }
20178
- if (f === "--help" || f === "-h") return { help: true };
20179
- if (f === "--quiet" || f === "-q") {
20180
- o = true;
20181
- continue;
20182
- }
20183
- if (f === "--debug") {
20184
- r = true;
20185
- continue;
20186
- }
20187
- if (f === "--override") {
20188
- s = true;
20189
- continue;
20190
- }
20191
- if (f === "--fast") {
20192
- i = true;
20193
- continue;
20194
- }
20195
- if (f === "-f" || f === "--file" || f.startsWith("-f=") || f.startsWith("--file=")) {
20196
- let c = f.indexOf("="), a = c === -1 ? f : f.slice(0, c), g = c === -1 ? e[++h] : f.slice(c + 1);
20197
- if (!g || g === "--") return { error: `${a} requires a path` };
20198
- let p = g.split(",").map((y) => y.trim()).filter(Boolean);
20199
- if (p.length === 0) return { error: `${a} requires a path` };
20200
- n.push(...p), t = true;
20201
- continue;
20202
- }
20203
- if (f.startsWith("-")) return { error: `unknown option: ${f}` };
20204
- l = h;
20205
- break;
20206
- }
20207
- let d = l === -1 ? [] : e.slice(l);
20208
- return { paths: n, pathSet: t, quiet: o, debug: r, override: s, fast: i, command: d };
20209
- }
20210
- function Ae(e) {
20211
- return e[0] === "~" ? Q.join(me.homedir(), e.slice(1)) : e;
20212
- }
20213
- function Ee(e) {
20214
- let n = J(), t = { encoding: n.encoding || "utf8", quiet: n.quiet, debug: n.debug === true, override: n.override === true, fast: n.fast === true, paths: [".env"], defaultPath: true };
20215
- return n.path != null && (t.paths = [n.path], t.defaultPath = false), e.pathSet && (t.paths = e.paths, t.defaultPath = false), e.quiet != null && (t.quiet = e.quiet), e.debug != null && (t.debug = e.debug), e.override != null && (t.override = e.override), e.fast != null && (t.fast = e.fast), t;
20216
- }
20217
- function be(e) {
20218
- let n = {}, t = [], o = { override: e.override, debug: e.debug };
20219
- for (let s of e.paths) {
20220
- let i = Q.resolve(process.cwd(), Ae(s));
20221
- try {
20222
- let l = R.parse(ge.readFileSync(i, { encoding: e.encoding }), { fast: e.fast });
20223
- R.populate(n, l, o), t.push(s);
20224
- } catch (l) {
20225
- if (e.debug && console.log(`\u2506 failed to load ${s} ${l.message}`), !(e.defaultPath && l.code === "ENOENT")) throw l;
20226
- }
20227
- }
20228
- return { injected: R.populate(process.env, n, o), loadedPaths: t };
20229
- }
20230
- function K(e) {
20231
- let n = e[0];
20232
- if (n === "--help" || n === "-h") {
20233
- D();
20234
- return;
20235
- }
20236
- if (n !== "run") {
20237
- D(), process.exitCode = 1;
20238
- return;
20239
- }
20240
- let t = we(e.slice(1));
20241
- if (t.help) {
20242
- D();
20243
- return;
20244
- }
20245
- if (t.error) {
20246
- console.error(`dotenv: ${t.error}`), D(), process.exitCode = 1;
20247
- return;
20248
- }
20249
- if (t.command.length === 0) {
20250
- D(), process.exitCode = 1;
20251
- return;
20252
- }
20253
- let o = Ee(t);
20254
- try {
20255
- let c = be(o);
20256
- if (!(o.quiet == null ? J().quiet : o.quiet)) {
20257
- let g = `\u25C7 injected env (${Object.keys(c.injected).length})`;
20258
- c.loadedPaths.length > 0 && (g += ` from ${c.loadedPaths.join(", ")}`), console.error(g);
20259
- }
20260
- } catch (c) {
20261
- console.error(`dotenv: ${c.message}`), process.exitCode = 1;
20262
- return;
20263
- }
20264
- let r = !!process.stdin.isTTY, s = process.platform !== "win32" && !r, i = Ce(t.command[0], t.command.slice(1), { stdio: "inherit", detached: s }), l = /* @__PURE__ */ new Map(), d = 0;
20265
- function h(c) {
20266
- if (!(!i.pid || i.exitCode !== null || i.signalCode !== null)) {
20267
- if (process.platform === "win32") {
20268
- ve.spawnSync("taskkill", ["/pid", String(i.pid), "/T", "/F"], { stdio: "ignore" });
20269
- return;
20270
- }
20271
- try {
20272
- process.kill(s ? -i.pid : i.pid, c);
20273
- } catch (a) {
20274
- if (a.code !== "ESRCH") throw a;
20275
- }
20276
- }
20277
- }
20278
- function f() {
20279
- for (let [c, a] of l) process.removeListener(c, a);
20280
- }
20281
- for (let c of ["SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT"]) {
20282
- let a = () => {
20283
- if (c === "SIGINT") {
20284
- if (d++, r && process.platform !== "win32" && d === 1) return;
20285
- if (d > 1) {
20286
- h(d === 2 ? "SIGTERM" : "SIGKILL");
20287
- return;
20288
- }
20289
- }
20290
- h(c);
20291
- };
20292
- l.set(c, a), process.on(c, a);
20293
- }
20294
- i.on("error", function(c) {
20295
- f(), console.error(`dotenv: ${c.message}`), process.exitCode = 1;
20296
- }), i.on("exit", function(c, a) {
20297
- f(), typeof c == "number" ? process.exit(c) : (setInterval(() => {
20298
- }, 1e3), process.kill(process.pid, a));
20299
- });
20300
- }
20301
- F.exports = K;
20302
- __require.main === F && K(process.argv.slice(2));
20303
- });
20304
- var S = N();
20305
- var qe = X();
20306
- module.exports = S;
20307
- module.exports.config = S.config;
20308
- module.exports.configDotenv = S.configDotenv;
20309
- module.exports.parse = S.parse;
20310
- module.exports.populate = S.populate;
20311
- __require.main === module && qe(process.argv.slice(2));
20312
- }
20313
- });
20314
-
20315
20315
  // ../../node_modules/semver/internal/constants.js
20316
20316
  var require_constants = __commonJS({
20317
20317
  "../../node_modules/semver/internal/constants.js"(exports, module) {
@@ -22307,9 +22307,7 @@ var require_semver2 = __commonJS({
22307
22307
  });
22308
22308
 
22309
22309
  // ../argent-mcp/src/mcp-server.ts
22310
- import { appendFile, mkdir as mkdir5 } from "node:fs/promises";
22311
- import { dirname as dirname11 } from "node:path";
22312
- import { homedir as homedir5 } from "node:os";
22310
+ import { join as join19 } from "node:path";
22313
22311
  import { setTimeout as sleep } from "node:timers/promises";
22314
22312
 
22315
22313
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
@@ -22552,10 +22550,10 @@ function mergeDefs(...defs) {
22552
22550
  function cloneDef(schema) {
22553
22551
  return mergeDefs(schema._zod.def);
22554
22552
  }
22555
- function getElementAtPath(obj, path18) {
22556
- if (!path18)
22553
+ function getElementAtPath(obj, path19) {
22554
+ if (!path19)
22557
22555
  return obj;
22558
- return path18.reduce((acc, key) => acc?.[key], obj);
22556
+ return path19.reduce((acc, key) => acc?.[key], obj);
22559
22557
  }
22560
22558
  function promiseAllObject(promisesObj) {
22561
22559
  const keys = Object.keys(promisesObj);
@@ -22895,11 +22893,11 @@ function explicitlyAborted(x, startIndex = 0) {
22895
22893
  }
22896
22894
  return false;
22897
22895
  }
22898
- function prefixIssues(path18, issues) {
22896
+ function prefixIssues(path19, issues) {
22899
22897
  return issues.map((iss) => {
22900
22898
  var _a3;
22901
22899
  (_a3 = iss).path ?? (_a3.path = []);
22902
- iss.path.unshift(path18);
22900
+ iss.path.unshift(path19);
22903
22901
  return iss;
22904
22902
  });
22905
22903
  }
@@ -23357,16 +23355,16 @@ function flattenError(error2, mapper = (issue2) => issue2.message) {
23357
23355
  }
23358
23356
  function formatError(error2, mapper = (issue2) => issue2.message) {
23359
23357
  const fieldErrors = { _errors: [] };
23360
- const processError = (error3, path18 = []) => {
23358
+ const processError = (error3, path19 = []) => {
23361
23359
  for (const issue2 of error3.issues) {
23362
23360
  if (issue2.code === "invalid_union" && issue2.errors.length) {
23363
- issue2.errors.map((issues) => processError({ issues }, [...path18, ...issue2.path]));
23361
+ issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
23364
23362
  } else if (issue2.code === "invalid_key") {
23365
- processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
23363
+ processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
23366
23364
  } else if (issue2.code === "invalid_element") {
23367
- processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
23365
+ processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
23368
23366
  } else {
23369
- const fullpath = [...path18, ...issue2.path];
23367
+ const fullpath = [...path19, ...issue2.path];
23370
23368
  if (fullpath.length === 0) {
23371
23369
  fieldErrors._errors.push(mapper(issue2));
23372
23370
  } else {
@@ -25666,7 +25664,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
25666
25664
  var NONE = 0;
25667
25665
  var ASSUMED = 1;
25668
25666
  var PROVEN = 2;
25669
- function isRecursive(inst, stack, resolve12) {
25667
+ function isRecursive(inst, stack, resolve13) {
25670
25668
  const cached2 = recursive.get(inst);
25671
25669
  if (cached2 !== void 0)
25672
25670
  return cached2 ? PROVEN : NONE;
@@ -25676,7 +25674,7 @@ function isRecursive(inst, stack, resolve12) {
25676
25674
  let result = NONE;
25677
25675
  const check = (child) => {
25678
25676
  if (result !== PROVEN && child?._zod) {
25679
- const answer = isRecursive(child, stack, resolve12);
25677
+ const answer = isRecursive(child, stack, resolve13);
25680
25678
  if (answer > result)
25681
25679
  result = answer;
25682
25680
  }
@@ -25687,7 +25685,7 @@ function isRecursive(inst, stack, resolve12) {
25687
25685
  const desc = Object.getOwnPropertyDescriptor(sh, key);
25688
25686
  if (spread && !desc.enumerable)
25689
25687
  continue;
25690
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve12) : NONE;
25688
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve13) : NONE;
25691
25689
  if (child > answer)
25692
25690
  answer = child;
25693
25691
  }
@@ -25751,7 +25749,7 @@ function isRecursive(inst, stack, resolve12) {
25751
25749
  break;
25752
25750
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
25753
25751
  case "lazy": {
25754
- const inner = def._cachedInner ?? (resolve12 ? inst._zod.innerType : void 0);
25752
+ const inner = def._cachedInner ?? (resolve13 ? inst._zod.innerType : void 0);
25755
25753
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
25756
25754
  break;
25757
25755
  }
@@ -30329,12 +30327,12 @@ var StdioServerTransport = class {
30329
30327
  this.onclose?.();
30330
30328
  }
30331
30329
  send(message) {
30332
- return new Promise((resolve12) => {
30330
+ return new Promise((resolve13) => {
30333
30331
  const json = serializeMessage(message);
30334
30332
  if (this._stdout.write(json)) {
30335
- resolve12();
30333
+ resolve13();
30336
30334
  } else {
30337
- this._stdout.once("drain", resolve12);
30335
+ this._stdout.once("drain", resolve13);
30338
30336
  }
30339
30337
  });
30340
30338
  }
@@ -30954,7 +30952,7 @@ var Protocol = class {
30954
30952
  return;
30955
30953
  }
30956
30954
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
30957
- await new Promise((resolve12) => setTimeout(resolve12, pollInterval));
30955
+ await new Promise((resolve13) => setTimeout(resolve13, pollInterval));
30958
30956
  options?.signal?.throwIfAborted();
30959
30957
  }
30960
30958
  } catch (error2) {
@@ -30971,7 +30969,7 @@ var Protocol = class {
30971
30969
  */
30972
30970
  request(request, resultSchema, options) {
30973
30971
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
30974
- return new Promise((resolve12, reject) => {
30972
+ return new Promise((resolve13, reject) => {
30975
30973
  const earlyReject = (error2) => {
30976
30974
  reject(error2);
30977
30975
  };
@@ -31049,7 +31047,7 @@ var Protocol = class {
31049
31047
  if (!parseResult.success) {
31050
31048
  reject(parseResult.error);
31051
31049
  } else {
31052
- resolve12(parseResult.data);
31050
+ resolve13(parseResult.data);
31053
31051
  }
31054
31052
  } catch (error2) {
31055
31053
  reject(error2);
@@ -31311,12 +31309,12 @@ var Protocol = class {
31311
31309
  }
31312
31310
  } catch {
31313
31311
  }
31314
- return new Promise((resolve12, reject) => {
31312
+ return new Promise((resolve13, reject) => {
31315
31313
  if (signal.aborted) {
31316
31314
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
31317
31315
  return;
31318
31316
  }
31319
- const timeoutId = setTimeout(resolve12, interval);
31317
+ const timeoutId = setTimeout(resolve13, interval);
31320
31318
  signal.addEventListener("abort", () => {
31321
31319
  clearTimeout(timeoutId);
31322
31320
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -32098,505 +32096,36 @@ var Server = class extends Protocol {
32098
32096
 
32099
32097
  // ../argent-tools-client/src/launcher.ts
32100
32098
  import * as net from "node:net";
32101
- import * as fs from "node:fs";
32102
- import * as path from "node:path";
32099
+ import * as fs5 from "node:fs";
32100
+ import * as path7 from "node:path";
32103
32101
  import * as readline from "node:readline";
32104
- import { homedir } from "node:os";
32105
32102
  import { spawn, execFileSync } from "node:child_process";
32106
32103
  import { createHash, randomBytes } from "node:crypto";
32107
32104
  import { mkdir, writeFile, readFile, readdir, unlink, rename, chmod } from "node:fs/promises";
32108
- var STATE_DIR = path.join(homedir(), ".argent");
32109
- var STATE_FILE = path.join(STATE_DIR, "tool-server.json");
32110
- var LOG_FILE = path.join(STATE_DIR, "tool-server.log");
32111
- var LOCK_FILE = path.join(STATE_DIR, "tool-server.lock");
32112
- var AUTH_TOKEN_BYTES = 32;
32113
- var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
32114
- var AUTOSPAWN_IDLE_TIMEOUT_MINUTES = 30;
32115
- var AUTOSPAWN_HOST = "127.0.0.1";
32116
- function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
32117
- const env = {
32118
- ...baseEnv,
32119
- ARGENT_PORT: String(port),
32120
- ARGENT_SIMULATOR_SERVER_DIR: paths.simulatorServerDir,
32121
- ARGENT_NATIVE_DEVTOOLS_DIR: paths.nativeDevtoolsDir
32122
- };
32123
- if (options.host !== void 0) env.ARGENT_HOST = options.host;
32124
- if (options.idleTimeoutMinutes !== void 0) {
32125
- env.ARGENT_IDLE_TIMEOUT_MINUTES = String(options.idleTimeoutMinutes);
32126
- }
32127
- env[AUTH_TOKEN_ENV] = options.token ?? "";
32128
- if (paths.installKind) env.ARGENT_INSTALL_KIND = paths.installKind;
32129
- if (paths.installProjectRoot) env.ARGENT_PROJECT_ROOT = paths.installProjectRoot;
32130
- return env;
32131
- }
32132
- function generateToken() {
32133
- return randomBytes(AUTH_TOKEN_BYTES).toString("hex");
32134
- }
32135
- function findFreePort() {
32136
- return new Promise((resolve12, reject) => {
32137
- const srv = net.createServer();
32138
- srv.listen(0, "127.0.0.1", () => {
32139
- const addr = srv.address();
32140
- if (!addr || typeof addr !== "object") {
32141
- srv.close(() => reject(new Error("Could not bind to find free port")));
32142
- return;
32143
- }
32144
- const port = addr.port;
32145
- srv.close((err) => {
32146
- if (err) reject(err);
32147
- else resolve12(port);
32148
- });
32149
- });
32150
- srv.on("error", reject);
32151
- });
32152
- }
32153
- function isVersionNewer(a, b) {
32154
- const parse4 = (v) => {
32155
- const [core = "", ...preParts] = v.split("+")[0].split("-");
32156
- const nums = core.split(".").map((n) => Number.parseInt(n, 10));
32157
- if (nums.length === 0 || nums.some((n) => Number.isNaN(n))) return null;
32158
- return { nums, pre: preParts.length > 0 ? preParts.join("-").split(".") : [] };
32159
- };
32160
- const pa = parse4(a);
32161
- const pb = parse4(b);
32162
- if (!pa || !pb) return false;
32163
- for (let i = 0; i < 3; i++) {
32164
- const x = pa.nums[i] ?? 0;
32165
- const y = pb.nums[i] ?? 0;
32166
- if (x !== y) return x > y;
32167
- }
32168
- if (pa.pre.length === 0 && pb.pre.length === 0) return false;
32169
- if (pa.pre.length === 0) return true;
32170
- if (pb.pre.length === 0) return false;
32171
- for (let i = 0; i < Math.max(pa.pre.length, pb.pre.length); i++) {
32172
- const x = pa.pre[i];
32173
- const y = pb.pre[i];
32174
- if (x === void 0) return false;
32175
- if (y === void 0) return true;
32176
- if (x === y) continue;
32177
- const xn = /^\d+$/.test(x) ? Number.parseInt(x, 10) : null;
32178
- const yn = /^\d+$/.test(y) ? Number.parseInt(y, 10) : null;
32179
- if (xn !== null && yn !== null) return xn > yn;
32180
- if (xn !== null) return false;
32181
- if (yn !== null) return true;
32182
- return x > y;
32183
- }
32184
- return false;
32185
- }
32186
- function readBundlePackageVersion(bundlePath) {
32187
- try {
32188
- const pkg = JSON.parse(
32189
- fs.readFileSync(path.join(path.dirname(bundlePath), "..", "package.json"), "utf8")
32190
- );
32191
- return typeof pkg.version === "string" ? pkg.version : void 0;
32192
- } catch {
32193
- return void 0;
32194
- }
32195
- }
32196
- function isProcessAlive(pid) {
32197
- try {
32198
- process.kill(pid, 0);
32199
- return true;
32200
- } catch {
32201
- return false;
32202
- }
32203
- }
32204
- function healthCheckHost(host) {
32205
- if (host === "0.0.0.0" || host === "") return "127.0.0.1";
32206
- if (host === "::" || host === "::0") return "::1";
32207
- return host;
32208
- }
32209
- function formatUrl(host, port) {
32210
- const h = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
32211
- return `http://${h}:${port}`;
32212
- }
32213
- function authHeaders(token) {
32214
- return token ? { Authorization: `Bearer ${token}` } : {};
32215
- }
32216
- async function isToolsServerHealthy(port, host = "127.0.0.1", timeoutMs = 2e3, token) {
32217
- const controller = new AbortController();
32218
- const timer = setTimeout(() => controller.abort(), timeoutMs);
32219
- try {
32220
- const res = await fetch(`${formatUrl(healthCheckHost(host), port)}/tools`, {
32221
- signal: controller.signal,
32222
- headers: authHeaders(token)
32223
- });
32224
- await res.body?.cancel().catch(() => {
32225
- });
32226
- return res.ok;
32227
- } catch {
32228
- return false;
32229
- } finally {
32230
- clearTimeout(timer);
32231
- }
32232
- }
32233
- var SPAWN_READY_TIMEOUT_MS = 15e3;
32234
- function killSpawnedChild(child, pid) {
32235
- try {
32236
- process.kill(-pid, "SIGKILL");
32237
- } catch {
32238
- try {
32239
- child.kill("SIGKILL");
32240
- } catch {
32241
- }
32242
- }
32243
- }
32244
- function resolveToolsServerNode() {
32245
- const { bun, deno, electron } = process.versions;
32246
- return !(bun || deno || electron) && fs.existsSync(process.execPath) ? process.execPath : "node";
32247
- }
32248
- function spawnToolsServer(paths, port, options = {}) {
32249
- return new Promise((resolve12, reject) => {
32250
- let logFd;
32251
- try {
32252
- fs.mkdirSync(STATE_DIR, { recursive: true });
32253
- logFd = fs.openSync(LOG_FILE, "a");
32254
- } catch {
32255
- logFd = fs.openSync("/dev/null", "w");
32256
- }
32257
- const nodeBin = resolveToolsServerNode();
32258
- const child = spawn(nodeBin, [paths.bundlePath, "start"], {
32259
- detached: true,
32260
- stdio: ["ignore", "pipe", logFd],
32261
- env: buildToolsServerEnv(paths, port, process.env, options)
32262
- });
32263
- fs.closeSync(logFd);
32264
- child.unref();
32265
- const pid = child.pid;
32266
- if (!pid) {
32267
- child.once(
32268
- "error",
32269
- (err) => reject(
32270
- new Error(
32271
- err.code === "ENOENT" && nodeBin === "node" ? "Could not start the argent tool-server: `node` was not found on PATH. Install Node.js 22.18+ or add it to PATH." : `Could not start the argent tool-server: ${err.message}`
32272
- )
32273
- )
32274
- );
32275
- return;
32276
- }
32277
- let settled = false;
32278
- const settle2 = (fn) => {
32279
- if (settled) return;
32280
- settled = true;
32281
- fn();
32282
- };
32283
- const rejectAndKill = (err) => settle2(() => {
32284
- killSpawnedChild(child, pid);
32285
- reject(err);
32286
- });
32287
- const rl = readline.createInterface({ input: child.stdout });
32288
- rl.on("line", (line) => {
32289
- const match = line.match(/Tools server listening on http:\/\/.+:(\d+)/);
32290
- if (match) {
32291
- const actualPort = parseInt(match[1], 10);
32292
- rl.close();
32293
- child.stdout?.resume();
32294
- child.stdout?.unref?.();
32295
- settle2(() => resolve12({ port: actualPort, pid }));
32296
- }
32297
- });
32298
- child.on("error", (err) => {
32299
- rl.close();
32300
- rejectAndKill(err);
32301
- });
32302
- child.on("exit", (code) => {
32303
- rl.close();
32304
- settle2(() => reject(new Error(`tool-server exited with code ${code} before becoming ready`)));
32305
- });
32306
- const timer = setTimeout(() => {
32307
- rl.close();
32308
- rejectAndKill(new Error("Timed out waiting for tools server to become ready"));
32309
- }, options.readyTimeoutMs ?? SPAWN_READY_TIMEOUT_MS);
32310
- rl.on("close", () => clearTimeout(timer));
32311
- });
32312
- }
32313
- function stateFileForBundle(bundlePath) {
32314
- const key = createHash("sha256").update(bundlePath).digest("hex").slice(0, 12);
32315
- return path.join(STATE_DIR, `tool-server-${key}.json`);
32316
- }
32317
- async function readStateFile(file) {
32318
- try {
32319
- const raw2 = await readFile(file, "utf8");
32320
- return JSON.parse(raw2);
32321
- } catch {
32322
- return null;
32323
- }
32324
- }
32325
- async function readToolsServerState(bundlePath) {
32326
- if (bundlePath === void 0) return readStateFile(STATE_FILE);
32327
- const own2 = await readStateFile(stateFileForBundle(bundlePath));
32328
- if (own2) return own2;
32329
- const legacy = await readStateFile(STATE_FILE);
32330
- return legacy && legacy.bundlePath === bundlePath ? legacy : null;
32331
- }
32332
- async function writeToolsServerState(state) {
32333
- const target = stateFileForBundle(state.bundlePath);
32334
- await mkdir(STATE_DIR, { recursive: true });
32335
- const tmp = `${target}.${process.pid}.tmp`;
32336
- try {
32337
- await writeFile(tmp, JSON.stringify(state, null, 2) + "\n", {
32338
- encoding: "utf8",
32339
- mode: 384
32340
- });
32341
- await chmod(tmp, 384);
32342
- await rename(tmp, target);
32343
- } catch (err) {
32344
- await unlink(tmp).catch(() => {
32345
- });
32346
- throw err;
32347
- }
32348
- }
32349
- async function clearToolsServerState(bundlePath) {
32350
- const files = [STATE_FILE];
32351
- if (bundlePath !== void 0) {
32352
- files[0] = stateFileForBundle(bundlePath);
32353
- const legacy = await readStateFile(STATE_FILE);
32354
- if (legacy && legacy.bundlePath === bundlePath) files.push(STATE_FILE);
32355
- }
32356
- for (const file of files) {
32357
- try {
32358
- await unlink(file);
32359
- } catch {
32360
- }
32361
- }
32362
- }
32363
- var STATE_FILE_RE = /^tool-server(-[0-9a-f]{12})?\.json$/;
32364
- async function readAllToolsServerStates() {
32365
- let names;
32366
- try {
32367
- names = await readdir(STATE_DIR);
32368
- } catch {
32369
- return [];
32370
- }
32371
- const out = [];
32372
- for (const name of names) {
32373
- if (!STATE_FILE_RE.test(name)) continue;
32374
- const file = path.join(STATE_DIR, name);
32375
- const state = await readStateFile(file);
32376
- if (state) out.push({ file, state });
32377
- }
32378
- return out;
32379
- }
32380
- async function sweepDeadStateFiles() {
32381
- for (const { file } of await readAllToolsServerStates()) {
32382
- if (file === STATE_FILE) continue;
32383
- const fresh = await readStateFile(file);
32384
- if (!fresh) continue;
32385
- if (!isProcessAlive(fresh.pid)) {
32386
- await unlink(file).catch(() => {
32387
- });
32388
- continue;
32389
- }
32390
- if (fs.existsSync(fresh.bundlePath)) continue;
32391
- if (!couldBeOurToolServer(fresh.pid, fresh.bundlePath)) continue;
32392
- await unlink(file).catch(() => {
32393
- });
32394
- void terminatePid(fresh.pid, () => couldBeOurToolServer(fresh.pid, fresh.bundlePath));
32395
- }
32396
- }
32397
- var readState = readToolsServerState;
32398
- var writeState = writeToolsServerState;
32399
- var SIGTERM_GRACE_MS = 6e3;
32400
- var SIGKILL_GRACE_MS = 1e3;
32401
- var KILL_POLL_MS = 100;
32402
- async function waitForExit(pid, timeoutMs) {
32403
- const deadline = Date.now() + timeoutMs;
32404
- while (Date.now() < deadline) {
32405
- if (!isProcessAlive(pid)) return true;
32406
- await new Promise((r) => setTimeout(r, KILL_POLL_MS));
32407
- }
32408
- return !isProcessAlive(pid);
32409
- }
32410
- async function terminatePid(pid, stillOurs) {
32411
- if (!isProcessAlive(pid)) return;
32412
- if (stillOurs && !stillOurs()) return;
32413
- try {
32414
- process.kill(pid, "SIGTERM");
32415
- } catch {
32416
- return;
32417
- }
32418
- if (await waitForExit(pid, SIGTERM_GRACE_MS)) return;
32419
- if (stillOurs && !(isProcessAlive(pid) && stillOurs())) return;
32420
- try {
32421
- process.kill(pid, "SIGKILL");
32422
- } catch {
32423
- return;
32424
- }
32425
- await waitForExit(pid, SIGKILL_GRACE_MS);
32426
- }
32427
- var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs.existsSync(p)) ?? "ps";
32428
- var PS_WIDTH_FLAGS = ["-ww"];
32429
- var PS_LOCALE = process.platform === "darwin" ? "en_US.UTF-8" : "C.UTF-8";
32430
- function readProcessCommandLine(pid, flags = PS_WIDTH_FLAGS, env = { ...process.env, LC_ALL: PS_LOCALE }) {
32431
- return execFileSync(PS_BIN, [...flags, "-p", String(pid), "-o", "command="], {
32432
- env,
32433
- encoding: "utf8",
32434
- timeout: 2e3,
32435
- // A recycled pid can sit on a process with an argv past Node's 1 MiB exec
32436
- // default, where the overrun surfaces as ENOBUFS instead of a command line.
32437
- // Same ceiling as tool-server's vega-process ps probes.
32438
- maxBuffer: 16 * 1024 * 1024,
32439
- // Piping ps's stderr is what puts a rejected flag ("ps: invalid option --
32440
- // 'w'") into the thrown error's message.
32441
- stdio: ["ignore", "pipe", "pipe"]
32442
- }).trim();
32443
- }
32444
- function couldBeOurToolServer(pid, marker) {
32445
- if (!marker) return false;
32446
- if (process.platform === "win32") return true;
32447
- const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
32448
- const ours = new RegExp(`(?:^|[\\t\\n\\v\\f\\r ])${escaped} start(?:[\\t\\n\\v\\f\\r ]|$)`);
32449
- const nonAscii = [...marker].some((c) => c.charCodeAt(0) > 127);
32450
- let failure2;
32451
- for (const env of [void 0, process.env]) {
32452
- try {
32453
- if (ours.test(readProcessCommandLine(pid, PS_WIDTH_FLAGS, env))) return true;
32454
- failure2 = void 0;
32455
- if (!nonAscii) break;
32456
- } catch (err) {
32457
- failure2 = String(err);
32458
- if (err.code === "ETIMEDOUT") break;
32459
- }
32460
- }
32461
- if (failure2 !== void 0) {
32462
- process.stderr.write(
32463
- `[launcher] ps could not read pid ${pid}'s command line; leaving it alone: ${failure2}
32464
- `
32465
- );
32466
- }
32467
- return false;
32468
- }
32469
- var LOCK_WAIT_TIMEOUT_MS = 3e4;
32470
- var LOCK_STALE_MS = 45e3;
32471
- var LOCK_POLL_MS = 100;
32472
- function spawnLockIsStale() {
32473
- try {
32474
- const { pid, ts } = JSON.parse(fs.readFileSync(LOCK_FILE, "utf8"));
32475
- if (typeof pid === "number" && pid > 0 && !isProcessAlive(pid)) return true;
32476
- if (typeof ts === "number" && Date.now() - ts > LOCK_STALE_MS) return true;
32477
- return false;
32478
- } catch {
32479
- try {
32480
- return Date.now() - fs.statSync(LOCK_FILE).mtimeMs > LOCK_STALE_MS;
32481
- } catch {
32482
- return true;
32483
- }
32484
- }
32485
- }
32486
- async function acquireSpawnLock() {
32487
- try {
32488
- fs.mkdirSync(STATE_DIR, { recursive: true });
32489
- } catch {
32490
- return null;
32491
- }
32492
- const nonce = randomBytes(8).toString("hex");
32493
- const deadline = Date.now() + LOCK_WAIT_TIMEOUT_MS;
32494
- for (; ; ) {
32495
- try {
32496
- const fd = fs.openSync(LOCK_FILE, "wx");
32497
- try {
32498
- fs.writeSync(fd, JSON.stringify({ pid: process.pid, nonce, ts: Date.now() }));
32499
- } finally {
32500
- fs.closeSync(fd);
32501
- }
32502
- let released = false;
32503
- return {
32504
- release: () => {
32505
- if (released) return;
32506
- released = true;
32507
- try {
32508
- const cur = JSON.parse(fs.readFileSync(LOCK_FILE, "utf8"));
32509
- if (cur.pid === process.pid && cur.nonce === nonce) fs.unlinkSync(LOCK_FILE);
32510
- } catch {
32511
- }
32512
- }
32513
- };
32514
- } catch (err) {
32515
- if (err.code !== "EEXIST") return null;
32516
- if (spawnLockIsStale()) {
32517
- try {
32518
- fs.unlinkSync(LOCK_FILE);
32519
- } catch {
32520
- }
32521
- if (!fs.existsSync(LOCK_FILE)) continue;
32522
- }
32523
- if (Date.now() >= deadline) return null;
32524
- await new Promise((r) => setTimeout(r, LOCK_POLL_MS));
32525
- }
32526
- }
32105
+
32106
+ // ../configuration-core/src/flags.ts
32107
+ import * as fs from "node:fs";
32108
+ import * as path2 from "node:path";
32109
+
32110
+ // ../configuration-core/src/home.ts
32111
+ import * as os from "node:os";
32112
+ import * as path from "node:path";
32113
+ var ARGENT_HOME_DIR_ENV = "ARGENT_HOME_DIR";
32114
+ function nonEmpty(value) {
32115
+ if (value == void 0) return null;
32116
+ const trimmed = value.trim();
32117
+ return trimmed === "" ? null : value;
32527
32118
  }
32528
- async function reusableHandle(state, wantBundlePath, wantVersion) {
32529
- if (!state || !isProcessAlive(state.pid)) return null;
32530
- if (wantBundlePath !== void 0 && state.bundlePath !== wantBundlePath) return null;
32531
- if (wantBundlePath !== void 0 && state.version !== void 0) {
32532
- const diskVersion = readBundlePackageVersion(wantBundlePath);
32533
- if (diskVersion !== void 0) {
32534
- if (diskVersion !== state.version) return null;
32535
- } else if (wantVersion !== void 0 && state.version !== wantVersion && isVersionNewer(wantVersion, state.version)) {
32536
- return null;
32537
- }
32538
- }
32539
- const host = state.host ?? "127.0.0.1";
32540
- const healthy = await isToolsServerHealthy(state.port, host, 2e3, state.token);
32541
- if (!healthy) return null;
32542
- return { url: formatUrl(healthCheckHost(host), state.port), token: state.token ?? "" };
32119
+ function resolveHomeDir(options = {}) {
32120
+ if (options.homeDir) return options.homeDir;
32121
+ return process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
32543
32122
  }
32544
- async function ensureToolsServer(paths) {
32545
- const fast = await reusableHandle(
32546
- await readState(paths.bundlePath),
32547
- paths.bundlePath,
32548
- paths.version
32549
- );
32550
- if (fast) return fast;
32551
- const lock = await acquireSpawnLock();
32552
- try {
32553
- const state = await readState(paths.bundlePath);
32554
- const reuse = await reusableHandle(state, paths.bundlePath, paths.version);
32555
- if (reuse) return reuse;
32556
- if (state && state.managed === "autospawn" && state.bundlePath === paths.bundlePath && isProcessAlive(state.pid) && couldBeOurToolServer(state.pid, state.bundlePath)) {
32557
- await terminatePid(state.pid, () => couldBeOurToolServer(state.pid, state.bundlePath));
32558
- }
32559
- await clearToolsServerState(paths.bundlePath);
32560
- await sweepDeadStateFiles();
32561
- if (!fs.existsSync(paths.bundlePath)) {
32562
- throw new Error(
32563
- `The argent install serving this session is gone from disk (${paths.bundlePath}) \u2014 it was likely updated or removed. Restart the editor's MCP connection to reconnect.`
32564
- );
32565
- }
32566
- const diskVersion = readBundlePackageVersion(paths.bundlePath) ?? paths.version;
32567
- const token = generateToken();
32568
- const port = await findFreePort();
32569
- const { port: actualPort, pid } = await spawnToolsServer(paths, port, {
32570
- token,
32571
- host: AUTOSPAWN_HOST,
32572
- idleTimeoutMinutes: AUTOSPAWN_IDLE_TIMEOUT_MINUTES
32573
- });
32574
- await writeState({
32575
- port: actualPort,
32576
- pid,
32577
- startedAt: (/* @__PURE__ */ new Date()).toISOString(),
32578
- bundlePath: paths.bundlePath,
32579
- version: diskVersion,
32580
- host: AUTOSPAWN_HOST,
32581
- token,
32582
- managed: "autospawn"
32583
- });
32584
- return { url: formatUrl(AUTOSPAWN_HOST, actualPort), token };
32585
- } finally {
32586
- lock?.release();
32587
- }
32123
+ function argentHomeDir(options = {}) {
32124
+ const override = options.homeDir ? null : nonEmpty(process.env[ARGENT_HOME_DIR_ENV]);
32125
+ return override ? path.resolve(override.trim()) : path.join(resolveHomeDir(options), ".argent");
32588
32126
  }
32589
32127
 
32590
- // ../argent-tools-client/src/tools-client.ts
32591
- var import_yaml2 = __toESM(require_dist2(), 1);
32592
- import { readFile as readFile5 } from "node:fs/promises";
32593
- import { maxHeaderSize } from "node:http";
32594
- import * as path12 from "node:path";
32595
-
32596
32128
  // ../configuration-core/src/flags.ts
32597
- import * as fs2 from "node:fs";
32598
- import * as path2 from "node:path";
32599
- import { homedir as homedir2 } from "node:os";
32600
32129
  var FLAG_REGISTRY = [
32601
32130
  {
32602
32131
  name: "disable-auto-screenshot",
@@ -32663,7 +32192,7 @@ function findProjectRoot(startDir) {
32663
32192
  let current = path2.resolve(startDir);
32664
32193
  while (true) {
32665
32194
  for (const marker of PROJECT_MARKERS) {
32666
- if (fs2.existsSync(path2.join(current, marker))) return current;
32195
+ if (fs.existsSync(path2.join(current, marker))) return current;
32667
32196
  }
32668
32197
  const parent = path2.dirname(current);
32669
32198
  if (parent === current) return null;
@@ -32674,9 +32203,8 @@ function resolveProjectRoot(startDir) {
32674
32203
  return findProjectRoot(startDir) ?? path2.resolve(startDir);
32675
32204
  }
32676
32205
  function getFlagsPath(scope, options = {}) {
32677
- const home = options.homeDir ?? homedir2();
32678
32206
  if (scope === "global") {
32679
- return path2.join(home, ".argent", "flags.json");
32207
+ return path2.join(argentHomeDir({ homeDir: options.homeDir }), "flags.json");
32680
32208
  }
32681
32209
  const cwd = options.cwd ?? process.cwd();
32682
32210
  return path2.join(resolveProjectRoot(cwd), ".argent", "flags.json");
@@ -32684,7 +32212,7 @@ function getFlagsPath(scope, options = {}) {
32684
32212
  function readFlagsFile(filePath) {
32685
32213
  let raw2;
32686
32214
  try {
32687
- raw2 = fs2.readFileSync(filePath, "utf8");
32215
+ raw2 = fs.readFileSync(filePath, "utf8");
32688
32216
  } catch {
32689
32217
  return {};
32690
32218
  }
@@ -32721,35 +32249,20 @@ function isFeatureEnabled(name, options = {}, registry2 = FLAG_REGISTRY) {
32721
32249
  }
32722
32250
 
32723
32251
  // ../configuration-core/src/paths.ts
32724
- import * as fs3 from "node:fs";
32725
- import * as os from "node:os";
32252
+ import * as fs2 from "node:fs";
32726
32253
  import * as path3 from "node:path";
32727
- function nonEmpty(value) {
32728
- if (value == void 0) return null;
32729
- const trimmed = value.trim();
32730
- return trimmed === "" ? null : value;
32731
- }
32732
- function resolveHomeDir(options = {}) {
32733
- if (options.homeDir) return options.homeDir;
32734
- return process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
32735
- }
32736
32254
  function isHomeDir(dir, options = {}) {
32737
32255
  return canonicalPath(dir) === canonicalPath(resolveHomeDir(options));
32738
32256
  }
32739
32257
  function canonicalPath(p) {
32740
32258
  try {
32741
- return fs3.realpathSync.native(p);
32259
+ return fs2.realpathSync.native(p);
32742
32260
  } catch {
32743
32261
  return path3.resolve(p);
32744
32262
  }
32745
32263
  }
32746
- function argentHomeDir() {
32747
- return path3.join(resolveHomeDir(), ".argent");
32748
- }
32749
32264
  function configDir(scope = "global", options = {}) {
32750
- if (scope === "global") {
32751
- return path3.join(resolveHomeDir(options), ".argent");
32752
- }
32265
+ if (scope === "global") return argentHomeDir(options);
32753
32266
  const cwd = options.cwd ?? process.cwd();
32754
32267
  return path3.join(resolveProjectRoot(cwd), ".argent");
32755
32268
  }
@@ -32759,11 +32272,11 @@ function configFilePath(scope = "global", options = {}) {
32759
32272
 
32760
32273
  // ../configuration-core/src/config.ts
32761
32274
  import * as crypto from "node:crypto";
32762
- import * as fs4 from "node:fs";
32275
+ import * as fs3 from "node:fs";
32763
32276
  import * as path4 from "node:path";
32764
32277
  function readConfigObject(scope = "global", options = {}) {
32765
32278
  try {
32766
- const raw2 = fs4.readFileSync(configFilePath(scope, options), "utf8");
32279
+ const raw2 = fs3.readFileSync(configFilePath(scope, options), "utf8");
32767
32280
  const json = JSON.parse(raw2);
32768
32281
  if (json && typeof json === "object" && !Array.isArray(json)) {
32769
32282
  return json;
@@ -32810,7 +32323,7 @@ function setAtPath(obj, dottedKey, value) {
32810
32323
  }
32811
32324
  cur[parts[parts.length - 1]] = value;
32812
32325
  }
32813
- var LOCK_STALE_MS2 = 1e4;
32326
+ var LOCK_STALE_MS = 1e4;
32814
32327
  var LOCK_MAX_WAIT_MS = 2e3;
32815
32328
  var LOCK_RETRY_MS = 25;
32816
32329
  function sleepSync(ms) {
@@ -32821,9 +32334,9 @@ function acquireConfigLock(finalPath) {
32821
32334
  const deadline = Date.now() + LOCK_MAX_WAIT_MS;
32822
32335
  for (; ; ) {
32823
32336
  try {
32824
- const fd = fs4.openSync(lockPath, "wx", 384);
32337
+ const fd = fs3.openSync(lockPath, "wx", 384);
32825
32338
  try {
32826
- fs4.writeSync(fd, `${process.pid}
32339
+ fs3.writeSync(fd, `${process.pid}
32827
32340
  `);
32828
32341
  } catch {
32829
32342
  }
@@ -32831,8 +32344,8 @@ function acquireConfigLock(finalPath) {
32831
32344
  } catch (err) {
32832
32345
  if (err.code !== "EEXIST") return null;
32833
32346
  try {
32834
- if (Date.now() - fs4.statSync(lockPath).mtimeMs > LOCK_STALE_MS2) {
32835
- fs4.unlinkSync(lockPath);
32347
+ if (Date.now() - fs3.statSync(lockPath).mtimeMs > LOCK_STALE_MS) {
32348
+ fs3.unlinkSync(lockPath);
32836
32349
  continue;
32837
32350
  }
32838
32351
  } catch {
@@ -32844,35 +32357,35 @@ function acquireConfigLock(finalPath) {
32844
32357
  }
32845
32358
  function releaseConfigLock(lock) {
32846
32359
  try {
32847
- fs4.closeSync(lock.fd);
32360
+ fs3.closeSync(lock.fd);
32848
32361
  } catch {
32849
32362
  }
32850
32363
  try {
32851
- fs4.unlinkSync(lock.lockPath);
32364
+ fs3.unlinkSync(lock.lockPath);
32852
32365
  } catch {
32853
32366
  }
32854
32367
  }
32855
32368
  function updateConfig(mutate, scope = "global", options = {}) {
32856
32369
  const dir = configDir(scope, options);
32857
- fs4.mkdirSync(dir, { recursive: true });
32370
+ fs3.mkdirSync(dir, { recursive: true });
32858
32371
  const finalPath = configFilePath(scope, options);
32859
32372
  const lock = acquireConfigLock(finalPath);
32860
32373
  try {
32861
32374
  const next = readConfigObject(scope, options);
32862
32375
  mutate(next);
32863
32376
  const tmpPath = path4.join(dir, `.config.tmp.${process.pid}.${crypto.randomUUID()}`);
32864
- const fd = fs4.openSync(tmpPath, "wx", 384);
32377
+ const fd = fs3.openSync(tmpPath, "wx", 384);
32865
32378
  try {
32866
- fs4.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
32867
- fs4.fsyncSync(fd);
32379
+ fs3.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
32380
+ fs3.fsyncSync(fd);
32868
32381
  } finally {
32869
- fs4.closeSync(fd);
32382
+ fs3.closeSync(fd);
32870
32383
  }
32871
32384
  try {
32872
- fs4.renameSync(tmpPath, finalPath);
32385
+ fs3.renameSync(tmpPath, finalPath);
32873
32386
  } catch (err) {
32874
32387
  try {
32875
- fs4.unlinkSync(tmpPath);
32388
+ fs3.unlinkSync(tmpPath);
32876
32389
  } catch {
32877
32390
  }
32878
32391
  throw err;
@@ -32889,12 +32402,24 @@ function getWhatsNewSeenVersion(options = {}) {
32889
32402
  return typeof value === "string" ? value : null;
32890
32403
  }
32891
32404
  function setWhatsNewSeenVersion(version2, options = {}) {
32892
- updateConfig((config2) => setAtPath(config2, WHATS_NEW_SEEN_KEY, version2), "global", options);
32405
+ let recorded = false;
32406
+ updateConfig(
32407
+ (config2) => {
32408
+ const value = getAtPath(config2, WHATS_NEW_SEEN_KEY);
32409
+ const seen = typeof value === "string" ? value : null;
32410
+ if (options.ifSeen !== void 0 && options.ifSeen !== seen) return;
32411
+ setAtPath(config2, WHATS_NEW_SEEN_KEY, version2);
32412
+ recorded = true;
32413
+ },
32414
+ "global",
32415
+ options
32416
+ );
32417
+ return recorded;
32893
32418
  }
32894
32419
 
32895
32420
  // ../configuration-core/src/secrets.ts
32896
- var import_dotenv = __toESM(require_dist3(), 1);
32897
- import * as fs5 from "node:fs";
32421
+ var import_dotenv = __toESM(require_dist2(), 1);
32422
+ import * as fs4 from "node:fs";
32898
32423
  import * as path5 from "node:path";
32899
32424
  var SECRET_ENV_PREFIX = "ARGENT_SECRET_";
32900
32425
  var SECRETS_FILE_NAME = "secrets.env";
@@ -32924,10 +32449,10 @@ function fileSource(filePath, exposure) {
32924
32449
  names: [],
32925
32450
  values: /* @__PURE__ */ new Map()
32926
32451
  };
32927
- if (!fs5.statSync(filePath, { throwIfNoEntry: false })) return absent;
32452
+ if (!fs4.statSync(filePath, { throwIfNoEntry: false })) return absent;
32928
32453
  let content;
32929
32454
  try {
32930
- content = fs5.readFileSync(filePath, "utf8");
32455
+ content = fs4.readFileSync(filePath, "utf8");
32931
32456
  } catch {
32932
32457
  return absent;
32933
32458
  }
@@ -32967,7 +32492,7 @@ function secretSources(options = {}) {
32967
32492
  }
32968
32493
  }
32969
32494
  filePaths.push({
32970
- path: path5.join(home, ".argent", SECRETS_FILE_NAME),
32495
+ path: path5.join(argentHomeDir(options), SECRETS_FILE_NAME),
32971
32496
  exposure: "dedicated"
32972
32497
  });
32973
32498
  const seen = /* @__PURE__ */ new Set();
@@ -33053,7 +32578,7 @@ function applyMergePolicy(policy, local, global) {
33053
32578
  }
33054
32579
 
33055
32580
  // ../configuration-core/src/config-schema.ts
33056
- import { isAbsolute as isAbsolute2 } from "node:path";
32581
+ import { isAbsolute } from "node:path";
33057
32582
  function asBoolean(raw2) {
33058
32583
  return typeof raw2 === "boolean" ? raw2 : void 0;
33059
32584
  }
@@ -33089,6 +32614,15 @@ var CONFIG_SCHEMA = [
33089
32614
  // drained/reset, not just the file rewritten.
33090
32615
  manageCommand: "argent telemetry"
33091
32616
  },
32617
+ {
32618
+ key: "autoUpdate.enabled",
32619
+ description: "Automatically update the global Argent installation. Project-local installs require confirmation.",
32620
+ scopes: ["global"],
32621
+ parse: asBoolean,
32622
+ merge: "prioritize-local",
32623
+ default: true,
32624
+ example: "false"
32625
+ },
33092
32626
  {
33093
32627
  key: "lens.agent",
33094
32628
  description: "Coding-agent id remembered by `argent lens` to skip the picker.",
@@ -33114,7 +32648,7 @@ var CONFIG_SCHEMA = [
33114
32648
  scopes: ["project", "global"],
33115
32649
  parse: (raw2) => {
33116
32650
  const value = asString(raw2);
33117
- return value !== void 0 && (value === "~" || value.startsWith("~/") || isAbsolute2(value)) ? value : void 0;
32651
+ return value !== void 0 && (value === "~" || value.startsWith("~/") || isAbsolute(value)) ? value : void 0;
33118
32652
  },
33119
32653
  expected: "an absolute path, or one starting with `~/`",
33120
32654
  merge: "prioritize-local",
@@ -33209,6 +32743,499 @@ var UnknownConfigKeyError = class extends Error {
33209
32743
  key;
33210
32744
  };
33211
32745
 
32746
+ // ../argent-tools-client/src/launcher.ts
32747
+ var STATE_DIR = argentHomeDir();
32748
+ var STATE_FILE = path7.join(STATE_DIR, "tool-server.json");
32749
+ var LOG_FILE = path7.join(STATE_DIR, "tool-server.log");
32750
+ var LOCK_FILE = path7.join(STATE_DIR, "tool-server.lock");
32751
+ var AUTH_TOKEN_BYTES = 32;
32752
+ var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
32753
+ var AUTOSPAWN_IDLE_TIMEOUT_MINUTES = 30;
32754
+ var AUTOSPAWN_HOST = "127.0.0.1";
32755
+ function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
32756
+ const env = {
32757
+ ...baseEnv,
32758
+ ARGENT_PORT: String(port),
32759
+ ARGENT_SIMULATOR_SERVER_DIR: paths.simulatorServerDir,
32760
+ ARGENT_NATIVE_DEVTOOLS_DIR: paths.nativeDevtoolsDir
32761
+ };
32762
+ if (options.host !== void 0) env.ARGENT_HOST = options.host;
32763
+ if (options.idleTimeoutMinutes !== void 0) {
32764
+ env.ARGENT_IDLE_TIMEOUT_MINUTES = String(options.idleTimeoutMinutes);
32765
+ }
32766
+ env[AUTH_TOKEN_ENV] = options.token ?? "";
32767
+ env.ARGENT_SERVER_MANAGED = options.managed ?? "autospawn";
32768
+ if (paths.installKind) env.ARGENT_INSTALL_KIND = paths.installKind;
32769
+ if (paths.installProjectRoot) env.ARGENT_PROJECT_ROOT = paths.installProjectRoot;
32770
+ return env;
32771
+ }
32772
+ function generateToken() {
32773
+ return randomBytes(AUTH_TOKEN_BYTES).toString("hex");
32774
+ }
32775
+ function findFreePort() {
32776
+ return new Promise((resolve13, reject) => {
32777
+ const srv = net.createServer();
32778
+ srv.listen(0, "127.0.0.1", () => {
32779
+ const addr = srv.address();
32780
+ if (!addr || typeof addr !== "object") {
32781
+ srv.close(() => reject(new Error("Could not bind to find free port")));
32782
+ return;
32783
+ }
32784
+ const port = addr.port;
32785
+ srv.close((err) => {
32786
+ if (err) reject(err);
32787
+ else resolve13(port);
32788
+ });
32789
+ });
32790
+ srv.on("error", reject);
32791
+ });
32792
+ }
32793
+ function isVersionNewer(a, b) {
32794
+ const parse4 = (v) => {
32795
+ const [core = "", ...preParts] = v.split("+")[0].split("-");
32796
+ const nums = core.split(".").map((n) => Number.parseInt(n, 10));
32797
+ if (nums.length === 0 || nums.some((n) => Number.isNaN(n))) return null;
32798
+ return { nums, pre: preParts.length > 0 ? preParts.join("-").split(".") : [] };
32799
+ };
32800
+ const pa = parse4(a);
32801
+ const pb = parse4(b);
32802
+ if (!pa || !pb) return false;
32803
+ for (let i = 0; i < 3; i++) {
32804
+ const x = pa.nums[i] ?? 0;
32805
+ const y = pb.nums[i] ?? 0;
32806
+ if (x !== y) return x > y;
32807
+ }
32808
+ if (pa.pre.length === 0 && pb.pre.length === 0) return false;
32809
+ if (pa.pre.length === 0) return true;
32810
+ if (pb.pre.length === 0) return false;
32811
+ for (let i = 0; i < Math.max(pa.pre.length, pb.pre.length); i++) {
32812
+ const x = pa.pre[i];
32813
+ const y = pb.pre[i];
32814
+ if (x === void 0) return false;
32815
+ if (y === void 0) return true;
32816
+ if (x === y) continue;
32817
+ const xn = /^\d+$/.test(x) ? Number.parseInt(x, 10) : null;
32818
+ const yn = /^\d+$/.test(y) ? Number.parseInt(y, 10) : null;
32819
+ if (xn !== null && yn !== null) return xn > yn;
32820
+ if (xn !== null) return false;
32821
+ if (yn !== null) return true;
32822
+ return x > y;
32823
+ }
32824
+ return false;
32825
+ }
32826
+ function readBundlePackageVersion(bundlePath) {
32827
+ try {
32828
+ const pkg = JSON.parse(
32829
+ fs5.readFileSync(path7.join(path7.dirname(bundlePath), "..", "package.json"), "utf8")
32830
+ );
32831
+ return typeof pkg.version === "string" ? pkg.version : void 0;
32832
+ } catch {
32833
+ return void 0;
32834
+ }
32835
+ }
32836
+ function isProcessAlive(pid) {
32837
+ try {
32838
+ process.kill(pid, 0);
32839
+ return true;
32840
+ } catch {
32841
+ return false;
32842
+ }
32843
+ }
32844
+ function healthCheckHost(host) {
32845
+ if (host === "0.0.0.0" || host === "") return "127.0.0.1";
32846
+ if (host === "::" || host === "::0") return "::1";
32847
+ return host;
32848
+ }
32849
+ function formatUrl(host, port) {
32850
+ const h = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
32851
+ return `http://${h}:${port}`;
32852
+ }
32853
+ function authHeaders(token) {
32854
+ return token ? { Authorization: `Bearer ${token}` } : {};
32855
+ }
32856
+ async function isToolsServerHealthy(port, host = "127.0.0.1", timeoutMs = 2e3, token) {
32857
+ const controller = new AbortController();
32858
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
32859
+ try {
32860
+ const res = await fetch(`${formatUrl(healthCheckHost(host), port)}/tools`, {
32861
+ signal: controller.signal,
32862
+ headers: authHeaders(token)
32863
+ });
32864
+ await res.body?.cancel().catch(() => {
32865
+ });
32866
+ return res.ok;
32867
+ } catch {
32868
+ return false;
32869
+ } finally {
32870
+ clearTimeout(timer);
32871
+ }
32872
+ }
32873
+ var SPAWN_READY_TIMEOUT_MS = 15e3;
32874
+ function killSpawnedChild(child, pid) {
32875
+ try {
32876
+ process.kill(-pid, "SIGKILL");
32877
+ } catch {
32878
+ try {
32879
+ child.kill("SIGKILL");
32880
+ } catch {
32881
+ }
32882
+ }
32883
+ }
32884
+ function resolveToolsServerNode() {
32885
+ const { bun, deno, electron } = process.versions;
32886
+ return !(bun || deno || electron) && fs5.existsSync(process.execPath) ? process.execPath : "node";
32887
+ }
32888
+ function parseListeningPort(line) {
32889
+ const match = line.match(/Tools server listening on http:\/\/.+:(\d+)/);
32890
+ return match ? parseInt(match[1], 10) : null;
32891
+ }
32892
+ function spawnToolsServer(paths, port, options = {}) {
32893
+ return new Promise((resolve13, reject) => {
32894
+ let logFd;
32895
+ try {
32896
+ fs5.mkdirSync(STATE_DIR, { recursive: true });
32897
+ logFd = fs5.openSync(LOG_FILE, "a");
32898
+ } catch {
32899
+ logFd = fs5.openSync("/dev/null", "w");
32900
+ }
32901
+ const nodeBin = resolveToolsServerNode();
32902
+ const child = spawn(nodeBin, [paths.bundlePath, "start"], {
32903
+ detached: true,
32904
+ stdio: ["ignore", "pipe", logFd],
32905
+ env: buildToolsServerEnv(paths, port, process.env, options)
32906
+ });
32907
+ fs5.closeSync(logFd);
32908
+ const pid = child.pid;
32909
+ if (!pid) {
32910
+ child.once(
32911
+ "error",
32912
+ (err) => reject(
32913
+ new Error(
32914
+ err.code === "ENOENT" && nodeBin === "node" ? "Could not start the argent tool-server: `node` was not found on PATH. Install Node.js 22.18+ or add it to PATH." : `Could not start the argent tool-server: ${err.message}`
32915
+ )
32916
+ )
32917
+ );
32918
+ return;
32919
+ }
32920
+ let settled = false;
32921
+ const settle2 = (fn) => {
32922
+ if (settled) return;
32923
+ settled = true;
32924
+ fn();
32925
+ };
32926
+ const rejectAndKill = (err) => settle2(() => {
32927
+ killSpawnedChild(child, pid);
32928
+ reject(err);
32929
+ });
32930
+ const rl = readline.createInterface({ input: child.stdout });
32931
+ rl.on("line", (line) => {
32932
+ const actualPort = parseListeningPort(line);
32933
+ if (actualPort !== null) {
32934
+ rl.close();
32935
+ child.stdout?.resume();
32936
+ child.stdout?.unref?.();
32937
+ child.unref();
32938
+ settle2(() => resolve13({ port: actualPort, pid }));
32939
+ }
32940
+ });
32941
+ child.on("error", (err) => {
32942
+ rl.close();
32943
+ rejectAndKill(err);
32944
+ });
32945
+ child.on("exit", (code) => {
32946
+ rl.close();
32947
+ settle2(() => reject(new Error(`tool-server exited with code ${code} before becoming ready`)));
32948
+ });
32949
+ const timer = setTimeout(() => {
32950
+ rl.close();
32951
+ rejectAndKill(new Error("Timed out waiting for tools server to become ready"));
32952
+ }, options.readyTimeoutMs ?? SPAWN_READY_TIMEOUT_MS);
32953
+ rl.on("close", () => clearTimeout(timer));
32954
+ });
32955
+ }
32956
+ function stateFileForBundle(bundlePath) {
32957
+ const key = createHash("sha256").update(bundlePath).digest("hex").slice(0, 12);
32958
+ return path7.join(STATE_DIR, `tool-server-${key}.json`);
32959
+ }
32960
+ async function readStateFile(file) {
32961
+ try {
32962
+ const raw2 = await readFile(file, "utf8");
32963
+ return JSON.parse(raw2);
32964
+ } catch {
32965
+ return null;
32966
+ }
32967
+ }
32968
+ async function readToolsServerState(bundlePath) {
32969
+ if (bundlePath === void 0) return readStateFile(STATE_FILE);
32970
+ const own2 = await readStateFile(stateFileForBundle(bundlePath));
32971
+ if (own2) return own2;
32972
+ const legacy = await readStateFile(STATE_FILE);
32973
+ return legacy && legacy.bundlePath === bundlePath ? legacy : null;
32974
+ }
32975
+ async function writeToolsServerState(state) {
32976
+ const target = stateFileForBundle(state.bundlePath);
32977
+ await mkdir(STATE_DIR, { recursive: true });
32978
+ const tmp = `${target}.${process.pid}.tmp`;
32979
+ try {
32980
+ await writeFile(tmp, JSON.stringify(state, null, 2) + "\n", {
32981
+ encoding: "utf8",
32982
+ mode: 384
32983
+ });
32984
+ await chmod(tmp, 384);
32985
+ await rename(tmp, target);
32986
+ } catch (err) {
32987
+ await unlink(tmp).catch(() => {
32988
+ });
32989
+ throw err;
32990
+ }
32991
+ }
32992
+ async function clearToolsServerState(bundlePath) {
32993
+ const files = [STATE_FILE];
32994
+ if (bundlePath !== void 0) {
32995
+ files[0] = stateFileForBundle(bundlePath);
32996
+ const legacy = await readStateFile(STATE_FILE);
32997
+ if (legacy && legacy.bundlePath === bundlePath) files.push(STATE_FILE);
32998
+ }
32999
+ for (const file of files) {
33000
+ try {
33001
+ await unlink(file);
33002
+ } catch {
33003
+ }
33004
+ }
33005
+ }
33006
+ var STATE_FILE_RE = /^tool-server(-[0-9a-f]{12})?\.json$/;
33007
+ async function readAllToolsServerStates() {
33008
+ let names;
33009
+ try {
33010
+ names = await readdir(STATE_DIR);
33011
+ } catch {
33012
+ return [];
33013
+ }
33014
+ const out = [];
33015
+ for (const name of names) {
33016
+ if (!STATE_FILE_RE.test(name)) continue;
33017
+ const file = path7.join(STATE_DIR, name);
33018
+ const state = await readStateFile(file);
33019
+ if (state) out.push({ file, state });
33020
+ }
33021
+ return out;
33022
+ }
33023
+ async function sweepDeadStateFiles() {
33024
+ for (const { file } of await readAllToolsServerStates()) {
33025
+ if (file === STATE_FILE) continue;
33026
+ const fresh = await readStateFile(file);
33027
+ if (!fresh) continue;
33028
+ if (!isProcessAlive(fresh.pid)) {
33029
+ await unlink(file).catch(() => {
33030
+ });
33031
+ continue;
33032
+ }
33033
+ if (fs5.existsSync(fresh.bundlePath)) continue;
33034
+ if (!couldBeOurToolServer(fresh.pid, fresh.bundlePath)) continue;
33035
+ await unlink(file).catch(() => {
33036
+ });
33037
+ void terminatePid(fresh.pid, () => couldBeOurToolServer(fresh.pid, fresh.bundlePath));
33038
+ }
33039
+ }
33040
+ var readState = readToolsServerState;
33041
+ var writeState = writeToolsServerState;
33042
+ var SIGTERM_GRACE_MS = 6e3;
33043
+ var SIGKILL_GRACE_MS = 1e3;
33044
+ var KILL_POLL_MS = 100;
33045
+ async function waitForExit(pid, timeoutMs) {
33046
+ const deadline = Date.now() + timeoutMs;
33047
+ while (Date.now() < deadline) {
33048
+ if (!isProcessAlive(pid)) return true;
33049
+ await new Promise((r) => setTimeout(r, KILL_POLL_MS));
33050
+ }
33051
+ return !isProcessAlive(pid);
33052
+ }
33053
+ async function terminatePid(pid, stillOurs) {
33054
+ if (!isProcessAlive(pid)) return;
33055
+ if (stillOurs && !stillOurs()) return;
33056
+ try {
33057
+ process.kill(pid, "SIGTERM");
33058
+ } catch {
33059
+ return;
33060
+ }
33061
+ if (await waitForExit(pid, SIGTERM_GRACE_MS)) return;
33062
+ if (stillOurs && !(isProcessAlive(pid) && stillOurs())) return;
33063
+ try {
33064
+ process.kill(pid, "SIGKILL");
33065
+ } catch {
33066
+ return;
33067
+ }
33068
+ await waitForExit(pid, SIGKILL_GRACE_MS);
33069
+ }
33070
+ var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs5.existsSync(p)) ?? "ps";
33071
+ var PS_WIDTH_FLAGS = ["-ww"];
33072
+ var PS_LOCALE = process.platform === "darwin" ? "en_US.UTF-8" : "C.UTF-8";
33073
+ function readProcessCommandLine(pid, flags = PS_WIDTH_FLAGS, env = { ...process.env, LC_ALL: PS_LOCALE }) {
33074
+ return execFileSync(PS_BIN, [...flags, "-p", String(pid), "-o", "command="], {
33075
+ env,
33076
+ encoding: "utf8",
33077
+ timeout: 2e3,
33078
+ // A recycled pid can sit on a process with an argv past Node's 1 MiB exec
33079
+ // default, where the overrun surfaces as ENOBUFS instead of a command line.
33080
+ // Same ceiling as tool-server's vega-process ps probes.
33081
+ maxBuffer: 16 * 1024 * 1024,
33082
+ // Piping ps's stderr is what puts a rejected flag ("ps: invalid option --
33083
+ // 'w'") into the thrown error's message.
33084
+ stdio: ["ignore", "pipe", "pipe"]
33085
+ }).trim();
33086
+ }
33087
+ function couldBeOurToolServer(pid, marker) {
33088
+ if (!marker) return false;
33089
+ if (process.platform === "win32") return true;
33090
+ const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
33091
+ const ours = new RegExp(`(?:^|[\\t\\n\\v\\f\\r ])${escaped} start(?:[\\t\\n\\v\\f\\r ]|$)`);
33092
+ const nonAscii = [...marker].some((c) => c.charCodeAt(0) > 127);
33093
+ let failure2;
33094
+ for (const env of [void 0, process.env]) {
33095
+ try {
33096
+ if (ours.test(readProcessCommandLine(pid, PS_WIDTH_FLAGS, env))) return true;
33097
+ failure2 = void 0;
33098
+ if (!nonAscii) break;
33099
+ } catch (err) {
33100
+ failure2 = String(err);
33101
+ if (err.code === "ETIMEDOUT") break;
33102
+ }
33103
+ }
33104
+ if (failure2 !== void 0) {
33105
+ process.stderr.write(
33106
+ `[launcher] ps could not read pid ${pid}'s command line; leaving it alone: ${failure2}
33107
+ `
33108
+ );
33109
+ }
33110
+ return false;
33111
+ }
33112
+ var LOCK_WAIT_TIMEOUT_MS = 3e4;
33113
+ var LOCK_STALE_MS2 = 45e3;
33114
+ var LOCK_POLL_MS = 100;
33115
+ function spawnLockIsStale() {
33116
+ try {
33117
+ const { pid, ts } = JSON.parse(fs5.readFileSync(LOCK_FILE, "utf8"));
33118
+ if (typeof pid === "number" && pid > 0 && !isProcessAlive(pid)) return true;
33119
+ if (typeof ts === "number" && Date.now() - ts > LOCK_STALE_MS2) return true;
33120
+ return false;
33121
+ } catch {
33122
+ try {
33123
+ return Date.now() - fs5.statSync(LOCK_FILE).mtimeMs > LOCK_STALE_MS2;
33124
+ } catch {
33125
+ return true;
33126
+ }
33127
+ }
33128
+ }
33129
+ async function acquireSpawnLock() {
33130
+ try {
33131
+ fs5.mkdirSync(STATE_DIR, { recursive: true });
33132
+ } catch {
33133
+ return null;
33134
+ }
33135
+ const nonce = randomBytes(8).toString("hex");
33136
+ const deadline = Date.now() + LOCK_WAIT_TIMEOUT_MS;
33137
+ for (; ; ) {
33138
+ try {
33139
+ const fd = fs5.openSync(LOCK_FILE, "wx");
33140
+ try {
33141
+ fs5.writeSync(fd, JSON.stringify({ pid: process.pid, nonce, ts: Date.now() }));
33142
+ } finally {
33143
+ fs5.closeSync(fd);
33144
+ }
33145
+ let released = false;
33146
+ return {
33147
+ release: () => {
33148
+ if (released) return;
33149
+ released = true;
33150
+ try {
33151
+ const cur = JSON.parse(fs5.readFileSync(LOCK_FILE, "utf8"));
33152
+ if (cur.pid === process.pid && cur.nonce === nonce) fs5.unlinkSync(LOCK_FILE);
33153
+ } catch {
33154
+ }
33155
+ }
33156
+ };
33157
+ } catch (err) {
33158
+ if (err.code !== "EEXIST") return null;
33159
+ if (spawnLockIsStale()) {
33160
+ try {
33161
+ fs5.unlinkSync(LOCK_FILE);
33162
+ } catch {
33163
+ }
33164
+ if (!fs5.existsSync(LOCK_FILE)) continue;
33165
+ }
33166
+ if (Date.now() >= deadline) return null;
33167
+ await new Promise((r) => setTimeout(r, LOCK_POLL_MS));
33168
+ }
33169
+ }
33170
+ }
33171
+ async function reusableHandle(state, wantBundlePath, wantVersion) {
33172
+ if (!state || !isProcessAlive(state.pid)) return null;
33173
+ if (wantBundlePath !== void 0 && state.bundlePath !== wantBundlePath) return null;
33174
+ if (wantBundlePath !== void 0 && state.version !== void 0) {
33175
+ const diskVersion = readBundlePackageVersion(wantBundlePath);
33176
+ if (diskVersion !== void 0) {
33177
+ if (diskVersion !== state.version) return null;
33178
+ } else if (wantVersion !== void 0 && state.version !== wantVersion && isVersionNewer(wantVersion, state.version)) {
33179
+ return null;
33180
+ }
33181
+ }
33182
+ const host = state.host ?? "127.0.0.1";
33183
+ const healthy = await isToolsServerHealthy(state.port, host, 2e3, state.token);
33184
+ if (!healthy) return null;
33185
+ return { url: formatUrl(healthCheckHost(host), state.port), token: state.token ?? "" };
33186
+ }
33187
+ async function ensureToolsServer(paths) {
33188
+ const fast = await reusableHandle(
33189
+ await readState(paths.bundlePath),
33190
+ paths.bundlePath,
33191
+ paths.version
33192
+ );
33193
+ if (fast) return fast;
33194
+ const lock = await acquireSpawnLock();
33195
+ try {
33196
+ const state = await readState(paths.bundlePath);
33197
+ const reuse = await reusableHandle(state, paths.bundlePath, paths.version);
33198
+ if (reuse) return reuse;
33199
+ if (state && state.managed === "autospawn" && state.bundlePath === paths.bundlePath && isProcessAlive(state.pid) && couldBeOurToolServer(state.pid, state.bundlePath)) {
33200
+ await terminatePid(state.pid, () => couldBeOurToolServer(state.pid, state.bundlePath));
33201
+ }
33202
+ await clearToolsServerState(paths.bundlePath);
33203
+ await sweepDeadStateFiles();
33204
+ if (!fs5.existsSync(paths.bundlePath)) {
33205
+ throw new Error(
33206
+ `The argent install serving this session is gone from disk (${paths.bundlePath}) \u2014 it was likely updated or removed. Restart the editor's MCP connection to reconnect.`
33207
+ );
33208
+ }
33209
+ const diskVersion = readBundlePackageVersion(paths.bundlePath) ?? paths.version;
33210
+ const token = generateToken();
33211
+ const port = await findFreePort();
33212
+ const { port: actualPort, pid } = await spawnToolsServer(paths, port, {
33213
+ token,
33214
+ host: AUTOSPAWN_HOST,
33215
+ idleTimeoutMinutes: AUTOSPAWN_IDLE_TIMEOUT_MINUTES
33216
+ });
33217
+ await writeState({
33218
+ port: actualPort,
33219
+ pid,
33220
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
33221
+ bundlePath: paths.bundlePath,
33222
+ version: diskVersion,
33223
+ host: AUTOSPAWN_HOST,
33224
+ token,
33225
+ managed: "autospawn"
33226
+ });
33227
+ return { url: formatUrl(AUTOSPAWN_HOST, actualPort), token };
33228
+ } finally {
33229
+ lock?.release();
33230
+ }
33231
+ }
33232
+
33233
+ // ../argent-tools-client/src/tools-client.ts
33234
+ var import_yaml2 = __toESM(require_dist3(), 1);
33235
+ import { readFile as readFile5 } from "node:fs/promises";
33236
+ import { maxHeaderSize } from "node:http";
33237
+ import * as path13 from "node:path";
33238
+
33212
33239
  // ../registry/src/types.ts
33213
33240
  var LINKED_CALL_HEADER = "x-argent-linked";
33214
33241
  var E2E_DIR_CLIENT_HEADER = "x-argent-e2e-dir";
@@ -33268,8 +33295,8 @@ var UNEXPANDED_PATH = /^~|\$[A-Za-z0-9_{(]|`|%[A-Za-z_][A-Za-z0-9_]*%|^[A-Za-z][
33268
33295
  function isUnexpandedPath(p) {
33269
33296
  return UNEXPANDED_PATH.test(p);
33270
33297
  }
33271
- function isClientFileArgument({ spec, path: path18 }) {
33272
- return spec.kind === "file" && spec.path === `\${${spec.target}}` && path18.startsWith("/") && hasToolFileExtension(path18);
33298
+ function isClientFileArgument({ spec, path: path19 }) {
33299
+ return spec.kind === "file" && spec.path === `\${${spec.target}}` && path19.startsWith("/") && hasToolFileExtension(path19);
33273
33300
  }
33274
33301
 
33275
33302
  // ../registry/src/flow-platforms.ts
@@ -33278,22 +33305,22 @@ var SELECTABLE_PLATFORMS = [...LAUNCH_PLATFORMS, "ios-remote"];
33278
33305
 
33279
33306
  // ../registry/src/flow-file-refs.ts
33280
33307
  import * as fs7 from "node:fs/promises";
33281
- import * as path8 from "node:path";
33308
+ import * as path9 from "node:path";
33282
33309
 
33283
33310
  // ../registry/src/e2e-dirs.ts
33284
33311
  import * as fs6 from "node:fs/promises";
33285
- import * as path7 from "node:path";
33286
- var E2E_DIR = path7.join(".argent", "e2e");
33287
- var LEGACY_E2E_DIRS = Object.freeze([path7.join(".argent", "flows")]);
33312
+ import * as path8 from "node:path";
33313
+ var E2E_DIR = path8.join(".argent", "e2e");
33314
+ var LEGACY_E2E_DIRS = Object.freeze([path8.join(".argent", "flows")]);
33288
33315
  var E2E_DIRS = Object.freeze([E2E_DIR, ...LEGACY_E2E_DIRS]);
33289
33316
  function e2eDirFor(projectRoot) {
33290
- return path7.join(projectRoot, E2E_DIR);
33317
+ return path8.join(projectRoot, E2E_DIR);
33291
33318
  }
33292
33319
  function e2eDirsFor(projectRoot) {
33293
- return E2E_DIRS.map((dir) => path7.join(projectRoot, dir));
33320
+ return E2E_DIRS.map((dir) => path8.join(projectRoot, dir));
33294
33321
  }
33295
33322
  function e2eFileCandidates(projectRoot, name) {
33296
- return e2eDirsFor(projectRoot).map((dir) => path7.join(dir, `${name}.yaml`));
33323
+ return e2eDirsFor(projectRoot).map((dir) => path8.join(dir, `${name}.yaml`));
33297
33324
  }
33298
33325
  async function exists(file) {
33299
33326
  return fs6.stat(file).then(
@@ -33323,21 +33350,21 @@ async function pickE2eFile(candidates) {
33323
33350
  function e2eShadowWarning(used, shadowed) {
33324
33351
  return `${shadowed} is not used: ${used} has the same name and is read first.`;
33325
33352
  }
33326
- var E2E_DIR_NAMES = E2E_DIRS.map((dir) => path7.basename(dir));
33353
+ var E2E_DIR_NAMES = E2E_DIRS.map((dir) => path8.basename(dir));
33327
33354
  function e2eDirProject(dir) {
33328
33355
  const trimmed = dir.length > 1 ? dir.replace(/[\\/]+$/, "") : dir;
33329
- const argent = path7.dirname(trimmed);
33330
- if (!E2E_DIR_NAMES.includes(path7.basename(trimmed)) || path7.basename(argent) !== ".argent") {
33356
+ const argent = path8.dirname(trimmed);
33357
+ if (!E2E_DIR_NAMES.includes(path8.basename(trimmed)) || path8.basename(argent) !== ".argent") {
33331
33358
  return null;
33332
33359
  }
33333
- return path7.dirname(argent);
33360
+ return path8.dirname(argent);
33334
33361
  }
33335
33362
  function e2eRunFallbackDirs(anchorDir, target) {
33336
33363
  if (target.includes("/") || target.includes("\\")) return [];
33337
33364
  const project = e2eDirProject(anchorDir);
33338
33365
  if (project === null) return [];
33339
- const anchor2 = path7.resolve(anchorDir);
33340
- return e2eDirsFor(project).filter((dir) => path7.resolve(dir) !== anchor2);
33366
+ const anchor2 = path8.resolve(anchorDir);
33367
+ return e2eDirsFor(project).filter((dir) => path8.resolve(dir) !== anchor2);
33341
33368
  }
33342
33369
 
33343
33370
  // ../registry/src/tool-ids.ts
@@ -33390,7 +33417,7 @@ async function canonicalFlowPath(p) {
33390
33417
  return await fs7.realpath(p);
33391
33418
  } catch {
33392
33419
  try {
33393
- return path8.join(await fs7.realpath(path8.dirname(p)), path8.basename(p));
33420
+ return path9.join(await fs7.realpath(path9.dirname(p)), path9.basename(p));
33394
33421
  } catch {
33395
33422
  return p;
33396
33423
  }
@@ -33399,7 +33426,7 @@ async function canonicalFlowPath(p) {
33399
33426
  function completeRunExtension(value) {
33400
33427
  if (value.endsWith(".yaml")) return value;
33401
33428
  const candidate = `${value}.yaml`;
33402
- return FLOW_FILE_NAME_PATTERN.test(path8.posix.basename(candidate)) ? candidate : value;
33429
+ return FLOW_FILE_NAME_PATTERN.test(path9.posix.basename(candidate)) ? candidate : value;
33403
33430
  }
33404
33431
  var MAX_RUN_DEPTH = 20;
33405
33432
  var MAX_BLOCK_NESTING = 64;
@@ -33421,9 +33448,9 @@ function collectFlowRequests(doc) {
33421
33448
  for (const step of steps) {
33422
33449
  if (!isRecord(step)) continue;
33423
33450
  const run = step.run;
33424
- if (typeof run === "string" && !run.includes("\\") && !path8.posix.isAbsolute(run) && !/^[A-Za-z]:/.test(run)) {
33451
+ if (typeof run === "string" && !run.includes("\\") && !path9.posix.isAbsolute(run) && !/^[A-Za-z]:/.test(run)) {
33425
33452
  const target = completeRunExtension(run);
33426
- if (FLOW_FILE_NAME_PATTERN.test(path8.posix.basename(target))) runTargets.add(target);
33453
+ if (FLOW_FILE_NAME_PATTERN.test(path9.posix.basename(target))) runTargets.add(target);
33427
33454
  }
33428
33455
  const snapshot = isRecord(step.snapshot) ? step.snapshot.name : step.snapshot;
33429
33456
  if (typeof snapshot === "string" && FLOW_NAME_PATTERN.test(snapshot)) snapshots.add(snapshot);
@@ -33436,11 +33463,14 @@ function collectFlowRequests(doc) {
33436
33463
  visit(step.steps, depth + 1);
33437
33464
  }
33438
33465
  };
33439
- if (isRecord(doc)) visit(doc.steps, 0);
33466
+ if (isRecord(doc)) {
33467
+ visit(doc.steps, 0);
33468
+ visit(doc.shutdown, 0);
33469
+ }
33440
33470
  return { runTargets: [...runTargets], snapshots: [...snapshots], toolSteps, nested };
33441
33471
  }
33442
33472
  function baselineKeyFor(canonicalPath2, flowName) {
33443
- const stem = path8.basename(canonicalPath2, ".yaml");
33473
+ const stem = path9.basename(canonicalPath2, ".yaml");
33444
33474
  return FLOW_NAME_PATTERN.test(stem) ? stem : flowName;
33445
33475
  }
33446
33476
  function flowMemberKey(anchorDir, target) {
@@ -33469,11 +33499,11 @@ function nestedFlowTarget(args) {
33469
33499
  return { kind: "name", projectRoot, name, path: paths[0], paths };
33470
33500
  }
33471
33501
  if (name !== void 0 || !isResolvedAbsolute(flowPath)) return void 0;
33472
- if (!FLOW_FILE_NAME_PATTERN.test(path8.basename(flowPath))) return void 0;
33502
+ if (!FLOW_FILE_NAME_PATTERN.test(path9.basename(flowPath))) return void 0;
33473
33503
  return { kind: "e2e_test_path", path: flowPath };
33474
33504
  }
33475
33505
  function isResolvedAbsolute(value) {
33476
- return typeof value === "string" && path8.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
33506
+ return typeof value === "string" && path9.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
33477
33507
  }
33478
33508
 
33479
33509
  // ../registry/src/failure-codes.ts
@@ -33991,9 +34021,9 @@ var FAILURE_SPAWN_CODE_SET = new Set(FAILURE_SPAWN_CODES);
33991
34021
  import { randomUUID as randomUUID3 } from "node:crypto";
33992
34022
  import { AsyncLocalStorage } from "node:async_hooks";
33993
34023
  var resolvedDuringInvocation = new AsyncLocalStorage();
33994
- function valueAtPath(root, path18) {
34024
+ function valueAtPath(root, path19) {
33995
34025
  let current = root;
33996
- for (const key of path18) {
34026
+ for (const key of path19) {
33997
34027
  if (current === null || typeof current !== "object") return void 0;
33998
34028
  if (!Object.hasOwn(current, key)) return void 0;
33999
34029
  current = current[key];
@@ -34051,11 +34081,10 @@ function describeParamIssues(error2, params) {
34051
34081
  }
34052
34082
 
34053
34083
  // ../argent-tools-client/src/link-config.ts
34054
- import * as path9 from "node:path";
34055
- import { homedir as homedir4 } from "node:os";
34084
+ import * as path10 from "node:path";
34056
34085
  import { mkdir as mkdir2, writeFile as writeFile2, readFile as readFile2, unlink as unlink2, chmod as chmod2 } from "node:fs/promises";
34057
- var LINK_DIR = path9.join(homedir4(), ".argent");
34058
- var LINK_FILE = path9.join(LINK_DIR, "link.json");
34086
+ var LINK_DIR = argentHomeDir();
34087
+ var LINK_FILE = path10.join(LINK_DIR, "link.json");
34059
34088
  async function readLinkConfig() {
34060
34089
  try {
34061
34090
  const raw2 = await readFile2(LINK_FILE, "utf8");
@@ -34108,14 +34137,14 @@ import {
34108
34137
  writeFile as writeFile3
34109
34138
  } from "node:fs/promises";
34110
34139
  import { constants, tmpdir } from "node:os";
34111
- import * as path10 from "node:path";
34140
+ import * as path11 from "node:path";
34112
34141
 
34113
34142
  // ../archive/src/index.ts
34114
34143
  import { spawn as spawn2 } from "node:child_process";
34115
34144
  import { once } from "node:events";
34116
34145
  import { createReadStream, createWriteStream } from "node:fs";
34117
34146
  import { open as open2, rm, readdir as readdir3 } from "node:fs/promises";
34118
- import { basename as basename4, dirname as dirname5, join as join9, resolve as resolve7, sep as sep2 } from "node:path";
34147
+ import { basename as basename4, dirname as dirname5, join as join10, resolve as resolve8, sep as sep2 } from "node:path";
34119
34148
  import { Writable } from "node:stream";
34120
34149
  import { pipeline } from "node:stream/promises";
34121
34150
  import zlib from "node:zlib";
@@ -34270,7 +34299,7 @@ async function runTar(archive, args, signal) {
34270
34299
  child.on("error", (err) => {
34271
34300
  childError = err;
34272
34301
  });
34273
- const closed = new Promise((resolve12) => child.once("close", resolve12));
34302
+ const closed = new Promise((resolve13) => child.once("close", resolve13));
34274
34303
  const stdout = collect(child.stdout, MAX_LISTING_BYTES, {
34275
34304
  maxLines: MAX_LISTING_LINES,
34276
34305
  onOverflow: () => child.kill()
@@ -34319,16 +34348,16 @@ async function runTar(archive, args, signal) {
34319
34348
  function normalizeTarMemberPath(memberPath) {
34320
34349
  return memberPath.replace(/^\.\//, "").replace(/\\/g, "/");
34321
34350
  }
34322
- function isContainedPath(path18, windows = process.platform === "win32") {
34323
- const slashed = path18.replace(/\\/g, "/");
34351
+ function isContainedPath(path19, windows = process.platform === "win32") {
34352
+ const slashed = path19.replace(/\\/g, "/");
34324
34353
  const drive = windows ? /^[A-Za-z]:/ : /^[A-Za-z]:\//;
34325
34354
  return !slashed.startsWith("/") && !drive.test(slashed) && !slashed.split("/").includes("..");
34326
34355
  }
34327
34356
  function isSafeTarMember(memberPath, destDir) {
34328
34357
  const normalized = normalizeTarMemberPath(memberPath);
34329
34358
  if (!isContainedPath(normalized)) return false;
34330
- const root = resolve7(destDir);
34331
- return resolve7(destDir, normalized).startsWith(root + sep2);
34359
+ const root = resolve8(destDir);
34360
+ return resolve8(destDir, normalized).startsWith(root + sep2);
34332
34361
  }
34333
34362
  async function readListing(archive, args, signal) {
34334
34363
  try {
@@ -34380,7 +34409,7 @@ async function assertSafeArchive(archive, destDir, signal) {
34380
34409
  async function resolveMember(destDir, expectedName) {
34381
34410
  const entries = await readdir3(destDir);
34382
34411
  if (entries.includes(expectedName)) {
34383
- return join9(destDir, expectedName);
34412
+ return join10(destDir, expectedName);
34384
34413
  }
34385
34414
  const real = entries.filter((e) => !e.startsWith("._"));
34386
34415
  if (real.length !== 1) {
@@ -34388,7 +34417,7 @@ async function resolveMember(destDir, expectedName) {
34388
34417
  `Could not identify the extracted member (expected "${expectedName}", found ${real.length} entries).`
34389
34418
  );
34390
34419
  }
34391
- return join9(destDir, real[0]);
34420
+ return join10(destDir, real[0]);
34392
34421
  }
34393
34422
  async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
34394
34423
  signal?.throwIfAborted();
@@ -34441,20 +34470,20 @@ function interpolatePath(template, args) {
34441
34470
  return missing ? null : out;
34442
34471
  }
34443
34472
  function callerPath(p) {
34444
- const onCurrentDrive = path10.sep === "\\" && /^[\\/](?![\\/])/.test(p);
34445
- if (!onCurrentDrive && (path10.isAbsolute(p) || path10.win32.isAbsolute(p) || isUnexpandedPath(p))) {
34473
+ const onCurrentDrive = path11.sep === "\\" && /^[\\/](?![\\/])/.test(p);
34474
+ if (!onCurrentDrive && (path11.isAbsolute(p) || path11.win32.isAbsolute(p) || isUnexpandedPath(p))) {
34446
34475
  return p;
34447
34476
  }
34448
- const { root } = path10.parse(p);
34477
+ const { root } = path11.parse(p);
34449
34478
  const rest = p.slice(root.length);
34450
34479
  if (!rest.split(/[\\/]/).includes("..")) {
34451
- const resolved = path10.resolve(p);
34452
- const last = p.split(path10.sep === "\\" ? /[\\/]/ : "/").at(-1);
34453
- const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(path10.sep);
34454
- return dirOnly ? `${resolved}${path10.sep}` : resolved;
34480
+ const resolved = path11.resolve(p);
34481
+ const last = p.split(path11.sep === "\\" ? /[\\/]/ : "/").at(-1);
34482
+ const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(path11.sep);
34483
+ return dirOnly ? `${resolved}${path11.sep}` : resolved;
34455
34484
  }
34456
- const base = path10.resolve(root);
34457
- return base.endsWith(path10.sep) ? `${base}${rest}` : `${base}${path10.sep}${rest}`;
34485
+ const base = path11.resolve(root);
34486
+ return base.endsWith(path11.sep) ? `${base}${rest}` : `${base}${path11.sep}${rest}`;
34458
34487
  }
34459
34488
  async function specPath(spec, args) {
34460
34489
  if (spec.kind !== "file" || !spec.paths?.length) return interpolatePath(spec.path, args);
@@ -34501,9 +34530,9 @@ function untrackArchive(archive) {
34501
34530
  process.removeListener("exit", removePendingArchives);
34502
34531
  }
34503
34532
  function sha256File(filePath, signal) {
34504
- return new Promise((resolve12, reject) => {
34533
+ return new Promise((resolve13, reject) => {
34505
34534
  const hash = createHash2("sha256");
34506
- createReadStream2(filePath, { signal }).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve12(hash.digest("hex"))).on("error", reject);
34535
+ createReadStream2(filePath, { signal }).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve13(hash.digest("hex"))).on("error", reject);
34507
34536
  });
34508
34537
  }
34509
34538
  function toolServerError(text) {
@@ -34562,7 +34591,7 @@ async function uploadTar(tarPath, format, endpoint, signal) {
34562
34591
  }
34563
34592
  async function uploadFile(sourcePath, endpoint, signal) {
34564
34593
  const format = pickArchiveFormat(endpoint.formats);
34565
- const tarPath = path10.join(tmpdir(), `argent-upload-${randomUUID4()}.tar.gz`);
34594
+ const tarPath = path11.join(tmpdir(), `argent-upload-${randomUUID4()}.tar.gz`);
34566
34595
  trackArchive(tarPath);
34567
34596
  try {
34568
34597
  await createArchiveFile(await realpath2(sourcePath), tarPath, format, signal);
@@ -34637,7 +34666,7 @@ async function prepareFileInputs(specs, args, opts) {
34637
34666
  wire.mtimeMs = st.mtimeMs;
34638
34667
  }
34639
34668
  if (opts.uploadEndpoint && st) {
34640
- process.stderr.write(`Uploading ${path10.basename(filePath)} to the remote tool-server...
34669
+ process.stderr.write(`Uploading ${path11.basename(filePath)} to the remote tool-server...
34641
34670
  `);
34642
34671
  Object.assign(wire, await uploadFile(filePath, opts.uploadEndpoint, opts.signal));
34643
34672
  }
@@ -34647,7 +34676,7 @@ async function prepareFileInputs(specs, args, opts) {
34647
34676
  return out;
34648
34677
  }
34649
34678
  function isAllowedClientFilePath(p) {
34650
- if (!path10.isAbsolute(p)) return false;
34679
+ if (!path11.isAbsolute(p)) return false;
34651
34680
  const segments = p.split(/[\\/]+/);
34652
34681
  if (segments.includes("..")) return false;
34653
34682
  const file = segments[segments.length - 1] ?? "";
@@ -34658,7 +34687,7 @@ function isClientFileDirective2(value) {
34658
34687
  return !!value && typeof value === "object" && value[CLIENT_FILE_MARKER2] === true && typeof value.path === "string" && typeof value.content === "string";
34659
34688
  }
34660
34689
  async function replaceFile(target, bytes, mode) {
34661
- const temp = path10.join(path10.dirname(target), `.baseline-${randomUUID4()}.tmp`);
34690
+ const temp = path11.join(path11.dirname(target), `.baseline-${randomUUID4()}.tmp`);
34662
34691
  try {
34663
34692
  await writeFile3(temp, bytes, { flag: "wx" });
34664
34693
  if (mode !== void 0) await chmod3(temp, mode & 511);
@@ -34669,27 +34698,27 @@ async function replaceFile(target, bytes, mode) {
34669
34698
  }
34670
34699
  }
34671
34700
  async function writeBaselineFile(file, bytes, allowedDirs) {
34672
- if (!path10.isAbsolute(file) || path10.normalize(file) !== file || file.split(/[\\/]/).includes("..") || !file.endsWith(".png") || !allowedDirs.includes(path10.dirname(file))) {
34701
+ if (!path11.isAbsolute(file) || path11.normalize(file) !== file || file.split(/[\\/]/).includes("..") || !file.endsWith(".png") || !allowedDirs.includes(path11.dirname(file))) {
34673
34702
  return allowedDirs.length === 0 ? "this call writes no baselines" : `${file} is not a baseline of this call (${allowedDirs.map((d) => `${d}/<name>.png`).join(", ")})`;
34674
34703
  }
34675
34704
  if (bytes.length > MAX_CONTENT_BYTES) {
34676
34705
  return `${file}: the baseline is larger than the 32 MiB cap on a file this client writes`;
34677
34706
  }
34678
- const dir = path10.dirname(file);
34707
+ const dir = path11.dirname(file);
34679
34708
  await mkdir3(dir, { recursive: true });
34680
34709
  const link = await lstat(file).catch(() => null);
34681
34710
  const real = link === null ? null : await realpath2(file).catch(() => null);
34682
34711
  if (link !== null && real === null) return `${file} is a symbolic link to a missing file`;
34683
34712
  if (real !== null) {
34684
34713
  if (!real.endsWith(".png")) return `${file} links to a file that is not a PNG file`;
34685
- if (path10.dirname(real) !== await realpath2(dir)) {
34714
+ if (path11.dirname(real) !== await realpath2(dir)) {
34686
34715
  return `${file} links outside its baseline directory`;
34687
34716
  }
34688
34717
  }
34689
34718
  const existing = real === null ? null : await stat3(real);
34690
34719
  if (existing !== null && !existing.isFile()) return `${file} is not a regular file`;
34691
34720
  await replaceFile(
34692
- real ?? path10.join(await realpath2(dir), path10.basename(file)),
34721
+ real ?? path11.join(await realpath2(dir), path11.basename(file)),
34693
34722
  bytes,
34694
34723
  existing?.mode
34695
34724
  );
@@ -34715,7 +34744,7 @@ async function applyClientFileDirectives(result, opts = {}) {
34715
34744
  if (isClientFileDirective2(value)) {
34716
34745
  if (!isAllowedClientFilePath(value.path)) return null;
34717
34746
  try {
34718
- await mkdir3(path10.dirname(value.path), { recursive: true });
34747
+ await mkdir3(path11.dirname(value.path), { recursive: true });
34719
34748
  await writeFile3(value.path, value.content, "utf8");
34720
34749
  written.push(value.path);
34721
34750
  return value.path;
@@ -34742,15 +34771,15 @@ async function applyClientFileDirectives(result, opts = {}) {
34742
34771
  }
34743
34772
 
34744
34773
  // ../argent-tools-client/src/flow-files.ts
34745
- var import_yaml = __toESM(require_dist2(), 1);
34774
+ var import_yaml = __toESM(require_dist3(), 1);
34746
34775
  import { readdir as readdir4, readFile as readFile4, realpath as realpath3, stat as stat4 } from "node:fs/promises";
34747
- import * as path11 from "node:path";
34776
+ import * as path12 from "node:path";
34748
34777
  var INLINE_MEMBERS_BYTES = 256 * 1024;
34749
34778
  function filesLogEnabled() {
34750
34779
  return (process.env.ARGENT_E2E_FILES_LOG ?? process.env.ARGENT_FLOW_FILES_LOG) === "1";
34751
34780
  }
34752
34781
  function isWithin(inner, outer) {
34753
- return inner === outer || inner.startsWith(outer.endsWith(path11.sep) ? outer : outer + path11.sep);
34782
+ return inner === outer || inner.startsWith(outer.endsWith(path12.sep) ? outer : outer + path12.sep);
34754
34783
  }
34755
34784
  function printable(text) {
34756
34785
  return [...text].map(
@@ -34758,7 +34787,7 @@ function printable(text) {
34758
34787
  ).join("");
34759
34788
  }
34760
34789
  function isResolvedAbsolute2(value) {
34761
- return typeof value === "string" && path11.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
34790
+ return typeof value === "string" && path12.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
34762
34791
  }
34763
34792
  function namesValidFlow(args) {
34764
34793
  let canonical;
@@ -34770,13 +34799,13 @@ function namesValidFlow(args) {
34770
34799
  const { project_root, e2e_test_path: testPath, name } = canonical;
34771
34800
  if (!isResolvedAbsolute2(project_root)) return false;
34772
34801
  if (name === void 0) {
34773
- return isResolvedAbsolute2(testPath) && FLOW_FILE_NAME_PATTERN.test(path11.basename(testPath));
34802
+ return isResolvedAbsolute2(testPath) && FLOW_FILE_NAME_PATTERN.test(path12.basename(testPath));
34774
34803
  }
34775
34804
  return testPath === void 0 && typeof name === "string" && FLOW_NAME_PATTERN.test(name);
34776
34805
  }
34777
34806
  function savedFlowProject(file) {
34778
- if (!path11.isAbsolute(file)) return null;
34779
- for (let dir = path11.dirname(file); dir !== path11.dirname(dir); dir = path11.dirname(dir)) {
34807
+ if (!path12.isAbsolute(file)) return null;
34808
+ for (let dir = path12.dirname(file); dir !== path12.dirname(dir); dir = path12.dirname(dir)) {
34780
34809
  const project = e2eDirProject(dir);
34781
34810
  if (project !== null) return project;
34782
34811
  }
@@ -34791,11 +34820,11 @@ async function landing(spelled) {
34791
34820
  const canonical = await canonicalFlowPath(spelled);
34792
34821
  let at = spelled;
34793
34822
  for (; ; ) {
34794
- const parent = path11.dirname(at);
34823
+ const parent = path12.dirname(at);
34795
34824
  if (parent === at) return { canonical, fence: spelled, ...failure2 };
34796
34825
  const real = await realpath3(parent).catch(() => null);
34797
34826
  if (real !== null) {
34798
- return { canonical, fence: path11.join(real, path11.basename(at)), ...failure2 };
34827
+ return { canonical, fence: path12.join(real, path12.basename(at)), ...failure2 };
34799
34828
  }
34800
34829
  at = parent;
34801
34830
  }
@@ -34803,10 +34832,10 @@ async function landing(spelled) {
34803
34832
  }
34804
34833
  async function closureRoots(rootPath, rootCanonical, projectRoot) {
34805
34834
  const candidates = [];
34806
- if (typeof projectRoot === "string" && path11.isAbsolute(projectRoot)) {
34835
+ if (typeof projectRoot === "string" && path12.isAbsolute(projectRoot)) {
34807
34836
  candidates.push(projectRoot, ...e2eDirsFor(projectRoot));
34808
34837
  }
34809
- candidates.push(path11.dirname(rootPath), path11.dirname(rootCanonical));
34838
+ candidates.push(path12.dirname(rootPath), path12.dirname(rootCanonical));
34810
34839
  for (const file of [rootPath, rootCanonical]) {
34811
34840
  const project = savedFlowProject(file);
34812
34841
  if (project !== null) candidates.push(project);
@@ -34819,11 +34848,11 @@ async function closureRoots(rootPath, rootCanonical, projectRoot) {
34819
34848
  return real.filter((root) => !real.some((other) => other !== root && isWithin(root, other)));
34820
34849
  }
34821
34850
  async function readFlowMember(anchorDir, target, roots, budget, opts) {
34822
- const spelled = anchorDir + path11.sep + target;
34851
+ const spelled = anchorDir + path12.sep + target;
34823
34852
  const { canonical, fence, missing, error: error2 } = await landing(spelled);
34824
34853
  const spelling = await classifyOnDiskSpelling(
34825
- path11.dirname(spelled),
34826
- path11.posix.basename(target),
34854
+ path12.dirname(spelled),
34855
+ path12.posix.basename(target),
34827
34856
  FLOW_FILE_NAME_PATTERN
34828
34857
  );
34829
34858
  const member = {
@@ -34848,7 +34877,7 @@ async function readFlowMember(anchorDir, target, roots, budget, opts) {
34848
34877
  return { member: { ...member, state: "missing" }, sent: "missing" };
34849
34878
  }
34850
34879
  if (st.isDirectory()) return refuse("EISDIR: illegal operation on a directory, read");
34851
- if (!/\.ya?ml$/i.test(path11.basename(canonical))) {
34880
+ if (!/\.ya?ml$/i.test(path12.basename(canonical))) {
34852
34881
  return refuse(`${target} links to a file that is not a YAML file`);
34853
34882
  }
34854
34883
  const sent = await sendBytes(member, canonical, budget, opts);
@@ -34973,12 +35002,12 @@ function memberCollector(roots, opts) {
34973
35002
  }
34974
35003
  async function savedTest(target) {
34975
35004
  for (const candidate of target.paths) {
34976
- const found = await flow(path11.dirname(candidate), path11.basename(candidate), true);
35005
+ const found = await flow(path12.dirname(candidate), path12.basename(candidate), true);
34977
35006
  if (found !== void 0) return found;
34978
35007
  }
34979
35008
  let first;
34980
35009
  for (const candidate of target.paths) {
34981
- first ??= await flow(path11.dirname(candidate), path11.basename(candidate));
35010
+ first ??= await flow(path12.dirname(candidate), path12.basename(candidate));
34982
35011
  }
34983
35012
  return first;
34984
35013
  }
@@ -35015,7 +35044,7 @@ function memberCollector(roots, opts) {
35015
35044
  const requests = collectFlowRequests(doc);
35016
35045
  for (const name of requests.snapshots) snapshots.add(name);
35017
35046
  for (const step of requests.toolSteps) await toolFiles(step);
35018
- const anchorDir = path11.dirname(file.canonical);
35047
+ const anchorDir = path12.dirname(file.canonical);
35019
35048
  for (const target of requests.runTargets) {
35020
35049
  const key = flowMemberKey(anchorDir, target);
35021
35050
  if (visited.has(key)) continue;
@@ -35037,8 +35066,8 @@ function memberCollector(roots, opts) {
35037
35066
  }
35038
35067
  }
35039
35068
  if (snapshots.size === 0) continue;
35040
- const dir = path11.join(
35041
- path11.dirname(run.canonical),
35069
+ const dir = path12.join(
35070
+ path12.dirname(run.canonical),
35042
35071
  "__baselines__",
35043
35072
  baselineKeyFor(run.canonical, run.flowName)
35044
35073
  );
@@ -35062,7 +35091,7 @@ function memberCollector(roots, opts) {
35062
35091
  if (!name.endsWith(".png")) continue;
35063
35092
  const compared = [...prefixes].some((prefix) => name.startsWith(prefix));
35064
35093
  if (!updates && !compared) continue;
35065
- const file = path11.join(dir, name);
35094
+ const file = path12.join(dir, name);
35066
35095
  if (tools.has(file)) continue;
35067
35096
  const member = { role: "baseline", key: file, path: file };
35068
35097
  const entry = await baselineEntry(file, roots, updates && !compared);
@@ -35085,8 +35114,8 @@ async function collectFlowMembers(rootPath, rootBytes, args, opts) {
35085
35114
  if (!namesValidFlow(args)) return {};
35086
35115
  const canonical = await canonicalFlowPath(rootPath);
35087
35116
  const spelling = await classifyOnDiskSpelling(
35088
- path11.dirname(rootPath),
35089
- path11.basename(rootPath),
35117
+ path12.dirname(rootPath),
35118
+ path12.basename(rootPath),
35090
35119
  FLOW_FILE_NAME_PATTERN
35091
35120
  );
35092
35121
  const collector = memberCollector(
@@ -35097,7 +35126,7 @@ async function collectFlowMembers(rootPath, rootBytes, args, opts) {
35097
35126
  {
35098
35127
  canonical,
35099
35128
  text: rootBytes.toString("utf8"),
35100
- flowName: path11.basename(rootPath, ".yaml"),
35129
+ flowName: path12.basename(rootPath, ".yaml"),
35101
35130
  hop: 0,
35102
35131
  updates: args.updateBaselines === true,
35103
35132
  platform: callPlatform(args)
@@ -35126,31 +35155,31 @@ async function collectStepMembers(args, opts, recordingDirFor = e2eDirFor) {
35126
35155
  if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name) || !isResolvedAbsolute2(projectRoot) || step === void 0) {
35127
35156
  return [];
35128
35157
  }
35129
- const recording = path11.join(recordingDirFor(projectRoot), `${name}.yaml`);
35158
+ const recording = path12.join(recordingDirFor(projectRoot), `${name}.yaml`);
35130
35159
  const collector = memberCollector(
35131
35160
  await closureRoots(recording, (await landing(recording)).canonical, projectRoot),
35132
35161
  opts
35133
35162
  );
35134
35163
  await collector.toolFiles(step);
35135
35164
  if (canonicalToolId(step.tool) === "e2e-execute") {
35136
- const self = await collector.flow(path11.dirname(recording), path11.basename(recording));
35165
+ const self = await collector.flow(path12.dirname(recording), path12.basename(recording));
35137
35166
  let runArgs = step.args;
35138
35167
  const named = nestedFlowTarget(runArgs);
35139
35168
  if (named?.kind === "e2e_test_path") {
35140
- const stem = path11.basename(named.path, ".yaml");
35141
- const base = path11.basename(named.path);
35142
- const dir = path11.resolve(path11.dirname(named.path));
35143
- const recordingDir = path11.dirname(recording);
35169
+ const stem = path12.basename(named.path, ".yaml");
35170
+ const base = path12.basename(named.path);
35171
+ const dir = path12.resolve(path12.dirname(named.path));
35172
+ const recordingDir = path12.dirname(recording);
35144
35173
  const dirs = [recordingDir, ...e2eRunFallbackDirs(recordingDir, base)];
35145
- if (dirs.some((d) => path11.resolve(d) === dir)) {
35146
- await collector.flow(path11.dirname(named.path), base);
35174
+ if (dirs.some((d) => path12.resolve(d) === dir)) {
35175
+ await collector.flow(path12.dirname(named.path), base);
35147
35176
  runArgs = { ...runArgs, name: stem };
35148
35177
  delete runArgs.e2e_test_path;
35149
35178
  }
35150
35179
  }
35151
35180
  const target = nestedFlowTarget(runArgs);
35152
35181
  if (target?.kind === "name") {
35153
- await collector.flow(path11.dirname(self.member.canonical), `${target.name}.yaml`);
35182
+ await collector.flow(path12.dirname(self.member.canonical), `${target.name}.yaml`);
35154
35183
  const run = await collector.nestedRun(
35155
35184
  target,
35156
35185
  0,
@@ -35344,10 +35373,10 @@ function assertFiniteNumbers(args) {
35344
35373
  if (typeof item === "object" && item !== null) {
35345
35374
  pending.push({ value: item, key, parent: visit });
35346
35375
  } else if (typeof item === "number" && !Number.isFinite(item)) {
35347
- const path18 = [key];
35348
- for (let at = visit; at.parent; at = at.parent) path18.push(at.key);
35349
- path18.reverse();
35350
- issues.push({ code: "invalid_type", path: path18, message: `expected a number, got ${item}` });
35376
+ const path19 = [key];
35377
+ for (let at = visit; at.parent; at = at.parent) path19.push(at.key);
35378
+ path19.reverse();
35379
+ issues.push({ code: "invalid_type", path: path19, message: `expected a number, got ${item}` });
35351
35380
  if (issues.length === MAX_NON_FINITE_ISSUES) break;
35352
35381
  }
35353
35382
  }
@@ -35532,7 +35561,7 @@ function createToolsClient(options = {}) {
35532
35561
  log: diagnose,
35533
35562
  baselineDirs,
35534
35563
  collectMembers: collectFlowMembers,
35535
- collectStepMembers: olderServer ? (record2, o) => collectStepMembers(record2, o, (root) => path12.join(root, LEGACY_E2E_DIRS[0])) : collectStepMembers,
35564
+ collectStepMembers: olderServer ? (record2, o) => collectStepMembers(record2, o, (root) => path13.join(root, LEGACY_E2E_DIRS[0])) : collectStepMembers,
35536
35565
  toolFileInputs: (tool) => findTool(tools, tool)?.fileInputs,
35537
35566
  signal: opts?.signal
35538
35567
  });
@@ -35545,7 +35574,7 @@ function createToolsClient(options = {}) {
35545
35574
  }
35546
35575
  if (filesLogEnabled()) {
35547
35576
  for (const file of applied.written) {
35548
- if (baselineDirs.includes(path12.dirname(file))) {
35577
+ if (baselineDirs.includes(path13.dirname(file))) {
35549
35578
  diagnose(`[e2e-files] baseline ${file}: written`);
35550
35579
  }
35551
35580
  }
@@ -35689,7 +35718,7 @@ import {
35689
35718
  } from "node:fs/promises";
35690
35719
  import { constants as fsConstants } from "node:fs";
35691
35720
  import { tmpdir as tmpdir2 } from "node:os";
35692
- import { basename as basename7, dirname as dirname9, extname as extname2, isAbsolute as isAbsolute6, join as join13, normalize as normalize2, resolve as resolve10, sep as sep5 } from "node:path";
35721
+ import { basename as basename7, extname as extname2, isAbsolute as isAbsolute6, join as join14, normalize as normalize2, resolve as resolve11, sep as sep5 } from "node:path";
35693
35722
  import { createHash as createHash3 } from "node:crypto";
35694
35723
  var ARTIFACT_MARKER2 = "__argentArtifact";
35695
35724
  function isArtifactHandle(value) {
@@ -35713,16 +35742,16 @@ function projectSlug() {
35713
35742
  return `${name}-${hash}`;
35714
35743
  }
35715
35744
  function artifactsRoot() {
35716
- return process.env.ARGENT_ARTIFACTS_DIR ?? join13(tmpdir2(), "argent-artifacts");
35745
+ return process.env.ARGENT_ARTIFACTS_DIR ?? join14(tmpdir2(), "argent-artifacts");
35717
35746
  }
35718
35747
  function artifactDir(deviceId) {
35719
35748
  const parts = [artifactsRoot(), projectSlug(), sessionId()];
35720
35749
  if (deviceId) parts.push(sanitizeSegment(deviceId));
35721
- return join13(...parts);
35750
+ return join14(...parts);
35722
35751
  }
35723
35752
  function durableBaseDir() {
35724
35753
  const projectRoot = findProjectRoot(process.cwd());
35725
- return projectRoot ?? dirname9(argentHomeDir());
35754
+ return projectRoot ?? resolveHomeDir();
35726
35755
  }
35727
35756
  var ALLOWED_SAVE_DIRS = /* @__PURE__ */ new Set([normalize2(".argent/recordings")]);
35728
35757
  var RECORDINGS_SAVE_DIR = normalize2(".argent/recordings");
@@ -35736,9 +35765,9 @@ function configuredRecordingsDir() {
35736
35765
  if (typeof value !== "string") return null;
35737
35766
  const trimmed = value.trim();
35738
35767
  if (trimmed === "") return null;
35739
- const home = dirname9(argentHomeDir());
35740
- const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep5}`) ? join13(home, trimmed.slice(2)) : trimmed;
35741
- return resolve10(durableBaseDir(), expanded);
35768
+ const home = resolveHomeDir();
35769
+ const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep5}`) ? join14(home, trimmed.slice(2)) : trimmed;
35770
+ return resolve11(durableBaseDir(), expanded);
35742
35771
  }
35743
35772
  var MAX_ARTIFACT_BYTES = 2 * 1024 * 1024 * 1024;
35744
35773
  async function readCapped(res, cap) {
@@ -35771,10 +35800,10 @@ async function writeDurableUnique(dir, filename, write) {
35771
35800
  const stem = filename.slice(0, filename.length - ext.length);
35772
35801
  for (let i = 1; i <= 1e3; i++) {
35773
35802
  const candidate = i === 1 ? filename : `${stem} (${i})${ext}`;
35774
- const path18 = join13(dir, candidate);
35803
+ const path19 = join14(dir, candidate);
35775
35804
  try {
35776
- await write(path18);
35777
- return path18;
35805
+ await write(path19);
35806
+ return path19;
35778
35807
  } catch (err) {
35779
35808
  if (err?.code === "EEXIST") continue;
35780
35809
  throw err;
@@ -35794,21 +35823,21 @@ function durableSaveTarget(handle) {
35794
35823
  if (configured) {
35795
35824
  return {
35796
35825
  dir: configured,
35797
- path: join13(configured, sanitizeSegment(handle.filename)),
35826
+ path: join14(configured, sanitizeSegment(handle.filename)),
35798
35827
  base: configured,
35799
35828
  rel: ""
35800
35829
  };
35801
35830
  }
35802
35831
  }
35803
35832
  const base = durableBaseDir();
35804
- const dir = join13(base, rel);
35805
- return { dir, path: join13(dir, sanitizeSegment(handle.filename)), base, rel };
35833
+ const dir = join14(base, rel);
35834
+ return { dir, path: join14(dir, sanitizeSegment(handle.filename)), base, rel };
35806
35835
  }
35807
35836
  async function confineToRealBase(dir, base, rel) {
35808
35837
  try {
35809
35838
  const realDir = await realpath4(dir);
35810
35839
  const realBase = await realpath4(base);
35811
- return realDir === join13(realBase, rel);
35840
+ return realDir === join14(realBase, rel);
35812
35841
  } catch {
35813
35842
  return false;
35814
35843
  }
@@ -35832,9 +35861,9 @@ async function resolveLocalFile(handle) {
35832
35861
  }
35833
35862
  async function downloadAndExtractArchive(handle, data, dir, signal) {
35834
35863
  signal?.throwIfAborted();
35835
- const attemptDir = await mkdtemp(join13(dir, "bundle-"));
35836
- const tarball = join13(attemptDir, "download.tar");
35837
- const extractDir = join13(attemptDir, "files");
35864
+ const attemptDir = await mkdtemp(join14(dir, "bundle-"));
35865
+ const tarball = join14(attemptDir, "download.tar");
35866
+ const extractDir = join14(attemptDir, "files");
35838
35867
  try {
35839
35868
  await writeFile4(tarball, data, { signal });
35840
35869
  await mkdir4(extractDir);
@@ -35934,7 +35963,7 @@ async function materializeArtifacts(result, ctx) {
35934
35963
  return await downloadAndExtractArchive(value, data, dir, ctx.signal);
35935
35964
  }
35936
35965
  if (value.size > 0 && data.length !== value.size) return null;
35937
- const downloadedPath = join13(dir, sanitizeSegment(value.filename));
35966
+ const downloadedPath = join14(dir, sanitizeSegment(value.filename));
35938
35967
  await writeFile4(downloadedPath, data);
35939
35968
  if (value.mimeType.startsWith("image/")) {
35940
35969
  images.push({ localPath: downloadedPath, data, mimeType: value.mimeType });
@@ -35971,7 +36000,7 @@ function getDeviceIdFromArgs(args) {
35971
36000
  import * as fs8 from "node:fs";
35972
36001
 
35973
36002
  // ../telemetry/src/paths.ts
35974
- import * as path13 from "node:path";
36003
+ import * as path14 from "node:path";
35975
36004
 
35976
36005
  // ../telemetry/src/events.ts
35977
36006
  var PLATFORMS = [
@@ -36304,22 +36333,22 @@ var SESSION_ID2 = randomUUID5();
36304
36333
  // ../telemetry/src/identity.ts
36305
36334
  import * as crypto2 from "node:crypto";
36306
36335
  import * as fs9 from "node:fs";
36307
- import * as path14 from "node:path";
36336
+ import * as path15 from "node:path";
36308
36337
 
36309
36338
  // ../telemetry/src/fingerprint.ts
36310
36339
  import { execFileSync as execFileSync2, spawn as spawn3 } from "node:child_process";
36311
36340
 
36312
36341
  // ../native-devtools-ios/src/index.ts
36313
- import * as path15 from "node:path";
36342
+ import * as path16 from "node:path";
36314
36343
  import * as fs10 from "node:fs";
36315
- var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ?? path15.join(__dirname, "..", "dylibs");
36316
- var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ?? path15.join(__dirname, "..", "bin");
36317
- var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ?? path15.join(DYLIB_DIR, "tcp");
36318
- var DYLIB_TVOS_DIR = path15.join(DYLIB_DIR, "tvos");
36344
+ var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ?? path16.join(__dirname, "..", "dylibs");
36345
+ var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ?? path16.join(__dirname, "..", "bin");
36346
+ var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ?? path16.join(DYLIB_DIR, "tcp");
36347
+ var DYLIB_TVOS_DIR = path16.join(DYLIB_DIR, "tvos");
36319
36348
 
36320
36349
  // ../telemetry/src/consent.ts
36321
36350
  import * as fs11 from "node:fs";
36322
- import * as path16 from "node:path";
36351
+ import * as path17 from "node:path";
36323
36352
  var cache = /* @__PURE__ */ new Map();
36324
36353
  var sessionOverride = null;
36325
36354
  function readConfigOverrideAt(filePath) {
@@ -36360,8 +36389,12 @@ function readConfigOverrideAt(filePath) {
36360
36389
  function readPersistedConsent(cwd) {
36361
36390
  const globalPath = configFilePath("global");
36362
36391
  const projectPath = configFilePath("project", { cwd });
36392
+ const userConfigPath = path17.join(resolveHomeDir(), ".argent", "config.json");
36393
+ if (userConfigPath !== globalPath && readConfigOverrideAt(userConfigPath) === false) {
36394
+ return { enabled: false, detail: `${userConfigPath} (user)` };
36395
+ }
36363
36396
  const global = readConfigOverrideAt(globalPath);
36364
- const projectRoot = path16.dirname(path16.dirname(projectPath));
36397
+ const projectRoot = path17.dirname(path17.dirname(projectPath));
36365
36398
  const project = isHomeDir(projectRoot) ? null : readConfigOverrideAt(projectPath);
36366
36399
  if (project === false && global === false) {
36367
36400
  return { enabled: false, detail: "config.json (project and global)" };
@@ -36741,8 +36774,13 @@ async function flowRunToMcpContent(result, ctx) {
36741
36774
  });
36742
36775
  if (typeof result.warning === "string")
36743
36776
  blocks.push({ type: "text", text: `\u26A0 ${result.warning}` });
36777
+ let inShutdown = false;
36744
36778
  for (let i = 0; i < result.steps.length; i++) {
36745
36779
  const step = result.steps[i];
36780
+ if (step.shutdown === true && !inShutdown) {
36781
+ inShutdown = true;
36782
+ blocks.push({ type: "text", text: "shutdown:" });
36783
+ }
36746
36784
  const num = step.index !== void 0 ? step.index + 1 : i + 1;
36747
36785
  const glyph = step.status ? `${STATUS_GLYPH[step.status] ?? "\u2022"} ` : "";
36748
36786
  const reason = step.reason ?? step.error;
@@ -36769,11 +36807,17 @@ async function flowRunToMcpContent(result, ctx) {
36769
36807
  }
36770
36808
  }
36771
36809
  for (const write of result.baselineWrites ?? []) {
36772
- const { path: path18, error: error2 } = isRecord3(write) ? write : {};
36773
- if (typeof path18 === "string" && typeof error2 === "string") {
36774
- blocks.push({ type: "text", text: `\u2717 baseline not written: ${path18}: ${error2}` });
36810
+ const { path: path19, error: error2 } = isRecord3(write) ? write : {};
36811
+ if (typeof path19 === "string" && typeof error2 === "string") {
36812
+ blocks.push({ type: "text", text: `\u2717 baseline not written: ${path19}: ${error2}` });
36775
36813
  }
36776
36814
  }
36815
+ if (result.shutdownFailed === true) {
36816
+ blocks.push({
36817
+ type: "text",
36818
+ text: "\u26A0 shutdown did not finish: a shutdown step failed, so the run may have left state behind."
36819
+ });
36820
+ }
36777
36821
  if (result.ok !== void 0) {
36778
36822
  const counted = (result.passed ?? 0) + (result.failed ?? 0) + (result.errored ?? 0) + (result.skipped ?? 0);
36779
36823
  const note = result.ok && counted === 0 ? " (no test steps)" : "";
@@ -37817,14 +37861,14 @@ function debuggerLogRegistryText(result) {
37817
37861
  }
37818
37862
 
37819
37863
  // ../argent-mcp/src/instructions.ts
37820
- var SERVER_INSTRUCTIONS = "Argent \u2014 iOS Simulator, Android Emulator, and Chromium app control for interacting, testing, profiling and debugging mobile and Chromium applications. Use the platform the user named; otherwise prefer a device list-devices shows already running, and do not default to iOS. In a single-platform project, boot that platform. Prefer these tools over raw xcrun or adb commands, which are a fallback. Prefer launch-app or open-url over tapping home-screen icons. If the task may need a saved e2e test, load the argent-create-e2e skill (argent-qa-e2e for acceptance tests) before the first launch or in-app action: recording is not retroactive. Load the matching argent-* skill before React Native build or debug work, profiling, a physical phone, a Mac app or a TV. Interaction tools return the screen after the action: a screenshot plus the accessibility element tree with normalized tap frames. Take coordinates from that tree; call describe only when no fresh tree is available \u2014 never guess coordinates from pixels. When the screenshot or tree matches (or the tree differs slightly from) an earlier result, it names that earlier result by its screenshot or tree id (unchanged note or `-` gone / `+` new lines) in place of repeating it. If a tap fails twice, stop retrying and call a discovery tool again. Use await-ui-element to wait for the UI instead of polling with screenshots. Do not stop simulator servers when a task finishes: the next task reuses them. Call stop-all-simulator-servers when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services, always with devices: [...] naming the devices this session used. Never stop a Metro the user started unless they ask. One tool-server is shared by every agent using this argent install, so an unscoped call tears down their devices too \u2014 reserve it for a deliberate machine-wide cleanup. The argent CLI manages the toolkit: argent --help lists its commands.";
37864
+ var SERVER_INSTRUCTIONS = "Argent controls iOS, Android, Chromium, Mac, TV, and HarmonyOS apps. Use the platform named by the user; otherwise prefer an already-running device from `list-devices` (do not default to iOS). In a single-platform project, boot that platform. Prefer Argent tools over raw `xcrun`/`adb`; use `launch-app`/`open-url` instead of tapping home-screen icons. Load `argent-create-e2e` (`argent-qa-e2e` for acceptance tests) before the first action if an e2e test may be needed (recording is not retroactive), and load the matching `argent-*` skill before React Native build/debug, profiling, physical phone, Mac app, or TV work. Interaction tools return a screenshot + accessibility tree with normalized [0,1] tap frames (or an unchanged note / `-`+`+` diff referencing an earlier screenshot/tree id). Take tap coordinates from that tree \u2014 never guess from pixels \u2014 and call `describe` only without a fresh tree. After two failed taps, re-discover. Use `await-ui-element` instead of polling. Do not stop simulator servers when finishing; call `stop-all-simulator-servers` only when asked to clean up or when a skill tells you to recycle a device's services, scoped with `devices: [...]` (the tool-server is shared across agents), and never stop a user-started Metro. CLI: `argent --help`.";
37821
37865
 
37822
37866
  // ../argent-mcp/src/installed-version.ts
37823
37867
  import * as fs12 from "node:fs";
37824
- import * as path17 from "node:path";
37868
+ import * as path18 from "node:path";
37825
37869
  function getInstalledVersion() {
37826
37870
  try {
37827
- const pkgPath = path17.resolve(import.meta.dirname, "..", "package.json");
37871
+ const pkgPath = path18.resolve(import.meta.dirname, "..", "package.json");
37828
37872
  const pkg = JSON.parse(fs12.readFileSync(pkgPath, "utf8"));
37829
37873
  return pkg.version ?? "unknown";
37830
37874
  } catch {
@@ -37880,9 +37924,9 @@ async function untilAborted(work, signal) {
37880
37924
  }
37881
37925
  let onAbort = () => {
37882
37926
  };
37883
- const aborted2 = new Promise((resolve12) => {
37884
- onAbort = resolve12;
37885
- if (signal.aborted) resolve12();
37927
+ const aborted2 = new Promise((resolve13) => {
37928
+ onAbort = resolve13;
37929
+ if (signal.aborted) resolve13();
37886
37930
  else signal.addEventListener("abort", onAbort, { once: true });
37887
37931
  });
37888
37932
  try {
@@ -37943,6 +37987,94 @@ function createToolCaller(deps) {
37943
37987
  };
37944
37988
  }
37945
37989
 
37990
+ // ../argent-mcp/src/call-log.ts
37991
+ import {
37992
+ appendFileSync as appendFileSync2,
37993
+ chmodSync as chmodSync2,
37994
+ linkSync as linkSync2,
37995
+ mkdirSync as mkdirSync6,
37996
+ readFileSync as readFileSync8,
37997
+ renameSync as renameSync4,
37998
+ rmSync as rmSync3,
37999
+ statSync as statSync4
38000
+ } from "node:fs";
38001
+ import { appendFile } from "node:fs/promises";
38002
+ import { dirname as dirname10 } from "node:path";
38003
+ var CALL_LOG_MAX_BYTES = 10 * 1024 * 1024;
38004
+ var STAT_EVERY_BYTES = 1024 * 1024;
38005
+ function createCallLog(file, maxBytes = CALL_LOG_MAX_BYTES) {
38006
+ let dirReady = false;
38007
+ let checked = false;
38008
+ let estimate = 0;
38009
+ let sinceStat = 0;
38010
+ function check() {
38011
+ sinceStat = 0;
38012
+ estimate = 0;
38013
+ const st = statSync4(file, { throwIfNoEntry: false });
38014
+ if (!st) return;
38015
+ if (st.mode & 63) {
38016
+ try {
38017
+ chmodSync2(file, st.mode & 448);
38018
+ } catch {
38019
+ }
38020
+ }
38021
+ if (st.size < maxBytes) {
38022
+ estimate = st.size;
38023
+ return;
38024
+ }
38025
+ rotate(file, st);
38026
+ }
38027
+ return async function write(entry) {
38028
+ try {
38029
+ if (!dirReady) {
38030
+ mkdirSync6(dirname10(file), { recursive: true, mode: 448 });
38031
+ dirReady = true;
38032
+ }
38033
+ if (!checked || estimate >= maxBytes || sinceStat >= STAT_EVERY_BYTES) {
38034
+ checked = true;
38035
+ check();
38036
+ }
38037
+ const line = JSON.stringify(entry) + "\n";
38038
+ const bytes = Buffer.byteLength(line);
38039
+ estimate += bytes;
38040
+ sinceStat += bytes;
38041
+ await appendFile(file, line, { mode: 384 });
38042
+ } catch {
38043
+ }
38044
+ };
38045
+ }
38046
+ function rotate(file, measured) {
38047
+ const aside = `${file}.${process.pid}.rotating`;
38048
+ try {
38049
+ renameSync4(file, aside);
38050
+ } catch {
38051
+ return;
38052
+ }
38053
+ let moved;
38054
+ try {
38055
+ moved = statSync4(aside);
38056
+ } catch {
38057
+ return;
38058
+ }
38059
+ if (moved.ino === measured.ino && moved.dev === measured.dev) {
38060
+ try {
38061
+ renameSync4(aside, `${file}.1`);
38062
+ } catch {
38063
+ }
38064
+ return;
38065
+ }
38066
+ try {
38067
+ linkSync2(aside, file);
38068
+ } catch {
38069
+ try {
38070
+ appendFileSync2(file, readFileSync8(aside), { mode: 384 });
38071
+ } catch {
38072
+ return;
38073
+ }
38074
+ }
38075
+ rmSync3(aside, { force: true });
38076
+ }
38077
+
37946
38078
  // ../argent-mcp/src/whats-new.ts
37947
38079
  var import_semver = __toESM(require_semver2(), 1);
37948
38080
 
@@ -37987,11 +38119,15 @@ function formatWhatsNewNote(version2, highlights) {
37987
38119
  ].join("\n");
37988
38120
  }
37989
38121
  function takeWhatsNewNote(current) {
37990
- const seen = getWhatsNewSeenVersion();
37991
- if (!isNewerThanSeen(current, seen)) return void 0;
37992
- setWhatsNewSeenVersion(current);
37993
- const highlights = highlightsSince(seen, current);
37994
- return highlights.length > 0 ? formatWhatsNewNote(current, highlights) : void 0;
38122
+ let seen = getWhatsNewSeenVersion();
38123
+ while (isNewerThanSeen(current, seen)) {
38124
+ if (setWhatsNewSeenVersion(current, { ifSeen: seen })) {
38125
+ const highlights = highlightsSince(seen, current);
38126
+ return highlights.length > 0 ? formatWhatsNewNote(current, highlights) : void 0;
38127
+ }
38128
+ seen = getWhatsNewSeenVersion();
38129
+ }
38130
+ return void 0;
37995
38131
  }
37996
38132
 
37997
38133
  // ../argent-mcp/src/mcp-server.ts
@@ -38017,6 +38153,8 @@ async function startMcpServer(options) {
38017
38153
  const autoScreenshotOn = autoScreenshotEnabled();
38018
38154
  const autoDescribeOn = autoDescribeEnabled();
38019
38155
  const whatsNewOn = whatsNewEnabled();
38156
+ const installedVersion = getInstalledVersion();
38157
+ const highlightsVersion = true ? "0.35.1-next.30" : installedVersion;
38020
38158
  const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
38021
38159
  const trees = createTreeMemory();
38022
38160
  const screenshots = createScreenshotMemory();
@@ -38061,18 +38199,8 @@ async function startMcpServer(options) {
38061
38199
  }
38062
38200
  return reconnectPromise;
38063
38201
  }
38064
- const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? `${homedir5()}/.argent/mcp-calls.log`;
38065
- let logDirReady = false;
38066
- async function spyLog(entry) {
38067
- try {
38068
- if (!logDirReady) {
38069
- await mkdir5(dirname11(LOG_FILE2), { recursive: true });
38070
- logDirReady = true;
38071
- }
38072
- await appendFile(LOG_FILE2, JSON.stringify(entry) + "\n");
38073
- } catch {
38074
- }
38075
- }
38202
+ const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? join19(argentHomeDir(), "mcp-calls.log");
38203
+ const spyLog = createCallLog(LOG_FILE2);
38076
38204
  const { fetchTools, callTool } = createToolCaller({
38077
38205
  getHandle: () => ({ url: TOOLS_URL, token: AUTH_TOKEN }),
38078
38206
  remote,
@@ -38183,14 +38311,14 @@ ${shown.text}` }];
38183
38311
  if (!whatsNewOn || whatsNewChecked) return [];
38184
38312
  whatsNewChecked = true;
38185
38313
  try {
38186
- const note = takeWhatsNewNote(getInstalledVersion());
38314
+ const note = takeWhatsNewNote(highlightsVersion);
38187
38315
  return note ? [{ type: "text", text: note }] : [];
38188
38316
  } catch {
38189
38317
  return [];
38190
38318
  }
38191
38319
  }
38192
38320
  const server = new Server(
38193
- { name: "argent", version: getInstalledVersion() },
38321
+ { name: "argent", version: installedVersion },
38194
38322
  {
38195
38323
  capabilities: { tools: {} },
38196
38324
  instructions: SERVER_INSTRUCTIONS
@@ -38269,7 +38397,7 @@ ${shown.text}` }];
38269
38397
  content = [...content, { type: "text", text: screenshotIdLine(id) }];
38270
38398
  }
38271
38399
  }
38272
- if (udid && autoDescribeOn && canonicalToolId(params.name) === "describe") {
38400
+ if (udid && autoDescribeOn && canonicalToolId(params.name) === "describe" && params.arguments?.raw !== true) {
38273
38401
  const tree = describedTree(result);
38274
38402
  if (tree !== void 0) {
38275
38403
  treeUdid = udid;