@swmansion/argent 0.34.1-next.48 → 0.34.1-next.49

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
@@ -36259,7 +36259,7 @@ function isCi(env = process.env) {
36259
36259
  var SESSION_ID2 = randomUUID5();
36260
36260
  function readCliVersion() {
36261
36261
  if (true) {
36262
- return "0.34.1-next.48";
36262
+ return "0.34.1-next.49";
36263
36263
  }
36264
36264
  return "0.0.0";
36265
36265
  }
@@ -16945,7 +16945,7 @@ function isCi(env = process.env) {
16945
16945
  var SESSION_ID = randomUUID4();
16946
16946
  function readCliVersion() {
16947
16947
  if (true) {
16948
- return "0.34.1-next.48";
16948
+ return "0.34.1-next.49";
16949
16949
  }
16950
16950
  return "0.0.0";
16951
16951
  }
@@ -546,11 +546,11 @@ export interface ArgentToolArgs {
546
546
  udid: string;
547
547
  /** App bundle ID on iOS or package name on Android (on a Mac app, the bundle id in the device id) */
548
548
  bundleId: string;
549
- /** The app's Metro port, whose requests are left out of the listing. Omit it to use this device's port, 8081 by default. A Mac app ignores it. */
549
+ /** The app's Metro port, whose requests are left out of the listing. Omit it to use this device's port, 8081 by default. */
550
550
  port?: number;
551
- /** Maximum number of requests to return: the most recent ones, oldest first. 0 returns only the header and the total. On a Mac app it counts events, not requests: one request gives several events. 0 returns no events. */
551
+ /** Maximum number of requests to return: the most recent ones, oldest first. 0 returns only the header and the total. */
552
552
  limit?: number;
553
- /** Clear the log after reading. On iOS and Android, the IDs of cleared requests still work in view-network-request-details */
553
+ /** Clear the log after reading. The IDs of cleared requests still work in view-network-request-details */
554
554
  clear?: boolean;
555
555
  };
556
556
  "native-profiler-analyze": {
@@ -630,9 +630,9 @@ export interface ArgentToolArgs {
630
630
  hitTest?: boolean;
631
631
  };
632
632
  "network-capture-start": {
633
- /** Device ID from list-devices: an iOS simulator UDID or Android serial */
633
+ /** Device ID from list-devices: an iOS simulator UDID or Android serial, or a Mac app id (macos-app-<bundle id>) */
634
634
  udid: string;
635
- /** App bundle ID on iOS or package name on Android */
635
+ /** App bundle ID on iOS or package name on Android (on a Mac app, the bundle id in the device id) */
636
636
  bundleId: string;
637
637
  /** The app's Metro port: the JS layer is reached through it, and the native layers leave its requests out. Omit it to use this device's port, 8081 by default. */
638
638
  port?: number;
@@ -640,9 +640,9 @@ export interface ArgentToolArgs {
640
640
  logicalDeviceId?: string;
641
641
  };
642
642
  "network-capture-stop": {
643
- /** Device ID from list-devices: an iOS simulator UDID or Android serial */
643
+ /** Device ID from list-devices: an iOS simulator UDID or Android serial, or a Mac app id (macos-app-<bundle id>) */
644
644
  udid: string;
645
- /** App bundle ID on iOS or package name on Android */
645
+ /** App bundle ID on iOS or package name on Android (on a Mac app, the bundle id in the device id) */
646
646
  bundleId: string;
647
647
  /** The app's Metro port: the JS layer is reached through it, and the native layers leave its requests out. Omit it to use this device's port, 8081 by default. */
648
648
  port?: number;
@@ -1009,9 +1009,9 @@ export interface ArgentToolArgs {
1009
1009
  "view-network-request-details": {
1010
1010
  /** Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. */
1011
1011
  port?: number;
1012
- /** Device id from list-devices (iOS simulator UDID or Android serial), the same id used with debugger-connect. An ios- or android- ID needs no debugger connection. */
1012
+ /** Device id from list-devices (iOS simulator UDID or Android serial, the same id used with debugger-connect, or a Mac app id). A native ID needs no debugger connection. */
1013
1013
  device_id: string;
1014
- /** The requestId from view-network-logs, or an ios- or android- ID from native-network-logs. */
1014
+ /** The requestId from view-network-logs, or a native ID (ios-, android- or macos-) from native-network-logs. */
1015
1015
  requestId: string;
1016
1016
  /** Whether to include the response body (if captured). */
1017
1017
  includeBody?: boolean;
@@ -79676,7 +79676,7 @@ function assertSupported(toolId, capability42, device) {
79676
79676
  throw new UnsupportedOperationError(toolId, device, "supports() refiner rejected device");
79677
79677
  }
79678
79678
  }
79679
- var UnsupportedOperationError, NotImplementedOnPlatformError, InvalidToolInputError, MACOS_APPS_FLAG, MACOS_APPS_FLAG_OFF_REASON, MACOS_POINTER_ONLY, MACOS_NO_TRACKPAD_GESTURES, MACOS_NO_CAPTURE_START_STOP, MACOS_REFUSAL_REASONS, NO_CAPTURE_START_STOP_REASONS, CATALYST_NO_APPKIT_VIEWS, MACOS_CATALYST_REFUSAL_REASONS;
79679
+ var UnsupportedOperationError, NotImplementedOnPlatformError, InvalidToolInputError, MACOS_APPS_FLAG, MACOS_APPS_FLAG_OFF_REASON, MACOS_POINTER_ONLY, MACOS_NO_TRACKPAD_GESTURES, MACOS_REFUSAL_REASONS, NO_CAPTURE_START_STOP_REASONS, CATALYST_NO_APPKIT_VIEWS, MACOS_CATALYST_REFUSAL_REASONS;
79680
79680
  var init_capability = __esm({
79681
79681
  "../tool-server/src/utils/capability.ts"() {
79682
79682
  "use strict";
@@ -79744,16 +79744,13 @@ var init_capability = __esm({
79744
79744
  MACOS_APPS_FLAG_OFF_REASON = "the macos-apps flag is off. Run: argent enable macos-apps";
79745
79745
  MACOS_POINTER_ONLY = "a Mac app takes mouse input: use gesture-drag to drag and gesture-scroll to scroll";
79746
79746
  MACOS_NO_TRACKPAD_GESTURES = "a Mac app has no trackpad gesture input: use the app's own zoom or rotate controls with gesture-tap or keyboard";
79747
- MACOS_NO_CAPTURE_START_STOP = "a Mac app's network capture has no start or stop: native-network-logs turns it on at its first call, and stop-simulator-server or stop-all-simulator-servers for the app ends it and drops its log";
79748
79747
  MACOS_REFUSAL_REASONS = {
79749
79748
  "gesture-swipe": MACOS_POINTER_ONLY,
79750
79749
  "gesture-custom": MACOS_POINTER_ONLY,
79751
79750
  "gesture-pinch": MACOS_NO_TRACKPAD_GESTURES,
79752
79751
  "gesture-rotate": MACOS_NO_TRACKPAD_GESTURES,
79753
79752
  "button": "a Mac app has no hardware buttons: use keyboard for key presses",
79754
- "reinstall-app": "argent does not install Mac apps, it starts the .app where it was built. Rebuild the app, then run restart-app (or boot-device with macosAppPath for a .app at another path)",
79755
- "network-capture-start": MACOS_NO_CAPTURE_START_STOP,
79756
- "network-capture-stop": MACOS_NO_CAPTURE_START_STOP
79753
+ "reinstall-app": "argent does not install Mac apps, it starts the .app where it was built. Rebuild the app, then run restart-app (or boot-device with macosAppPath for a .app at another path)"
79757
79754
  };
79758
79755
  NO_CAPTURE_START_STOP_REASONS = {
79759
79756
  vega: "a Vega app's network capture has no start or stop: view-network-logs turns it on at its first call",
@@ -101450,7 +101447,7 @@ function isCi(env = process.env) {
101450
101447
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
101451
101448
  function readCliVersion() {
101452
101449
  if (true) {
101453
- return "0.34.1-next.48";
101450
+ return "0.34.1-next.49";
101454
101451
  }
101455
101452
  return "0.0.0";
101456
101453
  }
@@ -124680,6 +124677,7 @@ async function withKeyedLock(locks, key2, fn) {
124680
124677
  // ../tool-server/src/blueprints/ios-network-records.ts
124681
124678
  var RUN_TAG = (0, import_node_crypto7.randomBytes)(2).toString("hex");
124682
124679
  var IOS_NATIVE_REQUEST_ID = /^ios-[0-9a-f]{4}-\d+$/;
124680
+ var MACOS_NATIVE_REQUEST_ID = /^macos-[0-9a-f]{4}-\d+$/;
124683
124681
  var nextRecordNumber = 1;
124684
124682
  function lastIosRecordNumber() {
124685
124683
  return nextRecordNumber - 1;
@@ -124694,8 +124692,11 @@ var NO_EARLIER_ANSWER = `the app did not answer an earlier body read within ${RE
124694
124692
  var CONNECTION_CLOSED = "the agent's connection closed before this body was read";
124695
124693
  var REQUEST_BODY_GONE = "the agent holds no body for this request";
124696
124694
  var BODY_NO_LONGER_HELD = "the agent no longer holds this body";
124695
+ var MACOS_NO_BODIES = "argent does not keep the bodies of a Mac app's requests";
124696
+ var MACOS_CONNECTION_DROPPED = "argent's connection to the app dropped while this request ran, so argent can have missed its end; the request completes if its end comes later";
124697
124697
  var NO_RESPONSE_BODY = "the response has no body";
124698
- function createIosNetworkRecords(state3, link, recording = () => true) {
124698
+ function createIosNetworkRecords(state3, link, recording = () => true, layer = "ios-native") {
124699
+ const idPrefix = layer === "macos-native" ? "macos" : "ios";
124699
124700
  const records = [];
124700
124701
  let recordChars = 0;
124701
124702
  const recordSizes = /* @__PURE__ */ new WeakMap();
@@ -124719,8 +124720,8 @@ function createIosNetworkRecords(state3, link, recording = () => true) {
124719
124720
  const startedAt = typeof p.wallTime === "number" ? p.wallTime * 1e3 : typeof p.timestamp === "number" ? p.timestamp * 1e3 : Date.now();
124720
124721
  const postData = typeof req.postData === "string" ? req.postData : "";
124721
124722
  const record2 = {
124722
- id: `ios-${RUN_TAG}-${nextRecordNumber++}`,
124723
- layer: "ios-native",
124723
+ id: `${idPrefix}-${RUN_TAG}-${nextRecordNumber++}`,
124724
+ layer,
124724
124725
  layerId,
124725
124726
  connection,
124726
124727
  state: "pending",
@@ -124772,6 +124773,7 @@ function createIosNetworkRecords(state3, link, recording = () => true) {
124772
124773
  bodies.delete(`post:${record2.id}`);
124773
124774
  }
124774
124775
  function closedReason(connection) {
124776
+ if (layer === "macos-native") return MACOS_NO_BODIES;
124775
124777
  const live = link.liveConnection();
124776
124778
  if (live !== void 0) sawConnection(live);
124777
124779
  return endedConnections.has(connection) || newestConnection > connection ? PROCESS_GONE : CONNECTION_CLOSED;
@@ -124908,6 +124910,7 @@ function createIosNetworkRecords(state3, link, recording = () => true) {
124908
124910
  const at = message.indexOf(marker);
124909
124911
  const detail = at === -1 ? message : message.slice(at + marker.length);
124910
124912
  if (/^no /i.test(detail)) {
124913
+ if (layer === "macos-native") return MACOS_NO_BODIES;
124911
124914
  if (kind === "response") return BODY_NO_LONGER_HELD;
124912
124915
  if (/^no request stored\b/i.test(detail)) {
124913
124916
  return record2.state === "pending" ? STILL_SENDING : BODY_NO_LONGER_HELD;
@@ -124939,6 +124942,7 @@ function createIosNetworkRecords(state3, link, recording = () => true) {
124939
124942
  case "Network.responseReceived": {
124940
124943
  const r = asObject(p.response);
124941
124944
  const status = typeof r.status === "number" ? r.status : 0;
124945
+ delete record2.errorText;
124942
124946
  record2.state = "headers";
124943
124947
  record2.response = {
124944
124948
  // The URL of the final response, after any redirects.
@@ -124953,6 +124957,7 @@ function createIosNetworkRecords(state3, link, recording = () => true) {
124953
124957
  }
124954
124958
  case "Network.loadingFinished":
124955
124959
  cleared.delete(record2);
124960
+ delete record2.errorText;
124956
124961
  record2.state = "complete";
124957
124962
  if (typeof p.encodedDataLength === "number")
124958
124963
  record2.encodedDataLength = p.encodedDataLength;
@@ -124975,10 +124980,12 @@ function createIosNetworkRecords(state3, link, recording = () => true) {
124975
124980
  sawConnection(connection);
124976
124981
  const ended = check3.superseded || check3.running === false || check3.runningPid !== void 0 && check3.connectionPid !== void 0 && check3.runningPid !== check3.connectionPid;
124977
124982
  if (ended) endedConnections.add(connection);
124978
- const open5 = records.filter((r) => r.connection === connection && isOpen(r));
124983
+ const open5 = records.filter(
124984
+ (r) => r.connection === connection && (isOpen(r) || ended && r.errorText === MACOS_CONNECTION_DROPPED)
124985
+ );
124979
124986
  for (const record2 of open5) {
124980
124987
  record2.state = "failed";
124981
- record2.errorText = ended ? PROCESS_ENDED : NOT_RECONNECTED;
124988
+ record2.errorText = ended ? PROCESS_ENDED : layer === "macos-native" ? MACOS_CONNECTION_DROPPED : NOT_RECONNECTED;
124982
124989
  cleared.delete(record2);
124983
124990
  }
124984
124991
  for (const record2 of open5) resize(record2);
@@ -145730,7 +145737,8 @@ async function startSuspensionWatch(helperPath, pid) {
145730
145737
  }
145731
145738
 
145732
145739
  // ../tool-server/src/blueprints/macos-app.ts
145733
- var NATIVE_NETWORK_LOG_LIMIT = 1e3;
145740
+ var NETWORK_CAPTURE_ACK_TIMEOUT_MS = 5e3;
145741
+ var PROCESS_EXIT_WAIT_MS = 2e3;
145734
145742
  var MACOS_APP_NAMESPACE = "MacosApp";
145735
145743
  function macosAppRef(device) {
145736
145744
  return { urn: `${MACOS_APP_NAMESPACE}:${device.id}`, options: { device } };
@@ -145774,6 +145782,58 @@ function notRunningError(bundleId) {
145774
145782
  "not_found"
145775
145783
  );
145776
145784
  }
145785
+ var BUILD_UNKNOWN_STAGE = "macos_app_locate";
145786
+ function buildUnknownError(bundleId) {
145787
+ return macosFailure(
145788
+ `No copy of ${bundleId} that argent started is running. argent cannot find the app's build, so it cannot tell whether a copy that it did not start runs. Start the app with boot-device with macosAppPath (the .app path) on the device ${macosAppIdFromBundleId(bundleId)}: boot-device reports a copy that already runs.`,
145789
+ FAILURE_CODES.MACOS_APP_NOT_RUNNING,
145790
+ BUILD_UNKNOWN_STAGE,
145791
+ "not_found"
145792
+ );
145793
+ }
145794
+ async function noLaunchedCopyError(bundleId) {
145795
+ const appPath = getTrackedMacosApp(bundleId)?.appPath ?? await findMacosAppByBundleId(bundleId);
145796
+ let info;
145797
+ try {
145798
+ info = appPath ? await inspectMacosApp(appPath) : void 0;
145799
+ } catch {
145800
+ info = void 0;
145801
+ }
145802
+ if (!info || info.bundleId !== bundleId) return buildUnknownError(bundleId);
145803
+ const copies = await findRunningCopies(bundleId, info.executable);
145804
+ const refuse = (message) => macosFailure(
145805
+ message,
145806
+ FAILURE_CODES.MACOS_APP_ALREADY_RUNNING,
145807
+ "macos_app_reconnect",
145808
+ "validation"
145809
+ );
145810
+ if (copies.same.length > 0) {
145811
+ return refuse(
145812
+ `${bundleId} is running (pid ${copies.same.join(", ")}) without the argent library: argent did not start that copy, and argent drives only a copy that it starts. launch-app refuses to start a second copy beside it. That copy may be the user's: ask the user to quit it, or to agree to boot-device with force: true, which quits it and starts the app with the library. Unsaved changes in that copy are lost.`
145813
+ );
145814
+ }
145815
+ if (copies.otherBuilds.length > 0) {
145816
+ const where = copies.otherBuilds.map((b) => `${b.appPath} (pid ${b.pid})`).join(", ");
145817
+ return refuse(
145818
+ `${bundleId} is running from ${where} without the argent library: argent did not start that copy, and argent drives only a copy that it starts. argent runs one copy of a bundle id at a time, so launch-app refuses to start ${info.appPath} beside it. Quit that copy if it is yours.`
145819
+ );
145820
+ }
145821
+ return notRunningError(bundleId);
145822
+ }
145823
+ async function macosLaunchRefusal(bundleId) {
145824
+ if (await runningTrackedApp(bundleId)) return void 0;
145825
+ const tracked = getTrackedMacosApp(bundleId)?.appPath;
145826
+ const appPath = tracked ?? await findMacosAppByBundleId(bundleId);
145827
+ if (!appPath) return void 0;
145828
+ let info;
145829
+ try {
145830
+ info = await inspectMacosApp(appPath);
145831
+ } catch {
145832
+ return void 0;
145833
+ }
145834
+ if (info.bundleId !== bundleId) return void 0;
145835
+ return chromiumRefusal(info) ?? (tracked ? hardenedRuntimeRefusal(info) : void 0) ?? void 0;
145836
+ }
145777
145837
  function errorMessage2(err) {
145778
145838
  return err instanceof Error ? err.message : String(err);
145779
145839
  }
@@ -145859,13 +145919,28 @@ function closedByArgentError(bundleId, method) {
145859
145919
  var LibraryChannel = class {
145860
145920
  /**
145861
145921
  * @param expectedPid the app's pid when known; a launch learns it from the helper after the spawn.
145862
- * @param onNetworkEvent receives each network event, with the pid of the process that sent it.
145922
+ * @param network receives the network events and the close.
145863
145923
  */
145864
- constructor(socket, bundleId, expectedPid, onNetworkEvent) {
145924
+ constructor(socket, bundleId, expectedPid, network) {
145865
145925
  this.socket = socket;
145866
145926
  this.bundleId = bundleId;
145867
145927
  this.expectedPid = expectedPid;
145868
- this.onNetworkEvent = onNetworkEvent;
145928
+ this.network = network;
145929
+ this.cdp = createNdjsonCdpRequester(socket, {
145930
+ label: `macos-app ${bundleId}`,
145931
+ send: (frame2) => {
145932
+ const p = frame2.payload;
145933
+ if (p.method === "Network.enable") {
145934
+ this.disableIds.clear();
145935
+ this.enableIds.add(p.id);
145936
+ }
145937
+ if (p.method === "Network.disable") {
145938
+ this.enableIds.clear();
145939
+ this.disableIds.add(p.id);
145940
+ }
145941
+ return writeNdjsonFrame(socket, frame2);
145942
+ }
145943
+ });
145869
145944
  this.ready.catch(() => void 0);
145870
145945
  attachNdjsonReader(socket, {
145871
145946
  onDropped: reportDroppedFrameToStderr(`macos-app ${bundleId}`),
@@ -145879,7 +145954,31 @@ var LibraryChannel = class {
145879
145954
  socket;
145880
145955
  bundleId;
145881
145956
  expectedPid;
145882
- onNetworkEvent;
145957
+ network;
145958
+ /** The CDP requests of the network capture, such as Network.enable. */
145959
+ cdp;
145960
+ /** The library acknowledged Network.enable on this channel. */
145961
+ armed = false;
145962
+ /** The Network.enable on its way, resolved by the acknowledgement. */
145963
+ enabling;
145964
+ /** Resolves `enabling` as armed when the acknowledgement of an earlier Network.enable arms the channel first. */
145965
+ armEnabling;
145966
+ /** Why the last Network.enable did not arm this channel. */
145967
+ enableFailure;
145968
+ /** A stop's Network.disable timed out, and no acknowledgement of a Network.disable came since. */
145969
+ stopUnconfirmed = false;
145970
+ /** Confirms the waiting stop when the acknowledgement of an earlier Network.disable comes first. */
145971
+ confirmDisabling;
145972
+ /**
145973
+ * The CDP ids of the Network.enable requests sent on this channel since its
145974
+ * last Network.disable: an acknowledgement of any of them arms it.
145975
+ */
145976
+ enableIds = /* @__PURE__ */ new Set();
145977
+ /**
145978
+ * The CDP ids of the Network.disable requests sent on this channel since its
145979
+ * last Network.enable: an acknowledgement of any of them confirms a stop.
145980
+ */
145981
+ disableIds = /* @__PURE__ */ new Set();
145883
145982
  pending = /* @__PURE__ */ new Map();
145884
145983
  nextId = 1;
145885
145984
  hello = null;
@@ -145938,11 +146037,6 @@ var LibraryChannel = class {
145938
146037
  );
145939
146038
  });
145940
146039
  }
145941
- /** A `Control` command, which the library does not answer. */
145942
- sendControl(command) {
145943
- if (this.closeError) return;
145944
- this.socket.write(JSON.stringify({ type: "Control", payload: { command } }) + "\n");
145945
- }
145946
146040
  close() {
145947
146041
  this.closedByArgent = true;
145948
146042
  this.socket.destroy();
@@ -145963,11 +146057,16 @@ var LibraryChannel = class {
145963
146057
  }
145964
146058
  if (msg.type === "CDP") {
145965
146059
  const p = msg.payload;
146060
+ if (p && typeof p.id === "number" && this.enableIds.has(p.id) && "result" in p) {
146061
+ this.network.enabled(this);
146062
+ }
146063
+ if (p && typeof p.id === "number" && this.disableIds.has(p.id) && "result" in p) {
146064
+ this.stopUnconfirmed = false;
146065
+ this.confirmDisabling?.();
146066
+ }
146067
+ if (this.cdp.handleResponse(p)) return;
145966
146068
  if (p && typeof p.method === "string" && p.id === void 0) {
145967
- this.onNetworkEvent(
145968
- { method: p.method, params: p.params, timestamp: Date.now() },
145969
- this.hello.pid
145970
- );
146069
+ this.network.event(p.method, p.params, this.hello.pid);
145971
146070
  }
145972
146071
  return;
145973
146072
  }
@@ -146002,10 +146101,13 @@ var LibraryChannel = class {
146002
146101
  "unknown"
146003
146102
  )
146004
146103
  );
146104
+ this.network.closed(this);
146005
146105
  }
146006
146106
  fail(err) {
146007
146107
  if (this.closeError) return;
146008
146108
  this.closeError = err;
146109
+ this.armed = false;
146110
+ this.cdp.close();
146009
146111
  this.settleHello.reject(err);
146010
146112
  for (const call of this.pending.values()) {
146011
146113
  clearTimeout(call.timer);
@@ -146087,6 +146189,28 @@ async function helperPid(child, executable) {
146087
146189
  }
146088
146190
  var lifecycles = /* @__PURE__ */ new Map();
146089
146191
  var heldQuits = /* @__PURE__ */ new Map();
146192
+ function connectionClosedBefore(bundleId, method) {
146193
+ return new FailureError(
146194
+ `macos-app ${bundleId}: the connection closed before ${method} was answered`,
146195
+ {
146196
+ error_code: FAILURE_CODES.NDJSON_CDP_CONNECTION_CLOSED,
146197
+ failure_stage: "ndjson_cdp_request",
146198
+ failure_area: "tool_server",
146199
+ error_kind: "network"
146200
+ }
146201
+ );
146202
+ }
146203
+ var macosCaptures = /* @__PURE__ */ new Set();
146204
+ function findMacosNativeRecord(id) {
146205
+ for (const { records } of macosCaptures) {
146206
+ const record2 = records.record(id);
146207
+ if (record2) return { records, record: record2 };
146208
+ }
146209
+ return void 0;
146210
+ }
146211
+ function hasMacosNetworkCapture() {
146212
+ return [...macosCaptures].some(({ captured }) => captured());
146213
+ }
146090
146214
  async function waitWhileSuspended(watch, method) {
146091
146215
  const since = watch.suspendedSince();
146092
146216
  if (since === null) return;
@@ -146103,26 +146227,109 @@ function createMacosAppApi(bundleId) {
146103
146227
  let connecting = null;
146104
146228
  let launching = false;
146105
146229
  let disposed = false;
146106
- let networkInspection = false;
146107
- let networkLog = [];
146108
- let networkLogPid = null;
146109
- const networkLogOf = (pid) => {
146110
- if (pid !== networkLogPid) {
146111
- networkLog = [];
146112
- networkLogPid = pid;
146113
- }
146114
- return networkLog;
146115
- };
146116
- const recordNetworkEvent = (event2, pid) => {
146117
- const log = networkLogOf(pid);
146118
- if (log.length >= NATIVE_NETWORK_LOG_LIMIT) log.shift();
146119
- log.push(event2);
146120
- };
146121
- const adopt = (ch) => {
146230
+ let captureStarted = false;
146231
+ let captureStopped = false;
146232
+ let captureGap = false;
146233
+ let armedSinceLaunch = false;
146234
+ let recordedProcess = null;
146235
+ let nextProcessIndex = 1;
146236
+ const liveChannel = () => channel?.isOpen && channel.handshake ? channel : null;
146237
+ const captureState = () => {
146238
+ const ch = liveChannel();
146239
+ if (!ch) {
146240
+ return {
146241
+ armed: false,
146242
+ note: captureStarted ? "the app is not connected; capture arms when argent starts the app or connects to it, as network-capture-start does" : "the app is not connected"
146243
+ };
146244
+ }
146245
+ return {
146246
+ armed: ch.armed,
146247
+ pid: ch.handshake.pid,
146248
+ ...ch.armed ? {} : ch.enabling ? { note: "waiting for the app to acknowledge Network.enable" } : ch.enableFailure ? { note: ch.enableFailure } : {}
146249
+ };
146250
+ };
146251
+ const records = createIosNetworkRecords(
146252
+ captureState,
146253
+ {
146254
+ liveConnection: () => {
146255
+ const ch = liveChannel();
146256
+ return ch && recordedProcess?.pid === ch.handshake.pid ? recordedProcess.index : void 0;
146257
+ },
146258
+ request: (index, method, params, timeoutMs) => {
146259
+ const ch = liveChannel();
146260
+ return ch && recordedProcess?.index === index && recordedProcess.pid === ch.handshake.pid ? ch.cdp.request(method, params, { timeoutMs }) : Promise.reject(connectionClosedBefore(bundleId, method));
146261
+ }
146262
+ },
146263
+ () => captureStarted,
146264
+ "macos-native"
146265
+ );
146266
+ const capture = { records, captured: () => captureStarted || captureStopped };
146267
+ macosCaptures.add(capture);
146268
+ const network = {
146269
+ event(method, params, pid) {
146270
+ if (recordedProcess?.pid === pid) records.fold(recordedProcess.index, method, params);
146271
+ },
146272
+ closed(ch) {
146273
+ const process2 = recordedProcess;
146274
+ if (!ch.handshake || process2?.pid !== ch.handshake.pid) return;
146275
+ void pollPidsUntilGone([process2.pid], {
146276
+ timeoutMs: PROCESS_EXIT_WAIT_MS,
146277
+ pollIntervalMs: POLL_MS
146278
+ }).then((left) => {
146279
+ if (disposed) return;
146280
+ if (left.length === 0) {
146281
+ records.connectionClosed(process2.index, { superseded: false, running: false });
146282
+ } else if (recordedProcess?.channel === ch) {
146283
+ records.connectionClosed(process2.index, { superseded: false, running: true });
146284
+ }
146285
+ });
146286
+ },
146287
+ enabled(ch) {
146288
+ if (!captureStarted) return;
146289
+ ch.armed = true;
146290
+ delete ch.enableFailure;
146291
+ ch.armEnabling?.();
146292
+ }
146293
+ };
146294
+ const enableOn = (ch) => {
146295
+ if (ch.armed) return Promise.resolve(true);
146296
+ if (ch.enabling) return ch.enabling;
146297
+ delete ch.enableFailure;
146298
+ const enabling = new Promise((resolve21) => {
146299
+ ch.armEnabling = () => resolve21(true);
146300
+ ch.cdp.request("Network.enable", {}, { timeoutMs: NETWORK_CAPTURE_ACK_TIMEOUT_MS }).then(
146301
+ () => resolve21(ch.armed),
146302
+ (err) => {
146303
+ if (ch.isOpen && !disposed && !ch.armed) {
146304
+ ch.enableFailure = getFailureSignal(err)?.error_kind === "timeout" ? `the app did not acknowledge Network.enable within ${NETWORK_CAPTURE_ACK_TIMEOUT_MS / 1e3} s; network-capture-start asks again` : `the app did not enable capture (${errorMessage2(err)}); network-capture-start asks again`;
146305
+ }
146306
+ resolve21(false);
146307
+ }
146308
+ );
146309
+ }).finally(() => {
146310
+ if (ch.enabling !== enabling) return;
146311
+ ch.enabling = void 0;
146312
+ ch.armEnabling = void 0;
146313
+ });
146314
+ ch.enabling = enabling;
146315
+ return enabling;
146316
+ };
146317
+ const adopt = (ch, launched = false) => {
146122
146318
  if (channel !== ch) channel?.close();
146123
146319
  channel = ch;
146124
- networkLogOf(ch.handshake.pid);
146125
- if (networkInspection) ch.sendControl("activateNetworkInspection");
146320
+ const pid = ch.handshake.pid;
146321
+ if (recordedProcess?.pid !== pid) {
146322
+ if (recordedProcess) {
146323
+ records.connectionClosed(recordedProcess.index, { superseded: true });
146324
+ }
146325
+ recordedProcess = { pid, index: nextProcessIndex++, channel: ch };
146326
+ captureGap = captureStarted && !launched;
146327
+ armedSinceLaunch = launched && captureStarted;
146328
+ } else if (recordedProcess.channel !== ch) {
146329
+ records.connectionClosed(recordedProcess.index, { superseded: false, running: true });
146330
+ recordedProcess.channel = ch;
146331
+ }
146332
+ if (captureStarted) void enableOn(ch);
146126
146333
  };
146127
146334
  const closeChannel = () => {
146128
146335
  channel?.close();
@@ -146130,7 +146337,7 @@ function createMacosAppApi(bundleId) {
146130
146337
  };
146131
146338
  const reconnect = async () => {
146132
146339
  const app = await runningTrackedApp(bundleId);
146133
- if (!app) throw notRunningError(bundleId);
146340
+ if (!app) throw await noLaunchedCopyError(bundleId);
146134
146341
  const notConnected3 = (detail, cause) => macosFailure(
146135
146342
  `${bundleId} is running (pid ${app.pid}) but argent cannot reach its library: ${detail} If it is paused in a debugger, continue it and try again. Otherwise run restart-app to start it again with the library.`,
146136
146343
  FAILURE_CODES.MACOS_APP_NOT_CONNECTED,
@@ -146150,7 +146357,7 @@ function createMacosAppApi(bundleId) {
146150
146357
  net8.createConnection(app.listenSocket),
146151
146358
  bundleId,
146152
146359
  app.pid,
146153
- recordNetworkEvent
146360
+ network
146154
146361
  );
146155
146362
  try {
146156
146363
  await ch.waitForHandshake(RECONNECT_TIMEOUT_MS);
@@ -146439,12 +146646,7 @@ function createMacosAppApi(bundleId) {
146439
146646
  } catch (err) {
146440
146647
  throw helperLaunchFailure(info.executable, errorMessage2(err), err);
146441
146648
  }
146442
- const ch = new LibraryChannel(
146443
- helper.stdio[3],
146444
- bundleId,
146445
- null,
146446
- recordNetworkEvent
146447
- );
146649
+ const ch = new LibraryChannel(helper.stdio[3], bundleId, null, network);
146448
146650
  let pid;
146449
146651
  try {
146450
146652
  pid = await helperPid(helper, info.executable);
@@ -146513,7 +146715,7 @@ function createMacosAppApi(bundleId) {
146513
146715
  sandboxed: info.sandboxed,
146514
146716
  logPath
146515
146717
  };
146516
- adopt(ch);
146718
+ adopt(ch, true);
146517
146719
  const { note: noWindow, refusal: noDrivableWindow } = await waitForFirstWindow(
146518
146720
  ch,
146519
146721
  pid,
@@ -146589,20 +146791,91 @@ function createMacosAppApi(bundleId) {
146589
146791
  },
146590
146792
  isConnected: () => Boolean(channel?.isOpen && channel.handshake),
146591
146793
  handshake: () => channel?.isOpen ? channel.handshake : null,
146592
- async activateNetworkInspection() {
146593
- networkInspection = true;
146794
+ async startNetworkCapture() {
146795
+ captureStopped = false;
146796
+ const startedNow = !captureStarted;
146797
+ captureStarted = true;
146798
+ if (channel) channel.stopUnconfirmed = false;
146799
+ const servicesStopped = {
146800
+ armed: false,
146801
+ reason: "the app's services stopped during this start, which ended the capture; call network-capture-start again"
146802
+ };
146594
146803
  await lifecycles.get(bundleId)?.settled;
146595
- (await ensureChannel()).sendControl("activateNetworkInspection");
146804
+ if (disposed) return servicesStopped;
146805
+ let ch;
146806
+ try {
146807
+ ch = await ensureChannel();
146808
+ } catch (err) {
146809
+ if (disposed) return servicesStopped;
146810
+ const code = errorCode(err);
146811
+ const notRunning = code === FAILURE_CODES.MACOS_APP_NOT_RUNNING;
146812
+ const buildUnknown = notRunning && getFailureSignal(err)?.failure_stage === BUILD_UNKNOWN_STAGE;
146813
+ const notOurs = code === FAILURE_CODES.MACOS_APP_ALREADY_RUNNING;
146814
+ if (!notRunning && !notOurs && startedNow && !armedSinceLaunch) captureGap = true;
146815
+ return {
146816
+ armed: false,
146817
+ reason: buildUnknown ? `no copy of ${bundleId} that argent started is running, and argent cannot find the app's build to look for another copy; capture arms when boot-device with macosAppPath starts it` : notRunning ? `${bundleId} is not running; capture arms when boot-device, launch-app or restart-app starts it` : notOurs ? `capture arms when argent starts ${bundleId}, which needs the copy that runs now to quit first: ${errorMessage2(err)}` : `argent cannot reach ${bundleId}, so capture arms when argent connects to it: ${errorMessage2(err)}`
146818
+ };
146819
+ }
146820
+ if (startedNow && !armedSinceLaunch) captureGap = true;
146821
+ const armed = await enableOn(ch);
146822
+ if (disposed) return servicesStopped;
146823
+ if (armed) return { armed };
146824
+ return { armed, reason: captureState().note ?? "the app did not acknowledge Network.enable" };
146596
146825
  },
146597
- networkLog: () => [...networkLog],
146598
- clearNetworkLog: () => {
146599
- networkLog.length = 0;
146600
- }
146826
+ async stopNetworkCapture() {
146827
+ captureStopped = true;
146828
+ captureStarted = false;
146829
+ captureGap = false;
146830
+ armedSinceLaunch = false;
146831
+ const ch = liveChannel();
146832
+ if (!ch) return { confirmed: true };
146833
+ ch.armed = false;
146834
+ ch.enabling = void 0;
146835
+ ch.armEnabling = void 0;
146836
+ delete ch.enableFailure;
146837
+ let confirm;
146838
+ const disabling = new Promise((resolve21, reject) => {
146839
+ confirm = resolve21;
146840
+ ch.cdp.request("Network.disable", {}, { timeoutMs: NETWORK_CAPTURE_ACK_TIMEOUT_MS }).then(() => resolve21(), reject);
146841
+ });
146842
+ ch.confirmDisabling = confirm;
146843
+ try {
146844
+ await disabling;
146845
+ return { confirmed: true };
146846
+ } catch (err) {
146847
+ if (disposed) {
146848
+ return {
146849
+ confirmed: true,
146850
+ reason: "the app's services stopped during this stop, which dropped the requests it recorded"
146851
+ };
146852
+ }
146853
+ if (!ch.isOpen) return { confirmed: true };
146854
+ if (captureStopped) ch.stopUnconfirmed = true;
146855
+ return {
146856
+ confirmed: false,
146857
+ reason: `${getFailureSignal(err)?.error_kind === "timeout" ? `the app did not acknowledge Network.disable within ${NETWORK_CAPTURE_ACK_TIMEOUT_MS / 1e3} s` : `the app did not disable capture (${errorMessage2(err)})`}; argent records none of its new requests, and its next process starts without capture`
146858
+ };
146859
+ } finally {
146860
+ if (ch.confirmDisabling === confirm) ch.confirmDisabling = void 0;
146861
+ }
146862
+ },
146863
+ isNetworkCaptureStarted: () => captureStarted,
146864
+ isNetworkCaptureStopped: () => captureStopped,
146865
+ isNetworkCaptureStopUnconfirmed: () => liveChannel()?.stopUnconfirmed === true,
146866
+ takeCaptureGap: () => {
146867
+ const gap = captureGap;
146868
+ captureGap = false;
146869
+ return gap;
146870
+ },
146871
+ networkRecords: () => records
146601
146872
  };
146602
146873
  return {
146603
146874
  api,
146604
146875
  dispose: () => {
146605
146876
  disposed = true;
146877
+ macosCaptures.delete(capture);
146878
+ records.clear();
146606
146879
  if (!launching) closeChannel();
146607
146880
  }
146608
146881
  };
@@ -151833,8 +152106,12 @@ var BUNDLE_ID_MESSAGE = "bundleId may only contain letters, digits, '.', '_' and
151833
152106
  // ../tool-server/src/tools/network/network-capture.ts
151834
152107
  init_device_info();
151835
152108
  var captureSchema = external_exports.object({
151836
- udid: external_exports.string().describe("Device ID from list-devices: an iOS simulator UDID or Android serial"),
151837
- bundleId: external_exports.string().regex(BUNDLE_ID_PATTERN, BUNDLE_ID_MESSAGE).describe("App bundle ID on iOS or package name on Android"),
152109
+ udid: external_exports.string().describe(
152110
+ "Device ID from list-devices: an iOS simulator UDID or Android serial<flag:macos-apps>, or a Mac app id (macos-app-<bundle id>)</flag:macos-apps>"
152111
+ ),
152112
+ bundleId: external_exports.string().regex(BUNDLE_ID_PATTERN, BUNDLE_ID_MESSAGE).describe(
152113
+ "App bundle ID on iOS or package name on Android<flag:macos-apps> (on a Mac app, the bundle id in the device id)</flag:macos-apps>"
152114
+ ),
151838
152115
  port: metroPortField.describe(
151839
152116
  "The app's Metro port: the JS layer is reached through it, and the native layers leave its requests out. Omit it to use this device's port, 8081 by default."
151840
152117
  ),
@@ -151845,7 +152122,8 @@ var captureSchema = external_exports.object({
151845
152122
  var CAPTURE_CAPABILITY = {
151846
152123
  apple: { simulator: true },
151847
152124
  appleRemote: { simulator: true },
151848
- android: { emulator: true, device: true }
152125
+ android: { emulator: true, device: true },
152126
+ macos: { app: true, catalyst: true }
151849
152127
  };
151850
152128
  var captureLocks = /* @__PURE__ */ new Map();
151851
152129
  var captureSweeps = /* @__PURE__ */ new Set();
@@ -152099,13 +152377,13 @@ var zodSchema4 = external_exports.object({
152099
152377
  "App bundle ID on iOS or package name on Android<flag:macos-apps> (on a Mac app, the bundle id in the device id)</flag:macos-apps>"
152100
152378
  ),
152101
152379
  port: metroPortField.describe(
152102
- "The app's Metro port, whose requests are left out of the listing. Omit it to use this device's port, 8081 by default.<flag:macos-apps> A Mac app ignores it.</flag:macos-apps>"
152380
+ "The app's Metro port, whose requests are left out of the listing. Omit it to use this device's port, 8081 by default."
152103
152381
  ),
152104
152382
  limit: external_exports.number().int().nonnegative().optional().default(50).describe(
152105
- "Maximum number of requests to return: the most recent ones, oldest first. 0 returns only the header and the total.<flag:macos-apps> On a Mac app it counts events, not requests: one request gives several events. 0 returns no events.</flag:macos-apps>"
152383
+ "Maximum number of requests to return: the most recent ones, oldest first. 0 returns only the header and the total."
152106
152384
  ),
152107
152385
  clear: external_exports.boolean().optional().default(false).describe(
152108
- "Clear the log after reading. On iOS and Android, the IDs of cleared requests still work in view-network-request-details"
152386
+ "Clear the log after reading. The IDs of cleared requests still work in view-network-request-details"
152109
152387
  ),
152110
152388
  // Declared so this non-strict object refuses the old stop instead of stripping it: the read
152111
152389
  // would succeed while capture records on.
@@ -152129,13 +152407,13 @@ function createNativeNetworkLogsTool(registry2) {
152129
152407
  android: { emulator: true, device: true },
152130
152408
  macos: { app: true, catalyst: true }
152131
152409
  },
152132
- description: `Retrieve network requests captured at the native level: NSURLProtocol on iOS, OkHttp on Android.
152410
+ description: `Retrieve network requests captured at the native level: NSURLProtocol on iOS<flag:macos-apps> and Mac apps</flag:macos-apps>, OkHttp on Android.
152133
152411
  Use when inspecting native-level HTTP traffic that view-network-logs cannot see: requests that never pass through JS XMLHttpRequest or fetch.
152134
- On iOS it sees URLSession requests (default and ephemeral session configurations, and URLSession.shared) from native modules and Swift/Objective-C code. It does not see background URLSession transfers, WKWebView, Network.framework, or HTTP stacks that bypass URLSession (e.g. Flutter), so an empty result does not mean the app sent nothing.
152135
- Returns { status, header, armed, count, total, requests }: one line per request, oldest first, with its id (ios-3f9a-12, android-3f9a-12), method, URL, state (pending, headers, complete or failed), status, mimeType, durationMs and errorText. The header says whether capture is armed, how many requests there are and the app's pid once read, and why capture is not armed when it is not. Requests to Metro on \`port\` are left out. Pass a request's id to view-network-request-details for its headers and bodies, and on Android its redirects. The history is kept across relaunches of the app, except on a device whose devtools agent argent attached to.
152136
- On iOS and Android this tool only reads and never starts capture: call network-capture-start for the app first, then repeat the action whose requests you need. Before a start it returns started: false and a header that says capture is not started; after a start that found the native layer unavailable, started: false and a header that gives the reason of that start; after network-capture-stop it returns stopped: true and still lists what was captured.
152412
+ On iOS<flag:macos-apps> and Mac apps</flag:macos-apps> it sees URLSession requests (default and ephemeral session configurations, and URLSession.shared) from native modules and Swift/Objective-C code<flag:macos-apps>, and react-native-macos fetch</flag:macos-apps>. It does not see background URLSession transfers, WKWebView, Network.framework, or HTTP stacks that bypass URLSession (e.g. Flutter), so an empty result does not mean the app sent nothing.
152413
+ Returns { status, header, armed, count, total, requests }: one line per request, oldest first, with its id (ios-3f9a-12, android-3f9a-12<flag:macos-apps>, macos-3f9a-12</flag:macos-apps>), method, URL, state (pending, headers, complete or failed), status, mimeType, durationMs and errorText. The header says whether capture is armed, how many requests there are and the app's pid once read, and why capture is not armed when it is not. Requests to Metro on \`port\` are left out. Pass a request's id to view-network-request-details for its headers and bodies, and on Android its redirects. The history is kept across relaunches of the app, except on a device whose devtools agent argent attached to.
152414
+ This tool only reads and never starts capture: call network-capture-start for the app first, then repeat the action whose requests you need. Before a start it returns started: false and a header that says capture is not started; on iOS and Android, after a start that found the native layer unavailable, started: false and a header that gives the reason of that start; after network-capture-stop it returns stopped: true and still lists what was captured.
152137
152415
  On iOS: when capture started while the app was already running, the header of the first answer says that the app's launch was not recorded; to capture the launch, call restart-app, then network-capture-start (a relaunch ends JS capture), then this tool, unless the header says the launch cannot be recorded on that device. On a local simulator, launch-app and restart-app return networkCapture saying whether capture is armed in the new process.
152138
- <flag:macos-apps>On a Mac app it returns { status, count, events } instead: NSURLSession events, react-native-macos fetch included, each with URL, method, status, headers and timing, and no ids. There the first call starts capture, with no network-capture-start. Capture stays on across restart-app, with a new log per process, and requests sent while the app starts can be missing.
152416
+ <flag:macos-apps>On a Mac app: when capture started while the app was already running, the header of the first answer says that its requests before the start were not recorded. Capture stays on across restart-app, and requests sent while the app starts can be missing.
152139
152417
  </flag:macos-apps>On iOS: If status is restart_required: follow the message (usually restart-app), then retry. If status is service_stale: the app is already injected, so restarting it cannot help. Restart the tool-server (\`argent server stop && argent server start --detach\`) and retry. If the same status comes back after that restart, stop restarting: follow the message, which names the terminal fallback. If status is connect_pending: the app is injected and still connecting. Do not restart it, wait a few seconds and retry. If status is init_failed: follow the message (re-boot the simulator) rather than retrying.
152140
152418
  On a device whose devtools agent argent attached to rather than armed itself, a not-connected app fails with \`NATIVE_DEVTOOLS_NOT_CONNECTED\` instead of a status, and no restart on argent's side fixes it. An Apple system app is rejected outright (terminal: never retry it).
152141
152419
  On Android: needs a debuggable build. A header that says not attached means this tool-server did not attach capture to the app's current process: network-capture-start attaches it.
@@ -152156,6 +152434,7 @@ Android results also carry capture and captureDetail. When capture is active, ca
152156
152434
  },
152157
152435
  async execute(services, params) {
152158
152436
  const device = resolveDevice(params.udid);
152437
+ const port = metroPort({ device_id: params.udid, port: params.port });
152159
152438
  if (device.platform === "macos") {
152160
152439
  const app = requireMacosAppOfBundle(
152161
152440
  services,
@@ -152163,12 +152442,9 @@ Android results also carry capture and captureDetail. When capture is active, ca
152163
152442
  "native-network-logs",
152164
152443
  params.bundleId
152165
152444
  );
152166
- await app.activateNetworkInspection();
152167
- const events = params.limit === 0 ? [] : app.networkLog().slice(-params.limit);
152168
- if (params.clear) app.clearNetworkLog();
152169
- return { status: "ok", count: events.length, events };
152445
+ if (!isInjectableBundleId(params.bundleId)) throw macosNotInjectable(params.bundleId);
152446
+ return listMacosNative(app, params, port);
152170
152447
  }
152171
- const port = metroPort({ device_id: params.udid, port: params.port });
152172
152448
  if (device.platform === "android") {
152173
152449
  const api2 = services.androidNetwork;
152174
152450
  if (!api2 || !api2.isStarted() && !api2.isStopped()) {
@@ -152185,17 +152461,13 @@ Android results also carry capture and captureDetail. When capture is active, ca
152185
152461
  const api = services.nativeDevtools;
152186
152462
  const unavailable3 = nativeUnavailableReason(device.id, params.bundleId);
152187
152463
  if (api?.isNetworkCaptureStopped(params.bundleId)) {
152188
- const store2 = api.networkRecords(params.bundleId);
152189
- const listing2 = listNative("ios-native", store2?.records(port) ?? [], params.limit, {
152190
- armed: false,
152191
- state: "stopped",
152192
- detail: stoppedDetail(
152193
- liveIosNetworkCaptures(params.udid).includes(params.bundleId),
152194
- unavailable3
152195
- )
152196
- });
152197
- if (params.clear) store2?.clear();
152198
- return { ...listing2, stopped: true };
152464
+ return listStopped(
152465
+ "ios-native",
152466
+ api.networkRecords(params.bundleId),
152467
+ params,
152468
+ port,
152469
+ stoppedDetail(liveIosNetworkCaptures(params.udid).includes(params.bundleId), unavailable3)
152470
+ );
152199
152471
  }
152200
152472
  if (!api?.isNetworkCaptureStarted(params.bundleId)) {
152201
152473
  return unavailable3 ? unavailableListing("ios-native", unavailable3) : notStarted("ios-native", params.bundleId);
@@ -152224,6 +152496,55 @@ Android results also carry capture and captureDetail. When capture is active, ca
152224
152496
  };
152225
152497
  }
152226
152498
  var STOPPED_DETAIL = "capture stopped by network-capture-stop; network-capture-start turns it on again";
152499
+ function listStopped(layer, store, params, port, detail = [STOPPED_DETAIL]) {
152500
+ const listing = listNative(layer, store?.records(port) ?? [], params.limit, {
152501
+ armed: false,
152502
+ state: "stopped",
152503
+ detail
152504
+ });
152505
+ if (params.clear) store?.clear();
152506
+ return { ...listing, stopped: true };
152507
+ }
152508
+ function listMacosNative(app, params, port) {
152509
+ const store = app.networkRecords();
152510
+ if (app.isNetworkCaptureStopped()) {
152511
+ return listStopped(
152512
+ "macos-native",
152513
+ store,
152514
+ params,
152515
+ port,
152516
+ stoppedDetail(app.isNetworkCaptureStopUnconfirmed())
152517
+ );
152518
+ }
152519
+ if (!app.isNetworkCaptureStarted()) return notStarted("macos-native", params.bundleId);
152520
+ const state3 = store.state();
152521
+ const detail = [];
152522
+ if (state3.pid !== void 0) detail.push(`pid ${state3.pid}`);
152523
+ if (state3.note) detail.push(state3.note);
152524
+ if (app.takeCaptureGap()) {
152525
+ detail.push(
152526
+ "capture started while the app was already running, so the requests before that were not recorded"
152527
+ );
152528
+ }
152529
+ const listing = listNative("macos-native", store.records(port), params.limit, {
152530
+ armed: state3.armed,
152531
+ state: state3.armed ? "armed" : "not armed",
152532
+ detail
152533
+ });
152534
+ if (params.clear) store.clear();
152535
+ return listing;
152536
+ }
152537
+ function macosNotInjectable(bundleId) {
152538
+ return new FailureError(
152539
+ `${bundleId} is an Apple app; argent captures only apps it can load its library into, such as your own builds. Treat its native network log as unavailable rather than retrying.`,
152540
+ {
152541
+ error_code: FAILURE_CODES.NATIVE_DEVTOOLS_NOT_INJECTABLE,
152542
+ error_kind: "validation",
152543
+ failure_area: "tool_server",
152544
+ failure_stage: "native_network_logs_macos_bundle_id"
152545
+ }
152546
+ );
152547
+ }
152227
152548
  function stoppedDetail(mayIntercept, unavailableReason) {
152228
152549
  const stopped = unavailableReason ? `capture stopped by network-capture-stop; a later network-capture-start found the layer unavailable: ${unavailableReason}` : STOPPED_DETAIL;
152229
152550
  return mayIntercept ? [
@@ -166092,12 +166413,18 @@ function redactHeaders(headers) {
166092
166413
  }
166093
166414
  return result;
166094
166415
  }
166095
- var NATIVE_ID_PREFIXES = { android: "android-", ios: "ios-" };
166416
+ var NATIVE_ID_PREFIXES = { android: "android-", ios: "ios-", macos: "macos-" };
166096
166417
  function nativeIdPlatform2(requestId) {
166097
166418
  if (requestId.startsWith(NATIVE_ID_PREFIXES.android)) return "android";
166098
166419
  if (requestId.startsWith(NATIVE_ID_PREFIXES.ios)) return "ios";
166420
+ if (requestId.startsWith(NATIVE_ID_PREFIXES.macos)) return "macos";
166099
166421
  return void 0;
166100
166422
  }
166423
+ var NATIVE_LAYERS = {
166424
+ android: { source: "an Android device", name: "Android" },
166425
+ ios: { source: "an iOS simulator", name: "iOS" },
166426
+ macos: { source: "a Mac app", name: "Mac app" }
166427
+ };
166101
166428
  var MAX_BODY_SIZE = 1e3;
166102
166429
  var MAX_DECODED_BODY_BYTES = 16 * 1024 * 1024;
166103
166430
  function cutMarker(fullSize, mimeType, shown = MAX_BODY_SIZE) {
@@ -166124,19 +166451,19 @@ ${postData.slice(0, MAX_BODY_SIZE)}...`;
166124
166451
  var zodSchema39 = external_exports.object({
166125
166452
  port: metroPortField,
166126
166453
  device_id: external_exports.string().describe(
166127
- "Device id from list-devices (iOS simulator UDID or Android serial), the same id used with debugger-connect. An ios- or android- ID needs no debugger connection."
166454
+ "Device id from list-devices (iOS simulator UDID or Android serial, the same id used with debugger-connect<flag:macos-apps>, or a Mac app id</flag:macos-apps>). A native ID needs no debugger connection."
166128
166455
  ),
166129
166456
  requestId: external_exports.string().describe(
166130
- "The requestId from view-network-logs, or an ios- or android- ID from native-network-logs."
166457
+ "The requestId from view-network-logs, or a native ID (ios-, android-<flag:macos-apps> or macos-</flag:macos-apps>) from native-network-logs."
166131
166458
  ),
166132
166459
  includeBody: external_exports.boolean().default(true).describe("Whether to include the response body (if captured).")
166133
166460
  });
166134
166461
  var networkRequestTool = {
166135
166462
  id: "view-network-request-details",
166136
- description: `Get full details of a specific network request by its requestId: one from view-network-logs, or an ios- or android- ID from native-network-logs, which needs no debugger connection.
166463
+ description: `Get full details of a specific network request by its requestId: one from view-network-logs, or a native ID (ios-, android-<flag:macos-apps> or macos-</flag:macos-apps>) from native-network-logs, which needs no debugger connection.
166137
166464
  Returns request/response headers (sensitive headers redacted), status, timing, the request body, and optionally the response body.
166138
- Request and response bodies over 1000 chars are cut to 1000 under a "[TRUNCATED: ...]" line that gives the full size; a binary response body is omitted, as is a binary request body of an ios- or android- ID. For an ios- or android- ID, a body that cannot be read shows "[unavailable: <reason>]"; when the reason says the app may still be sending the request body, call again once the request has ended. Use when you need headers, body, or timing for a specific request after listing logs.
166139
- Returns an error message string if the requestId is not found; on iOS and Android it also says when network capture is not started, which network-capture-start does. IDs keep working after network-capture-stop. A view-network-logs ID holds until the app's JS runtime reloads: the new runtime numbers its requests from rn-net-1 again, so an old ID can name a new request. ios- and android- IDs are not affected.`,
166465
+ Request and response bodies over 1000 chars are cut to 1000 under a "[TRUNCATED: ...]" line that gives the full size; a binary response body is omitted, as is a binary request body of a native ID. For a native ID, a body that cannot be read shows "[unavailable: <reason>]"; when the reason says the app may still be sending the request body, call again once the request has ended. Use when you need headers, body, or timing for a specific request after listing logs.
166466
+ Returns an error message string if the requestId is not found; on iOS<flag:macos-apps>, a Mac app</flag:macos-apps> and Android it also says when network capture is not started, which network-capture-start does. IDs keep working after network-capture-stop. A view-network-logs ID holds until the app's JS runtime reloads: the new runtime numbers its requests from rn-net-1 again, so an old ID can name a new request. Native IDs are not affected.`,
166140
166467
  zodSchema: zodSchema39,
166141
166468
  readOnly: true,
166142
166469
  interaction: {
@@ -166144,10 +166471,12 @@ Returns an error message string if the requestId is not found; on iOS and Androi
166144
166471
  completedMsg: ({ params }) => `Read network request ${params.requestId}`,
166145
166472
  failedMsg: ({ params, failureSignal: failureSignal2 }) => `Failed to read network request ${params.requestId}: ${failureSignal2.error_code}`
166146
166473
  },
166147
- capability: DEBUGGER_TOOL_CAPABILITY,
166474
+ // A Mac app has only native IDs, which need no debugger.
166475
+ capability: { ...DEBUGGER_TOOL_CAPABILITY, macos: { app: true, catalyst: true } },
166148
166476
  services: (params) => {
166149
166477
  if (isNativeRequestId(params.requestId)) return {};
166150
166478
  const device = resolveDevice(params.device_id);
166479
+ if (device.platform === "macos") return {};
166151
166480
  if (device.platform === "chromium") {
166152
166481
  return { chromium: chromiumCdpRef(device) };
166153
166482
  }
@@ -166166,7 +166495,18 @@ Returns an error message string if the requestId is not found; on iOS and Androi
166166
166495
  const found = findIosNativeRecord(params.requestId);
166167
166496
  return found ? nativeRequestDetails(found.record, found.records, params.includeBody) : nativeNotFound(params.requestId, params.device_id, "ios");
166168
166497
  }
166498
+ if (MACOS_NATIVE_REQUEST_ID.test(params.requestId)) {
166499
+ const found = findMacosNativeRecord(params.requestId);
166500
+ return found ? nativeRequestDetails(found.record, found.records, params.includeBody) : nativeNotFound(params.requestId, params.device_id, "macos");
166501
+ }
166169
166502
  const device = resolveDevice(params.device_id);
166503
+ if (device.platform === "macos") {
166504
+ return nativeNotFound(
166505
+ params.requestId,
166506
+ params.device_id,
166507
+ nativeIdPlatform2(params.requestId) ?? "macos"
166508
+ );
166509
+ }
166170
166510
  if (device.platform === "chromium") {
166171
166511
  const chromium = services.chromium;
166172
166512
  const rec = chromium.server.network.get(params.requestId);
@@ -166295,16 +166635,17 @@ ${body.slice(0, MAX_BODY_SIZE)}...`;
166295
166635
  }
166296
166636
  };
166297
166637
  function isNativeRequestId(requestId) {
166298
- return ANDROID_NATIVE_REQUEST_ID.test(requestId) || IOS_NATIVE_REQUEST_ID.test(requestId);
166638
+ return ANDROID_NATIVE_REQUEST_ID.test(requestId) || IOS_NATIVE_REQUEST_ID.test(requestId) || MACOS_NATIVE_REQUEST_ID.test(requestId);
166299
166639
  }
166300
166640
  function nativeNotFound(requestId, deviceId, layer) {
166301
166641
  const { platform } = resolveDevice(deviceId);
166302
166642
  const prefix = NATIVE_ID_PREFIXES[layer];
166643
+ const { source, name } = NATIVE_LAYERS[layer];
166303
166644
  if (platform === "chromium" || platform === "vega") {
166304
- return `Request ${requestId} not found. An ${prefix} ID comes from ${layer === "android" ? "an Android device" : "an iOS simulator"}. Use view-network-logs to list this device's requests.`;
166645
+ return `Request ${requestId} not found. ${layer === "macos" ? "A" : "An"} ${prefix} ID comes from ${source}. Use view-network-logs to list this device's requests.`;
166305
166646
  }
166306
- const captured = layer === "android" ? hasAndroidNetworkCapture() : hasIosNetworkCapture();
166307
- return captured ? `Request ${requestId} not found. Use native-network-logs to list the requests the ${layer === "android" ? "Android" : "iOS"} native layer recorded.` : `Request ${requestId} not found. Native network capture is not started, so no requests are recorded. Call network-capture-start with udid and bundleId, repeat the action, then list the requests with native-network-logs.`;
166647
+ const captured = layer === "android" ? hasAndroidNetworkCapture() : layer === "ios" ? hasIosNetworkCapture() : hasMacosNetworkCapture();
166648
+ return captured ? `Request ${requestId} not found. Use native-network-logs to list the requests the ${name} native layer recorded.` : `Request ${requestId} not found. Native network capture is not started, so no requests are recorded. Call network-capture-start with udid and bundleId, repeat the action, then list the requests with native-network-logs.`;
166308
166649
  }
166309
166650
  async function nativeRequestDetails(record2, bodies, includeBody) {
166310
166651
  const { wireHeaders } = record2.request;
@@ -166359,8 +166700,8 @@ async function nativeRequestDetails(record2, bodies, includeBody) {
166359
166700
  resp.body = await readNativeBody(() => bodies.responseBody(record2.id), {
166360
166701
  mimeType: record2.response.mimeType,
166361
166702
  contentType: headerValue(record2.response.headers, "content-type"),
166362
- // An iOS response body is read decoded, so its Content-Encoding is not applied again.
166363
- contentEncoding: record2.layer === "ios-native" ? "" : headerValue(record2.response.headers, "content-encoding"),
166703
+ // An iOS or Mac app response body is read decoded, so its Content-Encoding is not applied again.
166704
+ contentEncoding: record2.layer === "ios-native" || record2.layer === "macos-native" ? "" : headerValue(record2.response.headers, "content-encoding"),
166364
166705
  wholeSize: sizeInBytes(record2.encodedDataLength ?? NaN, "as the app received them")
166365
166706
  });
166366
166707
  }
@@ -166530,8 +166871,8 @@ var JS_ANSWER_WAIT_MS = 5e3;
166530
166871
  function createNetworkCaptureStartTool(registry2) {
166531
166872
  return {
166532
166873
  id: "network-capture-start",
166533
- description: `Start network capture for an app on every layer that sees its requests: the app's JS runtime and the native layer (NSURLProtocol on iOS; OkHttp on Android, which needs a debuggable build).
166534
- Use when you are about to trigger requests you need to inspect, also as a step of an e2e test. Unlike native-network-logs and view-network-logs, which on iOS and Android only read and say capture is not started until this runs, this turns capture on and waits a few seconds for each layer to arm. A second call keeps the requests captured so far.
166874
+ description: `Start network capture for an app on every layer that sees its requests: the app's JS runtime and the native layer (NSURLProtocol on iOS; OkHttp on Android, which needs a debuggable build).<flag:macos-apps> On a Mac app, only its native NSURLProtocol layer.</flag:macos-apps>
166875
+ Use when you are about to trigger requests you need to inspect, also as a step of an e2e test. Unlike the read tools (native-network-logs and view-network-logs on iOS and Android<flag:macos-apps>, native-network-logs on a Mac app</flag:macos-apps>), which only read and say capture is not started until this runs, this turns capture on and waits a few seconds for each layer to arm. A second call keeps the requests captured so far.
166535
166876
  Returns { status, layers }: per layer, armed, and a reason when it is not armed (unavailable: true when nothing arms it without a change you must make). A native layer that is not armed yet arms by itself, for example at the app's next launch (on Android, only a launch by launch-app or restart-app), and native capture follows the app into later processes that launch-app and restart-app start, until network-capture-stop. On a device whose devtools agent argent attached to, a relaunch ends native capture: call this tool again after it. The JS layer arms only at a call of this tool: call it again once the app's JavaScript has loaded, and after a reload or relaunch. Capture can slow the app.
166536
166877
  Fails with NETWORK_CAPTURE_UNAVAILABLE when no layer can capture this app.`,
166537
166878
  zodSchema: captureSchema,
@@ -166546,6 +166887,14 @@ Fails with NETWORK_CAPTURE_UNAVAILABLE when no layer can capture this app.`,
166546
166887
  async execute(_services, params) {
166547
166888
  const device = resolveDevice(params.udid);
166548
166889
  assertSupported("network-capture-start", CAPTURE_CAPABILITY, device);
166890
+ if (device.platform === "macos") {
166891
+ const layer = await withCaptureLock(
166892
+ params.udid,
166893
+ params.bundleId,
166894
+ () => startMacosLayer(registry2, device, params)
166895
+ );
166896
+ return { status: "ok", layers: [layer] };
166897
+ }
166549
166898
  const port = metroPort({ device_id: params.udid, port: params.port });
166550
166899
  const layers = await withCaptureLock(params.udid, params.bundleId, async () => {
166551
166900
  if (device.platform === "ios-remote") await ensureDeps(["sim-remote"]);
@@ -166563,22 +166912,49 @@ Fails with NETWORK_CAPTURE_UNAVAILABLE when no layer can capture this app.`,
166563
166912
  ]);
166564
166913
  });
166565
166914
  if (layers.every((layer) => layer.unavailable)) {
166566
- const message = `Network capture cannot start for ${params.bundleId} on ${params.udid}: ` + layers.map((layer) => `${layer.layer}: ${layer.reason}`).join("; ");
166915
+ const error63 = unavailableError(params, layers);
166567
166916
  const missing = await missingNativeDep(device);
166568
166917
  if (missing && layers.some((layer) => layer.reason === missing.message)) {
166569
- throw new DependencyMissingError(missing.missing, message);
166918
+ throw new DependencyMissingError(missing.missing, error63.message);
166570
166919
  }
166571
- throw new FailureError(message, {
166572
- error_code: FAILURE_CODES.NETWORK_CAPTURE_UNAVAILABLE,
166573
- failure_stage: "network_capture_start",
166574
- failure_area: "tool_server",
166575
- error_kind: "unsupported"
166576
- });
166920
+ throw error63;
166577
166921
  }
166578
166922
  return { status: "ok", layers };
166579
166923
  }
166580
166924
  };
166581
166925
  }
166926
+ async function startMacosLayer(registry2, device, params) {
166927
+ const ref = macosAppRef(device);
166928
+ const app = requireMacosAppOfBundle(
166929
+ { macosApp: await registry2.resolveService(ref.urn, ref.options) },
166930
+ device,
166931
+ "network-capture-start",
166932
+ params.bundleId
166933
+ );
166934
+ if (!isInjectableBundleId(params.bundleId)) {
166935
+ throw unavailableError(params, [
166936
+ unavailable2(
166937
+ "macos-native",
166938
+ `${params.bundleId} is an Apple app; argent captures only apps it can load its library into, such as your own builds`
166939
+ )
166940
+ ]);
166941
+ }
166942
+ const refusal = app.isConnected() ? void 0 : await macosLaunchRefusal(params.bundleId);
166943
+ if (refusal) throw unavailableError(params, [unavailable2("macos-native", refusal)]);
166944
+ const { armed, reason: reason2 } = await app.startNetworkCapture();
166945
+ return { layer: "macos-native", armed, ...reason2 ? { reason: reason2 } : {} };
166946
+ }
166947
+ function unavailableError(params, layers) {
166948
+ return new FailureError(
166949
+ `Network capture cannot start for ${params.bundleId} on ${params.udid}: ` + layers.map((layer) => `${layer.layer}: ${layer.reason}`).join("; "),
166950
+ {
166951
+ error_code: FAILURE_CODES.NETWORK_CAPTURE_UNAVAILABLE,
166952
+ failure_stage: "network_capture_start",
166953
+ failure_area: "tool_server",
166954
+ error_kind: "unsupported"
166955
+ }
166956
+ );
166957
+ }
166582
166958
  function unavailable2(layer, reason2) {
166583
166959
  return { layer, armed: false, reason: reason2, unavailable: true };
166584
166960
  }
@@ -166816,7 +167192,7 @@ function createNetworkCaptureStopTool(registry2) {
166816
167192
  id: "network-capture-stop",
166817
167193
  description: `Stop network capture for an app on every layer and keep what was captured.
166818
167194
  Use when you have the requests you need, before you profile, or to end capture in an e2e test. Unlike stop-all-simulator-servers, the requests stay listed in native-network-logs and view-network-logs, and their ids keep working in view-network-request-details (a view-network-logs id until the app's JS runtime reloads).
166819
- Capture stays off: the read tools, launch-app and restart-app do not turn it on again; network-capture-start does. A request in flight at the stop completes in the list on iOS and in the JS runtime; on Android the list marks it failed, while the app's own request goes on. On Android, a body that view-network-request-details did not read before the stop is no longer available.
167195
+ Capture stays off: the read tools, launch-app and restart-app do not turn it on again; network-capture-start does. A request in flight at the stop completes in the list on iOS<flag:macos-apps> and Mac apps</flag:macos-apps> and in the JS runtime; on Android the list marks it failed, while the app's own request goes on. On Android, a body that view-network-request-details did not read before the stop is no longer available.
166820
167196
  Returns { status, layers }: per layer, armed (false once the layer confirmed the stop), total (the requests it keeps for the app, or 0 when the stop could not count them, as on a JS runtime it did not reach) and a reason when the layer was not reached or was not started.`,
166821
167197
  zodSchema: captureSchema,
166822
167198
  capability: CAPTURE_CAPABILITY,
@@ -166831,6 +167207,14 @@ Returns { status, layers }: per layer, armed (false once the layer confirmed the
166831
167207
  const device = resolveDevice(params.udid);
166832
167208
  assertSupported("network-capture-stop", CAPTURE_CAPABILITY, device);
166833
167209
  const port = metroPort({ device_id: params.udid, port: params.port });
167210
+ if (device.platform === "macos") {
167211
+ const layer = await withCaptureLock(
167212
+ params.udid,
167213
+ params.bundleId,
167214
+ () => stopMacosLayer(registry2, device, params.bundleId, port)
167215
+ );
167216
+ return { status: "ok", layers: [layer] };
167217
+ }
166834
167218
  const layers = await withCaptureLock(
166835
167219
  params.udid,
166836
167220
  params.bundleId,
@@ -167024,6 +167408,25 @@ async function stopIosLayer(registry2, device, bundleId, port) {
167024
167408
  ...reason2 ? { reason: reason2 } : {}
167025
167409
  };
167026
167410
  }
167411
+ async function stopMacosLayer(registry2, device, bundleId, port) {
167412
+ const ref = macosAppRef(device);
167413
+ const app = requireMacosAppOfBundle(
167414
+ { macosApp: await registry2.resolveService(ref.urn, ref.options) },
167415
+ device,
167416
+ "network-capture-stop",
167417
+ bundleId
167418
+ );
167419
+ if (!app.isNetworkCaptureStarted() && !app.isNetworkCaptureStopped()) {
167420
+ return { layer: "macos-native", armed: false, total: 0, reason: NOT_STARTED2 };
167421
+ }
167422
+ const { confirmed, reason: reason2 } = await app.stopNetworkCapture();
167423
+ return {
167424
+ layer: "macos-native",
167425
+ armed: !confirmed,
167426
+ total: app.networkRecords().records(port).length,
167427
+ ...reason2 ? { reason: reason2 } : {}
167428
+ };
167429
+ }
167027
167430
  async function stopAndroidLayer(registry2, device, bundleId, port) {
167028
167431
  const ref = androidNetworkInspectorRef(device, bundleId, port);
167029
167432
  if (!isLiveService(registry2, ref.urn)) {
@@ -183170,7 +183573,7 @@ var zodSchema65 = external_exports.object({
183170
183573
  function createStopSimulatorServerTool(registry2) {
183171
183574
  return {
183172
183575
  id: "stop-simulator-server",
183173
- description: `Stop the transport session for a specific device (iOS simulator / Android: simulator-server process; physical iOS: the on-device runner; Chromium: CDP WebSocket) and free its resources; on a TV target it also reaps that device's TV-control daemons. Use to restart a wedged transport, or when the user is done with one device but wants to keep others running - not just because a task on it finished, since the next task on that device would start cold again. On iOS / Android / TV it deliberately leaves this device's native-devtools, accessibility, profiler and debugger services running - to drain those as well, use stop-all-simulator-servers with \`devices\`. On CHROMIUM, stopping the transport also ends the JS-runtime debugger session and its captured console history - reconnect with debugger-connect afterwards.<flag:macos-apps> On a Mac app it also ends the native-network-logs capture and drops its log; call native-network-logs again to restart it.</flag:macos-apps> Returns { stopped, udid }; \`stopped\` is false, not an error, when no session is open for the id.`,
183576
+ description: `Stop the transport session for a specific device (iOS simulator / Android: simulator-server process; physical iOS: the on-device runner; Chromium: CDP WebSocket) and free its resources; on a TV target it also reaps that device's TV-control daemons. Use to restart a wedged transport, or when the user is done with one device but wants to keep others running - not just because a task on it finished, since the next task on that device would start cold again. On iOS / Android / TV it deliberately leaves this device's native-devtools, accessibility, profiler and debugger services running - to drain those as well, use stop-all-simulator-servers with \`devices\`. On CHROMIUM, stopping the transport also ends the JS-runtime debugger session and its captured console history - reconnect with debugger-connect afterwards.<flag:macos-apps> On a Mac app it also ends the network capture and drops the requests it recorded; call network-capture-start to capture again.</flag:macos-apps> Returns { stopped, udid }; \`stopped\` is false, not an error, when no session is open for the id.`,
183174
183577
  zodSchema: zodSchema65,
183175
183578
  interaction: {
183176
183579
  startedMsg: ({ params }) => `Stopping simulator server for ${params.udid}`,
@@ -183214,7 +183617,7 @@ var zodSchema66 = external_exports.object({
183214
183617
  function createStopAllSimulatorServersTool(registry2) {
183215
183618
  return {
183216
183619
  id: "stop-all-simulator-servers",
183217
- description: `Stop the services a device owns - simulator-server processes (iOS + Android), native devtools, the iOS accessibility service, TV-control daemons, Chromium CDP sessions, screen recordings, native profiler sessions, native network capture with the requests it recorded, and JS-runtime debugger sessions along with the network inspectors and React profiler sessions that ride on them - freeing their spawned processes, sockets and ports. Network capture started by network-capture-start ends here too, with the requests it recorded, except in a JS runtime this call does not reach, for example after Metro restarted: this call does not connect to it again, so its JS capture keeps recording and keeps its requests, and the result does not say so. A later network-capture-stop that reaches that runtime stops the recording. Call this when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services mid-flow - not just because a task finished, since the next task reuses these services and would start cold again. To stop the network capture of one app and keep its requests, call network-capture-stop instead.<flag:macos-apps> On a Mac app it also ends the native-network-logs capture and drops its log; network-capture-stop does not apply there.</flag:macos-apps>
183620
+ description: `Stop the services a device owns - simulator-server processes (iOS + Android), native devtools, the iOS accessibility service, TV-control daemons, Chromium CDP sessions, screen recordings, native profiler sessions, native network capture with the requests it recorded, and JS-runtime debugger sessions along with the network inspectors and React profiler sessions that ride on them - freeing their spawned processes, sockets and ports. Network capture started by network-capture-start ends here too, with the requests it recorded, except in a JS runtime this call does not reach, for example after Metro restarted: this call does not connect to it again, so its JS capture keeps recording and keeps its requests, and the result does not say so. A later network-capture-stop that reaches that runtime stops the recording. Call this when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services mid-flow - not just because a task finished, since the next task reuses these services and would start cold again. To stop the network capture of one app and keep its requests, call network-capture-stop instead.
183218
183621
  PASS \`devices\` with the device ids this session used: one tool-server serves every agent, subagent and CLI call using this argent install, and an unscoped call tears down THEIR devices too. Omit \`devices\` only when a machine-wide cleanup is what you actually want. An EMPTY array stops nothing; it does not ask for the machine-wide sweep.
183219
183622
  A JS-runtime debugger session is keyed by the id you called \`debugger-connect\` with. On a Metro serving two or more devices that id can be a \`logicalDeviceId\`: connect refuses a serial, or a simulator udid it cannot match to one Metro device by name, and tells you to re-target with the \`logicalDeviceId\` it returns. A scope built from \`list-devices\` ids cannot reach that session. Pass any such \`logicalDeviceId\` in \`devices\` ALONGSIDE the device id.
183220
183623
  Returns { stopped }: the URNs of the live services that were shut down; empty means nothing was still running. { unmatched }, present only when a supplied id owns no service here, lists those ids, so a typo or a device NAME passed instead of an id does not read as a clean machine. It is NOT proof the id is wrong: a Vega device you only booted and drove with the remote registers no service and lands here, as does any device this session never started anything on. { left_running } lists the URNs of live debugger sessions (and the network inspectors / React profiler sessions riding on them) whose id no device scope can name; re-call with the id after each URN's \`<namespace>:<port>:\` prefix to reap them. { aborted: true } means the request was cancelled part-way: the rest was left untouched and \`unmatched\` / \`left_running\` were not computed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.34.1-next.48",
3
+ "version": "0.34.1-next.49",
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",
@@ -146,7 +146,7 @@ A warning does not reject the step. If `e2e-finish-recording` reports dropped wa
146
146
 
147
147
  ### Network capture
148
148
 
149
- On iOS and Android, `view-network-logs` and `native-network-logs` only read. Before `network-capture-start`, they say that capture is not started. A `tool:` step passes whatever text it returns, so a read before a start replays green and proves nothing.
149
+ On iOS and Android, `view-network-logs` and `native-network-logs` only read. On a Mac app, `native-network-logs` only reads. Before `network-capture-start`, they say that capture is not started. A `tool:` step passes whatever text it returns, so a read before a start replays green and proves nothing.
150
150
 
151
151
  1. Record `network-capture-start` through `e2e-add-step` after the launch and its first-screen wait, before the action whose requests the test reads. A launch ends the capture of the JS layer. A start before `launch:` makes the test a fragment.
152
152
  2. Before a recorded `network-capture-stop`, record a wait for the screen that shows the result of the request. Argent records no request that the app sends after the stop.