@swmansion/argent 0.35.1-next.2 → 0.35.1-next.21

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 (52) hide show
  1. package/bin/argent-android-devtools-0.4.0.apk +0 -0
  2. package/bin/darwin/argent-macos-helper +0 -0
  3. package/bin/darwin/ax-service +0 -0
  4. package/bin/darwin/tvos-ax-service +0 -0
  5. package/bin/darwin/tvos-hid-daemon +0 -0
  6. package/bin/network-inspector/network-inspector.jar +0 -0
  7. package/bin/tcp/ax-service +0 -0
  8. package/dist/cli-cmds.mjs +1782 -1642
  9. package/dist/client.js +267 -250
  10. package/dist/fatal-handlers.js +7 -1
  11. package/dist/fatal-handlers.js.map +1 -1
  12. package/dist/installer.mjs +768 -550
  13. package/dist/mcp-server.mjs +1224 -1173
  14. package/dist/tool-args.generated.d.ts +353 -317
  15. package/dist/tool-server.cjs +103309 -101972
  16. package/dylibs/libArgentAudio.dylib +0 -0
  17. package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
  18. package/dylibs/libKeyboardPatch.dylib +0 -0
  19. package/dylibs/libNativeDevtoolsIos.dylib +0 -0
  20. package/dylibs/macos/libArgentInjectionBootstrap.dylib +0 -0
  21. package/dylibs/macos/libNativeDevtoolsMacos.dylib +0 -0
  22. package/dylibs/tcp/argent-audio-feeder +0 -0
  23. package/dylibs/tcp/libArgentAudio.dylib +0 -0
  24. package/dylibs/tcp/libArgentInjectionBootstrap.dylib +0 -0
  25. package/dylibs/tcp/libKeyboardPatch.dylib +0 -0
  26. package/dylibs/tcp/libNativeDevtoolsIos.dylib +0 -0
  27. package/dylibs/tvos/libArgentInjectionBootstrap.dylib +0 -0
  28. package/dylibs/tvos/libKeyboardPatch.dylib +0 -0
  29. package/dylibs/tvos/libNativeDevtoolsIos.dylib +0 -0
  30. package/package.json +2 -2
  31. package/skills/argent-android-emulator-setup/SKILL.md +2 -2
  32. package/skills/argent-create-e2e/SKILL.md +1 -1
  33. package/skills/argent-create-e2e/references/e2e-yaml.md +23 -2
  34. package/skills/argent-create-e2e/references/live-authoring.md +9 -0
  35. package/skills/argent-device-interact/SKILL.md +21 -94
  36. package/skills/argent-device-interact/references/advanced.md +64 -0
  37. package/skills/argent-ios-device-interact/SKILL.md +1 -1
  38. package/skills/argent-ios-device-setup/SKILL.md +1 -1
  39. package/skills/argent-ios-simulator-setup/SKILL.md +1 -1
  40. package/skills/argent-lens/SKILL.md +1 -1
  41. package/skills/argent-macos-app-interact/SKILL.md +1 -1
  42. package/skills/argent-metro-debugger/SKILL.md +1 -1
  43. package/skills/argent-native-profiler/SKILL.md +1 -1
  44. package/skills/argent-qa-e2e/SKILL.md +1 -1
  45. package/skills/argent-react-native-app-workflow/SKILL.md +1 -1
  46. package/skills/argent-react-native-optimization/SKILL.md +1 -1
  47. package/skills/argent-react-native-profiler/SKILL.md +1 -1
  48. package/skills/argent-screen-recording/SKILL.md +1 -1
  49. package/skills/argent-screenshot-diff/SKILL.md +1 -1
  50. package/skills/argent-settings-permissions/SKILL.md +1 -1
  51. package/skills/argent-test-ui-flow/SKILL.md +1 -1
  52. 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) {
@@ -22308,8 +22308,7 @@ var require_semver2 = __commonJS({
22308
22308
 
22309
22309
  // ../argent-mcp/src/mcp-server.ts
22310
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";
22311
+ import { dirname as dirname10, join as join19 } from "node:path";
22313
22312
  import { setTimeout as sleep } from "node:timers/promises";
22314
22313
 
22315
22314
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
@@ -22552,10 +22551,10 @@ function mergeDefs(...defs) {
22552
22551
  function cloneDef(schema) {
22553
22552
  return mergeDefs(schema._zod.def);
22554
22553
  }
22555
- function getElementAtPath(obj, path18) {
22556
- if (!path18)
22554
+ function getElementAtPath(obj, path19) {
22555
+ if (!path19)
22557
22556
  return obj;
22558
- return path18.reduce((acc, key) => acc?.[key], obj);
22557
+ return path19.reduce((acc, key) => acc?.[key], obj);
22559
22558
  }
22560
22559
  function promiseAllObject(promisesObj) {
22561
22560
  const keys = Object.keys(promisesObj);
@@ -22895,11 +22894,11 @@ function explicitlyAborted(x, startIndex = 0) {
22895
22894
  }
22896
22895
  return false;
22897
22896
  }
22898
- function prefixIssues(path18, issues) {
22897
+ function prefixIssues(path19, issues) {
22899
22898
  return issues.map((iss) => {
22900
22899
  var _a3;
22901
22900
  (_a3 = iss).path ?? (_a3.path = []);
22902
- iss.path.unshift(path18);
22901
+ iss.path.unshift(path19);
22903
22902
  return iss;
22904
22903
  });
22905
22904
  }
@@ -23357,16 +23356,16 @@ function flattenError(error2, mapper = (issue2) => issue2.message) {
23357
23356
  }
23358
23357
  function formatError(error2, mapper = (issue2) => issue2.message) {
23359
23358
  const fieldErrors = { _errors: [] };
23360
- const processError = (error3, path18 = []) => {
23359
+ const processError = (error3, path19 = []) => {
23361
23360
  for (const issue2 of error3.issues) {
23362
23361
  if (issue2.code === "invalid_union" && issue2.errors.length) {
23363
- issue2.errors.map((issues) => processError({ issues }, [...path18, ...issue2.path]));
23362
+ issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
23364
23363
  } else if (issue2.code === "invalid_key") {
23365
- processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
23364
+ processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
23366
23365
  } else if (issue2.code === "invalid_element") {
23367
- processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
23366
+ processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
23368
23367
  } else {
23369
- const fullpath = [...path18, ...issue2.path];
23368
+ const fullpath = [...path19, ...issue2.path];
23370
23369
  if (fullpath.length === 0) {
23371
23370
  fieldErrors._errors.push(mapper(issue2));
23372
23371
  } else {
@@ -25666,7 +25665,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
25666
25665
  var NONE = 0;
25667
25666
  var ASSUMED = 1;
25668
25667
  var PROVEN = 2;
25669
- function isRecursive(inst, stack, resolve12) {
25668
+ function isRecursive(inst, stack, resolve13) {
25670
25669
  const cached2 = recursive.get(inst);
25671
25670
  if (cached2 !== void 0)
25672
25671
  return cached2 ? PROVEN : NONE;
@@ -25676,7 +25675,7 @@ function isRecursive(inst, stack, resolve12) {
25676
25675
  let result = NONE;
25677
25676
  const check = (child) => {
25678
25677
  if (result !== PROVEN && child?._zod) {
25679
- const answer = isRecursive(child, stack, resolve12);
25678
+ const answer = isRecursive(child, stack, resolve13);
25680
25679
  if (answer > result)
25681
25680
  result = answer;
25682
25681
  }
@@ -25687,7 +25686,7 @@ function isRecursive(inst, stack, resolve12) {
25687
25686
  const desc = Object.getOwnPropertyDescriptor(sh, key);
25688
25687
  if (spread && !desc.enumerable)
25689
25688
  continue;
25690
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve12) : NONE;
25689
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve13) : NONE;
25691
25690
  if (child > answer)
25692
25691
  answer = child;
25693
25692
  }
@@ -25751,7 +25750,7 @@ function isRecursive(inst, stack, resolve12) {
25751
25750
  break;
25752
25751
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
25753
25752
  case "lazy": {
25754
- const inner = def._cachedInner ?? (resolve12 ? inst._zod.innerType : void 0);
25753
+ const inner = def._cachedInner ?? (resolve13 ? inst._zod.innerType : void 0);
25755
25754
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
25756
25755
  break;
25757
25756
  }
@@ -30329,12 +30328,12 @@ var StdioServerTransport = class {
30329
30328
  this.onclose?.();
30330
30329
  }
30331
30330
  send(message) {
30332
- return new Promise((resolve12) => {
30331
+ return new Promise((resolve13) => {
30333
30332
  const json = serializeMessage(message);
30334
30333
  if (this._stdout.write(json)) {
30335
- resolve12();
30334
+ resolve13();
30336
30335
  } else {
30337
- this._stdout.once("drain", resolve12);
30336
+ this._stdout.once("drain", resolve13);
30338
30337
  }
30339
30338
  });
30340
30339
  }
@@ -30954,7 +30953,7 @@ var Protocol = class {
30954
30953
  return;
30955
30954
  }
30956
30955
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
30957
- await new Promise((resolve12) => setTimeout(resolve12, pollInterval));
30956
+ await new Promise((resolve13) => setTimeout(resolve13, pollInterval));
30958
30957
  options?.signal?.throwIfAborted();
30959
30958
  }
30960
30959
  } catch (error2) {
@@ -30971,7 +30970,7 @@ var Protocol = class {
30971
30970
  */
30972
30971
  request(request, resultSchema, options) {
30973
30972
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
30974
- return new Promise((resolve12, reject) => {
30973
+ return new Promise((resolve13, reject) => {
30975
30974
  const earlyReject = (error2) => {
30976
30975
  reject(error2);
30977
30976
  };
@@ -31049,7 +31048,7 @@ var Protocol = class {
31049
31048
  if (!parseResult.success) {
31050
31049
  reject(parseResult.error);
31051
31050
  } else {
31052
- resolve12(parseResult.data);
31051
+ resolve13(parseResult.data);
31053
31052
  }
31054
31053
  } catch (error2) {
31055
31054
  reject(error2);
@@ -31311,12 +31310,12 @@ var Protocol = class {
31311
31310
  }
31312
31311
  } catch {
31313
31312
  }
31314
- return new Promise((resolve12, reject) => {
31313
+ return new Promise((resolve13, reject) => {
31315
31314
  if (signal.aborted) {
31316
31315
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
31317
31316
  return;
31318
31317
  }
31319
- const timeoutId = setTimeout(resolve12, interval);
31318
+ const timeoutId = setTimeout(resolve13, interval);
31320
31319
  signal.addEventListener("abort", () => {
31321
31320
  clearTimeout(timeoutId);
31322
31321
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -32098,505 +32097,36 @@ var Server = class extends Protocol {
32098
32097
 
32099
32098
  // ../argent-tools-client/src/launcher.ts
32100
32099
  import * as net from "node:net";
32101
- import * as fs from "node:fs";
32102
- import * as path from "node:path";
32100
+ import * as fs5 from "node:fs";
32101
+ import * as path7 from "node:path";
32103
32102
  import * as readline from "node:readline";
32104
- import { homedir } from "node:os";
32105
32103
  import { spawn, execFileSync } from "node:child_process";
32106
32104
  import { createHash, randomBytes } from "node:crypto";
32107
32105
  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
- }
32106
+
32107
+ // ../configuration-core/src/flags.ts
32108
+ import * as fs from "node:fs";
32109
+ import * as path2 from "node:path";
32110
+
32111
+ // ../configuration-core/src/home.ts
32112
+ import * as os from "node:os";
32113
+ import * as path from "node:path";
32114
+ var ARGENT_HOME_DIR_ENV = "ARGENT_HOME_DIR";
32115
+ function nonEmpty(value) {
32116
+ if (value == void 0) return null;
32117
+ const trimmed = value.trim();
32118
+ return trimmed === "" ? null : value;
32527
32119
  }
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 ?? "" };
32120
+ function resolveHomeDir(options = {}) {
32121
+ if (options.homeDir) return options.homeDir;
32122
+ return process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
32543
32123
  }
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
- }
32124
+ function argentHomeDir(options = {}) {
32125
+ const override = options.homeDir ? null : nonEmpty(process.env[ARGENT_HOME_DIR_ENV]);
32126
+ return override ? path.resolve(override.trim()) : path.join(resolveHomeDir(options), ".argent");
32588
32127
  }
32589
32128
 
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
32129
  // ../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
32130
  var FLAG_REGISTRY = [
32601
32131
  {
32602
32132
  name: "disable-auto-screenshot",
@@ -32663,7 +32193,7 @@ function findProjectRoot(startDir) {
32663
32193
  let current = path2.resolve(startDir);
32664
32194
  while (true) {
32665
32195
  for (const marker of PROJECT_MARKERS) {
32666
- if (fs2.existsSync(path2.join(current, marker))) return current;
32196
+ if (fs.existsSync(path2.join(current, marker))) return current;
32667
32197
  }
32668
32198
  const parent = path2.dirname(current);
32669
32199
  if (parent === current) return null;
@@ -32674,9 +32204,8 @@ function resolveProjectRoot(startDir) {
32674
32204
  return findProjectRoot(startDir) ?? path2.resolve(startDir);
32675
32205
  }
32676
32206
  function getFlagsPath(scope, options = {}) {
32677
- const home = options.homeDir ?? homedir2();
32678
32207
  if (scope === "global") {
32679
- return path2.join(home, ".argent", "flags.json");
32208
+ return path2.join(argentHomeDir({ homeDir: options.homeDir }), "flags.json");
32680
32209
  }
32681
32210
  const cwd = options.cwd ?? process.cwd();
32682
32211
  return path2.join(resolveProjectRoot(cwd), ".argent", "flags.json");
@@ -32684,7 +32213,7 @@ function getFlagsPath(scope, options = {}) {
32684
32213
  function readFlagsFile(filePath) {
32685
32214
  let raw2;
32686
32215
  try {
32687
- raw2 = fs2.readFileSync(filePath, "utf8");
32216
+ raw2 = fs.readFileSync(filePath, "utf8");
32688
32217
  } catch {
32689
32218
  return {};
32690
32219
  }
@@ -32721,35 +32250,20 @@ function isFeatureEnabled(name, options = {}, registry2 = FLAG_REGISTRY) {
32721
32250
  }
32722
32251
 
32723
32252
  // ../configuration-core/src/paths.ts
32724
- import * as fs3 from "node:fs";
32725
- import * as os from "node:os";
32253
+ import * as fs2 from "node:fs";
32726
32254
  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
32255
  function isHomeDir(dir, options = {}) {
32737
32256
  return canonicalPath(dir) === canonicalPath(resolveHomeDir(options));
32738
32257
  }
32739
32258
  function canonicalPath(p) {
32740
32259
  try {
32741
- return fs3.realpathSync.native(p);
32260
+ return fs2.realpathSync.native(p);
32742
32261
  } catch {
32743
32262
  return path3.resolve(p);
32744
32263
  }
32745
32264
  }
32746
- function argentHomeDir() {
32747
- return path3.join(resolveHomeDir(), ".argent");
32748
- }
32749
32265
  function configDir(scope = "global", options = {}) {
32750
- if (scope === "global") {
32751
- return path3.join(resolveHomeDir(options), ".argent");
32752
- }
32266
+ if (scope === "global") return argentHomeDir(options);
32753
32267
  const cwd = options.cwd ?? process.cwd();
32754
32268
  return path3.join(resolveProjectRoot(cwd), ".argent");
32755
32269
  }
@@ -32759,11 +32273,11 @@ function configFilePath(scope = "global", options = {}) {
32759
32273
 
32760
32274
  // ../configuration-core/src/config.ts
32761
32275
  import * as crypto from "node:crypto";
32762
- import * as fs4 from "node:fs";
32276
+ import * as fs3 from "node:fs";
32763
32277
  import * as path4 from "node:path";
32764
32278
  function readConfigObject(scope = "global", options = {}) {
32765
32279
  try {
32766
- const raw2 = fs4.readFileSync(configFilePath(scope, options), "utf8");
32280
+ const raw2 = fs3.readFileSync(configFilePath(scope, options), "utf8");
32767
32281
  const json = JSON.parse(raw2);
32768
32282
  if (json && typeof json === "object" && !Array.isArray(json)) {
32769
32283
  return json;
@@ -32810,7 +32324,7 @@ function setAtPath(obj, dottedKey, value) {
32810
32324
  }
32811
32325
  cur[parts[parts.length - 1]] = value;
32812
32326
  }
32813
- var LOCK_STALE_MS2 = 1e4;
32327
+ var LOCK_STALE_MS = 1e4;
32814
32328
  var LOCK_MAX_WAIT_MS = 2e3;
32815
32329
  var LOCK_RETRY_MS = 25;
32816
32330
  function sleepSync(ms) {
@@ -32821,9 +32335,9 @@ function acquireConfigLock(finalPath) {
32821
32335
  const deadline = Date.now() + LOCK_MAX_WAIT_MS;
32822
32336
  for (; ; ) {
32823
32337
  try {
32824
- const fd = fs4.openSync(lockPath, "wx", 384);
32338
+ const fd = fs3.openSync(lockPath, "wx", 384);
32825
32339
  try {
32826
- fs4.writeSync(fd, `${process.pid}
32340
+ fs3.writeSync(fd, `${process.pid}
32827
32341
  `);
32828
32342
  } catch {
32829
32343
  }
@@ -32831,8 +32345,8 @@ function acquireConfigLock(finalPath) {
32831
32345
  } catch (err) {
32832
32346
  if (err.code !== "EEXIST") return null;
32833
32347
  try {
32834
- if (Date.now() - fs4.statSync(lockPath).mtimeMs > LOCK_STALE_MS2) {
32835
- fs4.unlinkSync(lockPath);
32348
+ if (Date.now() - fs3.statSync(lockPath).mtimeMs > LOCK_STALE_MS) {
32349
+ fs3.unlinkSync(lockPath);
32836
32350
  continue;
32837
32351
  }
32838
32352
  } catch {
@@ -32844,35 +32358,35 @@ function acquireConfigLock(finalPath) {
32844
32358
  }
32845
32359
  function releaseConfigLock(lock) {
32846
32360
  try {
32847
- fs4.closeSync(lock.fd);
32361
+ fs3.closeSync(lock.fd);
32848
32362
  } catch {
32849
32363
  }
32850
32364
  try {
32851
- fs4.unlinkSync(lock.lockPath);
32365
+ fs3.unlinkSync(lock.lockPath);
32852
32366
  } catch {
32853
32367
  }
32854
32368
  }
32855
32369
  function updateConfig(mutate, scope = "global", options = {}) {
32856
32370
  const dir = configDir(scope, options);
32857
- fs4.mkdirSync(dir, { recursive: true });
32371
+ fs3.mkdirSync(dir, { recursive: true });
32858
32372
  const finalPath = configFilePath(scope, options);
32859
32373
  const lock = acquireConfigLock(finalPath);
32860
32374
  try {
32861
32375
  const next = readConfigObject(scope, options);
32862
32376
  mutate(next);
32863
32377
  const tmpPath = path4.join(dir, `.config.tmp.${process.pid}.${crypto.randomUUID()}`);
32864
- const fd = fs4.openSync(tmpPath, "wx", 384);
32378
+ const fd = fs3.openSync(tmpPath, "wx", 384);
32865
32379
  try {
32866
- fs4.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
32867
- fs4.fsyncSync(fd);
32380
+ fs3.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
32381
+ fs3.fsyncSync(fd);
32868
32382
  } finally {
32869
- fs4.closeSync(fd);
32383
+ fs3.closeSync(fd);
32870
32384
  }
32871
32385
  try {
32872
- fs4.renameSync(tmpPath, finalPath);
32386
+ fs3.renameSync(tmpPath, finalPath);
32873
32387
  } catch (err) {
32874
32388
  try {
32875
- fs4.unlinkSync(tmpPath);
32389
+ fs3.unlinkSync(tmpPath);
32876
32390
  } catch {
32877
32391
  }
32878
32392
  throw err;
@@ -32889,12 +32403,24 @@ function getWhatsNewSeenVersion(options = {}) {
32889
32403
  return typeof value === "string" ? value : null;
32890
32404
  }
32891
32405
  function setWhatsNewSeenVersion(version2, options = {}) {
32892
- updateConfig((config2) => setAtPath(config2, WHATS_NEW_SEEN_KEY, version2), "global", options);
32406
+ let recorded = false;
32407
+ updateConfig(
32408
+ (config2) => {
32409
+ const value = getAtPath(config2, WHATS_NEW_SEEN_KEY);
32410
+ const seen = typeof value === "string" ? value : null;
32411
+ if (options.ifSeen !== void 0 && options.ifSeen !== seen) return;
32412
+ setAtPath(config2, WHATS_NEW_SEEN_KEY, version2);
32413
+ recorded = true;
32414
+ },
32415
+ "global",
32416
+ options
32417
+ );
32418
+ return recorded;
32893
32419
  }
32894
32420
 
32895
32421
  // ../configuration-core/src/secrets.ts
32896
- var import_dotenv = __toESM(require_dist3(), 1);
32897
- import * as fs5 from "node:fs";
32422
+ var import_dotenv = __toESM(require_dist2(), 1);
32423
+ import * as fs4 from "node:fs";
32898
32424
  import * as path5 from "node:path";
32899
32425
  var SECRET_ENV_PREFIX = "ARGENT_SECRET_";
32900
32426
  var SECRETS_FILE_NAME = "secrets.env";
@@ -32924,10 +32450,10 @@ function fileSource(filePath, exposure) {
32924
32450
  names: [],
32925
32451
  values: /* @__PURE__ */ new Map()
32926
32452
  };
32927
- if (!fs5.statSync(filePath, { throwIfNoEntry: false })) return absent;
32453
+ if (!fs4.statSync(filePath, { throwIfNoEntry: false })) return absent;
32928
32454
  let content;
32929
32455
  try {
32930
- content = fs5.readFileSync(filePath, "utf8");
32456
+ content = fs4.readFileSync(filePath, "utf8");
32931
32457
  } catch {
32932
32458
  return absent;
32933
32459
  }
@@ -32967,7 +32493,7 @@ function secretSources(options = {}) {
32967
32493
  }
32968
32494
  }
32969
32495
  filePaths.push({
32970
- path: path5.join(home, ".argent", SECRETS_FILE_NAME),
32496
+ path: path5.join(argentHomeDir(options), SECRETS_FILE_NAME),
32971
32497
  exposure: "dedicated"
32972
32498
  });
32973
32499
  const seen = /* @__PURE__ */ new Set();
@@ -33053,7 +32579,7 @@ function applyMergePolicy(policy, local, global) {
33053
32579
  }
33054
32580
 
33055
32581
  // ../configuration-core/src/config-schema.ts
33056
- import { isAbsolute as isAbsolute2 } from "node:path";
32582
+ import { isAbsolute } from "node:path";
33057
32583
  function asBoolean(raw2) {
33058
32584
  return typeof raw2 === "boolean" ? raw2 : void 0;
33059
32585
  }
@@ -33089,6 +32615,15 @@ var CONFIG_SCHEMA = [
33089
32615
  // drained/reset, not just the file rewritten.
33090
32616
  manageCommand: "argent telemetry"
33091
32617
  },
32618
+ {
32619
+ key: "autoUpdate.enabled",
32620
+ description: "Automatically update the global Argent installation. Project-local installs require confirmation.",
32621
+ scopes: ["global"],
32622
+ parse: asBoolean,
32623
+ merge: "prioritize-local",
32624
+ default: true,
32625
+ example: "false"
32626
+ },
33092
32627
  {
33093
32628
  key: "lens.agent",
33094
32629
  description: "Coding-agent id remembered by `argent lens` to skip the picker.",
@@ -33114,7 +32649,7 @@ var CONFIG_SCHEMA = [
33114
32649
  scopes: ["project", "global"],
33115
32650
  parse: (raw2) => {
33116
32651
  const value = asString(raw2);
33117
- return value !== void 0 && (value === "~" || value.startsWith("~/") || isAbsolute2(value)) ? value : void 0;
32652
+ return value !== void 0 && (value === "~" || value.startsWith("~/") || isAbsolute(value)) ? value : void 0;
33118
32653
  },
33119
32654
  expected: "an absolute path, or one starting with `~/`",
33120
32655
  merge: "prioritize-local",
@@ -33209,6 +32744,499 @@ var UnknownConfigKeyError = class extends Error {
33209
32744
  key;
33210
32745
  };
33211
32746
 
32747
+ // ../argent-tools-client/src/launcher.ts
32748
+ var STATE_DIR = argentHomeDir();
32749
+ var STATE_FILE = path7.join(STATE_DIR, "tool-server.json");
32750
+ var LOG_FILE = path7.join(STATE_DIR, "tool-server.log");
32751
+ var LOCK_FILE = path7.join(STATE_DIR, "tool-server.lock");
32752
+ var AUTH_TOKEN_BYTES = 32;
32753
+ var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
32754
+ var AUTOSPAWN_IDLE_TIMEOUT_MINUTES = 30;
32755
+ var AUTOSPAWN_HOST = "127.0.0.1";
32756
+ function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
32757
+ const env = {
32758
+ ...baseEnv,
32759
+ ARGENT_PORT: String(port),
32760
+ ARGENT_SIMULATOR_SERVER_DIR: paths.simulatorServerDir,
32761
+ ARGENT_NATIVE_DEVTOOLS_DIR: paths.nativeDevtoolsDir
32762
+ };
32763
+ if (options.host !== void 0) env.ARGENT_HOST = options.host;
32764
+ if (options.idleTimeoutMinutes !== void 0) {
32765
+ env.ARGENT_IDLE_TIMEOUT_MINUTES = String(options.idleTimeoutMinutes);
32766
+ }
32767
+ env[AUTH_TOKEN_ENV] = options.token ?? "";
32768
+ env.ARGENT_SERVER_MANAGED = options.managed ?? "autospawn";
32769
+ if (paths.installKind) env.ARGENT_INSTALL_KIND = paths.installKind;
32770
+ if (paths.installProjectRoot) env.ARGENT_PROJECT_ROOT = paths.installProjectRoot;
32771
+ return env;
32772
+ }
32773
+ function generateToken() {
32774
+ return randomBytes(AUTH_TOKEN_BYTES).toString("hex");
32775
+ }
32776
+ function findFreePort() {
32777
+ return new Promise((resolve13, reject) => {
32778
+ const srv = net.createServer();
32779
+ srv.listen(0, "127.0.0.1", () => {
32780
+ const addr = srv.address();
32781
+ if (!addr || typeof addr !== "object") {
32782
+ srv.close(() => reject(new Error("Could not bind to find free port")));
32783
+ return;
32784
+ }
32785
+ const port = addr.port;
32786
+ srv.close((err) => {
32787
+ if (err) reject(err);
32788
+ else resolve13(port);
32789
+ });
32790
+ });
32791
+ srv.on("error", reject);
32792
+ });
32793
+ }
32794
+ function isVersionNewer(a, b) {
32795
+ const parse4 = (v) => {
32796
+ const [core = "", ...preParts] = v.split("+")[0].split("-");
32797
+ const nums = core.split(".").map((n) => Number.parseInt(n, 10));
32798
+ if (nums.length === 0 || nums.some((n) => Number.isNaN(n))) return null;
32799
+ return { nums, pre: preParts.length > 0 ? preParts.join("-").split(".") : [] };
32800
+ };
32801
+ const pa = parse4(a);
32802
+ const pb = parse4(b);
32803
+ if (!pa || !pb) return false;
32804
+ for (let i = 0; i < 3; i++) {
32805
+ const x = pa.nums[i] ?? 0;
32806
+ const y = pb.nums[i] ?? 0;
32807
+ if (x !== y) return x > y;
32808
+ }
32809
+ if (pa.pre.length === 0 && pb.pre.length === 0) return false;
32810
+ if (pa.pre.length === 0) return true;
32811
+ if (pb.pre.length === 0) return false;
32812
+ for (let i = 0; i < Math.max(pa.pre.length, pb.pre.length); i++) {
32813
+ const x = pa.pre[i];
32814
+ const y = pb.pre[i];
32815
+ if (x === void 0) return false;
32816
+ if (y === void 0) return true;
32817
+ if (x === y) continue;
32818
+ const xn = /^\d+$/.test(x) ? Number.parseInt(x, 10) : null;
32819
+ const yn = /^\d+$/.test(y) ? Number.parseInt(y, 10) : null;
32820
+ if (xn !== null && yn !== null) return xn > yn;
32821
+ if (xn !== null) return false;
32822
+ if (yn !== null) return true;
32823
+ return x > y;
32824
+ }
32825
+ return false;
32826
+ }
32827
+ function readBundlePackageVersion(bundlePath) {
32828
+ try {
32829
+ const pkg = JSON.parse(
32830
+ fs5.readFileSync(path7.join(path7.dirname(bundlePath), "..", "package.json"), "utf8")
32831
+ );
32832
+ return typeof pkg.version === "string" ? pkg.version : void 0;
32833
+ } catch {
32834
+ return void 0;
32835
+ }
32836
+ }
32837
+ function isProcessAlive(pid) {
32838
+ try {
32839
+ process.kill(pid, 0);
32840
+ return true;
32841
+ } catch {
32842
+ return false;
32843
+ }
32844
+ }
32845
+ function healthCheckHost(host) {
32846
+ if (host === "0.0.0.0" || host === "") return "127.0.0.1";
32847
+ if (host === "::" || host === "::0") return "::1";
32848
+ return host;
32849
+ }
32850
+ function formatUrl(host, port) {
32851
+ const h = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
32852
+ return `http://${h}:${port}`;
32853
+ }
32854
+ function authHeaders(token) {
32855
+ return token ? { Authorization: `Bearer ${token}` } : {};
32856
+ }
32857
+ async function isToolsServerHealthy(port, host = "127.0.0.1", timeoutMs = 2e3, token) {
32858
+ const controller = new AbortController();
32859
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
32860
+ try {
32861
+ const res = await fetch(`${formatUrl(healthCheckHost(host), port)}/tools`, {
32862
+ signal: controller.signal,
32863
+ headers: authHeaders(token)
32864
+ });
32865
+ await res.body?.cancel().catch(() => {
32866
+ });
32867
+ return res.ok;
32868
+ } catch {
32869
+ return false;
32870
+ } finally {
32871
+ clearTimeout(timer);
32872
+ }
32873
+ }
32874
+ var SPAWN_READY_TIMEOUT_MS = 15e3;
32875
+ function killSpawnedChild(child, pid) {
32876
+ try {
32877
+ process.kill(-pid, "SIGKILL");
32878
+ } catch {
32879
+ try {
32880
+ child.kill("SIGKILL");
32881
+ } catch {
32882
+ }
32883
+ }
32884
+ }
32885
+ function resolveToolsServerNode() {
32886
+ const { bun, deno, electron } = process.versions;
32887
+ return !(bun || deno || electron) && fs5.existsSync(process.execPath) ? process.execPath : "node";
32888
+ }
32889
+ function parseListeningPort(line) {
32890
+ const match = line.match(/Tools server listening on http:\/\/.+:(\d+)/);
32891
+ return match ? parseInt(match[1], 10) : null;
32892
+ }
32893
+ function spawnToolsServer(paths, port, options = {}) {
32894
+ return new Promise((resolve13, reject) => {
32895
+ let logFd;
32896
+ try {
32897
+ fs5.mkdirSync(STATE_DIR, { recursive: true });
32898
+ logFd = fs5.openSync(LOG_FILE, "a");
32899
+ } catch {
32900
+ logFd = fs5.openSync("/dev/null", "w");
32901
+ }
32902
+ const nodeBin = resolveToolsServerNode();
32903
+ const child = spawn(nodeBin, [paths.bundlePath, "start"], {
32904
+ detached: true,
32905
+ stdio: ["ignore", "pipe", logFd],
32906
+ env: buildToolsServerEnv(paths, port, process.env, options)
32907
+ });
32908
+ fs5.closeSync(logFd);
32909
+ const pid = child.pid;
32910
+ if (!pid) {
32911
+ child.once(
32912
+ "error",
32913
+ (err) => reject(
32914
+ new Error(
32915
+ 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}`
32916
+ )
32917
+ )
32918
+ );
32919
+ return;
32920
+ }
32921
+ let settled = false;
32922
+ const settle2 = (fn) => {
32923
+ if (settled) return;
32924
+ settled = true;
32925
+ fn();
32926
+ };
32927
+ const rejectAndKill = (err) => settle2(() => {
32928
+ killSpawnedChild(child, pid);
32929
+ reject(err);
32930
+ });
32931
+ const rl = readline.createInterface({ input: child.stdout });
32932
+ rl.on("line", (line) => {
32933
+ const actualPort = parseListeningPort(line);
32934
+ if (actualPort !== null) {
32935
+ rl.close();
32936
+ child.stdout?.resume();
32937
+ child.stdout?.unref?.();
32938
+ child.unref();
32939
+ settle2(() => resolve13({ port: actualPort, pid }));
32940
+ }
32941
+ });
32942
+ child.on("error", (err) => {
32943
+ rl.close();
32944
+ rejectAndKill(err);
32945
+ });
32946
+ child.on("exit", (code) => {
32947
+ rl.close();
32948
+ settle2(() => reject(new Error(`tool-server exited with code ${code} before becoming ready`)));
32949
+ });
32950
+ const timer = setTimeout(() => {
32951
+ rl.close();
32952
+ rejectAndKill(new Error("Timed out waiting for tools server to become ready"));
32953
+ }, options.readyTimeoutMs ?? SPAWN_READY_TIMEOUT_MS);
32954
+ rl.on("close", () => clearTimeout(timer));
32955
+ });
32956
+ }
32957
+ function stateFileForBundle(bundlePath) {
32958
+ const key = createHash("sha256").update(bundlePath).digest("hex").slice(0, 12);
32959
+ return path7.join(STATE_DIR, `tool-server-${key}.json`);
32960
+ }
32961
+ async function readStateFile(file) {
32962
+ try {
32963
+ const raw2 = await readFile(file, "utf8");
32964
+ return JSON.parse(raw2);
32965
+ } catch {
32966
+ return null;
32967
+ }
32968
+ }
32969
+ async function readToolsServerState(bundlePath) {
32970
+ if (bundlePath === void 0) return readStateFile(STATE_FILE);
32971
+ const own2 = await readStateFile(stateFileForBundle(bundlePath));
32972
+ if (own2) return own2;
32973
+ const legacy = await readStateFile(STATE_FILE);
32974
+ return legacy && legacy.bundlePath === bundlePath ? legacy : null;
32975
+ }
32976
+ async function writeToolsServerState(state) {
32977
+ const target = stateFileForBundle(state.bundlePath);
32978
+ await mkdir(STATE_DIR, { recursive: true });
32979
+ const tmp = `${target}.${process.pid}.tmp`;
32980
+ try {
32981
+ await writeFile(tmp, JSON.stringify(state, null, 2) + "\n", {
32982
+ encoding: "utf8",
32983
+ mode: 384
32984
+ });
32985
+ await chmod(tmp, 384);
32986
+ await rename(tmp, target);
32987
+ } catch (err) {
32988
+ await unlink(tmp).catch(() => {
32989
+ });
32990
+ throw err;
32991
+ }
32992
+ }
32993
+ async function clearToolsServerState(bundlePath) {
32994
+ const files = [STATE_FILE];
32995
+ if (bundlePath !== void 0) {
32996
+ files[0] = stateFileForBundle(bundlePath);
32997
+ const legacy = await readStateFile(STATE_FILE);
32998
+ if (legacy && legacy.bundlePath === bundlePath) files.push(STATE_FILE);
32999
+ }
33000
+ for (const file of files) {
33001
+ try {
33002
+ await unlink(file);
33003
+ } catch {
33004
+ }
33005
+ }
33006
+ }
33007
+ var STATE_FILE_RE = /^tool-server(-[0-9a-f]{12})?\.json$/;
33008
+ async function readAllToolsServerStates() {
33009
+ let names;
33010
+ try {
33011
+ names = await readdir(STATE_DIR);
33012
+ } catch {
33013
+ return [];
33014
+ }
33015
+ const out = [];
33016
+ for (const name of names) {
33017
+ if (!STATE_FILE_RE.test(name)) continue;
33018
+ const file = path7.join(STATE_DIR, name);
33019
+ const state = await readStateFile(file);
33020
+ if (state) out.push({ file, state });
33021
+ }
33022
+ return out;
33023
+ }
33024
+ async function sweepDeadStateFiles() {
33025
+ for (const { file } of await readAllToolsServerStates()) {
33026
+ if (file === STATE_FILE) continue;
33027
+ const fresh = await readStateFile(file);
33028
+ if (!fresh) continue;
33029
+ if (!isProcessAlive(fresh.pid)) {
33030
+ await unlink(file).catch(() => {
33031
+ });
33032
+ continue;
33033
+ }
33034
+ if (fs5.existsSync(fresh.bundlePath)) continue;
33035
+ if (!couldBeOurToolServer(fresh.pid, fresh.bundlePath)) continue;
33036
+ await unlink(file).catch(() => {
33037
+ });
33038
+ void terminatePid(fresh.pid, () => couldBeOurToolServer(fresh.pid, fresh.bundlePath));
33039
+ }
33040
+ }
33041
+ var readState = readToolsServerState;
33042
+ var writeState = writeToolsServerState;
33043
+ var SIGTERM_GRACE_MS = 6e3;
33044
+ var SIGKILL_GRACE_MS = 1e3;
33045
+ var KILL_POLL_MS = 100;
33046
+ async function waitForExit(pid, timeoutMs) {
33047
+ const deadline = Date.now() + timeoutMs;
33048
+ while (Date.now() < deadline) {
33049
+ if (!isProcessAlive(pid)) return true;
33050
+ await new Promise((r) => setTimeout(r, KILL_POLL_MS));
33051
+ }
33052
+ return !isProcessAlive(pid);
33053
+ }
33054
+ async function terminatePid(pid, stillOurs) {
33055
+ if (!isProcessAlive(pid)) return;
33056
+ if (stillOurs && !stillOurs()) return;
33057
+ try {
33058
+ process.kill(pid, "SIGTERM");
33059
+ } catch {
33060
+ return;
33061
+ }
33062
+ if (await waitForExit(pid, SIGTERM_GRACE_MS)) return;
33063
+ if (stillOurs && !(isProcessAlive(pid) && stillOurs())) return;
33064
+ try {
33065
+ process.kill(pid, "SIGKILL");
33066
+ } catch {
33067
+ return;
33068
+ }
33069
+ await waitForExit(pid, SIGKILL_GRACE_MS);
33070
+ }
33071
+ var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs5.existsSync(p)) ?? "ps";
33072
+ var PS_WIDTH_FLAGS = ["-ww"];
33073
+ var PS_LOCALE = process.platform === "darwin" ? "en_US.UTF-8" : "C.UTF-8";
33074
+ function readProcessCommandLine(pid, flags = PS_WIDTH_FLAGS, env = { ...process.env, LC_ALL: PS_LOCALE }) {
33075
+ return execFileSync(PS_BIN, [...flags, "-p", String(pid), "-o", "command="], {
33076
+ env,
33077
+ encoding: "utf8",
33078
+ timeout: 2e3,
33079
+ // A recycled pid can sit on a process with an argv past Node's 1 MiB exec
33080
+ // default, where the overrun surfaces as ENOBUFS instead of a command line.
33081
+ // Same ceiling as tool-server's vega-process ps probes.
33082
+ maxBuffer: 16 * 1024 * 1024,
33083
+ // Piping ps's stderr is what puts a rejected flag ("ps: invalid option --
33084
+ // 'w'") into the thrown error's message.
33085
+ stdio: ["ignore", "pipe", "pipe"]
33086
+ }).trim();
33087
+ }
33088
+ function couldBeOurToolServer(pid, marker) {
33089
+ if (!marker) return false;
33090
+ if (process.platform === "win32") return true;
33091
+ const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
33092
+ const ours = new RegExp(`(?:^|[\\t\\n\\v\\f\\r ])${escaped} start(?:[\\t\\n\\v\\f\\r ]|$)`);
33093
+ const nonAscii = [...marker].some((c) => c.charCodeAt(0) > 127);
33094
+ let failure2;
33095
+ for (const env of [void 0, process.env]) {
33096
+ try {
33097
+ if (ours.test(readProcessCommandLine(pid, PS_WIDTH_FLAGS, env))) return true;
33098
+ failure2 = void 0;
33099
+ if (!nonAscii) break;
33100
+ } catch (err) {
33101
+ failure2 = String(err);
33102
+ if (err.code === "ETIMEDOUT") break;
33103
+ }
33104
+ }
33105
+ if (failure2 !== void 0) {
33106
+ process.stderr.write(
33107
+ `[launcher] ps could not read pid ${pid}'s command line; leaving it alone: ${failure2}
33108
+ `
33109
+ );
33110
+ }
33111
+ return false;
33112
+ }
33113
+ var LOCK_WAIT_TIMEOUT_MS = 3e4;
33114
+ var LOCK_STALE_MS2 = 45e3;
33115
+ var LOCK_POLL_MS = 100;
33116
+ function spawnLockIsStale() {
33117
+ try {
33118
+ const { pid, ts } = JSON.parse(fs5.readFileSync(LOCK_FILE, "utf8"));
33119
+ if (typeof pid === "number" && pid > 0 && !isProcessAlive(pid)) return true;
33120
+ if (typeof ts === "number" && Date.now() - ts > LOCK_STALE_MS2) return true;
33121
+ return false;
33122
+ } catch {
33123
+ try {
33124
+ return Date.now() - fs5.statSync(LOCK_FILE).mtimeMs > LOCK_STALE_MS2;
33125
+ } catch {
33126
+ return true;
33127
+ }
33128
+ }
33129
+ }
33130
+ async function acquireSpawnLock() {
33131
+ try {
33132
+ fs5.mkdirSync(STATE_DIR, { recursive: true });
33133
+ } catch {
33134
+ return null;
33135
+ }
33136
+ const nonce = randomBytes(8).toString("hex");
33137
+ const deadline = Date.now() + LOCK_WAIT_TIMEOUT_MS;
33138
+ for (; ; ) {
33139
+ try {
33140
+ const fd = fs5.openSync(LOCK_FILE, "wx");
33141
+ try {
33142
+ fs5.writeSync(fd, JSON.stringify({ pid: process.pid, nonce, ts: Date.now() }));
33143
+ } finally {
33144
+ fs5.closeSync(fd);
33145
+ }
33146
+ let released = false;
33147
+ return {
33148
+ release: () => {
33149
+ if (released) return;
33150
+ released = true;
33151
+ try {
33152
+ const cur = JSON.parse(fs5.readFileSync(LOCK_FILE, "utf8"));
33153
+ if (cur.pid === process.pid && cur.nonce === nonce) fs5.unlinkSync(LOCK_FILE);
33154
+ } catch {
33155
+ }
33156
+ }
33157
+ };
33158
+ } catch (err) {
33159
+ if (err.code !== "EEXIST") return null;
33160
+ if (spawnLockIsStale()) {
33161
+ try {
33162
+ fs5.unlinkSync(LOCK_FILE);
33163
+ } catch {
33164
+ }
33165
+ if (!fs5.existsSync(LOCK_FILE)) continue;
33166
+ }
33167
+ if (Date.now() >= deadline) return null;
33168
+ await new Promise((r) => setTimeout(r, LOCK_POLL_MS));
33169
+ }
33170
+ }
33171
+ }
33172
+ async function reusableHandle(state, wantBundlePath, wantVersion) {
33173
+ if (!state || !isProcessAlive(state.pid)) return null;
33174
+ if (wantBundlePath !== void 0 && state.bundlePath !== wantBundlePath) return null;
33175
+ if (wantBundlePath !== void 0 && state.version !== void 0) {
33176
+ const diskVersion = readBundlePackageVersion(wantBundlePath);
33177
+ if (diskVersion !== void 0) {
33178
+ if (diskVersion !== state.version) return null;
33179
+ } else if (wantVersion !== void 0 && state.version !== wantVersion && isVersionNewer(wantVersion, state.version)) {
33180
+ return null;
33181
+ }
33182
+ }
33183
+ const host = state.host ?? "127.0.0.1";
33184
+ const healthy = await isToolsServerHealthy(state.port, host, 2e3, state.token);
33185
+ if (!healthy) return null;
33186
+ return { url: formatUrl(healthCheckHost(host), state.port), token: state.token ?? "" };
33187
+ }
33188
+ async function ensureToolsServer(paths) {
33189
+ const fast = await reusableHandle(
33190
+ await readState(paths.bundlePath),
33191
+ paths.bundlePath,
33192
+ paths.version
33193
+ );
33194
+ if (fast) return fast;
33195
+ const lock = await acquireSpawnLock();
33196
+ try {
33197
+ const state = await readState(paths.bundlePath);
33198
+ const reuse = await reusableHandle(state, paths.bundlePath, paths.version);
33199
+ if (reuse) return reuse;
33200
+ if (state && state.managed === "autospawn" && state.bundlePath === paths.bundlePath && isProcessAlive(state.pid) && couldBeOurToolServer(state.pid, state.bundlePath)) {
33201
+ await terminatePid(state.pid, () => couldBeOurToolServer(state.pid, state.bundlePath));
33202
+ }
33203
+ await clearToolsServerState(paths.bundlePath);
33204
+ await sweepDeadStateFiles();
33205
+ if (!fs5.existsSync(paths.bundlePath)) {
33206
+ throw new Error(
33207
+ `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.`
33208
+ );
33209
+ }
33210
+ const diskVersion = readBundlePackageVersion(paths.bundlePath) ?? paths.version;
33211
+ const token = generateToken();
33212
+ const port = await findFreePort();
33213
+ const { port: actualPort, pid } = await spawnToolsServer(paths, port, {
33214
+ token,
33215
+ host: AUTOSPAWN_HOST,
33216
+ idleTimeoutMinutes: AUTOSPAWN_IDLE_TIMEOUT_MINUTES
33217
+ });
33218
+ await writeState({
33219
+ port: actualPort,
33220
+ pid,
33221
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
33222
+ bundlePath: paths.bundlePath,
33223
+ version: diskVersion,
33224
+ host: AUTOSPAWN_HOST,
33225
+ token,
33226
+ managed: "autospawn"
33227
+ });
33228
+ return { url: formatUrl(AUTOSPAWN_HOST, actualPort), token };
33229
+ } finally {
33230
+ lock?.release();
33231
+ }
33232
+ }
33233
+
33234
+ // ../argent-tools-client/src/tools-client.ts
33235
+ var import_yaml2 = __toESM(require_dist3(), 1);
33236
+ import { readFile as readFile5 } from "node:fs/promises";
33237
+ import { maxHeaderSize } from "node:http";
33238
+ import * as path13 from "node:path";
33239
+
33212
33240
  // ../registry/src/types.ts
33213
33241
  var LINKED_CALL_HEADER = "x-argent-linked";
33214
33242
  var E2E_DIR_CLIENT_HEADER = "x-argent-e2e-dir";
@@ -33268,8 +33296,8 @@ var UNEXPANDED_PATH = /^~|\$[A-Za-z0-9_{(]|`|%[A-Za-z_][A-Za-z0-9_]*%|^[A-Za-z][
33268
33296
  function isUnexpandedPath(p) {
33269
33297
  return UNEXPANDED_PATH.test(p);
33270
33298
  }
33271
- function isClientFileArgument({ spec, path: path18 }) {
33272
- return spec.kind === "file" && spec.path === `\${${spec.target}}` && path18.startsWith("/") && hasToolFileExtension(path18);
33299
+ function isClientFileArgument({ spec, path: path19 }) {
33300
+ return spec.kind === "file" && spec.path === `\${${spec.target}}` && path19.startsWith("/") && hasToolFileExtension(path19);
33273
33301
  }
33274
33302
 
33275
33303
  // ../registry/src/flow-platforms.ts
@@ -33278,22 +33306,22 @@ var SELECTABLE_PLATFORMS = [...LAUNCH_PLATFORMS, "ios-remote"];
33278
33306
 
33279
33307
  // ../registry/src/flow-file-refs.ts
33280
33308
  import * as fs7 from "node:fs/promises";
33281
- import * as path8 from "node:path";
33309
+ import * as path9 from "node:path";
33282
33310
 
33283
33311
  // ../registry/src/e2e-dirs.ts
33284
33312
  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")]);
33313
+ import * as path8 from "node:path";
33314
+ var E2E_DIR = path8.join(".argent", "e2e");
33315
+ var LEGACY_E2E_DIRS = Object.freeze([path8.join(".argent", "flows")]);
33288
33316
  var E2E_DIRS = Object.freeze([E2E_DIR, ...LEGACY_E2E_DIRS]);
33289
33317
  function e2eDirFor(projectRoot) {
33290
- return path7.join(projectRoot, E2E_DIR);
33318
+ return path8.join(projectRoot, E2E_DIR);
33291
33319
  }
33292
33320
  function e2eDirsFor(projectRoot) {
33293
- return E2E_DIRS.map((dir) => path7.join(projectRoot, dir));
33321
+ return E2E_DIRS.map((dir) => path8.join(projectRoot, dir));
33294
33322
  }
33295
33323
  function e2eFileCandidates(projectRoot, name) {
33296
- return e2eDirsFor(projectRoot).map((dir) => path7.join(dir, `${name}.yaml`));
33324
+ return e2eDirsFor(projectRoot).map((dir) => path8.join(dir, `${name}.yaml`));
33297
33325
  }
33298
33326
  async function exists(file) {
33299
33327
  return fs6.stat(file).then(
@@ -33323,21 +33351,21 @@ async function pickE2eFile(candidates) {
33323
33351
  function e2eShadowWarning(used, shadowed) {
33324
33352
  return `${shadowed} is not used: ${used} has the same name and is read first.`;
33325
33353
  }
33326
- var E2E_DIR_NAMES = E2E_DIRS.map((dir) => path7.basename(dir));
33354
+ var E2E_DIR_NAMES = E2E_DIRS.map((dir) => path8.basename(dir));
33327
33355
  function e2eDirProject(dir) {
33328
33356
  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") {
33357
+ const argent = path8.dirname(trimmed);
33358
+ if (!E2E_DIR_NAMES.includes(path8.basename(trimmed)) || path8.basename(argent) !== ".argent") {
33331
33359
  return null;
33332
33360
  }
33333
- return path7.dirname(argent);
33361
+ return path8.dirname(argent);
33334
33362
  }
33335
33363
  function e2eRunFallbackDirs(anchorDir, target) {
33336
33364
  if (target.includes("/") || target.includes("\\")) return [];
33337
33365
  const project = e2eDirProject(anchorDir);
33338
33366
  if (project === null) return [];
33339
- const anchor2 = path7.resolve(anchorDir);
33340
- return e2eDirsFor(project).filter((dir) => path7.resolve(dir) !== anchor2);
33367
+ const anchor2 = path8.resolve(anchorDir);
33368
+ return e2eDirsFor(project).filter((dir) => path8.resolve(dir) !== anchor2);
33341
33369
  }
33342
33370
 
33343
33371
  // ../registry/src/tool-ids.ts
@@ -33390,7 +33418,7 @@ async function canonicalFlowPath(p) {
33390
33418
  return await fs7.realpath(p);
33391
33419
  } catch {
33392
33420
  try {
33393
- return path8.join(await fs7.realpath(path8.dirname(p)), path8.basename(p));
33421
+ return path9.join(await fs7.realpath(path9.dirname(p)), path9.basename(p));
33394
33422
  } catch {
33395
33423
  return p;
33396
33424
  }
@@ -33399,7 +33427,7 @@ async function canonicalFlowPath(p) {
33399
33427
  function completeRunExtension(value) {
33400
33428
  if (value.endsWith(".yaml")) return value;
33401
33429
  const candidate = `${value}.yaml`;
33402
- return FLOW_FILE_NAME_PATTERN.test(path8.posix.basename(candidate)) ? candidate : value;
33430
+ return FLOW_FILE_NAME_PATTERN.test(path9.posix.basename(candidate)) ? candidate : value;
33403
33431
  }
33404
33432
  var MAX_RUN_DEPTH = 20;
33405
33433
  var MAX_BLOCK_NESTING = 64;
@@ -33421,9 +33449,9 @@ function collectFlowRequests(doc) {
33421
33449
  for (const step of steps) {
33422
33450
  if (!isRecord(step)) continue;
33423
33451
  const run = step.run;
33424
- if (typeof run === "string" && !run.includes("\\") && !path8.posix.isAbsolute(run) && !/^[A-Za-z]:/.test(run)) {
33452
+ if (typeof run === "string" && !run.includes("\\") && !path9.posix.isAbsolute(run) && !/^[A-Za-z]:/.test(run)) {
33425
33453
  const target = completeRunExtension(run);
33426
- if (FLOW_FILE_NAME_PATTERN.test(path8.posix.basename(target))) runTargets.add(target);
33454
+ if (FLOW_FILE_NAME_PATTERN.test(path9.posix.basename(target))) runTargets.add(target);
33427
33455
  }
33428
33456
  const snapshot = isRecord(step.snapshot) ? step.snapshot.name : step.snapshot;
33429
33457
  if (typeof snapshot === "string" && FLOW_NAME_PATTERN.test(snapshot)) snapshots.add(snapshot);
@@ -33436,11 +33464,14 @@ function collectFlowRequests(doc) {
33436
33464
  visit(step.steps, depth + 1);
33437
33465
  }
33438
33466
  };
33439
- if (isRecord(doc)) visit(doc.steps, 0);
33467
+ if (isRecord(doc)) {
33468
+ visit(doc.steps, 0);
33469
+ visit(doc.shutdown, 0);
33470
+ }
33440
33471
  return { runTargets: [...runTargets], snapshots: [...snapshots], toolSteps, nested };
33441
33472
  }
33442
33473
  function baselineKeyFor(canonicalPath2, flowName) {
33443
- const stem = path8.basename(canonicalPath2, ".yaml");
33474
+ const stem = path9.basename(canonicalPath2, ".yaml");
33444
33475
  return FLOW_NAME_PATTERN.test(stem) ? stem : flowName;
33445
33476
  }
33446
33477
  function flowMemberKey(anchorDir, target) {
@@ -33469,11 +33500,11 @@ function nestedFlowTarget(args) {
33469
33500
  return { kind: "name", projectRoot, name, path: paths[0], paths };
33470
33501
  }
33471
33502
  if (name !== void 0 || !isResolvedAbsolute(flowPath)) return void 0;
33472
- if (!FLOW_FILE_NAME_PATTERN.test(path8.basename(flowPath))) return void 0;
33503
+ if (!FLOW_FILE_NAME_PATTERN.test(path9.basename(flowPath))) return void 0;
33473
33504
  return { kind: "e2e_test_path", path: flowPath };
33474
33505
  }
33475
33506
  function isResolvedAbsolute(value) {
33476
- return typeof value === "string" && path8.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
33507
+ return typeof value === "string" && path9.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
33477
33508
  }
33478
33509
 
33479
33510
  // ../registry/src/failure-codes.ts
@@ -33991,9 +34022,9 @@ var FAILURE_SPAWN_CODE_SET = new Set(FAILURE_SPAWN_CODES);
33991
34022
  import { randomUUID as randomUUID3 } from "node:crypto";
33992
34023
  import { AsyncLocalStorage } from "node:async_hooks";
33993
34024
  var resolvedDuringInvocation = new AsyncLocalStorage();
33994
- function valueAtPath(root, path18) {
34025
+ function valueAtPath(root, path19) {
33995
34026
  let current = root;
33996
- for (const key of path18) {
34027
+ for (const key of path19) {
33997
34028
  if (current === null || typeof current !== "object") return void 0;
33998
34029
  if (!Object.hasOwn(current, key)) return void 0;
33999
34030
  current = current[key];
@@ -34051,11 +34082,10 @@ function describeParamIssues(error2, params) {
34051
34082
  }
34052
34083
 
34053
34084
  // ../argent-tools-client/src/link-config.ts
34054
- import * as path9 from "node:path";
34055
- import { homedir as homedir4 } from "node:os";
34085
+ import * as path10 from "node:path";
34056
34086
  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");
34087
+ var LINK_DIR = argentHomeDir();
34088
+ var LINK_FILE = path10.join(LINK_DIR, "link.json");
34059
34089
  async function readLinkConfig() {
34060
34090
  try {
34061
34091
  const raw2 = await readFile2(LINK_FILE, "utf8");
@@ -34108,14 +34138,14 @@ import {
34108
34138
  writeFile as writeFile3
34109
34139
  } from "node:fs/promises";
34110
34140
  import { constants, tmpdir } from "node:os";
34111
- import * as path10 from "node:path";
34141
+ import * as path11 from "node:path";
34112
34142
 
34113
34143
  // ../archive/src/index.ts
34114
34144
  import { spawn as spawn2 } from "node:child_process";
34115
34145
  import { once } from "node:events";
34116
34146
  import { createReadStream, createWriteStream } from "node:fs";
34117
34147
  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";
34148
+ import { basename as basename4, dirname as dirname5, join as join10, resolve as resolve8, sep as sep2 } from "node:path";
34119
34149
  import { Writable } from "node:stream";
34120
34150
  import { pipeline } from "node:stream/promises";
34121
34151
  import zlib from "node:zlib";
@@ -34270,7 +34300,7 @@ async function runTar(archive, args, signal) {
34270
34300
  child.on("error", (err) => {
34271
34301
  childError = err;
34272
34302
  });
34273
- const closed = new Promise((resolve12) => child.once("close", resolve12));
34303
+ const closed = new Promise((resolve13) => child.once("close", resolve13));
34274
34304
  const stdout = collect(child.stdout, MAX_LISTING_BYTES, {
34275
34305
  maxLines: MAX_LISTING_LINES,
34276
34306
  onOverflow: () => child.kill()
@@ -34319,16 +34349,16 @@ async function runTar(archive, args, signal) {
34319
34349
  function normalizeTarMemberPath(memberPath) {
34320
34350
  return memberPath.replace(/^\.\//, "").replace(/\\/g, "/");
34321
34351
  }
34322
- function isContainedPath(path18, windows = process.platform === "win32") {
34323
- const slashed = path18.replace(/\\/g, "/");
34352
+ function isContainedPath(path19, windows = process.platform === "win32") {
34353
+ const slashed = path19.replace(/\\/g, "/");
34324
34354
  const drive = windows ? /^[A-Za-z]:/ : /^[A-Za-z]:\//;
34325
34355
  return !slashed.startsWith("/") && !drive.test(slashed) && !slashed.split("/").includes("..");
34326
34356
  }
34327
34357
  function isSafeTarMember(memberPath, destDir) {
34328
34358
  const normalized = normalizeTarMemberPath(memberPath);
34329
34359
  if (!isContainedPath(normalized)) return false;
34330
- const root = resolve7(destDir);
34331
- return resolve7(destDir, normalized).startsWith(root + sep2);
34360
+ const root = resolve8(destDir);
34361
+ return resolve8(destDir, normalized).startsWith(root + sep2);
34332
34362
  }
34333
34363
  async function readListing(archive, args, signal) {
34334
34364
  try {
@@ -34380,7 +34410,7 @@ async function assertSafeArchive(archive, destDir, signal) {
34380
34410
  async function resolveMember(destDir, expectedName) {
34381
34411
  const entries = await readdir3(destDir);
34382
34412
  if (entries.includes(expectedName)) {
34383
- return join9(destDir, expectedName);
34413
+ return join10(destDir, expectedName);
34384
34414
  }
34385
34415
  const real = entries.filter((e) => !e.startsWith("._"));
34386
34416
  if (real.length !== 1) {
@@ -34388,7 +34418,7 @@ async function resolveMember(destDir, expectedName) {
34388
34418
  `Could not identify the extracted member (expected "${expectedName}", found ${real.length} entries).`
34389
34419
  );
34390
34420
  }
34391
- return join9(destDir, real[0]);
34421
+ return join10(destDir, real[0]);
34392
34422
  }
34393
34423
  async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
34394
34424
  signal?.throwIfAborted();
@@ -34441,20 +34471,20 @@ function interpolatePath(template, args) {
34441
34471
  return missing ? null : out;
34442
34472
  }
34443
34473
  function callerPath(p) {
34444
- const onCurrentDrive = path10.sep === "\\" && /^[\\/](?![\\/])/.test(p);
34445
- if (!onCurrentDrive && (path10.isAbsolute(p) || path10.win32.isAbsolute(p) || isUnexpandedPath(p))) {
34474
+ const onCurrentDrive = path11.sep === "\\" && /^[\\/](?![\\/])/.test(p);
34475
+ if (!onCurrentDrive && (path11.isAbsolute(p) || path11.win32.isAbsolute(p) || isUnexpandedPath(p))) {
34446
34476
  return p;
34447
34477
  }
34448
- const { root } = path10.parse(p);
34478
+ const { root } = path11.parse(p);
34449
34479
  const rest = p.slice(root.length);
34450
34480
  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;
34481
+ const resolved = path11.resolve(p);
34482
+ const last = p.split(path11.sep === "\\" ? /[\\/]/ : "/").at(-1);
34483
+ const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(path11.sep);
34484
+ return dirOnly ? `${resolved}${path11.sep}` : resolved;
34455
34485
  }
34456
- const base = path10.resolve(root);
34457
- return base.endsWith(path10.sep) ? `${base}${rest}` : `${base}${path10.sep}${rest}`;
34486
+ const base = path11.resolve(root);
34487
+ return base.endsWith(path11.sep) ? `${base}${rest}` : `${base}${path11.sep}${rest}`;
34458
34488
  }
34459
34489
  async function specPath(spec, args) {
34460
34490
  if (spec.kind !== "file" || !spec.paths?.length) return interpolatePath(spec.path, args);
@@ -34501,9 +34531,9 @@ function untrackArchive(archive) {
34501
34531
  process.removeListener("exit", removePendingArchives);
34502
34532
  }
34503
34533
  function sha256File(filePath, signal) {
34504
- return new Promise((resolve12, reject) => {
34534
+ return new Promise((resolve13, reject) => {
34505
34535
  const hash = createHash2("sha256");
34506
- createReadStream2(filePath, { signal }).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve12(hash.digest("hex"))).on("error", reject);
34536
+ createReadStream2(filePath, { signal }).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve13(hash.digest("hex"))).on("error", reject);
34507
34537
  });
34508
34538
  }
34509
34539
  function toolServerError(text) {
@@ -34562,7 +34592,7 @@ async function uploadTar(tarPath, format, endpoint, signal) {
34562
34592
  }
34563
34593
  async function uploadFile(sourcePath, endpoint, signal) {
34564
34594
  const format = pickArchiveFormat(endpoint.formats);
34565
- const tarPath = path10.join(tmpdir(), `argent-upload-${randomUUID4()}.tar.gz`);
34595
+ const tarPath = path11.join(tmpdir(), `argent-upload-${randomUUID4()}.tar.gz`);
34566
34596
  trackArchive(tarPath);
34567
34597
  try {
34568
34598
  await createArchiveFile(await realpath2(sourcePath), tarPath, format, signal);
@@ -34637,7 +34667,7 @@ async function prepareFileInputs(specs, args, opts) {
34637
34667
  wire.mtimeMs = st.mtimeMs;
34638
34668
  }
34639
34669
  if (opts.uploadEndpoint && st) {
34640
- process.stderr.write(`Uploading ${path10.basename(filePath)} to the remote tool-server...
34670
+ process.stderr.write(`Uploading ${path11.basename(filePath)} to the remote tool-server...
34641
34671
  `);
34642
34672
  Object.assign(wire, await uploadFile(filePath, opts.uploadEndpoint, opts.signal));
34643
34673
  }
@@ -34647,7 +34677,7 @@ async function prepareFileInputs(specs, args, opts) {
34647
34677
  return out;
34648
34678
  }
34649
34679
  function isAllowedClientFilePath(p) {
34650
- if (!path10.isAbsolute(p)) return false;
34680
+ if (!path11.isAbsolute(p)) return false;
34651
34681
  const segments = p.split(/[\\/]+/);
34652
34682
  if (segments.includes("..")) return false;
34653
34683
  const file = segments[segments.length - 1] ?? "";
@@ -34658,7 +34688,7 @@ function isClientFileDirective2(value) {
34658
34688
  return !!value && typeof value === "object" && value[CLIENT_FILE_MARKER2] === true && typeof value.path === "string" && typeof value.content === "string";
34659
34689
  }
34660
34690
  async function replaceFile(target, bytes, mode) {
34661
- const temp = path10.join(path10.dirname(target), `.baseline-${randomUUID4()}.tmp`);
34691
+ const temp = path11.join(path11.dirname(target), `.baseline-${randomUUID4()}.tmp`);
34662
34692
  try {
34663
34693
  await writeFile3(temp, bytes, { flag: "wx" });
34664
34694
  if (mode !== void 0) await chmod3(temp, mode & 511);
@@ -34669,27 +34699,27 @@ async function replaceFile(target, bytes, mode) {
34669
34699
  }
34670
34700
  }
34671
34701
  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))) {
34702
+ if (!path11.isAbsolute(file) || path11.normalize(file) !== file || file.split(/[\\/]/).includes("..") || !file.endsWith(".png") || !allowedDirs.includes(path11.dirname(file))) {
34673
34703
  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
34704
  }
34675
34705
  if (bytes.length > MAX_CONTENT_BYTES) {
34676
34706
  return `${file}: the baseline is larger than the 32 MiB cap on a file this client writes`;
34677
34707
  }
34678
- const dir = path10.dirname(file);
34708
+ const dir = path11.dirname(file);
34679
34709
  await mkdir3(dir, { recursive: true });
34680
34710
  const link = await lstat(file).catch(() => null);
34681
34711
  const real = link === null ? null : await realpath2(file).catch(() => null);
34682
34712
  if (link !== null && real === null) return `${file} is a symbolic link to a missing file`;
34683
34713
  if (real !== null) {
34684
34714
  if (!real.endsWith(".png")) return `${file} links to a file that is not a PNG file`;
34685
- if (path10.dirname(real) !== await realpath2(dir)) {
34715
+ if (path11.dirname(real) !== await realpath2(dir)) {
34686
34716
  return `${file} links outside its baseline directory`;
34687
34717
  }
34688
34718
  }
34689
34719
  const existing = real === null ? null : await stat3(real);
34690
34720
  if (existing !== null && !existing.isFile()) return `${file} is not a regular file`;
34691
34721
  await replaceFile(
34692
- real ?? path10.join(await realpath2(dir), path10.basename(file)),
34722
+ real ?? path11.join(await realpath2(dir), path11.basename(file)),
34693
34723
  bytes,
34694
34724
  existing?.mode
34695
34725
  );
@@ -34715,7 +34745,7 @@ async function applyClientFileDirectives(result, opts = {}) {
34715
34745
  if (isClientFileDirective2(value)) {
34716
34746
  if (!isAllowedClientFilePath(value.path)) return null;
34717
34747
  try {
34718
- await mkdir3(path10.dirname(value.path), { recursive: true });
34748
+ await mkdir3(path11.dirname(value.path), { recursive: true });
34719
34749
  await writeFile3(value.path, value.content, "utf8");
34720
34750
  written.push(value.path);
34721
34751
  return value.path;
@@ -34742,15 +34772,15 @@ async function applyClientFileDirectives(result, opts = {}) {
34742
34772
  }
34743
34773
 
34744
34774
  // ../argent-tools-client/src/flow-files.ts
34745
- var import_yaml = __toESM(require_dist2(), 1);
34775
+ var import_yaml = __toESM(require_dist3(), 1);
34746
34776
  import { readdir as readdir4, readFile as readFile4, realpath as realpath3, stat as stat4 } from "node:fs/promises";
34747
- import * as path11 from "node:path";
34777
+ import * as path12 from "node:path";
34748
34778
  var INLINE_MEMBERS_BYTES = 256 * 1024;
34749
34779
  function filesLogEnabled() {
34750
34780
  return (process.env.ARGENT_E2E_FILES_LOG ?? process.env.ARGENT_FLOW_FILES_LOG) === "1";
34751
34781
  }
34752
34782
  function isWithin(inner, outer) {
34753
- return inner === outer || inner.startsWith(outer.endsWith(path11.sep) ? outer : outer + path11.sep);
34783
+ return inner === outer || inner.startsWith(outer.endsWith(path12.sep) ? outer : outer + path12.sep);
34754
34784
  }
34755
34785
  function printable(text) {
34756
34786
  return [...text].map(
@@ -34758,7 +34788,7 @@ function printable(text) {
34758
34788
  ).join("");
34759
34789
  }
34760
34790
  function isResolvedAbsolute2(value) {
34761
- return typeof value === "string" && path11.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
34791
+ return typeof value === "string" && path12.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
34762
34792
  }
34763
34793
  function namesValidFlow(args) {
34764
34794
  let canonical;
@@ -34770,13 +34800,13 @@ function namesValidFlow(args) {
34770
34800
  const { project_root, e2e_test_path: testPath, name } = canonical;
34771
34801
  if (!isResolvedAbsolute2(project_root)) return false;
34772
34802
  if (name === void 0) {
34773
- return isResolvedAbsolute2(testPath) && FLOW_FILE_NAME_PATTERN.test(path11.basename(testPath));
34803
+ return isResolvedAbsolute2(testPath) && FLOW_FILE_NAME_PATTERN.test(path12.basename(testPath));
34774
34804
  }
34775
34805
  return testPath === void 0 && typeof name === "string" && FLOW_NAME_PATTERN.test(name);
34776
34806
  }
34777
34807
  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)) {
34808
+ if (!path12.isAbsolute(file)) return null;
34809
+ for (let dir = path12.dirname(file); dir !== path12.dirname(dir); dir = path12.dirname(dir)) {
34780
34810
  const project = e2eDirProject(dir);
34781
34811
  if (project !== null) return project;
34782
34812
  }
@@ -34791,11 +34821,11 @@ async function landing(spelled) {
34791
34821
  const canonical = await canonicalFlowPath(spelled);
34792
34822
  let at = spelled;
34793
34823
  for (; ; ) {
34794
- const parent = path11.dirname(at);
34824
+ const parent = path12.dirname(at);
34795
34825
  if (parent === at) return { canonical, fence: spelled, ...failure2 };
34796
34826
  const real = await realpath3(parent).catch(() => null);
34797
34827
  if (real !== null) {
34798
- return { canonical, fence: path11.join(real, path11.basename(at)), ...failure2 };
34828
+ return { canonical, fence: path12.join(real, path12.basename(at)), ...failure2 };
34799
34829
  }
34800
34830
  at = parent;
34801
34831
  }
@@ -34803,10 +34833,10 @@ async function landing(spelled) {
34803
34833
  }
34804
34834
  async function closureRoots(rootPath, rootCanonical, projectRoot) {
34805
34835
  const candidates = [];
34806
- if (typeof projectRoot === "string" && path11.isAbsolute(projectRoot)) {
34836
+ if (typeof projectRoot === "string" && path12.isAbsolute(projectRoot)) {
34807
34837
  candidates.push(projectRoot, ...e2eDirsFor(projectRoot));
34808
34838
  }
34809
- candidates.push(path11.dirname(rootPath), path11.dirname(rootCanonical));
34839
+ candidates.push(path12.dirname(rootPath), path12.dirname(rootCanonical));
34810
34840
  for (const file of [rootPath, rootCanonical]) {
34811
34841
  const project = savedFlowProject(file);
34812
34842
  if (project !== null) candidates.push(project);
@@ -34819,11 +34849,11 @@ async function closureRoots(rootPath, rootCanonical, projectRoot) {
34819
34849
  return real.filter((root) => !real.some((other) => other !== root && isWithin(root, other)));
34820
34850
  }
34821
34851
  async function readFlowMember(anchorDir, target, roots, budget, opts) {
34822
- const spelled = anchorDir + path11.sep + target;
34852
+ const spelled = anchorDir + path12.sep + target;
34823
34853
  const { canonical, fence, missing, error: error2 } = await landing(spelled);
34824
34854
  const spelling = await classifyOnDiskSpelling(
34825
- path11.dirname(spelled),
34826
- path11.posix.basename(target),
34855
+ path12.dirname(spelled),
34856
+ path12.posix.basename(target),
34827
34857
  FLOW_FILE_NAME_PATTERN
34828
34858
  );
34829
34859
  const member = {
@@ -34848,7 +34878,7 @@ async function readFlowMember(anchorDir, target, roots, budget, opts) {
34848
34878
  return { member: { ...member, state: "missing" }, sent: "missing" };
34849
34879
  }
34850
34880
  if (st.isDirectory()) return refuse("EISDIR: illegal operation on a directory, read");
34851
- if (!/\.ya?ml$/i.test(path11.basename(canonical))) {
34881
+ if (!/\.ya?ml$/i.test(path12.basename(canonical))) {
34852
34882
  return refuse(`${target} links to a file that is not a YAML file`);
34853
34883
  }
34854
34884
  const sent = await sendBytes(member, canonical, budget, opts);
@@ -34973,12 +35003,12 @@ function memberCollector(roots, opts) {
34973
35003
  }
34974
35004
  async function savedTest(target) {
34975
35005
  for (const candidate of target.paths) {
34976
- const found = await flow(path11.dirname(candidate), path11.basename(candidate), true);
35006
+ const found = await flow(path12.dirname(candidate), path12.basename(candidate), true);
34977
35007
  if (found !== void 0) return found;
34978
35008
  }
34979
35009
  let first;
34980
35010
  for (const candidate of target.paths) {
34981
- first ??= await flow(path11.dirname(candidate), path11.basename(candidate));
35011
+ first ??= await flow(path12.dirname(candidate), path12.basename(candidate));
34982
35012
  }
34983
35013
  return first;
34984
35014
  }
@@ -35015,7 +35045,7 @@ function memberCollector(roots, opts) {
35015
35045
  const requests = collectFlowRequests(doc);
35016
35046
  for (const name of requests.snapshots) snapshots.add(name);
35017
35047
  for (const step of requests.toolSteps) await toolFiles(step);
35018
- const anchorDir = path11.dirname(file.canonical);
35048
+ const anchorDir = path12.dirname(file.canonical);
35019
35049
  for (const target of requests.runTargets) {
35020
35050
  const key = flowMemberKey(anchorDir, target);
35021
35051
  if (visited.has(key)) continue;
@@ -35037,8 +35067,8 @@ function memberCollector(roots, opts) {
35037
35067
  }
35038
35068
  }
35039
35069
  if (snapshots.size === 0) continue;
35040
- const dir = path11.join(
35041
- path11.dirname(run.canonical),
35070
+ const dir = path12.join(
35071
+ path12.dirname(run.canonical),
35042
35072
  "__baselines__",
35043
35073
  baselineKeyFor(run.canonical, run.flowName)
35044
35074
  );
@@ -35062,7 +35092,7 @@ function memberCollector(roots, opts) {
35062
35092
  if (!name.endsWith(".png")) continue;
35063
35093
  const compared = [...prefixes].some((prefix) => name.startsWith(prefix));
35064
35094
  if (!updates && !compared) continue;
35065
- const file = path11.join(dir, name);
35095
+ const file = path12.join(dir, name);
35066
35096
  if (tools.has(file)) continue;
35067
35097
  const member = { role: "baseline", key: file, path: file };
35068
35098
  const entry = await baselineEntry(file, roots, updates && !compared);
@@ -35085,8 +35115,8 @@ async function collectFlowMembers(rootPath, rootBytes, args, opts) {
35085
35115
  if (!namesValidFlow(args)) return {};
35086
35116
  const canonical = await canonicalFlowPath(rootPath);
35087
35117
  const spelling = await classifyOnDiskSpelling(
35088
- path11.dirname(rootPath),
35089
- path11.basename(rootPath),
35118
+ path12.dirname(rootPath),
35119
+ path12.basename(rootPath),
35090
35120
  FLOW_FILE_NAME_PATTERN
35091
35121
  );
35092
35122
  const collector = memberCollector(
@@ -35097,7 +35127,7 @@ async function collectFlowMembers(rootPath, rootBytes, args, opts) {
35097
35127
  {
35098
35128
  canonical,
35099
35129
  text: rootBytes.toString("utf8"),
35100
- flowName: path11.basename(rootPath, ".yaml"),
35130
+ flowName: path12.basename(rootPath, ".yaml"),
35101
35131
  hop: 0,
35102
35132
  updates: args.updateBaselines === true,
35103
35133
  platform: callPlatform(args)
@@ -35126,31 +35156,31 @@ async function collectStepMembers(args, opts, recordingDirFor = e2eDirFor) {
35126
35156
  if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name) || !isResolvedAbsolute2(projectRoot) || step === void 0) {
35127
35157
  return [];
35128
35158
  }
35129
- const recording = path11.join(recordingDirFor(projectRoot), `${name}.yaml`);
35159
+ const recording = path12.join(recordingDirFor(projectRoot), `${name}.yaml`);
35130
35160
  const collector = memberCollector(
35131
35161
  await closureRoots(recording, (await landing(recording)).canonical, projectRoot),
35132
35162
  opts
35133
35163
  );
35134
35164
  await collector.toolFiles(step);
35135
35165
  if (canonicalToolId(step.tool) === "e2e-execute") {
35136
- const self = await collector.flow(path11.dirname(recording), path11.basename(recording));
35166
+ const self = await collector.flow(path12.dirname(recording), path12.basename(recording));
35137
35167
  let runArgs = step.args;
35138
35168
  const named = nestedFlowTarget(runArgs);
35139
35169
  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);
35170
+ const stem = path12.basename(named.path, ".yaml");
35171
+ const base = path12.basename(named.path);
35172
+ const dir = path12.resolve(path12.dirname(named.path));
35173
+ const recordingDir = path12.dirname(recording);
35144
35174
  const dirs = [recordingDir, ...e2eRunFallbackDirs(recordingDir, base)];
35145
- if (dirs.some((d) => path11.resolve(d) === dir)) {
35146
- await collector.flow(path11.dirname(named.path), base);
35175
+ if (dirs.some((d) => path12.resolve(d) === dir)) {
35176
+ await collector.flow(path12.dirname(named.path), base);
35147
35177
  runArgs = { ...runArgs, name: stem };
35148
35178
  delete runArgs.e2e_test_path;
35149
35179
  }
35150
35180
  }
35151
35181
  const target = nestedFlowTarget(runArgs);
35152
35182
  if (target?.kind === "name") {
35153
- await collector.flow(path11.dirname(self.member.canonical), `${target.name}.yaml`);
35183
+ await collector.flow(path12.dirname(self.member.canonical), `${target.name}.yaml`);
35154
35184
  const run = await collector.nestedRun(
35155
35185
  target,
35156
35186
  0,
@@ -35344,10 +35374,10 @@ function assertFiniteNumbers(args) {
35344
35374
  if (typeof item === "object" && item !== null) {
35345
35375
  pending.push({ value: item, key, parent: visit });
35346
35376
  } 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}` });
35377
+ const path19 = [key];
35378
+ for (let at = visit; at.parent; at = at.parent) path19.push(at.key);
35379
+ path19.reverse();
35380
+ issues.push({ code: "invalid_type", path: path19, message: `expected a number, got ${item}` });
35351
35381
  if (issues.length === MAX_NON_FINITE_ISSUES) break;
35352
35382
  }
35353
35383
  }
@@ -35532,7 +35562,7 @@ function createToolsClient(options = {}) {
35532
35562
  log: diagnose,
35533
35563
  baselineDirs,
35534
35564
  collectMembers: collectFlowMembers,
35535
- collectStepMembers: olderServer ? (record2, o) => collectStepMembers(record2, o, (root) => path12.join(root, LEGACY_E2E_DIRS[0])) : collectStepMembers,
35565
+ collectStepMembers: olderServer ? (record2, o) => collectStepMembers(record2, o, (root) => path13.join(root, LEGACY_E2E_DIRS[0])) : collectStepMembers,
35536
35566
  toolFileInputs: (tool) => findTool(tools, tool)?.fileInputs,
35537
35567
  signal: opts?.signal
35538
35568
  });
@@ -35545,7 +35575,7 @@ function createToolsClient(options = {}) {
35545
35575
  }
35546
35576
  if (filesLogEnabled()) {
35547
35577
  for (const file of applied.written) {
35548
- if (baselineDirs.includes(path12.dirname(file))) {
35578
+ if (baselineDirs.includes(path13.dirname(file))) {
35549
35579
  diagnose(`[e2e-files] baseline ${file}: written`);
35550
35580
  }
35551
35581
  }
@@ -35689,7 +35719,7 @@ import {
35689
35719
  } from "node:fs/promises";
35690
35720
  import { constants as fsConstants } from "node:fs";
35691
35721
  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";
35722
+ 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
35723
  import { createHash as createHash3 } from "node:crypto";
35694
35724
  var ARTIFACT_MARKER2 = "__argentArtifact";
35695
35725
  function isArtifactHandle(value) {
@@ -35713,16 +35743,16 @@ function projectSlug() {
35713
35743
  return `${name}-${hash}`;
35714
35744
  }
35715
35745
  function artifactsRoot() {
35716
- return process.env.ARGENT_ARTIFACTS_DIR ?? join13(tmpdir2(), "argent-artifacts");
35746
+ return process.env.ARGENT_ARTIFACTS_DIR ?? join14(tmpdir2(), "argent-artifacts");
35717
35747
  }
35718
35748
  function artifactDir(deviceId) {
35719
35749
  const parts = [artifactsRoot(), projectSlug(), sessionId()];
35720
35750
  if (deviceId) parts.push(sanitizeSegment(deviceId));
35721
- return join13(...parts);
35751
+ return join14(...parts);
35722
35752
  }
35723
35753
  function durableBaseDir() {
35724
35754
  const projectRoot = findProjectRoot(process.cwd());
35725
- return projectRoot ?? dirname9(argentHomeDir());
35755
+ return projectRoot ?? resolveHomeDir();
35726
35756
  }
35727
35757
  var ALLOWED_SAVE_DIRS = /* @__PURE__ */ new Set([normalize2(".argent/recordings")]);
35728
35758
  var RECORDINGS_SAVE_DIR = normalize2(".argent/recordings");
@@ -35736,9 +35766,9 @@ function configuredRecordingsDir() {
35736
35766
  if (typeof value !== "string") return null;
35737
35767
  const trimmed = value.trim();
35738
35768
  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);
35769
+ const home = resolveHomeDir();
35770
+ const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep5}`) ? join14(home, trimmed.slice(2)) : trimmed;
35771
+ return resolve11(durableBaseDir(), expanded);
35742
35772
  }
35743
35773
  var MAX_ARTIFACT_BYTES = 2 * 1024 * 1024 * 1024;
35744
35774
  async function readCapped(res, cap) {
@@ -35771,10 +35801,10 @@ async function writeDurableUnique(dir, filename, write) {
35771
35801
  const stem = filename.slice(0, filename.length - ext.length);
35772
35802
  for (let i = 1; i <= 1e3; i++) {
35773
35803
  const candidate = i === 1 ? filename : `${stem} (${i})${ext}`;
35774
- const path18 = join13(dir, candidate);
35804
+ const path19 = join14(dir, candidate);
35775
35805
  try {
35776
- await write(path18);
35777
- return path18;
35806
+ await write(path19);
35807
+ return path19;
35778
35808
  } catch (err) {
35779
35809
  if (err?.code === "EEXIST") continue;
35780
35810
  throw err;
@@ -35794,21 +35824,21 @@ function durableSaveTarget(handle) {
35794
35824
  if (configured) {
35795
35825
  return {
35796
35826
  dir: configured,
35797
- path: join13(configured, sanitizeSegment(handle.filename)),
35827
+ path: join14(configured, sanitizeSegment(handle.filename)),
35798
35828
  base: configured,
35799
35829
  rel: ""
35800
35830
  };
35801
35831
  }
35802
35832
  }
35803
35833
  const base = durableBaseDir();
35804
- const dir = join13(base, rel);
35805
- return { dir, path: join13(dir, sanitizeSegment(handle.filename)), base, rel };
35834
+ const dir = join14(base, rel);
35835
+ return { dir, path: join14(dir, sanitizeSegment(handle.filename)), base, rel };
35806
35836
  }
35807
35837
  async function confineToRealBase(dir, base, rel) {
35808
35838
  try {
35809
35839
  const realDir = await realpath4(dir);
35810
35840
  const realBase = await realpath4(base);
35811
- return realDir === join13(realBase, rel);
35841
+ return realDir === join14(realBase, rel);
35812
35842
  } catch {
35813
35843
  return false;
35814
35844
  }
@@ -35832,9 +35862,9 @@ async function resolveLocalFile(handle) {
35832
35862
  }
35833
35863
  async function downloadAndExtractArchive(handle, data, dir, signal) {
35834
35864
  signal?.throwIfAborted();
35835
- const attemptDir = await mkdtemp(join13(dir, "bundle-"));
35836
- const tarball = join13(attemptDir, "download.tar");
35837
- const extractDir = join13(attemptDir, "files");
35865
+ const attemptDir = await mkdtemp(join14(dir, "bundle-"));
35866
+ const tarball = join14(attemptDir, "download.tar");
35867
+ const extractDir = join14(attemptDir, "files");
35838
35868
  try {
35839
35869
  await writeFile4(tarball, data, { signal });
35840
35870
  await mkdir4(extractDir);
@@ -35934,7 +35964,7 @@ async function materializeArtifacts(result, ctx) {
35934
35964
  return await downloadAndExtractArchive(value, data, dir, ctx.signal);
35935
35965
  }
35936
35966
  if (value.size > 0 && data.length !== value.size) return null;
35937
- const downloadedPath = join13(dir, sanitizeSegment(value.filename));
35967
+ const downloadedPath = join14(dir, sanitizeSegment(value.filename));
35938
35968
  await writeFile4(downloadedPath, data);
35939
35969
  if (value.mimeType.startsWith("image/")) {
35940
35970
  images.push({ localPath: downloadedPath, data, mimeType: value.mimeType });
@@ -35971,7 +36001,7 @@ function getDeviceIdFromArgs(args) {
35971
36001
  import * as fs8 from "node:fs";
35972
36002
 
35973
36003
  // ../telemetry/src/paths.ts
35974
- import * as path13 from "node:path";
36004
+ import * as path14 from "node:path";
35975
36005
 
35976
36006
  // ../telemetry/src/events.ts
35977
36007
  var PLATFORMS = [
@@ -36304,22 +36334,22 @@ var SESSION_ID2 = randomUUID5();
36304
36334
  // ../telemetry/src/identity.ts
36305
36335
  import * as crypto2 from "node:crypto";
36306
36336
  import * as fs9 from "node:fs";
36307
- import * as path14 from "node:path";
36337
+ import * as path15 from "node:path";
36308
36338
 
36309
36339
  // ../telemetry/src/fingerprint.ts
36310
36340
  import { execFileSync as execFileSync2, spawn as spawn3 } from "node:child_process";
36311
36341
 
36312
36342
  // ../native-devtools-ios/src/index.ts
36313
- import * as path15 from "node:path";
36343
+ import * as path16 from "node:path";
36314
36344
  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");
36345
+ var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ?? path16.join(__dirname, "..", "dylibs");
36346
+ var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ?? path16.join(__dirname, "..", "bin");
36347
+ var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ?? path16.join(DYLIB_DIR, "tcp");
36348
+ var DYLIB_TVOS_DIR = path16.join(DYLIB_DIR, "tvos");
36319
36349
 
36320
36350
  // ../telemetry/src/consent.ts
36321
36351
  import * as fs11 from "node:fs";
36322
- import * as path16 from "node:path";
36352
+ import * as path17 from "node:path";
36323
36353
  var cache = /* @__PURE__ */ new Map();
36324
36354
  var sessionOverride = null;
36325
36355
  function readConfigOverrideAt(filePath) {
@@ -36360,8 +36390,12 @@ function readConfigOverrideAt(filePath) {
36360
36390
  function readPersistedConsent(cwd) {
36361
36391
  const globalPath = configFilePath("global");
36362
36392
  const projectPath = configFilePath("project", { cwd });
36393
+ const userConfigPath = path17.join(resolveHomeDir(), ".argent", "config.json");
36394
+ if (userConfigPath !== globalPath && readConfigOverrideAt(userConfigPath) === false) {
36395
+ return { enabled: false, detail: `${userConfigPath} (user)` };
36396
+ }
36363
36397
  const global = readConfigOverrideAt(globalPath);
36364
- const projectRoot = path16.dirname(path16.dirname(projectPath));
36398
+ const projectRoot = path17.dirname(path17.dirname(projectPath));
36365
36399
  const project = isHomeDir(projectRoot) ? null : readConfigOverrideAt(projectPath);
36366
36400
  if (project === false && global === false) {
36367
36401
  return { enabled: false, detail: "config.json (project and global)" };
@@ -36741,8 +36775,13 @@ async function flowRunToMcpContent(result, ctx) {
36741
36775
  });
36742
36776
  if (typeof result.warning === "string")
36743
36777
  blocks.push({ type: "text", text: `\u26A0 ${result.warning}` });
36778
+ let inShutdown = false;
36744
36779
  for (let i = 0; i < result.steps.length; i++) {
36745
36780
  const step = result.steps[i];
36781
+ if (step.shutdown === true && !inShutdown) {
36782
+ inShutdown = true;
36783
+ blocks.push({ type: "text", text: "shutdown:" });
36784
+ }
36746
36785
  const num = step.index !== void 0 ? step.index + 1 : i + 1;
36747
36786
  const glyph = step.status ? `${STATUS_GLYPH[step.status] ?? "\u2022"} ` : "";
36748
36787
  const reason = step.reason ?? step.error;
@@ -36769,11 +36808,17 @@ async function flowRunToMcpContent(result, ctx) {
36769
36808
  }
36770
36809
  }
36771
36810
  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}` });
36811
+ const { path: path19, error: error2 } = isRecord3(write) ? write : {};
36812
+ if (typeof path19 === "string" && typeof error2 === "string") {
36813
+ blocks.push({ type: "text", text: `\u2717 baseline not written: ${path19}: ${error2}` });
36775
36814
  }
36776
36815
  }
36816
+ if (result.shutdownFailed === true) {
36817
+ blocks.push({
36818
+ type: "text",
36819
+ text: "\u26A0 shutdown did not finish: a shutdown step failed, so the run may have left state behind."
36820
+ });
36821
+ }
36777
36822
  if (result.ok !== void 0) {
36778
36823
  const counted = (result.passed ?? 0) + (result.failed ?? 0) + (result.errored ?? 0) + (result.skipped ?? 0);
36779
36824
  const note = result.ok && counted === 0 ? " (no test steps)" : "";
@@ -37817,14 +37862,14 @@ function debuggerLogRegistryText(result) {
37817
37862
  }
37818
37863
 
37819
37864
  // ../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.";
37865
+ 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
37866
 
37822
37867
  // ../argent-mcp/src/installed-version.ts
37823
37868
  import * as fs12 from "node:fs";
37824
- import * as path17 from "node:path";
37869
+ import * as path18 from "node:path";
37825
37870
  function getInstalledVersion() {
37826
37871
  try {
37827
- const pkgPath = path17.resolve(import.meta.dirname, "..", "package.json");
37872
+ const pkgPath = path18.resolve(import.meta.dirname, "..", "package.json");
37828
37873
  const pkg = JSON.parse(fs12.readFileSync(pkgPath, "utf8"));
37829
37874
  return pkg.version ?? "unknown";
37830
37875
  } catch {
@@ -37880,9 +37925,9 @@ async function untilAborted(work, signal) {
37880
37925
  }
37881
37926
  let onAbort = () => {
37882
37927
  };
37883
- const aborted2 = new Promise((resolve12) => {
37884
- onAbort = resolve12;
37885
- if (signal.aborted) resolve12();
37928
+ const aborted2 = new Promise((resolve13) => {
37929
+ onAbort = resolve13;
37930
+ if (signal.aborted) resolve13();
37886
37931
  else signal.addEventListener("abort", onAbort, { once: true });
37887
37932
  });
37888
37933
  try {
@@ -37987,11 +38032,15 @@ function formatWhatsNewNote(version2, highlights) {
37987
38032
  ].join("\n");
37988
38033
  }
37989
38034
  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;
38035
+ let seen = getWhatsNewSeenVersion();
38036
+ while (isNewerThanSeen(current, seen)) {
38037
+ if (setWhatsNewSeenVersion(current, { ifSeen: seen })) {
38038
+ const highlights = highlightsSince(seen, current);
38039
+ return highlights.length > 0 ? formatWhatsNewNote(current, highlights) : void 0;
38040
+ }
38041
+ seen = getWhatsNewSeenVersion();
38042
+ }
38043
+ return void 0;
37995
38044
  }
37996
38045
 
37997
38046
  // ../argent-mcp/src/mcp-server.ts
@@ -38017,6 +38066,8 @@ async function startMcpServer(options) {
38017
38066
  const autoScreenshotOn = autoScreenshotEnabled();
38018
38067
  const autoDescribeOn = autoDescribeEnabled();
38019
38068
  const whatsNewOn = whatsNewEnabled();
38069
+ const installedVersion = getInstalledVersion();
38070
+ const highlightsVersion = true ? "0.35.1-next.21" : installedVersion;
38020
38071
  const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
38021
38072
  const trees = createTreeMemory();
38022
38073
  const screenshots = createScreenshotMemory();
@@ -38061,12 +38112,12 @@ async function startMcpServer(options) {
38061
38112
  }
38062
38113
  return reconnectPromise;
38063
38114
  }
38064
- const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? `${homedir5()}/.argent/mcp-calls.log`;
38115
+ const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? join19(argentHomeDir(), "mcp-calls.log");
38065
38116
  let logDirReady = false;
38066
38117
  async function spyLog(entry) {
38067
38118
  try {
38068
38119
  if (!logDirReady) {
38069
- await mkdir5(dirname11(LOG_FILE2), { recursive: true });
38120
+ await mkdir5(dirname10(LOG_FILE2), { recursive: true });
38070
38121
  logDirReady = true;
38071
38122
  }
38072
38123
  await appendFile(LOG_FILE2, JSON.stringify(entry) + "\n");
@@ -38183,14 +38234,14 @@ ${shown.text}` }];
38183
38234
  if (!whatsNewOn || whatsNewChecked) return [];
38184
38235
  whatsNewChecked = true;
38185
38236
  try {
38186
- const note = takeWhatsNewNote(getInstalledVersion());
38237
+ const note = takeWhatsNewNote(highlightsVersion);
38187
38238
  return note ? [{ type: "text", text: note }] : [];
38188
38239
  } catch {
38189
38240
  return [];
38190
38241
  }
38191
38242
  }
38192
38243
  const server = new Server(
38193
- { name: "argent", version: getInstalledVersion() },
38244
+ { name: "argent", version: installedVersion },
38194
38245
  {
38195
38246
  capabilities: { tools: {} },
38196
38247
  instructions: SERVER_INSTRUCTIONS
@@ -38269,7 +38320,7 @@ ${shown.text}` }];
38269
38320
  content = [...content, { type: "text", text: screenshotIdLine(id) }];
38270
38321
  }
38271
38322
  }
38272
- if (udid && autoDescribeOn && canonicalToolId(params.name) === "describe") {
38323
+ if (udid && autoDescribeOn && canonicalToolId(params.name) === "describe" && params.arguments?.raw !== true) {
38273
38324
  const tree = describedTree(result);
38274
38325
  if (tree !== void 0) {
38275
38326
  treeUdid = udid;