@swmansion/argent 0.35.1-next.99 → 0.36.0

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.
Binary file
Binary file
Binary file
Binary file
Binary file
package/dist/cli-cmds.mjs CHANGED
@@ -11012,13 +11012,13 @@ var require_min_release_age = __commonJS({
11012
11012
  return Number.isFinite(days) && days > 0 ? days * config_parse_1.DAY_MS : 0;
11013
11013
  }
11014
11014
  function probe(p, cwd) {
11015
- return new Promise((resolve26) => {
11015
+ return new Promise((resolve25) => {
11016
11016
  (0, node_child_process_1.exec)(p.command, { cwd, timeout: PROBE_TIMEOUT_MS2, windowsHide: true }, (err, stdout2) => {
11017
11017
  if (err) {
11018
- resolve26(0);
11018
+ resolve25(0);
11019
11019
  return;
11020
11020
  }
11021
- resolve26(p.parse(stdout2));
11021
+ resolve25(p.parse(stdout2));
11022
11022
  });
11023
11023
  });
11024
11024
  }
@@ -11051,12 +11051,12 @@ var require_registry = __commonJS({
11051
11051
  var node_https_1 = __importDefault(__require("node:https"));
11052
11052
  var REQUEST_TIMEOUT_MS = 1e4;
11053
11053
  function fetchRegistryInfo2(url2) {
11054
- return new Promise((resolve26) => {
11054
+ return new Promise((resolve25) => {
11055
11055
  let resolved = false;
11056
11056
  const safeResolve = (value) => {
11057
11057
  if (!resolved) {
11058
11058
  resolved = true;
11059
- resolve26(value);
11059
+ resolve25(value);
11060
11060
  }
11061
11061
  };
11062
11062
  const req = node_https_1.default.get(url2, { timeout: REQUEST_TIMEOUT_MS }, (res) => {
@@ -12226,7 +12226,7 @@ function generateAuthToken() {
12226
12226
  return generateToken();
12227
12227
  }
12228
12228
  function findFreePort() {
12229
- return new Promise((resolve26, reject) => {
12229
+ return new Promise((resolve25, reject) => {
12230
12230
  const srv = net.createServer();
12231
12231
  srv.listen(0, "127.0.0.1", () => {
12232
12232
  const addr = srv.address();
@@ -12237,7 +12237,7 @@ function findFreePort() {
12237
12237
  const port = addr.port;
12238
12238
  srv.close((err) => {
12239
12239
  if (err) reject(err);
12240
- else resolve26(port);
12240
+ else resolve25(port);
12241
12241
  });
12242
12242
  });
12243
12243
  srv.on("error", reject);
@@ -12346,7 +12346,7 @@ function parseListeningPort(line) {
12346
12346
  return match ? parseInt(match[1], 10) : null;
12347
12347
  }
12348
12348
  function spawnToolsServer(paths, port, options = {}) {
12349
- return new Promise((resolve26, reject) => {
12349
+ return new Promise((resolve25, reject) => {
12350
12350
  let logFd;
12351
12351
  try {
12352
12352
  fs8.mkdirSync(STATE_DIR, { recursive: true });
@@ -12391,7 +12391,7 @@ function spawnToolsServer(paths, port, options = {}) {
12391
12391
  child.stdout?.resume();
12392
12392
  child.stdout?.unref?.();
12393
12393
  child.unref();
12394
- settle2(() => resolve26({ port: actualPort, pid }));
12394
+ settle2(() => resolve25({ port: actualPort, pid }));
12395
12395
  }
12396
12396
  });
12397
12397
  child.on("error", (err) => {
@@ -18645,7 +18645,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
18645
18645
  var NONE = 0;
18646
18646
  var ASSUMED = 1;
18647
18647
  var PROVEN = 2;
18648
- function isRecursive(inst, stack, resolve26) {
18648
+ function isRecursive(inst, stack, resolve25) {
18649
18649
  const cached3 = recursive.get(inst);
18650
18650
  if (cached3 !== void 0)
18651
18651
  return cached3 ? PROVEN : NONE;
@@ -18655,7 +18655,7 @@ function isRecursive(inst, stack, resolve26) {
18655
18655
  let result = NONE;
18656
18656
  const check3 = (child) => {
18657
18657
  if (result !== PROVEN && child?._zod) {
18658
- const answer = isRecursive(child, stack, resolve26);
18658
+ const answer = isRecursive(child, stack, resolve25);
18659
18659
  if (answer > result)
18660
18660
  result = answer;
18661
18661
  }
@@ -18666,7 +18666,7 @@ function isRecursive(inst, stack, resolve26) {
18666
18666
  const desc = Object.getOwnPropertyDescriptor(sh, key);
18667
18667
  if (spread && !desc.enumerable)
18668
18668
  continue;
18669
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve26) : NONE;
18669
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve25) : NONE;
18670
18670
  if (child > answer)
18671
18671
  answer = child;
18672
18672
  }
@@ -18730,7 +18730,7 @@ function isRecursive(inst, stack, resolve26) {
18730
18730
  break;
18731
18731
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
18732
18732
  case "lazy": {
18733
- const inner = def._cachedInner ?? (resolve26 ? inst._zod.innerType : void 0);
18733
+ const inner = def._cachedInner ?? (resolve25 ? inst._zod.innerType : void 0);
18734
18734
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
18735
18735
  break;
18736
18736
  }
@@ -33640,7 +33640,7 @@ async function runTar(archive, args, signal) {
33640
33640
  child.on("error", (err) => {
33641
33641
  childError = err;
33642
33642
  });
33643
- const closed = new Promise((resolve26) => child.once("close", resolve26));
33643
+ const closed = new Promise((resolve25) => child.once("close", resolve25));
33644
33644
  const stdout2 = collect(child.stdout, MAX_LISTING_BYTES, {
33645
33645
  maxLines: MAX_LISTING_LINES,
33646
33646
  onOverflow: () => child.kill()
@@ -33874,9 +33874,9 @@ function untrackArchive(archive) {
33874
33874
  process.removeListener("exit", removePendingArchives);
33875
33875
  }
33876
33876
  function sha256File(filePath, signal) {
33877
- return new Promise((resolve26, reject) => {
33877
+ return new Promise((resolve25, reject) => {
33878
33878
  const hash2 = createHash2("sha256");
33879
- createReadStream2(filePath, { signal }).on("data", (chunk) => hash2.update(chunk)).on("end", () => resolve26(hash2.digest("hex"))).on("error", reject);
33879
+ createReadStream2(filePath, { signal }).on("data", (chunk) => hash2.update(chunk)).on("end", () => resolve25(hash2.digest("hex"))).on("error", reject);
33880
33880
  });
33881
33881
  }
33882
33882
  function toolServerError(text2) {
@@ -36038,8 +36038,8 @@ var Deferred = class {
36038
36038
  _resolve;
36039
36039
  _reject;
36040
36040
  constructor() {
36041
- this._promise = new Promise((resolve26, reject) => {
36042
- this._resolve = resolve26;
36041
+ this._promise = new Promise((resolve25, reject) => {
36042
+ this._resolve = resolve25;
36043
36043
  this._reject = reject;
36044
36044
  });
36045
36045
  }
@@ -36932,8 +36932,8 @@ var ExportOperation = class {
36932
36932
  _metrics;
36933
36933
  _exportScheduledResolve;
36934
36934
  constructor(exporter, logRecords, exportTimeoutMillis, metrics) {
36935
- this._exportScheduledPromise = new Promise((resolve26) => {
36936
- this._exportScheduledResolve = resolve26;
36935
+ this._exportScheduledPromise = new Promise((resolve25) => {
36936
+ this._exportScheduledResolve = resolve25;
36937
36937
  });
36938
36938
  this._exportCompleted = this._executeExport(exporter, logRecords, exportTimeoutMillis);
36939
36939
  this._metrics = metrics;
@@ -36958,7 +36958,7 @@ var ExportOperation = class {
36958
36958
  }
36959
36959
  }
36960
36960
  async _exportWithTimeout(exporter, logRecords, exportTimeoutMillis) {
36961
- return new Promise((resolve26, reject) => {
36961
+ return new Promise((resolve25, reject) => {
36962
36962
  const timer = setTimeout(() => {
36963
36963
  reject(new Error("Timeout"));
36964
36964
  }, exportTimeoutMillis);
@@ -36966,7 +36966,7 @@ var ExportOperation = class {
36966
36966
  this._metrics.finishLogs(logRecords.length, result.error);
36967
36967
  clearTimeout(timer);
36968
36968
  if (result.code === ExportResultCode.SUCCESS) {
36969
- resolve26();
36969
+ resolve25();
36970
36970
  } else {
36971
36971
  reject(result.error ?? new Error("BatchLogRecordProcessor: log record export failed"));
36972
36972
  }
@@ -37747,7 +37747,7 @@ function parseRetryAfterToMills(retryAfter) {
37747
37747
  var DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION4}`;
37748
37748
  var MAX_RESPONSE_BODY_SIZE = 4 * 1024 * 1024;
37749
37749
  function sendWithHttp(request, url2, headers, compression, userAgent, agent, data, timeoutMillis) {
37750
- return new Promise((resolve26) => {
37750
+ return new Promise((resolve25) => {
37751
37751
  const parsedUrl = new URL(url2);
37752
37752
  if (userAgent) {
37753
37753
  headers["User-Agent"] = `${userAgent} ${DEFAULT_USER_AGENT}`;
@@ -37766,7 +37766,7 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
37766
37766
  responseSize += chunk.length;
37767
37767
  if (responseSize > MAX_RESPONSE_BODY_SIZE) {
37768
37768
  const sizeError = new Error(`OTLP export response body exceeded size limit of ${MAX_RESPONSE_BODY_SIZE} bytes`);
37769
- resolve26({ status: "failure", error: sizeError });
37769
+ resolve25({ status: "failure", error: sizeError });
37770
37770
  res.destroy();
37771
37771
  return;
37772
37772
  }
@@ -37774,18 +37774,18 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
37774
37774
  });
37775
37775
  res.on("end", () => {
37776
37776
  if (res.statusCode && res.statusCode <= 299) {
37777
- resolve26({
37777
+ resolve25({
37778
37778
  status: "success",
37779
37779
  data: Buffer.concat(responseData)
37780
37780
  });
37781
37781
  } else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {
37782
- resolve26({
37782
+ resolve25({
37783
37783
  status: "retryable",
37784
37784
  retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
37785
37785
  });
37786
37786
  } else {
37787
37787
  const error63 = new OTLPExporterError(res.statusMessage, res.statusCode, Buffer.concat(responseData).toString());
37788
- resolve26({
37788
+ resolve25({
37789
37789
  status: "failure",
37790
37790
  error: error63
37791
37791
  });
@@ -37793,17 +37793,17 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
37793
37793
  });
37794
37794
  res.on("error", (error63) => {
37795
37795
  if (res.statusCode && res.statusCode <= 299) {
37796
- resolve26({
37796
+ resolve25({
37797
37797
  status: "success"
37798
37798
  });
37799
37799
  } else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {
37800
- resolve26({
37800
+ resolve25({
37801
37801
  status: "retryable",
37802
37802
  error: error63,
37803
37803
  retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
37804
37804
  });
37805
37805
  } else {
37806
- resolve26({
37806
+ resolve25({
37807
37807
  status: "failure",
37808
37808
  error: error63
37809
37809
  });
@@ -37812,26 +37812,26 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
37812
37812
  });
37813
37813
  req.setTimeout(timeoutMillis, () => {
37814
37814
  req.destroy();
37815
- resolve26({
37815
+ resolve25({
37816
37816
  status: "retryable",
37817
37817
  error: new Error("Request timed out")
37818
37818
  });
37819
37819
  });
37820
37820
  req.on("error", (error63) => {
37821
37821
  if (isHttpTransportNetworkErrorRetryable(error63)) {
37822
- resolve26({
37822
+ resolve25({
37823
37823
  status: "retryable",
37824
37824
  error: error63
37825
37825
  });
37826
37826
  } else {
37827
- resolve26({
37827
+ resolve25({
37828
37828
  status: "failure",
37829
37829
  error: error63
37830
37830
  });
37831
37831
  }
37832
37832
  });
37833
37833
  compressAndSend(req, compression, data, (error63) => {
37834
- resolve26({
37834
+ resolve25({
37835
37835
  status: "failure",
37836
37836
  error: error63
37837
37837
  });
@@ -37921,9 +37921,9 @@ var RetryingTransport = class {
37921
37921
  this._transport = transport;
37922
37922
  }
37923
37923
  retry(data, timeoutMillis, inMillis) {
37924
- return new Promise((resolve26, reject) => {
37924
+ return new Promise((resolve25, reject) => {
37925
37925
  setTimeout(() => {
37926
- this._transport.send(data, timeoutMillis).then(resolve26, reject);
37926
+ this._transport.send(data, timeoutMillis).then(resolve25, reject);
37927
37927
  }, inMillis);
37928
37928
  });
37929
37929
  }
@@ -39157,7 +39157,7 @@ function isCi(env = process.env) {
39157
39157
  var SESSION_ID2 = randomUUID5();
39158
39158
  function readCliVersion() {
39159
39159
  if (true) {
39160
- return "0.35.1-next.99";
39160
+ return "0.36.0";
39161
39161
  }
39162
39162
  return "0.0.0";
39163
39163
  }
@@ -39467,12 +39467,12 @@ function resolveHostFingerprint() {
39467
39467
  }
39468
39468
  }
39469
39469
  function resolveHostFingerprintAsync() {
39470
- return new Promise((resolve26) => {
39470
+ return new Promise((resolve25) => {
39471
39471
  let binary;
39472
39472
  try {
39473
39473
  binary = simulatorServerBinaryPath();
39474
39474
  } catch {
39475
- resolve26(null);
39475
+ resolve25(null);
39476
39476
  return;
39477
39477
  }
39478
39478
  let settled = false;
@@ -39485,7 +39485,7 @@ function resolveHostFingerprintAsync() {
39485
39485
  child?.kill("SIGKILL");
39486
39486
  } catch {
39487
39487
  }
39488
- resolve26(value);
39488
+ resolve25(value);
39489
39489
  };
39490
39490
  const watchdog = setTimeout(() => finish(null), FINGERPRINT_TIMEOUT_MS);
39491
39491
  watchdog.unref?.();
@@ -39705,7 +39705,7 @@ var DRAIN_GRACE_MS = 250;
39705
39705
  async function raceDrain(client2, timeoutMs) {
39706
39706
  await Promise.race([
39707
39707
  client2.shutdown(timeoutMs),
39708
- new Promise((resolve26) => setTimeout(resolve26, timeoutMs + DRAIN_GRACE_MS).unref())
39708
+ new Promise((resolve25) => setTimeout(resolve25, timeoutMs + DRAIN_GRACE_MS).unref())
39709
39709
  ]);
39710
39710
  }
39711
39711
  async function shutdown(timeoutMs = SHORT_FLUSH_TIMEOUT_MS) {
@@ -40767,7 +40767,7 @@ async function readMarkerFile(marker) {
40767
40767
  }
40768
40768
  if (owner) return owner;
40769
40769
  if (attempt === MARKER_READ_RETRIES) return null;
40770
- await new Promise((resolve26) => setTimeout(resolve26, MARKER_READ_DELAY_MS));
40770
+ await new Promise((resolve25) => setTimeout(resolve25, MARKER_READ_DELAY_MS));
40771
40771
  }
40772
40772
  }
40773
40773
  async function classifyExportDir(dir, flowPath) {
@@ -40895,7 +40895,7 @@ function resolveArtifactDisplayPaths(report) {
40895
40895
  }
40896
40896
  function exitAfterFlush(code, streams = [process.stdout, process.stderr]) {
40897
40897
  return Promise.all(
40898
- streams.map((s) => new Promise((resolve26) => s.write("", () => resolve26())))
40898
+ streams.map((s) => new Promise((resolve25) => s.write("", () => resolve25())))
40899
40899
  ).then(() => process.exit(code));
40900
40900
  }
40901
40901
  function renderReport(report) {
@@ -41962,6 +41962,11 @@ function applyDeviceFromEnv(payload, schema, positional, env = process.env) {
41962
41962
  }
41963
41963
 
41964
41964
  // ../argent-cli/src/run.ts
41965
+ function outFlagPath(value) {
41966
+ const out = value?.trim();
41967
+ if (!out) throw new FlagParseException("--out requires a path");
41968
+ return out;
41969
+ }
41965
41970
  function splitOptions(argv) {
41966
41971
  let json2 = false;
41967
41972
  let outPath = null;
@@ -41973,14 +41978,12 @@ function splitOptions(argv) {
41973
41978
  continue;
41974
41979
  }
41975
41980
  if (tok === "--out") {
41976
- const v = argv[i2 + 1];
41977
- if (!v) throw new FlagParseException("--out requires a path");
41978
- outPath = v;
41981
+ outPath = outFlagPath(argv[i2 + 1]);
41979
41982
  i2 += 1;
41980
41983
  continue;
41981
41984
  }
41982
41985
  if (tok.startsWith("--out=")) {
41983
- outPath = tok.slice("--out=".length);
41986
+ outPath = outFlagPath(tok.slice("--out=".length));
41984
41987
  continue;
41985
41988
  }
41986
41989
  rest.push(tok);
@@ -41988,13 +41991,13 @@ function splitOptions(argv) {
41988
41991
  return { json: json2, outPath, argvForFlags: rest };
41989
41992
  }
41990
41993
  async function readStdin() {
41991
- return new Promise((resolve26, reject) => {
41994
+ return new Promise((resolve25, reject) => {
41992
41995
  let data = "";
41993
41996
  process.stdin.setEncoding("utf8");
41994
41997
  process.stdin.on("data", (chunk) => {
41995
41998
  data += chunk;
41996
41999
  });
41997
- process.stdin.on("end", () => resolve26(data));
42000
+ process.stdin.on("end", () => resolve25(data));
41998
42001
  process.stdin.on("error", reject);
41999
42002
  });
42000
42003
  }
@@ -42007,7 +42010,7 @@ function printToolHelp(meta3) {
42007
42010
  ${description}
42008
42011
  `);
42009
42012
  console.log("Flags:");
42010
- console.log(formatSchemaUsage(schema));
42013
+ console.log(formatSchemaUsage(withoutGlobalFlags(schema)));
42011
42014
  console.log("\nGlobal flags:");
42012
42015
  if (!hasOwnArgsField) {
42013
42016
  console.log(" --args <json> Pass the entire payload as JSON (overrides flags)");
@@ -42016,15 +42019,20 @@ ${description}
42016
42019
  console.log(" --<field>-json <json> Pass a single field as JSON (objects/nested arrays)");
42017
42020
  console.log(" --json Print only the raw JSON result");
42018
42021
  console.log(
42019
- " --out <path> Save the image result, or the screen after an action, to <path>"
42022
+ " --out <path> Save the image result, or the screen after an action, to <path>; outranks a payload `out`"
42020
42023
  );
42021
42024
  console.log(" --help, -h Show this help");
42022
42025
  const deviceField = requiredDeviceField(schema);
42023
42026
  if (deviceField) console.log(`
42024
42027
  ARGENT_UDID sets --${deviceField} when the call leaves it out.`);
42025
42028
  }
42029
+ function withoutGlobalFlags(schema) {
42030
+ if (!schema?.properties) return schema;
42031
+ const { out: _out, ...properties } = schema.properties;
42032
+ return { ...schema, properties };
42033
+ }
42026
42034
  async function fetchImageToFile(result, outPath) {
42027
- const url2 = result.url;
42035
+ const url2 = result?.url;
42028
42036
  if (!url2) {
42029
42037
  throw new Error("Tool result did not include a `url`; cannot save image");
42030
42038
  }
@@ -42033,7 +42041,7 @@ async function fetchImageToFile(result, outPath) {
42033
42041
  writeImageFile(outPath, Buffer.from(await res.arrayBuffer()));
42034
42042
  }
42035
42043
  function drainStdout() {
42036
- return new Promise((resolve26) => process.stdout.write("", () => resolve26()));
42044
+ return new Promise((resolve25) => process.stdout.write("", () => resolve25()));
42037
42045
  }
42038
42046
  function onReaderClosed(exit) {
42039
42047
  for (const stream of [process.stdout, process.stderr]) {
@@ -42045,9 +42053,12 @@ function onReaderClosed(exit) {
42045
42053
  });
42046
42054
  }
42047
42055
  }
42048
- function writeImageFile(outPath, data) {
42049
- fs16.mkdirSync(path22.dirname(path22.resolve(outPath)), { recursive: true });
42050
- fs16.writeFileSync(outPath, data);
42056
+ function writeImageFile(file2, data) {
42057
+ fs16.mkdirSync(path22.dirname(file2), { recursive: true });
42058
+ if (fs16.statSync(file2, { throwIfNoEntry: false })?.isFile() === false) {
42059
+ throw new Error(`${file2} is not a regular file`);
42060
+ }
42061
+ fs16.writeFileSync(file2, data);
42051
42062
  }
42052
42063
  function renderResult(result, outputHint, images, json2) {
42053
42064
  if (json2) return JSON.stringify(result, null, 2);
@@ -42110,8 +42121,9 @@ result, without waiting.
42110
42121
  Set ARGENT_UDID to use that device when a tool needs --udid or --device_id
42111
42122
  and the call does not pass one.
42112
42123
 
42113
- Exits 1 when the tool fails, or when --out without --json gets no screen
42114
- after an action. Also exits 1 when the result reports that the call did not
42124
+ Exits 1 when the tool fails, when an image result is not saved to --out or
42125
+ a payload \`out\`, or when --out without --json gets no screen after an
42126
+ action. Also exits 1 when the result reports that the call did not
42115
42127
  do its job: an e2e test that does not pass, an await-ui-element or
42116
42128
  await-network-request wait with success=false, a run-sequence that a step
42117
42129
  stopped, a debugger tool with no connection or an error, a native-devtools
@@ -42249,6 +42261,7 @@ settled=false or debugger-status's not_connected.
42249
42261
  `Note: ignoring unused argument(s): ${parsed.positional.join(", ")}. Pass values as --flag <value> or --flag=<value>.`
42250
42262
  );
42251
42263
  }
42264
+ if (outPath && meta3.outputHint === "image") delete payload.out;
42252
42265
  const missing = findMissingRequired(payload, schema);
42253
42266
  if (missing.length > 0) {
42254
42267
  const envHint = deviceField && missing.includes(deviceField) ? ` (--${deviceField} can come from ARGENT_UDID)` : "";
@@ -42258,6 +42271,17 @@ settled=false or debugger-status's not_connected.
42258
42271
  envHint
42259
42272
  );
42260
42273
  }
42274
+ const payloadOut = typeof payload.out === "string" ? payload.out.trim() : null;
42275
+ if (meta3.outputHint === "image" && payload.out !== void 0 && !path22.isAbsolute(payloadOut ?? "")) {
42276
+ await failInvocation(
42277
+ "`out` must be an absolute path on this computer; `--out <path>` also takes a relative one",
42278
+ null,
42279
+ {
42280
+ error_code: FAILURE_CODES.CLI_RUN_INPUT_VALIDATION_FAILED,
42281
+ failure_stage: "cli_run_payload_out"
42282
+ }
42283
+ );
42284
+ }
42261
42285
  let result;
42262
42286
  let note2;
42263
42287
  let failure2;
@@ -42327,19 +42351,20 @@ settled=false or debugger-status's not_connected.
42327
42351
  process.exit(1);
42328
42352
  }
42329
42353
  };
42330
- if (outPath && meta3.outputHint === "image") {
42354
+ const imageOut = outPath ?? payloadOut;
42355
+ if (imageOut && meta3.outputHint === "image") {
42331
42356
  await saveImage(async () => {
42332
42357
  if (images.length > 0) {
42333
- writeImageFile(outPath, images[0].data);
42334
- } else if (result && typeof result === "object") {
42335
- await fetchImageToFile(result, outPath);
42358
+ writeImageFile(imageOut, images[0].data);
42359
+ } else {
42360
+ await fetchImageToFile(result, imageOut);
42336
42361
  }
42337
42362
  });
42338
42363
  }
42339
42364
  if (note2) console.error(note2);
42340
42365
  console.log(renderResult(result, meta3.outputHint, images, json2));
42341
- if (outPath && meta3.outputHint === "image" && !json2) {
42342
- console.log(`Wrote: ${outPath}`);
42366
+ if (imageOut && meta3.outputHint === "image" && !json2) {
42367
+ console.log(`Wrote: ${imageOut}`);
42343
42368
  }
42344
42369
  if (!json2) {
42345
42370
  const capture = await captureAfterAction({ client: client2, toolName, payload, profiling });
@@ -43294,7 +43319,7 @@ function ptyInjectBeats(text2) {
43294
43319
  ];
43295
43320
  }
43296
43321
  function sleep2(ms) {
43297
- return new Promise((resolve26) => setTimeout(resolve26, ms));
43322
+ return new Promise((resolve25) => setTimeout(resolve25, ms));
43298
43323
  }
43299
43324
  var DEFAULT_COLS = 80;
43300
43325
  var DEFAULT_ROWS = 24;
@@ -43516,7 +43541,7 @@ var DEATH_CONFIRMATIONS = 3;
43516
43541
  var SSE_RECONNECT_MS = 1e3;
43517
43542
  var authHeaders3 = {};
43518
43543
  function sleep3(ms) {
43519
- return new Promise((resolve26) => setTimeout(resolve26, ms));
43544
+ return new Promise((resolve25) => setTimeout(resolve25, ms));
43520
43545
  }
43521
43546
  var TRUST_PROMPT_RE = /trust this folder|do you trust|yes,? i trust|trust the files in this/i;
43522
43547
  async function dismissTrustPrompt(session) {
@@ -51718,7 +51743,7 @@ import * as path41 from "node:path";
51718
51743
 
51719
51744
  // ../argent-installer/src/init-scope.ts
51720
51745
  import { existsSync as existsSync19 } from "node:fs";
51721
- import { resolve as resolve23 } from "node:path";
51746
+ import { resolve as resolve22 } from "node:path";
51722
51747
 
51723
51748
  // ../argent-installer/src/init-skills.ts
51724
51749
  import { spawn as spawn6 } from "node:child_process";
@@ -17177,7 +17177,7 @@ function isCi(env = process.env) {
17177
17177
  var SESSION_ID = randomUUID4();
17178
17178
  function readCliVersion() {
17179
17179
  if (true) {
17180
- return "0.35.1-next.99";
17180
+ return "0.36.0";
17181
17181
  }
17182
17182
  return "0.0.0";
17183
17183
  }
@@ -32151,9 +32151,9 @@ function writeOwnFileInPlace(file, data, mode) {
32151
32151
  return false;
32152
32152
  }
32153
32153
  try {
32154
- const stat6 = fs.fstatSync(fd);
32155
- if (!stat6.isFile() || stat6.uid !== uid && uid !== 0) return false;
32156
- fs.fchmodSync(fd, stat6.mode & mode & 511);
32154
+ const stat7 = fs.fstatSync(fd);
32155
+ if (!stat7.isFile() || stat7.uid !== uid && uid !== 0) return false;
32156
+ fs.fchmodSync(fd, stat7.mode & mode & 511);
32157
32157
  fs.ftruncateSync(fd);
32158
32158
  fs.writeFileSync(fd, data);
32159
32159
  return true;
@@ -32863,21 +32863,21 @@ function primaryGid() {
32863
32863
  function untrusted(dir) {
32864
32864
  const uid = process.getuid?.();
32865
32865
  if (uid === void 0) return null;
32866
- const otherCanWrite = (stat7) => {
32867
- const ownPrivateGroup = process.platform === "linux" && stat7.gid === primaryGid();
32868
- return (stat7.mode & 2) !== 0 || (stat7.mode & 16) !== 0 && !ownPrivateGroup;
32866
+ const otherCanWrite = (stat8) => {
32867
+ const ownPrivateGroup = process.platform === "linux" && stat8.gid === primaryGid();
32868
+ return (stat8.mode & 2) !== 0 || (stat8.mode & 16) !== 0 && !ownPrivateGroup;
32869
32869
  };
32870
- let stat6;
32870
+ let stat7;
32871
32871
  let parent;
32872
32872
  try {
32873
- stat6 = fs7.lstatSync(dir);
32873
+ stat7 = fs7.lstatSync(dir);
32874
32874
  parent = fs7.statSync(path7.dirname(dir));
32875
32875
  } catch {
32876
32876
  return "it cannot be read";
32877
32877
  }
32878
- if (!stat6.isDirectory()) return "it is not a directory";
32879
- if (stat6.uid !== uid) return "another account owns it";
32880
- if ((stat6.mode & 63) !== 0) return "other accounts can read or write it";
32878
+ if (!stat7.isDirectory()) return "it is not a directory";
32879
+ if (stat7.uid !== uid) return "another account owns it";
32880
+ if ((stat7.mode & 63) !== 0) return "other accounts can read or write it";
32881
32881
  if (parent.uid !== uid && parent.uid !== 0 || otherCanWrite(parent)) {
32882
32882
  return "other accounts can write its parent directory";
32883
32883
  }
@@ -33214,13 +33214,13 @@ function isWritable(dir) {
33214
33214
  return false;
33215
33215
  }
33216
33216
  }
33217
- function homeRefusal(stat6, uid) {
33218
- if (stat6.uid !== uid && !(stat6.uid === 0 && isWritable(STATE_DIR))) {
33217
+ function homeRefusal(stat7, uid) {
33218
+ if (stat7.uid !== uid && !(stat7.uid === 0 && isWritable(STATE_DIR))) {
33219
33219
  return `The Argent home ${STATE_DIR} belongs to another user. Change its owner or set ARGENT_HOME_DIR to a directory you own.`;
33220
33220
  }
33221
- const ownPrivateGroup = process.platform === "linux" && stat6.gid === primaryGid2();
33222
- const groupCanWrite = (stat6.mode & 16) !== 0 && !ownPrivateGroup;
33223
- if ((stat6.mode & 2) !== 0 || groupCanWrite) {
33221
+ const ownPrivateGroup = process.platform === "linux" && stat7.gid === primaryGid2();
33222
+ const groupCanWrite = (stat7.mode & 16) !== 0 && !ownPrivateGroup;
33223
+ if ((stat7.mode & 2) !== 0 || groupCanWrite) {
33224
33224
  return `The Argent home ${STATE_DIR} is writable by other users. If only you have used it, run \`chmod -R go-w '${STATE_DIR}/'\`. Otherwise set ARGENT_HOME_DIR to a new private directory.`;
33225
33225
  }
33226
33226
  return null;
@@ -33228,9 +33228,9 @@ function homeRefusal(stat6, uid) {
33228
33228
  function assertPrivateArgentHome() {
33229
33229
  const uid = process.getuid?.();
33230
33230
  if (uid === void 0) return;
33231
- const stat6 = statHome();
33232
- if (!stat6) return;
33233
- const refusal = homeRefusal(stat6, uid);
33231
+ const stat7 = statHome();
33232
+ if (!stat7) return;
33233
+ const refusal = homeRefusal(stat7, uid);
33234
33234
  if (refusal) throw new UnsafeArgentHomeError(refusal);
33235
33235
  }
33236
33236
  async function writeToolsServerState(state) {
@@ -37043,7 +37043,8 @@ function shouldShowFirstRunNotice() {
37043
37043
  import { createHash as createHash4 } from "node:crypto";
37044
37044
 
37045
37045
  // ../argent-mcp/src/content.ts
37046
- import { readFile as readFile7 } from "node:fs/promises";
37046
+ import { mkdir as mkdir4, readFile as readFile7, stat as stat6, writeFile as writeFile3 } from "node:fs/promises";
37047
+ import { dirname as dirname11, isAbsolute as isAbsolute7 } from "node:path";
37047
37048
  var PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
37048
37049
  function imageBlock(data, mimeType) {
37049
37050
  return { type: "image", data: data.toString("base64"), mimeType };
@@ -37073,13 +37074,20 @@ async function toMcpContent(result, outputHint, ctx, args) {
37073
37074
  const { result: rewritten, images } = await materializeArtifacts(result, ctx);
37074
37075
  if (outputHint === "image") {
37075
37076
  if (images.length > 0) {
37076
- const saved = { type: "text", text: `Saved: ${images[0].localPath}` };
37077
+ const saved = {
37078
+ type: "text",
37079
+ text: await savedText(images[0].localPath, images[0].data, args)
37080
+ };
37077
37081
  if (suppressImage) return [saved];
37078
37082
  const blocks2 = images.map((img) => imageBlock(img.data, img.mimeType));
37079
37083
  blocks2.push(saved);
37080
37084
  return blocks2;
37081
37085
  }
37082
- return legacyImageContent(rewritten, suppressImage, ctx.signal);
37086
+ const legacy = await legacyImageContent(rewritten, suppressImage, ctx.signal);
37087
+ const out = requestedOut(args);
37088
+ if (!out) return legacy;
37089
+ const notSaved = `Could not save to ${out}: no image file came back, so any file already there is not this capture.`;
37090
+ return [...legacy, { type: "text", text: notSaved }];
37083
37091
  }
37084
37092
  const blocks = [{ type: "text", text: stringifyForText(rewritten) }];
37085
37093
  if (!suppressImage) for (const img of images) blocks.push(imageBlock(img.data, img.mimeType));
@@ -37090,6 +37098,29 @@ async function toMcpContent(result, outputHint, ctx, args) {
37090
37098
  }
37091
37099
  return [{ type: "text", text: stringifyForText(result) }];
37092
37100
  }
37101
+ function requestedOut(args) {
37102
+ return isRecord3(args) && typeof args.out === "string" ? args.out.trim() : "";
37103
+ }
37104
+ async function savedText(scratchPath, data, args) {
37105
+ const out = requestedOut(args);
37106
+ if (!out) return `Saved: ${scratchPath}`;
37107
+ if (!isAbsolute7(out)) {
37108
+ return `Saved: ${scratchPath}
37109
+ Could not save to ${out}: not an absolute path on this computer`;
37110
+ }
37111
+ try {
37112
+ await mkdir4(dirname11(out), { recursive: true });
37113
+ if ((await stat6(out).catch(() => null))?.isFile() === false) {
37114
+ throw new Error("not a regular file");
37115
+ }
37116
+ await writeFile3(out, data);
37117
+ return `Saved: ${out}`;
37118
+ } catch (err) {
37119
+ const reason = err instanceof Error ? err.message : String(err);
37120
+ return `Saved: ${scratchPath}
37121
+ Could not save to ${out}: ${reason}`;
37122
+ }
37123
+ }
37093
37124
  function joinTextOnlyContent(blocks) {
37094
37125
  if (blocks.length < 2 || !blocks.every((b) => b.type === "text")) return blocks;
37095
37126
  return [{ type: "text", text: blocks.map((b) => b.text).join("\n") }];
@@ -37362,7 +37393,8 @@ async function flowRunToMcpContent(result, ctx) {
37362
37393
  blocks.push({ type: "text", text: parts.join("\n") });
37363
37394
  }
37364
37395
  if (step.result !== void 0) {
37365
- blocks.push(...await toMcpContent(step.result, step.outputHint, ctx, step.args));
37396
+ const renderArgs = isRecord3(step.args) ? { includeImageInContext: step.args.includeImageInContext } : void 0;
37397
+ blocks.push(...await toMcpContent(step.result, step.outputHint, ctx, renderArgs));
37366
37398
  }
37367
37399
  if (isRecord3(step.artifacts)) {
37368
37400
  blocks.push(...await stepArtifactBlocks(step.artifacts, step.status, ctx, step.depth));
@@ -38445,7 +38477,7 @@ import {
38445
38477
  statSync as statSync5
38446
38478
  } from "node:fs";
38447
38479
  import { appendFile } from "node:fs/promises";
38448
- import { dirname as dirname11 } from "node:path";
38480
+ import { dirname as dirname12 } from "node:path";
38449
38481
  var CALL_LOG_MAX_BYTES = 10 * 1024 * 1024;
38450
38482
  var STAT_EVERY_BYTES = 1024 * 1024;
38451
38483
  function createCallLog(file, maxBytes = CALL_LOG_MAX_BYTES) {
@@ -38473,7 +38505,7 @@ function createCallLog(file, maxBytes = CALL_LOG_MAX_BYTES) {
38473
38505
  return async function write(entry) {
38474
38506
  try {
38475
38507
  if (!dirReady) {
38476
- mkdirSync7(dirname11(file), { recursive: true, mode: 448 });
38508
+ mkdirSync7(dirname12(file), { recursive: true, mode: 448 });
38477
38509
  dirReady = true;
38478
38510
  }
38479
38511
  if (!checked || estimate >= maxBytes || sinceStat >= STAT_EVERY_BYTES) {
@@ -38526,6 +38558,13 @@ var import_semver = __toESM(require_semver2(), 1);
38526
38558
 
38527
38559
  // ../argent-mcp/src/release-highlights.ts
38528
38560
  var RELEASE_HIGHLIGHTS = {
38561
+ "0.36.0": [
38562
+ "Reduced token usage by over 30% in a typical task through more compact element trees and trimmed MCP tool descriptions and schemas.",
38563
+ "`argent e2e check` validates E2E tests before running them, and E2E tests now support `shutdown:` cleanup blocks, `{{var:NAME}}` variables, `{{output:...}}` script outputs, and `--secrets-file`.",
38564
+ "`await-network-request` checks request and response bodies, headers, and JWT claims, and supports `absent` mode to assert no matching request was sent.",
38565
+ "Hover over points in Mac apps with `gesture-hover` and keep a finger down between custom gesture calls.",
38566
+ "Global Argent installations update automatically, and devices can be claimed per session."
38567
+ ],
38529
38568
  "0.35.0": [
38530
38569
  "UI sessions use less agent context: Argent skips unchanged automatic screenshots and sends just the changed lines for small element tree updates.",
38531
38570
  "Capture native network requests from iOS and Mac apps and inspect their headers and bodies.",
@@ -38589,7 +38628,7 @@ async function startMcpServer(options) {
38589
38628
  const autoDescribeOn = autoDescribeEnabled();
38590
38629
  const whatsNewOn = whatsNewEnabled();
38591
38630
  const installedVersion = getInstalledVersion();
38592
- const highlightsVersion = true ? "0.35.1-next.99" : installedVersion;
38631
+ const highlightsVersion = true ? "0.36.0" : installedVersion;
38593
38632
  const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
38594
38633
  const trees = createTreeMemory();
38595
38634
  const screenshots = createScreenshotMemory();
@@ -1080,6 +1080,8 @@ export interface ArgentToolArgs {
1080
1080
  includeImageInContext?: boolean;
1081
1081
  /** Chromium only: downscaler when scale < 1 (default lanczos3). */
1082
1082
  downscaler?: "lanczos3" | "box" | "bilinear" | "nearest";
1083
+ /** Over MCP or `argent run`, also save the PNG at this absolute path on your machine, creating missing directories and replacing an existing file. An e2e test step and the Node client write nothing. */
1084
+ out?: string;
1083
1085
  };
1084
1086
  "screenshot-diff": {
1085
1087
  /** Saved baseline PNG path (omit when `captureBaseline: true`). */
@@ -67164,16 +67164,16 @@ var require_path_is_absolute = __commonJS({
67164
67164
  function posix7(path78) {
67165
67165
  return path78.charAt(0) === "/";
67166
67166
  }
67167
- function win323(path78) {
67167
+ function win324(path78) {
67168
67168
  var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
67169
67169
  var result = splitDeviceRe.exec(path78);
67170
67170
  var device = result[1] || "";
67171
67171
  var isUnc = Boolean(device && device.charAt(1) !== ":");
67172
67172
  return Boolean(result[2] || isUnc);
67173
67173
  }
67174
- module2.exports = process.platform === "win32" ? win323 : posix7;
67174
+ module2.exports = process.platform === "win32" ? win324 : posix7;
67175
67175
  module2.exports.posix = posix7;
67176
- module2.exports.win32 = win323;
67176
+ module2.exports.win32 = win324;
67177
67177
  }
67178
67178
  });
67179
67179
 
@@ -73425,7 +73425,7 @@ function isCi(env = process.env) {
73425
73425
  var SESSION_ID = (0, import_node_crypto4.randomUUID)();
73426
73426
  function readCliVersion() {
73427
73427
  if (true) {
73428
- return "0.35.1-next.99";
73428
+ return "0.36.0";
73429
73429
  }
73430
73430
  return "0.0.0";
73431
73431
  }
@@ -75586,7 +75586,7 @@ var import_node_path10 = __toESM(require("node:path"));
75586
75586
  var import_semver3 = __toESM(require_semver2());
75587
75587
 
75588
75588
  // ../tool-server/package.json
75589
- var version2 = "0.35.0";
75589
+ var version2 = "0.36.0";
75590
75590
 
75591
75591
  // ../tool-server/src/utils/update-check-env.ts
75592
75592
  function isUpdateCheckDisabled() {
@@ -141786,7 +141786,11 @@ var zodSchema19 = external_exports.object({
141786
141786
  includeImageInContext: external_exports.boolean().optional().default(true).describe(
141787
141787
  "Set false only when saving a full-res (`scale: 1.0`) baseline/current for `screenshot-diff`."
141788
141788
  ),
141789
- downscaler: external_exports.enum(["lanczos3", "box", "bilinear", "nearest"]).optional().describe("Chromium only: downscaler when scale < 1 (default lanczos3).")
141789
+ downscaler: external_exports.enum(["lanczos3", "box", "bilinear", "nearest"]).optional().describe("Chromium only: downscaler when scale < 1 (default lanczos3)."),
141790
+ // Written by argent-mcp and argent-cli, not by this tool.
141791
+ out: external_exports.string().trim().refine((p) => path47.win32.isAbsolute(p), "must be an absolute path").optional().describe(
141792
+ "Over MCP or `argent run`, also save the PNG at this absolute path on your machine, creating missing directories and replacing an existing file. An e2e test step and the Node client write nothing."
141793
+ )
141790
141794
  });
141791
141795
  function createScreenshotTool(registry2) {
141792
141796
  return {
@@ -141796,7 +141800,7 @@ Use when you need a baseline image or the screen state after a delay (interactio
141796
141800
  zodSchema: zodSchema19,
141797
141801
  alwaysLoad: true,
141798
141802
  searchHint: "device simulator emulator chromium screen image capture baseline tvos apple tv",
141799
- readOnly: true,
141803
+ // Not readOnly: plan mode would run a call whose `out` replaces a file without a prompt.
141800
141804
  interaction: {
141801
141805
  startedMsg: () => "Capturing screenshot",
141802
141806
  completedMsg: ({ result }) => `Captured screenshot ${result.image.filename}`,
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.35.1-next.99",
3
+ "version": "0.36.0",
4
4
  "mcpName": "io.github.software-mansion/argent",
5
5
  "description": "MCP server for iOS Simulator, Android Emulator, Chromium app and Mac app control",
6
6
  "license": "Apache-2.0",
@@ -98,5 +98,5 @@
98
98
  "vitest": "^5.0.5",
99
99
  "yaml": "^2.9.1"
100
100
  },
101
- "gitHead": "512c4ebaab29020a596ff3e0bd873af664ae2d53"
101
+ "gitHead": "5666f2873979233235bf0ec50daeb53b3bd8523e"
102
102
  }
@@ -59,6 +59,6 @@ Use `await-ui-element` to gate a step on a screen transition. To gate on an HTTP
59
59
  ## Screenshots & Android Notes
60
60
 
61
61
  - Call `screenshot` for initial state, baselines before visible UI changes, state after a delay, or when an attached capture shows a transitional/loading frame.
62
- - Keep the default downscaled capture for routine checks; reserve `scale: 1.0` (with `includeImageInContext: false`) for saving baselines/currents for `argent-screenshot-diff`.
62
+ - Keep the default downscaled capture for routine checks; reserve `scale: 1.0` (with `includeImageInContext: false` and `out` at an absolute path unique to this run) for saving baselines/currents for `argent-screenshot-diff`.
63
63
  - If `screenshot` times out, restart the device transport with `stop-simulator-server`.
64
64
  - **Android first-launch permissions:** `reinstall-app` on Android installs with `-g`, pre-granting runtime permissions on first launch.
@@ -19,7 +19,7 @@ Do not use screenshot diffing for tap-coordinate discovery. Use `describe` to fi
19
19
  ## 3. Deterministic Flow
20
20
 
21
21
  1. Navigate to the known-good state. Capture the baseline before the relevant interaction or before editing whenever feasible.
22
- 2. Save a baseline PNG with `screenshot` using `scale: 1.0` and `includeImageInContext: false`, so the full-size image stays out of context; keep the returned `path`. Use normal downscaled screenshots for everything else. Images of different sizes return `dimension_mismatch` and are not compared, so keep one baseline per device model.
22
+ 2. Save a baseline PNG with `screenshot` using `scale: 1.0` and `includeImageInContext: false`, so the full-size image stays out of context, and `out` at an absolute path unique to this run, so another session cannot overwrite it. Use normal downscaled screenshots for everything else. Images of different sizes return `dimension_mismatch` and are not compared, so keep one baseline per device model.
23
23
  3. Perform the interaction, apply the code change and navigate to the state under test, after the app reloads or rebuilds.
24
- 4. Call `screenshot-diff` with that `baselinePath`, `captureCurrent: true`, `udid`, and `outputDir`. If both images are already saved, pass `currentPath` instead of `captureCurrent`.
24
+ 4. Call `screenshot-diff` with that `out` path as `baselinePath`, `captureCurrent: true`, `udid`, and `outputDir`. If both images are already saved, pass `currentPath` instead of `captureCurrent`.
25
25
  5. Inspect the summary and artifact paths, then combine the diff with normal visual inspection and any structural/runtime evidence needed for the assertion.
@@ -13,7 +13,7 @@ Physical iPhone (`kind: "device"`): read `argent-ios-device-interact` first. `la
13
13
 
14
14
  For implementation tasks that modify visible UI, this workflow also serves as a visual acceptance path.
15
15
 
16
- 1. **Baseline screenshot**: call `screenshot` to see the current UI state. For visual regression comparison or UI change verification, capture the baseline at `scale: 1.0` with `includeImageInContext: false` and keep the returned `path` before editing whenever feasible.
16
+ 1. **Baseline screenshot**: call `screenshot` to see the current UI state. For visual regression comparison or UI change verification, capture the baseline at `scale: 1.0` with `includeImageInContext: false` and a run-unique absolute `out` path before editing whenever feasible.
17
17
  2. **Find target**: get element coordinates from a discovery tool before tapping:
18
18
  - **App screens (React Native included), in-app modals and system dialogs**: `describe`. Fall back to `screenshot` only if an overlay is not exposed reliably. When the app raises its own permission dialog, answer it here; that's the real flow under test. To take a prompt _out_ of the flow, use `argent-settings-permissions` during setup.
19
19
  3. **Interact**: perform the action (`gesture-tap`, `gesture-swipe`, `keyboard`, `button`, ...); you receive a screenshot and element tree automatically (an unchanged screenshot or identical/slightly changed tree references the earlier `Screenshot id` / `Tree id` with a note or `-`/`+` line diff instead of repeating it).