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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +1 -0
  2. package/assets/ios-screen-stream/Info.plist +12 -0
  3. package/assets/ios-screen-stream/ios-screen-stream.swift +321 -0
  4. package/bin/argent-android-devtools-0.4.0.apk +0 -0
  5. package/bin/darwin/argent-macos-helper +0 -0
  6. package/bin/darwin/ax-service +0 -0
  7. package/bin/darwin/simulator-server +0 -0
  8. package/bin/darwin/tvos-ax-service +0 -0
  9. package/bin/darwin/tvos-hid-daemon +0 -0
  10. package/bin/linux/simulator-server +0 -0
  11. package/bin/linux-arm64/simulator-server +0 -0
  12. package/bin/network-inspector/network-inspector.jar +0 -0
  13. package/bin/tcp/ax-service +0 -0
  14. package/bin/win32/simulator-server.exe +0 -0
  15. package/dist/cli-cmds.mjs +925 -559
  16. package/dist/client.js +345 -179
  17. package/dist/flow-script-runner.mjs +1 -0
  18. package/dist/installer-help.js +4 -0
  19. package/dist/installer-help.js.map +1 -1
  20. package/dist/installer.mjs +1219 -922
  21. package/dist/ios-device-runner/ArgentRunner/ArgentRunnerUITests/ArgentLaunchPerformanceTests.swift +21 -0
  22. package/dist/ios-device-runner/ArgentRunner/ArgentRunnerUITests/ArgentRunnerSession+Commands.swift +9 -3
  23. package/dist/mcp-server.mjs +558 -712
  24. package/dist/preview-ui/index.html +28 -2
  25. package/dist/tool-args.generated.d.ts +58 -12
  26. package/dist/tool-server.cjs +11444 -5226
  27. package/dylibs/libArgentAudio.dylib +0 -0
  28. package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
  29. package/dylibs/libKeyboardPatch.dylib +0 -0
  30. package/dylibs/libNativeDevtoolsIos.dylib +0 -0
  31. package/dylibs/macos/libArgentInjectionBootstrap.dylib +0 -0
  32. package/dylibs/macos/libNativeDevtoolsMacos.dylib +0 -0
  33. package/dylibs/tcp/libArgentInjectionBootstrap.dylib +0 -0
  34. package/dylibs/tcp/libKeyboardPatch.dylib +0 -0
  35. package/dylibs/tcp/libNativeDevtoolsIos.dylib +0 -0
  36. package/dylibs/tvos/libArgentInjectionBootstrap.dylib +0 -0
  37. package/dylibs/tvos/libKeyboardPatch.dylib +0 -0
  38. package/dylibs/tvos/libNativeDevtoolsIos.dylib +0 -0
  39. package/package.json +1 -1
  40. package/rules/argent.md +6 -23
  41. package/skills/argent-create-e2e/references/e2e-yaml.md +2 -2
  42. package/skills/argent-create-e2e/references/live-authoring.md +1 -1
  43. package/skills/argent-device-interact/SKILL.md +22 -21
  44. package/skills/argent-device-interact/references/foldables.md +22 -0
  45. package/skills/argent-ios-device-interact/SKILL.md +2 -2
  46. package/skills/argent-macos-app-interact/SKILL.md +15 -5
  47. package/skills/argent-macos-app-interact/references/e2e.md +1 -1
  48. package/skills/argent-metro-debugger/SKILL.md +1 -1
  49. package/skills/argent-native-profiler/SKILL.md +14 -2
  50. package/skills/argent-react-native-app-workflow/SKILL.md +1 -1
  51. package/skills/argent-react-native-optimization/SKILL.md +10 -1
  52. package/skills/argent-react-native-profiler/SKILL.md +4 -3
  53. package/skills/argent-screen-recording/SKILL.md +3 -2
  54. package/skills/argent-screenshot-diff/SKILL.md +1 -1
package/dist/client.js CHANGED
@@ -4390,10 +4390,10 @@ var require_resolve_block_map = __commonJS({
4390
4390
  let offset = bm.offset;
4391
4391
  let commentEnd = null;
4392
4392
  for (const collItem of bm.items) {
4393
- const { start, key, sep: sep6, value } = collItem;
4393
+ const { start, key, sep: sep7, value } = collItem;
4394
4394
  const keyProps = resolveProps.resolveProps(start, {
4395
4395
  indicator: "explicit-key-ind",
4396
- next: key ?? sep6?.[0],
4396
+ next: key ?? sep7?.[0],
4397
4397
  offset,
4398
4398
  onError,
4399
4399
  parentIndent: bm.indent,
@@ -4407,7 +4407,7 @@ var require_resolve_block_map = __commonJS({
4407
4407
  else if ("indent" in key && key.indent !== bm.indent)
4408
4408
  onError(offset, "BAD_INDENT", startColMsg);
4409
4409
  }
4410
- if (!keyProps.anchor && !keyProps.tag && !sep6) {
4410
+ if (!keyProps.anchor && !keyProps.tag && !sep7) {
4411
4411
  commentEnd = keyProps.end;
4412
4412
  if (keyProps.comment) {
4413
4413
  if (map.comment)
@@ -4431,7 +4431,7 @@ var require_resolve_block_map = __commonJS({
4431
4431
  ctx.atKey = false;
4432
4432
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
4433
4433
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
4434
- const valueProps = resolveProps.resolveProps(sep6 ?? [], {
4434
+ const valueProps = resolveProps.resolveProps(sep7 ?? [], {
4435
4435
  indicator: "map-value-ind",
4436
4436
  next: value,
4437
4437
  offset: keyNode.range[2],
@@ -4447,7 +4447,7 @@ var require_resolve_block_map = __commonJS({
4447
4447
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
4448
4448
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
4449
4449
  }
4450
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep6, null, valueProps, onError);
4450
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep7, null, valueProps, onError);
4451
4451
  if (ctx.schema.compat)
4452
4452
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
4453
4453
  offset = valueNode.range[2];
@@ -4538,7 +4538,7 @@ var require_resolve_end = __commonJS({
4538
4538
  let comment = "";
4539
4539
  if (end) {
4540
4540
  let hasSpace = false;
4541
- let sep6 = "";
4541
+ let sep7 = "";
4542
4542
  for (const token of end) {
4543
4543
  const { source, type } = token;
4544
4544
  switch (type) {
@@ -4552,13 +4552,13 @@ var require_resolve_end = __commonJS({
4552
4552
  if (!comment)
4553
4553
  comment = cb;
4554
4554
  else
4555
- comment += sep6 + cb;
4556
- sep6 = "";
4555
+ comment += sep7 + cb;
4556
+ sep7 = "";
4557
4557
  break;
4558
4558
  }
4559
4559
  case "newline":
4560
4560
  if (comment)
4561
- sep6 += source;
4561
+ sep7 += source;
4562
4562
  hasSpace = true;
4563
4563
  break;
4564
4564
  default:
@@ -4601,18 +4601,18 @@ var require_resolve_flow_collection = __commonJS({
4601
4601
  let offset = fc.offset + fc.start.source.length;
4602
4602
  for (let i = 0; i < fc.items.length; ++i) {
4603
4603
  const collItem = fc.items[i];
4604
- const { start, key, sep: sep6, value } = collItem;
4604
+ const { start, key, sep: sep7, value } = collItem;
4605
4605
  const props = resolveProps.resolveProps(start, {
4606
4606
  flow: fcName,
4607
4607
  indicator: "explicit-key-ind",
4608
- next: key ?? sep6?.[0],
4608
+ next: key ?? sep7?.[0],
4609
4609
  offset,
4610
4610
  onError,
4611
4611
  parentIndent: fc.indent,
4612
4612
  startOnNewline: false
4613
4613
  });
4614
4614
  if (!props.found) {
4615
- if (!props.anchor && !props.tag && !sep6 && !value) {
4615
+ if (!props.anchor && !props.tag && !sep7 && !value) {
4616
4616
  if (i === 0 && props.comma)
4617
4617
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
4618
4618
  else if (i < fc.items.length - 1)
@@ -4666,8 +4666,8 @@ var require_resolve_flow_collection = __commonJS({
4666
4666
  }
4667
4667
  }
4668
4668
  }
4669
- if (!isMap && !sep6 && !props.found) {
4670
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep6, null, props, onError);
4669
+ if (!isMap && !sep7 && !props.found) {
4670
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep7, null, props, onError);
4671
4671
  coll.items.push(valueNode);
4672
4672
  offset = valueNode.range[2];
4673
4673
  if (isBlock(value))
@@ -4679,7 +4679,7 @@ var require_resolve_flow_collection = __commonJS({
4679
4679
  if (isBlock(key))
4680
4680
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
4681
4681
  ctx.atKey = false;
4682
- const valueProps = resolveProps.resolveProps(sep6 ?? [], {
4682
+ const valueProps = resolveProps.resolveProps(sep7 ?? [], {
4683
4683
  flow: fcName,
4684
4684
  indicator: "map-value-ind",
4685
4685
  next: value,
@@ -4690,8 +4690,8 @@ var require_resolve_flow_collection = __commonJS({
4690
4690
  });
4691
4691
  if (valueProps.found) {
4692
4692
  if (!isMap && !props.found && ctx.options.strict) {
4693
- if (sep6)
4694
- for (const st of sep6) {
4693
+ if (sep7)
4694
+ for (const st of sep7) {
4695
4695
  if (st === valueProps.found)
4696
4696
  break;
4697
4697
  if (st.type === "newline") {
@@ -4708,7 +4708,7 @@ var require_resolve_flow_collection = __commonJS({
4708
4708
  else
4709
4709
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
4710
4710
  }
4711
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep6, null, valueProps, onError) : null;
4711
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep7, null, valueProps, onError) : null;
4712
4712
  if (valueNode) {
4713
4713
  if (isBlock(value))
4714
4714
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -4888,7 +4888,7 @@ var require_resolve_block_scalar = __commonJS({
4888
4888
  chompStart = i + 1;
4889
4889
  }
4890
4890
  let value = "";
4891
- let sep6 = "";
4891
+ let sep7 = "";
4892
4892
  let prevMoreIndented = false;
4893
4893
  for (let i = 0; i < contentStart; ++i)
4894
4894
  value += lines[i][0].slice(trimIndent) + "\n";
@@ -4905,24 +4905,24 @@ var require_resolve_block_scalar = __commonJS({
4905
4905
  indent = "";
4906
4906
  }
4907
4907
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
4908
- value += sep6 + indent.slice(trimIndent) + content;
4909
- sep6 = "\n";
4908
+ value += sep7 + indent.slice(trimIndent) + content;
4909
+ sep7 = "\n";
4910
4910
  } else if (indent.length > trimIndent || content[0] === " ") {
4911
- if (sep6 === " ")
4912
- sep6 = "\n";
4913
- else if (!prevMoreIndented && sep6 === "\n")
4914
- sep6 = "\n\n";
4915
- value += sep6 + indent.slice(trimIndent) + content;
4916
- sep6 = "\n";
4911
+ if (sep7 === " ")
4912
+ sep7 = "\n";
4913
+ else if (!prevMoreIndented && sep7 === "\n")
4914
+ sep7 = "\n\n";
4915
+ value += sep7 + indent.slice(trimIndent) + content;
4916
+ sep7 = "\n";
4917
4917
  prevMoreIndented = true;
4918
4918
  } else if (content === "") {
4919
- if (sep6 === "\n")
4919
+ if (sep7 === "\n")
4920
4920
  value += "\n";
4921
4921
  else
4922
- sep6 = "\n";
4922
+ sep7 = "\n";
4923
4923
  } else {
4924
- value += sep6 + content;
4925
- sep6 = " ";
4924
+ value += sep7 + content;
4925
+ sep7 = " ";
4926
4926
  prevMoreIndented = false;
4927
4927
  }
4928
4928
  }
@@ -5105,25 +5105,25 @@ var require_resolve_flow_scalar = __commonJS({
5105
5105
  trimBoth = /^[ \t]+|[ \t]+$/g;
5106
5106
  }
5107
5107
  let res = match[1].replace(trimEnd, "");
5108
- let sep6 = " ";
5108
+ let sep7 = " ";
5109
5109
  let pos = line.lastIndex;
5110
5110
  while (match = line.exec(source)) {
5111
5111
  const lm = match[1].replace(trimBoth, "");
5112
5112
  if (lm === "") {
5113
- if (sep6 === "\n")
5114
- res += sep6;
5113
+ if (sep7 === "\n")
5114
+ res += sep7;
5115
5115
  else
5116
- sep6 = "\n";
5116
+ sep7 = "\n";
5117
5117
  } else {
5118
- res += sep6 + lm;
5119
- sep6 = " ";
5118
+ res += sep7 + lm;
5119
+ sep7 = " ";
5120
5120
  }
5121
5121
  pos = line.lastIndex;
5122
5122
  }
5123
5123
  const last = /[ \t]*(.*)/sy;
5124
5124
  last.lastIndex = pos;
5125
5125
  match = last.exec(source);
5126
- return res + sep6 + (match?.[1] ?? "");
5126
+ return res + sep7 + (match?.[1] ?? "");
5127
5127
  }
5128
5128
  function doubleQuotedValue(source, onError) {
5129
5129
  let res = "";
@@ -5933,14 +5933,14 @@ var require_cst_stringify = __commonJS({
5933
5933
  }
5934
5934
  }
5935
5935
  }
5936
- function stringifyItem({ start, key, sep: sep6, value }) {
5936
+ function stringifyItem({ start, key, sep: sep7, value }) {
5937
5937
  let res = "";
5938
5938
  for (const st of start)
5939
5939
  res += st.source;
5940
5940
  if (key)
5941
5941
  res += stringifyToken(key);
5942
- if (sep6)
5943
- for (const st of sep6)
5942
+ if (sep7)
5943
+ for (const st of sep7)
5944
5944
  res += st.source;
5945
5945
  if (value)
5946
5946
  res += stringifyToken(value);
@@ -7107,18 +7107,18 @@ var require_parser = __commonJS({
7107
7107
  if (this.type === "map-value-ind") {
7108
7108
  const prev = getPrevProps(this.peek(2));
7109
7109
  const start = getFirstKeyStartProps(prev);
7110
- let sep6;
7110
+ let sep7;
7111
7111
  if (scalar.end) {
7112
- sep6 = scalar.end;
7113
- sep6.push(this.sourceToken);
7112
+ sep7 = scalar.end;
7113
+ sep7.push(this.sourceToken);
7114
7114
  delete scalar.end;
7115
7115
  } else
7116
- sep6 = [this.sourceToken];
7116
+ sep7 = [this.sourceToken];
7117
7117
  const map = {
7118
7118
  type: "block-map",
7119
7119
  offset: scalar.offset,
7120
7120
  indent: scalar.indent,
7121
- items: [{ start, key: scalar, sep: sep6 }]
7121
+ items: [{ start, key: scalar, sep: sep7 }]
7122
7122
  };
7123
7123
  this.onKeyLine = true;
7124
7124
  this.stack[this.stack.length - 1] = map;
@@ -7271,15 +7271,15 @@ var require_parser = __commonJS({
7271
7271
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
7272
7272
  const start2 = getFirstKeyStartProps(it.start);
7273
7273
  const key = it.key;
7274
- const sep6 = it.sep;
7275
- sep6.push(this.sourceToken);
7274
+ const sep7 = it.sep;
7275
+ sep7.push(this.sourceToken);
7276
7276
  delete it.key;
7277
7277
  delete it.sep;
7278
7278
  this.stack.push({
7279
7279
  type: "block-map",
7280
7280
  offset: this.offset,
7281
7281
  indent: this.indent,
7282
- items: [{ start: start2, key, sep: sep6 }]
7282
+ items: [{ start: start2, key, sep: sep7 }]
7283
7283
  });
7284
7284
  } else if (start.length > 0) {
7285
7285
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -7308,14 +7308,14 @@ var require_parser = __commonJS({
7308
7308
  case "scalar":
7309
7309
  case "single-quoted-scalar":
7310
7310
  case "double-quoted-scalar": {
7311
- const fs8 = this.flowScalar(this.type);
7311
+ const fs9 = this.flowScalar(this.type);
7312
7312
  if (atNextItem || it.value) {
7313
- map.items.push({ start, key: fs8, sep: [] });
7313
+ map.items.push({ start, key: fs9, sep: [] });
7314
7314
  this.onKeyLine = true;
7315
7315
  } else if (it.sep) {
7316
- this.stack.push(fs8);
7316
+ this.stack.push(fs9);
7317
7317
  } else {
7318
- Object.assign(it, { key: fs8, sep: [] });
7318
+ Object.assign(it, { key: fs9, sep: [] });
7319
7319
  this.onKeyLine = true;
7320
7320
  }
7321
7321
  return;
@@ -7443,13 +7443,13 @@ var require_parser = __commonJS({
7443
7443
  case "scalar":
7444
7444
  case "single-quoted-scalar":
7445
7445
  case "double-quoted-scalar": {
7446
- const fs8 = this.flowScalar(this.type);
7446
+ const fs9 = this.flowScalar(this.type);
7447
7447
  if (!it || it.value)
7448
- fc.items.push({ start: [], key: fs8, sep: [] });
7448
+ fc.items.push({ start: [], key: fs9, sep: [] });
7449
7449
  else if (it.sep)
7450
- this.stack.push(fs8);
7450
+ this.stack.push(fs9);
7451
7451
  else
7452
- Object.assign(it, { key: fs8, sep: [] });
7452
+ Object.assign(it, { key: fs9, sep: [] });
7453
7453
  return;
7454
7454
  }
7455
7455
  case "flow-map-end":
@@ -7473,13 +7473,13 @@ var require_parser = __commonJS({
7473
7473
  const prev = getPrevProps(parent);
7474
7474
  const start = getFirstKeyStartProps(prev);
7475
7475
  fixFlowSeqItems(fc);
7476
- const sep6 = fc.end.splice(1, fc.end.length);
7477
- sep6.push(this.sourceToken);
7476
+ const sep7 = fc.end.splice(1, fc.end.length);
7477
+ sep7.push(this.sourceToken);
7478
7478
  const map = {
7479
7479
  type: "block-map",
7480
7480
  offset: fc.offset,
7481
7481
  indent: fc.indent,
7482
- items: [{ start, key: fc, sep: sep6 }]
7482
+ items: [{ start, key: fc, sep: sep7 }]
7483
7483
  };
7484
7484
  this.onKeyLine = true;
7485
7485
  this.stack[this.stack.length - 1] = map;
@@ -7657,7 +7657,7 @@ var require_public_api = __commonJS({
7657
7657
  }
7658
7658
  return doc;
7659
7659
  }
7660
- function parse(src, reviver, options) {
7660
+ function parse2(src, reviver, options) {
7661
7661
  let _reviver = void 0;
7662
7662
  if (typeof reviver === "function") {
7663
7663
  _reviver = reviver;
@@ -7698,7 +7698,7 @@ var require_public_api = __commonJS({
7698
7698
  return value.toString(options);
7699
7699
  return new Document.Document(value, _replacer, options).toString(options);
7700
7700
  }
7701
- exports.parse = parse;
7701
+ exports.parse = parse2;
7702
7702
  exports.parseAllDocuments = parseAllDocuments;
7703
7703
  exports.parseDocument = parseDocument;
7704
7704
  exports.stringify = stringify;
@@ -7798,6 +7798,11 @@ var FLAG_REGISTRY = [
7798
7798
  name: "forward-secrets",
7799
7799
  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."
7800
7800
  },
7801
+ {
7802
+ name: "ios-audio-always-inserted",
7803
+ 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.",
7804
+ defaultEnabled: true
7805
+ },
7801
7806
  {
7802
7807
  name: "video-watermark",
7803
7808
  description: "Overlay the argent corner watermark on recorded screen videos. On by default; turn it off with `argent disable video-watermark`.",
@@ -7805,7 +7810,7 @@ var FLAG_REGISTRY = [
7805
7810
  },
7806
7811
  {
7807
7812
  name: "macos-apps",
7808
- 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`.",
7813
+ 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`.",
7809
7814
  defaultEnabled: true
7810
7815
  }
7811
7816
  ];
@@ -7875,6 +7880,7 @@ function isFeatureEnabled(name, options = {}, registry = FLAG_REGISTRY) {
7875
7880
  }
7876
7881
 
7877
7882
  // ../configuration-core/src/paths.ts
7883
+ import * as fs2 from "node:fs";
7878
7884
  import * as os from "node:os";
7879
7885
  import * as path2 from "node:path";
7880
7886
  function nonEmpty(value) {
@@ -7886,6 +7892,16 @@ function resolveHomeDir(options = {}) {
7886
7892
  if (options.homeDir) return options.homeDir;
7887
7893
  return process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
7888
7894
  }
7895
+ function isHomeDir(dir, options = {}) {
7896
+ return canonicalPath(dir) === canonicalPath(resolveHomeDir(options));
7897
+ }
7898
+ function canonicalPath(p) {
7899
+ try {
7900
+ return fs2.realpathSync.native(p);
7901
+ } catch {
7902
+ return path2.resolve(p);
7903
+ }
7904
+ }
7889
7905
  function argentHomeDir() {
7890
7906
  return path2.join(resolveHomeDir(), ".argent");
7891
7907
  }
@@ -7902,11 +7918,11 @@ function configFilePath(scope = "global", options = {}) {
7902
7918
 
7903
7919
  // ../configuration-core/src/config.ts
7904
7920
  import * as crypto from "node:crypto";
7905
- import * as fs2 from "node:fs";
7921
+ import * as fs3 from "node:fs";
7906
7922
  import * as path3 from "node:path";
7907
7923
  function readConfigObject(scope = "global", options = {}) {
7908
7924
  try {
7909
- const raw = fs2.readFileSync(configFilePath(scope, options), "utf8");
7925
+ const raw = fs3.readFileSync(configFilePath(scope, options), "utf8");
7910
7926
  const json = JSON.parse(raw);
7911
7927
  if (json && typeof json === "object" && !Array.isArray(json)) {
7912
7928
  return json;
@@ -7943,7 +7959,7 @@ function getAtPath(obj, dottedKey) {
7943
7959
 
7944
7960
  // ../configuration-core/src/secrets.ts
7945
7961
  var import_dotenv = __toESM(require_dist(), 1);
7946
- import * as fs3 from "node:fs";
7962
+ import * as fs4 from "node:fs";
7947
7963
  import * as path4 from "node:path";
7948
7964
  var SECRET_ENV_PREFIX = "ARGENT_SECRET_";
7949
7965
  var SECRETS_FILE_NAME = "secrets.env";
@@ -7973,10 +7989,10 @@ function fileSource(filePath, exposure) {
7973
7989
  names: [],
7974
7990
  values: /* @__PURE__ */ new Map()
7975
7991
  };
7976
- if (!fs3.statSync(filePath, { throwIfNoEntry: false })) return absent;
7992
+ if (!fs4.statSync(filePath, { throwIfNoEntry: false })) return absent;
7977
7993
  let content;
7978
7994
  try {
7979
- content = fs3.readFileSync(filePath, "utf8");
7995
+ content = fs4.readFileSync(filePath, "utf8");
7980
7996
  } catch {
7981
7997
  return absent;
7982
7998
  }
@@ -8002,7 +8018,9 @@ function fileSource(filePath, exposure) {
8002
8018
  }
8003
8019
  function secretSources(options = {}) {
8004
8020
  const sources = [envSource(options.env ?? process.env)];
8005
- const projectRoot = findProjectRoot(options.cwd ?? process.cwd());
8021
+ const home = resolveHomeDir(options);
8022
+ const found = findProjectRoot(options.cwd ?? process.cwd());
8023
+ const projectRoot = found && isHomeDir(found, options) ? home : found;
8006
8024
  const filePaths = [];
8007
8025
  if (projectRoot) {
8008
8026
  filePaths.push({
@@ -8014,7 +8032,7 @@ function secretSources(options = {}) {
8014
8032
  }
8015
8033
  }
8016
8034
  filePaths.push({
8017
- path: path4.join(resolveHomeDir(options), ".argent", SECRETS_FILE_NAME),
8035
+ path: path4.join(home, ".argent", SECRETS_FILE_NAME),
8018
8036
  exposure: "dedicated"
8019
8037
  });
8020
8038
  const seen = /* @__PURE__ */ new Set();
@@ -8136,14 +8154,6 @@ var CONFIG_SCHEMA = [
8136
8154
  // drained/reset, not just the file rewritten.
8137
8155
  manageCommand: "argent telemetry"
8138
8156
  },
8139
- {
8140
- key: "allowlist.enabled",
8141
- 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.",
8142
- scopes: ["project", "global"],
8143
- parse: asBoolean,
8144
- merge: "prioritize-restrictive",
8145
- example: "false"
8146
- },
8147
8157
  {
8148
8158
  key: "lens.agent",
8149
8159
  description: "Coding-agent id remembered by `argent lens` to skip the picker.",
@@ -8266,7 +8276,7 @@ var UnknownConfigKeyError = class extends Error {
8266
8276
 
8267
8277
  // ../argent-tools-client/src/launcher.ts
8268
8278
  import * as net from "node:net";
8269
- import * as fs4 from "node:fs";
8279
+ import * as fs5 from "node:fs";
8270
8280
  import * as path6 from "node:path";
8271
8281
  import * as readline from "node:readline";
8272
8282
  import { homedir as homedir3 } from "node:os";
@@ -8280,6 +8290,7 @@ var LOCK_FILE = path6.join(STATE_DIR, "tool-server.lock");
8280
8290
  var AUTH_TOKEN_BYTES = 32;
8281
8291
  var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
8282
8292
  var AUTOSPAWN_IDLE_TIMEOUT_MINUTES = 30;
8293
+ var AUTOSPAWN_HOST = "127.0.0.1";
8283
8294
  function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
8284
8295
  const env = {
8285
8296
  ...baseEnv,
@@ -8291,7 +8302,7 @@ function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
8291
8302
  if (options.idleTimeoutMinutes !== void 0) {
8292
8303
  env.ARGENT_IDLE_TIMEOUT_MINUTES = String(options.idleTimeoutMinutes);
8293
8304
  }
8294
- if (options.token) env[AUTH_TOKEN_ENV] = options.token;
8305
+ env[AUTH_TOKEN_ENV] = options.token ?? "";
8295
8306
  if (paths.installKind) env.ARGENT_INSTALL_KIND = paths.installKind;
8296
8307
  if (paths.installProjectRoot) env.ARGENT_PROJECT_ROOT = paths.installProjectRoot;
8297
8308
  return env;
@@ -8300,7 +8311,7 @@ function generateToken() {
8300
8311
  return randomBytes(AUTH_TOKEN_BYTES).toString("hex");
8301
8312
  }
8302
8313
  function findFreePort() {
8303
- return new Promise((resolve9, reject) => {
8314
+ return new Promise((resolve11, reject) => {
8304
8315
  const srv = net.createServer();
8305
8316
  srv.listen(0, "127.0.0.1", () => {
8306
8317
  const addr = srv.address();
@@ -8311,21 +8322,21 @@ function findFreePort() {
8311
8322
  const port = addr.port;
8312
8323
  srv.close((err) => {
8313
8324
  if (err) reject(err);
8314
- else resolve9(port);
8325
+ else resolve11(port);
8315
8326
  });
8316
8327
  });
8317
8328
  srv.on("error", reject);
8318
8329
  });
8319
8330
  }
8320
8331
  function isVersionNewer(a, b) {
8321
- const parse = (v) => {
8332
+ const parse2 = (v) => {
8322
8333
  const [core = "", ...preParts] = v.split("+")[0].split("-");
8323
8334
  const nums = core.split(".").map((n) => Number.parseInt(n, 10));
8324
8335
  if (nums.length === 0 || nums.some((n) => Number.isNaN(n))) return null;
8325
8336
  return { nums, pre: preParts.length > 0 ? preParts.join("-").split(".") : [] };
8326
8337
  };
8327
- const pa = parse(a);
8328
- const pb = parse(b);
8338
+ const pa = parse2(a);
8339
+ const pb = parse2(b);
8329
8340
  if (!pa || !pb) return false;
8330
8341
  for (let i = 0; i < 3; i++) {
8331
8342
  const x = pa.nums[i] ?? 0;
@@ -8353,7 +8364,7 @@ function isVersionNewer(a, b) {
8353
8364
  function readBundlePackageVersion(bundlePath) {
8354
8365
  try {
8355
8366
  const pkg = JSON.parse(
8356
- fs4.readFileSync(path6.join(path6.dirname(bundlePath), "..", "package.json"), "utf8")
8367
+ fs5.readFileSync(path6.join(path6.dirname(bundlePath), "..", "package.json"), "utf8")
8357
8368
  );
8358
8369
  return typeof pkg.version === "string" ? pkg.version : void 0;
8359
8370
  } catch {
@@ -8408,23 +8419,26 @@ function killSpawnedChild(child, pid) {
8408
8419
  }
8409
8420
  }
8410
8421
  }
8422
+ function resolveToolsServerNode() {
8423
+ const { bun, deno, electron } = process.versions;
8424
+ return !(bun || deno || electron) && fs5.existsSync(process.execPath) ? process.execPath : "node";
8425
+ }
8411
8426
  function spawnToolsServer(paths, port, options = {}) {
8412
- return new Promise((resolve9, reject) => {
8427
+ return new Promise((resolve11, reject) => {
8413
8428
  let logFd;
8414
8429
  try {
8415
- fs4.mkdirSync(STATE_DIR, { recursive: true });
8416
- logFd = fs4.openSync(LOG_FILE, "a");
8430
+ fs5.mkdirSync(STATE_DIR, { recursive: true });
8431
+ logFd = fs5.openSync(LOG_FILE, "a");
8417
8432
  } catch {
8418
- logFd = fs4.openSync("/dev/null", "w");
8433
+ logFd = fs5.openSync("/dev/null", "w");
8419
8434
  }
8420
- const { bun, deno, electron } = process.versions;
8421
- const nodeBin = !(bun || deno || electron) && fs4.existsSync(process.execPath) ? process.execPath : "node";
8435
+ const nodeBin = resolveToolsServerNode();
8422
8436
  const child = spawn(nodeBin, [paths.bundlePath, "start"], {
8423
8437
  detached: true,
8424
8438
  stdio: ["ignore", "pipe", logFd],
8425
8439
  env: buildToolsServerEnv(paths, port, process.env, options)
8426
8440
  });
8427
- fs4.closeSync(logFd);
8441
+ fs5.closeSync(logFd);
8428
8442
  child.unref();
8429
8443
  const pid = child.pid;
8430
8444
  if (!pid) {
@@ -8456,7 +8470,7 @@ function spawnToolsServer(paths, port, options = {}) {
8456
8470
  rl.close();
8457
8471
  child.stdout?.resume();
8458
8472
  child.stdout?.unref?.();
8459
- settle(() => resolve9({ port: actualPort, pid }));
8473
+ settle(() => resolve11({ port: actualPort, pid }));
8460
8474
  }
8461
8475
  });
8462
8476
  child.on("error", (err) => {
@@ -8551,7 +8565,7 @@ async function sweepDeadStateFiles() {
8551
8565
  });
8552
8566
  continue;
8553
8567
  }
8554
- if (fs4.existsSync(fresh.bundlePath)) continue;
8568
+ if (fs5.existsSync(fresh.bundlePath)) continue;
8555
8569
  if (!couldBeOurToolServer(fresh.pid, fresh.bundlePath)) continue;
8556
8570
  await unlink(file).catch(() => {
8557
8571
  });
@@ -8598,7 +8612,7 @@ async function killToolServer(bundlePath) {
8598
8612
  await clearToolsServerState(bundlePath ?? state.bundlePath);
8599
8613
  return alive;
8600
8614
  }
8601
- var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs4.existsSync(p)) ?? "ps";
8615
+ var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs5.existsSync(p)) ?? "ps";
8602
8616
  var PS_WIDTH_FLAGS = ["-ww"];
8603
8617
  var PS_LOCALE = process.platform === "darwin" ? "en_US.UTF-8" : "C.UTF-8";
8604
8618
  function readProcessCommandLine(pid, flags = PS_WIDTH_FLAGS, env = { ...process.env, LC_ALL: PS_LOCALE }) {
@@ -8645,13 +8659,13 @@ var LOCK_STALE_MS = 45e3;
8645
8659
  var LOCK_POLL_MS = 100;
8646
8660
  function spawnLockIsStale() {
8647
8661
  try {
8648
- const { pid, ts } = JSON.parse(fs4.readFileSync(LOCK_FILE, "utf8"));
8662
+ const { pid, ts } = JSON.parse(fs5.readFileSync(LOCK_FILE, "utf8"));
8649
8663
  if (typeof pid === "number" && pid > 0 && !isProcessAlive(pid)) return true;
8650
8664
  if (typeof ts === "number" && Date.now() - ts > LOCK_STALE_MS) return true;
8651
8665
  return false;
8652
8666
  } catch {
8653
8667
  try {
8654
- return Date.now() - fs4.statSync(LOCK_FILE).mtimeMs > LOCK_STALE_MS;
8668
+ return Date.now() - fs5.statSync(LOCK_FILE).mtimeMs > LOCK_STALE_MS;
8655
8669
  } catch {
8656
8670
  return true;
8657
8671
  }
@@ -8659,7 +8673,7 @@ function spawnLockIsStale() {
8659
8673
  }
8660
8674
  async function acquireSpawnLock() {
8661
8675
  try {
8662
- fs4.mkdirSync(STATE_DIR, { recursive: true });
8676
+ fs5.mkdirSync(STATE_DIR, { recursive: true });
8663
8677
  } catch {
8664
8678
  return null;
8665
8679
  }
@@ -8667,11 +8681,11 @@ async function acquireSpawnLock() {
8667
8681
  const deadline = Date.now() + LOCK_WAIT_TIMEOUT_MS;
8668
8682
  for (; ; ) {
8669
8683
  try {
8670
- const fd = fs4.openSync(LOCK_FILE, "wx");
8684
+ const fd = fs5.openSync(LOCK_FILE, "wx");
8671
8685
  try {
8672
- fs4.writeSync(fd, JSON.stringify({ pid: process.pid, nonce, ts: Date.now() }));
8686
+ fs5.writeSync(fd, JSON.stringify({ pid: process.pid, nonce, ts: Date.now() }));
8673
8687
  } finally {
8674
- fs4.closeSync(fd);
8688
+ fs5.closeSync(fd);
8675
8689
  }
8676
8690
  let released = false;
8677
8691
  return {
@@ -8679,8 +8693,8 @@ async function acquireSpawnLock() {
8679
8693
  if (released) return;
8680
8694
  released = true;
8681
8695
  try {
8682
- const cur = JSON.parse(fs4.readFileSync(LOCK_FILE, "utf8"));
8683
- if (cur.pid === process.pid && cur.nonce === nonce) fs4.unlinkSync(LOCK_FILE);
8696
+ const cur = JSON.parse(fs5.readFileSync(LOCK_FILE, "utf8"));
8697
+ if (cur.pid === process.pid && cur.nonce === nonce) fs5.unlinkSync(LOCK_FILE);
8684
8698
  } catch {
8685
8699
  }
8686
8700
  }
@@ -8689,10 +8703,10 @@ async function acquireSpawnLock() {
8689
8703
  if (err.code !== "EEXIST") return null;
8690
8704
  if (spawnLockIsStale()) {
8691
8705
  try {
8692
- fs4.unlinkSync(LOCK_FILE);
8706
+ fs5.unlinkSync(LOCK_FILE);
8693
8707
  } catch {
8694
8708
  }
8695
- if (!fs4.existsSync(LOCK_FILE)) continue;
8709
+ if (!fs5.existsSync(LOCK_FILE)) continue;
8696
8710
  }
8697
8711
  if (Date.now() >= deadline) return null;
8698
8712
  await new Promise((r) => setTimeout(r, LOCK_POLL_MS));
@@ -8732,7 +8746,7 @@ async function ensureToolsServer(paths) {
8732
8746
  }
8733
8747
  await clearToolsServerState(paths.bundlePath);
8734
8748
  await sweepDeadStateFiles();
8735
- if (!fs4.existsSync(paths.bundlePath)) {
8749
+ if (!fs5.existsSync(paths.bundlePath)) {
8736
8750
  throw new Error(
8737
8751
  `The argent install serving this session is gone from disk (${paths.bundlePath}) \u2014 it was likely updated or removed. Restart the editor's MCP connection to reconnect.`
8738
8752
  );
@@ -8742,6 +8756,7 @@ async function ensureToolsServer(paths) {
8742
8756
  const port = await findFreePort();
8743
8757
  const { port: actualPort, pid } = await spawnToolsServer(paths, port, {
8744
8758
  token,
8759
+ host: AUTOSPAWN_HOST,
8745
8760
  idleTimeoutMinutes: AUTOSPAWN_IDLE_TIMEOUT_MINUTES
8746
8761
  });
8747
8762
  await writeState({
@@ -8750,11 +8765,11 @@ async function ensureToolsServer(paths) {
8750
8765
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
8751
8766
  bundlePath: paths.bundlePath,
8752
8767
  version: diskVersion,
8753
- host: "127.0.0.1",
8768
+ host: AUTOSPAWN_HOST,
8754
8769
  token,
8755
8770
  managed: "autospawn"
8756
8771
  });
8757
- return { url: formatUrl("127.0.0.1", actualPort), token };
8772
+ return { url: formatUrl(AUTOSPAWN_HOST, actualPort), token };
8758
8773
  } finally {
8759
8774
  lock?.release();
8760
8775
  }
@@ -8796,7 +8811,18 @@ function interpolateFileInputPath(template, args) {
8796
8811
  });
8797
8812
  return missing ? null : out;
8798
8813
  }
8799
- var TOOL_FILE_EXTENSIONS = [".png", ".yaml"];
8814
+ var TOOL_FILE_EXTENSIONS = [
8815
+ ".png",
8816
+ ".yaml",
8817
+ ".wav",
8818
+ ".mp3",
8819
+ ".m4a",
8820
+ ".aac",
8821
+ ".caf",
8822
+ ".aif",
8823
+ ".aiff",
8824
+ ".flac"
8825
+ ];
8800
8826
  function hasToolFileExtension(file) {
8801
8827
  const name = file.toLowerCase();
8802
8828
  return TOOL_FILE_EXTENSIONS.some((extension) => name.endsWith(extension));
@@ -8810,16 +8836,24 @@ function toolStepFiles(specs, args) {
8810
8836
  }
8811
8837
  return files;
8812
8838
  }
8839
+ var UNEXPANDED_PATH = /^~|\$[A-Za-z0-9_{(]|`|%[A-Za-z_][A-Za-z0-9_]*%|^[A-Za-z][A-Za-z0-9+.-]+:/;
8840
+ function isUnexpandedPath(p) {
8841
+ return UNEXPANDED_PATH.test(p);
8842
+ }
8813
8843
  function isClientFileArgument({ spec, path: path14 }) {
8814
8844
  return spec.kind === "file" && spec.path === `\${${spec.target}}` && path14.startsWith("/") && hasToolFileExtension(path14);
8815
8845
  }
8816
8846
 
8847
+ // ../registry/src/flow-platforms.ts
8848
+ var LAUNCH_PLATFORMS = ["ios", "android", "chromium", "vega", "macos"];
8849
+ var SELECTABLE_PLATFORMS = [...LAUNCH_PLATFORMS, "ios-remote"];
8850
+
8817
8851
  // ../registry/src/flow-file-refs.ts
8818
- import * as fs6 from "node:fs/promises";
8852
+ import * as fs7 from "node:fs/promises";
8819
8853
  import * as path8 from "node:path";
8820
8854
 
8821
8855
  // ../registry/src/e2e-dirs.ts
8822
- import * as fs5 from "node:fs/promises";
8856
+ import * as fs6 from "node:fs/promises";
8823
8857
  import * as path7 from "node:path";
8824
8858
  var E2E_DIR = path7.join(".argent", "e2e");
8825
8859
  var LEGACY_E2E_DIRS = Object.freeze([path7.join(".argent", "flows")]);
@@ -8834,7 +8868,7 @@ function e2eFileCandidates(projectRoot, name) {
8834
8868
  return e2eDirsFor(projectRoot).map((dir) => path7.join(dir, `${name}.yaml`));
8835
8869
  }
8836
8870
  async function exists(file) {
8837
- return fs5.stat(file).then(
8871
+ return fs6.stat(file).then(
8838
8872
  () => true,
8839
8873
  () => false
8840
8874
  );
@@ -8925,10 +8959,10 @@ function canonicalToolArgs(tool, args) {
8925
8959
  // ../registry/src/flow-file-refs.ts
8926
8960
  async function canonicalFlowPath(p) {
8927
8961
  try {
8928
- return await fs6.realpath(p);
8962
+ return await fs7.realpath(p);
8929
8963
  } catch {
8930
8964
  try {
8931
- return path8.join(await fs6.realpath(path8.dirname(p)), path8.basename(p));
8965
+ return path8.join(await fs7.realpath(path8.dirname(p)), path8.basename(p));
8932
8966
  } catch {
8933
8967
  return p;
8934
8968
  }
@@ -8944,6 +8978,9 @@ var MAX_BLOCK_NESTING = 64;
8944
8978
  function isRecord(value) {
8945
8979
  return typeof value === "object" && value !== null && !Array.isArray(value);
8946
8980
  }
8981
+ function flowYamlSource(content) {
8982
+ return content.replace(/^\s+/, (lead) => lead.replace(/[^\n]/g, "")).trimEnd();
8983
+ }
8947
8984
  function collectFlowRequests(doc) {
8948
8985
  const runTargets = /* @__PURE__ */ new Set();
8949
8986
  const snapshots = /* @__PURE__ */ new Set();
@@ -8974,15 +9011,15 @@ function collectFlowRequests(doc) {
8974
9011
  if (isRecord(doc)) visit(doc.steps, 0);
8975
9012
  return { runTargets: [...runTargets], snapshots: [...snapshots], toolSteps, nested };
8976
9013
  }
8977
- function baselineKeyFor(canonicalPath, flowName) {
8978
- const stem = path8.basename(canonicalPath, ".yaml");
9014
+ function baselineKeyFor(canonicalPath2, flowName) {
9015
+ const stem = path8.basename(canonicalPath2, ".yaml");
8979
9016
  return FLOW_NAME_PATTERN.test(stem) ? stem : flowName;
8980
9017
  }
8981
9018
  function flowMemberKey(anchorDir, target) {
8982
9019
  return `${anchorDir}\0${target}`;
8983
9020
  }
8984
9021
  async function classifyOnDiskSpelling(dir, base, addressable = FLOW_FILE_NAME_PATTERN) {
8985
- const entries = await fs6.readdir(dir).catch(() => null);
9022
+ const entries = await fs7.readdir(dir).catch(() => null);
8986
9023
  if (entries === null || entries.includes(base)) return { state: "listed" };
8987
9024
  const actual = entries.find((entry) => entry.toLowerCase() === base.toLowerCase());
8988
9025
  if (actual === void 0) return { state: "absent" };
@@ -9092,6 +9129,9 @@ var FAILURE_CODES = {
9092
9129
  ANDROID_ADB_COMMAND_FAILED: "ANDROID_ADB_COMMAND_FAILED",
9093
9130
  ANDROID_ADB_BOOT_TERMINAL_STATE: "ANDROID_ADB_BOOT_TERMINAL_STATE",
9094
9131
  ANDROID_ADB_BOOT_TIMEOUT: "ANDROID_ADB_BOOT_TIMEOUT",
9132
+ ANDROID_NETWORK_RESTORE_TIMEOUT: "ANDROID_NETWORK_RESTORE_TIMEOUT",
9133
+ ANDROID_OFFLINE_TIMEOUT: "ANDROID_OFFLINE_TIMEOUT",
9134
+ ANDROID_OFFLINE_UNSUPPORTED: "ANDROID_OFFLINE_UNSUPPORTED",
9095
9135
  SIMULATOR_NETWORK_TIMEOUT: "SIMULATOR_NETWORK_TIMEOUT",
9096
9136
  SIMULATOR_NETWORK_CONNECTION_REFUSED: "SIMULATOR_NETWORK_CONNECTION_REFUSED",
9097
9137
  SIMULATOR_NETWORK_CONNECTION_RESET: "SIMULATOR_NETWORK_CONNECTION_RESET",
@@ -9211,12 +9251,15 @@ var FAILURE_CODES = {
9211
9251
  DEBUGGER_CDP_PROTOCOL_ERROR: "DEBUGGER_CDP_PROTOCOL_ERROR",
9212
9252
  DEBUGGER_CDP_CONNECT_FAILED: "DEBUGGER_CDP_CONNECT_FAILED",
9213
9253
  DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN: "DEBUGGER_CDP_SOCKET_CLOSED_BEFORE_OPEN",
9254
+ DEBUGGER_CDP_ORIGIN_REJECTED: "DEBUGGER_CDP_ORIGIN_REJECTED",
9214
9255
  DEBUGGER_CDP_NOT_CONNECTED: "DEBUGGER_CDP_NOT_CONNECTED",
9215
9256
  DEBUGGER_CDP_REQUEST_TIMEOUT: "DEBUGGER_CDP_REQUEST_TIMEOUT",
9216
9257
  DEBUGGER_CDP_CONNECTION_CLOSED: "DEBUGGER_CDP_CONNECTION_CLOSED",
9217
9258
  DEBUGGER_TARGET_DEVICE_MISMATCH: "DEBUGGER_TARGET_DEVICE_MISMATCH",
9218
9259
  DEBUGGER_EVALUATE_EXPRESSION_THREW: "DEBUGGER_EVALUATE_EXPRESSION_THREW",
9219
9260
  DEBUGGER_RELOAD_FAILED: "DEBUGGER_RELOAD_FAILED",
9261
+ // e2e-add-step refused a debugger-* call that answered `not_connected`.
9262
+ DEBUGGER_NOT_CONNECTED: "DEBUGGER_NOT_CONNECTED",
9220
9263
  JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED: "JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED",
9221
9264
  JS_RUNTIME_PAYLOAD_INVALID: "JS_RUNTIME_PAYLOAD_INVALID",
9222
9265
  JS_RUNTIME_PAYLOAD_DEVICE_MISSING: "JS_RUNTIME_PAYLOAD_DEVICE_MISSING",
@@ -9285,6 +9328,32 @@ var FAILURE_CODES = {
9285
9328
  NATIVE_PROFILER_PERFETTO_PROCESS_ERROR: "NATIVE_PROFILER_PERFETTO_PROCESS_ERROR",
9286
9329
  NATIVE_PROFILER_PERFETTO_READY_TIMEOUT: "NATIVE_PROFILER_PERFETTO_READY_TIMEOUT",
9287
9330
  NATIVE_PROFILER_PERFETTO_READY_EXITED: "NATIVE_PROFILER_PERFETTO_READY_EXITED",
9331
+ /**
9332
+ * native-profiler-launch-analysis. Input problems use TOOL_INPUT_INVALID and
9333
+ * devicectl steps IOS_DEVICECTL_COMMAND_FAILED.
9334
+ * @see [workflow.ts](../../tool-server/src/utils/ios-launch-time/workflow.ts)
9335
+ */
9336
+ // Not macOS, or an Xcode that cannot record the launch on this target.
9337
+ LAUNCH_ANALYSIS_UNSUPPORTED_HOST: "LAUNCH_ANALYSIS_UNSUPPORTED_HOST",
9338
+ // No usable iPhone or simulator was selected, or Argent's runner holds it.
9339
+ LAUNCH_ANALYSIS_DEVICE_UNAVAILABLE: "LAUNCH_ANALYSIS_DEVICE_UNAVAILABLE",
9340
+ // The bundle_id app is not installed on the selected device.
9341
+ LAUNCH_ANALYSIS_APP_NOT_INSTALLED: "LAUNCH_ANALYSIS_APP_NOT_INSTALLED",
9342
+ // The runner's xcodebuild failed on code signing or provisioning.
9343
+ LAUNCH_ANALYSIS_SIGNING_FAILED: "LAUNCH_ANALYSIS_SIGNING_FAILED",
9344
+ // The iPhone's free developer profile has no slot for Argent's runner.
9345
+ LAUNCH_ANALYSIS_FREE_PROFILE_LIMIT: "LAUNCH_ANALYSIS_FREE_PROFILE_LIMIT",
9346
+ // simctl could not wait for boot, find, launch or terminate the app.
9347
+ LAUNCH_ANALYSIS_SIMCTL_FAILED: "LAUNCH_ANALYSIS_SIMCTL_FAILED",
9348
+ LAUNCH_ANALYSIS_RECORD_FAILED: "LAUNCH_ANALYSIS_RECORD_FAILED",
9349
+ // xctrace could not export the TOC, the CPU samples or the first-frame marker.
9350
+ LAUNCH_ANALYSIS_EXPORT_FAILED: "LAUNCH_ANALYSIS_EXPORT_FAILED",
9351
+ // The App Launch trace has no first frame of the app, so it has no launch window.
9352
+ LAUNCH_ANALYSIS_NO_FIRST_FRAME: "LAUNCH_ANALYSIS_NO_FIRST_FRAME",
9353
+ // The XCTest launch run of Argent's runner failed.
9354
+ LAUNCH_ANALYSIS_RUNNER_TEST_FAILED: "LAUNCH_ANALYSIS_RUNNER_TEST_FAILED",
9355
+ // The launch test ran, but Argent read no launch measurements from its result.
9356
+ LAUNCH_ANALYSIS_NO_SAMPLES: "LAUNCH_ANALYSIS_NO_SAMPLES",
9288
9357
  // iOS and Android share one capture path (simulator-server frames into
9289
9358
  // ffmpeg), so these name the failing stage, not the device family.
9290
9359
  SCREEN_RECORDING_FACTORY_OPTIONS_MISSING: "SCREEN_RECORDING_FACTORY_OPTIONS_MISSING",
@@ -9299,6 +9368,19 @@ var FAILURE_CODES = {
9299
9368
  SCREEN_RECORDING_SERVER_SHUTTING_DOWN: "SCREEN_RECORDING_SERVER_SHUTTING_DOWN",
9300
9369
  SCREEN_RECORDING_STREAM_UNAVAILABLE: "SCREEN_RECORDING_STREAM_UNAVAILABLE",
9301
9370
  SCREEN_RECORDING_FFMPEG_NOT_FOUND: "SCREEN_RECORDING_FFMPEG_NOT_FOUND",
9371
+ // A cabled iPhone has no simulator-server: its frames come from a host-side
9372
+ // CoreMediaIO capture helper, which can fail in ways of its own.
9373
+ SCREEN_RECORDING_DEVICE_HELPER_BUILD_FAILED: "SCREEN_RECORDING_DEVICE_HELPER_BUILD_FAILED",
9374
+ SCREEN_RECORDING_DEVICE_SCREEN_NOT_FOUND: "SCREEN_RECORDING_DEVICE_SCREEN_NOT_FOUND",
9375
+ SCREEN_RECORDING_DEVICE_CAMERA_PERMISSION_DENIED: "SCREEN_RECORDING_DEVICE_CAMERA_PERMISSION_DENIED",
9376
+ SCREEN_RECORDING_DEVICE_HELPER_FAILED: "SCREEN_RECORDING_DEVICE_HELPER_FAILED",
9377
+ AUDIO_CLIP_CONVERSION_FAILED: "AUDIO_CLIP_CONVERSION_FAILED",
9378
+ AUDIO_HOOK_NOT_ACTIVE: "AUDIO_HOOK_NOT_ACTIVE",
9379
+ AUDIO_ENV_SETUP_FAILED: "AUDIO_ENV_SETUP_FAILED",
9380
+ AUDIO_WRONG_PLATFORM: "AUDIO_WRONG_PLATFORM",
9381
+ AUDIO_HOOK_UNAVAILABLE: "AUDIO_HOOK_UNAVAILABLE",
9382
+ AUDIO_INJECTION_NOT_OURS: "AUDIO_INJECTION_NOT_OURS",
9383
+ AUDIO_SIMULATOR_NOT_BOOTED: "AUDIO_SIMULATOR_NOT_BOOTED",
9302
9384
  FLOW_PROJECT_ROOT_INVALID: "FLOW_PROJECT_ROOT_INVALID",
9303
9385
  FLOW_NAME_INVALID: "FLOW_NAME_INVALID",
9304
9386
  FLOW_NO_ACTIVE_RECORDING: "FLOW_NO_ACTIVE_RECORDING",
@@ -9362,6 +9444,8 @@ var FAILURE_CODES = {
9362
9444
  MACOS_APP_BUNDLE_ID_MISMATCH: "MACOS_APP_BUNDLE_ID_MISMATCH",
9363
9445
  MACOS_APP_OPEN_URL_FAILED: "MACOS_APP_OPEN_URL_FAILED",
9364
9446
  MACOS_APP_FILE_ACCESS_FAILED: "MACOS_APP_FILE_ACCESS_FAILED",
9447
+ /** The app's loaded Argent library lacks support for the requested operation. */
9448
+ MACOS_APP_LIBRARY_OUTDATED: "MACOS_APP_LIBRARY_OUTDATED",
9365
9449
  KEYBOARD_KEY_UNSUPPORTED: "KEYBOARD_KEY_UNSUPPORTED",
9366
9450
  KEYBOARD_CHARACTER_UNSUPPORTED: "KEYBOARD_CHARACTER_UNSUPPORTED",
9367
9451
  KEYBOARD_TEXT_AND_KEY_COMBINED: "KEYBOARD_TEXT_AND_KEY_COMBINED",
@@ -9548,7 +9632,7 @@ import { spawn as spawn2 } from "node:child_process";
9548
9632
  import { once } from "node:events";
9549
9633
  import { createReadStream, createWriteStream } from "node:fs";
9550
9634
  import { open, rm, readdir as readdir3 } from "node:fs/promises";
9551
- import { basename as basename4, dirname as dirname5, join as join9, resolve as resolve6, sep as sep2 } from "node:path";
9635
+ import { basename as basename4, dirname as dirname5, join as join9, resolve as resolve7, sep as sep2 } from "node:path";
9552
9636
  import { Writable } from "node:stream";
9553
9637
  import { pipeline } from "node:stream/promises";
9554
9638
  import zlib from "node:zlib";
@@ -9646,7 +9730,7 @@ async function sniffFormat(archivePath) {
9646
9730
  }
9647
9731
  }
9648
9732
  var ZSTD_FRAME_MAGIC = 4247762216;
9649
- async function assertSingleCompleteZstdFrame(archivePath) {
9733
+ async function assertSingleCompleteZstdFrame(archivePath, signal) {
9650
9734
  const fh = await open(archivePath, "r");
9651
9735
  try {
9652
9736
  const { size } = await fh.stat();
@@ -9656,6 +9740,7 @@ async function assertSingleCompleteZstdFrame(archivePath) {
9656
9740
  let pos = 0;
9657
9741
  const read = async (n) => {
9658
9742
  if (pos < windowStart || pos + n > windowEnd) {
9743
+ signal?.throwIfAborted();
9659
9744
  const { bytesRead } = await fh.read(window, 0, window.length, pos);
9660
9745
  windowStart = pos;
9661
9746
  windowEnd = pos + bytesRead;
@@ -9693,14 +9778,16 @@ function tarEnv(env) {
9693
9778
  const characterType = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
9694
9779
  return /utf-?8/i.test(characterType) ? env : { ...env, LC_ALL: TAR_LOCALE };
9695
9780
  }
9696
- async function runTar(archive, args) {
9781
+ async function runTar(archive, args, signal) {
9697
9782
  const child = spawn2("tar", [...args, "-f", "-"], {
9783
+ signal,
9698
9784
  env: tarEnv(process.env)
9699
9785
  });
9700
- const exited = new Promise((res, rej) => {
9701
- child.on("error", rej);
9702
- child.on("close", res);
9786
+ let childError;
9787
+ child.on("error", (err) => {
9788
+ childError = err;
9703
9789
  });
9790
+ const closed = new Promise((resolve11) => child.once("close", resolve11));
9704
9791
  const stdout = collect(child.stdout, MAX_LISTING_BYTES, {
9705
9792
  maxLines: MAX_LISTING_LINES,
9706
9793
  onOverflow: () => child.kill()
@@ -9727,12 +9814,15 @@ async function runTar(archive, args) {
9727
9814
  if (err) child.stdin?.destroy();
9728
9815
  done(err);
9729
9816
  }
9730
- })
9817
+ }),
9818
+ { signal }
9731
9819
  ).then(
9732
9820
  () => null,
9733
9821
  (err) => err
9734
9822
  );
9735
- const [code, feedError] = await Promise.all([exited, fed]);
9823
+ const [code, feedError] = await Promise.all([closed, fed]);
9824
+ signal?.throwIfAborted();
9825
+ if (childError) throw childError;
9736
9826
  if (stdout.overflowed()) {
9737
9827
  throw new Error(
9738
9828
  `tar ${args.join(" ")} listed more than ${MAX_LISTING_LINES} members or ${MAX_LISTING_BYTES >> 20} MiB`
@@ -9754,24 +9844,25 @@ function isContainedPath(path14, windows = process.platform === "win32") {
9754
9844
  function isSafeTarMember(memberPath, destDir) {
9755
9845
  const normalized = normalizeTarMemberPath(memberPath);
9756
9846
  if (!isContainedPath(normalized)) return false;
9757
- const root = resolve6(destDir);
9758
- return resolve6(destDir, normalized).startsWith(root + sep2);
9847
+ const root = resolve7(destDir);
9848
+ return resolve7(destDir, normalized).startsWith(root + sep2);
9759
9849
  }
9760
- async function readListing(archive, args) {
9850
+ async function readListing(archive, args, signal) {
9761
9851
  try {
9762
- return await runTar(archive, args);
9852
+ return await runTar(archive, args, signal);
9763
9853
  } catch (err) {
9854
+ signal?.throwIfAborted();
9764
9855
  throw new ArchiveError(
9765
9856
  `Could not read archive: ${err instanceof Error ? err.message : String(err)}`
9766
9857
  );
9767
9858
  }
9768
9859
  }
9769
- async function listTarMembers(archive) {
9770
- const stdout = await readListing(archive, ["-t"]);
9860
+ async function listTarMembers(archive, signal) {
9861
+ const stdout = await readListing(archive, ["-t"], signal);
9771
9862
  return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
9772
9863
  }
9773
- async function assertSafeMemberTypes(archive) {
9774
- const stdout = await readListing(archive, ["-tv"]);
9864
+ async function assertSafeMemberTypes(archive, signal) {
9865
+ const stdout = await readListing(archive, ["-tv"], signal);
9775
9866
  for (const line of stdout.split("\n")) {
9776
9867
  if (!line.trim()) continue;
9777
9868
  const type = line[0];
@@ -9791,8 +9882,8 @@ async function assertSafeMemberTypes(archive) {
9791
9882
  );
9792
9883
  }
9793
9884
  }
9794
- async function assertSafeArchive(archive, destDir) {
9795
- const members = await listTarMembers(archive);
9885
+ async function assertSafeArchive(archive, destDir, signal) {
9886
+ const members = await listTarMembers(archive, signal);
9796
9887
  if (members.length === 0) {
9797
9888
  throw new ArchiveError("Archive is empty.");
9798
9889
  }
@@ -9801,7 +9892,7 @@ async function assertSafeArchive(archive, destDir) {
9801
9892
  throw new ArchiveError(`Archive contains an unsafe path "${member}" \u2014 refusing extraction.`);
9802
9893
  }
9803
9894
  }
9804
- await assertSafeMemberTypes(archive);
9895
+ await assertSafeMemberTypes(archive, signal);
9805
9896
  }
9806
9897
  async function resolveMember(destDir, expectedName) {
9807
9898
  const entries = await readdir3(destDir);
@@ -9816,19 +9907,24 @@ async function resolveMember(destDir, expectedName) {
9816
9907
  }
9817
9908
  return join9(destDir, real[0]);
9818
9909
  }
9819
- async function safeExtractArchive(archivePath, destDir, expectedName) {
9910
+ async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
9911
+ signal?.throwIfAborted();
9820
9912
  let archive;
9821
9913
  try {
9822
9914
  archive = { path: archivePath, format: await sniffFormat(archivePath) };
9823
- if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath);
9915
+ if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath, signal);
9824
9916
  } catch (err) {
9917
+ signal?.throwIfAborted();
9825
9918
  throw new ArchiveError(
9826
9919
  `Could not read archive: ${err instanceof Error ? err.message : String(err)}`
9827
9920
  );
9828
9921
  }
9829
- await assertSafeArchive(archive, destDir);
9830
- await runTar(archive, ["-x", "-C", destDir]);
9831
- return resolveMember(destDir, expectedName);
9922
+ await assertSafeArchive(archive, destDir, signal);
9923
+ signal?.throwIfAborted();
9924
+ await runTar(archive, ["-x", "-C", destDir], signal);
9925
+ const member = await resolveMember(destDir, expectedName);
9926
+ signal?.throwIfAborted();
9927
+ return member;
9832
9928
  }
9833
9929
 
9834
9930
  // ../argent-tools-client/src/errors.ts
@@ -9861,6 +9957,22 @@ function interpolatePath(template, args) {
9861
9957
  });
9862
9958
  return missing ? null : out;
9863
9959
  }
9960
+ function callerPath(p) {
9961
+ const onCurrentDrive = path10.sep === "\\" && /^[\\/](?![\\/])/.test(p);
9962
+ if (!onCurrentDrive && (path10.isAbsolute(p) || path10.win32.isAbsolute(p) || isUnexpandedPath(p))) {
9963
+ return p;
9964
+ }
9965
+ const { root } = path10.parse(p);
9966
+ const rest = p.slice(root.length);
9967
+ if (!rest.split(/[\\/]/).includes("..")) {
9968
+ const resolved = path10.resolve(p);
9969
+ const last = p.split(path10.sep === "\\" ? /[\\/]/ : "/").at(-1);
9970
+ const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(path10.sep);
9971
+ return dirOnly ? `${resolved}${path10.sep}` : resolved;
9972
+ }
9973
+ const base = path10.resolve(root);
9974
+ return base.endsWith(path10.sep) ? `${base}${rest}` : `${base}${path10.sep}${rest}`;
9975
+ }
9864
9976
  async function specPath(spec, args) {
9865
9977
  if (spec.kind !== "file" || !spec.paths?.length) return interpolatePath(spec.path, args);
9866
9978
  const candidates = [];
@@ -9905,10 +10017,10 @@ function untrackArchive(archive) {
9905
10017
  for (const s of ARCHIVE_SIGNALS) process.removeListener(s, removeArchivesOnSignal);
9906
10018
  process.removeListener("exit", removePendingArchives);
9907
10019
  }
9908
- function sha256File(filePath) {
9909
- return new Promise((resolve9, reject) => {
10020
+ function sha256File(filePath, signal) {
10021
+ return new Promise((resolve11, reject) => {
9910
10022
  const hash = createHash2("sha256");
9911
- createReadStream2(filePath).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve9(hash.digest("hex"))).on("error", reject);
10023
+ createReadStream2(filePath, { signal }).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve11(hash.digest("hex"))).on("error", reject);
9912
10024
  });
9913
10025
  }
9914
10026
  function toolServerError(text) {
@@ -9971,7 +10083,7 @@ async function uploadFile(sourcePath, endpoint, signal) {
9971
10083
  trackArchive(tarPath);
9972
10084
  try {
9973
10085
  await createArchiveFile(await realpath2(sourcePath), tarPath, format, signal);
9974
- const contentHash = await sha256File(tarPath);
10086
+ const contentHash = await sha256File(tarPath, signal);
9975
10087
  return { uploadId: await uploadTar(tarPath, format, endpoint, signal), contentHash };
9976
10088
  } finally {
9977
10089
  untrackArchive(tarPath);
@@ -10006,13 +10118,21 @@ async function prepareFileInputs(specs, args, opts) {
10006
10118
  return args;
10007
10119
  }
10008
10120
  const record = args;
10009
- let out = null;
10121
+ const planned = [];
10122
+ const callArgs = { ...record };
10010
10123
  for (const spec of specs) {
10011
10124
  if (spec.skipWhenSet && record[spec.skipWhenSet] !== void 0) continue;
10012
10125
  if (spec.target in record && typeof record[spec.target] !== "string") continue;
10013
- const filePath = await specPath(spec, record);
10014
- if (filePath === null) continue;
10015
- if (spec.target in record && record[spec.target] !== filePath) continue;
10126
+ const spelled = await specPath(spec, record);
10127
+ if (spelled === null) continue;
10128
+ if (spec.target in record && record[spec.target] !== spelled) continue;
10129
+ const filePath = callerPath(spelled);
10130
+ planned.push({ spec, filePath });
10131
+ if (spec.target in record) callArgs[spec.target] = filePath;
10132
+ }
10133
+ if (planned.length === 0) return args;
10134
+ const out = { ...record };
10135
+ for (const { spec, filePath } of planned) {
10016
10136
  const wire = { [FILE_INPUT_MARKER2]: true, path: filePath };
10017
10137
  if (spec.kind === "file") {
10018
10138
  const read = await readFileInputWire(filePath, { includeContent: opts.includeContent });
@@ -10020,12 +10140,12 @@ async function prepareFileInputs(specs, args, opts) {
10020
10140
  if (spec.collect === "flow" && opts.includeContent && wire.content !== void 0 && opts.collectMembers) {
10021
10141
  Object.assign(
10022
10142
  wire,
10023
- await opts.collectMembers(filePath, Buffer.from(wire.content, "base64"), record, opts)
10143
+ await opts.collectMembers(filePath, Buffer.from(wire.content, "base64"), callArgs, opts)
10024
10144
  );
10025
10145
  }
10026
10146
  }
10027
10147
  if (spec.kind === "probe" && spec.collect === "step" && opts.includeContent && opts.collectStepMembers) {
10028
- wire.members = await opts.collectStepMembers(record, opts);
10148
+ wire.members = await opts.collectStepMembers(callArgs, opts);
10029
10149
  }
10030
10150
  if (spec.kind === "tar-upload") {
10031
10151
  const st = await stat3(filePath).catch(() => null);
@@ -10039,10 +10159,9 @@ async function prepareFileInputs(specs, args, opts) {
10039
10159
  Object.assign(wire, await uploadFile(filePath, opts.uploadEndpoint, opts.signal));
10040
10160
  }
10041
10161
  }
10042
- out = out ?? { ...record };
10043
10162
  out[spec.target] = wire;
10044
10163
  }
10045
- return out ?? args;
10164
+ return out;
10046
10165
  }
10047
10166
  function isAllowedClientFilePath(p) {
10048
10167
  if (!path10.isAbsolute(p)) return false;
@@ -10406,7 +10525,7 @@ function memberCollector(roots, opts) {
10406
10525
  for (let file = files.shift(); file !== void 0; file = files.shift()) {
10407
10526
  let doc;
10408
10527
  try {
10409
- doc = (0, import_yaml.parse)(file.text.trim(), { logLevel: "error" });
10528
+ doc = (0, import_yaml.parse)(flowYamlSource(file.text), { logLevel: "error" });
10410
10529
  } catch {
10411
10530
  continue;
10412
10531
  }
@@ -10521,7 +10640,7 @@ function recordedStep(args) {
10521
10640
  async function collectStepMembers(args, opts, recordingDirFor = e2eDirFor) {
10522
10641
  const { name, project_root: projectRoot } = args;
10523
10642
  const step = recordedStep(args);
10524
- if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name) || typeof projectRoot !== "string" || !path11.isAbsolute(projectRoot) || step === void 0) {
10643
+ if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name) || !isResolvedAbsolute2(projectRoot) || step === void 0) {
10525
10644
  return [];
10526
10645
  }
10527
10646
  const recording = path11.join(recordingDirFor(projectRoot), `${name}.yaml`);
@@ -10607,7 +10726,10 @@ async function stepForOlderServer(args, listedId) {
10607
10726
  async function e2eShadowWarningFor(tool, args) {
10608
10727
  const id = canonicalToolId(tool);
10609
10728
  if (id !== "e2e-execute" && id !== "e2e-read-prerequisite") return void 0;
10610
- const target = nestedFlowTarget(args);
10729
+ const root = args?.project_root;
10730
+ const target = nestedFlowTarget(
10731
+ typeof root === "string" ? { ...args, project_root: callerPath(root) } : args
10732
+ );
10611
10733
  if (target?.kind !== "name") return void 0;
10612
10734
  const picked = await pickE2eFile(target.paths);
10613
10735
  return picked.shadowed === void 0 ? void 0 : e2eShadowWarning(picked.path, picked.shadowed);
@@ -10771,7 +10893,7 @@ async function forwardedSecrets(args) {
10771
10893
  }
10772
10894
  let parsed;
10773
10895
  try {
10774
- parsed = text === void 0 ? void 0 : (0, import_yaml2.parse)(text.trim(), { logLevel: "error" });
10896
+ parsed = text === void 0 ? void 0 : (0, import_yaml2.parse)(flowYamlSource(text), { logLevel: "error" });
10775
10897
  } catch {
10776
10898
  continue;
10777
10899
  }
@@ -10802,6 +10924,34 @@ function secretsTransportRefusal(url) {
10802
10924
  return void 0;
10803
10925
  }
10804
10926
  var FETCH_HEAD_BYTES = 256;
10927
+ function isRecord2(value) {
10928
+ return typeof value === "object" && value !== null && !Array.isArray(value);
10929
+ }
10930
+ var PROJECT_PATH_ADVICE = {
10931
+ project_root: "Pass the absolute path to the project root directory - the same cwd the calling agent is working in.",
10932
+ e2e_test_path: "Pass the absolute path to the e2e test file."
10933
+ };
10934
+ function assertAbsoluteProjectPaths(meta, args) {
10935
+ if (!meta || !isRecord2(args)) return;
10936
+ const aliases = Object.entries(toolParamAliases(meta.name));
10937
+ for (const [param, advice] of Object.entries(PROJECT_PATH_ADVICE)) {
10938
+ const value = args[param];
10939
+ if (typeof value !== "string" || callerPath(value) === value) continue;
10940
+ const names = [param, ...aliases.filter(([, current]) => current === param).map(([f]) => f)];
10941
+ if (!meta.fileInputs?.some((spec) => names.some((n) => spec.path.includes(`\${${n}}`)))) {
10942
+ continue;
10943
+ }
10944
+ throw new Error(`${param} must be an absolute path (got "${value}"). ${advice}`);
10945
+ }
10946
+ }
10947
+ function failedRun(result) {
10948
+ if (!isRecord2(result)) return result;
10949
+ if (result.ok === true) return { ...result, ok: false };
10950
+ if (isRecord2(result.toolResult) && result.toolResult.ok === true) {
10951
+ return { ...result, toolResult: { ...result.toolResult, ok: false } };
10952
+ }
10953
+ return result;
10954
+ }
10805
10955
  function createToolsClient(options = {}) {
10806
10956
  let cached = null;
10807
10957
  const doFetch = options.fetchImpl ?? ((url, init) => fetch(url, init));
@@ -10850,6 +11000,7 @@ function createToolsClient(options = {}) {
10850
11000
  let finalArgs = canonicalToolArgs(name, args);
10851
11001
  const { tools, uploadFormats } = await fetchToolList({ signal: opts?.signal });
10852
11002
  const meta = findTool(tools, name);
11003
+ if (options.refuseRelativeProjectPaths) assertAbsoluteProjectPaths(meta, finalArgs);
10853
11004
  const olderServer = meta !== null && !tools.some((t) => t.name === canonicalToolId(meta.name));
10854
11005
  if (meta) {
10855
11006
  finalArgs = await nameToE2ePathForOlderServer(meta.name, meta.fileInputs, finalArgs);
@@ -10887,7 +11038,7 @@ function createToolsClient(options = {}) {
10887
11038
  }
10888
11039
  }
10889
11040
  }
10890
- const result = applied.result;
11041
+ const result = applied.failed.length > 0 ? failedRun(applied.result) : applied.result;
10891
11042
  if (shadowWarning === void 0 || typeof result !== "object" || result === null || Array.isArray(result) || typeof result.warning === "string") {
10892
11043
  return result;
10893
11044
  }
@@ -11014,10 +11165,19 @@ function createToolsClient(options = {}) {
11014
11165
  }
11015
11166
 
11016
11167
  // ../argent-tools-client/src/artifacts.ts
11017
- import { copyFile, mkdir as mkdir4, readFile as readFile6, realpath as realpath4, rm as rm3, stat as stat5, writeFile as writeFile4 } from "node:fs/promises";
11168
+ import {
11169
+ copyFile,
11170
+ mkdir as mkdir4,
11171
+ mkdtemp,
11172
+ readFile as readFile6,
11173
+ realpath as realpath4,
11174
+ rm as rm3,
11175
+ stat as stat5,
11176
+ writeFile as writeFile4
11177
+ } from "node:fs/promises";
11018
11178
  import { constants as fsConstants } from "node:fs";
11019
11179
  import { tmpdir as tmpdir2 } from "node:os";
11020
- 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";
11180
+ 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";
11021
11181
  import { createHash as createHash3 } from "node:crypto";
11022
11182
  var ARTIFACT_MARKER2 = "__argentArtifact";
11023
11183
  function isArtifactHandle(value) {
@@ -11065,8 +11225,8 @@ function configuredRecordingsDir() {
11065
11225
  const trimmed = value.trim();
11066
11226
  if (trimmed === "") return null;
11067
11227
  const home = dirname9(argentHomeDir());
11068
- const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep4}`) ? join13(home, trimmed.slice(2)) : trimmed;
11069
- return resolve8(durableBaseDir(), expanded);
11228
+ const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep5}`) ? join13(home, trimmed.slice(2)) : trimmed;
11229
+ return resolve10(durableBaseDir(), expanded);
11070
11230
  }
11071
11231
  var MAX_ARTIFACT_BYTES = 2 * 1024 * 1024 * 1024;
11072
11232
  async function readCapped(res, cap) {
@@ -11113,7 +11273,7 @@ async function writeDurableUnique(dir, filename, write) {
11113
11273
  function durableSaveTarget(handle) {
11114
11274
  if (typeof handle.saveDir !== "string" || !handle.saveDir || handle.archive) return null;
11115
11275
  const rel = normalize2(handle.saveDir);
11116
- if (isAbsolute6(rel) || rel === ".." || rel.startsWith(`..${sep4}`) || rel.split(sep4).includes("..")) {
11276
+ if (isAbsolute6(rel) || rel === ".." || rel.startsWith(`..${sep5}`) || rel.split(sep5).includes("..")) {
11117
11277
  return null;
11118
11278
  }
11119
11279
  if (!ALLOWED_SAVE_DIRS.has(rel)) return null;
@@ -11158,16 +11318,22 @@ async function resolveLocalFile(handle) {
11158
11318
  return null;
11159
11319
  }
11160
11320
  }
11161
- async function downloadAndExtractArchive(handle, data, dir) {
11162
- const tarball = join13(dir, `${sanitizeSegment(handle.filename)}.tar.gz`);
11321
+ async function downloadAndExtractArchive(handle, data, dir, signal) {
11322
+ signal?.throwIfAborted();
11323
+ const attemptDir = await mkdtemp(join13(dir, "bundle-"));
11324
+ const tarball = join13(attemptDir, "download.tar");
11325
+ const extractDir = join13(attemptDir, "files");
11163
11326
  try {
11164
- await writeFile4(tarball, data);
11165
- return await safeExtractArchive(tarball, dir, handle.filename);
11327
+ await writeFile4(tarball, data, { signal });
11328
+ await mkdir4(extractDir);
11329
+ const member = await safeExtractArchive(tarball, extractDir, handle.filename, signal);
11330
+ await rm3(tarball);
11331
+ signal?.throwIfAborted();
11332
+ return member;
11166
11333
  } catch {
11167
- return null;
11168
- } finally {
11169
- await rm3(tarball, { force: true }).catch(() => {
11334
+ await rm3(attemptDir, { recursive: true, force: true }).catch(() => {
11170
11335
  });
11336
+ return null;
11171
11337
  }
11172
11338
  }
11173
11339
  async function materializeArtifacts(result, ctx) {
@@ -11253,7 +11419,7 @@ async function materializeArtifacts(result, ctx) {
11253
11419
  if (!data) return null;
11254
11420
  await ensureDir();
11255
11421
  if (value.archive === "tar.gz") {
11256
- return await downloadAndExtractArchive(value, data, dir);
11422
+ return await downloadAndExtractArchive(value, data, dir, ctx.signal);
11257
11423
  }
11258
11424
  if (value.size > 0 && data.length !== value.size) return null;
11259
11425
  const downloadedPath = join13(dir, sanitizeSegment(value.filename));
@@ -11290,12 +11456,12 @@ function getDeviceIdFromArgs(args) {
11290
11456
  }
11291
11457
 
11292
11458
  // src/bundled-paths.ts
11293
- import * as fs7 from "node:fs";
11459
+ import * as fs8 from "node:fs";
11294
11460
  import * as path13 from "node:path";
11295
11461
  function readPackageVersion() {
11296
11462
  try {
11297
11463
  const pkg = JSON.parse(
11298
- fs7.readFileSync(path13.join(import.meta.dirname, "..", "package.json"), "utf8")
11464
+ fs8.readFileSync(path13.join(import.meta.dirname, "..", "package.json"), "utf8")
11299
11465
  );
11300
11466
  return pkg.version;
11301
11467
  } catch {
@@ -11306,9 +11472,9 @@ var PACKAGE_NAME = "@swmansion/argent";
11306
11472
  function findDeclaringRoot(startDir) {
11307
11473
  let dir = startDir;
11308
11474
  for (; ; ) {
11309
- if (fs7.existsSync(path13.join(dir, ".argent", "install.json"))) return dir;
11475
+ if (fs8.existsSync(path13.join(dir, ".argent", "install.json"))) return dir;
11310
11476
  try {
11311
- const manifest = JSON.parse(fs7.readFileSync(path13.join(dir, "package.json"), "utf8"));
11477
+ const manifest = JSON.parse(fs8.readFileSync(path13.join(dir, "package.json"), "utf8"));
11312
11478
  if (manifest.devDependencies?.[PACKAGE_NAME] || manifest.dependencies?.[PACKAGE_NAME] || manifest.optionalDependencies?.[PACKAGE_NAME]) {
11313
11479
  return dir;
11314
11480
  }
@@ -11324,7 +11490,7 @@ function findStablePackageDir(startDir, packageRoot) {
11324
11490
  for (; ; ) {
11325
11491
  const candidate = path13.join(dir, "node_modules", PACKAGE_NAME);
11326
11492
  try {
11327
- if (fs7.realpathSync(candidate) === packageRoot) return candidate;
11493
+ if (fs8.realpathSync(candidate) === packageRoot) return candidate;
11328
11494
  } catch {
11329
11495
  }
11330
11496
  const parent = path13.dirname(dir);
@@ -11337,7 +11503,7 @@ function classifyInstall() {
11337
11503
  let dir;
11338
11504
  let cwd;
11339
11505
  try {
11340
- packageRoot = fs7.realpathSync(path13.join(import.meta.dirname, ".."));
11506
+ packageRoot = fs8.realpathSync(path13.join(import.meta.dirname, ".."));
11341
11507
  cwd = process.cwd();
11342
11508
  dir = cwd;
11343
11509
  } catch {
@@ -11345,7 +11511,7 @@ function classifyInstall() {
11345
11511
  }
11346
11512
  for (; ; ) {
11347
11513
  try {
11348
- const nmReal = fs7.realpathSync(path13.join(dir, "node_modules"));
11514
+ const nmReal = fs8.realpathSync(path13.join(dir, "node_modules"));
11349
11515
  if (packageRoot === nmReal || packageRoot.startsWith(nmReal + path13.sep)) {
11350
11516
  return {
11351
11517
  kind: "local",