@swmansion/argent 0.34.1-next.4 → 0.34.1-next.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +1 -0
  2. package/assets/ios-screen-stream/Info.plist +12 -0
  3. package/assets/ios-screen-stream/ios-screen-stream.swift +321 -0
  4. package/bin/argent-android-devtools-0.4.0.apk +0 -0
  5. package/bin/darwin/argent-macos-helper +0 -0
  6. package/bin/darwin/ax-service +0 -0
  7. package/bin/darwin/simulator-server +0 -0
  8. package/bin/darwin/tvos-ax-service +0 -0
  9. package/bin/darwin/tvos-hid-daemon +0 -0
  10. package/bin/linux/simulator-server +0 -0
  11. package/bin/linux-arm64/simulator-server +0 -0
  12. package/bin/network-inspector/network-inspector.jar +0 -0
  13. package/bin/tcp/ax-service +0 -0
  14. package/bin/win32/simulator-server.exe +0 -0
  15. package/dist/cli-cmds.mjs +925 -559
  16. package/dist/client.js +345 -179
  17. package/dist/flow-script-runner.mjs +1 -0
  18. package/dist/installer-help.js +4 -0
  19. package/dist/installer-help.js.map +1 -1
  20. package/dist/installer.mjs +1219 -922
  21. package/dist/ios-device-runner/ArgentRunner/ArgentRunnerUITests/ArgentLaunchPerformanceTests.swift +21 -0
  22. package/dist/ios-device-runner/ArgentRunner/ArgentRunnerUITests/ArgentRunnerSession+Commands.swift +9 -3
  23. package/dist/mcp-server.mjs +558 -712
  24. package/dist/preview-ui/index.html +28 -2
  25. package/dist/tool-args.generated.d.ts +58 -12
  26. package/dist/tool-server.cjs +11444 -5226
  27. package/dylibs/libArgentAudio.dylib +0 -0
  28. package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
  29. package/dylibs/libKeyboardPatch.dylib +0 -0
  30. package/dylibs/libNativeDevtoolsIos.dylib +0 -0
  31. package/dylibs/macos/libArgentInjectionBootstrap.dylib +0 -0
  32. package/dylibs/macos/libNativeDevtoolsMacos.dylib +0 -0
  33. package/dylibs/tcp/libArgentInjectionBootstrap.dylib +0 -0
  34. package/dylibs/tcp/libKeyboardPatch.dylib +0 -0
  35. package/dylibs/tcp/libNativeDevtoolsIos.dylib +0 -0
  36. package/dylibs/tvos/libArgentInjectionBootstrap.dylib +0 -0
  37. package/dylibs/tvos/libKeyboardPatch.dylib +0 -0
  38. package/dylibs/tvos/libNativeDevtoolsIos.dylib +0 -0
  39. package/package.json +1 -1
  40. package/rules/argent.md +6 -23
  41. package/skills/argent-create-e2e/references/e2e-yaml.md +2 -2
  42. package/skills/argent-create-e2e/references/live-authoring.md +1 -1
  43. package/skills/argent-device-interact/SKILL.md +22 -21
  44. package/skills/argent-device-interact/references/foldables.md +22 -0
  45. package/skills/argent-ios-device-interact/SKILL.md +2 -2
  46. package/skills/argent-macos-app-interact/SKILL.md +15 -5
  47. package/skills/argent-macos-app-interact/references/e2e.md +1 -1
  48. package/skills/argent-metro-debugger/SKILL.md +1 -1
  49. package/skills/argent-native-profiler/SKILL.md +14 -2
  50. package/skills/argent-react-native-app-workflow/SKILL.md +1 -1
  51. package/skills/argent-react-native-optimization/SKILL.md +10 -1
  52. package/skills/argent-react-native-profiler/SKILL.md +4 -3
  53. package/skills/argent-screen-recording/SKILL.md +3 -2
  54. package/skills/argent-screenshot-diff/SKILL.md +1 -1
@@ -2990,7 +2990,7 @@ var require_compile = __commonJS({
2990
2990
  const schOrFunc = root.refs[ref];
2991
2991
  if (schOrFunc)
2992
2992
  return schOrFunc;
2993
- let _sch = resolve10.call(this, root, ref);
2993
+ let _sch = resolve12.call(this, root, ref);
2994
2994
  if (_sch === void 0) {
2995
2995
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
2996
2996
  const { schemaId } = this.opts;
@@ -3017,7 +3017,7 @@ var require_compile = __commonJS({
3017
3017
  function sameSchemaEnv(s1, s2) {
3018
3018
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
3019
3019
  }
3020
- function resolve10(root, ref) {
3020
+ function resolve12(root, ref) {
3021
3021
  let sch;
3022
3022
  while (typeof (sch = this.refs[ref]) == "string")
3023
3023
  ref = sch;
@@ -3235,8 +3235,8 @@ var require_utils = __commonJS({
3235
3235
  }
3236
3236
  return ind;
3237
3237
  }
3238
- function removeDotSegments(path17) {
3239
- let input = path17;
3238
+ function removeDotSegments(path18) {
3239
+ let input = path18;
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 [path17, query] = wsComponent.resourceName.split("?");
3492
- wsComponent.path = path17 && path17 !== "/" ? path17 : void 0;
3491
+ const [path18, query] = wsComponent.resourceName.split("?");
3492
+ wsComponent.path = path18 && path18 !== "/" ? path18 : void 0;
3493
3493
  wsComponent.query = query;
3494
3494
  wsComponent.resourceName = void 0;
3495
3495
  }
@@ -3644,21 +3644,21 @@ var require_fast_uri = __commonJS({
3644
3644
  normalizeString(uri, options);
3645
3645
  } else if (typeof uri === "object") {
3646
3646
  uri = /** @type {T} */
3647
- parse3(serialize(uri, options), options);
3647
+ parse4(serialize(uri, options), options);
3648
3648
  }
3649
3649
  return uri;
3650
3650
  }
3651
- function resolve10(baseURI, relativeURI, options) {
3651
+ function resolve12(baseURI, relativeURI, options) {
3652
3652
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3653
- const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
3653
+ const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
3654
3654
  schemelessOptions.skipEscape = true;
3655
3655
  return serialize(resolved, schemelessOptions);
3656
3656
  }
3657
3657
  function resolveComponent(base, relative2, options, skipNormalization) {
3658
3658
  const target = {};
3659
3659
  if (!skipNormalization) {
3660
- base = parse3(serialize(base, options), options);
3661
- relative2 = parse3(serialize(relative2, options), options);
3660
+ base = parse4(serialize(base, options), options);
3661
+ relative2 = parse4(serialize(relative2, options), options);
3662
3662
  }
3663
3663
  options = options || {};
3664
3664
  if (!options.tolerant && relative2.scheme) {
@@ -3881,7 +3881,7 @@ var require_fast_uri = __commonJS({
3881
3881
  }
3882
3882
  return { parsed, malformedAuthorityOrPort };
3883
3883
  }
3884
- function parse3(uri, opts) {
3884
+ function parse4(uri, opts) {
3885
3885
  return parseWithStatus(uri, opts).parsed;
3886
3886
  }
3887
3887
  function normalizeString(uri, opts) {
@@ -3906,11 +3906,11 @@ var require_fast_uri = __commonJS({
3906
3906
  var fastUri = {
3907
3907
  SCHEMES,
3908
3908
  normalize: normalize3,
3909
- resolve: resolve10,
3909
+ resolve: resolve12,
3910
3910
  resolveComponent,
3911
3911
  equal,
3912
3912
  serialize,
3913
- parse: parse3
3913
+ parse: parse4
3914
3914
  };
3915
3915
  module.exports = fastUri;
3916
3916
  module.exports.default = fastUri;
@@ -6882,12 +6882,12 @@ var require_dist = __commonJS({
6882
6882
  throw new Error(`Unknown format "${name}"`);
6883
6883
  return f;
6884
6884
  };
6885
- function addFormats(ajv, list, fs12, exportName) {
6885
+ function addFormats(ajv, list, fs13, exportName) {
6886
6886
  var _a3;
6887
6887
  var _b;
6888
6888
  (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
6889
6889
  for (const f of list)
6890
- ajv.addFormat(f, fs12[f]);
6890
+ ajv.addFormat(f, fs13[f]);
6891
6891
  }
6892
6892
  module.exports = exports = formatsPlugin;
6893
6893
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -6972,17 +6972,17 @@ var require_visit = __commonJS({
6972
6972
  visit.BREAK = BREAK;
6973
6973
  visit.SKIP = SKIP;
6974
6974
  visit.REMOVE = REMOVE;
6975
- function visit_(key, node2, visitor, path17) {
6976
- const ctrl = callVisitor(key, node2, visitor, path17);
6975
+ function visit_(key, node2, visitor, path18) {
6976
+ const ctrl = callVisitor(key, node2, visitor, path18);
6977
6977
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
6978
- replaceNode(key, path17, ctrl);
6979
- return visit_(key, ctrl, visitor, path17);
6978
+ replaceNode(key, path18, ctrl);
6979
+ return visit_(key, ctrl, visitor, path18);
6980
6980
  }
6981
6981
  if (typeof ctrl !== "symbol") {
6982
6982
  if (identity.isCollection(node2)) {
6983
- path17 = Object.freeze(path17.concat(node2));
6983
+ path18 = Object.freeze(path18.concat(node2));
6984
6984
  for (let i = 0; i < node2.items.length; ++i) {
6985
- const ci = visit_(i, node2.items[i], visitor, path17);
6985
+ const ci = visit_(i, node2.items[i], visitor, path18);
6986
6986
  if (typeof ci === "number")
6987
6987
  i = ci - 1;
6988
6988
  else if (ci === BREAK)
@@ -6993,13 +6993,13 @@ var require_visit = __commonJS({
6993
6993
  }
6994
6994
  }
6995
6995
  } else if (identity.isPair(node2)) {
6996
- path17 = Object.freeze(path17.concat(node2));
6997
- const ck = visit_("key", node2.key, visitor, path17);
6996
+ path18 = Object.freeze(path18.concat(node2));
6997
+ const ck = visit_("key", node2.key, visitor, path18);
6998
6998
  if (ck === BREAK)
6999
6999
  return BREAK;
7000
7000
  else if (ck === REMOVE)
7001
7001
  node2.key = null;
7002
- const cv = visit_("value", node2.value, visitor, path17);
7002
+ const cv = visit_("value", node2.value, visitor, path18);
7003
7003
  if (cv === BREAK)
7004
7004
  return BREAK;
7005
7005
  else if (cv === REMOVE)
@@ -7020,17 +7020,17 @@ var require_visit = __commonJS({
7020
7020
  visitAsync.BREAK = BREAK;
7021
7021
  visitAsync.SKIP = SKIP;
7022
7022
  visitAsync.REMOVE = REMOVE;
7023
- async function visitAsync_(key, node2, visitor, path17) {
7024
- const ctrl = await callVisitor(key, node2, visitor, path17);
7023
+ async function visitAsync_(key, node2, visitor, path18) {
7024
+ const ctrl = await callVisitor(key, node2, visitor, path18);
7025
7025
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
7026
- replaceNode(key, path17, ctrl);
7027
- return visitAsync_(key, ctrl, visitor, path17);
7026
+ replaceNode(key, path18, ctrl);
7027
+ return visitAsync_(key, ctrl, visitor, path18);
7028
7028
  }
7029
7029
  if (typeof ctrl !== "symbol") {
7030
7030
  if (identity.isCollection(node2)) {
7031
- path17 = Object.freeze(path17.concat(node2));
7031
+ path18 = Object.freeze(path18.concat(node2));
7032
7032
  for (let i = 0; i < node2.items.length; ++i) {
7033
- const ci = await visitAsync_(i, node2.items[i], visitor, path17);
7033
+ const ci = await visitAsync_(i, node2.items[i], visitor, path18);
7034
7034
  if (typeof ci === "number")
7035
7035
  i = ci - 1;
7036
7036
  else if (ci === BREAK)
@@ -7041,13 +7041,13 @@ var require_visit = __commonJS({
7041
7041
  }
7042
7042
  }
7043
7043
  } else if (identity.isPair(node2)) {
7044
- path17 = Object.freeze(path17.concat(node2));
7045
- const ck = await visitAsync_("key", node2.key, visitor, path17);
7044
+ path18 = Object.freeze(path18.concat(node2));
7045
+ const ck = await visitAsync_("key", node2.key, visitor, path18);
7046
7046
  if (ck === BREAK)
7047
7047
  return BREAK;
7048
7048
  else if (ck === REMOVE)
7049
7049
  node2.key = null;
7050
- const cv = await visitAsync_("value", node2.value, visitor, path17);
7050
+ const cv = await visitAsync_("value", node2.value, visitor, path18);
7051
7051
  if (cv === BREAK)
7052
7052
  return BREAK;
7053
7053
  else if (cv === REMOVE)
@@ -7074,23 +7074,23 @@ var require_visit = __commonJS({
7074
7074
  }
7075
7075
  return visitor;
7076
7076
  }
7077
- function callVisitor(key, node2, visitor, path17) {
7077
+ function callVisitor(key, node2, visitor, path18) {
7078
7078
  if (typeof visitor === "function")
7079
- return visitor(key, node2, path17);
7079
+ return visitor(key, node2, path18);
7080
7080
  if (identity.isMap(node2))
7081
- return visitor.Map?.(key, node2, path17);
7081
+ return visitor.Map?.(key, node2, path18);
7082
7082
  if (identity.isSeq(node2))
7083
- return visitor.Seq?.(key, node2, path17);
7083
+ return visitor.Seq?.(key, node2, path18);
7084
7084
  if (identity.isPair(node2))
7085
- return visitor.Pair?.(key, node2, path17);
7085
+ return visitor.Pair?.(key, node2, path18);
7086
7086
  if (identity.isScalar(node2))
7087
- return visitor.Scalar?.(key, node2, path17);
7087
+ return visitor.Scalar?.(key, node2, path18);
7088
7088
  if (identity.isAlias(node2))
7089
- return visitor.Alias?.(key, node2, path17);
7089
+ return visitor.Alias?.(key, node2, path18);
7090
7090
  return void 0;
7091
7091
  }
7092
- function replaceNode(key, path17, node2) {
7093
- const parent = path17[path17.length - 1];
7092
+ function replaceNode(key, path18, node2) {
7093
+ const parent = path18[path18.length - 1];
7094
7094
  if (identity.isCollection(parent)) {
7095
7095
  parent.items[key] = node2;
7096
7096
  } else if (identity.isPair(parent)) {
@@ -7702,10 +7702,10 @@ var require_Collection = __commonJS({
7702
7702
  var createNode = require_createNode();
7703
7703
  var identity = require_identity();
7704
7704
  var Node = require_Node();
7705
- function collectionFromPath(schema, path17, value) {
7705
+ function collectionFromPath(schema, path18, value) {
7706
7706
  let v = value;
7707
- for (let i = path17.length - 1; i >= 0; --i) {
7708
- const k = path17[i];
7707
+ for (let i = path18.length - 1; i >= 0; --i) {
7708
+ const k = path18[i];
7709
7709
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
7710
7710
  const a = [];
7711
7711
  a[k] = v;
@@ -7724,7 +7724,7 @@ var require_Collection = __commonJS({
7724
7724
  sourceObjects: /* @__PURE__ */ new Map()
7725
7725
  });
7726
7726
  }
7727
- var isEmptyPath = (path17) => path17 == null || typeof path17 === "object" && !!path17[Symbol.iterator]().next().done;
7727
+ var isEmptyPath = (path18) => path18 == null || typeof path18 === "object" && !!path18[Symbol.iterator]().next().done;
7728
7728
  var Collection = class extends Node.NodeBase {
7729
7729
  constructor(type, schema) {
7730
7730
  super(type);
@@ -7754,11 +7754,11 @@ var require_Collection = __commonJS({
7754
7754
  * be a Pair instance or a `{ key, value }` object, which may not have a key
7755
7755
  * that already exists in the map.
7756
7756
  */
7757
- addIn(path17, value) {
7758
- if (isEmptyPath(path17))
7757
+ addIn(path18, value) {
7758
+ if (isEmptyPath(path18))
7759
7759
  this.add(value);
7760
7760
  else {
7761
- const [key, ...rest] = path17;
7761
+ const [key, ...rest] = path18;
7762
7762
  const node2 = this.get(key, true);
7763
7763
  if (identity.isCollection(node2))
7764
7764
  node2.addIn(rest, value);
@@ -7772,8 +7772,8 @@ var require_Collection = __commonJS({
7772
7772
  * Removes a value from the collection.
7773
7773
  * @returns `true` if the item was found and removed.
7774
7774
  */
7775
- deleteIn(path17) {
7776
- const [key, ...rest] = path17;
7775
+ deleteIn(path18) {
7776
+ const [key, ...rest] = path18;
7777
7777
  if (rest.length === 0)
7778
7778
  return this.delete(key);
7779
7779
  const node2 = this.get(key, true);
@@ -7787,8 +7787,8 @@ var require_Collection = __commonJS({
7787
7787
  * scalar values from their surrounding node; to disable set `keepScalar` to
7788
7788
  * `true` (collections are always returned intact).
7789
7789
  */
7790
- getIn(path17, keepScalar) {
7791
- const [key, ...rest] = path17;
7790
+ getIn(path18, keepScalar) {
7791
+ const [key, ...rest] = path18;
7792
7792
  const node2 = this.get(key, true);
7793
7793
  if (rest.length === 0)
7794
7794
  return !keepScalar && identity.isScalar(node2) ? node2.value : node2;
@@ -7806,8 +7806,8 @@ var require_Collection = __commonJS({
7806
7806
  /**
7807
7807
  * Checks if the collection includes a value with the key `key`.
7808
7808
  */
7809
- hasIn(path17) {
7810
- const [key, ...rest] = path17;
7809
+ hasIn(path18) {
7810
+ const [key, ...rest] = path18;
7811
7811
  if (rest.length === 0)
7812
7812
  return this.has(key);
7813
7813
  const node2 = this.get(key, true);
@@ -7817,8 +7817,8 @@ var require_Collection = __commonJS({
7817
7817
  * Sets a value in this collection. For `!!set`, `value` needs to be a
7818
7818
  * boolean to add/remove the item from the set.
7819
7819
  */
7820
- setIn(path17, value) {
7821
- const [key, ...rest] = path17;
7820
+ setIn(path18, value) {
7821
+ const [key, ...rest] = path18;
7822
7822
  if (rest.length === 0) {
7823
7823
  this.set(key, value);
7824
7824
  } else {
@@ -10333,9 +10333,9 @@ var require_Document = __commonJS({
10333
10333
  this.contents.add(value);
10334
10334
  }
10335
10335
  /** Adds a value to the document. */
10336
- addIn(path17, value) {
10336
+ addIn(path18, value) {
10337
10337
  if (assertCollection(this.contents))
10338
- this.contents.addIn(path17, value);
10338
+ this.contents.addIn(path18, value);
10339
10339
  }
10340
10340
  /**
10341
10341
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -10410,14 +10410,14 @@ var require_Document = __commonJS({
10410
10410
  * Removes a value from the document.
10411
10411
  * @returns `true` if the item was found and removed.
10412
10412
  */
10413
- deleteIn(path17) {
10414
- if (Collection.isEmptyPath(path17)) {
10413
+ deleteIn(path18) {
10414
+ if (Collection.isEmptyPath(path18)) {
10415
10415
  if (this.contents == null)
10416
10416
  return false;
10417
10417
  this.contents = null;
10418
10418
  return true;
10419
10419
  }
10420
- return assertCollection(this.contents) ? this.contents.deleteIn(path17) : false;
10420
+ return assertCollection(this.contents) ? this.contents.deleteIn(path18) : false;
10421
10421
  }
10422
10422
  /**
10423
10423
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -10432,10 +10432,10 @@ var require_Document = __commonJS({
10432
10432
  * scalar values from their surrounding node; to disable set `keepScalar` to
10433
10433
  * `true` (collections are always returned intact).
10434
10434
  */
10435
- getIn(path17, keepScalar) {
10436
- if (Collection.isEmptyPath(path17))
10435
+ getIn(path18, keepScalar) {
10436
+ if (Collection.isEmptyPath(path18))
10437
10437
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
10438
- return identity.isCollection(this.contents) ? this.contents.getIn(path17, keepScalar) : void 0;
10438
+ return identity.isCollection(this.contents) ? this.contents.getIn(path18, keepScalar) : void 0;
10439
10439
  }
10440
10440
  /**
10441
10441
  * Checks if the document includes a value with the key `key`.
@@ -10446,10 +10446,10 @@ var require_Document = __commonJS({
10446
10446
  /**
10447
10447
  * Checks if the document includes a value at `path`.
10448
10448
  */
10449
- hasIn(path17) {
10450
- if (Collection.isEmptyPath(path17))
10449
+ hasIn(path18) {
10450
+ if (Collection.isEmptyPath(path18))
10451
10451
  return this.contents !== void 0;
10452
- return identity.isCollection(this.contents) ? this.contents.hasIn(path17) : false;
10452
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path18) : false;
10453
10453
  }
10454
10454
  /**
10455
10455
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -10466,13 +10466,13 @@ var require_Document = __commonJS({
10466
10466
  * Sets a value in this document. For `!!set`, `value` needs to be a
10467
10467
  * boolean to add/remove the item from the set.
10468
10468
  */
10469
- setIn(path17, value) {
10470
- if (Collection.isEmptyPath(path17)) {
10469
+ setIn(path18, value) {
10470
+ if (Collection.isEmptyPath(path18)) {
10471
10471
  this.contents = value;
10472
10472
  } else if (this.contents == null) {
10473
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path17), value);
10473
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path18), value);
10474
10474
  } else if (assertCollection(this.contents)) {
10475
- this.contents.setIn(path17, value);
10475
+ this.contents.setIn(path18, value);
10476
10476
  }
10477
10477
  }
10478
10478
  /**
@@ -10858,10 +10858,10 @@ var require_resolve_block_map = __commonJS({
10858
10858
  let offset = bm.offset;
10859
10859
  let commentEnd = null;
10860
10860
  for (const collItem of bm.items) {
10861
- const { start, key, sep: sep5, value } = collItem;
10861
+ const { start, key, sep: sep6, value } = collItem;
10862
10862
  const keyProps = resolveProps.resolveProps(start, {
10863
10863
  indicator: "explicit-key-ind",
10864
- next: key ?? sep5?.[0],
10864
+ next: key ?? sep6?.[0],
10865
10865
  offset,
10866
10866
  onError,
10867
10867
  parentIndent: bm.indent,
@@ -10875,7 +10875,7 @@ var require_resolve_block_map = __commonJS({
10875
10875
  else if ("indent" in key && key.indent !== bm.indent)
10876
10876
  onError(offset, "BAD_INDENT", startColMsg);
10877
10877
  }
10878
- if (!keyProps.anchor && !keyProps.tag && !sep5) {
10878
+ if (!keyProps.anchor && !keyProps.tag && !sep6) {
10879
10879
  commentEnd = keyProps.end;
10880
10880
  if (keyProps.comment) {
10881
10881
  if (map.comment)
@@ -10899,7 +10899,7 @@ var require_resolve_block_map = __commonJS({
10899
10899
  ctx.atKey = false;
10900
10900
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
10901
10901
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
10902
- const valueProps = resolveProps.resolveProps(sep5 ?? [], {
10902
+ const valueProps = resolveProps.resolveProps(sep6 ?? [], {
10903
10903
  indicator: "map-value-ind",
10904
10904
  next: value,
10905
10905
  offset: keyNode.range[2],
@@ -10915,7 +10915,7 @@ var require_resolve_block_map = __commonJS({
10915
10915
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
10916
10916
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
10917
10917
  }
10918
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep5, null, valueProps, onError);
10918
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep6, null, valueProps, onError);
10919
10919
  if (ctx.schema.compat)
10920
10920
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
10921
10921
  offset = valueNode.range[2];
@@ -11006,7 +11006,7 @@ var require_resolve_end = __commonJS({
11006
11006
  let comment = "";
11007
11007
  if (end) {
11008
11008
  let hasSpace = false;
11009
- let sep5 = "";
11009
+ let sep6 = "";
11010
11010
  for (const token of end) {
11011
11011
  const { source, type } = token;
11012
11012
  switch (type) {
@@ -11020,13 +11020,13 @@ var require_resolve_end = __commonJS({
11020
11020
  if (!comment)
11021
11021
  comment = cb;
11022
11022
  else
11023
- comment += sep5 + cb;
11024
- sep5 = "";
11023
+ comment += sep6 + cb;
11024
+ sep6 = "";
11025
11025
  break;
11026
11026
  }
11027
11027
  case "newline":
11028
11028
  if (comment)
11029
- sep5 += source;
11029
+ sep6 += source;
11030
11030
  hasSpace = true;
11031
11031
  break;
11032
11032
  default:
@@ -11069,18 +11069,18 @@ var require_resolve_flow_collection = __commonJS({
11069
11069
  let offset = fc.offset + fc.start.source.length;
11070
11070
  for (let i = 0; i < fc.items.length; ++i) {
11071
11071
  const collItem = fc.items[i];
11072
- const { start, key, sep: sep5, value } = collItem;
11072
+ const { start, key, sep: sep6, value } = collItem;
11073
11073
  const props = resolveProps.resolveProps(start, {
11074
11074
  flow: fcName,
11075
11075
  indicator: "explicit-key-ind",
11076
- next: key ?? sep5?.[0],
11076
+ next: key ?? sep6?.[0],
11077
11077
  offset,
11078
11078
  onError,
11079
11079
  parentIndent: fc.indent,
11080
11080
  startOnNewline: false
11081
11081
  });
11082
11082
  if (!props.found) {
11083
- if (!props.anchor && !props.tag && !sep5 && !value) {
11083
+ if (!props.anchor && !props.tag && !sep6 && !value) {
11084
11084
  if (i === 0 && props.comma)
11085
11085
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
11086
11086
  else if (i < fc.items.length - 1)
@@ -11134,8 +11134,8 @@ var require_resolve_flow_collection = __commonJS({
11134
11134
  }
11135
11135
  }
11136
11136
  }
11137
- if (!isMap && !sep5 && !props.found) {
11138
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep5, null, props, onError);
11137
+ if (!isMap && !sep6 && !props.found) {
11138
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep6, null, props, onError);
11139
11139
  coll.items.push(valueNode);
11140
11140
  offset = valueNode.range[2];
11141
11141
  if (isBlock(value))
@@ -11147,7 +11147,7 @@ var require_resolve_flow_collection = __commonJS({
11147
11147
  if (isBlock(key))
11148
11148
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
11149
11149
  ctx.atKey = false;
11150
- const valueProps = resolveProps.resolveProps(sep5 ?? [], {
11150
+ const valueProps = resolveProps.resolveProps(sep6 ?? [], {
11151
11151
  flow: fcName,
11152
11152
  indicator: "map-value-ind",
11153
11153
  next: value,
@@ -11158,8 +11158,8 @@ var require_resolve_flow_collection = __commonJS({
11158
11158
  });
11159
11159
  if (valueProps.found) {
11160
11160
  if (!isMap && !props.found && ctx.options.strict) {
11161
- if (sep5)
11162
- for (const st of sep5) {
11161
+ if (sep6)
11162
+ for (const st of sep6) {
11163
11163
  if (st === valueProps.found)
11164
11164
  break;
11165
11165
  if (st.type === "newline") {
@@ -11176,7 +11176,7 @@ var require_resolve_flow_collection = __commonJS({
11176
11176
  else
11177
11177
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
11178
11178
  }
11179
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep5, null, valueProps, onError) : null;
11179
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep6, null, valueProps, onError) : null;
11180
11180
  if (valueNode) {
11181
11181
  if (isBlock(value))
11182
11182
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -11356,7 +11356,7 @@ var require_resolve_block_scalar = __commonJS({
11356
11356
  chompStart = i + 1;
11357
11357
  }
11358
11358
  let value = "";
11359
- let sep5 = "";
11359
+ let sep6 = "";
11360
11360
  let prevMoreIndented = false;
11361
11361
  for (let i = 0; i < contentStart; ++i)
11362
11362
  value += lines[i][0].slice(trimIndent) + "\n";
@@ -11373,24 +11373,24 @@ var require_resolve_block_scalar = __commonJS({
11373
11373
  indent = "";
11374
11374
  }
11375
11375
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
11376
- value += sep5 + indent.slice(trimIndent) + content;
11377
- sep5 = "\n";
11376
+ value += sep6 + indent.slice(trimIndent) + content;
11377
+ sep6 = "\n";
11378
11378
  } else if (indent.length > trimIndent || content[0] === " ") {
11379
- if (sep5 === " ")
11380
- sep5 = "\n";
11381
- else if (!prevMoreIndented && sep5 === "\n")
11382
- sep5 = "\n\n";
11383
- value += sep5 + indent.slice(trimIndent) + content;
11384
- sep5 = "\n";
11379
+ if (sep6 === " ")
11380
+ sep6 = "\n";
11381
+ else if (!prevMoreIndented && sep6 === "\n")
11382
+ sep6 = "\n\n";
11383
+ value += sep6 + indent.slice(trimIndent) + content;
11384
+ sep6 = "\n";
11385
11385
  prevMoreIndented = true;
11386
11386
  } else if (content === "") {
11387
- if (sep5 === "\n")
11387
+ if (sep6 === "\n")
11388
11388
  value += "\n";
11389
11389
  else
11390
- sep5 = "\n";
11390
+ sep6 = "\n";
11391
11391
  } else {
11392
- value += sep5 + content;
11393
- sep5 = " ";
11392
+ value += sep6 + content;
11393
+ sep6 = " ";
11394
11394
  prevMoreIndented = false;
11395
11395
  }
11396
11396
  }
@@ -11573,25 +11573,25 @@ var require_resolve_flow_scalar = __commonJS({
11573
11573
  trimBoth = /^[ \t]+|[ \t]+$/g;
11574
11574
  }
11575
11575
  let res = match[1].replace(trimEnd, "");
11576
- let sep5 = " ";
11576
+ let sep6 = " ";
11577
11577
  let pos = line.lastIndex;
11578
11578
  while (match = line.exec(source)) {
11579
11579
  const lm = match[1].replace(trimBoth, "");
11580
11580
  if (lm === "") {
11581
- if (sep5 === "\n")
11582
- res += sep5;
11581
+ if (sep6 === "\n")
11582
+ res += sep6;
11583
11583
  else
11584
- sep5 = "\n";
11584
+ sep6 = "\n";
11585
11585
  } else {
11586
- res += sep5 + lm;
11587
- sep5 = " ";
11586
+ res += sep6 + lm;
11587
+ sep6 = " ";
11588
11588
  }
11589
11589
  pos = line.lastIndex;
11590
11590
  }
11591
11591
  const last = /[ \t]*(.*)/sy;
11592
11592
  last.lastIndex = pos;
11593
11593
  match = last.exec(source);
11594
- return res + sep5 + (match?.[1] ?? "");
11594
+ return res + sep6 + (match?.[1] ?? "");
11595
11595
  }
11596
11596
  function doubleQuotedValue(source, onError) {
11597
11597
  let res = "";
@@ -12401,14 +12401,14 @@ var require_cst_stringify = __commonJS({
12401
12401
  }
12402
12402
  }
12403
12403
  }
12404
- function stringifyItem({ start, key, sep: sep5, value }) {
12404
+ function stringifyItem({ start, key, sep: sep6, value }) {
12405
12405
  let res = "";
12406
12406
  for (const st of start)
12407
12407
  res += st.source;
12408
12408
  if (key)
12409
12409
  res += stringifyToken(key);
12410
- if (sep5)
12411
- for (const st of sep5)
12410
+ if (sep6)
12411
+ for (const st of sep6)
12412
12412
  res += st.source;
12413
12413
  if (value)
12414
12414
  res += stringifyToken(value);
@@ -12433,9 +12433,9 @@ var require_cst_visit = __commonJS({
12433
12433
  visit.BREAK = BREAK;
12434
12434
  visit.SKIP = SKIP;
12435
12435
  visit.REMOVE = REMOVE;
12436
- visit.itemAtPath = (cst, path17) => {
12436
+ visit.itemAtPath = (cst, path18) => {
12437
12437
  let item = cst;
12438
- for (const [field, index] of path17) {
12438
+ for (const [field, index] of path18) {
12439
12439
  const tok = item?.[field];
12440
12440
  if (tok && "items" in tok) {
12441
12441
  item = tok.items[index];
@@ -12444,23 +12444,23 @@ var require_cst_visit = __commonJS({
12444
12444
  }
12445
12445
  return item;
12446
12446
  };
12447
- visit.parentCollection = (cst, path17) => {
12448
- const parent = visit.itemAtPath(cst, path17.slice(0, -1));
12449
- const field = path17[path17.length - 1][0];
12447
+ visit.parentCollection = (cst, path18) => {
12448
+ const parent = visit.itemAtPath(cst, path18.slice(0, -1));
12449
+ const field = path18[path18.length - 1][0];
12450
12450
  const coll = parent?.[field];
12451
12451
  if (coll && "items" in coll)
12452
12452
  return coll;
12453
12453
  throw new Error("Parent collection not found");
12454
12454
  };
12455
- function _visit(path17, item, visitor) {
12456
- let ctrl = visitor(item, path17);
12455
+ function _visit(path18, item, visitor) {
12456
+ let ctrl = visitor(item, path18);
12457
12457
  if (typeof ctrl === "symbol")
12458
12458
  return ctrl;
12459
12459
  for (const field of ["key", "value"]) {
12460
12460
  const token = item[field];
12461
12461
  if (token && "items" in token) {
12462
12462
  for (let i = 0; i < token.items.length; ++i) {
12463
- const ci = _visit(Object.freeze(path17.concat([[field, i]])), token.items[i], visitor);
12463
+ const ci = _visit(Object.freeze(path18.concat([[field, i]])), token.items[i], visitor);
12464
12464
  if (typeof ci === "number")
12465
12465
  i = ci - 1;
12466
12466
  else if (ci === BREAK)
@@ -12471,10 +12471,10 @@ var require_cst_visit = __commonJS({
12471
12471
  }
12472
12472
  }
12473
12473
  if (typeof ctrl === "function" && field === "key")
12474
- ctrl = ctrl(item, path17);
12474
+ ctrl = ctrl(item, path18);
12475
12475
  }
12476
12476
  }
12477
- return typeof ctrl === "function" ? ctrl(item, path17) : ctrl;
12477
+ return typeof ctrl === "function" ? ctrl(item, path18) : ctrl;
12478
12478
  }
12479
12479
  exports.visit = visit;
12480
12480
  }
@@ -13575,18 +13575,18 @@ var require_parser = __commonJS({
13575
13575
  if (this.type === "map-value-ind") {
13576
13576
  const prev = getPrevProps(this.peek(2));
13577
13577
  const start = getFirstKeyStartProps(prev);
13578
- let sep5;
13578
+ let sep6;
13579
13579
  if (scalar.end) {
13580
- sep5 = scalar.end;
13581
- sep5.push(this.sourceToken);
13580
+ sep6 = scalar.end;
13581
+ sep6.push(this.sourceToken);
13582
13582
  delete scalar.end;
13583
13583
  } else
13584
- sep5 = [this.sourceToken];
13584
+ sep6 = [this.sourceToken];
13585
13585
  const map = {
13586
13586
  type: "block-map",
13587
13587
  offset: scalar.offset,
13588
13588
  indent: scalar.indent,
13589
- items: [{ start, key: scalar, sep: sep5 }]
13589
+ items: [{ start, key: scalar, sep: sep6 }]
13590
13590
  };
13591
13591
  this.onKeyLine = true;
13592
13592
  this.stack[this.stack.length - 1] = map;
@@ -13739,15 +13739,15 @@ var require_parser = __commonJS({
13739
13739
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
13740
13740
  const start2 = getFirstKeyStartProps(it.start);
13741
13741
  const key = it.key;
13742
- const sep5 = it.sep;
13743
- sep5.push(this.sourceToken);
13742
+ const sep6 = it.sep;
13743
+ sep6.push(this.sourceToken);
13744
13744
  delete it.key;
13745
13745
  delete it.sep;
13746
13746
  this.stack.push({
13747
13747
  type: "block-map",
13748
13748
  offset: this.offset,
13749
13749
  indent: this.indent,
13750
- items: [{ start: start2, key, sep: sep5 }]
13750
+ items: [{ start: start2, key, sep: sep6 }]
13751
13751
  });
13752
13752
  } else if (start.length > 0) {
13753
13753
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -13776,14 +13776,14 @@ var require_parser = __commonJS({
13776
13776
  case "scalar":
13777
13777
  case "single-quoted-scalar":
13778
13778
  case "double-quoted-scalar": {
13779
- const fs12 = this.flowScalar(this.type);
13779
+ const fs13 = this.flowScalar(this.type);
13780
13780
  if (atNextItem || it.value) {
13781
- map.items.push({ start, key: fs12, sep: [] });
13781
+ map.items.push({ start, key: fs13, sep: [] });
13782
13782
  this.onKeyLine = true;
13783
13783
  } else if (it.sep) {
13784
- this.stack.push(fs12);
13784
+ this.stack.push(fs13);
13785
13785
  } else {
13786
- Object.assign(it, { key: fs12, sep: [] });
13786
+ Object.assign(it, { key: fs13, sep: [] });
13787
13787
  this.onKeyLine = true;
13788
13788
  }
13789
13789
  return;
@@ -13911,13 +13911,13 @@ var require_parser = __commonJS({
13911
13911
  case "scalar":
13912
13912
  case "single-quoted-scalar":
13913
13913
  case "double-quoted-scalar": {
13914
- const fs12 = this.flowScalar(this.type);
13914
+ const fs13 = this.flowScalar(this.type);
13915
13915
  if (!it || it.value)
13916
- fc.items.push({ start: [], key: fs12, sep: [] });
13916
+ fc.items.push({ start: [], key: fs13, sep: [] });
13917
13917
  else if (it.sep)
13918
- this.stack.push(fs12);
13918
+ this.stack.push(fs13);
13919
13919
  else
13920
- Object.assign(it, { key: fs12, sep: [] });
13920
+ Object.assign(it, { key: fs13, sep: [] });
13921
13921
  return;
13922
13922
  }
13923
13923
  case "flow-map-end":
@@ -13941,13 +13941,13 @@ var require_parser = __commonJS({
13941
13941
  const prev = getPrevProps(parent);
13942
13942
  const start = getFirstKeyStartProps(prev);
13943
13943
  fixFlowSeqItems(fc);
13944
- const sep5 = fc.end.splice(1, fc.end.length);
13945
- sep5.push(this.sourceToken);
13944
+ const sep6 = fc.end.splice(1, fc.end.length);
13945
+ sep6.push(this.sourceToken);
13946
13946
  const map = {
13947
13947
  type: "block-map",
13948
13948
  offset: fc.offset,
13949
13949
  indent: fc.indent,
13950
- items: [{ start, key: fc, sep: sep5 }]
13950
+ items: [{ start, key: fc, sep: sep6 }]
13951
13951
  };
13952
13952
  this.onKeyLine = true;
13953
13953
  this.stack[this.stack.length - 1] = map;
@@ -14125,7 +14125,7 @@ var require_public_api = __commonJS({
14125
14125
  }
14126
14126
  return doc;
14127
14127
  }
14128
- function parse3(src, reviver, options) {
14128
+ function parse4(src, reviver, options) {
14129
14129
  let _reviver = void 0;
14130
14130
  if (typeof reviver === "function") {
14131
14131
  _reviver = reviver;
@@ -14166,7 +14166,7 @@ var require_public_api = __commonJS({
14166
14166
  return value.toString(options);
14167
14167
  return new Document.Document(value, _replacer, options).toString(options);
14168
14168
  }
14169
- exports.parse = parse3;
14169
+ exports.parse = parse4;
14170
14170
  exports.parseAllDocuments = parseAllDocuments;
14171
14171
  exports.parseDocument = parseDocument;
14172
14172
  exports.stringify = stringify;
@@ -14619,8 +14619,9 @@ var require_dist3 = __commonJS({
14619
14619
 
14620
14620
  // ../argent-mcp/src/mcp-server.ts
14621
14621
  import { appendFile, mkdir as mkdir5 } from "node:fs/promises";
14622
- import { dirname as dirname10 } from "node:path";
14622
+ import { dirname as dirname11 } from "node:path";
14623
14623
  import { homedir as homedir5 } from "node:os";
14624
+ import { setTimeout as sleep } from "node:timers/promises";
14624
14625
 
14625
14626
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
14626
14627
  import process2 from "node:process";
@@ -14862,10 +14863,10 @@ function mergeDefs(...defs) {
14862
14863
  function cloneDef(schema) {
14863
14864
  return mergeDefs(schema._zod.def);
14864
14865
  }
14865
- function getElementAtPath(obj, path17) {
14866
- if (!path17)
14866
+ function getElementAtPath(obj, path18) {
14867
+ if (!path18)
14867
14868
  return obj;
14868
- return path17.reduce((acc, key) => acc?.[key], obj);
14869
+ return path18.reduce((acc, key) => acc?.[key], obj);
14869
14870
  }
14870
14871
  function promiseAllObject(promisesObj) {
14871
14872
  const keys = Object.keys(promisesObj);
@@ -15205,11 +15206,11 @@ function explicitlyAborted(x, startIndex = 0) {
15205
15206
  }
15206
15207
  return false;
15207
15208
  }
15208
- function prefixIssues(path17, issues) {
15209
+ function prefixIssues(path18, issues) {
15209
15210
  return issues.map((iss) => {
15210
15211
  var _a3;
15211
15212
  (_a3 = iss).path ?? (_a3.path = []);
15212
- iss.path.unshift(path17);
15213
+ iss.path.unshift(path18);
15213
15214
  return iss;
15214
15215
  });
15215
15216
  }
@@ -15667,16 +15668,16 @@ function flattenError(error2, mapper = (issue2) => issue2.message) {
15667
15668
  }
15668
15669
  function formatError(error2, mapper = (issue2) => issue2.message) {
15669
15670
  const fieldErrors = { _errors: [] };
15670
- const processError = (error3, path17 = []) => {
15671
+ const processError = (error3, path18 = []) => {
15671
15672
  for (const issue2 of error3.issues) {
15672
15673
  if (issue2.code === "invalid_union" && issue2.errors.length) {
15673
- issue2.errors.map((issues) => processError({ issues }, [...path17, ...issue2.path]));
15674
+ issue2.errors.map((issues) => processError({ issues }, [...path18, ...issue2.path]));
15674
15675
  } else if (issue2.code === "invalid_key") {
15675
- processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
15676
+ processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
15676
15677
  } else if (issue2.code === "invalid_element") {
15677
- processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
15678
+ processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
15678
15679
  } else {
15679
- const fullpath = [...path17, ...issue2.path];
15680
+ const fullpath = [...path18, ...issue2.path];
15680
15681
  if (fullpath.length === 0) {
15681
15682
  fieldErrors._errors.push(mapper(issue2));
15682
15683
  } else {
@@ -15819,17 +15820,17 @@ var validateAsync = async (schema, value, _ctx) => {
15819
15820
  return result.issues.length === 0;
15820
15821
  };
15821
15822
  var _encode = (_Err) => {
15822
- const parse3 = _parse(_Err);
15823
+ const parse4 = _parse(_Err);
15823
15824
  const fn = (schema, value, _ctx, _params) => {
15824
15825
  const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
15825
- return parse3(schema, value, ctx, finalizeParams(fn, _params));
15826
+ return parse4(schema, value, ctx, finalizeParams(fn, _params));
15826
15827
  };
15827
15828
  return fn;
15828
15829
  };
15829
15830
  var _decode = (_Err) => {
15830
- const parse3 = _parse(_Err);
15831
+ const parse4 = _parse(_Err);
15831
15832
  const fn = (schema, value, _ctx, _params) => {
15832
- return parse3(schema, value, _ctx, finalizeParams(fn, _params));
15833
+ return parse4(schema, value, _ctx, finalizeParams(fn, _params));
15833
15834
  };
15834
15835
  return fn;
15835
15836
  };
@@ -16866,7 +16867,7 @@ function capSize(inst, size) {
16866
16867
  if (!caps.length)
16867
16868
  return;
16868
16869
  const cap = Math.min(...caps.map((c) => c[0]));
16869
- const parse3 = inst._zod.parse;
16870
+ const parse4 = inst._zod.parse;
16870
16871
  inst._zod.parse = (payload, ctx) => {
16871
16872
  const n = size(payload.value);
16872
16873
  if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
@@ -16880,7 +16881,7 @@ function capSize(inst, size) {
16880
16881
  }
16881
16882
  }
16882
16883
  }
16883
- return parse3(payload, ctx);
16884
+ return parse4(payload, ctx);
16884
16885
  };
16885
16886
  }
16886
16887
  var arraySize = (input) => Array.isArray(input) ? input.length : -1;
@@ -17976,7 +17977,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
17976
17977
  var NONE = 0;
17977
17978
  var ASSUMED = 1;
17978
17979
  var PROVEN = 2;
17979
- function isRecursive(inst, stack, resolve10) {
17980
+ function isRecursive(inst, stack, resolve12) {
17980
17981
  const cached2 = recursive.get(inst);
17981
17982
  if (cached2 !== void 0)
17982
17983
  return cached2 ? PROVEN : NONE;
@@ -17986,7 +17987,7 @@ function isRecursive(inst, stack, resolve10) {
17986
17987
  let result = NONE;
17987
17988
  const check = (child) => {
17988
17989
  if (result !== PROVEN && child?._zod) {
17989
- const answer = isRecursive(child, stack, resolve10);
17990
+ const answer = isRecursive(child, stack, resolve12);
17990
17991
  if (answer > result)
17991
17992
  result = answer;
17992
17993
  }
@@ -17997,7 +17998,7 @@ function isRecursive(inst, stack, resolve10) {
17997
17998
  const desc = Object.getOwnPropertyDescriptor(sh, key);
17998
17999
  if (spread && !desc.enumerable)
17999
18000
  continue;
18000
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve10) : NONE;
18001
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve12) : NONE;
18001
18002
  if (child > answer)
18002
18003
  answer = child;
18003
18004
  }
@@ -18061,7 +18062,7 @@ function isRecursive(inst, stack, resolve10) {
18061
18062
  break;
18062
18063
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
18063
18064
  case "lazy": {
18064
- const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
18065
+ const inner = def._cachedInner ?? (resolve12 ? inst._zod.innerType : void 0);
18065
18066
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
18066
18067
  break;
18067
18068
  }
@@ -22639,12 +22640,12 @@ var StdioServerTransport = class {
22639
22640
  this.onclose?.();
22640
22641
  }
22641
22642
  send(message) {
22642
- return new Promise((resolve10) => {
22643
+ return new Promise((resolve12) => {
22643
22644
  const json = serializeMessage(message);
22644
22645
  if (this._stdout.write(json)) {
22645
- resolve10();
22646
+ resolve12();
22646
22647
  } else {
22647
- this._stdout.once("drain", resolve10);
22648
+ this._stdout.once("drain", resolve12);
22648
22649
  }
22649
22650
  });
22650
22651
  }
@@ -23264,7 +23265,7 @@ var Protocol = class {
23264
23265
  return;
23265
23266
  }
23266
23267
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
23267
- await new Promise((resolve10) => setTimeout(resolve10, pollInterval));
23268
+ await new Promise((resolve12) => setTimeout(resolve12, pollInterval));
23268
23269
  options?.signal?.throwIfAborted();
23269
23270
  }
23270
23271
  } catch (error2) {
@@ -23281,7 +23282,7 @@ var Protocol = class {
23281
23282
  */
23282
23283
  request(request, resultSchema, options) {
23283
23284
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
23284
- return new Promise((resolve10, reject) => {
23285
+ return new Promise((resolve12, reject) => {
23285
23286
  const earlyReject = (error2) => {
23286
23287
  reject(error2);
23287
23288
  };
@@ -23359,7 +23360,7 @@ var Protocol = class {
23359
23360
  if (!parseResult.success) {
23360
23361
  reject(parseResult.error);
23361
23362
  } else {
23362
- resolve10(parseResult.data);
23363
+ resolve12(parseResult.data);
23363
23364
  }
23364
23365
  } catch (error2) {
23365
23366
  reject(error2);
@@ -23621,12 +23622,12 @@ var Protocol = class {
23621
23622
  }
23622
23623
  } catch {
23623
23624
  }
23624
- return new Promise((resolve10, reject) => {
23625
+ return new Promise((resolve12, reject) => {
23625
23626
  if (signal.aborted) {
23626
23627
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
23627
23628
  return;
23628
23629
  }
23629
- const timeoutId = setTimeout(resolve10, interval);
23630
+ const timeoutId = setTimeout(resolve12, interval);
23630
23631
  signal.addEventListener("abort", () => {
23631
23632
  clearTimeout(timeoutId);
23632
23633
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -24422,6 +24423,7 @@ var LOCK_FILE = path.join(STATE_DIR, "tool-server.lock");
24422
24423
  var AUTH_TOKEN_BYTES = 32;
24423
24424
  var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
24424
24425
  var AUTOSPAWN_IDLE_TIMEOUT_MINUTES = 30;
24426
+ var AUTOSPAWN_HOST = "127.0.0.1";
24425
24427
  function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
24426
24428
  const env = {
24427
24429
  ...baseEnv,
@@ -24433,7 +24435,7 @@ function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
24433
24435
  if (options.idleTimeoutMinutes !== void 0) {
24434
24436
  env.ARGENT_IDLE_TIMEOUT_MINUTES = String(options.idleTimeoutMinutes);
24435
24437
  }
24436
- if (options.token) env[AUTH_TOKEN_ENV] = options.token;
24438
+ env[AUTH_TOKEN_ENV] = options.token ?? "";
24437
24439
  if (paths.installKind) env.ARGENT_INSTALL_KIND = paths.installKind;
24438
24440
  if (paths.installProjectRoot) env.ARGENT_PROJECT_ROOT = paths.installProjectRoot;
24439
24441
  return env;
@@ -24442,7 +24444,7 @@ function generateToken() {
24442
24444
  return randomBytes(AUTH_TOKEN_BYTES).toString("hex");
24443
24445
  }
24444
24446
  function findFreePort() {
24445
- return new Promise((resolve10, reject) => {
24447
+ return new Promise((resolve12, reject) => {
24446
24448
  const srv = net.createServer();
24447
24449
  srv.listen(0, "127.0.0.1", () => {
24448
24450
  const addr = srv.address();
@@ -24453,21 +24455,21 @@ function findFreePort() {
24453
24455
  const port = addr.port;
24454
24456
  srv.close((err) => {
24455
24457
  if (err) reject(err);
24456
- else resolve10(port);
24458
+ else resolve12(port);
24457
24459
  });
24458
24460
  });
24459
24461
  srv.on("error", reject);
24460
24462
  });
24461
24463
  }
24462
24464
  function isVersionNewer(a, b) {
24463
- const parse3 = (v) => {
24465
+ const parse4 = (v) => {
24464
24466
  const [core = "", ...preParts] = v.split("+")[0].split("-");
24465
24467
  const nums = core.split(".").map((n) => Number.parseInt(n, 10));
24466
24468
  if (nums.length === 0 || nums.some((n) => Number.isNaN(n))) return null;
24467
24469
  return { nums, pre: preParts.length > 0 ? preParts.join("-").split(".") : [] };
24468
24470
  };
24469
- const pa = parse3(a);
24470
- const pb = parse3(b);
24471
+ const pa = parse4(a);
24472
+ const pb = parse4(b);
24471
24473
  if (!pa || !pb) return false;
24472
24474
  for (let i = 0; i < 3; i++) {
24473
24475
  const x = pa.nums[i] ?? 0;
@@ -24550,8 +24552,12 @@ function killSpawnedChild(child, pid) {
24550
24552
  }
24551
24553
  }
24552
24554
  }
24555
+ function resolveToolsServerNode() {
24556
+ const { bun, deno, electron } = process.versions;
24557
+ return !(bun || deno || electron) && fs.existsSync(process.execPath) ? process.execPath : "node";
24558
+ }
24553
24559
  function spawnToolsServer(paths, port, options = {}) {
24554
- return new Promise((resolve10, reject) => {
24560
+ return new Promise((resolve12, reject) => {
24555
24561
  let logFd;
24556
24562
  try {
24557
24563
  fs.mkdirSync(STATE_DIR, { recursive: true });
@@ -24559,8 +24565,7 @@ function spawnToolsServer(paths, port, options = {}) {
24559
24565
  } catch {
24560
24566
  logFd = fs.openSync("/dev/null", "w");
24561
24567
  }
24562
- const { bun, deno, electron } = process.versions;
24563
- const nodeBin = !(bun || deno || electron) && fs.existsSync(process.execPath) ? process.execPath : "node";
24568
+ const nodeBin = resolveToolsServerNode();
24564
24569
  const child = spawn(nodeBin, [paths.bundlePath, "start"], {
24565
24570
  detached: true,
24566
24571
  stdio: ["ignore", "pipe", logFd],
@@ -24598,7 +24603,7 @@ function spawnToolsServer(paths, port, options = {}) {
24598
24603
  rl.close();
24599
24604
  child.stdout?.resume();
24600
24605
  child.stdout?.unref?.();
24601
- settle2(() => resolve10({ port: actualPort, pid }));
24606
+ settle2(() => resolve12({ port: actualPort, pid }));
24602
24607
  }
24603
24608
  });
24604
24609
  child.on("error", (err) => {
@@ -24874,6 +24879,7 @@ async function ensureToolsServer(paths) {
24874
24879
  const port = await findFreePort();
24875
24880
  const { port: actualPort, pid } = await spawnToolsServer(paths, port, {
24876
24881
  token,
24882
+ host: AUTOSPAWN_HOST,
24877
24883
  idleTimeoutMinutes: AUTOSPAWN_IDLE_TIMEOUT_MINUTES
24878
24884
  });
24879
24885
  await writeState({
@@ -24882,11 +24888,11 @@ async function ensureToolsServer(paths) {
24882
24888
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
24883
24889
  bundlePath: paths.bundlePath,
24884
24890
  version: diskVersion,
24885
- host: "127.0.0.1",
24891
+ host: AUTOSPAWN_HOST,
24886
24892
  token,
24887
24893
  managed: "autospawn"
24888
24894
  });
24889
- return { url: formatUrl("127.0.0.1", actualPort), token };
24895
+ return { url: formatUrl(AUTOSPAWN_HOST, actualPort), token };
24890
24896
  } finally {
24891
24897
  lock?.release();
24892
24898
  }
@@ -24939,6 +24945,11 @@ var FLAG_REGISTRY = [
24939
24945
  name: "forward-secrets",
24940
24946
  description: "Over `argent link` or ARGENT_TOOLS_URL, resolve each `{{secret:NAME}}` a call names on this machine and send the value with the call, so a remote tool-server can type a secret it does not hold. The linked tool-server then receives every secret of this machine that a call names, so link only one you trust with all of them. Values go only over https:// with the certificate checked, or to a loopback address. Off by default."
24941
24947
  },
24948
+ {
24949
+ name: "ios-audio-always-inserted",
24950
+ description: "Insert the iOS audio hook (libArgentAudio.dylib) into every app an armed simulator launches, so audio-input works without restart-app. Dormant until the app opens audio. On by default; `argent disable ios-audio-always-inserted` inserts it only on the first audio tool call, for apps launched after that call.",
24951
+ defaultEnabled: true
24952
+ },
24942
24953
  {
24943
24954
  name: "video-watermark",
24944
24955
  description: "Overlay the argent corner watermark on recorded screen videos. On by default; turn it off with `argent disable video-watermark`.",
@@ -24946,7 +24957,7 @@ var FLAG_REGISTRY = [
24946
24957
  },
24947
24958
  {
24948
24959
  name: "macos-apps",
24949
- description: "Drive native Mac apps (AppKit, SwiftUI, react-native-macos) from inside the app. Adds the macos platform to list-devices and boot-device, and the file-panel and menu-bar tools. On by default; turn it off with `argent disable macos-apps`.",
24960
+ description: "Control native Mac apps, including Mac Catalyst. Adds the macos platform to list-devices and boot-device, and the file-panel and menu-bar tools. On by default; turn it off with `argent disable macos-apps`.",
24950
24961
  defaultEnabled: true
24951
24962
  }
24952
24963
  ];
@@ -25016,6 +25027,7 @@ function isFeatureEnabled(name, options = {}, registry2 = FLAG_REGISTRY) {
25016
25027
  }
25017
25028
 
25018
25029
  // ../configuration-core/src/paths.ts
25030
+ import * as fs3 from "node:fs";
25019
25031
  import * as os from "node:os";
25020
25032
  import * as path3 from "node:path";
25021
25033
  function nonEmpty(value) {
@@ -25027,6 +25039,16 @@ function resolveHomeDir(options = {}) {
25027
25039
  if (options.homeDir) return options.homeDir;
25028
25040
  return process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
25029
25041
  }
25042
+ function isHomeDir(dir, options = {}) {
25043
+ return canonicalPath(dir) === canonicalPath(resolveHomeDir(options));
25044
+ }
25045
+ function canonicalPath(p) {
25046
+ try {
25047
+ return fs3.realpathSync.native(p);
25048
+ } catch {
25049
+ return path3.resolve(p);
25050
+ }
25051
+ }
25030
25052
  function argentHomeDir() {
25031
25053
  return path3.join(resolveHomeDir(), ".argent");
25032
25054
  }
@@ -25043,11 +25065,11 @@ function configFilePath(scope = "global", options = {}) {
25043
25065
 
25044
25066
  // ../configuration-core/src/config.ts
25045
25067
  import * as crypto from "node:crypto";
25046
- import * as fs3 from "node:fs";
25068
+ import * as fs4 from "node:fs";
25047
25069
  import * as path4 from "node:path";
25048
25070
  function readConfigObject(scope = "global", options = {}) {
25049
25071
  try {
25050
- const raw2 = fs3.readFileSync(configFilePath(scope, options), "utf8");
25072
+ const raw2 = fs4.readFileSync(configFilePath(scope, options), "utf8");
25051
25073
  const json = JSON.parse(raw2);
25052
25074
  if (json && typeof json === "object" && !Array.isArray(json)) {
25053
25075
  return json;
@@ -25092,9 +25114,9 @@ function acquireConfigLock(finalPath) {
25092
25114
  const deadline = Date.now() + LOCK_MAX_WAIT_MS;
25093
25115
  for (; ; ) {
25094
25116
  try {
25095
- const fd = fs3.openSync(lockPath, "wx", 384);
25117
+ const fd = fs4.openSync(lockPath, "wx", 384);
25096
25118
  try {
25097
- fs3.writeSync(fd, `${process.pid}
25119
+ fs4.writeSync(fd, `${process.pid}
25098
25120
  `);
25099
25121
  } catch {
25100
25122
  }
@@ -25102,8 +25124,8 @@ function acquireConfigLock(finalPath) {
25102
25124
  } catch (err) {
25103
25125
  if (err.code !== "EEXIST") return null;
25104
25126
  try {
25105
- if (Date.now() - fs3.statSync(lockPath).mtimeMs > LOCK_STALE_MS2) {
25106
- fs3.unlinkSync(lockPath);
25127
+ if (Date.now() - fs4.statSync(lockPath).mtimeMs > LOCK_STALE_MS2) {
25128
+ fs4.unlinkSync(lockPath);
25107
25129
  continue;
25108
25130
  }
25109
25131
  } catch {
@@ -25115,35 +25137,35 @@ function acquireConfigLock(finalPath) {
25115
25137
  }
25116
25138
  function releaseConfigLock(lock) {
25117
25139
  try {
25118
- fs3.closeSync(lock.fd);
25140
+ fs4.closeSync(lock.fd);
25119
25141
  } catch {
25120
25142
  }
25121
25143
  try {
25122
- fs3.unlinkSync(lock.lockPath);
25144
+ fs4.unlinkSync(lock.lockPath);
25123
25145
  } catch {
25124
25146
  }
25125
25147
  }
25126
25148
  function updateConfig(mutate, scope = "global", options = {}) {
25127
25149
  const dir = configDir(scope, options);
25128
- fs3.mkdirSync(dir, { recursive: true });
25150
+ fs4.mkdirSync(dir, { recursive: true });
25129
25151
  const finalPath = configFilePath(scope, options);
25130
25152
  const lock = acquireConfigLock(finalPath);
25131
25153
  try {
25132
25154
  const next = readConfigObject(scope, options);
25133
25155
  mutate(next);
25134
25156
  const tmpPath = path4.join(dir, `.config.tmp.${process.pid}.${crypto.randomUUID()}`);
25135
- const fd = fs3.openSync(tmpPath, "wx", 384);
25157
+ const fd = fs4.openSync(tmpPath, "wx", 384);
25136
25158
  try {
25137
- fs3.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
25138
- fs3.fsyncSync(fd);
25159
+ fs4.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
25160
+ fs4.fsyncSync(fd);
25139
25161
  } finally {
25140
- fs3.closeSync(fd);
25162
+ fs4.closeSync(fd);
25141
25163
  }
25142
25164
  try {
25143
- fs3.renameSync(tmpPath, finalPath);
25165
+ fs4.renameSync(tmpPath, finalPath);
25144
25166
  } catch (err) {
25145
25167
  try {
25146
- fs3.unlinkSync(tmpPath);
25168
+ fs4.unlinkSync(tmpPath);
25147
25169
  } catch {
25148
25170
  }
25149
25171
  throw err;
@@ -25155,7 +25177,7 @@ function updateConfig(mutate, scope = "global", options = {}) {
25155
25177
 
25156
25178
  // ../configuration-core/src/secrets.ts
25157
25179
  var import_dotenv = __toESM(require_dist3(), 1);
25158
- import * as fs4 from "node:fs";
25180
+ import * as fs5 from "node:fs";
25159
25181
  import * as path5 from "node:path";
25160
25182
  var SECRET_ENV_PREFIX = "ARGENT_SECRET_";
25161
25183
  var SECRETS_FILE_NAME = "secrets.env";
@@ -25185,10 +25207,10 @@ function fileSource(filePath, exposure) {
25185
25207
  names: [],
25186
25208
  values: /* @__PURE__ */ new Map()
25187
25209
  };
25188
- if (!fs4.statSync(filePath, { throwIfNoEntry: false })) return absent;
25210
+ if (!fs5.statSync(filePath, { throwIfNoEntry: false })) return absent;
25189
25211
  let content;
25190
25212
  try {
25191
- content = fs4.readFileSync(filePath, "utf8");
25213
+ content = fs5.readFileSync(filePath, "utf8");
25192
25214
  } catch {
25193
25215
  return absent;
25194
25216
  }
@@ -25214,7 +25236,9 @@ function fileSource(filePath, exposure) {
25214
25236
  }
25215
25237
  function secretSources(options = {}) {
25216
25238
  const sources = [envSource(options.env ?? process.env)];
25217
- const projectRoot = findProjectRoot(options.cwd ?? process.cwd());
25239
+ const home = resolveHomeDir(options);
25240
+ const found = findProjectRoot(options.cwd ?? process.cwd());
25241
+ const projectRoot = found && isHomeDir(found, options) ? home : found;
25218
25242
  const filePaths = [];
25219
25243
  if (projectRoot) {
25220
25244
  filePaths.push({
@@ -25226,7 +25250,7 @@ function secretSources(options = {}) {
25226
25250
  }
25227
25251
  }
25228
25252
  filePaths.push({
25229
- path: path5.join(resolveHomeDir(options), ".argent", SECRETS_FILE_NAME),
25253
+ path: path5.join(home, ".argent", SECRETS_FILE_NAME),
25230
25254
  exposure: "dedicated"
25231
25255
  });
25232
25256
  const seen = /* @__PURE__ */ new Set();
@@ -25348,14 +25372,6 @@ var CONFIG_SCHEMA = [
25348
25372
  // drained/reset, not just the file rewritten.
25349
25373
  manageCommand: "argent telemetry"
25350
25374
  },
25351
- {
25352
- key: "allowlist.enabled",
25353
- description: "Whether `argent update` re-applies editor auto-approve allowlist rules. Unset (the default) keeps the current behavior: update refreshes the rules for editors that already have argent configured. Set to `false` to keep update from touching editor allowlists. `false` in either scope wins, so a committed project opt-out holds for every teammate.",
25354
- scopes: ["project", "global"],
25355
- parse: asBoolean,
25356
- merge: "prioritize-restrictive",
25357
- example: "false"
25358
- },
25359
25375
  {
25360
25376
  key: "lens.agent",
25361
25377
  description: "Coding-agent id remembered by `argent lens` to skip the picker.",
@@ -25506,7 +25522,18 @@ function interpolateFileInputPath(template, args) {
25506
25522
  });
25507
25523
  return missing ? null : out;
25508
25524
  }
25509
- var TOOL_FILE_EXTENSIONS = [".png", ".yaml"];
25525
+ var TOOL_FILE_EXTENSIONS = [
25526
+ ".png",
25527
+ ".yaml",
25528
+ ".wav",
25529
+ ".mp3",
25530
+ ".m4a",
25531
+ ".aac",
25532
+ ".caf",
25533
+ ".aif",
25534
+ ".aiff",
25535
+ ".flac"
25536
+ ];
25510
25537
  function hasToolFileExtension(file) {
25511
25538
  const name = file.toLowerCase();
25512
25539
  return TOOL_FILE_EXTENSIONS.some((extension) => name.endsWith(extension));
@@ -25520,16 +25547,24 @@ function toolStepFiles(specs, args) {
25520
25547
  }
25521
25548
  return files;
25522
25549
  }
25523
- function isClientFileArgument({ spec, path: path17 }) {
25524
- return spec.kind === "file" && spec.path === `\${${spec.target}}` && path17.startsWith("/") && hasToolFileExtension(path17);
25550
+ var UNEXPANDED_PATH = /^~|\$[A-Za-z0-9_{(]|`|%[A-Za-z_][A-Za-z0-9_]*%|^[A-Za-z][A-Za-z0-9+.-]+:/;
25551
+ function isUnexpandedPath(p) {
25552
+ return UNEXPANDED_PATH.test(p);
25553
+ }
25554
+ function isClientFileArgument({ spec, path: path18 }) {
25555
+ return spec.kind === "file" && spec.path === `\${${spec.target}}` && path18.startsWith("/") && hasToolFileExtension(path18);
25525
25556
  }
25526
25557
 
25558
+ // ../registry/src/flow-platforms.ts
25559
+ var LAUNCH_PLATFORMS = ["ios", "android", "chromium", "vega", "macos"];
25560
+ var SELECTABLE_PLATFORMS = [...LAUNCH_PLATFORMS, "ios-remote"];
25561
+
25527
25562
  // ../registry/src/flow-file-refs.ts
25528
- import * as fs6 from "node:fs/promises";
25563
+ import * as fs7 from "node:fs/promises";
25529
25564
  import * as path8 from "node:path";
25530
25565
 
25531
25566
  // ../registry/src/e2e-dirs.ts
25532
- import * as fs5 from "node:fs/promises";
25567
+ import * as fs6 from "node:fs/promises";
25533
25568
  import * as path7 from "node:path";
25534
25569
  var E2E_DIR = path7.join(".argent", "e2e");
25535
25570
  var LEGACY_E2E_DIRS = Object.freeze([path7.join(".argent", "flows")]);
@@ -25544,7 +25579,7 @@ function e2eFileCandidates(projectRoot, name) {
25544
25579
  return e2eDirsFor(projectRoot).map((dir) => path7.join(dir, `${name}.yaml`));
25545
25580
  }
25546
25581
  async function exists(file) {
25547
- return fs5.stat(file).then(
25582
+ return fs6.stat(file).then(
25548
25583
  () => true,
25549
25584
  () => false
25550
25585
  );
@@ -25635,10 +25670,10 @@ function canonicalToolArgs(tool, args) {
25635
25670
  // ../registry/src/flow-file-refs.ts
25636
25671
  async function canonicalFlowPath(p) {
25637
25672
  try {
25638
- return await fs6.realpath(p);
25673
+ return await fs7.realpath(p);
25639
25674
  } catch {
25640
25675
  try {
25641
- return path8.join(await fs6.realpath(path8.dirname(p)), path8.basename(p));
25676
+ return path8.join(await fs7.realpath(path8.dirname(p)), path8.basename(p));
25642
25677
  } catch {
25643
25678
  return p;
25644
25679
  }
@@ -25654,6 +25689,9 @@ var MAX_BLOCK_NESTING = 64;
25654
25689
  function isRecord(value) {
25655
25690
  return typeof value === "object" && value !== null && !Array.isArray(value);
25656
25691
  }
25692
+ function flowYamlSource(content) {
25693
+ return content.replace(/^\s+/, (lead) => lead.replace(/[^\n]/g, "")).trimEnd();
25694
+ }
25657
25695
  function collectFlowRequests(doc) {
25658
25696
  const runTargets = /* @__PURE__ */ new Set();
25659
25697
  const snapshots = /* @__PURE__ */ new Set();
@@ -25684,15 +25722,15 @@ function collectFlowRequests(doc) {
25684
25722
  if (isRecord(doc)) visit(doc.steps, 0);
25685
25723
  return { runTargets: [...runTargets], snapshots: [...snapshots], toolSteps, nested };
25686
25724
  }
25687
- function baselineKeyFor(canonicalPath, flowName) {
25688
- const stem = path8.basename(canonicalPath, ".yaml");
25725
+ function baselineKeyFor(canonicalPath2, flowName) {
25726
+ const stem = path8.basename(canonicalPath2, ".yaml");
25689
25727
  return FLOW_NAME_PATTERN.test(stem) ? stem : flowName;
25690
25728
  }
25691
25729
  function flowMemberKey(anchorDir, target) {
25692
25730
  return `${anchorDir}\0${target}`;
25693
25731
  }
25694
25732
  async function classifyOnDiskSpelling(dir, base, addressable = FLOW_FILE_NAME_PATTERN) {
25695
- const entries = await fs6.readdir(dir).catch(() => null);
25733
+ const entries = await fs7.readdir(dir).catch(() => null);
25696
25734
  if (entries === null || entries.includes(base)) return { state: "listed" };
25697
25735
  const actual = entries.find((entry) => entry.toLowerCase() === base.toLowerCase());
25698
25736
  if (actual === void 0) return { state: "absent" };
@@ -25802,6 +25840,9 @@ var FAILURE_CODES = {
25802
25840
  ANDROID_ADB_COMMAND_FAILED: "ANDROID_ADB_COMMAND_FAILED",
25803
25841
  ANDROID_ADB_BOOT_TERMINAL_STATE: "ANDROID_ADB_BOOT_TERMINAL_STATE",
25804
25842
  ANDROID_ADB_BOOT_TIMEOUT: "ANDROID_ADB_BOOT_TIMEOUT",
25843
+ ANDROID_NETWORK_RESTORE_TIMEOUT: "ANDROID_NETWORK_RESTORE_TIMEOUT",
25844
+ ANDROID_OFFLINE_TIMEOUT: "ANDROID_OFFLINE_TIMEOUT",
25845
+ ANDROID_OFFLINE_UNSUPPORTED: "ANDROID_OFFLINE_UNSUPPORTED",
25805
25846
  SIMULATOR_NETWORK_TIMEOUT: "SIMULATOR_NETWORK_TIMEOUT",
25806
25847
  SIMULATOR_NETWORK_CONNECTION_REFUSED: "SIMULATOR_NETWORK_CONNECTION_REFUSED",
25807
25848
  SIMULATOR_NETWORK_CONNECTION_RESET: "SIMULATOR_NETWORK_CONNECTION_RESET",
@@ -25921,12 +25962,15 @@ var FAILURE_CODES = {
25921
25962
  DEBUGGER_CDP_PROTOCOL_ERROR: "DEBUGGER_CDP_PROTOCOL_ERROR",
25922
25963
  DEBUGGER_CDP_CONNECT_FAILED: "DEBUGGER_CDP_CONNECT_FAILED",
25923
25964
  DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN: "DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN",
25965
+ DEBUGGER_CDP_ORIGIN_REJECTED: "DEBUGGER_CDP_ORIGIN_REJECTED",
25924
25966
  DEBUGGER_CDP_NOT_CONNECTED: "DEBUGGER_CDP_NOT_CONNECTED",
25925
25967
  DEBUGGER_CDP_REQUEST_TIMEOUT: "DEBUGGER_CDP_REQUEST_TIMEOUT",
25926
25968
  DEBUGGER_CDP_CONNECTION_CLOSED: "DEBUGGER_CDP_CONNECTION_CLOSED",
25927
25969
  DEBUGGER_TARGET_DEVICE_MISMATCH: "DEBUGGER_TARGET_DEVICE_MISMATCH",
25928
25970
  DEBUGGER_EVALUATE_EXPRESSION_THREW: "DEBUGGER_EVALUATE_EXPRESSION_THREW",
25929
25971
  DEBUGGER_RELOAD_FAILED: "DEBUGGER_RELOAD_FAILED",
25972
+ // e2e-add-step refused a debugger-* call that answered `not_connected`.
25973
+ DEBUGGER_NOT_CONNECTED: "DEBUGGER_NOT_CONNECTED",
25930
25974
  JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED: "JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED",
25931
25975
  JS_RUNTIME_PAYLOAD_INVALID: "JS_RUNTIME_PAYLOAD_INVALID",
25932
25976
  JS_RUNTIME_PAYLOAD_DEVICE_MISSING: "JS_RUNTIME_PAYLOAD_DEVICE_MISSING",
@@ -25995,6 +26039,32 @@ var FAILURE_CODES = {
25995
26039
  NATIVE_PROFILER_PERFETTO_PROCESS_ERROR: "NATIVE_PROFILER_PERFETTO_PROCESS_ERROR",
25996
26040
  NATIVE_PROFILER_PERFETTO_READY_TIMEOUT: "NATIVE_PROFILER_PERFETTO_READY_TIMEOUT",
25997
26041
  NATIVE_PROFILER_PERFETTO_READY_EXITED: "NATIVE_PROFILER_PERFETTO_READY_EXITED",
26042
+ /**
26043
+ * native-profiler-launch-analysis. Input problems use TOOL_INPUT_INVALID and
26044
+ * devicectl steps IOS_DEVICECTL_COMMAND_FAILED.
26045
+ * @see [workflow.ts](../../tool-server/src/utils/ios-launch-time/workflow.ts)
26046
+ */
26047
+ // Not macOS, or an Xcode that cannot record the launch on this target.
26048
+ LAUNCH_ANALYSIS_UNSUPPORTED_HOST: "LAUNCH_ANALYSIS_UNSUPPORTED_HOST",
26049
+ // No usable iPhone or simulator was selected, or Argent's runner holds it.
26050
+ LAUNCH_ANALYSIS_DEVICE_UNAVAILABLE: "LAUNCH_ANALYSIS_DEVICE_UNAVAILABLE",
26051
+ // The bundle_id app is not installed on the selected device.
26052
+ LAUNCH_ANALYSIS_APP_NOT_INSTALLED: "LAUNCH_ANALYSIS_APP_NOT_INSTALLED",
26053
+ // The runner's xcodebuild failed on code signing or provisioning.
26054
+ LAUNCH_ANALYSIS_SIGNING_FAILED: "LAUNCH_ANALYSIS_SIGNING_FAILED",
26055
+ // The iPhone's free developer profile has no slot for Argent's runner.
26056
+ LAUNCH_ANALYSIS_FREE_PROFILE_LIMIT: "LAUNCH_ANALYSIS_FREE_PROFILE_LIMIT",
26057
+ // simctl could not wait for boot, find, launch or terminate the app.
26058
+ LAUNCH_ANALYSIS_SIMCTL_FAILED: "LAUNCH_ANALYSIS_SIMCTL_FAILED",
26059
+ LAUNCH_ANALYSIS_RECORD_FAILED: "LAUNCH_ANALYSIS_RECORD_FAILED",
26060
+ // xctrace could not export the TOC, the CPU samples or the first-frame marker.
26061
+ LAUNCH_ANALYSIS_EXPORT_FAILED: "LAUNCH_ANALYSIS_EXPORT_FAILED",
26062
+ // The App Launch trace has no first frame of the app, so it has no launch window.
26063
+ LAUNCH_ANALYSIS_NO_FIRST_FRAME: "LAUNCH_ANALYSIS_NO_FIRST_FRAME",
26064
+ // The XCTest launch run of Argent's runner failed.
26065
+ LAUNCH_ANALYSIS_RUNNER_TEST_FAILED: "LAUNCH_ANALYSIS_RUNNER_TEST_FAILED",
26066
+ // The launch test ran, but Argent read no launch measurements from its result.
26067
+ LAUNCH_ANALYSIS_NO_SAMPLES: "LAUNCH_ANALYSIS_NO_SAMPLES",
25998
26068
  // iOS and Android share one capture path (simulator-server frames into
25999
26069
  // ffmpeg), so these name the failing stage, not the device family.
26000
26070
  SCREEN_RECORDING_FACTORY_OPTIONS_MISSING: "SCREEN_RECORDING_FACTORY_OPTIONS_MISSING",
@@ -26009,6 +26079,19 @@ var FAILURE_CODES = {
26009
26079
  SCREEN_RECORDING_SERVER_SHUTTING_DOWN: "SCREEN_RECORDING_SERVER_SHUTTING_DOWN",
26010
26080
  SCREEN_RECORDING_STREAM_UNAVAILABLE: "SCREEN_RECORDING_STREAM_UNAVAILABLE",
26011
26081
  SCREEN_RECORDING_FFMPEG_NOT_FOUND: "SCREEN_RECORDING_FFMPEG_NOT_FOUND",
26082
+ // A cabled iPhone has no simulator-server: its frames come from a host-side
26083
+ // CoreMediaIO capture helper, which can fail in ways of its own.
26084
+ SCREEN_RECORDING_DEVICE_HELPER_BUILD_FAILED: "SCREEN_RECORDING_DEVICE_HELPER_BUILD_FAILED",
26085
+ SCREEN_RECORDING_DEVICE_SCREEN_NOT_FOUND: "SCREEN_RECORDING_DEVICE_SCREEN_NOT_FOUND",
26086
+ SCREEN_RECORDING_DEVICE_CAMERA_PERMISSION_DENIED: "SCREEN_RECORDING_DEVICE_CAMERA_PERMISSION_DENIED",
26087
+ SCREEN_RECORDING_DEVICE_HELPER_FAILED: "SCREEN_RECORDING_DEVICE_HELPER_FAILED",
26088
+ AUDIO_CLIP_CONVERSION_FAILED: "AUDIO_CLIP_CONVERSION_FAILED",
26089
+ AUDIO_HOOK_NOT_ACTIVE: "AUDIO_HOOK_NOT_ACTIVE",
26090
+ AUDIO_ENV_SETUP_FAILED: "AUDIO_ENV_SETUP_FAILED",
26091
+ AUDIO_WRONG_PLATFORM: "AUDIO_WRONG_PLATFORM",
26092
+ AUDIO_HOOK_UNAVAILABLE: "AUDIO_HOOK_UNAVAILABLE",
26093
+ AUDIO_INJECTION_NOT_OURS: "AUDIO_INJECTION_NOT_OURS",
26094
+ AUDIO_SIMULATOR_NOT_BOOTED: "AUDIO_SIMULATOR_NOT_BOOTED",
26012
26095
  FLOW_PROJECT_ROOT_INVALID: "FLOW_PROJECT_ROOT_INVALID",
26013
26096
  FLOW_NAME_INVALID: "FLOW_NAME_INVALID",
26014
26097
  FLOW_NO_ACTIVE_RECORDING: "FLOW_NO_ACTIVE_RECORDING",
@@ -26072,6 +26155,8 @@ var FAILURE_CODES = {
26072
26155
  MACOS_APP_BUNDLE_ID_MISMATCH: "MACOS_APP_BUNDLE_ID_MISMATCH",
26073
26156
  MACOS_APP_OPEN_URL_FAILED: "MACOS_APP_OPEN_URL_FAILED",
26074
26157
  MACOS_APP_FILE_ACCESS_FAILED: "MACOS_APP_FILE_ACCESS_FAILED",
26158
+ /** The app's loaded Argent library lacks support for the requested operation. */
26159
+ MACOS_APP_LIBRARY_OUTDATED: "MACOS_APP_LIBRARY_OUTDATED",
26075
26160
  KEYBOARD_KEY_UNSUPPORTED: "KEYBOARD_KEY_UNSUPPORTED",
26076
26161
  KEYBOARD_CHARACTER_UNSUPPORTED: "KEYBOARD_CHARACTER_UNSUPPORTED",
26077
26162
  KEYBOARD_TEXT_AND_KEY_COMBINED: "KEYBOARD_TEXT_AND_KEY_COMBINED",
@@ -26141,13 +26226,19 @@ var FAILURE_COMMANDS = [
26141
26226
  "ax_service",
26142
26227
  "simulator_server",
26143
26228
  "ffmpeg",
26229
+ "afconvert",
26144
26230
  "cdp",
26145
26231
  "electron",
26146
26232
  "npm",
26147
26233
  "npx",
26148
26234
  "unknown",
26149
26235
  "devicectl",
26150
- "xcodebuild"
26236
+ "xcodebuild",
26237
+ "swiftc",
26238
+ // The host-side helper that captures a cabled iPhone's screen.
26239
+ "ios_screen_stream",
26240
+ // `xcrun xcresulttool`, which reads an XCTest result bundle.
26241
+ "xcresulttool"
26151
26242
  ];
26152
26243
  var FAILURE_SIGNAL_NAMES = [
26153
26244
  "SIGABRT",
@@ -26178,9 +26269,9 @@ var FAILURE_SPAWN_CODE_SET = new Set(FAILURE_SPAWN_CODES);
26178
26269
  import { randomUUID as randomUUID3 } from "node:crypto";
26179
26270
  import { AsyncLocalStorage } from "node:async_hooks";
26180
26271
  var resolvedDuringInvocation = new AsyncLocalStorage();
26181
- function valueAtPath(root, path17) {
26272
+ function valueAtPath(root, path18) {
26182
26273
  let current = root;
26183
- for (const key of path17) {
26274
+ for (const key of path18) {
26184
26275
  if (current === null || typeof current !== "object") return void 0;
26185
26276
  if (!Object.hasOwn(current, key)) return void 0;
26186
26277
  current = current[key];
@@ -26302,7 +26393,7 @@ import { spawn as spawn2 } from "node:child_process";
26302
26393
  import { once } from "node:events";
26303
26394
  import { createReadStream, createWriteStream } from "node:fs";
26304
26395
  import { open as open2, rm, readdir as readdir3 } from "node:fs/promises";
26305
- import { basename as basename4, dirname as dirname5, join as join9, resolve as resolve6, sep as sep2 } from "node:path";
26396
+ import { basename as basename4, dirname as dirname5, join as join9, resolve as resolve7, sep as sep2 } from "node:path";
26306
26397
  import { Writable } from "node:stream";
26307
26398
  import { pipeline } from "node:stream/promises";
26308
26399
  import zlib from "node:zlib";
@@ -26400,7 +26491,7 @@ async function sniffFormat(archivePath) {
26400
26491
  }
26401
26492
  }
26402
26493
  var ZSTD_FRAME_MAGIC = 4247762216;
26403
- async function assertSingleCompleteZstdFrame(archivePath) {
26494
+ async function assertSingleCompleteZstdFrame(archivePath, signal) {
26404
26495
  const fh = await open2(archivePath, "r");
26405
26496
  try {
26406
26497
  const { size } = await fh.stat();
@@ -26410,6 +26501,7 @@ async function assertSingleCompleteZstdFrame(archivePath) {
26410
26501
  let pos = 0;
26411
26502
  const read = async (n) => {
26412
26503
  if (pos < windowStart || pos + n > windowEnd) {
26504
+ signal?.throwIfAborted();
26413
26505
  const { bytesRead } = await fh.read(window, 0, window.length, pos);
26414
26506
  windowStart = pos;
26415
26507
  windowEnd = pos + bytesRead;
@@ -26447,14 +26539,16 @@ function tarEnv(env) {
26447
26539
  const characterType = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
26448
26540
  return /utf-?8/i.test(characterType) ? env : { ...env, LC_ALL: TAR_LOCALE };
26449
26541
  }
26450
- async function runTar(archive, args) {
26542
+ async function runTar(archive, args, signal) {
26451
26543
  const child = spawn2("tar", [...args, "-f", "-"], {
26544
+ signal,
26452
26545
  env: tarEnv(process.env)
26453
26546
  });
26454
- const exited = new Promise((res, rej) => {
26455
- child.on("error", rej);
26456
- child.on("close", res);
26547
+ let childError;
26548
+ child.on("error", (err) => {
26549
+ childError = err;
26457
26550
  });
26551
+ const closed = new Promise((resolve12) => child.once("close", resolve12));
26458
26552
  const stdout = collect(child.stdout, MAX_LISTING_BYTES, {
26459
26553
  maxLines: MAX_LISTING_LINES,
26460
26554
  onOverflow: () => child.kill()
@@ -26481,12 +26575,15 @@ async function runTar(archive, args) {
26481
26575
  if (err) child.stdin?.destroy();
26482
26576
  done(err);
26483
26577
  }
26484
- })
26578
+ }),
26579
+ { signal }
26485
26580
  ).then(
26486
26581
  () => null,
26487
26582
  (err) => err
26488
26583
  );
26489
- const [code, feedError] = await Promise.all([exited, fed]);
26584
+ const [code, feedError] = await Promise.all([closed, fed]);
26585
+ signal?.throwIfAborted();
26586
+ if (childError) throw childError;
26490
26587
  if (stdout.overflowed()) {
26491
26588
  throw new Error(
26492
26589
  `tar ${args.join(" ")} listed more than ${MAX_LISTING_LINES} members or ${MAX_LISTING_BYTES >> 20} MiB`
@@ -26500,32 +26597,33 @@ async function runTar(archive, args) {
26500
26597
  function normalizeTarMemberPath(memberPath) {
26501
26598
  return memberPath.replace(/^\.\//, "").replace(/\\/g, "/");
26502
26599
  }
26503
- function isContainedPath(path17, windows = process.platform === "win32") {
26504
- const slashed = path17.replace(/\\/g, "/");
26600
+ function isContainedPath(path18, windows = process.platform === "win32") {
26601
+ const slashed = path18.replace(/\\/g, "/");
26505
26602
  const drive = windows ? /^[A-Za-z]:/ : /^[A-Za-z]:\//;
26506
26603
  return !slashed.startsWith("/") && !drive.test(slashed) && !slashed.split("/").includes("..");
26507
26604
  }
26508
26605
  function isSafeTarMember(memberPath, destDir) {
26509
26606
  const normalized = normalizeTarMemberPath(memberPath);
26510
26607
  if (!isContainedPath(normalized)) return false;
26511
- const root = resolve6(destDir);
26512
- return resolve6(destDir, normalized).startsWith(root + sep2);
26608
+ const root = resolve7(destDir);
26609
+ return resolve7(destDir, normalized).startsWith(root + sep2);
26513
26610
  }
26514
- async function readListing(archive, args) {
26611
+ async function readListing(archive, args, signal) {
26515
26612
  try {
26516
- return await runTar(archive, args);
26613
+ return await runTar(archive, args, signal);
26517
26614
  } catch (err) {
26615
+ signal?.throwIfAborted();
26518
26616
  throw new ArchiveError(
26519
26617
  `Could not read archive: ${err instanceof Error ? err.message : String(err)}`
26520
26618
  );
26521
26619
  }
26522
26620
  }
26523
- async function listTarMembers(archive) {
26524
- const stdout = await readListing(archive, ["-t"]);
26621
+ async function listTarMembers(archive, signal) {
26622
+ const stdout = await readListing(archive, ["-t"], signal);
26525
26623
  return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
26526
26624
  }
26527
- async function assertSafeMemberTypes(archive) {
26528
- const stdout = await readListing(archive, ["-tv"]);
26625
+ async function assertSafeMemberTypes(archive, signal) {
26626
+ const stdout = await readListing(archive, ["-tv"], signal);
26529
26627
  for (const line of stdout.split("\n")) {
26530
26628
  if (!line.trim()) continue;
26531
26629
  const type = line[0];
@@ -26545,8 +26643,8 @@ async function assertSafeMemberTypes(archive) {
26545
26643
  );
26546
26644
  }
26547
26645
  }
26548
- async function assertSafeArchive(archive, destDir) {
26549
- const members2 = await listTarMembers(archive);
26646
+ async function assertSafeArchive(archive, destDir, signal) {
26647
+ const members2 = await listTarMembers(archive, signal);
26550
26648
  if (members2.length === 0) {
26551
26649
  throw new ArchiveError("Archive is empty.");
26552
26650
  }
@@ -26555,7 +26653,7 @@ async function assertSafeArchive(archive, destDir) {
26555
26653
  throw new ArchiveError(`Archive contains an unsafe path "${member}" \u2014 refusing extraction.`);
26556
26654
  }
26557
26655
  }
26558
- await assertSafeMemberTypes(archive);
26656
+ await assertSafeMemberTypes(archive, signal);
26559
26657
  }
26560
26658
  async function resolveMember(destDir, expectedName) {
26561
26659
  const entries = await readdir3(destDir);
@@ -26570,19 +26668,24 @@ async function resolveMember(destDir, expectedName) {
26570
26668
  }
26571
26669
  return join9(destDir, real[0]);
26572
26670
  }
26573
- async function safeExtractArchive(archivePath, destDir, expectedName) {
26671
+ async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
26672
+ signal?.throwIfAborted();
26574
26673
  let archive;
26575
26674
  try {
26576
26675
  archive = { path: archivePath, format: await sniffFormat(archivePath) };
26577
- if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath);
26676
+ if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath, signal);
26578
26677
  } catch (err) {
26678
+ signal?.throwIfAborted();
26579
26679
  throw new ArchiveError(
26580
26680
  `Could not read archive: ${err instanceof Error ? err.message : String(err)}`
26581
26681
  );
26582
26682
  }
26583
- await assertSafeArchive(archive, destDir);
26584
- await runTar(archive, ["-x", "-C", destDir]);
26585
- return resolveMember(destDir, expectedName);
26683
+ await assertSafeArchive(archive, destDir, signal);
26684
+ signal?.throwIfAborted();
26685
+ await runTar(archive, ["-x", "-C", destDir], signal);
26686
+ const member = await resolveMember(destDir, expectedName);
26687
+ signal?.throwIfAborted();
26688
+ return member;
26586
26689
  }
26587
26690
 
26588
26691
  // ../argent-tools-client/src/errors.ts
@@ -26615,6 +26718,22 @@ function interpolatePath(template, args) {
26615
26718
  });
26616
26719
  return missing ? null : out;
26617
26720
  }
26721
+ function callerPath(p) {
26722
+ const onCurrentDrive = path10.sep === "\\" && /^[\\/](?![\\/])/.test(p);
26723
+ if (!onCurrentDrive && (path10.isAbsolute(p) || path10.win32.isAbsolute(p) || isUnexpandedPath(p))) {
26724
+ return p;
26725
+ }
26726
+ const { root } = path10.parse(p);
26727
+ const rest = p.slice(root.length);
26728
+ if (!rest.split(/[\\/]/).includes("..")) {
26729
+ const resolved = path10.resolve(p);
26730
+ const last = p.split(path10.sep === "\\" ? /[\\/]/ : "/").at(-1);
26731
+ const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(path10.sep);
26732
+ return dirOnly ? `${resolved}${path10.sep}` : resolved;
26733
+ }
26734
+ const base = path10.resolve(root);
26735
+ return base.endsWith(path10.sep) ? `${base}${rest}` : `${base}${path10.sep}${rest}`;
26736
+ }
26618
26737
  async function specPath(spec, args) {
26619
26738
  if (spec.kind !== "file" || !spec.paths?.length) return interpolatePath(spec.path, args);
26620
26739
  const candidates = [];
@@ -26659,10 +26778,10 @@ function untrackArchive(archive) {
26659
26778
  for (const s of ARCHIVE_SIGNALS) process.removeListener(s, removeArchivesOnSignal);
26660
26779
  process.removeListener("exit", removePendingArchives);
26661
26780
  }
26662
- function sha256File(filePath) {
26663
- return new Promise((resolve10, reject) => {
26781
+ function sha256File(filePath, signal) {
26782
+ return new Promise((resolve12, reject) => {
26664
26783
  const hash = createHash2("sha256");
26665
- createReadStream2(filePath).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve10(hash.digest("hex"))).on("error", reject);
26784
+ createReadStream2(filePath, { signal }).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve12(hash.digest("hex"))).on("error", reject);
26666
26785
  });
26667
26786
  }
26668
26787
  function toolServerError(text) {
@@ -26725,7 +26844,7 @@ async function uploadFile(sourcePath, endpoint, signal) {
26725
26844
  trackArchive(tarPath);
26726
26845
  try {
26727
26846
  await createArchiveFile(await realpath2(sourcePath), tarPath, format, signal);
26728
- const contentHash = await sha256File(tarPath);
26847
+ const contentHash = await sha256File(tarPath, signal);
26729
26848
  return { uploadId: await uploadTar(tarPath, format, endpoint, signal), contentHash };
26730
26849
  } finally {
26731
26850
  untrackArchive(tarPath);
@@ -26760,13 +26879,21 @@ async function prepareFileInputs(specs, args, opts) {
26760
26879
  return args;
26761
26880
  }
26762
26881
  const record2 = args;
26763
- let out = null;
26882
+ const planned = [];
26883
+ const callArgs = { ...record2 };
26764
26884
  for (const spec of specs) {
26765
26885
  if (spec.skipWhenSet && record2[spec.skipWhenSet] !== void 0) continue;
26766
26886
  if (spec.target in record2 && typeof record2[spec.target] !== "string") continue;
26767
- const filePath = await specPath(spec, record2);
26768
- if (filePath === null) continue;
26769
- if (spec.target in record2 && record2[spec.target] !== filePath) continue;
26887
+ const spelled = await specPath(spec, record2);
26888
+ if (spelled === null) continue;
26889
+ if (spec.target in record2 && record2[spec.target] !== spelled) continue;
26890
+ const filePath = callerPath(spelled);
26891
+ planned.push({ spec, filePath });
26892
+ if (spec.target in record2) callArgs[spec.target] = filePath;
26893
+ }
26894
+ if (planned.length === 0) return args;
26895
+ const out = { ...record2 };
26896
+ for (const { spec, filePath } of planned) {
26770
26897
  const wire = { [FILE_INPUT_MARKER2]: true, path: filePath };
26771
26898
  if (spec.kind === "file") {
26772
26899
  const read = await readFileInputWire(filePath, { includeContent: opts.includeContent });
@@ -26774,12 +26901,12 @@ async function prepareFileInputs(specs, args, opts) {
26774
26901
  if (spec.collect === "flow" && opts.includeContent && wire.content !== void 0 && opts.collectMembers) {
26775
26902
  Object.assign(
26776
26903
  wire,
26777
- await opts.collectMembers(filePath, Buffer.from(wire.content, "base64"), record2, opts)
26904
+ await opts.collectMembers(filePath, Buffer.from(wire.content, "base64"), callArgs, opts)
26778
26905
  );
26779
26906
  }
26780
26907
  }
26781
26908
  if (spec.kind === "probe" && spec.collect === "step" && opts.includeContent && opts.collectStepMembers) {
26782
- wire.members = await opts.collectStepMembers(record2, opts);
26909
+ wire.members = await opts.collectStepMembers(callArgs, opts);
26783
26910
  }
26784
26911
  if (spec.kind === "tar-upload") {
26785
26912
  const st = await stat3(filePath).catch(() => null);
@@ -26793,10 +26920,9 @@ async function prepareFileInputs(specs, args, opts) {
26793
26920
  Object.assign(wire, await uploadFile(filePath, opts.uploadEndpoint, opts.signal));
26794
26921
  }
26795
26922
  }
26796
- out = out ?? { ...record2 };
26797
26923
  out[spec.target] = wire;
26798
26924
  }
26799
- return out ?? args;
26925
+ return out;
26800
26926
  }
26801
26927
  function isAllowedClientFilePath(p) {
26802
26928
  if (!path10.isAbsolute(p)) return false;
@@ -27160,7 +27286,7 @@ function memberCollector(roots, opts) {
27160
27286
  for (let file = files.shift(); file !== void 0; file = files.shift()) {
27161
27287
  let doc;
27162
27288
  try {
27163
- doc = (0, import_yaml.parse)(file.text.trim(), { logLevel: "error" });
27289
+ doc = (0, import_yaml.parse)(flowYamlSource(file.text), { logLevel: "error" });
27164
27290
  } catch {
27165
27291
  continue;
27166
27292
  }
@@ -27275,7 +27401,7 @@ function recordedStep(args) {
27275
27401
  async function collectStepMembers(args, opts, recordingDirFor = e2eDirFor) {
27276
27402
  const { name, project_root: projectRoot } = args;
27277
27403
  const step = recordedStep(args);
27278
- if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name) || typeof projectRoot !== "string" || !path11.isAbsolute(projectRoot) || step === void 0) {
27404
+ if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name) || !isResolvedAbsolute2(projectRoot) || step === void 0) {
27279
27405
  return [];
27280
27406
  }
27281
27407
  const recording = path11.join(recordingDirFor(projectRoot), `${name}.yaml`);
@@ -27361,7 +27487,10 @@ async function stepForOlderServer(args, listedId) {
27361
27487
  async function e2eShadowWarningFor(tool, args) {
27362
27488
  const id = canonicalToolId(tool);
27363
27489
  if (id !== "e2e-execute" && id !== "e2e-read-prerequisite") return void 0;
27364
- const target = nestedFlowTarget(args);
27490
+ const root = args?.project_root;
27491
+ const target = nestedFlowTarget(
27492
+ typeof root === "string" ? { ...args, project_root: callerPath(root) } : args
27493
+ );
27365
27494
  if (target?.kind !== "name") return void 0;
27366
27495
  const picked = await pickE2eFile(target.paths);
27367
27496
  return picked.shadowed === void 0 ? void 0 : e2eShadowWarning(picked.path, picked.shadowed);
@@ -27525,7 +27654,7 @@ async function forwardedSecrets(args) {
27525
27654
  }
27526
27655
  let parsed;
27527
27656
  try {
27528
- parsed = text === void 0 ? void 0 : (0, import_yaml2.parse)(text.trim(), { logLevel: "error" });
27657
+ parsed = text === void 0 ? void 0 : (0, import_yaml2.parse)(flowYamlSource(text), { logLevel: "error" });
27529
27658
  } catch {
27530
27659
  continue;
27531
27660
  }
@@ -27556,6 +27685,34 @@ function secretsTransportRefusal(url) {
27556
27685
  return void 0;
27557
27686
  }
27558
27687
  var FETCH_HEAD_BYTES = 256;
27688
+ function isRecord2(value) {
27689
+ return typeof value === "object" && value !== null && !Array.isArray(value);
27690
+ }
27691
+ var PROJECT_PATH_ADVICE = {
27692
+ project_root: "Pass the absolute path to the project root directory - the same cwd the calling agent is working in.",
27693
+ e2e_test_path: "Pass the absolute path to the e2e test file."
27694
+ };
27695
+ function assertAbsoluteProjectPaths(meta2, args) {
27696
+ if (!meta2 || !isRecord2(args)) return;
27697
+ const aliases = Object.entries(toolParamAliases(meta2.name));
27698
+ for (const [param, advice] of Object.entries(PROJECT_PATH_ADVICE)) {
27699
+ const value = args[param];
27700
+ if (typeof value !== "string" || callerPath(value) === value) continue;
27701
+ const names = [param, ...aliases.filter(([, current]) => current === param).map(([f]) => f)];
27702
+ if (!meta2.fileInputs?.some((spec) => names.some((n) => spec.path.includes(`\${${n}}`)))) {
27703
+ continue;
27704
+ }
27705
+ throw new Error(`${param} must be an absolute path (got "${value}"). ${advice}`);
27706
+ }
27707
+ }
27708
+ function failedRun(result) {
27709
+ if (!isRecord2(result)) return result;
27710
+ if (result.ok === true) return { ...result, ok: false };
27711
+ if (isRecord2(result.toolResult) && result.toolResult.ok === true) {
27712
+ return { ...result, toolResult: { ...result.toolResult, ok: false } };
27713
+ }
27714
+ return result;
27715
+ }
27559
27716
  function createToolsClient(options = {}) {
27560
27717
  let cached2 = null;
27561
27718
  const doFetch = options.fetchImpl ?? ((url, init) => fetch(url, init));
@@ -27604,6 +27761,7 @@ function createToolsClient(options = {}) {
27604
27761
  let finalArgs = canonicalToolArgs(name, args);
27605
27762
  const { tools, uploadFormats } = await fetchToolList({ signal: opts?.signal });
27606
27763
  const meta2 = findTool(tools, name);
27764
+ if (options.refuseRelativeProjectPaths) assertAbsoluteProjectPaths(meta2, finalArgs);
27607
27765
  const olderServer = meta2 !== null && !tools.some((t) => t.name === canonicalToolId(meta2.name));
27608
27766
  if (meta2) {
27609
27767
  finalArgs = await nameToE2ePathForOlderServer(meta2.name, meta2.fileInputs, finalArgs);
@@ -27641,7 +27799,7 @@ function createToolsClient(options = {}) {
27641
27799
  }
27642
27800
  }
27643
27801
  }
27644
- const result = applied.result;
27802
+ const result = applied.failed.length > 0 ? failedRun(applied.result) : applied.result;
27645
27803
  if (shadowWarning === void 0 || typeof result !== "object" || result === null || Array.isArray(result) || typeof result.warning === "string") {
27646
27804
  return result;
27647
27805
  }
@@ -27768,10 +27926,19 @@ function createToolsClient(options = {}) {
27768
27926
  }
27769
27927
 
27770
27928
  // ../argent-tools-client/src/artifacts.ts
27771
- import { copyFile, mkdir as mkdir4, readFile as readFile6, realpath as realpath4, rm as rm3, stat as stat5, writeFile as writeFile4 } from "node:fs/promises";
27929
+ import {
27930
+ copyFile,
27931
+ mkdir as mkdir4,
27932
+ mkdtemp,
27933
+ readFile as readFile6,
27934
+ realpath as realpath4,
27935
+ rm as rm3,
27936
+ stat as stat5,
27937
+ writeFile as writeFile4
27938
+ } from "node:fs/promises";
27772
27939
  import { constants as fsConstants } from "node:fs";
27773
27940
  import { tmpdir as tmpdir2 } from "node:os";
27774
- import { basename as basename7, dirname as dirname9, extname as extname2, isAbsolute as isAbsolute6, join as join13, normalize as normalize2, resolve as resolve8, sep as sep4 } from "node:path";
27941
+ import { basename as basename7, dirname as dirname9, extname as extname2, isAbsolute as isAbsolute6, join as join13, normalize as normalize2, resolve as resolve10, sep as sep5 } from "node:path";
27775
27942
  import { createHash as createHash3 } from "node:crypto";
27776
27943
  var ARTIFACT_MARKER2 = "__argentArtifact";
27777
27944
  function isArtifactHandle(value) {
@@ -27819,8 +27986,8 @@ function configuredRecordingsDir() {
27819
27986
  const trimmed = value.trim();
27820
27987
  if (trimmed === "") return null;
27821
27988
  const home = dirname9(argentHomeDir());
27822
- const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep4}`) ? join13(home, trimmed.slice(2)) : trimmed;
27823
- return resolve8(durableBaseDir(), expanded);
27989
+ const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep5}`) ? join13(home, trimmed.slice(2)) : trimmed;
27990
+ return resolve10(durableBaseDir(), expanded);
27824
27991
  }
27825
27992
  var MAX_ARTIFACT_BYTES = 2 * 1024 * 1024 * 1024;
27826
27993
  async function readCapped(res, cap) {
@@ -27853,10 +28020,10 @@ async function writeDurableUnique(dir, filename, write) {
27853
28020
  const stem = filename.slice(0, filename.length - ext.length);
27854
28021
  for (let i = 1; i <= 1e3; i++) {
27855
28022
  const candidate = i === 1 ? filename : `${stem} (${i})${ext}`;
27856
- const path17 = join13(dir, candidate);
28023
+ const path18 = join13(dir, candidate);
27857
28024
  try {
27858
- await write(path17);
27859
- return path17;
28025
+ await write(path18);
28026
+ return path18;
27860
28027
  } catch (err) {
27861
28028
  if (err?.code === "EEXIST") continue;
27862
28029
  throw err;
@@ -27867,7 +28034,7 @@ async function writeDurableUnique(dir, filename, write) {
27867
28034
  function durableSaveTarget(handle) {
27868
28035
  if (typeof handle.saveDir !== "string" || !handle.saveDir || handle.archive) return null;
27869
28036
  const rel = normalize2(handle.saveDir);
27870
- if (isAbsolute6(rel) || rel === ".." || rel.startsWith(`..${sep4}`) || rel.split(sep4).includes("..")) {
28037
+ if (isAbsolute6(rel) || rel === ".." || rel.startsWith(`..${sep5}`) || rel.split(sep5).includes("..")) {
27871
28038
  return null;
27872
28039
  }
27873
28040
  if (!ALLOWED_SAVE_DIRS.has(rel)) return null;
@@ -27912,16 +28079,22 @@ async function resolveLocalFile(handle) {
27912
28079
  return null;
27913
28080
  }
27914
28081
  }
27915
- async function downloadAndExtractArchive(handle, data, dir) {
27916
- const tarball = join13(dir, `${sanitizeSegment(handle.filename)}.tar.gz`);
28082
+ async function downloadAndExtractArchive(handle, data, dir, signal) {
28083
+ signal?.throwIfAborted();
28084
+ const attemptDir = await mkdtemp(join13(dir, "bundle-"));
28085
+ const tarball = join13(attemptDir, "download.tar");
28086
+ const extractDir = join13(attemptDir, "files");
27917
28087
  try {
27918
- await writeFile4(tarball, data);
27919
- return await safeExtractArchive(tarball, dir, handle.filename);
28088
+ await writeFile4(tarball, data, { signal });
28089
+ await mkdir4(extractDir);
28090
+ const member = await safeExtractArchive(tarball, extractDir, handle.filename, signal);
28091
+ await rm3(tarball);
28092
+ signal?.throwIfAborted();
28093
+ return member;
27920
28094
  } catch {
27921
- return null;
27922
- } finally {
27923
- await rm3(tarball, { force: true }).catch(() => {
28095
+ await rm3(attemptDir, { recursive: true, force: true }).catch(() => {
27924
28096
  });
28097
+ return null;
27925
28098
  }
27926
28099
  }
27927
28100
  async function materializeArtifacts(result, ctx) {
@@ -28007,7 +28180,7 @@ async function materializeArtifacts(result, ctx) {
28007
28180
  if (!data) return null;
28008
28181
  await ensureDir();
28009
28182
  if (value.archive === "tar.gz") {
28010
- return await downloadAndExtractArchive(value, data, dir);
28183
+ return await downloadAndExtractArchive(value, data, dir, ctx.signal);
28011
28184
  }
28012
28185
  if (value.size > 0 && data.length !== value.size) return null;
28013
28186
  const downloadedPath = join13(dir, sanitizeSegment(value.filename));
@@ -28044,7 +28217,7 @@ function getDeviceIdFromArgs(args) {
28044
28217
  }
28045
28218
 
28046
28219
  // ../telemetry/src/debug.ts
28047
- import * as fs7 from "node:fs";
28220
+ import * as fs8 from "node:fs";
28048
28221
 
28049
28222
  // ../telemetry/src/paths.ts
28050
28223
  import * as path13 from "node:path";
@@ -28066,7 +28239,8 @@ var DEVICE_KINDS = [
28066
28239
  "emulator",
28067
28240
  "vvd",
28068
28241
  "device",
28069
- "app"
28242
+ "app",
28243
+ "catalyst"
28070
28244
  ];
28071
28245
  var DEBUGGER_NOT_CONNECTED_REASONS = [
28072
28246
  "metro_not_running",
@@ -28226,7 +28400,8 @@ var ALLOWED = {
28226
28400
  install_mode: INSTALL_MODE
28227
28401
  },
28228
28402
  "installation:allowlist_decision": {
28229
- is_enabled: bool
28403
+ is_enabled: bool,
28404
+ decided_by: oneOf(["flag", "default", "prompt"])
28230
28405
  },
28231
28406
  "installation:stale_config_cleanup": {
28232
28407
  removed_count: COUNT,
@@ -28372,380 +28547,12 @@ import { randomUUID as randomUUID5 } from "node:crypto";
28372
28547
  // ../telemetry/src/cloud-agent-detect.ts
28373
28548
  import { existsSync as existsSync3 } from "node:fs";
28374
28549
 
28375
- // ../../node_modules/ci-info/vendors.json
28376
- var vendors_default = [
28377
- {
28378
- name: "Agola CI",
28379
- constant: "AGOLA",
28380
- env: "AGOLA_GIT_REF",
28381
- pr: "AGOLA_PULL_REQUEST_ID"
28382
- },
28383
- {
28384
- name: "Alpic",
28385
- constant: "ALPIC",
28386
- env: "ALPIC_HOST"
28387
- },
28388
- {
28389
- name: "Appcircle",
28390
- constant: "APPCIRCLE",
28391
- env: "AC_APPCIRCLE",
28392
- pr: {
28393
- env: "AC_GIT_PR",
28394
- ne: "false"
28395
- }
28396
- },
28397
- {
28398
- name: "AppVeyor",
28399
- constant: "APPVEYOR",
28400
- env: "APPVEYOR",
28401
- pr: "APPVEYOR_PULL_REQUEST_NUMBER"
28402
- },
28403
- {
28404
- name: "AWS CodeBuild",
28405
- constant: "CODEBUILD",
28406
- env: "CODEBUILD_BUILD_ARN",
28407
- pr: {
28408
- env: "CODEBUILD_WEBHOOK_EVENT",
28409
- any: [
28410
- "PULL_REQUEST_CREATED",
28411
- "PULL_REQUEST_UPDATED",
28412
- "PULL_REQUEST_REOPENED"
28413
- ]
28414
- }
28415
- },
28416
- {
28417
- name: "Azure Pipelines",
28418
- constant: "AZURE_PIPELINES",
28419
- env: "TF_BUILD",
28420
- pr: {
28421
- BUILD_REASON: "PullRequest"
28422
- }
28423
- },
28424
- {
28425
- name: "Bamboo",
28426
- constant: "BAMBOO",
28427
- env: "bamboo_planKey"
28428
- },
28429
- {
28430
- name: "Bitbucket Pipelines",
28431
- constant: "BITBUCKET",
28432
- env: "BITBUCKET_COMMIT",
28433
- pr: "BITBUCKET_PR_ID"
28434
- },
28435
- {
28436
- name: "Bitrise",
28437
- constant: "BITRISE",
28438
- env: "BITRISE_IO",
28439
- pr: "BITRISE_PULL_REQUEST"
28440
- },
28441
- {
28442
- name: "Buddy",
28443
- constant: "BUDDY",
28444
- env: "BUDDY_WORKSPACE_ID",
28445
- pr: "BUDDY_EXECUTION_PULL_REQUEST_ID"
28446
- },
28447
- {
28448
- name: "Buildkite",
28449
- constant: "BUILDKITE",
28450
- env: "BUILDKITE",
28451
- pr: {
28452
- env: "BUILDKITE_PULL_REQUEST",
28453
- ne: "false"
28454
- }
28455
- },
28456
- {
28457
- name: "CircleCI",
28458
- constant: "CIRCLE",
28459
- env: "CIRCLECI",
28460
- pr: "CIRCLE_PULL_REQUEST"
28461
- },
28462
- {
28463
- name: "Cirrus CI",
28464
- constant: "CIRRUS",
28465
- env: "CIRRUS_CI",
28466
- pr: "CIRRUS_PR"
28467
- },
28468
- {
28469
- name: "Cloudflare Pages",
28470
- constant: "CLOUDFLARE_PAGES",
28471
- env: "CF_PAGES"
28472
- },
28473
- {
28474
- name: "Cloudflare Workers",
28475
- constant: "CLOUDFLARE_WORKERS",
28476
- env: "WORKERS_CI"
28477
- },
28478
- {
28479
- name: "Codefresh",
28480
- constant: "CODEFRESH",
28481
- env: "CF_BUILD_ID",
28482
- pr: {
28483
- any: [
28484
- "CF_PULL_REQUEST_NUMBER",
28485
- "CF_PULL_REQUEST_ID"
28486
- ]
28487
- }
28488
- },
28489
- {
28490
- name: "Codemagic",
28491
- constant: "CODEMAGIC",
28492
- env: "CM_BUILD_ID",
28493
- pr: "CM_PULL_REQUEST"
28494
- },
28495
- {
28496
- name: "Codeship",
28497
- constant: "CODESHIP",
28498
- env: {
28499
- CI_NAME: "codeship"
28500
- }
28501
- },
28502
- {
28503
- name: "Drone",
28504
- constant: "DRONE",
28505
- env: "DRONE",
28506
- pr: {
28507
- DRONE_BUILD_EVENT: "pull_request"
28508
- }
28509
- },
28510
- {
28511
- name: "dsari",
28512
- constant: "DSARI",
28513
- env: "DSARI"
28514
- },
28515
- {
28516
- name: "Earthly",
28517
- constant: "EARTHLY",
28518
- env: "EARTHLY_CI"
28519
- },
28520
- {
28521
- name: "Expo Application Services",
28522
- constant: "EAS",
28523
- env: "EAS_BUILD"
28524
- },
28525
- {
28526
- name: "Gerrit",
28527
- constant: "GERRIT",
28528
- env: "GERRIT_PROJECT"
28529
- },
28530
- {
28531
- name: "Gitea Actions",
28532
- constant: "GITEA_ACTIONS",
28533
- env: "GITEA_ACTIONS"
28534
- },
28535
- {
28536
- name: "GitHub Actions",
28537
- constant: "GITHUB_ACTIONS",
28538
- env: "GITHUB_ACTIONS",
28539
- pr: {
28540
- GITHUB_EVENT_NAME: "pull_request"
28541
- }
28542
- },
28543
- {
28544
- name: "GitLab CI",
28545
- constant: "GITLAB",
28546
- env: "GITLAB_CI",
28547
- pr: "CI_MERGE_REQUEST_ID"
28548
- },
28549
- {
28550
- name: "GoCD",
28551
- constant: "GOCD",
28552
- env: "GO_PIPELINE_LABEL"
28553
- },
28554
- {
28555
- name: "Google Cloud Build",
28556
- constant: "GOOGLE_CLOUD_BUILD",
28557
- env: "BUILDER_OUTPUT"
28558
- },
28559
- {
28560
- name: "Harness CI",
28561
- constant: "HARNESS",
28562
- env: "HARNESS_BUILD_ID"
28563
- },
28564
- {
28565
- name: "Heroku",
28566
- constant: "HEROKU",
28567
- env: {
28568
- env: "NODE",
28569
- includes: "/app/.heroku/node/bin/node"
28570
- }
28571
- },
28572
- {
28573
- name: "Hudson",
28574
- constant: "HUDSON",
28575
- env: "HUDSON_URL"
28576
- },
28577
- {
28578
- name: "Jenkins",
28579
- constant: "JENKINS",
28580
- env: [
28581
- "JENKINS_URL",
28582
- "BUILD_ID"
28583
- ],
28584
- pr: {
28585
- any: [
28586
- "ghprbPullId",
28587
- "CHANGE_ID"
28588
- ]
28589
- }
28590
- },
28591
- {
28592
- name: "LayerCI",
28593
- constant: "LAYERCI",
28594
- env: "LAYERCI",
28595
- pr: "LAYERCI_PULL_REQUEST"
28596
- },
28597
- {
28598
- name: "Magnum CI",
28599
- constant: "MAGNUM",
28600
- env: "MAGNUM"
28601
- },
28602
- {
28603
- name: "Netlify CI",
28604
- constant: "NETLIFY",
28605
- env: "NETLIFY",
28606
- pr: {
28607
- env: "PULL_REQUEST",
28608
- ne: "false"
28609
- }
28610
- },
28611
- {
28612
- name: "Nevercode",
28613
- constant: "NEVERCODE",
28614
- env: "NEVERCODE",
28615
- pr: {
28616
- env: "NEVERCODE_PULL_REQUEST",
28617
- ne: "false"
28618
- }
28619
- },
28620
- {
28621
- name: "Prow",
28622
- constant: "PROW",
28623
- env: "PROW_JOB_ID"
28624
- },
28625
- {
28626
- name: "ReleaseHub",
28627
- constant: "RELEASEHUB",
28628
- env: "RELEASE_BUILD_ID"
28629
- },
28630
- {
28631
- name: "Render",
28632
- constant: "RENDER",
28633
- env: "RENDER",
28634
- pr: {
28635
- IS_PULL_REQUEST: "true"
28636
- }
28637
- },
28638
- {
28639
- name: "Sail CI",
28640
- constant: "SAIL",
28641
- env: "SAILCI",
28642
- pr: "SAIL_PULL_REQUEST_NUMBER"
28643
- },
28644
- {
28645
- name: "Screwdriver",
28646
- constant: "SCREWDRIVER",
28647
- env: "SCREWDRIVER",
28648
- pr: {
28649
- env: "SD_PULL_REQUEST",
28650
- ne: "false"
28651
- }
28652
- },
28653
- {
28654
- name: "Semaphore",
28655
- constant: "SEMAPHORE",
28656
- env: "SEMAPHORE",
28657
- pr: "PULL_REQUEST_NUMBER"
28658
- },
28659
- {
28660
- name: "Sourcehut",
28661
- constant: "SOURCEHUT",
28662
- env: {
28663
- CI_NAME: "sourcehut"
28664
- }
28665
- },
28666
- {
28667
- name: "Strider CD",
28668
- constant: "STRIDER",
28669
- env: "STRIDER"
28670
- },
28671
- {
28672
- name: "TaskCluster",
28673
- constant: "TASKCLUSTER",
28674
- env: [
28675
- "TASK_ID",
28676
- "RUN_ID"
28677
- ]
28678
- },
28679
- {
28680
- name: "TeamCity",
28681
- constant: "TEAMCITY",
28682
- env: "TEAMCITY_VERSION"
28683
- },
28684
- {
28685
- name: "Travis CI",
28686
- constant: "TRAVIS",
28687
- env: "TRAVIS",
28688
- pr: {
28689
- env: "TRAVIS_PULL_REQUEST",
28690
- ne: "false"
28691
- }
28692
- },
28693
- {
28694
- name: "Vela",
28695
- constant: "VELA",
28696
- env: "VELA",
28697
- pr: {
28698
- VELA_PULL_REQUEST: "1"
28699
- }
28700
- },
28701
- {
28702
- name: "Vercel",
28703
- constant: "VERCEL",
28704
- env: {
28705
- any: [
28706
- "NOW_BUILDER",
28707
- "VERCEL"
28708
- ]
28709
- },
28710
- pr: "VERCEL_GIT_PULL_REQUEST_ID"
28711
- },
28712
- {
28713
- name: "Visual Studio App Center",
28714
- constant: "APPCENTER",
28715
- env: "APPCENTER_BUILD_ID"
28716
- },
28717
- {
28718
- name: "Woodpecker",
28719
- constant: "WOODPECKER",
28720
- env: {
28721
- CI: "woodpecker"
28722
- },
28723
- pr: {
28724
- CI_BUILD_EVENT: "pull_request"
28725
- }
28726
- },
28727
- {
28728
- name: "Xcode Cloud",
28729
- constant: "XCODE_CLOUD",
28730
- env: "CI_XCODE_PROJECT",
28731
- pr: "CI_PULL_REQUEST_NUMBER"
28732
- },
28733
- {
28734
- name: "Xcode Server",
28735
- constant: "XCODE_SERVER",
28736
- env: "XCS"
28737
- }
28738
- ];
28739
-
28740
- // ../telemetry/src/ci-detect.ts
28741
- var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
28742
-
28743
28550
  // ../telemetry/src/base-props.ts
28744
28551
  var SESSION_ID2 = randomUUID5();
28745
28552
 
28746
28553
  // ../telemetry/src/identity.ts
28747
28554
  import * as crypto2 from "node:crypto";
28748
- import * as fs8 from "node:fs";
28555
+ import * as fs9 from "node:fs";
28749
28556
  import * as path14 from "node:path";
28750
28557
 
28751
28558
  // ../telemetry/src/fingerprint.ts
@@ -28753,21 +28560,22 @@ import { execFileSync as execFileSync2, spawn as spawn3 } from "node:child_proce
28753
28560
 
28754
28561
  // ../native-devtools-ios/src/index.ts
28755
28562
  import * as path15 from "node:path";
28756
- import * as fs9 from "node:fs";
28563
+ import * as fs10 from "node:fs";
28757
28564
  var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ?? path15.join(__dirname, "..", "dylibs");
28758
28565
  var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ?? path15.join(__dirname, "..", "bin");
28759
28566
  var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ?? path15.join(DYLIB_DIR, "tcp");
28760
28567
  var DYLIB_TVOS_DIR = path15.join(DYLIB_DIR, "tvos");
28761
28568
 
28762
28569
  // ../telemetry/src/consent.ts
28763
- import * as fs10 from "node:fs";
28570
+ import * as fs11 from "node:fs";
28571
+ import * as path16 from "node:path";
28764
28572
  var cache = /* @__PURE__ */ new Map();
28765
28573
  var sessionOverride = null;
28766
28574
  function readConfigOverrideAt(filePath) {
28767
28575
  const miss = { mtimeMs: null, fingerprint: null, enabledOverride: null };
28768
28576
  let stats;
28769
28577
  try {
28770
- stats = fs10.lstatSync(filePath);
28578
+ stats = fs11.lstatSync(filePath);
28771
28579
  } catch {
28772
28580
  cache.set(filePath, miss);
28773
28581
  return null;
@@ -28784,7 +28592,7 @@ function readConfigOverrideAt(filePath) {
28784
28592
  }
28785
28593
  let parsedEnabled = null;
28786
28594
  try {
28787
- const raw2 = fs10.readFileSync(filePath, "utf8");
28595
+ const raw2 = fs11.readFileSync(filePath, "utf8");
28788
28596
  const json = JSON.parse(raw2);
28789
28597
  if (json && typeof json === "object") {
28790
28598
  const t = json.telemetry;
@@ -28802,7 +28610,8 @@ function readPersistedConsent(cwd) {
28802
28610
  const globalPath = configFilePath("global");
28803
28611
  const projectPath = configFilePath("project", { cwd });
28804
28612
  const global = readConfigOverrideAt(globalPath);
28805
- const project = projectPath === globalPath ? null : readConfigOverrideAt(projectPath);
28613
+ const projectRoot = path16.dirname(path16.dirname(projectPath));
28614
+ const project = isHomeDir(projectRoot) ? null : readConfigOverrideAt(projectPath);
28806
28615
  if (project === false && global === false) {
28807
28616
  return { enabled: false, detail: "config.json (project and global)" };
28808
28617
  }
@@ -28893,7 +28702,7 @@ var PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
28893
28702
  function imageBlock(data, mimeType) {
28894
28703
  return { type: "image", data: data.toString("base64"), mimeType };
28895
28704
  }
28896
- async function fetchPngBytes(url) {
28705
+ async function fetchPngBytes(url, signal) {
28897
28706
  try {
28898
28707
  let buf;
28899
28708
  if (url.startsWith("file://")) {
@@ -28901,7 +28710,7 @@ async function fetchPngBytes(url) {
28901
28710
  const { fileURLToPath } = await import("node:url");
28902
28711
  buf = await readFile8(fileURLToPath(url));
28903
28712
  } else {
28904
- const res = await fetch(url);
28713
+ const res = await fetch(url, { signal });
28905
28714
  if (!res.ok) return null;
28906
28715
  buf = Buffer.from(await res.arrayBuffer());
28907
28716
  }
@@ -28913,7 +28722,7 @@ async function fetchPngBytes(url) {
28913
28722
  }
28914
28723
  }
28915
28724
  async function toMcpContent(result, outputHint, ctx, args) {
28916
- const suppressImage = isRecord2(args) && args.includeImageInContext === false;
28725
+ const suppressImage = isRecord3(args) && args.includeImageInContext === false;
28917
28726
  if (ctx) {
28918
28727
  const { result: rewritten, images } = await materializeArtifacts(result, ctx);
28919
28728
  if (outputHint === "image") {
@@ -28924,7 +28733,7 @@ async function toMcpContent(result, outputHint, ctx, args) {
28924
28733
  blocks2.push(saved);
28925
28734
  return blocks2;
28926
28735
  }
28927
- return legacyImageContent(rewritten, suppressImage);
28736
+ return legacyImageContent(rewritten, suppressImage, ctx.signal);
28928
28737
  }
28929
28738
  const blocks = [{ type: "text", text: stringifyForText(rewritten) }];
28930
28739
  if (!suppressImage) for (const img of images) blocks.push(imageBlock(img.data, img.mimeType));
@@ -28938,13 +28747,13 @@ async function toMcpContent(result, outputHint, ctx, args) {
28938
28747
  function stringifyForText(value) {
28939
28748
  return JSON.stringify(value ?? null, null, 2);
28940
28749
  }
28941
- async function legacyImageContent(result, suppressImage) {
28750
+ async function legacyImageContent(result, suppressImage, signal) {
28942
28751
  if (result && typeof result === "object" && "url" in result) {
28943
28752
  const r = result;
28944
28753
  if (suppressImage) {
28945
28754
  return [{ type: "text", text: `Saved: ${r.path ?? ""}` }];
28946
28755
  }
28947
- const buf = await fetchPngBytes(r.url);
28756
+ const buf = await fetchPngBytes(r.url, signal);
28948
28757
  if (buf) {
28949
28758
  return [imageBlock(buf, "image/png"), { type: "text", text: `Saved: ${r.path ?? ""}` }];
28950
28759
  }
@@ -28957,20 +28766,22 @@ async function legacyImageContent(result, suppressImage) {
28957
28766
  }
28958
28767
  return [{ type: "text", text: JSON.stringify(result, null, 2) }];
28959
28768
  }
28960
- function isRecord2(value) {
28769
+ function isRecord3(value) {
28961
28770
  return value !== null && typeof value === "object";
28962
28771
  }
28963
28772
  function isScreenshotDiffResult(value) {
28964
- if (!isRecord2(value)) return false;
28773
+ if (!isRecord3(value)) return false;
28965
28774
  return typeof value.summary === "string";
28966
28775
  }
28967
28776
  async function screenshotDiffToMcpContent(result, ctx) {
28968
28777
  const blocks = [];
28969
28778
  let contextDiffPath = result.contextDiffPath;
28779
+ let diffPath = result.diffPath;
28970
28780
  let materializedImages = [];
28971
28781
  if (ctx) {
28972
28782
  const { result: rewritten, images } = await materializeArtifacts(result, ctx);
28973
28783
  contextDiffPath = rewritten.contextDiffPath;
28784
+ diffPath = rewritten.diffPath;
28974
28785
  materializedImages = images;
28975
28786
  }
28976
28787
  if (typeof contextDiffPath === "string") {
@@ -28994,6 +28805,15 @@ async function screenshotDiffToMcpContent(result, ctx) {
28994
28805
  }
28995
28806
  }
28996
28807
  blocks.push({ type: "text", text: result.summary });
28808
+ const paths = [
28809
+ ["diffPath", diffPath],
28810
+ ["contextDiffPath", contextDiffPath]
28811
+ ];
28812
+ for (const [key, value] of paths) {
28813
+ if (value === void 0) continue;
28814
+ const text = `${key}: ${typeof value === "string" ? value : "(unavailable)"}`;
28815
+ blocks.push({ type: "text", text });
28816
+ }
28997
28817
  return blocks;
28998
28818
  }
28999
28819
  var STATUS_GLYPH = {
@@ -29056,14 +28876,14 @@ async function flowRunToMcpContent(result, ctx) {
29056
28876
  if (step.result !== void 0) {
29057
28877
  blocks.push(...await toMcpContent(step.result, step.outputHint, ctx, step.args));
29058
28878
  }
29059
- if (isRecord2(step.artifacts)) {
28879
+ if (isRecord3(step.artifacts)) {
29060
28880
  blocks.push(...await stepArtifactBlocks(step.artifacts, step.status, ctx, step.depth));
29061
28881
  }
29062
28882
  }
29063
28883
  for (const write of result.baselineWrites ?? []) {
29064
- const { path: path17, error: error2 } = isRecord2(write) ? write : {};
29065
- if (typeof path17 === "string" && typeof error2 === "string") {
29066
- blocks.push({ type: "text", text: `\u2717 baseline not written: ${path17}: ${error2}` });
28884
+ const { path: path18, error: error2 } = isRecord3(write) ? write : {};
28885
+ if (typeof path18 === "string" && typeof error2 === "string") {
28886
+ blocks.push({ type: "text", text: `\u2717 baseline not written: ${path18}: ${error2}` });
29067
28887
  }
29068
28888
  }
29069
28889
  if (result.ok !== void 0) {
@@ -29227,7 +29047,7 @@ function treeIdLine(id) {
29227
29047
  return `Tree id: ${id}`;
29228
29048
  }
29229
29049
  function unchangedTreeNote(id, tool) {
29230
- return `Identical to element tree \`${id}\`, which an earlier \`${tool}\` result returned, so it is not repeated here: take elements and frames from that tree. The action can still have had an effect that the tree does not show, such as text typed in a field. Call \`describe\` if you do not have tree \`${id}\`.`;
29050
+ return `Element tree matches \`${id}\` from an earlier \`${tool}\` result. Actions may have effects the tree omits. Call \`describe\` if you lack that tree.`;
29231
29051
  }
29232
29052
  function randomTag() {
29233
29053
  return randomInt(36 ** 3).toString(36).padStart(3, "0");
@@ -29434,7 +29254,7 @@ function toMcpToolList(tools, options = {}) {
29434
29254
  // ../argent-mcp/src/list-devices-text.ts
29435
29255
  var RUNTIME_PREFIX = "com.apple.CoreSimulator.SimRuntime.";
29436
29256
  var STOPPED_SIMULATORS_HEADER = "iOS simulators that are shut down, one per line (platform, udid, name, runtime, state, tags); start one with boot-device:";
29437
- function isRecord3(value) {
29257
+ function isRecord4(value) {
29438
29258
  return value !== null && typeof value === "object" && !Array.isArray(value);
29439
29259
  }
29440
29260
  function shortRuntime(runtime) {
@@ -29478,8 +29298,8 @@ function stoppedSimulatorLine(device) {
29478
29298
  return parts.join(" ");
29479
29299
  }
29480
29300
  function listDevicesText(result) {
29481
- if (!isRecord3(result) || !Array.isArray(result.devices)) return void 0;
29482
- if (!result.devices.every(isRecord3)) return void 0;
29301
+ if (!isRecord4(result) || !Array.isArray(result.devices)) return void 0;
29302
+ if (!result.devices.every(isRecord4)) return void 0;
29483
29303
  const devices = result.devices;
29484
29304
  const listed = [];
29485
29305
  const stopped = [];
@@ -29504,15 +29324,15 @@ ${stopped.join("\n")}`;
29504
29324
  }
29505
29325
 
29506
29326
  // ../argent-mcp/src/instructions.ts
29507
- var SERVER_INSTRUCTIONS = "Argent \u2014 iOS Simulator, Android Emulator, and Chromium app control for interacting, testing, profiling and debugging mobile and Chromium applications. Interaction tools return the screen after the action: a screenshot plus the accessibility element tree with normalized tap frames. Take coordinates from that tree; call describe only when no fresh tree is available \u2014 never guess coordinates from pixels. A result names an identical earlier tree by its tree id in place of repeating it. Do not stop simulator servers when a task finishes: the next task reuses them. Call stop-all-simulator-servers when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services, always with devices: [...] naming the devices this session used. Never stop a Metro the user started unless they ask. One tool-server is shared by every agent using this argent install, so an unscoped call tears down their devices too \u2014 reserve it for a deliberate machine-wide cleanup.";
29327
+ var SERVER_INSTRUCTIONS = "Argent \u2014 iOS Simulator, Android Emulator, and Chromium app control for interacting, testing, profiling and debugging mobile and Chromium applications. Use the platform the user named; otherwise prefer a device list-devices shows already running, and do not default to iOS. In a single-platform project, boot that platform. Prefer these tools over raw xcrun or adb commands, which are a fallback. Prefer launch-app or open-url over tapping home-screen icons. If the task may need a saved e2e test, load the argent-create-e2e skill (argent-qa-e2e for acceptance tests) before the first launch or in-app action: recording is not retroactive. Load the matching argent-* skill before React Native build or debug work, profiling, a physical phone, a Mac app or a TV. Interaction tools return the screen after the action: a screenshot plus the accessibility element tree with normalized tap frames. Take coordinates from that tree; call describe only when no fresh tree is available \u2014 never guess coordinates from pixels. A result names an identical earlier tree by its tree id in place of repeating it. If a tap fails twice, stop retrying and call a discovery tool again. Use await-ui-element to wait for the UI instead of polling with screenshots. Do not stop simulator servers when a task finishes: the next task reuses them. Call stop-all-simulator-servers when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services, always with devices: [...] naming the devices this session used. Never stop a Metro the user started unless they ask. One tool-server is shared by every agent using this argent install, so an unscoped call tears down their devices too \u2014 reserve it for a deliberate machine-wide cleanup. The argent CLI manages the toolkit: argent --help lists its commands.";
29508
29328
 
29509
29329
  // ../argent-mcp/src/installed-version.ts
29510
- import * as fs11 from "node:fs";
29511
- import * as path16 from "node:path";
29330
+ import * as fs12 from "node:fs";
29331
+ import * as path17 from "node:path";
29512
29332
  function getInstalledVersion() {
29513
29333
  try {
29514
- const pkgPath = path16.resolve(import.meta.dirname, "..", "package.json");
29515
- const pkg = JSON.parse(fs11.readFileSync(pkgPath, "utf8"));
29334
+ const pkgPath = path17.resolve(import.meta.dirname, "..", "package.json");
29335
+ const pkg = JSON.parse(fs12.readFileSync(pkgPath, "utf8"));
29516
29336
  return pkg.version ?? "unknown";
29517
29337
  } catch {
29518
29338
  return "unknown";
@@ -29567,9 +29387,9 @@ async function untilAborted(work, signal) {
29567
29387
  }
29568
29388
  let onAbort = () => {
29569
29389
  };
29570
- const aborted2 = new Promise((resolve10) => {
29571
- onAbort = resolve10;
29572
- if (signal.aborted) resolve10();
29390
+ const aborted2 = new Promise((resolve12) => {
29391
+ onAbort = resolve12;
29392
+ if (signal.aborted) resolve12();
29573
29393
  else signal.addEventListener("abort", onAbort, { once: true });
29574
29394
  });
29575
29395
  try {
@@ -29608,11 +29428,12 @@ function createToolCaller(deps) {
29608
29428
  const client = createToolsClient({
29609
29429
  baseUrl: async () => ({ ...deps.getHandle(), remote: deps.remote }),
29610
29430
  headers: deps.extraHeaders,
29431
+ refuseRelativeProjectPaths: true,
29611
29432
  fetchImpl: async (url, init, meta2) => {
29612
29433
  parseUrl(url);
29613
29434
  return fetchWithReconnect(() => rebase(url), deps.reconnect, {
29614
29435
  init: () => withHeaders(init),
29615
- // A call that carried an upload is sent once and never aborted: the
29436
+ // A call that carried an upload is sent once and never timed out: the
29616
29437
  // tool-server consumes the upload when it reads the call, so a second
29617
29438
  // attempt could only fail.
29618
29439
  fetchTimeoutMs: meta2.longRunning || meta2.carriesUpload ? null : timeout,
@@ -29630,6 +29451,19 @@ function createToolCaller(deps) {
29630
29451
  }
29631
29452
 
29632
29453
  // ../argent-mcp/src/mcp-server.ts
29454
+ var SAVES_FILES_AFTER_CANCEL = /* @__PURE__ */ new Set(["screen-recording-stop", "native-profiler-stop"]);
29455
+ async function withDeadline(signal, ms, work) {
29456
+ const deadline = new AbortController();
29457
+ const timer = setTimeout(
29458
+ () => deadline.abort(new DOMException("The operation was aborted due to timeout", "TimeoutError")),
29459
+ ms
29460
+ );
29461
+ try {
29462
+ return await work(AbortSignal.any([signal, deadline.signal]));
29463
+ } finally {
29464
+ clearTimeout(timer);
29465
+ }
29466
+ }
29633
29467
  async function startMcpServer(options) {
29634
29468
  if (shouldShowFirstRunNotice()) {
29635
29469
  process.stderr.write(`[argent] ${FIRST_RUN_NOTICE}
@@ -29686,7 +29520,7 @@ async function startMcpServer(options) {
29686
29520
  async function spyLog(entry) {
29687
29521
  try {
29688
29522
  if (!logDirReady) {
29689
- await mkdir5(dirname10(LOG_FILE2), { recursive: true });
29523
+ await mkdir5(dirname11(LOG_FILE2), { recursive: true });
29690
29524
  logDirReady = true;
29691
29525
  }
29692
29526
  await appendFile(LOG_FILE2, JSON.stringify(entry) + "\n");
@@ -29699,16 +29533,15 @@ async function startMcpServer(options) {
29699
29533
  reconnect,
29700
29534
  extraHeaders: aiClientHeaders
29701
29535
  });
29702
- async function awaitScreenSettled(udid, toolName) {
29536
+ async function awaitScreenSettled(udid, toolName, signal) {
29703
29537
  const maxWaitMs = getAutoScreenshotDelayMs(toolName);
29704
29538
  if (maxWaitMs === 0) return true;
29705
29539
  const started = Date.now();
29706
29540
  try {
29707
- const idle = await callTool(
29708
- "await-screen-idle",
29709
- { udid, timeoutMs: maxWaitMs },
29710
- // The tool bounds its poll to maxWaitMs; the rest covers its setup.
29711
- { signal: AbortSignal.timeout(maxWaitMs + captureTimeoutMs) }
29541
+ const idle = await withDeadline(
29542
+ signal,
29543
+ maxWaitMs + captureTimeoutMs,
29544
+ (s) => callTool("await-screen-idle", { udid, timeoutMs: maxWaitMs }, { signal: s })
29712
29545
  );
29713
29546
  await spyLog({
29714
29547
  ts: (/* @__PURE__ */ new Date()).toISOString(),
@@ -29719,7 +29552,10 @@ async function startMcpServer(options) {
29719
29552
  });
29720
29553
  return idle.result?.settled === true;
29721
29554
  } catch {
29722
- await new Promise((r) => setTimeout(r, Math.max(0, maxWaitMs - (Date.now() - started))));
29555
+ await sleep(Math.max(0, maxWaitMs - (Date.now() - started)), void 0, { signal }).catch(
29556
+ () => {
29557
+ }
29558
+ );
29723
29559
  return false;
29724
29560
  }
29725
29561
  }
@@ -29729,7 +29565,8 @@ async function startMcpServer(options) {
29729
29565
  const blocks = await toMcpContent(result, "image", {
29730
29566
  toolsUrl: TOOLS_URL,
29731
29567
  authToken: AUTH_TOKEN,
29732
- deviceId: udid
29568
+ deviceId: udid,
29569
+ signal
29733
29570
  });
29734
29571
  if (!blocks.some((b) => b.type === "image")) return [];
29735
29572
  return [{ type: "text", text: "--- Screen after action ---" }, ...blocks];
@@ -29774,10 +29611,10 @@ ${shown.text}` }];
29774
29611
  instructions: SERVER_INSTRUCTIONS
29775
29612
  }
29776
29613
  );
29777
- server.setRequestHandler(ListToolsRequestSchema, async () => {
29614
+ server.setRequestHandler(ListToolsRequestSchema, async (_request, { signal }) => {
29778
29615
  try {
29779
29616
  const keywordFacts = !showsSchemaKeywords(server.getClientVersion()?.name);
29780
- const tools = toMcpToolList(await fetchTools(), { keywordFacts });
29617
+ const tools = toMcpToolList(await fetchTools({ signal }), { keywordFacts });
29781
29618
  await spyLog({
29782
29619
  ts: (/* @__PURE__ */ new Date()).toISOString(),
29783
29620
  event: "list_tools",
@@ -29793,8 +29630,9 @@ ${shown.text}` }];
29793
29630
  return { tools: [] };
29794
29631
  }
29795
29632
  });
29796
- server.setRequestHandler(CallToolRequestSchema, async ({ params }, { signal: cancelled }) => {
29633
+ server.setRequestHandler(CallToolRequestSchema, async ({ params }, { signal }) => {
29797
29634
  const t0 = Date.now();
29635
+ const callSignal = SAVES_FILES_AFTER_CANCEL.has(canonicalToolId(params.name)) ? void 0 : signal;
29798
29636
  let treeUdid;
29799
29637
  await spyLog({
29800
29638
  ts: (/* @__PURE__ */ new Date()).toISOString(),
@@ -29803,7 +29641,11 @@ ${shown.text}` }];
29803
29641
  args: params.arguments
29804
29642
  });
29805
29643
  try {
29806
- const { result, outputHint, note, profiling } = await callTool(params.name, params.arguments);
29644
+ const { result, outputHint, note, profiling } = await callTool(
29645
+ params.name,
29646
+ params.arguments,
29647
+ { signal: callSignal }
29648
+ );
29807
29649
  await spyLog({
29808
29650
  ts: (/* @__PURE__ */ new Date()).toISOString(),
29809
29651
  event: "tool_result",
@@ -29815,7 +29657,8 @@ ${shown.text}` }];
29815
29657
  const ctx = {
29816
29658
  toolsUrl: TOOLS_URL,
29817
29659
  authToken: AUTH_TOKEN,
29818
- deviceId: getDeviceIdFromArgs(params.arguments)
29660
+ deviceId: getDeviceIdFromArgs(params.arguments),
29661
+ signal: callSignal
29819
29662
  };
29820
29663
  const devicesText = canonicalToolId(params.name) === "list-devices" ? listDevicesText(result) : void 0;
29821
29664
  let content;
@@ -29849,22 +29692,24 @@ ${shown.text}` }];
29849
29692
  ];
29850
29693
  } else if (udid && (wantScreenshot || wantTree) && profiling) {
29851
29694
  if (params.name !== "describe") {
29852
- await awaitScreenSettled(udid, params.name);
29695
+ await awaitScreenSettled(udid, params.name, signal);
29853
29696
  content = [...content, { type: "text", text: PROFILING_CAPTURE_SKIPPED_NOTE }];
29854
29697
  }
29855
29698
  } else if (udid && (wantScreenshot || wantTree)) {
29856
- const screenSettled = await awaitScreenSettled(udid, params.name);
29857
- const signal = AbortSignal.timeout(captureTimeoutMs);
29858
- const screenshot = wantScreenshot ? captureScreenshotBlocks(udid, signal) : Promise.resolve([]);
29859
- if (!screenSettled) await screenshot;
29699
+ const screenSettled = await awaitScreenSettled(udid, params.name, signal);
29860
29700
  if (wantTree) treeUdid = udid;
29861
- const tree = wantTree ? captureTreeBlocks(udid, params.name, signal) : Promise.resolve([]);
29862
- content = [...content, ...await screenshot, ...await tree];
29701
+ const captured = await withDeadline(signal, captureTimeoutMs, async (captureSignal) => {
29702
+ const screenshot = wantScreenshot ? captureScreenshotBlocks(udid, captureSignal) : Promise.resolve([]);
29703
+ if (!screenSettled) await screenshot;
29704
+ const tree = wantTree ? captureTreeBlocks(udid, params.name, captureSignal) : Promise.resolve([]);
29705
+ return [...await screenshot, ...await tree];
29706
+ });
29707
+ content = [...content, ...captured];
29863
29708
  }
29864
29709
  if (note) {
29865
29710
  content = [{ type: "text", text: note }, ...content];
29866
29711
  }
29867
- if (treeUdid !== void 0 && cancelled.aborted) trees.forget(treeUdid);
29712
+ if (treeUdid !== void 0 && signal.aborted) trees.forget(treeUdid);
29868
29713
  return { content };
29869
29714
  } catch (err) {
29870
29715
  if (treeUdid !== void 0) trees.forget(treeUdid);
@@ -29874,6 +29719,7 @@ ${shown.text}` }];
29874
29719
  name: params.name,
29875
29720
  durationMs: Date.now() - t0,
29876
29721
  isError: true,
29722
+ ...signal.aborted ? { cancelled: true } : {},
29877
29723
  error: String(err instanceof Error ? err.message : err)
29878
29724
  });
29879
29725
  return {