@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.
@@ -235,7 +235,7 @@ var init_config = __esm({
235
235
  var require_main = __commonJS({
236
236
  "../../node_modules/dotenv/lib/main.js"(exports2, module2) {
237
237
  var fs69 = require("fs");
238
- var path52 = require("path");
238
+ var path53 = require("path");
239
239
  var os21 = require("os");
240
240
  var crypto8 = require("crypto");
241
241
  var TIPS = [
@@ -374,7 +374,7 @@ var require_main = __commonJS({
374
374
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
375
375
  }
376
376
  } else {
377
- possibleVaultPath = path52.resolve(process.cwd(), ".env.vault");
377
+ possibleVaultPath = path53.resolve(process.cwd(), ".env.vault");
378
378
  }
379
379
  if (fs69.existsSync(possibleVaultPath)) {
380
380
  return possibleVaultPath;
@@ -382,7 +382,7 @@ var require_main = __commonJS({
382
382
  return null;
383
383
  }
384
384
  function _resolveHome(envPath) {
385
- return envPath[0] === "~" ? path52.join(os21.homedir(), envPath.slice(1)) : envPath;
385
+ return envPath[0] === "~" ? path53.join(os21.homedir(), envPath.slice(1)) : envPath;
386
386
  }
387
387
  function _configVault(options) {
388
388
  const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
@@ -399,7 +399,7 @@ var require_main = __commonJS({
399
399
  return { parsed };
400
400
  }
401
401
  function configDotenv(options) {
402
- const dotenvPath = path52.resolve(process.cwd(), ".env");
402
+ const dotenvPath = path53.resolve(process.cwd(), ".env");
403
403
  let encoding = "utf8";
404
404
  let processEnv = process.env;
405
405
  if (options && options.processEnv != null) {
@@ -427,13 +427,13 @@ var require_main = __commonJS({
427
427
  }
428
428
  let lastError;
429
429
  const parsedAll = {};
430
- for (const path53 of optionPaths) {
430
+ for (const path54 of optionPaths) {
431
431
  try {
432
- const parsed = DotenvModule.parse(fs69.readFileSync(path53, { encoding }));
432
+ const parsed = DotenvModule.parse(fs69.readFileSync(path54, { encoding }));
433
433
  DotenvModule.populate(parsedAll, parsed, options);
434
434
  } catch (e) {
435
435
  if (debug) {
436
- _debug(`failed to load ${path53} ${e.message}`);
436
+ _debug(`failed to load ${path54} ${e.message}`);
437
437
  }
438
438
  lastError = e;
439
439
  }
@@ -446,7 +446,7 @@ var require_main = __commonJS({
446
446
  const shortPaths = [];
447
447
  for (const filePath of optionPaths) {
448
448
  try {
449
- const relative5 = path52.relative(process.cwd(), filePath);
449
+ const relative5 = path53.relative(process.cwd(), filePath);
450
450
  shortPaths.push(relative5);
451
451
  } catch (e) {
452
452
  if (debug) {
@@ -998,9 +998,11 @@ var init_event_emitter = __esm({
998
998
  function isLiveServiceState(state3) {
999
999
  return state3 === "RUNNING" /* RUNNING */ || state3 === "STARTING" /* STARTING */;
1000
1000
  }
1001
+ var LINKED_CALL_HEADER;
1001
1002
  var init_types = __esm({
1002
1003
  "../registry/src/types.ts"() {
1003
1004
  "use strict";
1005
+ LINKED_CALL_HEADER = "x-argent-linked";
1004
1006
  }
1005
1007
  });
1006
1008
 
@@ -1120,7 +1122,23 @@ function interpolateFileInputPath(template, args) {
1120
1122
  });
1121
1123
  return missing ? null : out;
1122
1124
  }
1123
- var FILE_INPUT_MARKER, FLOW_NAME_CHARSET, FLOW_NAME_PATTERN, FLOW_FILE_NAME_PATTERN, SCRIPT_FILE_NAME_PATTERN, CLIENT_FILE_MARKER;
1125
+ function hasToolFileExtension(file2) {
1126
+ const name = file2.toLowerCase();
1127
+ return TOOL_FILE_EXTENSIONS.some((extension2) => name.endsWith(extension2));
1128
+ }
1129
+ function toolStepFiles(specs, args) {
1130
+ const files = [];
1131
+ for (const spec of specs ?? []) {
1132
+ if (spec.skipWhenSet !== void 0 && args[spec.skipWhenSet] !== void 0) continue;
1133
+ const filled = interpolateFileInputPath(spec.path, args);
1134
+ if (filled !== null) files.push({ spec, path: filled });
1135
+ }
1136
+ return files;
1137
+ }
1138
+ function isClientFileArgument({ spec, path: path53 }) {
1139
+ return spec.kind === "file" && spec.path === `\${${spec.target}}` && path53.startsWith("/") && hasToolFileExtension(path53);
1140
+ }
1141
+ var FILE_INPUT_MARKER, FLOW_NAME_CHARSET, FLOW_NAME_PATTERN, FLOW_FILE_NAME_PATTERN, SCRIPT_FILE_NAME_PATTERN, CLIENT_FILE_MARKER, TOOL_FILE_EXTENSIONS;
1124
1142
  var init_file_inputs = __esm({
1125
1143
  "../registry/src/file-inputs.ts"() {
1126
1144
  "use strict";
@@ -1130,6 +1148,7 @@ var init_file_inputs = __esm({
1130
1148
  FLOW_FILE_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}\\.yaml$`);
1131
1149
  SCRIPT_FILE_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}\\.mjs$`);
1132
1150
  CLIENT_FILE_MARKER = "__argentClientFile";
1151
+ TOOL_FILE_EXTENSIONS = [".png", ".yaml"];
1133
1152
  }
1134
1153
  });
1135
1154
 
@@ -1174,6 +1193,26 @@ async function resolveFlowRelativeFile(anchorDir, target, addressable) {
1174
1193
  );
1175
1194
  return { canonical, spelling };
1176
1195
  }
1196
+ function nestedFlowTarget(args) {
1197
+ if (typeof args !== "object" || args === null || Array.isArray(args)) return void 0;
1198
+ const { name, project_root: projectRoot, flow_path: flowPath } = args;
1199
+ if (flowPath === void 0) {
1200
+ if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name)) return void 0;
1201
+ if (!isResolvedAbsolute(projectRoot)) return void 0;
1202
+ return {
1203
+ kind: "name",
1204
+ projectRoot,
1205
+ name,
1206
+ path: path5.join(projectRoot, ".argent", "flows", `${name}.yaml`)
1207
+ };
1208
+ }
1209
+ if (name !== void 0 || !isResolvedAbsolute(flowPath)) return void 0;
1210
+ if (!FLOW_FILE_NAME_PATTERN.test(path5.basename(flowPath))) return void 0;
1211
+ return { kind: "flow_path", path: flowPath };
1212
+ }
1213
+ function isResolvedAbsolute(value) {
1214
+ return typeof value === "string" && path5.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
1215
+ }
1177
1216
  var fs4, path5, MAX_RUN_DEPTH;
1178
1217
  var init_flow_file_refs = __esm({
1179
1218
  "../registry/src/flow-file-refs.ts"() {
@@ -1933,10 +1972,10 @@ function mergeDefs(...defs) {
1933
1972
  function cloneDef(schema) {
1934
1973
  return mergeDefs(schema._zod.def);
1935
1974
  }
1936
- function getElementAtPath(obj, path52) {
1937
- if (!path52)
1975
+ function getElementAtPath(obj, path53) {
1976
+ if (!path53)
1938
1977
  return obj;
1939
- return path52.reduce((acc, key2) => acc?.[key2], obj);
1978
+ return path53.reduce((acc, key2) => acc?.[key2], obj);
1940
1979
  }
1941
1980
  function promiseAllObject(promisesObj) {
1942
1981
  const keys = Object.keys(promisesObj);
@@ -2264,11 +2303,11 @@ function explicitlyAborted(x, startIndex = 0) {
2264
2303
  }
2265
2304
  return false;
2266
2305
  }
2267
- function prefixIssues(path52, issues) {
2306
+ function prefixIssues(path53, issues) {
2268
2307
  return issues.map((iss) => {
2269
2308
  var _a3;
2270
2309
  (_a3 = iss).path ?? (_a3.path = []);
2271
- iss.path.unshift(path52);
2310
+ iss.path.unshift(path53);
2272
2311
  return iss;
2273
2312
  });
2274
2313
  }
@@ -2485,16 +2524,16 @@ function flattenError(error52, mapper = (issue2) => issue2.message) {
2485
2524
  }
2486
2525
  function formatError(error52, mapper = (issue2) => issue2.message) {
2487
2526
  const fieldErrors = { _errors: [] };
2488
- const processError = (error53, path52 = []) => {
2527
+ const processError = (error53, path53 = []) => {
2489
2528
  for (const issue2 of error53.issues) {
2490
2529
  if (issue2.code === "invalid_union" && issue2.errors.length) {
2491
- issue2.errors.map((issues) => processError({ issues }, [...path52, ...issue2.path]));
2530
+ issue2.errors.map((issues) => processError({ issues }, [...path53, ...issue2.path]));
2492
2531
  } else if (issue2.code === "invalid_key") {
2493
- processError({ issues: issue2.issues }, [...path52, ...issue2.path]);
2532
+ processError({ issues: issue2.issues }, [...path53, ...issue2.path]);
2494
2533
  } else if (issue2.code === "invalid_element") {
2495
- processError({ issues: issue2.issues }, [...path52, ...issue2.path]);
2534
+ processError({ issues: issue2.issues }, [...path53, ...issue2.path]);
2496
2535
  } else {
2497
- const fullpath = [...path52, ...issue2.path];
2536
+ const fullpath = [...path53, ...issue2.path];
2498
2537
  if (fullpath.length === 0) {
2499
2538
  fieldErrors._errors.push(mapper(issue2));
2500
2539
  } else {
@@ -2521,17 +2560,17 @@ function formatError(error52, mapper = (issue2) => issue2.message) {
2521
2560
  }
2522
2561
  function treeifyError(error52, mapper = (issue2) => issue2.message) {
2523
2562
  const result = { errors: [] };
2524
- const processError = (error53, path52 = []) => {
2563
+ const processError = (error53, path53 = []) => {
2525
2564
  var _a3, _b;
2526
2565
  for (const issue2 of error53.issues) {
2527
2566
  if (issue2.code === "invalid_union" && issue2.errors.length) {
2528
- issue2.errors.map((issues) => processError({ issues }, [...path52, ...issue2.path]));
2567
+ issue2.errors.map((issues) => processError({ issues }, [...path53, ...issue2.path]));
2529
2568
  } else if (issue2.code === "invalid_key") {
2530
- processError({ issues: issue2.issues }, [...path52, ...issue2.path]);
2569
+ processError({ issues: issue2.issues }, [...path53, ...issue2.path]);
2531
2570
  } else if (issue2.code === "invalid_element") {
2532
- processError({ issues: issue2.issues }, [...path52, ...issue2.path]);
2571
+ processError({ issues: issue2.issues }, [...path53, ...issue2.path]);
2533
2572
  } else {
2534
- const fullpath = [...path52, ...issue2.path];
2573
+ const fullpath = [...path53, ...issue2.path];
2535
2574
  if (fullpath.length === 0) {
2536
2575
  result.errors.push(mapper(issue2));
2537
2576
  continue;
@@ -2563,8 +2602,8 @@ function treeifyError(error52, mapper = (issue2) => issue2.message) {
2563
2602
  }
2564
2603
  function toDotPath(_path) {
2565
2604
  const segs = [];
2566
- const path52 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2567
- for (const seg of path52) {
2605
+ const path53 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2606
+ for (const seg of path53) {
2568
2607
  if (typeof seg === "number")
2569
2608
  segs.push(`[${seg}]`);
2570
2609
  else if (typeof seg === "symbol")
@@ -15994,13 +16033,13 @@ function resolveRef(ref, ctx) {
15994
16033
  if (!ref.startsWith("#")) {
15995
16034
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
15996
16035
  }
15997
- const path52 = ref.slice(1).split("/").filter(Boolean);
15998
- if (path52.length === 0) {
16036
+ const path53 = ref.slice(1).split("/").filter(Boolean);
16037
+ if (path53.length === 0) {
15999
16038
  return ctx.rootSchema;
16000
16039
  }
16001
16040
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
16002
- if (path52[0] === defsKey) {
16003
- const key2 = path52[1];
16041
+ if (path53[0] === defsKey) {
16042
+ const key2 = path53[1];
16004
16043
  if (!key2 || !ctx.defs[key2]) {
16005
16044
  throw new Error(`Reference not found: ${ref}`);
16006
16045
  }
@@ -16792,9 +16831,9 @@ function terminatingSignalCause(message) {
16792
16831
  error_kind: "unknown"
16793
16832
  });
16794
16833
  }
16795
- function valueAtPath(root, path52) {
16834
+ function valueAtPath(root, path53) {
16796
16835
  let current = root;
16797
- for (const key2 of path52) {
16836
+ for (const key2 of path53) {
16798
16837
  if (current === null || typeof current !== "object") return void 0;
16799
16838
  if (!Object.hasOwn(current, key2)) return void 0;
16800
16839
  current = current[key2];
@@ -33472,11 +33511,11 @@ var require_mime_types = __commonJS({
33472
33511
  }
33473
33512
  return exts[0];
33474
33513
  }
33475
- function lookup(path52) {
33476
- if (!path52 || typeof path52 !== "string") {
33514
+ function lookup(path53) {
33515
+ if (!path53 || typeof path53 !== "string") {
33477
33516
  return false;
33478
33517
  }
33479
- var extension3 = extname6("x." + path52).toLowerCase().slice(1);
33518
+ var extension3 = extname6("x." + path53).toLowerCase().slice(1);
33480
33519
  if (!extension3) {
33481
33520
  return false;
33482
33521
  }
@@ -37100,13 +37139,13 @@ var require_view = __commonJS({
37100
37139
  "../../node_modules/express/lib/view.js"(exports2, module2) {
37101
37140
  "use strict";
37102
37141
  var debug = require_src()("express:view");
37103
- var path52 = require("node:path");
37142
+ var path53 = require("node:path");
37104
37143
  var fs69 = require("node:fs");
37105
- var dirname18 = path52.dirname;
37106
- var basename14 = path52.basename;
37107
- var extname6 = path52.extname;
37108
- var join55 = path52.join;
37109
- var resolve14 = path52.resolve;
37144
+ var dirname19 = path53.dirname;
37145
+ var basename14 = path53.basename;
37146
+ var extname6 = path53.extname;
37147
+ var join55 = path53.join;
37148
+ var resolve14 = path53.resolve;
37110
37149
  module2.exports = View;
37111
37150
  function View(name, options) {
37112
37151
  var opts = options || {};
@@ -37135,17 +37174,17 @@ var require_view = __commonJS({
37135
37174
  this.path = this.lookup(fileName);
37136
37175
  }
37137
37176
  View.prototype.lookup = function lookup(name) {
37138
- var path53;
37177
+ var path54;
37139
37178
  var roots = [].concat(this.root);
37140
37179
  debug('lookup "%s"', name);
37141
- for (var i = 0; i < roots.length && !path53; i++) {
37180
+ for (var i = 0; i < roots.length && !path54; i++) {
37142
37181
  var root = roots[i];
37143
37182
  var loc = resolve14(root, name);
37144
- var dir = dirname18(loc);
37183
+ var dir = dirname19(loc);
37145
37184
  var file2 = basename14(loc);
37146
- path53 = this.resolve(dir, file2);
37185
+ path54 = this.resolve(dir, file2);
37147
37186
  }
37148
- return path53;
37187
+ return path54;
37149
37188
  };
37150
37189
  View.prototype.render = function render(options, callback) {
37151
37190
  var sync = true;
@@ -37167,21 +37206,21 @@ var require_view = __commonJS({
37167
37206
  };
37168
37207
  View.prototype.resolve = function resolve15(dir, file2) {
37169
37208
  var ext = this.ext;
37170
- var path53 = join55(dir, file2);
37171
- var stat6 = tryStat(path53);
37209
+ var path54 = join55(dir, file2);
37210
+ var stat6 = tryStat(path54);
37172
37211
  if (stat6 && stat6.isFile()) {
37173
- return path53;
37212
+ return path54;
37174
37213
  }
37175
- path53 = join55(dir, basename14(file2, ext), "index" + ext);
37176
- stat6 = tryStat(path53);
37214
+ path54 = join55(dir, basename14(file2, ext), "index" + ext);
37215
+ stat6 = tryStat(path54);
37177
37216
  if (stat6 && stat6.isFile()) {
37178
- return path53;
37217
+ return path54;
37179
37218
  }
37180
37219
  };
37181
- function tryStat(path53) {
37182
- debug('stat "%s"', path53);
37220
+ function tryStat(path54) {
37221
+ debug('stat "%s"', path54);
37183
37222
  try {
37184
- return fs69.statSync(path53);
37223
+ return fs69.statSync(path54);
37185
37224
  } catch (e) {
37186
37225
  return void 0;
37187
37226
  }
@@ -46791,11 +46830,11 @@ var require_mime_types2 = __commonJS({
46791
46830
  }
46792
46831
  return exts[0];
46793
46832
  }
46794
- function lookup(path52) {
46795
- if (!path52 || typeof path52 !== "string") {
46833
+ function lookup(path53) {
46834
+ if (!path53 || typeof path53 !== "string") {
46796
46835
  return false;
46797
46836
  }
46798
- var extension3 = extname6("x." + path52).toLowerCase().slice(1);
46837
+ var extension3 = extname6("x." + path53).toLowerCase().slice(1);
46799
46838
  if (!extension3) {
46800
46839
  return false;
46801
46840
  }
@@ -47926,15 +47965,15 @@ var require_dist3 = __commonJS({
47926
47965
  let index = 0;
47927
47966
  function consumeUntil(end) {
47928
47967
  const output = [];
47929
- let path52 = "";
47968
+ let path53 = "";
47930
47969
  function writePath() {
47931
- if (!path52)
47970
+ if (!path53)
47932
47971
  return;
47933
47972
  output.push({
47934
47973
  type: "text",
47935
- value: encodePath(path52)
47974
+ value: encodePath(path53)
47936
47975
  });
47937
- path52 = "";
47976
+ path53 = "";
47938
47977
  }
47939
47978
  while (index < chars.length) {
47940
47979
  const value = chars[index++];
@@ -47946,7 +47985,7 @@ var require_dist3 = __commonJS({
47946
47985
  if (index === chars.length) {
47947
47986
  throw new PathError(`Unexpected end after \\ at index ${index}`, str);
47948
47987
  }
47949
- path52 += chars[index++];
47988
+ path53 += chars[index++];
47950
47989
  continue;
47951
47990
  }
47952
47991
  if (value === ":" || value === "*") {
@@ -47990,7 +48029,7 @@ var require_dist3 = __commonJS({
47990
48029
  if (value === "}" || value === "(" || value === ")" || value === "[" || value === "]" || value === "+" || value === "?" || value === "!") {
47991
48030
  throw new PathError(`Unexpected ${value} at index ${index - 1}`, str);
47992
48031
  }
47993
- path52 += value;
48032
+ path53 += value;
47994
48033
  }
47995
48034
  if (end) {
47996
48035
  throw new PathError(`Unexpected end at index ${index}, expected ${end}`, str);
@@ -48000,17 +48039,17 @@ var require_dist3 = __commonJS({
48000
48039
  }
48001
48040
  return new TokenData(consumeUntil(""), str);
48002
48041
  }
48003
- function compile(path52, options = {}) {
48042
+ function compile(path53, options = {}) {
48004
48043
  const { encode: encode9 = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
48005
- const data = typeof path52 === "object" ? path52 : parse4(path52, options);
48044
+ const data = typeof path53 === "object" ? path53 : parse4(path53, options);
48006
48045
  const fn = tokensToFunction(data.tokens, delimiter, encode9);
48007
- return function path53(params = {}) {
48046
+ return function path54(params = {}) {
48008
48047
  const missing = [];
48009
- const path54 = fn(params, missing);
48048
+ const path55 = fn(params, missing);
48010
48049
  if (missing.length) {
48011
48050
  throw new TypeError(`Missing parameters: ${missing.join(", ")}`);
48012
48051
  }
48013
- return path54;
48052
+ return path55;
48014
48053
  };
48015
48054
  }
48016
48055
  function tokensToFunction(tokens, delimiter, encode9) {
@@ -48072,9 +48111,9 @@ var require_dist3 = __commonJS({
48072
48111
  return encodeValue(value);
48073
48112
  };
48074
48113
  }
48075
- function match(path52, options = {}) {
48114
+ function match(path53, options = {}) {
48076
48115
  const { decode: decode9 = decodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
48077
- const { regexp, keys } = pathToRegexp(path52, options);
48116
+ const { regexp, keys } = pathToRegexp(path53, options);
48078
48117
  const decoders = keys.map((key2) => {
48079
48118
  if (decode9 === false)
48080
48119
  return NOOP_VALUE;
@@ -48086,7 +48125,7 @@ var require_dist3 = __commonJS({
48086
48125
  const m = regexp.exec(input);
48087
48126
  if (!m)
48088
48127
  return false;
48089
- const path53 = m[0];
48128
+ const path54 = m[0];
48090
48129
  const params = /* @__PURE__ */ Object.create(null);
48091
48130
  for (let i = 1; i < m.length; i++) {
48092
48131
  if (m[i] === void 0)
@@ -48095,21 +48134,21 @@ var require_dist3 = __commonJS({
48095
48134
  const decoder = decoders[i - 1];
48096
48135
  params[key2.name] = decoder(m[i]);
48097
48136
  }
48098
- return { path: path53, params };
48137
+ return { path: path54, params };
48099
48138
  };
48100
48139
  }
48101
- function pathToRegexp(path52, options = {}) {
48140
+ function pathToRegexp(path53, options = {}) {
48102
48141
  const { delimiter = DEFAULT_DELIMITER, end = true, sensitive = false, trailing = true } = options;
48103
48142
  const keys = [];
48104
48143
  let source = "";
48105
48144
  let combinations = 0;
48106
- function process3(path53) {
48107
- if (Array.isArray(path53)) {
48108
- for (const p of path53)
48145
+ function process3(path54) {
48146
+ if (Array.isArray(path54)) {
48147
+ for (const p of path54)
48109
48148
  process3(p);
48110
48149
  return;
48111
48150
  }
48112
- const data = typeof path53 === "object" ? path53 : parse4(path53, options);
48151
+ const data = typeof path54 === "object" ? path54 : parse4(path54, options);
48113
48152
  flatten(data.tokens, 0, [], (tokens) => {
48114
48153
  if (combinations >= 256) {
48115
48154
  throw new PathError("Too many path combinations", data.originalPath);
@@ -48120,7 +48159,7 @@ var require_dist3 = __commonJS({
48120
48159
  combinations++;
48121
48160
  });
48122
48161
  }
48123
- process3(path52);
48162
+ process3(path53);
48124
48163
  let pattern = `^(?:${source})`;
48125
48164
  if (trailing)
48126
48165
  pattern += "(?:" + escape2(delimiter) + "$)?";
@@ -48260,18 +48299,18 @@ var require_layer = __commonJS({
48260
48299
  var TRAILING_SLASH_REGEXP = /\/+$/;
48261
48300
  var MATCHING_GROUP_REGEXP = /\((?:\?<(.*?)>)?(?!\?)/g;
48262
48301
  module2.exports = Layer;
48263
- function Layer(path52, options, fn) {
48302
+ function Layer(path53, options, fn) {
48264
48303
  if (!(this instanceof Layer)) {
48265
- return new Layer(path52, options, fn);
48304
+ return new Layer(path53, options, fn);
48266
48305
  }
48267
- debug("new %o", path52);
48306
+ debug("new %o", path53);
48268
48307
  const opts = options || {};
48269
48308
  this.handle = fn;
48270
48309
  this.keys = [];
48271
48310
  this.name = fn.name || "<anonymous>";
48272
48311
  this.params = void 0;
48273
48312
  this.path = void 0;
48274
- this.slash = path52 === "/" && opts.end === false;
48313
+ this.slash = path53 === "/" && opts.end === false;
48275
48314
  function matcher(_path) {
48276
48315
  if (_path instanceof RegExp) {
48277
48316
  const keys = [];
@@ -48310,7 +48349,7 @@ var require_layer = __commonJS({
48310
48349
  decode: decodeParam
48311
48350
  });
48312
48351
  }
48313
- this.matchers = Array.isArray(path52) ? path52.map(matcher) : [matcher(path52)];
48352
+ this.matchers = Array.isArray(path53) ? path53.map(matcher) : [matcher(path53)];
48314
48353
  }
48315
48354
  Layer.prototype.handleError = function handleError(error52, req, res, next) {
48316
48355
  const fn = this.handle;
@@ -48350,9 +48389,9 @@ var require_layer = __commonJS({
48350
48389
  next(err);
48351
48390
  }
48352
48391
  };
48353
- Layer.prototype.match = function match(path52) {
48392
+ Layer.prototype.match = function match(path53) {
48354
48393
  let match2;
48355
- if (path52 != null) {
48394
+ if (path53 != null) {
48356
48395
  if (this.slash) {
48357
48396
  this.params = {};
48358
48397
  this.path = "";
@@ -48360,7 +48399,7 @@ var require_layer = __commonJS({
48360
48399
  }
48361
48400
  let i = 0;
48362
48401
  while (!match2 && i < this.matchers.length) {
48363
- match2 = this.matchers[i](path52);
48402
+ match2 = this.matchers[i](path53);
48364
48403
  i++;
48365
48404
  }
48366
48405
  }
@@ -48388,13 +48427,13 @@ var require_layer = __commonJS({
48388
48427
  throw err;
48389
48428
  }
48390
48429
  }
48391
- function loosen(path52) {
48392
- if (path52 instanceof RegExp || path52 === "/") {
48393
- return path52;
48430
+ function loosen(path53) {
48431
+ if (path53 instanceof RegExp || path53 === "/") {
48432
+ return path53;
48394
48433
  }
48395
- return Array.isArray(path52) ? path52.map(function(p) {
48434
+ return Array.isArray(path53) ? path53.map(function(p) {
48396
48435
  return loosen(p);
48397
- }) : String(path52).replace(TRAILING_SLASH_REGEXP, "");
48436
+ }) : String(path53).replace(TRAILING_SLASH_REGEXP, "");
48398
48437
  }
48399
48438
  }
48400
48439
  });
@@ -48410,9 +48449,9 @@ var require_route = __commonJS({
48410
48449
  var flatten = Array.prototype.flat;
48411
48450
  var methods = METHODS.map((method) => method.toLowerCase());
48412
48451
  module2.exports = Route2;
48413
- function Route2(path52) {
48414
- debug("new %o", path52);
48415
- this.path = path52;
48452
+ function Route2(path53) {
48453
+ debug("new %o", path53);
48454
+ this.path = path53;
48416
48455
  this.stack = [];
48417
48456
  this.methods = /* @__PURE__ */ Object.create(null);
48418
48457
  }
@@ -48620,8 +48659,8 @@ var require_router = __commonJS({
48620
48659
  if (++sync > 100) {
48621
48660
  return setImmediate(next, err);
48622
48661
  }
48623
- const path52 = getPathname(req);
48624
- if (path52 == null) {
48662
+ const path53 = getPathname(req);
48663
+ if (path53 == null) {
48625
48664
  return done(layerError);
48626
48665
  }
48627
48666
  let layer;
@@ -48629,7 +48668,7 @@ var require_router = __commonJS({
48629
48668
  let route;
48630
48669
  while (match !== true && idx < stack.length) {
48631
48670
  layer = stack[idx++];
48632
- match = matchLayer(layer, path52);
48671
+ match = matchLayer(layer, path53);
48633
48672
  route = layer.route;
48634
48673
  if (typeof match !== "boolean") {
48635
48674
  layerError = layerError || match;
@@ -48667,18 +48706,18 @@ var require_router = __commonJS({
48667
48706
  } else if (route) {
48668
48707
  layer.handleRequest(req, res, next);
48669
48708
  } else {
48670
- trimPrefix(layer, layerError, layerPath, path52);
48709
+ trimPrefix(layer, layerError, layerPath, path53);
48671
48710
  }
48672
48711
  sync = 0;
48673
48712
  });
48674
48713
  }
48675
- function trimPrefix(layer, layerError, layerPath, path52) {
48714
+ function trimPrefix(layer, layerError, layerPath, path53) {
48676
48715
  if (layerPath.length !== 0) {
48677
- if (layerPath !== path52.substring(0, layerPath.length)) {
48716
+ if (layerPath !== path53.substring(0, layerPath.length)) {
48678
48717
  next(layerError);
48679
48718
  return;
48680
48719
  }
48681
- const c = path52[layerPath.length];
48720
+ const c = path53[layerPath.length];
48682
48721
  if (c && c !== "/") {
48683
48722
  next(layerError);
48684
48723
  return;
@@ -48702,7 +48741,7 @@ var require_router = __commonJS({
48702
48741
  };
48703
48742
  Router2.prototype.use = function use(handler) {
48704
48743
  let offset = 0;
48705
- let path52 = "/";
48744
+ let path53 = "/";
48706
48745
  if (typeof handler !== "function") {
48707
48746
  let arg = handler;
48708
48747
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -48710,7 +48749,7 @@ var require_router = __commonJS({
48710
48749
  }
48711
48750
  if (typeof arg !== "function") {
48712
48751
  offset = 1;
48713
- path52 = handler;
48752
+ path53 = handler;
48714
48753
  }
48715
48754
  }
48716
48755
  const callbacks = flatten.call(slice.call(arguments, offset), Infinity);
@@ -48722,8 +48761,8 @@ var require_router = __commonJS({
48722
48761
  if (typeof fn !== "function") {
48723
48762
  throw new TypeError("argument handler must be a function");
48724
48763
  }
48725
- debug("use %o %s", path52, fn.name || "<anonymous>");
48726
- const layer = new Layer(path52, {
48764
+ debug("use %o %s", path53, fn.name || "<anonymous>");
48765
+ const layer = new Layer(path53, {
48727
48766
  sensitive: this.caseSensitive,
48728
48767
  strict: false,
48729
48768
  end: false
@@ -48733,9 +48772,9 @@ var require_router = __commonJS({
48733
48772
  }
48734
48773
  return this;
48735
48774
  };
48736
- Router2.prototype.route = function route(path52) {
48737
- const route2 = new Route2(path52);
48738
- const layer = new Layer(path52, {
48775
+ Router2.prototype.route = function route(path53) {
48776
+ const route2 = new Route2(path53);
48777
+ const layer = new Layer(path53, {
48739
48778
  sensitive: this.caseSensitive,
48740
48779
  strict: this.strict,
48741
48780
  end: true
@@ -48748,8 +48787,8 @@ var require_router = __commonJS({
48748
48787
  return route2;
48749
48788
  };
48750
48789
  methods.concat("all").forEach(function(method) {
48751
- Router2.prototype[method] = function(path52) {
48752
- const route = this.route(path52);
48790
+ Router2.prototype[method] = function(path53) {
48791
+ const route = this.route(path53);
48753
48792
  route[method].apply(route, slice.call(arguments, 1));
48754
48793
  return this;
48755
48794
  };
@@ -48778,9 +48817,9 @@ var require_router = __commonJS({
48778
48817
  const fqdnIndex = url2.substring(0, pathLength).indexOf("://");
48779
48818
  return fqdnIndex !== -1 ? url2.substring(0, url2.indexOf("/", 3 + fqdnIndex)) : void 0;
48780
48819
  }
48781
- function matchLayer(layer, path52) {
48820
+ function matchLayer(layer, path53) {
48782
48821
  try {
48783
- return layer.match(path52);
48822
+ return layer.match(path53);
48784
48823
  } catch (err) {
48785
48824
  return err;
48786
48825
  }
@@ -49008,7 +49047,7 @@ var require_application = __commonJS({
49008
49047
  };
49009
49048
  app.use = function use(fn) {
49010
49049
  var offset = 0;
49011
- var path52 = "/";
49050
+ var path53 = "/";
49012
49051
  if (typeof fn !== "function") {
49013
49052
  var arg = fn;
49014
49053
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -49016,7 +49055,7 @@ var require_application = __commonJS({
49016
49055
  }
49017
49056
  if (typeof arg !== "function") {
49018
49057
  offset = 1;
49019
- path52 = fn;
49058
+ path53 = fn;
49020
49059
  }
49021
49060
  }
49022
49061
  var fns = flatten.call(slice.call(arguments, offset), Infinity);
@@ -49026,12 +49065,12 @@ var require_application = __commonJS({
49026
49065
  var router = this.router;
49027
49066
  fns.forEach(function(fn2) {
49028
49067
  if (!fn2 || !fn2.handle || !fn2.set) {
49029
- return router.use(path52, fn2);
49068
+ return router.use(path53, fn2);
49030
49069
  }
49031
- debug(".use app under %s", path52);
49032
- fn2.mountpath = path52;
49070
+ debug(".use app under %s", path53);
49071
+ fn2.mountpath = path53;
49033
49072
  fn2.parent = this;
49034
- router.use(path52, function mounted_app(req, res, next) {
49073
+ router.use(path53, function mounted_app(req, res, next) {
49035
49074
  var orig = req.app;
49036
49075
  fn2.handle(req, res, function(err) {
49037
49076
  Object.setPrototypeOf(req, orig.request);
@@ -49043,8 +49082,8 @@ var require_application = __commonJS({
49043
49082
  }, this);
49044
49083
  return this;
49045
49084
  };
49046
- app.route = function route(path52) {
49047
- return this.router.route(path52);
49085
+ app.route = function route(path53) {
49086
+ return this.router.route(path53);
49048
49087
  };
49049
49088
  app.engine = function engine(ext, fn) {
49050
49089
  if (typeof fn !== "function") {
@@ -49087,7 +49126,7 @@ var require_application = __commonJS({
49087
49126
  }
49088
49127
  return this;
49089
49128
  };
49090
- app.path = function path52() {
49129
+ app.path = function path53() {
49091
49130
  return this.parent ? this.parent.path() + this.mountpath : "";
49092
49131
  };
49093
49132
  app.enabled = function enabled(setting) {
@@ -49103,17 +49142,17 @@ var require_application = __commonJS({
49103
49142
  return this.set(setting, false);
49104
49143
  };
49105
49144
  methods.forEach(function(method) {
49106
- app[method] = function(path52) {
49145
+ app[method] = function(path53) {
49107
49146
  if (method === "get" && arguments.length === 1) {
49108
- return this.set(path52);
49147
+ return this.set(path53);
49109
49148
  }
49110
- var route = this.route(path52);
49149
+ var route = this.route(path53);
49111
49150
  route[method].apply(route, slice.call(arguments, 1));
49112
49151
  return this;
49113
49152
  };
49114
49153
  });
49115
- app.all = function all(path52) {
49116
- var route = this.route(path52);
49154
+ app.all = function all(path53) {
49155
+ var route = this.route(path53);
49117
49156
  var args = slice.call(arguments, 1);
49118
49157
  for (var i = 0; i < methods.length; i++) {
49119
49158
  route[methods[i]].apply(route, args);
@@ -59147,11 +59186,11 @@ var require_mime_types3 = __commonJS({
59147
59186
  }
59148
59187
  return exts[0];
59149
59188
  }
59150
- function lookup(path52) {
59151
- if (!path52 || typeof path52 !== "string") {
59189
+ function lookup(path53) {
59190
+ if (!path53 || typeof path53 !== "string") {
59152
59191
  return false;
59153
59192
  }
59154
- var extension3 = extname6("x." + path52).toLowerCase().slice(1);
59193
+ var extension3 = extname6("x." + path53).toLowerCase().slice(1);
59155
59194
  if (!extension3) {
59156
59195
  return false;
59157
59196
  }
@@ -59528,7 +59567,7 @@ var require_request = __commonJS({
59528
59567
  var subdomains2 = !isIP(hostname3) ? hostname3.split(".").reverse() : [hostname3];
59529
59568
  return subdomains2.slice(offset);
59530
59569
  });
59531
- defineGetter(req, "path", function path52() {
59570
+ defineGetter(req, "path", function path53() {
59532
59571
  return parse4(this).pathname;
59533
59572
  });
59534
59573
  defineGetter(req, "host", function host() {
@@ -59739,8 +59778,8 @@ var require_content_disposition = __commonJS({
59739
59778
  this.type = type;
59740
59779
  this.parameters = parameters;
59741
59780
  }
59742
- function basename14(path52) {
59743
- const normalized = path52.replaceAll("\\", "/");
59781
+ function basename14(path53) {
59782
+ const normalized = path53.replaceAll("\\", "/");
59744
59783
  let end = normalized.length;
59745
59784
  while (end > 0 && normalized[end - 1] === "/") {
59746
59785
  end--;
@@ -69427,11 +69466,11 @@ var require_mime_types4 = __commonJS({
69427
69466
  }
69428
69467
  return exts[0];
69429
69468
  }
69430
- function lookup(path52) {
69431
- if (!path52 || typeof path52 !== "string") {
69469
+ function lookup(path53) {
69470
+ if (!path53 || typeof path53 !== "string") {
69432
69471
  return false;
69433
69472
  }
69434
- var extension3 = extname6("x." + path52).toLowerCase().slice(1);
69473
+ var extension3 = extname6("x." + path53).toLowerCase().slice(1);
69435
69474
  if (!extension3) {
69436
69475
  return false;
69437
69476
  }
@@ -69491,27 +69530,27 @@ var require_send = __commonJS({
69491
69530
  var ms = require_ms();
69492
69531
  var onFinished = require_on_finished();
69493
69532
  var parseRange = require_range_parser();
69494
- var path52 = require("path");
69533
+ var path53 = require("path");
69495
69534
  var statuses = require_statuses();
69496
69535
  var Stream2 = require("stream");
69497
69536
  var util = require("util");
69498
- var extname6 = path52.extname;
69499
- var join55 = path52.join;
69500
- var normalize = path52.normalize;
69501
- var resolve14 = path52.resolve;
69502
- var sep5 = path52.sep;
69537
+ var extname6 = path53.extname;
69538
+ var join55 = path53.join;
69539
+ var normalize = path53.normalize;
69540
+ var resolve14 = path53.resolve;
69541
+ var sep5 = path53.sep;
69503
69542
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
69504
69543
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
69505
69544
  var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
69506
69545
  module2.exports = send;
69507
- function send(req, path53, options) {
69508
- return new SendStream(req, path53, options);
69546
+ function send(req, path54, options) {
69547
+ return new SendStream(req, path54, options);
69509
69548
  }
69510
- function SendStream(req, path53, options) {
69549
+ function SendStream(req, path54, options) {
69511
69550
  Stream2.call(this);
69512
69551
  var opts = options || {};
69513
69552
  this.options = opts;
69514
- this.path = path53;
69553
+ this.path = path54;
69515
69554
  this.req = req;
69516
69555
  this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
69517
69556
  this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
@@ -69625,10 +69664,10 @@ var require_send = __commonJS({
69625
69664
  var lastModified = this.res.getHeader("Last-Modified");
69626
69665
  return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
69627
69666
  };
69628
- SendStream.prototype.redirect = function redirect(path53) {
69667
+ SendStream.prototype.redirect = function redirect(path54) {
69629
69668
  var res = this.res;
69630
69669
  if (hasListeners(this, "directory")) {
69631
- this.emit("directory", res, path53);
69670
+ this.emit("directory", res, path54);
69632
69671
  return;
69633
69672
  }
69634
69673
  if (this.hasTrailingSlash()) {
@@ -69648,38 +69687,38 @@ var require_send = __commonJS({
69648
69687
  SendStream.prototype.pipe = function pipe2(res) {
69649
69688
  var root = this._root;
69650
69689
  this.res = res;
69651
- var path53 = decode9(this.path);
69652
- if (path53 === -1) {
69690
+ var path54 = decode9(this.path);
69691
+ if (path54 === -1) {
69653
69692
  this.error(400);
69654
69693
  return res;
69655
69694
  }
69656
- if (~path53.indexOf("\0")) {
69695
+ if (~path54.indexOf("\0")) {
69657
69696
  this.error(400);
69658
69697
  return res;
69659
69698
  }
69660
69699
  var parts2;
69661
69700
  if (root !== null) {
69662
- if (path53) {
69663
- path53 = normalize("." + sep5 + path53);
69701
+ if (path54) {
69702
+ path54 = normalize("." + sep5 + path54);
69664
69703
  }
69665
- if (UP_PATH_REGEXP.test(path53)) {
69666
- debug('malicious path "%s"', path53);
69704
+ if (UP_PATH_REGEXP.test(path54)) {
69705
+ debug('malicious path "%s"', path54);
69667
69706
  this.error(403);
69668
69707
  return res;
69669
69708
  }
69670
- parts2 = path53.split(sep5);
69671
- path53 = normalize(join55(root, path53));
69709
+ parts2 = path54.split(sep5);
69710
+ path54 = normalize(join55(root, path54));
69672
69711
  } else {
69673
- if (UP_PATH_REGEXP.test(path53)) {
69674
- debug('malicious path "%s"', path53);
69712
+ if (UP_PATH_REGEXP.test(path54)) {
69713
+ debug('malicious path "%s"', path54);
69675
69714
  this.error(403);
69676
69715
  return res;
69677
69716
  }
69678
- parts2 = normalize(path53).split(sep5);
69679
- path53 = resolve14(path53);
69717
+ parts2 = normalize(path54).split(sep5);
69718
+ path54 = resolve14(path54);
69680
69719
  }
69681
69720
  if (containsDotFile(parts2)) {
69682
- debug('%s dotfile "%s"', this._dotfiles, path53);
69721
+ debug('%s dotfile "%s"', this._dotfiles, path54);
69683
69722
  switch (this._dotfiles) {
69684
69723
  case "allow":
69685
69724
  break;
@@ -69693,13 +69732,13 @@ var require_send = __commonJS({
69693
69732
  }
69694
69733
  }
69695
69734
  if (this._index.length && this.hasTrailingSlash()) {
69696
- this.sendIndex(path53);
69735
+ this.sendIndex(path54);
69697
69736
  return res;
69698
69737
  }
69699
- this.sendFile(path53);
69738
+ this.sendFile(path54);
69700
69739
  return res;
69701
69740
  };
69702
- SendStream.prototype.send = function send2(path53, stat6) {
69741
+ SendStream.prototype.send = function send2(path54, stat6) {
69703
69742
  var len = stat6.size;
69704
69743
  var options = this.options;
69705
69744
  var opts = {};
@@ -69711,9 +69750,9 @@ var require_send = __commonJS({
69711
69750
  this.headersAlreadySent();
69712
69751
  return;
69713
69752
  }
69714
- debug('pipe "%s"', path53);
69715
- this.setHeader(path53, stat6);
69716
- this.type(path53);
69753
+ debug('pipe "%s"', path54);
69754
+ this.setHeader(path54, stat6);
69755
+ this.type(path54);
69717
69756
  if (this.isConditionalGET()) {
69718
69757
  if (this.isPreconditionFailure()) {
69719
69758
  this.error(412);
@@ -69762,28 +69801,28 @@ var require_send = __commonJS({
69762
69801
  res.end();
69763
69802
  return;
69764
69803
  }
69765
- this.stream(path53, opts);
69804
+ this.stream(path54, opts);
69766
69805
  };
69767
- SendStream.prototype.sendFile = function sendFile(path53) {
69806
+ SendStream.prototype.sendFile = function sendFile(path54) {
69768
69807
  var i = 0;
69769
69808
  var self2 = this;
69770
- debug('stat "%s"', path53);
69771
- fs69.stat(path53, function onstat(err, stat6) {
69772
- var pathEndsWithSep = path53[path53.length - 1] === sep5;
69773
- if (err && err.code === "ENOENT" && !extname6(path53) && !pathEndsWithSep) {
69809
+ debug('stat "%s"', path54);
69810
+ fs69.stat(path54, function onstat(err, stat6) {
69811
+ var pathEndsWithSep = path54[path54.length - 1] === sep5;
69812
+ if (err && err.code === "ENOENT" && !extname6(path54) && !pathEndsWithSep) {
69774
69813
  return next(err);
69775
69814
  }
69776
69815
  if (err) return self2.onStatError(err);
69777
- if (stat6.isDirectory()) return self2.redirect(path53);
69816
+ if (stat6.isDirectory()) return self2.redirect(path54);
69778
69817
  if (pathEndsWithSep) return self2.error(404);
69779
- self2.emit("file", path53, stat6);
69780
- self2.send(path53, stat6);
69818
+ self2.emit("file", path54, stat6);
69819
+ self2.send(path54, stat6);
69781
69820
  });
69782
69821
  function next(err) {
69783
69822
  if (self2._extensions.length <= i) {
69784
69823
  return err ? self2.onStatError(err) : self2.error(404);
69785
69824
  }
69786
- var p = path53 + "." + self2._extensions[i++];
69825
+ var p = path54 + "." + self2._extensions[i++];
69787
69826
  debug('stat "%s"', p);
69788
69827
  fs69.stat(p, function(err2, stat6) {
69789
69828
  if (err2) return next(err2);
@@ -69793,7 +69832,7 @@ var require_send = __commonJS({
69793
69832
  });
69794
69833
  }
69795
69834
  };
69796
- SendStream.prototype.sendIndex = function sendIndex(path53) {
69835
+ SendStream.prototype.sendIndex = function sendIndex(path54) {
69797
69836
  var i = -1;
69798
69837
  var self2 = this;
69799
69838
  function next(err) {
@@ -69801,7 +69840,7 @@ var require_send = __commonJS({
69801
69840
  if (err) return self2.onStatError(err);
69802
69841
  return self2.error(404);
69803
69842
  }
69804
- var p = join55(path53, self2._index[i]);
69843
+ var p = join55(path54, self2._index[i]);
69805
69844
  debug('stat "%s"', p);
69806
69845
  fs69.stat(p, function(err2, stat6) {
69807
69846
  if (err2) return next(err2);
@@ -69812,10 +69851,10 @@ var require_send = __commonJS({
69812
69851
  }
69813
69852
  next();
69814
69853
  };
69815
- SendStream.prototype.stream = function stream(path53, options) {
69854
+ SendStream.prototype.stream = function stream(path54, options) {
69816
69855
  var self2 = this;
69817
69856
  var res = this.res;
69818
- var stream2 = fs69.createReadStream(path53, options);
69857
+ var stream2 = fs69.createReadStream(path54, options);
69819
69858
  this.emit("stream", stream2);
69820
69859
  stream2.pipe(res);
69821
69860
  function cleanup() {
@@ -69830,17 +69869,17 @@ var require_send = __commonJS({
69830
69869
  self2.emit("end");
69831
69870
  });
69832
69871
  };
69833
- SendStream.prototype.type = function type(path53) {
69872
+ SendStream.prototype.type = function type(path54) {
69834
69873
  var res = this.res;
69835
69874
  if (res.getHeader("Content-Type")) return;
69836
- var ext = extname6(path53);
69875
+ var ext = extname6(path54);
69837
69876
  var type2 = mime.contentType(ext) || "application/octet-stream";
69838
69877
  debug("content-type %s", type2);
69839
69878
  res.setHeader("Content-Type", type2);
69840
69879
  };
69841
- SendStream.prototype.setHeader = function setHeader(path53, stat6) {
69880
+ SendStream.prototype.setHeader = function setHeader(path54, stat6) {
69842
69881
  var res = this.res;
69843
- this.emit("headers", res, path53, stat6);
69882
+ this.emit("headers", res, path54, stat6);
69844
69883
  if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
69845
69884
  debug("accept ranges");
69846
69885
  res.setHeader("Accept-Ranges", "bytes");
@@ -69898,9 +69937,9 @@ var require_send = __commonJS({
69898
69937
  }
69899
69938
  return err instanceof Error ? createError(status, err, { expose: false }) : createError(status, err);
69900
69939
  }
69901
- function decode9(path53) {
69940
+ function decode9(path54) {
69902
69941
  try {
69903
- return decodeURIComponent(path53);
69942
+ return decodeURIComponent(path54);
69904
69943
  } catch (err) {
69905
69944
  return -1;
69906
69945
  }
@@ -70044,7 +70083,7 @@ var require_response = __commonJS({
70044
70083
  var http6 = require("node:http");
70045
70084
  var onFinished = require_on_finished();
70046
70085
  var mime = require_mime_types2();
70047
- var path52 = require("node:path");
70086
+ var path53 = require("node:path");
70048
70087
  var pathIsAbsolute = require("node:path").isAbsolute;
70049
70088
  var statuses = require_statuses();
70050
70089
  var sign = require_cookie_signature().sign;
@@ -70053,8 +70092,8 @@ var require_response = __commonJS({
70053
70092
  var setCharset = require_utils3().setCharset;
70054
70093
  var cookie = require_cookie();
70055
70094
  var send = require_send();
70056
- var extname6 = path52.extname;
70057
- var resolve14 = path52.resolve;
70095
+ var extname6 = path53.extname;
70096
+ var resolve14 = path53.resolve;
70058
70097
  var vary = require_vary();
70059
70098
  var { Buffer: Buffer2 } = require("node:buffer");
70060
70099
  var res = Object.create(http6.ServerResponse.prototype);
@@ -70200,26 +70239,26 @@ var require_response = __commonJS({
70200
70239
  this.type("txt");
70201
70240
  return this.send(body);
70202
70241
  };
70203
- res.sendFile = function sendFile(path53, options, callback) {
70242
+ res.sendFile = function sendFile(path54, options, callback) {
70204
70243
  var done = callback;
70205
70244
  var req = this.req;
70206
70245
  var res2 = this;
70207
70246
  var next = req.next;
70208
70247
  var opts = options || {};
70209
- if (!path53) {
70248
+ if (!path54) {
70210
70249
  throw new TypeError("path argument is required to res.sendFile");
70211
70250
  }
70212
- if (typeof path53 !== "string") {
70251
+ if (typeof path54 !== "string") {
70213
70252
  throw new TypeError("path must be a string to res.sendFile");
70214
70253
  }
70215
70254
  if (typeof options === "function") {
70216
70255
  done = options;
70217
70256
  opts = {};
70218
70257
  }
70219
- if (!opts.root && !pathIsAbsolute(path53)) {
70258
+ if (!opts.root && !pathIsAbsolute(path54)) {
70220
70259
  throw new TypeError("path must be absolute or specify root to res.sendFile");
70221
70260
  }
70222
- var pathname = encodeURI(path53);
70261
+ var pathname = encodeURI(path54);
70223
70262
  opts.etag = this.app.enabled("etag");
70224
70263
  var file2 = send(req, pathname, opts);
70225
70264
  sendfile(res2, file2, opts, function(err) {
@@ -70230,7 +70269,7 @@ var require_response = __commonJS({
70230
70269
  }
70231
70270
  });
70232
70271
  };
70233
- res.download = function download(path53, filename, options, callback) {
70272
+ res.download = function download(path54, filename, options, callback) {
70234
70273
  var done = callback;
70235
70274
  var name = filename;
70236
70275
  var opts = options || null;
@@ -70247,7 +70286,7 @@ var require_response = __commonJS({
70247
70286
  opts = filename;
70248
70287
  }
70249
70288
  var headers = {
70250
- "Content-Disposition": contentDisposition(name || path53)
70289
+ "Content-Disposition": contentDisposition(name || path54)
70251
70290
  };
70252
70291
  if (opts && opts.headers) {
70253
70292
  var keys = Object.keys(opts.headers);
@@ -70260,7 +70299,7 @@ var require_response = __commonJS({
70260
70299
  }
70261
70300
  opts = Object.create(opts);
70262
70301
  opts.headers = headers;
70263
- var fullPath = !opts.root ? resolve14(path53) : path53;
70302
+ var fullPath = !opts.root ? resolve14(path54) : path54;
70264
70303
  return this.sendFile(fullPath, opts, done);
70265
70304
  };
70266
70305
  res.contentType = res.type = function contentType(type) {
@@ -70543,11 +70582,11 @@ var require_serve_static = __commonJS({
70543
70582
  }
70544
70583
  var forwardError = !fallthrough;
70545
70584
  var originalUrl = parseUrl.original(req);
70546
- var path52 = parseUrl(req).pathname;
70547
- if (path52 === "/" && originalUrl.pathname.substr(-1) !== "/") {
70548
- path52 = "";
70585
+ var path53 = parseUrl(req).pathname;
70586
+ if (path53 === "/" && originalUrl.pathname.substr(-1) !== "/") {
70587
+ path53 = "";
70549
70588
  }
70550
- var stream = send(req, path52, opts);
70589
+ var stream = send(req, path53, opts);
70551
70590
  stream.on("directory", onDirectory);
70552
70591
  if (setHeaders) {
70553
70592
  stream.on("headers", setHeaders);
@@ -77641,8 +77680,8 @@ __export(adb_exports, {
77641
77680
  waitForBootCompleted: () => waitForBootCompleted
77642
77681
  });
77643
77682
  async function resolveAdbOrThrow() {
77644
- const path52 = await resolveAndroidBinary("adb");
77645
- if (!path52) {
77683
+ const path53 = await resolveAndroidBinary("adb");
77684
+ if (!path53) {
77646
77685
  throw new FailureError(
77647
77686
  "`adb` not found on PATH or under `$ANDROID_HOME/platform-tools`. Install Android SDK Platform Tools or set `$ANDROID_HOME` to your SDK root.",
77648
77687
  {
@@ -77653,11 +77692,11 @@ async function resolveAdbOrThrow() {
77653
77692
  }
77654
77693
  );
77655
77694
  }
77656
- return path52;
77695
+ return path53;
77657
77696
  }
77658
77697
  async function resolveEmulatorOrThrow() {
77659
- const path52 = await resolveAndroidBinary("emulator");
77660
- if (!path52) {
77698
+ const path53 = await resolveAndroidBinary("emulator");
77699
+ if (!path53) {
77661
77700
  throw new FailureError(
77662
77701
  "`emulator` not found on PATH or under `$ANDROID_HOME/emulator`. Install the Android Emulator package or set `$ANDROID_HOME` to your SDK root.",
77663
77702
  {
@@ -77668,7 +77707,7 @@ async function resolveEmulatorOrThrow() {
77668
77707
  }
77669
77708
  );
77670
77709
  }
77671
- return path52;
77710
+ return path53;
77672
77711
  }
77673
77712
  async function emulatorSupportsFlag(flag, options = {}) {
77674
77713
  let emulatorPath;
@@ -78102,7 +78141,7 @@ var require_safe_json_stringify = __commonJS({
78102
78141
  var require_ncp = __commonJS({
78103
78142
  "../../node_modules/ncp/lib/ncp.js"(exports2, module2) {
78104
78143
  var fs69 = require("fs");
78105
- var path52 = require("path");
78144
+ var path53 = require("path");
78106
78145
  module2.exports = ncp;
78107
78146
  ncp.ncp = ncp;
78108
78147
  function ncp(source, dest, options, callback) {
@@ -78111,7 +78150,7 @@ var require_ncp = __commonJS({
78111
78150
  cback = options;
78112
78151
  options = {};
78113
78152
  }
78114
- var basePath = process.cwd(), currentPath = path52.resolve(basePath, source), targetPath = path52.resolve(basePath, dest), filter = options.filter, rename2 = options.rename, transform2 = options.transform, clobber = options.clobber !== false, modified = options.modified, dereference = options.dereference, errs = null, started = 0, finished = 0, running = 0, limit = options.limit || ncp.limit || 16;
78153
+ var basePath = process.cwd(), currentPath = path53.resolve(basePath, source), targetPath = path53.resolve(basePath, dest), filter = options.filter, rename2 = options.rename, transform2 = options.transform, clobber = options.clobber !== false, modified = options.modified, dereference = options.dereference, errs = null, started = 0, finished = 0, running = 0, limit = options.limit || ncp.limit || 16;
78115
78154
  limit = limit < 1 ? 1 : limit > 512 ? 512 : limit;
78116
78155
  startCopy(currentPath);
78117
78156
  function startCopy(source2) {
@@ -78230,7 +78269,7 @@ var require_ncp = __commonJS({
78230
78269
  return onError(err);
78231
78270
  }
78232
78271
  items.forEach(function(item) {
78233
- startCopy(path52.join(dir, item));
78272
+ startCopy(path53.join(dir, item));
78234
78273
  });
78235
78274
  return cb();
78236
78275
  });
@@ -78246,7 +78285,7 @@ var require_ncp = __commonJS({
78246
78285
  }
78247
78286
  function checkLink(resolvedPath, target) {
78248
78287
  if (dereference) {
78249
- resolvedPath = path52.resolve(basePath, resolvedPath);
78288
+ resolvedPath = path53.resolve(basePath, resolvedPath);
78250
78289
  }
78251
78290
  isWritable2(target, function(writable) {
78252
78291
  if (writable) {
@@ -78257,7 +78296,7 @@ var require_ncp = __commonJS({
78257
78296
  return onError(err);
78258
78297
  }
78259
78298
  if (dereference) {
78260
- targetDest = path52.resolve(basePath, targetDest);
78299
+ targetDest = path53.resolve(basePath, targetDest);
78261
78300
  }
78262
78301
  if (targetDest === resolvedPath) {
78263
78302
  return cb();
@@ -78276,8 +78315,8 @@ var require_ncp = __commonJS({
78276
78315
  return cb();
78277
78316
  });
78278
78317
  }
78279
- function isWritable2(path53, done) {
78280
- fs69.lstat(path53, function(err) {
78318
+ function isWritable2(path54, done) {
78319
+ fs69.lstat(path54, function(err) {
78281
78320
  if (err) {
78282
78321
  if (err.code === "ENOENT") return done(true);
78283
78322
  return done(false);
@@ -78540,7 +78579,7 @@ var require_minimatch = __commonJS({
78540
78579
  "../../node_modules/glob/node_modules/minimatch/minimatch.js"(exports2, module2) {
78541
78580
  module2.exports = minimatch;
78542
78581
  minimatch.Minimatch = Minimatch;
78543
- var path52 = (function() {
78582
+ var path53 = (function() {
78544
78583
  try {
78545
78584
  return require("path");
78546
78585
  } catch (e) {
@@ -78548,7 +78587,7 @@ var require_minimatch = __commonJS({
78548
78587
  })() || {
78549
78588
  sep: "/"
78550
78589
  };
78551
- minimatch.sep = path52.sep;
78590
+ minimatch.sep = path53.sep;
78552
78591
  var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
78553
78592
  var expand = require_brace_expansion();
78554
78593
  var plTypes = {
@@ -78637,8 +78676,8 @@ var require_minimatch = __commonJS({
78637
78676
  assertValidPattern(pattern);
78638
78677
  if (!options) options = {};
78639
78678
  pattern = pattern.trim();
78640
- if (!options.allowWindowsEscape && path52.sep !== "/") {
78641
- pattern = pattern.split(path52.sep).join("/");
78679
+ if (!options.allowWindowsEscape && path53.sep !== "/") {
78680
+ pattern = pattern.split(path53.sep).join("/");
78642
78681
  }
78643
78682
  this.options = options;
78644
78683
  this.maxGlobstarRecursion = options.maxGlobstarRecursion !== void 0 ? options.maxGlobstarRecursion : 200;
@@ -79009,8 +79048,8 @@ var require_minimatch = __commonJS({
79009
79048
  if (this.empty) return f === "";
79010
79049
  if (f === "/" && partial2) return true;
79011
79050
  var options = this.options;
79012
- if (path52.sep !== "/") {
79013
- f = f.split(path52.sep).join("/");
79051
+ if (path53.sep !== "/") {
79052
+ f = f.split(path53.sep).join("/");
79014
79053
  }
79015
79054
  f = f.split(slashSplit);
79016
79055
  this.debug(this.pattern, "split", f);
@@ -79211,18 +79250,18 @@ var require_minimatch = __commonJS({
79211
79250
  var require_path_is_absolute = __commonJS({
79212
79251
  "../../node_modules/path-is-absolute/index.js"(exports2, module2) {
79213
79252
  "use strict";
79214
- function posix7(path52) {
79215
- return path52.charAt(0) === "/";
79253
+ function posix8(path53) {
79254
+ return path53.charAt(0) === "/";
79216
79255
  }
79217
- function win322(path52) {
79256
+ function win322(path53) {
79218
79257
  var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
79219
- var result = splitDeviceRe.exec(path52);
79258
+ var result = splitDeviceRe.exec(path53);
79220
79259
  var device = result[1] || "";
79221
79260
  var isUnc = Boolean(device && device.charAt(1) !== ":");
79222
79261
  return Boolean(result[2] || isUnc);
79223
79262
  }
79224
- module2.exports = process.platform === "win32" ? win322 : posix7;
79225
- module2.exports.posix = posix7;
79263
+ module2.exports = process.platform === "win32" ? win322 : posix8;
79264
+ module2.exports.posix = posix8;
79226
79265
  module2.exports.win32 = win322;
79227
79266
  }
79228
79267
  });
@@ -79242,9 +79281,9 @@ var require_common2 = __commonJS({
79242
79281
  function ownProp(obj, field) {
79243
79282
  return Object.prototype.hasOwnProperty.call(obj, field);
79244
79283
  }
79245
- var path52 = require("path");
79284
+ var path53 = require("path");
79246
79285
  var minimatch = require_minimatch();
79247
- var isAbsolute9 = require_path_is_absolute();
79286
+ var isAbsolute10 = require_path_is_absolute();
79248
79287
  var Minimatch = minimatch.Minimatch;
79249
79288
  function alphasorti(a, b) {
79250
79289
  return a.toLowerCase().localeCompare(b.toLowerCase());
@@ -79309,10 +79348,10 @@ var require_common2 = __commonJS({
79309
79348
  self2.cwd = cwd;
79310
79349
  else {
79311
79350
  self2.cwd = options.cwd;
79312
- self2.changedCwd = path52.resolve(options.cwd) !== cwd;
79351
+ self2.changedCwd = path53.resolve(options.cwd) !== cwd;
79313
79352
  }
79314
- self2.root = options.root || path52.resolve(self2.cwd, "/");
79315
- self2.root = path52.resolve(self2.root);
79353
+ self2.root = options.root || path53.resolve(self2.cwd, "/");
79354
+ self2.root = path53.resolve(self2.root);
79316
79355
  if (process.platform === "win32")
79317
79356
  self2.root = self2.root.replace(/\\/g, "/");
79318
79357
  self2.nomount = !!options.nomount;
@@ -79386,28 +79425,28 @@ var require_common2 = __commonJS({
79386
79425
  function makeAbs(self2, f) {
79387
79426
  var abs = f;
79388
79427
  if (f.charAt(0) === "/") {
79389
- abs = path52.join(self2.root, f);
79390
- } else if (isAbsolute9(f) || f === "") {
79428
+ abs = path53.join(self2.root, f);
79429
+ } else if (isAbsolute10(f) || f === "") {
79391
79430
  abs = f;
79392
79431
  } else if (self2.changedCwd) {
79393
- abs = path52.resolve(self2.cwd, f);
79432
+ abs = path53.resolve(self2.cwd, f);
79394
79433
  } else {
79395
- abs = path52.resolve(f);
79434
+ abs = path53.resolve(f);
79396
79435
  }
79397
79436
  return abs;
79398
79437
  }
79399
- function isIgnored(self2, path53) {
79438
+ function isIgnored(self2, path54) {
79400
79439
  if (!self2.ignore.length)
79401
79440
  return false;
79402
79441
  return self2.ignore.some(function(item) {
79403
- return item.matcher.match(path53) || !!(item.gmatcher && item.gmatcher.match(path53));
79442
+ return item.matcher.match(path54) || !!(item.gmatcher && item.gmatcher.match(path54));
79404
79443
  });
79405
79444
  }
79406
- function childrenIgnored(self2, path53) {
79445
+ function childrenIgnored(self2, path54) {
79407
79446
  if (!self2.ignore.length)
79408
79447
  return false;
79409
79448
  return self2.ignore.some(function(item) {
79410
- return !!(item.gmatcher && item.gmatcher.match(path53));
79449
+ return !!(item.gmatcher && item.gmatcher.match(path54));
79411
79450
  });
79412
79451
  }
79413
79452
  }
@@ -79423,9 +79462,9 @@ var require_sync = __commonJS({
79423
79462
  var Minimatch = minimatch.Minimatch;
79424
79463
  var Glob = require_glob().Glob;
79425
79464
  var util = require("util");
79426
- var path52 = require("path");
79465
+ var path53 = require("path");
79427
79466
  var assert2 = require("assert");
79428
- var isAbsolute9 = require_path_is_absolute();
79467
+ var isAbsolute10 = require_path_is_absolute();
79429
79468
  var common = require_common2();
79430
79469
  var alphasort = common.alphasort;
79431
79470
  var alphasorti = common.alphasorti;
@@ -79499,8 +79538,8 @@ var require_sync = __commonJS({
79499
79538
  var read;
79500
79539
  if (prefix === null)
79501
79540
  read = ".";
79502
- else if (isAbsolute9(prefix) || isAbsolute9(pattern.join("/"))) {
79503
- if (!prefix || !isAbsolute9(prefix))
79541
+ else if (isAbsolute10(prefix) || isAbsolute10(pattern.join("/"))) {
79542
+ if (!prefix || !isAbsolute10(prefix))
79504
79543
  prefix = "/" + prefix;
79505
79544
  read = prefix;
79506
79545
  } else
@@ -79551,7 +79590,7 @@ var require_sync = __commonJS({
79551
79590
  e = prefix + e;
79552
79591
  }
79553
79592
  if (e.charAt(0) === "/" && !this.nomount) {
79554
- e = path52.join(this.root, e);
79593
+ e = path53.join(this.root, e);
79555
79594
  }
79556
79595
  this.matches[index][e] = true;
79557
79596
  }
@@ -79685,12 +79724,12 @@ var require_sync = __commonJS({
79685
79724
  this.matches[index] = /* @__PURE__ */ Object.create(null);
79686
79725
  if (!exists2)
79687
79726
  return;
79688
- if (prefix && isAbsolute9(prefix) && !this.nomount) {
79727
+ if (prefix && isAbsolute10(prefix) && !this.nomount) {
79689
79728
  var trail = /[\/\\]$/.test(prefix);
79690
79729
  if (prefix.charAt(0) === "/") {
79691
- prefix = path52.join(this.root, prefix);
79730
+ prefix = path53.join(this.root, prefix);
79692
79731
  } else {
79693
- prefix = path52.resolve(this.root, prefix);
79732
+ prefix = path53.resolve(this.root, prefix);
79694
79733
  if (trail)
79695
79734
  prefix += "/";
79696
79735
  }
@@ -79803,9 +79842,9 @@ var require_glob = __commonJS({
79803
79842
  var Minimatch = minimatch.Minimatch;
79804
79843
  var inherits = require_inherits();
79805
79844
  var EE = require("events").EventEmitter;
79806
- var path52 = require("path");
79845
+ var path53 = require("path");
79807
79846
  var assert2 = require("assert");
79808
- var isAbsolute9 = require_path_is_absolute();
79847
+ var isAbsolute10 = require_path_is_absolute();
79809
79848
  var globSync = require_sync();
79810
79849
  var common = require_common2();
79811
79850
  var alphasort = common.alphasort;
@@ -80019,8 +80058,8 @@ var require_glob = __commonJS({
80019
80058
  var read;
80020
80059
  if (prefix === null)
80021
80060
  read = ".";
80022
- else if (isAbsolute9(prefix) || isAbsolute9(pattern.join("/"))) {
80023
- if (!prefix || !isAbsolute9(prefix))
80061
+ else if (isAbsolute10(prefix) || isAbsolute10(pattern.join("/"))) {
80062
+ if (!prefix || !isAbsolute10(prefix))
80024
80063
  prefix = "/" + prefix;
80025
80064
  read = prefix;
80026
80065
  } else
@@ -80076,7 +80115,7 @@ var require_glob = __commonJS({
80076
80115
  e = prefix + e;
80077
80116
  }
80078
80117
  if (e.charAt(0) === "/" && !this.nomount) {
80079
- e = path52.join(this.root, e);
80118
+ e = path53.join(this.root, e);
80080
80119
  }
80081
80120
  this._emitMatch(index, e);
80082
80121
  }
@@ -80252,12 +80291,12 @@ var require_glob = __commonJS({
80252
80291
  this.matches[index] = /* @__PURE__ */ Object.create(null);
80253
80292
  if (!exists2)
80254
80293
  return cb();
80255
- if (prefix && isAbsolute9(prefix) && !this.nomount) {
80294
+ if (prefix && isAbsolute10(prefix) && !this.nomount) {
80256
80295
  var trail = /[\/\\]$/.test(prefix);
80257
80296
  if (prefix.charAt(0) === "/") {
80258
- prefix = path52.join(this.root, prefix);
80297
+ prefix = path53.join(this.root, prefix);
80259
80298
  } else {
80260
- prefix = path52.resolve(this.root, prefix);
80299
+ prefix = path53.resolve(this.root, prefix);
80261
80300
  if (trail)
80262
80301
  prefix += "/";
80263
80302
  }
@@ -80335,7 +80374,7 @@ var require_rimraf = __commonJS({
80335
80374
  module2.exports = rimraf;
80336
80375
  rimraf.sync = rimrafSync;
80337
80376
  var assert2 = require("assert");
80338
- var path52 = require("path");
80377
+ var path53 = require("path");
80339
80378
  var fs69 = require("fs");
80340
80379
  var glob = require_glob();
80341
80380
  var globOpts = {
@@ -80514,7 +80553,7 @@ var require_rimraf = __commonJS({
80514
80553
  return options.rmdir(p, cb);
80515
80554
  var errState;
80516
80555
  files.forEach(function(f) {
80517
- rimraf(path52.join(p, f), options, function(er2) {
80556
+ rimraf(path53.join(p, f), options, function(er2) {
80518
80557
  if (errState)
80519
80558
  return;
80520
80559
  if (er2)
@@ -80589,7 +80628,7 @@ var require_rimraf = __commonJS({
80589
80628
  assert2(p);
80590
80629
  assert2(options);
80591
80630
  options.readdirSync(p).forEach(function(f) {
80592
- rimrafSync(path52.join(p, f), options);
80631
+ rimrafSync(path53.join(p, f), options);
80593
80632
  });
80594
80633
  options.rmdirSync(p, options);
80595
80634
  }
@@ -80599,7 +80638,7 @@ var require_rimraf = __commonJS({
80599
80638
  // ../../node_modules/mkdirp/index.js
80600
80639
  var require_mkdirp = __commonJS({
80601
80640
  "../../node_modules/mkdirp/index.js"(exports2, module2) {
80602
- var path52 = require("path");
80641
+ var path53 = require("path");
80603
80642
  var fs69 = require("fs");
80604
80643
  var _0777 = parseInt("0777", 8);
80605
80644
  module2.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
@@ -80619,7 +80658,7 @@ var require_mkdirp = __commonJS({
80619
80658
  var cb = f || /* istanbul ignore next */
80620
80659
  function() {
80621
80660
  };
80622
- p = path52.resolve(p);
80661
+ p = path53.resolve(p);
80623
80662
  xfs.mkdir(p, mode, function(er) {
80624
80663
  if (!er) {
80625
80664
  made = made || p;
@@ -80627,8 +80666,8 @@ var require_mkdirp = __commonJS({
80627
80666
  }
80628
80667
  switch (er.code) {
80629
80668
  case "ENOENT":
80630
- if (path52.dirname(p) === p) return cb(er);
80631
- mkdirP(path52.dirname(p), opts, function(er2, made2) {
80669
+ if (path53.dirname(p) === p) return cb(er);
80670
+ mkdirP(path53.dirname(p), opts, function(er2, made2) {
80632
80671
  if (er2) cb(er2, made2);
80633
80672
  else mkdirP(p, opts, cb, made2);
80634
80673
  });
@@ -80655,14 +80694,14 @@ var require_mkdirp = __commonJS({
80655
80694
  mode = _0777;
80656
80695
  }
80657
80696
  if (!made) made = null;
80658
- p = path52.resolve(p);
80697
+ p = path53.resolve(p);
80659
80698
  try {
80660
80699
  xfs.mkdirSync(p, mode);
80661
80700
  made = made || p;
80662
80701
  } catch (err0) {
80663
80702
  switch (err0.code) {
80664
80703
  case "ENOENT":
80665
- made = sync(path52.dirname(p), opts, made);
80704
+ made = sync(path53.dirname(p), opts, made);
80666
80705
  sync(p, opts, made);
80667
80706
  break;
80668
80707
  // In the case of any other error, just see if there's a dir
@@ -80689,7 +80728,7 @@ var require_mv = __commonJS({
80689
80728
  "../../node_modules/mv/index.js"(exports2, module2) {
80690
80729
  var fs69 = require("fs");
80691
80730
  var ncp = require_ncp().ncp;
80692
- var path52 = require("path");
80731
+ var path53 = require("path");
80693
80732
  var rimraf = require_rimraf();
80694
80733
  var mkdirp = require_mkdirp();
80695
80734
  module2.exports = mv;
@@ -80707,7 +80746,7 @@ var require_mv = __commonJS({
80707
80746
  doRename();
80708
80747
  }
80709
80748
  function mkdirs() {
80710
- mkdirp(path52.dirname(dest), function(err) {
80749
+ mkdirp(path53.dirname(dest), function(err) {
80711
80750
  if (err) return cb(err);
80712
80751
  doRename();
80713
80752
  });
@@ -84077,17 +84116,17 @@ var require_visit = __commonJS({
84077
84116
  visit.BREAK = BREAK;
84078
84117
  visit.SKIP = SKIP;
84079
84118
  visit.REMOVE = REMOVE;
84080
- function visit_(key2, node, visitor, path52) {
84081
- const ctrl = callVisitor(key2, node, visitor, path52);
84119
+ function visit_(key2, node, visitor, path53) {
84120
+ const ctrl = callVisitor(key2, node, visitor, path53);
84082
84121
  if (identity2.isNode(ctrl) || identity2.isPair(ctrl)) {
84083
- replaceNode(key2, path52, ctrl);
84084
- return visit_(key2, ctrl, visitor, path52);
84122
+ replaceNode(key2, path53, ctrl);
84123
+ return visit_(key2, ctrl, visitor, path53);
84085
84124
  }
84086
84125
  if (typeof ctrl !== "symbol") {
84087
84126
  if (identity2.isCollection(node)) {
84088
- path52 = Object.freeze(path52.concat(node));
84127
+ path53 = Object.freeze(path53.concat(node));
84089
84128
  for (let i = 0; i < node.items.length; ++i) {
84090
- const ci = visit_(i, node.items[i], visitor, path52);
84129
+ const ci = visit_(i, node.items[i], visitor, path53);
84091
84130
  if (typeof ci === "number")
84092
84131
  i = ci - 1;
84093
84132
  else if (ci === BREAK)
@@ -84098,13 +84137,13 @@ var require_visit = __commonJS({
84098
84137
  }
84099
84138
  }
84100
84139
  } else if (identity2.isPair(node)) {
84101
- path52 = Object.freeze(path52.concat(node));
84102
- const ck = visit_("key", node.key, visitor, path52);
84140
+ path53 = Object.freeze(path53.concat(node));
84141
+ const ck = visit_("key", node.key, visitor, path53);
84103
84142
  if (ck === BREAK)
84104
84143
  return BREAK;
84105
84144
  else if (ck === REMOVE)
84106
84145
  node.key = null;
84107
- const cv = visit_("value", node.value, visitor, path52);
84146
+ const cv = visit_("value", node.value, visitor, path53);
84108
84147
  if (cv === BREAK)
84109
84148
  return BREAK;
84110
84149
  else if (cv === REMOVE)
@@ -84125,17 +84164,17 @@ var require_visit = __commonJS({
84125
84164
  visitAsync.BREAK = BREAK;
84126
84165
  visitAsync.SKIP = SKIP;
84127
84166
  visitAsync.REMOVE = REMOVE;
84128
- async function visitAsync_(key2, node, visitor, path52) {
84129
- const ctrl = await callVisitor(key2, node, visitor, path52);
84167
+ async function visitAsync_(key2, node, visitor, path53) {
84168
+ const ctrl = await callVisitor(key2, node, visitor, path53);
84130
84169
  if (identity2.isNode(ctrl) || identity2.isPair(ctrl)) {
84131
- replaceNode(key2, path52, ctrl);
84132
- return visitAsync_(key2, ctrl, visitor, path52);
84170
+ replaceNode(key2, path53, ctrl);
84171
+ return visitAsync_(key2, ctrl, visitor, path53);
84133
84172
  }
84134
84173
  if (typeof ctrl !== "symbol") {
84135
84174
  if (identity2.isCollection(node)) {
84136
- path52 = Object.freeze(path52.concat(node));
84175
+ path53 = Object.freeze(path53.concat(node));
84137
84176
  for (let i = 0; i < node.items.length; ++i) {
84138
- const ci = await visitAsync_(i, node.items[i], visitor, path52);
84177
+ const ci = await visitAsync_(i, node.items[i], visitor, path53);
84139
84178
  if (typeof ci === "number")
84140
84179
  i = ci - 1;
84141
84180
  else if (ci === BREAK)
@@ -84146,13 +84185,13 @@ var require_visit = __commonJS({
84146
84185
  }
84147
84186
  }
84148
84187
  } else if (identity2.isPair(node)) {
84149
- path52 = Object.freeze(path52.concat(node));
84150
- const ck = await visitAsync_("key", node.key, visitor, path52);
84188
+ path53 = Object.freeze(path53.concat(node));
84189
+ const ck = await visitAsync_("key", node.key, visitor, path53);
84151
84190
  if (ck === BREAK)
84152
84191
  return BREAK;
84153
84192
  else if (ck === REMOVE)
84154
84193
  node.key = null;
84155
- const cv = await visitAsync_("value", node.value, visitor, path52);
84194
+ const cv = await visitAsync_("value", node.value, visitor, path53);
84156
84195
  if (cv === BREAK)
84157
84196
  return BREAK;
84158
84197
  else if (cv === REMOVE)
@@ -84179,23 +84218,23 @@ var require_visit = __commonJS({
84179
84218
  }
84180
84219
  return visitor;
84181
84220
  }
84182
- function callVisitor(key2, node, visitor, path52) {
84221
+ function callVisitor(key2, node, visitor, path53) {
84183
84222
  if (typeof visitor === "function")
84184
- return visitor(key2, node, path52);
84223
+ return visitor(key2, node, path53);
84185
84224
  if (identity2.isMap(node))
84186
- return visitor.Map?.(key2, node, path52);
84225
+ return visitor.Map?.(key2, node, path53);
84187
84226
  if (identity2.isSeq(node))
84188
- return visitor.Seq?.(key2, node, path52);
84227
+ return visitor.Seq?.(key2, node, path53);
84189
84228
  if (identity2.isPair(node))
84190
- return visitor.Pair?.(key2, node, path52);
84229
+ return visitor.Pair?.(key2, node, path53);
84191
84230
  if (identity2.isScalar(node))
84192
- return visitor.Scalar?.(key2, node, path52);
84231
+ return visitor.Scalar?.(key2, node, path53);
84193
84232
  if (identity2.isAlias(node))
84194
- return visitor.Alias?.(key2, node, path52);
84233
+ return visitor.Alias?.(key2, node, path53);
84195
84234
  return void 0;
84196
84235
  }
84197
- function replaceNode(key2, path52, node) {
84198
- const parent = path52[path52.length - 1];
84236
+ function replaceNode(key2, path53, node) {
84237
+ const parent = path53[path53.length - 1];
84199
84238
  if (identity2.isCollection(parent)) {
84200
84239
  parent.items[key2] = node;
84201
84240
  } else if (identity2.isPair(parent)) {
@@ -84805,10 +84844,10 @@ var require_Collection = __commonJS({
84805
84844
  var createNode = require_createNode();
84806
84845
  var identity2 = require_identity();
84807
84846
  var Node = require_Node();
84808
- function collectionFromPath(schema, path52, value) {
84847
+ function collectionFromPath(schema, path53, value) {
84809
84848
  let v = value;
84810
- for (let i = path52.length - 1; i >= 0; --i) {
84811
- const k = path52[i];
84849
+ for (let i = path53.length - 1; i >= 0; --i) {
84850
+ const k = path53[i];
84812
84851
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
84813
84852
  const a = [];
84814
84853
  a[k] = v;
@@ -84827,7 +84866,7 @@ var require_Collection = __commonJS({
84827
84866
  sourceObjects: /* @__PURE__ */ new Map()
84828
84867
  });
84829
84868
  }
84830
- var isEmptyPath = (path52) => path52 == null || typeof path52 === "object" && !!path52[Symbol.iterator]().next().done;
84869
+ var isEmptyPath = (path53) => path53 == null || typeof path53 === "object" && !!path53[Symbol.iterator]().next().done;
84831
84870
  var Collection = class extends Node.NodeBase {
84832
84871
  constructor(type, schema) {
84833
84872
  super(type);
@@ -84857,11 +84896,11 @@ var require_Collection = __commonJS({
84857
84896
  * be a Pair instance or a `{ key, value }` object, which may not have a key
84858
84897
  * that already exists in the map.
84859
84898
  */
84860
- addIn(path52, value) {
84861
- if (isEmptyPath(path52))
84899
+ addIn(path53, value) {
84900
+ if (isEmptyPath(path53))
84862
84901
  this.add(value);
84863
84902
  else {
84864
- const [key2, ...rest] = path52;
84903
+ const [key2, ...rest] = path53;
84865
84904
  const node = this.get(key2, true);
84866
84905
  if (identity2.isCollection(node))
84867
84906
  node.addIn(rest, value);
@@ -84875,8 +84914,8 @@ var require_Collection = __commonJS({
84875
84914
  * Removes a value from the collection.
84876
84915
  * @returns `true` if the item was found and removed.
84877
84916
  */
84878
- deleteIn(path52) {
84879
- const [key2, ...rest] = path52;
84917
+ deleteIn(path53) {
84918
+ const [key2, ...rest] = path53;
84880
84919
  if (rest.length === 0)
84881
84920
  return this.delete(key2);
84882
84921
  const node = this.get(key2, true);
@@ -84890,8 +84929,8 @@ var require_Collection = __commonJS({
84890
84929
  * scalar values from their surrounding node; to disable set `keepScalar` to
84891
84930
  * `true` (collections are always returned intact).
84892
84931
  */
84893
- getIn(path52, keepScalar) {
84894
- const [key2, ...rest] = path52;
84932
+ getIn(path53, keepScalar) {
84933
+ const [key2, ...rest] = path53;
84895
84934
  const node = this.get(key2, true);
84896
84935
  if (rest.length === 0)
84897
84936
  return !keepScalar && identity2.isScalar(node) ? node.value : node;
@@ -84909,8 +84948,8 @@ var require_Collection = __commonJS({
84909
84948
  /**
84910
84949
  * Checks if the collection includes a value with the key `key`.
84911
84950
  */
84912
- hasIn(path52) {
84913
- const [key2, ...rest] = path52;
84951
+ hasIn(path53) {
84952
+ const [key2, ...rest] = path53;
84914
84953
  if (rest.length === 0)
84915
84954
  return this.has(key2);
84916
84955
  const node = this.get(key2, true);
@@ -84920,8 +84959,8 @@ var require_Collection = __commonJS({
84920
84959
  * Sets a value in this collection. For `!!set`, `value` needs to be a
84921
84960
  * boolean to add/remove the item from the set.
84922
84961
  */
84923
- setIn(path52, value) {
84924
- const [key2, ...rest] = path52;
84962
+ setIn(path53, value) {
84963
+ const [key2, ...rest] = path53;
84925
84964
  if (rest.length === 0) {
84926
84965
  this.set(key2, value);
84927
84966
  } else {
@@ -87436,9 +87475,9 @@ var require_Document = __commonJS({
87436
87475
  this.contents.add(value);
87437
87476
  }
87438
87477
  /** Adds a value to the document. */
87439
- addIn(path52, value) {
87478
+ addIn(path53, value) {
87440
87479
  if (assertCollection(this.contents))
87441
- this.contents.addIn(path52, value);
87480
+ this.contents.addIn(path53, value);
87442
87481
  }
87443
87482
  /**
87444
87483
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -87513,14 +87552,14 @@ var require_Document = __commonJS({
87513
87552
  * Removes a value from the document.
87514
87553
  * @returns `true` if the item was found and removed.
87515
87554
  */
87516
- deleteIn(path52) {
87517
- if (Collection.isEmptyPath(path52)) {
87555
+ deleteIn(path53) {
87556
+ if (Collection.isEmptyPath(path53)) {
87518
87557
  if (this.contents == null)
87519
87558
  return false;
87520
87559
  this.contents = null;
87521
87560
  return true;
87522
87561
  }
87523
- return assertCollection(this.contents) ? this.contents.deleteIn(path52) : false;
87562
+ return assertCollection(this.contents) ? this.contents.deleteIn(path53) : false;
87524
87563
  }
87525
87564
  /**
87526
87565
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -87535,10 +87574,10 @@ var require_Document = __commonJS({
87535
87574
  * scalar values from their surrounding node; to disable set `keepScalar` to
87536
87575
  * `true` (collections are always returned intact).
87537
87576
  */
87538
- getIn(path52, keepScalar) {
87539
- if (Collection.isEmptyPath(path52))
87577
+ getIn(path53, keepScalar) {
87578
+ if (Collection.isEmptyPath(path53))
87540
87579
  return !keepScalar && identity2.isScalar(this.contents) ? this.contents.value : this.contents;
87541
- return identity2.isCollection(this.contents) ? this.contents.getIn(path52, keepScalar) : void 0;
87580
+ return identity2.isCollection(this.contents) ? this.contents.getIn(path53, keepScalar) : void 0;
87542
87581
  }
87543
87582
  /**
87544
87583
  * Checks if the document includes a value with the key `key`.
@@ -87549,10 +87588,10 @@ var require_Document = __commonJS({
87549
87588
  /**
87550
87589
  * Checks if the document includes a value at `path`.
87551
87590
  */
87552
- hasIn(path52) {
87553
- if (Collection.isEmptyPath(path52))
87591
+ hasIn(path53) {
87592
+ if (Collection.isEmptyPath(path53))
87554
87593
  return this.contents !== void 0;
87555
- return identity2.isCollection(this.contents) ? this.contents.hasIn(path52) : false;
87594
+ return identity2.isCollection(this.contents) ? this.contents.hasIn(path53) : false;
87556
87595
  }
87557
87596
  /**
87558
87597
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -87569,13 +87608,13 @@ var require_Document = __commonJS({
87569
87608
  * Sets a value in this document. For `!!set`, `value` needs to be a
87570
87609
  * boolean to add/remove the item from the set.
87571
87610
  */
87572
- setIn(path52, value) {
87573
- if (Collection.isEmptyPath(path52)) {
87611
+ setIn(path53, value) {
87612
+ if (Collection.isEmptyPath(path53)) {
87574
87613
  this.contents = value;
87575
87614
  } else if (this.contents == null) {
87576
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path52), value);
87615
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path53), value);
87577
87616
  } else if (assertCollection(this.contents)) {
87578
- this.contents.setIn(path52, value);
87617
+ this.contents.setIn(path53, value);
87579
87618
  }
87580
87619
  }
87581
87620
  /**
@@ -89535,9 +89574,9 @@ var require_cst_visit = __commonJS({
89535
89574
  visit.BREAK = BREAK;
89536
89575
  visit.SKIP = SKIP;
89537
89576
  visit.REMOVE = REMOVE;
89538
- visit.itemAtPath = (cst, path52) => {
89577
+ visit.itemAtPath = (cst, path53) => {
89539
89578
  let item = cst;
89540
- for (const [field, index] of path52) {
89579
+ for (const [field, index] of path53) {
89541
89580
  const tok = item?.[field];
89542
89581
  if (tok && "items" in tok) {
89543
89582
  item = tok.items[index];
@@ -89546,23 +89585,23 @@ var require_cst_visit = __commonJS({
89546
89585
  }
89547
89586
  return item;
89548
89587
  };
89549
- visit.parentCollection = (cst, path52) => {
89550
- const parent = visit.itemAtPath(cst, path52.slice(0, -1));
89551
- const field = path52[path52.length - 1][0];
89588
+ visit.parentCollection = (cst, path53) => {
89589
+ const parent = visit.itemAtPath(cst, path53.slice(0, -1));
89590
+ const field = path53[path53.length - 1][0];
89552
89591
  const coll = parent?.[field];
89553
89592
  if (coll && "items" in coll)
89554
89593
  return coll;
89555
89594
  throw new Error("Parent collection not found");
89556
89595
  };
89557
- function _visit(path52, item, visitor) {
89558
- let ctrl = visitor(item, path52);
89596
+ function _visit(path53, item, visitor) {
89597
+ let ctrl = visitor(item, path53);
89559
89598
  if (typeof ctrl === "symbol")
89560
89599
  return ctrl;
89561
89600
  for (const field of ["key", "value"]) {
89562
89601
  const token = item[field];
89563
89602
  if (token && "items" in token) {
89564
89603
  for (let i = 0; i < token.items.length; ++i) {
89565
- const ci = _visit(Object.freeze(path52.concat([[field, i]])), token.items[i], visitor);
89604
+ const ci = _visit(Object.freeze(path53.concat([[field, i]])), token.items[i], visitor);
89566
89605
  if (typeof ci === "number")
89567
89606
  i = ci - 1;
89568
89607
  else if (ci === BREAK)
@@ -89573,10 +89612,10 @@ var require_cst_visit = __commonJS({
89573
89612
  }
89574
89613
  }
89575
89614
  if (typeof ctrl === "function" && field === "key")
89576
- ctrl = ctrl(item, path52);
89615
+ ctrl = ctrl(item, path53);
89577
89616
  }
89578
89617
  }
89579
- return typeof ctrl === "function" ? ctrl(item, path52) : ctrl;
89618
+ return typeof ctrl === "function" ? ctrl(item, path53) : ctrl;
89580
89619
  }
89581
89620
  exports2.visit = visit;
89582
89621
  }
@@ -91334,7 +91373,7 @@ __export(index_exports, {
91334
91373
  start: () => start
91335
91374
  });
91336
91375
  module.exports = __toCommonJS(index_exports);
91337
- var path51 = __toESM(require("node:path"));
91376
+ var path52 = __toESM(require("node:path"));
91338
91377
  var import_node_os14 = require("node:os");
91339
91378
  init_src();
91340
91379
  init_src2();
@@ -93783,7 +93822,7 @@ function appendRootPathToUrlIfNeeded(url2) {
93783
93822
  return void 0;
93784
93823
  }
93785
93824
  }
93786
- function appendResourcePathToUrl(url2, path52) {
93825
+ function appendResourcePathToUrl(url2, path53) {
93787
93826
  try {
93788
93827
  new URL(url2);
93789
93828
  } catch {
@@ -93793,11 +93832,11 @@ function appendResourcePathToUrl(url2, path52) {
93793
93832
  if (!url2.endsWith("/")) {
93794
93833
  url2 = url2 + "/";
93795
93834
  }
93796
- url2 += path52;
93835
+ url2 += path53;
93797
93836
  try {
93798
93837
  new URL(url2);
93799
93838
  } catch {
93800
- diag2.warn(`Configuration: Provided URL appended with '${path52}' is not a valid URL, using 'undefined' instead of '${url2}'`);
93839
+ diag2.warn(`Configuration: Provided URL appended with '${path53}' is not a valid URL, using 'undefined' instead of '${url2}'`);
93801
93840
  return void 0;
93802
93841
  }
93803
93842
  return url2;
@@ -94458,9 +94497,9 @@ function isReplitAgent(env) {
94458
94497
  }
94459
94498
  var DEVIN_MARKER_PATH = "/opt/.devin";
94460
94499
  var JULES_MARKER_PATH = "/opt/environment_summary.sh";
94461
- function safeExists(fileExists, path52) {
94500
+ function safeExists(fileExists, path53) {
94462
94501
  try {
94463
- return fileExists(path52);
94502
+ return fileExists(path53);
94464
94503
  } catch {
94465
94504
  return false;
94466
94505
  }
@@ -94881,7 +94920,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
94881
94920
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
94882
94921
  function readCliVersion() {
94883
94922
  if (true) {
94884
- return "0.27.1-next.21";
94923
+ return "0.27.1-next.23";
94885
94924
  }
94886
94925
  return "0.0.0";
94887
94926
  }
@@ -95844,18 +95883,18 @@ async function resolveVegaBinary() {
95844
95883
  }
95845
95884
  const onPath = await commandOnPath("vega") ?? await commandOnPath("kepler");
95846
95885
  const fallback = (0, import_node_path5.join)((0, import_node_os3.homedir)(), "vega", "bin", "vega");
95847
- const path52 = onPath ?? (await isExecutable(fallback) ? fallback : null);
95848
- cachedVegaBinary = { path: path52, checkedAt: now };
95849
- return path52;
95886
+ const path53 = onPath ?? (await isExecutable(fallback) ? fallback : null);
95887
+ cachedVegaBinary = { path: path53, checkedAt: now };
95888
+ return path53;
95850
95889
  }
95851
95890
  async function resolveVegaOrThrow() {
95852
- const path52 = await resolveVegaBinary();
95853
- if (!path52) {
95891
+ const path53 = await resolveVegaBinary();
95892
+ if (!path53) {
95854
95893
  throw new Error(
95855
95894
  "`vega` (or `kepler`) not found on PATH or under `~/vega/bin`. Install the Vega SDK and run `source ~/vega/env`, then retry."
95856
95895
  );
95857
95896
  }
95858
- return path52;
95897
+ return path53;
95859
95898
  }
95860
95899
  var VEGA_KILL_SIGNAL = "SIGKILL";
95861
95900
  async function reapVegaGroup(child) {
@@ -98363,50 +98402,50 @@ function from(...paths) {
98363
98402
  const joined = paths.join("/");
98364
98403
  return joined.replace(/\/+/g, "/").replace(/^\/+/, "").replace(/\/+$/, "");
98365
98404
  }
98366
- function parts(path52) {
98367
- return path52 === "" ? [] : path52.split("/");
98405
+ function parts(path53) {
98406
+ return path53 === "" ? [] : path53.split("/");
98368
98407
  }
98369
98408
  function decode3(raw) {
98370
- const path52 = from(raw);
98371
- return encode3(path52);
98409
+ const path53 = from(raw);
98410
+ return encode3(path53);
98372
98411
  }
98373
- function encode3(path52) {
98374
- if (parts(path52).length > MAX_PARTS) {
98412
+ function encode3(path53) {
98413
+ if (parts(path53).length > MAX_PARTS) {
98375
98414
  throw new Error(`path exceeds ${MAX_PARTS} parts`);
98376
98415
  }
98377
- return path52;
98416
+ return path53;
98378
98417
  }
98379
- function hasPrefix(prefix, path52) {
98418
+ function hasPrefix(prefix, path53) {
98380
98419
  if (prefix === "") {
98381
98420
  return true;
98382
98421
  }
98383
- if (!path52.startsWith(prefix)) {
98422
+ if (!path53.startsWith(prefix)) {
98384
98423
  return false;
98385
98424
  }
98386
- if (path52.length === prefix.length) {
98425
+ if (path53.length === prefix.length) {
98387
98426
  return true;
98388
98427
  }
98389
- return path52[prefix.length] === "/";
98428
+ return path53[prefix.length] === "/";
98390
98429
  }
98391
- function stripPrefix(prefix, path52) {
98392
- if (!hasPrefix(prefix, path52)) {
98430
+ function stripPrefix(prefix, path53) {
98431
+ if (!hasPrefix(prefix, path53)) {
98393
98432
  return null;
98394
98433
  }
98395
98434
  if (prefix === "") {
98396
- return path52;
98435
+ return path53;
98397
98436
  }
98398
- if (path52.length === prefix.length) {
98437
+ if (path53.length === prefix.length) {
98399
98438
  return "";
98400
98439
  }
98401
- return path52.slice(prefix.length + 1);
98440
+ return path53.slice(prefix.length + 1);
98402
98441
  }
98403
- function join13(path52, other) {
98404
- if (path52 === "") {
98442
+ function join13(path53, other) {
98443
+ if (path53 === "") {
98405
98444
  return other;
98406
98445
  } else if (other === "") {
98407
- return path52;
98446
+ return path53;
98408
98447
  } else {
98409
- return `${path52}/${other}`;
98448
+ return `${path53}/${other}`;
98410
98449
  }
98411
98450
  }
98412
98451
  function empty() {
@@ -101711,12 +101750,12 @@ var Publisher = class {
101711
101750
  * Publishes a broadcast with any associated tracks.
101712
101751
  * Opens a bidi stream to send PublishNamespace and waits for response.
101713
101752
  */
101714
- publish(path52, broadcast) {
101715
- this.#broadcasts.set(path52, broadcast);
101716
- this.#notifyConsumers(path52, true);
101717
- void this.#runPublish(path52, broadcast);
101753
+ publish(path53, broadcast) {
101754
+ this.#broadcasts.set(path53, broadcast);
101755
+ this.#notifyConsumers(path53, true);
101756
+ void this.#runPublish(path53, broadcast);
101718
101757
  }
101719
- async #runPublish(path52, broadcast) {
101758
+ async #runPublish(path53, broadcast) {
101720
101759
  try {
101721
101760
  const requestId = await this.#session.nextRequestId();
101722
101761
  if (requestId === void 0)
@@ -101724,7 +101763,7 @@ var Publisher = class {
101724
101763
  const stream = await this.#session.openBi();
101725
101764
  try {
101726
101765
  await stream.writer.u53(PublishNamespace.id);
101727
- const msg = new PublishNamespace({ requestId, trackNamespace: path52 });
101766
+ const msg = new PublishNamespace({ requestId, trackNamespace: path53 });
101728
101767
  await msg.encode(stream.writer, this.#session.version);
101729
101768
  const respTypeId = await stream.reader.u53();
101730
101769
  if (respTypeId === RequestOk.id) {
@@ -101740,7 +101779,7 @@ var Publisher = class {
101740
101779
  if (this.#session.version === Version.DRAFT_14 || this.#session.version === Version.DRAFT_15 || this.#session.version === Version.DRAFT_16) {
101741
101780
  try {
101742
101781
  await stream.writer.u53(PublishNamespaceDone.id);
101743
- const done = new PublishNamespaceDone({ trackNamespace: path52, requestId });
101782
+ const done = new PublishNamespaceDone({ trackNamespace: path53, requestId });
101744
101783
  await done.encode(stream.writer, this.#session.version);
101745
101784
  } catch {
101746
101785
  }
@@ -101752,11 +101791,11 @@ var Publisher = class {
101752
101791
  }
101753
101792
  } catch (err) {
101754
101793
  const e = error51(err);
101755
- console.warn(`announce failed: broadcast=${path52} error=${e.message}`);
101794
+ console.warn(`announce failed: broadcast=${path53} error=${e.message}`);
101756
101795
  } finally {
101757
101796
  broadcast.close();
101758
- this.#broadcasts.delete(path52);
101759
- this.#notifyConsumers(path52, false);
101797
+ this.#broadcasts.delete(path53);
101798
+ this.#notifyConsumers(path53, false);
101760
101799
  }
101761
101800
  }
101762
101801
  /**
@@ -101948,9 +101987,9 @@ var Publisher = class {
101948
101987
  }
101949
101988
  stream.close();
101950
101989
  }
101951
- #notifyConsumers(path52, active) {
101990
+ #notifyConsumers(path53, active) {
101952
101991
  for (const consumer of this.#announcedConsumers) {
101953
- const suffix = stripPrefix(consumer.prefix, path52);
101992
+ const suffix = stripPrefix(consumer.prefix, path53);
101954
101993
  if (suffix === null)
101955
101994
  continue;
101956
101995
  try {
@@ -102079,23 +102118,23 @@ var Subscriber = class {
102079
102118
  const msgType = await stream.reader.u53();
102080
102119
  if (msgType === SubscribeNamespaceEntry.id) {
102081
102120
  const entry = await SubscribeNamespaceEntry.decode(stream.reader, version3);
102082
- const path52 = join13(prefix, entry.suffix);
102083
- console.debug(`announced: broadcast=${path52} active=true`);
102084
- this.#announced.add(path52);
102121
+ const path53 = join13(prefix, entry.suffix);
102122
+ console.debug(`announced: broadcast=${path53} active=true`);
102123
+ this.#announced.add(path53);
102085
102124
  for (const consumer of this.#announcedConsumers) {
102086
- if (!hasPrefix(consumer.prefix, path52))
102125
+ if (!hasPrefix(consumer.prefix, path53))
102087
102126
  continue;
102088
- consumer.append({ path: path52, active: true });
102127
+ consumer.append({ path: path53, active: true });
102089
102128
  }
102090
102129
  } else if (msgType === SubscribeNamespaceEntryDone.id) {
102091
102130
  const entry = await SubscribeNamespaceEntryDone.decode(stream.reader, version3);
102092
- const path52 = join13(prefix, entry.suffix);
102093
- console.debug(`announced: broadcast=${path52} active=false`);
102094
- this.#announced.delete(path52);
102131
+ const path53 = join13(prefix, entry.suffix);
102132
+ console.debug(`announced: broadcast=${path53} active=false`);
102133
+ this.#announced.delete(path53);
102095
102134
  for (const consumer of this.#announcedConsumers) {
102096
- if (!hasPrefix(consumer.prefix, path52))
102135
+ if (!hasPrefix(consumer.prefix, path53))
102097
102136
  continue;
102098
- consumer.append({ path: path52, active: false });
102137
+ consumer.append({ path: path53, active: false });
102099
102138
  }
102100
102139
  } else if (msgType === PublishBlocked.id && version3 === Version.DRAFT_17) {
102101
102140
  const blocked = await PublishBlocked.decode(stream.reader, version3);
@@ -102127,14 +102166,14 @@ var Subscriber = class {
102127
102166
  /**
102128
102167
  * Consumes a broadcast from the connection.
102129
102168
  */
102130
- consume(path52) {
102169
+ consume(path53) {
102131
102170
  const broadcast = new Broadcast();
102132
102171
  void (async () => {
102133
102172
  for (; ; ) {
102134
102173
  const request3 = await broadcast.requested();
102135
102174
  if (!request3)
102136
102175
  break;
102137
- void this.#runSubscribe(path52, request3);
102176
+ void this.#runSubscribe(path53, request3);
102138
102177
  }
102139
102178
  })();
102140
102179
  return broadcast;
@@ -102214,8 +102253,8 @@ var Subscriber = class {
102214
102253
  */
102215
102254
  async runPublishNamespace(msg, stream) {
102216
102255
  const version3 = this.#session.version;
102217
- const path52 = msg.trackNamespace;
102218
- if (this.#announced.has(path52)) {
102256
+ const path53 = msg.trackNamespace;
102257
+ if (this.#announced.has(path53)) {
102219
102258
  console.warn("duplicate PublishNamespace");
102220
102259
  if (version3 === Version.DRAFT_14) {
102221
102260
  await stream.writer.u53(PublishNamespaceError.id);
@@ -102237,7 +102276,7 @@ var Subscriber = class {
102237
102276
  stream.close();
102238
102277
  return;
102239
102278
  }
102240
- this.#announced.add(path52);
102279
+ this.#announced.add(path53);
102241
102280
  try {
102242
102281
  if (version3 === Version.DRAFT_14) {
102243
102282
  await stream.writer.u53(PublishNamespaceOk.id);
@@ -102250,25 +102289,25 @@ var Subscriber = class {
102250
102289
  });
102251
102290
  await ok.encode(stream.writer, version3);
102252
102291
  }
102253
- console.debug(`announced: broadcast=${path52} active=true`);
102292
+ console.debug(`announced: broadcast=${path53} active=true`);
102254
102293
  for (const consumer of this.#announcedConsumers) {
102255
- const suffix = stripPrefix(consumer.prefix, path52);
102294
+ const suffix = stripPrefix(consumer.prefix, path53);
102256
102295
  if (suffix === null)
102257
102296
  continue;
102258
- consumer.append({ path: path52, active: true });
102297
+ consumer.append({ path: path53, active: true });
102259
102298
  }
102260
- console.debug(`runPublishNamespace: awaiting stream.reader.closed for ${path52}`);
102299
+ console.debug(`runPublishNamespace: awaiting stream.reader.closed for ${path53}`);
102261
102300
  await stream.reader.closed;
102262
- console.debug(`runPublishNamespace: stream.reader.closed resolved for ${path52}`);
102301
+ console.debug(`runPublishNamespace: stream.reader.closed resolved for ${path53}`);
102263
102302
  } finally {
102264
- this.#announced.delete(path52);
102265
- console.debug(`announced: broadcast=${path52} active=false`);
102303
+ this.#announced.delete(path53);
102304
+ console.debug(`announced: broadcast=${path53} active=false`);
102266
102305
  for (const consumer of this.#announcedConsumers) {
102267
- const suffix = stripPrefix(consumer.prefix, path52);
102306
+ const suffix = stripPrefix(consumer.prefix, path53);
102268
102307
  if (suffix === null)
102269
102308
  continue;
102270
102309
  try {
102271
- consumer.append({ path: path52, active: false });
102310
+ consumer.append({ path: path53, active: false });
102272
102311
  } catch {
102273
102312
  }
102274
102313
  }
@@ -102407,8 +102446,8 @@ var Connection = class {
102407
102446
  * @param name - The broadcast path to publish
102408
102447
  * @param broadcast - The broadcast to publish
102409
102448
  */
102410
- publish(path52, broadcast) {
102411
- this.#publisher.publish(path52, broadcast);
102449
+ publish(path53, broadcast) {
102450
+ this.#publisher.publish(path53, broadcast);
102412
102451
  }
102413
102452
  /**
102414
102453
  * Gets an announced reader for the specified prefix.
@@ -102920,8 +102959,8 @@ var AnnounceInit = class _AnnounceInit {
102920
102959
  }
102921
102960
  async #encode(w) {
102922
102961
  await w.u53(this.suffixes.length);
102923
- for (const path52 of this.suffixes) {
102924
- await w.string(encode3(path52));
102962
+ for (const path53 of this.suffixes) {
102963
+ await w.string(encode3(path53));
102925
102964
  }
102926
102965
  }
102927
102966
  static async #decode(r) {
@@ -103475,15 +103514,15 @@ var Publisher2 = class {
103475
103514
  * Publishes a broadcast with any associated tracks.
103476
103515
  * @param name - The broadcast to publish
103477
103516
  */
103478
- publish(path52, broadcast) {
103517
+ publish(path53, broadcast) {
103479
103518
  this.#broadcasts.mutate((broadcasts) => {
103480
103519
  if (!broadcasts)
103481
103520
  throw new Error("closed");
103482
- broadcasts.set(path52, broadcast);
103521
+ broadcasts.set(path53, broadcast);
103483
103522
  });
103484
103523
  void broadcast.closed.finally(() => {
103485
103524
  this.#broadcasts.mutate((broadcasts) => {
103486
- broadcasts?.delete(path52);
103525
+ broadcasts?.delete(path53);
103487
103526
  });
103488
103527
  });
103489
103528
  }
@@ -103803,16 +103842,16 @@ var Setup2 = class _Setup {
103803
103842
  }
103804
103843
  static async #decode(r) {
103805
103844
  const count2 = await r.u53();
103806
- let path52;
103845
+ let path53;
103807
103846
  for (let i = 0; i < count2; i++) {
103808
103847
  const id = await r.u53();
103809
103848
  const len = await r.u53();
103810
103849
  const value = await r.read(len);
103811
103850
  if (id === PARAM_PATH) {
103812
- path52 = new TextDecoder().decode(value);
103851
+ path53 = new TextDecoder().decode(value);
103813
103852
  }
103814
103853
  }
103815
- return new _Setup({ path: path52 });
103854
+ return new _Setup({ path: path53 });
103816
103855
  }
103817
103856
  async encode(w, version3) {
103818
103857
  if (!hasSetupStream(version3))
@@ -103902,9 +103941,9 @@ var Subscriber2 = class {
103902
103941
  case Version2.DRAFT_02: {
103903
103942
  const init2 = await AnnounceInit.decode(stream.reader, this.version);
103904
103943
  for (const suffix of init2.suffixes) {
103905
- const path52 = join13(prefix, suffix);
103906
- console.debug(`announced: broadcast=${path52} active=true`);
103907
- announced2.append({ path: path52, active: true });
103944
+ const path53 = join13(prefix, suffix);
103945
+ console.debug(`announced: broadcast=${path53} active=true`);
103946
+ announced2.append({ path: path53, active: true });
103908
103947
  }
103909
103948
  break;
103910
103949
  }
@@ -103923,9 +103962,9 @@ var Subscriber2 = class {
103923
103962
  if (options.ignoreSelf && announce.hops.includes(this.origin)) {
103924
103963
  continue;
103925
103964
  }
103926
- const path52 = join13(prefix, announce.suffix);
103927
- console.debug(`announced: broadcast=${path52} active=${announce.active}`);
103928
- announced2.append({ path: path52, active: announce.active });
103965
+ const path53 = join13(prefix, announce.suffix);
103966
+ console.debug(`announced: broadcast=${path53} active=${announce.active}`);
103967
+ announced2.append({ path: path53, active: announce.active });
103929
103968
  }
103930
103969
  announced2.close();
103931
103970
  } catch (err) {
@@ -103938,14 +103977,14 @@ var Subscriber2 = class {
103938
103977
  * @param name - The name of the broadcast to consume
103939
103978
  * @returns A Broadcast instance
103940
103979
  */
103941
- consume(path52) {
103980
+ consume(path53) {
103942
103981
  const broadcast = new Broadcast();
103943
103982
  void (async () => {
103944
103983
  for (; ; ) {
103945
103984
  const request3 = await broadcast.requested();
103946
103985
  if (!request3)
103947
103986
  break;
103948
- void this.#runSubscribe(path52, request3);
103987
+ void this.#runSubscribe(path53, request3);
103949
103988
  }
103950
103989
  })();
103951
103990
  return broadcast;
@@ -104202,8 +104241,8 @@ var Connection2 = class {
104202
104241
  this.close();
104203
104242
  }
104204
104243
  }
104205
- publish(path52, broadcast) {
104206
- this.#publisher.publish(path52, broadcast);
104244
+ publish(path53, broadcast) {
104245
+ this.#publisher.publish(path53, broadcast);
104207
104246
  }
104208
104247
  announced(prefix = empty()) {
104209
104248
  return this.#subscriber.announced(prefix);
@@ -115019,7 +115058,7 @@ async function resolveMembers(members, tempDirs, lookupUpload) {
115019
115058
  for (const raw of members) {
115020
115059
  if (typeof raw !== "object" || raw === null) continue;
115021
115060
  const member = raw;
115022
- if (member.role !== "flow" && member.role !== "baseline" || typeof member.key !== "string" || Object.hasOwn(out, member.key)) {
115061
+ if (member.role !== "flow" && member.role !== "baseline" && member.role !== "tool" || typeof member.key !== "string" || Object.hasOwn(out, member.key)) {
115023
115062
  continue;
115024
115063
  }
115025
115064
  const flow = member.role === "flow";
@@ -115058,6 +115097,9 @@ async function resolveOne(spec, wire, tempDirs, lookupUpload) {
115058
115097
  ...probe3.statVerified ? { statVerified: true } : {}
115059
115098
  };
115060
115099
  if (spec.kind === "probe") {
115100
+ if (spec.collect === "step" && Array.isArray(wire.members)) {
115101
+ meta3.members = await resolveMembers(wire.members, tempDirs, lookupUpload);
115102
+ }
115061
115103
  return { value: wire.path, meta: meta3 };
115062
115104
  }
115063
115105
  if (spec.kind === "tar-upload") {
@@ -115159,8 +115201,8 @@ async function resolveFileInputs(def, body, lookupUpload) {
115159
115201
  delete args[spec.target];
115160
115202
  continue;
115161
115203
  }
115162
- const { value: path52, meta: meta3 } = await resolveOne(spec, value, tempDirs, lookupUpload);
115163
- args[spec.target] = path52;
115204
+ const { value: path53, meta: meta3 } = await resolveOne(spec, value, tempDirs, lookupUpload);
115205
+ args[spec.target] = path53;
115164
115206
  resolved = { ...resolved ?? {}, [spec.target]: meta3 };
115165
115207
  }
115166
115208
  } catch (err) {
@@ -116031,6 +116073,10 @@ function createHttpApp(registry2, options) {
116031
116073
  const data = await registry2.invokeTool(name, parsedData, {
116032
116074
  signal: controller.signal,
116033
116075
  ...resolvedFileInputs ? { fileInputs: resolvedFileInputs } : {},
116076
+ // The argent client marks every call it sends over a link. A false
116077
+ // mark makes the recorder stricter for that caller and keeps its
116078
+ // recording in memory, sent back in client-file directives.
116079
+ ...firstHeader(req.headers[LINKED_CALL_HEADER]) === "1" ? { linked: true } : {},
116034
116080
  toolInvocationId,
116035
116081
  ...recordChildInvocation ? { recordChildInvocation } : {},
116036
116082
  ...wantsStream ? { emitProgress: (event2) => writeLine({ event: "progress", data: event2 }) } : {}
@@ -123752,10 +123798,10 @@ function captureRotationForSurface(rotation) {
123752
123798
  if (rotation === null || rotation === 0) return void 0;
123753
123799
  return SURFACE_ROTATION_TO_NAME[rotation];
123754
123800
  }
123755
- async function readPngSize2(path52) {
123801
+ async function readPngSize2(path53) {
123756
123802
  let handle;
123757
123803
  try {
123758
- handle = await import_node_fs13.promises.open(path52, "r");
123804
+ handle = await import_node_fs13.promises.open(path53, "r");
123759
123805
  const buf = Buffer.alloc(24);
123760
123806
  const { bytesRead } = await handle.read(buf, 0, 24, 0);
123761
123807
  if (bytesRead < 24) return null;
@@ -127049,11 +127095,16 @@ init_device_info();
127049
127095
  // ../tool-server/src/utils/sub-invoke.ts
127050
127096
  var import_node_crypto11 = require("node:crypto");
127051
127097
  init_src2();
127052
- async function invokeSubTool(registry2, ctx, toolId, args) {
127098
+ async function invokeSubTool(registry2, ctx, toolId, args, extra) {
127053
127099
  const signal = ctx?.signal;
127054
127100
  const recordChildInvocation = ctx?.recordChildInvocation;
127101
+ const flowStack = extra?.flowStack ?? ctx?.flowStack;
127102
+ const forwarded = {
127103
+ ...extra?.fileInputs ? { fileInputs: extra.fileInputs } : {},
127104
+ ...flowStack ? { flowStack } : {}
127105
+ };
127055
127106
  if (!recordChildInvocation) {
127056
- return signal ? registry2.invokeTool(toolId, args, { signal }) : registry2.invokeTool(toolId, args);
127107
+ return signal || Object.keys(forwarded).length > 0 ? registry2.invokeTool(toolId, args, { ...signal ? { signal } : {}, ...forwarded }) : registry2.invokeTool(toolId, args);
127057
127108
  }
127058
127109
  const toolInvocationId = (0, import_node_crypto11.randomUUID)();
127059
127110
  const release = recordChildInvocation(toolInvocationId, args);
@@ -127061,7 +127112,8 @@ async function invokeSubTool(registry2, ctx, toolId, args) {
127061
127112
  return await registry2.invokeTool(toolId, args, {
127062
127113
  signal,
127063
127114
  toolInvocationId,
127064
- recordChildInvocation
127115
+ recordChildInvocation,
127116
+ ...forwarded
127065
127117
  });
127066
127118
  } finally {
127067
127119
  release();
@@ -127752,13 +127804,13 @@ async function fetchVegaPageSource(timeoutMs = 15e3) {
127752
127804
  });
127753
127805
  }
127754
127806
  }
127755
- function postJson(host, port, path52, body, timeoutMs) {
127807
+ function postJson(host, port, path53, body, timeoutMs) {
127756
127808
  return new Promise((resolve14, reject) => {
127757
127809
  const req = (0, import_node_http3.request)(
127758
127810
  {
127759
127811
  host,
127760
127812
  port,
127761
- path: path52,
127813
+ path: path53,
127762
127814
  method: "POST",
127763
127815
  headers: {
127764
127816
  "Content-Type": "application/json",
@@ -130856,16 +130908,16 @@ var MatcherView = class {
130856
130908
  * @returns {string|undefined}
130857
130909
  */
130858
130910
  getCurrentTag() {
130859
- const path52 = this._matcher.path;
130860
- return path52.length > 0 ? path52[path52.length - 1].tag : void 0;
130911
+ const path53 = this._matcher.path;
130912
+ return path53.length > 0 ? path53[path53.length - 1].tag : void 0;
130861
130913
  }
130862
130914
  /**
130863
130915
  * Get current namespace.
130864
130916
  * @returns {string|undefined}
130865
130917
  */
130866
130918
  getCurrentNamespace() {
130867
- const path52 = this._matcher.path;
130868
- return path52.length > 0 ? path52[path52.length - 1].namespace : void 0;
130919
+ const path53 = this._matcher.path;
130920
+ return path53.length > 0 ? path53[path53.length - 1].namespace : void 0;
130869
130921
  }
130870
130922
  /**
130871
130923
  * Get current node's attribute value.
@@ -130873,9 +130925,9 @@ var MatcherView = class {
130873
130925
  * @returns {*}
130874
130926
  */
130875
130927
  getAttrValue(attrName) {
130876
- const path52 = this._matcher.path;
130877
- if (path52.length === 0) return void 0;
130878
- return path52[path52.length - 1].values?.[attrName];
130928
+ const path53 = this._matcher.path;
130929
+ if (path53.length === 0) return void 0;
130930
+ return path53[path53.length - 1].values?.[attrName];
130879
130931
  }
130880
130932
  /**
130881
130933
  * Check if current node has an attribute.
@@ -130883,9 +130935,9 @@ var MatcherView = class {
130883
130935
  * @returns {boolean}
130884
130936
  */
130885
130937
  hasAttr(attrName) {
130886
- const path52 = this._matcher.path;
130887
- if (path52.length === 0) return false;
130888
- const current = path52[path52.length - 1];
130938
+ const path53 = this._matcher.path;
130939
+ if (path53.length === 0) return false;
130940
+ const current = path53[path53.length - 1];
130889
130941
  return current.values !== void 0 && attrName in current.values;
130890
130942
  }
130891
130943
  /**
@@ -130893,18 +130945,18 @@ var MatcherView = class {
130893
130945
  * @returns {number}
130894
130946
  */
130895
130947
  getPosition() {
130896
- const path52 = this._matcher.path;
130897
- if (path52.length === 0) return -1;
130898
- return path52[path52.length - 1].position ?? 0;
130948
+ const path53 = this._matcher.path;
130949
+ if (path53.length === 0) return -1;
130950
+ return path53[path53.length - 1].position ?? 0;
130899
130951
  }
130900
130952
  /**
130901
130953
  * Get current node's repeat counter (occurrence count of this tag name).
130902
130954
  * @returns {number}
130903
130955
  */
130904
130956
  getCounter() {
130905
- const path52 = this._matcher.path;
130906
- if (path52.length === 0) return -1;
130907
- return path52[path52.length - 1].counter ?? 0;
130957
+ const path53 = this._matcher.path;
130958
+ if (path53.length === 0) return -1;
130959
+ return path53[path53.length - 1].counter ?? 0;
130908
130960
  }
130909
130961
  /**
130910
130962
  * Get current node's sibling index (alias for getPosition).
@@ -137266,46 +137318,46 @@ var jsonReplacer = (_key, value) => {
137266
137318
  };
137267
137319
  async function writeDump(dir, filename, data) {
137268
137320
  try {
137269
- const path52 = (0, import_path2.join)(dir, filename);
137321
+ const path53 = (0, import_path2.join)(dir, filename);
137270
137322
  const json2 = JSON.stringify(data, jsonReplacer, 2);
137271
- await import_fs.promises.writeFile(path52, json2, "utf8");
137272
- return path52;
137323
+ await import_fs.promises.writeFile(path53, json2, "utf8");
137324
+ return path53;
137273
137325
  } catch {
137274
137326
  return null;
137275
137327
  }
137276
137328
  }
137277
137329
  async function writeDumpCompact(dir, filename, data) {
137278
137330
  try {
137279
- const path52 = (0, import_path2.join)(dir, filename);
137331
+ const path53 = (0, import_path2.join)(dir, filename);
137280
137332
  const json2 = JSON.stringify(data, jsonReplacer);
137281
- await import_fs.promises.writeFile(path52, json2, "utf8");
137282
- return path52;
137333
+ await import_fs.promises.writeFile(path53, json2, "utf8");
137334
+ return path53;
137283
137335
  } catch {
137284
137336
  return null;
137285
137337
  }
137286
137338
  }
137287
- async function readCpuProfile(path52) {
137288
- const json2 = await import_fs.promises.readFile(path52, "utf8");
137339
+ async function readCpuProfile(path53) {
137340
+ const json2 = await import_fs.promises.readFile(path53, "utf8");
137289
137341
  const parsed = JSON.parse(json2);
137290
137342
  if (!parsed || typeof parsed !== "object") {
137291
137343
  throw new Error(
137292
- `On-disk CPU profile at ${path52} is missing or not an object. The session dump is corrupt or was written by an incompatible tool-server version; rerun react-profiler-start/stop to capture a fresh session.`
137344
+ `On-disk CPU profile at ${path53} is missing or not an object. The session dump is corrupt or was written by an incompatible tool-server version; rerun react-profiler-start/stop to capture a fresh session.`
137293
137345
  );
137294
137346
  }
137295
137347
  if (!Array.isArray(parsed.samples) || !Array.isArray(parsed.nodes) || !Array.isArray(parsed.timeDeltas)) {
137296
137348
  throw new Error(
137297
- `On-disk CPU profile at ${path52} is malformed (missing samples/nodes/timeDeltas). The session was likely recorded against a release build where Hermes CPU sampling never started, or the dump was truncated. Rerun react-profiler-start on a dev build and retry.`
137349
+ `On-disk CPU profile at ${path53} is malformed (missing samples/nodes/timeDeltas). The session was likely recorded against a release build where Hermes CPU sampling never started, or the dump was truncated. Rerun react-profiler-start on a dev build and retry.`
137298
137350
  );
137299
137351
  }
137300
137352
  if (typeof parsed.startTime !== "number" || typeof parsed.endTime !== "number") {
137301
137353
  throw new Error(
137302
- `On-disk CPU profile at ${path52} is missing startTime/endTime timestamps; the recording is incomplete and cannot be analysed.`
137354
+ `On-disk CPU profile at ${path53} is missing startTime/endTime timestamps; the recording is incomplete and cannot be analysed.`
137303
137355
  );
137304
137356
  }
137305
137357
  return parsed;
137306
137358
  }
137307
- async function readCommitTree(path52) {
137308
- const json2 = await import_fs.promises.readFile(path52, "utf8");
137359
+ async function readCommitTree(path53) {
137360
+ const json2 = await import_fs.promises.readFile(path53, "utf8");
137309
137361
  return JSON.parse(json2);
137310
137362
  }
137311
137363
 
@@ -137755,9 +137807,9 @@ init_src2();
137755
137807
  var import_fs2 = require("fs");
137756
137808
  var import_path3 = require("path");
137757
137809
  var import_semver4 = __toESM(require_semver2());
137758
- async function readFileSafe(path52) {
137810
+ async function readFileSafe(path53) {
137759
137811
  try {
137760
- return await import_fs2.promises.readFile(path52, "utf8");
137812
+ return await import_fs2.promises.readFile(path53, "utf8");
137761
137813
  } catch {
137762
137814
  return null;
137763
137815
  }
@@ -139234,9 +139286,9 @@ function shortenPath(file2) {
139234
139286
  const parts2 = file2.replace(/\\/g, "/").split("/");
139235
139287
  return parts2.slice(-2).join("/");
139236
139288
  }
139237
- async function writeReport(path52, content) {
139289
+ async function writeReport(path53, content) {
139238
139290
  try {
139239
- await import_fs4.promises.writeFile(path52, content, "utf8");
139291
+ await import_fs4.promises.writeFile(path53, content, "utf8");
139240
139292
  return true;
139241
139293
  } catch {
139242
139294
  return false;
@@ -140483,8 +140535,8 @@ function extractRows(xml) {
140483
140535
  }
140484
140536
  return rows;
140485
140537
  }
140486
- function isSystemLibraryPath(path52) {
140487
- return SYSTEM_LIBRARY_PATH_PREFIXES.some((prefix) => path52.startsWith(prefix));
140538
+ function isSystemLibraryPath(path53) {
140539
+ return SYSTEM_LIBRARY_PATH_PREFIXES.some((prefix) => path53.startsWith(prefix));
140488
140540
  }
140489
140541
  function parseCpuXml(xml, targetPid = null) {
140490
140542
  const frameRegistry = /* @__PURE__ */ new Map();
@@ -147435,6 +147487,21 @@ async function resolveFlowKey(projectRoot, name) {
147435
147487
  return resolving;
147436
147488
  }
147437
147489
  var keyResolutions = /* @__PURE__ */ new Map();
147490
+ function flowNameCasingError(flowName, spelling) {
147491
+ const recovery = spelling.addressable ? `Pass name "${path39.basename(spelling.actual, ".yaml")}".` : `Rename "${spelling.actual}" to "${flowName}.yaml" to run it \u2014 flow files must be lowercase .yaml.`;
147492
+ return new FailureError(
147493
+ `Invalid flow name "${flowName}": no saved flow is named "${flowName}.yaml" \u2014 this filesystem matched it case-insensitively to "${spelling.actual}", so the flow name (which keys the report and __baselines__/) would be one no directory entry carries. ` + recovery,
147494
+ {
147495
+ error_code: FAILURE_CODES.FLOW_NAME_INVALID,
147496
+ failure_stage: "flow_name_casing",
147497
+ failure_area: "tool_server",
147498
+ error_kind: "validation"
147499
+ }
147500
+ );
147501
+ }
147502
+ function isLinkedRecorderCall(session, ctx) {
147503
+ return session.persist === "client" || ctx?.linked === true;
147504
+ }
147438
147505
  var recordings = /* @__PURE__ */ new Map();
147439
147506
  var flowFileLocks = /* @__PURE__ */ new Map();
147440
147507
  async function withFlowLock(key2, fn) {
@@ -148877,9 +148944,9 @@ function* outputReferenceFields(step) {
148877
148944
  case "pinch":
148878
148945
  case "rotate": {
148879
148946
  if (!step.selector) return;
148880
- const { path: path52, alt } = gestureTargetPath(step);
148881
- for (const field of selectorFields(step.selector, path52)) {
148882
- yield alt ? { ...field, altWhere: `${alt}${field.where.slice(path52.length)}` } : field;
148947
+ const { path: path53, alt } = gestureTargetPath(step);
148948
+ for (const field of selectorFields(step.selector, path53)) {
148949
+ yield alt ? { ...field, altWhere: `${alt}${field.where.slice(path53.length)}` } : field;
148883
148950
  }
148884
148951
  return;
148885
148952
  }
@@ -149561,7 +149628,7 @@ var flowStartRecordingTool = {
149561
149628
  description: `Start recording a new flow, resetting .argent/flows/<name>.yaml to an empty flow and replacing any existing one.
149562
149629
  Use when you want to capture a reusable sequence of device interactions for later replay.
149563
149630
  Returns { message, flowFile, savedTo } and optionally { restarted, discardedSteps } if a live recording of the same flow was discarded.
149564
- Whether this server writes that file depends on where your project is: co-located, it creates it and fails if the .argent/flows/ directory cannot be created or the file cannot be written; against a remote tool-server it writes nothing and \`savedTo\` is a directive your client applies (a null \`savedTo\` back means it did not).
149631
+ Without a link, it creates that file and fails if the .argent/flows/ directory cannot be created or the file cannot be written. Over a link (argent link or ARGENT_TOOLS_URL, also to 127.0.0.1), your client writes the file, and \`savedTo\` is its path on your computer, or null when that write failed.
149565
149632
 
149566
149633
  Several flows can be recorded at once \u2014 each keyed by the \`name\` + \`project_root\`
149567
149634
  that every subsequent recording tool repeats \u2014 and one recording's steps never
@@ -149584,10 +149651,10 @@ Call flow-finish-recording when done.
149584
149651
 
149585
149652
  If a recorded step turns out to be wrong, edit the .yaml file directly to
149586
149653
  remove or reorder steps - after flow-finish-recording, not during the
149587
- recording. Against a remote client the in-memory copy is authoritative and
149588
- every write serializes it over your edit; in host mode the recorder re-reads
149589
- the file before each append, so a mid-recording edit renumbers the steps and
149590
- costs the finish the cross-tree verdicts anchored to them.`,
149654
+ recording. Over a link, the next recorded step writes over your edit.
149655
+ Without a link, the recorder reads the file again before each step, but an
149656
+ edit that renumbers the steps drops the warnings that flow-finish-recording
149657
+ reports for those steps.`,
149591
149658
  zodSchema: zodSchema63,
149592
149659
  fileInputs: fileInputs2,
149593
149660
  services: () => ({}),
@@ -149600,7 +149667,7 @@ costs the finish the cross-tree verdicts anchored to them.`,
149600
149667
  validateFlow(flow);
149601
149668
  const flowFile = serializeFlow(flow);
149602
149669
  const probe3 = ctx?.fileInputs?.project_root;
149603
- const persist = probe3 && !probe3.presentOnHost ? "client" : "host";
149670
+ const persist = ctx?.linked || probe3 && !probe3.presentOnHost ? "client" : "host";
149604
149671
  const { savedTo, replaced, discardedSteps } = await withFlowFileLock(
149605
149672
  params.project_root,
149606
149673
  params.name,
@@ -149645,8 +149712,8 @@ costs the finish the cross-tree verdicts anchored to them.`,
149645
149712
 
149646
149713
  // ../tool-server/src/tools/flows/flow-add-step.ts
149647
149714
  init_zod();
149648
- var fs56 = __toESM(require("node:fs/promises"));
149649
- var path41 = __toESM(require("node:path"));
149715
+ var fs57 = __toESM(require("node:fs/promises"));
149716
+ var path43 = __toESM(require("node:path"));
149650
149717
  init_src2();
149651
149718
 
149652
149719
  // ../tool-server/src/tools/flows/flow-actions.ts
@@ -150413,8 +150480,8 @@ async function captureFile(env, budgetMs) {
150413
150480
  const ref = simulatorServerRef(env.device);
150414
150481
  const api = await env.registry.resolveService(ref.urn, ref.options);
150415
150482
  const panel = await resolveCapturePanel(api);
150416
- const { path: path52 } = await httpScreenshot(api, void 0, void 0, CAPTURE_SCALE, panel?.screen);
150417
- return { path: path52, ...panel?.warning !== void 0 ? { warning: panel.warning } : {} };
150483
+ const { path: path53 } = await httpScreenshot(api, void 0, void 0, CAPTURE_SCALE, panel?.screen);
150484
+ return { path: path53, ...panel?.warning !== void 0 ? { warning: panel.warning } : {} };
150418
150485
  }
150419
150486
  async function captureIosDeviceFile(env, budgetMs) {
150420
150487
  const ref = iosDeviceRunnerRef(env.device);
@@ -151476,6 +151543,382 @@ function assertReason(condition, selector, expectedText, textMatch, matches2, or
151476
151543
  }
151477
151544
  }
151478
151545
 
151546
+ // ../tool-server/src/tools/flows/flow-tool-inputs.ts
151547
+ var path42 = __toESM(require("node:path"));
151548
+ init_src2();
151549
+
151550
+ // ../tool-server/src/tools/flows/project-access.ts
151551
+ var fs56 = __toESM(require("node:fs/promises"));
151552
+ var path41 = __toESM(require("node:path"));
151553
+ init_src2();
151554
+ function clientBaselinePath(clientFlowPath, key2, file2) {
151555
+ return path41.posix.join(path41.posix.dirname(clientFlowPath), "__baselines__", key2, file2);
151556
+ }
151557
+ function isEnoent(err) {
151558
+ return err?.code === "ENOENT";
151559
+ }
151560
+ function isNothingThere(err) {
151561
+ return isEnoent(err) || err?.code === "ENOTDIR";
151562
+ }
151563
+ var HostProjectAccess = class {
151564
+ mode = "host";
151565
+ async resolveFlowFile(anchorDir, target) {
151566
+ const { canonical, spelling } = await resolveFlowRelativeFile(
151567
+ anchorDir,
151568
+ target,
151569
+ FLOW_FILE_NAME_PATTERN
151570
+ );
151571
+ return {
151572
+ canonical,
151573
+ spelling,
151574
+ read: async () => {
151575
+ try {
151576
+ return await fs56.readFile(canonical, "utf8");
151577
+ } catch (err) {
151578
+ if (!isEnoent(err)) throw err;
151579
+ return null;
151580
+ }
151581
+ }
151582
+ };
151583
+ }
151584
+ async readFile(filePath) {
151585
+ try {
151586
+ return await fs56.readFile(filePath);
151587
+ } catch (err) {
151588
+ if (!isNothingThere(err)) throw err;
151589
+ return null;
151590
+ }
151591
+ }
151592
+ async writeBaseline(filePath, bytes) {
151593
+ const replaced = await fs56.access(filePath).then(
151594
+ () => true,
151595
+ () => false
151596
+ );
151597
+ await fs56.mkdir(path41.dirname(filePath), { recursive: true });
151598
+ await fs56.writeFile(filePath, bytes);
151599
+ return { replaced };
151600
+ }
151601
+ };
151602
+ var BASELINE_CAP_BYTES = 32 * 1024 * 1024;
151603
+ function clientRefusal(subject2, reason, verb = "send") {
151604
+ return new FailureError(`the client refused to ${verb} "${subject2}": ${reason}`, {
151605
+ error_code: FAILURE_CODES.FLOW_FILE_INVALID,
151606
+ failure_stage: "client_member_refused",
151607
+ failure_area: "tool_server",
151608
+ error_kind: "validation"
151609
+ });
151610
+ }
151611
+ var callOverlays = /* @__PURE__ */ new WeakMap();
151612
+ var ClientProjectAccess = class {
151613
+ constructor(members) {
151614
+ this.members = members;
151615
+ let overlay = callOverlays.get(members);
151616
+ if (overlay === void 0) {
151617
+ overlay = /* @__PURE__ */ new Map();
151618
+ callOverlays.set(members, overlay);
151619
+ }
151620
+ this.overlay = overlay;
151621
+ }
151622
+ members;
151623
+ mode = "client";
151624
+ /** Baselines this call wrote, by client path. */
151625
+ overlay;
151626
+ /** The member the runner reaches for this pair, or undefined when the client did not send one. */
151627
+ member(anchorDir, target) {
151628
+ const key2 = flowMemberKey(anchorDir, target);
151629
+ return Object.hasOwn(this.members, key2) ? this.members[key2] : void 0;
151630
+ }
151631
+ async resolveFlowFile(anchorDir, target) {
151632
+ const member = this.member(anchorDir, target);
151633
+ if (member?.role !== "flow" || member.canonical === void 0) {
151634
+ throw clientRefusal(target, `${target} is not a run: target of a flow this client sent`);
151635
+ }
151636
+ const text = member.state === "present" ? member.text ?? "" : null;
151637
+ return {
151638
+ canonical: member.canonical,
151639
+ spelling: member.spelling ?? { state: "listed" },
151640
+ read: async () => {
151641
+ if (member.state !== "refused") return text;
151642
+ throw clientRefusal(target, member.error ?? "the client did not send it");
151643
+ }
151644
+ };
151645
+ }
151646
+ /**
151647
+ * A file the client sent by its path: a baseline, or a file argument of a
151648
+ * `tool:` step. The client sends one path once, so a tool file at a
151649
+ * baseline's path stands for that baseline too.
151650
+ */
151651
+ file(filePath) {
151652
+ const member = Object.hasOwn(this.members, filePath) ? this.members[filePath] : void 0;
151653
+ return member?.role === "baseline" || member?.role === "tool" ? member : void 0;
151654
+ }
151655
+ /**
151656
+ * A baseline of this run or a file argument of a `tool:` step: the bytes
151657
+ * this call wrote there, else the file the client sent, else null, the "no
151658
+ * baseline" outcome: a compare run gets every baseline of its snapshots the
151659
+ * client has, and every file a `tool:` step names.
151660
+ */
151661
+ async readFile(filePath) {
151662
+ const written = this.overlay.get(filePath);
151663
+ if (written !== void 0) return written;
151664
+ const member = this.file(filePath);
151665
+ if (member === void 0 || member.state === "missing") return null;
151666
+ if (member.state === "present" && member.hostPath !== void 0) {
151667
+ return fs56.readFile(member.hostPath);
151668
+ }
151669
+ throw clientRefusal(
151670
+ filePath,
151671
+ member.error ?? "the client sent only its name, for a run that updates baselines"
151672
+ );
151673
+ }
151674
+ /**
151675
+ * Keep a new baseline for the result and for later reads in this call.
151676
+ * `replaced` says whether one was there before: written earlier in this
151677
+ * call, or on the client.
151678
+ */
151679
+ async writeBaseline(filePath, bytes) {
151680
+ if (bytes.length > BASELINE_CAP_BYTES) {
151681
+ throw new FailureError(
151682
+ `the baseline for "${filePath}" is larger than the 32 MiB cap on a file the client writes, so this tool-server did not keep it`,
151683
+ {
151684
+ error_code: FAILURE_CODES.FLOW_FILE_INVALID,
151685
+ failure_stage: "client_content_cap",
151686
+ failure_area: "tool_server",
151687
+ error_kind: "validation"
151688
+ }
151689
+ );
151690
+ }
151691
+ const member = this.file(filePath);
151692
+ if (member?.state === "refused") {
151693
+ throw clientRefusal(filePath, member.error ?? "refused", "write");
151694
+ }
151695
+ const replaced = this.overlay.has(filePath) || member !== void 0 && member.state !== "missing";
151696
+ this.overlay.set(filePath, bytes);
151697
+ return { replaced };
151698
+ }
151699
+ /** The baselines this call wrote, last bytes per path, as directives for the result. */
151700
+ baselineDirectives() {
151701
+ return [...this.overlay].map(([filePath, bytes]) => ({
151702
+ [CLIENT_FILE_MARKER]: true,
151703
+ path: filePath,
151704
+ content: bytes.toString("base64"),
151705
+ encoding: "base64"
151706
+ }));
151707
+ }
151708
+ };
151709
+
151710
+ // ../tool-server/src/tools/flows/flow-tool-inputs.ts
151711
+ var UPLOAD_STAGE_BY_KIND = {
151712
+ run: "flow_upload_run_composition",
151713
+ script: "flow_upload_script_step",
151714
+ snapshot: "flow_upload_snapshot_baseline",
151715
+ nested: "flow_upload_nested_flow",
151716
+ toolFile: "flow_upload_tool_file_input",
151717
+ recording: "flow_upload_recording_tool"
151718
+ };
151719
+ function nestedFlowRef(args) {
151720
+ if (typeof args.name === "string") return ` (name: ${args.name})`;
151721
+ if (typeof args.flow_path === "string") return ` (flow_path: ${args.flow_path})`;
151722
+ return "";
151723
+ }
151724
+ function toolStepFilePaths(registry2, tool, args) {
151725
+ return toolStepFiles(registry2.getTool(tool)?.fileInputs, args);
151726
+ }
151727
+ function isFileArgument({ spec }) {
151728
+ return spec.kind === "file" && spec.path === `\${${spec.target}}`;
151729
+ }
151730
+ function servedToolInput(file2, withFiles) {
151731
+ return isClientFileArgument(file2) && withFiles;
151732
+ }
151733
+ function refusedToolInputFix(file2) {
151734
+ if (isClientFileArgument(file2)) return "update";
151735
+ if (!isFileArgument(file2)) return void 0;
151736
+ return path42.posix.isAbsolute(file2.path) ? "extension" : "relative";
151737
+ }
151738
+ function toolStepUploadIssue(registry2, tool, args, withFiles) {
151739
+ if (tool === "flow-execute") {
151740
+ if (withFiles && nestedFlowTarget(args)?.kind === "name") return void 0;
151741
+ return { kind: "nested", line: `tool: flow-execute${nestedFlowRef(args)}`, fixes: [] };
151742
+ }
151743
+ const refused = toolStepFilePaths(registry2, tool, args).filter(
151744
+ (file2) => !servedToolInput(file2, withFiles)
151745
+ );
151746
+ if (refused.length === 0) return void 0;
151747
+ const fixes = /* @__PURE__ */ new Set();
151748
+ for (const file2 of refused) {
151749
+ const fix = refusedToolInputFix(file2);
151750
+ if (fix !== void 0) fixes.add(fix);
151751
+ }
151752
+ return {
151753
+ kind: "toolFile",
151754
+ line: `tool: ${tool} (${refused.map((file2) => file2.path).join(", ")})`,
151755
+ fixes: [...fixes]
151756
+ };
151757
+ }
151758
+ function toolFilePathHints(fixes) {
151759
+ const all = new Set(fixes);
151760
+ return [
151761
+ ...all.has("relative") ? [" Over a link, a tool: step must name a file by an absolute path."] : [],
151762
+ ...all.has("extension") ? [" Over a link, a tool: step can name only a .png or .yaml file."] : []
151763
+ ].join("");
151764
+ }
151765
+ function uploadUpdateHint(items) {
151766
+ return items.length > 0 ? ` This tool-server runs ${items.join(", and ")}. Update the argent CLI or MCP adapter on the client.` : "";
151767
+ }
151768
+ function withClientPaths(prepared, text) {
151769
+ let out = text;
151770
+ for (const [target, input] of Object.entries(prepared.fileInputs ?? {})) {
151771
+ const tempPath = prepared.args[target];
151772
+ if (typeof tempPath === "string" && input.viaUpload) {
151773
+ out = out.split(tempPath).join(input.clientPath);
151774
+ }
151775
+ }
151776
+ return out;
151777
+ }
151778
+ async function prepareToolStepInputs(registry2, project, toolId, args) {
151779
+ if (project instanceof ClientProjectAccess && toolId === "flow-execute") {
151780
+ return prepareNestedFlow(registry2, project, args);
151781
+ }
151782
+ const files = project.mode === "client" ? toolStepFilePaths(registry2, toolId, args).filter(
151783
+ ({ spec }) => spec.unwrapWhenSet === void 0 || args[spec.unwrapWhenSet] === void 0
151784
+ ) : [];
151785
+ if (files.length === 0) return { args, cleanup: async () => {
151786
+ } };
151787
+ const wrapped = { ...args };
151788
+ for (const file2 of files) {
151789
+ if (!isClientFileArgument(file2)) {
151790
+ throw new FileInputError(
151791
+ `"${file2.path}" (argument ${file2.spec.target} of ${toolId}) cannot be read from the client`
151792
+ );
151793
+ }
151794
+ const bytes = await project.readFile(file2.path);
151795
+ if (bytes === null) {
151796
+ throw new FileInputError(
151797
+ `the client has no file at "${file2.path}" (argument ${file2.spec.target} of ${toolId})`
151798
+ );
151799
+ }
151800
+ const wire = {
151801
+ [FILE_INPUT_MARKER]: true,
151802
+ path: file2.path,
151803
+ size: bytes.length,
151804
+ content: bytes.toString("base64")
151805
+ };
151806
+ wrapped[file2.spec.target] = wire;
151807
+ }
151808
+ const resolved = await resolveFileInputs({ fileInputs: files.map((f) => f.spec) }, wrapped);
151809
+ return {
151810
+ args: resolved.args,
151811
+ ...resolved.fileInputs ? { fileInputs: resolved.fileInputs } : {},
151812
+ cleanup: resolved.cleanup
151813
+ };
151814
+ }
151815
+ async function prepareNestedFlow(registry2, project, args) {
151816
+ const target = nestedFlowTarget(args);
151817
+ if (target?.kind !== "name") return { args, cleanup: async () => {
151818
+ } };
151819
+ const hop = await project.resolveFlowFile(path42.dirname(target.path), `${target.name}.yaml`);
151820
+ if (hop.spelling.state === "case_folded") throw flowNameCasingError(target.name, hop.spelling);
151821
+ const text = await hop.read();
151822
+ if (text === null) {
151823
+ throw new Error(`ENOENT: no such file or directory, open '${hop.canonical}'`);
151824
+ }
151825
+ const bytes = Buffer.from(text, "utf8");
151826
+ const wire = {
151827
+ [FILE_INPUT_MARKER]: true,
151828
+ path: target.path,
151829
+ size: bytes.length,
151830
+ content: bytes.toString("base64")
151831
+ };
151832
+ const resolved = await resolveFileInputs(
151833
+ { fileInputs: registry2.getTool("flow-execute")?.fileInputs },
151834
+ { ...args, flow_file: wire }
151835
+ );
151836
+ const input = resolved.fileInputs?.flow_file;
151837
+ if (input) {
151838
+ input.canonical = hop.canonical;
151839
+ input.spelling = hop.spelling;
151840
+ input.members = project.members;
151841
+ }
151842
+ return {
151843
+ args: resolved.args,
151844
+ ...resolved.fileInputs ? { fileInputs: resolved.fileInputs } : {},
151845
+ cleanup: resolved.cleanup
151846
+ };
151847
+ }
151848
+
151849
+ // ../tool-server/src/tools/flows/flow-nested-outcome.ts
151850
+ var FLOW_EXECUTE_TOOL_ID = "flow-execute";
151851
+ var RUN_SEQUENCE_TOOL_ID = "run-sequence";
151852
+ function isRecord(value) {
151853
+ return typeof value === "object" && value !== null;
151854
+ }
151855
+ function firstFailingStep(steps) {
151856
+ if (!Array.isArray(steps)) return void 0;
151857
+ for (const entry of steps) {
151858
+ if (!isRecord(entry)) continue;
151859
+ if (entry.status !== "fail" && entry.status !== "error") continue;
151860
+ const what = typeof entry.tool === "string" ? entry.tool : typeof entry.kind === "string" ? entry.kind : "step";
151861
+ const why = typeof entry.reason === "string" ? entry.reason : "no reason given";
151862
+ return `${what}: ${why}`;
151863
+ }
151864
+ return void 0;
151865
+ }
151866
+ function count(value) {
151867
+ return typeof value === "number" ? value : 0;
151868
+ }
151869
+ function flowExecuteOutcome(result) {
151870
+ const flow = typeof result.flow === "string" ? result.flow : "the composed flow";
151871
+ if (!("steps" in result) && typeof result.notice === "string") {
151872
+ const prerequisite = typeof result.executionPrerequisite === "string" && result.executionPrerequisite ? `: ${result.executionPrerequisite}` : "";
151873
+ return {
151874
+ status: "error",
151875
+ reason: `flow "${flow}" did not run \u2014 its execution prerequisite was not acknowledged${prerequisite}. Add prerequisiteAcknowledged: true to the step's args, or compose with run: instead.`
151876
+ };
151877
+ }
151878
+ if (result.aborted === true) {
151879
+ return { status: "skip", reason: `flow "${flow}" was aborted` };
151880
+ }
151881
+ if (result.ok === false) {
151882
+ const detail = firstFailingStep(result.steps);
151883
+ return {
151884
+ status: "fail",
151885
+ reason: `flow "${flow}" failed: ${count(result.passed)} passed, ${count(result.failed)} failed, ${count(result.errored)} errored${detail ? ` (${detail})` : ""}`
151886
+ };
151887
+ }
151888
+ return void 0;
151889
+ }
151890
+ function runSequenceOutcome(result) {
151891
+ const steps = result.steps;
151892
+ if (!Array.isArray(steps)) return void 0;
151893
+ const failed2 = steps.find((s) => isRecord(s) && typeof s.error === "string");
151894
+ if (failed2 && isRecord(failed2)) {
151895
+ const tool = typeof failed2.tool === "string" ? failed2.tool : "step";
151896
+ return {
151897
+ status: "fail",
151898
+ reason: `run-sequence stopped at ${tool} after ${count(result.completed)} of ${count(result.total)} steps: ${String(failed2.error)}`
151899
+ };
151900
+ }
151901
+ const total = count(result.total);
151902
+ if (total > 0 && steps.length < total) {
151903
+ return {
151904
+ status: "skip",
151905
+ reason: `run-sequence was aborted after ${count(result.completed)} of ${total} steps`
151906
+ };
151907
+ }
151908
+ return void 0;
151909
+ }
151910
+ var NESTED_ORCHESTRATORS = /* @__PURE__ */ new Map([
151911
+ [FLOW_EXECUTE_TOOL_ID, flowExecuteOutcome],
151912
+ [RUN_SEQUENCE_TOOL_ID, runSequenceOutcome]
151913
+ ]);
151914
+ function isNestedOrchestratorTool(tool) {
151915
+ return NESTED_ORCHESTRATORS.has(tool);
151916
+ }
151917
+ function nestedOrchestratorOutcome(tool, result) {
151918
+ if (!isRecord(result)) return void 0;
151919
+ return NESTED_ORCHESTRATORS.get(tool)?.(result);
151920
+ }
151921
+
151479
151922
  // ../tool-server/src/tools/flows/flow-step-definitions.ts
151480
151923
  function yamlSelectorLabel(sel) {
151481
151924
  const yaml = selectorToYaml(sel);
@@ -151807,7 +152250,7 @@ function textTieClause(udid) {
151807
152250
  return ` Check FIRST whether the selector matches more than one element, because a \`text\` check reads only one of them \u2014 the first visible match in reading order \u2014 and the two sides can elect DIFFERENT ones from the very same nodes: an exact frame tie is settled by which node its tree listed first, ${order}. The reason above quotes whichever element the RUNNER elected, so compare it against the one you meant. If that is what happened, both trees hold both elements and neither the tree differences nor a changed screen below explains anything \u2014 narrow the selector until it resolves a single node, and note that a longer \`await:\` timeout cannot help, since the text it read is already final.`;
151808
152251
  }
151809
152252
  var SPELLING_CLAUSE = "Both of those are about the selector exactly as recorded, so convert it in the strict map spelling (`{ text: \u2026 }` / `{ id: \u2026 }`, a straight copy of the step's `selector:`): a bare-string conversion (`{ visible: Continue }`) re-parses as a LOOSE selector \u2014 identifier first, text only as a fallback \u2014 which is a different check this probe never made.";
151810
- var UNMET_WAIT_WARNING = "recorded, but the wait itself never held \u2014 `await-ui-element` reports an unmet condition by returning success:false instead of failing, so the step was written to the flow anyway. At replay an unmet wait FAILS the step and stops the run there, so re-record it once the condition can actually hold, and delete the failed step after `flow-finish-recording` rather than mid-recording: against a remote client the in-memory copy is authoritative and the next append writes the step straight back, and in host mode the recorder re-reads the file before each append, so an edit that renumbers the steps costs the finish the verdicts it would otherwise carry. The cross-tree re-probe was skipped: it asks whether a check that PASSED would survive conversion to `await:`/`assert:`, and this one did not pass";
152253
+ var UNMET_WAIT_WARNING = "recorded, but the wait itself never held \u2014 `await-ui-element` reports an unmet condition by returning success:false instead of failing, so the step was written to the flow anyway. At replay an unmet wait FAILS the step and stops the run there, so re-record it once the condition can actually hold, and delete the failed step after `flow-finish-recording` rather than mid-recording: over a link the in-memory copy is authoritative and the next append writes the step straight back, and without a link the recorder re-reads the file before each append, so an edit that renumbers the steps costs the finish the verdicts it would otherwise carry. The cross-tree re-probe was skipped: it asks whether a check that PASSED would survive conversion to `await:`/`assert:`, and this one did not pass";
151811
152254
  var UNREADABLE_WAIT_WARNING = "recorded, but this wait reached its deadline without a trustworthy read of the UI tree, so the condition was never judged \u2014 `await-ui-element` returns success:false for that too, and the step was written to the flow anyway. Either no read in the window could be trusted, or the reads went dark before the end and what they saw no longer describes it. Whether the condition holds is UNKNOWN, not known-bad: `toolResult.note` names the tree-source error where a fetch threw, and describes what was seen where the tree was merely empty or degraded. Get that source back and re-record the step to find out. Do not delete the step on this warning alone. The cross-tree re-probe was skipped: it asks whether a check that PASSED would survive conversion to `await:`/`assert:`, and this one never got an answer";
151812
152255
  var CANCELLED_WAIT_WARNING = "recorded, but this wait was cancelled before its deadline, so the condition was never settled \u2014 `await-ui-element` reports a cancelled wait as success:false, and the step was written to the flow anyway. Whether it holds is UNKNOWN, not known-bad: re-record the step to find out. The cross-tree re-probe was skipped for the same reason";
151813
152256
  function unmetWaitWarningFor(cause) {
@@ -151940,7 +152383,7 @@ async function captureTapSelector(registry2, session, udid, point) {
151940
152383
  async function activeFlowState(session) {
151941
152384
  if (session.persist === "host") {
151942
152385
  try {
151943
- session.flow = parseFlow(await fs56.readFile(session.filePath, "utf8"));
152386
+ session.flow = parseFlow(await fs57.readFile(session.filePath, "utf8"));
151944
152387
  } catch (err) {
151945
152388
  return {
151946
152389
  stepCount: session.flow.steps.length,
@@ -151969,7 +152412,7 @@ var DIRECTIVE_COMMAND_HINTS = {
151969
152412
  run: {
151970
152413
  tool: "flow-execute",
151971
152414
  rewritten: true,
151972
- rewriteCondition: "when the target resolves as a sibling flow in this recording's folder \u2014 a `name` that does not is kept as a raw `tool: flow-execute` step, and so is every target in a REMOTE recording (`run:` composition is host-resolved, so the host cannot validate the client's siblings); a `flow_path` that is not a sibling is refused outright and records nothing"
152415
+ rewriteCondition: "when the target resolves as a sibling flow in this recording's folder, on the computer that has the project; a `name` that does not is kept as a raw `tool: flow-execute` step, and a `flow_path` that is not a sibling is refused outright and records nothing"
151973
152416
  },
151974
152417
  type: { tool: "keyboard", rewritten: false },
151975
152418
  await: { tool: AWAIT_UI_ELEMENT_TOOL_ID, rewritten: false },
@@ -152017,7 +152460,7 @@ function directiveCommandHint(command) {
152017
152460
  return `"${command}" is a flow directive, not a tool. Record it by calling \`${hint.tool}\` through flow-add-step` + (hint.rewritten ? ` \u2014 the recorder rewrites it into the \`${command}:\` step ${hint.rewriteCondition ?? "for you"}. Where the call is recorded at all, a \`delayMs\` on it opts out of the rewrite: the step is then kept in its raw \`tool: ${hint.tool}\` form (a replay delay has no directive form), so leave \`delayMs\` off if you want the \`${command}:\` step.` : `. It is stored as a raw \`tool: ${hint.tool}\` step; converting it to \`${command}:\` is part of the polish pass.`);
152018
152461
  }
152019
152462
  var RUN_TARGET_COMMAND = "flow-execute";
152020
- async function rewriteSiblingFlowPath(session, args) {
152463
+ async function rewriteSiblingFlowPath(session, args, project, linked) {
152021
152464
  const flowPath = args.flow_path;
152022
152465
  if (typeof flowPath !== "string" || args.name !== void 0) return;
152023
152466
  const invalid = (detail) => new FailureError(
@@ -152029,42 +152472,48 @@ async function rewriteSiblingFlowPath(session, args) {
152029
152472
  error_kind: "validation"
152030
152473
  }
152031
152474
  );
152032
- if (!session || session.persist !== "host") {
152033
- throw invalid(
152034
- "the recording is not persisted on this host, so its siblings cannot be resolved here"
152035
- );
152036
- }
152037
152475
  if (flowPath.split(/[\\/]+/).includes("..")) {
152038
152476
  throw invalid(
152039
152477
  'flow paths must not contain ".." segments \u2014 sibling identity is decided lexically from this path, and a symlinked directory component would make the rewrite run a different file than the path opens'
152040
152478
  );
152041
152479
  }
152042
- const ext = path41.extname(flowPath);
152043
- const bareExtension = path41.basename(flowPath).toLowerCase() === ".yaml";
152480
+ const ext = path43.extname(flowPath);
152481
+ const bareExtension = path43.basename(flowPath).toLowerCase() === ".yaml";
152044
152482
  if (!bareExtension && ext !== ".yaml") {
152045
152483
  throw invalid(
152046
152484
  ext.toLowerCase() === ".yaml" ? `flow files must use the lowercase .yaml extension, not "${ext}"` : "flow files must use the .yaml extension"
152047
152485
  );
152048
152486
  }
152049
- const flowsDir = path41.dirname(session.filePath);
152050
- if (path41.resolve(path41.dirname(flowPath)) !== path41.resolve(flowsDir)) {
152487
+ const flowsDir = path43.dirname(session.filePath);
152488
+ if (path43.resolve(path43.dirname(flowPath)) !== path43.resolve(flowsDir)) {
152051
152489
  throw invalid(
152052
152490
  `it is not in the recording's flow directory ("${flowsDir}"), and a raw tool: step has no boundary to resolve a path through at replay`
152053
152491
  );
152054
152492
  }
152055
- const stem = bareExtension ? "" : path41.basename(flowPath, ".yaml");
152493
+ const stem = bareExtension ? "" : path43.basename(flowPath, ".yaml");
152056
152494
  assertSafeFlowName(stem);
152057
152495
  const projectRoot = args.project_root;
152058
- if (typeof projectRoot !== "string" || !path41.isAbsolute(projectRoot)) {
152496
+ if (typeof projectRoot !== "string" || !path43.isAbsolute(projectRoot)) {
152059
152497
  throw invalid(
152060
152498
  `project_root must be an absolute path (got ${typeof projectRoot === "string" ? `"${projectRoot}"` : "none"}) \u2014 a relative root would be resolved against the tool server's cwd, not the calling agent's`
152061
152499
  );
152062
152500
  }
152063
- if (path41.resolve(flowsDirFor(projectRoot), `${stem}.yaml`) !== path41.resolve(flowPath)) {
152501
+ if (path43.resolve(flowsDirFor(projectRoot), `${stem}.yaml`) !== path43.resolve(flowPath)) {
152064
152502
  throw invalid(`project_root "${projectRoot}" does not resolve "${stem}" to it`);
152065
152503
  }
152066
- const suppliedBase = path41.basename(flowPath);
152067
- const spelling = await classifyOnDiskSpelling(flowsDir, suppliedBase);
152504
+ const suppliedBase = path43.basename(flowPath);
152505
+ if (linked && project.mode === "host") {
152506
+ throw new FailureError(
152507
+ `Cannot record a flow-execute of flow_path "${flowPath}": the argent client sent no files with this call, so the recorder cannot check that the file is a sibling of the recording. Update the argent CLI or MCP adapter on the client.`,
152508
+ {
152509
+ error_code: FAILURE_CODES.FLOW_FILE_INVALID,
152510
+ failure_stage: "flow_add_step_flow_path",
152511
+ failure_area: "tool_server",
152512
+ error_kind: "validation"
152513
+ }
152514
+ );
152515
+ }
152516
+ const { spelling } = await project.resolveFlowFile(flowsDir, suppliedBase);
152068
152517
  if (spelling.state !== "listed") {
152069
152518
  const recovery = spelling.state === "absent" ? `pass the basename exactly as it appears on disk` : spelling.addressable ? `pass flow_path with the on-disk basename "${spelling.actual}"` : `rename "${spelling.actual}" to "${suppliedBase}" to record it \u2014 flow files must be lowercase .yaml`;
152070
152519
  throw invalid(
@@ -152074,49 +152523,45 @@ async function rewriteSiblingFlowPath(session, args) {
152074
152523
  delete args.flow_path;
152075
152524
  args.name = stem;
152076
152525
  }
152077
- async function captureRunTarget(session, args) {
152526
+ async function captureRunTarget(session, args, project) {
152078
152527
  const name = typeof args.name === "string" ? args.name : void 0;
152079
152528
  if (name === void 0) {
152080
152529
  return { warning: "flow-execute call had no flow name; kept the raw step" };
152081
152530
  }
152082
- if (session.persist !== "host") {
152083
- return {
152084
- warning: `kept the raw flow-execute step \u2014 run: composition is host-resolved, so a remote recording can't reference "${name}" portably`
152085
- };
152086
- }
152087
152531
  try {
152088
152532
  assertSafeFlowName(name);
152089
- const realFlowPath = await fs56.realpath(session.filePath);
152090
- const flowsDir = path41.dirname(realFlowPath);
152091
- const fragPath = path41.join(flowsDir, `${name}.yaml`);
152092
152533
  const projectRoot = args.project_root;
152093
- if (typeof projectRoot !== "string" || !path41.isAbsolute(projectRoot)) {
152534
+ if (typeof projectRoot !== "string" || !path43.isAbsolute(projectRoot)) {
152094
152535
  return {
152095
152536
  warning: `kept the raw flow-execute step \u2014 project_root must be an absolute path (got ${typeof projectRoot === "string" ? `"${projectRoot}"` : "none"}) to confirm "${name}" names the recording's own sibling`
152096
152537
  };
152097
152538
  }
152098
- const spelling = await classifyOnDiskSpelling(flowsDir, `${name}.yaml`);
152539
+ const self2 = await project.resolveFlowFile(
152540
+ path43.dirname(session.filePath),
152541
+ path43.basename(session.filePath)
152542
+ );
152543
+ const flowsDir = path43.dirname(self2.canonical);
152544
+ const fragPath = path43.join(flowsDir, `${name}.yaml`);
152545
+ const sibling = await project.resolveFlowFile(flowsDir, `${name}.yaml`);
152546
+ const spelling = sibling.spelling;
152099
152547
  if (spelling.state === "case_folded") {
152100
- const recovery = spelling.addressable ? `re-run it as name "${path41.basename(spelling.actual, ".yaml")}" to record it` : `rename "${spelling.actual}" to "${name}.yaml" to record it \u2014 flow files must be lowercase .yaml`;
152548
+ const recovery = spelling.addressable ? `re-run it as name "${path43.basename(spelling.actual, ".yaml")}" to record it` : `rename "${spelling.actual}" to "${name}.yaml" to record it \u2014 flow files must be lowercase .yaml`;
152101
152549
  return {
152102
152550
  warning: `kept the raw flow-execute step \u2014 no sibling is named "${name}.yaml" (this filesystem matched it case-insensitively to "${spelling.actual}"), so a run: ${name} step would name a flow no case-sensitive checkout can find \u2014 ${recovery}`
152103
152551
  };
152104
152552
  }
152105
- parseFlow(await fs56.readFile(fragPath, "utf8"));
152106
- let executedPath;
152107
- try {
152108
- executedPath = await fs56.realpath(path41.join(flowsDirFor(projectRoot), `${name}.yaml`));
152109
- } catch {
152110
- executedPath = void 0;
152111
- }
152112
- if (executedPath === void 0) {
152553
+ const text = await sibling.read();
152554
+ if (text === null) throw new Error(`ENOENT: no such file or directory, open '${fragPath}'`);
152555
+ parseFlow(text);
152556
+ const executed = await project.resolveFlowFile(flowsDirFor(projectRoot), `${name}.yaml`);
152557
+ if (await executed.read() === null) {
152113
152558
  return {
152114
152559
  warning: `kept the raw flow-execute step \u2014 could not verify which file the live flow-execute ran ("${name}" has no canonical file in project_root's flows dir to compare the sibling against)`
152115
152560
  };
152116
152561
  }
152117
- if (executedPath !== await fs56.realpath(fragPath)) {
152562
+ if (executed.canonical !== sibling.canonical) {
152118
152563
  return {
152119
- warning: `kept the raw flow-execute step \u2014 project_root "${projectRoot}" resolves "${name}" to "${executedPath}", not the recording's sibling "${fragPath}", so "${name}.yaml" beside the recording's real file is not the file the live flow-execute ran and a run: ${name} step would replay a different flow than the one that just ran`
152564
+ warning: `kept the raw flow-execute step \u2014 project_root "${projectRoot}" resolves "${name}" to "${executed.canonical}", not the recording's sibling "${fragPath}", so "${name}.yaml" beside the recording's real file is not the file the live flow-execute ran and a run: ${name} step would replay a different flow than the one that just ran`
152120
152565
  };
152121
152566
  }
152122
152567
  return { flow: `${name}.yaml` };
@@ -152126,6 +152571,30 @@ async function captureRunTarget(session, args) {
152126
152571
  };
152127
152572
  }
152128
152573
  }
152574
+ function replayRefusal(issue2, args) {
152575
+ let hint;
152576
+ if (issue2.kind === "nested") {
152577
+ hint = nestedFlowTarget(args)?.kind === "name" ? " Over a link, a nested flow-execute runs only when the argent client sends the flow it names with the call. Update the argent CLI or MCP adapter on the client." : " Over a link, a nested flow-execute runs only when it names its flow with a flow name in name, has an absolute project_root with no .. segment, and has no flow_path.";
152578
+ } else if (issue2.fixes.length === 0) {
152579
+ hint = " A replay without a link runs this step. To keep it, add it to the YAML by hand after flow-finish-recording.";
152580
+ } else {
152581
+ hint = uploadUpdateHint(
152582
+ issue2.fixes.includes("update") ? ["tool: steps with file arguments for a client that sends them with the call"] : []
152583
+ ) + toolFilePathHints(issue2.fixes);
152584
+ }
152585
+ return new FailureError(
152586
+ `Cannot record this call: the recording is over a link, and a replay over the same link refuses the step "${issue2.line}". Nothing ran and no step was recorded.${hint}`,
152587
+ {
152588
+ error_code: FAILURE_CODES.FLOW_FILE_INVALID,
152589
+ failure_stage: UPLOAD_STAGE_BY_KIND[issue2.kind],
152590
+ failure_area: "tool_server",
152591
+ error_kind: "validation"
152592
+ }
152593
+ );
152594
+ }
152595
+ var fileInputs3 = [
152596
+ { target: "project_root", path: "${project_root}", kind: "probe", collect: "step" }
152597
+ ];
152129
152598
  function createFlowAddStepTool(registry2) {
152130
152599
  return {
152131
152600
  id: "flow-add-step",
@@ -152146,6 +152615,7 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
152146
152615
  // because an aborted request still appends its first.
152147
152616
  longRunning: true,
152148
152617
  zodSchema: zodSchema64,
152618
+ fileInputs: fileInputs3,
152149
152619
  services: () => ({}),
152150
152620
  async execute(_services, params, ctx) {
152151
152621
  const session = await requireRecordingSession(params.project_root, params.name);
@@ -152162,7 +152632,21 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
152162
152632
  throw err;
152163
152633
  }
152164
152634
  const authoredArgs = { ...args };
152165
- if (params.command === RUN_TARGET_COMMAND) await rewriteSiblingFlowPath(session, args);
152635
+ const linked = isLinkedRecorderCall(session, ctx);
152636
+ const stepFiles = ctx?.fileInputs?.project_root?.members;
152637
+ const project = stepFiles ? new ClientProjectAccess(stepFiles) : new HostProjectAccess();
152638
+ if (params.command === RUN_TARGET_COMMAND) {
152639
+ await rewriteSiblingFlowPath(session, args, project, linked);
152640
+ }
152641
+ if (linked) {
152642
+ const issue2 = toolStepUploadIssue(
152643
+ registry2,
152644
+ params.command,
152645
+ args,
152646
+ project.mode === "client"
152647
+ );
152648
+ if (issue2) throw replayRefusal(issue2, args);
152649
+ }
152166
152650
  const isTap = params.command === "gesture-tap" && params.delayMs === void 0 && typeof args.udid === "string" && typeof args.x === "number" && typeof args.y === "number";
152167
152651
  let captured;
152168
152652
  if (isTap) {
@@ -152171,9 +152655,18 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
152171
152655
  y: args.y
152172
152656
  });
152173
152657
  }
152658
+ let prepared;
152174
152659
  let toolResult;
152175
152660
  try {
152176
- toolResult = await invokeSubTool(registry2, ctx, params.command, args);
152661
+ prepared = await prepareToolStepInputs(registry2, project, params.command, args);
152662
+ const nestedFromClient = params.command === RUN_TARGET_COMMAND && prepared.fileInputs !== void 0;
152663
+ toolResult = await invokeSubTool(registry2, ctx, params.command, prepared.args, {
152664
+ ...prepared.fileInputs ? { fileInputs: prepared.fileInputs } : {},
152665
+ // A nested run whose flow came from the client gets a run stack even
152666
+ // with no enclosing run, which marks it as nested: its refusals name
152667
+ // the flow it runs, and this call returns the baselines it writes.
152668
+ ...nestedFromClient ? { flowStack: ctx?.flowStack ?? [] } : {}
152669
+ });
152177
152670
  } catch (err) {
152178
152671
  const hint = isToolNotFound(err, params.command) ? directiveCommandHint(params.command) : void 0;
152179
152672
  if (hint) return recordNothing(session, hint);
@@ -152181,16 +152674,36 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
152181
152674
  registry2,
152182
152675
  err,
152183
152676
  params.command,
152184
- args,
152677
+ prepared?.args ?? args,
152185
152678
  authoredArgs
152186
152679
  );
152187
- if (reframed === void 0) throw err;
152680
+ if (reframed === void 0) {
152681
+ if (prepared && err instanceof Error)
152682
+ err.message = withClientPaths(prepared, err.message);
152683
+ throw err;
152684
+ }
152188
152685
  throw new FailureError(reframed, {
152189
152686
  error_code: FAILURE_CODES.TOOL_INPUT_INVALID,
152190
152687
  failure_stage: "flow_add_step_nested_params",
152191
152688
  failure_area: "tool_server",
152192
152689
  error_kind: "validation"
152193
152690
  });
152691
+ } finally {
152692
+ await prepared?.cleanup();
152693
+ }
152694
+ if (linked && params.command === RUN_TARGET_COMMAND) {
152695
+ const outcome = nestedOrchestratorOutcome(RUN_TARGET_COMMAND, toolResult);
152696
+ if (outcome) {
152697
+ throw new FailureError(
152698
+ outcome.status === "fail" ? `Cannot record this call: the nested flow did not pass (${outcome.reason}). A replay over the same link fails at the same step. No step was recorded. Fix the nested flow, then call flow-add-step again.` : `Cannot record this call: the nested flow did not run (${outcome.reason}). No step was recorded.`,
152699
+ {
152700
+ error_code: FAILURE_CODES.FLOW_FILE_INVALID,
152701
+ failure_stage: "flow_add_step_nested_failed",
152702
+ failure_area: "tool_server",
152703
+ error_kind: "validation"
152704
+ }
152705
+ );
152706
+ }
152194
152707
  }
152195
152708
  if (isNativeDevtoolsBlockResult(params.command, toolResult)) {
152196
152709
  throw new FailureError(
@@ -152215,7 +152728,7 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
152215
152728
  if (probed) waitWarning = { warning: probed, kind: "conversion" };
152216
152729
  }
152217
152730
  }
152218
- const runTarget = params.command === RUN_TARGET_COMMAND && params.delayMs === void 0 ? await captureRunTarget(session, args) : void 0;
152731
+ const runTarget = params.command === RUN_TARGET_COMMAND && params.delayMs === void 0 ? await captureRunTarget(session, args, project) : void 0;
152219
152732
  const strippedArgs = stripDeviceKeys(args);
152220
152733
  const { bundleId: _bundleId, launchArgs, ...extraLaunchArgs } = strippedArgs;
152221
152734
  const noLaunchArgs = launchArgs === void 0 || Array.isArray(launchArgs) && launchArgs.length === 0;
@@ -152275,12 +152788,14 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
152275
152788
  step: stepAnchor(step)
152276
152789
  });
152277
152790
  }
152791
+ const baselineWrites = project instanceof ClientProjectAccess && ctx?.flowStack === void 0 ? project.baselineDirectives() : [];
152278
152792
  return {
152279
152793
  message: `Step added to "${params.name}" flow${warning ? ` \u2014 ${warning}` : ""}`,
152280
152794
  toolResult,
152281
152795
  stepCount,
152282
152796
  recorded: summarizeStep(step, stepCount),
152283
- savedTo
152797
+ savedTo,
152798
+ ...baselineWrites.length > 0 ? { baselineWrites } : {}
152284
152799
  };
152285
152800
  }
152286
152801
  };
@@ -152328,16 +152843,16 @@ var nodePath = __toESM(require("node:path"));
152328
152843
  init_src2();
152329
152844
 
152330
152845
  // ../tool-server/src/tools/flows/flow-script-step.ts
152331
- var fs58 = __toESM(require("node:fs/promises"));
152332
- var path43 = __toESM(require("node:path"));
152846
+ var fs59 = __toESM(require("node:fs/promises"));
152847
+ var path45 = __toESM(require("node:path"));
152333
152848
  var import_node_url4 = require("node:url");
152334
152849
  init_src2();
152335
152850
 
152336
152851
  // ../tool-server/src/tools/flows/script/flow-script-executor.ts
152337
152852
  var import_node_child_process35 = require("node:child_process");
152338
- var fs57 = __toESM(require("node:fs"));
152853
+ var fs58 = __toESM(require("node:fs"));
152339
152854
  var os17 = __toESM(require("node:os"));
152340
- var path42 = __toESM(require("node:path"));
152855
+ var path44 = __toESM(require("node:path"));
152341
152856
  var import_node_string_decoder = require("node:string_decoder");
152342
152857
  var import_node_url3 = require("node:url");
152343
152858
  init_src();
@@ -152679,7 +153194,7 @@ var FlowScriptExecutor = class {
152679
153194
  SCRIPT_STEP_LOG_LIMIT_BYTES,
152680
153195
  request3.logBudget
152681
153196
  );
152682
- const scriptPath = realPathOrSelf(path42.resolve(cwd, request3.scriptPath));
153197
+ const scriptPath = realPathOrSelf(path44.resolve(cwd, request3.scriptPath));
152683
153198
  let child;
152684
153199
  try {
152685
153200
  const forkOptions = {
@@ -153043,12 +153558,12 @@ function resolveWorkingDirectory(request3, notes) {
153043
153558
  );
153044
153559
  }
153045
153560
  function describeDirectoryProblem(candidate) {
153046
- if (!path42.isAbsolute(candidate)) {
153561
+ if (!path44.isAbsolute(candidate)) {
153047
153562
  return "is not an absolute path (a relative path would resolve against the tool server's own working directory)";
153048
153563
  }
153049
153564
  if (candidate.split(/[\\/]+/).includes("..")) return 'contains a ".." segment';
153050
153565
  try {
153051
- return fs57.statSync(candidate).isDirectory() ? null : "is not a directory";
153566
+ return fs58.statSync(candidate).isDirectory() ? null : "is not a directory";
153052
153567
  } catch {
153053
153568
  return "does not exist";
153054
153569
  }
@@ -153070,15 +153585,15 @@ function encodeRequestOutput(output) {
153070
153585
  }
153071
153586
  function realPathOrSelf(candidate) {
153072
153587
  try {
153073
- return fs57.realpathSync(candidate);
153588
+ return fs58.realpathSync(candidate);
153074
153589
  } catch {
153075
153590
  return candidate;
153076
153591
  }
153077
153592
  }
153078
153593
  function resolveRunnerPath(runnerDir) {
153079
153594
  const dir = runnerDir ?? __dirname;
153080
- const runner = path42.join(dir, RUNNER_FILE);
153081
- if (!fs57.existsSync(runner)) {
153595
+ const runner = path44.join(dir, RUNNER_FILE);
153596
+ if (!fs58.existsSync(runner)) {
153082
153597
  throw new ScriptSetupError(
153083
153598
  "spawn",
153084
153599
  `The script runner is missing from this installation (looked for ${runner}).`
@@ -153464,7 +153979,7 @@ async function runFlowScriptStep(request3) {
153464
153979
  target,
153465
153980
  SCRIPT_FILE_NAME_PATTERN
153466
153981
  );
153467
- const suppliedBase = path43.posix.basename(target);
153982
+ const suppliedBase = path45.posix.basename(target);
153468
153983
  if (spelling.state === "case_folded") {
153469
153984
  const recovery = spelling.addressable ? `Use "${target.slice(0, target.length - suppliedBase.length)}${spelling.actual}".` : `Rename "${spelling.actual}" to "${suppliedBase}".`;
153470
153985
  return {
@@ -153528,8 +154043,8 @@ function readableFrame(frame, roots) {
153528
154043
  return match;
153529
154044
  }
153530
154045
  for (const root of roots) {
153531
- const relative5 = path43.relative(root, file2);
153532
- if (relative5 !== "" && !relative5.startsWith("..") && !path43.isAbsolute(relative5)) {
154046
+ const relative5 = path45.relative(root, file2);
154047
+ if (relative5 !== "" && !relative5.startsWith("..") && !path45.isAbsolute(relative5)) {
153533
154048
  return `${relative5}${position}`;
153534
154049
  }
153535
154050
  }
@@ -153563,7 +154078,7 @@ function scriptRan(result) {
153563
154078
  }
153564
154079
  async function scriptFileProblem(canonical) {
153565
154080
  try {
153566
- const stat6 = await fs58.stat(canonical);
154081
+ const stat6 = await fs59.stat(canonical);
153567
154082
  return stat6.isFile() ? null : "is not a file";
153568
154083
  } catch (err) {
153569
154084
  const code = err.code;
@@ -153656,7 +154171,7 @@ var flowAddScriptTool = {
153656
154171
  completedMsg: ({ params, result }) => result.status === "pass" ? `Added script step to flow ${params.name}` : `Script for flow ${params.name} failed; nothing recorded`,
153657
154172
  failedMsg: ({ params, failureSignal: failureSignal2 }) => `Failed to add script step to flow ${params.name}: ${failureSignal2.error_code}`
153658
154173
  },
153659
- description: `Run a local .mjs file and record it as a \`script:\` step in an active flow. Use this tool only when the user requests a local script in the flow. Pass the same \`name\` and \`project_root\` as \`flow-start-recording\`, and call it where the script must run. A failed script is not recorded. Check \`reason\` and the affected state before you retry.`,
154174
+ description: `Run a local .mjs file and record it as a \`script:\` step in an active flow. Use when the user requests a local script in the flow, and only then. Pass the same \`name\` and \`project_root\` as \`flow-start-recording\`, and call it where the script must run. Returns \`status\`, \`reason\` and \`stepCount\`. A failed script is not recorded. Check \`reason\` and the affected state before you retry. Over a link (argent link or ARGENT_TOOLS_URL), the tool refuses the call: record such a flow with no link.`,
153660
154175
  // A script's default limit is 30s and its host cap five minutes, against the
153661
154176
  // MCP adapter's 30s per-request fetch budget. Without this the adapter aborts
153662
154177
  // a slow call and RETRIES it, re-running a script whose whole purpose is a
@@ -153670,9 +154185,9 @@ var flowAddScriptTool = {
153670
154185
  services: () => ({}),
153671
154186
  async execute(_services, params, ctx) {
153672
154187
  const session = await requireRecordingSession(params.project_root, params.name);
153673
- if (session.persist !== "host") {
154188
+ if (isLinkedRecorderCall(session, ctx)) {
153674
154189
  throw new FailureError(
153675
- `Cannot access the script for flow "${params.name}". Finish the recording, add the \`script:\` step to the YAML, and replay it locally.`,
154190
+ `Cannot add a script step to flow "${params.name}": the recording is over a link (argent link or ARGENT_TOOLS_URL), and a flow cannot run script steps over a link. Nothing ran and no step was recorded. To record a script step, record the flow on the computer that runs the tool-server, with no link and no ARGENT_TOOLS_URL.`,
153676
154191
  {
153677
154192
  error_code: FAILURE_CODES.FLOW_FILE_INVALID,
153678
154193
  failure_stage: "flow_add_script_client_mode",
@@ -153755,7 +154270,7 @@ var flowAddScriptTool = {
153755
154270
 
153756
154271
  // ../tool-server/src/tools/flows/flow-finish-recording.ts
153757
154272
  init_zod();
153758
- var fs59 = __toESM(require("node:fs/promises"));
154273
+ var fs60 = __toESM(require("node:fs/promises"));
153759
154274
  var zodSchema67 = external_exports.object({
153760
154275
  name: external_exports.string().describe("Name of the flow being recorded \u2014 the one passed to flow-start-recording."),
153761
154276
  project_root: external_exports.string().describe(
@@ -153830,7 +154345,7 @@ You can still edit the .yaml file directly afterwards to remove or reorder steps
153830
154345
  flowFile2 = serializeFlow(session.flow);
153831
154346
  savedTo2 = clientFileDirective(filePath2, flowFile2);
153832
154347
  } else {
153833
- flowFile2 = await fs59.readFile(filePath2, "utf8");
154348
+ flowFile2 = await fs60.readFile(filePath2, "utf8");
153834
154349
  savedTo2 = filePath2;
153835
154350
  }
153836
154351
  const flow2 = parseFlow(flowFile2);
@@ -153859,237 +154374,15 @@ You can still edit the .yaml file directly afterwards to remove or reorder steps
153859
154374
  // ../tool-server/src/tools/flows/flow-run.ts
153860
154375
  init_zod();
153861
154376
  var fs63 = __toESM(require("node:fs/promises"));
153862
- var path47 = __toESM(require("node:path"));
153863
- init_src2();
153864
-
153865
- // ../tool-server/src/tools/flows/project-access.ts
153866
- var fs60 = __toESM(require("node:fs/promises"));
153867
- var path44 = __toESM(require("node:path"));
154377
+ var path48 = __toESM(require("node:path"));
153868
154378
  init_src2();
153869
- function clientBaselinePath(clientFlowPath, key2, file2) {
153870
- return path44.posix.join(path44.posix.dirname(clientFlowPath), "__baselines__", key2, file2);
153871
- }
153872
- function isEnoent(err) {
153873
- return err?.code === "ENOENT";
153874
- }
153875
- function isNothingThere(err) {
153876
- return isEnoent(err) || err?.code === "ENOTDIR";
153877
- }
153878
- var HostProjectAccess = class {
153879
- mode = "host";
153880
- async resolveFlowFile(anchorDir, target) {
153881
- const { canonical, spelling } = await resolveFlowRelativeFile(
153882
- anchorDir,
153883
- target,
153884
- FLOW_FILE_NAME_PATTERN
153885
- );
153886
- return {
153887
- canonical,
153888
- spelling,
153889
- read: async () => {
153890
- try {
153891
- return await fs60.readFile(canonical, "utf8");
153892
- } catch (err) {
153893
- if (!isEnoent(err)) throw err;
153894
- return null;
153895
- }
153896
- }
153897
- };
153898
- }
153899
- async readFile(filePath) {
153900
- try {
153901
- return await fs60.readFile(filePath);
153902
- } catch (err) {
153903
- if (!isNothingThere(err)) throw err;
153904
- return null;
153905
- }
153906
- }
153907
- async writeBaseline(filePath, bytes) {
153908
- const replaced = await fs60.access(filePath).then(
153909
- () => true,
153910
- () => false
153911
- );
153912
- await fs60.mkdir(path44.dirname(filePath), { recursive: true });
153913
- await fs60.writeFile(filePath, bytes);
153914
- return { replaced };
153915
- }
153916
- };
153917
- var BASELINE_CAP_BYTES = 32 * 1024 * 1024;
153918
- function clientRefusal(subject2, reason, verb = "send") {
153919
- return new FailureError(`the client refused to ${verb} "${subject2}": ${reason}`, {
153920
- error_code: FAILURE_CODES.FLOW_FILE_INVALID,
153921
- failure_stage: "client_member_refused",
153922
- failure_area: "tool_server",
153923
- error_kind: "validation"
153924
- });
153925
- }
153926
- var ClientProjectAccess = class {
153927
- constructor(members) {
153928
- this.members = members;
153929
- }
153930
- members;
153931
- mode = "client";
153932
- /** Baselines this call wrote, by client path. */
153933
- overlay = /* @__PURE__ */ new Map();
153934
- /** The member the runner reaches for this pair, or undefined when the client did not send one. */
153935
- member(anchorDir, target) {
153936
- const key2 = flowMemberKey(anchorDir, target);
153937
- return Object.hasOwn(this.members, key2) ? this.members[key2] : void 0;
153938
- }
153939
- async resolveFlowFile(anchorDir, target) {
153940
- const member = this.member(anchorDir, target);
153941
- if (member?.role !== "flow" || member.canonical === void 0) {
153942
- throw clientRefusal(target, `${target} is not a run: target of a flow this client sent`);
153943
- }
153944
- const text = member.state === "present" ? member.text ?? "" : null;
153945
- return {
153946
- canonical: member.canonical,
153947
- spelling: member.spelling ?? { state: "listed" },
153948
- read: async () => {
153949
- if (member.state !== "refused") return text;
153950
- throw clientRefusal(target, member.error ?? "the client did not send it");
153951
- }
153952
- };
153953
- }
153954
- baseline(filePath) {
153955
- const member = Object.hasOwn(this.members, filePath) ? this.members[filePath] : void 0;
153956
- return member?.role === "baseline" ? member : void 0;
153957
- }
153958
- /**
153959
- * A baseline of this run: the bytes this call wrote there, else the file
153960
- * the client sent, else null, the "no baseline" outcome: a compare run gets
153961
- * every baseline of its snapshots the client has.
153962
- */
153963
- async readFile(filePath) {
153964
- const written = this.overlay.get(filePath);
153965
- if (written !== void 0) return written;
153966
- const member = this.baseline(filePath);
153967
- if (member === void 0 || member.state === "missing") return null;
153968
- if (member.state === "present" && member.hostPath !== void 0) {
153969
- return fs60.readFile(member.hostPath);
153970
- }
153971
- throw clientRefusal(
153972
- filePath,
153973
- member.error ?? "the client sent only its name, for a run that updates baselines"
153974
- );
153975
- }
153976
- /**
153977
- * Keep a new baseline for the result and for later reads in this call.
153978
- * `replaced` says whether one was there before: written earlier in this
153979
- * call, or on the client.
153980
- */
153981
- async writeBaseline(filePath, bytes) {
153982
- if (bytes.length > BASELINE_CAP_BYTES) {
153983
- throw new FailureError(
153984
- `the baseline for "${filePath}" is larger than the 32 MiB cap on a file the client writes, so this tool-server did not keep it`,
153985
- {
153986
- error_code: FAILURE_CODES.FLOW_FILE_INVALID,
153987
- failure_stage: "client_content_cap",
153988
- failure_area: "tool_server",
153989
- error_kind: "validation"
153990
- }
153991
- );
153992
- }
153993
- const member = this.baseline(filePath);
153994
- if (member?.state === "refused") {
153995
- throw clientRefusal(filePath, member.error ?? "refused", "write");
153996
- }
153997
- const replaced = this.overlay.has(filePath) || member !== void 0 && member.state !== "missing";
153998
- this.overlay.set(filePath, bytes);
153999
- return { replaced };
154000
- }
154001
- /** The baselines this call wrote, last bytes per path, as directives for the result. */
154002
- baselineDirectives() {
154003
- return [...this.overlay].map(([filePath, bytes]) => ({
154004
- [CLIENT_FILE_MARKER]: true,
154005
- path: filePath,
154006
- content: bytes.toString("base64"),
154007
- encoding: "base64"
154008
- }));
154009
- }
154010
- };
154011
-
154012
- // ../tool-server/src/tools/flows/flow-nested-outcome.ts
154013
- var FLOW_EXECUTE_TOOL_ID = "flow-execute";
154014
- var RUN_SEQUENCE_TOOL_ID = "run-sequence";
154015
- function isRecord(value) {
154016
- return typeof value === "object" && value !== null;
154017
- }
154018
- function firstFailingStep(steps) {
154019
- if (!Array.isArray(steps)) return void 0;
154020
- for (const entry of steps) {
154021
- if (!isRecord(entry)) continue;
154022
- if (entry.status !== "fail" && entry.status !== "error") continue;
154023
- const what = typeof entry.tool === "string" ? entry.tool : typeof entry.kind === "string" ? entry.kind : "step";
154024
- const why = typeof entry.reason === "string" ? entry.reason : "no reason given";
154025
- return `${what}: ${why}`;
154026
- }
154027
- return void 0;
154028
- }
154029
- function count(value) {
154030
- return typeof value === "number" ? value : 0;
154031
- }
154032
- function flowExecuteOutcome(result) {
154033
- const flow = typeof result.flow === "string" ? result.flow : "the composed flow";
154034
- if (!("steps" in result) && typeof result.notice === "string") {
154035
- const prerequisite = typeof result.executionPrerequisite === "string" && result.executionPrerequisite ? `: ${result.executionPrerequisite}` : "";
154036
- return {
154037
- status: "error",
154038
- reason: `flow "${flow}" did not run \u2014 its execution prerequisite was not acknowledged${prerequisite}. Add prerequisiteAcknowledged: true to the step's args, or compose with run: instead.`
154039
- };
154040
- }
154041
- if (result.aborted === true) {
154042
- return { status: "skip", reason: `flow "${flow}" was aborted` };
154043
- }
154044
- if (result.ok === false) {
154045
- const detail = firstFailingStep(result.steps);
154046
- return {
154047
- status: "fail",
154048
- reason: `flow "${flow}" failed: ${count(result.passed)} passed, ${count(result.failed)} failed, ${count(result.errored)} errored${detail ? ` (${detail})` : ""}`
154049
- };
154050
- }
154051
- return void 0;
154052
- }
154053
- function runSequenceOutcome(result) {
154054
- const steps = result.steps;
154055
- if (!Array.isArray(steps)) return void 0;
154056
- const failed2 = steps.find((s) => isRecord(s) && typeof s.error === "string");
154057
- if (failed2 && isRecord(failed2)) {
154058
- const tool = typeof failed2.tool === "string" ? failed2.tool : "step";
154059
- return {
154060
- status: "fail",
154061
- reason: `run-sequence stopped at ${tool} after ${count(result.completed)} of ${count(result.total)} steps: ${String(failed2.error)}`
154062
- };
154063
- }
154064
- const total = count(result.total);
154065
- if (total > 0 && steps.length < total) {
154066
- return {
154067
- status: "skip",
154068
- reason: `run-sequence was aborted after ${count(result.completed)} of ${total} steps`
154069
- };
154070
- }
154071
- return void 0;
154072
- }
154073
- var NESTED_ORCHESTRATORS = /* @__PURE__ */ new Map([
154074
- [FLOW_EXECUTE_TOOL_ID, flowExecuteOutcome],
154075
- [RUN_SEQUENCE_TOOL_ID, runSequenceOutcome]
154076
- ]);
154077
- function isNestedOrchestratorTool(tool) {
154078
- return NESTED_ORCHESTRATORS.has(tool);
154079
- }
154080
- function nestedOrchestratorOutcome(tool, result) {
154081
- if (!isRecord(result)) return void 0;
154082
- return NESTED_ORCHESTRATORS.get(tool)?.(result);
154083
- }
154084
-
154085
- // ../tool-server/src/tools/flows/flow-run.ts
154086
154379
  init_device_info();
154087
154380
 
154088
154381
  // ../tool-server/src/tools/flows/flow-visual.ts
154089
154382
  var import_node_crypto12 = require("node:crypto");
154090
154383
  var fs62 = __toESM(require("node:fs/promises"));
154091
154384
  var os18 = __toESM(require("node:os"));
154092
- var path46 = __toESM(require("node:path"));
154385
+ var path47 = __toESM(require("node:path"));
154093
154386
  var import_pngjs4 = __toESM(require_png());
154094
154387
  init_src2();
154095
154388
 
@@ -156189,7 +156482,7 @@ function cropIdentity(s) {
156189
156482
  return JSON.stringify(cropIdentityParts(s));
156190
156483
  }
156191
156484
  function baselineDir(flowsDir, flowName) {
156192
- return path46.join(flowsDir, "__baselines__", flowName);
156485
+ return path47.join(flowsDir, "__baselines__", flowName);
156193
156486
  }
156194
156487
  async function cleanupDiffDir(dir, keep) {
156195
156488
  try {
@@ -156198,7 +156491,7 @@ async function cleanupDiffDir(dir, keep) {
156198
156491
  return;
156199
156492
  }
156200
156493
  for (const entry of await fs62.readdir(dir)) {
156201
- const entryPath = path46.join(dir, entry);
156494
+ const entryPath = path47.join(dir, entry);
156202
156495
  if (entryPath !== keep) await fs62.rm(entryPath, { recursive: true, force: true });
156203
156496
  }
156204
156497
  } catch {
@@ -156254,7 +156547,7 @@ async function runSnapshot(env, opts) {
156254
156547
  const cropSuffix = opts.cropOn === void 0 ? "" : `-crop-${(0, import_node_crypto12.createHash)("sha256").update(cropIdentity(opts.cropOn)).digest("hex").slice(0, 8)}`;
156255
156548
  const snapshotKey = `${opts.name}__${authoringPlatform(env.device.platform)}-${w}x${h}${cropSuffix}`;
156256
156549
  const key2 = `${snapshotKey}.png`;
156257
- const baselinePath = opts.clientFlowPath === void 0 ? path46.join(baselineDir(opts.flowsDir, opts.flowName), key2) : clientBaselinePath(opts.clientFlowPath, opts.flowName, key2);
156550
+ const baselinePath = opts.clientFlowPath === void 0 ? path47.join(baselineDir(opts.flowsDir, opts.flowName), key2) : clientBaselinePath(opts.clientFlowPath, opts.flowName, key2);
156258
156551
  const priorApp = opts.seenKeys.get(snapshotKey);
156259
156552
  if (priorApp !== void 0 && priorApp !== opts.appIdentity) {
156260
156553
  return {
@@ -156282,8 +156575,8 @@ async function runSnapshot(env, opts) {
156282
156575
  let keepBaselineCopy = false;
156283
156576
  const hostBaseline = async (bytes) => {
156284
156577
  if (opts.clientFlowPath === void 0) return baselinePath;
156285
- baselineCopyDir = await fs62.mkdtemp(path46.join(os18.tmpdir(), "argent-flow-baseline-"));
156286
- const copy = path46.join(baselineCopyDir, key2);
156578
+ baselineCopyDir = await fs62.mkdtemp(path47.join(os18.tmpdir(), "argent-flow-baseline-"));
156579
+ const copy = path47.join(baselineCopyDir, key2);
156287
156580
  await fs62.writeFile(copy, bytes);
156288
156581
  return copy;
156289
156582
  };
@@ -156293,8 +156586,8 @@ async function runSnapshot(env, opts) {
156293
156586
  };
156294
156587
  try {
156295
156588
  if (cropFrame !== void 0) {
156296
- cropDir = await fs62.mkdtemp(path46.join(os18.tmpdir(), "argent-flow-crop-"));
156297
- const croppedPath = path46.join(cropDir, key2);
156589
+ cropDir = await fs62.mkdtemp(path47.join(os18.tmpdir(), "argent-flow-crop-"));
156590
+ const croppedPath = path47.join(cropDir, key2);
156298
156591
  const cropped = await cropPngFile(shot.image.hostPath, croppedPath, cropFrame);
156299
156592
  if (cropped === null) {
156300
156593
  return {
@@ -156354,7 +156647,7 @@ async function runSnapshot(env, opts) {
156354
156647
  };
156355
156648
  }
156356
156649
  const localBaseline = await hostBaseline(stored);
156357
- const outputDir = await fs62.mkdtemp(path46.join(os18.tmpdir(), "argent-flow-diff-"));
156650
+ const outputDir = await fs62.mkdtemp(path47.join(os18.tmpdir(), "argent-flow-diff-"));
156358
156651
  let keepInOutputDir;
156359
156652
  try {
156360
156653
  const result = await diffPngFiles({
@@ -156416,7 +156709,7 @@ async function runSnapshot(env, opts) {
156416
156709
  if (baselineCopyDir !== void 0) {
156417
156710
  await cleanupDiffDir(
156418
156711
  baselineCopyDir,
156419
- keepBaselineCopy ? path46.join(baselineCopyDir, key2) : void 0
156712
+ keepBaselineCopy ? path47.join(baselineCopyDir, key2) : void 0
156420
156713
  );
156421
156714
  }
156422
156715
  }
@@ -156520,7 +156813,7 @@ var zodSchema68 = external_exports.object({
156520
156813
  "Path to the flow .yaml as readable by the tool-server. Internal \u2014 the argent client derives it from project_root and name automatically; leave unset."
156521
156814
  ),
156522
156815
  flow_path: external_exports.string().optional().describe(
156523
- "Omit when name is set. Absolute path to a flow .yaml on the client. Over a link (argent link or ARGENT_TOOLS_URL), the argent client uploads the file, its run: fragments and the snapshot baselines that the run compares, and the tool-server runs those copies. Keep run: fragments under project_root or beside the flow file. With updateBaselines, the client writes the new baselines when the run ends. Over a link, the flow and its fragments must not have script: steps, or tool: steps that take a file or record a flow. Without a link, the tool-server reads the files in place and all step kinds run."
156816
+ "Omit when name is set. Absolute path to a flow .yaml on the client. Over a link (argent link or ARGENT_TOOLS_URL), the argent client uploads the file, its run: fragments and the snapshot baselines of each run, and the tool-server runs those copies. Keep run: fragments under project_root or beside the flow file. With updateBaselines, the client writes the new baselines when the run ends. The client also uploads each absolute .png or .yaml path that a tool: step takes as a file argument, when the file is under project_root or beside the flow file. A tool: flow-execute step that names a flow with name and an absolute project_root without a .. segment runs: the client also uploads that flow and its own files. Over a link, the uploaded flows must not have: script: steps; tool: steps that run a flow another way or record a flow; tool: steps that take a directory, an app or an output directory; tool: steps whose tool builds a file path from several arguments; tool: steps that name a relative path or a file other than .png or .yaml. Without a link, the tool-server reads the files in place and all step kinds run."
156524
156817
  ),
156525
156818
  device: external_exports.string().optional().describe(
156526
156819
  "Device id to run against (iOS UDID, Android/Vega serial, Chromium id) \u2014 the id list-devices reports. Auto-detected when omitted, but only when exactly one booted device matches (optionally narrowed by `platform`); with several booted the run fails and lists them, so pass this explicitly whenever more than one device is up."
@@ -156529,7 +156822,7 @@ var zodSchema68 = external_exports.object({
156529
156822
  "Restrict auto-detection to this platform when several devices are booted. `ios` selects local simulators only \u2014 pass `ios-remote` to select a remote one. `chromium` does more than filter: with no `device` it SELECTS the self-boot branch for an e2e flow - the runner boots an Electron instance from the `launch` step's chromium value and tears it down after the run (a single-key `launch: { chromium: \u2026 }` map selects it on its own, without this parameter). When it selects that branch it never falls back to device auto-detection (a fragment, or an e2e launch map with no `chromium` key, still does), and the launch value must be a real Electron app path on the tool-server host: a bare-string `launch:` - what the recorder writes - holds an installed-app bundle id, so passing `chromium` for one fails the whole run with `Electron boot: path does not exist`. Edit the launch to `{ chromium: <app path> }` first."
156530
156823
  ),
156531
156824
  updateBaselines: external_exports.boolean().optional().describe(
156532
- "Write/refresh screenshot baselines for `snapshot` steps instead of diffing against them."
156825
+ "Write/refresh screenshot baselines for `snapshot` steps instead of diffing against them, also in the flows that tool: flow-execute steps run, unless such a step sets updateBaselines itself."
156533
156826
  ),
156534
156827
  prerequisiteAcknowledged: external_exports.boolean().optional().describe(
156535
156828
  "Set to true to confirm the execution prerequisite has been met. Required (LLM path) when a fragment defines an executionPrerequisite."
@@ -156545,7 +156838,7 @@ var zodSchema68 = external_exports.object({
156545
156838
  });
156546
156839
  }
156547
156840
  });
156548
- var fileInputs3 = [
156841
+ var fileInputs4 = [
156549
156842
  {
156550
156843
  target: "flow_path",
156551
156844
  path: "${flow_path}",
@@ -156562,6 +156855,18 @@ var fileInputs3 = [
156562
156855
  collect: "flow"
156563
156856
  }
156564
156857
  ];
156858
+ var FLOW_STARTING_TOOLS = /* @__PURE__ */ new Set(["flow-execute", "flow-add-step"]);
156859
+ function nestedRunArgs(state3, tool, args) {
156860
+ return tool === "flow-execute" && state3.updateBaselines && args.updateBaselines === void 0 ? { ...args, updateBaselines: true } : args;
156861
+ }
156862
+ function nestingFailure(message) {
156863
+ return new FailureError(message, {
156864
+ error_code: FAILURE_CODES.FLOW_FILE_INVALID,
156865
+ failure_stage: "flow_run_validate",
156866
+ failure_area: "tool_server",
156867
+ error_kind: "validation"
156868
+ });
156869
+ }
156565
156870
  var POST_LAUNCH_SETTLE_MS = 1500;
156566
156871
  var NATIVE_READY_TIMEOUT_MS = NATIVE_DEVTOOLS_CONNECT_BUDGET_MS;
156567
156872
  var NATIVE_READY_POLL_MS = 250;
@@ -156835,7 +157140,7 @@ function deviceEnv(state3) {
156835
157140
  return { ...state3, device: state3.device };
156836
157141
  }
156837
157142
  function displayFlowName(params) {
156838
- const stem = params.flow_path === void 0 ? void 0 : path47.basename(params.flow_path, ".yaml");
157143
+ const stem = params.flow_path === void 0 ? void 0 : path48.basename(params.flow_path, ".yaml");
156839
157144
  return params.name || stem || params.flow_path || "(unspecified)";
156840
157145
  }
156841
157146
  function* walkSteps(steps, within = "") {
@@ -156905,82 +157210,65 @@ function fragmentLoadRefusal(registry2, fragment, target) {
156905
157210
  const retiredArg = findRetiredToolArg(registry2, fragment.steps);
156906
157211
  return retiredArg ? `fragment "${target}" ${retiredArgReason(retiredArg)}` : void 0;
156907
157212
  }
156908
- var UPLOAD_STAGE_BY_KIND = {
156909
- run: "flow_upload_run_composition",
156910
- script: "flow_upload_script_step",
156911
- snapshot: "flow_upload_snapshot_baseline",
156912
- nested: "flow_upload_nested_flow",
156913
- toolFile: "flow_upload_tool_file_input",
156914
- recording: "flow_upload_recording_tool"
156915
- };
156916
- function nestedFlowRef(args) {
156917
- if (typeof args.name === "string") return ` (name: ${args.name})`;
156918
- if (typeof args.flow_path === "string") return ` (flow_path: ${args.flow_path})`;
156919
- return "";
156920
- }
156921
- function toolStepFilePaths(registry2, tool, args) {
156922
- const paths = [];
156923
- for (const spec of registry2.getTool(tool)?.fileInputs ?? []) {
156924
- if (spec.skipWhenSet !== void 0 && args[spec.skipWhenSet] !== void 0) continue;
156925
- const filled = interpolateFileInputPath(spec.path, args);
156926
- if (filled !== null) paths.push(filled);
156927
- }
156928
- return paths;
156929
- }
156930
- function assertUploadSelfContained(registry2, flow, closure) {
157213
+ function assertUploadSelfContained(registry2, flow, closure, origin = {
157214
+ subject: "This flow",
157215
+ arrival: "it arrived as an upload"
157216
+ }) {
156931
157217
  const offending = [];
157218
+ const toolFileFixes = /* @__PURE__ */ new Set();
157219
+ let namedNestedFlow = false;
156932
157220
  const queue = [{ flow, canonical: closure?.rootCanonical ?? "", within: "", hop: 0 }];
156933
157221
  const seen = /* @__PURE__ */ new Set();
157222
+ const follow = (file2, anchorDir, target, entry) => {
157223
+ if (entry.kind === "run" && file2.hop + 1 >= MAX_RUN_DEPTH) return;
157224
+ const key2 = flowMemberKey(anchorDir, target);
157225
+ if (closure === void 0 || seen.has(key2)) return;
157226
+ seen.add(key2);
157227
+ const member = closure.project.member(anchorDir, target);
157228
+ if (member?.state === "refused") {
157229
+ offending.push({ kind: entry.kind, line: `${entry.line} (${member.error})` });
157230
+ } else if (member?.state === "present" && member.canonical !== void 0 && file2.hop + 1 < MAX_RUN_DEPTH) {
157231
+ let next;
157232
+ try {
157233
+ next = parseFlow(member.text ?? "");
157234
+ } catch {
157235
+ return;
157236
+ }
157237
+ queue.push({
157238
+ flow: next,
157239
+ canonical: member.canonical,
157240
+ within: ` in ${member.canonical}`,
157241
+ hop: file2.hop + 1
157242
+ });
157243
+ }
157244
+ };
156934
157245
  for (let file2 = queue.shift(); file2 !== void 0; file2 = queue.shift()) {
156935
157246
  for (const { step, where } of walkSteps(file2.flow.steps, file2.within)) {
156936
157247
  if (step.kind === "run") {
156937
- if (!closure) {
156938
- offending.push({ kind: "run", line: `${where}: run: ${step.flow}` });
156939
- continue;
156940
- }
156941
- if (file2.hop + 1 >= MAX_RUN_DEPTH) continue;
156942
- const anchorDir = path47.dirname(file2.canonical);
156943
- const key2 = flowMemberKey(anchorDir, step.flow);
156944
- if (seen.has(key2)) continue;
156945
- seen.add(key2);
156946
- const member = closure.project.member(anchorDir, step.flow);
156947
- if (member?.state === "refused") {
156948
- offending.push({ kind: "run", line: `${where}: run: ${step.flow} (${member.error})` });
156949
- } else if (member?.state === "present" && member.canonical !== void 0) {
156950
- let fragment;
156951
- try {
156952
- fragment = parseFlow(member.text ?? "");
156953
- } catch {
156954
- continue;
156955
- }
156956
- queue.push({
156957
- flow: fragment,
156958
- canonical: member.canonical,
156959
- within: ` in ${member.canonical}`,
156960
- hop: file2.hop + 1
156961
- });
156962
- }
157248
+ const line = `${where}: run: ${step.flow}`;
157249
+ if (!closure) offending.push({ kind: "run", line });
157250
+ else follow(file2, path48.dirname(file2.canonical), step.flow, { kind: "run", line });
156963
157251
  } else if (step.kind === "script") {
156964
157252
  offending.push({ kind: "script", line: `${where}: script: { path: ${step.path} }` });
156965
157253
  } else if (step.kind === "snapshot") {
156966
157254
  if (closure) continue;
156967
157255
  offending.push({ kind: "snapshot", line: `${where}: snapshot: ${step.name}` });
156968
- } else if (step.kind === "tool" && step.name === "flow-execute") {
156969
- offending.push({
156970
- kind: "nested",
156971
- line: `${where}: tool: flow-execute${nestedFlowRef(step.args)}`
156972
- });
156973
157256
  } else if (step.kind === "tool" && RECORDING_TOOL_IDS.has(step.name)) {
156974
157257
  offending.push({
156975
157258
  kind: "recording",
156976
157259
  line: `${where}: tool: ${step.name} (records a flow)`
156977
157260
  });
156978
157261
  } else if (step.kind === "tool") {
156979
- const paths = toolStepFilePaths(registry2, step.name, step.args);
156980
- if (paths.length > 0) {
156981
- offending.push({
156982
- kind: "toolFile",
156983
- line: `${where}: tool: ${step.name} (${paths.join(", ")})`
157262
+ const issue2 = toolStepUploadIssue(registry2, step.name, step.args, closure !== void 0);
157263
+ const target = step.name === "flow-execute" ? nestedFlowTarget(step.args) : void 0;
157264
+ if (issue2 !== void 0) {
157265
+ offending.push({ kind: issue2.kind, line: `${where}: ${issue2.line}` });
157266
+ for (const fix of issue2.fixes) toolFileFixes.add(fix);
157267
+ if (target?.kind === "name") namedNestedFlow = true;
157268
+ } else if (target?.kind === "name") {
157269
+ follow(file2, path48.dirname(target.path), `${target.name}.yaml`, {
157270
+ kind: "nested",
157271
+ line: `${where}: tool: flow-execute (name: ${target.name})`
156984
157272
  });
156985
157273
  }
156986
157274
  }
@@ -156989,13 +157277,16 @@ function assertUploadSelfContained(registry2, flow, closure) {
156989
157277
  if (offending.length === 0) return;
156990
157278
  const servable = [
156991
157279
  ...!closure && offending.some((o) => o.kind === "run") ? ["run: steps for a client that sends their fragments with the call"] : [],
156992
- ...!closure && offending.some((o) => o.kind === "snapshot") ? ["snapshot: steps for a client that sends their baselines with the call"] : []
157280
+ ...!closure && namedNestedFlow ? [
157281
+ "tool: flow-execute steps that name a flow with name, for a client that sends those flows with the call"
157282
+ ] : [],
157283
+ ...!closure && offending.some((o) => o.kind === "snapshot") ? ["snapshot: steps for a client that sends their baselines with the call"] : [],
157284
+ ...toolFileFixes.has("update") ? ["tool: steps with file arguments for a client that sends them with the call"] : []
156993
157285
  ];
156994
- const updateHint = servable.length > 0 ? ` This tool-server runs ${servable.join(", and ")}. Update the argent CLI or MCP adapter on the client.` : "";
156995
157286
  throw new FailureError(
156996
- `This flow is not self-contained, and it arrived as an upload. The steps below read or write project files, which stay on the client:
157287
+ `${origin.subject} is not self-contained, and ${origin.arrival}. The steps below read or write project files, which stay on the client:
156997
157288
  ` + offending.map((o) => ` - ${o.line}`).join("\n") + `
156998
- Run the flow on the computer that runs the tool-server, with no link and no ARGENT_TOOLS_URL, so that the tool-server reads the files in place.${updateHint}`,
157289
+ Run the flow on the computer that runs the tool-server, with no link and no ARGENT_TOOLS_URL, so that the tool-server reads the files in place.${uploadUpdateHint(servable)}${toolFilePathHints(toolFileFixes)}`,
156999
157290
  {
157000
157291
  error_code: FAILURE_CODES.FLOW_FILE_INVALID,
157001
157292
  failure_stage: UPLOAD_STAGE_BY_KIND[offending[0].kind],
@@ -157019,7 +157310,7 @@ exactly one flow source: name (under project_root) or flow_path.
157019
157310
  Returns a per-step report: the first failure stops the run and the rest report as skipped.`,
157020
157311
  longRunning: true,
157021
157312
  zodSchema: zodSchema68,
157022
- fileInputs: fileInputs3,
157313
+ fileInputs: fileInputs4,
157023
157314
  services: () => ({}),
157024
157315
  async execute(_services, params, ctx) {
157025
157316
  const runStartedAt = Date.now();
@@ -157033,7 +157324,7 @@ Returns a per-step report: the first failure stops the run and the rest report a
157033
157324
  const clientProject = rootInput?.members ? new ClientProjectAccess(rootInput.members) : void 0;
157034
157325
  const project = clientProject ?? new HostProjectAccess();
157035
157326
  const canonicalPath = await canonicalFlowPath(filePath);
157036
- const flowsDir = path47.dirname(canonicalPath);
157327
+ const flowsDir = path48.dirname(canonicalPath);
157037
157328
  const flow = parseFlow(await fs63.readFile(canonicalPath, "utf8"));
157038
157329
  if (viaUpload) {
157039
157330
  assertUploadSelfContained(
@@ -157042,6 +157333,12 @@ Returns a per-step report: the first failure stops the run and the rest report a
157042
157333
  clientProject && rootInput ? {
157043
157334
  project: clientProject,
157044
157335
  rootCanonical: rootInput.canonical ?? rootInput.clientPath
157336
+ } : void 0,
157337
+ // A nested run's refusal is quoted in the step or the call that runs
157338
+ // it, so it names its own flow, whose steps it numbers.
157339
+ ctx?.flowStack !== void 0 ? {
157340
+ subject: `The nested flow "${flowName}"`,
157341
+ arrival: "the client sent it with the call"
157045
157342
  } : void 0
157046
157343
  );
157047
157344
  }
@@ -157058,8 +157355,16 @@ Returns a per-step report: the first failure stops the run and the rest report a
157058
157355
  canonical: clientProject && rootInput ? clientRootCanonical(rootInput, params.name, flow) : canonicalPath,
157059
157356
  display: flowName
157060
157357
  };
157358
+ const enclosing = ctx?.flowStack ?? [];
157359
+ if (enclosing.some((entry) => entry.canonical === rootEntry.canonical)) {
157360
+ throw nestingFailure(
157361
+ `cyclic flow reference: ${[...enclosing, rootEntry].map((entry) => entry.display).join(" \u2192 ")}`
157362
+ );
157363
+ }
157364
+ if (enclosing.length >= MAX_RUN_DEPTH) throw nestingFailure("max run depth exceeded");
157365
+ const seed = [...enclosing, rootEntry];
157061
157366
  if (flow.executionPrerequisite && !pinnedToChromium(params.device)) {
157062
- const leading = await leadingLaunch(flow, [rootEntry], { registry: registry2, project });
157367
+ const leading = await leadingLaunch(flow, seed, { registry: registry2, project });
157063
157368
  if (leading) {
157064
157369
  const pinRemedy = chromiumPinnable(leading.app, params.platform) ? ` Or pin the run to a chromium instance you have already brought to that state (--device chromium-cdp-<port>), where the leading launch only attaches.` : "";
157065
157370
  throw new FailureError(
@@ -157087,7 +157392,7 @@ Returns a per-step report: the first failure stops the run and the rest report a
157087
157392
  flow,
157088
157393
  params,
157089
157394
  flowsDir,
157090
- rootEntry,
157395
+ seed,
157091
157396
  viaUpload,
157092
157397
  project
157093
157398
  );
@@ -157139,7 +157444,8 @@ Returns a per-step report: the first failure stops the run and the rest report a
157139
157444
  let aborted2;
157140
157445
  try {
157141
157446
  await execSteps(state3, flow.steps, {
157142
- runStack: [rootEntry],
157447
+ runStack: seed,
157448
+ rootDisplay: rootEntry.display,
157143
157449
  depth: 0
157144
157450
  });
157145
157451
  } finally {
@@ -157157,14 +157463,14 @@ Returns a per-step report: the first failure stops the run and the rest report a
157157
157463
  aborted2,
157158
157464
  { startedAt: runStartedAt, durationMs: Date.now() - runStartedAt }
157159
157465
  );
157160
- const baselineWrites = clientProject?.baselineDirectives() ?? [];
157466
+ const baselineWrites = ctx?.flowStack === void 0 ? clientProject?.baselineDirectives() ?? [] : [];
157161
157467
  return baselineWrites.length > 0 ? { ...result, baselineWrites } : result;
157162
157468
  }
157163
157469
  };
157164
157470
  }
157165
- async function resolveRunDevice(registry2, ctx, flow, params, flowDir, rootEntry, viaUpload, project) {
157471
+ async function resolveRunDevice(registry2, ctx, flow, params, flowDir, runStack, viaUpload, project) {
157166
157472
  if (!params.device) {
157167
- const leading = await leadingLaunch(flow, [rootEntry], { registry: registry2, project });
157473
+ const leading = await leadingLaunch(flow, runStack, { registry: registry2, project });
157168
157474
  const spec = leading && chromiumBootSpec(leading.app, params.platform);
157169
157475
  if (spec) {
157170
157476
  let booted;
@@ -157218,10 +157524,10 @@ function clientRootCanonical(root, name, flow) {
157218
157524
  return root.canonical ?? root.clientPath;
157219
157525
  }
157220
157526
  async function leadingLaunch(flow, stack, env) {
157221
- const found = await scanLeadingLaunch(flow, stack, env);
157527
+ const found = await scanLeadingLaunch(flow, stack, stack.at(-1).display, env);
157222
157528
  return found === NO_EXECUTABLE_STEP ? null : found;
157223
157529
  }
157224
- async function scanLeadingLaunch(flow, stack, env) {
157530
+ async function scanLeadingLaunch(flow, stack, rootDisplay, env) {
157225
157531
  const top = stack[stack.length - 1];
157226
157532
  for (const step of flow.steps) {
157227
157533
  if (precedesLeadingLaunch(step)) continue;
@@ -157230,7 +157536,7 @@ async function scanLeadingLaunch(flow, stack, env) {
157230
157536
  let nested;
157231
157537
  let canonical;
157232
157538
  try {
157233
- const hop = await env.project.resolveFlowFile(path47.dirname(top.canonical), step.flow);
157539
+ const hop = await env.project.resolveFlowFile(path48.dirname(top.canonical), step.flow);
157234
157540
  canonical = hop.canonical;
157235
157541
  if (stack.some((entry) => entry.canonical === canonical)) return null;
157236
157542
  if (stack.length >= MAX_RUN_DEPTH) return null;
@@ -157244,7 +157550,8 @@ async function scanLeadingLaunch(flow, stack, env) {
157244
157550
  if (fragmentLoadRefusal(env.registry, nested, step.flow) !== void 0) return null;
157245
157551
  const inner = await scanLeadingLaunch(
157246
157552
  nested,
157247
- [...stack, { canonical, display: runDisplayFor(step.flow, stack[0].display) }],
157553
+ [...stack, { canonical, display: runDisplayFor(step.flow, rootDisplay) }],
157554
+ rootDisplay,
157248
157555
  env
157249
157556
  );
157250
157557
  if (inner !== NO_EXECUTABLE_STEP) return inner;
@@ -157264,7 +157571,7 @@ function launchTargetPlatform(launch, platform) {
157264
157571
  return null;
157265
157572
  }
157266
157573
  async function resolveAppPath(specPath, flowDir) {
157267
- const lexical = path47.resolve(flowDir, specPath);
157574
+ const lexical = path48.resolve(flowDir, specPath);
157268
157575
  try {
157269
157576
  return await fs63.realpath(lexical);
157270
157577
  } catch {
@@ -157272,7 +157579,7 @@ async function resolveAppPath(specPath, flowDir) {
157272
157579
  }
157273
157580
  }
157274
157581
  async function bootChromiumForFlow(spec, flowDir, viaUpload) {
157275
- if (viaUpload && !path47.isAbsolute(spec.path)) {
157582
+ if (viaUpload && !path48.isAbsolute(spec.path)) {
157276
157583
  throw new FailureError(
157277
157584
  `A relative chromium app path ("${spec.path}") resolves against the flow file's directory, which requires a run with no link and no ARGENT_TOOLS_URL \u2014 an uploaded flow has no real flow directory on this host. Use an absolute tool-server path instead.`,
157278
157585
  {
@@ -157346,7 +157653,7 @@ function scopeFlow(scope) {
157346
157653
  return scope.runStack[scope.runStack.length - 1].display;
157347
157654
  }
157348
157655
  function runDisplayName(target, scope) {
157349
- return runDisplayFor(target, scope.runStack[0].display);
157656
+ return runDisplayFor(target, scope.rootDisplay);
157350
157657
  }
157351
157658
  function runDisplayFor(target, rootDisplay) {
157352
157659
  const stem = runTargetName(target);
@@ -157358,7 +157665,7 @@ function stepFlow(step, scope) {
157358
157665
  return step.kind === "run" ? runDisplayName(step.flow, scope) : scopeFlow(scope);
157359
157666
  }
157360
157667
  function scopeFlowDir(scope) {
157361
- return path47.dirname(scope.runStack[scope.runStack.length - 1].canonical);
157668
+ return path48.dirname(scope.runStack[scope.runStack.length - 1].canonical);
157362
157669
  }
157363
157670
  function childScope(scope, overrides = {}) {
157364
157671
  return { ...scope, ...overrides, depth: scope.depth + 1 };
@@ -157570,7 +157877,7 @@ async function execRunStep(state3, step, scope) {
157570
157877
  if (scope.runStack.length >= MAX_RUN_DEPTH) {
157571
157878
  return fail("max run depth exceeded");
157572
157879
  }
157573
- const suppliedBase = path47.posix.basename(target);
157880
+ const suppliedBase = path48.posix.basename(target);
157574
157881
  if (spelling.state === "case_folded") {
157575
157882
  const recovery = spelling.addressable ? `reference it as "${target.slice(0, target.length - suppliedBase.length)}${spelling.actual}"` : `rename "${spelling.actual}" to "${suppliedBase}" to compose it \u2014 flow files must be lowercase .yaml`;
157576
157883
  return fail(
@@ -157755,8 +158062,20 @@ async function execLeafStep(state3, step, index, scope) {
157755
158062
  if (UI_TURNING_TOOLS.has(step.name) && state3.lastRead) {
157756
158063
  state3.lastRead.uiOrientation = void 0;
157757
158064
  }
158065
+ let prepared;
157758
158066
  try {
157759
- const result = await invokeSubTool(registry2, ctx, step.name, args);
158067
+ prepared = await prepareToolStepInputs(
158068
+ registry2,
158069
+ state3.project,
158070
+ step.name,
158071
+ nestedRunArgs(state3, step.name, args)
158072
+ );
158073
+ const result = await invokeSubTool(registry2, ctx, step.name, prepared.args, {
158074
+ ...prepared.fileInputs ? { fileInputs: prepared.fileInputs } : {},
158075
+ // The two tools that can start a nested run continue this run's
158076
+ // stack, so a flow that runs itself stops at the cycle guard.
158077
+ ...FLOW_STARTING_TOOLS.has(step.name) ? { flowStack: scope.runStack } : {}
158078
+ });
157760
158079
  if (isUnmetUiWaitResult(step.name, result)) {
157761
158080
  const note = result.note;
157762
158081
  return {
@@ -157811,8 +158130,22 @@ async function execLeafStep(state3, step, index, scope) {
157811
158130
  if (signal?.aborted) {
157812
158131
  return { ...base, status: "skip", tool: step.name, reason: ABORTED_OUTCOME.reason };
157813
158132
  }
157814
- const reframed = describeNestedParamError(registry2, err, step.name, args, step.args ?? {});
157815
- return { ...base, status: "error", tool: step.name, reason: reframed ?? errMsg4(err) };
158133
+ const reframed = describeNestedParamError(
158134
+ registry2,
158135
+ err,
158136
+ step.name,
158137
+ prepared?.args ?? args,
158138
+ step.args ?? {}
158139
+ );
158140
+ const reason = reframed ?? errMsg4(err);
158141
+ return {
158142
+ ...base,
158143
+ status: "error",
158144
+ tool: step.name,
158145
+ reason: prepared ? withClientPaths(prepared, reason) : reason
158146
+ };
158147
+ } finally {
158148
+ await prepared?.cleanup();
157816
158149
  }
157817
158150
  }
157818
158151
  case "script": {
@@ -157839,7 +158172,7 @@ function assertFlowPathShape(flowPath) {
157839
158172
  error_kind: "validation"
157840
158173
  });
157841
158174
  }
157842
- if (!path47.isAbsolute(flowPath)) {
158175
+ if (!path48.isAbsolute(flowPath)) {
157843
158176
  throw new FailureError(
157844
158177
  `Invalid flow_path "${flowPath}": flow paths must be absolute \u2014 a relative path is resolved against the tool server's working directory, not the caller's. Pass the absolute path to the flow's YAML.`,
157845
158178
  {
@@ -157863,8 +158196,8 @@ function assertFlowPathShape(flowPath) {
157863
158196
  }
157864
158197
  }
157865
158198
  function flowNameOf(clientPath) {
157866
- const clientExt = path47.extname(clientPath);
157867
- const bareExtension = path47.basename(clientPath).toLowerCase() === ".yaml";
158199
+ const clientExt = path48.extname(clientPath);
158200
+ const bareExtension = path48.basename(clientPath).toLowerCase() === ".yaml";
157868
158201
  if (!bareExtension && clientExt !== ".yaml") {
157869
158202
  const detail = clientExt.toLowerCase() === ".yaml" ? `flow files must use the lowercase .yaml extension, not "${clientExt}".` : `flow files must use the .yaml extension.`;
157870
158203
  throw new FailureError(`Invalid flow_path "${clientPath}": ${detail}`, {
@@ -157874,12 +158207,12 @@ function flowNameOf(clientPath) {
157874
158207
  error_kind: "validation"
157875
158208
  });
157876
158209
  }
157877
- const flowName = bareExtension ? "" : path47.basename(clientPath, ".yaml");
158210
+ const flowName = bareExtension ? "" : path48.basename(clientPath, ".yaml");
157878
158211
  assertSafeFlowName(flowName);
157879
158212
  return flowName;
157880
158213
  }
157881
158214
  function flowPathCasingError(clientPath, spelling) {
157882
- const suppliedBase = path47.basename(clientPath);
158215
+ const suppliedBase = path48.basename(clientPath);
157883
158216
  const recovery = spelling.state === "absent" ? `Pass the basename exactly as it appears on disk.` : spelling.addressable ? `Pass flow_path with the on-disk basename "${spelling.actual}".` : `Rename "${spelling.actual}" to "${suppliedBase}" to run it \u2014 flow files must be lowercase .yaml.`;
157884
158217
  return new FailureError(
157885
158218
  `Invalid flow_path "${clientPath}": the file must be named as it appears on disk \u2014 this filesystem matched "${suppliedBase}" case-insensitively` + (spelling.state === "case_folded" ? ` to "${spelling.actual}"` : "") + `, so the flow name (which keys the report and __baselines__/) would be one no directory entry carries. ${recovery}`,
@@ -157891,18 +158224,6 @@ function flowPathCasingError(clientPath, spelling) {
157891
158224
  }
157892
158225
  );
157893
158226
  }
157894
- function flowNameCasingError(flowName, spelling) {
157895
- const recovery = spelling.addressable ? `Pass name "${path47.basename(spelling.actual, ".yaml")}".` : `Rename "${spelling.actual}" to "${flowName}.yaml" to run it \u2014 flow files must be lowercase .yaml.`;
157896
- return new FailureError(
157897
- `Invalid flow name "${flowName}": no saved flow is named "${flowName}.yaml" \u2014 this filesystem matched it case-insensitively to "${spelling.actual}", so the flow name (which keys the report and __baselines__/) would be one no directory entry carries. ` + recovery,
157898
- {
157899
- error_code: FAILURE_CODES.FLOW_NAME_INVALID,
157900
- failure_stage: "flow_name_casing",
157901
- failure_area: "tool_server",
157902
- error_kind: "validation"
157903
- }
157904
- );
157905
- }
157906
158227
  async function resolveFlowSource(params, fileInput, flowPathInput) {
157907
158228
  if (params.name === void 0 === (params.flow_path === void 0)) {
157908
158229
  throw new FailureError("Pass exactly one flow source: name or flow_path.", {
@@ -157919,7 +158240,7 @@ async function resolveFlowSource(params, fileInput, flowPathInput) {
157919
158240
  assertFlowPathShape(clientPath2);
157920
158241
  return { filePath: params.flow_path, flowName: flowNameOf(clientPath2), viaUpload: true };
157921
158242
  }
157922
- const isVerifiedHostPath = flowPathInput?.presentOnHost === true && flowPathInput.statVerified === true && path47.resolve(params.flow_path) === path47.resolve(flowPathInput.clientPath);
158243
+ const isVerifiedHostPath = flowPathInput?.presentOnHost === true && flowPathInput.statVerified === true && path48.resolve(params.flow_path) === path48.resolve(flowPathInput.clientPath);
157923
158244
  if (!isVerifiedHostPath) {
157924
158245
  throw new FailureError(
157925
158246
  `Invalid flow_path "${params.flow_path}": explicit flow paths must be supplied through the flow_path file-input boundary. Pass the client-local path and let the argent client resolve it.`,
@@ -157935,8 +158256,8 @@ async function resolveFlowSource(params, fileInput, flowPathInput) {
157935
158256
  const clientPath = flowPathInput.clientPath;
157936
158257
  const flowName2 = flowNameOf(clientPath);
157937
158258
  const spelling2 = await classifyOnDiskSpelling(
157938
- path47.dirname(params.flow_path),
157939
- path47.basename(clientPath)
158259
+ path48.dirname(params.flow_path),
158260
+ path48.basename(clientPath)
157940
158261
  );
157941
158262
  if (spelling2.state !== "listed") throw flowPathCasingError(clientPath, spelling2);
157942
158263
  return { filePath: params.flow_path, flowName: flowName2, viaUpload: false };
@@ -157946,7 +158267,7 @@ async function resolveFlowSource(params, fileInput, flowPathInput) {
157946
158267
  const expected = getFlowPath(params.project_root, flowName);
157947
158268
  if (params.flow_file && fileInput?.viaUpload)
157948
158269
  return { filePath: params.flow_file, flowName, viaUpload: true };
157949
- if (params.flow_file && (!path47.isAbsolute(params.flow_file) || params.flow_file.split(/[\\/]+/).includes("..") || path47.resolve(params.flow_file) !== path47.resolve(expected))) {
158270
+ if (params.flow_file && (!path48.isAbsolute(params.flow_file) || params.flow_file.split(/[\\/]+/).includes("..") || path48.resolve(params.flow_file) !== path48.resolve(expected))) {
157950
158271
  throw new FailureError(
157951
158272
  `Invalid flow_file "${params.flow_file}": it must resolve to the flow's path under the project root ("${expected}"). flow_file is internal \u2014 leave it unset and pass project_root + name.`,
157952
158273
  {
@@ -157957,7 +158278,7 @@ async function resolveFlowSource(params, fileInput, flowPathInput) {
157957
158278
  }
157958
158279
  );
157959
158280
  }
157960
- const spelling = await classifyOnDiskSpelling(path47.dirname(expected), `${flowName}.yaml`);
158281
+ const spelling = await classifyOnDiskSpelling(path48.dirname(expected), `${flowName}.yaml`);
157961
158282
  if (spelling.state === "case_folded") throw flowNameCasingError(flowName, spelling);
157962
158283
  return { filePath: params.flow_file || expected, flowName, viaUpload: false };
157963
158284
  }
@@ -157989,7 +158310,7 @@ var zodSchema69 = external_exports.object({
157989
158310
  });
157990
158311
  }
157991
158312
  });
157992
- var fileInputs4 = [
158313
+ var fileInputs5 = [
157993
158314
  {
157994
158315
  target: "flow_path",
157995
158316
  path: "${flow_path}",
@@ -158022,7 +158343,7 @@ needs booting, so calling this costs nothing but a file read.
158022
158343
  Fails if the flow file does not exist.
158023
158344
  Address the flow exactly as you will address it in flow-execute: name or flow_path, one and only one; supplying both or neither is rejected. The name goes in \`name\`, which resolves <project_root>/.argent/flows/<name>.yaml.`,
158024
158345
  zodSchema: zodSchema69,
158025
- fileInputs: fileInputs4,
158346
+ fileInputs: fileInputs5,
158026
158347
  services: () => ({}),
158027
158348
  async execute(_services, params, ctx) {
158028
158349
  const { filePath, flowName } = await resolveFlowSource(
@@ -158046,40 +158367,40 @@ var import_promises12 = require("node:fs/promises");
158046
158367
  var import_node_path23 = require("node:path");
158047
158368
  var import_node_child_process37 = require("node:child_process");
158048
158369
  var import_dotenv2 = __toESM(require_main());
158049
- async function exists(path52) {
158370
+ async function exists(path53) {
158050
158371
  try {
158051
- await (0, import_promises12.access)(path52);
158372
+ await (0, import_promises12.access)(path53);
158052
158373
  return true;
158053
158374
  } catch {
158054
158375
  return false;
158055
158376
  }
158056
158377
  }
158057
- async function isDirectory(path52) {
158378
+ async function isDirectory(path53) {
158058
158379
  try {
158059
- const s = await (0, import_promises12.stat)(path52);
158380
+ const s = await (0, import_promises12.stat)(path53);
158060
158381
  return s.isDirectory();
158061
158382
  } catch {
158062
158383
  return false;
158063
158384
  }
158064
158385
  }
158065
- async function readJsonFile(path52) {
158386
+ async function readJsonFile(path53) {
158066
158387
  try {
158067
- const raw = await (0, import_promises12.readFile)(path52, "utf-8");
158388
+ const raw = await (0, import_promises12.readFile)(path53, "utf-8");
158068
158389
  return JSON.parse(raw);
158069
158390
  } catch {
158070
158391
  return null;
158071
158392
  }
158072
158393
  }
158073
- async function readTextFile(path52) {
158394
+ async function readTextFile(path53) {
158074
158395
  try {
158075
- return await (0, import_promises12.readFile)(path52, "utf-8");
158396
+ return await (0, import_promises12.readFile)(path53, "utf-8");
158076
158397
  } catch {
158077
158398
  return null;
158078
158399
  }
158079
158400
  }
158080
- async function listDir(path52) {
158401
+ async function listDir(path53) {
158081
158402
  try {
158082
- const entries = await (0, import_promises12.readdir)(path52);
158403
+ const entries = await (0, import_promises12.readdir)(path53);
158083
158404
  return entries;
158084
158405
  } catch {
158085
158406
  return null;
@@ -158340,7 +158661,7 @@ async function readWorkspaceSnapshot(workspacePath) {
158340
158661
  var zodSchema70 = external_exports.object({
158341
158662
  workspacePath: external_exports.string().describe("Absolute path to the project root directory to inspect (e.g. /Users/dev/MyApp)")
158342
158663
  });
158343
- var fileInputs5 = [
158664
+ var fileInputs6 = [
158344
158665
  { target: "workspacePath", path: "${workspacePath}", kind: "directory" }
158345
158666
  ];
158346
158667
  var gatherWorkspaceDataTool = {
@@ -158369,7 +158690,7 @@ Use when you need to inspect project configuration without manually reading mult
158369
158690
  Returns partial data if workspacePath does not exist or is not readable; missing items are represented as null or empty collections.
158370
158691
  Fails if the workspacePath is not an absolute path or the directory cannot be accessed.`,
158371
158692
  zodSchema: zodSchema70,
158372
- fileInputs: fileInputs5,
158693
+ fileInputs: fileInputs6,
158373
158694
  services: () => ({}),
158374
158695
  async execute(_services, params) {
158375
158696
  return readWorkspaceSnapshot(params.workspacePath);
@@ -158379,11 +158700,11 @@ Fails if the workspacePath is not an absolute path or the directory cannot be ac
158379
158700
  // ../tool-server/src/tools/system/update-argent.ts
158380
158701
  var import_node_child_process38 = require("node:child_process");
158381
158702
  var fs65 = __toESM(require("node:fs"));
158382
- var path48 = __toESM(require("node:path"));
158703
+ var path49 = __toESM(require("node:path"));
158383
158704
  init_zod();
158384
158705
  function resolveCliEntry() {
158385
158706
  try {
158386
- const entry = path48.join(__dirname, "cli.js");
158707
+ const entry = path49.join(__dirname, "cli.js");
158387
158708
  return fs65.existsSync(entry) ? entry : null;
158388
158709
  } catch {
158389
158710
  return null;
@@ -158398,20 +158719,20 @@ function classifyRunningInstall() {
158398
158719
  }
158399
158720
  let runningRoot;
158400
158721
  try {
158401
- runningRoot = fs65.realpathSync(path48.dirname(__dirname));
158722
+ runningRoot = fs65.realpathSync(path49.dirname(__dirname));
158402
158723
  } catch {
158403
158724
  return { kind: "global", projectRoot: null };
158404
158725
  }
158405
158726
  let dir = process.cwd();
158406
158727
  while (true) {
158407
158728
  try {
158408
- const nmReal = fs65.realpathSync(path48.join(dir, "node_modules"));
158409
- if (runningRoot === nmReal || runningRoot.startsWith(nmReal + path48.sep)) {
158729
+ const nmReal = fs65.realpathSync(path49.join(dir, "node_modules"));
158730
+ if (runningRoot === nmReal || runningRoot.startsWith(nmReal + path49.sep)) {
158410
158731
  return { kind: "local", projectRoot: dir };
158411
158732
  }
158412
158733
  } catch {
158413
158734
  }
158414
- const parent = path48.dirname(dir);
158735
+ const parent = path49.dirname(dir);
158415
158736
  if (parent === dir) break;
158416
158737
  dir = parent;
158417
158738
  }
@@ -158425,15 +158746,15 @@ function findDeclaringProjectRoot(startDir) {
158425
158746
  return null;
158426
158747
  }
158427
158748
  while (true) {
158428
- if (fs65.existsSync(path48.join(dir, ".argent", "install.json"))) return dir;
158749
+ if (fs65.existsSync(path49.join(dir, ".argent", "install.json"))) return dir;
158429
158750
  try {
158430
- const manifest = JSON.parse(fs65.readFileSync(path48.join(dir, "package.json"), "utf8"));
158751
+ const manifest = JSON.parse(fs65.readFileSync(path49.join(dir, "package.json"), "utf8"));
158431
158752
  if (manifest.devDependencies?.[PACKAGE_NAME2] || manifest.dependencies?.[PACKAGE_NAME2] || manifest.optionalDependencies?.[PACKAGE_NAME2]) {
158432
158753
  return dir;
158433
158754
  }
158434
158755
  } catch {
158435
158756
  }
158436
- const parent = path48.dirname(dir);
158757
+ const parent = path49.dirname(dir);
158437
158758
  if (parent === dir) return null;
158438
158759
  dir = parent;
158439
158760
  }
@@ -158592,7 +158913,7 @@ var capability32 = {
158592
158913
  apple: { simulator: true, device: true },
158593
158914
  android: { emulator: true, device: true, unknown: true }
158594
158915
  };
158595
- var fileInputs6 = [
158916
+ var fileInputs7 = [
158596
158917
  { target: "baselinePath", path: "${baselinePath}", kind: "file", optional: true },
158597
158918
  { target: "currentPath", path: "${currentPath}", kind: "file", optional: true },
158598
158919
  { target: "outputDir", path: "${outputDir}", kind: "probe", optional: true }
@@ -158615,7 +158936,7 @@ Fails if the input sources are invalid, PNG files cannot be read, outputDir cann
158615
158936
  searchHint: "compare screenshots png diff visual UI changes UI regression visual regression screenshot diff changed regions text ocr live capture",
158616
158937
  zodSchema: zodSchema73,
158617
158938
  capability: capability32,
158618
- fileInputs: fileInputs6,
158939
+ fileInputs: fileInputs7,
158619
158940
  services: (params) => {
158620
158941
  if (params.captureBaseline || params.captureCurrent) {
158621
158942
  const device = resolveDevice(params.udid);
@@ -159671,33 +159992,33 @@ function startSimulatorWatcher(registry2) {
159671
159992
  var import_node_child_process40 = require("node:child_process");
159672
159993
  var fs68 = __toESM(require("node:fs"));
159673
159994
  var os20 = __toESM(require("node:os"));
159674
- var path50 = __toESM(require("node:path"));
159995
+ var path51 = __toESM(require("node:path"));
159675
159996
  function ensureLensAppBundle(electronBin) {
159676
159997
  if (process.platform !== "darwin") return null;
159677
159998
  try {
159678
159999
  const realApp = electronBin.replace(/\/Contents\/MacOS\/[^/]+$/, "");
159679
160000
  if (!realApp.endsWith(".app")) return null;
159680
- const realContents = path50.join(realApp, "Contents");
159681
- const wrapperContents = path50.join(
160001
+ const realContents = path51.join(realApp, "Contents");
160002
+ const wrapperContents = path51.join(
159682
160003
  os20.tmpdir(),
159683
160004
  "argent-lens-app",
159684
160005
  "Argent Lens.app",
159685
160006
  "Contents"
159686
160007
  );
159687
- const wrapperExec = path50.join(wrapperContents, "MacOS", "Electron");
160008
+ const wrapperExec = path51.join(wrapperContents, "MacOS", "Electron");
159688
160009
  try {
159689
160010
  if (fs68.realpathSync(wrapperExec) === fs68.realpathSync(electronBin)) return wrapperExec;
159690
160011
  } catch {
159691
160012
  }
159692
- fs68.rmSync(path50.dirname(wrapperContents), { recursive: true, force: true });
159693
- fs68.mkdirSync(path50.join(wrapperContents, "MacOS"), { recursive: true });
159694
- fs68.symlinkSync(path50.join(realContents, "Frameworks"), path50.join(wrapperContents, "Frameworks"));
159695
- fs68.symlinkSync(path50.join(realContents, "Resources"), path50.join(wrapperContents, "Resources"));
160013
+ fs68.rmSync(path51.dirname(wrapperContents), { recursive: true, force: true });
160014
+ fs68.mkdirSync(path51.join(wrapperContents, "MacOS"), { recursive: true });
160015
+ fs68.symlinkSync(path51.join(realContents, "Frameworks"), path51.join(wrapperContents, "Frameworks"));
160016
+ fs68.symlinkSync(path51.join(realContents, "Resources"), path51.join(wrapperContents, "Resources"));
159696
160017
  fs68.symlinkSync(electronBin, wrapperExec);
159697
- const pkgInfo = path50.join(realContents, "PkgInfo");
159698
- if (fs68.existsSync(pkgInfo)) fs68.copyFileSync(pkgInfo, path50.join(wrapperContents, "PkgInfo"));
159699
- const plist = path50.join(wrapperContents, "Info.plist");
159700
- fs68.copyFileSync(path50.join(realContents, "Info.plist"), plist);
160018
+ const pkgInfo = path51.join(realContents, "PkgInfo");
160019
+ if (fs68.existsSync(pkgInfo)) fs68.copyFileSync(pkgInfo, path51.join(wrapperContents, "PkgInfo"));
160020
+ const plist = path51.join(wrapperContents, "Info.plist");
160021
+ fs68.copyFileSync(path51.join(realContents, "Info.plist"), plist);
159701
160022
  const setPlist = (entry, value) => {
159702
160023
  try {
159703
160024
  (0, import_node_child_process40.execFileSync)("/usr/libexec/PlistBuddy", ["-c", `Set :${entry} ${value}`, plist]);
@@ -159738,7 +160059,7 @@ function createPreviewWindowManager(opts = {}) {
159738
160059
  };
159739
160060
  const resolveMainScript = () => {
159740
160061
  if (opts.mainScript) return opts.mainScript;
159741
- const bundled = path50.join(__dirname, "preview-window", "main.cjs");
160062
+ const bundled = path51.join(__dirname, "preview-window", "main.cjs");
159742
160063
  if (fs68.existsSync(bundled)) return bundled;
159743
160064
  return require.resolve("@argent/preview-window/dist/main.js");
159744
160065
  };
@@ -159885,7 +160206,7 @@ function start() {
159885
160206
  attachRegistryLogger(registry2);
159886
160207
  let eventLog = null;
159887
160208
  if (isFlagEnabled("tool-server-event-log")) {
159888
- const eventLogPath = process.env.ARGENT_EVENT_LOG || path51.join((0, import_node_os14.homedir)(), ".argent", "tool-server-events.jsonl");
160209
+ const eventLogPath = process.env.ARGENT_EVENT_LOG || path52.join((0, import_node_os14.homedir)(), ".argent", "tool-server-events.jsonl");
159889
160210
  try {
159890
160211
  eventLog = createToolServerEventLog({ filePath: eventLogPath });
159891
160212
  } catch (err) {