@swmansion/argent 0.35.1-next.6 → 0.35.1-next.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +16 -15
  2. package/bin/argent-android-devtools-0.4.0.apk +0 -0
  3. package/bin/darwin/argent-macos-helper +0 -0
  4. package/bin/darwin/ax-service +0 -0
  5. package/bin/darwin/tvos-ax-service +0 -0
  6. package/bin/darwin/tvos-hid-daemon +0 -0
  7. package/bin/network-inspector/network-inspector.jar +0 -0
  8. package/bin/tcp/ax-service +0 -0
  9. package/dist/cli-cmds.mjs +2509 -2084
  10. package/dist/client.js +494 -386
  11. package/dist/fatal-handlers.js +7 -1
  12. package/dist/fatal-handlers.js.map +1 -1
  13. package/dist/installer-help.js +2 -1
  14. package/dist/installer-help.js.map +1 -1
  15. package/dist/installer.mjs +706 -676
  16. package/dist/mcp-server.mjs +1724 -1523
  17. package/dist/tool-args.generated.d.ts +411 -318
  18. package/dist/tool-server.cjs +12443 -9286
  19. package/dylibs/libArgentAudio.dylib +0 -0
  20. package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
  21. package/dylibs/libKeyboardPatch.dylib +0 -0
  22. package/dylibs/libNativeDevtoolsIos.dylib +0 -0
  23. package/dylibs/macos/libArgentInjectionBootstrap.dylib +0 -0
  24. package/dylibs/macos/libNativeDevtoolsMacos.dylib +0 -0
  25. package/dylibs/tcp/argent-audio-feeder +0 -0
  26. package/dylibs/tcp/libArgentAudio.dylib +0 -0
  27. package/dylibs/tcp/libArgentInjectionBootstrap.dylib +0 -0
  28. package/dylibs/tcp/libKeyboardPatch.dylib +0 -0
  29. package/dylibs/tcp/libNativeDevtoolsIos.dylib +0 -0
  30. package/dylibs/tvos/libArgentInjectionBootstrap.dylib +0 -0
  31. package/dylibs/tvos/libKeyboardPatch.dylib +0 -0
  32. package/dylibs/tvos/libNativeDevtoolsIos.dylib +0 -0
  33. package/package.json +2 -2
  34. package/skills/argent-android-emulator-setup/SKILL.md +2 -2
  35. package/skills/argent-create-e2e/SKILL.md +2 -1
  36. package/skills/argent-create-e2e/references/e2e-yaml.md +42 -2
  37. package/skills/argent-create-e2e/references/live-authoring.md +14 -3
  38. package/skills/argent-device-interact/SKILL.md +21 -94
  39. package/skills/argent-device-interact/references/advanced.md +64 -0
  40. package/skills/argent-ios-device-interact/SKILL.md +1 -1
  41. package/skills/argent-ios-device-setup/SKILL.md +1 -1
  42. package/skills/argent-ios-simulator-setup/SKILL.md +1 -1
  43. package/skills/argent-lens/SKILL.md +1 -1
  44. package/skills/argent-macos-app-interact/SKILL.md +1 -1
  45. package/skills/argent-metro-debugger/SKILL.md +4 -4
  46. package/skills/argent-native-profiler/SKILL.md +1 -1
  47. package/skills/argent-qa-e2e/SKILL.md +1 -1
  48. package/skills/argent-react-native-app-workflow/SKILL.md +1 -1
  49. package/skills/argent-react-native-optimization/SKILL.md +1 -1
  50. package/skills/argent-react-native-profiler/SKILL.md +1 -1
  51. package/skills/argent-screen-recording/SKILL.md +1 -1
  52. package/skills/argent-screenshot-diff/SKILL.md +1 -1
  53. package/skills/argent-settings-permissions/SKILL.md +1 -1
  54. package/skills/argent-test-ui-flow/SKILL.md +1 -1
  55. package/skills/argent-tv-interact/SKILL.md +1 -1
@@ -2990,7 +2990,7 @@ var require_compile = __commonJS({
2990
2990
  const schOrFunc = root.refs[ref];
2991
2991
  if (schOrFunc)
2992
2992
  return schOrFunc;
2993
- let _sch = resolve12.call(this, root, ref);
2993
+ let _sch = resolve13.call(this, root, ref);
2994
2994
  if (_sch === void 0) {
2995
2995
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
2996
2996
  const { schemaId } = this.opts;
@@ -3017,7 +3017,7 @@ var require_compile = __commonJS({
3017
3017
  function sameSchemaEnv(s1, s2) {
3018
3018
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
3019
3019
  }
3020
- function resolve12(root, ref) {
3020
+ function resolve13(root, ref) {
3021
3021
  let sch;
3022
3022
  while (typeof (sch = this.refs[ref]) == "string")
3023
3023
  ref = sch;
@@ -3235,8 +3235,8 @@ var require_utils = __commonJS({
3235
3235
  }
3236
3236
  return ind;
3237
3237
  }
3238
- function removeDotSegments(path18) {
3239
- let input = path18;
3238
+ function removeDotSegments(path19) {
3239
+ let input = path19;
3240
3240
  const output = [];
3241
3241
  let nextSlash = -1;
3242
3242
  let len = 0;
@@ -3488,8 +3488,8 @@ var require_schemes = __commonJS({
3488
3488
  wsComponent.secure = void 0;
3489
3489
  }
3490
3490
  if (wsComponent.resourceName) {
3491
- const [path18, query] = wsComponent.resourceName.split("?");
3492
- wsComponent.path = path18 && path18 !== "/" ? path18 : void 0;
3491
+ const [path19, query] = wsComponent.resourceName.split("?");
3492
+ wsComponent.path = path19 && path19 !== "/" ? path19 : void 0;
3493
3493
  wsComponent.query = query;
3494
3494
  wsComponent.resourceName = void 0;
3495
3495
  }
@@ -3644,21 +3644,21 @@ var require_fast_uri = __commonJS({
3644
3644
  normalizeString(uri, options);
3645
3645
  } else if (typeof uri === "object") {
3646
3646
  uri = /** @type {T} */
3647
- parse4(serialize(uri, options), options);
3647
+ parse5(serialize(uri, options), options);
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
- const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
3653
+ const resolved = resolveComponent(parse5(baseURI, schemelessOptions), parse5(relativeURI, schemelessOptions), schemelessOptions, true);
3654
3654
  schemelessOptions.skipEscape = true;
3655
3655
  return serialize(resolved, schemelessOptions);
3656
3656
  }
3657
3657
  function resolveComponent(base, relative2, options, skipNormalization) {
3658
3658
  const target = {};
3659
3659
  if (!skipNormalization) {
3660
- base = parse4(serialize(base, options), options);
3661
- relative2 = parse4(serialize(relative2, options), options);
3660
+ base = parse5(serialize(base, options), options);
3661
+ relative2 = parse5(serialize(relative2, options), options);
3662
3662
  }
3663
3663
  options = options || {};
3664
3664
  if (!options.tolerant && relative2.scheme) {
@@ -3881,7 +3881,7 @@ var require_fast_uri = __commonJS({
3881
3881
  }
3882
3882
  return { parsed, malformedAuthorityOrPort };
3883
3883
  }
3884
- function parse4(uri, opts) {
3884
+ function parse5(uri, opts) {
3885
3885
  return parseWithStatus(uri, opts).parsed;
3886
3886
  }
3887
3887
  function normalizeString(uri, opts) {
@@ -3906,11 +3906,11 @@ 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,
3913
- parse: parse4
3913
+ parse: parse5
3914
3914
  };
3915
3915
  module.exports = fastUri;
3916
3916
  module.exports.default = fastUri;
@@ -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;
@@ -12577,12 +12577,12 @@ var require_dist = __commonJS({
12577
12577
  throw new Error(`Unknown format "${name}"`);
12578
12578
  return f;
12579
12579
  };
12580
- function addFormats(ajv, list, fs13, exportName) {
12580
+ function addFormats(ajv, list, fs14, exportName) {
12581
12581
  var _a3;
12582
12582
  var _b;
12583
12583
  (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
12584
12584
  for (const f of list)
12585
- ajv.addFormat(f, fs13[f]);
12585
+ ajv.addFormat(f, fs14[f]);
12586
12586
  }
12587
12587
  module.exports = exports = formatsPlugin;
12588
12588
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -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
  /**
@@ -16553,10 +16945,10 @@ var require_resolve_block_map = __commonJS({
16553
16945
  let offset = bm.offset;
16554
16946
  let commentEnd = null;
16555
16947
  for (const collItem of bm.items) {
16556
- const { start, key, sep: sep6, value } = collItem;
16948
+ const { start, key, sep: sep7, value } = collItem;
16557
16949
  const keyProps = resolveProps.resolveProps(start, {
16558
16950
  indicator: "explicit-key-ind",
16559
- next: key ?? sep6?.[0],
16951
+ next: key ?? sep7?.[0],
16560
16952
  offset,
16561
16953
  onError,
16562
16954
  parentIndent: bm.indent,
@@ -16570,7 +16962,7 @@ var require_resolve_block_map = __commonJS({
16570
16962
  else if ("indent" in key && key.indent !== bm.indent)
16571
16963
  onError(offset, "BAD_INDENT", startColMsg);
16572
16964
  }
16573
- if (!keyProps.anchor && !keyProps.tag && !sep6) {
16965
+ if (!keyProps.anchor && !keyProps.tag && !sep7) {
16574
16966
  commentEnd = keyProps.end;
16575
16967
  if (keyProps.comment) {
16576
16968
  if (map.comment)
@@ -16594,7 +16986,7 @@ var require_resolve_block_map = __commonJS({
16594
16986
  ctx.atKey = false;
16595
16987
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
16596
16988
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
16597
- const valueProps = resolveProps.resolveProps(sep6 ?? [], {
16989
+ const valueProps = resolveProps.resolveProps(sep7 ?? [], {
16598
16990
  indicator: "map-value-ind",
16599
16991
  next: value,
16600
16992
  offset: keyNode.range[2],
@@ -16610,7 +17002,7 @@ var require_resolve_block_map = __commonJS({
16610
17002
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
16611
17003
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
16612
17004
  }
16613
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep6, null, valueProps, onError);
17005
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep7, null, valueProps, onError);
16614
17006
  if (ctx.schema.compat)
16615
17007
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
16616
17008
  offset = valueNode.range[2];
@@ -16701,7 +17093,7 @@ var require_resolve_end = __commonJS({
16701
17093
  let comment = "";
16702
17094
  if (end) {
16703
17095
  let hasSpace = false;
16704
- let sep6 = "";
17096
+ let sep7 = "";
16705
17097
  for (const token of end) {
16706
17098
  const { source, type } = token;
16707
17099
  switch (type) {
@@ -16715,13 +17107,13 @@ var require_resolve_end = __commonJS({
16715
17107
  if (!comment)
16716
17108
  comment = cb;
16717
17109
  else
16718
- comment += sep6 + cb;
16719
- sep6 = "";
17110
+ comment += sep7 + cb;
17111
+ sep7 = "";
16720
17112
  break;
16721
17113
  }
16722
17114
  case "newline":
16723
17115
  if (comment)
16724
- sep6 += source;
17116
+ sep7 += source;
16725
17117
  hasSpace = true;
16726
17118
  break;
16727
17119
  default:
@@ -16764,18 +17156,18 @@ var require_resolve_flow_collection = __commonJS({
16764
17156
  let offset = fc.offset + fc.start.source.length;
16765
17157
  for (let i = 0; i < fc.items.length; ++i) {
16766
17158
  const collItem = fc.items[i];
16767
- const { start, key, sep: sep6, value } = collItem;
17159
+ const { start, key, sep: sep7, value } = collItem;
16768
17160
  const props = resolveProps.resolveProps(start, {
16769
17161
  flow: fcName,
16770
17162
  indicator: "explicit-key-ind",
16771
- next: key ?? sep6?.[0],
17163
+ next: key ?? sep7?.[0],
16772
17164
  offset,
16773
17165
  onError,
16774
17166
  parentIndent: fc.indent,
16775
17167
  startOnNewline: false
16776
17168
  });
16777
17169
  if (!props.found) {
16778
- if (!props.anchor && !props.tag && !sep6 && !value) {
17170
+ if (!props.anchor && !props.tag && !sep7 && !value) {
16779
17171
  if (i === 0 && props.comma)
16780
17172
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
16781
17173
  else if (i < fc.items.length - 1)
@@ -16829,8 +17221,8 @@ var require_resolve_flow_collection = __commonJS({
16829
17221
  }
16830
17222
  }
16831
17223
  }
16832
- if (!isMap && !sep6 && !props.found) {
16833
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep6, null, props, onError);
17224
+ if (!isMap && !sep7 && !props.found) {
17225
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep7, null, props, onError);
16834
17226
  coll.items.push(valueNode);
16835
17227
  offset = valueNode.range[2];
16836
17228
  if (isBlock(value))
@@ -16842,7 +17234,7 @@ var require_resolve_flow_collection = __commonJS({
16842
17234
  if (isBlock(key))
16843
17235
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
16844
17236
  ctx.atKey = false;
16845
- const valueProps = resolveProps.resolveProps(sep6 ?? [], {
17237
+ const valueProps = resolveProps.resolveProps(sep7 ?? [], {
16846
17238
  flow: fcName,
16847
17239
  indicator: "map-value-ind",
16848
17240
  next: value,
@@ -16853,8 +17245,8 @@ var require_resolve_flow_collection = __commonJS({
16853
17245
  });
16854
17246
  if (valueProps.found) {
16855
17247
  if (!isMap && !props.found && ctx.options.strict) {
16856
- if (sep6)
16857
- for (const st of sep6) {
17248
+ if (sep7)
17249
+ for (const st of sep7) {
16858
17250
  if (st === valueProps.found)
16859
17251
  break;
16860
17252
  if (st.type === "newline") {
@@ -16871,7 +17263,7 @@ var require_resolve_flow_collection = __commonJS({
16871
17263
  else
16872
17264
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
16873
17265
  }
16874
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep6, null, valueProps, onError) : null;
17266
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep7, null, valueProps, onError) : null;
16875
17267
  if (valueNode) {
16876
17268
  if (isBlock(value))
16877
17269
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -17051,7 +17443,7 @@ var require_resolve_block_scalar = __commonJS({
17051
17443
  chompStart = i + 1;
17052
17444
  }
17053
17445
  let value = "";
17054
- let sep6 = "";
17446
+ let sep7 = "";
17055
17447
  let prevMoreIndented = false;
17056
17448
  for (let i = 0; i < contentStart; ++i)
17057
17449
  value += lines[i][0].slice(trimIndent) + "\n";
@@ -17068,24 +17460,24 @@ var require_resolve_block_scalar = __commonJS({
17068
17460
  indent = "";
17069
17461
  }
17070
17462
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
17071
- value += sep6 + indent.slice(trimIndent) + content;
17072
- sep6 = "\n";
17463
+ value += sep7 + indent.slice(trimIndent) + content;
17464
+ sep7 = "\n";
17073
17465
  } else if (indent.length > trimIndent || content[0] === " ") {
17074
- if (sep6 === " ")
17075
- sep6 = "\n";
17076
- else if (!prevMoreIndented && sep6 === "\n")
17077
- sep6 = "\n\n";
17078
- value += sep6 + indent.slice(trimIndent) + content;
17079
- sep6 = "\n";
17466
+ if (sep7 === " ")
17467
+ sep7 = "\n";
17468
+ else if (!prevMoreIndented && sep7 === "\n")
17469
+ sep7 = "\n\n";
17470
+ value += sep7 + indent.slice(trimIndent) + content;
17471
+ sep7 = "\n";
17080
17472
  prevMoreIndented = true;
17081
17473
  } else if (content === "") {
17082
- if (sep6 === "\n")
17474
+ if (sep7 === "\n")
17083
17475
  value += "\n";
17084
17476
  else
17085
- sep6 = "\n";
17477
+ sep7 = "\n";
17086
17478
  } else {
17087
- value += sep6 + content;
17088
- sep6 = " ";
17479
+ value += sep7 + content;
17480
+ sep7 = " ";
17089
17481
  prevMoreIndented = false;
17090
17482
  }
17091
17483
  }
@@ -17268,25 +17660,25 @@ var require_resolve_flow_scalar = __commonJS({
17268
17660
  trimBoth = /^[ \t]+|[ \t]+$/g;
17269
17661
  }
17270
17662
  let res = match[1].replace(trimEnd, "");
17271
- let sep6 = " ";
17663
+ let sep7 = " ";
17272
17664
  let pos = line.lastIndex;
17273
17665
  while (match = line.exec(source)) {
17274
17666
  const lm = match[1].replace(trimBoth, "");
17275
17667
  if (lm === "") {
17276
- if (sep6 === "\n")
17277
- res += sep6;
17668
+ if (sep7 === "\n")
17669
+ res += sep7;
17278
17670
  else
17279
- sep6 = "\n";
17671
+ sep7 = "\n";
17280
17672
  } else {
17281
- res += sep6 + lm;
17282
- sep6 = " ";
17673
+ res += sep7 + lm;
17674
+ sep7 = " ";
17283
17675
  }
17284
17676
  pos = line.lastIndex;
17285
17677
  }
17286
17678
  const last = /[ \t]*(.*)/sy;
17287
17679
  last.lastIndex = pos;
17288
17680
  match = last.exec(source);
17289
- return res + sep6 + (match?.[1] ?? "");
17681
+ return res + sep7 + (match?.[1] ?? "");
17290
17682
  }
17291
17683
  function doubleQuotedValue(source, onError) {
17292
17684
  let res = "";
@@ -18096,14 +18488,14 @@ var require_cst_stringify = __commonJS({
18096
18488
  }
18097
18489
  }
18098
18490
  }
18099
- function stringifyItem({ start, key, sep: sep6, value }) {
18491
+ function stringifyItem({ start, key, sep: sep7, value }) {
18100
18492
  let res = "";
18101
18493
  for (const st of start)
18102
18494
  res += st.source;
18103
18495
  if (key)
18104
18496
  res += stringifyToken(key);
18105
- if (sep6)
18106
- for (const st of sep6)
18497
+ if (sep7)
18498
+ for (const st of sep7)
18107
18499
  res += st.source;
18108
18500
  if (value)
18109
18501
  res += stringifyToken(value);
@@ -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
  }
@@ -19270,18 +19662,18 @@ var require_parser = __commonJS({
19270
19662
  if (this.type === "map-value-ind") {
19271
19663
  const prev = getPrevProps(this.peek(2));
19272
19664
  const start = getFirstKeyStartProps(prev);
19273
- let sep6;
19665
+ let sep7;
19274
19666
  if (scalar.end) {
19275
- sep6 = scalar.end;
19276
- sep6.push(this.sourceToken);
19667
+ sep7 = scalar.end;
19668
+ sep7.push(this.sourceToken);
19277
19669
  delete scalar.end;
19278
19670
  } else
19279
- sep6 = [this.sourceToken];
19671
+ sep7 = [this.sourceToken];
19280
19672
  const map = {
19281
19673
  type: "block-map",
19282
19674
  offset: scalar.offset,
19283
19675
  indent: scalar.indent,
19284
- items: [{ start, key: scalar, sep: sep6 }]
19676
+ items: [{ start, key: scalar, sep: sep7 }]
19285
19677
  };
19286
19678
  this.onKeyLine = true;
19287
19679
  this.stack[this.stack.length - 1] = map;
@@ -19434,15 +19826,15 @@ var require_parser = __commonJS({
19434
19826
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
19435
19827
  const start2 = getFirstKeyStartProps(it.start);
19436
19828
  const key = it.key;
19437
- const sep6 = it.sep;
19438
- sep6.push(this.sourceToken);
19829
+ const sep7 = it.sep;
19830
+ sep7.push(this.sourceToken);
19439
19831
  delete it.key;
19440
19832
  delete it.sep;
19441
19833
  this.stack.push({
19442
19834
  type: "block-map",
19443
19835
  offset: this.offset,
19444
19836
  indent: this.indent,
19445
- items: [{ start: start2, key, sep: sep6 }]
19837
+ items: [{ start: start2, key, sep: sep7 }]
19446
19838
  });
19447
19839
  } else if (start.length > 0) {
19448
19840
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -19471,14 +19863,14 @@ var require_parser = __commonJS({
19471
19863
  case "scalar":
19472
19864
  case "single-quoted-scalar":
19473
19865
  case "double-quoted-scalar": {
19474
- const fs13 = this.flowScalar(this.type);
19866
+ const fs14 = this.flowScalar(this.type);
19475
19867
  if (atNextItem || it.value) {
19476
- map.items.push({ start, key: fs13, sep: [] });
19868
+ map.items.push({ start, key: fs14, sep: [] });
19477
19869
  this.onKeyLine = true;
19478
19870
  } else if (it.sep) {
19479
- this.stack.push(fs13);
19871
+ this.stack.push(fs14);
19480
19872
  } else {
19481
- Object.assign(it, { key: fs13, sep: [] });
19873
+ Object.assign(it, { key: fs14, sep: [] });
19482
19874
  this.onKeyLine = true;
19483
19875
  }
19484
19876
  return;
@@ -19606,13 +19998,13 @@ var require_parser = __commonJS({
19606
19998
  case "scalar":
19607
19999
  case "single-quoted-scalar":
19608
20000
  case "double-quoted-scalar": {
19609
- const fs13 = this.flowScalar(this.type);
20001
+ const fs14 = this.flowScalar(this.type);
19610
20002
  if (!it || it.value)
19611
- fc.items.push({ start: [], key: fs13, sep: [] });
20003
+ fc.items.push({ start: [], key: fs14, sep: [] });
19612
20004
  else if (it.sep)
19613
- this.stack.push(fs13);
20005
+ this.stack.push(fs14);
19614
20006
  else
19615
- Object.assign(it, { key: fs13, sep: [] });
20007
+ Object.assign(it, { key: fs14, sep: [] });
19616
20008
  return;
19617
20009
  }
19618
20010
  case "flow-map-end":
@@ -19636,13 +20028,13 @@ var require_parser = __commonJS({
19636
20028
  const prev = getPrevProps(parent);
19637
20029
  const start = getFirstKeyStartProps(prev);
19638
20030
  fixFlowSeqItems(fc);
19639
- const sep6 = fc.end.splice(1, fc.end.length);
19640
- sep6.push(this.sourceToken);
20031
+ const sep7 = fc.end.splice(1, fc.end.length);
20032
+ sep7.push(this.sourceToken);
19641
20033
  const map = {
19642
20034
  type: "block-map",
19643
20035
  offset: fc.offset,
19644
20036
  indent: fc.indent,
19645
- items: [{ start, key: fc, sep: sep6 }]
20037
+ items: [{ start, key: fc, sep: sep7 }]
19646
20038
  };
19647
20039
  this.onKeyLine = true;
19648
20040
  this.stack[this.stack.length - 1] = map;
@@ -19820,7 +20212,7 @@ var require_public_api = __commonJS({
19820
20212
  }
19821
20213
  return doc;
19822
20214
  }
19823
- function parse4(src, reviver, options) {
20215
+ function parse5(src, reviver, options) {
19824
20216
  let _reviver = void 0;
19825
20217
  if (typeof reviver === "function") {
19826
20218
  _reviver = reviver;
@@ -19861,7 +20253,7 @@ var require_public_api = __commonJS({
19861
20253
  return value.toString(options);
19862
20254
  return new Document.Document(value, _replacer, options).toString(options);
19863
20255
  }
19864
- exports.parse = parse4;
20256
+ exports.parse = parse5;
19865
20257
  exports.parseAllDocuments = parseAllDocuments;
19866
20258
  exports.parseDocument = parseDocument;
19867
20259
  exports.stringify = stringify;
@@ -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) {
@@ -20783,7 +20783,7 @@ var require_parse = __commonJS({
20783
20783
  "../../node_modules/semver/functions/parse.js"(exports, module) {
20784
20784
  "use strict";
20785
20785
  var SemVer = require_semver();
20786
- var parse4 = (version2, options, throwErrors = false) => {
20786
+ var parse5 = (version2, options, throwErrors = false) => {
20787
20787
  if (version2 instanceof SemVer) {
20788
20788
  return version2;
20789
20789
  }
@@ -20796,7 +20796,7 @@ var require_parse = __commonJS({
20796
20796
  throw er;
20797
20797
  }
20798
20798
  };
20799
- module.exports = parse4;
20799
+ module.exports = parse5;
20800
20800
  }
20801
20801
  });
20802
20802
 
@@ -20804,9 +20804,9 @@ var require_parse = __commonJS({
20804
20804
  var require_valid = __commonJS({
20805
20805
  "../../node_modules/semver/functions/valid.js"(exports, module) {
20806
20806
  "use strict";
20807
- var parse4 = require_parse();
20807
+ var parse5 = require_parse();
20808
20808
  var valid = (version2, options) => {
20809
- const v = parse4(version2, options);
20809
+ const v = parse5(version2, options);
20810
20810
  return v ? v.version : null;
20811
20811
  };
20812
20812
  module.exports = valid;
@@ -20817,9 +20817,9 @@ var require_valid = __commonJS({
20817
20817
  var require_clean = __commonJS({
20818
20818
  "../../node_modules/semver/functions/clean.js"(exports, module) {
20819
20819
  "use strict";
20820
- var parse4 = require_parse();
20820
+ var parse5 = require_parse();
20821
20821
  var clean = (version2, options) => {
20822
- const s = parse4(version2.trim().replace(/^[=v]+/, ""), options);
20822
+ const s = parse5(version2.trim().replace(/^[=v]+/, ""), options);
20823
20823
  return s ? s.version : null;
20824
20824
  };
20825
20825
  module.exports = clean;
@@ -20854,10 +20854,10 @@ var require_inc = __commonJS({
20854
20854
  var require_diff = __commonJS({
20855
20855
  "../../node_modules/semver/functions/diff.js"(exports, module) {
20856
20856
  "use strict";
20857
- var parse4 = require_parse();
20857
+ var parse5 = require_parse();
20858
20858
  var diff = (version1, version2) => {
20859
- const v1 = parse4(version1, null, true);
20860
- const v2 = parse4(version2, null, true);
20859
+ const v1 = parse5(version1, null, true);
20860
+ const v2 = parse5(version2, null, true);
20861
20861
  const comparison = v1.compare(v2);
20862
20862
  if (comparison === 0) {
20863
20863
  return null;
@@ -20928,9 +20928,9 @@ var require_patch = __commonJS({
20928
20928
  var require_prerelease = __commonJS({
20929
20929
  "../../node_modules/semver/functions/prerelease.js"(exports, module) {
20930
20930
  "use strict";
20931
- var parse4 = require_parse();
20931
+ var parse5 = require_parse();
20932
20932
  var prerelease = (version2, options) => {
20933
- const parsed = parse4(version2, options);
20933
+ const parsed = parse5(version2, options);
20934
20934
  return parsed && parsed.prerelease.length ? parsed.prerelease : null;
20935
20935
  };
20936
20936
  module.exports = prerelease;
@@ -21116,7 +21116,7 @@ var require_coerce = __commonJS({
21116
21116
  "../../node_modules/semver/functions/coerce.js"(exports, module) {
21117
21117
  "use strict";
21118
21118
  var SemVer = require_semver();
21119
- var parse4 = require_parse();
21119
+ var parse5 = require_parse();
21120
21120
  var { safeRe: re, t } = require_re();
21121
21121
  var coerce = (version2, options) => {
21122
21122
  if (version2 instanceof SemVer) {
@@ -21151,7 +21151,7 @@ var require_coerce = __commonJS({
21151
21151
  const patch = match[4] || "0";
21152
21152
  const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
21153
21153
  const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
21154
- return parse4(`${major}.${minor}.${patch}${prerelease}${build}`, options);
21154
+ return parse5(`${major}.${minor}.${patch}${prerelease}${build}`, options);
21155
21155
  };
21156
21156
  module.exports = coerce;
21157
21157
  }
@@ -21161,7 +21161,7 @@ var require_coerce = __commonJS({
21161
21161
  var require_truncate = __commonJS({
21162
21162
  "../../node_modules/semver/functions/truncate.js"(exports, module) {
21163
21163
  "use strict";
21164
- var parse4 = require_parse();
21164
+ var parse5 = require_parse();
21165
21165
  var constants2 = require_constants();
21166
21166
  var SemVer = require_semver();
21167
21167
  var truncate = (version2, truncation, options) => {
@@ -21173,7 +21173,7 @@ var require_truncate = __commonJS({
21173
21173
  };
21174
21174
  var cloneInputVersion = (version2, options) => {
21175
21175
  const versionStringToParse = version2 instanceof SemVer ? version2.version : version2;
21176
- return parse4(versionStringToParse, options);
21176
+ return parse5(versionStringToParse, options);
21177
21177
  };
21178
21178
  var doTruncation = (version2, truncation) => {
21179
21179
  if (isPrerelease(truncation)) {
@@ -22217,7 +22217,7 @@ var require_semver2 = __commonJS({
22217
22217
  var constants2 = require_constants();
22218
22218
  var SemVer = require_semver();
22219
22219
  var identifiers = require_identifiers();
22220
- var parse4 = require_parse();
22220
+ var parse5 = require_parse();
22221
22221
  var valid = require_valid();
22222
22222
  var clean = require_clean();
22223
22223
  var inc = require_inc();
@@ -22256,7 +22256,7 @@ var require_semver2 = __commonJS({
22256
22256
  var simplifyRange = require_simplify();
22257
22257
  var subset = require_subset();
22258
22258
  module.exports = {
22259
- parse: parse4,
22259
+ parse: parse5,
22260
22260
  valid,
22261
22261
  clean,
22262
22262
  inc,
@@ -22307,9 +22307,7 @@ var require_semver2 = __commonJS({
22307
22307
  });
22308
22308
 
22309
22309
  // ../argent-mcp/src/mcp-server.ts
22310
- import { appendFile, mkdir as mkdir5 } from "node:fs/promises";
22311
- import { dirname as dirname11 } from "node:path";
22312
- import { homedir as homedir5 } from "node:os";
22310
+ import { join as join19 } from "node:path";
22313
22311
  import { setTimeout as sleep } from "node:timers/promises";
22314
22312
 
22315
22313
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
@@ -22552,10 +22550,10 @@ function mergeDefs(...defs) {
22552
22550
  function cloneDef(schema) {
22553
22551
  return mergeDefs(schema._zod.def);
22554
22552
  }
22555
- function getElementAtPath(obj, path18) {
22556
- if (!path18)
22553
+ function getElementAtPath(obj, path19) {
22554
+ if (!path19)
22557
22555
  return obj;
22558
- return path18.reduce((acc, key) => acc?.[key], obj);
22556
+ return path19.reduce((acc, key) => acc?.[key], obj);
22559
22557
  }
22560
22558
  function promiseAllObject(promisesObj) {
22561
22559
  const keys = Object.keys(promisesObj);
@@ -22895,11 +22893,11 @@ function explicitlyAborted(x, startIndex = 0) {
22895
22893
  }
22896
22894
  return false;
22897
22895
  }
22898
- function prefixIssues(path18, issues) {
22896
+ function prefixIssues(path19, issues) {
22899
22897
  return issues.map((iss) => {
22900
22898
  var _a3;
22901
22899
  (_a3 = iss).path ?? (_a3.path = []);
22902
- iss.path.unshift(path18);
22900
+ iss.path.unshift(path19);
22903
22901
  return iss;
22904
22902
  });
22905
22903
  }
@@ -23357,16 +23355,16 @@ function flattenError(error2, mapper = (issue2) => issue2.message) {
23357
23355
  }
23358
23356
  function formatError(error2, mapper = (issue2) => issue2.message) {
23359
23357
  const fieldErrors = { _errors: [] };
23360
- const processError = (error3, path18 = []) => {
23358
+ const processError = (error3, path19 = []) => {
23361
23359
  for (const issue2 of error3.issues) {
23362
23360
  if (issue2.code === "invalid_union" && issue2.errors.length) {
23363
- issue2.errors.map((issues) => processError({ issues }, [...path18, ...issue2.path]));
23361
+ issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
23364
23362
  } else if (issue2.code === "invalid_key") {
23365
- processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
23363
+ processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
23366
23364
  } else if (issue2.code === "invalid_element") {
23367
- processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
23365
+ processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
23368
23366
  } else {
23369
- const fullpath = [...path18, ...issue2.path];
23367
+ const fullpath = [...path19, ...issue2.path];
23370
23368
  if (fullpath.length === 0) {
23371
23369
  fieldErrors._errors.push(mapper(issue2));
23372
23370
  } else {
@@ -23509,17 +23507,17 @@ var validateAsync = async (schema, value, _ctx) => {
23509
23507
  return result.issues.length === 0;
23510
23508
  };
23511
23509
  var _encode = (_Err) => {
23512
- const parse4 = _parse(_Err);
23510
+ const parse5 = _parse(_Err);
23513
23511
  const fn = (schema, value, _ctx, _params) => {
23514
23512
  const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
23515
- return parse4(schema, value, ctx, finalizeParams(fn, _params));
23513
+ return parse5(schema, value, ctx, finalizeParams(fn, _params));
23516
23514
  };
23517
23515
  return fn;
23518
23516
  };
23519
23517
  var _decode = (_Err) => {
23520
- const parse4 = _parse(_Err);
23518
+ const parse5 = _parse(_Err);
23521
23519
  const fn = (schema, value, _ctx, _params) => {
23522
- return parse4(schema, value, _ctx, finalizeParams(fn, _params));
23520
+ return parse5(schema, value, _ctx, finalizeParams(fn, _params));
23523
23521
  };
23524
23522
  return fn;
23525
23523
  };
@@ -24556,7 +24554,7 @@ function capSize(inst, size) {
24556
24554
  if (!caps.length)
24557
24555
  return;
24558
24556
  const cap = Math.min(...caps.map((c) => c[0]));
24559
- const parse4 = inst._zod.parse;
24557
+ const parse5 = inst._zod.parse;
24560
24558
  inst._zod.parse = (payload, ctx) => {
24561
24559
  const n = size(payload.value);
24562
24560
  if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
@@ -24570,7 +24568,7 @@ function capSize(inst, size) {
24570
24568
  }
24571
24569
  }
24572
24570
  }
24573
- return parse4(payload, ctx);
24571
+ return parse5(payload, ctx);
24574
24572
  };
24575
24573
  }
24576
24574
  var arraySize = (input) => Array.isArray(input) ? input.length : -1;
@@ -25666,7 +25664,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
25666
25664
  var NONE = 0;
25667
25665
  var ASSUMED = 1;
25668
25666
  var PROVEN = 2;
25669
- function isRecursive(inst, stack, resolve12) {
25667
+ function isRecursive(inst, stack, resolve13) {
25670
25668
  const cached2 = recursive.get(inst);
25671
25669
  if (cached2 !== void 0)
25672
25670
  return cached2 ? PROVEN : NONE;
@@ -25676,7 +25674,7 @@ function isRecursive(inst, stack, resolve12) {
25676
25674
  let result = NONE;
25677
25675
  const check = (child) => {
25678
25676
  if (result !== PROVEN && child?._zod) {
25679
- const answer = isRecursive(child, stack, resolve12);
25677
+ const answer = isRecursive(child, stack, resolve13);
25680
25678
  if (answer > result)
25681
25679
  result = answer;
25682
25680
  }
@@ -25687,7 +25685,7 @@ function isRecursive(inst, stack, resolve12) {
25687
25685
  const desc = Object.getOwnPropertyDescriptor(sh, key);
25688
25686
  if (spread && !desc.enumerable)
25689
25687
  continue;
25690
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve12) : NONE;
25688
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve13) : NONE;
25691
25689
  if (child > answer)
25692
25690
  answer = child;
25693
25691
  }
@@ -25751,7 +25749,7 @@ function isRecursive(inst, stack, resolve12) {
25751
25749
  break;
25752
25750
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
25753
25751
  case "lazy": {
25754
- const inner = def._cachedInner ?? (resolve12 ? inst._zod.innerType : void 0);
25752
+ const inner = def._cachedInner ?? (resolve13 ? inst._zod.innerType : void 0);
25755
25753
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
25756
25754
  break;
25757
25755
  }
@@ -30329,12 +30327,12 @@ var StdioServerTransport = class {
30329
30327
  this.onclose?.();
30330
30328
  }
30331
30329
  send(message) {
30332
- return new Promise((resolve12) => {
30330
+ return new Promise((resolve13) => {
30333
30331
  const json = serializeMessage(message);
30334
30332
  if (this._stdout.write(json)) {
30335
- resolve12();
30333
+ resolve13();
30336
30334
  } else {
30337
- this._stdout.once("drain", resolve12);
30335
+ this._stdout.once("drain", resolve13);
30338
30336
  }
30339
30337
  });
30340
30338
  }
@@ -30954,7 +30952,7 @@ var Protocol = class {
30954
30952
  return;
30955
30953
  }
30956
30954
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
30957
- await new Promise((resolve12) => setTimeout(resolve12, pollInterval));
30955
+ await new Promise((resolve13) => setTimeout(resolve13, pollInterval));
30958
30956
  options?.signal?.throwIfAborted();
30959
30957
  }
30960
30958
  } catch (error2) {
@@ -30971,7 +30969,7 @@ var Protocol = class {
30971
30969
  */
30972
30970
  request(request, resultSchema, options) {
30973
30971
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
30974
- return new Promise((resolve12, reject) => {
30972
+ return new Promise((resolve13, reject) => {
30975
30973
  const earlyReject = (error2) => {
30976
30974
  reject(error2);
30977
30975
  };
@@ -31049,7 +31047,7 @@ var Protocol = class {
31049
31047
  if (!parseResult.success) {
31050
31048
  reject(parseResult.error);
31051
31049
  } else {
31052
- resolve12(parseResult.data);
31050
+ resolve13(parseResult.data);
31053
31051
  }
31054
31052
  } catch (error2) {
31055
31053
  reject(error2);
@@ -31311,12 +31309,12 @@ var Protocol = class {
31311
31309
  }
31312
31310
  } catch {
31313
31311
  }
31314
- return new Promise((resolve12, reject) => {
31312
+ return new Promise((resolve13, reject) => {
31315
31313
  if (signal.aborted) {
31316
31314
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
31317
31315
  return;
31318
31316
  }
31319
- const timeoutId = setTimeout(resolve12, interval);
31317
+ const timeoutId = setTimeout(resolve13, interval);
31320
31318
  signal.addEventListener("abort", () => {
31321
31319
  clearTimeout(timeoutId);
31322
31320
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -32098,506 +32096,36 @@ var Server = class extends Protocol {
32098
32096
 
32099
32097
  // ../argent-tools-client/src/launcher.ts
32100
32098
  import * as net from "node:net";
32101
- import * as fs from "node:fs";
32102
- import * as path from "node:path";
32099
+ import * as fs6 from "node:fs";
32100
+ import * as path7 from "node:path";
32103
32101
  import * as readline from "node:readline";
32104
- import { homedir } from "node:os";
32105
32102
  import { spawn, execFileSync } from "node:child_process";
32106
32103
  import { createHash, randomBytes } from "node:crypto";
32107
32104
  import { mkdir, writeFile, readFile, readdir, unlink, rename, chmod } from "node:fs/promises";
32108
- var STATE_DIR = path.join(homedir(), ".argent");
32109
- var STATE_FILE = path.join(STATE_DIR, "tool-server.json");
32110
- var LOG_FILE = path.join(STATE_DIR, "tool-server.log");
32111
- var LOCK_FILE = path.join(STATE_DIR, "tool-server.lock");
32112
- var AUTH_TOKEN_BYTES = 32;
32113
- var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
32114
- var AUTOSPAWN_IDLE_TIMEOUT_MINUTES = 30;
32115
- var AUTOSPAWN_HOST = "127.0.0.1";
32116
- function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
32117
- const env = {
32118
- ...baseEnv,
32119
- ARGENT_PORT: String(port),
32120
- ARGENT_SIMULATOR_SERVER_DIR: paths.simulatorServerDir,
32121
- ARGENT_NATIVE_DEVTOOLS_DIR: paths.nativeDevtoolsDir
32122
- };
32123
- if (options.host !== void 0) env.ARGENT_HOST = options.host;
32124
- if (options.idleTimeoutMinutes !== void 0) {
32125
- env.ARGENT_IDLE_TIMEOUT_MINUTES = String(options.idleTimeoutMinutes);
32126
- }
32127
- env[AUTH_TOKEN_ENV] = options.token ?? "";
32128
- env.ARGENT_SERVER_MANAGED = options.managed ?? "autospawn";
32129
- if (paths.installKind) env.ARGENT_INSTALL_KIND = paths.installKind;
32130
- if (paths.installProjectRoot) env.ARGENT_PROJECT_ROOT = paths.installProjectRoot;
32131
- return env;
32132
- }
32133
- function generateToken() {
32134
- return randomBytes(AUTH_TOKEN_BYTES).toString("hex");
32135
- }
32136
- function findFreePort() {
32137
- return new Promise((resolve12, reject) => {
32138
- const srv = net.createServer();
32139
- srv.listen(0, "127.0.0.1", () => {
32140
- const addr = srv.address();
32141
- if (!addr || typeof addr !== "object") {
32142
- srv.close(() => reject(new Error("Could not bind to find free port")));
32143
- return;
32144
- }
32145
- const port = addr.port;
32146
- srv.close((err) => {
32147
- if (err) reject(err);
32148
- else resolve12(port);
32149
- });
32150
- });
32151
- srv.on("error", reject);
32152
- });
32153
- }
32154
- function isVersionNewer(a, b) {
32155
- const parse4 = (v) => {
32156
- const [core = "", ...preParts] = v.split("+")[0].split("-");
32157
- const nums = core.split(".").map((n) => Number.parseInt(n, 10));
32158
- if (nums.length === 0 || nums.some((n) => Number.isNaN(n))) return null;
32159
- return { nums, pre: preParts.length > 0 ? preParts.join("-").split(".") : [] };
32160
- };
32161
- const pa = parse4(a);
32162
- const pb = parse4(b);
32163
- if (!pa || !pb) return false;
32164
- for (let i = 0; i < 3; i++) {
32165
- const x = pa.nums[i] ?? 0;
32166
- const y = pb.nums[i] ?? 0;
32167
- if (x !== y) return x > y;
32168
- }
32169
- if (pa.pre.length === 0 && pb.pre.length === 0) return false;
32170
- if (pa.pre.length === 0) return true;
32171
- if (pb.pre.length === 0) return false;
32172
- for (let i = 0; i < Math.max(pa.pre.length, pb.pre.length); i++) {
32173
- const x = pa.pre[i];
32174
- const y = pb.pre[i];
32175
- if (x === void 0) return false;
32176
- if (y === void 0) return true;
32177
- if (x === y) continue;
32178
- const xn = /^\d+$/.test(x) ? Number.parseInt(x, 10) : null;
32179
- const yn = /^\d+$/.test(y) ? Number.parseInt(y, 10) : null;
32180
- if (xn !== null && yn !== null) return xn > yn;
32181
- if (xn !== null) return false;
32182
- if (yn !== null) return true;
32183
- return x > y;
32184
- }
32185
- return false;
32186
- }
32187
- function readBundlePackageVersion(bundlePath) {
32188
- try {
32189
- const pkg = JSON.parse(
32190
- fs.readFileSync(path.join(path.dirname(bundlePath), "..", "package.json"), "utf8")
32191
- );
32192
- return typeof pkg.version === "string" ? pkg.version : void 0;
32193
- } catch {
32194
- return void 0;
32195
- }
32196
- }
32197
- function isProcessAlive(pid) {
32198
- try {
32199
- process.kill(pid, 0);
32200
- return true;
32201
- } catch {
32202
- return false;
32203
- }
32204
- }
32205
- function healthCheckHost(host) {
32206
- if (host === "0.0.0.0" || host === "") return "127.0.0.1";
32207
- if (host === "::" || host === "::0") return "::1";
32208
- return host;
32209
- }
32210
- function formatUrl(host, port) {
32211
- const h = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
32212
- return `http://${h}:${port}`;
32213
- }
32214
- function authHeaders(token) {
32215
- return token ? { Authorization: `Bearer ${token}` } : {};
32216
- }
32217
- async function isToolsServerHealthy(port, host = "127.0.0.1", timeoutMs = 2e3, token) {
32218
- const controller = new AbortController();
32219
- const timer = setTimeout(() => controller.abort(), timeoutMs);
32220
- try {
32221
- const res = await fetch(`${formatUrl(healthCheckHost(host), port)}/tools`, {
32222
- signal: controller.signal,
32223
- headers: authHeaders(token)
32224
- });
32225
- await res.body?.cancel().catch(() => {
32226
- });
32227
- return res.ok;
32228
- } catch {
32229
- return false;
32230
- } finally {
32231
- clearTimeout(timer);
32232
- }
32233
- }
32234
- var SPAWN_READY_TIMEOUT_MS = 15e3;
32235
- function killSpawnedChild(child, pid) {
32236
- try {
32237
- process.kill(-pid, "SIGKILL");
32238
- } catch {
32239
- try {
32240
- child.kill("SIGKILL");
32241
- } catch {
32242
- }
32243
- }
32244
- }
32245
- function resolveToolsServerNode() {
32246
- const { bun, deno, electron } = process.versions;
32247
- return !(bun || deno || electron) && fs.existsSync(process.execPath) ? process.execPath : "node";
32248
- }
32249
- function spawnToolsServer(paths, port, options = {}) {
32250
- return new Promise((resolve12, reject) => {
32251
- let logFd;
32252
- try {
32253
- fs.mkdirSync(STATE_DIR, { recursive: true });
32254
- logFd = fs.openSync(LOG_FILE, "a");
32255
- } catch {
32256
- logFd = fs.openSync("/dev/null", "w");
32257
- }
32258
- const nodeBin = resolveToolsServerNode();
32259
- const child = spawn(nodeBin, [paths.bundlePath, "start"], {
32260
- detached: true,
32261
- stdio: ["ignore", "pipe", logFd],
32262
- env: buildToolsServerEnv(paths, port, process.env, options)
32263
- });
32264
- fs.closeSync(logFd);
32265
- child.unref();
32266
- const pid = child.pid;
32267
- if (!pid) {
32268
- child.once(
32269
- "error",
32270
- (err) => reject(
32271
- new Error(
32272
- 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}`
32273
- )
32274
- )
32275
- );
32276
- return;
32277
- }
32278
- let settled = false;
32279
- const settle2 = (fn) => {
32280
- if (settled) return;
32281
- settled = true;
32282
- fn();
32283
- };
32284
- const rejectAndKill = (err) => settle2(() => {
32285
- killSpawnedChild(child, pid);
32286
- reject(err);
32287
- });
32288
- const rl = readline.createInterface({ input: child.stdout });
32289
- rl.on("line", (line) => {
32290
- const match = line.match(/Tools server listening on http:\/\/.+:(\d+)/);
32291
- if (match) {
32292
- const actualPort = parseInt(match[1], 10);
32293
- rl.close();
32294
- child.stdout?.resume();
32295
- child.stdout?.unref?.();
32296
- settle2(() => resolve12({ port: actualPort, pid }));
32297
- }
32298
- });
32299
- child.on("error", (err) => {
32300
- rl.close();
32301
- rejectAndKill(err);
32302
- });
32303
- child.on("exit", (code) => {
32304
- rl.close();
32305
- settle2(() => reject(new Error(`tool-server exited with code ${code} before becoming ready`)));
32306
- });
32307
- const timer = setTimeout(() => {
32308
- rl.close();
32309
- rejectAndKill(new Error("Timed out waiting for tools server to become ready"));
32310
- }, options.readyTimeoutMs ?? SPAWN_READY_TIMEOUT_MS);
32311
- rl.on("close", () => clearTimeout(timer));
32312
- });
32313
- }
32314
- function stateFileForBundle(bundlePath) {
32315
- const key = createHash("sha256").update(bundlePath).digest("hex").slice(0, 12);
32316
- return path.join(STATE_DIR, `tool-server-${key}.json`);
32317
- }
32318
- async function readStateFile(file) {
32319
- try {
32320
- const raw2 = await readFile(file, "utf8");
32321
- return JSON.parse(raw2);
32322
- } catch {
32323
- return null;
32324
- }
32325
- }
32326
- async function readToolsServerState(bundlePath) {
32327
- if (bundlePath === void 0) return readStateFile(STATE_FILE);
32328
- const own2 = await readStateFile(stateFileForBundle(bundlePath));
32329
- if (own2) return own2;
32330
- const legacy = await readStateFile(STATE_FILE);
32331
- return legacy && legacy.bundlePath === bundlePath ? legacy : null;
32332
- }
32333
- async function writeToolsServerState(state) {
32334
- const target = stateFileForBundle(state.bundlePath);
32335
- await mkdir(STATE_DIR, { recursive: true });
32336
- const tmp = `${target}.${process.pid}.tmp`;
32337
- try {
32338
- await writeFile(tmp, JSON.stringify(state, null, 2) + "\n", {
32339
- encoding: "utf8",
32340
- mode: 384
32341
- });
32342
- await chmod(tmp, 384);
32343
- await rename(tmp, target);
32344
- } catch (err) {
32345
- await unlink(tmp).catch(() => {
32346
- });
32347
- throw err;
32348
- }
32349
- }
32350
- async function clearToolsServerState(bundlePath) {
32351
- const files = [STATE_FILE];
32352
- if (bundlePath !== void 0) {
32353
- files[0] = stateFileForBundle(bundlePath);
32354
- const legacy = await readStateFile(STATE_FILE);
32355
- if (legacy && legacy.bundlePath === bundlePath) files.push(STATE_FILE);
32356
- }
32357
- for (const file of files) {
32358
- try {
32359
- await unlink(file);
32360
- } catch {
32361
- }
32362
- }
32363
- }
32364
- var STATE_FILE_RE = /^tool-server(-[0-9a-f]{12})?\.json$/;
32365
- async function readAllToolsServerStates() {
32366
- let names;
32367
- try {
32368
- names = await readdir(STATE_DIR);
32369
- } catch {
32370
- return [];
32371
- }
32372
- const out = [];
32373
- for (const name of names) {
32374
- if (!STATE_FILE_RE.test(name)) continue;
32375
- const file = path.join(STATE_DIR, name);
32376
- const state = await readStateFile(file);
32377
- if (state) out.push({ file, state });
32378
- }
32379
- return out;
32380
- }
32381
- async function sweepDeadStateFiles() {
32382
- for (const { file } of await readAllToolsServerStates()) {
32383
- if (file === STATE_FILE) continue;
32384
- const fresh = await readStateFile(file);
32385
- if (!fresh) continue;
32386
- if (!isProcessAlive(fresh.pid)) {
32387
- await unlink(file).catch(() => {
32388
- });
32389
- continue;
32390
- }
32391
- if (fs.existsSync(fresh.bundlePath)) continue;
32392
- if (!couldBeOurToolServer(fresh.pid, fresh.bundlePath)) continue;
32393
- await unlink(file).catch(() => {
32394
- });
32395
- void terminatePid(fresh.pid, () => couldBeOurToolServer(fresh.pid, fresh.bundlePath));
32396
- }
32397
- }
32398
- var readState = readToolsServerState;
32399
- var writeState = writeToolsServerState;
32400
- var SIGTERM_GRACE_MS = 6e3;
32401
- var SIGKILL_GRACE_MS = 1e3;
32402
- var KILL_POLL_MS = 100;
32403
- async function waitForExit(pid, timeoutMs) {
32404
- const deadline = Date.now() + timeoutMs;
32405
- while (Date.now() < deadline) {
32406
- if (!isProcessAlive(pid)) return true;
32407
- await new Promise((r) => setTimeout(r, KILL_POLL_MS));
32408
- }
32409
- return !isProcessAlive(pid);
32410
- }
32411
- async function terminatePid(pid, stillOurs) {
32412
- if (!isProcessAlive(pid)) return;
32413
- if (stillOurs && !stillOurs()) return;
32414
- try {
32415
- process.kill(pid, "SIGTERM");
32416
- } catch {
32417
- return;
32418
- }
32419
- if (await waitForExit(pid, SIGTERM_GRACE_MS)) return;
32420
- if (stillOurs && !(isProcessAlive(pid) && stillOurs())) return;
32421
- try {
32422
- process.kill(pid, "SIGKILL");
32423
- } catch {
32424
- return;
32425
- }
32426
- await waitForExit(pid, SIGKILL_GRACE_MS);
32427
- }
32428
- var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs.existsSync(p)) ?? "ps";
32429
- var PS_WIDTH_FLAGS = ["-ww"];
32430
- var PS_LOCALE = process.platform === "darwin" ? "en_US.UTF-8" : "C.UTF-8";
32431
- function readProcessCommandLine(pid, flags = PS_WIDTH_FLAGS, env = { ...process.env, LC_ALL: PS_LOCALE }) {
32432
- return execFileSync(PS_BIN, [...flags, "-p", String(pid), "-o", "command="], {
32433
- env,
32434
- encoding: "utf8",
32435
- timeout: 2e3,
32436
- // A recycled pid can sit on a process with an argv past Node's 1 MiB exec
32437
- // default, where the overrun surfaces as ENOBUFS instead of a command line.
32438
- // Same ceiling as tool-server's vega-process ps probes.
32439
- maxBuffer: 16 * 1024 * 1024,
32440
- // Piping ps's stderr is what puts a rejected flag ("ps: invalid option --
32441
- // 'w'") into the thrown error's message.
32442
- stdio: ["ignore", "pipe", "pipe"]
32443
- }).trim();
32444
- }
32445
- function couldBeOurToolServer(pid, marker) {
32446
- if (!marker) return false;
32447
- if (process.platform === "win32") return true;
32448
- const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
32449
- const ours = new RegExp(`(?:^|[\\t\\n\\v\\f\\r ])${escaped} start(?:[\\t\\n\\v\\f\\r ]|$)`);
32450
- const nonAscii = [...marker].some((c) => c.charCodeAt(0) > 127);
32451
- let failure2;
32452
- for (const env of [void 0, process.env]) {
32453
- try {
32454
- if (ours.test(readProcessCommandLine(pid, PS_WIDTH_FLAGS, env))) return true;
32455
- failure2 = void 0;
32456
- if (!nonAscii) break;
32457
- } catch (err) {
32458
- failure2 = String(err);
32459
- if (err.code === "ETIMEDOUT") break;
32460
- }
32461
- }
32462
- if (failure2 !== void 0) {
32463
- process.stderr.write(
32464
- `[launcher] ps could not read pid ${pid}'s command line; leaving it alone: ${failure2}
32465
- `
32466
- );
32467
- }
32468
- return false;
32469
- }
32470
- var LOCK_WAIT_TIMEOUT_MS = 3e4;
32471
- var LOCK_STALE_MS = 45e3;
32472
- var LOCK_POLL_MS = 100;
32473
- function spawnLockIsStale() {
32474
- try {
32475
- const { pid, ts } = JSON.parse(fs.readFileSync(LOCK_FILE, "utf8"));
32476
- if (typeof pid === "number" && pid > 0 && !isProcessAlive(pid)) return true;
32477
- if (typeof ts === "number" && Date.now() - ts > LOCK_STALE_MS) return true;
32478
- return false;
32479
- } catch {
32480
- try {
32481
- return Date.now() - fs.statSync(LOCK_FILE).mtimeMs > LOCK_STALE_MS;
32482
- } catch {
32483
- return true;
32484
- }
32485
- }
32486
- }
32487
- async function acquireSpawnLock() {
32488
- try {
32489
- fs.mkdirSync(STATE_DIR, { recursive: true });
32490
- } catch {
32491
- return null;
32492
- }
32493
- const nonce = randomBytes(8).toString("hex");
32494
- const deadline = Date.now() + LOCK_WAIT_TIMEOUT_MS;
32495
- for (; ; ) {
32496
- try {
32497
- const fd = fs.openSync(LOCK_FILE, "wx");
32498
- try {
32499
- fs.writeSync(fd, JSON.stringify({ pid: process.pid, nonce, ts: Date.now() }));
32500
- } finally {
32501
- fs.closeSync(fd);
32502
- }
32503
- let released = false;
32504
- return {
32505
- release: () => {
32506
- if (released) return;
32507
- released = true;
32508
- try {
32509
- const cur = JSON.parse(fs.readFileSync(LOCK_FILE, "utf8"));
32510
- if (cur.pid === process.pid && cur.nonce === nonce) fs.unlinkSync(LOCK_FILE);
32511
- } catch {
32512
- }
32513
- }
32514
- };
32515
- } catch (err) {
32516
- if (err.code !== "EEXIST") return null;
32517
- if (spawnLockIsStale()) {
32518
- try {
32519
- fs.unlinkSync(LOCK_FILE);
32520
- } catch {
32521
- }
32522
- if (!fs.existsSync(LOCK_FILE)) continue;
32523
- }
32524
- if (Date.now() >= deadline) return null;
32525
- await new Promise((r) => setTimeout(r, LOCK_POLL_MS));
32526
- }
32527
- }
32105
+
32106
+ // ../configuration-core/src/flags.ts
32107
+ import * as fs from "node:fs";
32108
+ import * as path2 from "node:path";
32109
+
32110
+ // ../configuration-core/src/home.ts
32111
+ import * as os from "node:os";
32112
+ import * as path from "node:path";
32113
+ var ARGENT_HOME_DIR_ENV = "ARGENT_HOME_DIR";
32114
+ function nonEmpty(value) {
32115
+ if (value == void 0) return null;
32116
+ const trimmed = value.trim();
32117
+ return trimmed === "" ? null : value;
32528
32118
  }
32529
- async function reusableHandle(state, wantBundlePath, wantVersion) {
32530
- if (!state || !isProcessAlive(state.pid)) return null;
32531
- if (wantBundlePath !== void 0 && state.bundlePath !== wantBundlePath) return null;
32532
- if (wantBundlePath !== void 0 && state.version !== void 0) {
32533
- const diskVersion = readBundlePackageVersion(wantBundlePath);
32534
- if (diskVersion !== void 0) {
32535
- if (diskVersion !== state.version) return null;
32536
- } else if (wantVersion !== void 0 && state.version !== wantVersion && isVersionNewer(wantVersion, state.version)) {
32537
- return null;
32538
- }
32539
- }
32540
- const host = state.host ?? "127.0.0.1";
32541
- const healthy = await isToolsServerHealthy(state.port, host, 2e3, state.token);
32542
- if (!healthy) return null;
32543
- return { url: formatUrl(healthCheckHost(host), state.port), token: state.token ?? "" };
32119
+ function resolveHomeDir(options = {}) {
32120
+ if (options.homeDir) return options.homeDir;
32121
+ return process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
32544
32122
  }
32545
- async function ensureToolsServer(paths) {
32546
- const fast = await reusableHandle(
32547
- await readState(paths.bundlePath),
32548
- paths.bundlePath,
32549
- paths.version
32550
- );
32551
- if (fast) return fast;
32552
- const lock = await acquireSpawnLock();
32553
- try {
32554
- const state = await readState(paths.bundlePath);
32555
- const reuse = await reusableHandle(state, paths.bundlePath, paths.version);
32556
- if (reuse) return reuse;
32557
- if (state && state.managed === "autospawn" && state.bundlePath === paths.bundlePath && isProcessAlive(state.pid) && couldBeOurToolServer(state.pid, state.bundlePath)) {
32558
- await terminatePid(state.pid, () => couldBeOurToolServer(state.pid, state.bundlePath));
32559
- }
32560
- await clearToolsServerState(paths.bundlePath);
32561
- await sweepDeadStateFiles();
32562
- if (!fs.existsSync(paths.bundlePath)) {
32563
- throw new Error(
32564
- `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.`
32565
- );
32566
- }
32567
- const diskVersion = readBundlePackageVersion(paths.bundlePath) ?? paths.version;
32568
- const token = generateToken();
32569
- const port = await findFreePort();
32570
- const { port: actualPort, pid } = await spawnToolsServer(paths, port, {
32571
- token,
32572
- host: AUTOSPAWN_HOST,
32573
- idleTimeoutMinutes: AUTOSPAWN_IDLE_TIMEOUT_MINUTES
32574
- });
32575
- await writeState({
32576
- port: actualPort,
32577
- pid,
32578
- startedAt: (/* @__PURE__ */ new Date()).toISOString(),
32579
- bundlePath: paths.bundlePath,
32580
- version: diskVersion,
32581
- host: AUTOSPAWN_HOST,
32582
- token,
32583
- managed: "autospawn"
32584
- });
32585
- return { url: formatUrl(AUTOSPAWN_HOST, actualPort), token };
32586
- } finally {
32587
- lock?.release();
32588
- }
32123
+ function argentHomeDir(options = {}) {
32124
+ const override = options.homeDir ? null : nonEmpty(process.env[ARGENT_HOME_DIR_ENV]);
32125
+ return override ? path.resolve(override.trim()) : path.join(resolveHomeDir(options), ".argent");
32589
32126
  }
32590
32127
 
32591
- // ../argent-tools-client/src/tools-client.ts
32592
- var import_yaml2 = __toESM(require_dist2(), 1);
32593
- import { readFile as readFile5 } from "node:fs/promises";
32594
- import { maxHeaderSize } from "node:http";
32595
- import * as path12 from "node:path";
32596
-
32597
32128
  // ../configuration-core/src/flags.ts
32598
- import * as fs2 from "node:fs";
32599
- import * as path2 from "node:path";
32600
- import { homedir as homedir2 } from "node:os";
32601
32129
  var FLAG_REGISTRY = [
32602
32130
  {
32603
32131
  name: "disable-auto-screenshot",
@@ -32664,7 +32192,7 @@ function findProjectRoot(startDir) {
32664
32192
  let current = path2.resolve(startDir);
32665
32193
  while (true) {
32666
32194
  for (const marker of PROJECT_MARKERS) {
32667
- if (fs2.existsSync(path2.join(current, marker))) return current;
32195
+ if (fs.existsSync(path2.join(current, marker))) return current;
32668
32196
  }
32669
32197
  const parent = path2.dirname(current);
32670
32198
  if (parent === current) return null;
@@ -32675,9 +32203,8 @@ function resolveProjectRoot(startDir) {
32675
32203
  return findProjectRoot(startDir) ?? path2.resolve(startDir);
32676
32204
  }
32677
32205
  function getFlagsPath(scope, options = {}) {
32678
- const home = options.homeDir ?? homedir2();
32679
32206
  if (scope === "global") {
32680
- return path2.join(home, ".argent", "flags.json");
32207
+ return path2.join(argentHomeDir({ homeDir: options.homeDir }), "flags.json");
32681
32208
  }
32682
32209
  const cwd = options.cwd ?? process.cwd();
32683
32210
  return path2.join(resolveProjectRoot(cwd), ".argent", "flags.json");
@@ -32685,7 +32212,7 @@ function getFlagsPath(scope, options = {}) {
32685
32212
  function readFlagsFile(filePath) {
32686
32213
  let raw2;
32687
32214
  try {
32688
- raw2 = fs2.readFileSync(filePath, "utf8");
32215
+ raw2 = fs.readFileSync(filePath, "utf8");
32689
32216
  } catch {
32690
32217
  return {};
32691
32218
  }
@@ -32722,35 +32249,20 @@ function isFeatureEnabled(name, options = {}, registry2 = FLAG_REGISTRY) {
32722
32249
  }
32723
32250
 
32724
32251
  // ../configuration-core/src/paths.ts
32725
- import * as fs3 from "node:fs";
32726
- import * as os from "node:os";
32252
+ import * as fs2 from "node:fs";
32727
32253
  import * as path3 from "node:path";
32728
- function nonEmpty(value) {
32729
- if (value == void 0) return null;
32730
- const trimmed = value.trim();
32731
- return trimmed === "" ? null : value;
32732
- }
32733
- function resolveHomeDir(options = {}) {
32734
- if (options.homeDir) return options.homeDir;
32735
- return process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
32736
- }
32737
32254
  function isHomeDir(dir, options = {}) {
32738
32255
  return canonicalPath(dir) === canonicalPath(resolveHomeDir(options));
32739
32256
  }
32740
32257
  function canonicalPath(p) {
32741
32258
  try {
32742
- return fs3.realpathSync.native(p);
32259
+ return fs2.realpathSync.native(p);
32743
32260
  } catch {
32744
32261
  return path3.resolve(p);
32745
32262
  }
32746
32263
  }
32747
- function argentHomeDir() {
32748
- return path3.join(resolveHomeDir(), ".argent");
32749
- }
32750
32264
  function configDir(scope = "global", options = {}) {
32751
- if (scope === "global") {
32752
- return path3.join(resolveHomeDir(options), ".argent");
32753
- }
32265
+ if (scope === "global") return argentHomeDir(options);
32754
32266
  const cwd = options.cwd ?? process.cwd();
32755
32267
  return path3.join(resolveProjectRoot(cwd), ".argent");
32756
32268
  }
@@ -32760,11 +32272,11 @@ function configFilePath(scope = "global", options = {}) {
32760
32272
 
32761
32273
  // ../configuration-core/src/config.ts
32762
32274
  import * as crypto from "node:crypto";
32763
- import * as fs4 from "node:fs";
32275
+ import * as fs3 from "node:fs";
32764
32276
  import * as path4 from "node:path";
32765
32277
  function readConfigObject(scope = "global", options = {}) {
32766
32278
  try {
32767
- const raw2 = fs4.readFileSync(configFilePath(scope, options), "utf8");
32279
+ const raw2 = fs3.readFileSync(configFilePath(scope, options), "utf8");
32768
32280
  const json = JSON.parse(raw2);
32769
32281
  if (json && typeof json === "object" && !Array.isArray(json)) {
32770
32282
  return json;
@@ -32811,7 +32323,7 @@ function setAtPath(obj, dottedKey, value) {
32811
32323
  }
32812
32324
  cur[parts[parts.length - 1]] = value;
32813
32325
  }
32814
- var LOCK_STALE_MS2 = 1e4;
32326
+ var LOCK_STALE_MS = 1e4;
32815
32327
  var LOCK_MAX_WAIT_MS = 2e3;
32816
32328
  var LOCK_RETRY_MS = 25;
32817
32329
  function sleepSync(ms) {
@@ -32822,9 +32334,9 @@ function acquireConfigLock(finalPath) {
32822
32334
  const deadline = Date.now() + LOCK_MAX_WAIT_MS;
32823
32335
  for (; ; ) {
32824
32336
  try {
32825
- const fd = fs4.openSync(lockPath, "wx", 384);
32337
+ const fd = fs3.openSync(lockPath, "wx", 384);
32826
32338
  try {
32827
- fs4.writeSync(fd, `${process.pid}
32339
+ fs3.writeSync(fd, `${process.pid}
32828
32340
  `);
32829
32341
  } catch {
32830
32342
  }
@@ -32832,8 +32344,8 @@ function acquireConfigLock(finalPath) {
32832
32344
  } catch (err) {
32833
32345
  if (err.code !== "EEXIST") return null;
32834
32346
  try {
32835
- if (Date.now() - fs4.statSync(lockPath).mtimeMs > LOCK_STALE_MS2) {
32836
- fs4.unlinkSync(lockPath);
32347
+ if (Date.now() - fs3.statSync(lockPath).mtimeMs > LOCK_STALE_MS) {
32348
+ fs3.unlinkSync(lockPath);
32837
32349
  continue;
32838
32350
  }
32839
32351
  } catch {
@@ -32845,35 +32357,35 @@ function acquireConfigLock(finalPath) {
32845
32357
  }
32846
32358
  function releaseConfigLock(lock) {
32847
32359
  try {
32848
- fs4.closeSync(lock.fd);
32360
+ fs3.closeSync(lock.fd);
32849
32361
  } catch {
32850
32362
  }
32851
32363
  try {
32852
- fs4.unlinkSync(lock.lockPath);
32364
+ fs3.unlinkSync(lock.lockPath);
32853
32365
  } catch {
32854
32366
  }
32855
32367
  }
32856
32368
  function updateConfig(mutate, scope = "global", options = {}) {
32857
32369
  const dir = configDir(scope, options);
32858
- fs4.mkdirSync(dir, { recursive: true });
32370
+ fs3.mkdirSync(dir, { recursive: true });
32859
32371
  const finalPath = configFilePath(scope, options);
32860
32372
  const lock = acquireConfigLock(finalPath);
32861
32373
  try {
32862
32374
  const next = readConfigObject(scope, options);
32863
32375
  mutate(next);
32864
32376
  const tmpPath = path4.join(dir, `.config.tmp.${process.pid}.${crypto.randomUUID()}`);
32865
- const fd = fs4.openSync(tmpPath, "wx", 384);
32377
+ const fd = fs3.openSync(tmpPath, "wx", 384);
32866
32378
  try {
32867
- fs4.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
32868
- fs4.fsyncSync(fd);
32379
+ fs3.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
32380
+ fs3.fsyncSync(fd);
32869
32381
  } finally {
32870
- fs4.closeSync(fd);
32382
+ fs3.closeSync(fd);
32871
32383
  }
32872
32384
  try {
32873
- fs4.renameSync(tmpPath, finalPath);
32385
+ fs3.renameSync(tmpPath, finalPath);
32874
32386
  } catch (err) {
32875
32387
  try {
32876
- fs4.unlinkSync(tmpPath);
32388
+ fs3.unlinkSync(tmpPath);
32877
32389
  } catch {
32878
32390
  }
32879
32391
  throw err;
@@ -32906,8 +32418,8 @@ function setWhatsNewSeenVersion(version2, options = {}) {
32906
32418
  }
32907
32419
 
32908
32420
  // ../configuration-core/src/secrets.ts
32909
- var import_dotenv = __toESM(require_dist3(), 1);
32910
- import * as fs5 from "node:fs";
32421
+ var import_dotenv = __toESM(require_dist2(), 1);
32422
+ import * as fs4 from "node:fs";
32911
32423
  import * as path5 from "node:path";
32912
32424
  var SECRET_ENV_PREFIX = "ARGENT_SECRET_";
32913
32425
  var SECRETS_FILE_NAME = "secrets.env";
@@ -32937,18 +32449,33 @@ function fileSource(filePath, exposure) {
32937
32449
  names: [],
32938
32450
  values: /* @__PURE__ */ new Map()
32939
32451
  };
32940
- if (!fs5.statSync(filePath, { throwIfNoEntry: false })) return absent;
32452
+ if (!fs4.statSync(filePath, { throwIfNoEntry: false })) return absent;
32941
32453
  let content;
32942
32454
  try {
32943
- content = fs5.readFileSync(filePath, "utf8");
32455
+ content = fs4.readFileSync(filePath, "utf8");
32944
32456
  } catch {
32945
32457
  return absent;
32946
32458
  }
32459
+ return parsedFileSource(label, content, exposure);
32460
+ }
32461
+ function secretsFileSource(filePath) {
32462
+ const resolved = path5.resolve(filePath);
32463
+ let content;
32464
+ try {
32465
+ content = fs4.readFileSync(resolved, "utf8");
32466
+ } catch (err) {
32467
+ const code = err.code;
32468
+ const reason = code === "ENOENT" ? "no such file" : code === "EISDIR" ? "it is a directory" : code === "EACCES" ? "permission denied" : err instanceof Error ? err.message : String(err);
32469
+ throw new Error(`Cannot read the secrets file ${resolved}: ${reason}`, { cause: err });
32470
+ }
32471
+ return parsedFileSource(`${resolved} (--secrets-file)`, content, "prefixed");
32472
+ }
32473
+ function parsedFileSource(label, content, exposure) {
32947
32474
  const values = /* @__PURE__ */ new Map();
32948
32475
  let skippedUnprefixed = false;
32949
32476
  for (const [key, value] of Object.entries((0, import_dotenv.parse)(content))) {
32950
32477
  const prefixed = key.startsWith(SECRET_ENV_PREFIX);
32951
- if (exposure === "shared" && !prefixed) {
32478
+ if (exposure === "prefixed" && !prefixed) {
32952
32479
  skippedUnprefixed = true;
32953
32480
  continue;
32954
32481
  }
@@ -32965,7 +32492,13 @@ function fileSource(filePath, exposure) {
32965
32492
  };
32966
32493
  }
32967
32494
  function secretSources(options = {}) {
32968
- const sources = [envSource(options.env ?? process.env)];
32495
+ const sources = [];
32496
+ const seen = /* @__PURE__ */ new Set();
32497
+ if (options.secretsFile !== void 0) {
32498
+ sources.push(secretsFileSource(options.secretsFile));
32499
+ seen.add(path5.resolve(options.secretsFile));
32500
+ }
32501
+ sources.push(envSource(options.env ?? process.env));
32969
32502
  const home = resolveHomeDir(options);
32970
32503
  const found = findProjectRoot(options.cwd ?? process.cwd());
32971
32504
  const projectRoot = found && isHomeDir(found, options) ? home : found;
@@ -32976,14 +32509,13 @@ function secretSources(options = {}) {
32976
32509
  exposure: "dedicated"
32977
32510
  });
32978
32511
  for (const name of SHARED_ENV_FILES) {
32979
- filePaths.push({ path: path5.join(projectRoot, name), exposure: "shared" });
32512
+ filePaths.push({ path: path5.join(projectRoot, name), exposure: "prefixed" });
32980
32513
  }
32981
32514
  }
32982
32515
  filePaths.push({
32983
- path: path5.join(home, ".argent", SECRETS_FILE_NAME),
32516
+ path: path5.join(argentHomeDir(options), SECRETS_FILE_NAME),
32984
32517
  exposure: "dedicated"
32985
32518
  });
32986
- const seen = /* @__PURE__ */ new Set();
32987
32519
  for (const entry of filePaths) {
32988
32520
  const resolved = path5.resolve(entry.path);
32989
32521
  if (seen.has(resolved)) continue;
@@ -32995,6 +32527,15 @@ function secretSources(options = {}) {
32995
32527
  function encodeClientSecrets(values) {
32996
32528
  return Buffer.from(JSON.stringify(Object.fromEntries(values)), "utf8").toString("base64");
32997
32529
  }
32530
+ function summarizeSecretSources(sources) {
32531
+ return sources.map(({ values: _values, ...summary }) => ({
32532
+ ...summary,
32533
+ names: [...summary.names]
32534
+ }));
32535
+ }
32536
+ function encodeSecretSourceSummaries(sources) {
32537
+ return Buffer.from(JSON.stringify(sources), "utf8").toString("base64");
32538
+ }
32998
32539
  function lookupSecret(name, sources) {
32999
32540
  for (const source of sources) {
33000
32541
  const value = source.values.get(name);
@@ -33013,228 +32554,730 @@ function lookupPlaceholderSecret(rawName, sources) {
33013
32554
  const name = rawName.replace(REDUNDANT_PREFIX_RE, "");
33014
32555
  return { name, value: lookupSecret(name, sources) };
33015
32556
  }
33016
-
33017
- // ../configuration-core/src/merge.ts
33018
- function mergeRestrictive(local, global) {
33019
- if (local === void 0) return global;
33020
- if (global === void 0) return local;
33021
- if (typeof local === "boolean" && typeof global === "boolean") {
33022
- return local && global;
32557
+
32558
+ // ../configuration-core/src/merge.ts
32559
+ function mergeRestrictive(local, global) {
32560
+ if (local === void 0) return global;
32561
+ if (global === void 0) return local;
32562
+ if (typeof local === "boolean" && typeof global === "boolean") {
32563
+ return local && global;
32564
+ }
32565
+ if (typeof local === "number" && typeof global === "number") {
32566
+ return Math.min(local, global);
32567
+ }
32568
+ return local;
32569
+ }
32570
+ function toArray(value) {
32571
+ return Array.isArray(value) ? value : null;
32572
+ }
32573
+ function mergeUnion(local, global) {
32574
+ const l = toArray(local);
32575
+ const g = toArray(global);
32576
+ if (l === null && g === null) return local ?? global;
32577
+ const merged = [...g ?? [], ...l ?? []];
32578
+ return Array.from(new Set(merged));
32579
+ }
32580
+ function mergeIntersection(local, global) {
32581
+ const l = toArray(local);
32582
+ const g = toArray(global);
32583
+ if (l === null && g === null) return local ?? global;
32584
+ if (l === null) return global;
32585
+ if (g === null) return local;
32586
+ const globalSet = new Set(g);
32587
+ return l.filter((item) => globalSet.has(item));
32588
+ }
32589
+ function applyMergePolicy(policy, local, global) {
32590
+ if (typeof policy === "function") return policy({ local, global });
32591
+ switch (policy) {
32592
+ case "prioritize-local":
32593
+ return local ?? global;
32594
+ case "prioritize-global":
32595
+ return global ?? local;
32596
+ case "prioritize-restrictive":
32597
+ return mergeRestrictive(local, global);
32598
+ case "union":
32599
+ return mergeUnion(local, global);
32600
+ case "intersection":
32601
+ return mergeIntersection(local, global);
32602
+ default: {
32603
+ const _exhaustive = policy;
32604
+ return _exhaustive;
32605
+ }
32606
+ }
32607
+ }
32608
+
32609
+ // ../configuration-core/src/config-schema.ts
32610
+ import { isAbsolute } from "node:path";
32611
+ function asBoolean(raw2) {
32612
+ return typeof raw2 === "boolean" ? raw2 : void 0;
32613
+ }
32614
+ function asString(raw2) {
32615
+ if (typeof raw2 !== "string") return void 0;
32616
+ const trimmed = raw2.trim();
32617
+ return trimmed === "" ? void 0 : trimmed;
32618
+ }
32619
+ function asPositiveInteger(raw2) {
32620
+ return typeof raw2 === "number" && Number.isSafeInteger(raw2) && raw2 > 0 ? raw2 : void 0;
32621
+ }
32622
+ var MIN_SCRIPT_HEAP_LIMIT_MB = 32;
32623
+ var MIN_SCRIPT_TIMEOUT_MS = 100;
32624
+ function asStringArray(raw2) {
32625
+ if (!Array.isArray(raw2)) return void 0;
32626
+ const out = [];
32627
+ for (const item of raw2) {
32628
+ if (typeof item === "string" && item.trim() !== "") out.push(item.trim());
32629
+ }
32630
+ return out;
32631
+ }
32632
+ var CONFIG_SCHEMA = [
32633
+ {
32634
+ key: "telemetry.enabled",
32635
+ description: "Whether anonymous opt-out telemetry is enabled (on by default; environment opt-outs like DO_NOT_TRACK are not reflected here \u2014 `argent telemetry status` shows effective consent). `false` in either scope wins, so a committed project opt-out holds for every teammate.",
32636
+ scopes: ["project", "global"],
32637
+ parse: asBoolean,
32638
+ merge: "prioritize-restrictive",
32639
+ // Opt-out: consent.ts reads an unstored value as enabled, so the config
32640
+ // surface must show the same rather than "(unset)".
32641
+ default: true,
32642
+ // Opt-in/out goes through the dedicated command so the live client is
32643
+ // drained/reset, not just the file rewritten.
32644
+ manageCommand: "argent telemetry",
32645
+ // consent.ts keeps a ~/.argent opt-out under a moved home; show the same.
32646
+ userHomeOptOut: true
32647
+ },
32648
+ {
32649
+ key: "autoUpdate.enabled",
32650
+ description: "Automatically update the global Argent installation. Project-local installs require confirmation.",
32651
+ scopes: ["global"],
32652
+ parse: asBoolean,
32653
+ merge: "prioritize-local",
32654
+ default: true,
32655
+ // The global install is shared by every Argent home.
32656
+ userHomeOptOut: true,
32657
+ example: "false"
32658
+ },
32659
+ {
32660
+ key: "lens.agent",
32661
+ description: "Coding-agent id remembered by `argent lens` to skip the picker.",
32662
+ scopes: ["project", "global"],
32663
+ parse: asString,
32664
+ merge: "prioritize-local",
32665
+ example: "claude"
32666
+ },
32667
+ {
32668
+ key: "ios.additionalDeviceSets",
32669
+ description: "Additional CoreSimulator device-set directories whose simulators argent should see alongside the default set. Absolute paths (or ~/\u2026); relative entries resolve against the project root (project scope) or home (global scope).",
32670
+ scopes: ["project", "global"],
32671
+ parse: asStringArray,
32672
+ // Additive rather than shadowing: global baseline first, project extras
32673
+ // after, deduplicated. `getAdditionalIosDeviceSets` re-implements this union
32674
+ // (path resolution must precede dedup) and guards on the preset staying "union".
32675
+ merge: "union",
32676
+ example: '["~/DeviceSets/ci"]'
32677
+ },
32678
+ {
32679
+ key: "android.sdkRoot",
32680
+ description: "Android SDK root argent uses instead of `ANDROID_HOME`, for hosts whose SDK is not where the environment says (Nix, custom layouts). Absolute or `~/`-prefixed. Applies to the tool-server and to the simulator-server it starts. `adb` on PATH still wins, as it does with the environment variable.",
32681
+ scopes: ["project", "global"],
32682
+ parse: (raw2) => {
32683
+ const value = asString(raw2);
32684
+ return value !== void 0 && (value === "~" || value.startsWith("~/") || isAbsolute(value)) ? value : void 0;
32685
+ },
32686
+ expected: "an absolute path, or one starting with `~/`",
32687
+ merge: "prioritize-local",
32688
+ example: "~/Library/Android/sdk"
32689
+ },
32690
+ {
32691
+ key: "android.adbServerPort",
32692
+ description: "Port of the adb server argent uses, for hosts that run Android devices on a server other than the default 5037 (a device pool with its own server, for example). Applies when the tool-server starts, to the tool-server and every adb and simulator-server it runs. `ANDROID_ADB_SERVER_PORT` or `ADB_SERVER_SOCKET` in the tool-server's environment still wins, as it does for adb itself.",
32693
+ scopes: ["project", "global"],
32694
+ parse: (raw2) => {
32695
+ const value = asPositiveInteger(raw2);
32696
+ return value !== void 0 && value < 65536 ? value : void 0;
32697
+ },
32698
+ expected: "a TCP port, 1-65535",
32699
+ merge: "prioritize-local",
32700
+ example: "5038"
32701
+ },
32702
+ {
32703
+ key: "recordings.directory",
32704
+ description: "Directory where finished screen recordings (mp4) are saved on the client host. Absolute, `~`-prefixed, or relative to the project root (home dir when not in a project). Unset \u21D2 `.argent/recordings` under the project root.",
32705
+ scopes: ["project", "global"],
32706
+ parse: asString,
32707
+ // Resolved on the client (the machine the mp4 is persisted to), so with a
32708
+ // remote `argent link` tool-server it is the *client's* config that decides.
32709
+ merge: "prioritize-local",
32710
+ example: "~/Movies/argent"
32711
+ },
32712
+ // Global-scope only: a checked-in `.argent/config.json` must not raise the
32713
+ // ceiling on how much of the machine a script step may occupy. `merge` is
32714
+ // nominal here — the project scope of a global-only key is never read.
32715
+ {
32716
+ key: "scripts.maxTimeoutMs",
32717
+ description: `Upper bound, in milliseconds, on the time limit an e2e test \`script\` step may ask for (default 300000 \u2014 five minutes). Bounds how long one script can occupy the host. Values below ${MIN_SCRIPT_TIMEOUT_MS} ms are refused: the step starts a Node process before the script runs, so a smaller ceiling ends a script that did nothing wrong.`,
32718
+ scopes: ["global"],
32719
+ parse: (raw2) => {
32720
+ const value = asPositiveInteger(raw2);
32721
+ return value !== void 0 && value >= MIN_SCRIPT_TIMEOUT_MS ? value : void 0;
32722
+ },
32723
+ expected: `a whole number of milliseconds, at least ${MIN_SCRIPT_TIMEOUT_MS}`,
32724
+ merge: "prioritize-global",
32725
+ default: 5 * 6e4,
32726
+ example: "300000"
32727
+ },
32728
+ {
32729
+ key: "scripts.heapLimitMb",
32730
+ description: `Old-space heap limit, in MiB, given to each e2e test \`script\` process (default 512). Values below ${MIN_SCRIPT_HEAP_LIMIT_MB} MiB are refused: that is already below what importing a real npm dependency needs, and under about 5 MiB the process dies inside V8's own startup before any script runs.`,
32731
+ scopes: ["global"],
32732
+ parse: (raw2) => {
32733
+ const value = asPositiveInteger(raw2);
32734
+ return value !== void 0 && value >= MIN_SCRIPT_HEAP_LIMIT_MB ? value : void 0;
32735
+ },
32736
+ expected: `a whole number of MiB, at least ${MIN_SCRIPT_HEAP_LIMIT_MB}`,
32737
+ merge: "prioritize-global",
32738
+ default: 512,
32739
+ example: "512"
32740
+ }
32741
+ ];
32742
+ function getConfigDefinition(key, registry2 = CONFIG_SCHEMA) {
32743
+ return registry2.find((def) => def.key === key);
32744
+ }
32745
+
32746
+ // ../configuration-core/src/config-access.ts
32747
+ import * as fs5 from "node:fs";
32748
+ import * as path6 from "node:path";
32749
+ function readScopeValue(def, scope, options) {
32750
+ if (!def.scopes.includes(scope)) return void 0;
32751
+ const raw2 = getAtPath(readConfigObject(scope, options), def.key);
32752
+ return raw2 === void 0 ? void 0 : def.parse(raw2);
32753
+ }
32754
+ function getConfigValue(def, options = {}) {
32755
+ const local = readScopeValue(def, "project", options);
32756
+ const global = readScopeValue(def, "global", options);
32757
+ const merged = applyMergePolicy(def.merge, local, global) ?? def.default;
32758
+ if (!def.userHomeOptOut) return merged;
32759
+ const userHome = { homeDir: resolveHomeDir(options) };
32760
+ if (argentHomeDir(options) === argentHomeDir(userHome)) return merged;
32761
+ return readScopeValue(def, "global", userHome) === false ? false : merged;
32762
+ }
32763
+ function getConfigValueByKey(key, options = {}, registry2 = CONFIG_SCHEMA) {
32764
+ const def = requireDefinition(key, registry2);
32765
+ return getConfigValue(def, options);
32766
+ }
32767
+ function requireDefinition(key, registry2 = CONFIG_SCHEMA) {
32768
+ const def = getConfigDefinition(key, registry2);
32769
+ if (!def) {
32770
+ throw new UnknownConfigKeyError(key);
32771
+ }
32772
+ return def;
32773
+ }
32774
+ var UnknownConfigKeyError = class extends Error {
32775
+ constructor(key) {
32776
+ super(`Unknown configuration key "${key}".`);
32777
+ this.key = key;
32778
+ this.name = "UnknownConfigKeyError";
32779
+ }
32780
+ key;
32781
+ };
32782
+
32783
+ // ../argent-tools-client/src/launcher.ts
32784
+ var STATE_DIR = argentHomeDir();
32785
+ var STATE_FILE = path7.join(STATE_DIR, "tool-server.json");
32786
+ var LOG_FILE = path7.join(STATE_DIR, "tool-server.log");
32787
+ var LOCK_FILE = path7.join(STATE_DIR, "tool-server.lock");
32788
+ var AUTH_TOKEN_BYTES = 32;
32789
+ var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
32790
+ var AUTOSPAWN_IDLE_TIMEOUT_MINUTES = 30;
32791
+ var AUTOSPAWN_HOST = "127.0.0.1";
32792
+ function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
32793
+ const env = {
32794
+ ...baseEnv,
32795
+ ARGENT_PORT: String(port),
32796
+ ARGENT_SIMULATOR_SERVER_DIR: paths.simulatorServerDir,
32797
+ ARGENT_NATIVE_DEVTOOLS_DIR: paths.nativeDevtoolsDir
32798
+ };
32799
+ if (options.host !== void 0) env.ARGENT_HOST = options.host;
32800
+ if (options.idleTimeoutMinutes !== void 0) {
32801
+ env.ARGENT_IDLE_TIMEOUT_MINUTES = String(options.idleTimeoutMinutes);
32802
+ }
32803
+ env[AUTH_TOKEN_ENV] = options.token ?? "";
32804
+ env.ARGENT_SERVER_MANAGED = options.managed ?? "autospawn";
32805
+ if (paths.installKind) env.ARGENT_INSTALL_KIND = paths.installKind;
32806
+ if (paths.installProjectRoot) env.ARGENT_PROJECT_ROOT = paths.installProjectRoot;
32807
+ return env;
32808
+ }
32809
+ function generateToken() {
32810
+ return randomBytes(AUTH_TOKEN_BYTES).toString("hex");
32811
+ }
32812
+ function findFreePort() {
32813
+ return new Promise((resolve13, reject) => {
32814
+ const srv = net.createServer();
32815
+ srv.listen(0, "127.0.0.1", () => {
32816
+ const addr = srv.address();
32817
+ if (!addr || typeof addr !== "object") {
32818
+ srv.close(() => reject(new Error("Could not bind to find free port")));
32819
+ return;
32820
+ }
32821
+ const port = addr.port;
32822
+ srv.close((err) => {
32823
+ if (err) reject(err);
32824
+ else resolve13(port);
32825
+ });
32826
+ });
32827
+ srv.on("error", reject);
32828
+ });
32829
+ }
32830
+ function isVersionNewer(a, b) {
32831
+ const parse5 = (v) => {
32832
+ const [core = "", ...preParts] = v.split("+")[0].split("-");
32833
+ const nums = core.split(".").map((n) => Number.parseInt(n, 10));
32834
+ if (nums.length === 0 || nums.some((n) => Number.isNaN(n))) return null;
32835
+ return { nums, pre: preParts.length > 0 ? preParts.join("-").split(".") : [] };
32836
+ };
32837
+ const pa = parse5(a);
32838
+ const pb = parse5(b);
32839
+ if (!pa || !pb) return false;
32840
+ for (let i = 0; i < 3; i++) {
32841
+ const x = pa.nums[i] ?? 0;
32842
+ const y = pb.nums[i] ?? 0;
32843
+ if (x !== y) return x > y;
32844
+ }
32845
+ if (pa.pre.length === 0 && pb.pre.length === 0) return false;
32846
+ if (pa.pre.length === 0) return true;
32847
+ if (pb.pre.length === 0) return false;
32848
+ for (let i = 0; i < Math.max(pa.pre.length, pb.pre.length); i++) {
32849
+ const x = pa.pre[i];
32850
+ const y = pb.pre[i];
32851
+ if (x === void 0) return false;
32852
+ if (y === void 0) return true;
32853
+ if (x === y) continue;
32854
+ const xn = /^\d+$/.test(x) ? Number.parseInt(x, 10) : null;
32855
+ const yn = /^\d+$/.test(y) ? Number.parseInt(y, 10) : null;
32856
+ if (xn !== null && yn !== null) return xn > yn;
32857
+ if (xn !== null) return false;
32858
+ if (yn !== null) return true;
32859
+ return x > y;
32860
+ }
32861
+ return false;
32862
+ }
32863
+ function readBundlePackageVersion(bundlePath) {
32864
+ try {
32865
+ const pkg = JSON.parse(
32866
+ fs6.readFileSync(path7.join(path7.dirname(bundlePath), "..", "package.json"), "utf8")
32867
+ );
32868
+ return typeof pkg.version === "string" ? pkg.version : void 0;
32869
+ } catch {
32870
+ return void 0;
32871
+ }
32872
+ }
32873
+ function isProcessAlive(pid) {
32874
+ try {
32875
+ process.kill(pid, 0);
32876
+ return true;
32877
+ } catch {
32878
+ return false;
32879
+ }
32880
+ }
32881
+ function healthCheckHost(host) {
32882
+ if (host === "0.0.0.0" || host === "") return "127.0.0.1";
32883
+ if (host === "::" || host === "::0") return "::1";
32884
+ return host;
32885
+ }
32886
+ function formatUrl(host, port) {
32887
+ const h = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
32888
+ return `http://${h}:${port}`;
32889
+ }
32890
+ function authHeaders(token) {
32891
+ return token ? { Authorization: `Bearer ${token}` } : {};
32892
+ }
32893
+ async function isToolsServerHealthy(port, host = "127.0.0.1", timeoutMs = 2e3, token) {
32894
+ const controller = new AbortController();
32895
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
32896
+ try {
32897
+ const res = await fetch(`${formatUrl(healthCheckHost(host), port)}/tools`, {
32898
+ signal: controller.signal,
32899
+ headers: authHeaders(token)
32900
+ });
32901
+ await res.body?.cancel().catch(() => {
32902
+ });
32903
+ return res.ok;
32904
+ } catch {
32905
+ return false;
32906
+ } finally {
32907
+ clearTimeout(timer);
32908
+ }
32909
+ }
32910
+ var SPAWN_READY_TIMEOUT_MS = 15e3;
32911
+ function killSpawnedChild(child, pid) {
32912
+ try {
32913
+ process.kill(-pid, "SIGKILL");
32914
+ } catch {
32915
+ try {
32916
+ child.kill("SIGKILL");
32917
+ } catch {
32918
+ }
32919
+ }
32920
+ }
32921
+ function resolveToolsServerNode() {
32922
+ const { bun, deno, electron } = process.versions;
32923
+ return !(bun || deno || electron) && fs6.existsSync(process.execPath) ? process.execPath : "node";
32924
+ }
32925
+ function parseListeningPort(line) {
32926
+ const match = line.match(/Tools server listening on http:\/\/.+:(\d+)/);
32927
+ return match ? parseInt(match[1], 10) : null;
32928
+ }
32929
+ function spawnToolsServer(paths, port, options = {}) {
32930
+ return new Promise((resolve13, reject) => {
32931
+ let logFd;
32932
+ try {
32933
+ fs6.mkdirSync(STATE_DIR, { recursive: true });
32934
+ logFd = fs6.openSync(LOG_FILE, "a");
32935
+ } catch {
32936
+ logFd = fs6.openSync("/dev/null", "w");
32937
+ }
32938
+ const nodeBin = resolveToolsServerNode();
32939
+ const child = spawn(nodeBin, [paths.bundlePath, "start"], {
32940
+ detached: true,
32941
+ stdio: ["ignore", "pipe", logFd],
32942
+ env: buildToolsServerEnv(paths, port, process.env, options)
32943
+ });
32944
+ fs6.closeSync(logFd);
32945
+ const pid = child.pid;
32946
+ if (!pid) {
32947
+ child.once(
32948
+ "error",
32949
+ (err) => reject(
32950
+ new Error(
32951
+ 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}`
32952
+ )
32953
+ )
32954
+ );
32955
+ return;
32956
+ }
32957
+ let settled = false;
32958
+ const settle2 = (fn) => {
32959
+ if (settled) return;
32960
+ settled = true;
32961
+ fn();
32962
+ };
32963
+ const rejectAndKill = (err) => settle2(() => {
32964
+ killSpawnedChild(child, pid);
32965
+ reject(err);
32966
+ });
32967
+ const rl = readline.createInterface({ input: child.stdout });
32968
+ rl.on("line", (line) => {
32969
+ const actualPort = parseListeningPort(line);
32970
+ if (actualPort !== null) {
32971
+ rl.close();
32972
+ child.stdout?.resume();
32973
+ child.stdout?.unref?.();
32974
+ child.unref();
32975
+ settle2(() => resolve13({ port: actualPort, pid }));
32976
+ }
32977
+ });
32978
+ child.on("error", (err) => {
32979
+ rl.close();
32980
+ rejectAndKill(err);
32981
+ });
32982
+ child.on("exit", (code) => {
32983
+ rl.close();
32984
+ settle2(() => reject(new Error(`tool-server exited with code ${code} before becoming ready`)));
32985
+ });
32986
+ const timer = setTimeout(() => {
32987
+ rl.close();
32988
+ rejectAndKill(new Error("Timed out waiting for tools server to become ready"));
32989
+ }, options.readyTimeoutMs ?? SPAWN_READY_TIMEOUT_MS);
32990
+ rl.on("close", () => clearTimeout(timer));
32991
+ });
32992
+ }
32993
+ function stateFileForBundle(bundlePath) {
32994
+ const key = createHash("sha256").update(bundlePath).digest("hex").slice(0, 12);
32995
+ return path7.join(STATE_DIR, `tool-server-${key}.json`);
32996
+ }
32997
+ async function readStateFile(file) {
32998
+ try {
32999
+ const raw2 = await readFile(file, "utf8");
33000
+ return JSON.parse(raw2);
33001
+ } catch {
33002
+ return null;
33003
+ }
33004
+ }
33005
+ async function readToolsServerState(bundlePath) {
33006
+ if (bundlePath === void 0) return readStateFile(STATE_FILE);
33007
+ const own2 = await readStateFile(stateFileForBundle(bundlePath));
33008
+ if (own2) return own2;
33009
+ const legacy = await readStateFile(STATE_FILE);
33010
+ return legacy && legacy.bundlePath === bundlePath ? legacy : null;
33011
+ }
33012
+ async function writeToolsServerState(state) {
33013
+ const target = stateFileForBundle(state.bundlePath);
33014
+ await mkdir(STATE_DIR, { recursive: true });
33015
+ const tmp = `${target}.${process.pid}.tmp`;
33016
+ try {
33017
+ await writeFile(tmp, JSON.stringify(state, null, 2) + "\n", {
33018
+ encoding: "utf8",
33019
+ mode: 384
33020
+ });
33021
+ await chmod(tmp, 384);
33022
+ await rename(tmp, target);
33023
+ } catch (err) {
33024
+ await unlink(tmp).catch(() => {
33025
+ });
33026
+ throw err;
33027
+ }
33028
+ }
33029
+ async function clearToolsServerState(bundlePath) {
33030
+ const files = [STATE_FILE];
33031
+ if (bundlePath !== void 0) {
33032
+ files[0] = stateFileForBundle(bundlePath);
33033
+ const legacy = await readStateFile(STATE_FILE);
33034
+ if (legacy && legacy.bundlePath === bundlePath) files.push(STATE_FILE);
33023
33035
  }
33024
- if (typeof local === "number" && typeof global === "number") {
33025
- return Math.min(local, global);
33036
+ for (const file of files) {
33037
+ try {
33038
+ await unlink(file);
33039
+ } catch {
33040
+ }
33026
33041
  }
33027
- return local;
33028
- }
33029
- function toArray(value) {
33030
- return Array.isArray(value) ? value : null;
33031
33042
  }
33032
- function mergeUnion(local, global) {
33033
- const l = toArray(local);
33034
- const g = toArray(global);
33035
- if (l === null && g === null) return local ?? global;
33036
- const merged = [...g ?? [], ...l ?? []];
33037
- return Array.from(new Set(merged));
33038
- }
33039
- function mergeIntersection(local, global) {
33040
- const l = toArray(local);
33041
- const g = toArray(global);
33042
- if (l === null && g === null) return local ?? global;
33043
- if (l === null) return global;
33044
- if (g === null) return local;
33045
- const globalSet = new Set(g);
33046
- return l.filter((item) => globalSet.has(item));
33043
+ var STATE_FILE_RE = /^tool-server(-[0-9a-f]{12})?\.json$/;
33044
+ async function readAllToolsServerStates() {
33045
+ let names;
33046
+ try {
33047
+ names = await readdir(STATE_DIR);
33048
+ } catch {
33049
+ return [];
33050
+ }
33051
+ const out = [];
33052
+ for (const name of names) {
33053
+ if (!STATE_FILE_RE.test(name)) continue;
33054
+ const file = path7.join(STATE_DIR, name);
33055
+ const state = await readStateFile(file);
33056
+ if (state) out.push({ file, state });
33057
+ }
33058
+ return out;
33047
33059
  }
33048
- function applyMergePolicy(policy, local, global) {
33049
- if (typeof policy === "function") return policy({ local, global });
33050
- switch (policy) {
33051
- case "prioritize-local":
33052
- return local ?? global;
33053
- case "prioritize-global":
33054
- return global ?? local;
33055
- case "prioritize-restrictive":
33056
- return mergeRestrictive(local, global);
33057
- case "union":
33058
- return mergeUnion(local, global);
33059
- case "intersection":
33060
- return mergeIntersection(local, global);
33061
- default: {
33062
- const _exhaustive = policy;
33063
- return _exhaustive;
33060
+ async function sweepDeadStateFiles() {
33061
+ for (const { file } of await readAllToolsServerStates()) {
33062
+ if (file === STATE_FILE) continue;
33063
+ const fresh = await readStateFile(file);
33064
+ if (!fresh) continue;
33065
+ if (!isProcessAlive(fresh.pid)) {
33066
+ await unlink(file).catch(() => {
33067
+ });
33068
+ continue;
33064
33069
  }
33070
+ if (fs6.existsSync(fresh.bundlePath)) continue;
33071
+ if (!couldBeOurToolServer(fresh.pid, fresh.bundlePath)) continue;
33072
+ await unlink(file).catch(() => {
33073
+ });
33074
+ void terminatePid(fresh.pid, () => couldBeOurToolServer(fresh.pid, fresh.bundlePath));
33065
33075
  }
33066
33076
  }
33067
-
33068
- // ../configuration-core/src/config-schema.ts
33069
- import { isAbsolute as isAbsolute2 } from "node:path";
33070
- function asBoolean(raw2) {
33071
- return typeof raw2 === "boolean" ? raw2 : void 0;
33077
+ var readState = readToolsServerState;
33078
+ var writeState = writeToolsServerState;
33079
+ var SIGTERM_GRACE_MS = 6e3;
33080
+ var SIGKILL_GRACE_MS = 1e3;
33081
+ var KILL_POLL_MS = 100;
33082
+ async function waitForExit(pid, timeoutMs) {
33083
+ const deadline = Date.now() + timeoutMs;
33084
+ while (Date.now() < deadline) {
33085
+ if (!isProcessAlive(pid)) return true;
33086
+ await new Promise((r) => setTimeout(r, KILL_POLL_MS));
33087
+ }
33088
+ return !isProcessAlive(pid);
33072
33089
  }
33073
- function asString(raw2) {
33074
- if (typeof raw2 !== "string") return void 0;
33075
- const trimmed = raw2.trim();
33076
- return trimmed === "" ? void 0 : trimmed;
33090
+ async function terminatePid(pid, stillOurs) {
33091
+ if (!isProcessAlive(pid)) return;
33092
+ if (stillOurs && !stillOurs()) return;
33093
+ try {
33094
+ process.kill(pid, "SIGTERM");
33095
+ } catch {
33096
+ return;
33097
+ }
33098
+ if (await waitForExit(pid, SIGTERM_GRACE_MS)) return;
33099
+ if (stillOurs && !(isProcessAlive(pid) && stillOurs())) return;
33100
+ try {
33101
+ process.kill(pid, "SIGKILL");
33102
+ } catch {
33103
+ return;
33104
+ }
33105
+ await waitForExit(pid, SIGKILL_GRACE_MS);
33077
33106
  }
33078
- function asPositiveInteger(raw2) {
33079
- return typeof raw2 === "number" && Number.isSafeInteger(raw2) && raw2 > 0 ? raw2 : void 0;
33107
+ var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs6.existsSync(p)) ?? "ps";
33108
+ var PS_WIDTH_FLAGS = ["-ww"];
33109
+ var PS_LOCALE = process.platform === "darwin" ? "en_US.UTF-8" : "C.UTF-8";
33110
+ function readProcessCommandLine(pid, flags = PS_WIDTH_FLAGS, env = { ...process.env, LC_ALL: PS_LOCALE }) {
33111
+ return execFileSync(PS_BIN, [...flags, "-p", String(pid), "-o", "command="], {
33112
+ env,
33113
+ encoding: "utf8",
33114
+ timeout: 2e3,
33115
+ // A recycled pid can sit on a process with an argv past Node's 1 MiB exec
33116
+ // default, where the overrun surfaces as ENOBUFS instead of a command line.
33117
+ // Same ceiling as tool-server's vega-process ps probes.
33118
+ maxBuffer: 16 * 1024 * 1024,
33119
+ // Piping ps's stderr is what puts a rejected flag ("ps: invalid option --
33120
+ // 'w'") into the thrown error's message.
33121
+ stdio: ["ignore", "pipe", "pipe"]
33122
+ }).trim();
33080
33123
  }
33081
- var MIN_SCRIPT_HEAP_LIMIT_MB = 32;
33082
- var MIN_SCRIPT_TIMEOUT_MS = 100;
33083
- function asStringArray(raw2) {
33084
- if (!Array.isArray(raw2)) return void 0;
33085
- const out = [];
33086
- for (const item of raw2) {
33087
- if (typeof item === "string" && item.trim() !== "") out.push(item.trim());
33124
+ function couldBeOurToolServer(pid, marker) {
33125
+ if (!marker) return false;
33126
+ if (process.platform === "win32") return true;
33127
+ const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
33128
+ const ours = new RegExp(`(?:^|[\\t\\n\\v\\f\\r ])${escaped} start(?:[\\t\\n\\v\\f\\r ]|$)`);
33129
+ const nonAscii = [...marker].some((c) => c.charCodeAt(0) > 127);
33130
+ let failure2;
33131
+ for (const env of [void 0, process.env]) {
33132
+ try {
33133
+ if (ours.test(readProcessCommandLine(pid, PS_WIDTH_FLAGS, env))) return true;
33134
+ failure2 = void 0;
33135
+ if (!nonAscii) break;
33136
+ } catch (err) {
33137
+ failure2 = String(err);
33138
+ if (err.code === "ETIMEDOUT") break;
33139
+ }
33088
33140
  }
33089
- return out;
33090
- }
33091
- var CONFIG_SCHEMA = [
33092
- {
33093
- key: "telemetry.enabled",
33094
- description: "Whether anonymous opt-out telemetry is enabled (on by default; environment opt-outs like DO_NOT_TRACK are not reflected here \u2014 `argent telemetry status` shows effective consent). `false` in either scope wins, so a committed project opt-out holds for every teammate.",
33095
- scopes: ["project", "global"],
33096
- parse: asBoolean,
33097
- merge: "prioritize-restrictive",
33098
- // Opt-out: consent.ts reads an unstored value as enabled, so the config
33099
- // surface must show the same rather than "(unset)".
33100
- default: true,
33101
- // Opt-in/out goes through the dedicated command so the live client is
33102
- // drained/reset, not just the file rewritten.
33103
- manageCommand: "argent telemetry"
33104
- },
33105
- {
33106
- key: "autoUpdate.enabled",
33107
- description: "Automatically update the global Argent installation. Project-local installs require confirmation.",
33108
- scopes: ["global"],
33109
- parse: asBoolean,
33110
- merge: "prioritize-local",
33111
- default: true,
33112
- example: "false"
33113
- },
33114
- {
33115
- key: "lens.agent",
33116
- description: "Coding-agent id remembered by `argent lens` to skip the picker.",
33117
- scopes: ["project", "global"],
33118
- parse: asString,
33119
- merge: "prioritize-local",
33120
- example: "claude"
33121
- },
33122
- {
33123
- key: "ios.additionalDeviceSets",
33124
- description: "Additional CoreSimulator device-set directories whose simulators argent should see alongside the default set. Absolute paths (or ~/\u2026); relative entries resolve against the project root (project scope) or home (global scope).",
33125
- scopes: ["project", "global"],
33126
- parse: asStringArray,
33127
- // Additive rather than shadowing: global baseline first, project extras
33128
- // after, deduplicated. `getAdditionalIosDeviceSets` re-implements this union
33129
- // (path resolution must precede dedup) and guards on the preset staying "union".
33130
- merge: "union",
33131
- example: '["~/DeviceSets/ci"]'
33132
- },
33133
- {
33134
- key: "android.sdkRoot",
33135
- description: "Android SDK root argent uses instead of `ANDROID_HOME`, for hosts whose SDK is not where the environment says (Nix, custom layouts). Absolute or `~/`-prefixed. Applies to the tool-server and to the simulator-server it starts. `adb` on PATH still wins, as it does with the environment variable.",
33136
- scopes: ["project", "global"],
33137
- parse: (raw2) => {
33138
- const value = asString(raw2);
33139
- return value !== void 0 && (value === "~" || value.startsWith("~/") || isAbsolute2(value)) ? value : void 0;
33140
- },
33141
- expected: "an absolute path, or one starting with `~/`",
33142
- merge: "prioritize-local",
33143
- example: "~/Library/Android/sdk"
33144
- },
33145
- {
33146
- key: "android.adbServerPort",
33147
- description: "Port of the adb server argent uses, for hosts that run Android devices on a server other than the default 5037 (a device pool with its own server, for example). Applies when the tool-server starts, to the tool-server and every adb and simulator-server it runs. `ANDROID_ADB_SERVER_PORT` or `ADB_SERVER_SOCKET` in the tool-server's environment still wins, as it does for adb itself.",
33148
- scopes: ["project", "global"],
33149
- parse: (raw2) => {
33150
- const value = asPositiveInteger(raw2);
33151
- return value !== void 0 && value < 65536 ? value : void 0;
33152
- },
33153
- expected: "a TCP port, 1-65535",
33154
- merge: "prioritize-local",
33155
- example: "5038"
33156
- },
33157
- {
33158
- key: "recordings.directory",
33159
- description: "Directory where finished screen recordings (mp4) are saved on the client host. Absolute, `~`-prefixed, or relative to the project root (home dir when not in a project). Unset \u21D2 `.argent/recordings` under the project root.",
33160
- scopes: ["project", "global"],
33161
- parse: asString,
33162
- // Resolved on the client (the machine the mp4 is persisted to), so with a
33163
- // remote `argent link` tool-server it is the *client's* config that decides.
33164
- merge: "prioritize-local",
33165
- example: "~/Movies/argent"
33166
- },
33167
- // Global-scope only: a checked-in `.argent/config.json` must not raise the
33168
- // ceiling on how much of the machine a script step may occupy. `merge` is
33169
- // nominal here — the project scope of a global-only key is never read.
33170
- {
33171
- key: "scripts.maxTimeoutMs",
33172
- description: `Upper bound, in milliseconds, on the time limit an e2e test \`script\` step may ask for (default 300000 \u2014 five minutes). Bounds how long one script can occupy the host. Values below ${MIN_SCRIPT_TIMEOUT_MS} ms are refused: the step starts a Node process before the script runs, so a smaller ceiling ends a script that did nothing wrong.`,
33173
- scopes: ["global"],
33174
- parse: (raw2) => {
33175
- const value = asPositiveInteger(raw2);
33176
- return value !== void 0 && value >= MIN_SCRIPT_TIMEOUT_MS ? value : void 0;
33177
- },
33178
- expected: `a whole number of milliseconds, at least ${MIN_SCRIPT_TIMEOUT_MS}`,
33179
- merge: "prioritize-global",
33180
- default: 5 * 6e4,
33181
- example: "300000"
33182
- },
33183
- {
33184
- key: "scripts.heapLimitMb",
33185
- description: `Old-space heap limit, in MiB, given to each e2e test \`script\` process (default 512). Values below ${MIN_SCRIPT_HEAP_LIMIT_MB} MiB are refused: that is already below what importing a real npm dependency needs, and under about 5 MiB the process dies inside V8's own startup before any script runs.`,
33186
- scopes: ["global"],
33187
- parse: (raw2) => {
33188
- const value = asPositiveInteger(raw2);
33189
- return value !== void 0 && value >= MIN_SCRIPT_HEAP_LIMIT_MB ? value : void 0;
33190
- },
33191
- expected: `a whole number of MiB, at least ${MIN_SCRIPT_HEAP_LIMIT_MB}`,
33192
- merge: "prioritize-global",
33193
- default: 512,
33194
- example: "512"
33141
+ if (failure2 !== void 0) {
33142
+ process.stderr.write(
33143
+ `[launcher] ps could not read pid ${pid}'s command line; leaving it alone: ${failure2}
33144
+ `
33145
+ );
33195
33146
  }
33196
- ];
33197
- function getConfigDefinition(key, registry2 = CONFIG_SCHEMA) {
33198
- return registry2.find((def) => def.key === key);
33199
- }
33200
-
33201
- // ../configuration-core/src/config-access.ts
33202
- import * as path6 from "node:path";
33203
- function readScopeValue(def, scope, options) {
33204
- if (!def.scopes.includes(scope)) return void 0;
33205
- const raw2 = getAtPath(readConfigObject(scope, options), def.key);
33206
- return raw2 === void 0 ? void 0 : def.parse(raw2);
33147
+ return false;
33207
33148
  }
33208
- function getConfigValue(def, options = {}) {
33209
- const local = readScopeValue(def, "project", options);
33210
- const global = readScopeValue(def, "global", options);
33211
- const merged = applyMergePolicy(def.merge, local, global);
33212
- return merged ?? def.default;
33149
+ var LOCK_WAIT_TIMEOUT_MS = 3e4;
33150
+ var LOCK_STALE_MS2 = 45e3;
33151
+ var LOCK_POLL_MS = 100;
33152
+ function spawnLockIsStale() {
33153
+ try {
33154
+ const { pid, ts } = JSON.parse(fs6.readFileSync(LOCK_FILE, "utf8"));
33155
+ if (typeof pid === "number" && pid > 0 && !isProcessAlive(pid)) return true;
33156
+ if (typeof ts === "number" && Date.now() - ts > LOCK_STALE_MS2) return true;
33157
+ return false;
33158
+ } catch {
33159
+ try {
33160
+ return Date.now() - fs6.statSync(LOCK_FILE).mtimeMs > LOCK_STALE_MS2;
33161
+ } catch {
33162
+ return true;
33163
+ }
33164
+ }
33213
33165
  }
33214
- function getConfigValueByKey(key, options = {}, registry2 = CONFIG_SCHEMA) {
33215
- const def = requireDefinition(key, registry2);
33216
- return getConfigValue(def, options);
33166
+ async function acquireSpawnLock() {
33167
+ try {
33168
+ fs6.mkdirSync(STATE_DIR, { recursive: true });
33169
+ } catch {
33170
+ return null;
33171
+ }
33172
+ const nonce = randomBytes(8).toString("hex");
33173
+ const deadline = Date.now() + LOCK_WAIT_TIMEOUT_MS;
33174
+ for (; ; ) {
33175
+ try {
33176
+ const fd = fs6.openSync(LOCK_FILE, "wx");
33177
+ try {
33178
+ fs6.writeSync(fd, JSON.stringify({ pid: process.pid, nonce, ts: Date.now() }));
33179
+ } finally {
33180
+ fs6.closeSync(fd);
33181
+ }
33182
+ let released = false;
33183
+ return {
33184
+ release: () => {
33185
+ if (released) return;
33186
+ released = true;
33187
+ try {
33188
+ const cur = JSON.parse(fs6.readFileSync(LOCK_FILE, "utf8"));
33189
+ if (cur.pid === process.pid && cur.nonce === nonce) fs6.unlinkSync(LOCK_FILE);
33190
+ } catch {
33191
+ }
33192
+ }
33193
+ };
33194
+ } catch (err) {
33195
+ if (err.code !== "EEXIST") return null;
33196
+ if (spawnLockIsStale()) {
33197
+ try {
33198
+ fs6.unlinkSync(LOCK_FILE);
33199
+ } catch {
33200
+ }
33201
+ if (!fs6.existsSync(LOCK_FILE)) continue;
33202
+ }
33203
+ if (Date.now() >= deadline) return null;
33204
+ await new Promise((r) => setTimeout(r, LOCK_POLL_MS));
33205
+ }
33206
+ }
33217
33207
  }
33218
- function requireDefinition(key, registry2 = CONFIG_SCHEMA) {
33219
- const def = getConfigDefinition(key, registry2);
33220
- if (!def) {
33221
- throw new UnknownConfigKeyError(key);
33208
+ async function reusableHandle(state, wantBundlePath, wantVersion) {
33209
+ if (!state || !isProcessAlive(state.pid)) return null;
33210
+ if (wantBundlePath !== void 0 && state.bundlePath !== wantBundlePath) return null;
33211
+ if (wantBundlePath !== void 0 && state.version !== void 0) {
33212
+ const diskVersion = readBundlePackageVersion(wantBundlePath);
33213
+ if (diskVersion !== void 0) {
33214
+ if (diskVersion !== state.version) return null;
33215
+ } else if (wantVersion !== void 0 && state.version !== wantVersion && isVersionNewer(wantVersion, state.version)) {
33216
+ return null;
33217
+ }
33222
33218
  }
33223
- return def;
33219
+ const host = state.host ?? "127.0.0.1";
33220
+ const healthy = await isToolsServerHealthy(state.port, host, 2e3, state.token);
33221
+ if (!healthy) return null;
33222
+ return { url: formatUrl(healthCheckHost(host), state.port), token: state.token ?? "" };
33224
33223
  }
33225
- var UnknownConfigKeyError = class extends Error {
33226
- constructor(key) {
33227
- super(`Unknown configuration key "${key}".`);
33228
- this.key = key;
33229
- this.name = "UnknownConfigKeyError";
33224
+ async function ensureToolsServer(paths) {
33225
+ const fast = await reusableHandle(
33226
+ await readState(paths.bundlePath),
33227
+ paths.bundlePath,
33228
+ paths.version
33229
+ );
33230
+ if (fast) return fast;
33231
+ const lock = await acquireSpawnLock();
33232
+ try {
33233
+ const state = await readState(paths.bundlePath);
33234
+ const reuse = await reusableHandle(state, paths.bundlePath, paths.version);
33235
+ if (reuse) return reuse;
33236
+ if (state && state.managed === "autospawn" && state.bundlePath === paths.bundlePath && isProcessAlive(state.pid) && couldBeOurToolServer(state.pid, state.bundlePath)) {
33237
+ await terminatePid(state.pid, () => couldBeOurToolServer(state.pid, state.bundlePath));
33238
+ }
33239
+ await clearToolsServerState(paths.bundlePath);
33240
+ await sweepDeadStateFiles();
33241
+ if (!fs6.existsSync(paths.bundlePath)) {
33242
+ throw new Error(
33243
+ `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.`
33244
+ );
33245
+ }
33246
+ const diskVersion = readBundlePackageVersion(paths.bundlePath) ?? paths.version;
33247
+ const token = generateToken();
33248
+ const port = await findFreePort();
33249
+ const { port: actualPort, pid } = await spawnToolsServer(paths, port, {
33250
+ token,
33251
+ host: AUTOSPAWN_HOST,
33252
+ idleTimeoutMinutes: AUTOSPAWN_IDLE_TIMEOUT_MINUTES
33253
+ });
33254
+ await writeState({
33255
+ port: actualPort,
33256
+ pid,
33257
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
33258
+ bundlePath: paths.bundlePath,
33259
+ version: diskVersion,
33260
+ host: AUTOSPAWN_HOST,
33261
+ token,
33262
+ managed: "autospawn"
33263
+ });
33264
+ return { url: formatUrl(AUTOSPAWN_HOST, actualPort), token };
33265
+ } finally {
33266
+ lock?.release();
33230
33267
  }
33231
- key;
33232
- };
33268
+ }
33269
+
33270
+ // ../argent-tools-client/src/tools-client.ts
33271
+ var import_yaml2 = __toESM(require_dist3(), 1);
33272
+ import { readFile as readFile5 } from "node:fs/promises";
33273
+ import { maxHeaderSize } from "node:http";
33274
+ import * as path13 from "node:path";
33233
33275
 
33234
33276
  // ../registry/src/types.ts
33235
33277
  var LINKED_CALL_HEADER = "x-argent-linked";
33236
33278
  var E2E_DIR_CLIENT_HEADER = "x-argent-e2e-dir";
33237
33279
  var CLIENT_SECRETS_HEADER = "x-argent-client-secrets";
33280
+ var CLIENT_SECRET_SOURCES_HEADER = "x-argent-client-secret-sources";
33238
33281
 
33239
33282
  // ../registry/src/artifacts.ts
33240
33283
  import { stat } from "node:fs/promises";
@@ -33290,8 +33333,8 @@ var UNEXPANDED_PATH = /^~|\$[A-Za-z0-9_{(]|`|%[A-Za-z_][A-Za-z0-9_]*%|^[A-Za-z][
33290
33333
  function isUnexpandedPath(p) {
33291
33334
  return UNEXPANDED_PATH.test(p);
33292
33335
  }
33293
- function isClientFileArgument({ spec, path: path18 }) {
33294
- return spec.kind === "file" && spec.path === `\${${spec.target}}` && path18.startsWith("/") && hasToolFileExtension(path18);
33336
+ function isClientFileArgument({ spec, path: path19 }) {
33337
+ return spec.kind === "file" && spec.path === `\${${spec.target}}` && path19.startsWith("/") && hasToolFileExtension(path19);
33295
33338
  }
33296
33339
 
33297
33340
  // ../registry/src/flow-platforms.ts
@@ -33299,26 +33342,26 @@ var LAUNCH_PLATFORMS = ["ios", "android", "chromium", "vega", "macos"];
33299
33342
  var SELECTABLE_PLATFORMS = [...LAUNCH_PLATFORMS, "ios-remote"];
33300
33343
 
33301
33344
  // ../registry/src/flow-file-refs.ts
33302
- import * as fs7 from "node:fs/promises";
33303
- import * as path8 from "node:path";
33345
+ import * as fs8 from "node:fs/promises";
33346
+ import * as path9 from "node:path";
33304
33347
 
33305
33348
  // ../registry/src/e2e-dirs.ts
33306
- import * as fs6 from "node:fs/promises";
33307
- import * as path7 from "node:path";
33308
- var E2E_DIR = path7.join(".argent", "e2e");
33309
- var LEGACY_E2E_DIRS = Object.freeze([path7.join(".argent", "flows")]);
33349
+ import * as fs7 from "node:fs/promises";
33350
+ import * as path8 from "node:path";
33351
+ var E2E_DIR = path8.join(".argent", "e2e");
33352
+ var LEGACY_E2E_DIRS = Object.freeze([path8.join(".argent", "flows")]);
33310
33353
  var E2E_DIRS = Object.freeze([E2E_DIR, ...LEGACY_E2E_DIRS]);
33311
33354
  function e2eDirFor(projectRoot) {
33312
- return path7.join(projectRoot, E2E_DIR);
33355
+ return path8.join(projectRoot, E2E_DIR);
33313
33356
  }
33314
33357
  function e2eDirsFor(projectRoot) {
33315
- return E2E_DIRS.map((dir) => path7.join(projectRoot, dir));
33358
+ return E2E_DIRS.map((dir) => path8.join(projectRoot, dir));
33316
33359
  }
33317
33360
  function e2eFileCandidates(projectRoot, name) {
33318
- return e2eDirsFor(projectRoot).map((dir) => path7.join(dir, `${name}.yaml`));
33361
+ return e2eDirsFor(projectRoot).map((dir) => path8.join(dir, `${name}.yaml`));
33319
33362
  }
33320
33363
  async function exists(file) {
33321
- return fs6.stat(file).then(
33364
+ return fs7.stat(file).then(
33322
33365
  () => true,
33323
33366
  () => false
33324
33367
  );
@@ -33345,21 +33388,21 @@ async function pickE2eFile(candidates) {
33345
33388
  function e2eShadowWarning(used, shadowed) {
33346
33389
  return `${shadowed} is not used: ${used} has the same name and is read first.`;
33347
33390
  }
33348
- var E2E_DIR_NAMES = E2E_DIRS.map((dir) => path7.basename(dir));
33391
+ var E2E_DIR_NAMES = E2E_DIRS.map((dir) => path8.basename(dir));
33349
33392
  function e2eDirProject(dir) {
33350
33393
  const trimmed = dir.length > 1 ? dir.replace(/[\\/]+$/, "") : dir;
33351
- const argent = path7.dirname(trimmed);
33352
- if (!E2E_DIR_NAMES.includes(path7.basename(trimmed)) || path7.basename(argent) !== ".argent") {
33394
+ const argent = path8.dirname(trimmed);
33395
+ if (!E2E_DIR_NAMES.includes(path8.basename(trimmed)) || path8.basename(argent) !== ".argent") {
33353
33396
  return null;
33354
33397
  }
33355
- return path7.dirname(argent);
33398
+ return path8.dirname(argent);
33356
33399
  }
33357
33400
  function e2eRunFallbackDirs(anchorDir, target) {
33358
33401
  if (target.includes("/") || target.includes("\\")) return [];
33359
33402
  const project = e2eDirProject(anchorDir);
33360
33403
  if (project === null) return [];
33361
- const anchor2 = path7.resolve(anchorDir);
33362
- return e2eDirsFor(project).filter((dir) => path7.resolve(dir) !== anchor2);
33404
+ const anchor2 = path8.resolve(anchorDir);
33405
+ return e2eDirsFor(project).filter((dir) => path8.resolve(dir) !== anchor2);
33363
33406
  }
33364
33407
 
33365
33408
  // ../registry/src/tool-ids.ts
@@ -33409,10 +33452,10 @@ function canonicalToolArgs(tool, args) {
33409
33452
  // ../registry/src/flow-file-refs.ts
33410
33453
  async function canonicalFlowPath(p) {
33411
33454
  try {
33412
- return await fs7.realpath(p);
33455
+ return await fs8.realpath(p);
33413
33456
  } catch {
33414
33457
  try {
33415
- return path8.join(await fs7.realpath(path8.dirname(p)), path8.basename(p));
33458
+ return path9.join(await fs8.realpath(path9.dirname(p)), path9.basename(p));
33416
33459
  } catch {
33417
33460
  return p;
33418
33461
  }
@@ -33421,7 +33464,7 @@ async function canonicalFlowPath(p) {
33421
33464
  function completeRunExtension(value) {
33422
33465
  if (value.endsWith(".yaml")) return value;
33423
33466
  const candidate = `${value}.yaml`;
33424
- return FLOW_FILE_NAME_PATTERN.test(path8.posix.basename(candidate)) ? candidate : value;
33467
+ return FLOW_FILE_NAME_PATTERN.test(path9.posix.basename(candidate)) ? candidate : value;
33425
33468
  }
33426
33469
  var MAX_RUN_DEPTH = 20;
33427
33470
  var MAX_BLOCK_NESTING = 64;
@@ -33443,9 +33486,9 @@ function collectFlowRequests(doc) {
33443
33486
  for (const step of steps) {
33444
33487
  if (!isRecord(step)) continue;
33445
33488
  const run = step.run;
33446
- if (typeof run === "string" && !run.includes("\\") && !path8.posix.isAbsolute(run) && !/^[A-Za-z]:/.test(run)) {
33489
+ if (typeof run === "string" && !run.includes("\\") && !path9.posix.isAbsolute(run) && !/^[A-Za-z]:/.test(run)) {
33447
33490
  const target = completeRunExtension(run);
33448
- if (FLOW_FILE_NAME_PATTERN.test(path8.posix.basename(target))) runTargets.add(target);
33491
+ if (FLOW_FILE_NAME_PATTERN.test(path9.posix.basename(target))) runTargets.add(target);
33449
33492
  }
33450
33493
  const snapshot = isRecord(step.snapshot) ? step.snapshot.name : step.snapshot;
33451
33494
  if (typeof snapshot === "string" && FLOW_NAME_PATTERN.test(snapshot)) snapshots.add(snapshot);
@@ -33458,18 +33501,21 @@ function collectFlowRequests(doc) {
33458
33501
  visit(step.steps, depth + 1);
33459
33502
  }
33460
33503
  };
33461
- if (isRecord(doc)) visit(doc.steps, 0);
33504
+ if (isRecord(doc)) {
33505
+ visit(doc.steps, 0);
33506
+ visit(doc.shutdown, 0);
33507
+ }
33462
33508
  return { runTargets: [...runTargets], snapshots: [...snapshots], toolSteps, nested };
33463
33509
  }
33464
33510
  function baselineKeyFor(canonicalPath2, flowName) {
33465
- const stem = path8.basename(canonicalPath2, ".yaml");
33511
+ const stem = path9.basename(canonicalPath2, ".yaml");
33466
33512
  return FLOW_NAME_PATTERN.test(stem) ? stem : flowName;
33467
33513
  }
33468
33514
  function flowMemberKey(anchorDir, target) {
33469
33515
  return `${anchorDir}\0${target}`;
33470
33516
  }
33471
33517
  async function classifyOnDiskSpelling(dir, base, addressable = FLOW_FILE_NAME_PATTERN) {
33472
- const entries = await fs7.readdir(dir).catch(() => null);
33518
+ const entries = await fs8.readdir(dir).catch(() => null);
33473
33519
  if (entries === null || entries.includes(base)) return { state: "listed" };
33474
33520
  const actual = entries.find((entry) => entry.toLowerCase() === base.toLowerCase());
33475
33521
  if (actual === void 0) return { state: "absent" };
@@ -33491,11 +33537,11 @@ function nestedFlowTarget(args) {
33491
33537
  return { kind: "name", projectRoot, name, path: paths[0], paths };
33492
33538
  }
33493
33539
  if (name !== void 0 || !isResolvedAbsolute(flowPath)) return void 0;
33494
- if (!FLOW_FILE_NAME_PATTERN.test(path8.basename(flowPath))) return void 0;
33540
+ if (!FLOW_FILE_NAME_PATTERN.test(path9.basename(flowPath))) return void 0;
33495
33541
  return { kind: "e2e_test_path", path: flowPath };
33496
33542
  }
33497
33543
  function isResolvedAbsolute(value) {
33498
- return typeof value === "string" && path8.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
33544
+ return typeof value === "string" && path9.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
33499
33545
  }
33500
33546
 
33501
33547
  // ../registry/src/failure-codes.ts
@@ -34013,9 +34059,9 @@ var FAILURE_SPAWN_CODE_SET = new Set(FAILURE_SPAWN_CODES);
34013
34059
  import { randomUUID as randomUUID3 } from "node:crypto";
34014
34060
  import { AsyncLocalStorage } from "node:async_hooks";
34015
34061
  var resolvedDuringInvocation = new AsyncLocalStorage();
34016
- function valueAtPath(root, path18) {
34062
+ function valueAtPath(root, path19) {
34017
34063
  let current = root;
34018
- for (const key of path18) {
34064
+ for (const key of path19) {
34019
34065
  if (current === null || typeof current !== "object") return void 0;
34020
34066
  if (!Object.hasOwn(current, key)) return void 0;
34021
34067
  current = current[key];
@@ -34073,11 +34119,10 @@ function describeParamIssues(error2, params) {
34073
34119
  }
34074
34120
 
34075
34121
  // ../argent-tools-client/src/link-config.ts
34076
- import * as path9 from "node:path";
34077
- import { homedir as homedir4 } from "node:os";
34122
+ import * as path10 from "node:path";
34078
34123
  import { mkdir as mkdir2, writeFile as writeFile2, readFile as readFile2, unlink as unlink2, chmod as chmod2 } from "node:fs/promises";
34079
- var LINK_DIR = path9.join(homedir4(), ".argent");
34080
- var LINK_FILE = path9.join(LINK_DIR, "link.json");
34124
+ var LINK_DIR = argentHomeDir();
34125
+ var LINK_FILE = path10.join(LINK_DIR, "link.json");
34081
34126
  async function readLinkConfig() {
34082
34127
  try {
34083
34128
  const raw2 = await readFile2(LINK_FILE, "utf8");
@@ -34130,14 +34175,14 @@ import {
34130
34175
  writeFile as writeFile3
34131
34176
  } from "node:fs/promises";
34132
34177
  import { constants, tmpdir } from "node:os";
34133
- import * as path10 from "node:path";
34178
+ import * as path11 from "node:path";
34134
34179
 
34135
34180
  // ../archive/src/index.ts
34136
34181
  import { spawn as spawn2 } from "node:child_process";
34137
34182
  import { once } from "node:events";
34138
34183
  import { createReadStream, createWriteStream } from "node:fs";
34139
34184
  import { open as open2, rm, readdir as readdir3 } from "node:fs/promises";
34140
- import { basename as basename4, dirname as dirname5, join as join9, resolve as resolve7, sep as sep2 } from "node:path";
34185
+ import { basename as basename4, dirname as dirname5, join as join10, resolve as resolve8, sep as sep2 } from "node:path";
34141
34186
  import { Writable } from "node:stream";
34142
34187
  import { pipeline } from "node:stream/promises";
34143
34188
  import zlib from "node:zlib";
@@ -34292,7 +34337,7 @@ async function runTar(archive, args, signal) {
34292
34337
  child.on("error", (err) => {
34293
34338
  childError = err;
34294
34339
  });
34295
- const closed = new Promise((resolve12) => child.once("close", resolve12));
34340
+ const closed = new Promise((resolve13) => child.once("close", resolve13));
34296
34341
  const stdout = collect(child.stdout, MAX_LISTING_BYTES, {
34297
34342
  maxLines: MAX_LISTING_LINES,
34298
34343
  onOverflow: () => child.kill()
@@ -34341,16 +34386,16 @@ async function runTar(archive, args, signal) {
34341
34386
  function normalizeTarMemberPath(memberPath) {
34342
34387
  return memberPath.replace(/^\.\//, "").replace(/\\/g, "/");
34343
34388
  }
34344
- function isContainedPath(path18, windows = process.platform === "win32") {
34345
- const slashed = path18.replace(/\\/g, "/");
34389
+ function isContainedPath(path19, windows = process.platform === "win32") {
34390
+ const slashed = path19.replace(/\\/g, "/");
34346
34391
  const drive = windows ? /^[A-Za-z]:/ : /^[A-Za-z]:\//;
34347
34392
  return !slashed.startsWith("/") && !drive.test(slashed) && !slashed.split("/").includes("..");
34348
34393
  }
34349
34394
  function isSafeTarMember(memberPath, destDir) {
34350
34395
  const normalized = normalizeTarMemberPath(memberPath);
34351
34396
  if (!isContainedPath(normalized)) return false;
34352
- const root = resolve7(destDir);
34353
- return resolve7(destDir, normalized).startsWith(root + sep2);
34397
+ const root = resolve8(destDir);
34398
+ return resolve8(destDir, normalized).startsWith(root + sep2);
34354
34399
  }
34355
34400
  async function readListing(archive, args, signal) {
34356
34401
  try {
@@ -34402,7 +34447,7 @@ async function assertSafeArchive(archive, destDir, signal) {
34402
34447
  async function resolveMember(destDir, expectedName) {
34403
34448
  const entries = await readdir3(destDir);
34404
34449
  if (entries.includes(expectedName)) {
34405
- return join9(destDir, expectedName);
34450
+ return join10(destDir, expectedName);
34406
34451
  }
34407
34452
  const real = entries.filter((e) => !e.startsWith("._"));
34408
34453
  if (real.length !== 1) {
@@ -34410,7 +34455,7 @@ async function resolveMember(destDir, expectedName) {
34410
34455
  `Could not identify the extracted member (expected "${expectedName}", found ${real.length} entries).`
34411
34456
  );
34412
34457
  }
34413
- return join9(destDir, real[0]);
34458
+ return join10(destDir, real[0]);
34414
34459
  }
34415
34460
  async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
34416
34461
  signal?.throwIfAborted();
@@ -34463,20 +34508,20 @@ function interpolatePath(template, args) {
34463
34508
  return missing ? null : out;
34464
34509
  }
34465
34510
  function callerPath(p) {
34466
- const onCurrentDrive = path10.sep === "\\" && /^[\\/](?![\\/])/.test(p);
34467
- if (!onCurrentDrive && (path10.isAbsolute(p) || path10.win32.isAbsolute(p) || isUnexpandedPath(p))) {
34511
+ const onCurrentDrive = path11.sep === "\\" && /^[\\/](?![\\/])/.test(p);
34512
+ if (!onCurrentDrive && (path11.isAbsolute(p) || path11.win32.isAbsolute(p) || isUnexpandedPath(p))) {
34468
34513
  return p;
34469
34514
  }
34470
- const { root } = path10.parse(p);
34515
+ const { root } = path11.parse(p);
34471
34516
  const rest = p.slice(root.length);
34472
34517
  if (!rest.split(/[\\/]/).includes("..")) {
34473
- const resolved = path10.resolve(p);
34474
- const last = p.split(path10.sep === "\\" ? /[\\/]/ : "/").at(-1);
34475
- const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(path10.sep);
34476
- return dirOnly ? `${resolved}${path10.sep}` : resolved;
34518
+ const resolved = path11.resolve(p);
34519
+ const last = p.split(path11.sep === "\\" ? /[\\/]/ : "/").at(-1);
34520
+ const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(path11.sep);
34521
+ return dirOnly ? `${resolved}${path11.sep}` : resolved;
34477
34522
  }
34478
- const base = path10.resolve(root);
34479
- return base.endsWith(path10.sep) ? `${base}${rest}` : `${base}${path10.sep}${rest}`;
34523
+ const base = path11.resolve(root);
34524
+ return base.endsWith(path11.sep) ? `${base}${rest}` : `${base}${path11.sep}${rest}`;
34480
34525
  }
34481
34526
  async function specPath(spec, args) {
34482
34527
  if (spec.kind !== "file" || !spec.paths?.length) return interpolatePath(spec.path, args);
@@ -34523,9 +34568,9 @@ function untrackArchive(archive) {
34523
34568
  process.removeListener("exit", removePendingArchives);
34524
34569
  }
34525
34570
  function sha256File(filePath, signal) {
34526
- return new Promise((resolve12, reject) => {
34571
+ return new Promise((resolve13, reject) => {
34527
34572
  const hash = createHash2("sha256");
34528
- createReadStream2(filePath, { signal }).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve12(hash.digest("hex"))).on("error", reject);
34573
+ createReadStream2(filePath, { signal }).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve13(hash.digest("hex"))).on("error", reject);
34529
34574
  });
34530
34575
  }
34531
34576
  function toolServerError(text) {
@@ -34584,7 +34629,7 @@ async function uploadTar(tarPath, format, endpoint, signal) {
34584
34629
  }
34585
34630
  async function uploadFile(sourcePath, endpoint, signal) {
34586
34631
  const format = pickArchiveFormat(endpoint.formats);
34587
- const tarPath = path10.join(tmpdir(), `argent-upload-${randomUUID4()}.tar.gz`);
34632
+ const tarPath = path11.join(tmpdir(), `argent-upload-${randomUUID4()}.tar.gz`);
34588
34633
  trackArchive(tarPath);
34589
34634
  try {
34590
34635
  await createArchiveFile(await realpath2(sourcePath), tarPath, format, signal);
@@ -34659,7 +34704,7 @@ async function prepareFileInputs(specs, args, opts) {
34659
34704
  wire.mtimeMs = st.mtimeMs;
34660
34705
  }
34661
34706
  if (opts.uploadEndpoint && st) {
34662
- process.stderr.write(`Uploading ${path10.basename(filePath)} to the remote tool-server...
34707
+ process.stderr.write(`Uploading ${path11.basename(filePath)} to the remote tool-server...
34663
34708
  `);
34664
34709
  Object.assign(wire, await uploadFile(filePath, opts.uploadEndpoint, opts.signal));
34665
34710
  }
@@ -34669,7 +34714,7 @@ async function prepareFileInputs(specs, args, opts) {
34669
34714
  return out;
34670
34715
  }
34671
34716
  function isAllowedClientFilePath(p) {
34672
- if (!path10.isAbsolute(p)) return false;
34717
+ if (!path11.isAbsolute(p)) return false;
34673
34718
  const segments = p.split(/[\\/]+/);
34674
34719
  if (segments.includes("..")) return false;
34675
34720
  const file = segments[segments.length - 1] ?? "";
@@ -34680,7 +34725,7 @@ function isClientFileDirective2(value) {
34680
34725
  return !!value && typeof value === "object" && value[CLIENT_FILE_MARKER2] === true && typeof value.path === "string" && typeof value.content === "string";
34681
34726
  }
34682
34727
  async function replaceFile(target, bytes, mode) {
34683
- const temp = path10.join(path10.dirname(target), `.baseline-${randomUUID4()}.tmp`);
34728
+ const temp = path11.join(path11.dirname(target), `.baseline-${randomUUID4()}.tmp`);
34684
34729
  try {
34685
34730
  await writeFile3(temp, bytes, { flag: "wx" });
34686
34731
  if (mode !== void 0) await chmod3(temp, mode & 511);
@@ -34691,27 +34736,27 @@ async function replaceFile(target, bytes, mode) {
34691
34736
  }
34692
34737
  }
34693
34738
  async function writeBaselineFile(file, bytes, allowedDirs) {
34694
- if (!path10.isAbsolute(file) || path10.normalize(file) !== file || file.split(/[\\/]/).includes("..") || !file.endsWith(".png") || !allowedDirs.includes(path10.dirname(file))) {
34739
+ if (!path11.isAbsolute(file) || path11.normalize(file) !== file || file.split(/[\\/]/).includes("..") || !file.endsWith(".png") || !allowedDirs.includes(path11.dirname(file))) {
34695
34740
  return allowedDirs.length === 0 ? "this call writes no baselines" : `${file} is not a baseline of this call (${allowedDirs.map((d) => `${d}/<name>.png`).join(", ")})`;
34696
34741
  }
34697
34742
  if (bytes.length > MAX_CONTENT_BYTES) {
34698
34743
  return `${file}: the baseline is larger than the 32 MiB cap on a file this client writes`;
34699
34744
  }
34700
- const dir = path10.dirname(file);
34745
+ const dir = path11.dirname(file);
34701
34746
  await mkdir3(dir, { recursive: true });
34702
34747
  const link = await lstat(file).catch(() => null);
34703
34748
  const real = link === null ? null : await realpath2(file).catch(() => null);
34704
34749
  if (link !== null && real === null) return `${file} is a symbolic link to a missing file`;
34705
34750
  if (real !== null) {
34706
34751
  if (!real.endsWith(".png")) return `${file} links to a file that is not a PNG file`;
34707
- if (path10.dirname(real) !== await realpath2(dir)) {
34752
+ if (path11.dirname(real) !== await realpath2(dir)) {
34708
34753
  return `${file} links outside its baseline directory`;
34709
34754
  }
34710
34755
  }
34711
34756
  const existing = real === null ? null : await stat3(real);
34712
34757
  if (existing !== null && !existing.isFile()) return `${file} is not a regular file`;
34713
34758
  await replaceFile(
34714
- real ?? path10.join(await realpath2(dir), path10.basename(file)),
34759
+ real ?? path11.join(await realpath2(dir), path11.basename(file)),
34715
34760
  bytes,
34716
34761
  existing?.mode
34717
34762
  );
@@ -34737,7 +34782,7 @@ async function applyClientFileDirectives(result, opts = {}) {
34737
34782
  if (isClientFileDirective2(value)) {
34738
34783
  if (!isAllowedClientFilePath(value.path)) return null;
34739
34784
  try {
34740
- await mkdir3(path10.dirname(value.path), { recursive: true });
34785
+ await mkdir3(path11.dirname(value.path), { recursive: true });
34741
34786
  await writeFile3(value.path, value.content, "utf8");
34742
34787
  written.push(value.path);
34743
34788
  return value.path;
@@ -34764,15 +34809,15 @@ async function applyClientFileDirectives(result, opts = {}) {
34764
34809
  }
34765
34810
 
34766
34811
  // ../argent-tools-client/src/flow-files.ts
34767
- var import_yaml = __toESM(require_dist2(), 1);
34812
+ var import_yaml = __toESM(require_dist3(), 1);
34768
34813
  import { readdir as readdir4, readFile as readFile4, realpath as realpath3, stat as stat4 } from "node:fs/promises";
34769
- import * as path11 from "node:path";
34814
+ import * as path12 from "node:path";
34770
34815
  var INLINE_MEMBERS_BYTES = 256 * 1024;
34771
34816
  function filesLogEnabled() {
34772
34817
  return (process.env.ARGENT_E2E_FILES_LOG ?? process.env.ARGENT_FLOW_FILES_LOG) === "1";
34773
34818
  }
34774
34819
  function isWithin(inner, outer) {
34775
- return inner === outer || inner.startsWith(outer.endsWith(path11.sep) ? outer : outer + path11.sep);
34820
+ return inner === outer || inner.startsWith(outer.endsWith(path12.sep) ? outer : outer + path12.sep);
34776
34821
  }
34777
34822
  function printable(text) {
34778
34823
  return [...text].map(
@@ -34780,7 +34825,7 @@ function printable(text) {
34780
34825
  ).join("");
34781
34826
  }
34782
34827
  function isResolvedAbsolute2(value) {
34783
- return typeof value === "string" && path11.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
34828
+ return typeof value === "string" && path12.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
34784
34829
  }
34785
34830
  function namesValidFlow(args) {
34786
34831
  let canonical;
@@ -34792,13 +34837,13 @@ function namesValidFlow(args) {
34792
34837
  const { project_root, e2e_test_path: testPath, name } = canonical;
34793
34838
  if (!isResolvedAbsolute2(project_root)) return false;
34794
34839
  if (name === void 0) {
34795
- return isResolvedAbsolute2(testPath) && FLOW_FILE_NAME_PATTERN.test(path11.basename(testPath));
34840
+ return isResolvedAbsolute2(testPath) && FLOW_FILE_NAME_PATTERN.test(path12.basename(testPath));
34796
34841
  }
34797
34842
  return testPath === void 0 && typeof name === "string" && FLOW_NAME_PATTERN.test(name);
34798
34843
  }
34799
34844
  function savedFlowProject(file) {
34800
- if (!path11.isAbsolute(file)) return null;
34801
- for (let dir = path11.dirname(file); dir !== path11.dirname(dir); dir = path11.dirname(dir)) {
34845
+ if (!path12.isAbsolute(file)) return null;
34846
+ for (let dir = path12.dirname(file); dir !== path12.dirname(dir); dir = path12.dirname(dir)) {
34802
34847
  const project = e2eDirProject(dir);
34803
34848
  if (project !== null) return project;
34804
34849
  }
@@ -34813,11 +34858,11 @@ async function landing(spelled) {
34813
34858
  const canonical = await canonicalFlowPath(spelled);
34814
34859
  let at = spelled;
34815
34860
  for (; ; ) {
34816
- const parent = path11.dirname(at);
34861
+ const parent = path12.dirname(at);
34817
34862
  if (parent === at) return { canonical, fence: spelled, ...failure2 };
34818
34863
  const real = await realpath3(parent).catch(() => null);
34819
34864
  if (real !== null) {
34820
- return { canonical, fence: path11.join(real, path11.basename(at)), ...failure2 };
34865
+ return { canonical, fence: path12.join(real, path12.basename(at)), ...failure2 };
34821
34866
  }
34822
34867
  at = parent;
34823
34868
  }
@@ -34825,10 +34870,10 @@ async function landing(spelled) {
34825
34870
  }
34826
34871
  async function closureRoots(rootPath, rootCanonical, projectRoot) {
34827
34872
  const candidates = [];
34828
- if (typeof projectRoot === "string" && path11.isAbsolute(projectRoot)) {
34873
+ if (typeof projectRoot === "string" && path12.isAbsolute(projectRoot)) {
34829
34874
  candidates.push(projectRoot, ...e2eDirsFor(projectRoot));
34830
34875
  }
34831
- candidates.push(path11.dirname(rootPath), path11.dirname(rootCanonical));
34876
+ candidates.push(path12.dirname(rootPath), path12.dirname(rootCanonical));
34832
34877
  for (const file of [rootPath, rootCanonical]) {
34833
34878
  const project = savedFlowProject(file);
34834
34879
  if (project !== null) candidates.push(project);
@@ -34841,11 +34886,11 @@ async function closureRoots(rootPath, rootCanonical, projectRoot) {
34841
34886
  return real.filter((root) => !real.some((other) => other !== root && isWithin(root, other)));
34842
34887
  }
34843
34888
  async function readFlowMember(anchorDir, target, roots, budget, opts) {
34844
- const spelled = anchorDir + path11.sep + target;
34889
+ const spelled = anchorDir + path12.sep + target;
34845
34890
  const { canonical, fence, missing, error: error2 } = await landing(spelled);
34846
34891
  const spelling = await classifyOnDiskSpelling(
34847
- path11.dirname(spelled),
34848
- path11.posix.basename(target),
34892
+ path12.dirname(spelled),
34893
+ path12.posix.basename(target),
34849
34894
  FLOW_FILE_NAME_PATTERN
34850
34895
  );
34851
34896
  const member = {
@@ -34870,7 +34915,7 @@ async function readFlowMember(anchorDir, target, roots, budget, opts) {
34870
34915
  return { member: { ...member, state: "missing" }, sent: "missing" };
34871
34916
  }
34872
34917
  if (st.isDirectory()) return refuse("EISDIR: illegal operation on a directory, read");
34873
- if (!/\.ya?ml$/i.test(path11.basename(canonical))) {
34918
+ if (!/\.ya?ml$/i.test(path12.basename(canonical))) {
34874
34919
  return refuse(`${target} links to a file that is not a YAML file`);
34875
34920
  }
34876
34921
  const sent = await sendBytes(member, canonical, budget, opts);
@@ -34963,7 +35008,7 @@ function memberCollector(roots, opts) {
34963
35008
  const runs = /* @__PURE__ */ new Set();
34964
35009
  const baselineDirs = /* @__PURE__ */ new Map();
34965
35010
  const budget = { inline: 0 };
34966
- const logging = filesLogEnabled();
35011
+ const logging = filesLogEnabled() && opts.scanOnly !== true;
34967
35012
  const log = opts.log ?? ((line) => void process.stderr.write(`${line}
34968
35013
  `));
34969
35014
  const emit = (member, sent) => {
@@ -34983,6 +35028,7 @@ function memberCollector(roots, opts) {
34983
35028
  return entry;
34984
35029
  }
34985
35030
  async function toolFiles(step) {
35031
+ if (opts.scanOnly) return;
34986
35032
  if (canonicalToolId(step.tool) === "e2e-execute") return;
34987
35033
  for (const file of toolStepFiles(opts.toolFileInputs?.(step.tool), step.args)) {
34988
35034
  const { unwrapWhenSet } = file.spec;
@@ -34995,12 +35041,12 @@ function memberCollector(roots, opts) {
34995
35041
  }
34996
35042
  async function savedTest(target) {
34997
35043
  for (const candidate of target.paths) {
34998
- const found = await flow(path11.dirname(candidate), path11.basename(candidate), true);
35044
+ const found = await flow(path12.dirname(candidate), path12.basename(candidate), true);
34999
35045
  if (found !== void 0) return found;
35000
35046
  }
35001
35047
  let first;
35002
35048
  for (const candidate of target.paths) {
35003
- first ??= await flow(path11.dirname(candidate), path11.basename(candidate));
35049
+ first ??= await flow(path12.dirname(candidate), path12.basename(candidate));
35004
35050
  }
35005
35051
  return first;
35006
35052
  }
@@ -35009,6 +35055,12 @@ function memberCollector(roots, opts) {
35009
35055
  if (text === void 0 || hop >= MAX_RUN_DEPTH) return void 0;
35010
35056
  return { canonical: member.canonical, text, flowName: target.name, hop, updates, platform };
35011
35057
  }
35058
+ async function pathRun(target, hop, updates, platform) {
35059
+ const { member, text } = await flow(path12.dirname(target.path), path12.basename(target.path));
35060
+ if (text === void 0 || hop >= MAX_RUN_DEPTH) return void 0;
35061
+ const flowName = path12.basename(target.path, ".yaml");
35062
+ return { canonical: member.canonical, text, flowName, hop, updates, platform };
35063
+ }
35012
35064
  async function runTarget(anchorDir, target) {
35013
35065
  const found = await flow(anchorDir, target);
35014
35066
  if (found.member.spelling?.state !== "absent") return found;
@@ -35037,7 +35089,7 @@ function memberCollector(roots, opts) {
35037
35089
  const requests = collectFlowRequests(doc);
35038
35090
  for (const name of requests.snapshots) snapshots.add(name);
35039
35091
  for (const step of requests.toolSteps) await toolFiles(step);
35040
- const anchorDir = path11.dirname(file.canonical);
35092
+ const anchorDir = path12.dirname(file.canonical);
35041
35093
  for (const target of requests.runTargets) {
35042
35094
  const key = flowMemberKey(anchorDir, target);
35043
35095
  if (visited.has(key)) continue;
@@ -35048,19 +35100,14 @@ function memberCollector(roots, opts) {
35048
35100
  }
35049
35101
  }
35050
35102
  for (const { target, args } of requests.nested) {
35051
- if (target.kind !== "name") continue;
35052
- const next = await nestedRun(
35053
- target,
35054
- file.hop + 1,
35055
- nestedRunUpdates(run.updates, args),
35056
- run.platform
35057
- );
35103
+ const updates = nestedRunUpdates(run.updates, args);
35104
+ const next = target.kind === "name" ? await nestedRun(target, file.hop + 1, updates, run.platform) : opts.scanOnly ? await pathRun(target, file.hop + 1, updates, run.platform) : void 0;
35058
35105
  if (next !== void 0) queue.push(next);
35059
35106
  }
35060
35107
  }
35061
35108
  if (snapshots.size === 0) continue;
35062
- const dir = path11.join(
35063
- path11.dirname(run.canonical),
35109
+ const dir = path12.join(
35110
+ path12.dirname(run.canonical),
35064
35111
  "__baselines__",
35065
35112
  baselineKeyFor(run.canonical, run.flowName)
35066
35113
  );
@@ -35075,6 +35122,7 @@ function memberCollector(roots, opts) {
35075
35122
  }
35076
35123
  }
35077
35124
  async function sendBaselines() {
35125
+ if (opts.scanOnly) return;
35078
35126
  for (const [dir, { prefixes, updates }] of baselineDirs) {
35079
35127
  const real = (await landing(dir)).canonical;
35080
35128
  if (!roots.some((root) => isWithin(real, root))) continue;
@@ -35084,7 +35132,7 @@ function memberCollector(roots, opts) {
35084
35132
  if (!name.endsWith(".png")) continue;
35085
35133
  const compared = [...prefixes].some((prefix) => name.startsWith(prefix));
35086
35134
  if (!updates && !compared) continue;
35087
- const file = path11.join(dir, name);
35135
+ const file = path12.join(dir, name);
35088
35136
  if (tools.has(file)) continue;
35089
35137
  const member = { role: "baseline", key: file, path: file };
35090
35138
  const entry = await baselineEntry(file, roots, updates && !compared);
@@ -35107,19 +35155,19 @@ async function collectFlowMembers(rootPath, rootBytes, args, opts) {
35107
35155
  if (!namesValidFlow(args)) return {};
35108
35156
  const canonical = await canonicalFlowPath(rootPath);
35109
35157
  const spelling = await classifyOnDiskSpelling(
35110
- path11.dirname(rootPath),
35111
- path11.basename(rootPath),
35158
+ path12.dirname(rootPath),
35159
+ path12.basename(rootPath),
35112
35160
  FLOW_FILE_NAME_PATTERN
35113
35161
  );
35114
35162
  const collector = memberCollector(
35115
- await closureRoots(rootPath, canonical, args.project_root),
35163
+ opts.scanOnly ? [path12.parse(path12.resolve(rootPath)).root] : await closureRoots(rootPath, canonical, args.project_root),
35116
35164
  opts
35117
35165
  );
35118
35166
  await collector.walk([
35119
35167
  {
35120
35168
  canonical,
35121
35169
  text: rootBytes.toString("utf8"),
35122
- flowName: path11.basename(rootPath, ".yaml"),
35170
+ flowName: path12.basename(rootPath, ".yaml"),
35123
35171
  hop: 0,
35124
35172
  updates: args.updateBaselines === true,
35125
35173
  platform: callPlatform(args)
@@ -35148,31 +35196,31 @@ async function collectStepMembers(args, opts, recordingDirFor = e2eDirFor) {
35148
35196
  if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name) || !isResolvedAbsolute2(projectRoot) || step === void 0) {
35149
35197
  return [];
35150
35198
  }
35151
- const recording = path11.join(recordingDirFor(projectRoot), `${name}.yaml`);
35199
+ const recording = path12.join(recordingDirFor(projectRoot), `${name}.yaml`);
35152
35200
  const collector = memberCollector(
35153
- await closureRoots(recording, (await landing(recording)).canonical, projectRoot),
35201
+ opts.scanOnly ? [path12.parse(recording).root] : await closureRoots(recording, (await landing(recording)).canonical, projectRoot),
35154
35202
  opts
35155
35203
  );
35156
35204
  await collector.toolFiles(step);
35157
35205
  if (canonicalToolId(step.tool) === "e2e-execute") {
35158
- const self = await collector.flow(path11.dirname(recording), path11.basename(recording));
35206
+ const self = await collector.flow(path12.dirname(recording), path12.basename(recording));
35159
35207
  let runArgs = step.args;
35160
35208
  const named = nestedFlowTarget(runArgs);
35161
35209
  if (named?.kind === "e2e_test_path") {
35162
- const stem = path11.basename(named.path, ".yaml");
35163
- const base = path11.basename(named.path);
35164
- const dir = path11.resolve(path11.dirname(named.path));
35165
- const recordingDir = path11.dirname(recording);
35210
+ const stem = path12.basename(named.path, ".yaml");
35211
+ const base = path12.basename(named.path);
35212
+ const dir = path12.resolve(path12.dirname(named.path));
35213
+ const recordingDir = path12.dirname(recording);
35166
35214
  const dirs = [recordingDir, ...e2eRunFallbackDirs(recordingDir, base)];
35167
- if (dirs.some((d) => path11.resolve(d) === dir)) {
35168
- await collector.flow(path11.dirname(named.path), base);
35215
+ if (dirs.some((d) => path12.resolve(d) === dir)) {
35216
+ await collector.flow(path12.dirname(named.path), base);
35169
35217
  runArgs = { ...runArgs, name: stem };
35170
35218
  delete runArgs.e2e_test_path;
35171
35219
  }
35172
35220
  }
35173
35221
  const target = nestedFlowTarget(runArgs);
35174
35222
  if (target?.kind === "name") {
35175
- await collector.flow(path11.dirname(self.member.canonical), `${target.name}.yaml`);
35223
+ await collector.flow(path12.dirname(self.member.canonical), `${target.name}.yaml`);
35176
35224
  const run = await collector.nestedRun(
35177
35225
  target,
35178
35226
  0,
@@ -35366,10 +35414,10 @@ function assertFiniteNumbers(args) {
35366
35414
  if (typeof item === "object" && item !== null) {
35367
35415
  pending.push({ value: item, key, parent: visit });
35368
35416
  } else if (typeof item === "number" && !Number.isFinite(item)) {
35369
- const path18 = [key];
35370
- for (let at = visit; at.parent; at = at.parent) path18.push(at.key);
35371
- path18.reverse();
35372
- issues.push({ code: "invalid_type", path: path18, message: `expected a number, got ${item}` });
35417
+ const path19 = [key];
35418
+ for (let at = visit; at.parent; at = at.parent) path19.push(at.key);
35419
+ path19.reverse();
35420
+ issues.push({ code: "invalid_type", path: path19, message: `expected a number, got ${item}` });
35373
35421
  if (issues.length === MAX_NON_FINITE_ISSUES) break;
35374
35422
  }
35375
35423
  }
@@ -35396,8 +35444,31 @@ function carriesMembers(args) {
35396
35444
  function carriesUpload(args) {
35397
35445
  return carriesMembers(args) || wiresOf(args).some((wire) => typeof wire.uploadId === "string");
35398
35446
  }
35399
- async function forwardedSecrets(args) {
35400
- if (!isFeatureEnabled("forward-secrets")) return void 0;
35447
+ function secretValues(names, sources) {
35448
+ const values = /* @__PURE__ */ new Map();
35449
+ for (const rawName of names) {
35450
+ const { name, value } = lookupPlaceholderSecret(rawName, sources);
35451
+ if (value !== void 0) values.set(name, value);
35452
+ }
35453
+ return values;
35454
+ }
35455
+ async function callerSecrets(scanned, remote, secretsFile) {
35456
+ const forward = !remote || isFeatureEnabled("forward-secrets");
35457
+ if (!forward && secretsFile === void 0) return void 0;
35458
+ const names = await placeholderNamesIn(scanned);
35459
+ if (remote) {
35460
+ if (names.size === 0) return void 0;
35461
+ if (!forward) {
35462
+ const values = secretValues(names, [secretsFileSource(secretsFile)]);
35463
+ return values.size === 0 ? void 0 : { values };
35464
+ }
35465
+ return { values: secretValues(names, secretSources({ secretsFile })) };
35466
+ }
35467
+ if (names.size === 0) return { values: /* @__PURE__ */ new Map() };
35468
+ const sources = secretSources({ secretsFile });
35469
+ return { values: secretValues(names, sources), sources: summarizeSecretSources(sources) };
35470
+ }
35471
+ async function placeholderNamesIn(args) {
35401
35472
  const names = /* @__PURE__ */ new Set();
35402
35473
  const scan = (text) => {
35403
35474
  for (const name of placeholderNames(text)) names.add(name);
@@ -35434,15 +35505,33 @@ async function forwardedSecrets(args) {
35434
35505
  }
35435
35506
  };
35436
35507
  await visit(args);
35437
- if (names.size === 0) return void 0;
35438
- const sources = secretSources();
35439
- const values = /* @__PURE__ */ new Map();
35440
- for (const rawName of names) {
35441
- const { name, value } = lookupPlaceholderSecret(rawName, sources);
35442
- if (value !== void 0) values.set(name, value);
35508
+ return names;
35509
+ }
35510
+ async function localScanArgs(meta2, args, prepare) {
35511
+ const scanned = [args];
35512
+ const collecting = meta2?.fileInputs?.filter((spec) => spec.collect !== void 0) ?? [];
35513
+ if (meta2 && RECORDING_TOOLS.has(canonicalToolId(meta2.name))) {
35514
+ collecting.push(RECORDING_FILE_INPUT);
35443
35515
  }
35444
- return values;
35516
+ if (collecting.length > 0) {
35517
+ scanned.push(await prepare(collecting).catch(() => void 0));
35518
+ }
35519
+ return scanned;
35445
35520
  }
35521
+ var RECORDING_TOOLS = /* @__PURE__ */ new Set([
35522
+ "e2e-start-recording",
35523
+ "e2e-add-script",
35524
+ "e2e-add-step",
35525
+ "e2e-finish-recording"
35526
+ ]);
35527
+ var RECORDING_FILE_INPUT = {
35528
+ target: "__recording",
35529
+ path: `\${project_root}/${E2E_DIRS[0].split(path13.sep).join("/")}/\${name}.yaml`,
35530
+ paths: E2E_DIRS.map((dir) => `\${project_root}/${dir.split(path13.sep).join("/")}/\${name}.yaml`),
35531
+ kind: "file",
35532
+ optional: true,
35533
+ collect: "flow"
35534
+ };
35446
35535
  function secretsTransportRefusal(url) {
35447
35536
  if (!URL.canParse(url)) return `${url} is not a URL`;
35448
35537
  const { protocol, hostname } = new URL(url);
@@ -35546,6 +35635,23 @@ function createToolsClient(options = {}) {
35546
35635
  const shadowWarning = await e2eShadowWarningFor(name, args);
35547
35636
  const baselineDirs = [];
35548
35637
  let unwrittenBaselines = [];
35638
+ const memberOptions = {
35639
+ collectMembers: collectFlowMembers,
35640
+ collectStepMembers: olderServer ? (record2, o) => collectStepMembers(record2, o, (root) => path13.join(root, LEGACY_E2E_DIRS[0])) : collectStepMembers,
35641
+ toolFileInputs: (tool) => findTool(tools, tool)?.fileInputs,
35642
+ signal: opts?.signal
35643
+ };
35644
+ const scanned = remote ? void 0 : await localScanArgs(
35645
+ meta2,
35646
+ finalArgs,
35647
+ (specs) => prepareFileInputs(specs, finalArgs ?? {}, {
35648
+ includeContent: true,
35649
+ scanOnly: true,
35650
+ log: () => {
35651
+ },
35652
+ ...memberOptions
35653
+ })
35654
+ );
35549
35655
  if (meta2?.fileInputs?.length) {
35550
35656
  if (remote) assertRequiredPresent(meta2, finalArgs);
35551
35657
  finalArgs = await prepareFileInputs(meta2.fileInputs, finalArgs ?? {}, {
@@ -35553,10 +35659,7 @@ function createToolsClient(options = {}) {
35553
35659
  uploadEndpoint: remote ? { url, token, formats: uploadFormats } : void 0,
35554
35660
  log: diagnose,
35555
35661
  baselineDirs,
35556
- collectMembers: collectFlowMembers,
35557
- collectStepMembers: olderServer ? (record2, o) => collectStepMembers(record2, o, (root) => path12.join(root, LEGACY_E2E_DIRS[0])) : collectStepMembers,
35558
- toolFileInputs: (tool) => findTool(tools, tool)?.fileInputs,
35559
- signal: opts?.signal
35662
+ ...memberOptions
35560
35663
  });
35561
35664
  }
35562
35665
  const settle2 = async (data2) => {
@@ -35567,7 +35670,7 @@ function createToolsClient(options = {}) {
35567
35670
  }
35568
35671
  if (filesLogEnabled()) {
35569
35672
  for (const file of applied.written) {
35570
- if (baselineDirs.includes(path12.dirname(file))) {
35673
+ if (baselineDirs.includes(path13.dirname(file))) {
35571
35674
  diagnose(`[e2e-files] baseline ${file}: written`);
35572
35675
  }
35573
35676
  }
@@ -35581,13 +35684,13 @@ function createToolsClient(options = {}) {
35581
35684
  const unwrittenFailure = () => unwrittenBaselines.length > 0 ? `Baselines not written on this client: ${unwrittenBaselines.join(", ")}` : void 0;
35582
35685
  const stream = opts?.onProgress !== void 0 || carriesMembers(finalArgs);
35583
35686
  const sentOnce = carriesUpload(finalArgs);
35584
- const forwarded = remote ? await forwardedSecrets(finalArgs) : void 0;
35585
- const encodedSecrets = forwarded ? encodeClientSecrets(forwarded) : void 0;
35586
- const clientSecrets = forwarded?.size ? forwarded : void 0;
35687
+ const sent = await callerSecrets(remote ? finalArgs : scanned, remote, options.secretsFile);
35688
+ const encodedSecrets = sent ? encodeClientSecrets(sent.values) : void 0;
35689
+ const clientSecrets = sent?.values.size ? sent.values : void 0;
35587
35690
  const refusal = clientSecrets ? secretsTransportRefusal(url) : void 0;
35588
35691
  if (refusal !== void 0) {
35589
35692
  throw new Error(
35590
- `forward-secrets sends secret values only over https:// with the certificate checked, or to a loopback address, so the call was not sent (it names ${[...clientSecrets.keys()].join(", ")}): ${refusal}.`
35693
+ `argent sends secret values only over https:// with the certificate checked, or to a loopback address, so the call was not sent (it names ${[...clientSecrets.keys()].join(", ")}): ${refusal}.`
35591
35694
  );
35592
35695
  }
35593
35696
  const toolUrl = `${url}/tools/${encodeURIComponent(meta2?.name ?? name)}`;
@@ -35606,16 +35709,21 @@ function createToolsClient(options = {}) {
35606
35709
  ...stream ? { "Accept": "application/x-ndjson", "Accept-Encoding": "identity" } : {},
35607
35710
  ...authHeaders2(token)
35608
35711
  };
35609
- if (clientSecrets !== void 0 && encodedSecrets !== void 0) {
35610
- const headBytes = toolUrl.length + FETCH_HEAD_BYTES + Object.entries(headers).reduce(
35611
- (sum, [key, value]) => sum + key.length + value.length + 4,
35612
- 0
35613
- );
35614
- if (headBytes > maxHeaderSize) {
35615
- throw new Error(
35616
- `forward-secrets would send ${[...clientSecrets.keys()].join(", ")} in an ${CLIENT_SECRETS_HEADER} header of ${encodedSecrets.length} bytes, which takes the request headers past the ${maxHeaderSize} bytes a tool-server accepts, so the call was not sent. Define a secret this large on the machine running the tool-server instead.`
35712
+ const headBytes = () => toolUrl.length + FETCH_HEAD_BYTES + Object.entries(headers).reduce((sum, [key, value]) => sum + key.length + value.length + 4, 0);
35713
+ if (sent?.sources) {
35714
+ headers[CLIENT_SECRET_SOURCES_HEADER] = encodeSecretSourceSummaries(sent.sources);
35715
+ if (headBytes() > maxHeaderSize) {
35716
+ headers[CLIENT_SECRET_SOURCES_HEADER] = encodeSecretSourceSummaries(
35717
+ sent.sources.map((source) => ({ ...source, names: [] }))
35617
35718
  );
35618
35719
  }
35720
+ if (headBytes() > maxHeaderSize) delete headers[CLIENT_SECRET_SOURCES_HEADER];
35721
+ }
35722
+ if (clientSecrets !== void 0 && encodedSecrets !== void 0 && headBytes() > maxHeaderSize) {
35723
+ const names = [...clientSecrets.keys()].join(", ");
35724
+ throw new Error(
35725
+ remote ? `This call would send ${names} in an ${CLIENT_SECRETS_HEADER} header of ${encodedSecrets.length} bytes, which takes the request headers to about ${headBytes()} bytes, past the ${maxHeaderSize} bytes a tool-server accepts, so the call was not sent. Define a secret this large only on the machine running the tool-server instead.` : `The values of ${names} take the ${CLIENT_SECRETS_HEADER} header to ${encodedSecrets.length} bytes and the request headers to about ${headBytes()} bytes, past the ${maxHeaderSize} bytes the tool-server accepts, so the call was not sent. One call can send about 11 KiB of secret values: split the text across several calls.`
35726
+ );
35619
35727
  }
35620
35728
  const res = await doFetch(
35621
35729
  toolUrl,
@@ -35668,13 +35776,13 @@ function createToolsClient(options = {}) {
35668
35776
  }
35669
35777
  if (clientSecrets && res.status >= 300 && res.status < 400) {
35670
35778
  throw new ToolInvocationError(
35671
- `The tool-server answered ${res.status} ${res.statusText} to ${name}. forward-secrets does not follow a redirect, so the call was not sent on; link the URL it points to instead.`
35779
+ `The tool-server answered ${res.status} ${res.statusText} to ${name}. argent does not follow a redirect with secret values, so the call was not sent on; link the URL it points to instead.`
35672
35780
  );
35673
35781
  }
35674
35782
  const headersRefused = res.status === 431 || res.status === 400 && errorBodyMessage(json) === void 0;
35675
35783
  if (clientSecrets && headersRefused) {
35676
35784
  throw new ToolInvocationError(
35677
- `The tool-server, or a proxy in front of it, refused the request headers (${res.status}), as it does when they are too large. The ${CLIENT_SECRETS_HEADER} header carried ${[...clientSecrets.keys()].join(", ")}; define a secret this large on the machine running the tool-server instead.`
35785
+ `The tool-server, or a proxy in front of it, refused the request headers (${res.status}), as it does when they are too large. The ${CLIENT_SECRETS_HEADER} header carried ${[...clientSecrets.keys()].join(", ")}; ` + (remote ? `define a secret this large on the machine running the tool-server instead.` : `split the text across several calls.`)
35678
35786
  );
35679
35787
  }
35680
35788
  if (!res.ok) {
@@ -35711,7 +35819,7 @@ import {
35711
35819
  } from "node:fs/promises";
35712
35820
  import { constants as fsConstants } from "node:fs";
35713
35821
  import { tmpdir as tmpdir2 } from "node:os";
35714
- 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";
35822
+ import { basename as basename7, extname as extname2, isAbsolute as isAbsolute6, join as join14, normalize as normalize2, resolve as resolve11, sep as sep6 } from "node:path";
35715
35823
  import { createHash as createHash3 } from "node:crypto";
35716
35824
  var ARTIFACT_MARKER2 = "__argentArtifact";
35717
35825
  function isArtifactHandle(value) {
@@ -35735,16 +35843,16 @@ function projectSlug() {
35735
35843
  return `${name}-${hash}`;
35736
35844
  }
35737
35845
  function artifactsRoot() {
35738
- return process.env.ARGENT_ARTIFACTS_DIR ?? join13(tmpdir2(), "argent-artifacts");
35846
+ return process.env.ARGENT_ARTIFACTS_DIR ?? join14(tmpdir2(), "argent-artifacts");
35739
35847
  }
35740
35848
  function artifactDir(deviceId) {
35741
35849
  const parts = [artifactsRoot(), projectSlug(), sessionId()];
35742
35850
  if (deviceId) parts.push(sanitizeSegment(deviceId));
35743
- return join13(...parts);
35851
+ return join14(...parts);
35744
35852
  }
35745
35853
  function durableBaseDir() {
35746
35854
  const projectRoot = findProjectRoot(process.cwd());
35747
- return projectRoot ?? dirname9(argentHomeDir());
35855
+ return projectRoot ?? resolveHomeDir();
35748
35856
  }
35749
35857
  var ALLOWED_SAVE_DIRS = /* @__PURE__ */ new Set([normalize2(".argent/recordings")]);
35750
35858
  var RECORDINGS_SAVE_DIR = normalize2(".argent/recordings");
@@ -35758,9 +35866,9 @@ function configuredRecordingsDir() {
35758
35866
  if (typeof value !== "string") return null;
35759
35867
  const trimmed = value.trim();
35760
35868
  if (trimmed === "") return null;
35761
- const home = dirname9(argentHomeDir());
35762
- const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep5}`) ? join13(home, trimmed.slice(2)) : trimmed;
35763
- return resolve10(durableBaseDir(), expanded);
35869
+ const home = resolveHomeDir();
35870
+ const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep6}`) ? join14(home, trimmed.slice(2)) : trimmed;
35871
+ return resolve11(durableBaseDir(), expanded);
35764
35872
  }
35765
35873
  var MAX_ARTIFACT_BYTES = 2 * 1024 * 1024 * 1024;
35766
35874
  async function readCapped(res, cap) {
@@ -35793,10 +35901,10 @@ async function writeDurableUnique(dir, filename, write) {
35793
35901
  const stem = filename.slice(0, filename.length - ext.length);
35794
35902
  for (let i = 1; i <= 1e3; i++) {
35795
35903
  const candidate = i === 1 ? filename : `${stem} (${i})${ext}`;
35796
- const path18 = join13(dir, candidate);
35904
+ const path19 = join14(dir, candidate);
35797
35905
  try {
35798
- await write(path18);
35799
- return path18;
35906
+ await write(path19);
35907
+ return path19;
35800
35908
  } catch (err) {
35801
35909
  if (err?.code === "EEXIST") continue;
35802
35910
  throw err;
@@ -35807,7 +35915,7 @@ async function writeDurableUnique(dir, filename, write) {
35807
35915
  function durableSaveTarget(handle) {
35808
35916
  if (typeof handle.saveDir !== "string" || !handle.saveDir || handle.archive) return null;
35809
35917
  const rel = normalize2(handle.saveDir);
35810
- if (isAbsolute6(rel) || rel === ".." || rel.startsWith(`..${sep5}`) || rel.split(sep5).includes("..")) {
35918
+ if (isAbsolute6(rel) || rel === ".." || rel.startsWith(`..${sep6}`) || rel.split(sep6).includes("..")) {
35811
35919
  return null;
35812
35920
  }
35813
35921
  if (!ALLOWED_SAVE_DIRS.has(rel)) return null;
@@ -35816,21 +35924,21 @@ function durableSaveTarget(handle) {
35816
35924
  if (configured) {
35817
35925
  return {
35818
35926
  dir: configured,
35819
- path: join13(configured, sanitizeSegment(handle.filename)),
35927
+ path: join14(configured, sanitizeSegment(handle.filename)),
35820
35928
  base: configured,
35821
35929
  rel: ""
35822
35930
  };
35823
35931
  }
35824
35932
  }
35825
35933
  const base = durableBaseDir();
35826
- const dir = join13(base, rel);
35827
- return { dir, path: join13(dir, sanitizeSegment(handle.filename)), base, rel };
35934
+ const dir = join14(base, rel);
35935
+ return { dir, path: join14(dir, sanitizeSegment(handle.filename)), base, rel };
35828
35936
  }
35829
35937
  async function confineToRealBase(dir, base, rel) {
35830
35938
  try {
35831
35939
  const realDir = await realpath4(dir);
35832
35940
  const realBase = await realpath4(base);
35833
- return realDir === join13(realBase, rel);
35941
+ return realDir === join14(realBase, rel);
35834
35942
  } catch {
35835
35943
  return false;
35836
35944
  }
@@ -35854,9 +35962,9 @@ async function resolveLocalFile(handle) {
35854
35962
  }
35855
35963
  async function downloadAndExtractArchive(handle, data, dir, signal) {
35856
35964
  signal?.throwIfAborted();
35857
- const attemptDir = await mkdtemp(join13(dir, "bundle-"));
35858
- const tarball = join13(attemptDir, "download.tar");
35859
- const extractDir = join13(attemptDir, "files");
35965
+ const attemptDir = await mkdtemp(join14(dir, "bundle-"));
35966
+ const tarball = join14(attemptDir, "download.tar");
35967
+ const extractDir = join14(attemptDir, "files");
35860
35968
  try {
35861
35969
  await writeFile4(tarball, data, { signal });
35862
35970
  await mkdir4(extractDir);
@@ -35956,7 +36064,7 @@ async function materializeArtifacts(result, ctx) {
35956
36064
  return await downloadAndExtractArchive(value, data, dir, ctx.signal);
35957
36065
  }
35958
36066
  if (value.size > 0 && data.length !== value.size) return null;
35959
- const downloadedPath = join13(dir, sanitizeSegment(value.filename));
36067
+ const downloadedPath = join14(dir, sanitizeSegment(value.filename));
35960
36068
  await writeFile4(downloadedPath, data);
35961
36069
  if (value.mimeType.startsWith("image/")) {
35962
36070
  images.push({ localPath: downloadedPath, data, mimeType: value.mimeType });
@@ -35990,10 +36098,10 @@ function getDeviceIdFromArgs(args) {
35990
36098
  }
35991
36099
 
35992
36100
  // ../telemetry/src/debug.ts
35993
- import * as fs8 from "node:fs";
36101
+ import * as fs9 from "node:fs";
35994
36102
 
35995
36103
  // ../telemetry/src/paths.ts
35996
- import * as path13 from "node:path";
36104
+ import * as path14 from "node:path";
35997
36105
 
35998
36106
  // ../telemetry/src/events.ts
35999
36107
  var PLATFORMS = [
@@ -36318,37 +36426,37 @@ var ALLOWED = {
36318
36426
  import { randomUUID as randomUUID5 } from "node:crypto";
36319
36427
 
36320
36428
  // ../telemetry/src/cloud-agent-detect.ts
36321
- import { existsSync as existsSync3 } from "node:fs";
36429
+ import { existsSync as existsSync4 } from "node:fs";
36322
36430
 
36323
36431
  // ../telemetry/src/base-props.ts
36324
36432
  var SESSION_ID2 = randomUUID5();
36325
36433
 
36326
36434
  // ../telemetry/src/identity.ts
36327
36435
  import * as crypto2 from "node:crypto";
36328
- import * as fs9 from "node:fs";
36329
- import * as path14 from "node:path";
36436
+ import * as fs10 from "node:fs";
36437
+ import * as path15 from "node:path";
36330
36438
 
36331
36439
  // ../telemetry/src/fingerprint.ts
36332
36440
  import { execFileSync as execFileSync2, spawn as spawn3 } from "node:child_process";
36333
36441
 
36334
36442
  // ../native-devtools-ios/src/index.ts
36335
- import * as path15 from "node:path";
36336
- import * as fs10 from "node:fs";
36337
- var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ?? path15.join(__dirname, "..", "dylibs");
36338
- var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ?? path15.join(__dirname, "..", "bin");
36339
- var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ?? path15.join(DYLIB_DIR, "tcp");
36340
- var DYLIB_TVOS_DIR = path15.join(DYLIB_DIR, "tvos");
36443
+ import * as path16 from "node:path";
36444
+ import * as fs11 from "node:fs";
36445
+ var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ?? path16.join(__dirname, "..", "dylibs");
36446
+ var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ?? path16.join(__dirname, "..", "bin");
36447
+ var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ?? path16.join(DYLIB_DIR, "tcp");
36448
+ var DYLIB_TVOS_DIR = path16.join(DYLIB_DIR, "tvos");
36341
36449
 
36342
36450
  // ../telemetry/src/consent.ts
36343
- import * as fs11 from "node:fs";
36344
- import * as path16 from "node:path";
36451
+ import * as fs12 from "node:fs";
36452
+ import * as path17 from "node:path";
36345
36453
  var cache = /* @__PURE__ */ new Map();
36346
36454
  var sessionOverride = null;
36347
36455
  function readConfigOverrideAt(filePath) {
36348
36456
  const miss = { mtimeMs: null, fingerprint: null, enabledOverride: null };
36349
36457
  let stats;
36350
36458
  try {
36351
- stats = fs11.lstatSync(filePath);
36459
+ stats = fs12.lstatSync(filePath);
36352
36460
  } catch {
36353
36461
  cache.set(filePath, miss);
36354
36462
  return null;
@@ -36365,7 +36473,7 @@ function readConfigOverrideAt(filePath) {
36365
36473
  }
36366
36474
  let parsedEnabled = null;
36367
36475
  try {
36368
- const raw2 = fs11.readFileSync(filePath, "utf8");
36476
+ const raw2 = fs12.readFileSync(filePath, "utf8");
36369
36477
  const json = JSON.parse(raw2);
36370
36478
  if (json && typeof json === "object") {
36371
36479
  const t = json.telemetry;
@@ -36382,8 +36490,12 @@ function readConfigOverrideAt(filePath) {
36382
36490
  function readPersistedConsent(cwd) {
36383
36491
  const globalPath = configFilePath("global");
36384
36492
  const projectPath = configFilePath("project", { cwd });
36493
+ const userConfigPath = path17.join(resolveHomeDir(), ".argent", "config.json");
36494
+ if (userConfigPath !== globalPath && readConfigOverrideAt(userConfigPath) === false) {
36495
+ return { enabled: false, detail: `${userConfigPath} (user)` };
36496
+ }
36385
36497
  const global = readConfigOverrideAt(globalPath);
36386
- const projectRoot = path16.dirname(path16.dirname(projectPath));
36498
+ const projectRoot = path17.dirname(path17.dirname(projectPath));
36387
36499
  const project = isHomeDir(projectRoot) ? null : readConfigOverrideAt(projectPath);
36388
36500
  if (project === false && global === false) {
36389
36501
  return { enabled: false, detail: "config.json (project and global)" };
@@ -36763,8 +36875,13 @@ async function flowRunToMcpContent(result, ctx) {
36763
36875
  });
36764
36876
  if (typeof result.warning === "string")
36765
36877
  blocks.push({ type: "text", text: `\u26A0 ${result.warning}` });
36878
+ let inShutdown = false;
36766
36879
  for (let i = 0; i < result.steps.length; i++) {
36767
36880
  const step = result.steps[i];
36881
+ if (step.shutdown === true && !inShutdown) {
36882
+ inShutdown = true;
36883
+ blocks.push({ type: "text", text: "shutdown:" });
36884
+ }
36768
36885
  const num = step.index !== void 0 ? step.index + 1 : i + 1;
36769
36886
  const glyph = step.status ? `${STATUS_GLYPH[step.status] ?? "\u2022"} ` : "";
36770
36887
  const reason = step.reason ?? step.error;
@@ -36791,11 +36908,17 @@ async function flowRunToMcpContent(result, ctx) {
36791
36908
  }
36792
36909
  }
36793
36910
  for (const write of result.baselineWrites ?? []) {
36794
- const { path: path18, error: error2 } = isRecord3(write) ? write : {};
36795
- if (typeof path18 === "string" && typeof error2 === "string") {
36796
- blocks.push({ type: "text", text: `\u2717 baseline not written: ${path18}: ${error2}` });
36911
+ const { path: path19, error: error2 } = isRecord3(write) ? write : {};
36912
+ if (typeof path19 === "string" && typeof error2 === "string") {
36913
+ blocks.push({ type: "text", text: `\u2717 baseline not written: ${path19}: ${error2}` });
36797
36914
  }
36798
36915
  }
36916
+ if (result.shutdownFailed === true) {
36917
+ blocks.push({
36918
+ type: "text",
36919
+ text: "\u26A0 shutdown did not finish: a shutdown step failed, so the run may have left state behind."
36920
+ });
36921
+ }
36799
36922
  if (result.ok !== void 0) {
36800
36923
  const counted = (result.passed ?? 0) + (result.failed ?? 0) + (result.errored ?? 0) + (result.skipped ?? 0);
36801
36924
  const note = result.ok && counted === 0 ? " (no test steps)" : "";
@@ -37839,15 +37962,15 @@ function debuggerLogRegistryText(result) {
37839
37962
  }
37840
37963
 
37841
37964
  // ../argent-mcp/src/instructions.ts
37842
- 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.";
37965
+ 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`.";
37843
37966
 
37844
37967
  // ../argent-mcp/src/installed-version.ts
37845
- import * as fs12 from "node:fs";
37846
- import * as path17 from "node:path";
37968
+ import * as fs13 from "node:fs";
37969
+ import * as path18 from "node:path";
37847
37970
  function getInstalledVersion() {
37848
37971
  try {
37849
- const pkgPath = path17.resolve(import.meta.dirname, "..", "package.json");
37850
- const pkg = JSON.parse(fs12.readFileSync(pkgPath, "utf8"));
37972
+ const pkgPath = path18.resolve(import.meta.dirname, "..", "package.json");
37973
+ const pkg = JSON.parse(fs13.readFileSync(pkgPath, "utf8"));
37851
37974
  return pkg.version ?? "unknown";
37852
37975
  } catch {
37853
37976
  return "unknown";
@@ -37902,9 +38025,9 @@ async function untilAborted(work, signal) {
37902
38025
  }
37903
38026
  let onAbort = () => {
37904
38027
  };
37905
- const aborted2 = new Promise((resolve12) => {
37906
- onAbort = resolve12;
37907
- if (signal.aborted) resolve12();
38028
+ const aborted2 = new Promise((resolve13) => {
38029
+ onAbort = resolve13;
38030
+ if (signal.aborted) resolve13();
37908
38031
  else signal.addEventListener("abort", onAbort, { once: true });
37909
38032
  });
37910
38033
  try {
@@ -37965,6 +38088,94 @@ function createToolCaller(deps) {
37965
38088
  };
37966
38089
  }
37967
38090
 
38091
+ // ../argent-mcp/src/call-log.ts
38092
+ import {
38093
+ appendFileSync as appendFileSync2,
38094
+ chmodSync as chmodSync2,
38095
+ linkSync as linkSync2,
38096
+ mkdirSync as mkdirSync6,
38097
+ readFileSync as readFileSync8,
38098
+ renameSync as renameSync4,
38099
+ rmSync as rmSync3,
38100
+ statSync as statSync4
38101
+ } from "node:fs";
38102
+ import { appendFile } from "node:fs/promises";
38103
+ import { dirname as dirname10 } from "node:path";
38104
+ var CALL_LOG_MAX_BYTES = 10 * 1024 * 1024;
38105
+ var STAT_EVERY_BYTES = 1024 * 1024;
38106
+ function createCallLog(file, maxBytes = CALL_LOG_MAX_BYTES) {
38107
+ let dirReady = false;
38108
+ let checked = false;
38109
+ let estimate = 0;
38110
+ let sinceStat = 0;
38111
+ function check() {
38112
+ sinceStat = 0;
38113
+ estimate = 0;
38114
+ const st = statSync4(file, { throwIfNoEntry: false });
38115
+ if (!st) return;
38116
+ if (st.mode & 63) {
38117
+ try {
38118
+ chmodSync2(file, st.mode & 448);
38119
+ } catch {
38120
+ }
38121
+ }
38122
+ if (st.size < maxBytes) {
38123
+ estimate = st.size;
38124
+ return;
38125
+ }
38126
+ rotate(file, st);
38127
+ }
38128
+ return async function write(entry) {
38129
+ try {
38130
+ if (!dirReady) {
38131
+ mkdirSync6(dirname10(file), { recursive: true, mode: 448 });
38132
+ dirReady = true;
38133
+ }
38134
+ if (!checked || estimate >= maxBytes || sinceStat >= STAT_EVERY_BYTES) {
38135
+ checked = true;
38136
+ check();
38137
+ }
38138
+ const line = JSON.stringify(entry) + "\n";
38139
+ const bytes = Buffer.byteLength(line);
38140
+ estimate += bytes;
38141
+ sinceStat += bytes;
38142
+ await appendFile(file, line, { mode: 384 });
38143
+ } catch {
38144
+ }
38145
+ };
38146
+ }
38147
+ function rotate(file, measured) {
38148
+ const aside = `${file}.${process.pid}.rotating`;
38149
+ try {
38150
+ renameSync4(file, aside);
38151
+ } catch {
38152
+ return;
38153
+ }
38154
+ let moved;
38155
+ try {
38156
+ moved = statSync4(aside);
38157
+ } catch {
38158
+ return;
38159
+ }
38160
+ if (moved.ino === measured.ino && moved.dev === measured.dev) {
38161
+ try {
38162
+ renameSync4(aside, `${file}.1`);
38163
+ } catch {
38164
+ }
38165
+ return;
38166
+ }
38167
+ try {
38168
+ linkSync2(aside, file);
38169
+ } catch {
38170
+ try {
38171
+ appendFileSync2(file, readFileSync8(aside), { mode: 384 });
38172
+ } catch {
38173
+ return;
38174
+ }
38175
+ }
38176
+ rmSync3(aside, { force: true });
38177
+ }
38178
+
37968
38179
  // ../argent-mcp/src/whats-new.ts
37969
38180
  var import_semver = __toESM(require_semver2(), 1);
37970
38181
 
@@ -38044,7 +38255,7 @@ async function startMcpServer(options) {
38044
38255
  const autoDescribeOn = autoDescribeEnabled();
38045
38256
  const whatsNewOn = whatsNewEnabled();
38046
38257
  const installedVersion = getInstalledVersion();
38047
- const highlightsVersion = true ? "0.35.1-next.6" : installedVersion;
38258
+ const highlightsVersion = true ? "0.35.1-next.61" : installedVersion;
38048
38259
  const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
38049
38260
  const trees = createTreeMemory();
38050
38261
  const screenshots = createScreenshotMemory();
@@ -38089,18 +38300,8 @@ async function startMcpServer(options) {
38089
38300
  }
38090
38301
  return reconnectPromise;
38091
38302
  }
38092
- const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? `${homedir5()}/.argent/mcp-calls.log`;
38093
- let logDirReady = false;
38094
- async function spyLog(entry) {
38095
- try {
38096
- if (!logDirReady) {
38097
- await mkdir5(dirname11(LOG_FILE2), { recursive: true });
38098
- logDirReady = true;
38099
- }
38100
- await appendFile(LOG_FILE2, JSON.stringify(entry) + "\n");
38101
- } catch {
38102
- }
38103
- }
38303
+ const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? join19(argentHomeDir(), "mcp-calls.log");
38304
+ const spyLog = createCallLog(LOG_FILE2);
38104
38305
  const { fetchTools, callTool } = createToolCaller({
38105
38306
  getHandle: () => ({ url: TOOLS_URL, token: AUTH_TOKEN }),
38106
38307
  remote,
@@ -38297,7 +38498,7 @@ ${shown.text}` }];
38297
38498
  content = [...content, { type: "text", text: screenshotIdLine(id) }];
38298
38499
  }
38299
38500
  }
38300
- if (udid && autoDescribeOn && canonicalToolId(params.name) === "describe") {
38501
+ if (udid && autoDescribeOn && canonicalToolId(params.name) === "describe" && params.arguments?.raw !== true) {
38301
38502
  const tree = describedTree(result);
38302
38503
  if (tree !== void 0) {
38303
38504
  treeUdid = udid;