@swmansion/argent 0.35.1-next.99 → 0.36.1-next.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.
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) => {
@@ -12776,6 +12776,7 @@ import * as path14 from "node:path";
12776
12776
 
12777
12777
  // ../registry/src/types.ts
12778
12778
  var LINKED_CALL_HEADER = "x-argent-linked";
12779
+ var CALLER_DEADLINE_HEADER = "x-argent-deadline-ms";
12779
12780
  var E2E_DIR_CLIENT_HEADER = "x-argent-e2e-dir";
12780
12781
  var CLIENT_SECRETS_HEADER = "x-argent-client-secrets";
12781
12782
  var SESSION_HEADER = "x-argent-session";
@@ -13061,6 +13062,8 @@ var FAILURE_CODES = {
13061
13062
  REGISTRY_TOOL_EXECUTION_FAILED: "REGISTRY_TOOL_EXECUTION_FAILED",
13062
13063
  REGISTRY_TOOL_FAILURE_UNCLASSIFIED: "REGISTRY_TOOL_FAILURE_UNCLASSIFIED",
13063
13064
  REGISTRY_SERVICE_TERMINATING: "REGISTRY_SERVICE_TERMINATING",
13065
+ REGISTRY_TOOL_CALL_CANCELLED: "REGISTRY_TOOL_CALL_CANCELLED",
13066
+ REGISTRY_TOOL_CALL_TIMED_OUT: "REGISTRY_TOOL_CALL_TIMED_OUT",
13064
13067
  HTTP_TOOL_NOT_FOUND: "HTTP_TOOL_NOT_FOUND",
13065
13068
  HTTP_ZOD_VALIDATION_FAILED: "HTTP_ZOD_VALIDATION_FAILED",
13066
13069
  HTTP_CAPABILITY_UNSUPPORTED_OPERATION: "HTTP_CAPABILITY_UNSUPPORTED_OPERATION",
@@ -13267,7 +13270,6 @@ var FAILURE_CODES = {
13267
13270
  DEBUGGER_RELOAD_FAILED: "DEBUGGER_RELOAD_FAILED",
13268
13271
  // e2e-add-step refused a debugger-* call that answered `not_connected`.
13269
13272
  DEBUGGER_NOT_CONNECTED: "DEBUGGER_NOT_CONNECTED",
13270
- JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED: "JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED",
13271
13273
  JS_RUNTIME_PAYLOAD_INVALID: "JS_RUNTIME_PAYLOAD_INVALID",
13272
13274
  JS_RUNTIME_PAYLOAD_DEVICE_MISSING: "JS_RUNTIME_PAYLOAD_DEVICE_MISSING",
13273
13275
  JS_RUNTIME_PAYLOAD_PORT_INVALID: "JS_RUNTIME_PAYLOAD_PORT_INVALID",
@@ -13521,6 +13523,7 @@ var FAILURE_KINDS = [
13521
13523
  "network",
13522
13524
  "subprocess",
13523
13525
  "crash",
13526
+ "cancelled",
13524
13527
  "unknown"
13525
13528
  ];
13526
13529
  var FAILURE_COMMANDS = [
@@ -18645,7 +18648,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
18645
18648
  var NONE = 0;
18646
18649
  var ASSUMED = 1;
18647
18650
  var PROVEN = 2;
18648
- function isRecursive(inst, stack, resolve26) {
18651
+ function isRecursive(inst, stack, resolve25) {
18649
18652
  const cached3 = recursive.get(inst);
18650
18653
  if (cached3 !== void 0)
18651
18654
  return cached3 ? PROVEN : NONE;
@@ -18655,7 +18658,7 @@ function isRecursive(inst, stack, resolve26) {
18655
18658
  let result = NONE;
18656
18659
  const check3 = (child) => {
18657
18660
  if (result !== PROVEN && child?._zod) {
18658
- const answer = isRecursive(child, stack, resolve26);
18661
+ const answer = isRecursive(child, stack, resolve25);
18659
18662
  if (answer > result)
18660
18663
  result = answer;
18661
18664
  }
@@ -18666,7 +18669,7 @@ function isRecursive(inst, stack, resolve26) {
18666
18669
  const desc = Object.getOwnPropertyDescriptor(sh, key);
18667
18670
  if (spread && !desc.enumerable)
18668
18671
  continue;
18669
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve26) : NONE;
18672
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve25) : NONE;
18670
18673
  if (child > answer)
18671
18674
  answer = child;
18672
18675
  }
@@ -18730,7 +18733,7 @@ function isRecursive(inst, stack, resolve26) {
18730
18733
  break;
18731
18734
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
18732
18735
  case "lazy": {
18733
- const inner = def._cachedInner ?? (resolve26 ? inst._zod.innerType : void 0);
18736
+ const inner = def._cachedInner ?? (resolve25 ? inst._zod.innerType : void 0);
18734
18737
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
18735
18738
  break;
18736
18739
  }
@@ -33299,6 +33302,18 @@ function date4(params) {
33299
33302
  import { randomUUID as randomUUID3 } from "node:crypto";
33300
33303
  import { AsyncLocalStorage } from "node:async_hooks";
33301
33304
  var resolvedDuringInvocation = new AsyncLocalStorage();
33305
+ var CANCELLED_SIGNAL = {
33306
+ error_code: FAILURE_CODES.REGISTRY_TOOL_CALL_CANCELLED,
33307
+ failure_stage: "registry_tool_cancelled",
33308
+ failure_area: "registry",
33309
+ error_kind: "cancelled"
33310
+ };
33311
+ var TIMED_OUT_SIGNAL = {
33312
+ error_code: FAILURE_CODES.REGISTRY_TOOL_CALL_TIMED_OUT,
33313
+ failure_stage: "registry_tool_timed_out",
33314
+ failure_area: "registry",
33315
+ error_kind: "timeout"
33316
+ };
33302
33317
  function valueAtPath(root, path48) {
33303
33318
  let current = root;
33304
33319
  for (const key of path48) {
@@ -33640,7 +33655,7 @@ async function runTar(archive, args, signal) {
33640
33655
  child.on("error", (err) => {
33641
33656
  childError = err;
33642
33657
  });
33643
- const closed = new Promise((resolve26) => child.once("close", resolve26));
33658
+ const closed = new Promise((resolve25) => child.once("close", resolve25));
33644
33659
  const stdout2 = collect(child.stdout, MAX_LISTING_BYTES, {
33645
33660
  maxLines: MAX_LISTING_LINES,
33646
33661
  onOverflow: () => child.kill()
@@ -33874,9 +33889,9 @@ function untrackArchive(archive) {
33874
33889
  process.removeListener("exit", removePendingArchives);
33875
33890
  }
33876
33891
  function sha256File(filePath, signal) {
33877
- return new Promise((resolve26, reject) => {
33892
+ return new Promise((resolve25, reject) => {
33878
33893
  const hash2 = createHash2("sha256");
33879
- createReadStream2(filePath, { signal }).on("data", (chunk) => hash2.update(chunk)).on("end", () => resolve26(hash2.digest("hex"))).on("error", reject);
33894
+ createReadStream2(filePath, { signal }).on("data", (chunk) => hash2.update(chunk)).on("end", () => resolve25(hash2.digest("hex"))).on("error", reject);
33880
33895
  });
33881
33896
  }
33882
33897
  function toolServerError(text2) {
@@ -33904,34 +33919,33 @@ function uploadFailure(url2, res, text2, bytes) {
33904
33919
  }
33905
33920
  async function uploadTar(tarPath, format2, endpoint, signal) {
33906
33921
  const { size } = await stat3(tarPath);
33907
- const stream = createReadStream2(tarPath);
33922
+ const body = createReadStream2(tarPath).on("error", () => {
33923
+ });
33908
33924
  const init3 = {
33909
33925
  method: "POST",
33910
33926
  headers: {
33911
33927
  "content-type": ARCHIVE_CONTENT_TYPES[format2],
33912
33928
  ...endpoint.token ? { Authorization: `Bearer ${endpoint.token}` } : {}
33913
33929
  },
33914
- body: stream,
33930
+ body,
33915
33931
  duplex: "half",
33916
33932
  signal
33917
33933
  };
33918
- let res;
33919
33934
  try {
33920
- res = await fetch(`${endpoint.url}/upload`, init3);
33921
- } catch (err) {
33922
- stream.destroy();
33923
- throw err;
33924
- }
33925
- if (!res.ok) {
33926
- let text2 = "";
33927
- try {
33928
- text2 = await res.text();
33929
- } catch {
33935
+ const res = await fetch(`${endpoint.url}/upload`, init3);
33936
+ if (!res.ok) {
33937
+ let text2 = "";
33938
+ try {
33939
+ text2 = await res.text();
33940
+ } catch {
33941
+ }
33942
+ throw uploadFailure(endpoint.url, res, text2, size);
33930
33943
  }
33931
- throw uploadFailure(endpoint.url, res, text2, size);
33944
+ const json2 = await res.json();
33945
+ return json2.uploadId;
33946
+ } finally {
33947
+ body.destroy();
33932
33948
  }
33933
- const json2 = await res.json();
33934
- return json2.uploadId;
33935
33949
  }
33936
33950
  async function uploadFile(sourcePath, endpoint, signal) {
33937
33951
  const format2 = pickArchiveFormat(endpoint.formats);
@@ -34594,6 +34608,197 @@ async function e2eShadowWarningFor(tool, args) {
34594
34608
  return picked.shadowed === void 0 ? void 0 : e2eShadowWarning(picked.path, picked.shadowed);
34595
34609
  }
34596
34610
 
34611
+ // ../argent-tools-client/src/auto-capture.ts
34612
+ import { setTimeout as sleep } from "node:timers/promises";
34613
+ var AUTO_SCREENSHOT_TOOLS = /* @__PURE__ */ new Set([
34614
+ "gesture-tap",
34615
+ "gesture-swipe",
34616
+ "gesture-scroll",
34617
+ "gesture-drag",
34618
+ "gesture-hover",
34619
+ "gesture-custom",
34620
+ "gesture-pinch",
34621
+ "gesture-rotate",
34622
+ "button",
34623
+ "keyboard",
34624
+ "paste",
34625
+ "rotate",
34626
+ "fold",
34627
+ "tv-remote",
34628
+ "launch-app",
34629
+ "restart-app",
34630
+ "open-url",
34631
+ "describe",
34632
+ "run-sequence",
34633
+ // A wait is almost always followed by a look at the screen it waited for.
34634
+ "await-ui-element",
34635
+ "file-panel",
34636
+ "menu-bar"
34637
+ ]);
34638
+ var AUTO_SCREENSHOT_DELAY_MS_BY_TOOL = {
34639
+ "launch-app": 3e3,
34640
+ "restart-app": 3e3,
34641
+ "open-url": 2e3,
34642
+ "gesture-swipe": 1500,
34643
+ "gesture-scroll": 1500,
34644
+ "gesture-drag": 1500,
34645
+ "gesture-hover": 1500,
34646
+ "gesture-custom": 1500,
34647
+ "gesture-tap": 1500,
34648
+ "gesture-pinch": 1500,
34649
+ "gesture-rotate": 1500,
34650
+ // Only the settle after the last step; each step is an in-app action.
34651
+ "run-sequence": 3e3,
34652
+ "button": 1500,
34653
+ "tv-remote": 1500,
34654
+ "rotate": 1e3,
34655
+ // The fold tool already waits for the panel hand-over; the cap covers the
34656
+ // repaint after it.
34657
+ "fold": 1500,
34658
+ "keyboard": 300,
34659
+ "paste": 300,
34660
+ "describe": 100,
34661
+ // The wait returns on the first match, often mid-transition; the cap must
34662
+ // leave `await-screen-idle` room to see two identical reads.
34663
+ "await-ui-element": 1500
34664
+ };
34665
+ var DEFAULT_DELAY_MS = 1400;
34666
+ var LAUNCH_SETTLE_MS = 3e3;
34667
+ var CAPTURE_TIMEOUT_MS = 15e3;
34668
+ function autoScreenshotEnabled(options) {
34669
+ return !isFlagEnabled("disable-auto-screenshot", options);
34670
+ }
34671
+ var AUTO_DESCRIBE_TOOLS = /* @__PURE__ */ new Set([
34672
+ "gesture-tap",
34673
+ "gesture-swipe",
34674
+ "gesture-scroll",
34675
+ "gesture-drag",
34676
+ "gesture-hover",
34677
+ "gesture-custom",
34678
+ "gesture-pinch",
34679
+ "gesture-rotate",
34680
+ "button",
34681
+ "keyboard",
34682
+ "paste",
34683
+ "rotate",
34684
+ "fold",
34685
+ "tv-remote",
34686
+ "launch-app",
34687
+ "restart-app",
34688
+ "open-url",
34689
+ "run-sequence",
34690
+ "await-ui-element",
34691
+ "file-panel",
34692
+ "menu-bar"
34693
+ ]);
34694
+ function autoDescribeEnabled(options) {
34695
+ return !isFlagEnabled("disable-auto-describe", options);
34696
+ }
34697
+ var PROFILING_CAPTURE_SKIPPED_NOTE = "Auto-screenshot and element tree skipped while a profiler is recording on this device. Call screenshot or describe if you need to see the screen.";
34698
+ var SECRET_CAPTURE_SKIPPED_NOTE = "Auto-screenshot and element tree skipped: the input contains a {{secret:\u2026}} placeholder, and a capture of this screen could reveal the typed secret. The secret is already typed \u2014 do not send the typing step again, or the field will hold two copies of it. Submit or navigate away, then verify the resulting screen as usual. Only this call is covered: the next call is captured normally, and shows the secret if the field is still on screen. To cover the submit as well, put the typing and the submit in ONE `run-sequence` the next time you type a secret.";
34699
+ var AUTO_DESCRIBE_HEADER = "--- Elements after action (describe) ---";
34700
+ function shouldAutoDescribe(toolName, args) {
34701
+ const canonical = normalizeToolName(toolName);
34702
+ return AUTO_DESCRIBE_TOOLS.has(canonical) && !isListCall(canonical, args);
34703
+ }
34704
+ var SECRET_PLACEHOLDER_MARKER = "{{secret:";
34705
+ function containsSecretPlaceholder(args) {
34706
+ try {
34707
+ return JSON.stringify(args)?.includes(SECRET_PLACEHOLDER_MARKER) ?? false;
34708
+ } catch {
34709
+ return true;
34710
+ }
34711
+ }
34712
+ function getUdidFromArgs(args) {
34713
+ if (args && typeof args === "object" && "udid" in args && typeof args.udid === "string") {
34714
+ return args.udid;
34715
+ }
34716
+ return void 0;
34717
+ }
34718
+ function normalizeToolName(name) {
34719
+ const idx = name.lastIndexOf("__");
34720
+ return idx === -1 ? name : name.slice(idx + 2);
34721
+ }
34722
+ function shouldAutoScreenshot(toolName, args) {
34723
+ const canonical = normalizeToolName(toolName);
34724
+ return canonical !== "screenshot" && AUTO_SCREENSHOT_TOOLS.has(canonical) && !isListCall(canonical, args);
34725
+ }
34726
+ function isListCall(canonical, args) {
34727
+ return (canonical === "menu-bar" || canonical === "file-panel") && args?.action === "list";
34728
+ }
34729
+ function getAutoScreenshotDelayMs(toolName) {
34730
+ const canonical = normalizeToolName(toolName);
34731
+ const base = AUTO_SCREENSHOT_DELAY_MS_BY_TOOL[canonical] ?? DEFAULT_DELAY_MS;
34732
+ const envOverride = process.env.ARGENT_AUTO_SCREENSHOT_DELAY_MS;
34733
+ if (envOverride) {
34734
+ const envMs = parseInt(envOverride, 10);
34735
+ if (!Number.isNaN(envMs)) return Math.max(base, envMs);
34736
+ }
34737
+ return base;
34738
+ }
34739
+ function describedTree(result) {
34740
+ const { description, hint } = result ?? {};
34741
+ if (typeof description !== "string" || description.length === 0) return void 0;
34742
+ const hintLine = typeof hint === "string" && hint && !description.includes(hint) ? `Hint: ${hint}
34743
+ ` : "";
34744
+ return `${hintLine}${description}`;
34745
+ }
34746
+ var deadlines = /* @__PURE__ */ new WeakMap();
34747
+ async function withDeadline(signal, ms, work) {
34748
+ const deadline = new AbortController();
34749
+ const timer = setTimeout(
34750
+ () => deadline.abort(new DOMException("The operation was aborted due to timeout", "TimeoutError")),
34751
+ ms
34752
+ );
34753
+ const bounded = AbortSignal.any([signal, deadline.signal]);
34754
+ deadlines.set(bounded, performance.now() + ms);
34755
+ try {
34756
+ return await work(bounded);
34757
+ } finally {
34758
+ clearTimeout(timer);
34759
+ }
34760
+ }
34761
+ function signalDeadline(signal) {
34762
+ return deadlines.get(signal);
34763
+ }
34764
+ async function awaitScreenSettled(call, udid, toolName, signal, captureTimeoutMs) {
34765
+ const maxWaitMs = getAutoScreenshotDelayMs(toolName);
34766
+ if (maxWaitMs === 0) return { settled: true };
34767
+ const started = Date.now();
34768
+ const awaitIdle = async (timeoutMs) => await withDeadline(
34769
+ signal,
34770
+ timeoutMs + captureTimeoutMs,
34771
+ (s) => call("await-screen-idle", { udid, timeoutMs }, s)
34772
+ );
34773
+ try {
34774
+ let idle = await awaitIdle(maxWaitMs);
34775
+ if (idle?.launching === true && normalizeToolName(toolName) !== "describe") {
34776
+ idle = await awaitIdle(LAUNCH_SETTLE_MS);
34777
+ }
34778
+ return {
34779
+ settled: idle?.settled === true,
34780
+ readiness: { maxWaitMs, ...idle }
34781
+ };
34782
+ } catch {
34783
+ await sleep(Math.max(0, maxWaitMs - (Date.now() - started)), void 0, { signal }).catch(
34784
+ () => {
34785
+ }
34786
+ );
34787
+ return { settled: false };
34788
+ }
34789
+ }
34790
+ async function captureSettledScreen(options) {
34791
+ const { call, udid, toolName, signal, captureTimeoutMs } = options;
34792
+ const settledResult = await awaitScreenSettled(call, udid, toolName, signal, captureTimeoutMs);
34793
+ await options.onSettled?.(settledResult);
34794
+ return withDeadline(signal, captureTimeoutMs, async (captureSignal) => {
34795
+ const screenshot = options.screenshot?.(captureSignal) ?? Promise.resolve([]);
34796
+ if (!settledResult.settled) await screenshot;
34797
+ const tree = options.tree?.(captureSignal) ?? Promise.resolve([]);
34798
+ return [...await screenshot, ...await tree];
34799
+ });
34800
+ }
34801
+
34597
34802
  // ../argent-tools-client/src/tools-client.ts
34598
34803
  function authHeaders2(token) {
34599
34804
  return token ? { Authorization: `Bearer ${token}` } : {};
@@ -34852,6 +35057,12 @@ function secretsTransportRefusal(url2) {
34852
35057
  return void 0;
34853
35058
  }
34854
35059
  var FETCH_HEAD_BYTES = 256;
35060
+ var FETCH_IDLE_TIMEOUT_MS = 3e5;
35061
+ function callerDeadlineMs(signal) {
35062
+ const deadline = signal ? signalDeadline(signal) : void 0;
35063
+ if (deadline === void 0) return FETCH_IDLE_TIMEOUT_MS;
35064
+ return Math.max(1, Math.min(FETCH_IDLE_TIMEOUT_MS, Math.ceil(deadline - performance.now())));
35065
+ }
34855
35066
  function isRecord2(value) {
34856
35067
  return typeof value === "object" && value !== null && !Array.isArray(value);
34857
35068
  }
@@ -35035,6 +35246,8 @@ function createToolsClient(options = {}) {
35035
35246
  // Tells the tool-server this client writes recordings under
35036
35247
  // `.argent/e2e/`; an older client writes only `.argent/flows/`.
35037
35248
  [E2E_DIR_CLIENT_HEADER]: "1",
35249
+ // So the tool-server reads a hang-up at this time as a timeout, not a cancel.
35250
+ [CALLER_DEADLINE_HEADER]: String(callerDeadlineMs(opts?.signal)),
35038
35251
  ...encodedSecrets ? { [CLIENT_SECRETS_HEADER]: encodedSecrets } : {},
35039
35252
  // A proxy that compresses the stream holds each line until its buffer
35040
35253
  // fills. `identity` keeps the stream uncompressed end to end.
@@ -35429,191 +35642,6 @@ function getDeviceIdFromArgs(args) {
35429
35642
  return void 0;
35430
35643
  }
35431
35644
 
35432
- // ../argent-tools-client/src/auto-capture.ts
35433
- import { setTimeout as sleep } from "node:timers/promises";
35434
- var AUTO_SCREENSHOT_TOOLS = /* @__PURE__ */ new Set([
35435
- "gesture-tap",
35436
- "gesture-swipe",
35437
- "gesture-scroll",
35438
- "gesture-drag",
35439
- "gesture-hover",
35440
- "gesture-custom",
35441
- "gesture-pinch",
35442
- "gesture-rotate",
35443
- "button",
35444
- "keyboard",
35445
- "paste",
35446
- "rotate",
35447
- "fold",
35448
- "tv-remote",
35449
- "launch-app",
35450
- "restart-app",
35451
- "open-url",
35452
- "describe",
35453
- "run-sequence",
35454
- // A wait is almost always followed by a look at the screen it waited for.
35455
- "await-ui-element",
35456
- "file-panel",
35457
- "menu-bar"
35458
- ]);
35459
- var AUTO_SCREENSHOT_DELAY_MS_BY_TOOL = {
35460
- "launch-app": 3e3,
35461
- "restart-app": 3e3,
35462
- "open-url": 2e3,
35463
- "gesture-swipe": 1500,
35464
- "gesture-scroll": 1500,
35465
- "gesture-drag": 1500,
35466
- "gesture-hover": 1500,
35467
- "gesture-custom": 1500,
35468
- "gesture-tap": 1500,
35469
- "gesture-pinch": 1500,
35470
- "gesture-rotate": 1500,
35471
- // Only the settle after the last step; each step is an in-app action.
35472
- "run-sequence": 3e3,
35473
- "button": 1500,
35474
- "tv-remote": 1500,
35475
- "rotate": 1e3,
35476
- // The fold tool already waits for the panel hand-over; the cap covers the
35477
- // repaint after it.
35478
- "fold": 1500,
35479
- "keyboard": 300,
35480
- "paste": 300,
35481
- "describe": 100,
35482
- // The wait returns on the first match, often mid-transition; the cap must
35483
- // leave `await-screen-idle` room to see two identical reads.
35484
- "await-ui-element": 1500
35485
- };
35486
- var DEFAULT_DELAY_MS = 1400;
35487
- var LAUNCH_SETTLE_MS = 3e3;
35488
- var CAPTURE_TIMEOUT_MS = 15e3;
35489
- function autoScreenshotEnabled(options) {
35490
- return !isFlagEnabled("disable-auto-screenshot", options);
35491
- }
35492
- var AUTO_DESCRIBE_TOOLS = /* @__PURE__ */ new Set([
35493
- "gesture-tap",
35494
- "gesture-swipe",
35495
- "gesture-scroll",
35496
- "gesture-drag",
35497
- "gesture-hover",
35498
- "gesture-custom",
35499
- "gesture-pinch",
35500
- "gesture-rotate",
35501
- "button",
35502
- "keyboard",
35503
- "paste",
35504
- "rotate",
35505
- "fold",
35506
- "tv-remote",
35507
- "launch-app",
35508
- "restart-app",
35509
- "open-url",
35510
- "run-sequence",
35511
- "await-ui-element",
35512
- "file-panel",
35513
- "menu-bar"
35514
- ]);
35515
- function autoDescribeEnabled(options) {
35516
- return !isFlagEnabled("disable-auto-describe", options);
35517
- }
35518
- var PROFILING_CAPTURE_SKIPPED_NOTE = "Auto-screenshot and element tree skipped while a profiler is recording on this device. Call screenshot or describe if you need to see the screen.";
35519
- var SECRET_CAPTURE_SKIPPED_NOTE = "Auto-screenshot and element tree skipped: the input contains a {{secret:\u2026}} placeholder, and a capture of this screen could reveal the typed secret. The secret is already typed \u2014 do not send the typing step again, or the field will hold two copies of it. Submit or navigate away, then verify the resulting screen as usual. Only this call is covered: the next call is captured normally, and shows the secret if the field is still on screen. To cover the submit as well, put the typing and the submit in ONE `run-sequence` the next time you type a secret.";
35520
- var AUTO_DESCRIBE_HEADER = "--- Elements after action (describe) ---";
35521
- function shouldAutoDescribe(toolName, args) {
35522
- const canonical = normalizeToolName(toolName);
35523
- return AUTO_DESCRIBE_TOOLS.has(canonical) && !isListCall(canonical, args);
35524
- }
35525
- var SECRET_PLACEHOLDER_MARKER = "{{secret:";
35526
- function containsSecretPlaceholder(args) {
35527
- try {
35528
- return JSON.stringify(args)?.includes(SECRET_PLACEHOLDER_MARKER) ?? false;
35529
- } catch {
35530
- return true;
35531
- }
35532
- }
35533
- function getUdidFromArgs(args) {
35534
- if (args && typeof args === "object" && "udid" in args && typeof args.udid === "string") {
35535
- return args.udid;
35536
- }
35537
- return void 0;
35538
- }
35539
- function normalizeToolName(name) {
35540
- const idx = name.lastIndexOf("__");
35541
- return idx === -1 ? name : name.slice(idx + 2);
35542
- }
35543
- function shouldAutoScreenshot(toolName, args) {
35544
- const canonical = normalizeToolName(toolName);
35545
- return canonical !== "screenshot" && AUTO_SCREENSHOT_TOOLS.has(canonical) && !isListCall(canonical, args);
35546
- }
35547
- function isListCall(canonical, args) {
35548
- return (canonical === "menu-bar" || canonical === "file-panel") && args?.action === "list";
35549
- }
35550
- function getAutoScreenshotDelayMs(toolName) {
35551
- const canonical = normalizeToolName(toolName);
35552
- const base = AUTO_SCREENSHOT_DELAY_MS_BY_TOOL[canonical] ?? DEFAULT_DELAY_MS;
35553
- const envOverride = process.env.ARGENT_AUTO_SCREENSHOT_DELAY_MS;
35554
- if (envOverride) {
35555
- const envMs = parseInt(envOverride, 10);
35556
- if (!Number.isNaN(envMs)) return Math.max(base, envMs);
35557
- }
35558
- return base;
35559
- }
35560
- function describedTree(result) {
35561
- const { description, hint } = result ?? {};
35562
- if (typeof description !== "string" || description.length === 0) return void 0;
35563
- const hintLine = typeof hint === "string" && hint && !description.includes(hint) ? `Hint: ${hint}
35564
- ` : "";
35565
- return `${hintLine}${description}`;
35566
- }
35567
- async function withDeadline(signal, ms, work) {
35568
- const deadline = new AbortController();
35569
- const timer = setTimeout(
35570
- () => deadline.abort(new DOMException("The operation was aborted due to timeout", "TimeoutError")),
35571
- ms
35572
- );
35573
- try {
35574
- return await work(AbortSignal.any([signal, deadline.signal]));
35575
- } finally {
35576
- clearTimeout(timer);
35577
- }
35578
- }
35579
- async function awaitScreenSettled(call, udid, toolName, signal, captureTimeoutMs) {
35580
- const maxWaitMs = getAutoScreenshotDelayMs(toolName);
35581
- if (maxWaitMs === 0) return { settled: true };
35582
- const started = Date.now();
35583
- const awaitIdle = async (timeoutMs) => await withDeadline(
35584
- signal,
35585
- timeoutMs + captureTimeoutMs,
35586
- (s) => call("await-screen-idle", { udid, timeoutMs }, s)
35587
- );
35588
- try {
35589
- let idle = await awaitIdle(maxWaitMs);
35590
- if (idle?.launching === true && normalizeToolName(toolName) !== "describe") {
35591
- idle = await awaitIdle(LAUNCH_SETTLE_MS);
35592
- }
35593
- return {
35594
- settled: idle?.settled === true,
35595
- readiness: { maxWaitMs, ...idle }
35596
- };
35597
- } catch {
35598
- await sleep(Math.max(0, maxWaitMs - (Date.now() - started)), void 0, { signal }).catch(
35599
- () => {
35600
- }
35601
- );
35602
- return { settled: false };
35603
- }
35604
- }
35605
- async function captureSettledScreen(options) {
35606
- const { call, udid, toolName, signal, captureTimeoutMs } = options;
35607
- const settledResult = await awaitScreenSettled(call, udid, toolName, signal, captureTimeoutMs);
35608
- await options.onSettled?.(settledResult);
35609
- return withDeadline(signal, captureTimeoutMs, async (captureSignal) => {
35610
- const screenshot = options.screenshot?.(captureSignal) ?? Promise.resolve([]);
35611
- if (!settledResult.settled) await screenshot;
35612
- const tree = options.tree?.(captureSignal) ?? Promise.resolve([]);
35613
- return [...await screenshot, ...await tree];
35614
- });
35615
- }
35616
-
35617
35645
  // ../../node_modules/@opentelemetry/api-logs/build/esm/types/LogRecord.js
35618
35646
  var SeverityNumber;
35619
35647
  (function(SeverityNumber2) {
@@ -36038,8 +36066,8 @@ var Deferred = class {
36038
36066
  _resolve;
36039
36067
  _reject;
36040
36068
  constructor() {
36041
- this._promise = new Promise((resolve26, reject) => {
36042
- this._resolve = resolve26;
36069
+ this._promise = new Promise((resolve25, reject) => {
36070
+ this._resolve = resolve25;
36043
36071
  this._reject = reject;
36044
36072
  });
36045
36073
  }
@@ -36932,8 +36960,8 @@ var ExportOperation = class {
36932
36960
  _metrics;
36933
36961
  _exportScheduledResolve;
36934
36962
  constructor(exporter, logRecords, exportTimeoutMillis, metrics) {
36935
- this._exportScheduledPromise = new Promise((resolve26) => {
36936
- this._exportScheduledResolve = resolve26;
36963
+ this._exportScheduledPromise = new Promise((resolve25) => {
36964
+ this._exportScheduledResolve = resolve25;
36937
36965
  });
36938
36966
  this._exportCompleted = this._executeExport(exporter, logRecords, exportTimeoutMillis);
36939
36967
  this._metrics = metrics;
@@ -36958,7 +36986,7 @@ var ExportOperation = class {
36958
36986
  }
36959
36987
  }
36960
36988
  async _exportWithTimeout(exporter, logRecords, exportTimeoutMillis) {
36961
- return new Promise((resolve26, reject) => {
36989
+ return new Promise((resolve25, reject) => {
36962
36990
  const timer = setTimeout(() => {
36963
36991
  reject(new Error("Timeout"));
36964
36992
  }, exportTimeoutMillis);
@@ -36966,7 +36994,7 @@ var ExportOperation = class {
36966
36994
  this._metrics.finishLogs(logRecords.length, result.error);
36967
36995
  clearTimeout(timer);
36968
36996
  if (result.code === ExportResultCode.SUCCESS) {
36969
- resolve26();
36997
+ resolve25();
36970
36998
  } else {
36971
36999
  reject(result.error ?? new Error("BatchLogRecordProcessor: log record export failed"));
36972
37000
  }
@@ -37747,7 +37775,7 @@ function parseRetryAfterToMills(retryAfter) {
37747
37775
  var DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION4}`;
37748
37776
  var MAX_RESPONSE_BODY_SIZE = 4 * 1024 * 1024;
37749
37777
  function sendWithHttp(request, url2, headers, compression, userAgent, agent, data, timeoutMillis) {
37750
- return new Promise((resolve26) => {
37778
+ return new Promise((resolve25) => {
37751
37779
  const parsedUrl = new URL(url2);
37752
37780
  if (userAgent) {
37753
37781
  headers["User-Agent"] = `${userAgent} ${DEFAULT_USER_AGENT}`;
@@ -37766,7 +37794,7 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
37766
37794
  responseSize += chunk.length;
37767
37795
  if (responseSize > MAX_RESPONSE_BODY_SIZE) {
37768
37796
  const sizeError = new Error(`OTLP export response body exceeded size limit of ${MAX_RESPONSE_BODY_SIZE} bytes`);
37769
- resolve26({ status: "failure", error: sizeError });
37797
+ resolve25({ status: "failure", error: sizeError });
37770
37798
  res.destroy();
37771
37799
  return;
37772
37800
  }
@@ -37774,18 +37802,18 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
37774
37802
  });
37775
37803
  res.on("end", () => {
37776
37804
  if (res.statusCode && res.statusCode <= 299) {
37777
- resolve26({
37805
+ resolve25({
37778
37806
  status: "success",
37779
37807
  data: Buffer.concat(responseData)
37780
37808
  });
37781
37809
  } else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {
37782
- resolve26({
37810
+ resolve25({
37783
37811
  status: "retryable",
37784
37812
  retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
37785
37813
  });
37786
37814
  } else {
37787
37815
  const error63 = new OTLPExporterError(res.statusMessage, res.statusCode, Buffer.concat(responseData).toString());
37788
- resolve26({
37816
+ resolve25({
37789
37817
  status: "failure",
37790
37818
  error: error63
37791
37819
  });
@@ -37793,17 +37821,17 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
37793
37821
  });
37794
37822
  res.on("error", (error63) => {
37795
37823
  if (res.statusCode && res.statusCode <= 299) {
37796
- resolve26({
37824
+ resolve25({
37797
37825
  status: "success"
37798
37826
  });
37799
37827
  } else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {
37800
- resolve26({
37828
+ resolve25({
37801
37829
  status: "retryable",
37802
37830
  error: error63,
37803
37831
  retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
37804
37832
  });
37805
37833
  } else {
37806
- resolve26({
37834
+ resolve25({
37807
37835
  status: "failure",
37808
37836
  error: error63
37809
37837
  });
@@ -37812,26 +37840,26 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
37812
37840
  });
37813
37841
  req.setTimeout(timeoutMillis, () => {
37814
37842
  req.destroy();
37815
- resolve26({
37843
+ resolve25({
37816
37844
  status: "retryable",
37817
37845
  error: new Error("Request timed out")
37818
37846
  });
37819
37847
  });
37820
37848
  req.on("error", (error63) => {
37821
37849
  if (isHttpTransportNetworkErrorRetryable(error63)) {
37822
- resolve26({
37850
+ resolve25({
37823
37851
  status: "retryable",
37824
37852
  error: error63
37825
37853
  });
37826
37854
  } else {
37827
- resolve26({
37855
+ resolve25({
37828
37856
  status: "failure",
37829
37857
  error: error63
37830
37858
  });
37831
37859
  }
37832
37860
  });
37833
37861
  compressAndSend(req, compression, data, (error63) => {
37834
- resolve26({
37862
+ resolve25({
37835
37863
  status: "failure",
37836
37864
  error: error63
37837
37865
  });
@@ -37921,9 +37949,9 @@ var RetryingTransport = class {
37921
37949
  this._transport = transport;
37922
37950
  }
37923
37951
  retry(data, timeoutMillis, inMillis) {
37924
- return new Promise((resolve26, reject) => {
37952
+ return new Promise((resolve25, reject) => {
37925
37953
  setTimeout(() => {
37926
- this._transport.send(data, timeoutMillis).then(resolve26, reject);
37954
+ this._transport.send(data, timeoutMillis).then(resolve25, reject);
37927
37955
  }, inMillis);
37928
37956
  });
37929
37957
  }
@@ -39157,7 +39185,7 @@ function isCi(env = process.env) {
39157
39185
  var SESSION_ID2 = randomUUID5();
39158
39186
  function readCliVersion() {
39159
39187
  if (true) {
39160
- return "0.35.1-next.99";
39188
+ return "0.36.1-next.0";
39161
39189
  }
39162
39190
  return "0.0.0";
39163
39191
  }
@@ -39467,12 +39495,12 @@ function resolveHostFingerprint() {
39467
39495
  }
39468
39496
  }
39469
39497
  function resolveHostFingerprintAsync() {
39470
- return new Promise((resolve26) => {
39498
+ return new Promise((resolve25) => {
39471
39499
  let binary;
39472
39500
  try {
39473
39501
  binary = simulatorServerBinaryPath();
39474
39502
  } catch {
39475
- resolve26(null);
39503
+ resolve25(null);
39476
39504
  return;
39477
39505
  }
39478
39506
  let settled = false;
@@ -39485,7 +39513,7 @@ function resolveHostFingerprintAsync() {
39485
39513
  child?.kill("SIGKILL");
39486
39514
  } catch {
39487
39515
  }
39488
- resolve26(value);
39516
+ resolve25(value);
39489
39517
  };
39490
39518
  const watchdog = setTimeout(() => finish(null), FINGERPRINT_TIMEOUT_MS);
39491
39519
  watchdog.unref?.();
@@ -39705,7 +39733,7 @@ var DRAIN_GRACE_MS = 250;
39705
39733
  async function raceDrain(client2, timeoutMs) {
39706
39734
  await Promise.race([
39707
39735
  client2.shutdown(timeoutMs),
39708
- new Promise((resolve26) => setTimeout(resolve26, timeoutMs + DRAIN_GRACE_MS).unref())
39736
+ new Promise((resolve25) => setTimeout(resolve25, timeoutMs + DRAIN_GRACE_MS).unref())
39709
39737
  ]);
39710
39738
  }
39711
39739
  async function shutdown(timeoutMs = SHORT_FLUSH_TIMEOUT_MS) {
@@ -40606,9 +40634,11 @@ function stepLabel(s, topFlow) {
40606
40634
  return `${what ? `${s.kind} ${what}` : s.kind}${where}`;
40607
40635
  }
40608
40636
  function renderStepLine(s, n3, topFlow) {
40609
- const reason = s.reason ? ` \u2014 ${s.reason}` : "";
40637
+ const [head, ...more] = s.reason ? String(s.reason).split("\n") : [];
40638
+ const reason = head !== void 0 ? ` \u2014 ${head}` : "";
40610
40639
  const glyph = s.status === "pass" && s.warning ? "\u26A0" : STATUS_GLYPH[s.status];
40611
- return ` ${glyph} ${String(n3).padStart(2)} ${stepIndent(s.depth)}${stepLabel(s, topFlow)}${durationSuffix(s.durationMs)}${reason}`;
40640
+ const line = ` ${glyph} ${String(n3).padStart(2)} ${stepIndent(s.depth)}${stepLabel(s, topFlow)}${durationSuffix(s.durationMs)}${reason}`;
40641
+ return [line, ...more.map((text2) => renderUnderStepLine(s, n3, text2))].join("\n");
40612
40642
  }
40613
40643
  function renderUnderStepLine(s, n3, text2) {
40614
40644
  return `${" ".repeat(5 + Math.max(2, String(n3).length))}${stepIndent(s.depth)}${text2}`;
@@ -40767,7 +40797,7 @@ async function readMarkerFile(marker) {
40767
40797
  }
40768
40798
  if (owner) return owner;
40769
40799
  if (attempt === MARKER_READ_RETRIES) return null;
40770
- await new Promise((resolve26) => setTimeout(resolve26, MARKER_READ_DELAY_MS));
40800
+ await new Promise((resolve25) => setTimeout(resolve25, MARKER_READ_DELAY_MS));
40771
40801
  }
40772
40802
  }
40773
40803
  async function classifyExportDir(dir, flowPath) {
@@ -40895,7 +40925,7 @@ function resolveArtifactDisplayPaths(report) {
40895
40925
  }
40896
40926
  function exitAfterFlush(code, streams = [process.stdout, process.stderr]) {
40897
40927
  return Promise.all(
40898
- streams.map((s) => new Promise((resolve26) => s.write("", () => resolve26())))
40928
+ streams.map((s) => new Promise((resolve25) => s.write("", () => resolve25())))
40899
40929
  ).then(() => process.exit(code));
40900
40930
  }
40901
40931
  function renderReport(report) {
@@ -41962,6 +41992,11 @@ function applyDeviceFromEnv(payload, schema, positional, env = process.env) {
41962
41992
  }
41963
41993
 
41964
41994
  // ../argent-cli/src/run.ts
41995
+ function outFlagPath(value) {
41996
+ const out = value?.trim();
41997
+ if (!out) throw new FlagParseException("--out requires a path");
41998
+ return out;
41999
+ }
41965
42000
  function splitOptions(argv) {
41966
42001
  let json2 = false;
41967
42002
  let outPath = null;
@@ -41973,14 +42008,12 @@ function splitOptions(argv) {
41973
42008
  continue;
41974
42009
  }
41975
42010
  if (tok === "--out") {
41976
- const v = argv[i2 + 1];
41977
- if (!v) throw new FlagParseException("--out requires a path");
41978
- outPath = v;
42011
+ outPath = outFlagPath(argv[i2 + 1]);
41979
42012
  i2 += 1;
41980
42013
  continue;
41981
42014
  }
41982
42015
  if (tok.startsWith("--out=")) {
41983
- outPath = tok.slice("--out=".length);
42016
+ outPath = outFlagPath(tok.slice("--out=".length));
41984
42017
  continue;
41985
42018
  }
41986
42019
  rest.push(tok);
@@ -41988,13 +42021,13 @@ function splitOptions(argv) {
41988
42021
  return { json: json2, outPath, argvForFlags: rest };
41989
42022
  }
41990
42023
  async function readStdin() {
41991
- return new Promise((resolve26, reject) => {
42024
+ return new Promise((resolve25, reject) => {
41992
42025
  let data = "";
41993
42026
  process.stdin.setEncoding("utf8");
41994
42027
  process.stdin.on("data", (chunk) => {
41995
42028
  data += chunk;
41996
42029
  });
41997
- process.stdin.on("end", () => resolve26(data));
42030
+ process.stdin.on("end", () => resolve25(data));
41998
42031
  process.stdin.on("error", reject);
41999
42032
  });
42000
42033
  }
@@ -42007,7 +42040,7 @@ function printToolHelp(meta3) {
42007
42040
  ${description}
42008
42041
  `);
42009
42042
  console.log("Flags:");
42010
- console.log(formatSchemaUsage(schema));
42043
+ console.log(formatSchemaUsage(withoutGlobalFlags(schema)));
42011
42044
  console.log("\nGlobal flags:");
42012
42045
  if (!hasOwnArgsField) {
42013
42046
  console.log(" --args <json> Pass the entire payload as JSON (overrides flags)");
@@ -42016,15 +42049,20 @@ ${description}
42016
42049
  console.log(" --<field>-json <json> Pass a single field as JSON (objects/nested arrays)");
42017
42050
  console.log(" --json Print only the raw JSON result");
42018
42051
  console.log(
42019
- " --out <path> Save the image result, or the screen after an action, to <path>"
42052
+ " --out <path> Save the image result, or the screen after an action, to <path>; outranks a payload `out`"
42020
42053
  );
42021
42054
  console.log(" --help, -h Show this help");
42022
42055
  const deviceField = requiredDeviceField(schema);
42023
42056
  if (deviceField) console.log(`
42024
42057
  ARGENT_UDID sets --${deviceField} when the call leaves it out.`);
42025
42058
  }
42059
+ function withoutGlobalFlags(schema) {
42060
+ if (!schema?.properties) return schema;
42061
+ const { out: _out, ...properties } = schema.properties;
42062
+ return { ...schema, properties };
42063
+ }
42026
42064
  async function fetchImageToFile(result, outPath) {
42027
- const url2 = result.url;
42065
+ const url2 = result?.url;
42028
42066
  if (!url2) {
42029
42067
  throw new Error("Tool result did not include a `url`; cannot save image");
42030
42068
  }
@@ -42033,7 +42071,7 @@ async function fetchImageToFile(result, outPath) {
42033
42071
  writeImageFile(outPath, Buffer.from(await res.arrayBuffer()));
42034
42072
  }
42035
42073
  function drainStdout() {
42036
- return new Promise((resolve26) => process.stdout.write("", () => resolve26()));
42074
+ return new Promise((resolve25) => process.stdout.write("", () => resolve25()));
42037
42075
  }
42038
42076
  function onReaderClosed(exit) {
42039
42077
  for (const stream of [process.stdout, process.stderr]) {
@@ -42045,9 +42083,12 @@ function onReaderClosed(exit) {
42045
42083
  });
42046
42084
  }
42047
42085
  }
42048
- function writeImageFile(outPath, data) {
42049
- fs16.mkdirSync(path22.dirname(path22.resolve(outPath)), { recursive: true });
42050
- fs16.writeFileSync(outPath, data);
42086
+ function writeImageFile(file2, data) {
42087
+ fs16.mkdirSync(path22.dirname(file2), { recursive: true });
42088
+ if (fs16.statSync(file2, { throwIfNoEntry: false })?.isFile() === false) {
42089
+ throw new Error(`${file2} is not a regular file`);
42090
+ }
42091
+ fs16.writeFileSync(file2, data);
42051
42092
  }
42052
42093
  function renderResult(result, outputHint, images, json2) {
42053
42094
  if (json2) return JSON.stringify(result, null, 2);
@@ -42110,8 +42151,9 @@ result, without waiting.
42110
42151
  Set ARGENT_UDID to use that device when a tool needs --udid or --device_id
42111
42152
  and the call does not pass one.
42112
42153
 
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
42154
+ Exits 1 when the tool fails, when an image result is not saved to --out or
42155
+ a payload \`out\`, or when --out without --json gets no screen after an
42156
+ action. Also exits 1 when the result reports that the call did not
42115
42157
  do its job: an e2e test that does not pass, an await-ui-element or
42116
42158
  await-network-request wait with success=false, a run-sequence that a step
42117
42159
  stopped, a debugger tool with no connection or an error, a native-devtools
@@ -42249,6 +42291,7 @@ settled=false or debugger-status's not_connected.
42249
42291
  `Note: ignoring unused argument(s): ${parsed.positional.join(", ")}. Pass values as --flag <value> or --flag=<value>.`
42250
42292
  );
42251
42293
  }
42294
+ if (outPath && meta3.outputHint === "image") delete payload.out;
42252
42295
  const missing = findMissingRequired(payload, schema);
42253
42296
  if (missing.length > 0) {
42254
42297
  const envHint = deviceField && missing.includes(deviceField) ? ` (--${deviceField} can come from ARGENT_UDID)` : "";
@@ -42258,6 +42301,17 @@ settled=false or debugger-status's not_connected.
42258
42301
  envHint
42259
42302
  );
42260
42303
  }
42304
+ const payloadOut = typeof payload.out === "string" ? payload.out.trim() : null;
42305
+ if (meta3.outputHint === "image" && payload.out !== void 0 && !path22.isAbsolute(payloadOut ?? "")) {
42306
+ await failInvocation(
42307
+ "`out` must be an absolute path on this computer; `--out <path>` also takes a relative one",
42308
+ null,
42309
+ {
42310
+ error_code: FAILURE_CODES.CLI_RUN_INPUT_VALIDATION_FAILED,
42311
+ failure_stage: "cli_run_payload_out"
42312
+ }
42313
+ );
42314
+ }
42261
42315
  let result;
42262
42316
  let note2;
42263
42317
  let failure2;
@@ -42327,19 +42381,20 @@ settled=false or debugger-status's not_connected.
42327
42381
  process.exit(1);
42328
42382
  }
42329
42383
  };
42330
- if (outPath && meta3.outputHint === "image") {
42384
+ const imageOut = outPath ?? payloadOut;
42385
+ if (imageOut && meta3.outputHint === "image") {
42331
42386
  await saveImage(async () => {
42332
42387
  if (images.length > 0) {
42333
- writeImageFile(outPath, images[0].data);
42334
- } else if (result && typeof result === "object") {
42335
- await fetchImageToFile(result, outPath);
42388
+ writeImageFile(imageOut, images[0].data);
42389
+ } else {
42390
+ await fetchImageToFile(result, imageOut);
42336
42391
  }
42337
42392
  });
42338
42393
  }
42339
42394
  if (note2) console.error(note2);
42340
42395
  console.log(renderResult(result, meta3.outputHint, images, json2));
42341
- if (outPath && meta3.outputHint === "image" && !json2) {
42342
- console.log(`Wrote: ${outPath}`);
42396
+ if (imageOut && meta3.outputHint === "image" && !json2) {
42397
+ console.log(`Wrote: ${imageOut}`);
42343
42398
  }
42344
42399
  if (!json2) {
42345
42400
  const capture = await captureAfterAction({ client: client2, toolName, payload, profiling });
@@ -42584,7 +42639,14 @@ function logsCmd(follow) {
42584
42639
  return;
42585
42640
  }
42586
42641
  if (!follow) {
42587
- process.stdout.write(fs17.readFileSync(LOG_FILE2, "utf8"));
42642
+ let log2;
42643
+ try {
42644
+ log2 = fs17.readFileSync(LOG_FILE2, "utf8");
42645
+ } catch (err) {
42646
+ console.error(`argent server logs: cannot read ${LOG_FILE2} (${err.message}).`);
42647
+ process.exit(1);
42648
+ }
42649
+ process.stdout.write(log2);
42588
42650
  return;
42589
42651
  }
42590
42652
  const cannotFollow = (err) => {
@@ -43294,7 +43356,7 @@ function ptyInjectBeats(text2) {
43294
43356
  ];
43295
43357
  }
43296
43358
  function sleep2(ms) {
43297
- return new Promise((resolve26) => setTimeout(resolve26, ms));
43359
+ return new Promise((resolve25) => setTimeout(resolve25, ms));
43298
43360
  }
43299
43361
  var DEFAULT_COLS = 80;
43300
43362
  var DEFAULT_ROWS = 24;
@@ -43516,7 +43578,7 @@ var DEATH_CONFIRMATIONS = 3;
43516
43578
  var SSE_RECONNECT_MS = 1e3;
43517
43579
  var authHeaders3 = {};
43518
43580
  function sleep3(ms) {
43519
- return new Promise((resolve26) => setTimeout(resolve26, ms));
43581
+ return new Promise((resolve25) => setTimeout(resolve25, ms));
43520
43582
  }
43521
43583
  var TRUST_PROMPT_RE = /trust this folder|do you trust|yes,? i trust|trust the files in this/i;
43522
43584
  async function dismissTrustPrompt(session) {
@@ -50785,14 +50847,15 @@ var cursorAdapter = {
50785
50847
  editJsoncFile(cursorPermissionsPath(), ["mcpAllowlist"], [...list, CURSOR_ALLOWLIST_PATTERN]);
50786
50848
  },
50787
50849
  removeAllowlist(_root, scope) {
50788
- if (scope !== "global") return;
50850
+ if (scope !== "global") return false;
50789
50851
  const permPath = cursorPermissionsPath();
50790
- if (!fs29.existsSync(permPath)) return;
50852
+ if (!fs29.existsSync(permPath)) return false;
50791
50853
  const config3 = readJsonc(permPath);
50792
50854
  const list = Array.isArray(config3.mcpAllowlist) ? config3.mcpAllowlist : void 0;
50793
- if (!list || !list.includes(CURSOR_ALLOWLIST_PATTERN)) return;
50855
+ if (!list || !list.includes(CURSOR_ALLOWLIST_PATTERN)) return false;
50794
50856
  const next = list.filter((rule) => rule !== CURSOR_ALLOWLIST_PATTERN);
50795
50857
  editJsoncFile(permPath, ["mcpAllowlist"], next.length > 0 ? next : void 0);
50858
+ return true;
50796
50859
  }
50797
50860
  };
50798
50861
  function claudeProjectKeysForRoot(projects, root) {
@@ -50926,7 +50989,7 @@ var claudeAdapter = {
50926
50989
  addClaudePermission(root, scope);
50927
50990
  },
50928
50991
  removeAllowlist(root, scope) {
50929
- removeClaudePermission(root, scope);
50992
+ return removeClaudePermission(root, scope);
50930
50993
  }
50931
50994
  };
50932
50995
  var vscodeAdapter = {
@@ -51065,15 +51128,16 @@ var windsurfAdapter = {
51065
51128
  addAllowRule(devinUserConfigPath(), DEVIN_PERMISSION_RULE);
51066
51129
  },
51067
51130
  removeAllowlist(_root, scope) {
51068
- if (scope !== "global") return;
51069
- removeAllowRule(devinUserConfigPath(), DEVIN_PERMISSION_RULE);
51131
+ if (scope !== "global") return false;
51132
+ const removedRule = removeAllowRule(devinUserConfigPath(), DEVIN_PERMISSION_RULE);
51070
51133
  const configPath = path38.join(homedir6(), ".codeium", "windsurf", "mcp_config.json");
51071
- if (!fs29.existsSync(configPath)) return;
51134
+ if (!fs29.existsSync(configPath)) return removedRule;
51072
51135
  const config3 = readJsonc(configPath);
51073
51136
  const servers = config3.mcpServers;
51074
51137
  const entry = servers?.[MCP_SERVER_KEY];
51075
- if (!entry?.alwaysAllow) return;
51138
+ if (!entry?.alwaysAllow) return removedRule;
51076
51139
  editJsoncFile(configPath, ["mcpServers", MCP_SERVER_KEY, "alwaysAllow"], void 0);
51140
+ return true;
51077
51141
  }
51078
51142
  };
51079
51143
  var zedAdapter = {
@@ -51122,11 +51186,12 @@ var zedAdapter = {
51122
51186
  },
51123
51187
  removeAllowlist(root, scope) {
51124
51188
  const settingsPath = scope === "global" ? path38.join(homedir6(), ".config", "zed", "settings.json") : path38.join(root, ".zed", "settings.json");
51125
- if (!fs29.existsSync(settingsPath)) return;
51189
+ if (!fs29.existsSync(settingsPath)) return false;
51126
51190
  const config3 = readJsonc(settingsPath);
51127
51191
  const perms = config3.agent?.tool_permissions;
51128
- if (!perms || perms.default !== "allow") return;
51192
+ if (!perms || perms.default !== "allow") return false;
51129
51193
  editJsoncFile(settingsPath, ["agent", "tool_permissions", "default"], "confirm");
51194
+ return true;
51130
51195
  }
51131
51196
  };
51132
51197
  var geminiAdapter = {
@@ -51181,13 +51246,14 @@ var geminiAdapter = {
51181
51246
  removeAllowlist(root, scope) {
51182
51247
  const configPath = scope === "global" ? this.globalPath() : this.projectPath(root);
51183
51248
  if (!configPath || !fs29.existsSync(configPath)) {
51184
- return;
51249
+ return false;
51185
51250
  }
51186
51251
  const config3 = readJsonc(configPath);
51187
51252
  const servers = config3.mcpServers;
51188
51253
  const entry = servers?.[MCP_SERVER_KEY];
51189
- if (!entry?.trust) return;
51254
+ if (!entry?.trust) return false;
51190
51255
  editJsoncFile(configPath, ["mcpServers", MCP_SERVER_KEY, "trust"], void 0);
51256
+ return true;
51191
51257
  }
51192
51258
  };
51193
51259
  var CODEX_FILENAME = ".codex";
@@ -51276,20 +51342,23 @@ var codexAdapter = {
51276
51342
  removeAllowlist(root, scope) {
51277
51343
  const configPath = scope === "global" ? this.globalPath() : this.projectPath(root);
51278
51344
  if (!configPath) {
51279
- return;
51345
+ return false;
51280
51346
  }
51281
51347
  const tools2 = getAvailableToolIds();
51282
51348
  const config3 = readToml(configPath);
51283
51349
  const toolsConfig = config3?.mcp_servers?.argent?.tools;
51284
51350
  if (toolsConfig === void 0) {
51285
- return;
51351
+ return false;
51286
51352
  }
51353
+ let removed = false;
51287
51354
  for (const tool of tools2) {
51288
51355
  if (tool in toolsConfig) {
51289
51356
  delete toolsConfig[tool];
51357
+ removed = true;
51290
51358
  }
51291
51359
  }
51292
- writeToml(configPath, config3);
51360
+ if (removed) writeToml(configPath, config3);
51361
+ return removed;
51293
51362
  }
51294
51363
  };
51295
51364
  var hermesAdapter = {
@@ -51408,11 +51477,12 @@ var openCodeAdapter = {
51408
51477
  },
51409
51478
  removeAllowlist(root, scope) {
51410
51479
  const configPath = scope === "global" ? this.globalPath() : this.projectPath(root);
51411
- if (!configPath || !fs29.existsSync(configPath)) return;
51480
+ if (!configPath || !fs29.existsSync(configPath)) return false;
51412
51481
  const config3 = readJsonc(configPath);
51413
51482
  const tools2 = config3.tools;
51414
- if (!tools2 || !(OPENCODE_ALLOWLIST_PATTERN in tools2)) return;
51483
+ if (!tools2 || !(OPENCODE_ALLOWLIST_PATTERN in tools2)) return false;
51415
51484
  editJsoncFile(configPath, ["tools", OPENCODE_ALLOWLIST_PATTERN], void 0);
51485
+ return true;
51416
51486
  }
51417
51487
  };
51418
51488
  var KIRO_AUTO_APPROVE_ALL = ["*"];
@@ -51470,12 +51540,13 @@ var kiroAdapter = {
51470
51540
  },
51471
51541
  removeAllowlist(root, scope) {
51472
51542
  const configPath = scope === "global" ? this.globalPath() : this.projectPath(root);
51473
- if (!configPath || !fs29.existsSync(configPath)) return;
51543
+ if (!configPath || !fs29.existsSync(configPath)) return false;
51474
51544
  const config3 = readJsonc(configPath);
51475
51545
  const servers = config3.mcpServers;
51476
51546
  const entry = servers?.[MCP_SERVER_KEY];
51477
- if (!entry?.autoApprove) return;
51547
+ if (!entry?.autoApprove) return false;
51478
51548
  editJsoncFile(configPath, ["mcpServers", MCP_SERVER_KEY, "autoApprove"], void 0);
51549
+ return true;
51479
51550
  }
51480
51551
  };
51481
51552
  var ALL_ADAPTERS = [
@@ -51522,14 +51593,15 @@ function addAllowRule(settingsPath, rule) {
51522
51593
  editJsoncFile(settingsPath, ["permissions", "allow"], [...allow, rule]);
51523
51594
  }
51524
51595
  function removeAllowRule(settingsPath, rule) {
51525
- if (!fs29.existsSync(settingsPath)) return;
51596
+ if (!fs29.existsSync(settingsPath)) return false;
51526
51597
  const config3 = readJsonc(settingsPath);
51527
51598
  const permissions = config3?.permissions;
51528
51599
  const allow = permissions?.allow;
51529
- if (!permissions || !Array.isArray(allow)) return;
51530
- if (!allow.includes(rule)) return;
51600
+ if (!permissions || !Array.isArray(allow)) return false;
51601
+ if (!allow.includes(rule)) return false;
51531
51602
  const next = allow.filter((r2) => r2 !== rule);
51532
51603
  editJsoncFile(settingsPath, ["permissions", "allow"], next.length > 0 ? next : void 0);
51604
+ return true;
51533
51605
  }
51534
51606
  function claudeSettingsPath(root, scope) {
51535
51607
  return scope === "global" ? path38.join(homedir6(), ".claude", "settings.json") : path38.join(root, ".claude", "settings.json");
@@ -51538,7 +51610,7 @@ function addClaudePermission(root, scope) {
51538
51610
  addAllowRule(claudeSettingsPath(root, scope), PERMISSION_RULE);
51539
51611
  }
51540
51612
  function removeClaudePermission(root, scope) {
51541
- removeAllowRule(claudeSettingsPath(root, scope), PERMISSION_RULE);
51613
+ return removeAllowRule(claudeSettingsPath(root, scope), PERMISSION_RULE);
51542
51614
  }
51543
51615
  function formatManagedPathLabel(targetPath, root) {
51544
51616
  for (const home2 of [path38.resolve(homedir6()), canonicalPath(homedir6())]) {
@@ -51718,7 +51790,7 @@ import * as path41 from "node:path";
51718
51790
 
51719
51791
  // ../argent-installer/src/init-scope.ts
51720
51792
  import { existsSync as existsSync19 } from "node:fs";
51721
- import { resolve as resolve23 } from "node:path";
51793
+ import { resolve as resolve22 } from "node:path";
51722
51794
 
51723
51795
  // ../argent-installer/src/init-skills.ts
51724
51796
  import { spawn as spawn6 } from "node:child_process";