@swmansion/argent 0.35.1-next.17 → 0.35.1-next.19

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.
@@ -2990,7 +2990,7 @@ var require_compile = __commonJS({
2990
2990
  const schOrFunc = root.refs[ref];
2991
2991
  if (schOrFunc)
2992
2992
  return schOrFunc;
2993
- let _sch = resolve12.call(this, root, ref);
2993
+ let _sch = resolve13.call(this, root, ref);
2994
2994
  if (_sch === void 0) {
2995
2995
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
2996
2996
  const { schemaId } = this.opts;
@@ -3017,7 +3017,7 @@ var require_compile = __commonJS({
3017
3017
  function sameSchemaEnv(s1, s2) {
3018
3018
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
3019
3019
  }
3020
- function resolve12(root, ref) {
3020
+ function resolve13(root, ref) {
3021
3021
  let sch;
3022
3022
  while (typeof (sch = this.refs[ref]) == "string")
3023
3023
  ref = sch;
@@ -3235,8 +3235,8 @@ var require_utils = __commonJS({
3235
3235
  }
3236
3236
  return ind;
3237
3237
  }
3238
- function removeDotSegments(path18) {
3239
- let input = path18;
3238
+ function removeDotSegments(path19) {
3239
+ let input = path19;
3240
3240
  const output = [];
3241
3241
  let nextSlash = -1;
3242
3242
  let len = 0;
@@ -3488,8 +3488,8 @@ var require_schemes = __commonJS({
3488
3488
  wsComponent.secure = void 0;
3489
3489
  }
3490
3490
  if (wsComponent.resourceName) {
3491
- const [path18, query] = wsComponent.resourceName.split("?");
3492
- wsComponent.path = path18 && path18 !== "/" ? path18 : void 0;
3491
+ const [path19, query] = wsComponent.resourceName.split("?");
3492
+ wsComponent.path = path19 && path19 !== "/" ? path19 : void 0;
3493
3493
  wsComponent.query = query;
3494
3494
  wsComponent.resourceName = void 0;
3495
3495
  }
@@ -3648,7 +3648,7 @@ var require_fast_uri = __commonJS({
3648
3648
  }
3649
3649
  return uri;
3650
3650
  }
3651
- function resolve12(baseURI, relativeURI, options) {
3651
+ function resolve13(baseURI, relativeURI, options) {
3652
3652
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3653
3653
  const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
3654
3654
  schemelessOptions.skipEscape = true;
@@ -3906,7 +3906,7 @@ var require_fast_uri = __commonJS({
3906
3906
  var fastUri = {
3907
3907
  SCHEMES,
3908
3908
  normalize: normalize3,
3909
- resolve: resolve12,
3909
+ resolve: resolve13,
3910
3910
  resolveComponent,
3911
3911
  equal,
3912
3912
  serialize,
@@ -9697,7 +9697,7 @@ var require_compile2 = __commonJS({
9697
9697
  const schOrFunc = root.refs[ref];
9698
9698
  if (schOrFunc)
9699
9699
  return schOrFunc;
9700
- let _sch = resolve12.call(this, root, ref);
9700
+ let _sch = resolve13.call(this, root, ref);
9701
9701
  if (_sch === void 0) {
9702
9702
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
9703
9703
  const { schemaId } = this.opts;
@@ -9724,7 +9724,7 @@ var require_compile2 = __commonJS({
9724
9724
  function sameSchemaEnv(s1, s2) {
9725
9725
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
9726
9726
  }
9727
- function resolve12(root, ref) {
9727
+ function resolve13(root, ref) {
9728
9728
  let sch;
9729
9729
  while (typeof (sch = this.refs[ref]) == "string")
9730
9730
  ref = sch;
@@ -12590,6 +12590,398 @@ var require_dist = __commonJS({
12590
12590
  }
12591
12591
  });
12592
12592
 
12593
+ // ../../node_modules/dotenv/dist/index.cjs
12594
+ var require_dist2 = __commonJS({
12595
+ "../../node_modules/dotenv/dist/index.cjs"(exports, module) {
12596
+ var j = (e, n) => () => {
12597
+ try {
12598
+ return n || e((n = { exports: {} }).exports, n), n.exports;
12599
+ } catch (t) {
12600
+ throw n = 0, t;
12601
+ }
12602
+ };
12603
+ var k = j((xe, U) => {
12604
+ function G(e) {
12605
+ return typeof e == "string" ? !["false", "0", "no", "off", ""].includes(e.toLowerCase()) : !!e;
12606
+ }
12607
+ function Y(e = process.env) {
12608
+ let n = {};
12609
+ for (let t of ["ENCODING", "PATH", "QUIET", "DEBUG", "OVERRIDE", "FAST"]) {
12610
+ let o = e[`DOTENV_${t}`] != null ? e[`DOTENV_${t}`] : e[`DOTENV_CONFIG_${t}`];
12611
+ o != null && (n[t.toLowerCase()] = t === "ENCODING" || t === "PATH" ? o : G(o));
12612
+ }
12613
+ return n;
12614
+ }
12615
+ U.exports = { parseBoolean: G, optionsFromEnv: Y };
12616
+ });
12617
+ var N = j((ye, x) => {
12618
+ var z = __require("fs"), I = __require("path"), Z = __require("os"), { URL: ee, fileURLToPath: te } = __require("url"), { parseBoolean: $, optionsFromEnv: B } = k(), re = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg, b = new Uint8Array(256);
12619
+ for (let e = 48; e <= 57; e++) b[e] = 1;
12620
+ for (let e = 65; e <= 90; e++) b[e] = 1;
12621
+ for (let e = 97; e <= 122; e++) b[e] = 1;
12622
+ b[45] = 1;
12623
+ b[46] = 1;
12624
+ b[95] = 1;
12625
+ function ne(e) {
12626
+ let n = {}, t = e.toString();
12627
+ t = t.replace(/\r\n?/mg, `
12628
+ `);
12629
+ let o;
12630
+ for (; (o = re.exec(t)) != null; ) {
12631
+ let r = o[1], s = o[2] || "";
12632
+ s = s.trim();
12633
+ let i = s[0];
12634
+ s = s.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), i === '"' && (s = s.replace(/\\n/g, `
12635
+ `), s = s.replace(/\\r/g, "\r")), n[r] = s;
12636
+ }
12637
+ return n;
12638
+ }
12639
+ function w(e) {
12640
+ return e <= 32 ? e === 32 || e >= 9 && e <= 13 : e >= 160 && (e === 160 || e === 5760 || e >= 8192 && e <= 8202 || e === 8232 || e === 8233 || e === 8239 || e === 8287 || e === 12288 || e === 65279);
12641
+ }
12642
+ function q(e) {
12643
+ return e === 10 || e === 8232 || e === 8233;
12644
+ }
12645
+ function oe(e) {
12646
+ let n = {}, t = typeof e == "string" ? e : e.toString();
12647
+ t.indexOf("\r") !== -1 && (t = t.replace(/\r\n?/g, `
12648
+ `));
12649
+ let o = t.length, r = 0;
12650
+ for (; r < o; ) {
12651
+ let s = t.charCodeAt(r);
12652
+ for (; r < o && w(s); ) r++, s = t.charCodeAt(r);
12653
+ if (r >= o) break;
12654
+ if (s === 35) {
12655
+ for (; r < o && !q(t.charCodeAt(r)); ) r++;
12656
+ continue;
12657
+ }
12658
+ let i = -1;
12659
+ if (s === 101 && r + 6 < o && t.charCodeAt(r + 1) === 120 && t.charCodeAt(r + 2) === 112 && t.charCodeAt(r + 3) === 111 && t.charCodeAt(r + 4) === 114 && t.charCodeAt(r + 5) === 116) {
12660
+ let v = t.charCodeAt(r + 6);
12661
+ if (w(v)) {
12662
+ let u = r + 7;
12663
+ for (; u < o && w(t.charCodeAt(u)); ) u++;
12664
+ b[t.charCodeAt(u)] && (i = r + 6, r = u);
12665
+ } else s = t.charCodeAt(r);
12666
+ }
12667
+ let l = r, d = 0;
12668
+ for (; r < o && (d = t.charCodeAt(r), b[d]); ) r++;
12669
+ if (r === l) {
12670
+ for (; r < o && !q(t.charCodeAt(r)); ) r++;
12671
+ continue;
12672
+ }
12673
+ let h = t.slice(l, r), f = r;
12674
+ if (r >= o && (d = 0), w(d)) do
12675
+ r++, d = r < o ? t.charCodeAt(r) : 0;
12676
+ while (w(d));
12677
+ if (d === 61) r++;
12678
+ else if (d === 58 && r === f && r + 1 < o && w(t.charCodeAt(r + 1))) r += 2;
12679
+ else {
12680
+ for (r = i === -1 ? f : i; r < o && !q(t.charCodeAt(r)); ) r++;
12681
+ continue;
12682
+ }
12683
+ let c = r, a = r;
12684
+ for (; a < o && w(t.charCodeAt(a)); ) a++;
12685
+ let g = t.charCodeAt(a), p, y = false;
12686
+ if (g === 39 || g === 34 || g === 96) {
12687
+ let v = t[a], u = t.indexOf(v, a + 1), m = -1, C = -1;
12688
+ for (; u !== -1; ) {
12689
+ let O = t.charCodeAt(u - 1) === 92, E = u + 1;
12690
+ for (; E < o && !q(t.charCodeAt(E)) && w(t.charCodeAt(E)); ) E++;
12691
+ if ((E === o || q(t.charCodeAt(E)) || t.charCodeAt(E) === 35) && (m = u, C = E), !O) break;
12692
+ u = t.indexOf(v, u + 1);
12693
+ }
12694
+ if (m !== -1) {
12695
+ if (p = t.slice(a + 1, m), r = C, t.charCodeAt(r) === 35) for (; r < o && !q(t.charCodeAt(r)); ) r++;
12696
+ y = true;
12697
+ }
12698
+ }
12699
+ if (!y) {
12700
+ let v = t.indexOf(`
12701
+ `, c);
12702
+ v === -1 && (v = o);
12703
+ let u;
12704
+ if (o < 4096) u = t.indexOf("#", c), (u === -1 || u > v) && (u = v);
12705
+ else for (u = c; u < v && t.charCodeAt(u) !== 35; ) u++;
12706
+ let m = c, C = u;
12707
+ for (; m < C && w(t.charCodeAt(m)); ) m++;
12708
+ for (; C > m && w(t.charCodeAt(C - 1)); ) C--;
12709
+ let O = t.charCodeAt(m);
12710
+ if (p = t.slice(m, C), p.includes("\u2028") || p.includes("\u2029") ? p = p.replace(/^(['"`])([\s\S]*)\1$/mg, "$2") : C - m >= 2 && (O === 39 || O === 34 || O === 96) && t.charCodeAt(C - 1) === O && (p = t.slice(m + 1, C - 1)), r = u, u < v) for (; r < o && !q(t.charCodeAt(r)); ) r++;
12711
+ }
12712
+ g === 34 && (y || a < r) && p.indexOf("\\") !== -1 && (p = p.replace(/\\n/g, `
12713
+ `).replace(/\\r/g, "\r")), n[h] = p;
12714
+ }
12715
+ return n;
12716
+ }
12717
+ function se(e, n) {
12718
+ return n && $(n.fast) ? oe(e) : ne(e);
12719
+ }
12720
+ function T(e) {
12721
+ console.log(`\u2506 ${e}`);
12722
+ }
12723
+ function ie(e) {
12724
+ console.error(`\u25C7 ${e}`);
12725
+ }
12726
+ function V(e) {
12727
+ return e[0] === "~" ? I.join(Z.homedir(), e.slice(1)) : e;
12728
+ }
12729
+ function ce(e = {}) {
12730
+ let n = { ...e };
12731
+ for (let t of Object.keys(n)) n[t] === void 0 && delete n[t];
12732
+ return { ...B(), ...n };
12733
+ }
12734
+ function ae(e) {
12735
+ e = ce(e);
12736
+ let n = I.resolve(process.cwd(), ".env"), t = "utf8", o = process.env;
12737
+ e && e.processEnv != null && (o = e.processEnv);
12738
+ let r = $(e && e.debug);
12739
+ e && e.encoding ? t = e.encoding : r && T("no encoding is specified (UTF-8 is used by default)");
12740
+ let s = [n];
12741
+ if (e && e.path) if (!Array.isArray(e.path)) s = [V(e.path)];
12742
+ else {
12743
+ s = [];
12744
+ for (let c of e.path) s.push(V(c));
12745
+ }
12746
+ let i, l = {}, d = { fast: e.fast };
12747
+ for (let c of s) try {
12748
+ let a = A.parse(z.readFileSync(c, { encoding: t }), d);
12749
+ A.populate(l, a, e);
12750
+ } catch (a) {
12751
+ r && T(`failed to load ${c} ${a.message}`), i = a;
12752
+ }
12753
+ let h = A.populate(o, l, e), f = $(Object.prototype.hasOwnProperty.call(e, "quiet") ? e.quiet : B(o).quiet);
12754
+ if (r || !f) {
12755
+ let c = Object.keys(h).length, a = [];
12756
+ for (let g of s) try {
12757
+ let p = I.relative(process.cwd(), g instanceof ee ? te(g) : g);
12758
+ a.push(p);
12759
+ } catch (p) {
12760
+ r && T(`failed to load ${g} ${p.message}`), i = p;
12761
+ }
12762
+ ie(`injected env (${c}) from ${a.join(",")}`);
12763
+ }
12764
+ return i ? { parsed: l, error: i } : { parsed: l };
12765
+ }
12766
+ function le(e) {
12767
+ return A.configDotenv(e);
12768
+ }
12769
+ function fe(e, n, t = {}) {
12770
+ let o = $(t && t.debug), r = $(t && t.override), s = {};
12771
+ if (e === null || typeof e != "object" || n === null || typeof n != "object") {
12772
+ let i = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
12773
+ throw i.code = "OBJECT_REQUIRED", i;
12774
+ }
12775
+ for (let i of Object.keys(n)) Object.prototype.hasOwnProperty.call(e, i) ? (r === true && (e[i] = n[i], s[i] = n[i]), o && T(r === true ? `"${i}" is already defined and WAS overwritten` : `"${i}" is already defined and was NOT overwritten`)) : (e[i] = n[i], s[i] = n[i]);
12776
+ return s;
12777
+ }
12778
+ var A = { configDotenv: ae, config: le, parse: se, populate: fe };
12779
+ x.exports.configDotenv = A.configDotenv;
12780
+ x.exports.config = A.config;
12781
+ x.exports.parse = A.parse;
12782
+ x.exports.populate = A.populate;
12783
+ x.exports = A;
12784
+ });
12785
+ var M = j((Te, W) => {
12786
+ var _ = __require("child_process"), ue = __require("fs"), L = __require("path");
12787
+ function de(e) {
12788
+ let n = ['"'], t = 0;
12789
+ for (let o of e) {
12790
+ if (o === "\\") {
12791
+ t++;
12792
+ continue;
12793
+ }
12794
+ o === '"' ? n.push("\\".repeat(t * 2 + 1), '"') : n.push("\\".repeat(t), o), t = 0;
12795
+ }
12796
+ return n.push("\\".repeat(t * 2), '"'), n.join("");
12797
+ }
12798
+ function H(e, n = 1) {
12799
+ for (let t = 0; t < n; t++) {
12800
+ let o = [];
12801
+ for (let r of e) {
12802
+ let s = r.charCodeAt(0), i = s >= 48 && s <= 57 || s >= 65 && s <= 90 || s >= 97 && s <= 122, l = "\\/:._-".includes(r);
12803
+ !i && !l && s < 128 && o.push("^"), o.push(r);
12804
+ }
12805
+ e = o.join("");
12806
+ }
12807
+ return e;
12808
+ }
12809
+ function P(e, n) {
12810
+ let t = Object.keys(e).reverse().find((o) => o.toUpperCase() === n);
12811
+ return t === void 0 ? void 0 : e[t];
12812
+ }
12813
+ function pe(e, n, t) {
12814
+ let o = (P(n, "PATHEXT") || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean), s = o.some((l) => e.toLowerCase().endsWith(l.toLowerCase())) ? ["", ...o] : [...o, ""], i = /[\\/]/.test(e) ? [t] : [t, ...(P(n, "PATH") || "").split(";")];
12815
+ for (let l of i) for (let d of s) {
12816
+ let h = L.resolve(t, l.replace(/^"|"$/g, ""), e + d);
12817
+ try {
12818
+ if (ue.statSync(h).isFile()) return h;
12819
+ } catch {
12820
+ }
12821
+ }
12822
+ }
12823
+ function he(e, n, t) {
12824
+ if (process.platform !== "win32") return _.spawn(e, n, t);
12825
+ let o = t.env || process.env, r = pe(e, o, t.cwd || process.cwd());
12826
+ if (r && /\.(?:exe|com)$/i.test(r)) return _.spawn(r, n, t);
12827
+ let s = /\.(?:bat|cmd)$/i.test(r || e), i = [H(L.normalize(r || e))];
12828
+ for (let d of n) i.push(H(de(d), s ? 2 : 1));
12829
+ let l = i.join(" ");
12830
+ return _.spawn(P(o, "COMSPEC") || "cmd.exe", ["/d", "/v:off", "/s", "/c", `"${l}"`], { ...t, windowsVerbatimArguments: true });
12831
+ }
12832
+ W.exports = he;
12833
+ });
12834
+ var X = j(($e, F) => {
12835
+ var ge = __require("fs"), me = __require("os"), Q = __require("path"), ve = __require("child_process"), Ce = M(), R = N(), { optionsFromEnv: J } = k();
12836
+ function D() {
12837
+ console.log(["Usage: dotenv run [--help] [-q|--quiet] [--debug] [--override] [--fast] [-f|--file <paths>] [--] <command> [args...]", "", "Run a command with environment variables from a .env file.", "Place dotenv options before the command; all following arguments go to the command.", "", "Options:", " -f, --file <paths> .env paths, comma-separated or repeated (default: .env)", " -q, --quiet suppress the injected env message", " --debug enable debug logging", " --override override existing environment variables", " --fast use the faster character-scanner parser", "", "Environment variables (DOTENV_CONFIG_* names remain as fallbacks):", " DOTENV_PATH, DOTENV_ENCODING, DOTENV_QUIET,", " DOTENV_DEBUG, DOTENV_OVERRIDE,", " DOTENV_FAST"].join(`
12838
+ `));
12839
+ }
12840
+ function we(e) {
12841
+ let n = [], t = false, o, r, s, i, l = -1;
12842
+ for (let h = 0; h < e.length; h++) {
12843
+ let f = e[h];
12844
+ if (f === "--") {
12845
+ l = h + 1;
12846
+ break;
12847
+ }
12848
+ if (f === "--help" || f === "-h") return { help: true };
12849
+ if (f === "--quiet" || f === "-q") {
12850
+ o = true;
12851
+ continue;
12852
+ }
12853
+ if (f === "--debug") {
12854
+ r = true;
12855
+ continue;
12856
+ }
12857
+ if (f === "--override") {
12858
+ s = true;
12859
+ continue;
12860
+ }
12861
+ if (f === "--fast") {
12862
+ i = true;
12863
+ continue;
12864
+ }
12865
+ if (f === "-f" || f === "--file" || f.startsWith("-f=") || f.startsWith("--file=")) {
12866
+ let c = f.indexOf("="), a = c === -1 ? f : f.slice(0, c), g = c === -1 ? e[++h] : f.slice(c + 1);
12867
+ if (!g || g === "--") return { error: `${a} requires a path` };
12868
+ let p = g.split(",").map((y) => y.trim()).filter(Boolean);
12869
+ if (p.length === 0) return { error: `${a} requires a path` };
12870
+ n.push(...p), t = true;
12871
+ continue;
12872
+ }
12873
+ if (f.startsWith("-")) return { error: `unknown option: ${f}` };
12874
+ l = h;
12875
+ break;
12876
+ }
12877
+ let d = l === -1 ? [] : e.slice(l);
12878
+ return { paths: n, pathSet: t, quiet: o, debug: r, override: s, fast: i, command: d };
12879
+ }
12880
+ function Ae(e) {
12881
+ return e[0] === "~" ? Q.join(me.homedir(), e.slice(1)) : e;
12882
+ }
12883
+ function Ee(e) {
12884
+ let n = J(), t = { encoding: n.encoding || "utf8", quiet: n.quiet, debug: n.debug === true, override: n.override === true, fast: n.fast === true, paths: [".env"], defaultPath: true };
12885
+ return n.path != null && (t.paths = [n.path], t.defaultPath = false), e.pathSet && (t.paths = e.paths, t.defaultPath = false), e.quiet != null && (t.quiet = e.quiet), e.debug != null && (t.debug = e.debug), e.override != null && (t.override = e.override), e.fast != null && (t.fast = e.fast), t;
12886
+ }
12887
+ function be(e) {
12888
+ let n = {}, t = [], o = { override: e.override, debug: e.debug };
12889
+ for (let s of e.paths) {
12890
+ let i = Q.resolve(process.cwd(), Ae(s));
12891
+ try {
12892
+ let l = R.parse(ge.readFileSync(i, { encoding: e.encoding }), { fast: e.fast });
12893
+ R.populate(n, l, o), t.push(s);
12894
+ } catch (l) {
12895
+ if (e.debug && console.log(`\u2506 failed to load ${s} ${l.message}`), !(e.defaultPath && l.code === "ENOENT")) throw l;
12896
+ }
12897
+ }
12898
+ return { injected: R.populate(process.env, n, o), loadedPaths: t };
12899
+ }
12900
+ function K(e) {
12901
+ let n = e[0];
12902
+ if (n === "--help" || n === "-h") {
12903
+ D();
12904
+ return;
12905
+ }
12906
+ if (n !== "run") {
12907
+ D(), process.exitCode = 1;
12908
+ return;
12909
+ }
12910
+ let t = we(e.slice(1));
12911
+ if (t.help) {
12912
+ D();
12913
+ return;
12914
+ }
12915
+ if (t.error) {
12916
+ console.error(`dotenv: ${t.error}`), D(), process.exitCode = 1;
12917
+ return;
12918
+ }
12919
+ if (t.command.length === 0) {
12920
+ D(), process.exitCode = 1;
12921
+ return;
12922
+ }
12923
+ let o = Ee(t);
12924
+ try {
12925
+ let c = be(o);
12926
+ if (!(o.quiet == null ? J().quiet : o.quiet)) {
12927
+ let g = `\u25C7 injected env (${Object.keys(c.injected).length})`;
12928
+ c.loadedPaths.length > 0 && (g += ` from ${c.loadedPaths.join(", ")}`), console.error(g);
12929
+ }
12930
+ } catch (c) {
12931
+ console.error(`dotenv: ${c.message}`), process.exitCode = 1;
12932
+ return;
12933
+ }
12934
+ let r = !!process.stdin.isTTY, s = process.platform !== "win32" && !r, i = Ce(t.command[0], t.command.slice(1), { stdio: "inherit", detached: s }), l = /* @__PURE__ */ new Map(), d = 0;
12935
+ function h(c) {
12936
+ if (!(!i.pid || i.exitCode !== null || i.signalCode !== null)) {
12937
+ if (process.platform === "win32") {
12938
+ ve.spawnSync("taskkill", ["/pid", String(i.pid), "/T", "/F"], { stdio: "ignore" });
12939
+ return;
12940
+ }
12941
+ try {
12942
+ process.kill(s ? -i.pid : i.pid, c);
12943
+ } catch (a) {
12944
+ if (a.code !== "ESRCH") throw a;
12945
+ }
12946
+ }
12947
+ }
12948
+ function f() {
12949
+ for (let [c, a] of l) process.removeListener(c, a);
12950
+ }
12951
+ for (let c of ["SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT"]) {
12952
+ let a = () => {
12953
+ if (c === "SIGINT") {
12954
+ if (d++, r && process.platform !== "win32" && d === 1) return;
12955
+ if (d > 1) {
12956
+ h(d === 2 ? "SIGTERM" : "SIGKILL");
12957
+ return;
12958
+ }
12959
+ }
12960
+ h(c);
12961
+ };
12962
+ l.set(c, a), process.on(c, a);
12963
+ }
12964
+ i.on("error", function(c) {
12965
+ f(), console.error(`dotenv: ${c.message}`), process.exitCode = 1;
12966
+ }), i.on("exit", function(c, a) {
12967
+ f(), typeof c == "number" ? process.exit(c) : (setInterval(() => {
12968
+ }, 1e3), process.kill(process.pid, a));
12969
+ });
12970
+ }
12971
+ F.exports = K;
12972
+ __require.main === F && K(process.argv.slice(2));
12973
+ });
12974
+ var S = N();
12975
+ var qe = X();
12976
+ module.exports = S;
12977
+ module.exports.config = S.config;
12978
+ module.exports.configDotenv = S.configDotenv;
12979
+ module.exports.parse = S.parse;
12980
+ module.exports.populate = S.populate;
12981
+ __require.main === module && qe(process.argv.slice(2));
12982
+ }
12983
+ });
12984
+
12593
12985
  // ../../node_modules/yaml/dist/nodes/identity.js
12594
12986
  var require_identity = __commonJS({
12595
12987
  "../../node_modules/yaml/dist/nodes/identity.js"(exports) {
@@ -12667,17 +13059,17 @@ var require_visit = __commonJS({
12667
13059
  visit.BREAK = BREAK;
12668
13060
  visit.SKIP = SKIP;
12669
13061
  visit.REMOVE = REMOVE;
12670
- function visit_(key, node2, visitor, path18) {
12671
- const ctrl = callVisitor(key, node2, visitor, path18);
13062
+ function visit_(key, node2, visitor, path19) {
13063
+ const ctrl = callVisitor(key, node2, visitor, path19);
12672
13064
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
12673
- replaceNode(key, path18, ctrl);
12674
- return visit_(key, ctrl, visitor, path18);
13065
+ replaceNode(key, path19, ctrl);
13066
+ return visit_(key, ctrl, visitor, path19);
12675
13067
  }
12676
13068
  if (typeof ctrl !== "symbol") {
12677
13069
  if (identity.isCollection(node2)) {
12678
- path18 = Object.freeze(path18.concat(node2));
13070
+ path19 = Object.freeze(path19.concat(node2));
12679
13071
  for (let i = 0; i < node2.items.length; ++i) {
12680
- const ci = visit_(i, node2.items[i], visitor, path18);
13072
+ const ci = visit_(i, node2.items[i], visitor, path19);
12681
13073
  if (typeof ci === "number")
12682
13074
  i = ci - 1;
12683
13075
  else if (ci === BREAK)
@@ -12688,13 +13080,13 @@ var require_visit = __commonJS({
12688
13080
  }
12689
13081
  }
12690
13082
  } else if (identity.isPair(node2)) {
12691
- path18 = Object.freeze(path18.concat(node2));
12692
- const ck = visit_("key", node2.key, visitor, path18);
13083
+ path19 = Object.freeze(path19.concat(node2));
13084
+ const ck = visit_("key", node2.key, visitor, path19);
12693
13085
  if (ck === BREAK)
12694
13086
  return BREAK;
12695
13087
  else if (ck === REMOVE)
12696
13088
  node2.key = null;
12697
- const cv = visit_("value", node2.value, visitor, path18);
13089
+ const cv = visit_("value", node2.value, visitor, path19);
12698
13090
  if (cv === BREAK)
12699
13091
  return BREAK;
12700
13092
  else if (cv === REMOVE)
@@ -12715,17 +13107,17 @@ var require_visit = __commonJS({
12715
13107
  visitAsync.BREAK = BREAK;
12716
13108
  visitAsync.SKIP = SKIP;
12717
13109
  visitAsync.REMOVE = REMOVE;
12718
- async function visitAsync_(key, node2, visitor, path18) {
12719
- const ctrl = await callVisitor(key, node2, visitor, path18);
13110
+ async function visitAsync_(key, node2, visitor, path19) {
13111
+ const ctrl = await callVisitor(key, node2, visitor, path19);
12720
13112
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
12721
- replaceNode(key, path18, ctrl);
12722
- return visitAsync_(key, ctrl, visitor, path18);
13113
+ replaceNode(key, path19, ctrl);
13114
+ return visitAsync_(key, ctrl, visitor, path19);
12723
13115
  }
12724
13116
  if (typeof ctrl !== "symbol") {
12725
13117
  if (identity.isCollection(node2)) {
12726
- path18 = Object.freeze(path18.concat(node2));
13118
+ path19 = Object.freeze(path19.concat(node2));
12727
13119
  for (let i = 0; i < node2.items.length; ++i) {
12728
- const ci = await visitAsync_(i, node2.items[i], visitor, path18);
13120
+ const ci = await visitAsync_(i, node2.items[i], visitor, path19);
12729
13121
  if (typeof ci === "number")
12730
13122
  i = ci - 1;
12731
13123
  else if (ci === BREAK)
@@ -12736,13 +13128,13 @@ var require_visit = __commonJS({
12736
13128
  }
12737
13129
  }
12738
13130
  } else if (identity.isPair(node2)) {
12739
- path18 = Object.freeze(path18.concat(node2));
12740
- const ck = await visitAsync_("key", node2.key, visitor, path18);
13131
+ path19 = Object.freeze(path19.concat(node2));
13132
+ const ck = await visitAsync_("key", node2.key, visitor, path19);
12741
13133
  if (ck === BREAK)
12742
13134
  return BREAK;
12743
13135
  else if (ck === REMOVE)
12744
13136
  node2.key = null;
12745
- const cv = await visitAsync_("value", node2.value, visitor, path18);
13137
+ const cv = await visitAsync_("value", node2.value, visitor, path19);
12746
13138
  if (cv === BREAK)
12747
13139
  return BREAK;
12748
13140
  else if (cv === REMOVE)
@@ -12769,23 +13161,23 @@ var require_visit = __commonJS({
12769
13161
  }
12770
13162
  return visitor;
12771
13163
  }
12772
- function callVisitor(key, node2, visitor, path18) {
13164
+ function callVisitor(key, node2, visitor, path19) {
12773
13165
  if (typeof visitor === "function")
12774
- return visitor(key, node2, path18);
13166
+ return visitor(key, node2, path19);
12775
13167
  if (identity.isMap(node2))
12776
- return visitor.Map?.(key, node2, path18);
13168
+ return visitor.Map?.(key, node2, path19);
12777
13169
  if (identity.isSeq(node2))
12778
- return visitor.Seq?.(key, node2, path18);
13170
+ return visitor.Seq?.(key, node2, path19);
12779
13171
  if (identity.isPair(node2))
12780
- return visitor.Pair?.(key, node2, path18);
13172
+ return visitor.Pair?.(key, node2, path19);
12781
13173
  if (identity.isScalar(node2))
12782
- return visitor.Scalar?.(key, node2, path18);
13174
+ return visitor.Scalar?.(key, node2, path19);
12783
13175
  if (identity.isAlias(node2))
12784
- return visitor.Alias?.(key, node2, path18);
13176
+ return visitor.Alias?.(key, node2, path19);
12785
13177
  return void 0;
12786
13178
  }
12787
- function replaceNode(key, path18, node2) {
12788
- const parent = path18[path18.length - 1];
13179
+ function replaceNode(key, path19, node2) {
13180
+ const parent = path19[path19.length - 1];
12789
13181
  if (identity.isCollection(parent)) {
12790
13182
  parent.items[key] = node2;
12791
13183
  } else if (identity.isPair(parent)) {
@@ -13397,10 +13789,10 @@ var require_Collection = __commonJS({
13397
13789
  var createNode = require_createNode();
13398
13790
  var identity = require_identity();
13399
13791
  var Node = require_Node();
13400
- function collectionFromPath(schema, path18, value) {
13792
+ function collectionFromPath(schema, path19, value) {
13401
13793
  let v = value;
13402
- for (let i = path18.length - 1; i >= 0; --i) {
13403
- const k = path18[i];
13794
+ for (let i = path19.length - 1; i >= 0; --i) {
13795
+ const k = path19[i];
13404
13796
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
13405
13797
  const a = [];
13406
13798
  a[k] = v;
@@ -13419,7 +13811,7 @@ var require_Collection = __commonJS({
13419
13811
  sourceObjects: /* @__PURE__ */ new Map()
13420
13812
  });
13421
13813
  }
13422
- var isEmptyPath = (path18) => path18 == null || typeof path18 === "object" && !!path18[Symbol.iterator]().next().done;
13814
+ var isEmptyPath = (path19) => path19 == null || typeof path19 === "object" && !!path19[Symbol.iterator]().next().done;
13423
13815
  var Collection = class extends Node.NodeBase {
13424
13816
  constructor(type, schema) {
13425
13817
  super(type);
@@ -13449,11 +13841,11 @@ var require_Collection = __commonJS({
13449
13841
  * be a Pair instance or a `{ key, value }` object, which may not have a key
13450
13842
  * that already exists in the map.
13451
13843
  */
13452
- addIn(path18, value) {
13453
- if (isEmptyPath(path18))
13844
+ addIn(path19, value) {
13845
+ if (isEmptyPath(path19))
13454
13846
  this.add(value);
13455
13847
  else {
13456
- const [key, ...rest] = path18;
13848
+ const [key, ...rest] = path19;
13457
13849
  const node2 = this.get(key, true);
13458
13850
  if (identity.isCollection(node2))
13459
13851
  node2.addIn(rest, value);
@@ -13467,8 +13859,8 @@ var require_Collection = __commonJS({
13467
13859
  * Removes a value from the collection.
13468
13860
  * @returns `true` if the item was found and removed.
13469
13861
  */
13470
- deleteIn(path18) {
13471
- const [key, ...rest] = path18;
13862
+ deleteIn(path19) {
13863
+ const [key, ...rest] = path19;
13472
13864
  if (rest.length === 0)
13473
13865
  return this.delete(key);
13474
13866
  const node2 = this.get(key, true);
@@ -13482,8 +13874,8 @@ var require_Collection = __commonJS({
13482
13874
  * scalar values from their surrounding node; to disable set `keepScalar` to
13483
13875
  * `true` (collections are always returned intact).
13484
13876
  */
13485
- getIn(path18, keepScalar) {
13486
- const [key, ...rest] = path18;
13877
+ getIn(path19, keepScalar) {
13878
+ const [key, ...rest] = path19;
13487
13879
  const node2 = this.get(key, true);
13488
13880
  if (rest.length === 0)
13489
13881
  return !keepScalar && identity.isScalar(node2) ? node2.value : node2;
@@ -13501,8 +13893,8 @@ var require_Collection = __commonJS({
13501
13893
  /**
13502
13894
  * Checks if the collection includes a value with the key `key`.
13503
13895
  */
13504
- hasIn(path18) {
13505
- const [key, ...rest] = path18;
13896
+ hasIn(path19) {
13897
+ const [key, ...rest] = path19;
13506
13898
  if (rest.length === 0)
13507
13899
  return this.has(key);
13508
13900
  const node2 = this.get(key, true);
@@ -13512,8 +13904,8 @@ var require_Collection = __commonJS({
13512
13904
  * Sets a value in this collection. For `!!set`, `value` needs to be a
13513
13905
  * boolean to add/remove the item from the set.
13514
13906
  */
13515
- setIn(path18, value) {
13516
- const [key, ...rest] = path18;
13907
+ setIn(path19, value) {
13908
+ const [key, ...rest] = path19;
13517
13909
  if (rest.length === 0) {
13518
13910
  this.set(key, value);
13519
13911
  } else {
@@ -16028,9 +16420,9 @@ var require_Document = __commonJS({
16028
16420
  this.contents.add(value);
16029
16421
  }
16030
16422
  /** Adds a value to the document. */
16031
- addIn(path18, value) {
16423
+ addIn(path19, value) {
16032
16424
  if (assertCollection(this.contents))
16033
- this.contents.addIn(path18, value);
16425
+ this.contents.addIn(path19, value);
16034
16426
  }
16035
16427
  /**
16036
16428
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -16105,14 +16497,14 @@ var require_Document = __commonJS({
16105
16497
  * Removes a value from the document.
16106
16498
  * @returns `true` if the item was found and removed.
16107
16499
  */
16108
- deleteIn(path18) {
16109
- if (Collection.isEmptyPath(path18)) {
16500
+ deleteIn(path19) {
16501
+ if (Collection.isEmptyPath(path19)) {
16110
16502
  if (this.contents == null)
16111
16503
  return false;
16112
16504
  this.contents = null;
16113
16505
  return true;
16114
16506
  }
16115
- return assertCollection(this.contents) ? this.contents.deleteIn(path18) : false;
16507
+ return assertCollection(this.contents) ? this.contents.deleteIn(path19) : false;
16116
16508
  }
16117
16509
  /**
16118
16510
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -16127,10 +16519,10 @@ var require_Document = __commonJS({
16127
16519
  * scalar values from their surrounding node; to disable set `keepScalar` to
16128
16520
  * `true` (collections are always returned intact).
16129
16521
  */
16130
- getIn(path18, keepScalar) {
16131
- if (Collection.isEmptyPath(path18))
16522
+ getIn(path19, keepScalar) {
16523
+ if (Collection.isEmptyPath(path19))
16132
16524
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
16133
- return identity.isCollection(this.contents) ? this.contents.getIn(path18, keepScalar) : void 0;
16525
+ return identity.isCollection(this.contents) ? this.contents.getIn(path19, keepScalar) : void 0;
16134
16526
  }
16135
16527
  /**
16136
16528
  * Checks if the document includes a value with the key `key`.
@@ -16141,10 +16533,10 @@ var require_Document = __commonJS({
16141
16533
  /**
16142
16534
  * Checks if the document includes a value at `path`.
16143
16535
  */
16144
- hasIn(path18) {
16145
- if (Collection.isEmptyPath(path18))
16536
+ hasIn(path19) {
16537
+ if (Collection.isEmptyPath(path19))
16146
16538
  return this.contents !== void 0;
16147
- return identity.isCollection(this.contents) ? this.contents.hasIn(path18) : false;
16539
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path19) : false;
16148
16540
  }
16149
16541
  /**
16150
16542
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -16161,13 +16553,13 @@ var require_Document = __commonJS({
16161
16553
  * Sets a value in this document. For `!!set`, `value` needs to be a
16162
16554
  * boolean to add/remove the item from the set.
16163
16555
  */
16164
- setIn(path18, value) {
16165
- if (Collection.isEmptyPath(path18)) {
16556
+ setIn(path19, value) {
16557
+ if (Collection.isEmptyPath(path19)) {
16166
16558
  this.contents = value;
16167
16559
  } else if (this.contents == null) {
16168
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path18), value);
16560
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path19), value);
16169
16561
  } else if (assertCollection(this.contents)) {
16170
- this.contents.setIn(path18, value);
16562
+ this.contents.setIn(path19, value);
16171
16563
  }
16172
16564
  }
16173
16565
  /**
@@ -18128,9 +18520,9 @@ var require_cst_visit = __commonJS({
18128
18520
  visit.BREAK = BREAK;
18129
18521
  visit.SKIP = SKIP;
18130
18522
  visit.REMOVE = REMOVE;
18131
- visit.itemAtPath = (cst, path18) => {
18523
+ visit.itemAtPath = (cst, path19) => {
18132
18524
  let item = cst;
18133
- for (const [field, index] of path18) {
18525
+ for (const [field, index] of path19) {
18134
18526
  const tok = item?.[field];
18135
18527
  if (tok && "items" in tok) {
18136
18528
  item = tok.items[index];
@@ -18139,23 +18531,23 @@ var require_cst_visit = __commonJS({
18139
18531
  }
18140
18532
  return item;
18141
18533
  };
18142
- visit.parentCollection = (cst, path18) => {
18143
- const parent = visit.itemAtPath(cst, path18.slice(0, -1));
18144
- const field = path18[path18.length - 1][0];
18534
+ visit.parentCollection = (cst, path19) => {
18535
+ const parent = visit.itemAtPath(cst, path19.slice(0, -1));
18536
+ const field = path19[path19.length - 1][0];
18145
18537
  const coll = parent?.[field];
18146
18538
  if (coll && "items" in coll)
18147
18539
  return coll;
18148
18540
  throw new Error("Parent collection not found");
18149
18541
  };
18150
- function _visit(path18, item, visitor) {
18151
- let ctrl = visitor(item, path18);
18542
+ function _visit(path19, item, visitor) {
18543
+ let ctrl = visitor(item, path19);
18152
18544
  if (typeof ctrl === "symbol")
18153
18545
  return ctrl;
18154
18546
  for (const field of ["key", "value"]) {
18155
18547
  const token = item[field];
18156
18548
  if (token && "items" in token) {
18157
18549
  for (let i = 0; i < token.items.length; ++i) {
18158
- const ci = _visit(Object.freeze(path18.concat([[field, i]])), token.items[i], visitor);
18550
+ const ci = _visit(Object.freeze(path19.concat([[field, i]])), token.items[i], visitor);
18159
18551
  if (typeof ci === "number")
18160
18552
  i = ci - 1;
18161
18553
  else if (ci === BREAK)
@@ -18166,10 +18558,10 @@ var require_cst_visit = __commonJS({
18166
18558
  }
18167
18559
  }
18168
18560
  if (typeof ctrl === "function" && field === "key")
18169
- ctrl = ctrl(item, path18);
18561
+ ctrl = ctrl(item, path19);
18170
18562
  }
18171
18563
  }
18172
- return typeof ctrl === "function" ? ctrl(item, path18) : ctrl;
18564
+ return typeof ctrl === "function" ? ctrl(item, path19) : ctrl;
18173
18565
  }
18174
18566
  exports.visit = visit;
18175
18567
  }
@@ -19869,7 +20261,7 @@ var require_public_api = __commonJS({
19869
20261
  });
19870
20262
 
19871
20263
  // ../../node_modules/yaml/dist/index.js
19872
- var require_dist2 = __commonJS({
20264
+ var require_dist3 = __commonJS({
19873
20265
  "../../node_modules/yaml/dist/index.js"(exports) {
19874
20266
  "use strict";
19875
20267
  var composer = require_composer();
@@ -19920,398 +20312,6 @@ var require_dist2 = __commonJS({
19920
20312
  }
19921
20313
  });
19922
20314
 
19923
- // ../../node_modules/dotenv/dist/index.cjs
19924
- var require_dist3 = __commonJS({
19925
- "../../node_modules/dotenv/dist/index.cjs"(exports, module) {
19926
- var j = (e, n) => () => {
19927
- try {
19928
- return n || e((n = { exports: {} }).exports, n), n.exports;
19929
- } catch (t) {
19930
- throw n = 0, t;
19931
- }
19932
- };
19933
- var k = j((xe, U) => {
19934
- function G(e) {
19935
- return typeof e == "string" ? !["false", "0", "no", "off", ""].includes(e.toLowerCase()) : !!e;
19936
- }
19937
- function Y(e = process.env) {
19938
- let n = {};
19939
- for (let t of ["ENCODING", "PATH", "QUIET", "DEBUG", "OVERRIDE", "FAST"]) {
19940
- let o = e[`DOTENV_${t}`] != null ? e[`DOTENV_${t}`] : e[`DOTENV_CONFIG_${t}`];
19941
- o != null && (n[t.toLowerCase()] = t === "ENCODING" || t === "PATH" ? o : G(o));
19942
- }
19943
- return n;
19944
- }
19945
- U.exports = { parseBoolean: G, optionsFromEnv: Y };
19946
- });
19947
- var N = j((ye, x) => {
19948
- var z = __require("fs"), I = __require("path"), Z = __require("os"), { URL: ee, fileURLToPath: te } = __require("url"), { parseBoolean: $, optionsFromEnv: B } = k(), re = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg, b = new Uint8Array(256);
19949
- for (let e = 48; e <= 57; e++) b[e] = 1;
19950
- for (let e = 65; e <= 90; e++) b[e] = 1;
19951
- for (let e = 97; e <= 122; e++) b[e] = 1;
19952
- b[45] = 1;
19953
- b[46] = 1;
19954
- b[95] = 1;
19955
- function ne(e) {
19956
- let n = {}, t = e.toString();
19957
- t = t.replace(/\r\n?/mg, `
19958
- `);
19959
- let o;
19960
- for (; (o = re.exec(t)) != null; ) {
19961
- let r = o[1], s = o[2] || "";
19962
- s = s.trim();
19963
- let i = s[0];
19964
- s = s.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), i === '"' && (s = s.replace(/\\n/g, `
19965
- `), s = s.replace(/\\r/g, "\r")), n[r] = s;
19966
- }
19967
- return n;
19968
- }
19969
- function w(e) {
19970
- return e <= 32 ? e === 32 || e >= 9 && e <= 13 : e >= 160 && (e === 160 || e === 5760 || e >= 8192 && e <= 8202 || e === 8232 || e === 8233 || e === 8239 || e === 8287 || e === 12288 || e === 65279);
19971
- }
19972
- function q(e) {
19973
- return e === 10 || e === 8232 || e === 8233;
19974
- }
19975
- function oe(e) {
19976
- let n = {}, t = typeof e == "string" ? e : e.toString();
19977
- t.indexOf("\r") !== -1 && (t = t.replace(/\r\n?/g, `
19978
- `));
19979
- let o = t.length, r = 0;
19980
- for (; r < o; ) {
19981
- let s = t.charCodeAt(r);
19982
- for (; r < o && w(s); ) r++, s = t.charCodeAt(r);
19983
- if (r >= o) break;
19984
- if (s === 35) {
19985
- for (; r < o && !q(t.charCodeAt(r)); ) r++;
19986
- continue;
19987
- }
19988
- let i = -1;
19989
- if (s === 101 && r + 6 < o && t.charCodeAt(r + 1) === 120 && t.charCodeAt(r + 2) === 112 && t.charCodeAt(r + 3) === 111 && t.charCodeAt(r + 4) === 114 && t.charCodeAt(r + 5) === 116) {
19990
- let v = t.charCodeAt(r + 6);
19991
- if (w(v)) {
19992
- let u = r + 7;
19993
- for (; u < o && w(t.charCodeAt(u)); ) u++;
19994
- b[t.charCodeAt(u)] && (i = r + 6, r = u);
19995
- } else s = t.charCodeAt(r);
19996
- }
19997
- let l = r, d = 0;
19998
- for (; r < o && (d = t.charCodeAt(r), b[d]); ) r++;
19999
- if (r === l) {
20000
- for (; r < o && !q(t.charCodeAt(r)); ) r++;
20001
- continue;
20002
- }
20003
- let h = t.slice(l, r), f = r;
20004
- if (r >= o && (d = 0), w(d)) do
20005
- r++, d = r < o ? t.charCodeAt(r) : 0;
20006
- while (w(d));
20007
- if (d === 61) r++;
20008
- else if (d === 58 && r === f && r + 1 < o && w(t.charCodeAt(r + 1))) r += 2;
20009
- else {
20010
- for (r = i === -1 ? f : i; r < o && !q(t.charCodeAt(r)); ) r++;
20011
- continue;
20012
- }
20013
- let c = r, a = r;
20014
- for (; a < o && w(t.charCodeAt(a)); ) a++;
20015
- let g = t.charCodeAt(a), p, y = false;
20016
- if (g === 39 || g === 34 || g === 96) {
20017
- let v = t[a], u = t.indexOf(v, a + 1), m = -1, C = -1;
20018
- for (; u !== -1; ) {
20019
- let O = t.charCodeAt(u - 1) === 92, E = u + 1;
20020
- for (; E < o && !q(t.charCodeAt(E)) && w(t.charCodeAt(E)); ) E++;
20021
- if ((E === o || q(t.charCodeAt(E)) || t.charCodeAt(E) === 35) && (m = u, C = E), !O) break;
20022
- u = t.indexOf(v, u + 1);
20023
- }
20024
- if (m !== -1) {
20025
- if (p = t.slice(a + 1, m), r = C, t.charCodeAt(r) === 35) for (; r < o && !q(t.charCodeAt(r)); ) r++;
20026
- y = true;
20027
- }
20028
- }
20029
- if (!y) {
20030
- let v = t.indexOf(`
20031
- `, c);
20032
- v === -1 && (v = o);
20033
- let u;
20034
- if (o < 4096) u = t.indexOf("#", c), (u === -1 || u > v) && (u = v);
20035
- else for (u = c; u < v && t.charCodeAt(u) !== 35; ) u++;
20036
- let m = c, C = u;
20037
- for (; m < C && w(t.charCodeAt(m)); ) m++;
20038
- for (; C > m && w(t.charCodeAt(C - 1)); ) C--;
20039
- let O = t.charCodeAt(m);
20040
- if (p = t.slice(m, C), p.includes("\u2028") || p.includes("\u2029") ? p = p.replace(/^(['"`])([\s\S]*)\1$/mg, "$2") : C - m >= 2 && (O === 39 || O === 34 || O === 96) && t.charCodeAt(C - 1) === O && (p = t.slice(m + 1, C - 1)), r = u, u < v) for (; r < o && !q(t.charCodeAt(r)); ) r++;
20041
- }
20042
- g === 34 && (y || a < r) && p.indexOf("\\") !== -1 && (p = p.replace(/\\n/g, `
20043
- `).replace(/\\r/g, "\r")), n[h] = p;
20044
- }
20045
- return n;
20046
- }
20047
- function se(e, n) {
20048
- return n && $(n.fast) ? oe(e) : ne(e);
20049
- }
20050
- function T(e) {
20051
- console.log(`\u2506 ${e}`);
20052
- }
20053
- function ie(e) {
20054
- console.error(`\u25C7 ${e}`);
20055
- }
20056
- function V(e) {
20057
- return e[0] === "~" ? I.join(Z.homedir(), e.slice(1)) : e;
20058
- }
20059
- function ce(e = {}) {
20060
- let n = { ...e };
20061
- for (let t of Object.keys(n)) n[t] === void 0 && delete n[t];
20062
- return { ...B(), ...n };
20063
- }
20064
- function ae(e) {
20065
- e = ce(e);
20066
- let n = I.resolve(process.cwd(), ".env"), t = "utf8", o = process.env;
20067
- e && e.processEnv != null && (o = e.processEnv);
20068
- let r = $(e && e.debug);
20069
- e && e.encoding ? t = e.encoding : r && T("no encoding is specified (UTF-8 is used by default)");
20070
- let s = [n];
20071
- if (e && e.path) if (!Array.isArray(e.path)) s = [V(e.path)];
20072
- else {
20073
- s = [];
20074
- for (let c of e.path) s.push(V(c));
20075
- }
20076
- let i, l = {}, d = { fast: e.fast };
20077
- for (let c of s) try {
20078
- let a = A.parse(z.readFileSync(c, { encoding: t }), d);
20079
- A.populate(l, a, e);
20080
- } catch (a) {
20081
- r && T(`failed to load ${c} ${a.message}`), i = a;
20082
- }
20083
- let h = A.populate(o, l, e), f = $(Object.prototype.hasOwnProperty.call(e, "quiet") ? e.quiet : B(o).quiet);
20084
- if (r || !f) {
20085
- let c = Object.keys(h).length, a = [];
20086
- for (let g of s) try {
20087
- let p = I.relative(process.cwd(), g instanceof ee ? te(g) : g);
20088
- a.push(p);
20089
- } catch (p) {
20090
- r && T(`failed to load ${g} ${p.message}`), i = p;
20091
- }
20092
- ie(`injected env (${c}) from ${a.join(",")}`);
20093
- }
20094
- return i ? { parsed: l, error: i } : { parsed: l };
20095
- }
20096
- function le(e) {
20097
- return A.configDotenv(e);
20098
- }
20099
- function fe(e, n, t = {}) {
20100
- let o = $(t && t.debug), r = $(t && t.override), s = {};
20101
- if (e === null || typeof e != "object" || n === null || typeof n != "object") {
20102
- let i = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
20103
- throw i.code = "OBJECT_REQUIRED", i;
20104
- }
20105
- for (let i of Object.keys(n)) Object.prototype.hasOwnProperty.call(e, i) ? (r === true && (e[i] = n[i], s[i] = n[i]), o && T(r === true ? `"${i}" is already defined and WAS overwritten` : `"${i}" is already defined and was NOT overwritten`)) : (e[i] = n[i], s[i] = n[i]);
20106
- return s;
20107
- }
20108
- var A = { configDotenv: ae, config: le, parse: se, populate: fe };
20109
- x.exports.configDotenv = A.configDotenv;
20110
- x.exports.config = A.config;
20111
- x.exports.parse = A.parse;
20112
- x.exports.populate = A.populate;
20113
- x.exports = A;
20114
- });
20115
- var M = j((Te, W) => {
20116
- var _ = __require("child_process"), ue = __require("fs"), L = __require("path");
20117
- function de(e) {
20118
- let n = ['"'], t = 0;
20119
- for (let o of e) {
20120
- if (o === "\\") {
20121
- t++;
20122
- continue;
20123
- }
20124
- o === '"' ? n.push("\\".repeat(t * 2 + 1), '"') : n.push("\\".repeat(t), o), t = 0;
20125
- }
20126
- return n.push("\\".repeat(t * 2), '"'), n.join("");
20127
- }
20128
- function H(e, n = 1) {
20129
- for (let t = 0; t < n; t++) {
20130
- let o = [];
20131
- for (let r of e) {
20132
- let s = r.charCodeAt(0), i = s >= 48 && s <= 57 || s >= 65 && s <= 90 || s >= 97 && s <= 122, l = "\\/:._-".includes(r);
20133
- !i && !l && s < 128 && o.push("^"), o.push(r);
20134
- }
20135
- e = o.join("");
20136
- }
20137
- return e;
20138
- }
20139
- function P(e, n) {
20140
- let t = Object.keys(e).reverse().find((o) => o.toUpperCase() === n);
20141
- return t === void 0 ? void 0 : e[t];
20142
- }
20143
- function pe(e, n, t) {
20144
- let o = (P(n, "PATHEXT") || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean), s = o.some((l) => e.toLowerCase().endsWith(l.toLowerCase())) ? ["", ...o] : [...o, ""], i = /[\\/]/.test(e) ? [t] : [t, ...(P(n, "PATH") || "").split(";")];
20145
- for (let l of i) for (let d of s) {
20146
- let h = L.resolve(t, l.replace(/^"|"$/g, ""), e + d);
20147
- try {
20148
- if (ue.statSync(h).isFile()) return h;
20149
- } catch {
20150
- }
20151
- }
20152
- }
20153
- function he(e, n, t) {
20154
- if (process.platform !== "win32") return _.spawn(e, n, t);
20155
- let o = t.env || process.env, r = pe(e, o, t.cwd || process.cwd());
20156
- if (r && /\.(?:exe|com)$/i.test(r)) return _.spawn(r, n, t);
20157
- let s = /\.(?:bat|cmd)$/i.test(r || e), i = [H(L.normalize(r || e))];
20158
- for (let d of n) i.push(H(de(d), s ? 2 : 1));
20159
- let l = i.join(" ");
20160
- return _.spawn(P(o, "COMSPEC") || "cmd.exe", ["/d", "/v:off", "/s", "/c", `"${l}"`], { ...t, windowsVerbatimArguments: true });
20161
- }
20162
- W.exports = he;
20163
- });
20164
- var X = j(($e, F) => {
20165
- var ge = __require("fs"), me = __require("os"), Q = __require("path"), ve = __require("child_process"), Ce = M(), R = N(), { optionsFromEnv: J } = k();
20166
- function D() {
20167
- console.log(["Usage: dotenv run [--help] [-q|--quiet] [--debug] [--override] [--fast] [-f|--file <paths>] [--] <command> [args...]", "", "Run a command with environment variables from a .env file.", "Place dotenv options before the command; all following arguments go to the command.", "", "Options:", " -f, --file <paths> .env paths, comma-separated or repeated (default: .env)", " -q, --quiet suppress the injected env message", " --debug enable debug logging", " --override override existing environment variables", " --fast use the faster character-scanner parser", "", "Environment variables (DOTENV_CONFIG_* names remain as fallbacks):", " DOTENV_PATH, DOTENV_ENCODING, DOTENV_QUIET,", " DOTENV_DEBUG, DOTENV_OVERRIDE,", " DOTENV_FAST"].join(`
20168
- `));
20169
- }
20170
- function we(e) {
20171
- let n = [], t = false, o, r, s, i, l = -1;
20172
- for (let h = 0; h < e.length; h++) {
20173
- let f = e[h];
20174
- if (f === "--") {
20175
- l = h + 1;
20176
- break;
20177
- }
20178
- if (f === "--help" || f === "-h") return { help: true };
20179
- if (f === "--quiet" || f === "-q") {
20180
- o = true;
20181
- continue;
20182
- }
20183
- if (f === "--debug") {
20184
- r = true;
20185
- continue;
20186
- }
20187
- if (f === "--override") {
20188
- s = true;
20189
- continue;
20190
- }
20191
- if (f === "--fast") {
20192
- i = true;
20193
- continue;
20194
- }
20195
- if (f === "-f" || f === "--file" || f.startsWith("-f=") || f.startsWith("--file=")) {
20196
- let c = f.indexOf("="), a = c === -1 ? f : f.slice(0, c), g = c === -1 ? e[++h] : f.slice(c + 1);
20197
- if (!g || g === "--") return { error: `${a} requires a path` };
20198
- let p = g.split(",").map((y) => y.trim()).filter(Boolean);
20199
- if (p.length === 0) return { error: `${a} requires a path` };
20200
- n.push(...p), t = true;
20201
- continue;
20202
- }
20203
- if (f.startsWith("-")) return { error: `unknown option: ${f}` };
20204
- l = h;
20205
- break;
20206
- }
20207
- let d = l === -1 ? [] : e.slice(l);
20208
- return { paths: n, pathSet: t, quiet: o, debug: r, override: s, fast: i, command: d };
20209
- }
20210
- function Ae(e) {
20211
- return e[0] === "~" ? Q.join(me.homedir(), e.slice(1)) : e;
20212
- }
20213
- function Ee(e) {
20214
- let n = J(), t = { encoding: n.encoding || "utf8", quiet: n.quiet, debug: n.debug === true, override: n.override === true, fast: n.fast === true, paths: [".env"], defaultPath: true };
20215
- return n.path != null && (t.paths = [n.path], t.defaultPath = false), e.pathSet && (t.paths = e.paths, t.defaultPath = false), e.quiet != null && (t.quiet = e.quiet), e.debug != null && (t.debug = e.debug), e.override != null && (t.override = e.override), e.fast != null && (t.fast = e.fast), t;
20216
- }
20217
- function be(e) {
20218
- let n = {}, t = [], o = { override: e.override, debug: e.debug };
20219
- for (let s of e.paths) {
20220
- let i = Q.resolve(process.cwd(), Ae(s));
20221
- try {
20222
- let l = R.parse(ge.readFileSync(i, { encoding: e.encoding }), { fast: e.fast });
20223
- R.populate(n, l, o), t.push(s);
20224
- } catch (l) {
20225
- if (e.debug && console.log(`\u2506 failed to load ${s} ${l.message}`), !(e.defaultPath && l.code === "ENOENT")) throw l;
20226
- }
20227
- }
20228
- return { injected: R.populate(process.env, n, o), loadedPaths: t };
20229
- }
20230
- function K(e) {
20231
- let n = e[0];
20232
- if (n === "--help" || n === "-h") {
20233
- D();
20234
- return;
20235
- }
20236
- if (n !== "run") {
20237
- D(), process.exitCode = 1;
20238
- return;
20239
- }
20240
- let t = we(e.slice(1));
20241
- if (t.help) {
20242
- D();
20243
- return;
20244
- }
20245
- if (t.error) {
20246
- console.error(`dotenv: ${t.error}`), D(), process.exitCode = 1;
20247
- return;
20248
- }
20249
- if (t.command.length === 0) {
20250
- D(), process.exitCode = 1;
20251
- return;
20252
- }
20253
- let o = Ee(t);
20254
- try {
20255
- let c = be(o);
20256
- if (!(o.quiet == null ? J().quiet : o.quiet)) {
20257
- let g = `\u25C7 injected env (${Object.keys(c.injected).length})`;
20258
- c.loadedPaths.length > 0 && (g += ` from ${c.loadedPaths.join(", ")}`), console.error(g);
20259
- }
20260
- } catch (c) {
20261
- console.error(`dotenv: ${c.message}`), process.exitCode = 1;
20262
- return;
20263
- }
20264
- let r = !!process.stdin.isTTY, s = process.platform !== "win32" && !r, i = Ce(t.command[0], t.command.slice(1), { stdio: "inherit", detached: s }), l = /* @__PURE__ */ new Map(), d = 0;
20265
- function h(c) {
20266
- if (!(!i.pid || i.exitCode !== null || i.signalCode !== null)) {
20267
- if (process.platform === "win32") {
20268
- ve.spawnSync("taskkill", ["/pid", String(i.pid), "/T", "/F"], { stdio: "ignore" });
20269
- return;
20270
- }
20271
- try {
20272
- process.kill(s ? -i.pid : i.pid, c);
20273
- } catch (a) {
20274
- if (a.code !== "ESRCH") throw a;
20275
- }
20276
- }
20277
- }
20278
- function f() {
20279
- for (let [c, a] of l) process.removeListener(c, a);
20280
- }
20281
- for (let c of ["SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT"]) {
20282
- let a = () => {
20283
- if (c === "SIGINT") {
20284
- if (d++, r && process.platform !== "win32" && d === 1) return;
20285
- if (d > 1) {
20286
- h(d === 2 ? "SIGTERM" : "SIGKILL");
20287
- return;
20288
- }
20289
- }
20290
- h(c);
20291
- };
20292
- l.set(c, a), process.on(c, a);
20293
- }
20294
- i.on("error", function(c) {
20295
- f(), console.error(`dotenv: ${c.message}`), process.exitCode = 1;
20296
- }), i.on("exit", function(c, a) {
20297
- f(), typeof c == "number" ? process.exit(c) : (setInterval(() => {
20298
- }, 1e3), process.kill(process.pid, a));
20299
- });
20300
- }
20301
- F.exports = K;
20302
- __require.main === F && K(process.argv.slice(2));
20303
- });
20304
- var S = N();
20305
- var qe = X();
20306
- module.exports = S;
20307
- module.exports.config = S.config;
20308
- module.exports.configDotenv = S.configDotenv;
20309
- module.exports.parse = S.parse;
20310
- module.exports.populate = S.populate;
20311
- __require.main === module && qe(process.argv.slice(2));
20312
- }
20313
- });
20314
-
20315
20315
  // ../../node_modules/semver/internal/constants.js
20316
20316
  var require_constants = __commonJS({
20317
20317
  "../../node_modules/semver/internal/constants.js"(exports, module) {
@@ -22308,8 +22308,7 @@ var require_semver2 = __commonJS({
22308
22308
 
22309
22309
  // ../argent-mcp/src/mcp-server.ts
22310
22310
  import { appendFile, mkdir as mkdir5 } from "node:fs/promises";
22311
- import { dirname as dirname11 } from "node:path";
22312
- import { homedir as homedir5 } from "node:os";
22311
+ import { dirname as dirname10, join as join19 } from "node:path";
22313
22312
  import { setTimeout as sleep } from "node:timers/promises";
22314
22313
 
22315
22314
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
@@ -22552,10 +22551,10 @@ function mergeDefs(...defs) {
22552
22551
  function cloneDef(schema) {
22553
22552
  return mergeDefs(schema._zod.def);
22554
22553
  }
22555
- function getElementAtPath(obj, path18) {
22556
- if (!path18)
22554
+ function getElementAtPath(obj, path19) {
22555
+ if (!path19)
22557
22556
  return obj;
22558
- return path18.reduce((acc, key) => acc?.[key], obj);
22557
+ return path19.reduce((acc, key) => acc?.[key], obj);
22559
22558
  }
22560
22559
  function promiseAllObject(promisesObj) {
22561
22560
  const keys = Object.keys(promisesObj);
@@ -22895,11 +22894,11 @@ function explicitlyAborted(x, startIndex = 0) {
22895
22894
  }
22896
22895
  return false;
22897
22896
  }
22898
- function prefixIssues(path18, issues) {
22897
+ function prefixIssues(path19, issues) {
22899
22898
  return issues.map((iss) => {
22900
22899
  var _a3;
22901
22900
  (_a3 = iss).path ?? (_a3.path = []);
22902
- iss.path.unshift(path18);
22901
+ iss.path.unshift(path19);
22903
22902
  return iss;
22904
22903
  });
22905
22904
  }
@@ -23357,16 +23356,16 @@ function flattenError(error2, mapper = (issue2) => issue2.message) {
23357
23356
  }
23358
23357
  function formatError(error2, mapper = (issue2) => issue2.message) {
23359
23358
  const fieldErrors = { _errors: [] };
23360
- const processError = (error3, path18 = []) => {
23359
+ const processError = (error3, path19 = []) => {
23361
23360
  for (const issue2 of error3.issues) {
23362
23361
  if (issue2.code === "invalid_union" && issue2.errors.length) {
23363
- issue2.errors.map((issues) => processError({ issues }, [...path18, ...issue2.path]));
23362
+ issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
23364
23363
  } else if (issue2.code === "invalid_key") {
23365
- processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
23364
+ processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
23366
23365
  } else if (issue2.code === "invalid_element") {
23367
- processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
23366
+ processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
23368
23367
  } else {
23369
- const fullpath = [...path18, ...issue2.path];
23368
+ const fullpath = [...path19, ...issue2.path];
23370
23369
  if (fullpath.length === 0) {
23371
23370
  fieldErrors._errors.push(mapper(issue2));
23372
23371
  } else {
@@ -25666,7 +25665,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
25666
25665
  var NONE = 0;
25667
25666
  var ASSUMED = 1;
25668
25667
  var PROVEN = 2;
25669
- function isRecursive(inst, stack, resolve12) {
25668
+ function isRecursive(inst, stack, resolve13) {
25670
25669
  const cached2 = recursive.get(inst);
25671
25670
  if (cached2 !== void 0)
25672
25671
  return cached2 ? PROVEN : NONE;
@@ -25676,7 +25675,7 @@ function isRecursive(inst, stack, resolve12) {
25676
25675
  let result = NONE;
25677
25676
  const check = (child) => {
25678
25677
  if (result !== PROVEN && child?._zod) {
25679
- const answer = isRecursive(child, stack, resolve12);
25678
+ const answer = isRecursive(child, stack, resolve13);
25680
25679
  if (answer > result)
25681
25680
  result = answer;
25682
25681
  }
@@ -25687,7 +25686,7 @@ function isRecursive(inst, stack, resolve12) {
25687
25686
  const desc = Object.getOwnPropertyDescriptor(sh, key);
25688
25687
  if (spread && !desc.enumerable)
25689
25688
  continue;
25690
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve12) : NONE;
25689
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve13) : NONE;
25691
25690
  if (child > answer)
25692
25691
  answer = child;
25693
25692
  }
@@ -25751,7 +25750,7 @@ function isRecursive(inst, stack, resolve12) {
25751
25750
  break;
25752
25751
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
25753
25752
  case "lazy": {
25754
- const inner = def._cachedInner ?? (resolve12 ? inst._zod.innerType : void 0);
25753
+ const inner = def._cachedInner ?? (resolve13 ? inst._zod.innerType : void 0);
25755
25754
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
25756
25755
  break;
25757
25756
  }
@@ -30329,12 +30328,12 @@ var StdioServerTransport = class {
30329
30328
  this.onclose?.();
30330
30329
  }
30331
30330
  send(message) {
30332
- return new Promise((resolve12) => {
30331
+ return new Promise((resolve13) => {
30333
30332
  const json = serializeMessage(message);
30334
30333
  if (this._stdout.write(json)) {
30335
- resolve12();
30334
+ resolve13();
30336
30335
  } else {
30337
- this._stdout.once("drain", resolve12);
30336
+ this._stdout.once("drain", resolve13);
30338
30337
  }
30339
30338
  });
30340
30339
  }
@@ -30954,7 +30953,7 @@ var Protocol = class {
30954
30953
  return;
30955
30954
  }
30956
30955
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
30957
- await new Promise((resolve12) => setTimeout(resolve12, pollInterval));
30956
+ await new Promise((resolve13) => setTimeout(resolve13, pollInterval));
30958
30957
  options?.signal?.throwIfAborted();
30959
30958
  }
30960
30959
  } catch (error2) {
@@ -30971,7 +30970,7 @@ var Protocol = class {
30971
30970
  */
30972
30971
  request(request, resultSchema, options) {
30973
30972
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
30974
- return new Promise((resolve12, reject) => {
30973
+ return new Promise((resolve13, reject) => {
30975
30974
  const earlyReject = (error2) => {
30976
30975
  reject(error2);
30977
30976
  };
@@ -31049,7 +31048,7 @@ var Protocol = class {
31049
31048
  if (!parseResult.success) {
31050
31049
  reject(parseResult.error);
31051
31050
  } else {
31052
- resolve12(parseResult.data);
31051
+ resolve13(parseResult.data);
31053
31052
  }
31054
31053
  } catch (error2) {
31055
31054
  reject(error2);
@@ -31311,12 +31310,12 @@ var Protocol = class {
31311
31310
  }
31312
31311
  } catch {
31313
31312
  }
31314
- return new Promise((resolve12, reject) => {
31313
+ return new Promise((resolve13, reject) => {
31315
31314
  if (signal.aborted) {
31316
31315
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
31317
31316
  return;
31318
31317
  }
31319
- const timeoutId = setTimeout(resolve12, interval);
31318
+ const timeoutId = setTimeout(resolve13, interval);
31320
31319
  signal.addEventListener("abort", () => {
31321
31320
  clearTimeout(timeoutId);
31322
31321
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -32098,506 +32097,36 @@ var Server = class extends Protocol {
32098
32097
 
32099
32098
  // ../argent-tools-client/src/launcher.ts
32100
32099
  import * as net from "node:net";
32101
- import * as fs from "node:fs";
32102
- import * as path from "node:path";
32100
+ import * as fs5 from "node:fs";
32101
+ import * as path7 from "node:path";
32103
32102
  import * as readline from "node:readline";
32104
- import { homedir } from "node:os";
32105
32103
  import { spawn, execFileSync } from "node:child_process";
32106
32104
  import { createHash, randomBytes } from "node:crypto";
32107
32105
  import { mkdir, writeFile, readFile, readdir, unlink, rename, chmod } from "node:fs/promises";
32108
- var STATE_DIR = path.join(homedir(), ".argent");
32109
- var STATE_FILE = path.join(STATE_DIR, "tool-server.json");
32110
- var LOG_FILE = path.join(STATE_DIR, "tool-server.log");
32111
- var LOCK_FILE = path.join(STATE_DIR, "tool-server.lock");
32112
- var AUTH_TOKEN_BYTES = 32;
32113
- var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
32114
- var AUTOSPAWN_IDLE_TIMEOUT_MINUTES = 30;
32115
- var AUTOSPAWN_HOST = "127.0.0.1";
32116
- function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
32117
- const env = {
32118
- ...baseEnv,
32119
- ARGENT_PORT: String(port),
32120
- ARGENT_SIMULATOR_SERVER_DIR: paths.simulatorServerDir,
32121
- ARGENT_NATIVE_DEVTOOLS_DIR: paths.nativeDevtoolsDir
32122
- };
32123
- if (options.host !== void 0) env.ARGENT_HOST = options.host;
32124
- if (options.idleTimeoutMinutes !== void 0) {
32125
- env.ARGENT_IDLE_TIMEOUT_MINUTES = String(options.idleTimeoutMinutes);
32126
- }
32127
- env[AUTH_TOKEN_ENV] = options.token ?? "";
32128
- 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
- }
32106
+
32107
+ // ../configuration-core/src/flags.ts
32108
+ import * as fs from "node:fs";
32109
+ import * as path2 from "node:path";
32110
+
32111
+ // ../configuration-core/src/home.ts
32112
+ import * as os from "node:os";
32113
+ import * as path from "node:path";
32114
+ var ARGENT_HOME_DIR_ENV = "ARGENT_HOME_DIR";
32115
+ function nonEmpty(value) {
32116
+ if (value == void 0) return null;
32117
+ const trimmed = value.trim();
32118
+ return trimmed === "" ? null : value;
32528
32119
  }
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 ?? "" };
32120
+ function resolveHomeDir(options = {}) {
32121
+ if (options.homeDir) return options.homeDir;
32122
+ return process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
32544
32123
  }
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
- }
32124
+ function argentHomeDir(options = {}) {
32125
+ const override = options.homeDir ? null : nonEmpty(process.env[ARGENT_HOME_DIR_ENV]);
32126
+ return override ? path.resolve(override.trim()) : path.join(resolveHomeDir(options), ".argent");
32589
32127
  }
32590
32128
 
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
32129
  // ../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
32130
  var FLAG_REGISTRY = [
32602
32131
  {
32603
32132
  name: "disable-auto-screenshot",
@@ -32664,7 +32193,7 @@ function findProjectRoot(startDir) {
32664
32193
  let current = path2.resolve(startDir);
32665
32194
  while (true) {
32666
32195
  for (const marker of PROJECT_MARKERS) {
32667
- if (fs2.existsSync(path2.join(current, marker))) return current;
32196
+ if (fs.existsSync(path2.join(current, marker))) return current;
32668
32197
  }
32669
32198
  const parent = path2.dirname(current);
32670
32199
  if (parent === current) return null;
@@ -32675,9 +32204,8 @@ function resolveProjectRoot(startDir) {
32675
32204
  return findProjectRoot(startDir) ?? path2.resolve(startDir);
32676
32205
  }
32677
32206
  function getFlagsPath(scope, options = {}) {
32678
- const home = options.homeDir ?? homedir2();
32679
32207
  if (scope === "global") {
32680
- return path2.join(home, ".argent", "flags.json");
32208
+ return path2.join(argentHomeDir({ homeDir: options.homeDir }), "flags.json");
32681
32209
  }
32682
32210
  const cwd = options.cwd ?? process.cwd();
32683
32211
  return path2.join(resolveProjectRoot(cwd), ".argent", "flags.json");
@@ -32685,7 +32213,7 @@ function getFlagsPath(scope, options = {}) {
32685
32213
  function readFlagsFile(filePath) {
32686
32214
  let raw2;
32687
32215
  try {
32688
- raw2 = fs2.readFileSync(filePath, "utf8");
32216
+ raw2 = fs.readFileSync(filePath, "utf8");
32689
32217
  } catch {
32690
32218
  return {};
32691
32219
  }
@@ -32722,35 +32250,20 @@ function isFeatureEnabled(name, options = {}, registry2 = FLAG_REGISTRY) {
32722
32250
  }
32723
32251
 
32724
32252
  // ../configuration-core/src/paths.ts
32725
- import * as fs3 from "node:fs";
32726
- import * as os from "node:os";
32253
+ import * as fs2 from "node:fs";
32727
32254
  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
32255
  function isHomeDir(dir, options = {}) {
32738
32256
  return canonicalPath(dir) === canonicalPath(resolveHomeDir(options));
32739
32257
  }
32740
32258
  function canonicalPath(p) {
32741
32259
  try {
32742
- return fs3.realpathSync.native(p);
32260
+ return fs2.realpathSync.native(p);
32743
32261
  } catch {
32744
32262
  return path3.resolve(p);
32745
32263
  }
32746
32264
  }
32747
- function argentHomeDir() {
32748
- return path3.join(resolveHomeDir(), ".argent");
32749
- }
32750
32265
  function configDir(scope = "global", options = {}) {
32751
- if (scope === "global") {
32752
- return path3.join(resolveHomeDir(options), ".argent");
32753
- }
32266
+ if (scope === "global") return argentHomeDir(options);
32754
32267
  const cwd = options.cwd ?? process.cwd();
32755
32268
  return path3.join(resolveProjectRoot(cwd), ".argent");
32756
32269
  }
@@ -32760,11 +32273,11 @@ function configFilePath(scope = "global", options = {}) {
32760
32273
 
32761
32274
  // ../configuration-core/src/config.ts
32762
32275
  import * as crypto from "node:crypto";
32763
- import * as fs4 from "node:fs";
32276
+ import * as fs3 from "node:fs";
32764
32277
  import * as path4 from "node:path";
32765
32278
  function readConfigObject(scope = "global", options = {}) {
32766
32279
  try {
32767
- const raw2 = fs4.readFileSync(configFilePath(scope, options), "utf8");
32280
+ const raw2 = fs3.readFileSync(configFilePath(scope, options), "utf8");
32768
32281
  const json = JSON.parse(raw2);
32769
32282
  if (json && typeof json === "object" && !Array.isArray(json)) {
32770
32283
  return json;
@@ -32811,7 +32324,7 @@ function setAtPath(obj, dottedKey, value) {
32811
32324
  }
32812
32325
  cur[parts[parts.length - 1]] = value;
32813
32326
  }
32814
- var LOCK_STALE_MS2 = 1e4;
32327
+ var LOCK_STALE_MS = 1e4;
32815
32328
  var LOCK_MAX_WAIT_MS = 2e3;
32816
32329
  var LOCK_RETRY_MS = 25;
32817
32330
  function sleepSync(ms) {
@@ -32822,9 +32335,9 @@ function acquireConfigLock(finalPath) {
32822
32335
  const deadline = Date.now() + LOCK_MAX_WAIT_MS;
32823
32336
  for (; ; ) {
32824
32337
  try {
32825
- const fd = fs4.openSync(lockPath, "wx", 384);
32338
+ const fd = fs3.openSync(lockPath, "wx", 384);
32826
32339
  try {
32827
- fs4.writeSync(fd, `${process.pid}
32340
+ fs3.writeSync(fd, `${process.pid}
32828
32341
  `);
32829
32342
  } catch {
32830
32343
  }
@@ -32832,8 +32345,8 @@ function acquireConfigLock(finalPath) {
32832
32345
  } catch (err) {
32833
32346
  if (err.code !== "EEXIST") return null;
32834
32347
  try {
32835
- if (Date.now() - fs4.statSync(lockPath).mtimeMs > LOCK_STALE_MS2) {
32836
- fs4.unlinkSync(lockPath);
32348
+ if (Date.now() - fs3.statSync(lockPath).mtimeMs > LOCK_STALE_MS) {
32349
+ fs3.unlinkSync(lockPath);
32837
32350
  continue;
32838
32351
  }
32839
32352
  } catch {
@@ -32845,35 +32358,35 @@ function acquireConfigLock(finalPath) {
32845
32358
  }
32846
32359
  function releaseConfigLock(lock) {
32847
32360
  try {
32848
- fs4.closeSync(lock.fd);
32361
+ fs3.closeSync(lock.fd);
32849
32362
  } catch {
32850
32363
  }
32851
32364
  try {
32852
- fs4.unlinkSync(lock.lockPath);
32365
+ fs3.unlinkSync(lock.lockPath);
32853
32366
  } catch {
32854
32367
  }
32855
32368
  }
32856
32369
  function updateConfig(mutate, scope = "global", options = {}) {
32857
32370
  const dir = configDir(scope, options);
32858
- fs4.mkdirSync(dir, { recursive: true });
32371
+ fs3.mkdirSync(dir, { recursive: true });
32859
32372
  const finalPath = configFilePath(scope, options);
32860
32373
  const lock = acquireConfigLock(finalPath);
32861
32374
  try {
32862
32375
  const next = readConfigObject(scope, options);
32863
32376
  mutate(next);
32864
32377
  const tmpPath = path4.join(dir, `.config.tmp.${process.pid}.${crypto.randomUUID()}`);
32865
- const fd = fs4.openSync(tmpPath, "wx", 384);
32378
+ const fd = fs3.openSync(tmpPath, "wx", 384);
32866
32379
  try {
32867
- fs4.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
32868
- fs4.fsyncSync(fd);
32380
+ fs3.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
32381
+ fs3.fsyncSync(fd);
32869
32382
  } finally {
32870
- fs4.closeSync(fd);
32383
+ fs3.closeSync(fd);
32871
32384
  }
32872
32385
  try {
32873
- fs4.renameSync(tmpPath, finalPath);
32386
+ fs3.renameSync(tmpPath, finalPath);
32874
32387
  } catch (err) {
32875
32388
  try {
32876
- fs4.unlinkSync(tmpPath);
32389
+ fs3.unlinkSync(tmpPath);
32877
32390
  } catch {
32878
32391
  }
32879
32392
  throw err;
@@ -32906,8 +32419,8 @@ function setWhatsNewSeenVersion(version2, options = {}) {
32906
32419
  }
32907
32420
 
32908
32421
  // ../configuration-core/src/secrets.ts
32909
- var import_dotenv = __toESM(require_dist3(), 1);
32910
- import * as fs5 from "node:fs";
32422
+ var import_dotenv = __toESM(require_dist2(), 1);
32423
+ import * as fs4 from "node:fs";
32911
32424
  import * as path5 from "node:path";
32912
32425
  var SECRET_ENV_PREFIX = "ARGENT_SECRET_";
32913
32426
  var SECRETS_FILE_NAME = "secrets.env";
@@ -32937,10 +32450,10 @@ function fileSource(filePath, exposure) {
32937
32450
  names: [],
32938
32451
  values: /* @__PURE__ */ new Map()
32939
32452
  };
32940
- if (!fs5.statSync(filePath, { throwIfNoEntry: false })) return absent;
32453
+ if (!fs4.statSync(filePath, { throwIfNoEntry: false })) return absent;
32941
32454
  let content;
32942
32455
  try {
32943
- content = fs5.readFileSync(filePath, "utf8");
32456
+ content = fs4.readFileSync(filePath, "utf8");
32944
32457
  } catch {
32945
32458
  return absent;
32946
32459
  }
@@ -32980,7 +32493,7 @@ function secretSources(options = {}) {
32980
32493
  }
32981
32494
  }
32982
32495
  filePaths.push({
32983
- path: path5.join(home, ".argent", SECRETS_FILE_NAME),
32496
+ path: path5.join(argentHomeDir(options), SECRETS_FILE_NAME),
32984
32497
  exposure: "dedicated"
32985
32498
  });
32986
32499
  const seen = /* @__PURE__ */ new Set();
@@ -33066,7 +32579,7 @@ function applyMergePolicy(policy, local, global) {
33066
32579
  }
33067
32580
 
33068
32581
  // ../configuration-core/src/config-schema.ts
33069
- import { isAbsolute as isAbsolute2 } from "node:path";
32582
+ import { isAbsolute } from "node:path";
33070
32583
  function asBoolean(raw2) {
33071
32584
  return typeof raw2 === "boolean" ? raw2 : void 0;
33072
32585
  }
@@ -33136,7 +32649,7 @@ var CONFIG_SCHEMA = [
33136
32649
  scopes: ["project", "global"],
33137
32650
  parse: (raw2) => {
33138
32651
  const value = asString(raw2);
33139
- return value !== void 0 && (value === "~" || value.startsWith("~/") || isAbsolute2(value)) ? value : void 0;
32652
+ return value !== void 0 && (value === "~" || value.startsWith("~/") || isAbsolute(value)) ? value : void 0;
33140
32653
  },
33141
32654
  expected: "an absolute path, or one starting with `~/`",
33142
32655
  merge: "prioritize-local",
@@ -33231,6 +32744,499 @@ var UnknownConfigKeyError = class extends Error {
33231
32744
  key;
33232
32745
  };
33233
32746
 
32747
+ // ../argent-tools-client/src/launcher.ts
32748
+ var STATE_DIR = argentHomeDir();
32749
+ var STATE_FILE = path7.join(STATE_DIR, "tool-server.json");
32750
+ var LOG_FILE = path7.join(STATE_DIR, "tool-server.log");
32751
+ var LOCK_FILE = path7.join(STATE_DIR, "tool-server.lock");
32752
+ var AUTH_TOKEN_BYTES = 32;
32753
+ var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
32754
+ var AUTOSPAWN_IDLE_TIMEOUT_MINUTES = 30;
32755
+ var AUTOSPAWN_HOST = "127.0.0.1";
32756
+ function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
32757
+ const env = {
32758
+ ...baseEnv,
32759
+ ARGENT_PORT: String(port),
32760
+ ARGENT_SIMULATOR_SERVER_DIR: paths.simulatorServerDir,
32761
+ ARGENT_NATIVE_DEVTOOLS_DIR: paths.nativeDevtoolsDir
32762
+ };
32763
+ if (options.host !== void 0) env.ARGENT_HOST = options.host;
32764
+ if (options.idleTimeoutMinutes !== void 0) {
32765
+ env.ARGENT_IDLE_TIMEOUT_MINUTES = String(options.idleTimeoutMinutes);
32766
+ }
32767
+ env[AUTH_TOKEN_ENV] = options.token ?? "";
32768
+ env.ARGENT_SERVER_MANAGED = options.managed ?? "autospawn";
32769
+ if (paths.installKind) env.ARGENT_INSTALL_KIND = paths.installKind;
32770
+ if (paths.installProjectRoot) env.ARGENT_PROJECT_ROOT = paths.installProjectRoot;
32771
+ return env;
32772
+ }
32773
+ function generateToken() {
32774
+ return randomBytes(AUTH_TOKEN_BYTES).toString("hex");
32775
+ }
32776
+ function findFreePort() {
32777
+ return new Promise((resolve13, reject) => {
32778
+ const srv = net.createServer();
32779
+ srv.listen(0, "127.0.0.1", () => {
32780
+ const addr = srv.address();
32781
+ if (!addr || typeof addr !== "object") {
32782
+ srv.close(() => reject(new Error("Could not bind to find free port")));
32783
+ return;
32784
+ }
32785
+ const port = addr.port;
32786
+ srv.close((err) => {
32787
+ if (err) reject(err);
32788
+ else resolve13(port);
32789
+ });
32790
+ });
32791
+ srv.on("error", reject);
32792
+ });
32793
+ }
32794
+ function isVersionNewer(a, b) {
32795
+ const parse4 = (v) => {
32796
+ const [core = "", ...preParts] = v.split("+")[0].split("-");
32797
+ const nums = core.split(".").map((n) => Number.parseInt(n, 10));
32798
+ if (nums.length === 0 || nums.some((n) => Number.isNaN(n))) return null;
32799
+ return { nums, pre: preParts.length > 0 ? preParts.join("-").split(".") : [] };
32800
+ };
32801
+ const pa = parse4(a);
32802
+ const pb = parse4(b);
32803
+ if (!pa || !pb) return false;
32804
+ for (let i = 0; i < 3; i++) {
32805
+ const x = pa.nums[i] ?? 0;
32806
+ const y = pb.nums[i] ?? 0;
32807
+ if (x !== y) return x > y;
32808
+ }
32809
+ if (pa.pre.length === 0 && pb.pre.length === 0) return false;
32810
+ if (pa.pre.length === 0) return true;
32811
+ if (pb.pre.length === 0) return false;
32812
+ for (let i = 0; i < Math.max(pa.pre.length, pb.pre.length); i++) {
32813
+ const x = pa.pre[i];
32814
+ const y = pb.pre[i];
32815
+ if (x === void 0) return false;
32816
+ if (y === void 0) return true;
32817
+ if (x === y) continue;
32818
+ const xn = /^\d+$/.test(x) ? Number.parseInt(x, 10) : null;
32819
+ const yn = /^\d+$/.test(y) ? Number.parseInt(y, 10) : null;
32820
+ if (xn !== null && yn !== null) return xn > yn;
32821
+ if (xn !== null) return false;
32822
+ if (yn !== null) return true;
32823
+ return x > y;
32824
+ }
32825
+ return false;
32826
+ }
32827
+ function readBundlePackageVersion(bundlePath) {
32828
+ try {
32829
+ const pkg = JSON.parse(
32830
+ fs5.readFileSync(path7.join(path7.dirname(bundlePath), "..", "package.json"), "utf8")
32831
+ );
32832
+ return typeof pkg.version === "string" ? pkg.version : void 0;
32833
+ } catch {
32834
+ return void 0;
32835
+ }
32836
+ }
32837
+ function isProcessAlive(pid) {
32838
+ try {
32839
+ process.kill(pid, 0);
32840
+ return true;
32841
+ } catch {
32842
+ return false;
32843
+ }
32844
+ }
32845
+ function healthCheckHost(host) {
32846
+ if (host === "0.0.0.0" || host === "") return "127.0.0.1";
32847
+ if (host === "::" || host === "::0") return "::1";
32848
+ return host;
32849
+ }
32850
+ function formatUrl(host, port) {
32851
+ const h = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
32852
+ return `http://${h}:${port}`;
32853
+ }
32854
+ function authHeaders(token) {
32855
+ return token ? { Authorization: `Bearer ${token}` } : {};
32856
+ }
32857
+ async function isToolsServerHealthy(port, host = "127.0.0.1", timeoutMs = 2e3, token) {
32858
+ const controller = new AbortController();
32859
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
32860
+ try {
32861
+ const res = await fetch(`${formatUrl(healthCheckHost(host), port)}/tools`, {
32862
+ signal: controller.signal,
32863
+ headers: authHeaders(token)
32864
+ });
32865
+ await res.body?.cancel().catch(() => {
32866
+ });
32867
+ return res.ok;
32868
+ } catch {
32869
+ return false;
32870
+ } finally {
32871
+ clearTimeout(timer);
32872
+ }
32873
+ }
32874
+ var SPAWN_READY_TIMEOUT_MS = 15e3;
32875
+ function killSpawnedChild(child, pid) {
32876
+ try {
32877
+ process.kill(-pid, "SIGKILL");
32878
+ } catch {
32879
+ try {
32880
+ child.kill("SIGKILL");
32881
+ } catch {
32882
+ }
32883
+ }
32884
+ }
32885
+ function resolveToolsServerNode() {
32886
+ const { bun, deno, electron } = process.versions;
32887
+ return !(bun || deno || electron) && fs5.existsSync(process.execPath) ? process.execPath : "node";
32888
+ }
32889
+ function parseListeningPort(line) {
32890
+ const match = line.match(/Tools server listening on http:\/\/.+:(\d+)/);
32891
+ return match ? parseInt(match[1], 10) : null;
32892
+ }
32893
+ function spawnToolsServer(paths, port, options = {}) {
32894
+ return new Promise((resolve13, reject) => {
32895
+ let logFd;
32896
+ try {
32897
+ fs5.mkdirSync(STATE_DIR, { recursive: true });
32898
+ logFd = fs5.openSync(LOG_FILE, "a");
32899
+ } catch {
32900
+ logFd = fs5.openSync("/dev/null", "w");
32901
+ }
32902
+ const nodeBin = resolveToolsServerNode();
32903
+ const child = spawn(nodeBin, [paths.bundlePath, "start"], {
32904
+ detached: true,
32905
+ stdio: ["ignore", "pipe", logFd],
32906
+ env: buildToolsServerEnv(paths, port, process.env, options)
32907
+ });
32908
+ fs5.closeSync(logFd);
32909
+ const pid = child.pid;
32910
+ if (!pid) {
32911
+ child.once(
32912
+ "error",
32913
+ (err) => reject(
32914
+ new Error(
32915
+ err.code === "ENOENT" && nodeBin === "node" ? "Could not start the argent tool-server: `node` was not found on PATH. Install Node.js 22.18+ or add it to PATH." : `Could not start the argent tool-server: ${err.message}`
32916
+ )
32917
+ )
32918
+ );
32919
+ return;
32920
+ }
32921
+ let settled = false;
32922
+ const settle2 = (fn) => {
32923
+ if (settled) return;
32924
+ settled = true;
32925
+ fn();
32926
+ };
32927
+ const rejectAndKill = (err) => settle2(() => {
32928
+ killSpawnedChild(child, pid);
32929
+ reject(err);
32930
+ });
32931
+ const rl = readline.createInterface({ input: child.stdout });
32932
+ rl.on("line", (line) => {
32933
+ const actualPort = parseListeningPort(line);
32934
+ if (actualPort !== null) {
32935
+ rl.close();
32936
+ child.stdout?.resume();
32937
+ child.stdout?.unref?.();
32938
+ child.unref();
32939
+ settle2(() => resolve13({ port: actualPort, pid }));
32940
+ }
32941
+ });
32942
+ child.on("error", (err) => {
32943
+ rl.close();
32944
+ rejectAndKill(err);
32945
+ });
32946
+ child.on("exit", (code) => {
32947
+ rl.close();
32948
+ settle2(() => reject(new Error(`tool-server exited with code ${code} before becoming ready`)));
32949
+ });
32950
+ const timer = setTimeout(() => {
32951
+ rl.close();
32952
+ rejectAndKill(new Error("Timed out waiting for tools server to become ready"));
32953
+ }, options.readyTimeoutMs ?? SPAWN_READY_TIMEOUT_MS);
32954
+ rl.on("close", () => clearTimeout(timer));
32955
+ });
32956
+ }
32957
+ function stateFileForBundle(bundlePath) {
32958
+ const key = createHash("sha256").update(bundlePath).digest("hex").slice(0, 12);
32959
+ return path7.join(STATE_DIR, `tool-server-${key}.json`);
32960
+ }
32961
+ async function readStateFile(file) {
32962
+ try {
32963
+ const raw2 = await readFile(file, "utf8");
32964
+ return JSON.parse(raw2);
32965
+ } catch {
32966
+ return null;
32967
+ }
32968
+ }
32969
+ async function readToolsServerState(bundlePath) {
32970
+ if (bundlePath === void 0) return readStateFile(STATE_FILE);
32971
+ const own2 = await readStateFile(stateFileForBundle(bundlePath));
32972
+ if (own2) return own2;
32973
+ const legacy = await readStateFile(STATE_FILE);
32974
+ return legacy && legacy.bundlePath === bundlePath ? legacy : null;
32975
+ }
32976
+ async function writeToolsServerState(state) {
32977
+ const target = stateFileForBundle(state.bundlePath);
32978
+ await mkdir(STATE_DIR, { recursive: true });
32979
+ const tmp = `${target}.${process.pid}.tmp`;
32980
+ try {
32981
+ await writeFile(tmp, JSON.stringify(state, null, 2) + "\n", {
32982
+ encoding: "utf8",
32983
+ mode: 384
32984
+ });
32985
+ await chmod(tmp, 384);
32986
+ await rename(tmp, target);
32987
+ } catch (err) {
32988
+ await unlink(tmp).catch(() => {
32989
+ });
32990
+ throw err;
32991
+ }
32992
+ }
32993
+ async function clearToolsServerState(bundlePath) {
32994
+ const files = [STATE_FILE];
32995
+ if (bundlePath !== void 0) {
32996
+ files[0] = stateFileForBundle(bundlePath);
32997
+ const legacy = await readStateFile(STATE_FILE);
32998
+ if (legacy && legacy.bundlePath === bundlePath) files.push(STATE_FILE);
32999
+ }
33000
+ for (const file of files) {
33001
+ try {
33002
+ await unlink(file);
33003
+ } catch {
33004
+ }
33005
+ }
33006
+ }
33007
+ var STATE_FILE_RE = /^tool-server(-[0-9a-f]{12})?\.json$/;
33008
+ async function readAllToolsServerStates() {
33009
+ let names;
33010
+ try {
33011
+ names = await readdir(STATE_DIR);
33012
+ } catch {
33013
+ return [];
33014
+ }
33015
+ const out = [];
33016
+ for (const name of names) {
33017
+ if (!STATE_FILE_RE.test(name)) continue;
33018
+ const file = path7.join(STATE_DIR, name);
33019
+ const state = await readStateFile(file);
33020
+ if (state) out.push({ file, state });
33021
+ }
33022
+ return out;
33023
+ }
33024
+ async function sweepDeadStateFiles() {
33025
+ for (const { file } of await readAllToolsServerStates()) {
33026
+ if (file === STATE_FILE) continue;
33027
+ const fresh = await readStateFile(file);
33028
+ if (!fresh) continue;
33029
+ if (!isProcessAlive(fresh.pid)) {
33030
+ await unlink(file).catch(() => {
33031
+ });
33032
+ continue;
33033
+ }
33034
+ if (fs5.existsSync(fresh.bundlePath)) continue;
33035
+ if (!couldBeOurToolServer(fresh.pid, fresh.bundlePath)) continue;
33036
+ await unlink(file).catch(() => {
33037
+ });
33038
+ void terminatePid(fresh.pid, () => couldBeOurToolServer(fresh.pid, fresh.bundlePath));
33039
+ }
33040
+ }
33041
+ var readState = readToolsServerState;
33042
+ var writeState = writeToolsServerState;
33043
+ var SIGTERM_GRACE_MS = 6e3;
33044
+ var SIGKILL_GRACE_MS = 1e3;
33045
+ var KILL_POLL_MS = 100;
33046
+ async function waitForExit(pid, timeoutMs) {
33047
+ const deadline = Date.now() + timeoutMs;
33048
+ while (Date.now() < deadline) {
33049
+ if (!isProcessAlive(pid)) return true;
33050
+ await new Promise((r) => setTimeout(r, KILL_POLL_MS));
33051
+ }
33052
+ return !isProcessAlive(pid);
33053
+ }
33054
+ async function terminatePid(pid, stillOurs) {
33055
+ if (!isProcessAlive(pid)) return;
33056
+ if (stillOurs && !stillOurs()) return;
33057
+ try {
33058
+ process.kill(pid, "SIGTERM");
33059
+ } catch {
33060
+ return;
33061
+ }
33062
+ if (await waitForExit(pid, SIGTERM_GRACE_MS)) return;
33063
+ if (stillOurs && !(isProcessAlive(pid) && stillOurs())) return;
33064
+ try {
33065
+ process.kill(pid, "SIGKILL");
33066
+ } catch {
33067
+ return;
33068
+ }
33069
+ await waitForExit(pid, SIGKILL_GRACE_MS);
33070
+ }
33071
+ var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs5.existsSync(p)) ?? "ps";
33072
+ var PS_WIDTH_FLAGS = ["-ww"];
33073
+ var PS_LOCALE = process.platform === "darwin" ? "en_US.UTF-8" : "C.UTF-8";
33074
+ function readProcessCommandLine(pid, flags = PS_WIDTH_FLAGS, env = { ...process.env, LC_ALL: PS_LOCALE }) {
33075
+ return execFileSync(PS_BIN, [...flags, "-p", String(pid), "-o", "command="], {
33076
+ env,
33077
+ encoding: "utf8",
33078
+ timeout: 2e3,
33079
+ // A recycled pid can sit on a process with an argv past Node's 1 MiB exec
33080
+ // default, where the overrun surfaces as ENOBUFS instead of a command line.
33081
+ // Same ceiling as tool-server's vega-process ps probes.
33082
+ maxBuffer: 16 * 1024 * 1024,
33083
+ // Piping ps's stderr is what puts a rejected flag ("ps: invalid option --
33084
+ // 'w'") into the thrown error's message.
33085
+ stdio: ["ignore", "pipe", "pipe"]
33086
+ }).trim();
33087
+ }
33088
+ function couldBeOurToolServer(pid, marker) {
33089
+ if (!marker) return false;
33090
+ if (process.platform === "win32") return true;
33091
+ const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
33092
+ const ours = new RegExp(`(?:^|[\\t\\n\\v\\f\\r ])${escaped} start(?:[\\t\\n\\v\\f\\r ]|$)`);
33093
+ const nonAscii = [...marker].some((c) => c.charCodeAt(0) > 127);
33094
+ let failure2;
33095
+ for (const env of [void 0, process.env]) {
33096
+ try {
33097
+ if (ours.test(readProcessCommandLine(pid, PS_WIDTH_FLAGS, env))) return true;
33098
+ failure2 = void 0;
33099
+ if (!nonAscii) break;
33100
+ } catch (err) {
33101
+ failure2 = String(err);
33102
+ if (err.code === "ETIMEDOUT") break;
33103
+ }
33104
+ }
33105
+ if (failure2 !== void 0) {
33106
+ process.stderr.write(
33107
+ `[launcher] ps could not read pid ${pid}'s command line; leaving it alone: ${failure2}
33108
+ `
33109
+ );
33110
+ }
33111
+ return false;
33112
+ }
33113
+ var LOCK_WAIT_TIMEOUT_MS = 3e4;
33114
+ var LOCK_STALE_MS2 = 45e3;
33115
+ var LOCK_POLL_MS = 100;
33116
+ function spawnLockIsStale() {
33117
+ try {
33118
+ const { pid, ts } = JSON.parse(fs5.readFileSync(LOCK_FILE, "utf8"));
33119
+ if (typeof pid === "number" && pid > 0 && !isProcessAlive(pid)) return true;
33120
+ if (typeof ts === "number" && Date.now() - ts > LOCK_STALE_MS2) return true;
33121
+ return false;
33122
+ } catch {
33123
+ try {
33124
+ return Date.now() - fs5.statSync(LOCK_FILE).mtimeMs > LOCK_STALE_MS2;
33125
+ } catch {
33126
+ return true;
33127
+ }
33128
+ }
33129
+ }
33130
+ async function acquireSpawnLock() {
33131
+ try {
33132
+ fs5.mkdirSync(STATE_DIR, { recursive: true });
33133
+ } catch {
33134
+ return null;
33135
+ }
33136
+ const nonce = randomBytes(8).toString("hex");
33137
+ const deadline = Date.now() + LOCK_WAIT_TIMEOUT_MS;
33138
+ for (; ; ) {
33139
+ try {
33140
+ const fd = fs5.openSync(LOCK_FILE, "wx");
33141
+ try {
33142
+ fs5.writeSync(fd, JSON.stringify({ pid: process.pid, nonce, ts: Date.now() }));
33143
+ } finally {
33144
+ fs5.closeSync(fd);
33145
+ }
33146
+ let released = false;
33147
+ return {
33148
+ release: () => {
33149
+ if (released) return;
33150
+ released = true;
33151
+ try {
33152
+ const cur = JSON.parse(fs5.readFileSync(LOCK_FILE, "utf8"));
33153
+ if (cur.pid === process.pid && cur.nonce === nonce) fs5.unlinkSync(LOCK_FILE);
33154
+ } catch {
33155
+ }
33156
+ }
33157
+ };
33158
+ } catch (err) {
33159
+ if (err.code !== "EEXIST") return null;
33160
+ if (spawnLockIsStale()) {
33161
+ try {
33162
+ fs5.unlinkSync(LOCK_FILE);
33163
+ } catch {
33164
+ }
33165
+ if (!fs5.existsSync(LOCK_FILE)) continue;
33166
+ }
33167
+ if (Date.now() >= deadline) return null;
33168
+ await new Promise((r) => setTimeout(r, LOCK_POLL_MS));
33169
+ }
33170
+ }
33171
+ }
33172
+ async function reusableHandle(state, wantBundlePath, wantVersion) {
33173
+ if (!state || !isProcessAlive(state.pid)) return null;
33174
+ if (wantBundlePath !== void 0 && state.bundlePath !== wantBundlePath) return null;
33175
+ if (wantBundlePath !== void 0 && state.version !== void 0) {
33176
+ const diskVersion = readBundlePackageVersion(wantBundlePath);
33177
+ if (diskVersion !== void 0) {
33178
+ if (diskVersion !== state.version) return null;
33179
+ } else if (wantVersion !== void 0 && state.version !== wantVersion && isVersionNewer(wantVersion, state.version)) {
33180
+ return null;
33181
+ }
33182
+ }
33183
+ const host = state.host ?? "127.0.0.1";
33184
+ const healthy = await isToolsServerHealthy(state.port, host, 2e3, state.token);
33185
+ if (!healthy) return null;
33186
+ return { url: formatUrl(healthCheckHost(host), state.port), token: state.token ?? "" };
33187
+ }
33188
+ async function ensureToolsServer(paths) {
33189
+ const fast = await reusableHandle(
33190
+ await readState(paths.bundlePath),
33191
+ paths.bundlePath,
33192
+ paths.version
33193
+ );
33194
+ if (fast) return fast;
33195
+ const lock = await acquireSpawnLock();
33196
+ try {
33197
+ const state = await readState(paths.bundlePath);
33198
+ const reuse = await reusableHandle(state, paths.bundlePath, paths.version);
33199
+ if (reuse) return reuse;
33200
+ if (state && state.managed === "autospawn" && state.bundlePath === paths.bundlePath && isProcessAlive(state.pid) && couldBeOurToolServer(state.pid, state.bundlePath)) {
33201
+ await terminatePid(state.pid, () => couldBeOurToolServer(state.pid, state.bundlePath));
33202
+ }
33203
+ await clearToolsServerState(paths.bundlePath);
33204
+ await sweepDeadStateFiles();
33205
+ if (!fs5.existsSync(paths.bundlePath)) {
33206
+ throw new Error(
33207
+ `The argent install serving this session is gone from disk (${paths.bundlePath}) \u2014 it was likely updated or removed. Restart the editor's MCP connection to reconnect.`
33208
+ );
33209
+ }
33210
+ const diskVersion = readBundlePackageVersion(paths.bundlePath) ?? paths.version;
33211
+ const token = generateToken();
33212
+ const port = await findFreePort();
33213
+ const { port: actualPort, pid } = await spawnToolsServer(paths, port, {
33214
+ token,
33215
+ host: AUTOSPAWN_HOST,
33216
+ idleTimeoutMinutes: AUTOSPAWN_IDLE_TIMEOUT_MINUTES
33217
+ });
33218
+ await writeState({
33219
+ port: actualPort,
33220
+ pid,
33221
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
33222
+ bundlePath: paths.bundlePath,
33223
+ version: diskVersion,
33224
+ host: AUTOSPAWN_HOST,
33225
+ token,
33226
+ managed: "autospawn"
33227
+ });
33228
+ return { url: formatUrl(AUTOSPAWN_HOST, actualPort), token };
33229
+ } finally {
33230
+ lock?.release();
33231
+ }
33232
+ }
33233
+
33234
+ // ../argent-tools-client/src/tools-client.ts
33235
+ var import_yaml2 = __toESM(require_dist3(), 1);
33236
+ import { readFile as readFile5 } from "node:fs/promises";
33237
+ import { maxHeaderSize } from "node:http";
33238
+ import * as path13 from "node:path";
33239
+
33234
33240
  // ../registry/src/types.ts
33235
33241
  var LINKED_CALL_HEADER = "x-argent-linked";
33236
33242
  var E2E_DIR_CLIENT_HEADER = "x-argent-e2e-dir";
@@ -33290,8 +33296,8 @@ var UNEXPANDED_PATH = /^~|\$[A-Za-z0-9_{(]|`|%[A-Za-z_][A-Za-z0-9_]*%|^[A-Za-z][
33290
33296
  function isUnexpandedPath(p) {
33291
33297
  return UNEXPANDED_PATH.test(p);
33292
33298
  }
33293
- function isClientFileArgument({ spec, path: path18 }) {
33294
- return spec.kind === "file" && spec.path === `\${${spec.target}}` && path18.startsWith("/") && hasToolFileExtension(path18);
33299
+ function isClientFileArgument({ spec, path: path19 }) {
33300
+ return spec.kind === "file" && spec.path === `\${${spec.target}}` && path19.startsWith("/") && hasToolFileExtension(path19);
33295
33301
  }
33296
33302
 
33297
33303
  // ../registry/src/flow-platforms.ts
@@ -33300,22 +33306,22 @@ var SELECTABLE_PLATFORMS = [...LAUNCH_PLATFORMS, "ios-remote"];
33300
33306
 
33301
33307
  // ../registry/src/flow-file-refs.ts
33302
33308
  import * as fs7 from "node:fs/promises";
33303
- import * as path8 from "node:path";
33309
+ import * as path9 from "node:path";
33304
33310
 
33305
33311
  // ../registry/src/e2e-dirs.ts
33306
33312
  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")]);
33313
+ import * as path8 from "node:path";
33314
+ var E2E_DIR = path8.join(".argent", "e2e");
33315
+ var LEGACY_E2E_DIRS = Object.freeze([path8.join(".argent", "flows")]);
33310
33316
  var E2E_DIRS = Object.freeze([E2E_DIR, ...LEGACY_E2E_DIRS]);
33311
33317
  function e2eDirFor(projectRoot) {
33312
- return path7.join(projectRoot, E2E_DIR);
33318
+ return path8.join(projectRoot, E2E_DIR);
33313
33319
  }
33314
33320
  function e2eDirsFor(projectRoot) {
33315
- return E2E_DIRS.map((dir) => path7.join(projectRoot, dir));
33321
+ return E2E_DIRS.map((dir) => path8.join(projectRoot, dir));
33316
33322
  }
33317
33323
  function e2eFileCandidates(projectRoot, name) {
33318
- return e2eDirsFor(projectRoot).map((dir) => path7.join(dir, `${name}.yaml`));
33324
+ return e2eDirsFor(projectRoot).map((dir) => path8.join(dir, `${name}.yaml`));
33319
33325
  }
33320
33326
  async function exists(file) {
33321
33327
  return fs6.stat(file).then(
@@ -33345,21 +33351,21 @@ async function pickE2eFile(candidates) {
33345
33351
  function e2eShadowWarning(used, shadowed) {
33346
33352
  return `${shadowed} is not used: ${used} has the same name and is read first.`;
33347
33353
  }
33348
- var E2E_DIR_NAMES = E2E_DIRS.map((dir) => path7.basename(dir));
33354
+ var E2E_DIR_NAMES = E2E_DIRS.map((dir) => path8.basename(dir));
33349
33355
  function e2eDirProject(dir) {
33350
33356
  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") {
33357
+ const argent = path8.dirname(trimmed);
33358
+ if (!E2E_DIR_NAMES.includes(path8.basename(trimmed)) || path8.basename(argent) !== ".argent") {
33353
33359
  return null;
33354
33360
  }
33355
- return path7.dirname(argent);
33361
+ return path8.dirname(argent);
33356
33362
  }
33357
33363
  function e2eRunFallbackDirs(anchorDir, target) {
33358
33364
  if (target.includes("/") || target.includes("\\")) return [];
33359
33365
  const project = e2eDirProject(anchorDir);
33360
33366
  if (project === null) return [];
33361
- const anchor2 = path7.resolve(anchorDir);
33362
- return e2eDirsFor(project).filter((dir) => path7.resolve(dir) !== anchor2);
33367
+ const anchor2 = path8.resolve(anchorDir);
33368
+ return e2eDirsFor(project).filter((dir) => path8.resolve(dir) !== anchor2);
33363
33369
  }
33364
33370
 
33365
33371
  // ../registry/src/tool-ids.ts
@@ -33412,7 +33418,7 @@ async function canonicalFlowPath(p) {
33412
33418
  return await fs7.realpath(p);
33413
33419
  } catch {
33414
33420
  try {
33415
- return path8.join(await fs7.realpath(path8.dirname(p)), path8.basename(p));
33421
+ return path9.join(await fs7.realpath(path9.dirname(p)), path9.basename(p));
33416
33422
  } catch {
33417
33423
  return p;
33418
33424
  }
@@ -33421,7 +33427,7 @@ async function canonicalFlowPath(p) {
33421
33427
  function completeRunExtension(value) {
33422
33428
  if (value.endsWith(".yaml")) return value;
33423
33429
  const candidate = `${value}.yaml`;
33424
- return FLOW_FILE_NAME_PATTERN.test(path8.posix.basename(candidate)) ? candidate : value;
33430
+ return FLOW_FILE_NAME_PATTERN.test(path9.posix.basename(candidate)) ? candidate : value;
33425
33431
  }
33426
33432
  var MAX_RUN_DEPTH = 20;
33427
33433
  var MAX_BLOCK_NESTING = 64;
@@ -33443,9 +33449,9 @@ function collectFlowRequests(doc) {
33443
33449
  for (const step of steps) {
33444
33450
  if (!isRecord(step)) continue;
33445
33451
  const run = step.run;
33446
- if (typeof run === "string" && !run.includes("\\") && !path8.posix.isAbsolute(run) && !/^[A-Za-z]:/.test(run)) {
33452
+ if (typeof run === "string" && !run.includes("\\") && !path9.posix.isAbsolute(run) && !/^[A-Za-z]:/.test(run)) {
33447
33453
  const target = completeRunExtension(run);
33448
- if (FLOW_FILE_NAME_PATTERN.test(path8.posix.basename(target))) runTargets.add(target);
33454
+ if (FLOW_FILE_NAME_PATTERN.test(path9.posix.basename(target))) runTargets.add(target);
33449
33455
  }
33450
33456
  const snapshot = isRecord(step.snapshot) ? step.snapshot.name : step.snapshot;
33451
33457
  if (typeof snapshot === "string" && FLOW_NAME_PATTERN.test(snapshot)) snapshots.add(snapshot);
@@ -33465,7 +33471,7 @@ function collectFlowRequests(doc) {
33465
33471
  return { runTargets: [...runTargets], snapshots: [...snapshots], toolSteps, nested };
33466
33472
  }
33467
33473
  function baselineKeyFor(canonicalPath2, flowName) {
33468
- const stem = path8.basename(canonicalPath2, ".yaml");
33474
+ const stem = path9.basename(canonicalPath2, ".yaml");
33469
33475
  return FLOW_NAME_PATTERN.test(stem) ? stem : flowName;
33470
33476
  }
33471
33477
  function flowMemberKey(anchorDir, target) {
@@ -33494,11 +33500,11 @@ function nestedFlowTarget(args) {
33494
33500
  return { kind: "name", projectRoot, name, path: paths[0], paths };
33495
33501
  }
33496
33502
  if (name !== void 0 || !isResolvedAbsolute(flowPath)) return void 0;
33497
- if (!FLOW_FILE_NAME_PATTERN.test(path8.basename(flowPath))) return void 0;
33503
+ if (!FLOW_FILE_NAME_PATTERN.test(path9.basename(flowPath))) return void 0;
33498
33504
  return { kind: "e2e_test_path", path: flowPath };
33499
33505
  }
33500
33506
  function isResolvedAbsolute(value) {
33501
- return typeof value === "string" && path8.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
33507
+ return typeof value === "string" && path9.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
33502
33508
  }
33503
33509
 
33504
33510
  // ../registry/src/failure-codes.ts
@@ -34016,9 +34022,9 @@ var FAILURE_SPAWN_CODE_SET = new Set(FAILURE_SPAWN_CODES);
34016
34022
  import { randomUUID as randomUUID3 } from "node:crypto";
34017
34023
  import { AsyncLocalStorage } from "node:async_hooks";
34018
34024
  var resolvedDuringInvocation = new AsyncLocalStorage();
34019
- function valueAtPath(root, path18) {
34025
+ function valueAtPath(root, path19) {
34020
34026
  let current = root;
34021
- for (const key of path18) {
34027
+ for (const key of path19) {
34022
34028
  if (current === null || typeof current !== "object") return void 0;
34023
34029
  if (!Object.hasOwn(current, key)) return void 0;
34024
34030
  current = current[key];
@@ -34076,11 +34082,10 @@ function describeParamIssues(error2, params) {
34076
34082
  }
34077
34083
 
34078
34084
  // ../argent-tools-client/src/link-config.ts
34079
- import * as path9 from "node:path";
34080
- import { homedir as homedir4 } from "node:os";
34085
+ import * as path10 from "node:path";
34081
34086
  import { mkdir as mkdir2, writeFile as writeFile2, readFile as readFile2, unlink as unlink2, chmod as chmod2 } from "node:fs/promises";
34082
- var LINK_DIR = path9.join(homedir4(), ".argent");
34083
- var LINK_FILE = path9.join(LINK_DIR, "link.json");
34087
+ var LINK_DIR = argentHomeDir();
34088
+ var LINK_FILE = path10.join(LINK_DIR, "link.json");
34084
34089
  async function readLinkConfig() {
34085
34090
  try {
34086
34091
  const raw2 = await readFile2(LINK_FILE, "utf8");
@@ -34133,14 +34138,14 @@ import {
34133
34138
  writeFile as writeFile3
34134
34139
  } from "node:fs/promises";
34135
34140
  import { constants, tmpdir } from "node:os";
34136
- import * as path10 from "node:path";
34141
+ import * as path11 from "node:path";
34137
34142
 
34138
34143
  // ../archive/src/index.ts
34139
34144
  import { spawn as spawn2 } from "node:child_process";
34140
34145
  import { once } from "node:events";
34141
34146
  import { createReadStream, createWriteStream } from "node:fs";
34142
34147
  import { open as open2, rm, readdir as readdir3 } from "node:fs/promises";
34143
- import { basename as basename4, dirname as dirname5, join as join9, resolve as resolve7, sep as sep2 } from "node:path";
34148
+ import { basename as basename4, dirname as dirname5, join as join10, resolve as resolve8, sep as sep2 } from "node:path";
34144
34149
  import { Writable } from "node:stream";
34145
34150
  import { pipeline } from "node:stream/promises";
34146
34151
  import zlib from "node:zlib";
@@ -34295,7 +34300,7 @@ async function runTar(archive, args, signal) {
34295
34300
  child.on("error", (err) => {
34296
34301
  childError = err;
34297
34302
  });
34298
- const closed = new Promise((resolve12) => child.once("close", resolve12));
34303
+ const closed = new Promise((resolve13) => child.once("close", resolve13));
34299
34304
  const stdout = collect(child.stdout, MAX_LISTING_BYTES, {
34300
34305
  maxLines: MAX_LISTING_LINES,
34301
34306
  onOverflow: () => child.kill()
@@ -34344,16 +34349,16 @@ async function runTar(archive, args, signal) {
34344
34349
  function normalizeTarMemberPath(memberPath) {
34345
34350
  return memberPath.replace(/^\.\//, "").replace(/\\/g, "/");
34346
34351
  }
34347
- function isContainedPath(path18, windows = process.platform === "win32") {
34348
- const slashed = path18.replace(/\\/g, "/");
34352
+ function isContainedPath(path19, windows = process.platform === "win32") {
34353
+ const slashed = path19.replace(/\\/g, "/");
34349
34354
  const drive = windows ? /^[A-Za-z]:/ : /^[A-Za-z]:\//;
34350
34355
  return !slashed.startsWith("/") && !drive.test(slashed) && !slashed.split("/").includes("..");
34351
34356
  }
34352
34357
  function isSafeTarMember(memberPath, destDir) {
34353
34358
  const normalized = normalizeTarMemberPath(memberPath);
34354
34359
  if (!isContainedPath(normalized)) return false;
34355
- const root = resolve7(destDir);
34356
- return resolve7(destDir, normalized).startsWith(root + sep2);
34360
+ const root = resolve8(destDir);
34361
+ return resolve8(destDir, normalized).startsWith(root + sep2);
34357
34362
  }
34358
34363
  async function readListing(archive, args, signal) {
34359
34364
  try {
@@ -34405,7 +34410,7 @@ async function assertSafeArchive(archive, destDir, signal) {
34405
34410
  async function resolveMember(destDir, expectedName) {
34406
34411
  const entries = await readdir3(destDir);
34407
34412
  if (entries.includes(expectedName)) {
34408
- return join9(destDir, expectedName);
34413
+ return join10(destDir, expectedName);
34409
34414
  }
34410
34415
  const real = entries.filter((e) => !e.startsWith("._"));
34411
34416
  if (real.length !== 1) {
@@ -34413,7 +34418,7 @@ async function resolveMember(destDir, expectedName) {
34413
34418
  `Could not identify the extracted member (expected "${expectedName}", found ${real.length} entries).`
34414
34419
  );
34415
34420
  }
34416
- return join9(destDir, real[0]);
34421
+ return join10(destDir, real[0]);
34417
34422
  }
34418
34423
  async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
34419
34424
  signal?.throwIfAborted();
@@ -34466,20 +34471,20 @@ function interpolatePath(template, args) {
34466
34471
  return missing ? null : out;
34467
34472
  }
34468
34473
  function callerPath(p) {
34469
- const onCurrentDrive = path10.sep === "\\" && /^[\\/](?![\\/])/.test(p);
34470
- if (!onCurrentDrive && (path10.isAbsolute(p) || path10.win32.isAbsolute(p) || isUnexpandedPath(p))) {
34474
+ const onCurrentDrive = path11.sep === "\\" && /^[\\/](?![\\/])/.test(p);
34475
+ if (!onCurrentDrive && (path11.isAbsolute(p) || path11.win32.isAbsolute(p) || isUnexpandedPath(p))) {
34471
34476
  return p;
34472
34477
  }
34473
- const { root } = path10.parse(p);
34478
+ const { root } = path11.parse(p);
34474
34479
  const rest = p.slice(root.length);
34475
34480
  if (!rest.split(/[\\/]/).includes("..")) {
34476
- const resolved = path10.resolve(p);
34477
- const last = p.split(path10.sep === "\\" ? /[\\/]/ : "/").at(-1);
34478
- const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(path10.sep);
34479
- return dirOnly ? `${resolved}${path10.sep}` : resolved;
34481
+ const resolved = path11.resolve(p);
34482
+ const last = p.split(path11.sep === "\\" ? /[\\/]/ : "/").at(-1);
34483
+ const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(path11.sep);
34484
+ return dirOnly ? `${resolved}${path11.sep}` : resolved;
34480
34485
  }
34481
- const base = path10.resolve(root);
34482
- return base.endsWith(path10.sep) ? `${base}${rest}` : `${base}${path10.sep}${rest}`;
34486
+ const base = path11.resolve(root);
34487
+ return base.endsWith(path11.sep) ? `${base}${rest}` : `${base}${path11.sep}${rest}`;
34483
34488
  }
34484
34489
  async function specPath(spec, args) {
34485
34490
  if (spec.kind !== "file" || !spec.paths?.length) return interpolatePath(spec.path, args);
@@ -34526,9 +34531,9 @@ function untrackArchive(archive) {
34526
34531
  process.removeListener("exit", removePendingArchives);
34527
34532
  }
34528
34533
  function sha256File(filePath, signal) {
34529
- return new Promise((resolve12, reject) => {
34534
+ return new Promise((resolve13, reject) => {
34530
34535
  const hash = createHash2("sha256");
34531
- createReadStream2(filePath, { signal }).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve12(hash.digest("hex"))).on("error", reject);
34536
+ createReadStream2(filePath, { signal }).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve13(hash.digest("hex"))).on("error", reject);
34532
34537
  });
34533
34538
  }
34534
34539
  function toolServerError(text) {
@@ -34587,7 +34592,7 @@ async function uploadTar(tarPath, format, endpoint, signal) {
34587
34592
  }
34588
34593
  async function uploadFile(sourcePath, endpoint, signal) {
34589
34594
  const format = pickArchiveFormat(endpoint.formats);
34590
- const tarPath = path10.join(tmpdir(), `argent-upload-${randomUUID4()}.tar.gz`);
34595
+ const tarPath = path11.join(tmpdir(), `argent-upload-${randomUUID4()}.tar.gz`);
34591
34596
  trackArchive(tarPath);
34592
34597
  try {
34593
34598
  await createArchiveFile(await realpath2(sourcePath), tarPath, format, signal);
@@ -34662,7 +34667,7 @@ async function prepareFileInputs(specs, args, opts) {
34662
34667
  wire.mtimeMs = st.mtimeMs;
34663
34668
  }
34664
34669
  if (opts.uploadEndpoint && st) {
34665
- process.stderr.write(`Uploading ${path10.basename(filePath)} to the remote tool-server...
34670
+ process.stderr.write(`Uploading ${path11.basename(filePath)} to the remote tool-server...
34666
34671
  `);
34667
34672
  Object.assign(wire, await uploadFile(filePath, opts.uploadEndpoint, opts.signal));
34668
34673
  }
@@ -34672,7 +34677,7 @@ async function prepareFileInputs(specs, args, opts) {
34672
34677
  return out;
34673
34678
  }
34674
34679
  function isAllowedClientFilePath(p) {
34675
- if (!path10.isAbsolute(p)) return false;
34680
+ if (!path11.isAbsolute(p)) return false;
34676
34681
  const segments = p.split(/[\\/]+/);
34677
34682
  if (segments.includes("..")) return false;
34678
34683
  const file = segments[segments.length - 1] ?? "";
@@ -34683,7 +34688,7 @@ function isClientFileDirective2(value) {
34683
34688
  return !!value && typeof value === "object" && value[CLIENT_FILE_MARKER2] === true && typeof value.path === "string" && typeof value.content === "string";
34684
34689
  }
34685
34690
  async function replaceFile(target, bytes, mode) {
34686
- const temp = path10.join(path10.dirname(target), `.baseline-${randomUUID4()}.tmp`);
34691
+ const temp = path11.join(path11.dirname(target), `.baseline-${randomUUID4()}.tmp`);
34687
34692
  try {
34688
34693
  await writeFile3(temp, bytes, { flag: "wx" });
34689
34694
  if (mode !== void 0) await chmod3(temp, mode & 511);
@@ -34694,27 +34699,27 @@ async function replaceFile(target, bytes, mode) {
34694
34699
  }
34695
34700
  }
34696
34701
  async function writeBaselineFile(file, bytes, allowedDirs) {
34697
- if (!path10.isAbsolute(file) || path10.normalize(file) !== file || file.split(/[\\/]/).includes("..") || !file.endsWith(".png") || !allowedDirs.includes(path10.dirname(file))) {
34702
+ if (!path11.isAbsolute(file) || path11.normalize(file) !== file || file.split(/[\\/]/).includes("..") || !file.endsWith(".png") || !allowedDirs.includes(path11.dirname(file))) {
34698
34703
  return allowedDirs.length === 0 ? "this call writes no baselines" : `${file} is not a baseline of this call (${allowedDirs.map((d) => `${d}/<name>.png`).join(", ")})`;
34699
34704
  }
34700
34705
  if (bytes.length > MAX_CONTENT_BYTES) {
34701
34706
  return `${file}: the baseline is larger than the 32 MiB cap on a file this client writes`;
34702
34707
  }
34703
- const dir = path10.dirname(file);
34708
+ const dir = path11.dirname(file);
34704
34709
  await mkdir3(dir, { recursive: true });
34705
34710
  const link = await lstat(file).catch(() => null);
34706
34711
  const real = link === null ? null : await realpath2(file).catch(() => null);
34707
34712
  if (link !== null && real === null) return `${file} is a symbolic link to a missing file`;
34708
34713
  if (real !== null) {
34709
34714
  if (!real.endsWith(".png")) return `${file} links to a file that is not a PNG file`;
34710
- if (path10.dirname(real) !== await realpath2(dir)) {
34715
+ if (path11.dirname(real) !== await realpath2(dir)) {
34711
34716
  return `${file} links outside its baseline directory`;
34712
34717
  }
34713
34718
  }
34714
34719
  const existing = real === null ? null : await stat3(real);
34715
34720
  if (existing !== null && !existing.isFile()) return `${file} is not a regular file`;
34716
34721
  await replaceFile(
34717
- real ?? path10.join(await realpath2(dir), path10.basename(file)),
34722
+ real ?? path11.join(await realpath2(dir), path11.basename(file)),
34718
34723
  bytes,
34719
34724
  existing?.mode
34720
34725
  );
@@ -34740,7 +34745,7 @@ async function applyClientFileDirectives(result, opts = {}) {
34740
34745
  if (isClientFileDirective2(value)) {
34741
34746
  if (!isAllowedClientFilePath(value.path)) return null;
34742
34747
  try {
34743
- await mkdir3(path10.dirname(value.path), { recursive: true });
34748
+ await mkdir3(path11.dirname(value.path), { recursive: true });
34744
34749
  await writeFile3(value.path, value.content, "utf8");
34745
34750
  written.push(value.path);
34746
34751
  return value.path;
@@ -34767,15 +34772,15 @@ async function applyClientFileDirectives(result, opts = {}) {
34767
34772
  }
34768
34773
 
34769
34774
  // ../argent-tools-client/src/flow-files.ts
34770
- var import_yaml = __toESM(require_dist2(), 1);
34775
+ var import_yaml = __toESM(require_dist3(), 1);
34771
34776
  import { readdir as readdir4, readFile as readFile4, realpath as realpath3, stat as stat4 } from "node:fs/promises";
34772
- import * as path11 from "node:path";
34777
+ import * as path12 from "node:path";
34773
34778
  var INLINE_MEMBERS_BYTES = 256 * 1024;
34774
34779
  function filesLogEnabled() {
34775
34780
  return (process.env.ARGENT_E2E_FILES_LOG ?? process.env.ARGENT_FLOW_FILES_LOG) === "1";
34776
34781
  }
34777
34782
  function isWithin(inner, outer) {
34778
- return inner === outer || inner.startsWith(outer.endsWith(path11.sep) ? outer : outer + path11.sep);
34783
+ return inner === outer || inner.startsWith(outer.endsWith(path12.sep) ? outer : outer + path12.sep);
34779
34784
  }
34780
34785
  function printable(text) {
34781
34786
  return [...text].map(
@@ -34783,7 +34788,7 @@ function printable(text) {
34783
34788
  ).join("");
34784
34789
  }
34785
34790
  function isResolvedAbsolute2(value) {
34786
- return typeof value === "string" && path11.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
34791
+ return typeof value === "string" && path12.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
34787
34792
  }
34788
34793
  function namesValidFlow(args) {
34789
34794
  let canonical;
@@ -34795,13 +34800,13 @@ function namesValidFlow(args) {
34795
34800
  const { project_root, e2e_test_path: testPath, name } = canonical;
34796
34801
  if (!isResolvedAbsolute2(project_root)) return false;
34797
34802
  if (name === void 0) {
34798
- return isResolvedAbsolute2(testPath) && FLOW_FILE_NAME_PATTERN.test(path11.basename(testPath));
34803
+ return isResolvedAbsolute2(testPath) && FLOW_FILE_NAME_PATTERN.test(path12.basename(testPath));
34799
34804
  }
34800
34805
  return testPath === void 0 && typeof name === "string" && FLOW_NAME_PATTERN.test(name);
34801
34806
  }
34802
34807
  function savedFlowProject(file) {
34803
- if (!path11.isAbsolute(file)) return null;
34804
- for (let dir = path11.dirname(file); dir !== path11.dirname(dir); dir = path11.dirname(dir)) {
34808
+ if (!path12.isAbsolute(file)) return null;
34809
+ for (let dir = path12.dirname(file); dir !== path12.dirname(dir); dir = path12.dirname(dir)) {
34805
34810
  const project = e2eDirProject(dir);
34806
34811
  if (project !== null) return project;
34807
34812
  }
@@ -34816,11 +34821,11 @@ async function landing(spelled) {
34816
34821
  const canonical = await canonicalFlowPath(spelled);
34817
34822
  let at = spelled;
34818
34823
  for (; ; ) {
34819
- const parent = path11.dirname(at);
34824
+ const parent = path12.dirname(at);
34820
34825
  if (parent === at) return { canonical, fence: spelled, ...failure2 };
34821
34826
  const real = await realpath3(parent).catch(() => null);
34822
34827
  if (real !== null) {
34823
- return { canonical, fence: path11.join(real, path11.basename(at)), ...failure2 };
34828
+ return { canonical, fence: path12.join(real, path12.basename(at)), ...failure2 };
34824
34829
  }
34825
34830
  at = parent;
34826
34831
  }
@@ -34828,10 +34833,10 @@ async function landing(spelled) {
34828
34833
  }
34829
34834
  async function closureRoots(rootPath, rootCanonical, projectRoot) {
34830
34835
  const candidates = [];
34831
- if (typeof projectRoot === "string" && path11.isAbsolute(projectRoot)) {
34836
+ if (typeof projectRoot === "string" && path12.isAbsolute(projectRoot)) {
34832
34837
  candidates.push(projectRoot, ...e2eDirsFor(projectRoot));
34833
34838
  }
34834
- candidates.push(path11.dirname(rootPath), path11.dirname(rootCanonical));
34839
+ candidates.push(path12.dirname(rootPath), path12.dirname(rootCanonical));
34835
34840
  for (const file of [rootPath, rootCanonical]) {
34836
34841
  const project = savedFlowProject(file);
34837
34842
  if (project !== null) candidates.push(project);
@@ -34844,11 +34849,11 @@ async function closureRoots(rootPath, rootCanonical, projectRoot) {
34844
34849
  return real.filter((root) => !real.some((other) => other !== root && isWithin(root, other)));
34845
34850
  }
34846
34851
  async function readFlowMember(anchorDir, target, roots, budget, opts) {
34847
- const spelled = anchorDir + path11.sep + target;
34852
+ const spelled = anchorDir + path12.sep + target;
34848
34853
  const { canonical, fence, missing, error: error2 } = await landing(spelled);
34849
34854
  const spelling = await classifyOnDiskSpelling(
34850
- path11.dirname(spelled),
34851
- path11.posix.basename(target),
34855
+ path12.dirname(spelled),
34856
+ path12.posix.basename(target),
34852
34857
  FLOW_FILE_NAME_PATTERN
34853
34858
  );
34854
34859
  const member = {
@@ -34873,7 +34878,7 @@ async function readFlowMember(anchorDir, target, roots, budget, opts) {
34873
34878
  return { member: { ...member, state: "missing" }, sent: "missing" };
34874
34879
  }
34875
34880
  if (st.isDirectory()) return refuse("EISDIR: illegal operation on a directory, read");
34876
- if (!/\.ya?ml$/i.test(path11.basename(canonical))) {
34881
+ if (!/\.ya?ml$/i.test(path12.basename(canonical))) {
34877
34882
  return refuse(`${target} links to a file that is not a YAML file`);
34878
34883
  }
34879
34884
  const sent = await sendBytes(member, canonical, budget, opts);
@@ -34998,12 +35003,12 @@ function memberCollector(roots, opts) {
34998
35003
  }
34999
35004
  async function savedTest(target) {
35000
35005
  for (const candidate of target.paths) {
35001
- const found = await flow(path11.dirname(candidate), path11.basename(candidate), true);
35006
+ const found = await flow(path12.dirname(candidate), path12.basename(candidate), true);
35002
35007
  if (found !== void 0) return found;
35003
35008
  }
35004
35009
  let first;
35005
35010
  for (const candidate of target.paths) {
35006
- first ??= await flow(path11.dirname(candidate), path11.basename(candidate));
35011
+ first ??= await flow(path12.dirname(candidate), path12.basename(candidate));
35007
35012
  }
35008
35013
  return first;
35009
35014
  }
@@ -35040,7 +35045,7 @@ function memberCollector(roots, opts) {
35040
35045
  const requests = collectFlowRequests(doc);
35041
35046
  for (const name of requests.snapshots) snapshots.add(name);
35042
35047
  for (const step of requests.toolSteps) await toolFiles(step);
35043
- const anchorDir = path11.dirname(file.canonical);
35048
+ const anchorDir = path12.dirname(file.canonical);
35044
35049
  for (const target of requests.runTargets) {
35045
35050
  const key = flowMemberKey(anchorDir, target);
35046
35051
  if (visited.has(key)) continue;
@@ -35062,8 +35067,8 @@ function memberCollector(roots, opts) {
35062
35067
  }
35063
35068
  }
35064
35069
  if (snapshots.size === 0) continue;
35065
- const dir = path11.join(
35066
- path11.dirname(run.canonical),
35070
+ const dir = path12.join(
35071
+ path12.dirname(run.canonical),
35067
35072
  "__baselines__",
35068
35073
  baselineKeyFor(run.canonical, run.flowName)
35069
35074
  );
@@ -35087,7 +35092,7 @@ function memberCollector(roots, opts) {
35087
35092
  if (!name.endsWith(".png")) continue;
35088
35093
  const compared = [...prefixes].some((prefix) => name.startsWith(prefix));
35089
35094
  if (!updates && !compared) continue;
35090
- const file = path11.join(dir, name);
35095
+ const file = path12.join(dir, name);
35091
35096
  if (tools.has(file)) continue;
35092
35097
  const member = { role: "baseline", key: file, path: file };
35093
35098
  const entry = await baselineEntry(file, roots, updates && !compared);
@@ -35110,8 +35115,8 @@ async function collectFlowMembers(rootPath, rootBytes, args, opts) {
35110
35115
  if (!namesValidFlow(args)) return {};
35111
35116
  const canonical = await canonicalFlowPath(rootPath);
35112
35117
  const spelling = await classifyOnDiskSpelling(
35113
- path11.dirname(rootPath),
35114
- path11.basename(rootPath),
35118
+ path12.dirname(rootPath),
35119
+ path12.basename(rootPath),
35115
35120
  FLOW_FILE_NAME_PATTERN
35116
35121
  );
35117
35122
  const collector = memberCollector(
@@ -35122,7 +35127,7 @@ async function collectFlowMembers(rootPath, rootBytes, args, opts) {
35122
35127
  {
35123
35128
  canonical,
35124
35129
  text: rootBytes.toString("utf8"),
35125
- flowName: path11.basename(rootPath, ".yaml"),
35130
+ flowName: path12.basename(rootPath, ".yaml"),
35126
35131
  hop: 0,
35127
35132
  updates: args.updateBaselines === true,
35128
35133
  platform: callPlatform(args)
@@ -35151,31 +35156,31 @@ async function collectStepMembers(args, opts, recordingDirFor = e2eDirFor) {
35151
35156
  if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name) || !isResolvedAbsolute2(projectRoot) || step === void 0) {
35152
35157
  return [];
35153
35158
  }
35154
- const recording = path11.join(recordingDirFor(projectRoot), `${name}.yaml`);
35159
+ const recording = path12.join(recordingDirFor(projectRoot), `${name}.yaml`);
35155
35160
  const collector = memberCollector(
35156
35161
  await closureRoots(recording, (await landing(recording)).canonical, projectRoot),
35157
35162
  opts
35158
35163
  );
35159
35164
  await collector.toolFiles(step);
35160
35165
  if (canonicalToolId(step.tool) === "e2e-execute") {
35161
- const self = await collector.flow(path11.dirname(recording), path11.basename(recording));
35166
+ const self = await collector.flow(path12.dirname(recording), path12.basename(recording));
35162
35167
  let runArgs = step.args;
35163
35168
  const named = nestedFlowTarget(runArgs);
35164
35169
  if (named?.kind === "e2e_test_path") {
35165
- const stem = path11.basename(named.path, ".yaml");
35166
- const base = path11.basename(named.path);
35167
- const dir = path11.resolve(path11.dirname(named.path));
35168
- const recordingDir = path11.dirname(recording);
35170
+ const stem = path12.basename(named.path, ".yaml");
35171
+ const base = path12.basename(named.path);
35172
+ const dir = path12.resolve(path12.dirname(named.path));
35173
+ const recordingDir = path12.dirname(recording);
35169
35174
  const dirs = [recordingDir, ...e2eRunFallbackDirs(recordingDir, base)];
35170
- if (dirs.some((d) => path11.resolve(d) === dir)) {
35171
- await collector.flow(path11.dirname(named.path), base);
35175
+ if (dirs.some((d) => path12.resolve(d) === dir)) {
35176
+ await collector.flow(path12.dirname(named.path), base);
35172
35177
  runArgs = { ...runArgs, name: stem };
35173
35178
  delete runArgs.e2e_test_path;
35174
35179
  }
35175
35180
  }
35176
35181
  const target = nestedFlowTarget(runArgs);
35177
35182
  if (target?.kind === "name") {
35178
- await collector.flow(path11.dirname(self.member.canonical), `${target.name}.yaml`);
35183
+ await collector.flow(path12.dirname(self.member.canonical), `${target.name}.yaml`);
35179
35184
  const run = await collector.nestedRun(
35180
35185
  target,
35181
35186
  0,
@@ -35369,10 +35374,10 @@ function assertFiniteNumbers(args) {
35369
35374
  if (typeof item === "object" && item !== null) {
35370
35375
  pending.push({ value: item, key, parent: visit });
35371
35376
  } else if (typeof item === "number" && !Number.isFinite(item)) {
35372
- const path18 = [key];
35373
- for (let at = visit; at.parent; at = at.parent) path18.push(at.key);
35374
- path18.reverse();
35375
- issues.push({ code: "invalid_type", path: path18, message: `expected a number, got ${item}` });
35377
+ const path19 = [key];
35378
+ for (let at = visit; at.parent; at = at.parent) path19.push(at.key);
35379
+ path19.reverse();
35380
+ issues.push({ code: "invalid_type", path: path19, message: `expected a number, got ${item}` });
35376
35381
  if (issues.length === MAX_NON_FINITE_ISSUES) break;
35377
35382
  }
35378
35383
  }
@@ -35557,7 +35562,7 @@ function createToolsClient(options = {}) {
35557
35562
  log: diagnose,
35558
35563
  baselineDirs,
35559
35564
  collectMembers: collectFlowMembers,
35560
- collectStepMembers: olderServer ? (record2, o) => collectStepMembers(record2, o, (root) => path12.join(root, LEGACY_E2E_DIRS[0])) : collectStepMembers,
35565
+ collectStepMembers: olderServer ? (record2, o) => collectStepMembers(record2, o, (root) => path13.join(root, LEGACY_E2E_DIRS[0])) : collectStepMembers,
35561
35566
  toolFileInputs: (tool) => findTool(tools, tool)?.fileInputs,
35562
35567
  signal: opts?.signal
35563
35568
  });
@@ -35570,7 +35575,7 @@ function createToolsClient(options = {}) {
35570
35575
  }
35571
35576
  if (filesLogEnabled()) {
35572
35577
  for (const file of applied.written) {
35573
- if (baselineDirs.includes(path12.dirname(file))) {
35578
+ if (baselineDirs.includes(path13.dirname(file))) {
35574
35579
  diagnose(`[e2e-files] baseline ${file}: written`);
35575
35580
  }
35576
35581
  }
@@ -35714,7 +35719,7 @@ import {
35714
35719
  } from "node:fs/promises";
35715
35720
  import { constants as fsConstants } from "node:fs";
35716
35721
  import { tmpdir as tmpdir2 } from "node:os";
35717
- import { basename as basename7, dirname as dirname9, extname as extname2, isAbsolute as isAbsolute6, join as join13, normalize as normalize2, resolve as resolve10, sep as sep5 } from "node:path";
35722
+ import { basename as basename7, extname as extname2, isAbsolute as isAbsolute6, join as join14, normalize as normalize2, resolve as resolve11, sep as sep5 } from "node:path";
35718
35723
  import { createHash as createHash3 } from "node:crypto";
35719
35724
  var ARTIFACT_MARKER2 = "__argentArtifact";
35720
35725
  function isArtifactHandle(value) {
@@ -35738,16 +35743,16 @@ function projectSlug() {
35738
35743
  return `${name}-${hash}`;
35739
35744
  }
35740
35745
  function artifactsRoot() {
35741
- return process.env.ARGENT_ARTIFACTS_DIR ?? join13(tmpdir2(), "argent-artifacts");
35746
+ return process.env.ARGENT_ARTIFACTS_DIR ?? join14(tmpdir2(), "argent-artifacts");
35742
35747
  }
35743
35748
  function artifactDir(deviceId) {
35744
35749
  const parts = [artifactsRoot(), projectSlug(), sessionId()];
35745
35750
  if (deviceId) parts.push(sanitizeSegment(deviceId));
35746
- return join13(...parts);
35751
+ return join14(...parts);
35747
35752
  }
35748
35753
  function durableBaseDir() {
35749
35754
  const projectRoot = findProjectRoot(process.cwd());
35750
- return projectRoot ?? dirname9(argentHomeDir());
35755
+ return projectRoot ?? resolveHomeDir();
35751
35756
  }
35752
35757
  var ALLOWED_SAVE_DIRS = /* @__PURE__ */ new Set([normalize2(".argent/recordings")]);
35753
35758
  var RECORDINGS_SAVE_DIR = normalize2(".argent/recordings");
@@ -35761,9 +35766,9 @@ function configuredRecordingsDir() {
35761
35766
  if (typeof value !== "string") return null;
35762
35767
  const trimmed = value.trim();
35763
35768
  if (trimmed === "") return null;
35764
- const home = dirname9(argentHomeDir());
35765
- const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep5}`) ? join13(home, trimmed.slice(2)) : trimmed;
35766
- return resolve10(durableBaseDir(), expanded);
35769
+ const home = resolveHomeDir();
35770
+ const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep5}`) ? join14(home, trimmed.slice(2)) : trimmed;
35771
+ return resolve11(durableBaseDir(), expanded);
35767
35772
  }
35768
35773
  var MAX_ARTIFACT_BYTES = 2 * 1024 * 1024 * 1024;
35769
35774
  async function readCapped(res, cap) {
@@ -35796,10 +35801,10 @@ async function writeDurableUnique(dir, filename, write) {
35796
35801
  const stem = filename.slice(0, filename.length - ext.length);
35797
35802
  for (let i = 1; i <= 1e3; i++) {
35798
35803
  const candidate = i === 1 ? filename : `${stem} (${i})${ext}`;
35799
- const path18 = join13(dir, candidate);
35804
+ const path19 = join14(dir, candidate);
35800
35805
  try {
35801
- await write(path18);
35802
- return path18;
35806
+ await write(path19);
35807
+ return path19;
35803
35808
  } catch (err) {
35804
35809
  if (err?.code === "EEXIST") continue;
35805
35810
  throw err;
@@ -35819,21 +35824,21 @@ function durableSaveTarget(handle) {
35819
35824
  if (configured) {
35820
35825
  return {
35821
35826
  dir: configured,
35822
- path: join13(configured, sanitizeSegment(handle.filename)),
35827
+ path: join14(configured, sanitizeSegment(handle.filename)),
35823
35828
  base: configured,
35824
35829
  rel: ""
35825
35830
  };
35826
35831
  }
35827
35832
  }
35828
35833
  const base = durableBaseDir();
35829
- const dir = join13(base, rel);
35830
- return { dir, path: join13(dir, sanitizeSegment(handle.filename)), base, rel };
35834
+ const dir = join14(base, rel);
35835
+ return { dir, path: join14(dir, sanitizeSegment(handle.filename)), base, rel };
35831
35836
  }
35832
35837
  async function confineToRealBase(dir, base, rel) {
35833
35838
  try {
35834
35839
  const realDir = await realpath4(dir);
35835
35840
  const realBase = await realpath4(base);
35836
- return realDir === join13(realBase, rel);
35841
+ return realDir === join14(realBase, rel);
35837
35842
  } catch {
35838
35843
  return false;
35839
35844
  }
@@ -35857,9 +35862,9 @@ async function resolveLocalFile(handle) {
35857
35862
  }
35858
35863
  async function downloadAndExtractArchive(handle, data, dir, signal) {
35859
35864
  signal?.throwIfAborted();
35860
- const attemptDir = await mkdtemp(join13(dir, "bundle-"));
35861
- const tarball = join13(attemptDir, "download.tar");
35862
- const extractDir = join13(attemptDir, "files");
35865
+ const attemptDir = await mkdtemp(join14(dir, "bundle-"));
35866
+ const tarball = join14(attemptDir, "download.tar");
35867
+ const extractDir = join14(attemptDir, "files");
35863
35868
  try {
35864
35869
  await writeFile4(tarball, data, { signal });
35865
35870
  await mkdir4(extractDir);
@@ -35959,7 +35964,7 @@ async function materializeArtifacts(result, ctx) {
35959
35964
  return await downloadAndExtractArchive(value, data, dir, ctx.signal);
35960
35965
  }
35961
35966
  if (value.size > 0 && data.length !== value.size) return null;
35962
- const downloadedPath = join13(dir, sanitizeSegment(value.filename));
35967
+ const downloadedPath = join14(dir, sanitizeSegment(value.filename));
35963
35968
  await writeFile4(downloadedPath, data);
35964
35969
  if (value.mimeType.startsWith("image/")) {
35965
35970
  images.push({ localPath: downloadedPath, data, mimeType: value.mimeType });
@@ -35996,7 +36001,7 @@ function getDeviceIdFromArgs(args) {
35996
36001
  import * as fs8 from "node:fs";
35997
36002
 
35998
36003
  // ../telemetry/src/paths.ts
35999
- import * as path13 from "node:path";
36004
+ import * as path14 from "node:path";
36000
36005
 
36001
36006
  // ../telemetry/src/events.ts
36002
36007
  var PLATFORMS = [
@@ -36329,22 +36334,22 @@ var SESSION_ID2 = randomUUID5();
36329
36334
  // ../telemetry/src/identity.ts
36330
36335
  import * as crypto2 from "node:crypto";
36331
36336
  import * as fs9 from "node:fs";
36332
- import * as path14 from "node:path";
36337
+ import * as path15 from "node:path";
36333
36338
 
36334
36339
  // ../telemetry/src/fingerprint.ts
36335
36340
  import { execFileSync as execFileSync2, spawn as spawn3 } from "node:child_process";
36336
36341
 
36337
36342
  // ../native-devtools-ios/src/index.ts
36338
- import * as path15 from "node:path";
36343
+ import * as path16 from "node:path";
36339
36344
  import * as fs10 from "node:fs";
36340
- var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ?? path15.join(__dirname, "..", "dylibs");
36341
- var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ?? path15.join(__dirname, "..", "bin");
36342
- var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ?? path15.join(DYLIB_DIR, "tcp");
36343
- var DYLIB_TVOS_DIR = path15.join(DYLIB_DIR, "tvos");
36345
+ var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ?? path16.join(__dirname, "..", "dylibs");
36346
+ var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ?? path16.join(__dirname, "..", "bin");
36347
+ var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ?? path16.join(DYLIB_DIR, "tcp");
36348
+ var DYLIB_TVOS_DIR = path16.join(DYLIB_DIR, "tvos");
36344
36349
 
36345
36350
  // ../telemetry/src/consent.ts
36346
36351
  import * as fs11 from "node:fs";
36347
- import * as path16 from "node:path";
36352
+ import * as path17 from "node:path";
36348
36353
  var cache = /* @__PURE__ */ new Map();
36349
36354
  var sessionOverride = null;
36350
36355
  function readConfigOverrideAt(filePath) {
@@ -36385,8 +36390,12 @@ function readConfigOverrideAt(filePath) {
36385
36390
  function readPersistedConsent(cwd) {
36386
36391
  const globalPath = configFilePath("global");
36387
36392
  const projectPath = configFilePath("project", { cwd });
36393
+ const userConfigPath = path17.join(resolveHomeDir(), ".argent", "config.json");
36394
+ if (userConfigPath !== globalPath && readConfigOverrideAt(userConfigPath) === false) {
36395
+ return { enabled: false, detail: `${userConfigPath} (user)` };
36396
+ }
36388
36397
  const global = readConfigOverrideAt(globalPath);
36389
- const projectRoot = path16.dirname(path16.dirname(projectPath));
36398
+ const projectRoot = path17.dirname(path17.dirname(projectPath));
36390
36399
  const project = isHomeDir(projectRoot) ? null : readConfigOverrideAt(projectPath);
36391
36400
  if (project === false && global === false) {
36392
36401
  return { enabled: false, detail: "config.json (project and global)" };
@@ -36799,9 +36808,9 @@ async function flowRunToMcpContent(result, ctx) {
36799
36808
  }
36800
36809
  }
36801
36810
  for (const write of result.baselineWrites ?? []) {
36802
- const { path: path18, error: error2 } = isRecord3(write) ? write : {};
36803
- if (typeof path18 === "string" && typeof error2 === "string") {
36804
- blocks.push({ type: "text", text: `\u2717 baseline not written: ${path18}: ${error2}` });
36811
+ const { path: path19, error: error2 } = isRecord3(write) ? write : {};
36812
+ if (typeof path19 === "string" && typeof error2 === "string") {
36813
+ blocks.push({ type: "text", text: `\u2717 baseline not written: ${path19}: ${error2}` });
36805
36814
  }
36806
36815
  }
36807
36816
  if (result.shutdownFailed === true) {
@@ -37857,10 +37866,10 @@ var SERVER_INSTRUCTIONS = "Argent controls iOS, Android, Chromium, Mac, TV, and
37857
37866
 
37858
37867
  // ../argent-mcp/src/installed-version.ts
37859
37868
  import * as fs12 from "node:fs";
37860
- import * as path17 from "node:path";
37869
+ import * as path18 from "node:path";
37861
37870
  function getInstalledVersion() {
37862
37871
  try {
37863
- const pkgPath = path17.resolve(import.meta.dirname, "..", "package.json");
37872
+ const pkgPath = path18.resolve(import.meta.dirname, "..", "package.json");
37864
37873
  const pkg = JSON.parse(fs12.readFileSync(pkgPath, "utf8"));
37865
37874
  return pkg.version ?? "unknown";
37866
37875
  } catch {
@@ -37916,9 +37925,9 @@ async function untilAborted(work, signal) {
37916
37925
  }
37917
37926
  let onAbort = () => {
37918
37927
  };
37919
- const aborted2 = new Promise((resolve12) => {
37920
- onAbort = resolve12;
37921
- if (signal.aborted) resolve12();
37928
+ const aborted2 = new Promise((resolve13) => {
37929
+ onAbort = resolve13;
37930
+ if (signal.aborted) resolve13();
37922
37931
  else signal.addEventListener("abort", onAbort, { once: true });
37923
37932
  });
37924
37933
  try {
@@ -38058,7 +38067,7 @@ async function startMcpServer(options) {
38058
38067
  const autoDescribeOn = autoDescribeEnabled();
38059
38068
  const whatsNewOn = whatsNewEnabled();
38060
38069
  const installedVersion = getInstalledVersion();
38061
- const highlightsVersion = true ? "0.35.1-next.17" : installedVersion;
38070
+ const highlightsVersion = true ? "0.35.1-next.18" : installedVersion;
38062
38071
  const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
38063
38072
  const trees = createTreeMemory();
38064
38073
  const screenshots = createScreenshotMemory();
@@ -38103,12 +38112,12 @@ async function startMcpServer(options) {
38103
38112
  }
38104
38113
  return reconnectPromise;
38105
38114
  }
38106
- const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? `${homedir5()}/.argent/mcp-calls.log`;
38115
+ const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? join19(argentHomeDir(), "mcp-calls.log");
38107
38116
  let logDirReady = false;
38108
38117
  async function spyLog(entry) {
38109
38118
  try {
38110
38119
  if (!logDirReady) {
38111
- await mkdir5(dirname11(LOG_FILE2), { recursive: true });
38120
+ await mkdir5(dirname10(LOG_FILE2), { recursive: true });
38112
38121
  logDirReady = true;
38113
38122
  }
38114
38123
  await appendFile(LOG_FILE2, JSON.stringify(entry) + "\n");