@swmansion/argent 0.35.1-next.67 → 0.35.1-next.68

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.
@@ -3235,8 +3235,8 @@ var require_utils = __commonJS({
3235
3235
  }
3236
3236
  return ind;
3237
3237
  }
3238
- function removeDotSegments(path19) {
3239
- let input = path19;
3238
+ function removeDotSegments(path20) {
3239
+ let input = path20;
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 [path19, query] = wsComponent.resourceName.split("?");
3492
- wsComponent.path = path19 && path19 !== "/" ? path19 : void 0;
3491
+ const [path20, query] = wsComponent.resourceName.split("?");
3492
+ wsComponent.path = path20 && path20 !== "/" ? path20 : void 0;
3493
3493
  wsComponent.query = query;
3494
3494
  wsComponent.resourceName = void 0;
3495
3495
  }
@@ -12577,12 +12577,12 @@ var require_dist = __commonJS({
12577
12577
  throw new Error(`Unknown format "${name}"`);
12578
12578
  return f;
12579
12579
  };
12580
- function addFormats(ajv, list, fs14, exportName) {
12580
+ function addFormats(ajv, list, fs15, exportName) {
12581
12581
  var _a3;
12582
12582
  var _b;
12583
12583
  (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
12584
12584
  for (const f of list)
12585
- ajv.addFormat(f, fs14[f]);
12585
+ ajv.addFormat(f, fs15[f]);
12586
12586
  }
12587
12587
  module.exports = exports = formatsPlugin;
12588
12588
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -13059,17 +13059,17 @@ var require_visit = __commonJS({
13059
13059
  visit.BREAK = BREAK;
13060
13060
  visit.SKIP = SKIP;
13061
13061
  visit.REMOVE = REMOVE;
13062
- function visit_(key, node2, visitor, path19) {
13063
- const ctrl = callVisitor(key, node2, visitor, path19);
13062
+ function visit_(key, node2, visitor, path20) {
13063
+ const ctrl = callVisitor(key, node2, visitor, path20);
13064
13064
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
13065
- replaceNode(key, path19, ctrl);
13066
- return visit_(key, ctrl, visitor, path19);
13065
+ replaceNode(key, path20, ctrl);
13066
+ return visit_(key, ctrl, visitor, path20);
13067
13067
  }
13068
13068
  if (typeof ctrl !== "symbol") {
13069
13069
  if (identity.isCollection(node2)) {
13070
- path19 = Object.freeze(path19.concat(node2));
13070
+ path20 = Object.freeze(path20.concat(node2));
13071
13071
  for (let i = 0; i < node2.items.length; ++i) {
13072
- const ci = visit_(i, node2.items[i], visitor, path19);
13072
+ const ci = visit_(i, node2.items[i], visitor, path20);
13073
13073
  if (typeof ci === "number")
13074
13074
  i = ci - 1;
13075
13075
  else if (ci === BREAK)
@@ -13080,13 +13080,13 @@ var require_visit = __commonJS({
13080
13080
  }
13081
13081
  }
13082
13082
  } else if (identity.isPair(node2)) {
13083
- path19 = Object.freeze(path19.concat(node2));
13084
- const ck = visit_("key", node2.key, visitor, path19);
13083
+ path20 = Object.freeze(path20.concat(node2));
13084
+ const ck = visit_("key", node2.key, visitor, path20);
13085
13085
  if (ck === BREAK)
13086
13086
  return BREAK;
13087
13087
  else if (ck === REMOVE)
13088
13088
  node2.key = null;
13089
- const cv = visit_("value", node2.value, visitor, path19);
13089
+ const cv = visit_("value", node2.value, visitor, path20);
13090
13090
  if (cv === BREAK)
13091
13091
  return BREAK;
13092
13092
  else if (cv === REMOVE)
@@ -13107,17 +13107,17 @@ var require_visit = __commonJS({
13107
13107
  visitAsync.BREAK = BREAK;
13108
13108
  visitAsync.SKIP = SKIP;
13109
13109
  visitAsync.REMOVE = REMOVE;
13110
- async function visitAsync_(key, node2, visitor, path19) {
13111
- const ctrl = await callVisitor(key, node2, visitor, path19);
13110
+ async function visitAsync_(key, node2, visitor, path20) {
13111
+ const ctrl = await callVisitor(key, node2, visitor, path20);
13112
13112
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
13113
- replaceNode(key, path19, ctrl);
13114
- return visitAsync_(key, ctrl, visitor, path19);
13113
+ replaceNode(key, path20, ctrl);
13114
+ return visitAsync_(key, ctrl, visitor, path20);
13115
13115
  }
13116
13116
  if (typeof ctrl !== "symbol") {
13117
13117
  if (identity.isCollection(node2)) {
13118
- path19 = Object.freeze(path19.concat(node2));
13118
+ path20 = Object.freeze(path20.concat(node2));
13119
13119
  for (let i = 0; i < node2.items.length; ++i) {
13120
- const ci = await visitAsync_(i, node2.items[i], visitor, path19);
13120
+ const ci = await visitAsync_(i, node2.items[i], visitor, path20);
13121
13121
  if (typeof ci === "number")
13122
13122
  i = ci - 1;
13123
13123
  else if (ci === BREAK)
@@ -13128,13 +13128,13 @@ var require_visit = __commonJS({
13128
13128
  }
13129
13129
  }
13130
13130
  } else if (identity.isPair(node2)) {
13131
- path19 = Object.freeze(path19.concat(node2));
13132
- const ck = await visitAsync_("key", node2.key, visitor, path19);
13131
+ path20 = Object.freeze(path20.concat(node2));
13132
+ const ck = await visitAsync_("key", node2.key, visitor, path20);
13133
13133
  if (ck === BREAK)
13134
13134
  return BREAK;
13135
13135
  else if (ck === REMOVE)
13136
13136
  node2.key = null;
13137
- const cv = await visitAsync_("value", node2.value, visitor, path19);
13137
+ const cv = await visitAsync_("value", node2.value, visitor, path20);
13138
13138
  if (cv === BREAK)
13139
13139
  return BREAK;
13140
13140
  else if (cv === REMOVE)
@@ -13161,23 +13161,23 @@ var require_visit = __commonJS({
13161
13161
  }
13162
13162
  return visitor;
13163
13163
  }
13164
- function callVisitor(key, node2, visitor, path19) {
13164
+ function callVisitor(key, node2, visitor, path20) {
13165
13165
  if (typeof visitor === "function")
13166
- return visitor(key, node2, path19);
13166
+ return visitor(key, node2, path20);
13167
13167
  if (identity.isMap(node2))
13168
- return visitor.Map?.(key, node2, path19);
13168
+ return visitor.Map?.(key, node2, path20);
13169
13169
  if (identity.isSeq(node2))
13170
- return visitor.Seq?.(key, node2, path19);
13170
+ return visitor.Seq?.(key, node2, path20);
13171
13171
  if (identity.isPair(node2))
13172
- return visitor.Pair?.(key, node2, path19);
13172
+ return visitor.Pair?.(key, node2, path20);
13173
13173
  if (identity.isScalar(node2))
13174
- return visitor.Scalar?.(key, node2, path19);
13174
+ return visitor.Scalar?.(key, node2, path20);
13175
13175
  if (identity.isAlias(node2))
13176
- return visitor.Alias?.(key, node2, path19);
13176
+ return visitor.Alias?.(key, node2, path20);
13177
13177
  return void 0;
13178
13178
  }
13179
- function replaceNode(key, path19, node2) {
13180
- const parent = path19[path19.length - 1];
13179
+ function replaceNode(key, path20, node2) {
13180
+ const parent = path20[path20.length - 1];
13181
13181
  if (identity.isCollection(parent)) {
13182
13182
  parent.items[key] = node2;
13183
13183
  } else if (identity.isPair(parent)) {
@@ -13789,10 +13789,10 @@ var require_Collection = __commonJS({
13789
13789
  var createNode = require_createNode();
13790
13790
  var identity = require_identity();
13791
13791
  var Node = require_Node();
13792
- function collectionFromPath(schema, path19, value) {
13792
+ function collectionFromPath(schema, path20, value) {
13793
13793
  let v = value;
13794
- for (let i = path19.length - 1; i >= 0; --i) {
13795
- const k = path19[i];
13794
+ for (let i = path20.length - 1; i >= 0; --i) {
13795
+ const k = path20[i];
13796
13796
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
13797
13797
  const a = [];
13798
13798
  a[k] = v;
@@ -13811,7 +13811,7 @@ var require_Collection = __commonJS({
13811
13811
  sourceObjects: /* @__PURE__ */ new Map()
13812
13812
  });
13813
13813
  }
13814
- var isEmptyPath = (path19) => path19 == null || typeof path19 === "object" && !!path19[Symbol.iterator]().next().done;
13814
+ var isEmptyPath = (path20) => path20 == null || typeof path20 === "object" && !!path20[Symbol.iterator]().next().done;
13815
13815
  var Collection = class extends Node.NodeBase {
13816
13816
  constructor(type, schema) {
13817
13817
  super(type);
@@ -13841,11 +13841,11 @@ var require_Collection = __commonJS({
13841
13841
  * be a Pair instance or a `{ key, value }` object, which may not have a key
13842
13842
  * that already exists in the map.
13843
13843
  */
13844
- addIn(path19, value) {
13845
- if (isEmptyPath(path19))
13844
+ addIn(path20, value) {
13845
+ if (isEmptyPath(path20))
13846
13846
  this.add(value);
13847
13847
  else {
13848
- const [key, ...rest] = path19;
13848
+ const [key, ...rest] = path20;
13849
13849
  const node2 = this.get(key, true);
13850
13850
  if (identity.isCollection(node2))
13851
13851
  node2.addIn(rest, value);
@@ -13859,8 +13859,8 @@ var require_Collection = __commonJS({
13859
13859
  * Removes a value from the collection.
13860
13860
  * @returns `true` if the item was found and removed.
13861
13861
  */
13862
- deleteIn(path19) {
13863
- const [key, ...rest] = path19;
13862
+ deleteIn(path20) {
13863
+ const [key, ...rest] = path20;
13864
13864
  if (rest.length === 0)
13865
13865
  return this.delete(key);
13866
13866
  const node2 = this.get(key, true);
@@ -13874,8 +13874,8 @@ var require_Collection = __commonJS({
13874
13874
  * scalar values from their surrounding node; to disable set `keepScalar` to
13875
13875
  * `true` (collections are always returned intact).
13876
13876
  */
13877
- getIn(path19, keepScalar) {
13878
- const [key, ...rest] = path19;
13877
+ getIn(path20, keepScalar) {
13878
+ const [key, ...rest] = path20;
13879
13879
  const node2 = this.get(key, true);
13880
13880
  if (rest.length === 0)
13881
13881
  return !keepScalar && identity.isScalar(node2) ? node2.value : node2;
@@ -13893,8 +13893,8 @@ var require_Collection = __commonJS({
13893
13893
  /**
13894
13894
  * Checks if the collection includes a value with the key `key`.
13895
13895
  */
13896
- hasIn(path19) {
13897
- const [key, ...rest] = path19;
13896
+ hasIn(path20) {
13897
+ const [key, ...rest] = path20;
13898
13898
  if (rest.length === 0)
13899
13899
  return this.has(key);
13900
13900
  const node2 = this.get(key, true);
@@ -13904,8 +13904,8 @@ var require_Collection = __commonJS({
13904
13904
  * Sets a value in this collection. For `!!set`, `value` needs to be a
13905
13905
  * boolean to add/remove the item from the set.
13906
13906
  */
13907
- setIn(path19, value) {
13908
- const [key, ...rest] = path19;
13907
+ setIn(path20, value) {
13908
+ const [key, ...rest] = path20;
13909
13909
  if (rest.length === 0) {
13910
13910
  this.set(key, value);
13911
13911
  } else {
@@ -16420,9 +16420,9 @@ var require_Document = __commonJS({
16420
16420
  this.contents.add(value);
16421
16421
  }
16422
16422
  /** Adds a value to the document. */
16423
- addIn(path19, value) {
16423
+ addIn(path20, value) {
16424
16424
  if (assertCollection(this.contents))
16425
- this.contents.addIn(path19, value);
16425
+ this.contents.addIn(path20, value);
16426
16426
  }
16427
16427
  /**
16428
16428
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -16497,14 +16497,14 @@ var require_Document = __commonJS({
16497
16497
  * Removes a value from the document.
16498
16498
  * @returns `true` if the item was found and removed.
16499
16499
  */
16500
- deleteIn(path19) {
16501
- if (Collection.isEmptyPath(path19)) {
16500
+ deleteIn(path20) {
16501
+ if (Collection.isEmptyPath(path20)) {
16502
16502
  if (this.contents == null)
16503
16503
  return false;
16504
16504
  this.contents = null;
16505
16505
  return true;
16506
16506
  }
16507
- return assertCollection(this.contents) ? this.contents.deleteIn(path19) : false;
16507
+ return assertCollection(this.contents) ? this.contents.deleteIn(path20) : false;
16508
16508
  }
16509
16509
  /**
16510
16510
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -16519,10 +16519,10 @@ var require_Document = __commonJS({
16519
16519
  * scalar values from their surrounding node; to disable set `keepScalar` to
16520
16520
  * `true` (collections are always returned intact).
16521
16521
  */
16522
- getIn(path19, keepScalar) {
16523
- if (Collection.isEmptyPath(path19))
16522
+ getIn(path20, keepScalar) {
16523
+ if (Collection.isEmptyPath(path20))
16524
16524
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
16525
- return identity.isCollection(this.contents) ? this.contents.getIn(path19, keepScalar) : void 0;
16525
+ return identity.isCollection(this.contents) ? this.contents.getIn(path20, keepScalar) : void 0;
16526
16526
  }
16527
16527
  /**
16528
16528
  * Checks if the document includes a value with the key `key`.
@@ -16533,10 +16533,10 @@ var require_Document = __commonJS({
16533
16533
  /**
16534
16534
  * Checks if the document includes a value at `path`.
16535
16535
  */
16536
- hasIn(path19) {
16537
- if (Collection.isEmptyPath(path19))
16536
+ hasIn(path20) {
16537
+ if (Collection.isEmptyPath(path20))
16538
16538
  return this.contents !== void 0;
16539
- return identity.isCollection(this.contents) ? this.contents.hasIn(path19) : false;
16539
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path20) : false;
16540
16540
  }
16541
16541
  /**
16542
16542
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -16553,13 +16553,13 @@ var require_Document = __commonJS({
16553
16553
  * Sets a value in this document. For `!!set`, `value` needs to be a
16554
16554
  * boolean to add/remove the item from the set.
16555
16555
  */
16556
- setIn(path19, value) {
16557
- if (Collection.isEmptyPath(path19)) {
16556
+ setIn(path20, value) {
16557
+ if (Collection.isEmptyPath(path20)) {
16558
16558
  this.contents = value;
16559
16559
  } else if (this.contents == null) {
16560
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path19), value);
16560
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path20), value);
16561
16561
  } else if (assertCollection(this.contents)) {
16562
- this.contents.setIn(path19, value);
16562
+ this.contents.setIn(path20, value);
16563
16563
  }
16564
16564
  }
16565
16565
  /**
@@ -18520,9 +18520,9 @@ var require_cst_visit = __commonJS({
18520
18520
  visit.BREAK = BREAK;
18521
18521
  visit.SKIP = SKIP;
18522
18522
  visit.REMOVE = REMOVE;
18523
- visit.itemAtPath = (cst, path19) => {
18523
+ visit.itemAtPath = (cst, path20) => {
18524
18524
  let item = cst;
18525
- for (const [field, index] of path19) {
18525
+ for (const [field, index] of path20) {
18526
18526
  const tok = item?.[field];
18527
18527
  if (tok && "items" in tok) {
18528
18528
  item = tok.items[index];
@@ -18531,23 +18531,23 @@ var require_cst_visit = __commonJS({
18531
18531
  }
18532
18532
  return item;
18533
18533
  };
18534
- visit.parentCollection = (cst, path19) => {
18535
- const parent = visit.itemAtPath(cst, path19.slice(0, -1));
18536
- const field = path19[path19.length - 1][0];
18534
+ visit.parentCollection = (cst, path20) => {
18535
+ const parent = visit.itemAtPath(cst, path20.slice(0, -1));
18536
+ const field = path20[path20.length - 1][0];
18537
18537
  const coll = parent?.[field];
18538
18538
  if (coll && "items" in coll)
18539
18539
  return coll;
18540
18540
  throw new Error("Parent collection not found");
18541
18541
  };
18542
- function _visit(path19, item, visitor) {
18543
- let ctrl = visitor(item, path19);
18542
+ function _visit(path20, item, visitor) {
18543
+ let ctrl = visitor(item, path20);
18544
18544
  if (typeof ctrl === "symbol")
18545
18545
  return ctrl;
18546
18546
  for (const field of ["key", "value"]) {
18547
18547
  const token = item[field];
18548
18548
  if (token && "items" in token) {
18549
18549
  for (let i = 0; i < token.items.length; ++i) {
18550
- const ci = _visit(Object.freeze(path19.concat([[field, i]])), token.items[i], visitor);
18550
+ const ci = _visit(Object.freeze(path20.concat([[field, i]])), token.items[i], visitor);
18551
18551
  if (typeof ci === "number")
18552
18552
  i = ci - 1;
18553
18553
  else if (ci === BREAK)
@@ -18558,10 +18558,10 @@ var require_cst_visit = __commonJS({
18558
18558
  }
18559
18559
  }
18560
18560
  if (typeof ctrl === "function" && field === "key")
18561
- ctrl = ctrl(item, path19);
18561
+ ctrl = ctrl(item, path20);
18562
18562
  }
18563
18563
  }
18564
- return typeof ctrl === "function" ? ctrl(item, path19) : ctrl;
18564
+ return typeof ctrl === "function" ? ctrl(item, path20) : ctrl;
18565
18565
  }
18566
18566
  exports.visit = visit;
18567
18567
  }
@@ -19863,14 +19863,14 @@ var require_parser = __commonJS({
19863
19863
  case "scalar":
19864
19864
  case "single-quoted-scalar":
19865
19865
  case "double-quoted-scalar": {
19866
- const fs14 = this.flowScalar(this.type);
19866
+ const fs15 = this.flowScalar(this.type);
19867
19867
  if (atNextItem || it.value) {
19868
- map.items.push({ start, key: fs14, sep: [] });
19868
+ map.items.push({ start, key: fs15, sep: [] });
19869
19869
  this.onKeyLine = true;
19870
19870
  } else if (it.sep) {
19871
- this.stack.push(fs14);
19871
+ this.stack.push(fs15);
19872
19872
  } else {
19873
- Object.assign(it, { key: fs14, sep: [] });
19873
+ Object.assign(it, { key: fs15, sep: [] });
19874
19874
  this.onKeyLine = true;
19875
19875
  }
19876
19876
  return;
@@ -19998,13 +19998,13 @@ var require_parser = __commonJS({
19998
19998
  case "scalar":
19999
19999
  case "single-quoted-scalar":
20000
20000
  case "double-quoted-scalar": {
20001
- const fs14 = this.flowScalar(this.type);
20001
+ const fs15 = this.flowScalar(this.type);
20002
20002
  if (!it || it.value)
20003
- fc.items.push({ start: [], key: fs14, sep: [] });
20003
+ fc.items.push({ start: [], key: fs15, sep: [] });
20004
20004
  else if (it.sep)
20005
- this.stack.push(fs14);
20005
+ this.stack.push(fs15);
20006
20006
  else
20007
- Object.assign(it, { key: fs14, sep: [] });
20007
+ Object.assign(it, { key: fs15, sep: [] });
20008
20008
  return;
20009
20009
  }
20010
20010
  case "flow-map-end":
@@ -22307,7 +22307,7 @@ var require_semver2 = __commonJS({
22307
22307
  });
22308
22308
 
22309
22309
  // ../argent-mcp/src/mcp-server.ts
22310
- import { join as join19 } from "node:path";
22310
+ import { join as join20 } from "node:path";
22311
22311
  import { setTimeout as sleep } from "node:timers/promises";
22312
22312
 
22313
22313
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
@@ -22550,10 +22550,10 @@ function mergeDefs(...defs) {
22550
22550
  function cloneDef(schema) {
22551
22551
  return mergeDefs(schema._zod.def);
22552
22552
  }
22553
- function getElementAtPath(obj, path19) {
22554
- if (!path19)
22553
+ function getElementAtPath(obj, path20) {
22554
+ if (!path20)
22555
22555
  return obj;
22556
- return path19.reduce((acc, key) => acc?.[key], obj);
22556
+ return path20.reduce((acc, key) => acc?.[key], obj);
22557
22557
  }
22558
22558
  function promiseAllObject(promisesObj) {
22559
22559
  const keys = Object.keys(promisesObj);
@@ -22893,11 +22893,11 @@ function explicitlyAborted(x, startIndex = 0) {
22893
22893
  }
22894
22894
  return false;
22895
22895
  }
22896
- function prefixIssues(path19, issues) {
22896
+ function prefixIssues(path20, issues) {
22897
22897
  return issues.map((iss) => {
22898
22898
  var _a3;
22899
22899
  (_a3 = iss).path ?? (_a3.path = []);
22900
- iss.path.unshift(path19);
22900
+ iss.path.unshift(path20);
22901
22901
  return iss;
22902
22902
  });
22903
22903
  }
@@ -23355,16 +23355,16 @@ function flattenError(error2, mapper = (issue2) => issue2.message) {
23355
23355
  }
23356
23356
  function formatError(error2, mapper = (issue2) => issue2.message) {
23357
23357
  const fieldErrors = { _errors: [] };
23358
- const processError = (error3, path19 = []) => {
23358
+ const processError = (error3, path20 = []) => {
23359
23359
  for (const issue2 of error3.issues) {
23360
23360
  if (issue2.code === "invalid_union" && issue2.errors.length) {
23361
- issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
23361
+ issue2.errors.map((issues) => processError({ issues }, [...path20, ...issue2.path]));
23362
23362
  } else if (issue2.code === "invalid_key") {
23363
- processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
23363
+ processError({ issues: issue2.issues }, [...path20, ...issue2.path]);
23364
23364
  } else if (issue2.code === "invalid_element") {
23365
- processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
23365
+ processError({ issues: issue2.issues }, [...path20, ...issue2.path]);
23366
23366
  } else {
23367
- const fullpath = [...path19, ...issue2.path];
23367
+ const fullpath = [...path20, ...issue2.path];
23368
23368
  if (fullpath.length === 0) {
23369
23369
  fieldErrors._errors.push(mapper(issue2));
23370
23370
  } else {
@@ -32096,9 +32096,9 @@ var Server = class extends Protocol {
32096
32096
 
32097
32097
  // ../argent-tools-client/src/launcher.ts
32098
32098
  import * as net from "node:net";
32099
- import * as os2 from "node:os";
32100
- import * as fs6 from "node:fs";
32101
- import * as path7 from "node:path";
32099
+ import * as os3 from "node:os";
32100
+ import * as fs7 from "node:fs";
32101
+ import * as path8 from "node:path";
32102
32102
  import * as readline from "node:readline";
32103
32103
  import { spawn, execFileSync } from "node:child_process";
32104
32104
  import { createHash, randomBytes } from "node:crypto";
@@ -32781,14 +32781,141 @@ var UnknownConfigKeyError = class extends Error {
32781
32781
  key;
32782
32782
  };
32783
32783
 
32784
+ // ../configuration-core/src/cloud-android.ts
32785
+ import * as fs6 from "node:fs";
32786
+ import * as os2 from "node:os";
32787
+ import * as path7 from "node:path";
32788
+ var CLOUD_URL_ENV = "ARGENT_CLOUD_URL";
32789
+ var CLOUD_API_KEY_ENV = "ARGENT_CLOUD_API_KEY";
32790
+ function isLoopbackHost(hostname) {
32791
+ return hostname === "localhost" || hostname === "[::1]" || /^127(\.\d{1,3}){3}$/.test(hostname);
32792
+ }
32793
+ function parseCloudAndroidCredential(env) {
32794
+ const rawUrl = env[CLOUD_URL_ENV]?.trim();
32795
+ const apiKey = env[CLOUD_API_KEY_ENV]?.trim();
32796
+ if (!rawUrl || !apiKey) return null;
32797
+ let url;
32798
+ try {
32799
+ url = new URL(rawUrl);
32800
+ } catch {
32801
+ return null;
32802
+ }
32803
+ if (url.username || url.password || url.search || url.hash) return null;
32804
+ if (url.protocol !== "https:" && !(url.protocol === "http:" && isLoopbackHost(url.hostname))) {
32805
+ return null;
32806
+ }
32807
+ return { baseUrl: `${url.origin}${url.pathname.replace(/\/+$/, "")}`, apiKey };
32808
+ }
32809
+ function cloudAndroidMarkersDir() {
32810
+ if (markersDirOverride) return markersDirOverride;
32811
+ let home;
32812
+ try {
32813
+ home = os2.userInfo().homedir;
32814
+ } catch {
32815
+ home = "";
32816
+ }
32817
+ return path7.join(home || os2.homedir(), ".argent", "cloud-android-leases");
32818
+ }
32819
+ var markersDirOverride = null;
32820
+ function primaryGid() {
32821
+ try {
32822
+ return os2.userInfo().gid;
32823
+ } catch {
32824
+ return process.getgid?.();
32825
+ }
32826
+ }
32827
+ function untrusted(dir) {
32828
+ const uid = process.getuid?.();
32829
+ if (uid === void 0) return null;
32830
+ const otherCanWrite = (stat7) => {
32831
+ const ownPrivateGroup = process.platform === "linux" && stat7.gid === primaryGid();
32832
+ return (stat7.mode & 2) !== 0 || (stat7.mode & 16) !== 0 && !ownPrivateGroup;
32833
+ };
32834
+ let stat6;
32835
+ let parent;
32836
+ try {
32837
+ stat6 = fs6.lstatSync(dir);
32838
+ parent = fs6.statSync(path7.dirname(dir));
32839
+ } catch {
32840
+ return "it cannot be read";
32841
+ }
32842
+ if (!stat6.isDirectory()) return "it is not a directory";
32843
+ if (stat6.uid !== uid) return "another account owns it";
32844
+ if ((stat6.mode & 63) !== 0) return "other accounts can read or write it";
32845
+ if (parent.uid !== uid && parent.uid !== 0 || otherCanWrite(parent)) {
32846
+ return "other accounts can write its parent directory";
32847
+ }
32848
+ return null;
32849
+ }
32850
+ function trustedCloudAndroidMarkersDir() {
32851
+ const dir = cloudAndroidMarkersDir();
32852
+ return untrusted(dir) ? null : dir;
32853
+ }
32854
+ var CLOUD_ANDROID_MARKER_TTL_MS = 2 * 6e4;
32855
+ function readCloudAndroidMarker(file) {
32856
+ try {
32857
+ const raw2 = JSON.parse(fs6.readFileSync(file, "utf8"));
32858
+ if (typeof raw2.pid !== "number" || typeof raw2.lease !== "string") return null;
32859
+ if (typeof raw2.serial !== "string") return null;
32860
+ return {
32861
+ serial: raw2.serial,
32862
+ pid: raw2.pid,
32863
+ lease: raw2.lease,
32864
+ refreshedAt: fs6.statSync(file).mtimeMs
32865
+ };
32866
+ } catch {
32867
+ return null;
32868
+ }
32869
+ }
32870
+ function readCloudAndroidMarkers(dir = trustedCloudAndroidMarkersDir()) {
32871
+ if (!dir) return [];
32872
+ let names;
32873
+ try {
32874
+ names = fs6.readdirSync(dir);
32875
+ } catch {
32876
+ return [];
32877
+ }
32878
+ return names.filter((name) => name.endsWith(".json")).map((name) => readCloudAndroidMarker(path7.join(dir, name))).filter((marker) => marker !== null);
32879
+ }
32880
+ function pidAlive(pid) {
32881
+ try {
32882
+ process.kill(pid, 0);
32883
+ return true;
32884
+ } catch (err) {
32885
+ return err.code === "EPERM";
32886
+ }
32887
+ }
32888
+ function isLiveCloudAndroidMarker(marker, now = Date.now()) {
32889
+ return now - marker.refreshedAt < CLOUD_ANDROID_MARKER_TTL_MS && pidAlive(marker.pid);
32890
+ }
32891
+ function cloudAndroidLeaseHolders(dir = trustedCloudAndroidMarkersDir()) {
32892
+ const now = Date.now();
32893
+ return new Set(
32894
+ readCloudAndroidMarkers(dir).filter((marker) => isLiveCloudAndroidMarker(marker, now)).map((marker) => marker.pid)
32895
+ );
32896
+ }
32897
+
32784
32898
  // ../argent-tools-client/src/launcher.ts
32785
32899
  var STATE_DIR = argentHomeDir();
32786
- var STATE_FILE = path7.join(STATE_DIR, "tool-server.json");
32787
- var LOG_FILE = path7.join(STATE_DIR, "tool-server.log");
32788
- var LOCK_FILE = path7.join(STATE_DIR, "tool-server.lock");
32900
+ var STATE_FILE = path8.join(STATE_DIR, "tool-server.json");
32901
+ var LOG_FILE = path8.join(STATE_DIR, "tool-server.log");
32902
+ var LOCK_FILE = path8.join(STATE_DIR, "tool-server.lock");
32789
32903
  var AUTH_TOKEN_BYTES = 32;
32790
32904
  var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
32791
32905
  var AUTOSPAWN_IDLE_TIMEOUT_MINUTES = 30;
32906
+ var CLOUD_URL_ENV2 = "ARGENT_CLOUD_URL";
32907
+ var CLOUD_API_KEY_ENV2 = "ARGENT_CLOUD_API_KEY";
32908
+ function cloudCredential(env = process.env) {
32909
+ const parsed = parseCloudAndroidCredential(env);
32910
+ return parsed ? { url: parsed.baseUrl, apiKey: parsed.apiKey } : null;
32911
+ }
32912
+ function linkedCloudCredentialNotice(env = process.env) {
32913
+ if (!cloudCredential(env)) return null;
32914
+ return "[argent] ARGENT_CLOUD_URL and ARGENT_CLOUD_API_KEY are not used over a linked tool-server (ARGENT_TOOLS_URL or `argent link`): it never receives them. Unlink to use them on this machine.";
32915
+ }
32916
+ function cloudProfileId(credential) {
32917
+ return createHash("sha256").update(`argent-cloud-android\0${credential.url}\0${credential.apiKey}`).digest("hex").slice(0, 12);
32918
+ }
32792
32919
  var AUTOSPAWN_HOST = "127.0.0.1";
32793
32920
  function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
32794
32921
  const env = {
@@ -32797,6 +32924,12 @@ function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
32797
32924
  ARGENT_SIMULATOR_SERVER_DIR: paths.simulatorServerDir,
32798
32925
  ARGENT_NATIVE_DEVTOOLS_DIR: paths.nativeDevtoolsDir
32799
32926
  };
32927
+ delete env[CLOUD_API_KEY_ENV2];
32928
+ delete env[CLOUD_URL_ENV2];
32929
+ if (options.cloud) {
32930
+ env[CLOUD_URL_ENV2] = options.cloud.url;
32931
+ env[CLOUD_API_KEY_ENV2] = options.cloud.apiKey;
32932
+ }
32800
32933
  if (options.host !== void 0) env.ARGENT_HOST = options.host;
32801
32934
  if (options.idleTimeoutMinutes !== void 0) {
32802
32935
  env.ARGENT_IDLE_TIMEOUT_MINUTES = String(options.idleTimeoutMinutes);
@@ -32864,7 +32997,7 @@ function isVersionNewer(a, b) {
32864
32997
  function readBundlePackageVersion(bundlePath) {
32865
32998
  try {
32866
32999
  const pkg = JSON.parse(
32867
- fs6.readFileSync(path7.join(path7.dirname(bundlePath), "..", "package.json"), "utf8")
33000
+ fs7.readFileSync(path8.join(path8.dirname(bundlePath), "..", "package.json"), "utf8")
32868
33001
  );
32869
33002
  return typeof pkg.version === "string" ? pkg.version : void 0;
32870
33003
  } catch {
@@ -32921,7 +33054,7 @@ function killSpawnedChild(child, pid) {
32921
33054
  }
32922
33055
  function resolveToolsServerNode() {
32923
33056
  const { bun, deno, electron } = process.versions;
32924
- return !(bun || deno || electron) && fs6.existsSync(process.execPath) ? process.execPath : "node";
33057
+ return !(bun || deno || electron) && fs7.existsSync(process.execPath) ? process.execPath : "node";
32925
33058
  }
32926
33059
  function parseListeningPort(line) {
32927
33060
  const match = line.match(/Tools server listening on http:\/\/.+:(\d+)/);
@@ -32931,10 +33064,10 @@ function spawnToolsServer(paths, port, options = {}) {
32931
33064
  return new Promise((resolve13, reject) => {
32932
33065
  let logFd;
32933
33066
  try {
32934
- fs6.mkdirSync(STATE_DIR, { recursive: true });
32935
- logFd = fs6.openSync(LOG_FILE, "a");
33067
+ fs7.mkdirSync(STATE_DIR, { recursive: true });
33068
+ logFd = fs7.openSync(LOG_FILE, "a");
32936
33069
  } catch {
32937
- logFd = fs6.openSync("/dev/null", "w");
33070
+ logFd = fs7.openSync("/dev/null", "w");
32938
33071
  }
32939
33072
  const nodeBin = resolveToolsServerNode();
32940
33073
  const child = spawn(nodeBin, [paths.bundlePath, "start"], {
@@ -32942,7 +33075,7 @@ function spawnToolsServer(paths, port, options = {}) {
32942
33075
  stdio: ["ignore", "pipe", logFd],
32943
33076
  env: buildToolsServerEnv(paths, port, process.env, options)
32944
33077
  });
32945
- fs6.closeSync(logFd);
33078
+ fs7.closeSync(logFd);
32946
33079
  const pid = child.pid;
32947
33080
  if (!pid) {
32948
33081
  child.once(
@@ -32991,9 +33124,10 @@ function spawnToolsServer(paths, port, options = {}) {
32991
33124
  rl.on("close", () => clearTimeout(timer));
32992
33125
  });
32993
33126
  }
32994
- function stateFileForBundle(bundlePath) {
33127
+ function stateFileForBundle(bundlePath, cloudProfile) {
32995
33128
  const key = createHash("sha256").update(bundlePath).digest("hex").slice(0, 12);
32996
- return path7.join(STATE_DIR, `tool-server-${key}.json`);
33129
+ const profile = cloudProfile ? `-cloud-${cloudProfile}` : "";
33130
+ return path8.join(STATE_DIR, `tool-server-${key}${profile}.json`);
32997
33131
  }
32998
33132
  async function readStateFile(file) {
32999
33133
  try {
@@ -33003,16 +33137,20 @@ async function readStateFile(file) {
33003
33137
  return null;
33004
33138
  }
33005
33139
  }
33006
- async function readToolsServerState(bundlePath) {
33140
+ async function readToolsServerState(bundlePath, cloudProfile) {
33007
33141
  if (bundlePath === void 0) return readStateFile(STATE_FILE);
33142
+ if (cloudProfile) {
33143
+ const own3 = await readStateFile(stateFileForBundle(bundlePath, cloudProfile));
33144
+ return own3?.cloudProfile === cloudProfile ? own3 : null;
33145
+ }
33008
33146
  const own2 = await readStateFile(stateFileForBundle(bundlePath));
33009
33147
  if (own2) return own2;
33010
33148
  const legacy = await readStateFile(STATE_FILE);
33011
33149
  return legacy && legacy.bundlePath === bundlePath ? legacy : null;
33012
33150
  }
33013
- function primaryGid() {
33151
+ function primaryGid2() {
33014
33152
  try {
33015
- return os2.userInfo().gid;
33153
+ return os3.userInfo().gid;
33016
33154
  } catch {
33017
33155
  return process.getgid?.();
33018
33156
  }
@@ -33022,19 +33160,19 @@ var UnsafeArgentHomeError = class extends Error {
33022
33160
  };
33023
33161
  function statHome() {
33024
33162
  try {
33025
- fs6.mkdirSync(path7.dirname(STATE_DIR), { recursive: true });
33026
- fs6.mkdirSync(STATE_DIR, { mode: 448 });
33163
+ fs7.mkdirSync(path8.dirname(STATE_DIR), { recursive: true });
33164
+ fs7.mkdirSync(STATE_DIR, { mode: 448 });
33027
33165
  } catch {
33028
33166
  }
33029
33167
  try {
33030
- return fs6.statSync(STATE_DIR);
33168
+ return fs7.statSync(STATE_DIR);
33031
33169
  } catch {
33032
33170
  return null;
33033
33171
  }
33034
33172
  }
33035
33173
  function isWritable(dir) {
33036
33174
  try {
33037
- fs6.accessSync(dir, fs6.constants.W_OK);
33175
+ fs7.accessSync(dir, fs7.constants.W_OK);
33038
33176
  return true;
33039
33177
  } catch {
33040
33178
  return false;
@@ -33050,7 +33188,7 @@ function assertPrivateArgentHome() {
33050
33188
  `The Argent home ${STATE_DIR} belongs to another user. Change its owner or set ARGENT_HOME_DIR to a directory you own.`
33051
33189
  );
33052
33190
  }
33053
- const ownPrivateGroup = process.platform === "linux" && stat6.gid === primaryGid();
33191
+ const ownPrivateGroup = process.platform === "linux" && stat6.gid === primaryGid2();
33054
33192
  const groupCanWrite = (stat6.mode & 16) !== 0 && !ownPrivateGroup;
33055
33193
  if ((stat6.mode & 2) !== 0 || groupCanWrite) {
33056
33194
  throw new UnsafeArgentHomeError(
@@ -33062,20 +33200,22 @@ async function writeToolsServerState(state) {
33062
33200
  writeToolsServerStateSync(state);
33063
33201
  }
33064
33202
  function writeToolsServerStateSync(state) {
33065
- const target = stateFileForBundle(state.bundlePath);
33066
- fs6.mkdirSync(STATE_DIR, { recursive: true });
33203
+ const target = stateFileForBundle(state.bundlePath, state.cloudProfile);
33204
+ fs7.mkdirSync(STATE_DIR, { recursive: true });
33067
33205
  const tmp = `${target}.${randomBytes(8).toString("hex")}.tmp`;
33068
33206
  try {
33069
- fs6.writeFileSync(tmp, JSON.stringify(state, null, 2) + "\n", { flag: "wx", mode: 384 });
33070
- fs6.renameSync(tmp, target);
33207
+ fs7.writeFileSync(tmp, JSON.stringify(state, null, 2) + "\n", { flag: "wx", mode: 384 });
33208
+ fs7.renameSync(tmp, target);
33071
33209
  } catch (err) {
33072
- fs6.rmSync(tmp, { force: true });
33210
+ fs7.rmSync(tmp, { force: true });
33073
33211
  throw err;
33074
33212
  }
33075
33213
  }
33076
- async function clearToolsServerState(bundlePath) {
33214
+ async function clearToolsServerState(bundlePath, cloudProfile) {
33077
33215
  const files = [STATE_FILE];
33078
- if (bundlePath !== void 0) {
33216
+ if (bundlePath !== void 0 && cloudProfile) {
33217
+ files[0] = stateFileForBundle(bundlePath, cloudProfile);
33218
+ } else if (bundlePath !== void 0) {
33079
33219
  files[0] = stateFileForBundle(bundlePath);
33080
33220
  const legacy = await readStateFile(STATE_FILE);
33081
33221
  if (legacy && legacy.bundlePath === bundlePath) files.push(STATE_FILE);
@@ -33087,7 +33227,7 @@ async function clearToolsServerState(bundlePath) {
33087
33227
  }
33088
33228
  }
33089
33229
  }
33090
- var STATE_FILE_RE = /^tool-server(-[0-9a-f]{12})?\.json$/;
33230
+ var STATE_FILE_RE = /^tool-server(-[0-9a-f]{12}(-cloud-[0-9a-f]{12})?)?\.json$/;
33091
33231
  async function readAllToolsServerStates() {
33092
33232
  let names;
33093
33233
  try {
@@ -33098,7 +33238,7 @@ async function readAllToolsServerStates() {
33098
33238
  const out = [];
33099
33239
  for (const name of names) {
33100
33240
  if (!STATE_FILE_RE.test(name)) continue;
33101
- const file = path7.join(STATE_DIR, name);
33241
+ const file = path8.join(STATE_DIR, name);
33102
33242
  const state = await readStateFile(file);
33103
33243
  if (state) out.push({ file, state });
33104
33244
  }
@@ -33114,7 +33254,7 @@ async function sweepDeadStateFiles() {
33114
33254
  });
33115
33255
  continue;
33116
33256
  }
33117
- if (fs6.existsSync(fresh.bundlePath)) continue;
33257
+ if (fs7.existsSync(fresh.bundlePath)) continue;
33118
33258
  if (!couldBeOurToolServer(fresh.pid, fresh.bundlePath)) continue;
33119
33259
  await unlink(file).catch(() => {
33120
33260
  });
@@ -33151,7 +33291,11 @@ async function terminatePid(pid, stillOurs) {
33151
33291
  }
33152
33292
  await waitForExit(pid, SIGKILL_GRACE_MS);
33153
33293
  }
33154
- var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs6.existsSync(p)) ?? "ps";
33294
+ function clientCloudProfile(env = process.env) {
33295
+ const cloud = cloudCredential(env);
33296
+ return cloud ? cloudProfileId(cloud) : void 0;
33297
+ }
33298
+ var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs7.existsSync(p)) ?? "ps";
33155
33299
  var PS_WIDTH_FLAGS = ["-ww"];
33156
33300
  var PS_LOCALE = process.platform === "darwin" ? "en_US.UTF-8" : "C.UTF-8";
33157
33301
  function readProcessCommandLine(pid, flags = PS_WIDTH_FLAGS, env = { ...process.env, LC_ALL: PS_LOCALE }) {
@@ -33198,13 +33342,13 @@ var LOCK_STALE_MS2 = 45e3;
33198
33342
  var LOCK_POLL_MS = 100;
33199
33343
  function spawnLockIsStale() {
33200
33344
  try {
33201
- const { pid, ts } = JSON.parse(fs6.readFileSync(LOCK_FILE, "utf8"));
33345
+ const { pid, ts } = JSON.parse(fs7.readFileSync(LOCK_FILE, "utf8"));
33202
33346
  if (typeof pid === "number" && pid > 0 && !isProcessAlive(pid)) return true;
33203
33347
  if (typeof ts === "number" && Date.now() - ts > LOCK_STALE_MS2) return true;
33204
33348
  return false;
33205
33349
  } catch {
33206
33350
  try {
33207
- return Date.now() - fs6.statSync(LOCK_FILE).mtimeMs > LOCK_STALE_MS2;
33351
+ return Date.now() - fs7.statSync(LOCK_FILE).mtimeMs > LOCK_STALE_MS2;
33208
33352
  } catch {
33209
33353
  return true;
33210
33354
  }
@@ -33212,7 +33356,7 @@ function spawnLockIsStale() {
33212
33356
  }
33213
33357
  async function acquireSpawnLock() {
33214
33358
  try {
33215
- fs6.mkdirSync(STATE_DIR, { recursive: true });
33359
+ fs7.mkdirSync(STATE_DIR, { recursive: true });
33216
33360
  } catch {
33217
33361
  return null;
33218
33362
  }
@@ -33220,11 +33364,11 @@ async function acquireSpawnLock() {
33220
33364
  const deadline = Date.now() + LOCK_WAIT_TIMEOUT_MS;
33221
33365
  for (; ; ) {
33222
33366
  try {
33223
- const fd = fs6.openSync(LOCK_FILE, "wx");
33367
+ const fd = fs7.openSync(LOCK_FILE, "wx");
33224
33368
  try {
33225
- fs6.writeSync(fd, JSON.stringify({ pid: process.pid, nonce, ts: Date.now() }));
33369
+ fs7.writeSync(fd, JSON.stringify({ pid: process.pid, nonce, ts: Date.now() }));
33226
33370
  } finally {
33227
- fs6.closeSync(fd);
33371
+ fs7.closeSync(fd);
33228
33372
  }
33229
33373
  let released = false;
33230
33374
  return {
@@ -33232,8 +33376,8 @@ async function acquireSpawnLock() {
33232
33376
  if (released) return;
33233
33377
  released = true;
33234
33378
  try {
33235
- const cur = JSON.parse(fs6.readFileSync(LOCK_FILE, "utf8"));
33236
- if (cur.pid === process.pid && cur.nonce === nonce) fs6.unlinkSync(LOCK_FILE);
33379
+ const cur = JSON.parse(fs7.readFileSync(LOCK_FILE, "utf8"));
33380
+ if (cur.pid === process.pid && cur.nonce === nonce) fs7.unlinkSync(LOCK_FILE);
33237
33381
  } catch {
33238
33382
  }
33239
33383
  }
@@ -33242,10 +33386,10 @@ async function acquireSpawnLock() {
33242
33386
  if (err.code !== "EEXIST") return null;
33243
33387
  if (spawnLockIsStale()) {
33244
33388
  try {
33245
- fs6.unlinkSync(LOCK_FILE);
33389
+ fs7.unlinkSync(LOCK_FILE);
33246
33390
  } catch {
33247
33391
  }
33248
- if (!fs6.existsSync(LOCK_FILE)) continue;
33392
+ if (!fs7.existsSync(LOCK_FILE)) continue;
33249
33393
  }
33250
33394
  if (Date.now() >= deadline) return null;
33251
33395
  await new Promise((r) => setTimeout(r, LOCK_POLL_MS));
@@ -33255,7 +33399,8 @@ async function acquireSpawnLock() {
33255
33399
  async function reusableHandle(state, wantBundlePath, wantVersion) {
33256
33400
  if (!state || !isProcessAlive(state.pid)) return null;
33257
33401
  if (wantBundlePath !== void 0 && state.bundlePath !== wantBundlePath) return null;
33258
- if (wantBundlePath !== void 0 && state.version !== void 0) {
33402
+ const holdsLease = state.cloudProfile !== void 0 && cloudAndroidLeaseHolders().has(state.pid);
33403
+ if (wantBundlePath !== void 0 && state.version !== void 0 && !holdsLease) {
33259
33404
  const diskVersion = readBundlePackageVersion(wantBundlePath);
33260
33405
  if (diskVersion !== void 0) {
33261
33406
  if (diskVersion !== state.version) return null;
@@ -33268,25 +33413,24 @@ async function reusableHandle(state, wantBundlePath, wantVersion) {
33268
33413
  if (!healthy) return null;
33269
33414
  return { url: formatUrl(healthCheckHost(host), state.port), token: state.token ?? "" };
33270
33415
  }
33271
- async function ensureToolsServer(paths) {
33416
+ async function ensureToolsServer(paths, env = process.env) {
33272
33417
  assertPrivateArgentHome();
33273
- const fast = await reusableHandle(
33274
- await readState(paths.bundlePath),
33275
- paths.bundlePath,
33276
- paths.version
33277
- );
33418
+ const cloud = cloudCredential(env) ?? void 0;
33419
+ const cloudProfile = clientCloudProfile(env);
33420
+ const readOwnState = () => readState(paths.bundlePath, cloudProfile);
33421
+ const fast = await reusableHandle(await readOwnState(), paths.bundlePath, paths.version);
33278
33422
  if (fast) return fast;
33279
33423
  const lock = await acquireSpawnLock();
33280
33424
  try {
33281
- const state = await readState(paths.bundlePath);
33425
+ const state = await readOwnState();
33282
33426
  const reuse = await reusableHandle(state, paths.bundlePath, paths.version);
33283
33427
  if (reuse) return reuse;
33284
33428
  if (state && state.managed === "autospawn" && state.bundlePath === paths.bundlePath && isProcessAlive(state.pid) && couldBeOurToolServer(state.pid, state.bundlePath)) {
33285
33429
  await terminatePid(state.pid, () => couldBeOurToolServer(state.pid, state.bundlePath));
33286
33430
  }
33287
- await clearToolsServerState(paths.bundlePath);
33431
+ await clearToolsServerState(paths.bundlePath, cloudProfile);
33288
33432
  await sweepDeadStateFiles();
33289
- if (!fs6.existsSync(paths.bundlePath)) {
33433
+ if (!fs7.existsSync(paths.bundlePath)) {
33290
33434
  throw new Error(
33291
33435
  `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.`
33292
33436
  );
@@ -33297,9 +33441,11 @@ async function ensureToolsServer(paths) {
33297
33441
  const { port: actualPort, pid } = await spawnToolsServer(paths, port, {
33298
33442
  token,
33299
33443
  host: AUTOSPAWN_HOST,
33300
- idleTimeoutMinutes: AUTOSPAWN_IDLE_TIMEOUT_MINUTES
33444
+ idleTimeoutMinutes: AUTOSPAWN_IDLE_TIMEOUT_MINUTES,
33445
+ ...cloud ? { cloud } : {}
33301
33446
  });
33302
33447
  await writeState({
33448
+ ...cloudProfile ? { cloudProfile } : {},
33303
33449
  port: actualPort,
33304
33450
  pid,
33305
33451
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -33319,7 +33465,7 @@ async function ensureToolsServer(paths) {
33319
33465
  var import_yaml2 = __toESM(require_dist3(), 1);
33320
33466
  import { readFile as readFile5 } from "node:fs/promises";
33321
33467
  import { maxHeaderSize } from "node:http";
33322
- import * as path13 from "node:path";
33468
+ import * as path14 from "node:path";
33323
33469
 
33324
33470
  // ../registry/src/types.ts
33325
33471
  var LINKED_CALL_HEADER = "x-argent-linked";
@@ -33381,8 +33527,8 @@ var UNEXPANDED_PATH = /^~|\$[A-Za-z0-9_{(]|`|%[A-Za-z_][A-Za-z0-9_]*%|^[A-Za-z][
33381
33527
  function isUnexpandedPath(p) {
33382
33528
  return UNEXPANDED_PATH.test(p);
33383
33529
  }
33384
- function isClientFileArgument({ spec, path: path19 }) {
33385
- return spec.kind === "file" && spec.path === `\${${spec.target}}` && path19.startsWith("/") && hasToolFileExtension(path19);
33530
+ function isClientFileArgument({ spec, path: path20 }) {
33531
+ return spec.kind === "file" && spec.path === `\${${spec.target}}` && path20.startsWith("/") && hasToolFileExtension(path20);
33386
33532
  }
33387
33533
 
33388
33534
  // ../registry/src/flow-platforms.ts
@@ -33390,26 +33536,26 @@ var LAUNCH_PLATFORMS = ["ios", "android", "chromium", "vega", "macos"];
33390
33536
  var SELECTABLE_PLATFORMS = [...LAUNCH_PLATFORMS, "ios-remote"];
33391
33537
 
33392
33538
  // ../registry/src/flow-file-refs.ts
33393
- import * as fs8 from "node:fs/promises";
33394
- import * as path9 from "node:path";
33539
+ import * as fs9 from "node:fs/promises";
33540
+ import * as path10 from "node:path";
33395
33541
 
33396
33542
  // ../registry/src/e2e-dirs.ts
33397
- import * as fs7 from "node:fs/promises";
33398
- import * as path8 from "node:path";
33399
- var E2E_DIR = path8.join(".argent", "e2e");
33400
- var LEGACY_E2E_DIRS = Object.freeze([path8.join(".argent", "flows")]);
33543
+ import * as fs8 from "node:fs/promises";
33544
+ import * as path9 from "node:path";
33545
+ var E2E_DIR = path9.join(".argent", "e2e");
33546
+ var LEGACY_E2E_DIRS = Object.freeze([path9.join(".argent", "flows")]);
33401
33547
  var E2E_DIRS = Object.freeze([E2E_DIR, ...LEGACY_E2E_DIRS]);
33402
33548
  function e2eDirFor(projectRoot) {
33403
- return path8.join(projectRoot, E2E_DIR);
33549
+ return path9.join(projectRoot, E2E_DIR);
33404
33550
  }
33405
33551
  function e2eDirsFor(projectRoot) {
33406
- return E2E_DIRS.map((dir) => path8.join(projectRoot, dir));
33552
+ return E2E_DIRS.map((dir) => path9.join(projectRoot, dir));
33407
33553
  }
33408
33554
  function e2eFileCandidates(projectRoot, name) {
33409
- return e2eDirsFor(projectRoot).map((dir) => path8.join(dir, `${name}.yaml`));
33555
+ return e2eDirsFor(projectRoot).map((dir) => path9.join(dir, `${name}.yaml`));
33410
33556
  }
33411
33557
  async function exists(file) {
33412
- return fs7.stat(file).then(
33558
+ return fs8.stat(file).then(
33413
33559
  () => true,
33414
33560
  () => false
33415
33561
  );
@@ -33436,21 +33582,21 @@ async function pickE2eFile(candidates) {
33436
33582
  function e2eShadowWarning(used, shadowed) {
33437
33583
  return `${shadowed} is not used: ${used} has the same name and is read first.`;
33438
33584
  }
33439
- var E2E_DIR_NAMES = E2E_DIRS.map((dir) => path8.basename(dir));
33585
+ var E2E_DIR_NAMES = E2E_DIRS.map((dir) => path9.basename(dir));
33440
33586
  function e2eDirProject(dir) {
33441
33587
  const trimmed = dir.length > 1 ? dir.replace(/[\\/]+$/, "") : dir;
33442
- const argent = path8.dirname(trimmed);
33443
- if (!E2E_DIR_NAMES.includes(path8.basename(trimmed)) || path8.basename(argent) !== ".argent") {
33588
+ const argent = path9.dirname(trimmed);
33589
+ if (!E2E_DIR_NAMES.includes(path9.basename(trimmed)) || path9.basename(argent) !== ".argent") {
33444
33590
  return null;
33445
33591
  }
33446
- return path8.dirname(argent);
33592
+ return path9.dirname(argent);
33447
33593
  }
33448
33594
  function e2eRunFallbackDirs(anchorDir, target) {
33449
33595
  if (target.includes("/") || target.includes("\\")) return [];
33450
33596
  const project = e2eDirProject(anchorDir);
33451
33597
  if (project === null) return [];
33452
- const anchor2 = path8.resolve(anchorDir);
33453
- return e2eDirsFor(project).filter((dir) => path8.resolve(dir) !== anchor2);
33598
+ const anchor2 = path9.resolve(anchorDir);
33599
+ return e2eDirsFor(project).filter((dir) => path9.resolve(dir) !== anchor2);
33454
33600
  }
33455
33601
 
33456
33602
  // ../registry/src/tool-ids.ts
@@ -33500,10 +33646,10 @@ function canonicalToolArgs(tool, args) {
33500
33646
  // ../registry/src/flow-file-refs.ts
33501
33647
  async function canonicalFlowPath(p) {
33502
33648
  try {
33503
- return await fs8.realpath(p);
33649
+ return await fs9.realpath(p);
33504
33650
  } catch {
33505
33651
  try {
33506
- return path9.join(await fs8.realpath(path9.dirname(p)), path9.basename(p));
33652
+ return path10.join(await fs9.realpath(path10.dirname(p)), path10.basename(p));
33507
33653
  } catch {
33508
33654
  return p;
33509
33655
  }
@@ -33512,7 +33658,7 @@ async function canonicalFlowPath(p) {
33512
33658
  function completeRunExtension(value) {
33513
33659
  if (value.endsWith(".yaml")) return value;
33514
33660
  const candidate = `${value}.yaml`;
33515
- return FLOW_FILE_NAME_PATTERN.test(path9.posix.basename(candidate)) ? candidate : value;
33661
+ return FLOW_FILE_NAME_PATTERN.test(path10.posix.basename(candidate)) ? candidate : value;
33516
33662
  }
33517
33663
  var MAX_RUN_DEPTH = 20;
33518
33664
  var MAX_BLOCK_NESTING = 64;
@@ -33534,9 +33680,9 @@ function collectFlowRequests(doc) {
33534
33680
  for (const step of steps) {
33535
33681
  if (!isRecord(step)) continue;
33536
33682
  const run = step.run;
33537
- if (typeof run === "string" && !run.includes("\\") && !path9.posix.isAbsolute(run) && !/^[A-Za-z]:/.test(run)) {
33683
+ if (typeof run === "string" && !run.includes("\\") && !path10.posix.isAbsolute(run) && !/^[A-Za-z]:/.test(run)) {
33538
33684
  const target = completeRunExtension(run);
33539
- if (FLOW_FILE_NAME_PATTERN.test(path9.posix.basename(target))) runTargets.add(target);
33685
+ if (FLOW_FILE_NAME_PATTERN.test(path10.posix.basename(target))) runTargets.add(target);
33540
33686
  }
33541
33687
  const snapshot = isRecord(step.snapshot) ? step.snapshot.name : step.snapshot;
33542
33688
  if (typeof snapshot === "string" && FLOW_NAME_PATTERN.test(snapshot)) snapshots.add(snapshot);
@@ -33556,14 +33702,14 @@ function collectFlowRequests(doc) {
33556
33702
  return { runTargets: [...runTargets], snapshots: [...snapshots], toolSteps, nested };
33557
33703
  }
33558
33704
  function baselineKeyFor(canonicalPath2, flowName) {
33559
- const stem = path9.basename(canonicalPath2, ".yaml");
33705
+ const stem = path10.basename(canonicalPath2, ".yaml");
33560
33706
  return FLOW_NAME_PATTERN.test(stem) ? stem : flowName;
33561
33707
  }
33562
33708
  function flowMemberKey(anchorDir, target) {
33563
33709
  return `${anchorDir}\0${target}`;
33564
33710
  }
33565
33711
  async function classifyOnDiskSpelling(dir, base, addressable = FLOW_FILE_NAME_PATTERN) {
33566
- const entries = await fs8.readdir(dir).catch(() => null);
33712
+ const entries = await fs9.readdir(dir).catch(() => null);
33567
33713
  if (entries === null || entries.includes(base)) return { state: "listed" };
33568
33714
  const actual = entries.find((entry) => entry.toLowerCase() === base.toLowerCase());
33569
33715
  if (actual === void 0) return { state: "absent" };
@@ -33585,11 +33731,11 @@ function nestedFlowTarget(args) {
33585
33731
  return { kind: "name", projectRoot, name, path: paths[0], paths };
33586
33732
  }
33587
33733
  if (name !== void 0 || !isResolvedAbsolute(flowPath)) return void 0;
33588
- if (!FLOW_FILE_NAME_PATTERN.test(path9.basename(flowPath))) return void 0;
33734
+ if (!FLOW_FILE_NAME_PATTERN.test(path10.basename(flowPath))) return void 0;
33589
33735
  return { kind: "e2e_test_path", path: flowPath };
33590
33736
  }
33591
33737
  function isResolvedAbsolute(value) {
33592
- return typeof value === "string" && path9.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
33738
+ return typeof value === "string" && path10.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
33593
33739
  }
33594
33740
 
33595
33741
  // ../registry/src/failure-codes.ts
@@ -34023,6 +34169,17 @@ var FAILURE_CODES = {
34023
34169
  BOOT_HARMONY_STOP_TIMEOUT: "BOOT_HARMONY_STOP_TIMEOUT",
34024
34170
  BOOT_HARMONY_MANAGER_EXITED: "BOOT_HARMONY_MANAGER_EXITED",
34025
34171
  BOOT_HARMONY_START_FAILED: "BOOT_HARMONY_START_FAILED",
34172
+ /**
34173
+ * Argent Cloud Android emulators
34174
+ * @see [leases.ts](../../tool-server/src/utils/cloud-android/leases.ts)
34175
+ */
34176
+ CLOUD_ANDROID_ACCESS_DENIED: "CLOUD_ANDROID_ACCESS_DENIED",
34177
+ CLOUD_ANDROID_ACQUIRE_FAILED: "CLOUD_ANDROID_ACQUIRE_FAILED",
34178
+ CLOUD_ANDROID_ADB_KEY_MISSING: "CLOUD_ANDROID_ADB_KEY_MISSING",
34179
+ CLOUD_ANDROID_ADB_SERVER_REMOTE: "CLOUD_ANDROID_ADB_SERVER_REMOTE",
34180
+ CLOUD_ANDROID_CONNECT_FAILED: "CLOUD_ANDROID_CONNECT_FAILED",
34181
+ CLOUD_ANDROID_LEASE_IN_USE: "CLOUD_ANDROID_LEASE_IN_USE",
34182
+ CLOUD_ANDROID_NO_EMULATOR: "CLOUD_ANDROID_NO_EMULATOR",
34026
34183
  /**
34027
34184
  * External device providers
34028
34185
  * @see [external-devices.ts](../../tool-server/src/utils/external-devices.ts)
@@ -34107,9 +34264,9 @@ var FAILURE_SPAWN_CODE_SET = new Set(FAILURE_SPAWN_CODES);
34107
34264
  import { randomUUID as randomUUID3 } from "node:crypto";
34108
34265
  import { AsyncLocalStorage } from "node:async_hooks";
34109
34266
  var resolvedDuringInvocation = new AsyncLocalStorage();
34110
- function valueAtPath(root, path19) {
34267
+ function valueAtPath(root, path20) {
34111
34268
  let current = root;
34112
- for (const key of path19) {
34269
+ for (const key of path20) {
34113
34270
  if (current === null || typeof current !== "object") return void 0;
34114
34271
  if (!Object.hasOwn(current, key)) return void 0;
34115
34272
  current = current[key];
@@ -34167,10 +34324,10 @@ function describeParamIssues(error2, params) {
34167
34324
  }
34168
34325
 
34169
34326
  // ../argent-tools-client/src/link-config.ts
34170
- import * as path10 from "node:path";
34327
+ import * as path11 from "node:path";
34171
34328
  import { mkdir, writeFile, readFile as readFile2, unlink as unlink2, chmod } from "node:fs/promises";
34172
34329
  var LINK_DIR = argentHomeDir();
34173
- var LINK_FILE = path10.join(LINK_DIR, "link.json");
34330
+ var LINK_FILE = path11.join(LINK_DIR, "link.json");
34174
34331
  async function readLinkConfig() {
34175
34332
  try {
34176
34333
  const raw2 = await readFile2(LINK_FILE, "utf8");
@@ -34223,14 +34380,14 @@ import {
34223
34380
  writeFile as writeFile2
34224
34381
  } from "node:fs/promises";
34225
34382
  import { constants as constants2, tmpdir } from "node:os";
34226
- import * as path11 from "node:path";
34383
+ import * as path12 from "node:path";
34227
34384
 
34228
34385
  // ../archive/src/index.ts
34229
34386
  import { spawn as spawn2 } from "node:child_process";
34230
34387
  import { once } from "node:events";
34231
34388
  import { createReadStream, createWriteStream } from "node:fs";
34232
34389
  import { open as open2, rm, readdir as readdir3 } from "node:fs/promises";
34233
- import { basename as basename4, dirname as dirname5, join as join10, resolve as resolve8, sep as sep2 } from "node:path";
34390
+ import { basename as basename4, dirname as dirname6, join as join11, resolve as resolve8, sep as sep2 } from "node:path";
34234
34391
  import { Writable } from "node:stream";
34235
34392
  import { pipeline } from "node:stream/promises";
34236
34393
  import zlib from "node:zlib";
@@ -34254,7 +34411,7 @@ function createCompressor(format) {
34254
34411
  }
34255
34412
  function createTarArgs(sourcePath) {
34256
34413
  const name = basename4(sourcePath);
34257
- return ["-cf", "-", "-C", dirname5(sourcePath), /^[-@]/.test(name) ? `./${name}` : name];
34414
+ return ["-cf", "-", "-C", dirname6(sourcePath), /^[-@]/.test(name) ? `./${name}` : name];
34258
34415
  }
34259
34416
  var MAX_LISTING_BYTES = 32 << 20;
34260
34417
  var MAX_LISTING_LINES = 1 << 18;
@@ -34434,8 +34591,8 @@ async function runTar(archive, args, signal) {
34434
34591
  function normalizeTarMemberPath(memberPath) {
34435
34592
  return memberPath.replace(/^\.\//, "").replace(/\\/g, "/");
34436
34593
  }
34437
- function isContainedPath(path19, windows = process.platform === "win32") {
34438
- const slashed = path19.replace(/\\/g, "/");
34594
+ function isContainedPath(path20, windows = process.platform === "win32") {
34595
+ const slashed = path20.replace(/\\/g, "/");
34439
34596
  const drive = windows ? /^[A-Za-z]:/ : /^[A-Za-z]:\//;
34440
34597
  return !slashed.startsWith("/") && !drive.test(slashed) && !slashed.split("/").includes("..");
34441
34598
  }
@@ -34495,7 +34652,7 @@ async function assertSafeArchive(archive, destDir, signal) {
34495
34652
  async function resolveMember(destDir, expectedName) {
34496
34653
  const entries = await readdir3(destDir);
34497
34654
  if (entries.includes(expectedName)) {
34498
- return join10(destDir, expectedName);
34655
+ return join11(destDir, expectedName);
34499
34656
  }
34500
34657
  const real = entries.filter((e) => !e.startsWith("._"));
34501
34658
  if (real.length !== 1) {
@@ -34503,7 +34660,7 @@ async function resolveMember(destDir, expectedName) {
34503
34660
  `Could not identify the extracted member (expected "${expectedName}", found ${real.length} entries).`
34504
34661
  );
34505
34662
  }
34506
- return join10(destDir, real[0]);
34663
+ return join11(destDir, real[0]);
34507
34664
  }
34508
34665
  async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
34509
34666
  signal?.throwIfAborted();
@@ -34556,20 +34713,20 @@ function interpolatePath(template, args) {
34556
34713
  return missing ? null : out;
34557
34714
  }
34558
34715
  function callerPath(p) {
34559
- const onCurrentDrive = path11.sep === "\\" && /^[\\/](?![\\/])/.test(p);
34560
- if (!onCurrentDrive && (path11.isAbsolute(p) || path11.win32.isAbsolute(p) || isUnexpandedPath(p))) {
34716
+ const onCurrentDrive = path12.sep === "\\" && /^[\\/](?![\\/])/.test(p);
34717
+ if (!onCurrentDrive && (path12.isAbsolute(p) || path12.win32.isAbsolute(p) || isUnexpandedPath(p))) {
34561
34718
  return p;
34562
34719
  }
34563
- const { root } = path11.parse(p);
34720
+ const { root } = path12.parse(p);
34564
34721
  const rest = p.slice(root.length);
34565
34722
  if (!rest.split(/[\\/]/).includes("..")) {
34566
- const resolved = path11.resolve(p);
34567
- const last = p.split(path11.sep === "\\" ? /[\\/]/ : "/").at(-1);
34568
- const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(path11.sep);
34569
- return dirOnly ? `${resolved}${path11.sep}` : resolved;
34723
+ const resolved = path12.resolve(p);
34724
+ const last = p.split(path12.sep === "\\" ? /[\\/]/ : "/").at(-1);
34725
+ const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(path12.sep);
34726
+ return dirOnly ? `${resolved}${path12.sep}` : resolved;
34570
34727
  }
34571
- const base = path11.resolve(root);
34572
- return base.endsWith(path11.sep) ? `${base}${rest}` : `${base}${path11.sep}${rest}`;
34728
+ const base = path12.resolve(root);
34729
+ return base.endsWith(path12.sep) ? `${base}${rest}` : `${base}${path12.sep}${rest}`;
34573
34730
  }
34574
34731
  async function specPath(spec, args) {
34575
34732
  if (spec.kind !== "file" || !spec.paths?.length) return interpolatePath(spec.path, args);
@@ -34677,7 +34834,7 @@ async function uploadTar(tarPath, format, endpoint, signal) {
34677
34834
  }
34678
34835
  async function uploadFile(sourcePath, endpoint, signal) {
34679
34836
  const format = pickArchiveFormat(endpoint.formats);
34680
- const tarPath = path11.join(tmpdir(), `argent-upload-${randomUUID4()}.tar.gz`);
34837
+ const tarPath = path12.join(tmpdir(), `argent-upload-${randomUUID4()}.tar.gz`);
34681
34838
  trackArchive(tarPath);
34682
34839
  try {
34683
34840
  await createArchiveFile(await realpath2(sourcePath), tarPath, format, signal);
@@ -34752,7 +34909,7 @@ async function prepareFileInputs(specs, args, opts) {
34752
34909
  wire.mtimeMs = st.mtimeMs;
34753
34910
  }
34754
34911
  if (opts.uploadEndpoint && st) {
34755
- process.stderr.write(`Uploading ${path11.basename(filePath)} to the remote tool-server...
34912
+ process.stderr.write(`Uploading ${path12.basename(filePath)} to the remote tool-server...
34756
34913
  `);
34757
34914
  Object.assign(wire, await uploadFile(filePath, opts.uploadEndpoint, opts.signal));
34758
34915
  }
@@ -34762,7 +34919,7 @@ async function prepareFileInputs(specs, args, opts) {
34762
34919
  return out;
34763
34920
  }
34764
34921
  function isAllowedClientFilePath(p) {
34765
- if (!path11.isAbsolute(p)) return false;
34922
+ if (!path12.isAbsolute(p)) return false;
34766
34923
  const segments = p.split(/[\\/]+/);
34767
34924
  if (segments.includes("..")) return false;
34768
34925
  const file = segments[segments.length - 1] ?? "";
@@ -34773,7 +34930,7 @@ function isClientFileDirective2(value) {
34773
34930
  return !!value && typeof value === "object" && value[CLIENT_FILE_MARKER2] === true && typeof value.path === "string" && typeof value.content === "string";
34774
34931
  }
34775
34932
  async function replaceFile(target, bytes, mode) {
34776
- const temp = path11.join(path11.dirname(target), `.baseline-${randomUUID4()}.tmp`);
34933
+ const temp = path12.join(path12.dirname(target), `.baseline-${randomUUID4()}.tmp`);
34777
34934
  try {
34778
34935
  await writeFile2(temp, bytes, { flag: "wx" });
34779
34936
  if (mode !== void 0) await chmod2(temp, mode & 511);
@@ -34784,27 +34941,27 @@ async function replaceFile(target, bytes, mode) {
34784
34941
  }
34785
34942
  }
34786
34943
  async function writeBaselineFile(file, bytes, allowedDirs) {
34787
- if (!path11.isAbsolute(file) || path11.normalize(file) !== file || file.split(/[\\/]/).includes("..") || !file.endsWith(".png") || !allowedDirs.includes(path11.dirname(file))) {
34944
+ if (!path12.isAbsolute(file) || path12.normalize(file) !== file || file.split(/[\\/]/).includes("..") || !file.endsWith(".png") || !allowedDirs.includes(path12.dirname(file))) {
34788
34945
  return allowedDirs.length === 0 ? "this call writes no baselines" : `${file} is not a baseline of this call (${allowedDirs.map((d) => `${d}/<name>.png`).join(", ")})`;
34789
34946
  }
34790
34947
  if (bytes.length > MAX_CONTENT_BYTES) {
34791
34948
  return `${file}: the baseline is larger than the 32 MiB cap on a file this client writes`;
34792
34949
  }
34793
- const dir = path11.dirname(file);
34950
+ const dir = path12.dirname(file);
34794
34951
  await mkdir2(dir, { recursive: true });
34795
34952
  const link = await lstat(file).catch(() => null);
34796
34953
  const real = link === null ? null : await realpath2(file).catch(() => null);
34797
34954
  if (link !== null && real === null) return `${file} is a symbolic link to a missing file`;
34798
34955
  if (real !== null) {
34799
34956
  if (!real.endsWith(".png")) return `${file} links to a file that is not a PNG file`;
34800
- if (path11.dirname(real) !== await realpath2(dir)) {
34957
+ if (path12.dirname(real) !== await realpath2(dir)) {
34801
34958
  return `${file} links outside its baseline directory`;
34802
34959
  }
34803
34960
  }
34804
34961
  const existing = real === null ? null : await stat3(real);
34805
34962
  if (existing !== null && !existing.isFile()) return `${file} is not a regular file`;
34806
34963
  await replaceFile(
34807
- real ?? path11.join(await realpath2(dir), path11.basename(file)),
34964
+ real ?? path12.join(await realpath2(dir), path12.basename(file)),
34808
34965
  bytes,
34809
34966
  existing?.mode
34810
34967
  );
@@ -34830,7 +34987,7 @@ async function applyClientFileDirectives(result, opts = {}) {
34830
34987
  if (isClientFileDirective2(value)) {
34831
34988
  if (!isAllowedClientFilePath(value.path)) return null;
34832
34989
  try {
34833
- await mkdir2(path11.dirname(value.path), { recursive: true });
34990
+ await mkdir2(path12.dirname(value.path), { recursive: true });
34834
34991
  await writeFile2(value.path, value.content, "utf8");
34835
34992
  written.push(value.path);
34836
34993
  return value.path;
@@ -34859,13 +35016,13 @@ async function applyClientFileDirectives(result, opts = {}) {
34859
35016
  // ../argent-tools-client/src/flow-files.ts
34860
35017
  var import_yaml = __toESM(require_dist3(), 1);
34861
35018
  import { readdir as readdir4, readFile as readFile4, realpath as realpath3, stat as stat4 } from "node:fs/promises";
34862
- import * as path12 from "node:path";
35019
+ import * as path13 from "node:path";
34863
35020
  var INLINE_MEMBERS_BYTES = 256 * 1024;
34864
35021
  function filesLogEnabled() {
34865
35022
  return (process.env.ARGENT_E2E_FILES_LOG ?? process.env.ARGENT_FLOW_FILES_LOG) === "1";
34866
35023
  }
34867
35024
  function isWithin(inner, outer) {
34868
- return inner === outer || inner.startsWith(outer.endsWith(path12.sep) ? outer : outer + path12.sep);
35025
+ return inner === outer || inner.startsWith(outer.endsWith(path13.sep) ? outer : outer + path13.sep);
34869
35026
  }
34870
35027
  function printable(text) {
34871
35028
  return [...text].map(
@@ -34873,7 +35030,7 @@ function printable(text) {
34873
35030
  ).join("");
34874
35031
  }
34875
35032
  function isResolvedAbsolute2(value) {
34876
- return typeof value === "string" && path12.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
35033
+ return typeof value === "string" && path13.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
34877
35034
  }
34878
35035
  function namesValidFlow(args) {
34879
35036
  let canonical;
@@ -34885,13 +35042,13 @@ function namesValidFlow(args) {
34885
35042
  const { project_root, e2e_test_path: testPath, name } = canonical;
34886
35043
  if (!isResolvedAbsolute2(project_root)) return false;
34887
35044
  if (name === void 0) {
34888
- return isResolvedAbsolute2(testPath) && FLOW_FILE_NAME_PATTERN.test(path12.basename(testPath));
35045
+ return isResolvedAbsolute2(testPath) && FLOW_FILE_NAME_PATTERN.test(path13.basename(testPath));
34889
35046
  }
34890
35047
  return testPath === void 0 && typeof name === "string" && FLOW_NAME_PATTERN.test(name);
34891
35048
  }
34892
35049
  function savedFlowProject(file) {
34893
- if (!path12.isAbsolute(file)) return null;
34894
- for (let dir = path12.dirname(file); dir !== path12.dirname(dir); dir = path12.dirname(dir)) {
35050
+ if (!path13.isAbsolute(file)) return null;
35051
+ for (let dir = path13.dirname(file); dir !== path13.dirname(dir); dir = path13.dirname(dir)) {
34895
35052
  const project = e2eDirProject(dir);
34896
35053
  if (project !== null) return project;
34897
35054
  }
@@ -34906,11 +35063,11 @@ async function landing(spelled) {
34906
35063
  const canonical = await canonicalFlowPath(spelled);
34907
35064
  let at = spelled;
34908
35065
  for (; ; ) {
34909
- const parent = path12.dirname(at);
35066
+ const parent = path13.dirname(at);
34910
35067
  if (parent === at) return { canonical, fence: spelled, ...failure2 };
34911
35068
  const real = await realpath3(parent).catch(() => null);
34912
35069
  if (real !== null) {
34913
- return { canonical, fence: path12.join(real, path12.basename(at)), ...failure2 };
35070
+ return { canonical, fence: path13.join(real, path13.basename(at)), ...failure2 };
34914
35071
  }
34915
35072
  at = parent;
34916
35073
  }
@@ -34918,10 +35075,10 @@ async function landing(spelled) {
34918
35075
  }
34919
35076
  async function closureRoots(rootPath, rootCanonical, projectRoot) {
34920
35077
  const candidates = [];
34921
- if (typeof projectRoot === "string" && path12.isAbsolute(projectRoot)) {
35078
+ if (typeof projectRoot === "string" && path13.isAbsolute(projectRoot)) {
34922
35079
  candidates.push(projectRoot, ...e2eDirsFor(projectRoot));
34923
35080
  }
34924
- candidates.push(path12.dirname(rootPath), path12.dirname(rootCanonical));
35081
+ candidates.push(path13.dirname(rootPath), path13.dirname(rootCanonical));
34925
35082
  for (const file of [rootPath, rootCanonical]) {
34926
35083
  const project = savedFlowProject(file);
34927
35084
  if (project !== null) candidates.push(project);
@@ -34934,11 +35091,11 @@ async function closureRoots(rootPath, rootCanonical, projectRoot) {
34934
35091
  return real.filter((root) => !real.some((other) => other !== root && isWithin(root, other)));
34935
35092
  }
34936
35093
  async function readFlowMember(anchorDir, target, roots, budget, opts) {
34937
- const spelled = anchorDir + path12.sep + target;
35094
+ const spelled = anchorDir + path13.sep + target;
34938
35095
  const { canonical, fence, missing, error: error2 } = await landing(spelled);
34939
35096
  const spelling = await classifyOnDiskSpelling(
34940
- path12.dirname(spelled),
34941
- path12.posix.basename(target),
35097
+ path13.dirname(spelled),
35098
+ path13.posix.basename(target),
34942
35099
  FLOW_FILE_NAME_PATTERN
34943
35100
  );
34944
35101
  const member = {
@@ -34963,7 +35120,7 @@ async function readFlowMember(anchorDir, target, roots, budget, opts) {
34963
35120
  return { member: { ...member, state: "missing" }, sent: "missing" };
34964
35121
  }
34965
35122
  if (st.isDirectory()) return refuse("EISDIR: illegal operation on a directory, read");
34966
- if (!/\.ya?ml$/i.test(path12.basename(canonical))) {
35123
+ if (!/\.ya?ml$/i.test(path13.basename(canonical))) {
34967
35124
  return refuse(`${target} links to a file that is not a YAML file`);
34968
35125
  }
34969
35126
  const sent = await sendBytes(member, canonical, budget, opts);
@@ -35089,12 +35246,12 @@ function memberCollector(roots, opts) {
35089
35246
  }
35090
35247
  async function savedTest(target) {
35091
35248
  for (const candidate of target.paths) {
35092
- const found = await flow(path12.dirname(candidate), path12.basename(candidate), true);
35249
+ const found = await flow(path13.dirname(candidate), path13.basename(candidate), true);
35093
35250
  if (found !== void 0) return found;
35094
35251
  }
35095
35252
  let first;
35096
35253
  for (const candidate of target.paths) {
35097
- first ??= await flow(path12.dirname(candidate), path12.basename(candidate));
35254
+ first ??= await flow(path13.dirname(candidate), path13.basename(candidate));
35098
35255
  }
35099
35256
  return first;
35100
35257
  }
@@ -35104,9 +35261,9 @@ function memberCollector(roots, opts) {
35104
35261
  return { canonical: member.canonical, text, flowName: target.name, hop, updates, platform };
35105
35262
  }
35106
35263
  async function pathRun(target, hop, updates, platform) {
35107
- const { member, text } = await flow(path12.dirname(target.path), path12.basename(target.path));
35264
+ const { member, text } = await flow(path13.dirname(target.path), path13.basename(target.path));
35108
35265
  if (text === void 0 || hop >= MAX_RUN_DEPTH) return void 0;
35109
- const flowName = path12.basename(target.path, ".yaml");
35266
+ const flowName = path13.basename(target.path, ".yaml");
35110
35267
  return { canonical: member.canonical, text, flowName, hop, updates, platform };
35111
35268
  }
35112
35269
  async function runTarget(anchorDir, target) {
@@ -35137,7 +35294,7 @@ function memberCollector(roots, opts) {
35137
35294
  const requests = collectFlowRequests(doc);
35138
35295
  for (const name of requests.snapshots) snapshots.add(name);
35139
35296
  for (const step of requests.toolSteps) await toolFiles(step);
35140
- const anchorDir = path12.dirname(file.canonical);
35297
+ const anchorDir = path13.dirname(file.canonical);
35141
35298
  for (const target of requests.runTargets) {
35142
35299
  const key = flowMemberKey(anchorDir, target);
35143
35300
  if (visited.has(key)) continue;
@@ -35154,8 +35311,8 @@ function memberCollector(roots, opts) {
35154
35311
  }
35155
35312
  }
35156
35313
  if (snapshots.size === 0) continue;
35157
- const dir = path12.join(
35158
- path12.dirname(run.canonical),
35314
+ const dir = path13.join(
35315
+ path13.dirname(run.canonical),
35159
35316
  "__baselines__",
35160
35317
  baselineKeyFor(run.canonical, run.flowName)
35161
35318
  );
@@ -35180,7 +35337,7 @@ function memberCollector(roots, opts) {
35180
35337
  if (!name.endsWith(".png")) continue;
35181
35338
  const compared = [...prefixes].some((prefix) => name.startsWith(prefix));
35182
35339
  if (!updates && !compared) continue;
35183
- const file = path12.join(dir, name);
35340
+ const file = path13.join(dir, name);
35184
35341
  if (tools.has(file)) continue;
35185
35342
  const member = { role: "baseline", key: file, path: file };
35186
35343
  const entry = await baselineEntry(file, roots, updates && !compared);
@@ -35203,19 +35360,19 @@ async function collectFlowMembers(rootPath, rootBytes, args, opts) {
35203
35360
  if (!namesValidFlow(args)) return {};
35204
35361
  const canonical = await canonicalFlowPath(rootPath);
35205
35362
  const spelling = await classifyOnDiskSpelling(
35206
- path12.dirname(rootPath),
35207
- path12.basename(rootPath),
35363
+ path13.dirname(rootPath),
35364
+ path13.basename(rootPath),
35208
35365
  FLOW_FILE_NAME_PATTERN
35209
35366
  );
35210
35367
  const collector = memberCollector(
35211
- opts.scanOnly ? [path12.parse(path12.resolve(rootPath)).root] : await closureRoots(rootPath, canonical, args.project_root),
35368
+ opts.scanOnly ? [path13.parse(path13.resolve(rootPath)).root] : await closureRoots(rootPath, canonical, args.project_root),
35212
35369
  opts
35213
35370
  );
35214
35371
  await collector.walk([
35215
35372
  {
35216
35373
  canonical,
35217
35374
  text: rootBytes.toString("utf8"),
35218
- flowName: path12.basename(rootPath, ".yaml"),
35375
+ flowName: path13.basename(rootPath, ".yaml"),
35219
35376
  hop: 0,
35220
35377
  updates: args.updateBaselines === true,
35221
35378
  platform: callPlatform(args)
@@ -35244,31 +35401,31 @@ async function collectStepMembers(args, opts, recordingDirFor = e2eDirFor) {
35244
35401
  if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name) || !isResolvedAbsolute2(projectRoot) || step === void 0) {
35245
35402
  return [];
35246
35403
  }
35247
- const recording = path12.join(recordingDirFor(projectRoot), `${name}.yaml`);
35404
+ const recording = path13.join(recordingDirFor(projectRoot), `${name}.yaml`);
35248
35405
  const collector = memberCollector(
35249
- opts.scanOnly ? [path12.parse(recording).root] : await closureRoots(recording, (await landing(recording)).canonical, projectRoot),
35406
+ opts.scanOnly ? [path13.parse(recording).root] : await closureRoots(recording, (await landing(recording)).canonical, projectRoot),
35250
35407
  opts
35251
35408
  );
35252
35409
  await collector.toolFiles(step);
35253
35410
  if (canonicalToolId(step.tool) === "e2e-execute") {
35254
- const self = await collector.flow(path12.dirname(recording), path12.basename(recording));
35411
+ const self = await collector.flow(path13.dirname(recording), path13.basename(recording));
35255
35412
  let runArgs = step.args;
35256
35413
  const named = nestedFlowTarget(runArgs);
35257
35414
  if (named?.kind === "e2e_test_path") {
35258
- const stem = path12.basename(named.path, ".yaml");
35259
- const base = path12.basename(named.path);
35260
- const dir = path12.resolve(path12.dirname(named.path));
35261
- const recordingDir = path12.dirname(recording);
35415
+ const stem = path13.basename(named.path, ".yaml");
35416
+ const base = path13.basename(named.path);
35417
+ const dir = path13.resolve(path13.dirname(named.path));
35418
+ const recordingDir = path13.dirname(recording);
35262
35419
  const dirs = [recordingDir, ...e2eRunFallbackDirs(recordingDir, base)];
35263
- if (dirs.some((d) => path12.resolve(d) === dir)) {
35264
- await collector.flow(path12.dirname(named.path), base);
35420
+ if (dirs.some((d) => path13.resolve(d) === dir)) {
35421
+ await collector.flow(path13.dirname(named.path), base);
35265
35422
  runArgs = { ...runArgs, name: stem };
35266
35423
  delete runArgs.e2e_test_path;
35267
35424
  }
35268
35425
  }
35269
35426
  const target = nestedFlowTarget(runArgs);
35270
35427
  if (target?.kind === "name") {
35271
- await collector.flow(path12.dirname(self.member.canonical), `${target.name}.yaml`);
35428
+ await collector.flow(path13.dirname(self.member.canonical), `${target.name}.yaml`);
35272
35429
  const run = await collector.nestedRun(
35273
35430
  target,
35274
35431
  0,
@@ -35462,10 +35619,10 @@ function assertFiniteNumbers(args) {
35462
35619
  if (typeof item === "object" && item !== null) {
35463
35620
  pending.push({ value: item, key, parent: visit });
35464
35621
  } else if (typeof item === "number" && !Number.isFinite(item)) {
35465
- const path19 = [key];
35466
- for (let at = visit; at.parent; at = at.parent) path19.push(at.key);
35467
- path19.reverse();
35468
- issues.push({ code: "invalid_type", path: path19, message: `expected a number, got ${item}` });
35622
+ const path20 = [key];
35623
+ for (let at = visit; at.parent; at = at.parent) path20.push(at.key);
35624
+ path20.reverse();
35625
+ issues.push({ code: "invalid_type", path: path20, message: `expected a number, got ${item}` });
35469
35626
  if (issues.length === MAX_NON_FINITE_ISSUES) break;
35470
35627
  }
35471
35628
  }
@@ -35574,8 +35731,8 @@ var RECORDING_TOOLS = /* @__PURE__ */ new Set([
35574
35731
  ]);
35575
35732
  var RECORDING_FILE_INPUT = {
35576
35733
  target: "__recording",
35577
- path: `\${project_root}/${E2E_DIRS[0].split(path13.sep).join("/")}/\${name}.yaml`,
35578
- paths: E2E_DIRS.map((dir) => `\${project_root}/${dir.split(path13.sep).join("/")}/\${name}.yaml`),
35734
+ path: `\${project_root}/${E2E_DIRS[0].split(path14.sep).join("/")}/\${name}.yaml`,
35735
+ paths: E2E_DIRS.map((dir) => `\${project_root}/${dir.split(path14.sep).join("/")}/\${name}.yaml`),
35579
35736
  kind: "file",
35580
35737
  optional: true,
35581
35738
  collect: "flow"
@@ -35624,6 +35781,7 @@ function failedRun(result) {
35624
35781
  }
35625
35782
  function createToolsClient(options = {}) {
35626
35783
  let cached2 = null;
35784
+ let linkedNoticeShown = false;
35627
35785
  const doFetch = options.fetchImpl ?? ((url, init) => fetch(url, init));
35628
35786
  const diagnose = options.onDiagnostic ?? ((message) => void process.stderr.write(`${message}
35629
35787
  `));
@@ -35632,6 +35790,11 @@ function createToolsClient(options = {}) {
35632
35790
  assertPrivateArgentHome();
35633
35791
  const resolved = await getResolvedToolsUrl();
35634
35792
  if (resolved.url) {
35793
+ if (!linkedNoticeShown) {
35794
+ linkedNoticeShown = true;
35795
+ const notice = linkedCloudCredentialNotice();
35796
+ if (notice) diagnose(notice);
35797
+ }
35635
35798
  return { url: resolved.url, token: resolved.token ?? "", remote: true };
35636
35799
  }
35637
35800
  if (!cached2) {
@@ -35686,7 +35849,7 @@ function createToolsClient(options = {}) {
35686
35849
  let unwrittenBaselines = [];
35687
35850
  const memberOptions = {
35688
35851
  collectMembers: collectFlowMembers,
35689
- collectStepMembers: olderServer ? (record2, o) => collectStepMembers(record2, o, (root) => path13.join(root, LEGACY_E2E_DIRS[0])) : collectStepMembers,
35852
+ collectStepMembers: olderServer ? (record2, o) => collectStepMembers(record2, o, (root) => path14.join(root, LEGACY_E2E_DIRS[0])) : collectStepMembers,
35690
35853
  toolFileInputs: (tool) => findTool(tools, tool)?.fileInputs,
35691
35854
  signal: opts?.signal
35692
35855
  };
@@ -35719,7 +35882,7 @@ function createToolsClient(options = {}) {
35719
35882
  }
35720
35883
  if (filesLogEnabled()) {
35721
35884
  for (const file of applied.written) {
35722
- if (baselineDirs.includes(path13.dirname(file))) {
35885
+ if (baselineDirs.includes(path14.dirname(file))) {
35723
35886
  diagnose(`[e2e-files] baseline ${file}: written`);
35724
35887
  }
35725
35888
  }
@@ -35868,7 +36031,7 @@ import {
35868
36031
  } from "node:fs/promises";
35869
36032
  import { constants as fsConstants } from "node:fs";
35870
36033
  import { tmpdir as tmpdir2 } from "node:os";
35871
- import { basename as basename7, extname as extname2, isAbsolute as isAbsolute6, join as join14, normalize as normalize2, resolve as resolve11, sep as sep6 } from "node:path";
36034
+ import { basename as basename7, extname as extname2, isAbsolute as isAbsolute6, join as join15, normalize as normalize2, resolve as resolve11, sep as sep6 } from "node:path";
35872
36035
  import { createHash as createHash3 } from "node:crypto";
35873
36036
  var ARTIFACT_MARKER2 = "__argentArtifact";
35874
36037
  function isArtifactHandle(value) {
@@ -35892,12 +36055,12 @@ function projectSlug() {
35892
36055
  return `${name}-${hash}`;
35893
36056
  }
35894
36057
  function artifactsRoot() {
35895
- return process.env.ARGENT_ARTIFACTS_DIR ?? join14(tmpdir2(), "argent-artifacts");
36058
+ return process.env.ARGENT_ARTIFACTS_DIR ?? join15(tmpdir2(), "argent-artifacts");
35896
36059
  }
35897
36060
  function artifactDir(deviceId) {
35898
36061
  const parts = [artifactsRoot(), projectSlug(), sessionId()];
35899
36062
  if (deviceId) parts.push(sanitizeSegment(deviceId));
35900
- return join14(...parts);
36063
+ return join15(...parts);
35901
36064
  }
35902
36065
  function durableBaseDir() {
35903
36066
  const projectRoot = findProjectRoot(process.cwd());
@@ -35916,7 +36079,7 @@ function configuredRecordingsDir() {
35916
36079
  const trimmed = value.trim();
35917
36080
  if (trimmed === "") return null;
35918
36081
  const home = resolveHomeDir();
35919
- const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep6}`) ? join14(home, trimmed.slice(2)) : trimmed;
36082
+ const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep6}`) ? join15(home, trimmed.slice(2)) : trimmed;
35920
36083
  return resolve11(durableBaseDir(), expanded);
35921
36084
  }
35922
36085
  var MAX_ARTIFACT_BYTES = 2 * 1024 * 1024 * 1024;
@@ -35950,10 +36113,10 @@ async function writeDurableUnique(dir, filename, write) {
35950
36113
  const stem = filename.slice(0, filename.length - ext.length);
35951
36114
  for (let i = 1; i <= 1e3; i++) {
35952
36115
  const candidate = i === 1 ? filename : `${stem} (${i})${ext}`;
35953
- const path19 = join14(dir, candidate);
36116
+ const path20 = join15(dir, candidate);
35954
36117
  try {
35955
- await write(path19);
35956
- return path19;
36118
+ await write(path20);
36119
+ return path20;
35957
36120
  } catch (err) {
35958
36121
  if (err?.code === "EEXIST") continue;
35959
36122
  throw err;
@@ -35973,21 +36136,21 @@ function durableSaveTarget(handle) {
35973
36136
  if (configured) {
35974
36137
  return {
35975
36138
  dir: configured,
35976
- path: join14(configured, sanitizeSegment(handle.filename)),
36139
+ path: join15(configured, sanitizeSegment(handle.filename)),
35977
36140
  base: configured,
35978
36141
  rel: ""
35979
36142
  };
35980
36143
  }
35981
36144
  }
35982
36145
  const base = durableBaseDir();
35983
- const dir = join14(base, rel);
35984
- return { dir, path: join14(dir, sanitizeSegment(handle.filename)), base, rel };
36146
+ const dir = join15(base, rel);
36147
+ return { dir, path: join15(dir, sanitizeSegment(handle.filename)), base, rel };
35985
36148
  }
35986
36149
  async function confineToRealBase(dir, base, rel) {
35987
36150
  try {
35988
36151
  const realDir = await realpath4(dir);
35989
36152
  const realBase = await realpath4(base);
35990
- return realDir === join14(realBase, rel);
36153
+ return realDir === join15(realBase, rel);
35991
36154
  } catch {
35992
36155
  return false;
35993
36156
  }
@@ -36011,9 +36174,9 @@ async function resolveLocalFile(handle) {
36011
36174
  }
36012
36175
  async function downloadAndExtractArchive(handle, data, dir, signal) {
36013
36176
  signal?.throwIfAborted();
36014
- const attemptDir = await mkdtemp(join14(dir, "bundle-"));
36015
- const tarball = join14(attemptDir, "download.tar");
36016
- const extractDir = join14(attemptDir, "files");
36177
+ const attemptDir = await mkdtemp(join15(dir, "bundle-"));
36178
+ const tarball = join15(attemptDir, "download.tar");
36179
+ const extractDir = join15(attemptDir, "files");
36017
36180
  try {
36018
36181
  await writeFile3(tarball, data, { signal });
36019
36182
  await mkdir3(extractDir);
@@ -36113,7 +36276,7 @@ async function materializeArtifacts(result, ctx) {
36113
36276
  return await downloadAndExtractArchive(value, data, dir, ctx.signal);
36114
36277
  }
36115
36278
  if (value.size > 0 && data.length !== value.size) return null;
36116
- const downloadedPath = join14(dir, sanitizeSegment(value.filename));
36279
+ const downloadedPath = join15(dir, sanitizeSegment(value.filename));
36117
36280
  await writeFile3(downloadedPath, data);
36118
36281
  if (value.mimeType.startsWith("image/")) {
36119
36282
  images.push({ localPath: downloadedPath, data, mimeType: value.mimeType });
@@ -36147,10 +36310,10 @@ function getDeviceIdFromArgs(args) {
36147
36310
  }
36148
36311
 
36149
36312
  // ../telemetry/src/debug.ts
36150
- import * as fs9 from "node:fs";
36313
+ import * as fs10 from "node:fs";
36151
36314
 
36152
36315
  // ../telemetry/src/paths.ts
36153
- import * as path14 from "node:path";
36316
+ import * as path15 from "node:path";
36154
36317
 
36155
36318
  // ../telemetry/src/events.ts
36156
36319
  var PLATFORMS = [
@@ -36482,30 +36645,30 @@ var SESSION_ID2 = randomUUID5();
36482
36645
 
36483
36646
  // ../telemetry/src/identity.ts
36484
36647
  import * as crypto2 from "node:crypto";
36485
- import * as fs10 from "node:fs";
36486
- import * as path15 from "node:path";
36648
+ import * as fs11 from "node:fs";
36649
+ import * as path16 from "node:path";
36487
36650
 
36488
36651
  // ../telemetry/src/fingerprint.ts
36489
36652
  import { execFileSync as execFileSync2, spawn as spawn3 } from "node:child_process";
36490
36653
 
36491
36654
  // ../native-devtools-ios/src/index.ts
36492
- import * as path16 from "node:path";
36493
- import * as fs11 from "node:fs";
36494
- var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ?? path16.join(__dirname, "..", "dylibs");
36495
- var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ?? path16.join(__dirname, "..", "bin");
36496
- var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ?? path16.join(DYLIB_DIR, "tcp");
36497
- var DYLIB_TVOS_DIR = path16.join(DYLIB_DIR, "tvos");
36655
+ import * as path17 from "node:path";
36656
+ import * as fs12 from "node:fs";
36657
+ var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ?? path17.join(__dirname, "..", "dylibs");
36658
+ var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ?? path17.join(__dirname, "..", "bin");
36659
+ var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ?? path17.join(DYLIB_DIR, "tcp");
36660
+ var DYLIB_TVOS_DIR = path17.join(DYLIB_DIR, "tvos");
36498
36661
 
36499
36662
  // ../telemetry/src/consent.ts
36500
- import * as fs12 from "node:fs";
36501
- import * as path17 from "node:path";
36663
+ import * as fs13 from "node:fs";
36664
+ import * as path18 from "node:path";
36502
36665
  var cache = /* @__PURE__ */ new Map();
36503
36666
  var sessionOverride = null;
36504
36667
  function readConfigOverrideAt(filePath) {
36505
36668
  const miss = { mtimeMs: null, fingerprint: null, enabledOverride: null };
36506
36669
  let stats;
36507
36670
  try {
36508
- stats = fs12.lstatSync(filePath);
36671
+ stats = fs13.lstatSync(filePath);
36509
36672
  } catch {
36510
36673
  cache.set(filePath, miss);
36511
36674
  return null;
@@ -36522,7 +36685,7 @@ function readConfigOverrideAt(filePath) {
36522
36685
  }
36523
36686
  let parsedEnabled = null;
36524
36687
  try {
36525
- const raw2 = fs12.readFileSync(filePath, "utf8");
36688
+ const raw2 = fs13.readFileSync(filePath, "utf8");
36526
36689
  const json = JSON.parse(raw2);
36527
36690
  if (json && typeof json === "object") {
36528
36691
  const t = json.telemetry;
@@ -36539,12 +36702,12 @@ function readConfigOverrideAt(filePath) {
36539
36702
  function readPersistedConsent(cwd) {
36540
36703
  const globalPath = configFilePath("global");
36541
36704
  const projectPath = configFilePath("project", { cwd });
36542
- const userConfigPath = path17.join(resolveHomeDir(), ".argent", "config.json");
36705
+ const userConfigPath = path18.join(resolveHomeDir(), ".argent", "config.json");
36543
36706
  if (userConfigPath !== globalPath && readConfigOverrideAt(userConfigPath) === false) {
36544
36707
  return { enabled: false, detail: `${userConfigPath} (user)` };
36545
36708
  }
36546
36709
  const global = readConfigOverrideAt(globalPath);
36547
- const projectRoot = path17.dirname(path17.dirname(projectPath));
36710
+ const projectRoot = path18.dirname(path18.dirname(projectPath));
36548
36711
  const project = isHomeDir(projectRoot) ? null : readConfigOverrideAt(projectPath);
36549
36712
  if (project === false && global === false) {
36550
36713
  return { enabled: false, detail: "config.json (project and global)" };
@@ -36957,9 +37120,9 @@ async function flowRunToMcpContent(result, ctx) {
36957
37120
  }
36958
37121
  }
36959
37122
  for (const write of result.baselineWrites ?? []) {
36960
- const { path: path19, error: error2 } = isRecord3(write) ? write : {};
36961
- if (typeof path19 === "string" && typeof error2 === "string") {
36962
- blocks.push({ type: "text", text: `\u2717 baseline not written: ${path19}: ${error2}` });
37123
+ const { path: path20, error: error2 } = isRecord3(write) ? write : {};
37124
+ if (typeof path20 === "string" && typeof error2 === "string") {
37125
+ blocks.push({ type: "text", text: `\u2717 baseline not written: ${path20}: ${error2}` });
36963
37126
  }
36964
37127
  }
36965
37128
  if (result.shutdownFailed === true) {
@@ -38014,12 +38177,12 @@ function debuggerLogRegistryText(result) {
38014
38177
  var SERVER_INSTRUCTIONS = "Argent controls iOS, Android, Chromium, Mac, TV, and HarmonyOS apps. Use the platform named by the user; otherwise prefer an already-running device from `list-devices` (do not default to iOS). In a single-platform project, boot that platform. Prefer Argent tools over raw `xcrun`/`adb`; use `launch-app`/`open-url` instead of tapping home-screen icons. Load `argent-create-e2e` (`argent-qa-e2e` for acceptance tests) before the first action if an e2e test may be needed (recording is not retroactive), and load the matching `argent-*` skill before React Native build/debug, profiling, physical phone, Mac app, or TV work. Interaction tools return a screenshot + accessibility tree with normalized [0,1] tap frames (or an unchanged note / `-`+`+` diff referencing an earlier screenshot/tree id). Take tap coordinates from that tree \u2014 never guess from pixels \u2014 and call `describe` only without a fresh tree. After two failed taps, re-discover. Use `await-ui-element` instead of polling. Do not stop simulator servers when finishing; call `stop-all-simulator-servers` only when asked to clean up or when a skill tells you to recycle a device's services, scoped with `devices: [...]` (the tool-server is shared across agents), and never stop a user-started Metro. CLI: `argent --help`.";
38015
38178
 
38016
38179
  // ../argent-mcp/src/installed-version.ts
38017
- import * as fs13 from "node:fs";
38018
- import * as path18 from "node:path";
38180
+ import * as fs14 from "node:fs";
38181
+ import * as path19 from "node:path";
38019
38182
  function getInstalledVersion() {
38020
38183
  try {
38021
- const pkgPath = path18.resolve(import.meta.dirname, "..", "package.json");
38022
- const pkg = JSON.parse(fs13.readFileSync(pkgPath, "utf8"));
38184
+ const pkgPath = path19.resolve(import.meta.dirname, "..", "package.json");
38185
+ const pkg = JSON.parse(fs14.readFileSync(pkgPath, "utf8"));
38023
38186
  return pkg.version ?? "unknown";
38024
38187
  } catch {
38025
38188
  return "unknown";
@@ -38142,14 +38305,14 @@ import {
38142
38305
  appendFileSync as appendFileSync2,
38143
38306
  chmodSync,
38144
38307
  linkSync as linkSync2,
38145
- mkdirSync as mkdirSync6,
38146
- readFileSync as readFileSync8,
38308
+ mkdirSync as mkdirSync7,
38309
+ readFileSync as readFileSync9,
38147
38310
  renameSync as renameSync5,
38148
38311
  rmSync as rmSync4,
38149
- statSync as statSync4
38312
+ statSync as statSync5
38150
38313
  } from "node:fs";
38151
38314
  import { appendFile } from "node:fs/promises";
38152
- import { dirname as dirname10 } from "node:path";
38315
+ import { dirname as dirname11 } from "node:path";
38153
38316
  var CALL_LOG_MAX_BYTES = 10 * 1024 * 1024;
38154
38317
  var STAT_EVERY_BYTES = 1024 * 1024;
38155
38318
  function createCallLog(file, maxBytes = CALL_LOG_MAX_BYTES) {
@@ -38160,7 +38323,7 @@ function createCallLog(file, maxBytes = CALL_LOG_MAX_BYTES) {
38160
38323
  function check() {
38161
38324
  sinceStat = 0;
38162
38325
  estimate = 0;
38163
- const st = statSync4(file, { throwIfNoEntry: false });
38326
+ const st = statSync5(file, { throwIfNoEntry: false });
38164
38327
  if (!st) return;
38165
38328
  if (st.mode & 63) {
38166
38329
  try {
@@ -38177,7 +38340,7 @@ function createCallLog(file, maxBytes = CALL_LOG_MAX_BYTES) {
38177
38340
  return async function write(entry) {
38178
38341
  try {
38179
38342
  if (!dirReady) {
38180
- mkdirSync6(dirname10(file), { recursive: true, mode: 448 });
38343
+ mkdirSync7(dirname11(file), { recursive: true, mode: 448 });
38181
38344
  dirReady = true;
38182
38345
  }
38183
38346
  if (!checked || estimate >= maxBytes || sinceStat >= STAT_EVERY_BYTES) {
@@ -38202,7 +38365,7 @@ function rotate(file, measured) {
38202
38365
  }
38203
38366
  let moved;
38204
38367
  try {
38205
- moved = statSync4(aside);
38368
+ moved = statSync5(aside);
38206
38369
  } catch {
38207
38370
  return;
38208
38371
  }
@@ -38217,7 +38380,7 @@ function rotate(file, measured) {
38217
38380
  linkSync2(aside, file);
38218
38381
  } catch {
38219
38382
  try {
38220
- appendFileSync2(file, readFileSync8(aside), { mode: 384 });
38383
+ appendFileSync2(file, readFileSync9(aside), { mode: 384 });
38221
38384
  } catch {
38222
38385
  return;
38223
38386
  }
@@ -38305,7 +38468,7 @@ async function startMcpServer(options) {
38305
38468
  const autoDescribeOn = autoDescribeEnabled();
38306
38469
  const whatsNewOn = whatsNewEnabled();
38307
38470
  const installedVersion = getInstalledVersion();
38308
- const highlightsVersion = true ? "0.35.1-next.67" : installedVersion;
38471
+ const highlightsVersion = true ? "0.35.1-next.68" : installedVersion;
38309
38472
  const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
38310
38473
  const trees = createTreeMemory();
38311
38474
  const screenshots = createScreenshotMemory();
@@ -38316,6 +38479,9 @@ async function startMcpServer(options) {
38316
38479
  if (resolved.url) {
38317
38480
  TOOLS_URL = resolved.url;
38318
38481
  AUTH_TOKEN = resolved.token ?? "";
38482
+ const notice = linkedCloudCredentialNotice();
38483
+ if (notice) process.stderr.write(`${notice}
38484
+ `);
38319
38485
  } else {
38320
38486
  try {
38321
38487
  const handle = await ensureToolsServer(options.paths);
@@ -38350,7 +38516,7 @@ async function startMcpServer(options) {
38350
38516
  }
38351
38517
  return reconnectPromise;
38352
38518
  }
38353
- const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? join19(argentHomeDir(), "mcp-calls.log");
38519
+ const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? join20(argentHomeDir(), "mcp-calls.log");
38354
38520
  const spyLog = createCallLog(LOG_FILE2);
38355
38521
  const { fetchTools, callTool } = createToolCaller({
38356
38522
  getHandle: () => ({ url: TOOLS_URL, token: AUTH_TOKEN }),