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

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.49";
36262
+ return "0.34.1-next.50";
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.49";
16948
+ return "0.34.1-next.50";
16949
16949
  }
16950
16950
  return "0.0.0";
16951
16951
  }
@@ -636,6 +636,8 @@ export interface ArgentToolArgs {
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;
639
+ /** The layer to act on: js (the app's JS runtime, read with view-network-logs) or native (NSURLProtocol on iOS, OkHttp on Android, read with native-network-logs). Omit it to act on both. The other layer stays as it is. A Mac app has only the native layer. */
640
+ layer?: "js" | "native";
639
641
  /** Only when several devices share the Metro port: this device's logicalDeviceId, which the JS layer's reason lists. The JS layer connects to that runtime, and view-network-logs then takes it as device_id. The native layer always uses udid. */
640
642
  logicalDeviceId?: string;
641
643
  };
@@ -646,6 +648,8 @@ export interface ArgentToolArgs {
646
648
  bundleId: string;
647
649
  /** 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
650
  port?: number;
651
+ /** The layer to act on: js (the app's JS runtime, read with view-network-logs) or native (NSURLProtocol on iOS, OkHttp on Android, read with native-network-logs). Omit it to act on both. The other layer stays as it is. A Mac app has only the native layer. */
652
+ layer?: "js" | "native";
649
653
  /** Only when several devices share the Metro port: this device's logicalDeviceId, which the JS layer's reason lists. The JS layer connects to that runtime, and view-network-logs then takes it as device_id. The native layer always uses udid. */
650
654
  logicalDeviceId?: string;
651
655
  };
@@ -101447,7 +101447,7 @@ function isCi(env = process.env) {
101447
101447
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
101448
101448
  function readCliVersion() {
101449
101449
  if (true) {
101450
- return "0.34.1-next.49";
101450
+ return "0.34.1-next.50";
101451
101451
  }
101452
101452
  return "0.0.0";
101453
101453
  }
@@ -152115,10 +152115,32 @@ var captureSchema = external_exports.object({
152115
152115
  port: metroPortField.describe(
152116
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."
152117
152117
  ),
152118
+ layer: external_exports.enum(["js", "native"]).optional().describe(
152119
+ "The layer to act on: js (the app's JS runtime, read with view-network-logs) or native (NSURLProtocol on iOS, OkHttp on Android, read with native-network-logs). Omit it to act on both. The other layer stays as it is.<flag:macos-apps> A Mac app has only the native layer.</flag:macos-apps>"
152120
+ ),
152118
152121
  logicalDeviceId: external_exports.string().min(1).optional().describe(
152119
152122
  "Only when several devices share the Metro port: this device's logicalDeviceId, which the JS layer's reason lists. The JS layer connects to that runtime, and view-network-logs then takes it as device_id. The native layer always uses udid."
152120
152123
  )
152121
152124
  });
152125
+ function requestedLayers(layer) {
152126
+ return { js: layer !== "native", native: layer !== "js" };
152127
+ }
152128
+ var MACOS_NO_JS = 'a Mac app has no JS layer that argent captures: its network capture is native only, so omit layer or pass layer "native"';
152129
+ function captureName(layer) {
152130
+ return layer === "js" ? "JS network capture" : layer === "native" ? "native network capture" : "network capture";
152131
+ }
152132
+ function withLayerInRetries(layers, layer) {
152133
+ if (layer === void 0) return layers;
152134
+ return layers.map(
152135
+ (entry) => (
152136
+ // A reason that already names the layer to pass is left as it is.
152137
+ entry.reason && /network-capture-(start|stop)/.test(entry.reason) && !/layer "(js|native)"/.test(entry.reason) ? {
152138
+ ...entry,
152139
+ reason: `${entry.reason}; pass layer "${layer}" to that call, so it leaves the other layer as it is`
152140
+ } : entry
152141
+ )
152142
+ );
152143
+ }
152122
152144
  var CAPTURE_CAPABILITY = {
152123
152145
  apple: { simulator: true },
152124
152146
  appleRemote: { simulator: true },
@@ -154960,6 +154982,12 @@ function jsCapturesOn(device) {
154960
154982
  function findJsCapture(device, bundleId) {
154961
154983
  return jsCapturesOn(device).find((capture) => capture.bundleId === bundleId);
154962
154984
  }
154985
+ function jsCapturesOfAppOn(port, bundleId, exceptDevice) {
154986
+ return [...jsCaptures].filter(([payload, capture]) => {
154987
+ const { port: on, device } = splitPayload(payload);
154988
+ return capture.bundleId === bundleId && on === port && !sameDevice(device, exceptDevice);
154989
+ }).map(([, capture]) => capture);
154990
+ }
154963
154991
  function payloadsOf(devices2) {
154964
154992
  return [...jsCaptures.keys()].filter((payload) => {
154965
154993
  const { device } = splitPayload(payload);
@@ -166871,23 +166899,36 @@ var JS_ANSWER_WAIT_MS = 5e3;
166871
166899
  function createNetworkCaptureStartTool(registry2) {
166872
166900
  return {
166873
166901
  id: "network-capture-start",
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>
166902
+ 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> Pass layer js or native to start only that layer; the other layer stays as it is, and a later call can start it.
166875
166903
  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.
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.
166877
- Fails with NETWORK_CAPTURE_UNAVAILABLE when no layer can capture this app.`,
166904
+ Returns { status, layers }: per layer the call started, 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.
166905
+ Fails with NETWORK_CAPTURE_UNAVAILABLE when no layer the call names can capture this app.`,
166878
166906
  zodSchema: captureSchema,
166879
166907
  capability: CAPTURE_CAPABILITY,
166880
166908
  interaction: {
166881
- startedMsg: ({ params }) => `Starting network capture for ${params.bundleId}`,
166882
- completedMsg: ({ params }) => `Started network capture for ${params.bundleId}`,
166883
- failedMsg: ({ params, failureSignal: failureSignal2 }) => `Failed to start network capture for ${params.bundleId}: ${failureSignal2.error_code}`
166909
+ startedMsg: ({ params }) => `Starting ${captureName(params.layer)} for ${params.bundleId}`,
166910
+ completedMsg: ({ params, result }) => {
166911
+ const started = `Started ${captureName(params.layer)} for ${params.bundleId}`;
166912
+ const waiting = result.layers.filter((entry) => !entry.armed);
166913
+ if (waiting.length === 0) return started;
166914
+ const names = waiting.map((entry) => entry.layer).join(" and ");
166915
+ if (waiting.length === 1) {
166916
+ const reason2 = waiting[0].reason;
166917
+ return `${started}, but ${names} is not armed yet${reason2 ? `: ${reason2}` : ""}`;
166918
+ }
166919
+ const reasons = waiting.map((entry) => entry.reason ? `${entry.layer}: ${entry.reason}` : entry.layer).join("; ");
166920
+ return `${started}, but ${names} are not armed yet (${reasons})`;
166921
+ },
166922
+ failedMsg: ({ params, failureSignal: failureSignal2 }) => `Failed to start ${captureName(params.layer)} for ${params.bundleId}: ${failureSignal2.error_code}`
166884
166923
  },
166885
166924
  // Each layer resolves its own service, so one that fails leaves the others running.
166886
166925
  services: () => ({}),
166887
166926
  async execute(_services, params) {
166888
166927
  const device = resolveDevice(params.udid);
166889
166928
  assertSupported("network-capture-start", CAPTURE_CAPABILITY, device);
166929
+ const run2 = requestedLayers(params.layer);
166890
166930
  if (device.platform === "macos") {
166931
+ if (!run2.native) throw unavailableError(params, [unavailable2("js", MACOS_NO_JS)]);
166891
166932
  const layer = await withCaptureLock(
166892
166933
  params.udid,
166893
166934
  params.bundleId,
@@ -166898,17 +166939,27 @@ Fails with NETWORK_CAPTURE_UNAVAILABLE when no layer can capture this app.`,
166898
166939
  const port = metroPort({ device_id: params.udid, port: params.port });
166899
166940
  const layers = await withCaptureLock(params.udid, params.bundleId, async () => {
166900
166941
  if (device.platform === "ios-remote") await ensureDeps(["sim-remote"]);
166901
- if (device.platform === "ios" && isInjectableBundleId(params.bundleId)) {
166942
+ if (run2.native && device.platform === "ios" && isInjectableBundleId(params.bundleId)) {
166902
166943
  await refuseWhileXcodeInstalls(registry2, device, params.bundleId);
166903
166944
  }
166904
166945
  return runLayers([
166905
- device.platform !== "android" && !isInjectableBundleId(params.bundleId) ? Promise.resolve(
166906
- unavailable2(
166907
- "js",
166908
- `${params.bundleId} is an Apple system app, which runs no React Native JS`
166946
+ ...run2.js ? [
166947
+ device.platform !== "android" && !isInjectableBundleId(params.bundleId) ? Promise.resolve(
166948
+ unavailable2(
166949
+ "js",
166950
+ `${params.bundleId} is an Apple system app, which runs no React Native JS`
166951
+ )
166952
+ ) : startJsLayer(
166953
+ registry2,
166954
+ params.udid,
166955
+ params.logicalDeviceId,
166956
+ params.bundleId,
166957
+ port
166909
166958
  )
166910
- ) : startJsLayer(registry2, params.udid, params.logicalDeviceId, params.bundleId, port),
166911
- device.platform === "android" ? startAndroidLayer(registry2, device, params.bundleId, port) : startIosLayer(registry2, device, params.bundleId, port)
166959
+ ] : [],
166960
+ ...run2.native ? [
166961
+ device.platform === "android" ? startAndroidLayer(registry2, device, params.bundleId, port) : startIosLayer(registry2, device, params.bundleId, port, run2.js)
166962
+ ] : []
166912
166963
  ]);
166913
166964
  });
166914
166965
  if (layers.every((layer) => layer.unavailable)) {
@@ -166919,7 +166970,7 @@ Fails with NETWORK_CAPTURE_UNAVAILABLE when no layer can capture this app.`,
166919
166970
  }
166920
166971
  throw error63;
166921
166972
  }
166922
- return { status: "ok", layers };
166973
+ return { status: "ok", layers: withLayerInRetries(layers, params.layer) };
166923
166974
  }
166924
166975
  };
166925
166976
  }
@@ -167069,7 +167120,7 @@ async function startJsLayer(registry2, udid, logicalDeviceId, bundleId, port) {
167069
167120
  return {
167070
167121
  layer: "js",
167071
167122
  armed: false,
167072
- reason: "the app's JavaScript has not loaded yet; call network-capture-start again once it has"
167123
+ reason: "the app's JavaScript has not loaded yet; call network-capture-start again once it has, before you trigger the requests to inspect"
167073
167124
  };
167074
167125
  }
167075
167126
  return {
@@ -167096,7 +167147,7 @@ async function readMark(dbg) {
167096
167147
  return { install: null };
167097
167148
  }
167098
167149
  }
167099
- async function startIosLayer(registry2, device, bundleId, port) {
167150
+ async function startIosLayer(registry2, device, bundleId, port, jsToo) {
167100
167151
  if (!isInjectableBundleId(bundleId)) {
167101
167152
  return unavailable2(
167102
167153
  "ios-native",
@@ -167152,10 +167203,11 @@ async function startIosLayer(registry2, device, bundleId, port) {
167152
167203
  reason: "the app has not connected through the device's devtools agent; it arms when it does"
167153
167204
  };
167154
167205
  }
167206
+ const jsAfterRelaunch = jsToo ? ", then network-capture-start again, since a relaunch ends the JS layer's capture" : `; a relaunch also ends any JS capture of the app: if it ran and you still need it, call network-capture-start with layer "js" and the same port and logicalDeviceId as its start once the app's JavaScript loads (for native requests alone, restart-app is enough)`;
167155
167207
  return {
167156
167208
  layer: "ios-native",
167157
167209
  armed: false,
167158
- reason: block?.status === "restart_required" ? "no running process of the app can be armed; capture arms at its next launch, so call restart-app to capture it now, then network-capture-start again, since a relaunch ends the JS layer's capture; if restart-app fails rather than starting the app, the bundle id is not installed on this simulator: check it, or install the app" : "the app has not connected yet; capture arms when it does"
167210
+ reason: block?.status === "restart_required" ? `no running process of the app can be armed; capture arms at its next launch, so call restart-app to capture it now${jsAfterRelaunch}; if restart-app fails rather than starting the app, the bundle id is not installed on this simulator: check it, or install the app` : "the app has not connected yet; capture arms when it does"
167159
167211
  };
167160
167212
  }
167161
167213
  async function startAndroidLayer(registry2, device, bundleId, port) {
@@ -167190,16 +167242,19 @@ var JS_ANSWER_WAIT_MS2 = 5e3;
167190
167242
  function createNetworkCaptureStopTool(registry2) {
167191
167243
  return {
167192
167244
  id: "network-capture-stop",
167193
- description: `Stop network capture for an app on every layer and keep what was captured.
167245
+ description: `Stop network capture for an app on every layer and keep what was captured. Pass layer js or native to stop only that layer; the other layer keeps capturing.
167194
167246
  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).
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.
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.`,
167247
+ 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. When the stop covers the native layer on Android, the list marks such a request failed, while the app's own request goes on, and a body that view-network-request-details did not read before the stop is no longer available.
167248
+ Returns { status, layers }: per layer the call stopped, 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.`,
167197
167249
  zodSchema: captureSchema,
167198
167250
  capability: CAPTURE_CAPABILITY,
167199
167251
  interaction: {
167200
- startedMsg: ({ params }) => `Stopping network capture for ${params.bundleId}`,
167201
- completedMsg: ({ params }) => `Stopped network capture for ${params.bundleId}`,
167202
- failedMsg: ({ params, failureSignal: failureSignal2 }) => `Failed to stop network capture for ${params.bundleId}: ${failureSignal2.error_code}`
167252
+ startedMsg: ({ params }) => `Stopping ${captureName(params.layer)} for ${params.bundleId}`,
167253
+ completedMsg: ({ params, result }) => {
167254
+ const recording = result.layers.filter((entry) => entry.armed).map((entry) => entry.layer);
167255
+ return recording.length === 0 ? `Stopped ${captureName(params.layer)} for ${params.bundleId}` : `Stop of ${captureName(params.layer)} for ${params.bundleId} is unconfirmed: ${recording.join(" and ")} may still record`;
167256
+ },
167257
+ failedMsg: ({ params, failureSignal: failureSignal2 }) => `Failed to stop ${captureName(params.layer)} for ${params.bundleId}: ${failureSignal2.error_code}`
167203
167258
  },
167204
167259
  // A stop must not create the services it stops, so each layer looks them up itself.
167205
167260
  services: () => ({}),
@@ -167207,7 +167262,21 @@ Returns { status, layers }: per layer, armed (false once the layer confirmed the
167207
167262
  const device = resolveDevice(params.udid);
167208
167263
  assertSupported("network-capture-stop", CAPTURE_CAPABILITY, device);
167209
167264
  const port = metroPort({ device_id: params.udid, port: params.port });
167265
+ const run2 = requestedLayers(params.layer);
167210
167266
  if (device.platform === "macos") {
167267
+ if (!run2.native) {
167268
+ return {
167269
+ status: "ok",
167270
+ layers: [
167271
+ {
167272
+ layer: "js",
167273
+ armed: false,
167274
+ total: 0,
167275
+ reason: `${MACOS_NO_JS}; its native capture stays as it is`
167276
+ }
167277
+ ]
167278
+ };
167279
+ }
167211
167280
  const layer = await withCaptureLock(
167212
167281
  params.udid,
167213
167282
  params.bundleId,
@@ -167219,16 +167288,26 @@ Returns { status, layers }: per layer, armed (false once the layer confirmed the
167219
167288
  params.udid,
167220
167289
  params.bundleId,
167221
167290
  () => runLayers([
167222
- device.platform !== "android" && !isInjectableBundleId(params.bundleId) ? Promise.resolve({
167223
- layer: "js",
167224
- armed: false,
167225
- total: 0,
167226
- reason: `${params.bundleId} is an Apple system app, which runs no React Native JS`
167227
- }) : stopJsLayer(registry2, params.udid, params.logicalDeviceId, params.bundleId, port),
167228
- device.platform === "android" ? stopAndroidLayer(registry2, device, params.bundleId, port) : stopIosLayer(registry2, device, params.bundleId, port)
167291
+ ...run2.js ? [
167292
+ device.platform !== "android" && !isInjectableBundleId(params.bundleId) ? Promise.resolve({
167293
+ layer: "js",
167294
+ armed: false,
167295
+ total: 0,
167296
+ reason: `${params.bundleId} is an Apple system app, which runs no React Native JS`
167297
+ }) : stopJsLayer(
167298
+ registry2,
167299
+ params.udid,
167300
+ params.logicalDeviceId,
167301
+ params.bundleId,
167302
+ port
167303
+ )
167304
+ ] : [],
167305
+ ...run2.native ? [
167306
+ device.platform === "android" ? stopAndroidLayer(registry2, device, params.bundleId, port) : stopIosLayer(registry2, device, params.bundleId, port)
167307
+ ] : []
167229
167308
  ])
167230
167309
  );
167231
- return { status: "ok", layers };
167310
+ return { status: "ok", layers: withLayerInRetries(layers, params.layer) };
167232
167311
  }
167233
167312
  };
167234
167313
  }
@@ -167274,7 +167353,20 @@ async function stopJsLayer(registry2, udid, logicalDeviceId, bundleId, port) {
167274
167353
  try {
167275
167354
  dbg = await resolveJsRuntime(registry2, udid, logicalDeviceId, port);
167276
167355
  } catch (err) {
167277
- const notReached = jsNotReached(classifyNotConnected(err), port, err);
167356
+ const notConnected3 = classifyNotConnected(err);
167357
+ const notReached = jsNotReached(notConnected3, port, err);
167358
+ const mayRecordUnderOtherId = notConnected3 === "device_mismatch" && jsCapturesOfAppOn(port, bundleId, device).some(
167359
+ (capture) => capture.intent === "started" || capture.installed && capture.paused !== true
167360
+ );
167361
+ if (mayRecordUnderOtherId) {
167362
+ if (kept) storeStopped(kept.paused === true);
167363
+ return {
167364
+ layer: "js",
167365
+ armed: true,
167366
+ total: 0,
167367
+ reason: `${notReached}; a JS capture of ${bundleId} on this Metro may still record, so call network-capture-stop again with this device's logicalDeviceId before you rely on the stop${other ? `; ${otherPortHint(bundleId, other.port)}` : ""}`
167368
+ };
167369
+ }
167278
167370
  if (other) {
167279
167371
  return {
167280
167372
  layer: "js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.34.1-next.49",
3
+ "version": "0.34.1-next.50",
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",