@swmansion/argent 0.27.1-next.21 → 0.27.1-next.23

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.
package/dist/client.js CHANGED
@@ -39,7 +39,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
39
39
  var require_main = __commonJS({
40
40
  "../../node_modules/dotenv/lib/main.js"(exports, module) {
41
41
  var fs7 = __require("fs");
42
- var path12 = __require("path");
42
+ var path13 = __require("path");
43
43
  var os2 = __require("os");
44
44
  var crypto2 = __require("crypto");
45
45
  var TIPS = [
@@ -178,7 +178,7 @@ var require_main = __commonJS({
178
178
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
179
179
  }
180
180
  } else {
181
- possibleVaultPath = path12.resolve(process.cwd(), ".env.vault");
181
+ possibleVaultPath = path13.resolve(process.cwd(), ".env.vault");
182
182
  }
183
183
  if (fs7.existsSync(possibleVaultPath)) {
184
184
  return possibleVaultPath;
@@ -186,7 +186,7 @@ var require_main = __commonJS({
186
186
  return null;
187
187
  }
188
188
  function _resolveHome(envPath) {
189
- return envPath[0] === "~" ? path12.join(os2.homedir(), envPath.slice(1)) : envPath;
189
+ return envPath[0] === "~" ? path13.join(os2.homedir(), envPath.slice(1)) : envPath;
190
190
  }
191
191
  function _configVault(options) {
192
192
  const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
@@ -203,7 +203,7 @@ var require_main = __commonJS({
203
203
  return { parsed };
204
204
  }
205
205
  function configDotenv(options) {
206
- const dotenvPath = path12.resolve(process.cwd(), ".env");
206
+ const dotenvPath = path13.resolve(process.cwd(), ".env");
207
207
  let encoding = "utf8";
208
208
  let processEnv = process.env;
209
209
  if (options && options.processEnv != null) {
@@ -231,13 +231,13 @@ var require_main = __commonJS({
231
231
  }
232
232
  let lastError;
233
233
  const parsedAll = {};
234
- for (const path13 of optionPaths) {
234
+ for (const path14 of optionPaths) {
235
235
  try {
236
- const parsed = DotenvModule.parse(fs7.readFileSync(path13, { encoding }));
236
+ const parsed = DotenvModule.parse(fs7.readFileSync(path14, { encoding }));
237
237
  DotenvModule.populate(parsedAll, parsed, options);
238
238
  } catch (e) {
239
239
  if (debug) {
240
- _debug(`failed to load ${path13} ${e.message}`);
240
+ _debug(`failed to load ${path14} ${e.message}`);
241
241
  }
242
242
  lastError = e;
243
243
  }
@@ -250,7 +250,7 @@ var require_main = __commonJS({
250
250
  const shortPaths = [];
251
251
  for (const filePath of optionPaths) {
252
252
  try {
253
- const relative2 = path12.relative(process.cwd(), filePath);
253
+ const relative2 = path13.relative(process.cwd(), filePath);
254
254
  shortPaths.push(relative2);
255
255
  } catch (e) {
256
256
  if (debug) {
@@ -431,17 +431,17 @@ var require_visit = __commonJS({
431
431
  visit.BREAK = BREAK;
432
432
  visit.SKIP = SKIP;
433
433
  visit.REMOVE = REMOVE;
434
- function visit_(key, node, visitor, path12) {
435
- const ctrl = callVisitor(key, node, visitor, path12);
434
+ function visit_(key, node, visitor, path13) {
435
+ const ctrl = callVisitor(key, node, visitor, path13);
436
436
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
437
- replaceNode(key, path12, ctrl);
438
- return visit_(key, ctrl, visitor, path12);
437
+ replaceNode(key, path13, ctrl);
438
+ return visit_(key, ctrl, visitor, path13);
439
439
  }
440
440
  if (typeof ctrl !== "symbol") {
441
441
  if (identity.isCollection(node)) {
442
- path12 = Object.freeze(path12.concat(node));
442
+ path13 = Object.freeze(path13.concat(node));
443
443
  for (let i = 0; i < node.items.length; ++i) {
444
- const ci = visit_(i, node.items[i], visitor, path12);
444
+ const ci = visit_(i, node.items[i], visitor, path13);
445
445
  if (typeof ci === "number")
446
446
  i = ci - 1;
447
447
  else if (ci === BREAK)
@@ -452,13 +452,13 @@ var require_visit = __commonJS({
452
452
  }
453
453
  }
454
454
  } else if (identity.isPair(node)) {
455
- path12 = Object.freeze(path12.concat(node));
456
- const ck = visit_("key", node.key, visitor, path12);
455
+ path13 = Object.freeze(path13.concat(node));
456
+ const ck = visit_("key", node.key, visitor, path13);
457
457
  if (ck === BREAK)
458
458
  return BREAK;
459
459
  else if (ck === REMOVE)
460
460
  node.key = null;
461
- const cv = visit_("value", node.value, visitor, path12);
461
+ const cv = visit_("value", node.value, visitor, path13);
462
462
  if (cv === BREAK)
463
463
  return BREAK;
464
464
  else if (cv === REMOVE)
@@ -479,17 +479,17 @@ var require_visit = __commonJS({
479
479
  visitAsync.BREAK = BREAK;
480
480
  visitAsync.SKIP = SKIP;
481
481
  visitAsync.REMOVE = REMOVE;
482
- async function visitAsync_(key, node, visitor, path12) {
483
- const ctrl = await callVisitor(key, node, visitor, path12);
482
+ async function visitAsync_(key, node, visitor, path13) {
483
+ const ctrl = await callVisitor(key, node, visitor, path13);
484
484
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
485
- replaceNode(key, path12, ctrl);
486
- return visitAsync_(key, ctrl, visitor, path12);
485
+ replaceNode(key, path13, ctrl);
486
+ return visitAsync_(key, ctrl, visitor, path13);
487
487
  }
488
488
  if (typeof ctrl !== "symbol") {
489
489
  if (identity.isCollection(node)) {
490
- path12 = Object.freeze(path12.concat(node));
490
+ path13 = Object.freeze(path13.concat(node));
491
491
  for (let i = 0; i < node.items.length; ++i) {
492
- const ci = await visitAsync_(i, node.items[i], visitor, path12);
492
+ const ci = await visitAsync_(i, node.items[i], visitor, path13);
493
493
  if (typeof ci === "number")
494
494
  i = ci - 1;
495
495
  else if (ci === BREAK)
@@ -500,13 +500,13 @@ var require_visit = __commonJS({
500
500
  }
501
501
  }
502
502
  } else if (identity.isPair(node)) {
503
- path12 = Object.freeze(path12.concat(node));
504
- const ck = await visitAsync_("key", node.key, visitor, path12);
503
+ path13 = Object.freeze(path13.concat(node));
504
+ const ck = await visitAsync_("key", node.key, visitor, path13);
505
505
  if (ck === BREAK)
506
506
  return BREAK;
507
507
  else if (ck === REMOVE)
508
508
  node.key = null;
509
- const cv = await visitAsync_("value", node.value, visitor, path12);
509
+ const cv = await visitAsync_("value", node.value, visitor, path13);
510
510
  if (cv === BREAK)
511
511
  return BREAK;
512
512
  else if (cv === REMOVE)
@@ -533,23 +533,23 @@ var require_visit = __commonJS({
533
533
  }
534
534
  return visitor;
535
535
  }
536
- function callVisitor(key, node, visitor, path12) {
536
+ function callVisitor(key, node, visitor, path13) {
537
537
  if (typeof visitor === "function")
538
- return visitor(key, node, path12);
538
+ return visitor(key, node, path13);
539
539
  if (identity.isMap(node))
540
- return visitor.Map?.(key, node, path12);
540
+ return visitor.Map?.(key, node, path13);
541
541
  if (identity.isSeq(node))
542
- return visitor.Seq?.(key, node, path12);
542
+ return visitor.Seq?.(key, node, path13);
543
543
  if (identity.isPair(node))
544
- return visitor.Pair?.(key, node, path12);
544
+ return visitor.Pair?.(key, node, path13);
545
545
  if (identity.isScalar(node))
546
- return visitor.Scalar?.(key, node, path12);
546
+ return visitor.Scalar?.(key, node, path13);
547
547
  if (identity.isAlias(node))
548
- return visitor.Alias?.(key, node, path12);
548
+ return visitor.Alias?.(key, node, path13);
549
549
  return void 0;
550
550
  }
551
- function replaceNode(key, path12, node) {
552
- const parent = path12[path12.length - 1];
551
+ function replaceNode(key, path13, node) {
552
+ const parent = path13[path13.length - 1];
553
553
  if (identity.isCollection(parent)) {
554
554
  parent.items[key] = node;
555
555
  } else if (identity.isPair(parent)) {
@@ -1159,10 +1159,10 @@ var require_Collection = __commonJS({
1159
1159
  var createNode = require_createNode();
1160
1160
  var identity = require_identity();
1161
1161
  var Node = require_Node();
1162
- function collectionFromPath(schema, path12, value) {
1162
+ function collectionFromPath(schema, path13, value) {
1163
1163
  let v = value;
1164
- for (let i = path12.length - 1; i >= 0; --i) {
1165
- const k = path12[i];
1164
+ for (let i = path13.length - 1; i >= 0; --i) {
1165
+ const k = path13[i];
1166
1166
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
1167
1167
  const a = [];
1168
1168
  a[k] = v;
@@ -1181,7 +1181,7 @@ var require_Collection = __commonJS({
1181
1181
  sourceObjects: /* @__PURE__ */ new Map()
1182
1182
  });
1183
1183
  }
1184
- var isEmptyPath = (path12) => path12 == null || typeof path12 === "object" && !!path12[Symbol.iterator]().next().done;
1184
+ var isEmptyPath = (path13) => path13 == null || typeof path13 === "object" && !!path13[Symbol.iterator]().next().done;
1185
1185
  var Collection = class extends Node.NodeBase {
1186
1186
  constructor(type, schema) {
1187
1187
  super(type);
@@ -1211,11 +1211,11 @@ var require_Collection = __commonJS({
1211
1211
  * be a Pair instance or a `{ key, value }` object, which may not have a key
1212
1212
  * that already exists in the map.
1213
1213
  */
1214
- addIn(path12, value) {
1215
- if (isEmptyPath(path12))
1214
+ addIn(path13, value) {
1215
+ if (isEmptyPath(path13))
1216
1216
  this.add(value);
1217
1217
  else {
1218
- const [key, ...rest] = path12;
1218
+ const [key, ...rest] = path13;
1219
1219
  const node = this.get(key, true);
1220
1220
  if (identity.isCollection(node))
1221
1221
  node.addIn(rest, value);
@@ -1229,8 +1229,8 @@ var require_Collection = __commonJS({
1229
1229
  * Removes a value from the collection.
1230
1230
  * @returns `true` if the item was found and removed.
1231
1231
  */
1232
- deleteIn(path12) {
1233
- const [key, ...rest] = path12;
1232
+ deleteIn(path13) {
1233
+ const [key, ...rest] = path13;
1234
1234
  if (rest.length === 0)
1235
1235
  return this.delete(key);
1236
1236
  const node = this.get(key, true);
@@ -1244,8 +1244,8 @@ var require_Collection = __commonJS({
1244
1244
  * scalar values from their surrounding node; to disable set `keepScalar` to
1245
1245
  * `true` (collections are always returned intact).
1246
1246
  */
1247
- getIn(path12, keepScalar) {
1248
- const [key, ...rest] = path12;
1247
+ getIn(path13, keepScalar) {
1248
+ const [key, ...rest] = path13;
1249
1249
  const node = this.get(key, true);
1250
1250
  if (rest.length === 0)
1251
1251
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -1263,8 +1263,8 @@ var require_Collection = __commonJS({
1263
1263
  /**
1264
1264
  * Checks if the collection includes a value with the key `key`.
1265
1265
  */
1266
- hasIn(path12) {
1267
- const [key, ...rest] = path12;
1266
+ hasIn(path13) {
1267
+ const [key, ...rest] = path13;
1268
1268
  if (rest.length === 0)
1269
1269
  return this.has(key);
1270
1270
  const node = this.get(key, true);
@@ -1274,8 +1274,8 @@ var require_Collection = __commonJS({
1274
1274
  * Sets a value in this collection. For `!!set`, `value` needs to be a
1275
1275
  * boolean to add/remove the item from the set.
1276
1276
  */
1277
- setIn(path12, value) {
1278
- const [key, ...rest] = path12;
1277
+ setIn(path13, value) {
1278
+ const [key, ...rest] = path13;
1279
1279
  if (rest.length === 0) {
1280
1280
  this.set(key, value);
1281
1281
  } else {
@@ -3790,9 +3790,9 @@ var require_Document = __commonJS({
3790
3790
  this.contents.add(value);
3791
3791
  }
3792
3792
  /** Adds a value to the document. */
3793
- addIn(path12, value) {
3793
+ addIn(path13, value) {
3794
3794
  if (assertCollection(this.contents))
3795
- this.contents.addIn(path12, value);
3795
+ this.contents.addIn(path13, value);
3796
3796
  }
3797
3797
  /**
3798
3798
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -3867,14 +3867,14 @@ var require_Document = __commonJS({
3867
3867
  * Removes a value from the document.
3868
3868
  * @returns `true` if the item was found and removed.
3869
3869
  */
3870
- deleteIn(path12) {
3871
- if (Collection.isEmptyPath(path12)) {
3870
+ deleteIn(path13) {
3871
+ if (Collection.isEmptyPath(path13)) {
3872
3872
  if (this.contents == null)
3873
3873
  return false;
3874
3874
  this.contents = null;
3875
3875
  return true;
3876
3876
  }
3877
- return assertCollection(this.contents) ? this.contents.deleteIn(path12) : false;
3877
+ return assertCollection(this.contents) ? this.contents.deleteIn(path13) : false;
3878
3878
  }
3879
3879
  /**
3880
3880
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -3889,10 +3889,10 @@ var require_Document = __commonJS({
3889
3889
  * scalar values from their surrounding node; to disable set `keepScalar` to
3890
3890
  * `true` (collections are always returned intact).
3891
3891
  */
3892
- getIn(path12, keepScalar) {
3893
- if (Collection.isEmptyPath(path12))
3892
+ getIn(path13, keepScalar) {
3893
+ if (Collection.isEmptyPath(path13))
3894
3894
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
3895
- return identity.isCollection(this.contents) ? this.contents.getIn(path12, keepScalar) : void 0;
3895
+ return identity.isCollection(this.contents) ? this.contents.getIn(path13, keepScalar) : void 0;
3896
3896
  }
3897
3897
  /**
3898
3898
  * Checks if the document includes a value with the key `key`.
@@ -3903,10 +3903,10 @@ var require_Document = __commonJS({
3903
3903
  /**
3904
3904
  * Checks if the document includes a value at `path`.
3905
3905
  */
3906
- hasIn(path12) {
3907
- if (Collection.isEmptyPath(path12))
3906
+ hasIn(path13) {
3907
+ if (Collection.isEmptyPath(path13))
3908
3908
  return this.contents !== void 0;
3909
- return identity.isCollection(this.contents) ? this.contents.hasIn(path12) : false;
3909
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path13) : false;
3910
3910
  }
3911
3911
  /**
3912
3912
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -3923,13 +3923,13 @@ var require_Document = __commonJS({
3923
3923
  * Sets a value in this document. For `!!set`, `value` needs to be a
3924
3924
  * boolean to add/remove the item from the set.
3925
3925
  */
3926
- setIn(path12, value) {
3927
- if (Collection.isEmptyPath(path12)) {
3926
+ setIn(path13, value) {
3927
+ if (Collection.isEmptyPath(path13)) {
3928
3928
  this.contents = value;
3929
3929
  } else if (this.contents == null) {
3930
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path12), value);
3930
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path13), value);
3931
3931
  } else if (assertCollection(this.contents)) {
3932
- this.contents.setIn(path12, value);
3932
+ this.contents.setIn(path13, value);
3933
3933
  }
3934
3934
  }
3935
3935
  /**
@@ -5889,9 +5889,9 @@ var require_cst_visit = __commonJS({
5889
5889
  visit.BREAK = BREAK;
5890
5890
  visit.SKIP = SKIP;
5891
5891
  visit.REMOVE = REMOVE;
5892
- visit.itemAtPath = (cst, path12) => {
5892
+ visit.itemAtPath = (cst, path13) => {
5893
5893
  let item = cst;
5894
- for (const [field, index] of path12) {
5894
+ for (const [field, index] of path13) {
5895
5895
  const tok = item?.[field];
5896
5896
  if (tok && "items" in tok) {
5897
5897
  item = tok.items[index];
@@ -5900,23 +5900,23 @@ var require_cst_visit = __commonJS({
5900
5900
  }
5901
5901
  return item;
5902
5902
  };
5903
- visit.parentCollection = (cst, path12) => {
5904
- const parent = visit.itemAtPath(cst, path12.slice(0, -1));
5905
- const field = path12[path12.length - 1][0];
5903
+ visit.parentCollection = (cst, path13) => {
5904
+ const parent = visit.itemAtPath(cst, path13.slice(0, -1));
5905
+ const field = path13[path13.length - 1][0];
5906
5906
  const coll = parent?.[field];
5907
5907
  if (coll && "items" in coll)
5908
5908
  return coll;
5909
5909
  throw new Error("Parent collection not found");
5910
5910
  };
5911
- function _visit(path12, item, visitor) {
5912
- let ctrl = visitor(item, path12);
5911
+ function _visit(path13, item, visitor) {
5912
+ let ctrl = visitor(item, path13);
5913
5913
  if (typeof ctrl === "symbol")
5914
5914
  return ctrl;
5915
5915
  for (const field of ["key", "value"]) {
5916
5916
  const token = item[field];
5917
5917
  if (token && "items" in token) {
5918
5918
  for (let i = 0; i < token.items.length; ++i) {
5919
- const ci = _visit(Object.freeze(path12.concat([[field, i]])), token.items[i], visitor);
5919
+ const ci = _visit(Object.freeze(path13.concat([[field, i]])), token.items[i], visitor);
5920
5920
  if (typeof ci === "number")
5921
5921
  i = ci - 1;
5922
5922
  else if (ci === BREAK)
@@ -5927,10 +5927,10 @@ var require_cst_visit = __commonJS({
5927
5927
  }
5928
5928
  }
5929
5929
  if (typeof ctrl === "function" && field === "key")
5930
- ctrl = ctrl(item, path12);
5930
+ ctrl = ctrl(item, path13);
5931
5931
  }
5932
5932
  }
5933
- return typeof ctrl === "function" ? ctrl(item, path12) : ctrl;
5933
+ return typeof ctrl === "function" ? ctrl(item, path13) : ctrl;
5934
5934
  }
5935
5935
  exports.visit = visit;
5936
5936
  }
@@ -8097,7 +8097,7 @@ function generateToken() {
8097
8097
  return randomBytes(AUTH_TOKEN_BYTES).toString("hex");
8098
8098
  }
8099
8099
  function findFreePort() {
8100
- return new Promise((resolve7, reject) => {
8100
+ return new Promise((resolve8, reject) => {
8101
8101
  const srv = net.createServer();
8102
8102
  srv.listen(0, "127.0.0.1", () => {
8103
8103
  const addr = srv.address();
@@ -8108,7 +8108,7 @@ function findFreePort() {
8108
8108
  const port = addr.port;
8109
8109
  srv.close((err) => {
8110
8110
  if (err) reject(err);
8111
- else resolve7(port);
8111
+ else resolve8(port);
8112
8112
  });
8113
8113
  });
8114
8114
  srv.on("error", reject);
@@ -8206,7 +8206,7 @@ function killSpawnedChild(child, pid) {
8206
8206
  }
8207
8207
  }
8208
8208
  function spawnToolsServer(paths, port, options = {}) {
8209
- return new Promise((resolve7, reject) => {
8209
+ return new Promise((resolve8, reject) => {
8210
8210
  let logFd;
8211
8211
  try {
8212
8212
  fs4.mkdirSync(STATE_DIR, { recursive: true });
@@ -8252,7 +8252,7 @@ function spawnToolsServer(paths, port, options = {}) {
8252
8252
  rl.close();
8253
8253
  child.stdout?.resume();
8254
8254
  child.stdout?.unref?.();
8255
- settle(() => resolve7({ port: actualPort, pid }));
8255
+ settle(() => resolve8({ port: actualPort, pid }));
8256
8256
  }
8257
8257
  });
8258
8258
  child.on("error", (err) => {
@@ -8556,6 +8556,12 @@ async function ensureToolsServer(paths) {
8556
8556
  }
8557
8557
  }
8558
8558
 
8559
+ // ../argent-tools-client/src/tools-client.ts
8560
+ import * as path11 from "node:path";
8561
+
8562
+ // ../registry/src/types.ts
8563
+ var LINKED_CALL_HEADER = "x-argent-linked";
8564
+
8559
8565
  // ../registry/src/artifacts.ts
8560
8566
  import { stat } from "node:fs/promises";
8561
8567
  import { randomUUID as randomUUID2 } from "node:crypto";
@@ -8566,6 +8572,35 @@ var FLOW_NAME_CHARSET = "[A-Za-z0-9_-]+";
8566
8572
  var FLOW_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}$`);
8567
8573
  var FLOW_FILE_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}\\.yaml$`);
8568
8574
  var SCRIPT_FILE_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}\\.mjs$`);
8575
+ function interpolateFileInputPath(template, args) {
8576
+ let missing = false;
8577
+ const out = template.replace(/\$\{([A-Za-z0-9_]+)\}/g, (_m, name) => {
8578
+ const v = args[name];
8579
+ if (typeof v !== "string" || v.length === 0) {
8580
+ missing = true;
8581
+ return "";
8582
+ }
8583
+ return v;
8584
+ });
8585
+ return missing ? null : out;
8586
+ }
8587
+ var TOOL_FILE_EXTENSIONS = [".png", ".yaml"];
8588
+ function hasToolFileExtension(file) {
8589
+ const name = file.toLowerCase();
8590
+ return TOOL_FILE_EXTENSIONS.some((extension) => name.endsWith(extension));
8591
+ }
8592
+ function toolStepFiles(specs, args) {
8593
+ const files = [];
8594
+ for (const spec of specs ?? []) {
8595
+ if (spec.skipWhenSet !== void 0 && args[spec.skipWhenSet] !== void 0) continue;
8596
+ const filled = interpolateFileInputPath(spec.path, args);
8597
+ if (filled !== null) files.push({ spec, path: filled });
8598
+ }
8599
+ return files;
8600
+ }
8601
+ function isClientFileArgument({ spec, path: path13 }) {
8602
+ return spec.kind === "file" && spec.path === `\${${spec.target}}` && path13.startsWith("/") && hasToolFileExtension(path13);
8603
+ }
8569
8604
 
8570
8605
  // ../registry/src/flow-file-refs.ts
8571
8606
  import * as fs5 from "node:fs/promises";
@@ -8594,6 +8629,8 @@ function isRecord(value) {
8594
8629
  function collectFlowRequests(doc) {
8595
8630
  const runTargets = /* @__PURE__ */ new Set();
8596
8631
  const snapshots = /* @__PURE__ */ new Set();
8632
+ const toolSteps = [];
8633
+ const nested = [];
8597
8634
  const seen = /* @__PURE__ */ new Set();
8598
8635
  const visit = (steps, depth) => {
8599
8636
  if (!Array.isArray(steps) || depth > MAX_BLOCK_NESTING || seen.has(steps)) return;
@@ -8607,11 +8644,17 @@ function collectFlowRequests(doc) {
8607
8644
  }
8608
8645
  const snapshot = isRecord(step.snapshot) ? step.snapshot.name : step.snapshot;
8609
8646
  if (typeof snapshot === "string" && FLOW_NAME_PATTERN.test(snapshot)) snapshots.add(snapshot);
8647
+ if (typeof step.tool === "string") {
8648
+ const args = isRecord(step.args) ? step.args : {};
8649
+ toolSteps.push({ tool: step.tool, args });
8650
+ const target = step.tool === "flow-execute" ? nestedFlowTarget(args) : void 0;
8651
+ if (target !== void 0) nested.push({ target, args });
8652
+ }
8610
8653
  visit(step.steps, depth + 1);
8611
8654
  }
8612
8655
  };
8613
8656
  if (isRecord(doc)) visit(doc.steps, 0);
8614
- return { runTargets: [...runTargets], snapshots: [...snapshots] };
8657
+ return { runTargets: [...runTargets], snapshots: [...snapshots], toolSteps, nested };
8615
8658
  }
8616
8659
  function baselineKeyFor(canonicalPath, flowName) {
8617
8660
  const stem = path7.basename(canonicalPath, ".yaml");
@@ -8627,6 +8670,26 @@ async function classifyOnDiskSpelling(dir, base, addressable = FLOW_FILE_NAME_PA
8627
8670
  if (actual === void 0) return { state: "absent" };
8628
8671
  return { state: "case_folded", actual, addressable: addressable.test(actual) };
8629
8672
  }
8673
+ function nestedFlowTarget(args) {
8674
+ if (typeof args !== "object" || args === null || Array.isArray(args)) return void 0;
8675
+ const { name, project_root: projectRoot, flow_path: flowPath } = args;
8676
+ if (flowPath === void 0) {
8677
+ if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name)) return void 0;
8678
+ if (!isResolvedAbsolute(projectRoot)) return void 0;
8679
+ return {
8680
+ kind: "name",
8681
+ projectRoot,
8682
+ name,
8683
+ path: path7.join(projectRoot, ".argent", "flows", `${name}.yaml`)
8684
+ };
8685
+ }
8686
+ if (name !== void 0 || !isResolvedAbsolute(flowPath)) return void 0;
8687
+ if (!FLOW_FILE_NAME_PATTERN.test(path7.basename(flowPath))) return void 0;
8688
+ return { kind: "flow_path", path: flowPath };
8689
+ }
8690
+ function isResolvedAbsolute(value) {
8691
+ return typeof value === "string" && path7.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
8692
+ }
8630
8693
 
8631
8694
  // ../registry/src/failure-codes.ts
8632
8695
  var FAILURE_CODES = {
@@ -8947,9 +9010,9 @@ var FAILURE_SPAWN_CODE_SET = new Set(FAILURE_SPAWN_CODES);
8947
9010
  import { randomUUID as randomUUID3 } from "node:crypto";
8948
9011
  import { AsyncLocalStorage } from "node:async_hooks";
8949
9012
  var resolvedDuringInvocation = new AsyncLocalStorage();
8950
- function valueAtPath(root, path12) {
9013
+ function valueAtPath(root, path13) {
8951
9014
  let current = root;
8952
- for (const key of path12) {
9015
+ for (const key of path13) {
8953
9016
  if (current === null || typeof current !== "object") return void 0;
8954
9017
  if (!Object.hasOwn(current, key)) return void 0;
8955
9018
  current = current[key];
@@ -9233,9 +9296,9 @@ function untrackArchive(archive) {
9233
9296
  process.removeListener("exit", removePendingArchives);
9234
9297
  }
9235
9298
  function sha256File(filePath) {
9236
- return new Promise((resolve7, reject) => {
9299
+ return new Promise((resolve8, reject) => {
9237
9300
  const hash = createHash2("sha256");
9238
- createReadStream(filePath).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve7(hash.digest("hex"))).on("error", reject);
9301
+ createReadStream(filePath).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve8(hash.digest("hex"))).on("error", reject);
9239
9302
  });
9240
9303
  }
9241
9304
  function toolServerError(text) {
@@ -9343,6 +9406,9 @@ async function prepareFileInputs(specs, args, opts) {
9343
9406
  );
9344
9407
  }
9345
9408
  }
9409
+ if (spec.kind === "probe" && spec.collect === "step" && opts.includeContent && opts.collectStepMembers) {
9410
+ wire.members = await opts.collectStepMembers(record, opts);
9411
+ }
9346
9412
  if (spec.kind === "tar-upload") {
9347
9413
  const st = await stat2(filePath).catch(() => null);
9348
9414
  if (st) {
@@ -9469,14 +9535,14 @@ function printable(text) {
9469
9535
  (c) => c < " " || c === "\x7F" ? `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}` : c
9470
9536
  ).join("");
9471
9537
  }
9472
- function isResolvedAbsolute(value) {
9538
+ function isResolvedAbsolute2(value) {
9473
9539
  return typeof value === "string" && path10.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
9474
9540
  }
9475
9541
  function namesValidFlow(args) {
9476
9542
  const { project_root, flow_path, name } = args;
9477
- if (!isResolvedAbsolute(project_root)) return false;
9543
+ if (!isResolvedAbsolute2(project_root)) return false;
9478
9544
  if (name === void 0) {
9479
- return isResolvedAbsolute(flow_path) && FLOW_FILE_NAME_PATTERN.test(path10.basename(flow_path));
9545
+ return isResolvedAbsolute2(flow_path) && FLOW_FILE_NAME_PATTERN.test(path10.basename(flow_path));
9480
9546
  }
9481
9547
  return flow_path === void 0 && typeof name === "string" && FLOW_NAME_PATTERN.test(name);
9482
9548
  }
@@ -9562,6 +9628,29 @@ async function readFlowMember(anchorDir, target, roots, budget, opts) {
9562
9628
  const sent = await sendBytes(member, canonical, budget, opts);
9563
9629
  return { ...sent, text: sent.bytes?.toString("utf8") };
9564
9630
  }
9631
+ async function readToolMember(file, roots, budget, opts) {
9632
+ const member = { role: "tool", key: file, path: file };
9633
+ const refuse = (reason) => ({
9634
+ member: { ...member, state: "refused", error: reason },
9635
+ sent: `refused (${reason})`
9636
+ });
9637
+ const { canonical } = await landing(file);
9638
+ if (!roots.some((root) => isWithin(canonical, root))) {
9639
+ return refuse(`${file} is outside every root this client serves (${roots.join(", ")})`);
9640
+ }
9641
+ if (!hasToolFileExtension(canonical)) {
9642
+ return refuse(`${file} links to a file that is not one of ${TOOL_FILE_EXTENSIONS.join(", ")}`);
9643
+ }
9644
+ const st = await stat3(canonical).catch((err) => err);
9645
+ if (st instanceof Error) {
9646
+ if (st.code === "ENOENT" || st.code === "ENOTDIR") {
9647
+ return { member: { ...member, state: "missing" }, sent: "missing" };
9648
+ }
9649
+ return refuse(st.message);
9650
+ }
9651
+ if (st.isDirectory()) return refuse("EISDIR: illegal operation on a directory, read");
9652
+ return sendBytes(member, canonical, budget, opts);
9653
+ }
9565
9654
  function callPlatform(args) {
9566
9655
  if (typeof args.device === "string" && args.device.startsWith("chromium-cdp-")) return "chromium";
9567
9656
  if (typeof args.platform !== "string") return void 0;
@@ -9616,51 +9705,15 @@ async function sendBytes(member, real, budget, opts) {
9616
9705
  bytes
9617
9706
  };
9618
9707
  }
9619
- async function collectBaselineMembers(canonical, flowName, snapshots, args, roots, budget, opts, emit) {
9620
- const dir = path10.join(
9621
- path10.dirname(canonical),
9622
- "__baselines__",
9623
- baselineKeyFor(canonical, flowName)
9624
- );
9625
- const real = (await landing(dir)).canonical;
9626
- if (!roots.some((root) => isWithin(real, root))) return;
9627
- const updates = args.updateBaselines === true;
9628
- if (updates) opts.baselineDirs?.push(dir);
9629
- const platform = callPlatform(args);
9630
- const prefixes = snapshots.map(
9631
- (name) => `${name}__${platform === void 0 ? "" : `${platform}-`}`
9632
- );
9633
- const names = await readdir4(dir).catch(() => []);
9634
- for (const name of names.sort()) {
9635
- if (!name.endsWith(".png")) continue;
9636
- if (!updates && !prefixes.some((prefix) => name.startsWith(prefix))) continue;
9637
- const file = path10.join(dir, name);
9638
- const member = { role: "baseline", key: file, path: file };
9639
- const entry = await baselineEntry(file, roots, updates);
9640
- if (entry.state === "refused") {
9641
- emit({ ...member, state: "refused", error: entry.error }, `refused (${entry.error})`);
9642
- } else if (entry.state === "missing") {
9643
- emit({ ...member, state: "missing" }, "missing");
9644
- } else if (updates) {
9645
- emit({ ...member, state: "listed" }, "listed");
9646
- } else {
9647
- const sent = await sendBytes(member, entry.real, budget, opts);
9648
- emit(sent.member, sent.sent);
9649
- }
9650
- }
9708
+ function nestedRunUpdates(parentUpdates, args) {
9709
+ return args.updateBaselines === true || parentUpdates && args.updateBaselines === void 0;
9651
9710
  }
9652
- async function collectFlowMembers(rootPath, rootBytes, args, opts) {
9653
- if (!namesValidFlow(args)) return {};
9654
- const canonical = await canonicalFlowPath(rootPath);
9655
- const spelling = await classifyOnDiskSpelling(
9656
- path10.dirname(rootPath),
9657
- path10.basename(rootPath),
9658
- FLOW_FILE_NAME_PATTERN
9659
- );
9660
- const roots = await closureRoots(rootPath, canonical, args.project_root);
9711
+ function memberCollector(roots, opts) {
9661
9712
  const members = [];
9662
- const seen = /* @__PURE__ */ new Set();
9663
- const snapshots = /* @__PURE__ */ new Set();
9713
+ const flows = /* @__PURE__ */ new Map();
9714
+ const tools = /* @__PURE__ */ new Set();
9715
+ const runs = /* @__PURE__ */ new Set();
9716
+ const baselineDirs = /* @__PURE__ */ new Map();
9664
9717
  const budget = { inline: 0 };
9665
9718
  const logging = process.env[FLOW_FILES_LOG_ENV] === "1";
9666
9719
  const log = opts.log ?? ((line) => void process.stderr.write(`${line}
@@ -9670,42 +9723,194 @@ async function collectFlowMembers(rootPath, rootBytes, args, opts) {
9670
9723
  const subject = member.role === "flow" ? member.canonical : member.key;
9671
9724
  if (logging) log(printable(`[flow-files] ${member.role} ${subject}: ${sent}`));
9672
9725
  };
9673
- const queue = [{ canonical, text: rootBytes.toString("utf8"), hop: 0 }];
9674
- for (let file = queue.shift(); file !== void 0; file = queue.shift()) {
9675
- let doc;
9676
- try {
9677
- doc = (0, import_yaml.parse)(file.text.trim(), { logLevel: "error" });
9678
- } catch {
9679
- continue;
9680
- }
9681
- const requests = collectFlowRequests(doc);
9682
- for (const name of requests.snapshots) snapshots.add(name);
9683
- const anchorDir = path10.dirname(file.canonical);
9684
- for (const target of requests.runTargets) {
9685
- const key = flowMemberKey(anchorDir, target);
9686
- if (seen.has(key)) continue;
9687
- seen.add(key);
9688
- const { member, text, sent } = await readFlowMember(anchorDir, target, roots, budget, opts);
9689
- emit(member, sent);
9690
- if (text !== void 0 && file.hop + 1 < MAX_RUN_DEPTH) {
9691
- queue.push({ canonical: member.canonical, text, hop: file.hop + 1 });
9726
+ async function flow(anchorDir, target) {
9727
+ const key = flowMemberKey(anchorDir, target);
9728
+ const known = flows.get(key);
9729
+ if (known !== void 0) return known;
9730
+ const { member, text, sent } = await readFlowMember(anchorDir, target, roots, budget, opts);
9731
+ const entry = { member, ...text === void 0 ? {} : { text } };
9732
+ flows.set(key, entry);
9733
+ emit(member, sent);
9734
+ return entry;
9735
+ }
9736
+ async function toolFiles(step) {
9737
+ if (step.tool === "flow-execute") return;
9738
+ for (const file of toolStepFiles(opts.toolFileInputs?.(step.tool), step.args)) {
9739
+ const { unwrapWhenSet } = file.spec;
9740
+ if (unwrapWhenSet !== void 0 && step.args[unwrapWhenSet] !== void 0) continue;
9741
+ if (!isClientFileArgument(file) || tools.has(file.path)) continue;
9742
+ tools.add(file.path);
9743
+ const read = await readToolMember(file.path, roots, budget, opts);
9744
+ emit(read.member, read.sent);
9745
+ }
9746
+ }
9747
+ async function nestedRun(target, hop, updates, platform) {
9748
+ const { member, text } = await flow(path10.dirname(target.path), `${target.name}.yaml`);
9749
+ if (text === void 0 || hop >= MAX_RUN_DEPTH) return void 0;
9750
+ return { canonical: member.canonical, text, flowName: target.name, hop, updates, platform };
9751
+ }
9752
+ async function walk(start) {
9753
+ const queue = [...start];
9754
+ for (let run = queue.shift(); run !== void 0; run = queue.shift()) {
9755
+ const id = [run.canonical, run.flowName, run.updates, run.platform ?? ""].join("\0");
9756
+ if (runs.has(id)) continue;
9757
+ runs.add(id);
9758
+ const snapshots = /* @__PURE__ */ new Set();
9759
+ const visited = /* @__PURE__ */ new Set();
9760
+ const files = [{ canonical: run.canonical, text: run.text, hop: run.hop }];
9761
+ for (let file = files.shift(); file !== void 0; file = files.shift()) {
9762
+ let doc;
9763
+ try {
9764
+ doc = (0, import_yaml.parse)(file.text.trim(), { logLevel: "error" });
9765
+ } catch {
9766
+ continue;
9767
+ }
9768
+ const requests = collectFlowRequests(doc);
9769
+ for (const name of requests.snapshots) snapshots.add(name);
9770
+ for (const step of requests.toolSteps) await toolFiles(step);
9771
+ const anchorDir = path10.dirname(file.canonical);
9772
+ for (const target of requests.runTargets) {
9773
+ const key = flowMemberKey(anchorDir, target);
9774
+ if (visited.has(key)) continue;
9775
+ visited.add(key);
9776
+ const { member, text } = await flow(anchorDir, target);
9777
+ if (text !== void 0 && file.hop + 1 < MAX_RUN_DEPTH) {
9778
+ files.push({ canonical: member.canonical, text, hop: file.hop + 1 });
9779
+ }
9780
+ }
9781
+ for (const { target, args } of requests.nested) {
9782
+ if (target.kind !== "name") continue;
9783
+ const next = await nestedRun(
9784
+ target,
9785
+ file.hop + 1,
9786
+ nestedRunUpdates(run.updates, args),
9787
+ run.platform
9788
+ );
9789
+ if (next !== void 0) queue.push(next);
9790
+ }
9791
+ }
9792
+ if (snapshots.size === 0) continue;
9793
+ const dir = path10.join(
9794
+ path10.dirname(run.canonical),
9795
+ "__baselines__",
9796
+ baselineKeyFor(run.canonical, run.flowName)
9797
+ );
9798
+ const entry = baselineDirs.get(dir) ?? { prefixes: /* @__PURE__ */ new Set(), updates: false };
9799
+ baselineDirs.set(dir, entry);
9800
+ if (run.updates) {
9801
+ entry.updates = true;
9802
+ } else {
9803
+ const platform = run.platform === void 0 ? "" : `${run.platform}-`;
9804
+ for (const name of snapshots) entry.prefixes.add(`${name}__${platform}`);
9805
+ }
9806
+ }
9807
+ }
9808
+ async function sendBaselines() {
9809
+ for (const [dir, { prefixes, updates }] of baselineDirs) {
9810
+ const real = (await landing(dir)).canonical;
9811
+ if (!roots.some((root) => isWithin(real, root))) continue;
9812
+ if (updates) opts.baselineDirs?.push(dir);
9813
+ const names = await readdir4(dir).catch(() => []);
9814
+ for (const name of names.sort()) {
9815
+ if (!name.endsWith(".png")) continue;
9816
+ const compared = [...prefixes].some((prefix) => name.startsWith(prefix));
9817
+ if (!updates && !compared) continue;
9818
+ const file = path10.join(dir, name);
9819
+ if (tools.has(file)) continue;
9820
+ const member = { role: "baseline", key: file, path: file };
9821
+ const entry = await baselineEntry(file, roots, updates && !compared);
9822
+ if (entry.state === "refused") {
9823
+ emit({ ...member, state: "refused", error: entry.error }, `refused (${entry.error})`);
9824
+ } else if (entry.state === "missing") {
9825
+ emit({ ...member, state: "missing" }, "missing");
9826
+ } else if (!compared) {
9827
+ emit({ ...member, state: "listed" }, "listed");
9828
+ } else {
9829
+ const sent = await sendBytes(member, entry.real, budget, opts);
9830
+ emit(sent.member, sent.sent);
9831
+ }
9692
9832
  }
9693
9833
  }
9694
9834
  }
9695
- if (snapshots.size > 0) {
9696
- const flowName = path10.basename(rootPath, ".yaml");
9697
- await collectBaselineMembers(
9835
+ return { members, flow, toolFiles, nestedRun, walk, sendBaselines };
9836
+ }
9837
+ async function collectFlowMembers(rootPath, rootBytes, args, opts) {
9838
+ if (!namesValidFlow(args)) return {};
9839
+ const canonical = await canonicalFlowPath(rootPath);
9840
+ const spelling = await classifyOnDiskSpelling(
9841
+ path10.dirname(rootPath),
9842
+ path10.basename(rootPath),
9843
+ FLOW_FILE_NAME_PATTERN
9844
+ );
9845
+ const collector = memberCollector(
9846
+ await closureRoots(rootPath, canonical, args.project_root),
9847
+ opts
9848
+ );
9849
+ await collector.walk([
9850
+ {
9698
9851
  canonical,
9699
- flowName,
9700
- [...snapshots],
9701
- args,
9702
- roots,
9703
- budget,
9704
- opts,
9705
- emit
9706
- );
9852
+ text: rootBytes.toString("utf8"),
9853
+ flowName: path10.basename(rootPath, ".yaml"),
9854
+ hop: 0,
9855
+ updates: args.updateBaselines === true,
9856
+ platform: callPlatform(args)
9857
+ }
9858
+ ]);
9859
+ await collector.sendBaselines();
9860
+ return { canonical, spelling, members: collector.members };
9861
+ }
9862
+ function recordedStep(args) {
9863
+ const { command, args: text } = args;
9864
+ if (typeof command !== "string") return void 0;
9865
+ if (text === void 0) return { tool: command, args: {} };
9866
+ if (typeof text !== "string") return void 0;
9867
+ let parsed;
9868
+ try {
9869
+ parsed = JSON.parse(text);
9870
+ } catch {
9871
+ return void 0;
9872
+ }
9873
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return void 0;
9874
+ return { tool: command, args: parsed };
9875
+ }
9876
+ async function collectStepMembers(args, opts) {
9877
+ const { name, project_root: projectRoot } = args;
9878
+ const step = recordedStep(args);
9879
+ if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name) || typeof projectRoot !== "string" || !path10.isAbsolute(projectRoot) || step === void 0) {
9880
+ return [];
9881
+ }
9882
+ const recording = path10.join(projectRoot, ".argent", "flows", `${name}.yaml`);
9883
+ const collector = memberCollector(
9884
+ await closureRoots(recording, (await landing(recording)).canonical, projectRoot),
9885
+ opts
9886
+ );
9887
+ await collector.toolFiles(step);
9888
+ if (step.tool === "flow-execute") {
9889
+ const self = await collector.flow(path10.dirname(recording), path10.basename(recording));
9890
+ let runArgs = step.args;
9891
+ const named = nestedFlowTarget(runArgs);
9892
+ if (named?.kind === "flow_path") {
9893
+ const stem = path10.basename(named.path, ".yaml");
9894
+ if (path10.resolve(path10.dirname(named.path)) === path10.resolve(path10.dirname(recording))) {
9895
+ await collector.flow(path10.dirname(recording), path10.basename(named.path));
9896
+ runArgs = { ...runArgs, name: stem };
9897
+ delete runArgs.flow_path;
9898
+ }
9899
+ }
9900
+ const target = nestedFlowTarget(runArgs);
9901
+ if (target?.kind === "name") {
9902
+ await collector.flow(path10.dirname(self.member.canonical), `${target.name}.yaml`);
9903
+ const run = await collector.nestedRun(
9904
+ target,
9905
+ 0,
9906
+ runArgs.updateBaselines === true,
9907
+ callPlatform(runArgs)
9908
+ );
9909
+ if (run !== void 0) await collector.walk([run]);
9910
+ }
9707
9911
  }
9708
- return { canonical, spelling, members };
9912
+ await collector.sendBaselines();
9913
+ return collector.members;
9709
9914
  }
9710
9915
 
9711
9916
  // ../argent-tools-client/src/tools-client.ts
@@ -9866,7 +10071,8 @@ function createToolsClient(options = {}) {
9866
10071
  opts?.signal?.throwIfAborted();
9867
10072
  const { url, token, remote } = await route();
9868
10073
  let finalArgs = args;
9869
- const meta = await fetchTool(name, { signal: opts?.signal });
10074
+ const tools = await fetchTools({ signal: opts?.signal });
10075
+ const meta = tools.find((t) => t.name === name) ?? null;
9870
10076
  const baselineDirs = [];
9871
10077
  if (meta?.fileInputs?.length) {
9872
10078
  if (remote) assertRequiredPresent(meta, args);
@@ -9876,6 +10082,8 @@ function createToolsClient(options = {}) {
9876
10082
  log: diagnose,
9877
10083
  baselineDirs,
9878
10084
  collectMembers: collectFlowMembers,
10085
+ collectStepMembers,
10086
+ toolFileInputs: (tool) => tools.find((t) => t.name === tool)?.fileInputs,
9879
10087
  signal: opts?.signal
9880
10088
  });
9881
10089
  }
@@ -9885,7 +10093,11 @@ function createToolsClient(options = {}) {
9885
10093
  diagnose(`The baseline ${file} was not written on this client: ${error}`);
9886
10094
  }
9887
10095
  if (process.env.ARGENT_FLOW_FILES_LOG === "1") {
9888
- for (const file of applied.written) diagnose(`[flow-files] baseline ${file}: written`);
10096
+ for (const file of applied.written) {
10097
+ if (baselineDirs.includes(path11.dirname(file))) {
10098
+ diagnose(`[flow-files] baseline ${file}: written`);
10099
+ }
10100
+ }
9889
10101
  }
9890
10102
  return applied.result;
9891
10103
  };
@@ -9897,6 +10109,9 @@ function createToolsClient(options = {}) {
9897
10109
  method: "POST",
9898
10110
  headers: {
9899
10111
  "Content-Type": "application/json",
10112
+ // Tells the tool-server the call came over a link, a link to
10113
+ // 127.0.0.1 included, which nothing else in the request shows.
10114
+ ...remote ? { [LINKED_CALL_HEADER]: "1" } : {},
9900
10115
  // A proxy that compresses the stream holds each line until its buffer
9901
10116
  // fills. `identity` keeps the stream uncompressed end to end.
9902
10117
  ...stream ? { "Accept": "application/x-ndjson", "Accept-Encoding": "identity" } : {},
@@ -9957,7 +10172,7 @@ function createToolsClient(options = {}) {
9957
10172
  import { copyFile, mkdir as mkdir4, readFile as readFile5, realpath as realpath4, rm as rm3, stat as stat4, writeFile as writeFile4 } from "node:fs/promises";
9958
10173
  import { constants as fsConstants } from "node:fs";
9959
10174
  import { tmpdir as tmpdir2 } from "node:os";
9960
- import { basename as basename6, dirname as dirname7, extname as extname2, isAbsolute as isAbsolute5, join as join11, normalize as normalize2, resolve as resolve6, sep as sep4 } from "node:path";
10175
+ import { basename as basename6, dirname as dirname8, extname as extname2, isAbsolute as isAbsolute6, join as join11, normalize as normalize2, resolve as resolve7, sep as sep4 } from "node:path";
9961
10176
  import { createHash as createHash3 } from "node:crypto";
9962
10177
  var ARTIFACT_MARKER2 = "__argentArtifact";
9963
10178
  function isArtifactHandle(value) {
@@ -9990,7 +10205,7 @@ function artifactDir(deviceId) {
9990
10205
  }
9991
10206
  function durableBaseDir() {
9992
10207
  const projectRoot = findProjectRoot(process.cwd());
9993
- return projectRoot ?? dirname7(argentHomeDir());
10208
+ return projectRoot ?? dirname8(argentHomeDir());
9994
10209
  }
9995
10210
  var ALLOWED_SAVE_DIRS = /* @__PURE__ */ new Set([normalize2(".argent/recordings")]);
9996
10211
  var RECORDINGS_SAVE_DIR = normalize2(".argent/recordings");
@@ -10004,9 +10219,9 @@ function configuredRecordingsDir() {
10004
10219
  if (typeof value !== "string") return null;
10005
10220
  const trimmed = value.trim();
10006
10221
  if (trimmed === "") return null;
10007
- const home = dirname7(argentHomeDir());
10222
+ const home = dirname8(argentHomeDir());
10008
10223
  const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep4}`) ? join11(home, trimmed.slice(2)) : trimmed;
10009
- return resolve6(durableBaseDir(), expanded);
10224
+ return resolve7(durableBaseDir(), expanded);
10010
10225
  }
10011
10226
  var MAX_DURABLE_BYTES = 2 * 1024 * 1024 * 1024;
10012
10227
  async function readCapped(res, cap) {
@@ -10039,10 +10254,10 @@ async function writeDurableUnique(dir, filename, write) {
10039
10254
  const stem = filename.slice(0, filename.length - ext.length);
10040
10255
  for (let i = 1; i <= 1e3; i++) {
10041
10256
  const candidate = i === 1 ? filename : `${stem} (${i})${ext}`;
10042
- const path12 = join11(dir, candidate);
10257
+ const path13 = join11(dir, candidate);
10043
10258
  try {
10044
- await write(path12);
10045
- return path12;
10259
+ await write(path13);
10260
+ return path13;
10046
10261
  } catch (err) {
10047
10262
  if (err?.code === "EEXIST") continue;
10048
10263
  throw err;
@@ -10053,7 +10268,7 @@ async function writeDurableUnique(dir, filename, write) {
10053
10268
  function durableSaveTarget(handle) {
10054
10269
  if (typeof handle.saveDir !== "string" || !handle.saveDir || handle.archive) return null;
10055
10270
  const rel = normalize2(handle.saveDir);
10056
- if (isAbsolute5(rel) || rel === ".." || rel.startsWith(`..${sep4}`) || rel.split(sep4).includes("..")) {
10271
+ if (isAbsolute6(rel) || rel === ".." || rel.startsWith(`..${sep4}`) || rel.split(sep4).includes("..")) {
10057
10272
  return null;
10058
10273
  }
10059
10274
  if (!ALLOWED_SAVE_DIRS.has(rel)) return null;
@@ -10226,11 +10441,11 @@ function getDeviceIdFromArgs(args) {
10226
10441
 
10227
10442
  // src/bundled-paths.ts
10228
10443
  import * as fs6 from "node:fs";
10229
- import * as path11 from "node:path";
10444
+ import * as path12 from "node:path";
10230
10445
  function readPackageVersion() {
10231
10446
  try {
10232
10447
  const pkg = JSON.parse(
10233
- fs6.readFileSync(path11.join(import.meta.dirname, "..", "package.json"), "utf8")
10448
+ fs6.readFileSync(path12.join(import.meta.dirname, "..", "package.json"), "utf8")
10234
10449
  );
10235
10450
  return pkg.version;
10236
10451
  } catch {
@@ -10241,15 +10456,15 @@ var PACKAGE_NAME = "@swmansion/argent";
10241
10456
  function findDeclaringRoot(startDir) {
10242
10457
  let dir = startDir;
10243
10458
  for (; ; ) {
10244
- if (fs6.existsSync(path11.join(dir, ".argent", "install.json"))) return dir;
10459
+ if (fs6.existsSync(path12.join(dir, ".argent", "install.json"))) return dir;
10245
10460
  try {
10246
- const manifest = JSON.parse(fs6.readFileSync(path11.join(dir, "package.json"), "utf8"));
10461
+ const manifest = JSON.parse(fs6.readFileSync(path12.join(dir, "package.json"), "utf8"));
10247
10462
  if (manifest.devDependencies?.[PACKAGE_NAME] || manifest.dependencies?.[PACKAGE_NAME] || manifest.optionalDependencies?.[PACKAGE_NAME]) {
10248
10463
  return dir;
10249
10464
  }
10250
10465
  } catch {
10251
10466
  }
10252
- const parent = path11.dirname(dir);
10467
+ const parent = path12.dirname(dir);
10253
10468
  if (parent === dir) return null;
10254
10469
  dir = parent;
10255
10470
  }
@@ -10257,12 +10472,12 @@ function findDeclaringRoot(startDir) {
10257
10472
  function findStablePackageDir(startDir, packageRoot) {
10258
10473
  let dir = startDir;
10259
10474
  for (; ; ) {
10260
- const candidate = path11.join(dir, "node_modules", PACKAGE_NAME);
10475
+ const candidate = path12.join(dir, "node_modules", PACKAGE_NAME);
10261
10476
  try {
10262
10477
  if (fs6.realpathSync(candidate) === packageRoot) return candidate;
10263
10478
  } catch {
10264
10479
  }
10265
- const parent = path11.dirname(dir);
10480
+ const parent = path12.dirname(dir);
10266
10481
  if (parent === dir) return void 0;
10267
10482
  dir = parent;
10268
10483
  }
@@ -10272,7 +10487,7 @@ function classifyInstall() {
10272
10487
  let dir;
10273
10488
  let cwd;
10274
10489
  try {
10275
- packageRoot = fs6.realpathSync(path11.join(import.meta.dirname, ".."));
10490
+ packageRoot = fs6.realpathSync(path12.join(import.meta.dirname, ".."));
10276
10491
  cwd = process.cwd();
10277
10492
  dir = cwd;
10278
10493
  } catch {
@@ -10280,8 +10495,8 @@ function classifyInstall() {
10280
10495
  }
10281
10496
  for (; ; ) {
10282
10497
  try {
10283
- const nmReal = fs6.realpathSync(path11.join(dir, "node_modules"));
10284
- if (packageRoot === nmReal || packageRoot.startsWith(nmReal + path11.sep)) {
10498
+ const nmReal = fs6.realpathSync(path12.join(dir, "node_modules"));
10499
+ if (packageRoot === nmReal || packageRoot.startsWith(nmReal + path12.sep)) {
10285
10500
  return {
10286
10501
  kind: "local",
10287
10502
  projectRoot: findDeclaringRoot(cwd) ?? dir,
@@ -10290,22 +10505,22 @@ function classifyInstall() {
10290
10505
  }
10291
10506
  } catch {
10292
10507
  }
10293
- const parent = path11.dirname(dir);
10508
+ const parent = path12.dirname(dir);
10294
10509
  if (parent === dir) break;
10295
10510
  dir = parent;
10296
10511
  }
10297
- if (packageRoot.includes(`${path11.sep}.yarn${path11.sep}`)) {
10512
+ if (packageRoot.includes(`${path12.sep}.yarn${path12.sep}`)) {
10298
10513
  const declRoot = findDeclaringRoot(cwd);
10299
10514
  if (declRoot) return { kind: "local", projectRoot: declRoot };
10300
10515
  }
10301
10516
  return { kind: "global" };
10302
10517
  }
10303
10518
  var classifiedInstall = classifyInstall();
10304
- var packageDir = classifiedInstall.stablePackageDir ?? path11.join(import.meta.dirname, "..");
10519
+ var packageDir = classifiedInstall.stablePackageDir ?? path12.join(import.meta.dirname, "..");
10305
10520
  var BUNDLED_RUNTIME_PATHS = {
10306
- bundlePath: path11.join(packageDir, "dist", "tool-server.cjs"),
10307
- simulatorServerDir: path11.join(packageDir, "bin"),
10308
- nativeDevtoolsDir: path11.join(packageDir, "dylibs"),
10521
+ bundlePath: path12.join(packageDir, "dist", "tool-server.cjs"),
10522
+ simulatorServerDir: path12.join(packageDir, "bin"),
10523
+ nativeDevtoolsDir: path12.join(packageDir, "dylibs"),
10309
10524
  version: readPackageVersion(),
10310
10525
  installKind: classifiedInstall.kind,
10311
10526
  installProjectRoot: classifiedInstall.projectRoot