@swmansion/argent 0.36.0 → 0.36.1-next.1

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
@@ -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 = [
@@ -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) {
@@ -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) {
@@ -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.36.0";
39188
+ return "0.36.1-next.1";
39161
39189
  }
39162
39190
  return "0.0.0";
39163
39191
  }
@@ -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}`;
@@ -42609,7 +42639,14 @@ function logsCmd(follow) {
42609
42639
  return;
42610
42640
  }
42611
42641
  if (!follow) {
42612
- 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);
42613
42650
  return;
42614
42651
  }
42615
42652
  const cannotFollow = (err) => {
@@ -50810,14 +50847,15 @@ var cursorAdapter = {
50810
50847
  editJsoncFile(cursorPermissionsPath(), ["mcpAllowlist"], [...list, CURSOR_ALLOWLIST_PATTERN]);
50811
50848
  },
50812
50849
  removeAllowlist(_root, scope) {
50813
- if (scope !== "global") return;
50850
+ if (scope !== "global") return false;
50814
50851
  const permPath = cursorPermissionsPath();
50815
- if (!fs29.existsSync(permPath)) return;
50852
+ if (!fs29.existsSync(permPath)) return false;
50816
50853
  const config3 = readJsonc(permPath);
50817
50854
  const list = Array.isArray(config3.mcpAllowlist) ? config3.mcpAllowlist : void 0;
50818
- if (!list || !list.includes(CURSOR_ALLOWLIST_PATTERN)) return;
50855
+ if (!list || !list.includes(CURSOR_ALLOWLIST_PATTERN)) return false;
50819
50856
  const next = list.filter((rule) => rule !== CURSOR_ALLOWLIST_PATTERN);
50820
50857
  editJsoncFile(permPath, ["mcpAllowlist"], next.length > 0 ? next : void 0);
50858
+ return true;
50821
50859
  }
50822
50860
  };
50823
50861
  function claudeProjectKeysForRoot(projects, root) {
@@ -50951,7 +50989,7 @@ var claudeAdapter = {
50951
50989
  addClaudePermission(root, scope);
50952
50990
  },
50953
50991
  removeAllowlist(root, scope) {
50954
- removeClaudePermission(root, scope);
50992
+ return removeClaudePermission(root, scope);
50955
50993
  }
50956
50994
  };
50957
50995
  var vscodeAdapter = {
@@ -51090,15 +51128,16 @@ var windsurfAdapter = {
51090
51128
  addAllowRule(devinUserConfigPath(), DEVIN_PERMISSION_RULE);
51091
51129
  },
51092
51130
  removeAllowlist(_root, scope) {
51093
- if (scope !== "global") return;
51094
- removeAllowRule(devinUserConfigPath(), DEVIN_PERMISSION_RULE);
51131
+ if (scope !== "global") return false;
51132
+ const removedRule = removeAllowRule(devinUserConfigPath(), DEVIN_PERMISSION_RULE);
51095
51133
  const configPath = path38.join(homedir6(), ".codeium", "windsurf", "mcp_config.json");
51096
- if (!fs29.existsSync(configPath)) return;
51134
+ if (!fs29.existsSync(configPath)) return removedRule;
51097
51135
  const config3 = readJsonc(configPath);
51098
51136
  const servers = config3.mcpServers;
51099
51137
  const entry = servers?.[MCP_SERVER_KEY];
51100
- if (!entry?.alwaysAllow) return;
51138
+ if (!entry?.alwaysAllow) return removedRule;
51101
51139
  editJsoncFile(configPath, ["mcpServers", MCP_SERVER_KEY, "alwaysAllow"], void 0);
51140
+ return true;
51102
51141
  }
51103
51142
  };
51104
51143
  var zedAdapter = {
@@ -51147,11 +51186,12 @@ var zedAdapter = {
51147
51186
  },
51148
51187
  removeAllowlist(root, scope) {
51149
51188
  const settingsPath = scope === "global" ? path38.join(homedir6(), ".config", "zed", "settings.json") : path38.join(root, ".zed", "settings.json");
51150
- if (!fs29.existsSync(settingsPath)) return;
51189
+ if (!fs29.existsSync(settingsPath)) return false;
51151
51190
  const config3 = readJsonc(settingsPath);
51152
51191
  const perms = config3.agent?.tool_permissions;
51153
- if (!perms || perms.default !== "allow") return;
51192
+ if (!perms || perms.default !== "allow") return false;
51154
51193
  editJsoncFile(settingsPath, ["agent", "tool_permissions", "default"], "confirm");
51194
+ return true;
51155
51195
  }
51156
51196
  };
51157
51197
  var geminiAdapter = {
@@ -51206,13 +51246,14 @@ var geminiAdapter = {
51206
51246
  removeAllowlist(root, scope) {
51207
51247
  const configPath = scope === "global" ? this.globalPath() : this.projectPath(root);
51208
51248
  if (!configPath || !fs29.existsSync(configPath)) {
51209
- return;
51249
+ return false;
51210
51250
  }
51211
51251
  const config3 = readJsonc(configPath);
51212
51252
  const servers = config3.mcpServers;
51213
51253
  const entry = servers?.[MCP_SERVER_KEY];
51214
- if (!entry?.trust) return;
51254
+ if (!entry?.trust) return false;
51215
51255
  editJsoncFile(configPath, ["mcpServers", MCP_SERVER_KEY, "trust"], void 0);
51256
+ return true;
51216
51257
  }
51217
51258
  };
51218
51259
  var CODEX_FILENAME = ".codex";
@@ -51301,20 +51342,23 @@ var codexAdapter = {
51301
51342
  removeAllowlist(root, scope) {
51302
51343
  const configPath = scope === "global" ? this.globalPath() : this.projectPath(root);
51303
51344
  if (!configPath) {
51304
- return;
51345
+ return false;
51305
51346
  }
51306
51347
  const tools2 = getAvailableToolIds();
51307
51348
  const config3 = readToml(configPath);
51308
51349
  const toolsConfig = config3?.mcp_servers?.argent?.tools;
51309
51350
  if (toolsConfig === void 0) {
51310
- return;
51351
+ return false;
51311
51352
  }
51353
+ let removed = false;
51312
51354
  for (const tool of tools2) {
51313
51355
  if (tool in toolsConfig) {
51314
51356
  delete toolsConfig[tool];
51357
+ removed = true;
51315
51358
  }
51316
51359
  }
51317
- writeToml(configPath, config3);
51360
+ if (removed) writeToml(configPath, config3);
51361
+ return removed;
51318
51362
  }
51319
51363
  };
51320
51364
  var hermesAdapter = {
@@ -51433,11 +51477,12 @@ var openCodeAdapter = {
51433
51477
  },
51434
51478
  removeAllowlist(root, scope) {
51435
51479
  const configPath = scope === "global" ? this.globalPath() : this.projectPath(root);
51436
- if (!configPath || !fs29.existsSync(configPath)) return;
51480
+ if (!configPath || !fs29.existsSync(configPath)) return false;
51437
51481
  const config3 = readJsonc(configPath);
51438
51482
  const tools2 = config3.tools;
51439
- if (!tools2 || !(OPENCODE_ALLOWLIST_PATTERN in tools2)) return;
51483
+ if (!tools2 || !(OPENCODE_ALLOWLIST_PATTERN in tools2)) return false;
51440
51484
  editJsoncFile(configPath, ["tools", OPENCODE_ALLOWLIST_PATTERN], void 0);
51485
+ return true;
51441
51486
  }
51442
51487
  };
51443
51488
  var KIRO_AUTO_APPROVE_ALL = ["*"];
@@ -51495,12 +51540,13 @@ var kiroAdapter = {
51495
51540
  },
51496
51541
  removeAllowlist(root, scope) {
51497
51542
  const configPath = scope === "global" ? this.globalPath() : this.projectPath(root);
51498
- if (!configPath || !fs29.existsSync(configPath)) return;
51543
+ if (!configPath || !fs29.existsSync(configPath)) return false;
51499
51544
  const config3 = readJsonc(configPath);
51500
51545
  const servers = config3.mcpServers;
51501
51546
  const entry = servers?.[MCP_SERVER_KEY];
51502
- if (!entry?.autoApprove) return;
51547
+ if (!entry?.autoApprove) return false;
51503
51548
  editJsoncFile(configPath, ["mcpServers", MCP_SERVER_KEY, "autoApprove"], void 0);
51549
+ return true;
51504
51550
  }
51505
51551
  };
51506
51552
  var ALL_ADAPTERS = [
@@ -51547,14 +51593,15 @@ function addAllowRule(settingsPath, rule) {
51547
51593
  editJsoncFile(settingsPath, ["permissions", "allow"], [...allow, rule]);
51548
51594
  }
51549
51595
  function removeAllowRule(settingsPath, rule) {
51550
- if (!fs29.existsSync(settingsPath)) return;
51596
+ if (!fs29.existsSync(settingsPath)) return false;
51551
51597
  const config3 = readJsonc(settingsPath);
51552
51598
  const permissions = config3?.permissions;
51553
51599
  const allow = permissions?.allow;
51554
- if (!permissions || !Array.isArray(allow)) return;
51555
- if (!allow.includes(rule)) return;
51600
+ if (!permissions || !Array.isArray(allow)) return false;
51601
+ if (!allow.includes(rule)) return false;
51556
51602
  const next = allow.filter((r2) => r2 !== rule);
51557
51603
  editJsoncFile(settingsPath, ["permissions", "allow"], next.length > 0 ? next : void 0);
51604
+ return true;
51558
51605
  }
51559
51606
  function claudeSettingsPath(root, scope) {
51560
51607
  return scope === "global" ? path38.join(homedir6(), ".claude", "settings.json") : path38.join(root, ".claude", "settings.json");
@@ -51563,7 +51610,7 @@ function addClaudePermission(root, scope) {
51563
51610
  addAllowRule(claudeSettingsPath(root, scope), PERMISSION_RULE);
51564
51611
  }
51565
51612
  function removeClaudePermission(root, scope) {
51566
- removeAllowRule(claudeSettingsPath(root, scope), PERMISSION_RULE);
51613
+ return removeAllowRule(claudeSettingsPath(root, scope), PERMISSION_RULE);
51567
51614
  }
51568
51615
  function formatManagedPathLabel(targetPath, root) {
51569
51616
  for (const home2 of [path38.resolve(homedir6()), canonicalPath(homedir6())]) {