@swmansion/argent 0.34.1-next.7 → 0.34.1-next.70

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 (68) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +1 -1
  3. package/assets/argent.tracecfg.pbtxt +7 -1
  4. package/assets/ios-screen-stream/Info.plist +12 -0
  5. package/assets/ios-screen-stream/ios-screen-stream.swift +321 -0
  6. package/assets/trace-processor/engine_bundle.node.js +2074 -11121
  7. package/assets/trace-processor/trace_processor.wasm +0 -0
  8. package/bin/argent-android-devtools-0.4.0.apk +0 -0
  9. package/bin/darwin/argent-macos-helper +0 -0
  10. package/bin/darwin/ax-service +0 -0
  11. package/bin/darwin/simulator-server +0 -0
  12. package/bin/darwin/tvos-ax-service +0 -0
  13. package/bin/darwin/tvos-hid-daemon +0 -0
  14. package/bin/linux/simulator-server +0 -0
  15. package/bin/linux-arm64/simulator-server +0 -0
  16. package/bin/network-inspector/network-inspector.jar +0 -0
  17. package/bin/tcp/ax-service +0 -0
  18. package/bin/win32/simulator-server.exe +0 -0
  19. package/dist/cli-cmds.mjs +1259 -616
  20. package/dist/client.js +381 -180
  21. package/dist/flow-script-runner.mjs +1 -0
  22. package/dist/installer-help.js +4 -0
  23. package/dist/installer-help.js.map +1 -1
  24. package/dist/installer.mjs +1248 -898
  25. package/dist/ios-device-runner/ArgentRunner/ArgentRunner.xcodeproj/xcshareddata/xcschemes/ArgentRunner.xcscheme +1 -0
  26. package/dist/ios-device-runner/ArgentRunner/ArgentRunnerUITests/ArgentLaunchPerformanceTests.swift +21 -0
  27. package/dist/ios-device-runner/ArgentRunner/ArgentRunnerUITests/ArgentRunnerSession+Commands.swift +9 -3
  28. package/dist/ios-device-runner/ArgentRunner/ArgentRunnerUITests/ArgentRunnerSession.swift +3 -0
  29. package/dist/ios-device-runner/ArgentRunner/ArgentRunnerUITests/RunnerHTTPServer.swift +21 -9
  30. package/dist/mcp-server.mjs +2675 -715
  31. package/dist/preview-ui/index.html +28 -2
  32. package/dist/tool-args.generated.d.ts +101 -33
  33. package/dist/tool-server.cjs +15873 -6272
  34. package/dylibs/libArgentAudio.dylib +0 -0
  35. package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
  36. package/dylibs/libKeyboardPatch.dylib +0 -0
  37. package/dylibs/libNativeDevtoolsIos.dylib +0 -0
  38. package/dylibs/macos/libArgentInjectionBootstrap.dylib +0 -0
  39. package/dylibs/macos/libNativeDevtoolsMacos.dylib +0 -0
  40. package/dylibs/tcp/libArgentInjectionBootstrap.dylib +0 -0
  41. package/dylibs/tcp/libKeyboardPatch.dylib +0 -0
  42. package/dylibs/tcp/libNativeDevtoolsIos.dylib +0 -0
  43. package/dylibs/tvos/libArgentInjectionBootstrap.dylib +0 -0
  44. package/dylibs/tvos/libKeyboardPatch.dylib +0 -0
  45. package/dylibs/tvos/libNativeDevtoolsIos.dylib +0 -0
  46. package/package.json +1 -1
  47. package/rules/argent.md +6 -23
  48. package/skills/argent-android-emulator-setup/SKILL.md +4 -4
  49. package/skills/argent-create-e2e/SKILL.md +3 -0
  50. package/skills/argent-create-e2e/references/e2e-yaml.md +20 -2
  51. package/skills/argent-create-e2e/references/live-authoring.md +12 -1
  52. package/skills/argent-device-interact/SKILL.md +22 -21
  53. package/skills/argent-device-interact/references/foldables.md +22 -0
  54. package/skills/argent-ios-device-interact/SKILL.md +3 -3
  55. package/skills/argent-ios-device-setup/SKILL.md +4 -2
  56. package/skills/argent-macos-app-interact/SKILL.md +15 -5
  57. package/skills/argent-macos-app-interact/references/e2e.md +1 -1
  58. package/skills/argent-metro-debugger/SKILL.md +26 -14
  59. package/skills/argent-native-profiler/SKILL.md +14 -2
  60. package/skills/argent-qa-e2e/SKILL.md +1 -1
  61. package/skills/argent-react-native-app-workflow/SKILL.md +2 -2
  62. package/skills/argent-react-native-optimization/SKILL.md +10 -1
  63. package/skills/argent-react-native-optimization/references/fix-reference.md +10 -10
  64. package/skills/argent-react-native-profiler/SKILL.md +4 -3
  65. package/skills/argent-screen-recording/SKILL.md +6 -4
  66. package/skills/argent-screenshot-diff/SKILL.md +1 -1
  67. package/skills/argent-test-ui-flow/SKILL.md +1 -1
  68. package/skills/argent-tv-interact/SKILL.md +3 -3
package/dist/cli-cmds.mjs CHANGED
@@ -124,17 +124,17 @@ var require_visit = __commonJS({
124
124
  visit2.BREAK = BREAK;
125
125
  visit2.SKIP = SKIP;
126
126
  visit2.REMOVE = REMOVE;
127
- function visit_(key, node2, visitor, path25) {
128
- const ctrl = callVisitor(key, node2, visitor, path25);
127
+ function visit_(key, node2, visitor, path30) {
128
+ const ctrl = callVisitor(key, node2, visitor, path30);
129
129
  if (identity2.isNode(ctrl) || identity2.isPair(ctrl)) {
130
- replaceNode(key, path25, ctrl);
131
- return visit_(key, ctrl, visitor, path25);
130
+ replaceNode(key, path30, ctrl);
131
+ return visit_(key, ctrl, visitor, path30);
132
132
  }
133
133
  if (typeof ctrl !== "symbol") {
134
134
  if (identity2.isCollection(node2)) {
135
- path25 = Object.freeze(path25.concat(node2));
135
+ path30 = Object.freeze(path30.concat(node2));
136
136
  for (let i2 = 0; i2 < node2.items.length; ++i2) {
137
- const ci = visit_(i2, node2.items[i2], visitor, path25);
137
+ const ci = visit_(i2, node2.items[i2], visitor, path30);
138
138
  if (typeof ci === "number")
139
139
  i2 = ci - 1;
140
140
  else if (ci === BREAK)
@@ -145,13 +145,13 @@ var require_visit = __commonJS({
145
145
  }
146
146
  }
147
147
  } else if (identity2.isPair(node2)) {
148
- path25 = Object.freeze(path25.concat(node2));
149
- const ck = visit_("key", node2.key, visitor, path25);
148
+ path30 = Object.freeze(path30.concat(node2));
149
+ const ck = visit_("key", node2.key, visitor, path30);
150
150
  if (ck === BREAK)
151
151
  return BREAK;
152
152
  else if (ck === REMOVE)
153
153
  node2.key = null;
154
- const cv = visit_("value", node2.value, visitor, path25);
154
+ const cv = visit_("value", node2.value, visitor, path30);
155
155
  if (cv === BREAK)
156
156
  return BREAK;
157
157
  else if (cv === REMOVE)
@@ -172,17 +172,17 @@ var require_visit = __commonJS({
172
172
  visitAsync.BREAK = BREAK;
173
173
  visitAsync.SKIP = SKIP;
174
174
  visitAsync.REMOVE = REMOVE;
175
- async function visitAsync_(key, node2, visitor, path25) {
176
- const ctrl = await callVisitor(key, node2, visitor, path25);
175
+ async function visitAsync_(key, node2, visitor, path30) {
176
+ const ctrl = await callVisitor(key, node2, visitor, path30);
177
177
  if (identity2.isNode(ctrl) || identity2.isPair(ctrl)) {
178
- replaceNode(key, path25, ctrl);
179
- return visitAsync_(key, ctrl, visitor, path25);
178
+ replaceNode(key, path30, ctrl);
179
+ return visitAsync_(key, ctrl, visitor, path30);
180
180
  }
181
181
  if (typeof ctrl !== "symbol") {
182
182
  if (identity2.isCollection(node2)) {
183
- path25 = Object.freeze(path25.concat(node2));
183
+ path30 = Object.freeze(path30.concat(node2));
184
184
  for (let i2 = 0; i2 < node2.items.length; ++i2) {
185
- const ci = await visitAsync_(i2, node2.items[i2], visitor, path25);
185
+ const ci = await visitAsync_(i2, node2.items[i2], visitor, path30);
186
186
  if (typeof ci === "number")
187
187
  i2 = ci - 1;
188
188
  else if (ci === BREAK)
@@ -193,13 +193,13 @@ var require_visit = __commonJS({
193
193
  }
194
194
  }
195
195
  } else if (identity2.isPair(node2)) {
196
- path25 = Object.freeze(path25.concat(node2));
197
- const ck = await visitAsync_("key", node2.key, visitor, path25);
196
+ path30 = Object.freeze(path30.concat(node2));
197
+ const ck = await visitAsync_("key", node2.key, visitor, path30);
198
198
  if (ck === BREAK)
199
199
  return BREAK;
200
200
  else if (ck === REMOVE)
201
201
  node2.key = null;
202
- const cv = await visitAsync_("value", node2.value, visitor, path25);
202
+ const cv = await visitAsync_("value", node2.value, visitor, path30);
203
203
  if (cv === BREAK)
204
204
  return BREAK;
205
205
  else if (cv === REMOVE)
@@ -226,23 +226,23 @@ var require_visit = __commonJS({
226
226
  }
227
227
  return visitor;
228
228
  }
229
- function callVisitor(key, node2, visitor, path25) {
229
+ function callVisitor(key, node2, visitor, path30) {
230
230
  if (typeof visitor === "function")
231
- return visitor(key, node2, path25);
231
+ return visitor(key, node2, path30);
232
232
  if (identity2.isMap(node2))
233
- return visitor.Map?.(key, node2, path25);
233
+ return visitor.Map?.(key, node2, path30);
234
234
  if (identity2.isSeq(node2))
235
- return visitor.Seq?.(key, node2, path25);
235
+ return visitor.Seq?.(key, node2, path30);
236
236
  if (identity2.isPair(node2))
237
- return visitor.Pair?.(key, node2, path25);
237
+ return visitor.Pair?.(key, node2, path30);
238
238
  if (identity2.isScalar(node2))
239
- return visitor.Scalar?.(key, node2, path25);
239
+ return visitor.Scalar?.(key, node2, path30);
240
240
  if (identity2.isAlias(node2))
241
- return visitor.Alias?.(key, node2, path25);
241
+ return visitor.Alias?.(key, node2, path30);
242
242
  return void 0;
243
243
  }
244
- function replaceNode(key, path25, node2) {
245
- const parent = path25[path25.length - 1];
244
+ function replaceNode(key, path30, node2) {
245
+ const parent = path30[path30.length - 1];
246
246
  if (identity2.isCollection(parent)) {
247
247
  parent.items[key] = node2;
248
248
  } else if (identity2.isPair(parent)) {
@@ -854,10 +854,10 @@ var require_Collection = __commonJS({
854
854
  var createNode = require_createNode();
855
855
  var identity2 = require_identity();
856
856
  var Node = require_Node();
857
- function collectionFromPath(schema, path25, value) {
857
+ function collectionFromPath(schema, path30, value) {
858
858
  let v = value;
859
- for (let i2 = path25.length - 1; i2 >= 0; --i2) {
860
- const k = path25[i2];
859
+ for (let i2 = path30.length - 1; i2 >= 0; --i2) {
860
+ const k = path30[i2];
861
861
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
862
862
  const a2 = [];
863
863
  a2[k] = v;
@@ -876,7 +876,7 @@ var require_Collection = __commonJS({
876
876
  sourceObjects: /* @__PURE__ */ new Map()
877
877
  });
878
878
  }
879
- var isEmptyPath = (path25) => path25 == null || typeof path25 === "object" && !!path25[Symbol.iterator]().next().done;
879
+ var isEmptyPath = (path30) => path30 == null || typeof path30 === "object" && !!path30[Symbol.iterator]().next().done;
880
880
  var Collection = class extends Node.NodeBase {
881
881
  constructor(type, schema) {
882
882
  super(type);
@@ -906,11 +906,11 @@ var require_Collection = __commonJS({
906
906
  * be a Pair instance or a `{ key, value }` object, which may not have a key
907
907
  * that already exists in the map.
908
908
  */
909
- addIn(path25, value) {
910
- if (isEmptyPath(path25))
909
+ addIn(path30, value) {
910
+ if (isEmptyPath(path30))
911
911
  this.add(value);
912
912
  else {
913
- const [key, ...rest] = path25;
913
+ const [key, ...rest] = path30;
914
914
  const node2 = this.get(key, true);
915
915
  if (identity2.isCollection(node2))
916
916
  node2.addIn(rest, value);
@@ -924,8 +924,8 @@ var require_Collection = __commonJS({
924
924
  * Removes a value from the collection.
925
925
  * @returns `true` if the item was found and removed.
926
926
  */
927
- deleteIn(path25) {
928
- const [key, ...rest] = path25;
927
+ deleteIn(path30) {
928
+ const [key, ...rest] = path30;
929
929
  if (rest.length === 0)
930
930
  return this.delete(key);
931
931
  const node2 = this.get(key, true);
@@ -939,8 +939,8 @@ var require_Collection = __commonJS({
939
939
  * scalar values from their surrounding node; to disable set `keepScalar` to
940
940
  * `true` (collections are always returned intact).
941
941
  */
942
- getIn(path25, keepScalar) {
943
- const [key, ...rest] = path25;
942
+ getIn(path30, keepScalar) {
943
+ const [key, ...rest] = path30;
944
944
  const node2 = this.get(key, true);
945
945
  if (rest.length === 0)
946
946
  return !keepScalar && identity2.isScalar(node2) ? node2.value : node2;
@@ -958,8 +958,8 @@ var require_Collection = __commonJS({
958
958
  /**
959
959
  * Checks if the collection includes a value with the key `key`.
960
960
  */
961
- hasIn(path25) {
962
- const [key, ...rest] = path25;
961
+ hasIn(path30) {
962
+ const [key, ...rest] = path30;
963
963
  if (rest.length === 0)
964
964
  return this.has(key);
965
965
  const node2 = this.get(key, true);
@@ -969,8 +969,8 @@ var require_Collection = __commonJS({
969
969
  * Sets a value in this collection. For `!!set`, `value` needs to be a
970
970
  * boolean to add/remove the item from the set.
971
971
  */
972
- setIn(path25, value) {
973
- const [key, ...rest] = path25;
972
+ setIn(path30, value) {
973
+ const [key, ...rest] = path30;
974
974
  if (rest.length === 0) {
975
975
  this.set(key, value);
976
976
  } else {
@@ -3485,9 +3485,9 @@ var require_Document = __commonJS({
3485
3485
  this.contents.add(value);
3486
3486
  }
3487
3487
  /** Adds a value to the document. */
3488
- addIn(path25, value) {
3488
+ addIn(path30, value) {
3489
3489
  if (assertCollection(this.contents))
3490
- this.contents.addIn(path25, value);
3490
+ this.contents.addIn(path30, value);
3491
3491
  }
3492
3492
  /**
3493
3493
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -3562,14 +3562,14 @@ var require_Document = __commonJS({
3562
3562
  * Removes a value from the document.
3563
3563
  * @returns `true` if the item was found and removed.
3564
3564
  */
3565
- deleteIn(path25) {
3566
- if (Collection.isEmptyPath(path25)) {
3565
+ deleteIn(path30) {
3566
+ if (Collection.isEmptyPath(path30)) {
3567
3567
  if (this.contents == null)
3568
3568
  return false;
3569
3569
  this.contents = null;
3570
3570
  return true;
3571
3571
  }
3572
- return assertCollection(this.contents) ? this.contents.deleteIn(path25) : false;
3572
+ return assertCollection(this.contents) ? this.contents.deleteIn(path30) : false;
3573
3573
  }
3574
3574
  /**
3575
3575
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -3584,10 +3584,10 @@ var require_Document = __commonJS({
3584
3584
  * scalar values from their surrounding node; to disable set `keepScalar` to
3585
3585
  * `true` (collections are always returned intact).
3586
3586
  */
3587
- getIn(path25, keepScalar) {
3588
- if (Collection.isEmptyPath(path25))
3587
+ getIn(path30, keepScalar) {
3588
+ if (Collection.isEmptyPath(path30))
3589
3589
  return !keepScalar && identity2.isScalar(this.contents) ? this.contents.value : this.contents;
3590
- return identity2.isCollection(this.contents) ? this.contents.getIn(path25, keepScalar) : void 0;
3590
+ return identity2.isCollection(this.contents) ? this.contents.getIn(path30, keepScalar) : void 0;
3591
3591
  }
3592
3592
  /**
3593
3593
  * Checks if the document includes a value with the key `key`.
@@ -3598,10 +3598,10 @@ var require_Document = __commonJS({
3598
3598
  /**
3599
3599
  * Checks if the document includes a value at `path`.
3600
3600
  */
3601
- hasIn(path25) {
3602
- if (Collection.isEmptyPath(path25))
3601
+ hasIn(path30) {
3602
+ if (Collection.isEmptyPath(path30))
3603
3603
  return this.contents !== void 0;
3604
- return identity2.isCollection(this.contents) ? this.contents.hasIn(path25) : false;
3604
+ return identity2.isCollection(this.contents) ? this.contents.hasIn(path30) : false;
3605
3605
  }
3606
3606
  /**
3607
3607
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -3618,13 +3618,13 @@ var require_Document = __commonJS({
3618
3618
  * Sets a value in this document. For `!!set`, `value` needs to be a
3619
3619
  * boolean to add/remove the item from the set.
3620
3620
  */
3621
- setIn(path25, value) {
3622
- if (Collection.isEmptyPath(path25)) {
3621
+ setIn(path30, value) {
3622
+ if (Collection.isEmptyPath(path30)) {
3623
3623
  this.contents = value;
3624
3624
  } else if (this.contents == null) {
3625
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path25), value);
3625
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path30), value);
3626
3626
  } else if (assertCollection(this.contents)) {
3627
- this.contents.setIn(path25, value);
3627
+ this.contents.setIn(path30, value);
3628
3628
  }
3629
3629
  }
3630
3630
  /**
@@ -4010,10 +4010,10 @@ var require_resolve_block_map = __commonJS({
4010
4010
  let offset = bm.offset;
4011
4011
  let commentEnd = null;
4012
4012
  for (const collItem of bm.items) {
4013
- const { start, key, sep: sep6, value } = collItem;
4013
+ const { start, key, sep: sep7, value } = collItem;
4014
4014
  const keyProps = resolveProps.resolveProps(start, {
4015
4015
  indicator: "explicit-key-ind",
4016
- next: key ?? sep6?.[0],
4016
+ next: key ?? sep7?.[0],
4017
4017
  offset,
4018
4018
  onError,
4019
4019
  parentIndent: bm.indent,
@@ -4027,7 +4027,7 @@ var require_resolve_block_map = __commonJS({
4027
4027
  else if ("indent" in key && key.indent !== bm.indent)
4028
4028
  onError(offset, "BAD_INDENT", startColMsg);
4029
4029
  }
4030
- if (!keyProps.anchor && !keyProps.tag && !sep6) {
4030
+ if (!keyProps.anchor && !keyProps.tag && !sep7) {
4031
4031
  commentEnd = keyProps.end;
4032
4032
  if (keyProps.comment) {
4033
4033
  if (map2.comment)
@@ -4051,7 +4051,7 @@ var require_resolve_block_map = __commonJS({
4051
4051
  ctx.atKey = false;
4052
4052
  if (utilMapIncludes.mapIncludes(ctx, map2.items, keyNode))
4053
4053
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
4054
- const valueProps = resolveProps.resolveProps(sep6 ?? [], {
4054
+ const valueProps = resolveProps.resolveProps(sep7 ?? [], {
4055
4055
  indicator: "map-value-ind",
4056
4056
  next: value,
4057
4057
  offset: keyNode.range[2],
@@ -4067,7 +4067,7 @@ var require_resolve_block_map = __commonJS({
4067
4067
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
4068
4068
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
4069
4069
  }
4070
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep6, null, valueProps, onError);
4070
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep7, null, valueProps, onError);
4071
4071
  if (ctx.schema.compat)
4072
4072
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
4073
4073
  offset = valueNode.range[2];
@@ -4158,7 +4158,7 @@ var require_resolve_end = __commonJS({
4158
4158
  let comment = "";
4159
4159
  if (end) {
4160
4160
  let hasSpace = false;
4161
- let sep6 = "";
4161
+ let sep7 = "";
4162
4162
  for (const token of end) {
4163
4163
  const { source, type } = token;
4164
4164
  switch (type) {
@@ -4172,13 +4172,13 @@ var require_resolve_end = __commonJS({
4172
4172
  if (!comment)
4173
4173
  comment = cb;
4174
4174
  else
4175
- comment += sep6 + cb;
4176
- sep6 = "";
4175
+ comment += sep7 + cb;
4176
+ sep7 = "";
4177
4177
  break;
4178
4178
  }
4179
4179
  case "newline":
4180
4180
  if (comment)
4181
- sep6 += source;
4181
+ sep7 += source;
4182
4182
  hasSpace = true;
4183
4183
  break;
4184
4184
  default:
@@ -4221,18 +4221,18 @@ var require_resolve_flow_collection = __commonJS({
4221
4221
  let offset = fc.offset + fc.start.source.length;
4222
4222
  for (let i2 = 0; i2 < fc.items.length; ++i2) {
4223
4223
  const collItem = fc.items[i2];
4224
- const { start, key, sep: sep6, value } = collItem;
4224
+ const { start, key, sep: sep7, value } = collItem;
4225
4225
  const props = resolveProps.resolveProps(start, {
4226
4226
  flow: fcName,
4227
4227
  indicator: "explicit-key-ind",
4228
- next: key ?? sep6?.[0],
4228
+ next: key ?? sep7?.[0],
4229
4229
  offset,
4230
4230
  onError,
4231
4231
  parentIndent: fc.indent,
4232
4232
  startOnNewline: false
4233
4233
  });
4234
4234
  if (!props.found) {
4235
- if (!props.anchor && !props.tag && !sep6 && !value) {
4235
+ if (!props.anchor && !props.tag && !sep7 && !value) {
4236
4236
  if (i2 === 0 && props.comma)
4237
4237
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
4238
4238
  else if (i2 < fc.items.length - 1)
@@ -4286,8 +4286,8 @@ var require_resolve_flow_collection = __commonJS({
4286
4286
  }
4287
4287
  }
4288
4288
  }
4289
- if (!isMap && !sep6 && !props.found) {
4290
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep6, null, props, onError);
4289
+ if (!isMap && !sep7 && !props.found) {
4290
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep7, null, props, onError);
4291
4291
  coll.items.push(valueNode);
4292
4292
  offset = valueNode.range[2];
4293
4293
  if (isBlock(value))
@@ -4299,7 +4299,7 @@ var require_resolve_flow_collection = __commonJS({
4299
4299
  if (isBlock(key))
4300
4300
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
4301
4301
  ctx.atKey = false;
4302
- const valueProps = resolveProps.resolveProps(sep6 ?? [], {
4302
+ const valueProps = resolveProps.resolveProps(sep7 ?? [], {
4303
4303
  flow: fcName,
4304
4304
  indicator: "map-value-ind",
4305
4305
  next: value,
@@ -4310,8 +4310,8 @@ var require_resolve_flow_collection = __commonJS({
4310
4310
  });
4311
4311
  if (valueProps.found) {
4312
4312
  if (!isMap && !props.found && ctx.options.strict) {
4313
- if (sep6)
4314
- for (const st of sep6) {
4313
+ if (sep7)
4314
+ for (const st of sep7) {
4315
4315
  if (st === valueProps.found)
4316
4316
  break;
4317
4317
  if (st.type === "newline") {
@@ -4328,7 +4328,7 @@ var require_resolve_flow_collection = __commonJS({
4328
4328
  else
4329
4329
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
4330
4330
  }
4331
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep6, null, valueProps, onError) : null;
4331
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep7, null, valueProps, onError) : null;
4332
4332
  if (valueNode) {
4333
4333
  if (isBlock(value))
4334
4334
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -4508,7 +4508,7 @@ var require_resolve_block_scalar = __commonJS({
4508
4508
  chompStart = i2 + 1;
4509
4509
  }
4510
4510
  let value = "";
4511
- let sep6 = "";
4511
+ let sep7 = "";
4512
4512
  let prevMoreIndented = false;
4513
4513
  for (let i2 = 0; i2 < contentStart; ++i2)
4514
4514
  value += lines[i2][0].slice(trimIndent) + "\n";
@@ -4525,24 +4525,24 @@ var require_resolve_block_scalar = __commonJS({
4525
4525
  indent = "";
4526
4526
  }
4527
4527
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
4528
- value += sep6 + indent.slice(trimIndent) + content;
4529
- sep6 = "\n";
4528
+ value += sep7 + indent.slice(trimIndent) + content;
4529
+ sep7 = "\n";
4530
4530
  } else if (indent.length > trimIndent || content[0] === " ") {
4531
- if (sep6 === " ")
4532
- sep6 = "\n";
4533
- else if (!prevMoreIndented && sep6 === "\n")
4534
- sep6 = "\n\n";
4535
- value += sep6 + indent.slice(trimIndent) + content;
4536
- sep6 = "\n";
4531
+ if (sep7 === " ")
4532
+ sep7 = "\n";
4533
+ else if (!prevMoreIndented && sep7 === "\n")
4534
+ sep7 = "\n\n";
4535
+ value += sep7 + indent.slice(trimIndent) + content;
4536
+ sep7 = "\n";
4537
4537
  prevMoreIndented = true;
4538
4538
  } else if (content === "") {
4539
- if (sep6 === "\n")
4539
+ if (sep7 === "\n")
4540
4540
  value += "\n";
4541
4541
  else
4542
- sep6 = "\n";
4542
+ sep7 = "\n";
4543
4543
  } else {
4544
- value += sep6 + content;
4545
- sep6 = " ";
4544
+ value += sep7 + content;
4545
+ sep7 = " ";
4546
4546
  prevMoreIndented = false;
4547
4547
  }
4548
4548
  }
@@ -4725,25 +4725,25 @@ var require_resolve_flow_scalar = __commonJS({
4725
4725
  trimBoth = /^[ \t]+|[ \t]+$/g;
4726
4726
  }
4727
4727
  let res = match[1].replace(trimEnd, "");
4728
- let sep6 = " ";
4728
+ let sep7 = " ";
4729
4729
  let pos = line.lastIndex;
4730
4730
  while (match = line.exec(source)) {
4731
4731
  const lm = match[1].replace(trimBoth, "");
4732
4732
  if (lm === "") {
4733
- if (sep6 === "\n")
4734
- res += sep6;
4733
+ if (sep7 === "\n")
4734
+ res += sep7;
4735
4735
  else
4736
- sep6 = "\n";
4736
+ sep7 = "\n";
4737
4737
  } else {
4738
- res += sep6 + lm;
4739
- sep6 = " ";
4738
+ res += sep7 + lm;
4739
+ sep7 = " ";
4740
4740
  }
4741
4741
  pos = line.lastIndex;
4742
4742
  }
4743
4743
  const last = /[ \t]*(.*)/sy;
4744
4744
  last.lastIndex = pos;
4745
4745
  match = last.exec(source);
4746
- return res + sep6 + (match?.[1] ?? "");
4746
+ return res + sep7 + (match?.[1] ?? "");
4747
4747
  }
4748
4748
  function doubleQuotedValue(source, onError) {
4749
4749
  let res = "";
@@ -5553,14 +5553,14 @@ var require_cst_stringify = __commonJS({
5553
5553
  }
5554
5554
  }
5555
5555
  }
5556
- function stringifyItem({ start, key, sep: sep6, value }) {
5556
+ function stringifyItem({ start, key, sep: sep7, value }) {
5557
5557
  let res = "";
5558
5558
  for (const st of start)
5559
5559
  res += st.source;
5560
5560
  if (key)
5561
5561
  res += stringifyToken(key);
5562
- if (sep6)
5563
- for (const st of sep6)
5562
+ if (sep7)
5563
+ for (const st of sep7)
5564
5564
  res += st.source;
5565
5565
  if (value)
5566
5566
  res += stringifyToken(value);
@@ -5585,9 +5585,9 @@ var require_cst_visit = __commonJS({
5585
5585
  visit2.BREAK = BREAK;
5586
5586
  visit2.SKIP = SKIP;
5587
5587
  visit2.REMOVE = REMOVE;
5588
- visit2.itemAtPath = (cst, path25) => {
5588
+ visit2.itemAtPath = (cst, path30) => {
5589
5589
  let item = cst;
5590
- for (const [field, index] of path25) {
5590
+ for (const [field, index] of path30) {
5591
5591
  const tok = item?.[field];
5592
5592
  if (tok && "items" in tok) {
5593
5593
  item = tok.items[index];
@@ -5596,23 +5596,23 @@ var require_cst_visit = __commonJS({
5596
5596
  }
5597
5597
  return item;
5598
5598
  };
5599
- visit2.parentCollection = (cst, path25) => {
5600
- const parent = visit2.itemAtPath(cst, path25.slice(0, -1));
5601
- const field = path25[path25.length - 1][0];
5599
+ visit2.parentCollection = (cst, path30) => {
5600
+ const parent = visit2.itemAtPath(cst, path30.slice(0, -1));
5601
+ const field = path30[path30.length - 1][0];
5602
5602
  const coll = parent?.[field];
5603
5603
  if (coll && "items" in coll)
5604
5604
  return coll;
5605
5605
  throw new Error("Parent collection not found");
5606
5606
  };
5607
- function _visit(path25, item, visitor) {
5608
- let ctrl = visitor(item, path25);
5607
+ function _visit(path30, item, visitor) {
5608
+ let ctrl = visitor(item, path30);
5609
5609
  if (typeof ctrl === "symbol")
5610
5610
  return ctrl;
5611
5611
  for (const field of ["key", "value"]) {
5612
5612
  const token = item[field];
5613
5613
  if (token && "items" in token) {
5614
5614
  for (let i2 = 0; i2 < token.items.length; ++i2) {
5615
- const ci = _visit(Object.freeze(path25.concat([[field, i2]])), token.items[i2], visitor);
5615
+ const ci = _visit(Object.freeze(path30.concat([[field, i2]])), token.items[i2], visitor);
5616
5616
  if (typeof ci === "number")
5617
5617
  i2 = ci - 1;
5618
5618
  else if (ci === BREAK)
@@ -5623,10 +5623,10 @@ var require_cst_visit = __commonJS({
5623
5623
  }
5624
5624
  }
5625
5625
  if (typeof ctrl === "function" && field === "key")
5626
- ctrl = ctrl(item, path25);
5626
+ ctrl = ctrl(item, path30);
5627
5627
  }
5628
5628
  }
5629
- return typeof ctrl === "function" ? ctrl(item, path25) : ctrl;
5629
+ return typeof ctrl === "function" ? ctrl(item, path30) : ctrl;
5630
5630
  }
5631
5631
  exports.visit = visit2;
5632
5632
  }
@@ -6727,18 +6727,18 @@ var require_parser = __commonJS({
6727
6727
  if (this.type === "map-value-ind") {
6728
6728
  const prev = getPrevProps(this.peek(2));
6729
6729
  const start = getFirstKeyStartProps(prev);
6730
- let sep6;
6730
+ let sep7;
6731
6731
  if (scalar.end) {
6732
- sep6 = scalar.end;
6733
- sep6.push(this.sourceToken);
6732
+ sep7 = scalar.end;
6733
+ sep7.push(this.sourceToken);
6734
6734
  delete scalar.end;
6735
6735
  } else
6736
- sep6 = [this.sourceToken];
6736
+ sep7 = [this.sourceToken];
6737
6737
  const map2 = {
6738
6738
  type: "block-map",
6739
6739
  offset: scalar.offset,
6740
6740
  indent: scalar.indent,
6741
- items: [{ start, key: scalar, sep: sep6 }]
6741
+ items: [{ start, key: scalar, sep: sep7 }]
6742
6742
  };
6743
6743
  this.onKeyLine = true;
6744
6744
  this.stack[this.stack.length - 1] = map2;
@@ -6891,15 +6891,15 @@ var require_parser = __commonJS({
6891
6891
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
6892
6892
  const start2 = getFirstKeyStartProps(it.start);
6893
6893
  const key = it.key;
6894
- const sep6 = it.sep;
6895
- sep6.push(this.sourceToken);
6894
+ const sep7 = it.sep;
6895
+ sep7.push(this.sourceToken);
6896
6896
  delete it.key;
6897
6897
  delete it.sep;
6898
6898
  this.stack.push({
6899
6899
  type: "block-map",
6900
6900
  offset: this.offset,
6901
6901
  indent: this.indent,
6902
- items: [{ start: start2, key, sep: sep6 }]
6902
+ items: [{ start: start2, key, sep: sep7 }]
6903
6903
  });
6904
6904
  } else if (start.length > 0) {
6905
6905
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -6928,14 +6928,14 @@ var require_parser = __commonJS({
6928
6928
  case "scalar":
6929
6929
  case "single-quoted-scalar":
6930
6930
  case "double-quoted-scalar": {
6931
- const fs19 = this.flowScalar(this.type);
6931
+ const fs20 = this.flowScalar(this.type);
6932
6932
  if (atNextItem || it.value) {
6933
- map2.items.push({ start, key: fs19, sep: [] });
6933
+ map2.items.push({ start, key: fs20, sep: [] });
6934
6934
  this.onKeyLine = true;
6935
6935
  } else if (it.sep) {
6936
- this.stack.push(fs19);
6936
+ this.stack.push(fs20);
6937
6937
  } else {
6938
- Object.assign(it, { key: fs19, sep: [] });
6938
+ Object.assign(it, { key: fs20, sep: [] });
6939
6939
  this.onKeyLine = true;
6940
6940
  }
6941
6941
  return;
@@ -7063,13 +7063,13 @@ var require_parser = __commonJS({
7063
7063
  case "scalar":
7064
7064
  case "single-quoted-scalar":
7065
7065
  case "double-quoted-scalar": {
7066
- const fs19 = this.flowScalar(this.type);
7066
+ const fs20 = this.flowScalar(this.type);
7067
7067
  if (!it || it.value)
7068
- fc.items.push({ start: [], key: fs19, sep: [] });
7068
+ fc.items.push({ start: [], key: fs20, sep: [] });
7069
7069
  else if (it.sep)
7070
- this.stack.push(fs19);
7070
+ this.stack.push(fs20);
7071
7071
  else
7072
- Object.assign(it, { key: fs19, sep: [] });
7072
+ Object.assign(it, { key: fs20, sep: [] });
7073
7073
  return;
7074
7074
  }
7075
7075
  case "flow-map-end":
@@ -7093,13 +7093,13 @@ var require_parser = __commonJS({
7093
7093
  const prev = getPrevProps(parent);
7094
7094
  const start = getFirstKeyStartProps(prev);
7095
7095
  fixFlowSeqItems(fc);
7096
- const sep6 = fc.end.splice(1, fc.end.length);
7097
- sep6.push(this.sourceToken);
7096
+ const sep7 = fc.end.splice(1, fc.end.length);
7097
+ sep7.push(this.sourceToken);
7098
7098
  const map2 = {
7099
7099
  type: "block-map",
7100
7100
  offset: fc.offset,
7101
7101
  indent: fc.indent,
7102
- items: [{ start, key: fc, sep: sep6 }]
7102
+ items: [{ start, key: fc, sep: sep7 }]
7103
7103
  };
7104
7104
  this.onKeyLine = true;
7105
7105
  this.stack[this.stack.length - 1] = map2;
@@ -7277,7 +7277,7 @@ var require_public_api = __commonJS({
7277
7277
  }
7278
7278
  return doc;
7279
7279
  }
7280
- function parse3(src, reviver, options) {
7280
+ function parse4(src, reviver, options) {
7281
7281
  let _reviver = void 0;
7282
7282
  if (typeof reviver === "function") {
7283
7283
  _reviver = reviver;
@@ -7318,7 +7318,7 @@ var require_public_api = __commonJS({
7318
7318
  return value.toString(options);
7319
7319
  return new Document.Document(value, _replacer, options).toString(options);
7320
7320
  }
7321
- exports.parse = parse3;
7321
+ exports.parse = parse4;
7322
7322
  exports.parseAllDocuments = parseAllDocuments;
7323
7323
  exports.parseDocument = parseDocument;
7324
7324
  exports.stringify = stringify;
@@ -8916,8 +8916,8 @@ var require_src = __commonJS({
8916
8916
  });
8917
8917
 
8918
8918
  // ../argent-cli/src/run.ts
8919
- import * as fs12 from "node:fs";
8920
- import * as path18 from "node:path";
8919
+ import * as fs13 from "node:fs";
8920
+ import * as path20 from "node:path";
8921
8921
 
8922
8922
  // ../argent-tools-client/src/launcher.ts
8923
8923
  import * as net from "node:net";
@@ -8935,6 +8935,7 @@ var LOCK_FILE = path.join(STATE_DIR, "tool-server.lock");
8935
8935
  var AUTH_TOKEN_BYTES = 32;
8936
8936
  var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
8937
8937
  var AUTOSPAWN_IDLE_TIMEOUT_MINUTES = 30;
8938
+ var AUTOSPAWN_HOST = "127.0.0.1";
8938
8939
  function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
8939
8940
  const env = {
8940
8941
  ...baseEnv,
@@ -8946,7 +8947,7 @@ function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
8946
8947
  if (options.idleTimeoutMinutes !== void 0) {
8947
8948
  env.ARGENT_IDLE_TIMEOUT_MINUTES = String(options.idleTimeoutMinutes);
8948
8949
  }
8949
- if (options.token) env[AUTH_TOKEN_ENV] = options.token;
8950
+ env[AUTH_TOKEN_ENV] = options.token ?? "";
8950
8951
  if (paths.installKind) env.ARGENT_INSTALL_KIND = paths.installKind;
8951
8952
  if (paths.installProjectRoot) env.ARGENT_PROJECT_ROOT = paths.installProjectRoot;
8952
8953
  return env;
@@ -8958,7 +8959,7 @@ function generateAuthToken() {
8958
8959
  return generateToken();
8959
8960
  }
8960
8961
  function findFreePort() {
8961
- return new Promise((resolve13, reject) => {
8962
+ return new Promise((resolve14, reject) => {
8962
8963
  const srv = net.createServer();
8963
8964
  srv.listen(0, "127.0.0.1", () => {
8964
8965
  const addr = srv.address();
@@ -8969,21 +8970,21 @@ function findFreePort() {
8969
8970
  const port = addr.port;
8970
8971
  srv.close((err) => {
8971
8972
  if (err) reject(err);
8972
- else resolve13(port);
8973
+ else resolve14(port);
8973
8974
  });
8974
8975
  });
8975
8976
  srv.on("error", reject);
8976
8977
  });
8977
8978
  }
8978
8979
  function isVersionNewer(a2, b) {
8979
- const parse3 = (v) => {
8980
+ const parse4 = (v) => {
8980
8981
  const [core = "", ...preParts] = v.split("+")[0].split("-");
8981
8982
  const nums = core.split(".").map((n3) => Number.parseInt(n3, 10));
8982
8983
  if (nums.length === 0 || nums.some((n3) => Number.isNaN(n3))) return null;
8983
8984
  return { nums, pre: preParts.length > 0 ? preParts.join("-").split(".") : [] };
8984
8985
  };
8985
- const pa = parse3(a2);
8986
- const pb = parse3(b);
8986
+ const pa = parse4(a2);
8987
+ const pb = parse4(b);
8987
8988
  if (!pa || !pb) return false;
8988
8989
  for (let i2 = 0; i2 < 3; i2++) {
8989
8990
  const x = pa.nums[i2] ?? 0;
@@ -9069,8 +9070,12 @@ function killSpawnedChild(child, pid) {
9069
9070
  }
9070
9071
  }
9071
9072
  }
9073
+ function resolveToolsServerNode() {
9074
+ const { bun, deno, electron } = process.versions;
9075
+ return !(bun || deno || electron) && fs.existsSync(process.execPath) ? process.execPath : "node";
9076
+ }
9072
9077
  function spawnToolsServer(paths, port, options = {}) {
9073
- return new Promise((resolve13, reject) => {
9078
+ return new Promise((resolve14, reject) => {
9074
9079
  let logFd;
9075
9080
  try {
9076
9081
  fs.mkdirSync(STATE_DIR, { recursive: true });
@@ -9078,8 +9083,7 @@ function spawnToolsServer(paths, port, options = {}) {
9078
9083
  } catch {
9079
9084
  logFd = fs.openSync("/dev/null", "w");
9080
9085
  }
9081
- const { bun, deno, electron } = process.versions;
9082
- const nodeBin = !(bun || deno || electron) && fs.existsSync(process.execPath) ? process.execPath : "node";
9086
+ const nodeBin = resolveToolsServerNode();
9083
9087
  const child = spawn(nodeBin, [paths.bundlePath, "start"], {
9084
9088
  detached: true,
9085
9089
  stdio: ["ignore", "pipe", logFd],
@@ -9117,7 +9121,7 @@ function spawnToolsServer(paths, port, options = {}) {
9117
9121
  rl.close();
9118
9122
  child.stdout?.resume();
9119
9123
  child.stdout?.unref?.();
9120
- settle2(() => resolve13({ port: actualPort, pid }));
9124
+ settle2(() => resolve14({ port: actualPort, pid }));
9121
9125
  }
9122
9126
  });
9123
9127
  child.on("error", (err) => {
@@ -9412,6 +9416,7 @@ async function ensureToolsServer(paths) {
9412
9416
  const port = await findFreePort();
9413
9417
  const { port: actualPort, pid } = await spawnToolsServer(paths, port, {
9414
9418
  token,
9419
+ host: AUTOSPAWN_HOST,
9415
9420
  idleTimeoutMinutes: AUTOSPAWN_IDLE_TIMEOUT_MINUTES
9416
9421
  });
9417
9422
  await writeState({
@@ -9420,11 +9425,11 @@ async function ensureToolsServer(paths) {
9420
9425
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
9421
9426
  bundlePath: paths.bundlePath,
9422
9427
  version: diskVersion,
9423
- host: "127.0.0.1",
9428
+ host: AUTOSPAWN_HOST,
9424
9429
  token,
9425
9430
  managed: "autospawn"
9426
9431
  });
9427
- return { url: formatUrl("127.0.0.1", actualPort), token };
9432
+ return { url: formatUrl(AUTOSPAWN_HOST, actualPort), token };
9428
9433
  } finally {
9429
9434
  lock?.release();
9430
9435
  }
@@ -9477,14 +9482,24 @@ var FLAG_REGISTRY = [
9477
9482
  name: "forward-secrets",
9478
9483
  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."
9479
9484
  },
9485
+ {
9486
+ name: "ios-audio-always-inserted",
9487
+ 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.",
9488
+ defaultEnabled: true
9489
+ },
9480
9490
  {
9481
9491
  name: "video-watermark",
9482
9492
  description: "Overlay the argent corner watermark on recorded screen videos. On by default; turn it off with `argent disable video-watermark`.",
9483
9493
  defaultEnabled: true
9484
9494
  },
9495
+ {
9496
+ name: "whats-new",
9497
+ description: "After an update, tell the agent the highlights of the new Argent version on its first tool call. On by default; turn it off with `argent disable whats-new`.",
9498
+ defaultEnabled: true
9499
+ },
9485
9500
  {
9486
9501
  name: "macos-apps",
9487
- 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`.",
9502
+ 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`.",
9488
9503
  defaultEnabled: true
9489
9504
  }
9490
9505
  ];
@@ -9585,6 +9600,7 @@ function isFeatureEnabled(name, options = {}, registry2 = FLAG_REGISTRY) {
9585
9600
  }
9586
9601
 
9587
9602
  // ../configuration-core/src/paths.ts
9603
+ import * as fs3 from "node:fs";
9588
9604
  import * as os from "node:os";
9589
9605
  import * as path3 from "node:path";
9590
9606
  function nonEmpty(value) {
@@ -9596,6 +9612,16 @@ function resolveHomeDir(options = {}) {
9596
9612
  if (options.homeDir) return options.homeDir;
9597
9613
  return process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
9598
9614
  }
9615
+ function isHomeDir(dir, options = {}) {
9616
+ return canonicalPath(dir) === canonicalPath(resolveHomeDir(options));
9617
+ }
9618
+ function canonicalPath(p) {
9619
+ try {
9620
+ return fs3.realpathSync.native(p);
9621
+ } catch {
9622
+ return path3.resolve(p);
9623
+ }
9624
+ }
9599
9625
  function argentHomeDir() {
9600
9626
  return path3.join(resolveHomeDir(), ".argent");
9601
9627
  }
@@ -9612,11 +9638,11 @@ function configFilePath(scope = "global", options = {}) {
9612
9638
 
9613
9639
  // ../configuration-core/src/config.ts
9614
9640
  import * as crypto from "node:crypto";
9615
- import * as fs3 from "node:fs";
9641
+ import * as fs4 from "node:fs";
9616
9642
  import * as path4 from "node:path";
9617
9643
  function readConfigObject(scope = "global", options = {}) {
9618
9644
  try {
9619
- const raw = fs3.readFileSync(configFilePath(scope, options), "utf8");
9645
+ const raw = fs4.readFileSync(configFilePath(scope, options), "utf8");
9620
9646
  const json2 = JSON.parse(raw);
9621
9647
  if (json2 && typeof json2 === "object" && !Array.isArray(json2)) {
9622
9648
  return json2;
@@ -9692,9 +9718,9 @@ function acquireConfigLock(finalPath) {
9692
9718
  const deadline = Date.now() + LOCK_MAX_WAIT_MS;
9693
9719
  for (; ; ) {
9694
9720
  try {
9695
- const fd = fs3.openSync(lockPath, "wx", 384);
9721
+ const fd = fs4.openSync(lockPath, "wx", 384);
9696
9722
  try {
9697
- fs3.writeSync(fd, `${process.pid}
9723
+ fs4.writeSync(fd, `${process.pid}
9698
9724
  `);
9699
9725
  } catch {
9700
9726
  }
@@ -9702,8 +9728,8 @@ function acquireConfigLock(finalPath) {
9702
9728
  } catch (err) {
9703
9729
  if (err.code !== "EEXIST") return null;
9704
9730
  try {
9705
- if (Date.now() - fs3.statSync(lockPath).mtimeMs > LOCK_STALE_MS2) {
9706
- fs3.unlinkSync(lockPath);
9731
+ if (Date.now() - fs4.statSync(lockPath).mtimeMs > LOCK_STALE_MS2) {
9732
+ fs4.unlinkSync(lockPath);
9707
9733
  continue;
9708
9734
  }
9709
9735
  } catch {
@@ -9715,35 +9741,35 @@ function acquireConfigLock(finalPath) {
9715
9741
  }
9716
9742
  function releaseConfigLock(lock) {
9717
9743
  try {
9718
- fs3.closeSync(lock.fd);
9744
+ fs4.closeSync(lock.fd);
9719
9745
  } catch {
9720
9746
  }
9721
9747
  try {
9722
- fs3.unlinkSync(lock.lockPath);
9748
+ fs4.unlinkSync(lock.lockPath);
9723
9749
  } catch {
9724
9750
  }
9725
9751
  }
9726
9752
  function updateConfig(mutate, scope = "global", options = {}) {
9727
9753
  const dir = configDir(scope, options);
9728
- fs3.mkdirSync(dir, { recursive: true });
9754
+ fs4.mkdirSync(dir, { recursive: true });
9729
9755
  const finalPath = configFilePath(scope, options);
9730
9756
  const lock = acquireConfigLock(finalPath);
9731
9757
  try {
9732
9758
  const next = readConfigObject(scope, options);
9733
9759
  mutate(next);
9734
9760
  const tmpPath = path4.join(dir, `.config.tmp.${process.pid}.${crypto.randomUUID()}`);
9735
- const fd = fs3.openSync(tmpPath, "wx", 384);
9761
+ const fd = fs4.openSync(tmpPath, "wx", 384);
9736
9762
  try {
9737
- fs3.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
9738
- fs3.fsyncSync(fd);
9763
+ fs4.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
9764
+ fs4.fsyncSync(fd);
9739
9765
  } finally {
9740
- fs3.closeSync(fd);
9766
+ fs4.closeSync(fd);
9741
9767
  }
9742
9768
  try {
9743
- fs3.renameSync(tmpPath, finalPath);
9769
+ fs4.renameSync(tmpPath, finalPath);
9744
9770
  } catch (err) {
9745
9771
  try {
9746
- fs3.unlinkSync(tmpPath);
9772
+ fs4.unlinkSync(tmpPath);
9747
9773
  } catch {
9748
9774
  }
9749
9775
  throw err;
@@ -9755,7 +9781,7 @@ function updateConfig(mutate, scope = "global", options = {}) {
9755
9781
 
9756
9782
  // ../configuration-core/src/secrets.ts
9757
9783
  var import_dotenv = __toESM(require_dist2(), 1);
9758
- import * as fs4 from "node:fs";
9784
+ import * as fs5 from "node:fs";
9759
9785
  import * as path5 from "node:path";
9760
9786
  var SECRET_ENV_PREFIX = "ARGENT_SECRET_";
9761
9787
  var SECRETS_FILE_NAME = "secrets.env";
@@ -9785,10 +9811,10 @@ function fileSource(filePath, exposure) {
9785
9811
  names: [],
9786
9812
  values: /* @__PURE__ */ new Map()
9787
9813
  };
9788
- if (!fs4.statSync(filePath, { throwIfNoEntry: false })) return absent;
9814
+ if (!fs5.statSync(filePath, { throwIfNoEntry: false })) return absent;
9789
9815
  let content;
9790
9816
  try {
9791
- content = fs4.readFileSync(filePath, "utf8");
9817
+ content = fs5.readFileSync(filePath, "utf8");
9792
9818
  } catch {
9793
9819
  return absent;
9794
9820
  }
@@ -9814,7 +9840,9 @@ function fileSource(filePath, exposure) {
9814
9840
  }
9815
9841
  function secretSources(options = {}) {
9816
9842
  const sources = [envSource(options.env ?? process.env)];
9817
- const projectRoot = findProjectRoot(options.cwd ?? process.cwd());
9843
+ const home = resolveHomeDir(options);
9844
+ const found = findProjectRoot(options.cwd ?? process.cwd());
9845
+ const projectRoot = found && isHomeDir(found, options) ? home : found;
9818
9846
  const filePaths = [];
9819
9847
  if (projectRoot) {
9820
9848
  filePaths.push({
@@ -9826,7 +9854,7 @@ function secretSources(options = {}) {
9826
9854
  }
9827
9855
  }
9828
9856
  filePaths.push({
9829
- path: path5.join(resolveHomeDir(options), ".argent", SECRETS_FILE_NAME),
9857
+ path: path5.join(home, ".argent", SECRETS_FILE_NAME),
9830
9858
  exposure: "dedicated"
9831
9859
  });
9832
9860
  const seen = /* @__PURE__ */ new Set();
@@ -9966,14 +9994,6 @@ var CONFIG_SCHEMA = [
9966
9994
  // drained/reset, not just the file rewritten.
9967
9995
  manageCommand: "argent telemetry"
9968
9996
  },
9969
- {
9970
- key: "allowlist.enabled",
9971
- 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.",
9972
- scopes: ["project", "global"],
9973
- parse: asBoolean,
9974
- merge: "prioritize-restrictive",
9975
- example: "false"
9976
- },
9977
9997
  {
9978
9998
  key: "lens.agent",
9979
9999
  description: "Coding-agent id remembered by `argent lens` to skip the picker.",
@@ -10159,6 +10179,7 @@ function unsetConfigValue(key, scope = "global", options = {}, registry2 = CONFI
10159
10179
  return removed;
10160
10180
  }
10161
10181
  function listConfig(options = {}, registry2 = CONFIG_SCHEMA) {
10182
+ const projectIsHome = isHomeDir(resolveProjectRoot(options.cwd ?? process.cwd()), options);
10162
10183
  return registry2.map((def) => ({
10163
10184
  key: def.key,
10164
10185
  description: def.description,
@@ -10167,7 +10188,7 @@ function listConfig(options = {}, registry2 = CONFIG_SCHEMA) {
10167
10188
  ...describeExpectedValue(def) ? { expected: describeExpectedValue(def) } : {},
10168
10189
  ...def.example ? { example: def.example } : {},
10169
10190
  effective: getConfigValue(def, options),
10170
- project: readScopeValue(def, "project", options),
10191
+ project: projectIsHome ? void 0 : readScopeValue(def, "project", options),
10171
10192
  global: readScopeValue(def, "global", options)
10172
10193
  }));
10173
10194
  }
@@ -10220,7 +10241,18 @@ function interpolateFileInputPath(template, args) {
10220
10241
  });
10221
10242
  return missing ? null : out;
10222
10243
  }
10223
- var TOOL_FILE_EXTENSIONS = [".png", ".yaml"];
10244
+ var TOOL_FILE_EXTENSIONS = [
10245
+ ".png",
10246
+ ".yaml",
10247
+ ".wav",
10248
+ ".mp3",
10249
+ ".m4a",
10250
+ ".aac",
10251
+ ".caf",
10252
+ ".aif",
10253
+ ".aiff",
10254
+ ".flac"
10255
+ ];
10224
10256
  function hasToolFileExtension(file2) {
10225
10257
  const name = file2.toLowerCase();
10226
10258
  return TOOL_FILE_EXTENSIONS.some((extension) => name.endsWith(extension));
@@ -10234,16 +10266,24 @@ function toolStepFiles(specs, args) {
10234
10266
  }
10235
10267
  return files;
10236
10268
  }
10237
- function isClientFileArgument({ spec, path: path25 }) {
10238
- return spec.kind === "file" && spec.path === `\${${spec.target}}` && path25.startsWith("/") && hasToolFileExtension(path25);
10269
+ var UNEXPANDED_PATH = /^~|\$[A-Za-z0-9_{(]|`|%[A-Za-z_][A-Za-z0-9_]*%|^[A-Za-z][A-Za-z0-9+.-]+:/;
10270
+ function isUnexpandedPath(p) {
10271
+ return UNEXPANDED_PATH.test(p);
10272
+ }
10273
+ function isClientFileArgument({ spec, path: path30 }) {
10274
+ return spec.kind === "file" && spec.path === `\${${spec.target}}` && path30.startsWith("/") && hasToolFileExtension(path30);
10239
10275
  }
10240
10276
 
10277
+ // ../registry/src/flow-platforms.ts
10278
+ var LAUNCH_PLATFORMS = ["ios", "android", "chromium", "vega", "macos"];
10279
+ var SELECTABLE_PLATFORMS = [...LAUNCH_PLATFORMS, "ios-remote"];
10280
+
10241
10281
  // ../registry/src/flow-file-refs.ts
10242
- import * as fs6 from "node:fs/promises";
10282
+ import * as fs7 from "node:fs/promises";
10243
10283
  import * as path8 from "node:path";
10244
10284
 
10245
10285
  // ../registry/src/e2e-dirs.ts
10246
- import * as fs5 from "node:fs/promises";
10286
+ import * as fs6 from "node:fs/promises";
10247
10287
  import * as path7 from "node:path";
10248
10288
  var E2E_DIR = path7.join(".argent", "e2e");
10249
10289
  var LEGACY_E2E_DIRS = Object.freeze([path7.join(".argent", "flows")]);
@@ -10258,7 +10298,7 @@ function e2eFileCandidates(projectRoot, name) {
10258
10298
  return e2eDirsFor(projectRoot).map((dir) => path7.join(dir, `${name}.yaml`));
10259
10299
  }
10260
10300
  async function exists(file2) {
10261
- return fs5.stat(file2).then(
10301
+ return fs6.stat(file2).then(
10262
10302
  () => true,
10263
10303
  () => false
10264
10304
  );
@@ -10352,10 +10392,10 @@ function canonicalToolArgs(tool, args) {
10352
10392
  // ../registry/src/flow-file-refs.ts
10353
10393
  async function canonicalFlowPath(p) {
10354
10394
  try {
10355
- return await fs6.realpath(p);
10395
+ return await fs7.realpath(p);
10356
10396
  } catch {
10357
10397
  try {
10358
- return path8.join(await fs6.realpath(path8.dirname(p)), path8.basename(p));
10398
+ return path8.join(await fs7.realpath(path8.dirname(p)), path8.basename(p));
10359
10399
  } catch {
10360
10400
  return p;
10361
10401
  }
@@ -10371,6 +10411,9 @@ var MAX_BLOCK_NESTING = 64;
10371
10411
  function isRecord(value) {
10372
10412
  return typeof value === "object" && value !== null && !Array.isArray(value);
10373
10413
  }
10414
+ function flowYamlSource(content) {
10415
+ return content.replace(/^\s+/, (lead) => lead.replace(/[^\n]/g, "")).trimEnd();
10416
+ }
10374
10417
  function collectFlowRequests(doc) {
10375
10418
  const runTargets = /* @__PURE__ */ new Set();
10376
10419
  const snapshots = /* @__PURE__ */ new Set();
@@ -10401,15 +10444,15 @@ function collectFlowRequests(doc) {
10401
10444
  if (isRecord(doc)) visit2(doc.steps, 0);
10402
10445
  return { runTargets: [...runTargets], snapshots: [...snapshots], toolSteps, nested };
10403
10446
  }
10404
- function baselineKeyFor(canonicalPath, flowName) {
10405
- const stem = path8.basename(canonicalPath, ".yaml");
10447
+ function baselineKeyFor(canonicalPath2, flowName) {
10448
+ const stem = path8.basename(canonicalPath2, ".yaml");
10406
10449
  return FLOW_NAME_PATTERN.test(stem) ? stem : flowName;
10407
10450
  }
10408
10451
  function flowMemberKey(anchorDir, target) {
10409
10452
  return `${anchorDir}\0${target}`;
10410
10453
  }
10411
10454
  async function classifyOnDiskSpelling(dir, base, addressable = FLOW_FILE_NAME_PATTERN) {
10412
- const entries = await fs6.readdir(dir).catch(() => null);
10455
+ const entries = await fs7.readdir(dir).catch(() => null);
10413
10456
  if (entries === null || entries.includes(base)) return { state: "listed" };
10414
10457
  const actual = entries.find((entry) => entry.toLowerCase() === base.toLowerCase());
10415
10458
  if (actual === void 0) return { state: "absent" };
@@ -10519,6 +10562,10 @@ var FAILURE_CODES = {
10519
10562
  ANDROID_ADB_COMMAND_FAILED: "ANDROID_ADB_COMMAND_FAILED",
10520
10563
  ANDROID_ADB_BOOT_TERMINAL_STATE: "ANDROID_ADB_BOOT_TERMINAL_STATE",
10521
10564
  ANDROID_ADB_BOOT_TIMEOUT: "ANDROID_ADB_BOOT_TIMEOUT",
10565
+ ANDROID_NETWORK_PROXY_TIMEOUT: "ANDROID_NETWORK_PROXY_TIMEOUT",
10566
+ ANDROID_NETWORK_RESTORE_TIMEOUT: "ANDROID_NETWORK_RESTORE_TIMEOUT",
10567
+ ANDROID_OFFLINE_TIMEOUT: "ANDROID_OFFLINE_TIMEOUT",
10568
+ ANDROID_OFFLINE_UNSUPPORTED: "ANDROID_OFFLINE_UNSUPPORTED",
10522
10569
  SIMULATOR_NETWORK_TIMEOUT: "SIMULATOR_NETWORK_TIMEOUT",
10523
10570
  SIMULATOR_NETWORK_CONNECTION_REFUSED: "SIMULATOR_NETWORK_CONNECTION_REFUSED",
10524
10571
  SIMULATOR_NETWORK_CONNECTION_RESET: "SIMULATOR_NETWORK_CONNECTION_RESET",
@@ -10638,12 +10685,15 @@ var FAILURE_CODES = {
10638
10685
  DEBUGGER_CDP_PROTOCOL_ERROR: "DEBUGGER_CDP_PROTOCOL_ERROR",
10639
10686
  DEBUGGER_CDP_CONNECT_FAILED: "DEBUGGER_CDP_CONNECT_FAILED",
10640
10687
  DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN: "DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN",
10688
+ DEBUGGER_CDP_ORIGIN_REJECTED: "DEBUGGER_CDP_ORIGIN_REJECTED",
10641
10689
  DEBUGGER_CDP_NOT_CONNECTED: "DEBUGGER_CDP_NOT_CONNECTED",
10642
10690
  DEBUGGER_CDP_REQUEST_TIMEOUT: "DEBUGGER_CDP_REQUEST_TIMEOUT",
10643
10691
  DEBUGGER_CDP_CONNECTION_CLOSED: "DEBUGGER_CDP_CONNECTION_CLOSED",
10644
10692
  DEBUGGER_TARGET_DEVICE_MISMATCH: "DEBUGGER_TARGET_DEVICE_MISMATCH",
10645
10693
  DEBUGGER_EVALUATE_EXPRESSION_THREW: "DEBUGGER_EVALUATE_EXPRESSION_THREW",
10646
10694
  DEBUGGER_RELOAD_FAILED: "DEBUGGER_RELOAD_FAILED",
10695
+ // e2e-add-step refused a debugger-* call that answered `not_connected`.
10696
+ DEBUGGER_NOT_CONNECTED: "DEBUGGER_NOT_CONNECTED",
10647
10697
  JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED: "JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED",
10648
10698
  JS_RUNTIME_PAYLOAD_INVALID: "JS_RUNTIME_PAYLOAD_INVALID",
10649
10699
  JS_RUNTIME_PAYLOAD_DEVICE_MISSING: "JS_RUNTIME_PAYLOAD_DEVICE_MISSING",
@@ -10657,7 +10707,7 @@ var FAILURE_CODES = {
10657
10707
  ANDROID_NETWORK_INSPECTOR_RUN_AS_FAILED: "ANDROID_NETWORK_INSPECTOR_RUN_AS_FAILED",
10658
10708
  ANDROID_NETWORK_INSPECTOR_DEVICE_IN_USE: "ANDROID_NETWORK_INSPECTOR_DEVICE_IN_USE",
10659
10709
  ANDROID_NETWORK_INSPECTOR_NO_DEVICE_PORT: "ANDROID_NETWORK_INSPECTOR_NO_DEVICE_PORT",
10660
- NATIVE_NETWORK_LOGS_STOP_UNSUPPORTED: "NATIVE_NETWORK_LOGS_STOP_UNSUPPORTED",
10710
+ NETWORK_CAPTURE_UNAVAILABLE: "NETWORK_CAPTURE_UNAVAILABLE",
10661
10711
  NDJSON_CDP_REQUEST_TIMEOUT: "NDJSON_CDP_REQUEST_TIMEOUT",
10662
10712
  NDJSON_CDP_REQUEST_FAILED: "NDJSON_CDP_REQUEST_FAILED",
10663
10713
  NDJSON_CDP_CONNECTION_CLOSED: "NDJSON_CDP_CONNECTION_CLOSED",
@@ -10712,6 +10762,32 @@ var FAILURE_CODES = {
10712
10762
  NATIVE_PROFILER_PERFETTO_PROCESS_ERROR: "NATIVE_PROFILER_PERFETTO_PROCESS_ERROR",
10713
10763
  NATIVE_PROFILER_PERFETTO_READY_TIMEOUT: "NATIVE_PROFILER_PERFETTO_READY_TIMEOUT",
10714
10764
  NATIVE_PROFILER_PERFETTO_READY_EXITED: "NATIVE_PROFILER_PERFETTO_READY_EXITED",
10765
+ /**
10766
+ * native-profiler-launch-analysis. Input problems use TOOL_INPUT_INVALID and
10767
+ * devicectl steps IOS_DEVICECTL_COMMAND_FAILED.
10768
+ * @see [workflow.ts](../../tool-server/src/utils/ios-launch-time/workflow.ts)
10769
+ */
10770
+ // Not macOS, or an Xcode that cannot record the launch on this target.
10771
+ LAUNCH_ANALYSIS_UNSUPPORTED_HOST: "LAUNCH_ANALYSIS_UNSUPPORTED_HOST",
10772
+ // No usable iPhone or simulator was selected, or Argent's runner holds it.
10773
+ LAUNCH_ANALYSIS_DEVICE_UNAVAILABLE: "LAUNCH_ANALYSIS_DEVICE_UNAVAILABLE",
10774
+ // The bundle_id app is not installed on the selected device.
10775
+ LAUNCH_ANALYSIS_APP_NOT_INSTALLED: "LAUNCH_ANALYSIS_APP_NOT_INSTALLED",
10776
+ // The runner's xcodebuild failed on code signing or provisioning.
10777
+ LAUNCH_ANALYSIS_SIGNING_FAILED: "LAUNCH_ANALYSIS_SIGNING_FAILED",
10778
+ // The iPhone's free developer profile has no slot for Argent's runner.
10779
+ LAUNCH_ANALYSIS_FREE_PROFILE_LIMIT: "LAUNCH_ANALYSIS_FREE_PROFILE_LIMIT",
10780
+ // simctl could not wait for boot, find, launch or terminate the app.
10781
+ LAUNCH_ANALYSIS_SIMCTL_FAILED: "LAUNCH_ANALYSIS_SIMCTL_FAILED",
10782
+ LAUNCH_ANALYSIS_RECORD_FAILED: "LAUNCH_ANALYSIS_RECORD_FAILED",
10783
+ // xctrace could not export the TOC, the CPU samples or the first-frame marker.
10784
+ LAUNCH_ANALYSIS_EXPORT_FAILED: "LAUNCH_ANALYSIS_EXPORT_FAILED",
10785
+ // The App Launch trace has no first frame of the app, so it has no launch window.
10786
+ LAUNCH_ANALYSIS_NO_FIRST_FRAME: "LAUNCH_ANALYSIS_NO_FIRST_FRAME",
10787
+ // The XCTest launch run of Argent's runner failed.
10788
+ LAUNCH_ANALYSIS_RUNNER_TEST_FAILED: "LAUNCH_ANALYSIS_RUNNER_TEST_FAILED",
10789
+ // The launch test ran, but Argent read no launch measurements from its result.
10790
+ LAUNCH_ANALYSIS_NO_SAMPLES: "LAUNCH_ANALYSIS_NO_SAMPLES",
10715
10791
  // iOS and Android share one capture path (simulator-server frames into
10716
10792
  // ffmpeg), so these name the failing stage, not the device family.
10717
10793
  SCREEN_RECORDING_FACTORY_OPTIONS_MISSING: "SCREEN_RECORDING_FACTORY_OPTIONS_MISSING",
@@ -10726,6 +10802,19 @@ var FAILURE_CODES = {
10726
10802
  SCREEN_RECORDING_SERVER_SHUTTING_DOWN: "SCREEN_RECORDING_SERVER_SHUTTING_DOWN",
10727
10803
  SCREEN_RECORDING_STREAM_UNAVAILABLE: "SCREEN_RECORDING_STREAM_UNAVAILABLE",
10728
10804
  SCREEN_RECORDING_FFMPEG_NOT_FOUND: "SCREEN_RECORDING_FFMPEG_NOT_FOUND",
10805
+ // A cabled iPhone has no simulator-server: its frames come from a host-side
10806
+ // CoreMediaIO capture helper, which can fail in ways of its own.
10807
+ SCREEN_RECORDING_DEVICE_HELPER_BUILD_FAILED: "SCREEN_RECORDING_DEVICE_HELPER_BUILD_FAILED",
10808
+ SCREEN_RECORDING_DEVICE_SCREEN_NOT_FOUND: "SCREEN_RECORDING_DEVICE_SCREEN_NOT_FOUND",
10809
+ SCREEN_RECORDING_DEVICE_CAMERA_PERMISSION_DENIED: "SCREEN_RECORDING_DEVICE_CAMERA_PERMISSION_DENIED",
10810
+ SCREEN_RECORDING_DEVICE_HELPER_FAILED: "SCREEN_RECORDING_DEVICE_HELPER_FAILED",
10811
+ AUDIO_CLIP_CONVERSION_FAILED: "AUDIO_CLIP_CONVERSION_FAILED",
10812
+ AUDIO_HOOK_NOT_ACTIVE: "AUDIO_HOOK_NOT_ACTIVE",
10813
+ AUDIO_ENV_SETUP_FAILED: "AUDIO_ENV_SETUP_FAILED",
10814
+ AUDIO_WRONG_PLATFORM: "AUDIO_WRONG_PLATFORM",
10815
+ AUDIO_HOOK_UNAVAILABLE: "AUDIO_HOOK_UNAVAILABLE",
10816
+ AUDIO_INJECTION_NOT_OURS: "AUDIO_INJECTION_NOT_OURS",
10817
+ AUDIO_SIMULATOR_NOT_BOOTED: "AUDIO_SIMULATOR_NOT_BOOTED",
10729
10818
  FLOW_PROJECT_ROOT_INVALID: "FLOW_PROJECT_ROOT_INVALID",
10730
10819
  FLOW_NAME_INVALID: "FLOW_NAME_INVALID",
10731
10820
  FLOW_NO_ACTIVE_RECORDING: "FLOW_NO_ACTIVE_RECORDING",
@@ -10789,6 +10878,8 @@ var FAILURE_CODES = {
10789
10878
  MACOS_APP_BUNDLE_ID_MISMATCH: "MACOS_APP_BUNDLE_ID_MISMATCH",
10790
10879
  MACOS_APP_OPEN_URL_FAILED: "MACOS_APP_OPEN_URL_FAILED",
10791
10880
  MACOS_APP_FILE_ACCESS_FAILED: "MACOS_APP_FILE_ACCESS_FAILED",
10881
+ /** The app's loaded Argent library lacks support for the requested operation. */
10882
+ MACOS_APP_LIBRARY_OUTDATED: "MACOS_APP_LIBRARY_OUTDATED",
10792
10883
  KEYBOARD_KEY_UNSUPPORTED: "KEYBOARD_KEY_UNSUPPORTED",
10793
10884
  KEYBOARD_CHARACTER_UNSUPPORTED: "KEYBOARD_CHARACTER_UNSUPPORTED",
10794
10885
  KEYBOARD_TEXT_AND_KEY_COMBINED: "KEYBOARD_TEXT_AND_KEY_COMBINED",
@@ -10858,13 +10949,19 @@ var FAILURE_COMMANDS = [
10858
10949
  "ax_service",
10859
10950
  "simulator_server",
10860
10951
  "ffmpeg",
10952
+ "afconvert",
10861
10953
  "cdp",
10862
10954
  "electron",
10863
10955
  "npm",
10864
10956
  "npx",
10865
10957
  "unknown",
10866
10958
  "devicectl",
10867
- "xcodebuild"
10959
+ "xcodebuild",
10960
+ "swiftc",
10961
+ // The host-side helper that captures a cabled iPhone's screen.
10962
+ "ios_screen_stream",
10963
+ // `xcrun xcresulttool`, which reads an XCTest result bundle.
10964
+ "xcresulttool"
10868
10965
  ];
10869
10966
  var FAILURE_SIGNAL_NAMES = [
10870
10967
  "SIGABRT",
@@ -11708,10 +11805,10 @@ function mergeDefs(...defs) {
11708
11805
  function cloneDef(schema) {
11709
11806
  return mergeDefs(schema._zod.def);
11710
11807
  }
11711
- function getElementAtPath(obj, path25) {
11712
- if (!path25)
11808
+ function getElementAtPath(obj, path30) {
11809
+ if (!path30)
11713
11810
  return obj;
11714
- return path25.reduce((acc, key) => acc?.[key], obj);
11811
+ return path30.reduce((acc, key) => acc?.[key], obj);
11715
11812
  }
11716
11813
  function promiseAllObject(promisesObj) {
11717
11814
  const keys = Object.keys(promisesObj);
@@ -12051,11 +12148,11 @@ function explicitlyAborted(x, startIndex = 0) {
12051
12148
  }
12052
12149
  return false;
12053
12150
  }
12054
- function prefixIssues(path25, issues) {
12151
+ function prefixIssues(path30, issues) {
12055
12152
  return issues.map((iss) => {
12056
12153
  var _a3;
12057
12154
  (_a3 = iss).path ?? (_a3.path = []);
12058
- iss.path.unshift(path25);
12155
+ iss.path.unshift(path30);
12059
12156
  return iss;
12060
12157
  });
12061
12158
  }
@@ -12517,16 +12614,16 @@ function flattenError(error63, mapper = (issue2) => issue2.message) {
12517
12614
  }
12518
12615
  function formatError(error63, mapper = (issue2) => issue2.message) {
12519
12616
  const fieldErrors = { _errors: [] };
12520
- const processError = (error64, path25 = []) => {
12617
+ const processError = (error64, path30 = []) => {
12521
12618
  for (const issue2 of error64.issues) {
12522
12619
  if (issue2.code === "invalid_union" && issue2.errors.length) {
12523
- issue2.errors.map((issues) => processError({ issues }, [...path25, ...issue2.path]));
12620
+ issue2.errors.map((issues) => processError({ issues }, [...path30, ...issue2.path]));
12524
12621
  } else if (issue2.code === "invalid_key") {
12525
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
12622
+ processError({ issues: issue2.issues }, [...path30, ...issue2.path]);
12526
12623
  } else if (issue2.code === "invalid_element") {
12527
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
12624
+ processError({ issues: issue2.issues }, [...path30, ...issue2.path]);
12528
12625
  } else {
12529
- const fullpath = [...path25, ...issue2.path];
12626
+ const fullpath = [...path30, ...issue2.path];
12530
12627
  if (fullpath.length === 0) {
12531
12628
  fieldErrors._errors.push(mapper(issue2));
12532
12629
  } else {
@@ -12565,17 +12662,17 @@ function formatError(error63, mapper = (issue2) => issue2.message) {
12565
12662
  }
12566
12663
  function treeifyError(error63, mapper = (issue2) => issue2.message) {
12567
12664
  const result = { errors: [] };
12568
- const processError = (error64, path25 = []) => {
12665
+ const processError = (error64, path30 = []) => {
12569
12666
  var _a3;
12570
12667
  for (const issue2 of error64.issues) {
12571
12668
  if (issue2.code === "invalid_union" && issue2.errors.length) {
12572
- issue2.errors.map((issues) => processError({ issues }, [...path25, ...issue2.path]));
12669
+ issue2.errors.map((issues) => processError({ issues }, [...path30, ...issue2.path]));
12573
12670
  } else if (issue2.code === "invalid_key") {
12574
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
12671
+ processError({ issues: issue2.issues }, [...path30, ...issue2.path]);
12575
12672
  } else if (issue2.code === "invalid_element") {
12576
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
12673
+ processError({ issues: issue2.issues }, [...path30, ...issue2.path]);
12577
12674
  } else {
12578
- const fullpath = [...path25, ...issue2.path];
12675
+ const fullpath = [...path30, ...issue2.path];
12579
12676
  if (fullpath.length === 0) {
12580
12677
  result.errors.push(mapper(issue2));
12581
12678
  continue;
@@ -12614,8 +12711,8 @@ function treeifyError(error63, mapper = (issue2) => issue2.message) {
12614
12711
  }
12615
12712
  function toDotPath(_path) {
12616
12713
  const segs = [];
12617
- const path25 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
12618
- for (const seg of path25) {
12714
+ const path30 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
12715
+ for (const seg of path30) {
12619
12716
  if (typeof seg === "number")
12620
12717
  segs.push(`[${seg}]`);
12621
12718
  else if (typeof seg === "symbol")
@@ -12749,18 +12846,18 @@ var validateAsync = async (schema, value, _ctx) => {
12749
12846
  return result.issues.length === 0;
12750
12847
  };
12751
12848
  var _encode = (_Err) => {
12752
- const parse3 = _parse(_Err);
12849
+ const parse4 = _parse(_Err);
12753
12850
  const fn = (schema, value, _ctx, _params) => {
12754
12851
  const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
12755
- return parse3(schema, value, ctx, finalizeParams(fn, _params));
12852
+ return parse4(schema, value, ctx, finalizeParams(fn, _params));
12756
12853
  };
12757
12854
  return fn;
12758
12855
  };
12759
12856
  var encode = /* @__PURE__ */ _encode($ZodRealError);
12760
12857
  var _decode = (_Err) => {
12761
- const parse3 = _parse(_Err);
12858
+ const parse4 = _parse(_Err);
12762
12859
  const fn = (schema, value, _ctx, _params) => {
12763
- return parse3(schema, value, _ctx, finalizeParams(fn, _params));
12860
+ return parse4(schema, value, _ctx, finalizeParams(fn, _params));
12764
12861
  };
12765
12862
  return fn;
12766
12863
  };
@@ -14255,7 +14352,7 @@ function capSize(inst, size) {
14255
14352
  if (!caps.length)
14256
14353
  return;
14257
14354
  const cap = Math.min(...caps.map((c2) => c2[0]));
14258
- const parse3 = inst._zod.parse;
14355
+ const parse4 = inst._zod.parse;
14259
14356
  inst._zod.parse = (payload, ctx) => {
14260
14357
  const n3 = size(payload.value);
14261
14358
  if (n3 > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
@@ -14269,7 +14366,7 @@ function capSize(inst, size) {
14269
14366
  }
14270
14367
  }
14271
14368
  }
14272
- return parse3(payload, ctx);
14369
+ return parse4(payload, ctx);
14273
14370
  };
14274
14371
  }
14275
14372
  var arraySize = (input2) => Array.isArray(input2) ? input2.length : -1;
@@ -15958,7 +16055,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
15958
16055
  var NONE = 0;
15959
16056
  var ASSUMED = 1;
15960
16057
  var PROVEN = 2;
15961
- function isRecursive(inst, stack, resolve13) {
16058
+ function isRecursive(inst, stack, resolve14) {
15962
16059
  const cached3 = recursive.get(inst);
15963
16060
  if (cached3 !== void 0)
15964
16061
  return cached3 ? PROVEN : NONE;
@@ -15968,7 +16065,7 @@ function isRecursive(inst, stack, resolve13) {
15968
16065
  let result = NONE;
15969
16066
  const check2 = (child) => {
15970
16067
  if (result !== PROVEN && child?._zod) {
15971
- const answer = isRecursive(child, stack, resolve13);
16068
+ const answer = isRecursive(child, stack, resolve14);
15972
16069
  if (answer > result)
15973
16070
  result = answer;
15974
16071
  }
@@ -15979,7 +16076,7 @@ function isRecursive(inst, stack, resolve13) {
15979
16076
  const desc = Object.getOwnPropertyDescriptor(sh, key);
15980
16077
  if (spread && !desc.enumerable)
15981
16078
  continue;
15982
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve13) : NONE;
16079
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve14) : NONE;
15983
16080
  if (child > answer)
15984
16081
  answer = child;
15985
16082
  }
@@ -16043,7 +16140,7 @@ function isRecursive(inst, stack, resolve13) {
16043
16140
  break;
16044
16141
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
16045
16142
  case "lazy": {
16046
- const inner = def._cachedInner ?? (resolve13 ? inst._zod.innerType : void 0);
16143
+ const inner = def._cachedInner ?? (resolve14 ? inst._zod.innerType : void 0);
16047
16144
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
16048
16145
  break;
16049
16146
  }
@@ -29753,13 +29850,13 @@ function resolveRef(ref, ctx) {
29753
29850
  if (!ref.startsWith("#")) {
29754
29851
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
29755
29852
  }
29756
- const path25 = ref.slice(1).split("/").filter(Boolean);
29757
- if (path25.length === 0) {
29853
+ const path30 = ref.slice(1).split("/").filter(Boolean);
29854
+ if (path30.length === 0) {
29758
29855
  return ctx.rootSchema;
29759
29856
  }
29760
29857
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
29761
- if (path25[0] === defsKey) {
29762
- const key = path25[1] === void 0 ? void 0 : decodeJSONPointerSegment(path25[1]);
29858
+ if (path30[0] === defsKey) {
29859
+ const key = path30[1] === void 0 ? void 0 : decodeJSONPointerSegment(path30[1]);
29763
29860
  if (!key || !ctx.defs[key]) {
29764
29861
  throw new Error(`Reference not found: ${ref}`);
29765
29862
  }
@@ -30612,9 +30709,9 @@ function date4(params) {
30612
30709
  import { randomUUID as randomUUID3 } from "node:crypto";
30613
30710
  import { AsyncLocalStorage } from "node:async_hooks";
30614
30711
  var resolvedDuringInvocation = new AsyncLocalStorage();
30615
- function valueAtPath(root, path25) {
30712
+ function valueAtPath(root, path30) {
30616
30713
  let current = root;
30617
- for (const key of path25) {
30714
+ for (const key of path30) {
30618
30715
  if (current === null || typeof current !== "object") return void 0;
30619
30716
  if (!Object.hasOwn(current, key)) return void 0;
30620
30717
  current = current[key];
@@ -30774,8 +30871,8 @@ function parseLinkTarget(input2) {
30774
30871
  const host = u3.hostname.startsWith("[") ? u3.hostname.slice(1, -1) : u3.hostname;
30775
30872
  if (!host) throw new Error(`URL "${input2}" is missing a host.`);
30776
30873
  const port = u3.port ? Number(u3.port) : u3.protocol === "https:" ? 443 : 80;
30777
- const path25 = u3.pathname === "/" ? "" : u3.pathname.replace(/\/+$/, "");
30778
- const url2 = `${u3.protocol}//${u3.host}${path25}`;
30874
+ const path30 = u3.pathname === "/" ? "" : u3.pathname.replace(/\/+$/, "");
30875
+ const url2 = `${u3.protocol}//${u3.host}${path30}`;
30779
30876
  const token = u3.username ? decodeURIComponent(u3.username) : void 0;
30780
30877
  return { url: url2, host, port, ...token ? { token } : {} };
30781
30878
  }
@@ -30802,7 +30899,7 @@ import { spawn as spawn2 } from "node:child_process";
30802
30899
  import { once } from "node:events";
30803
30900
  import { createReadStream, createWriteStream } from "node:fs";
30804
30901
  import { open as open2, rm, readdir as readdir3 } from "node:fs/promises";
30805
- import { basename as basename4, dirname as dirname5, join as join9, resolve as resolve6, sep as sep2 } from "node:path";
30902
+ import { basename as basename4, dirname as dirname5, join as join9, resolve as resolve7, sep as sep2 } from "node:path";
30806
30903
  import { Writable } from "node:stream";
30807
30904
  import { pipeline } from "node:stream/promises";
30808
30905
  import zlib from "node:zlib";
@@ -30900,7 +30997,7 @@ async function sniffFormat(archivePath) {
30900
30997
  }
30901
30998
  }
30902
30999
  var ZSTD_FRAME_MAGIC = 4247762216;
30903
- async function assertSingleCompleteZstdFrame(archivePath) {
31000
+ async function assertSingleCompleteZstdFrame(archivePath, signal) {
30904
31001
  const fh = await open2(archivePath, "r");
30905
31002
  try {
30906
31003
  const { size } = await fh.stat();
@@ -30910,6 +31007,7 @@ async function assertSingleCompleteZstdFrame(archivePath) {
30910
31007
  let pos = 0;
30911
31008
  const read = async (n3) => {
30912
31009
  if (pos < windowStart || pos + n3 > windowEnd) {
31010
+ signal?.throwIfAborted();
30913
31011
  const { bytesRead } = await fh.read(window2, 0, window2.length, pos);
30914
31012
  windowStart = pos;
30915
31013
  windowEnd = pos + bytesRead;
@@ -30947,14 +31045,16 @@ function tarEnv(env) {
30947
31045
  const characterType = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
30948
31046
  return /utf-?8/i.test(characterType) ? env : { ...env, LC_ALL: TAR_LOCALE };
30949
31047
  }
30950
- async function runTar(archive, args) {
31048
+ async function runTar(archive, args, signal) {
30951
31049
  const child = spawn2("tar", [...args, "-f", "-"], {
31050
+ signal,
30952
31051
  env: tarEnv(process.env)
30953
31052
  });
30954
- const exited = new Promise((res, rej) => {
30955
- child.on("error", rej);
30956
- child.on("close", res);
31053
+ let childError;
31054
+ child.on("error", (err) => {
31055
+ childError = err;
30957
31056
  });
31057
+ const closed = new Promise((resolve14) => child.once("close", resolve14));
30958
31058
  const stdout2 = collect(child.stdout, MAX_LISTING_BYTES, {
30959
31059
  maxLines: MAX_LISTING_LINES,
30960
31060
  onOverflow: () => child.kill()
@@ -30981,12 +31081,15 @@ async function runTar(archive, args) {
30981
31081
  if (err) child.stdin?.destroy();
30982
31082
  done(err);
30983
31083
  }
30984
- })
31084
+ }),
31085
+ { signal }
30985
31086
  ).then(
30986
31087
  () => null,
30987
31088
  (err) => err
30988
31089
  );
30989
- const [code, feedError] = await Promise.all([exited, fed]);
31090
+ const [code, feedError] = await Promise.all([closed, fed]);
31091
+ signal?.throwIfAborted();
31092
+ if (childError) throw childError;
30990
31093
  if (stdout2.overflowed()) {
30991
31094
  throw new Error(
30992
31095
  `tar ${args.join(" ")} listed more than ${MAX_LISTING_LINES} members or ${MAX_LISTING_BYTES >> 20} MiB`
@@ -31000,32 +31103,33 @@ async function runTar(archive, args) {
31000
31103
  function normalizeTarMemberPath(memberPath) {
31001
31104
  return memberPath.replace(/^\.\//, "").replace(/\\/g, "/");
31002
31105
  }
31003
- function isContainedPath(path25, windows = process.platform === "win32") {
31004
- const slashed = path25.replace(/\\/g, "/");
31106
+ function isContainedPath(path30, windows = process.platform === "win32") {
31107
+ const slashed = path30.replace(/\\/g, "/");
31005
31108
  const drive = windows ? /^[A-Za-z]:/ : /^[A-Za-z]:\//;
31006
31109
  return !slashed.startsWith("/") && !drive.test(slashed) && !slashed.split("/").includes("..");
31007
31110
  }
31008
31111
  function isSafeTarMember(memberPath, destDir) {
31009
31112
  const normalized = normalizeTarMemberPath(memberPath);
31010
31113
  if (!isContainedPath(normalized)) return false;
31011
- const root = resolve6(destDir);
31012
- return resolve6(destDir, normalized).startsWith(root + sep2);
31114
+ const root = resolve7(destDir);
31115
+ return resolve7(destDir, normalized).startsWith(root + sep2);
31013
31116
  }
31014
- async function readListing(archive, args) {
31117
+ async function readListing(archive, args, signal) {
31015
31118
  try {
31016
- return await runTar(archive, args);
31119
+ return await runTar(archive, args, signal);
31017
31120
  } catch (err) {
31121
+ signal?.throwIfAborted();
31018
31122
  throw new ArchiveError(
31019
31123
  `Could not read archive: ${err instanceof Error ? err.message : String(err)}`
31020
31124
  );
31021
31125
  }
31022
31126
  }
31023
- async function listTarMembers(archive) {
31024
- const stdout2 = await readListing(archive, ["-t"]);
31127
+ async function listTarMembers(archive, signal) {
31128
+ const stdout2 = await readListing(archive, ["-t"], signal);
31025
31129
  return stdout2.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
31026
31130
  }
31027
- async function assertSafeMemberTypes(archive) {
31028
- const stdout2 = await readListing(archive, ["-tv"]);
31131
+ async function assertSafeMemberTypes(archive, signal) {
31132
+ const stdout2 = await readListing(archive, ["-tv"], signal);
31029
31133
  for (const line of stdout2.split("\n")) {
31030
31134
  if (!line.trim()) continue;
31031
31135
  const type = line[0];
@@ -31045,8 +31149,8 @@ async function assertSafeMemberTypes(archive) {
31045
31149
  );
31046
31150
  }
31047
31151
  }
31048
- async function assertSafeArchive(archive, destDir) {
31049
- const members2 = await listTarMembers(archive);
31152
+ async function assertSafeArchive(archive, destDir, signal) {
31153
+ const members2 = await listTarMembers(archive, signal);
31050
31154
  if (members2.length === 0) {
31051
31155
  throw new ArchiveError("Archive is empty.");
31052
31156
  }
@@ -31055,7 +31159,7 @@ async function assertSafeArchive(archive, destDir) {
31055
31159
  throw new ArchiveError(`Archive contains an unsafe path "${member}" \u2014 refusing extraction.`);
31056
31160
  }
31057
31161
  }
31058
- await assertSafeMemberTypes(archive);
31162
+ await assertSafeMemberTypes(archive, signal);
31059
31163
  }
31060
31164
  async function resolveMember(destDir, expectedName) {
31061
31165
  const entries = await readdir3(destDir);
@@ -31070,19 +31174,24 @@ async function resolveMember(destDir, expectedName) {
31070
31174
  }
31071
31175
  return join9(destDir, real[0]);
31072
31176
  }
31073
- async function safeExtractArchive(archivePath, destDir, expectedName) {
31177
+ async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
31178
+ signal?.throwIfAborted();
31074
31179
  let archive;
31075
31180
  try {
31076
31181
  archive = { path: archivePath, format: await sniffFormat(archivePath) };
31077
- if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath);
31182
+ if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath, signal);
31078
31183
  } catch (err) {
31184
+ signal?.throwIfAborted();
31079
31185
  throw new ArchiveError(
31080
31186
  `Could not read archive: ${err instanceof Error ? err.message : String(err)}`
31081
31187
  );
31082
31188
  }
31083
- await assertSafeArchive(archive, destDir);
31084
- await runTar(archive, ["-x", "-C", destDir]);
31085
- return resolveMember(destDir, expectedName);
31189
+ await assertSafeArchive(archive, destDir, signal);
31190
+ signal?.throwIfAborted();
31191
+ await runTar(archive, ["-x", "-C", destDir], signal);
31192
+ const member = await resolveMember(destDir, expectedName);
31193
+ signal?.throwIfAborted();
31194
+ return member;
31086
31195
  }
31087
31196
 
31088
31197
  // ../argent-tools-client/src/errors.ts
@@ -31115,6 +31224,22 @@ function interpolatePath(template, args) {
31115
31224
  });
31116
31225
  return missing ? null : out;
31117
31226
  }
31227
+ function callerPath(p) {
31228
+ const onCurrentDrive = path10.sep === "\\" && /^[\\/](?![\\/])/.test(p);
31229
+ if (!onCurrentDrive && (path10.isAbsolute(p) || path10.win32.isAbsolute(p) || isUnexpandedPath(p))) {
31230
+ return p;
31231
+ }
31232
+ const { root } = path10.parse(p);
31233
+ const rest = p.slice(root.length);
31234
+ if (!rest.split(/[\\/]/).includes("..")) {
31235
+ const resolved = path10.resolve(p);
31236
+ const last = p.split(path10.sep === "\\" ? /[\\/]/ : "/").at(-1);
31237
+ const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(path10.sep);
31238
+ return dirOnly ? `${resolved}${path10.sep}` : resolved;
31239
+ }
31240
+ const base = path10.resolve(root);
31241
+ return base.endsWith(path10.sep) ? `${base}${rest}` : `${base}${path10.sep}${rest}`;
31242
+ }
31118
31243
  async function specPath(spec, args) {
31119
31244
  if (spec.kind !== "file" || !spec.paths?.length) return interpolatePath(spec.path, args);
31120
31245
  const candidates = [];
@@ -31159,10 +31284,10 @@ function untrackArchive(archive) {
31159
31284
  for (const s of ARCHIVE_SIGNALS) process.removeListener(s, removeArchivesOnSignal);
31160
31285
  process.removeListener("exit", removePendingArchives);
31161
31286
  }
31162
- function sha256File(filePath) {
31163
- return new Promise((resolve13, reject) => {
31287
+ function sha256File(filePath, signal) {
31288
+ return new Promise((resolve14, reject) => {
31164
31289
  const hash2 = createHash2("sha256");
31165
- createReadStream2(filePath).on("data", (chunk) => hash2.update(chunk)).on("end", () => resolve13(hash2.digest("hex"))).on("error", reject);
31290
+ createReadStream2(filePath, { signal }).on("data", (chunk) => hash2.update(chunk)).on("end", () => resolve14(hash2.digest("hex"))).on("error", reject);
31166
31291
  });
31167
31292
  }
31168
31293
  function toolServerError(text2) {
@@ -31225,7 +31350,7 @@ async function uploadFile(sourcePath, endpoint, signal) {
31225
31350
  trackArchive(tarPath);
31226
31351
  try {
31227
31352
  await createArchiveFile(await realpath2(sourcePath), tarPath, format, signal);
31228
- const contentHash = await sha256File(tarPath);
31353
+ const contentHash = await sha256File(tarPath, signal);
31229
31354
  return { uploadId: await uploadTar(tarPath, format, endpoint, signal), contentHash };
31230
31355
  } finally {
31231
31356
  untrackArchive(tarPath);
@@ -31260,13 +31385,21 @@ async function prepareFileInputs(specs, args, opts) {
31260
31385
  return args;
31261
31386
  }
31262
31387
  const record2 = args;
31263
- let out = null;
31388
+ const planned = [];
31389
+ const callArgs = { ...record2 };
31264
31390
  for (const spec of specs) {
31265
31391
  if (spec.skipWhenSet && record2[spec.skipWhenSet] !== void 0) continue;
31266
31392
  if (spec.target in record2 && typeof record2[spec.target] !== "string") continue;
31267
- const filePath = await specPath(spec, record2);
31268
- if (filePath === null) continue;
31269
- if (spec.target in record2 && record2[spec.target] !== filePath) continue;
31393
+ const spelled = await specPath(spec, record2);
31394
+ if (spelled === null) continue;
31395
+ if (spec.target in record2 && record2[spec.target] !== spelled) continue;
31396
+ const filePath = callerPath(spelled);
31397
+ planned.push({ spec, filePath });
31398
+ if (spec.target in record2) callArgs[spec.target] = filePath;
31399
+ }
31400
+ if (planned.length === 0) return args;
31401
+ const out = { ...record2 };
31402
+ for (const { spec, filePath } of planned) {
31270
31403
  const wire = { [FILE_INPUT_MARKER2]: true, path: filePath };
31271
31404
  if (spec.kind === "file") {
31272
31405
  const read = await readFileInputWire(filePath, { includeContent: opts.includeContent });
@@ -31274,12 +31407,12 @@ async function prepareFileInputs(specs, args, opts) {
31274
31407
  if (spec.collect === "flow" && opts.includeContent && wire.content !== void 0 && opts.collectMembers) {
31275
31408
  Object.assign(
31276
31409
  wire,
31277
- await opts.collectMembers(filePath, Buffer.from(wire.content, "base64"), record2, opts)
31410
+ await opts.collectMembers(filePath, Buffer.from(wire.content, "base64"), callArgs, opts)
31278
31411
  );
31279
31412
  }
31280
31413
  }
31281
31414
  if (spec.kind === "probe" && spec.collect === "step" && opts.includeContent && opts.collectStepMembers) {
31282
- wire.members = await opts.collectStepMembers(record2, opts);
31415
+ wire.members = await opts.collectStepMembers(callArgs, opts);
31283
31416
  }
31284
31417
  if (spec.kind === "tar-upload") {
31285
31418
  const st = await stat3(filePath).catch(() => null);
@@ -31293,10 +31426,9 @@ async function prepareFileInputs(specs, args, opts) {
31293
31426
  Object.assign(wire, await uploadFile(filePath, opts.uploadEndpoint, opts.signal));
31294
31427
  }
31295
31428
  }
31296
- out = out ?? { ...record2 };
31297
31429
  out[spec.target] = wire;
31298
31430
  }
31299
- return out ?? args;
31431
+ return out;
31300
31432
  }
31301
31433
  function isAllowedClientFilePath(p) {
31302
31434
  if (!path10.isAbsolute(p)) return false;
@@ -31660,7 +31792,7 @@ function memberCollector(roots, opts) {
31660
31792
  for (let file2 = files.shift(); file2 !== void 0; file2 = files.shift()) {
31661
31793
  let doc;
31662
31794
  try {
31663
- doc = (0, import_yaml.parse)(file2.text.trim(), { logLevel: "error" });
31795
+ doc = (0, import_yaml.parse)(flowYamlSource(file2.text), { logLevel: "error" });
31664
31796
  } catch {
31665
31797
  continue;
31666
31798
  }
@@ -31775,7 +31907,7 @@ function recordedStep(args) {
31775
31907
  async function collectStepMembers(args, opts, recordingDirFor = e2eDirFor) {
31776
31908
  const { name, project_root: projectRoot } = args;
31777
31909
  const step = recordedStep(args);
31778
- if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name) || typeof projectRoot !== "string" || !path11.isAbsolute(projectRoot) || step === void 0) {
31910
+ if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name) || !isResolvedAbsolute2(projectRoot) || step === void 0) {
31779
31911
  return [];
31780
31912
  }
31781
31913
  const recording = path11.join(recordingDirFor(projectRoot), `${name}.yaml`);
@@ -31861,7 +31993,10 @@ async function stepForOlderServer(args, listedId) {
31861
31993
  async function e2eShadowWarningFor(tool, args) {
31862
31994
  const id = canonicalToolId(tool);
31863
31995
  if (id !== "e2e-execute" && id !== "e2e-read-prerequisite") return void 0;
31864
- const target = nestedFlowTarget(args);
31996
+ const root = args?.project_root;
31997
+ const target = nestedFlowTarget(
31998
+ typeof root === "string" ? { ...args, project_root: callerPath(root) } : args
31999
+ );
31865
32000
  if (target?.kind !== "name") return void 0;
31866
32001
  const picked = await pickE2eFile(target.paths);
31867
32002
  return picked.shadowed === void 0 ? void 0 : e2eShadowWarning(picked.path, picked.shadowed);
@@ -31979,6 +32114,34 @@ function assertRequiredPresent(meta3, args) {
31979
32114
  describeParamIssues({ issues }, record2)
31980
32115
  );
31981
32116
  }
32117
+ var MAX_NON_FINITE_ISSUES = 12;
32118
+ function assertFiniteNumbers(args) {
32119
+ const issues = [];
32120
+ const seen = /* @__PURE__ */ new WeakSet();
32121
+ const pending = [{ value: args, key: "" }];
32122
+ for (let i2 = 0; i2 < pending.length && issues.length < MAX_NON_FINITE_ISSUES; i2++) {
32123
+ const visit2 = pending[i2];
32124
+ const { value } = visit2;
32125
+ if (typeof value !== "object" || value === null || seen.has(value)) continue;
32126
+ seen.add(value);
32127
+ for (const [key, item] of Array.isArray(value) ? value.entries() : Object.entries(value)) {
32128
+ if (typeof item === "object" && item !== null) {
32129
+ pending.push({ value: item, key, parent: visit2 });
32130
+ } else if (typeof item === "number" && !Number.isFinite(item)) {
32131
+ const path30 = [key];
32132
+ for (let at = visit2; at.parent; at = at.parent) path30.push(at.key);
32133
+ path30.reverse();
32134
+ issues.push({ code: "invalid_type", path: path30, message: `expected a number, got ${item}` });
32135
+ if (issues.length === MAX_NON_FINITE_ISSUES) break;
32136
+ }
32137
+ }
32138
+ }
32139
+ if (issues.length === 0) return;
32140
+ throw new ToolInvocationError(
32141
+ describeParamIssues({ issues }, args),
32142
+ { errorKind: "validation", issues }
32143
+ );
32144
+ }
31982
32145
  function fetchFailure(err) {
31983
32146
  if (!(err instanceof Error)) return String(err);
31984
32147
  return err.cause instanceof Error ? `${err.message}: ${err.cause.message}` : err.message;
@@ -32025,7 +32188,7 @@ async function forwardedSecrets(args) {
32025
32188
  }
32026
32189
  let parsed;
32027
32190
  try {
32028
- parsed = text2 === void 0 ? void 0 : (0, import_yaml2.parse)(text2.trim(), { logLevel: "error" });
32191
+ parsed = text2 === void 0 ? void 0 : (0, import_yaml2.parse)(flowYamlSource(text2), { logLevel: "error" });
32029
32192
  } catch {
32030
32193
  continue;
32031
32194
  }
@@ -32056,6 +32219,34 @@ function secretsTransportRefusal(url2) {
32056
32219
  return void 0;
32057
32220
  }
32058
32221
  var FETCH_HEAD_BYTES = 256;
32222
+ function isRecord2(value) {
32223
+ return typeof value === "object" && value !== null && !Array.isArray(value);
32224
+ }
32225
+ var PROJECT_PATH_ADVICE = {
32226
+ project_root: "Pass the absolute path to the project root directory - the same cwd the calling agent is working in.",
32227
+ e2e_test_path: "Pass the absolute path to the e2e test file."
32228
+ };
32229
+ function assertAbsoluteProjectPaths(meta3, args) {
32230
+ if (!meta3 || !isRecord2(args)) return;
32231
+ const aliases = Object.entries(toolParamAliases(meta3.name));
32232
+ for (const [param, advice] of Object.entries(PROJECT_PATH_ADVICE)) {
32233
+ const value = args[param];
32234
+ if (typeof value !== "string" || callerPath(value) === value) continue;
32235
+ const names = [param, ...aliases.filter(([, current]) => current === param).map(([f]) => f)];
32236
+ if (!meta3.fileInputs?.some((spec) => names.some((n3) => spec.path.includes(`\${${n3}}`)))) {
32237
+ continue;
32238
+ }
32239
+ throw new Error(`${param} must be an absolute path (got "${value}"). ${advice}`);
32240
+ }
32241
+ }
32242
+ function failedRun(result) {
32243
+ if (!isRecord2(result)) return result;
32244
+ if (result.ok === true) return { ...result, ok: false };
32245
+ if (isRecord2(result.toolResult) && result.toolResult.ok === true) {
32246
+ return { ...result, toolResult: { ...result.toolResult, ok: false } };
32247
+ }
32248
+ return result;
32249
+ }
32059
32250
  function createToolsClient(options = {}) {
32060
32251
  let cached3 = null;
32061
32252
  const doFetch = options.fetchImpl ?? ((url2, init2) => fetch(url2, init2));
@@ -32100,10 +32291,12 @@ function createToolsClient(options = {}) {
32100
32291
  }
32101
32292
  async function callTool(name, args, opts) {
32102
32293
  opts?.signal?.throwIfAborted();
32294
+ assertFiniteNumbers(args);
32103
32295
  const { url: url2, token, remote } = await route();
32104
32296
  let finalArgs = canonicalToolArgs(name, args);
32105
32297
  const { tools: tools2, uploadFormats } = await fetchToolList({ signal: opts?.signal });
32106
32298
  const meta3 = findTool(tools2, name);
32299
+ if (options.refuseRelativeProjectPaths) assertAbsoluteProjectPaths(meta3, finalArgs);
32107
32300
  const olderServer = meta3 !== null && !tools2.some((t2) => t2.name === canonicalToolId(meta3.name));
32108
32301
  if (meta3) {
32109
32302
  finalArgs = await nameToE2ePathForOlderServer(meta3.name, meta3.fileInputs, finalArgs);
@@ -32141,7 +32334,7 @@ function createToolsClient(options = {}) {
32141
32334
  }
32142
32335
  }
32143
32336
  }
32144
- const result = applied.result;
32337
+ const result = applied.failed.length > 0 ? failedRun(applied.result) : applied.result;
32145
32338
  if (shadowWarning === void 0 || typeof result !== "object" || result === null || Array.isArray(result) || typeof result.warning === "string") {
32146
32339
  return result;
32147
32340
  }
@@ -32268,10 +32461,19 @@ function createToolsClient(options = {}) {
32268
32461
  }
32269
32462
 
32270
32463
  // ../argent-tools-client/src/artifacts.ts
32271
- import { copyFile, mkdir as mkdir4, readFile as readFile6, realpath as realpath4, rm as rm3, stat as stat5, writeFile as writeFile4 } from "node:fs/promises";
32464
+ import {
32465
+ copyFile,
32466
+ mkdir as mkdir4,
32467
+ mkdtemp,
32468
+ readFile as readFile6,
32469
+ realpath as realpath4,
32470
+ rm as rm3,
32471
+ stat as stat5,
32472
+ writeFile as writeFile4
32473
+ } from "node:fs/promises";
32272
32474
  import { constants as fsConstants } from "node:fs";
32273
32475
  import { tmpdir as tmpdir2 } from "node:os";
32274
- 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";
32476
+ 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";
32275
32477
  import { createHash as createHash3 } from "node:crypto";
32276
32478
  var ARTIFACT_MARKER2 = "__argentArtifact";
32277
32479
  function isArtifactHandle(value) {
@@ -32319,8 +32521,8 @@ function configuredRecordingsDir() {
32319
32521
  const trimmed = value.trim();
32320
32522
  if (trimmed === "") return null;
32321
32523
  const home = dirname9(argentHomeDir());
32322
- const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep4}`) ? join13(home, trimmed.slice(2)) : trimmed;
32323
- return resolve8(durableBaseDir(), expanded);
32524
+ const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep5}`) ? join13(home, trimmed.slice(2)) : trimmed;
32525
+ return resolve10(durableBaseDir(), expanded);
32324
32526
  }
32325
32527
  var MAX_ARTIFACT_BYTES = 2 * 1024 * 1024 * 1024;
32326
32528
  async function readCapped(res, cap) {
@@ -32353,10 +32555,10 @@ async function writeDurableUnique(dir, filename, write) {
32353
32555
  const stem = filename.slice(0, filename.length - ext.length);
32354
32556
  for (let i2 = 1; i2 <= 1e3; i2++) {
32355
32557
  const candidate = i2 === 1 ? filename : `${stem} (${i2})${ext}`;
32356
- const path25 = join13(dir, candidate);
32558
+ const path30 = join13(dir, candidate);
32357
32559
  try {
32358
- await write(path25);
32359
- return path25;
32560
+ await write(path30);
32561
+ return path30;
32360
32562
  } catch (err) {
32361
32563
  if (err?.code === "EEXIST") continue;
32362
32564
  throw err;
@@ -32367,7 +32569,7 @@ async function writeDurableUnique(dir, filename, write) {
32367
32569
  function durableSaveTarget(handle) {
32368
32570
  if (typeof handle.saveDir !== "string" || !handle.saveDir || handle.archive) return null;
32369
32571
  const rel = normalize2(handle.saveDir);
32370
- if (isAbsolute6(rel) || rel === ".." || rel.startsWith(`..${sep4}`) || rel.split(sep4).includes("..")) {
32572
+ if (isAbsolute6(rel) || rel === ".." || rel.startsWith(`..${sep5}`) || rel.split(sep5).includes("..")) {
32371
32573
  return null;
32372
32574
  }
32373
32575
  if (!ALLOWED_SAVE_DIRS.has(rel)) return null;
@@ -32412,16 +32614,22 @@ async function resolveLocalFile(handle) {
32412
32614
  return null;
32413
32615
  }
32414
32616
  }
32415
- async function downloadAndExtractArchive(handle, data, dir) {
32416
- const tarball = join13(dir, `${sanitizeSegment(handle.filename)}.tar.gz`);
32617
+ async function downloadAndExtractArchive(handle, data, dir, signal) {
32618
+ signal?.throwIfAborted();
32619
+ const attemptDir = await mkdtemp(join13(dir, "bundle-"));
32620
+ const tarball = join13(attemptDir, "download.tar");
32621
+ const extractDir = join13(attemptDir, "files");
32417
32622
  try {
32418
- await writeFile4(tarball, data);
32419
- return await safeExtractArchive(tarball, dir, handle.filename);
32623
+ await writeFile4(tarball, data, { signal });
32624
+ await mkdir4(extractDir);
32625
+ const member = await safeExtractArchive(tarball, extractDir, handle.filename, signal);
32626
+ await rm3(tarball);
32627
+ signal?.throwIfAborted();
32628
+ return member;
32420
32629
  } catch {
32421
- return null;
32422
- } finally {
32423
- await rm3(tarball, { force: true }).catch(() => {
32630
+ await rm3(attemptDir, { recursive: true, force: true }).catch(() => {
32424
32631
  });
32632
+ return null;
32425
32633
  }
32426
32634
  }
32427
32635
  async function materializeArtifacts(result, ctx) {
@@ -32507,7 +32715,7 @@ async function materializeArtifacts(result, ctx) {
32507
32715
  if (!data) return null;
32508
32716
  await ensureDir();
32509
32717
  if (value.archive === "tar.gz") {
32510
- return await downloadAndExtractArchive(value, data, dir);
32718
+ return await downloadAndExtractArchive(value, data, dir, ctx.signal);
32511
32719
  }
32512
32720
  if (value.size > 0 && data.length !== value.size) return null;
32513
32721
  const downloadedPath = join13(dir, sanitizeSegment(value.filename));
@@ -32967,8 +33175,8 @@ var Deferred = class {
32967
33175
  _resolve;
32968
33176
  _reject;
32969
33177
  constructor() {
32970
- this._promise = new Promise((resolve13, reject) => {
32971
- this._resolve = resolve13;
33178
+ this._promise = new Promise((resolve14, reject) => {
33179
+ this._resolve = resolve14;
32972
33180
  this._reject = reject;
32973
33181
  });
32974
33182
  }
@@ -33861,8 +34069,8 @@ var ExportOperation = class {
33861
34069
  _metrics;
33862
34070
  _exportScheduledResolve;
33863
34071
  constructor(exporter, logRecords, exportTimeoutMillis, metrics) {
33864
- this._exportScheduledPromise = new Promise((resolve13) => {
33865
- this._exportScheduledResolve = resolve13;
34072
+ this._exportScheduledPromise = new Promise((resolve14) => {
34073
+ this._exportScheduledResolve = resolve14;
33866
34074
  });
33867
34075
  this._exportCompleted = this._executeExport(exporter, logRecords, exportTimeoutMillis);
33868
34076
  this._metrics = metrics;
@@ -33887,7 +34095,7 @@ var ExportOperation = class {
33887
34095
  }
33888
34096
  }
33889
34097
  async _exportWithTimeout(exporter, logRecords, exportTimeoutMillis) {
33890
- return new Promise((resolve13, reject) => {
34098
+ return new Promise((resolve14, reject) => {
33891
34099
  const timer = setTimeout(() => {
33892
34100
  reject(new Error("Timeout"));
33893
34101
  }, exportTimeoutMillis);
@@ -33895,7 +34103,7 @@ var ExportOperation = class {
33895
34103
  this._metrics.finishLogs(logRecords.length, result.error);
33896
34104
  clearTimeout(timer);
33897
34105
  if (result.code === ExportResultCode.SUCCESS) {
33898
- resolve13();
34106
+ resolve14();
33899
34107
  } else {
33900
34108
  reject(result.error ?? new Error("BatchLogRecordProcessor: log record export failed"));
33901
34109
  }
@@ -34676,7 +34884,7 @@ function parseRetryAfterToMills(retryAfter) {
34676
34884
  var DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION4}`;
34677
34885
  var MAX_RESPONSE_BODY_SIZE = 4 * 1024 * 1024;
34678
34886
  function sendWithHttp(request, url2, headers, compression, userAgent, agent, data, timeoutMillis) {
34679
- return new Promise((resolve13) => {
34887
+ return new Promise((resolve14) => {
34680
34888
  const parsedUrl = new URL(url2);
34681
34889
  if (userAgent) {
34682
34890
  headers["User-Agent"] = `${userAgent} ${DEFAULT_USER_AGENT}`;
@@ -34695,7 +34903,7 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
34695
34903
  responseSize += chunk.length;
34696
34904
  if (responseSize > MAX_RESPONSE_BODY_SIZE) {
34697
34905
  const sizeError = new Error(`OTLP export response body exceeded size limit of ${MAX_RESPONSE_BODY_SIZE} bytes`);
34698
- resolve13({ status: "failure", error: sizeError });
34906
+ resolve14({ status: "failure", error: sizeError });
34699
34907
  res.destroy();
34700
34908
  return;
34701
34909
  }
@@ -34703,18 +34911,18 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
34703
34911
  });
34704
34912
  res.on("end", () => {
34705
34913
  if (res.statusCode && res.statusCode <= 299) {
34706
- resolve13({
34914
+ resolve14({
34707
34915
  status: "success",
34708
34916
  data: Buffer.concat(responseData)
34709
34917
  });
34710
34918
  } else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {
34711
- resolve13({
34919
+ resolve14({
34712
34920
  status: "retryable",
34713
34921
  retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
34714
34922
  });
34715
34923
  } else {
34716
34924
  const error63 = new OTLPExporterError(res.statusMessage, res.statusCode, Buffer.concat(responseData).toString());
34717
- resolve13({
34925
+ resolve14({
34718
34926
  status: "failure",
34719
34927
  error: error63
34720
34928
  });
@@ -34722,17 +34930,17 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
34722
34930
  });
34723
34931
  res.on("error", (error63) => {
34724
34932
  if (res.statusCode && res.statusCode <= 299) {
34725
- resolve13({
34933
+ resolve14({
34726
34934
  status: "success"
34727
34935
  });
34728
34936
  } else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {
34729
- resolve13({
34937
+ resolve14({
34730
34938
  status: "retryable",
34731
34939
  error: error63,
34732
34940
  retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
34733
34941
  });
34734
34942
  } else {
34735
- resolve13({
34943
+ resolve14({
34736
34944
  status: "failure",
34737
34945
  error: error63
34738
34946
  });
@@ -34741,26 +34949,26 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
34741
34949
  });
34742
34950
  req.setTimeout(timeoutMillis, () => {
34743
34951
  req.destroy();
34744
- resolve13({
34952
+ resolve14({
34745
34953
  status: "retryable",
34746
34954
  error: new Error("Request timed out")
34747
34955
  });
34748
34956
  });
34749
34957
  req.on("error", (error63) => {
34750
34958
  if (isHttpTransportNetworkErrorRetryable(error63)) {
34751
- resolve13({
34959
+ resolve14({
34752
34960
  status: "retryable",
34753
34961
  error: error63
34754
34962
  });
34755
34963
  } else {
34756
- resolve13({
34964
+ resolve14({
34757
34965
  status: "failure",
34758
34966
  error: error63
34759
34967
  });
34760
34968
  }
34761
34969
  });
34762
34970
  compressAndSend(req, compression, data, (error63) => {
34763
- resolve13({
34971
+ resolve14({
34764
34972
  status: "failure",
34765
34973
  error: error63
34766
34974
  });
@@ -34850,9 +35058,9 @@ var RetryingTransport = class {
34850
35058
  this._transport = transport;
34851
35059
  }
34852
35060
  retry(data, timeoutMillis, inMillis) {
34853
- return new Promise((resolve13, reject) => {
35061
+ return new Promise((resolve14, reject) => {
34854
35062
  setTimeout(() => {
34855
- this._transport.send(data, timeoutMillis).then(resolve13, reject);
35063
+ this._transport.send(data, timeoutMillis).then(resolve14, reject);
34856
35064
  }, inMillis);
34857
35065
  });
34858
35066
  }
@@ -34965,7 +35173,7 @@ function getSharedConfigurationFromEnvironment(signalIdentifier) {
34965
35173
  init_esm();
34966
35174
 
34967
35175
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-node-http-env-configuration.js
34968
- import * as fs7 from "fs";
35176
+ import * as fs8 from "fs";
34969
35177
  import * as path13 from "path";
34970
35178
  init_esm();
34971
35179
  function getStaticHeadersFromEnv(signalIdentifier) {
@@ -34987,7 +35195,7 @@ function appendRootPathToUrlIfNeeded(url2) {
34987
35195
  return void 0;
34988
35196
  }
34989
35197
  }
34990
- function appendResourcePathToUrl(url2, path25) {
35198
+ function appendResourcePathToUrl(url2, path30) {
34991
35199
  try {
34992
35200
  new URL(url2);
34993
35201
  } catch {
@@ -34997,11 +35205,11 @@ function appendResourcePathToUrl(url2, path25) {
34997
35205
  if (!url2.endsWith("/")) {
34998
35206
  url2 = url2 + "/";
34999
35207
  }
35000
- url2 += path25;
35208
+ url2 += path30;
35001
35209
  try {
35002
35210
  new URL(url2);
35003
35211
  } catch {
35004
- diag2.warn(`Configuration: Provided URL appended with '${path25}' is not a valid URL, using 'undefined' instead of '${url2}'`);
35212
+ diag2.warn(`Configuration: Provided URL appended with '${path30}' is not a valid URL, using 'undefined' instead of '${url2}'`);
35005
35213
  return void 0;
35006
35214
  }
35007
35215
  return url2;
@@ -35026,7 +35234,7 @@ function readFileFromEnv(signalSpecificEnvVar, nonSignalSpecificEnvVar, warningM
35026
35234
  const filePath = signalSpecificPath ?? nonSignalSpecificPath;
35027
35235
  if (filePath != null) {
35028
35236
  try {
35029
- return fs7.readFileSync(path13.resolve(process.cwd(), filePath));
35237
+ return fs8.readFileSync(path13.resolve(process.cwd(), filePath));
35030
35238
  } catch {
35031
35239
  diag2.warn(warningMessage);
35032
35240
  return void 0;
@@ -35112,7 +35320,7 @@ var OTLPLogExporter = class extends OTLPExporterBase {
35112
35320
  init_esm();
35113
35321
 
35114
35322
  // ../telemetry/src/debug.ts
35115
- import * as fs8 from "node:fs";
35323
+ import * as fs9 from "node:fs";
35116
35324
 
35117
35325
  // ../telemetry/src/paths.ts
35118
35326
  import * as path14 from "node:path";
@@ -35150,8 +35358,8 @@ function emitDebugPayload(payload) {
35150
35358
  } catch {
35151
35359
  }
35152
35360
  try {
35153
- fs8.mkdirSync(argentHomeDir(), { recursive: true });
35154
- fs8.appendFileSync(debugLogPath(), line + "\n");
35361
+ fs9.mkdirSync(argentHomeDir(), { recursive: true });
35362
+ fs9.appendFileSync(debugLogPath(), line + "\n");
35155
35363
  } catch {
35156
35364
  }
35157
35365
  }
@@ -35337,7 +35545,8 @@ var DEVICE_KINDS = [
35337
35545
  "emulator",
35338
35546
  "vvd",
35339
35547
  "device",
35340
- "app"
35548
+ "app",
35549
+ "catalyst"
35341
35550
  ];
35342
35551
  var DEBUGGER_NOT_CONNECTED_REASONS = [
35343
35552
  "metro_not_running",
@@ -35475,7 +35684,8 @@ var ALLOWED = {
35475
35684
  install_mode: INSTALL_MODE
35476
35685
  },
35477
35686
  "installation:allowlist_decision": {
35478
- is_enabled: bool
35687
+ is_enabled: bool,
35688
+ decided_by: oneOf(["flag", "default", "prompt"])
35479
35689
  },
35480
35690
  "installation:stale_config_cleanup": {
35481
35691
  removed_count: COUNT,
@@ -35662,9 +35872,9 @@ function isReplitAgent(env) {
35662
35872
  }
35663
35873
  var DEVIN_MARKER_PATH = "/opt/.devin";
35664
35874
  var JULES_MARKER_PATH = "/opt/environment_summary.sh";
35665
- function safeExists(fileExists, path25) {
35875
+ function safeExists(fileExists, path30) {
35666
35876
  try {
35667
- return fileExists(path25);
35877
+ return fileExists(path30);
35668
35878
  } catch {
35669
35879
  return false;
35670
35880
  }
@@ -36079,13 +36289,12 @@ function isCi(env = process.env) {
36079
36289
  if (GENERIC_CI_ENV_VARS.some((name) => Boolean(env[name]))) return true;
36080
36290
  return isKnownVendorCi(env);
36081
36291
  }
36082
- var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
36083
36292
 
36084
36293
  // ../telemetry/src/base-props.ts
36085
36294
  var SESSION_ID2 = randomUUID5();
36086
36295
  function readCliVersion() {
36087
36296
  if (true) {
36088
- return "0.34.1-next.7";
36297
+ return "0.34.1-next.70";
36089
36298
  }
36090
36299
  return "0.0.0";
36091
36300
  }
@@ -36118,7 +36327,7 @@ function getBaseProps(runtime) {
36118
36327
 
36119
36328
  // ../telemetry/src/identity.ts
36120
36329
  import * as crypto2 from "node:crypto";
36121
- import * as fs9 from "node:fs";
36330
+ import * as fs10 from "node:fs";
36122
36331
  import * as path15 from "node:path";
36123
36332
  var FINGERPRINT_PATTERN = /^[0-9a-f]{64}$/;
36124
36333
  var cached2 = null;
@@ -36215,17 +36424,17 @@ function resolveFingerprintOnce(resolveFingerprint) {
36215
36424
  function isCorruptIdFile(filePath) {
36216
36425
  let isRegularFile;
36217
36426
  try {
36218
- isRegularFile = fs9.lstatSync(filePath).isFile();
36427
+ isRegularFile = fs10.lstatSync(filePath).isFile();
36219
36428
  } catch {
36220
36429
  return false;
36221
36430
  }
36222
36431
  return isRegularFile && tryReadId(filePath) === null;
36223
36432
  }
36224
36433
  function writeIdFileAtomic(finalPath, id) {
36225
- fs9.mkdirSync(argentHomeDir(), { recursive: true });
36434
+ fs10.mkdirSync(argentHomeDir(), { recursive: true });
36226
36435
  let occupant;
36227
36436
  try {
36228
- occupant = fs9.lstatSync(finalPath);
36437
+ occupant = fs10.lstatSync(finalPath);
36229
36438
  } catch (err) {
36230
36439
  if (err.code !== "ENOENT") throw err;
36231
36440
  }
@@ -36236,24 +36445,24 @@ function writeIdFileAtomic(finalPath, id) {
36236
36445
  argentHomeDir(),
36237
36446
  `.telemetry-id.tmp.${process.pid}.${crypto2.randomUUID()}`
36238
36447
  );
36239
- const fd = fs9.openSync(tmpPath, "wx", 384);
36448
+ const fd = fs10.openSync(tmpPath, "wx", 384);
36240
36449
  try {
36241
36450
  try {
36242
- fs9.writeSync(fd, id);
36243
- fs9.fsyncSync(fd);
36451
+ fs10.writeSync(fd, id);
36452
+ fs10.fsyncSync(fd);
36244
36453
  } finally {
36245
- fs9.closeSync(fd);
36454
+ fs10.closeSync(fd);
36246
36455
  }
36247
- fs9.renameSync(tmpPath, finalPath);
36456
+ fs10.renameSync(tmpPath, finalPath);
36248
36457
  } finally {
36249
36458
  try {
36250
- fs9.unlinkSync(tmpPath);
36459
+ fs10.unlinkSync(tmpPath);
36251
36460
  } catch {
36252
36461
  }
36253
36462
  }
36254
36463
  }
36255
36464
  function mintRandomId(finalPath) {
36256
- fs9.mkdirSync(argentHomeDir(), { recursive: true });
36465
+ fs10.mkdirSync(argentHomeDir(), { recursive: true });
36257
36466
  let value = crypto2.randomUUID();
36258
36467
  for (let attempt = 0; attempt < 3; attempt++) {
36259
36468
  const tmpPath = path15.join(
@@ -36262,19 +36471,19 @@ function mintRandomId(finalPath) {
36262
36471
  );
36263
36472
  let fd;
36264
36473
  try {
36265
- fd = fs9.openSync(tmpPath, "wx", 384);
36474
+ fd = fs10.openSync(tmpPath, "wx", 384);
36266
36475
  } catch (err) {
36267
36476
  if (err.code === "EEXIST") continue;
36268
36477
  throw err;
36269
36478
  }
36270
36479
  try {
36271
36480
  try {
36272
- fs9.writeSync(fd, value);
36273
- fs9.fsyncSync(fd);
36481
+ fs10.writeSync(fd, value);
36482
+ fs10.fsyncSync(fd);
36274
36483
  } finally {
36275
- fs9.closeSync(fd);
36484
+ fs10.closeSync(fd);
36276
36485
  }
36277
- fs9.linkSync(tmpPath, finalPath);
36486
+ fs10.linkSync(tmpPath, finalPath);
36278
36487
  cached2 = { path: finalPath, id: value };
36279
36488
  return value;
36280
36489
  } catch (err) {
@@ -36293,7 +36502,7 @@ function mintRandomId(finalPath) {
36293
36502
  throw err;
36294
36503
  } finally {
36295
36504
  try {
36296
- fs9.unlinkSync(tmpPath);
36505
+ fs10.unlinkSync(tmpPath);
36297
36506
  } catch {
36298
36507
  }
36299
36508
  }
@@ -36306,7 +36515,7 @@ function claimCorruptOccupant(finalPath) {
36306
36515
  `.telemetry-id.corrupt.${process.pid}.${crypto2.randomUUID()}`
36307
36516
  );
36308
36517
  try {
36309
- fs9.renameSync(finalPath, claimed);
36518
+ fs10.renameSync(finalPath, claimed);
36310
36519
  } catch {
36311
36520
  return null;
36312
36521
  }
@@ -36315,7 +36524,7 @@ function claimCorruptOccupant(finalPath) {
36315
36524
  grabbed = tryReadId(claimed);
36316
36525
  } finally {
36317
36526
  try {
36318
- fs9.unlinkSync(claimed);
36527
+ fs10.unlinkSync(claimed);
36319
36528
  } catch {
36320
36529
  }
36321
36530
  }
@@ -36327,9 +36536,9 @@ function peekAnonId() {
36327
36536
  function tryReadId(filePath) {
36328
36537
  let raw;
36329
36538
  try {
36330
- const stats = fs9.lstatSync(filePath);
36539
+ const stats = fs10.lstatSync(filePath);
36331
36540
  if (!stats.isFile()) return null;
36332
- raw = fs9.readFileSync(filePath, "utf8");
36541
+ raw = fs10.readFileSync(filePath, "utf8");
36333
36542
  } catch (err) {
36334
36543
  if (err.code === "ENOENT") return null;
36335
36544
  return null;
@@ -36344,7 +36553,7 @@ import { execFileSync as execFileSync2, spawn as spawn3 } from "node:child_proce
36344
36553
 
36345
36554
  // ../native-devtools-ios/src/index.ts
36346
36555
  import * as path16 from "node:path";
36347
- import * as fs10 from "node:fs";
36556
+ import * as fs11 from "node:fs";
36348
36557
  var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ?? path16.join(__dirname, "..", "dylibs");
36349
36558
  var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ?? path16.join(__dirname, "..", "bin");
36350
36559
  var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ?? path16.join(DYLIB_DIR, "tcp");
@@ -36364,9 +36573,9 @@ function platformBinDir() {
36364
36573
  function simulatorServerBinaryPath() {
36365
36574
  const binaryName = simulatorServerBinaryName();
36366
36575
  const p = path16.join(platformBinDir(), binaryName);
36367
- if (!fs10.existsSync(p)) {
36576
+ if (!fs11.existsSync(p)) {
36368
36577
  const flat = path16.join(BIN_DIR, binaryName);
36369
- const migrationHint = fs10.existsSync(flat) ? ` Found a binary at the old flat path ${flat}; move it to ${p} or update ARGENT_SIMULATOR_SERVER_DIR to point at the parent of the platform subdirectory.` : "";
36578
+ const migrationHint = fs11.existsSync(flat) ? ` Found a binary at the old flat path ${flat}; move it to ${p} or update ARGENT_SIMULATOR_SERVER_DIR to point at the parent of the platform subdirectory.` : "";
36370
36579
  throw new Error(
36371
36580
  `simulator-server binary not found for platform "${hostPlatformKey()}" at ${p}. Supported hosts today: darwin, linux (x86_64 and arm64), win32.${migrationHint}`
36372
36581
  );
@@ -36395,12 +36604,12 @@ function resolveHostFingerprint() {
36395
36604
  }
36396
36605
  }
36397
36606
  function resolveHostFingerprintAsync() {
36398
- return new Promise((resolve13) => {
36607
+ return new Promise((resolve14) => {
36399
36608
  let binary;
36400
36609
  try {
36401
36610
  binary = simulatorServerBinaryPath();
36402
36611
  } catch {
36403
- resolve13(null);
36612
+ resolve14(null);
36404
36613
  return;
36405
36614
  }
36406
36615
  let settled = false;
@@ -36413,7 +36622,7 @@ function resolveHostFingerprintAsync() {
36413
36622
  child?.kill("SIGKILL");
36414
36623
  } catch {
36415
36624
  }
36416
- resolve13(value);
36625
+ resolve14(value);
36417
36626
  };
36418
36627
  const watchdog = setTimeout(() => finish(null), FINGERPRINT_TIMEOUT_MS);
36419
36628
  watchdog.unref?.();
@@ -36446,14 +36655,15 @@ function resolveHostFingerprintAsync() {
36446
36655
  }
36447
36656
 
36448
36657
  // ../telemetry/src/consent.ts
36449
- import * as fs11 from "node:fs";
36658
+ import * as fs12 from "node:fs";
36659
+ import * as path17 from "node:path";
36450
36660
  var cache = /* @__PURE__ */ new Map();
36451
36661
  var sessionOverride = null;
36452
36662
  function readConfigOverrideAt(filePath) {
36453
36663
  const miss = { mtimeMs: null, fingerprint: null, enabledOverride: null };
36454
36664
  let stats;
36455
36665
  try {
36456
- stats = fs11.lstatSync(filePath);
36666
+ stats = fs12.lstatSync(filePath);
36457
36667
  } catch {
36458
36668
  cache.set(filePath, miss);
36459
36669
  return null;
@@ -36470,7 +36680,7 @@ function readConfigOverrideAt(filePath) {
36470
36680
  }
36471
36681
  let parsedEnabled = null;
36472
36682
  try {
36473
- const raw = fs11.readFileSync(filePath, "utf8");
36683
+ const raw = fs12.readFileSync(filePath, "utf8");
36474
36684
  const json2 = JSON.parse(raw);
36475
36685
  if (json2 && typeof json2 === "object") {
36476
36686
  const t2 = json2.telemetry;
@@ -36488,7 +36698,8 @@ function readPersistedConsent(cwd) {
36488
36698
  const globalPath = configFilePath("global");
36489
36699
  const projectPath = configFilePath("project", { cwd });
36490
36700
  const global2 = readConfigOverrideAt(globalPath);
36491
- const project = projectPath === globalPath ? null : readConfigOverrideAt(projectPath);
36701
+ const projectRoot = path17.dirname(path17.dirname(projectPath));
36702
+ const project = isHomeDir(projectRoot) ? null : readConfigOverrideAt(projectPath);
36492
36703
  if (project === false && global2 === false) {
36493
36704
  return { enabled: false, detail: "config.json (project and global)" };
36494
36705
  }
@@ -36627,7 +36838,7 @@ var DRAIN_GRACE_MS = 250;
36627
36838
  async function raceDrain(client2, timeoutMs) {
36628
36839
  await Promise.race([
36629
36840
  client2.shutdown(timeoutMs),
36630
- new Promise((resolve13) => setTimeout(resolve13, timeoutMs + DRAIN_GRACE_MS).unref())
36841
+ new Promise((resolve14) => setTimeout(resolve14, timeoutMs + DRAIN_GRACE_MS).unref())
36631
36842
  ]);
36632
36843
  }
36633
36844
  async function shutdown(timeoutMs = SHORT_FLUSH_TIMEOUT_MS) {
@@ -36713,11 +36924,15 @@ function booleanLiteral(raw) {
36713
36924
  return void 0;
36714
36925
  }
36715
36926
  function coerceScalar(raw, type, field) {
36927
+ if (Array.isArray(type) && type.length === 2 && type.includes("null")) {
36928
+ type = type.find((member) => member === "integer" || member === "number");
36929
+ }
36716
36930
  if (type === "number") {
36717
36931
  if (raw.trim() === "")
36718
36932
  throw new FlagParseException(`--${field} expected a number, got "${raw}"`);
36719
36933
  const n3 = Number(raw);
36720
- if (Number.isNaN(n3)) throw new FlagParseException(`--${field} expected a number, got "${raw}"`);
36934
+ if (!Number.isFinite(n3))
36935
+ throw new FlagParseException(`--${field} expected a number, got "${raw}"`);
36721
36936
  return n3;
36722
36937
  }
36723
36938
  if (type === "integer") {
@@ -36921,7 +37136,7 @@ function renderType(prop) {
36921
37136
  const suffix = isScalarType(prop.items?.type) ? " (repeatable)" : "";
36922
37137
  return `array<${item}>${suffix}`;
36923
37138
  }
36924
- return prop.type ?? "any";
37139
+ return Array.isArray(prop.type) ? prop.type.join(" | ") : prop.type ?? "any";
36925
37140
  }
36926
37141
 
36927
37142
  // ../argent-cli/src/run-validation.ts
@@ -37025,11 +37240,11 @@ function isValidationIssue(value) {
37025
37240
  }
37026
37241
 
37027
37242
  // ../argent-cli/src/e2e.ts
37028
- var import_yaml3 = __toESM(require_dist(), 1);
37029
- import * as fsp from "node:fs/promises";
37243
+ var import_yaml4 = __toESM(require_dist(), 1);
37244
+ import * as fsp2 from "node:fs/promises";
37030
37245
  import { constants as fsConstants2 } from "node:fs";
37031
37246
  import { createHash as createHash5 } from "node:crypto";
37032
- import * as path17 from "node:path";
37247
+ import * as path19 from "node:path";
37033
37248
 
37034
37249
  // ../argent-cli/src/command-args.ts
37035
37250
  var UsageError = class extends Error {
@@ -37044,7 +37259,7 @@ function listChoices(choices) {
37044
37259
  return `${quoted.slice(0, -1).join(", ")} or ${quoted[quoted.length - 1]}`;
37045
37260
  }
37046
37261
  function resolveName(tok, specs) {
37047
- if (tok.startsWith("--")) return tok.slice(2) in specs ? tok.slice(2) : null;
37262
+ if (tok.startsWith("--")) return Object.hasOwn(specs, tok.slice(2)) ? tok.slice(2) : null;
37048
37263
  const short = tok.slice(1);
37049
37264
  for (const [name, spec] of Object.entries(specs)) {
37050
37265
  if (spec.alias === short) return name;
@@ -37101,6 +37316,150 @@ function parseCommandArgs(argv, specs) {
37101
37316
  return { positionals, options };
37102
37317
  }
37103
37318
 
37319
+ // ../argent-cli/src/e2e-suite.ts
37320
+ var import_yaml3 = __toESM(require_dist(), 1);
37321
+ import * as fsp from "node:fs/promises";
37322
+ import * as path18 from "node:path";
37323
+ var SUITE_CONFIG_FILE = "suite.config.yaml";
37324
+ var SuiteConfigError = class extends Error {
37325
+ constructor(message) {
37326
+ super(message);
37327
+ this.name = "SuiteConfigError";
37328
+ }
37329
+ };
37330
+ var SUITE_CONFIG_KEYS = ["tests", "continueOnFailure"];
37331
+ function parseSuiteConfig(text2) {
37332
+ let doc;
37333
+ try {
37334
+ doc = (0, import_yaml3.parse)(text2, { logLevel: "error" });
37335
+ } catch (err) {
37336
+ throw new SuiteConfigError(
37337
+ `not valid YAML: ${(err instanceof Error ? err.message : String(err)).trimEnd()}`
37338
+ );
37339
+ }
37340
+ if (doc === null || doc === void 0) return { continueOnFailure: false };
37341
+ if (typeof doc !== "object" || Array.isArray(doc)) {
37342
+ throw new SuiteConfigError(
37343
+ `must be a YAML map with the keys ${SUITE_CONFIG_KEYS.join(" and ")}`
37344
+ );
37345
+ }
37346
+ const map2 = doc;
37347
+ for (const key of Object.keys(map2)) {
37348
+ if (!SUITE_CONFIG_KEYS.includes(key)) {
37349
+ throw new SuiteConfigError(
37350
+ `unknown key ${JSON.stringify(key)}; the allowed keys are ${SUITE_CONFIG_KEYS.join(" and ")}`
37351
+ );
37352
+ }
37353
+ }
37354
+ const config3 = { continueOnFailure: false };
37355
+ if ("continueOnFailure" in map2) {
37356
+ if (typeof map2.continueOnFailure !== "boolean") {
37357
+ throw new SuiteConfigError("continueOnFailure must be true or false");
37358
+ }
37359
+ config3.continueOnFailure = map2.continueOnFailure;
37360
+ }
37361
+ if ("tests" in map2) {
37362
+ const entries = map2.tests;
37363
+ if (!Array.isArray(entries) || entries.length === 0) {
37364
+ throw new SuiteConfigError("tests must be a non-empty list of test names");
37365
+ }
37366
+ const names = [];
37367
+ for (const [index, entry] of entries.entries()) {
37368
+ if (typeof entry !== "string") {
37369
+ throw new SuiteConfigError(
37370
+ `tests entry ${index + 1} is not a string; put the test name in quotes`
37371
+ );
37372
+ }
37373
+ const name = entry.endsWith(".yaml") ? entry.slice(0, -".yaml".length) : entry;
37374
+ if (!FLOW_NAME_PATTERN.test(name)) {
37375
+ throw new SuiteConfigError(`tests entry ${JSON.stringify(entry)} is not a valid test name`);
37376
+ }
37377
+ if (names.includes(name)) {
37378
+ throw new SuiteConfigError(`tests lists ${JSON.stringify(name)} more than once`);
37379
+ }
37380
+ names.push(name);
37381
+ }
37382
+ config3.tests = names;
37383
+ }
37384
+ return config3;
37385
+ }
37386
+ async function readSuiteConfig(dir) {
37387
+ let text2;
37388
+ try {
37389
+ text2 = await fsp.readFile(path18.join(dir, SUITE_CONFIG_FILE), "utf8");
37390
+ } catch (err) {
37391
+ const code = err.code;
37392
+ throw new SuiteConfigError(
37393
+ `could not read the file: ${code ?? (err instanceof Error ? err.message : String(err))}`
37394
+ );
37395
+ }
37396
+ return parseSuiteConfig(text2);
37397
+ }
37398
+ function unlistedWarning(file2, manifest) {
37399
+ return `${file2} is not listed in the tests of ${manifest} and does not run`;
37400
+ }
37401
+ async function planDirectoryRun(runDir, collected, manifests) {
37402
+ const byDir = /* @__PURE__ */ new Map();
37403
+ for (const rel of collected) {
37404
+ const dir = path18.dirname(rel);
37405
+ const files = byDir.get(dir);
37406
+ if (files) files.push(rel);
37407
+ else byDir.set(dir, [rel]);
37408
+ }
37409
+ const testless = manifests.filter((manifest) => !byDir.has(path18.dirname(manifest)));
37410
+ const suiteEntries = /* @__PURE__ */ new Map();
37411
+ const unlisted = [];
37412
+ for (const dir of new Set(manifests.map((manifest) => path18.dirname(manifest)))) {
37413
+ const files = byDir.get(dir) ?? [];
37414
+ const manifest = path18.join(dir, SUITE_CONFIG_FILE);
37415
+ let config3;
37416
+ let ordered = files;
37417
+ try {
37418
+ config3 = await readSuiteConfig(path18.join(runDir, dir));
37419
+ if (config3.tests) {
37420
+ ordered = config3.tests.map((name) => {
37421
+ const file2 = files.find((f) => path18.basename(f, ".yaml") === name);
37422
+ if (file2 === void 0) {
37423
+ throw new SuiteConfigError(
37424
+ `tests entry ${JSON.stringify(name)} names no e2e test in this directory`
37425
+ );
37426
+ }
37427
+ return file2;
37428
+ });
37429
+ }
37430
+ } catch (err) {
37431
+ if (!(err instanceof SuiteConfigError)) throw err;
37432
+ suiteEntries.set(dir, [
37433
+ {
37434
+ kind: "invalid-suite",
37435
+ dir,
37436
+ manifest,
37437
+ message: `${manifest}: ${err.message}`,
37438
+ error: err.message,
37439
+ tests: files
37440
+ }
37441
+ ]);
37442
+ continue;
37443
+ }
37444
+ const suite = { dir, manifest, continueOnFailure: config3.continueOnFailure };
37445
+ suiteEntries.set(
37446
+ dir,
37447
+ ordered.map((file2) => ({ kind: "test", path: file2, suite }))
37448
+ );
37449
+ for (const file2 of files) {
37450
+ if (!ordered.includes(file2)) unlisted.push({ path: file2, suite });
37451
+ }
37452
+ }
37453
+ const entries = [];
37454
+ for (const rel of [...collected, ...testless].sort()) {
37455
+ const dir = path18.dirname(rel);
37456
+ const inSuite = suiteEntries.get(dir);
37457
+ if (inSuite === void 0) entries.push({ kind: "test", path: rel });
37458
+ else if ((byDir.get(dir)?.[0] ?? rel) === rel) entries.push(...inSuite);
37459
+ }
37460
+ return { entries, unlisted };
37461
+ }
37462
+
37104
37463
  // ../argent-cli/src/e2e.ts
37105
37464
  var STATUS_GLYPH = {
37106
37465
  pass: "\u2713",
@@ -37131,7 +37490,8 @@ async function offersMacosPlatform() {
37131
37490
  }
37132
37491
  async function printHelp(toStderr = false) {
37133
37492
  const print = toStderr ? console.error : console.log;
37134
- const macos = await offersMacosPlatform() ? " macos |" : "";
37493
+ const offersMacos = await offersMacosPlatform();
37494
+ const platforms = SELECTABLE_PLATFORMS.filter((p) => p !== "macos" || offersMacos);
37135
37495
  print(`Usage: argent e2e <subcommand> [options]
37136
37496
 
37137
37497
  Run a YAML e2e test without an LLM in the loop. \`run\` takes any of these forms:
@@ -37144,7 +37504,8 @@ Run a YAML e2e test without an LLM in the loop. \`run\` takes any of these forms
37144
37504
  directory. It must not contain ".." segments (pass the resolved
37145
37505
  path instead); a path is what reaches e2e tests kept elsewhere, and
37146
37506
  what \`argent e2e list\` prints for nested ones
37147
- a dir Every e2e test in that directory, run sequentially
37507
+ a dir The e2e tests in that directory, in no guaranteed order. To set
37508
+ the order, add an optional suite.config.yaml file (see below)
37148
37509
 
37149
37510
  For a name and for a file path alike, the
37150
37511
  filename (minus .yaml) names the run's report and artifacts, so it must
@@ -37159,8 +37520,8 @@ a running instance.
37159
37520
 
37160
37521
  A directory run prints only the steps that need attention (each failure, each
37161
37522
  warning, and each script step's output), then its outcome. After the last test
37162
- it lists every failed test with its reason and a command that re-runs that test
37163
- alone, then a final summary; --recursive walks subdirectories too
37523
+ it lists every failed test with its reason and a command that re-runs it,
37524
+ then a final summary; --recursive walks subdirectories too
37164
37525
  (__baselines__, node_modules and dot-directories other than .argent are
37165
37526
  skipped). A directory run and list skip a YAML file that is not an e2e test.
37166
37527
  A test that fails its steps keeps the batch running, as does one the
@@ -37169,6 +37530,15 @@ transport failure, a rejection the server does not mark as validation, or a
37169
37530
  reply that is not a report stops the batch and counts the remaining tests
37170
37531
  skipped.
37171
37532
 
37533
+ A directory that holds a suite.config.yaml file is a suite: its tests run in
37534
+ the order of its \`tests:\` list, or in file name order without one, and a failed
37535
+ test skips the later tests of the suite unless the file sets
37536
+ \`continueOnFailure: true\`. A test file that the \`tests:\` list does not name
37537
+ does not run. list prints the tests of a suite in run order. It leaves out a
37538
+ test file that the \`tests:\` list does not name and the tests of a suite with
37539
+ an invalid suite.config.yaml file, and names them on stderr; list --json keeps
37540
+ those tests and gives each a warning code.
37541
+
37172
37542
  A test can declare a \`requires:\` block (platform, runtimeKind) that names the
37173
37543
  targets it supports. A directory run skips each test whose requirements the
37174
37544
  target does not meet, so the same directory runs on each platform without a
@@ -37197,18 +37567,19 @@ Without a link, all step kinds run.
37197
37567
 
37198
37568
  Subcommands:
37199
37569
  run <test|test.yaml|dir> Run a saved e2e test by name, a YAML file by path,
37200
- or every test in a directory, and report pass/fail
37570
+ or the tests in a directory, and report pass/fail
37201
37571
  (exit reflects result)
37202
37572
  list [dir] [-r] [--json] List runnable YAML paths in dir (-r: also in its
37203
37573
  subdirectories), or in .argent/e2e and
37204
37574
  .argent/flows (legacy) with notes on stderr.
37205
37575
  --json prints { "e2eTests": [...] } instead, with
37206
- path and an optional warning per entry, plus name,
37207
- legacy and shadowedBy when no dir is given
37576
+ path and an optional warning and suite per entry,
37577
+ plus name, legacy and shadowedBy when no dir is
37578
+ given
37208
37579
 
37209
37580
  Options (run):
37210
37581
  --device <id> Device id to run against (auto-detected when omitted)
37211
- --platform <p> ios | android | chromium | vega |${macos} ios-remote \u2014 narrow
37582
+ --platform <p> ${platforms.join(" | ")} \u2014 narrow
37212
37583
  auto-detection (ios never picks a remote simulator)
37213
37584
  --update-baselines Write/refresh screenshot baselines instead of diffing,
37214
37585
  also those of tests that tool: e2e-execute steps run,
@@ -37243,7 +37614,9 @@ var RUN_OPTIONS = {
37243
37614
  "json-stream": { kind: "boolean" },
37244
37615
  "recursive": { kind: "boolean", alias: "r" },
37245
37616
  "device": { kind: "value" },
37246
- "platform": { kind: "value" },
37617
+ // The tool-server's schema rejection carries no error_kind, so in a directory
37618
+ // run it would stop the whole batch.
37619
+ "platform": { kind: "value", choices: SELECTABLE_PLATFORMS },
37247
37620
  "output": { kind: "value" }
37248
37621
  };
37249
37622
  var LIST_OPTIONS = {
@@ -37270,7 +37643,7 @@ function parseRunArgs(argv) {
37270
37643
  json: options.json === true,
37271
37644
  jsonStream: options["json-stream"] === true
37272
37645
  };
37273
- for (const name of ["device", "platform", "output"]) {
37646
+ for (const name of ["device", "output"]) {
37274
37647
  if (options[name] === "") throw new FlagParseException(`--${name} requires a value`);
37275
37648
  }
37276
37649
  if (positionals[0] !== void 0) out.flowRef = positionals[0];
@@ -37369,15 +37742,19 @@ function renderBatchSummary(counts, durationMs) {
37369
37742
  return `${verdict} \u2014 ${counts.total} e2e test${counts.total === 1 ? "" : "s"}: ${counts.passed} passed, ${counts.failed} failed, ${counts.skipped} skipped${durationSuffix(durationMs)}`;
37370
37743
  }
37371
37744
  function summarizeFailure(report) {
37745
+ const unwritten = unwrittenBaselines(report);
37372
37746
  let n3 = 0;
37373
37747
  for (const s of report.steps) {
37374
37748
  if (s.kind === "echo") continue;
37375
37749
  n3++;
37376
37750
  if (s.status === "fail" || s.status === "error") {
37377
- const detail = s.reason ? String(s.reason) : void 0;
37751
+ const lines = s.reason ? [String(s.reason)] : [];
37752
+ for (const line of unwritten) lines.push(`baseline not written: ${line}`);
37753
+ const detail = lines.length ? lines.join("\n") : void 0;
37378
37754
  return { headline: `step ${n3} ${stepLabel(s, e2eTestOf(report))}`, detail };
37379
37755
  }
37380
37756
  }
37757
+ if (unwritten.length) return { headline: "baselines not written", detail: unwritten.join("\n") };
37381
37758
  return { headline: "failed with no failing step" };
37382
37759
  }
37383
37760
  function renderFailedFlow(f) {
@@ -37405,17 +37782,20 @@ function shellQuoteArg(arg) {
37405
37782
  return `'${arg.replaceAll("'", "'\\''")}'`;
37406
37783
  }
37407
37784
  function optionSafePath(p) {
37408
- return p.startsWith("-") ? `.${path17.sep}${p}` : p;
37785
+ return p.startsWith("-") ? `.${path19.sep}${p}` : p;
37409
37786
  }
37410
37787
  function rerunCommand(flowPath, rel, projectRoot, args) {
37411
37788
  const pathArg = (p) => shellQuoteArg(optionSafePath(p));
37412
- const fromCwd = path17.relative(projectRoot, flowPath);
37413
- const shown = path17.isAbsolute(fromCwd) || fromCwd.split(/[\\/]+/).includes("..") ? flowPath : fromCwd;
37414
- const parts = ["argent e2e run", pathArg(shown)];
37789
+ const fromCwd = path19.relative(projectRoot, flowPath) || ".";
37790
+ const shown = path19.isAbsolute(fromCwd) || fromCwd.split(/[\\/]+/).includes("..") ? flowPath : fromCwd;
37791
+ const parts = [
37792
+ "argent e2e run",
37793
+ pathArg(SAFE_FLOW_NAME.test(shown) ? `.${path19.sep}${shown}` : shown)
37794
+ ];
37415
37795
  if (args.device) parts.push("--device", shellQuoteArg(args.device));
37416
37796
  if (args.platform) parts.push("--platform", shellQuoteArg(args.platform));
37417
37797
  if (args.updateBaselines) parts.push("--update-baselines");
37418
- if (args.output) parts.push("--output", pathArg(path17.join(args.output, path17.dirname(rel))));
37798
+ if (args.output) parts.push("--output", pathArg(path19.join(args.output, path19.dirname(rel))));
37419
37799
  return parts.join(" ");
37420
37800
  }
37421
37801
  var EXPORT_SOURCE_MARKER = ".argent-e2e-source";
@@ -37423,27 +37803,27 @@ var LEGACY_EXPORT_SOURCE_MARKER = ".argent-flow-source";
37423
37803
  var MARKER_READ_RETRIES = 4;
37424
37804
  var MARKER_READ_DELAY_MS = 5;
37425
37805
  async function readExportMarker(dir) {
37426
- const owner = await readMarkerFile(path17.join(dir, EXPORT_SOURCE_MARKER));
37427
- return owner !== void 0 ? owner : await readMarkerFile(path17.join(dir, LEGACY_EXPORT_SOURCE_MARKER));
37806
+ const owner = await readMarkerFile(path19.join(dir, EXPORT_SOURCE_MARKER));
37807
+ return owner !== void 0 ? owner : await readMarkerFile(path19.join(dir, LEGACY_EXPORT_SOURCE_MARKER));
37428
37808
  }
37429
37809
  async function readMarkerFile(marker) {
37430
37810
  for (let attempt = 0; ; attempt++) {
37431
37811
  let owner;
37432
37812
  try {
37433
- owner = (await fsp.readFile(marker, "utf8")).trim();
37813
+ owner = (await fsp2.readFile(marker, "utf8")).trim();
37434
37814
  } catch {
37435
37815
  return void 0;
37436
37816
  }
37437
37817
  if (owner) return owner;
37438
37818
  if (attempt === MARKER_READ_RETRIES) return null;
37439
- await new Promise((resolve13) => setTimeout(resolve13, MARKER_READ_DELAY_MS));
37819
+ await new Promise((resolve14) => setTimeout(resolve14, MARKER_READ_DELAY_MS));
37440
37820
  }
37441
37821
  }
37442
37822
  async function classifyExportDir(dir, flowPath) {
37443
37823
  let owner = await readExportMarker(dir);
37444
37824
  if (owner === void 0) {
37445
37825
  try {
37446
- if ((await fsp.readdir(dir)).length === 0) {
37826
+ if ((await fsp2.readdir(dir)).length === 0) {
37447
37827
  return { state: "free" };
37448
37828
  }
37449
37829
  } catch (err) {
@@ -37460,8 +37840,8 @@ function occupiedBy(owner) {
37460
37840
  }
37461
37841
  async function takeExportDir(dir, flowPath) {
37462
37842
  try {
37463
- await fsp.mkdir(dir, { recursive: true });
37464
- await fsp.writeFile(path17.join(dir, EXPORT_SOURCE_MARKER), `${flowPath}
37843
+ await fsp2.mkdir(dir, { recursive: true });
37844
+ await fsp2.writeFile(path19.join(dir, EXPORT_SOURCE_MARKER), `${flowPath}
37465
37845
  `, { flag: "wx" });
37466
37846
  return null;
37467
37847
  } catch (err) {
@@ -37480,7 +37860,7 @@ async function claimExportDirName(outputDir, flowPath, stem) {
37480
37860
  }
37481
37861
  const avoided = [];
37482
37862
  for (const name of candidates) {
37483
- const dir = path17.join(outputDir, name);
37863
+ const dir = path19.join(outputDir, name);
37484
37864
  const claim2 = await classifyExportDir(dir, flowPath);
37485
37865
  const reason = claim2.state === "foreign" ? occupiedBy(claim2.owner) : await takeExportDir(dir, flowPath);
37486
37866
  if (reason !== null) {
@@ -37500,7 +37880,7 @@ async function claimExportDirName(outputDir, flowPath, stem) {
37500
37880
  return null;
37501
37881
  }
37502
37882
  async function exportFailureArtifacts(report, outputDir, flowPath, ctx) {
37503
- const stem = path17.basename(flowPath, ".yaml");
37883
+ const stem = path19.basename(flowPath, ".yaml");
37504
37884
  if (!SAFE_ARTIFACT_NAME.test(stem)) {
37505
37885
  console.error(
37506
37886
  `warning: skipping artifact export for unsafe e2e test filename ${JSON.stringify(stem)}`
@@ -37533,13 +37913,13 @@ async function exportFailureArtifacts(report, outputDir, flowPath, ctx) {
37533
37913
  if (dir === null) {
37534
37914
  const dirName = await claimExportDirName(outputDir, flowPath, stem);
37535
37915
  if (dirName === null) return;
37536
- dir = path17.join(outputDir, dirName);
37916
+ dir = path19.join(outputDir, dirName);
37537
37917
  }
37538
- const dest = path17.join(dir, fileName(role));
37539
- const rel = path17.relative(outputDir, dest);
37540
- if (rel.startsWith("..") || path17.isAbsolute(rel)) continue;
37918
+ const dest = path19.join(dir, fileName(role));
37919
+ const rel = path19.relative(outputDir, dest);
37920
+ if (rel.startsWith("..") || path19.isAbsolute(rel)) continue;
37541
37921
  try {
37542
- await fsp.copyFile(value, dest);
37922
+ await fsp2.copyFile(value, dest);
37543
37923
  s.artifacts[role] = dest;
37544
37924
  } catch (err) {
37545
37925
  console.error(
@@ -37552,7 +37932,7 @@ async function exportFailureArtifacts(report, outputDir, flowPath, ctx) {
37552
37932
  function keyFromBaselinePath(artifacts) {
37553
37933
  const baseline = artifacts.baseline;
37554
37934
  if (typeof baseline !== "string") return null;
37555
- return path17.basename(baseline).replace(/\.png$/, "");
37935
+ return path19.basename(baseline).replace(/\.png$/, "");
37556
37936
  }
37557
37937
  function resolveArtifactDisplayPaths(report) {
37558
37938
  for (const s of report.steps) {
@@ -37564,7 +37944,7 @@ function resolveArtifactDisplayPaths(report) {
37564
37944
  }
37565
37945
  function exitAfterFlush(code, streams = [process.stdout, process.stderr]) {
37566
37946
  return Promise.all(
37567
- streams.map((s) => new Promise((resolve13) => s.write("", () => resolve13())))
37947
+ streams.map((s) => new Promise((resolve14) => s.write("", () => resolve14())))
37568
37948
  ).then(() => process.exit(code));
37569
37949
  }
37570
37950
  function renderReport(report) {
@@ -37597,9 +37977,9 @@ ${renderSummary(report)}`);
37597
37977
  }
37598
37978
  async function isRunnableFlowFile(filePath) {
37599
37979
  try {
37600
- const stat7 = await fsp.stat(filePath);
37980
+ const stat7 = await fsp2.stat(filePath);
37601
37981
  if (!stat7.isFile()) return false;
37602
- await fsp.access(filePath, fsConstants2.R_OK);
37982
+ await fsp2.access(filePath, fsConstants2.R_OK);
37603
37983
  return true;
37604
37984
  } catch {
37605
37985
  return false;
@@ -37612,7 +37992,7 @@ var E2E_FILE_WARNING_TEXT = {
37612
37992
  async function checkE2eTestShape(filePath) {
37613
37993
  let content;
37614
37994
  try {
37615
- content = (await fsp.readFile(filePath, "utf8")).trim();
37995
+ content = (await fsp2.readFile(filePath, "utf8")).trim();
37616
37996
  } catch {
37617
37997
  return "ok";
37618
37998
  }
@@ -37620,7 +38000,7 @@ async function checkE2eTestShape(filePath) {
37620
38000
  if (!content.includes("steps") && !/^version:/m.test(content)) return "skip";
37621
38001
  let parsed;
37622
38002
  try {
37623
- parsed = (0, import_yaml3.parse)(content, { logLevel: "error" });
38003
+ parsed = (0, import_yaml4.parse)(content, { logLevel: "error" });
37624
38004
  } catch {
37625
38005
  return "syntax-error";
37626
38006
  }
@@ -37632,26 +38012,26 @@ async function resolveFlowRef(ref, projectRoot) {
37632
38012
  if (!SAFE_FLOW_NAME.test(ref)) return { suppliedPath: ref, fromName: false };
37633
38013
  const picked = await resolveE2eFile(projectRoot, ref);
37634
38014
  return {
37635
- suppliedPath: path17.relative(projectRoot, picked.path),
38015
+ suppliedPath: path19.relative(projectRoot, picked.path),
37636
38016
  fromName: true,
37637
- ...picked.shadowed === void 0 ? {} : { shadowed: path17.relative(projectRoot, picked.shadowed) }
38017
+ ...picked.shadowed === void 0 ? {} : { shadowed: path19.relative(projectRoot, picked.shadowed) }
37638
38018
  };
37639
38019
  }
37640
38020
  async function savedFlowHint(projectRoot, missingPath) {
37641
- const dirs = E2E_DIRS.map((rel) => ({ rel, abs: path17.resolve(projectRoot, rel) }));
38021
+ const dirs = E2E_DIRS.map((rel) => ({ rel, abs: path19.resolve(projectRoot, rel) }));
37642
38022
  for (const { abs } of dirs) {
37643
- const within = path17.relative(abs, missingPath);
37644
- if (!within.startsWith("..") && !path17.isAbsolute(within)) return "";
38023
+ const within = path19.relative(abs, missingPath);
38024
+ if (!within.startsWith("..") && !path19.isAbsolute(within)) return "";
37645
38025
  }
37646
- const wanted = `${path17.basename(missingPath, ".yaml")}.yaml`;
38026
+ const wanted = `${path19.basename(missingPath, ".yaml")}.yaml`;
37647
38027
  for (const { rel, abs } of dirs) {
37648
- const entries = await fsp.readdir(abs).catch(() => null);
38028
+ const entries = await fsp2.readdir(abs).catch(() => null);
37649
38029
  if (entries === null) continue;
37650
38030
  const actual = entries.includes(wanted) ? wanted : entries.find((name2) => name2.toLowerCase() === wanted.toLowerCase());
37651
38031
  if (actual === void 0) continue;
37652
- const name = path17.basename(actual, ".yaml");
38032
+ const name = path19.basename(actual, ".yaml");
37653
38033
  if (!SAFE_FLOW_NAME.test(name)) return "";
37654
- if (!await isRunnableFlowFile(path17.join(abs, actual))) return "";
38034
+ if (!await isRunnableFlowFile(path19.join(abs, actual))) return "";
37655
38035
  return `
37656
38036
  An e2e test named "${name}" is saved under ${rel} \u2014 did you mean: argent e2e run ${name}`;
37657
38037
  }
@@ -37659,19 +38039,24 @@ An e2e test named "${name}" is saved under ${rel} \u2014 did you mean: argent e2
37659
38039
  }
37660
38040
  async function collectFlowFiles(dir, recursive2) {
37661
38041
  const found = [];
38042
+ const manifests = [];
37662
38043
  const walk = async (current, rel) => {
37663
- for (const entry of await fsp.readdir(current, { withFileTypes: true })) {
37664
- const entryRel = rel ? path17.join(rel, entry.name) : entry.name;
38044
+ for (const entry of await fsp2.readdir(current, { withFileTypes: true })) {
38045
+ const entryRel = rel ? path19.join(rel, entry.name) : entry.name;
37665
38046
  if (entry.isDirectory()) {
37666
38047
  if (recursive2 && entry.name !== "__baselines__" && entry.name !== "node_modules" && (entry.name === ".argent" || !entry.name.startsWith("."))) {
37667
- await walk(path17.join(current, entry.name), entryRel).catch(() => {
38048
+ await walk(path19.join(current, entry.name), entryRel).catch(() => {
37668
38049
  });
37669
38050
  }
37670
38051
  continue;
37671
38052
  }
38053
+ if (entry.name === SUITE_CONFIG_FILE) {
38054
+ manifests.push(entryRel);
38055
+ continue;
38056
+ }
37672
38057
  if (!entry.name.endsWith(".yaml")) continue;
37673
- if (!SAFE_FLOW_NAME.test(path17.basename(entry.name, ".yaml"))) continue;
37674
- const filePath = path17.join(current, entry.name);
38058
+ if (!SAFE_FLOW_NAME.test(path19.basename(entry.name, ".yaml"))) continue;
38059
+ const filePath = path19.join(current, entry.name);
37675
38060
  if (!await isRunnableFlowFile(filePath)) continue;
37676
38061
  const shape = await checkE2eTestShape(filePath);
37677
38062
  if (shape === "skip") continue;
@@ -37679,7 +38064,10 @@ async function collectFlowFiles(dir, recursive2) {
37679
38064
  }
37680
38065
  };
37681
38066
  await walk(dir, "");
37682
- return found.sort((a2, b) => a2.path < b.path ? -1 : a2.path > b.path ? 1 : 0);
38067
+ return {
38068
+ files: found.sort((a2, b) => a2.path < b.path ? -1 : a2.path > b.path ? 1 : 0),
38069
+ manifests: manifests.sort()
38070
+ };
37683
38071
  }
37684
38072
  var RUN_TOOL_ID = "e2e-execute";
37685
38073
  function buildRunPayload(flowPath, projectRoot, args) {
@@ -37802,6 +38190,10 @@ function unwrittenBaselines(report) {
37802
38190
  return typeof file2 === "string" && typeof error63 === "string" ? [`${file2}: ${error63}`] : [];
37803
38191
  });
37804
38192
  }
38193
+ var INVALID_SUITE_SIGNAL = {
38194
+ error_code: FAILURE_CODES.FLOW_FILE_INVALID,
38195
+ error_kind: "validation"
38196
+ };
37805
38197
  async function runFlowDirectory(dir, args, projectRoot, options) {
37806
38198
  const printError = (message, err = message) => {
37807
38199
  console.error(args.json ? JSON.stringify(errorRecord(err, message)) : message);
@@ -37810,32 +38202,91 @@ async function runFlowDirectory(dir, args, projectRoot, options) {
37810
38202
  printError(message);
37811
38203
  return exitAfterFlush(2);
37812
38204
  };
37813
- let flows;
38205
+ let found;
37814
38206
  try {
37815
- flows = (await collectFlowFiles(dir, args.recursive)).map((file2) => file2.path);
38207
+ found = await collectFlowFiles(dir, args.recursive);
37816
38208
  } catch {
37817
38209
  return reject(`Could not read e2e test directory: ${dir}`);
37818
38210
  }
37819
- if (flows.length === 0) {
38211
+ const plan = await planDirectoryRun(
38212
+ dir,
38213
+ found.files.map((file2) => file2.path),
38214
+ found.manifests
38215
+ );
38216
+ if (plan.entries.length === 0) {
37820
38217
  return reject(
37821
38218
  `No e2e tests found in ${dir}` + (args.recursive ? "" : "\nPass -r/--recursive to include subdirectories.")
37822
38219
  );
37823
38220
  }
38221
+ printWarnings(
38222
+ plan.unlisted.map((file2) => unlistedWarning(file2.path, file2.suite.manifest)),
38223
+ args.json
38224
+ );
38225
+ const runOrder = plan.entries.flatMap(
38226
+ (entry) => entry.kind === "test" ? [entry] : [
38227
+ entry,
38228
+ ...entry.tests.map((rel) => ({
38229
+ kind: "test",
38230
+ path: rel,
38231
+ invalidManifest: entry.manifest
38232
+ }))
38233
+ ]
38234
+ );
37824
38235
  const { callTool, baseUrl } = runToolsClient(args, options);
37825
- const outputBase = args.output ? path17.resolve(args.output) : void 0;
38236
+ const outputBase = args.output ? path19.resolve(args.output) : void 0;
37826
38237
  const results = [];
37827
38238
  const failures = [];
37828
38239
  const batchStartedAt = Date.now();
38240
+ const failedInSuite = /* @__PURE__ */ new Map();
38241
+ const recordRun = (result, suite) => {
38242
+ results.push(result);
38243
+ if (result.status === "fail" && suite && !suite.continueOnFailure) {
38244
+ failedInSuite.set(suite, result.path);
38245
+ }
38246
+ };
38247
+ const skip = (rel, outcome, reason) => {
38248
+ results.push({ path: rel, status: "skip", ...reason !== void 0 && { reason } });
38249
+ if (!args.json) {
38250
+ console.log(
38251
+ ` ${STATUS_GLYPH.skip} ${outcome}${reason === void 0 ? "" : `
38252
+ ${reason}`}`
38253
+ );
38254
+ }
38255
+ };
37829
38256
  let stopped = false;
37830
38257
  let unreachable = false;
37831
- for (const [i2, rel] of flows.entries()) {
37832
- if (!args.json) console.log(`[${i2 + 1}/${flows.length}] ${rel}`);
38258
+ for (const [i2, entry] of runOrder.entries()) {
38259
+ const rel = entry.kind === "test" ? entry.path : entry.manifest;
38260
+ if (!args.json) console.log(`[${i2 + 1}/${runOrder.length}] ${rel}`);
38261
+ if (entry.kind === "invalid-suite") {
38262
+ const verdict = "not run (invalid suite config)";
38263
+ if (!args.json) console.log(` ${STATUS_GLYPH.error} ${verdict}`);
38264
+ console.error(
38265
+ args.json ? JSON.stringify({ event: "error", error: entry.message, ...INVALID_SUITE_SIGNAL }) : entry.message
38266
+ );
38267
+ results.push({ path: rel, status: "fail", error: entry.message, ...INVALID_SUITE_SIGNAL });
38268
+ failures.push({
38269
+ path: rel,
38270
+ headline: verdict,
38271
+ detail: entry.message,
38272
+ rerun: rerunCommand(path19.join(dir, entry.dir), rel, projectRoot, args)
38273
+ });
38274
+ continue;
38275
+ }
37833
38276
  if (stopped) {
37834
- results.push({ path: rel, status: "skip" });
37835
- if (!args.json) console.log(` ${STATUS_GLYPH.skip} not run (batch stopped)`);
38277
+ skip(rel, "not run (batch stopped)");
37836
38278
  continue;
37837
38279
  }
37838
- const flowPath = path17.join(dir, rel);
38280
+ if (entry.invalidManifest !== void 0) {
38281
+ skip(rel, "skipped (invalid suite config)", `invalid suite config: ${entry.invalidManifest}`);
38282
+ continue;
38283
+ }
38284
+ const failedEarlier = entry.suite && failedInSuite.get(entry.suite);
38285
+ if (failedEarlier !== void 0) {
38286
+ skip(rel, "skipped (earlier test failed)", `earlier test failed: ${failedEarlier}`);
38287
+ continue;
38288
+ }
38289
+ const flowPath = path19.join(dir, rel);
37839
38290
  const rerun = rerunCommand(flowPath, rel, projectRoot, args);
37840
38291
  let report;
37841
38292
  try {
@@ -37847,18 +38298,14 @@ async function runFlowDirectory(dir, args, projectRoot, options) {
37847
38298
  const message = err instanceof Error ? err.message : String(err);
37848
38299
  const toolErr = err instanceof ToolInvocationError ? err : void 0;
37849
38300
  if (toolErr?.errorCode === FAILURE_CODES.FLOW_REQUIREMENTS_UNMET) {
37850
- const reason = message.replace(/^\[Tool:[^\]]+\] /, "");
37851
- results.push({ path: rel, status: "skip", reason });
37852
- if (!args.json)
37853
- console.log(` ${STATUS_GLYPH.skip} skipped (requires not met)
37854
- ${reason}`);
38301
+ skip(rel, "skipped (requires not met)", message.replace(/^\[Tool:[^\]]+\] /, ""));
37855
38302
  continue;
37856
38303
  }
37857
38304
  const rejectedThisFlowOnly = toolErr?.errorKind === "validation";
37858
38305
  const verdict = unreachableErr ? UNREACHABLE_VERDICT : rejectedThisFlowOnly ? rejectionVerdict(toolErr?.errorCode) : "did not finish (run error)";
37859
38306
  if (!args.json) console.log(` ${STATUS_GLYPH.error} ${verdict}`);
37860
38307
  printError(message, err);
37861
- results.push({ path: rel, status: "fail", error: message, ...failureSignal2(err) });
38308
+ recordRun({ path: rel, status: "fail", error: message, ...failureSignal2(err) }, entry.suite);
37862
38309
  failures.push({ path: rel, headline: verdict, detail: message, rerun });
37863
38310
  if (!rejectedThisFlowOnly) stopped = true;
37864
38311
  if (unreachableErr) unreachable = true;
@@ -37869,7 +38316,7 @@ async function runFlowDirectory(dir, args, projectRoot, options) {
37869
38316
  const verdict = "did not finish (no run report)";
37870
38317
  if (!args.json) console.log(` ${STATUS_GLYPH.error} ${verdict}`);
37871
38318
  printError(message);
37872
- results.push({ path: rel, status: "fail", error: message });
38319
+ recordRun({ path: rel, status: "fail", error: message }, entry.suite);
37873
38320
  failures.push({ path: rel, headline: verdict, detail: message, rerun });
37874
38321
  stopped = true;
37875
38322
  continue;
@@ -37877,21 +38324,12 @@ async function runFlowDirectory(dir, args, projectRoot, options) {
37877
38324
  printWarnings(nestedStepWarnings(report.steps), args.json);
37878
38325
  await exportAndResolveArtifacts(
37879
38326
  report,
37880
- outputBase ? path17.join(outputBase, path17.dirname(rel)) : void 0,
38327
+ outputBase ? path19.join(outputBase, path19.dirname(rel)) : void 0,
37881
38328
  flowPath,
37882
38329
  baseUrl
37883
38330
  );
37884
- const unwritten = unwrittenBaselines(report);
37885
- results.push({ path: rel, status: report.ok && !unwritten.length ? "pass" : "fail", report });
38331
+ recordRun({ path: rel, status: report.ok ? "pass" : "fail", report }, entry.suite);
37886
38332
  if (!report.ok) failures.push({ path: rel, ...summarizeFailure(report), rerun });
37887
- else if (unwritten.length) {
37888
- failures.push({
37889
- path: rel,
37890
- headline: "baselines not written",
37891
- detail: unwritten.join("\n"),
37892
- rerun
37893
- });
37894
- }
37895
38333
  if (!args.json) {
37896
38334
  for (const line of renderFailedSteps(report)) console.log(line);
37897
38335
  console.log(` ${renderSummary(report, { withDevice: true })}`);
@@ -37975,14 +38413,14 @@ Run \`argent e2e --help\`.`
37975
38413
  Pass the fully resolved path to the directory.`
37976
38414
  );
37977
38415
  }
37978
- const entries = [];
38416
+ const rows = [];
37979
38417
  const byName = /* @__PURE__ */ new Map();
37980
38418
  let anyDir = false;
37981
38419
  const dirs = listDir === void 0 ? E2E_DIRS : [listDir];
37982
38420
  for (const dir of dirs) {
37983
- let files;
38421
+ let found;
37984
38422
  try {
37985
- files = await collectFlowFiles(path17.resolve(dir), listDir === void 0 || recursive2);
38423
+ found = await collectFlowFiles(path19.resolve(dir), listDir === void 0 || recursive2);
37986
38424
  } catch (err) {
37987
38425
  const code = err.code;
37988
38426
  if (listDir === void 0 && (code === "ENOENT" || code === "ENOTDIR")) continue;
@@ -37991,49 +38429,99 @@ Pass the fully resolved path to the directory.`
37991
38429
  );
37992
38430
  }
37993
38431
  anyDir = true;
37994
- for (const { path: rel, warning } of files) {
37995
- const shown = path17.join(dir, rel);
37996
- const warningField = warning !== void 0 && { warning };
38432
+ const fileWarnings = new Map(found.files.map((file2) => [file2.path, file2.warning]));
38433
+ const plan = await planDirectoryRun(
38434
+ path19.resolve(dir),
38435
+ found.files.map((file2) => file2.path),
38436
+ found.manifests
38437
+ );
38438
+ const show = (rel) => optionSafePath(path19.join(dir, rel));
38439
+ const add = (rel, inSuite, notRun) => {
38440
+ const shown = show(rel);
38441
+ const fileWarning = fileWarnings.get(rel);
38442
+ const warning = notRun?.warning ?? fileWarning;
38443
+ let entry;
37997
38444
  if (listDir !== void 0) {
37998
- entries.push({ path: optionSafePath(shown), ...warningField });
38445
+ entry = { path: shown };
38446
+ } else {
38447
+ const name = path19.dirname(rel) === "." ? path19.basename(rel, ".yaml") : void 0;
38448
+ const shadowedBy = name === void 0 ? void 0 : byName.get(name);
38449
+ if (name !== void 0 && shadowedBy === void 0) byName.set(name, shown);
38450
+ entry = {
38451
+ path: shown,
38452
+ ...name !== void 0 && { name },
38453
+ legacy: dir !== E2E_DIR,
38454
+ ...shadowedBy !== void 0 && { shadowedBy }
38455
+ };
38456
+ }
38457
+ if (inSuite) entry.suite = optionSafePath(path19.dirname(path19.join(dir, rel)));
38458
+ if (warning !== void 0) entry.warning = warning;
38459
+ const notes = notRun?.notes ?? [
38460
+ ...entry.shadowedBy === void 0 ? [] : [`warning: ${shown} is shadowed by ${entry.shadowedBy} when run by name`],
38461
+ ...fileWarning === void 0 ? [] : [`warning: ${shown} ${E2E_FILE_WARNING_TEXT[fileWarning]}`]
38462
+ ];
38463
+ rows.push({ entry, listed: notRun === void 0, notes });
38464
+ };
38465
+ for (const [i2, entry] of plan.entries.entries()) {
38466
+ if (entry.kind === "invalid-suite") {
38467
+ const manifest = show(entry.manifest);
38468
+ if (entry.tests.length === 0) {
38469
+ rows.push({
38470
+ entry: {
38471
+ path: manifest,
38472
+ ...listDir === void 0 && { legacy: dir !== E2E_DIR },
38473
+ suite: show(entry.dir),
38474
+ warning: "invalid-suite-config"
38475
+ },
38476
+ listed: false,
38477
+ notes: [`warning: ${manifest}: ${entry.error}`]
38478
+ });
38479
+ }
38480
+ for (const [j, rel] of entry.tests.entries()) {
38481
+ add(rel, true, {
38482
+ warning: "invalid-suite-config",
38483
+ notes: [
38484
+ ...j === 0 ? [`warning: ${manifest}: ${entry.error}`] : [],
38485
+ ` not listed: ${show(rel)}`
38486
+ ]
38487
+ });
38488
+ }
37999
38489
  continue;
38000
38490
  }
38001
- const name = path17.dirname(rel) === "." ? path17.basename(rel, ".yaml") : void 0;
38002
- const shadowedBy = name === void 0 ? void 0 : byName.get(name);
38003
- if (name !== void 0 && shadowedBy === void 0) byName.set(name, shown);
38004
- entries.push({
38005
- path: shown,
38006
- ...name !== void 0 && { name },
38007
- legacy: dir !== E2E_DIR,
38008
- ...shadowedBy !== void 0 && { shadowedBy },
38009
- ...warningField
38010
- });
38491
+ add(entry.path, entry.suite !== void 0);
38492
+ const next = plan.entries[i2 + 1];
38493
+ if (entry.suite === void 0 || next?.kind === "test" && next.suite === entry.suite) {
38494
+ continue;
38495
+ }
38496
+ for (const file2 of plan.unlisted.filter((f) => f.suite === entry.suite)) {
38497
+ add(file2.path, true, {
38498
+ warning: "not-in-suite",
38499
+ notes: [`warning: ${unlistedWarning(show(file2.path), show(file2.suite.manifest))}`]
38500
+ });
38501
+ }
38011
38502
  }
38012
38503
  }
38013
38504
  if (json3) {
38014
- const doc = { e2eTests: entries, ...!anyDir && { warning: "no-e2e-directory" } };
38505
+ const doc = {
38506
+ e2eTests: rows.map((row) => row.entry),
38507
+ ...!anyDir && { warning: "no-e2e-directory" }
38508
+ };
38015
38509
  console.log(JSON.stringify(doc, null, 2));
38016
38510
  return;
38017
38511
  }
38512
+ const listed = rows.filter((row) => row.listed).map((row) => row.entry);
38018
38513
  if (!anyDir) {
38019
38514
  console.error(
38020
38515
  `warning: no ${E2E_DIRS.join(" or ")} directory in the current working directory`
38021
38516
  );
38022
- } else if (entries.length === 0) {
38517
+ } else if (rows.length === 0) {
38023
38518
  console.error(
38024
38519
  `No e2e tests found in ${listDir ?? E2E_DIRS.join(" or ")}` + (listDir === void 0 || recursive2 ? "" : "\nPass -r/--recursive to include subdirectories.")
38025
38520
  );
38026
38521
  } else {
38027
- console.log(entries.map((entry) => entry.path).join("\n"));
38028
- for (const entry of entries) {
38029
- if (entry.shadowedBy !== void 0)
38030
- console.error(
38031
- `warning: ${entry.path} is shadowed by ${entry.shadowedBy} when run by name`
38032
- );
38033
- if (entry.warning !== void 0)
38034
- console.error(`warning: ${entry.path} ${E2E_FILE_WARNING_TEXT[entry.warning]}`);
38035
- }
38036
- const legacyCount = entries.filter((entry) => entry.legacy).length;
38522
+ if (listed.length > 0) console.log(listed.map((entry) => entry.path).join("\n"));
38523
+ for (const note of rows.flatMap((row) => row.notes)) console.error(note);
38524
+ const legacyCount = listed.filter((entry) => entry.legacy).length;
38037
38525
  if (legacyCount > 0) {
38038
38526
  console.error(
38039
38527
  `note: ${legacyCount} test${legacyCount === 1 ? "" : "s"} listed from .argent/flows (legacy); move ${legacyCount === 1 ? "it" : "them"} to .argent/e2e`
@@ -38088,11 +38576,11 @@ Pass the fully resolved path to the directory.`
38088
38576
  }
38089
38577
  if (suppliedPath.split(/[\\/]+/).includes("..")) {
38090
38578
  let recovery = "Pass the fully resolved path to the e2e test's YAML.";
38091
- const suppliedBase2 = path17.basename(suppliedPath);
38579
+ const suppliedBase2 = path19.basename(suppliedPath);
38092
38580
  if (suppliedBase2 !== ".." && suppliedBase2 !== ".") {
38093
38581
  try {
38094
- const resolved = path17.join(await fsp.realpath(path17.dirname(suppliedPath)), suppliedBase2);
38095
- await fsp.stat(resolved);
38582
+ const resolved = path19.join(await fsp2.realpath(path19.dirname(suppliedPath)), suppliedBase2);
38583
+ await fsp2.stat(resolved);
38096
38584
  recovery = `Did you mean: argent e2e run ${shellQuoteArg(resolved)}`;
38097
38585
  } catch {
38098
38586
  }
@@ -38103,10 +38591,10 @@ Pass the fully resolved path to the directory.`
38103
38591
  2
38104
38592
  );
38105
38593
  }
38106
- const resolvedPath = path17.resolve(projectRoot, suppliedPath);
38594
+ const resolvedPath = path19.resolve(projectRoot, suppliedPath);
38107
38595
  let isDirectory = false;
38108
38596
  try {
38109
- isDirectory = (await fsp.stat(resolvedPath)).isDirectory();
38597
+ isDirectory = (await fsp2.stat(resolvedPath)).isDirectory();
38110
38598
  } catch {
38111
38599
  if (args.recursive && !fromName) {
38112
38600
  return fail(`E2E test directory not found: ${resolvedPath}`, 2);
@@ -38126,16 +38614,16 @@ Pass the fully resolved path to the directory.`
38126
38614
  }
38127
38615
  const separatorTrimmedPath = suppliedPath.replace(/[\\/]+$/, "");
38128
38616
  if (separatorTrimmedPath !== suppliedPath && separatorTrimmedPath !== "") {
38129
- const hint = SAFE_FLOW_NAME.test(separatorTrimmedPath) ? `.${path17.sep}${separatorTrimmedPath}` : separatorTrimmedPath;
38617
+ const hint = SAFE_FLOW_NAME.test(separatorTrimmedPath) ? `.${path19.sep}${separatorTrimmedPath}` : separatorTrimmedPath;
38130
38618
  return fail(
38131
38619
  `E2E test path must not end in a path separator \u2014 the separator claims a directory, which the kernel would refuse to open as a file, so the CLI would run a file this string does not name: ${suppliedPath}
38132
38620
  Did you mean: argent e2e run ${shellQuoteArg(hint)}`,
38133
38621
  2
38134
38622
  );
38135
38623
  }
38136
- if (path17.extname(suppliedPath) !== ".yaml") {
38137
- const looksLikeName = !suppliedPath.includes("/") && !suppliedPath.includes("\\") && path17.extname(suppliedPath) === "";
38138
- if (path17.basename(suppliedPath).toLowerCase() === ".yaml") {
38624
+ if (path19.extname(suppliedPath) !== ".yaml") {
38625
+ const looksLikeName = !suppliedPath.includes("/") && !suppliedPath.includes("\\") && path19.extname(suppliedPath) === "";
38626
+ if (path19.basename(suppliedPath).toLowerCase() === ".yaml") {
38139
38627
  return fail(
38140
38628
  `E2E test filename must have a non-empty name containing only letters, numbers, "_", or "-": ${suppliedPath}`,
38141
38629
  2
@@ -38148,15 +38636,15 @@ Names run \`${E2E_DIRS.map((dir) => `${dir}/<name>.yaml`).join("` or `")}\`; pas
38148
38636
  2
38149
38637
  );
38150
38638
  }
38151
- if (path17.extname(suppliedPath).toLowerCase() === ".yaml") {
38639
+ if (path19.extname(suppliedPath).toLowerCase() === ".yaml") {
38152
38640
  return fail(
38153
- `E2E test extension must be lowercase .yaml, not ${path17.extname(suppliedPath)}: ${suppliedPath}`,
38641
+ `E2E test extension must be lowercase .yaml, not ${path19.extname(suppliedPath)}: ${suppliedPath}`,
38154
38642
  2
38155
38643
  );
38156
38644
  }
38157
38645
  return fail(`E2E test path must end in .yaml: ${suppliedPath}`, 2);
38158
38646
  }
38159
- const flowName = path17.basename(suppliedPath, ".yaml");
38647
+ const flowName = path19.basename(suppliedPath, ".yaml");
38160
38648
  if (!SAFE_FLOW_NAME.test(flowName)) {
38161
38649
  return fail(
38162
38650
  `E2E test filename must have a non-empty name containing only letters, numbers, "_", or "-": ${suppliedPath}`,
@@ -38165,11 +38653,11 @@ Names run \`${E2E_DIRS.map((dir) => `${dir}/<name>.yaml`).join("` or `")}\`; pas
38165
38653
  }
38166
38654
  const flowPath = resolvedPath;
38167
38655
  try {
38168
- const stat7 = await fsp.stat(flowPath);
38656
+ const stat7 = await fsp2.stat(flowPath);
38169
38657
  if (!stat7.isFile()) {
38170
38658
  return fail(`E2E test path is not a file: ${flowPath}`, 2);
38171
38659
  }
38172
- await fsp.access(flowPath, fsConstants2.R_OK);
38660
+ await fsp2.access(flowPath, fsConstants2.R_OK);
38173
38661
  } catch (err) {
38174
38662
  const code = err.code;
38175
38663
  const detail = code === "ENOENT" ? "E2E test file not found" : "Could not read e2e test file";
@@ -38180,12 +38668,12 @@ No e2e test named "${args.flowRef}" is saved in ${E2E_DIRS.join(" or ")} \u2014
38180
38668
  }
38181
38669
  return fail(`${detail}: ${flowPath}${recovery}`, 2);
38182
38670
  }
38183
- const suppliedBase = path17.basename(flowPath);
38184
- const siblings = await fsp.readdir(path17.dirname(flowPath)).catch(() => null);
38671
+ const suppliedBase = path19.basename(flowPath);
38672
+ const siblings = await fsp2.readdir(path19.dirname(flowPath)).catch(() => null);
38185
38673
  if (siblings !== null && !siblings.includes(suppliedBase)) {
38186
38674
  const actual = siblings.find((name) => name.toLowerCase() === suppliedBase.toLowerCase());
38187
- const actualRunnable = actual !== void 0 && path17.extname(actual) === ".yaml" && SAFE_FLOW_NAME.test(path17.basename(actual, ".yaml"));
38188
- const recovery = actualRunnable ? fromName ? `Did you mean: argent e2e run ${path17.basename(actual, ".yaml")}` : `Did you mean: argent e2e run ${shellQuoteArg(path17.join(path17.dirname(suppliedPath), actual))}` : actual !== void 0 ? `Rename ${actual} to ${suppliedBase} to run it \u2014 e2e test files must be lowercase .yaml.` : "Pass the e2e test file's name exactly as it appears on disk.";
38675
+ const actualRunnable = actual !== void 0 && path19.extname(actual) === ".yaml" && SAFE_FLOW_NAME.test(path19.basename(actual, ".yaml"));
38676
+ const recovery = actualRunnable ? fromName ? `Did you mean: argent e2e run ${path19.basename(actual, ".yaml")}` : `Did you mean: argent e2e run ${shellQuoteArg(path19.join(path19.dirname(suppliedPath), actual))}` : actual !== void 0 ? `Rename ${actual} to ${suppliedBase} to run it \u2014 e2e test files must be lowercase .yaml.` : "Pass the e2e test file's name exactly as it appears on disk.";
38189
38677
  return fail(
38190
38678
  `E2E test path must name the file as it appears on disk \u2014 this filesystem matched ${JSON.stringify(suppliedBase)} case-insensitively${actual !== void 0 ? ` to ${JSON.stringify(actual)}` : ""}, so the test name (which keys the report, __baselines__/, and --output) would be one no file carries: ${suppliedPath}
38191
38679
  ${recovery}`,
@@ -38244,7 +38732,7 @@ ${recovery}`,
38244
38732
  try {
38245
38733
  await exportAndResolveArtifacts(
38246
38734
  report,
38247
- args.output ? path17.resolve(args.output) : void 0,
38735
+ args.output ? path19.resolve(args.output) : void 0,
38248
38736
  flowPath,
38249
38737
  baseUrl
38250
38738
  );
@@ -38265,12 +38753,7 @@ ${renderSummary(report, { withDevice: true })}`);
38265
38753
  } else {
38266
38754
  console.log(renderReport(report));
38267
38755
  }
38268
- const unwritten = unwrittenBaselines(report);
38269
- if (!args.json && !args.jsonStream) {
38270
- for (const line of unwritten)
38271
- console.log(` ${STATUS_GLYPH.error} baseline not written: ${line}`);
38272
- }
38273
- return exitAfterFlush(report.ok && unwritten.length === 0 ? 0 : 1);
38756
+ return exitAfterFlush(report.ok ? 0 : 1);
38274
38757
  }
38275
38758
 
38276
38759
  // ../argent-cli/src/run.ts
@@ -38300,13 +38783,13 @@ function splitOptions(argv) {
38300
38783
  return { json: json2, outPath, argvForFlags: rest };
38301
38784
  }
38302
38785
  async function readStdin() {
38303
- return new Promise((resolve13, reject) => {
38786
+ return new Promise((resolve14, reject) => {
38304
38787
  let data = "";
38305
38788
  process.stdin.setEncoding("utf8");
38306
38789
  process.stdin.on("data", (chunk) => {
38307
38790
  data += chunk;
38308
38791
  });
38309
- process.stdin.on("end", () => resolve13(data));
38792
+ process.stdin.on("end", () => resolve14(data));
38310
38793
  process.stdin.on("error", reject);
38311
38794
  });
38312
38795
  }
@@ -38338,8 +38821,8 @@ async function fetchImageToFile(result, outPath) {
38338
38821
  const res = await fetch(url2);
38339
38822
  if (!res.ok) throw new Error(`Failed to download image: ${res.status} ${res.statusText}`);
38340
38823
  const buf = Buffer.from(await res.arrayBuffer());
38341
- fs12.mkdirSync(path18.dirname(path18.resolve(outPath)), { recursive: true });
38342
- fs12.writeFileSync(outPath, buf);
38824
+ fs13.mkdirSync(path20.dirname(path20.resolve(outPath)), { recursive: true });
38825
+ fs13.writeFileSync(outPath, buf);
38343
38826
  }
38344
38827
  function renderResult(result, outputHint, images, json2) {
38345
38828
  if (json2) return JSON.stringify(result, null, 2);
@@ -38546,8 +39029,8 @@ settled=false or debugger-status's not_connected.
38546
39029
  if (outPath && meta3.outputHint === "image") {
38547
39030
  try {
38548
39031
  if (images.length > 0) {
38549
- fs12.mkdirSync(path18.dirname(path18.resolve(outPath)), { recursive: true });
38550
- fs12.writeFileSync(outPath, images[0].data);
39032
+ fs13.mkdirSync(path20.dirname(path20.resolve(outPath)), { recursive: true });
39033
+ fs13.writeFileSync(outPath, images[0].data);
38551
39034
  } else if (result && typeof result === "object") {
38552
39035
  await fetchImageToFile(result, outPath);
38553
39036
  }
@@ -38568,7 +39051,7 @@ settled=false or debugger-status's not_connected.
38568
39051
  console.log(`Wrote: ${outPath}`);
38569
39052
  }
38570
39053
  if (failure2) {
38571
- await new Promise((resolve13) => process.stdout.write("", () => resolve13()));
39054
+ await new Promise((resolve14) => process.stdout.write("", () => resolve14()));
38572
39055
  console.error(failure2);
38573
39056
  await trackRunFailure(toolName, startedAt, {
38574
39057
  error_code: FAILURE_CODES.CLI_RUN_TOOL_RESULT_FAILED,
@@ -38587,6 +39070,7 @@ function summarize(description, max = 80) {
38587
39070
  if (firstLine.length <= max) return firstLine;
38588
39071
  return firstLine.slice(0, max - 1).trimEnd() + "\u2026";
38589
39072
  }
39073
+ var TOOLS_OPTIONS = { json: { kind: "boolean" } };
38590
39074
  async function tools(argv, options) {
38591
39075
  const { fetchTool, fetchTools } = createToolsClient({ paths: options.paths });
38592
39076
  async function listTools(json3) {
@@ -38608,10 +39092,10 @@ async function tools(argv, options) {
38608
39092
  console.log(`
38609
39093
  ${sorted.length} tools. Run \`argent tools describe <name>\` for details.`);
38610
39094
  }
38611
- async function describeTool(name, json3) {
38612
- const meta3 = await fetchTool(name);
39095
+ async function describeTool(name2, json3) {
39096
+ const meta3 = await fetchTool(name2);
38613
39097
  if (!meta3) {
38614
- console.error(`Tool "${name}" not found. Run \`argent tools\` to list available tools.`);
39098
+ console.error(`Tool "${name2}" not found. Run \`argent tools\` to list available tools.`);
38615
39099
  process.exit(1);
38616
39100
  }
38617
39101
  if (json3) {
@@ -38639,38 +39123,51 @@ Options:
38639
39123
  Listing tools contacts the argent tool-server, starting one if none is running.
38640
39124
  `);
38641
39125
  }
38642
- const json2 = argv.includes("--json");
38643
39126
  const isHelpFlag = (a2) => a2 === "--help" || a2 === "-h";
38644
- const positional = argv.filter((a2) => !a2.startsWith("--") || isHelpFlag(a2));
38645
- const sub = positional[0];
38646
- if (sub !== void 0 && isHelpFlag(sub)) {
39127
+ if (argv.some(isHelpFlag)) {
39128
+ const [first, second] = argv.filter((a2) => !a2.startsWith("-") || isHelpFlag(a2));
39129
+ if (first === "describe" && second !== void 0 && !isHelpFlag(second)) {
39130
+ await describeTool(second, argv.includes("--json"));
39131
+ return;
39132
+ }
38647
39133
  printUsage4();
38648
39134
  return;
38649
39135
  }
39136
+ const usageError = (message) => {
39137
+ console.error(`Error: ${message}
39138
+ `);
39139
+ printUsage4();
39140
+ process.exit(2);
39141
+ };
39142
+ let parsed;
39143
+ try {
39144
+ parsed = parseCommandArgs(argv, TOOLS_OPTIONS);
39145
+ } catch (err) {
39146
+ if (!(err instanceof UsageError)) throw err;
39147
+ return usageError(err.message);
39148
+ }
39149
+ const [sub, name, extra] = parsed.positionals;
39150
+ const json2 = parsed.options.json === true;
38650
39151
  if (!sub) {
38651
39152
  await listTools(json2);
38652
39153
  return;
38653
39154
  }
38654
39155
  if (sub === "describe") {
38655
- const name = positional[1];
38656
- if (!name) {
38657
- console.error("Usage: argent tools describe <tool-name>");
38658
- process.exit(1);
38659
- }
39156
+ if (!name) return usageError("`argent tools describe` requires a <tool-name>");
39157
+ if (extra !== void 0) usageError(`Unexpected argument "${extra}"`);
38660
39158
  await describeTool(name, json2);
38661
39159
  return;
38662
39160
  }
38663
- console.error(`Unknown subcommand: tools ${sub}`);
38664
- process.exit(1);
39161
+ usageError(`Unknown subcommand: tools ${sub}`);
38665
39162
  }
38666
39163
 
38667
39164
  // ../argent-cli/src/server.ts
38668
- import * as fs13 from "node:fs";
38669
- import * as path19 from "node:path";
39165
+ import * as fs14 from "node:fs";
39166
+ import * as path21 from "node:path";
38670
39167
  import { constants as constants2, homedir as homedir5, networkInterfaces } from "node:os";
38671
39168
  import { spawn as spawn4 } from "node:child_process";
38672
- var STATE_DIR2 = path19.join(homedir5(), ".argent");
38673
- var LOG_FILE2 = path19.join(STATE_DIR2, "tool-server.log");
39169
+ var STATE_DIR2 = path21.join(homedir5(), ".argent");
39170
+ var LOG_FILE2 = path21.join(STATE_DIR2, "tool-server.log");
38674
39171
  async function describeForeignServers(ownBundlePath) {
38675
39172
  const others = (await readAllToolsServerStates()).filter(
38676
39173
  ({ state: state2 }) => state2.bundlePath !== ownBundlePath && isToolsServerProcessAlive(state2.pid)
@@ -38734,19 +39231,39 @@ Stop one with: kill <pid>`);
38734
39231
  }
38735
39232
  }
38736
39233
  function logsCmd(follow) {
38737
- if (!fs13.existsSync(LOG_FILE2)) {
39234
+ if (!fs14.existsSync(LOG_FILE2)) {
38738
39235
  console.log(`No log file at ${LOG_FILE2}`);
38739
39236
  return;
38740
39237
  }
38741
39238
  if (!follow) {
38742
- process.stdout.write(fs13.readFileSync(LOG_FILE2, "utf8"));
39239
+ process.stdout.write(fs14.readFileSync(LOG_FILE2, "utf8"));
38743
39240
  return;
38744
39241
  }
38745
- const child = spawn4("tail", ["-f", LOG_FILE2], { stdio: "inherit" });
39242
+ const cannotFollow = (err) => {
39243
+ console.error(
39244
+ `argent server logs: cannot run \`tail\` to follow the log (${err.message}). Run \`argent server logs\` without -f to print it.`
39245
+ );
39246
+ process.exit(1);
39247
+ };
39248
+ let child;
39249
+ try {
39250
+ child = spawn4("tail", ["-f", LOG_FILE2], { stdio: "inherit" });
39251
+ } catch (err) {
39252
+ return cannotFollow(err);
39253
+ }
39254
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
39255
+ process.on(signal, () => {
39256
+ try {
39257
+ child.kill(signal);
39258
+ } catch {
39259
+ }
39260
+ });
39261
+ }
38746
39262
  child.on(
38747
39263
  "exit",
38748
39264
  (code, signal) => process.exit(code ?? (signal ? 128 + (signalNumber(signal) ?? 0) : 0))
38749
39265
  );
39266
+ child.on("error", cannotFollow);
38750
39267
  }
38751
39268
  var StartFlagError = class extends Error {
38752
39269
  };
@@ -38759,9 +39276,9 @@ var START_OPTIONS = {
38759
39276
  "host": { kind: "value" },
38760
39277
  "idle-timeout": { kind: "value" }
38761
39278
  };
38762
- function parseOrStartFlagError(parse3) {
39279
+ function parseOrStartFlagError(parse4) {
38763
39280
  try {
38764
- return parse3();
39281
+ return parse4();
38765
39282
  } catch (err) {
38766
39283
  if (err instanceof UsageError) throw new StartFlagError(err.message);
38767
39284
  throw err;
@@ -38966,10 +39483,20 @@ async function runForeground(paths, port, host, idleTimeoutMinutes, token) {
38966
39483
  idleTimeoutMinutes,
38967
39484
  token
38968
39485
  });
38969
- const child = spawn4("node", [paths.bundlePath, "start"], {
38970
- stdio: "inherit",
38971
- env
38972
- });
39486
+ const cannotStart = (err) => {
39487
+ const message = err instanceof Error ? err.message : String(err);
39488
+ console.error(`argent server start: failed to spawn tool-server: ${message}`);
39489
+ process.exit(1);
39490
+ };
39491
+ let child;
39492
+ try {
39493
+ child = spawn4(resolveToolsServerNode(), [paths.bundlePath, "start"], {
39494
+ stdio: "inherit",
39495
+ env
39496
+ });
39497
+ } catch (err) {
39498
+ return cannotStart(err);
39499
+ }
38973
39500
  const forward = (signal) => () => {
38974
39501
  try {
38975
39502
  child.kill(signal);
@@ -38978,8 +39505,10 @@ async function runForeground(paths, port, host, idleTimeoutMinutes, token) {
38978
39505
  };
38979
39506
  const onInt = forward("SIGINT");
38980
39507
  const onTerm = forward("SIGTERM");
39508
+ const onHup = forward("SIGHUP");
38981
39509
  process.on("SIGINT", onInt);
38982
39510
  process.on("SIGTERM", onTerm);
39511
+ process.on("SIGHUP", onHup);
38983
39512
  let stateWritten = false;
38984
39513
  const childPid = child.pid;
38985
39514
  if (childPid !== void 0) {
@@ -39003,15 +39532,19 @@ async function runForeground(paths, port, host, idleTimeoutMinutes, token) {
39003
39532
  const cleanup = () => {
39004
39533
  process.removeListener("SIGINT", onInt);
39005
39534
  process.removeListener("SIGTERM", onTerm);
39535
+ process.removeListener("SIGHUP", onHup);
39006
39536
  if (stateWritten) {
39007
- clearToolsServerState(paths.bundlePath).catch(() => {
39008
- });
39537
+ const file2 = stateFileForBundle(paths.bundlePath);
39538
+ try {
39539
+ const cur = JSON.parse(fs14.readFileSync(file2, "utf8"));
39540
+ if (cur.pid === childPid) fs14.unlinkSync(file2);
39541
+ } catch {
39542
+ }
39009
39543
  }
39010
39544
  };
39011
39545
  child.on("error", (err) => {
39012
39546
  cleanup();
39013
- console.error(`argent server start: failed to spawn tool-server: ${err.message}`);
39014
- process.exit(1);
39547
+ cannotStart(err);
39015
39548
  });
39016
39549
  child.on("exit", (code, signal) => {
39017
39550
  cleanup();
@@ -39023,51 +39556,96 @@ async function runForeground(paths, port, host, idleTimeoutMinutes, token) {
39023
39556
  function signalNumber(signal) {
39024
39557
  return constants2.signals[signal] ?? null;
39025
39558
  }
39559
+ var SUBCOMMAND_HELP = {
39560
+ status: `Usage: argent server status [--json]
39561
+
39562
+ Show the pid, port, and health of this install's tool-server.
39563
+
39564
+ Flags:
39565
+ --json Print machine-readable JSON.
39566
+ --help, -h Show this help.
39567
+ `,
39568
+ stop: `Usage: argent server stop
39569
+
39570
+ Terminate this install's tool-server.
39571
+
39572
+ Flags:
39573
+ --help, -h Show this help.
39574
+ `,
39575
+ logs: `Usage: argent server logs [-f]
39576
+
39577
+ Print the tool-server log (${LOG_FILE2}).
39578
+
39579
+ Flags:
39580
+ --follow, -f Keep printing new lines until Ctrl-C.
39581
+ --help, -h Show this help.
39582
+ `
39583
+ };
39584
+ var STATUS_OPTIONS = { json: { kind: "boolean" } };
39585
+ var STOP_OPTIONS = {};
39586
+ var LOGS_OPTIONS = { follow: { kind: "boolean", alias: "f" } };
39587
+ function parseSubcommandArgs(sub, argv, specs) {
39588
+ if (argv.includes("--help") || argv.includes("-h")) {
39589
+ console.log(SUBCOMMAND_HELP[sub]);
39590
+ return null;
39591
+ }
39592
+ try {
39593
+ const { positionals, options } = parseCommandArgs(argv, specs);
39594
+ if (positionals.length > 0) throw new UsageError(`Unexpected argument "${positionals[0]}"`);
39595
+ return options;
39596
+ } catch (err) {
39597
+ if (!(err instanceof UsageError)) throw err;
39598
+ console.error(`Error: ${err.message}
39599
+ `);
39600
+ console.log(SUBCOMMAND_HELP[sub]);
39601
+ process.exit(2);
39602
+ }
39603
+ }
39026
39604
  function printServerHelp() {
39027
39605
  console.log(`Usage:
39028
- argent server start [flags] Spawn a long-lived tool-server (see --help)
39606
+ argent server start [flags] Spawn a long-lived tool-server
39029
39607
  argent server status [--json] Show tool-server pid, port, and health
39030
39608
  argent server stop Terminate the running tool-server
39031
39609
  argent server logs [-f] Print (or follow) the tool-server log
39610
+
39611
+ Run \`argent server <subcommand> --help\` for its flags.
39032
39612
  `);
39033
39613
  }
39034
39614
  async function server(argv, options) {
39035
- const sub = argv[0];
39036
- const json2 = argv.includes("--json");
39037
- const follow = argv.includes("-f") || argv.includes("--follow");
39615
+ const [sub, ...rest] = argv;
39038
39616
  if (!sub || sub === "--help" || sub === "-h") {
39039
39617
  printServerHelp();
39040
39618
  return;
39041
39619
  }
39042
- const rest = argv.slice(1);
39043
- const actsOnServer = sub === "status" || sub === "stop" || sub === "logs";
39044
- if (actsOnServer && (rest.includes("--help") || rest.includes("-h"))) {
39045
- printServerHelp();
39046
- return;
39047
- }
39048
39620
  switch (sub) {
39049
39621
  case "start":
39050
39622
  await startCmd(rest, options?.paths);
39051
39623
  return;
39052
- case "status":
39053
- await statusCmd(json2, options?.paths);
39624
+ case "status": {
39625
+ const parsed = parseSubcommandArgs("status", rest, STATUS_OPTIONS);
39626
+ if (parsed) await statusCmd(parsed.json === true, options?.paths);
39054
39627
  return;
39628
+ }
39055
39629
  case "stop":
39056
- await stopCmd(options?.paths);
39630
+ if (parseSubcommandArgs("stop", rest, STOP_OPTIONS)) await stopCmd(options?.paths);
39057
39631
  return;
39058
- case "logs":
39059
- logsCmd(follow);
39632
+ case "logs": {
39633
+ const parsed = parseSubcommandArgs("logs", rest, LOGS_OPTIONS);
39634
+ if (parsed) logsCmd(parsed.follow === true);
39060
39635
  return;
39636
+ }
39061
39637
  default:
39062
- console.error(`Unknown subcommand: server ${sub}`);
39063
- process.exit(1);
39638
+ console.error(`Error: Unknown subcommand: server ${sub}
39639
+ `);
39640
+ printServerHelp();
39641
+ process.exit(2);
39064
39642
  }
39065
39643
  }
39066
39644
 
39067
39645
  // ../argent-cli/src/lens.ts
39068
- import * as fs14 from "node:fs";
39646
+ import * as fs15 from "node:fs";
39069
39647
  import * as os2 from "node:os";
39070
- import * as path20 from "node:path";
39648
+ import * as path22 from "node:path";
39071
39649
 
39072
39650
  // ../argent-cli/src/lens-terminal.ts
39073
39651
  import { execFileSync as execFileSync3 } from "node:child_process";
@@ -39285,15 +39863,15 @@ function isSessionAlive(session) {
39285
39863
  // ../argent-cli/src/lens-pty.ts
39286
39864
  import { chmodSync as chmodSync2, readdirSync as readdirSync2 } from "node:fs";
39287
39865
  import { createRequire } from "node:module";
39288
- import { dirname as dirname12, join as join19 } from "node:path";
39866
+ import { dirname as dirname14, join as join20 } from "node:path";
39289
39867
  var nodeRequire = createRequire(import.meta.url);
39290
39868
  function ensureSpawnHelperExecutable(req = nodeRequire) {
39291
39869
  if (process.platform !== "darwin") return;
39292
39870
  try {
39293
- const prebuilds = join19(dirname12(req.resolve("node-pty/package.json")), "prebuilds");
39871
+ const prebuilds = join20(dirname14(req.resolve("node-pty/package.json")), "prebuilds");
39294
39872
  for (const entry of readdirSync2(prebuilds)) {
39295
39873
  try {
39296
- chmodSync2(join19(prebuilds, entry, "spawn-helper"), 493);
39874
+ chmodSync2(join20(prebuilds, entry, "spawn-helper"), 493);
39297
39875
  } catch {
39298
39876
  }
39299
39877
  }
@@ -39325,7 +39903,7 @@ function ptyInjectBeats(text2) {
39325
39903
  ];
39326
39904
  }
39327
39905
  function sleep(ms) {
39328
- return new Promise((resolve13) => setTimeout(resolve13, ms));
39906
+ return new Promise((resolve14) => setTimeout(resolve14, ms));
39329
39907
  }
39330
39908
  var DEFAULT_COLS = 80;
39331
39909
  var DEFAULT_ROWS = 24;
@@ -39435,10 +40013,10 @@ function parseSseBuffer(buffer) {
39435
40013
  const events = [];
39436
40014
  let rest = normalised;
39437
40015
  for (; ; ) {
39438
- const sep6 = rest.indexOf("\n\n");
39439
- if (sep6 === -1) break;
39440
- const rawFrame = rest.slice(0, sep6);
39441
- rest = rest.slice(sep6 + 2);
40016
+ const sep7 = rest.indexOf("\n\n");
40017
+ if (sep7 === -1) break;
40018
+ const rawFrame = rest.slice(0, sep7);
40019
+ rest = rest.slice(sep7 + 2);
39442
40020
  let event = "message";
39443
40021
  const dataLines = [];
39444
40022
  for (const line of rawFrame.split("\n")) {
@@ -39546,7 +40124,7 @@ var SPAWN_GRACE_MS = 8e3;
39546
40124
  var DEATH_CONFIRMATIONS = 3;
39547
40125
  var SSE_RECONNECT_MS = 1e3;
39548
40126
  function sleep2(ms) {
39549
- return new Promise((resolve13) => setTimeout(resolve13, ms));
40127
+ return new Promise((resolve14) => setTimeout(resolve14, ms));
39550
40128
  }
39551
40129
  var TRUST_PROMPT_RE = /trust this folder|do you trust|yes,? i trust|trust the files in this/i;
39552
40130
  async function dismissTrustPrompt(session) {
@@ -39818,12 +40396,12 @@ async function lens(argv, options) {
39818
40396
  await endSession(baseUrl);
39819
40397
  process.exit(1);
39820
40398
  }
39821
- const seedFile = path20.join(os2.tmpdir(), `argent-lens-seed-${process.pid}-${Date.now()}.txt`);
39822
- fs14.writeFileSync(seedFile, buildSeedPrompt(), "utf8");
40399
+ const seedFile = path22.join(os2.tmpdir(), `argent-lens-seed-${process.pid}-${Date.now()}.txt`);
40400
+ fs15.writeFileSync(seedFile, buildSeedPrompt(), "utf8");
39823
40401
  const launchCmd = agent.launch(shellQuote(process.cwd()), shellQuote(seedFile));
39824
40402
  const removeSeedFile = () => {
39825
40403
  try {
39826
- fs14.rmSync(seedFile, { force: true });
40404
+ fs15.rmSync(seedFile, { force: true });
39827
40405
  } catch {
39828
40406
  }
39829
40407
  };
@@ -40014,14 +40592,16 @@ async function endSession(baseUrl) {
40014
40592
 
40015
40593
  // ../argent-cli/src/flags.ts
40016
40594
  var import_picocolors2 = __toESM(require_picocolors(), 1);
40595
+ import * as path24 from "node:path";
40017
40596
 
40018
40597
  // ../argent-cli/src/secrets.ts
40019
40598
  var import_picocolors = __toESM(require_picocolors(), 1);
40599
+ var LIST_OPTIONS2 = { json: { kind: "boolean" } };
40020
40600
  async function secrets(argv) {
40021
40601
  const [sub, ...rest] = argv;
40022
40602
  if (sub === void 0 || sub === "list") return cmdList(rest);
40023
40603
  if (sub === "--help" || sub === "-h") return printUsage();
40024
- if (sub === "--json") return cmdList([sub, ...rest]);
40604
+ if (sub === "--json") return cmdList(rest[0] === "list" ? [sub, ...rest.slice(1)] : argv);
40025
40605
  console.error(`Error: unknown subcommand "secrets ${sub}". Try \`argent secrets --help\`.`);
40026
40606
  process.exit(2);
40027
40607
  }
@@ -40051,7 +40631,16 @@ Examples:
40051
40631
  }
40052
40632
  async function cmdList(argv) {
40053
40633
  if (argv.includes("--help") || argv.includes("-h")) return printUsage();
40054
- const json2 = argv.includes("--json");
40634
+ let json2;
40635
+ try {
40636
+ const { positionals, options } = parseCommandArgs(argv, LIST_OPTIONS2);
40637
+ if (positionals.length > 0) throw new UsageError(`Unexpected argument "${positionals[0]}"`);
40638
+ json2 = options.json === true;
40639
+ } catch (err) {
40640
+ if (!(err instanceof UsageError)) throw err;
40641
+ console.error(`Error: ${err.message}. Try \`argent secrets --help\`.`);
40642
+ process.exit(2);
40643
+ }
40055
40644
  const sources = secretSources();
40056
40645
  const all = secretNames(sources);
40057
40646
  if (json2) {
@@ -40119,6 +40708,19 @@ async function linkedSecretsNote() {
40119
40708
  return `Note: a remote tool-server is linked (${routed.url}). ${note}`;
40120
40709
  }
40121
40710
 
40711
+ // ../argent-cli/src/project-scope.ts
40712
+ import * as path23 from "node:path";
40713
+ function degenerateProjectScopeWarning(scope, file2) {
40714
+ if (scope !== "project") return null;
40715
+ if (isHomeDir(path23.dirname(path23.dirname(file2)))) {
40716
+ return `WARNING: no project found between ${process.cwd()} and your home directory \u2014 "project" scope resolved to the home directory, so this writes the GLOBAL ${path23.basename(file2, ".json")} file (${file2}).`;
40717
+ }
40718
+ if (findProjectRoot(process.cwd()) === null) {
40719
+ return `WARNING: no project markers (.argent, .git, package.json) found above ${process.cwd()} \u2014 treating it as the project root and creating ${file2}.`;
40720
+ }
40721
+ return null;
40722
+ }
40723
+
40122
40724
  // ../argent-cli/src/flags.ts
40123
40725
  function colorState(enabled) {
40124
40726
  const label = (enabled ? "enabled" : "disabled").padEnd(8);
@@ -40187,18 +40789,21 @@ function runToggle(argv, command, registry2) {
40187
40789
  process.exit(2);
40188
40790
  }
40189
40791
  const filePath = getFlagsPath(parsed.scope);
40792
+ const warning = degenerateProjectScopeWarning(parsed.scope, filePath);
40793
+ let wrote = true;
40190
40794
  try {
40191
40795
  if (command === "enable") {
40192
40796
  setFlag(parsed.name, true, parsed.scope);
40193
40797
  } else if (getFlagDefinition(parsed.name, registry2)?.defaultEnabled) {
40194
40798
  setFlag(parsed.name, false, parsed.scope);
40195
40799
  } else {
40196
- unsetFlag(parsed.name, parsed.scope);
40800
+ wrote = unsetFlag(parsed.name, parsed.scope);
40197
40801
  }
40198
40802
  } catch (err) {
40199
40803
  console.error(`Failed to ${command} flag: ${err instanceof Error ? err.message : String(err)}`);
40200
40804
  process.exit(1);
40201
40805
  }
40806
+ if (wrote && warning) console.error(import_picocolors2.default.yellow(warning));
40202
40807
  if (command === "enable") {
40203
40808
  console.log(`Enabled flag "${parsed.name}" (${parsed.scope}). Stored at ${filePath}.`);
40204
40809
  } else {
@@ -40224,6 +40829,7 @@ function enable(argv, registry2 = FLAG_REGISTRY) {
40224
40829
  function disable(argv, registry2 = FLAG_REGISTRY) {
40225
40830
  runToggle(argv, "disable", registry2);
40226
40831
  }
40832
+ var FLAGS_OPTIONS = { json: { kind: "boolean" } };
40227
40833
  function flags(argv, registry2 = FLAG_REGISTRY) {
40228
40834
  if (argv.includes("--help") || argv.includes("-h")) {
40229
40835
  console.log(`Usage: argent flags [--json]
@@ -40238,8 +40844,20 @@ Options:
40238
40844
  `);
40239
40845
  return;
40240
40846
  }
40241
- const json2 = argv.includes("--json");
40242
- const projectFlags = readFlags("project");
40847
+ let json2;
40848
+ try {
40849
+ const { positionals, options } = parseCommandArgs(argv, FLAGS_OPTIONS);
40850
+ if (positionals.length > 0) {
40851
+ throw new UsageError(`Unexpected extra argument: "${positionals[0]}"`);
40852
+ }
40853
+ json2 = options.json === true;
40854
+ } catch (err) {
40855
+ if (!(err instanceof UsageError)) throw err;
40856
+ console.error(`Error: ${err.message}`);
40857
+ process.exit(2);
40858
+ }
40859
+ const projectIsHome = isHomeDir(path24.dirname(path24.dirname(getFlagsPath("project"))));
40860
+ const projectFlags = projectIsHome ? {} : readFlags("project");
40243
40861
  const globalFlags = readFlags("global");
40244
40862
  const effective = {};
40245
40863
  for (const [k, v] of Object.entries(globalFlags)) effective[k] = { value: v, scope: "global" };
@@ -40296,12 +40914,12 @@ Options:
40296
40914
  }
40297
40915
  console.log(`
40298
40916
  Global: ${getFlagsPath("global")}`);
40299
- console.log(` Project: ${getFlagsPath("project")}`);
40917
+ if (!projectIsHome) console.log(` Project: ${getFlagsPath("project")}`);
40300
40918
  }
40301
40919
 
40302
40920
  // ../argent-cli/src/config.ts
40303
40921
  var import_picocolors3 = __toESM(require_picocolors(), 1);
40304
- import * as path21 from "node:path";
40922
+ import * as path25 from "node:path";
40305
40923
  function config2(argv) {
40306
40924
  if (argv.length === 0 || argv[0] === "--help" || argv[0] === "-h") {
40307
40925
  printUsage2();
@@ -40330,7 +40948,11 @@ Show every recognized configuration value, its effective (merged) value, and
40330
40948
  the raw value stored at each scope.`);
40331
40949
  return;
40332
40950
  }
40333
- const json2 = argv.includes("--json");
40951
+ const { positionals, json: json2 } = parseArgs2(argv, LIST_OPTIONS3);
40952
+ if (positionals.length > 0) {
40953
+ console.error(`Error: unexpected extra argument "${positionals[0]}".`);
40954
+ process.exit(2);
40955
+ }
40334
40956
  const entries = listConfig();
40335
40957
  if (json2) {
40336
40958
  console.log(JSON.stringify({ config: entries }, null, 2));
@@ -40364,7 +40986,7 @@ Print a configuration value. Without --scope, prints the effective value after
40364
40986
  merging project and global. With --scope, prints only that scope's stored value.`);
40365
40987
  return;
40366
40988
  }
40367
- const { positionals, scope, json: json2 } = parseArgs2(argv);
40989
+ const { positionals, scope, json: json2 } = parseArgs2(argv, GET_OPTIONS);
40368
40990
  const key = positionals[0];
40369
40991
  if (!key) {
40370
40992
  console.error("Error: `argent config get` requires a <key>.");
@@ -40398,7 +41020,7 @@ write <project-root>/.argent/config.json. Booleans, numbers, and JSON arrays are
40398
41020
  parsed (e.g. \`true\`, \`42\`, \`["a","b"]\`); anything else is stored as a string.`);
40399
41021
  return;
40400
41022
  }
40401
- const { positionals, scope } = parseArgs2(argv);
41023
+ const { positionals, scope } = parseArgs2(argv, WRITE_OPTIONS);
40402
41024
  const key = positionals[0];
40403
41025
  const rawValue = positionals[1];
40404
41026
  if (!key || rawValue === void 0) {
@@ -40410,7 +41032,7 @@ parsed (e.g. \`true\`, \`42\`, \`["a","b"]\`); anything else is stored as a stri
40410
41032
  process.exit(2);
40411
41033
  }
40412
41034
  const targetScope = scope ?? "global";
40413
- const warning = degenerateProjectScopeWarning(targetScope);
41035
+ const warning = projectConfigWarning(targetScope);
40414
41036
  try {
40415
41037
  const stored = setConfigValue(key, coerceCliValue(rawValue), targetScope);
40416
41038
  if (warning) console.error(import_picocolors3.default.yellow(warning));
@@ -40429,7 +41051,7 @@ Remove a configuration value at a scope (default global). Falls back to the
40429
41051
  other scope / the default on the next read.`);
40430
41052
  return;
40431
41053
  }
40432
- const { positionals, scope } = parseArgs2(argv);
41054
+ const { positionals, scope } = parseArgs2(argv, WRITE_OPTIONS);
40433
41055
  const key = positionals[0];
40434
41056
  if (!key) {
40435
41057
  console.error("Error: `argent config unset` requires a <key>.");
@@ -40440,7 +41062,7 @@ other scope / the default on the next read.`);
40440
41062
  process.exit(2);
40441
41063
  }
40442
41064
  const targetScope = scope ?? "global";
40443
- const warning = degenerateProjectScopeWarning(targetScope);
41065
+ const warning = projectConfigWarning(targetScope);
40444
41066
  try {
40445
41067
  const removed = unsetConfigValue(key, targetScope);
40446
41068
  if (removed && warning) console.error(import_picocolors3.default.yellow(warning));
@@ -40453,13 +41075,14 @@ other scope / the default on the next read.`);
40453
41075
  reportError(err);
40454
41076
  }
40455
41077
  }
40456
- var CONFIG_OPTIONS = {
40457
- scope: { kind: "value", choices: ["global", "project"] },
40458
- json: { kind: "boolean" }
40459
- };
40460
- function parseArgs2(argv) {
41078
+ var SCOPE_OPTION = { kind: "value", choices: ["global", "project"] };
41079
+ var JSON_OPTION = { kind: "boolean" };
41080
+ var LIST_OPTIONS3 = { json: JSON_OPTION };
41081
+ var GET_OPTIONS = { scope: SCOPE_OPTION, json: JSON_OPTION };
41082
+ var WRITE_OPTIONS = { scope: SCOPE_OPTION };
41083
+ function parseArgs2(argv, specs) {
40461
41084
  try {
40462
- const { positionals, options } = parseCommandArgs(argv, CONFIG_OPTIONS);
41085
+ const { positionals, options } = parseCommandArgs(argv, specs);
40463
41086
  return {
40464
41087
  positionals,
40465
41088
  scope: options.scope ?? null,
@@ -40476,18 +41099,10 @@ function wantsHelp(argv) {
40476
41099
  }
40477
41100
  function scopeLabel(scope) {
40478
41101
  if (scope === "global") return "global";
40479
- return `project: ${path21.dirname(configDir("project"))}`;
41102
+ return `project: ${path25.dirname(configDir("project"))}`;
40480
41103
  }
40481
- function degenerateProjectScopeWarning(scope) {
40482
- if (scope !== "project") return null;
40483
- const projDir = configDir("project");
40484
- if (path21.resolve(projDir) === path21.resolve(configDir("global"))) {
40485
- return `WARNING: no project found between ${process.cwd()} and your home directory \u2014 "project" scope resolved to the home directory, so this writes the GLOBAL config file (${path21.join(projDir, "config.json")}).`;
40486
- }
40487
- if (findProjectRoot(process.cwd()) === null) {
40488
- return `WARNING: no project markers (.argent, .git, package.json) found above ${process.cwd()} \u2014 treating it as the project root and creating ${path21.join(projDir, "config.json")}.`;
40489
- }
40490
- return null;
41104
+ function projectConfigWarning(scope) {
41105
+ return degenerateProjectScopeWarning(scope, path25.join(configDir("project"), "config.json"));
40491
41106
  }
40492
41107
  function restartHint(key) {
40493
41108
  if (key !== "android.adbServerPort") return null;
@@ -41313,7 +41928,7 @@ import { styleText as styleText2, stripVTControlCharacters } from "node:util";
41313
41928
  import process$1 from "node:process";
41314
41929
  var import_sisteransi2 = __toESM(require_src(), 1);
41315
41930
  import { existsSync as existsSync7, lstatSync as lstatSync3, readdirSync as readdirSync3 } from "node:fs";
41316
- import { dirname as dirname14, join as join22 } from "node:path";
41931
+ import { dirname as dirname18, join as join23 } from "node:path";
41317
41932
  function isUnicodeSupported() {
41318
41933
  if (process$1.platform !== "win32") {
41319
41934
  return process$1.env.TERM !== "linux";
@@ -42201,7 +42816,9 @@ async function unlink3(argv) {
42201
42816
 
42202
42817
  // ../argent-cli/src/telemetry.ts
42203
42818
  var import_picocolors5 = __toESM(require_picocolors(), 1);
42819
+ import * as path26 from "node:path";
42204
42820
  var SCOPES = ["global", "project"];
42821
+ var SUBCOMMANDS = ["status", "enable", "disable"];
42205
42822
  var TELEMETRY_OPTIONS = {
42206
42823
  scope: { kind: "value", choices: SCOPES }
42207
42824
  };
@@ -42210,8 +42827,14 @@ async function telemetry(args) {
42210
42827
  let scope = "global";
42211
42828
  const wantsHelp2 = args.includes("--help") || args.includes("-h");
42212
42829
  if (!wantsHelp2) {
42830
+ if (sub !== void 0 && !SUBCOMMANDS.includes(sub)) {
42831
+ console.error(`Error: Unknown subcommand: telemetry ${sub}`);
42832
+ printUsage3();
42833
+ process.exit(2);
42834
+ }
42213
42835
  try {
42214
- const { positionals, options } = parseCommandArgs(args.slice(1), TELEMETRY_OPTIONS);
42836
+ const specs = sub === "status" ? {} : TELEMETRY_OPTIONS;
42837
+ const { positionals, options } = parseCommandArgs(args.slice(1), specs);
42215
42838
  if (positionals.length > 0) {
42216
42839
  throw new UsageError(`Unexpected argument "${positionals[0]}".`);
42217
42840
  }
@@ -42244,10 +42867,6 @@ async function telemetry(args) {
42244
42867
  case "disable":
42245
42868
  await cmdDisable(scope);
42246
42869
  return;
42247
- default:
42248
- console.error(`Unknown subcommand: telemetry ${sub}`);
42249
- await shutdown();
42250
- process.exit(1);
42251
42870
  }
42252
42871
  }
42253
42872
  function printUsage3() {
@@ -42285,9 +42904,14 @@ function describeSource(source) {
42285
42904
  return "default (no opt-out set)";
42286
42905
  }
42287
42906
  }
42907
+ function projectConfigWarning2(scope) {
42908
+ return degenerateProjectScopeWarning(scope, path26.join(configDir("project"), "config.json"));
42909
+ }
42288
42910
  async function cmdEnable(scope) {
42911
+ const warning = projectConfigWarning2(scope);
42289
42912
  const wasEnabled = isEnabled();
42290
42913
  markEnabled(scope);
42914
+ if (warning) console.error(import_picocolors5.default.yellow(warning));
42291
42915
  const nowEnabled = isEnabled();
42292
42916
  if (!nowEnabled) {
42293
42917
  console.log(
@@ -42303,8 +42927,10 @@ async function cmdEnable(scope) {
42303
42927
  await shutdown();
42304
42928
  }
42305
42929
  async function cmdDisable(scope) {
42930
+ const warning = projectConfigWarning2(scope);
42306
42931
  const wasEnabled = isEnabled();
42307
42932
  await markDisabled(scope);
42933
+ if (warning) console.error(import_picocolors5.default.yellow(warning));
42308
42934
  if (!wasEnabled) {
42309
42935
  console.log(import_picocolors5.default.dim(`Telemetry was already disabled (written at ${scopeLabel2(scope)}).`));
42310
42936
  } else {
@@ -42315,8 +42941,8 @@ async function cmdDisable(scope) {
42315
42941
 
42316
42942
  // ../argent-cli/src/providers.ts
42317
42943
  var import_picocolors7 = __toESM(require_picocolors(), 1);
42318
- import * as fs18 from "node:fs";
42319
- import * as path24 from "node:path";
42944
+ import * as fs19 from "node:fs";
42945
+ import * as path29 from "node:path";
42320
42946
 
42321
42947
  // ../device-providers/src/contract.ts
42322
42948
  var PROVIDER_SCHEMA_VERSION = 1;
@@ -42461,9 +43087,9 @@ var providerEnvelopeSchema = providerRecordSchema.extend({
42461
43087
  });
42462
43088
 
42463
43089
  // ../device-providers/src/read.ts
42464
- import * as fs15 from "node:fs";
43090
+ import * as fs16 from "node:fs";
42465
43091
  import * as os3 from "node:os";
42466
- import * as path22 from "node:path";
43092
+ import * as path27 from "node:path";
42467
43093
  var DISABLE_ENV = "ARGENT_DISABLE_DEVICE_PROVIDERS";
42468
43094
  var OVERRIDE_ENV = "ARGENT_DEVICE_PROVIDERS";
42469
43095
  function resolveHomeDir2() {
@@ -42472,7 +43098,7 @@ function resolveHomeDir2() {
42472
43098
  return trimmed ? raw : os3.homedir();
42473
43099
  }
42474
43100
  function providersDirectory() {
42475
- return path22.join(resolveHomeDir2(), ".argent", "providers");
43101
+ return path27.join(resolveHomeDir2(), ".argent", "providers");
42476
43102
  }
42477
43103
  function discoveryDisabled() {
42478
43104
  const raw = process.env[DISABLE_ENV];
@@ -42488,7 +43114,7 @@ function warnOnce(key, message) {
42488
43114
  function readProviderFile(file2) {
42489
43115
  let raw;
42490
43116
  try {
42491
- raw = fs15.readFileSync(file2, "utf8");
43117
+ raw = fs16.readFileSync(file2, "utf8");
42492
43118
  } catch {
42493
43119
  return void 0;
42494
43120
  }
@@ -42538,15 +43164,15 @@ function discoverProviders() {
42538
43164
  function descriptorFiles() {
42539
43165
  const directory = providersDirectory();
42540
43166
  try {
42541
- return fs15.readdirSync(directory).filter((name) => name.endsWith(".json")).sort().map((name) => path22.join(directory, name));
43167
+ return fs16.readdirSync(directory).filter((name) => name.endsWith(".json")).sort().map((name) => path27.join(directory, name));
42542
43168
  } catch {
42543
43169
  return [];
42544
43170
  }
42545
43171
  }
42546
43172
 
42547
43173
  // ../device-providers/src/write.ts
42548
- import * as fs16 from "node:fs";
42549
- import * as path23 from "node:path";
43174
+ import * as fs17 from "node:fs";
43175
+ import * as path28 from "node:path";
42550
43176
  var ProviderValidationError = class extends Error {
42551
43177
  /** One line per problem, `path: message`, in the order zod reported them. */
42552
43178
  issues;
@@ -42598,20 +43224,20 @@ function publishProvider(record2, options = {}) {
42598
43224
  );
42599
43225
  }
42600
43226
  const directory = providersDirectory();
42601
- const file2 = path23.join(directory, `${validated.id}.json`);
43227
+ const file2 = path28.join(directory, `${validated.id}.json`);
42602
43228
  const body = JSON.stringify(canonicalize(candidate), null, 2) + "\n";
42603
43229
  try {
42604
- if (fs16.readFileSync(file2, "utf8") === body) return { changed: false, path: file2 };
43230
+ if (fs17.readFileSync(file2, "utf8") === body) return { changed: false, path: file2 };
42605
43231
  } catch {
42606
43232
  }
42607
- fs16.mkdirSync(directory, { recursive: true });
43233
+ fs17.mkdirSync(directory, { recursive: true });
42608
43234
  const temporary = `${file2}.${process.pid}.tmp`;
42609
43235
  try {
42610
- fs16.writeFileSync(temporary, body);
42611
- fs16.renameSync(temporary, file2);
43236
+ fs17.writeFileSync(temporary, body);
43237
+ fs17.renameSync(temporary, file2);
42612
43238
  } catch (error63) {
42613
43239
  try {
42614
- fs16.rmSync(temporary, { force: true });
43240
+ fs17.rmSync(temporary, { force: true });
42615
43241
  } catch {
42616
43242
  }
42617
43243
  throw error63;
@@ -42622,9 +43248,9 @@ function withdrawProvider(id) {
42622
43248
  if (!PROVIDER_ID_SHAPE.test(id)) {
42623
43249
  throw new Error(`'${id}' is not a valid provider id (${String(PROVIDER_ID_SHAPE)}).`);
42624
43250
  }
42625
- const file2 = path23.join(providersDirectory(), `${id}.json`);
43251
+ const file2 = path28.join(providersDirectory(), `${id}.json`);
42626
43252
  try {
42627
- fs16.unlinkSync(file2);
43253
+ fs17.unlinkSync(file2);
42628
43254
  return true;
42629
43255
  } catch (e) {
42630
43256
  if (e.code === "ENOENT") return false;
@@ -42654,7 +43280,7 @@ function pruneOrphanedProviders(options = {}) {
42654
43280
  continue;
42655
43281
  }
42656
43282
  try {
42657
- fs16.unlinkSync(file2);
43283
+ fs17.unlinkSync(file2);
42658
43284
  removed.push(entry);
42659
43285
  } catch {
42660
43286
  }
@@ -42664,7 +43290,7 @@ function pruneOrphanedProviders(options = {}) {
42664
43290
 
42665
43291
  // ../argent-cli/src/providers-check.ts
42666
43292
  var import_picocolors6 = __toESM(require_picocolors(), 1);
42667
- import * as fs17 from "node:fs";
43293
+ import * as fs18 from "node:fs";
42668
43294
  var KNOWN_CAPABILITIES = new Set(EXTERNAL_CAPABILITIES);
42669
43295
  var PROBE_TIMEOUT_MS = 5e3;
42670
43296
  function error62(message) {
@@ -42730,7 +43356,7 @@ async function checkDevices(devices, findings) {
42730
43356
  );
42731
43357
  } else {
42732
43358
  try {
42733
- fs17.accessSync(device.deviceSet, fs17.constants.R_OK);
43359
+ fs18.accessSync(device.deviceSet, fs18.constants.R_OK);
42734
43360
  } catch {
42735
43361
  findings.push(
42736
43362
  error62(`${label}: deviceSet '${device.deviceSet}' is not readable by this user`)
@@ -42787,7 +43413,7 @@ async function checkDevices(devices, findings) {
42787
43413
  );
42788
43414
  } else {
42789
43415
  try {
42790
- fs17.accessSync(device.nativeDevtools.socketPath, fs17.constants.R_OK | fs17.constants.W_OK);
43416
+ fs18.accessSync(device.nativeDevtools.socketPath, fs18.constants.R_OK | fs18.constants.W_OK);
42791
43417
  } catch {
42792
43418
  findings.push(
42793
43419
  error62(
@@ -42858,7 +43484,7 @@ async function checkDescriptorFile(file2, expectedVersion) {
42858
43484
  const report = { deviceCount: 0, findings, source: file2 };
42859
43485
  let raw;
42860
43486
  try {
42861
- raw = fs17.readFileSync(file2, "utf8");
43487
+ raw = fs18.readFileSync(file2, "utf8");
42862
43488
  } catch (e) {
42863
43489
  findings.push(error62(`unreadable: ${e instanceof Error ? e.message : String(e)}`));
42864
43490
  return report;
@@ -42919,12 +43545,20 @@ ${title}`);
42919
43545
  }
42920
43546
 
42921
43547
  // ../argent-cli/src/providers.ts
42922
- var SUBCOMMANDS = ["check", "list", "prune", "publish", "withdraw"];
43548
+ var SUBCOMMANDS2 = ["check", "list", "prune", "publish", "withdraw"];
43549
+ var SUBCOMMAND_FLAGS = {
43550
+ check: ["--file", "--json", "--schema-version"],
43551
+ list: ["--json"],
43552
+ prune: ["--dry-run", "--json"],
43553
+ publish: ["--file", "--json", "--pid", "--schema-version", "--stdin"],
43554
+ withdraw: ["--json"]
43555
+ };
42923
43556
  var UsageError2 = class extends Error {
42924
43557
  };
42925
43558
  function parseArgs3(argv) {
42926
43559
  const parsed = {
42927
43560
  dryRun: false,
43561
+ flags: [],
42928
43562
  json: false,
42929
43563
  operands: [],
42930
43564
  schemaVersion: PROVIDER_SCHEMA_VERSION,
@@ -42943,6 +43577,7 @@ function parseArgs3(argv) {
42943
43577
  };
42944
43578
  for (let i2 = 0; i2 < argv.length; i2++) {
42945
43579
  const token = argv[i2];
43580
+ if (token.startsWith("--")) parsed.flags.push(token.split("=")[0]);
42946
43581
  if (token === "--json") {
42947
43582
  parsed.json = true;
42948
43583
  } else if (token === "--dry-run") {
@@ -42994,7 +43629,7 @@ async function readDocument(args) {
42994
43629
  }
42995
43630
  if (args.file) {
42996
43631
  try {
42997
- return { raw: fs18.readFileSync(args.file, "utf8"), source: args.file };
43632
+ return { raw: fs19.readFileSync(args.file, "utf8"), source: args.file };
42998
43633
  } catch (e) {
42999
43634
  throw new UsageError2(
43000
43635
  `cannot read ${args.file}: ${e instanceof Error ? e.message : String(e)}`
@@ -43127,7 +43762,7 @@ function runWithdraw(args) {
43127
43762
  throw new UsageError2(`'${id}' is not a valid provider id (${String(PROVIDER_ID_SHAPE)})`);
43128
43763
  }
43129
43764
  const removed = withdrawProvider(id);
43130
- const file2 = path24.join(providersDirectory(), `${id}.json`);
43765
+ const file2 = path29.join(providersDirectory(), `${id}.json`);
43131
43766
  if (args.json) {
43132
43767
  console.log(JSON.stringify({ ok: true, path: file2, removed }, null, 2));
43133
43768
  return;
@@ -43255,7 +43890,8 @@ Options:
43255
43890
  later prune can remove this descriptor if that
43256
43891
  process dies. Overrides any pid in the document.
43257
43892
  --dry-run prune: report what would be removed, remove nothing.
43258
- --schema-version <n> Contract version to validate against (default ${PROVIDER_SCHEMA_VERSION}).
43893
+ --schema-version <n> check, publish: the contract version to validate
43894
+ against (default ${PROVIDER_SCHEMA_VERSION}).
43259
43895
  --json Emit a machine-readable report on stdout.
43260
43896
  --help, -h Show this message.
43261
43897
 
@@ -43288,7 +43924,7 @@ async function providers(argv) {
43288
43924
  if (subcommand === void 0) process.exit(2);
43289
43925
  return;
43290
43926
  }
43291
- if (!SUBCOMMANDS.includes(subcommand)) {
43927
+ if (!SUBCOMMANDS2.includes(subcommand)) {
43292
43928
  console.error(`Unknown subcommand: "${subcommand}"`);
43293
43929
  printHelp3();
43294
43930
  process.exit(2);
@@ -43309,6 +43945,13 @@ async function providers(argv) {
43309
43945
  console.error(`Unknown argument: "${args.operands[0]}"`);
43310
43946
  process.exit(2);
43311
43947
  }
43948
+ const stray = args.flags.find(
43949
+ (flag) => !SUBCOMMAND_FLAGS[subcommand].includes(flag)
43950
+ );
43951
+ if (stray !== void 0) {
43952
+ console.error(`${stray} does not apply to \`argent providers ${subcommand}\``);
43953
+ process.exit(2);
43954
+ }
43312
43955
  try {
43313
43956
  switch (subcommand) {
43314
43957
  case "check":