@swmansion/argent 0.35.1-next.38 → 0.35.1-next.39

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.
@@ -28,8 +28,10 @@ export interface ArgentToolArgs {
28
28
  method?: string;
29
29
  /** Exact HTTP status or class (e.g. "2xx"). */
30
30
  status?: "1xx" | "2xx" | "3xx" | "4xx" | "5xx" | number;
31
- /** `complete` (default, incl. HTTP errors), `failed` (network error), or `any`. */
32
- outcome?: "complete" | "failed" | "any";
31
+ /** `complete` includes HTTP error responses. `failed` matches network errors. `any` matches either. `sent` matches all states. Defaults to `sent` with `absent: true`, otherwise `complete`. */
32
+ outcome?: "complete" | "failed" | "any" | "sent";
33
+ /** Set to true to fail on the first match and require complete capture to pass. */
34
+ absent?: boolean;
33
35
  /** Timeout in ms (default 10000). */
34
36
  timeoutMs?: number;
35
37
  /** Poll interval in ms (default 400). */
@@ -99720,6 +99720,9 @@ init_external_devices();
99720
99720
  function deviceKeyOf(deviceId) {
99721
99721
  return externalNativeId(canonicalDeviceId(deviceId) ?? deviceId);
99722
99722
  }
99723
+ function recordNumber(id) {
99724
+ return Number(id.slice(id.lastIndexOf("-") + 1));
99725
+ }
99723
99726
  var MAX_RECORDS = 2e3;
99724
99727
  var RECORD_CHARS_BUDGET = 32 * 1024 * 1024;
99725
99728
  var MAX_VALUE_CHARS = 64 * 1024;
@@ -100555,6 +100558,7 @@ function createIosNetworkRecords(state3, link, recording = () => true, layer = "
100555
100558
  const idPrefix = layer === "macos-native" ? "macos" : "ios";
100556
100559
  const records = [];
100557
100560
  let recordChars = 0;
100561
+ let evictedThrough = 0;
100558
100562
  const recordSizes = /* @__PURE__ */ new WeakMap();
100559
100563
  const byId = /* @__PURE__ */ new Map();
100560
100564
  const byLayerId = /* @__PURE__ */ new Map();
@@ -100622,6 +100626,7 @@ function createIosNetworkRecords(state3, link, recording = () => true, layer = "
100622
100626
  function evict(record2) {
100623
100627
  const key2 = keyOf(record2.connection, record2.layerId);
100624
100628
  if (byLayerId.get(key2) === record2) byLayerId.delete(key2);
100629
+ evictedThrough = Math.max(evictedThrough, recordNumber(record2.id));
100625
100630
  byId.delete(record2.id);
100626
100631
  recordChars -= recordSizes.get(record2) ?? 0;
100627
100632
  recordSizes.delete(record2);
@@ -100848,6 +100853,7 @@ function createIosNetworkRecords(state3, link, recording = () => true, layer = "
100848
100853
  records: (port, options) => records.filter(
100849
100854
  (r) => (options?.includeHidden === true || !cleared.has(r)) && !isMetroTraffic(r.request.url, port)
100850
100855
  ),
100856
+ evictedThrough: () => evictedThrough,
100851
100857
  record: (id) => byId.get(id),
100852
100858
  clear() {
100853
100859
  for (const record2 of records) cleared.add(record2);
@@ -105519,6 +105525,7 @@ function createNetworkManager(deps) {
105519
105525
  const byId = /* @__PURE__ */ new Map();
105520
105526
  const seqOf = /* @__PURE__ */ new Map();
105521
105527
  let lastSeq = 0;
105528
+ let evictedSeq = 0;
105522
105529
  let mark;
105523
105530
  let conditions = null;
105524
105531
  const bodyBytesLeft = /* @__PURE__ */ new WeakMap();
@@ -105532,6 +105539,7 @@ function createNetworkManager(deps) {
105532
105539
  if (order.length > MAX_RECORDS2) {
105533
105540
  const evicted = order.shift();
105534
105541
  if (evicted) {
105542
+ evictedSeq = seqOf.get(evicted) ?? evictedSeq;
105535
105543
  byId.delete(evicted);
105536
105544
  seqOf.delete(evicted);
105537
105545
  }
@@ -105632,6 +105640,7 @@ function createNetworkManager(deps) {
105632
105640
  const rec = byId.get(id);
105633
105641
  return at !== void 0 && at > seq && rec ? [{ seq: at, record: rec }] : [];
105634
105642
  }),
105643
+ evictedThrough: () => evictedSeq,
105635
105644
  get: (requestId) => byId.get(requestId),
105636
105645
  startCapture: () => mark = { lastSeq },
105637
105646
  stopCapture: () => {
@@ -126692,6 +126701,7 @@ function createInspector(serial, packageName, initialMetroPort) {
126692
126701
  const connections3 = [];
126693
126702
  const records = [];
126694
126703
  let recordChars = 0;
126704
+ let evictedThrough = 0;
126695
126705
  const recordSizes = /* @__PURE__ */ new WeakMap();
126696
126706
  const byId = /* @__PURE__ */ new Map();
126697
126707
  const bodies = /* @__PURE__ */ new Map();
@@ -127632,6 +127642,7 @@ function createInspector(serial, packageName, initialMetroPort) {
127632
127642
  if (entry && entry.conn.byLayerId.get(record2.layerId) === record2) {
127633
127643
  entry.conn.byLayerId.delete(record2.layerId);
127634
127644
  }
127645
+ evictedThrough = Math.max(evictedThrough, recordNumber(record2.id));
127635
127646
  byId.delete(record2.id);
127636
127647
  recordChars -= recordSizes.get(record2) ?? 0;
127637
127648
  recordSizes.delete(record2);
@@ -127991,6 +128002,7 @@ function createInspector(serial, packageName, initialMetroPort) {
127991
128002
  records: (port, options) => records.filter(
127992
128003
  (r) => (options?.includeHidden === true || !cleared.has(r)) && !isMetroTraffic(r.request.url, port, { androidEmulatorHost: true })
127993
128004
  ),
128005
+ evictedThrough: () => evictedThrough,
127994
128006
  record: (id) => byId.get(id)?.record,
127995
128007
  responseBody: (id) => fetchBody(id, "response"),
127996
128008
  requestPostData: (id) => fetchBody(id, "post"),
@@ -129276,11 +129288,41 @@ function nativeUnavailableReason(udid, bundleId) {
129276
129288
  }
129277
129289
  var lastStarts = /* @__PURE__ */ new Map();
129278
129290
  function noteCaptureStart(udid, bundleId, layers, nativeFloor) {
129291
+ const named = new Set(layers.filter((entry) => !entry.unavailable).map((entry) => entry.layer));
129292
+ const previous = lastStarts.get(appKey(udid, bundleId));
129293
+ const kept = [...previous?.armed ?? []].filter((layer) => !named.has(layer));
129294
+ const missed = new Map([...previous?.missed ?? []].filter(([layer]) => !named.has(layer)));
129295
+ for (const entry of layers) {
129296
+ if (entry.unavailable || entry.armed || entry.layer === "js") continue;
129297
+ missed.set(
129298
+ entry.layer,
129299
+ `it was not armed at network-capture-start${entry.reason ? ` (${entry.reason})` : ""}, so it may have missed requests until it armed; call network-capture-start again once it is armed`
129300
+ );
129301
+ }
129279
129302
  lastStarts.set(appKey(udid, bundleId), {
129280
- layers: new Set(layers.filter((entry) => !entry.unavailable).map((entry) => entry.layer)),
129281
- nativeFloor
129303
+ layers: named,
129304
+ nativeFloor,
129305
+ armed: /* @__PURE__ */ new Set([...kept, ...layers.filter((entry) => entry.armed).map((entry) => entry.layer)]),
129306
+ missed
129282
129307
  });
129283
129308
  }
129309
+ function noteLayerArmed(udid, bundleId, layer) {
129310
+ lastStarts.get(appKey(udid, bundleId))?.armed.add(layer);
129311
+ }
129312
+ function noteLayerUnarmed(udid, bundleId, layer) {
129313
+ const missed = lastStarts.get(appKey(udid, bundleId))?.missed;
129314
+ if (missed && !missed.has(layer)) {
129315
+ missed.set(
129316
+ layer,
129317
+ "a read since network-capture-start found it not armed, so it may have missed requests; call network-capture-start again once it is armed"
129318
+ );
129319
+ }
129320
+ }
129321
+ function noteArmedAtStop(udid, bundleId, layer, armed) {
129322
+ const start2 = lastStarts.get(appKey(udid, bundleId));
129323
+ if (armed) start2?.armed.add(layer);
129324
+ else start2?.armed.delete(layer);
129325
+ }
129284
129326
  function lastCaptureStart(udid, bundleId) {
129285
129327
  return lastStarts.get(appKey(udid, bundleId));
129286
129328
  }
@@ -130971,6 +131013,7 @@ var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
130971
131013
  g.__argent_network_log = log;
130972
131014
  g.__argent_network_by_id = byId;
130973
131015
  var nextId = 1;
131016
+ g.__argent_network_lost_through = 0;
130974
131017
  // Only an identity: a new JS context gets another one, and its ids start at 1 again.
130975
131018
  var installToken = Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 10);
130976
131019
  g.__argent_network_install = installToken;
@@ -130995,6 +131038,7 @@ var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
130995
131038
  function evict() {
130996
131039
  while (log.length > MAX_ENTRIES || (bufferedChars > BUFFER_CAP && log.length > 0)) {
130997
131040
  var removed = log.shift();
131041
+ if (removed.id > g.__argent_network_lost_through) g.__argent_network_lost_through = removed.id;
130998
131042
  bufferedChars -= bodyChars(removed);
130999
131043
  delete byId[removed.requestId];
131000
131044
  }
@@ -131002,6 +131046,7 @@ var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
131002
131046
 
131003
131047
  // A request in flight keeps its record object, but adds to the buffer only while byId has it.
131004
131048
  g.__argent_network_clear = function() {
131049
+ g.__argent_network_lost_through = nextId - 1;
131005
131050
  log.length = 0;
131006
131051
  for (var key in byId) delete byId[key];
131007
131052
  bufferedChars = 0;
@@ -132114,6 +132159,18 @@ function makeNetworkWaitReadScript(mark, metroPort2) {
132114
132159
  var markToken = ${JSON.stringify(mark.install)};
132115
132160
  var lastId = ${mark.install === null ? 0 : mark.lastId};
132116
132161
  var sameContext = markToken !== null && token === markToken;
132162
+ var floor = sameContext ? lastId : 0;
132163
+ var lost;
132164
+ if (typeof g.__argent_network_lost_through === 'number') {
132165
+ lost = g.__argent_network_lost_through > floor;
132166
+ } else {
132167
+ // An interceptor from before this field: an id after the floor that the log lacks left it.
132168
+ var newest = floor;
132169
+ try { newest = JSON.parse(g.__argent_network_mark()).lastId; } catch (err) {}
132170
+ var kept = 0;
132171
+ for (var k = 0; k < log.length; k++) if (log[k].id > floor) kept++;
132172
+ lost = kept < newest - floor;
132173
+ }
132117
132174
  var entries = [];
132118
132175
  for (var i = 0; i < log.length; i++) {
132119
132176
  var e = log[i];
@@ -132135,6 +132192,7 @@ function makeNetworkWaitReadScript(mark, metroPort2) {
132135
132192
  xhr: xhr,
132136
132193
  token: token,
132137
132194
  paused: g.__argent_network_paused === true,
132195
+ lost: lost,
132138
132196
  entries: entries
132139
132197
  });
132140
132198
  })()`;
@@ -146100,7 +146158,13 @@ async function startJsLayer(registry2, udid, logicalDeviceId, bundleId, port) {
146100
146158
  try {
146101
146159
  const api = await registry2.resolveService(`NetworkInspector:${payload}`);
146102
146160
  const install = await installNetworkInterceptor(api.cdp, payload, dbg.runtimeApp);
146103
- if (install.installed) return { layer: "js", armed: true };
146161
+ if (install.installed) {
146162
+ if (capture.mark?.install === null) {
146163
+ const installed = await readMark(dbg).catch(() => void 0);
146164
+ if (installed?.install) capture.mark = { install: installed.install, lastId: 0 };
146165
+ }
146166
+ return { layer: "js", armed: true };
146167
+ }
146104
146168
  if (install.reason === NO_XHR_YET) {
146105
146169
  return {
146106
146170
  layer: "js",
@@ -146277,7 +146341,7 @@ Returns \`{ status: "ok", layers }\` with \`armed\` and any \`reason\`. Fails on
146277
146341
  )
146278
146342
  ] : [],
146279
146343
  ...run2.native ? [
146280
- app ? stopMacosLayer(app, port) : device.platform === "android" ? stopAndroidLayer(registry2, device, params.bundleId, port) : stopIosLayer(registry2, device, params.bundleId, port)
146344
+ app ? stopMacosLayer(app, device.id, params.bundleId, port) : device.platform === "android" ? stopAndroidLayer(registry2, device, params.bundleId, port) : stopIosLayer(registry2, device, params.bundleId, port)
146281
146345
  ] : []
146282
146346
  ]);
146283
146347
  });
@@ -146466,6 +146530,10 @@ async function stopIosLayer(registry2, device, bundleId, port) {
146466
146530
  if (!api.isNetworkCaptureStarted(bundleId) && !api.isNetworkCaptureStopped(bundleId)) {
146467
146531
  return { layer: "ios-native", armed: false, total: 0, reason: NOT_STARTED2 };
146468
146532
  }
146533
+ if (!api.isNetworkCaptureStopped(bundleId)) {
146534
+ const armed = api.networkRecords(bundleId)?.state().armed === true;
146535
+ noteArmedAtStop(device.id, bundleId, "ios-native", armed);
146536
+ }
146469
146537
  const { confirmed, reason: reason2 } = await api.stopNetworkCapture(bundleId);
146470
146538
  return {
146471
146539
  layer: "ios-native",
@@ -146474,10 +146542,13 @@ async function stopIosLayer(registry2, device, bundleId, port) {
146474
146542
  ...reason2 ? { reason: reason2 } : {}
146475
146543
  };
146476
146544
  }
146477
- async function stopMacosLayer(app, port) {
146545
+ async function stopMacosLayer(app, udid, bundleId, port) {
146478
146546
  if (!app.isNetworkCaptureStarted() && !app.isNetworkCaptureStopped()) {
146479
146547
  return { layer: "macos-native", armed: false, total: 0, reason: NOT_STARTED2 };
146480
146548
  }
146549
+ if (!app.isNetworkCaptureStopped()) {
146550
+ noteArmedAtStop(udid, bundleId, "macos-native", app.networkRecords().state().armed);
146551
+ }
146481
146552
  const { confirmed, reason: reason2 } = await app.stopNetworkCapture();
146482
146553
  return {
146483
146554
  layer: "macos-native",
@@ -146512,6 +146583,11 @@ async function stopAndroidLayer(registry2, device, bundleId, port) {
146512
146583
  if (!api.isStarted() && !api.isStopped()) {
146513
146584
  return { layer: "android-native", armed: false, total: 0, reason: NOT_STARTED2 };
146514
146585
  }
146586
+ if (!api.isStopped()) {
146587
+ const state3 = api.state();
146588
+ const armed = state3.armed && state3.capture?.state !== "unavailable";
146589
+ noteArmedAtStop(device.id, bundleId, "android-native", armed);
146590
+ }
146515
146591
  const { confirmed, reason: reason2 } = await api.stopCapture();
146516
146592
  return {
146517
146593
  layer: "android-native",
@@ -147454,15 +147530,23 @@ init_capability();
147454
147530
  // ../tool-server/src/tools/await-network-request/layers.ts
147455
147531
  var CAPTURE_ENDED = "its capture ended after the start (stop-all-simulator-servers, a stop of the device's services, or a tool-server restart); call network-capture-start again";
147456
147532
  var SWEEP_UNDER_WAY = "stop-all-simulator-servers or the tool-server's exit is ending the app's capture";
147533
+ var STOPPED_UNARMED = "the layer was not armed when network-capture-stop stopped it, so it may have missed requests in the window";
147534
+ var EVICTED = "its history is full, so it dropped requests sent since the start; call network-capture-start again closer to the action";
147535
+ var JS_EVICTED = `the app's JS log is full, so it dropped requests sent since the start; call network-capture-start again closer to the action`;
147457
147536
  var CAPTURE_CHANGED = "the app's capture changed during the read (a network-capture-start or -stop, or a teardown of the device), so the read left the app's JS runtime as it was";
147458
147537
  async function liveService(registry2, ref) {
147459
147538
  return isLiveService(registry2, ref.urn) ? registry2.resolveService(ref.urn, ref.options) : void 0;
147460
147539
  }
147461
- function unreadable(layer, note, stopped = false) {
147462
- return { layer, readable: false, armed: false, stopped, records: [], note };
147463
- }
147464
- function recordNumber(id) {
147465
- return Number(id.slice(id.lastIndexOf("-") + 1));
147540
+ function unreadable(layer, note, stopped = false, gap = false) {
147541
+ return {
147542
+ layer,
147543
+ readable: false,
147544
+ armed: false,
147545
+ stopped,
147546
+ records: [],
147547
+ note,
147548
+ ...gap ? { gap } : {}
147549
+ };
147466
147550
  }
147467
147551
  var LOST_ENDINGS = /* @__PURE__ */ new Set([
147468
147552
  STOPPED_BEFORE_FINISH,
@@ -147487,6 +147571,12 @@ function fromNative(record2) {
147487
147571
  startedAt: record2.timing.startedAt
147488
147572
  };
147489
147573
  }
147574
+ function windowNote(armed, stopped, unarmed, missed, evicted) {
147575
+ const gaps = [missed, evicted ? EVICTED : void 0].filter((note) => note !== void 0);
147576
+ const gap = gaps.length > 0 ? { gap: true } : {};
147577
+ if (!armed) return { note: stopped ? STOPPED_UNARMED : unarmed(), ...gap };
147578
+ return gaps.length > 0 ? { note: gaps.join("; "), ...gap } : {};
147579
+ }
147490
147580
  function nativeAfter(records, floor) {
147491
147581
  return records.filter((r) => recordNumber(r.id) > floor).map(fromNative);
147492
147582
  }
@@ -147495,7 +147585,16 @@ async function markedLayers(registry2, device, bundleId) {
147495
147585
  const start2 = lastCaptureStart(device.id, bundleId);
147496
147586
  const startWindow = {
147497
147587
  current: (layer, stopped) => !start2 || start2.layers.has(layer) || layer !== "js" && !stopped,
147498
- floor: (mark) => Math.max(mark.lastRecord, start2?.nativeFloor ?? 0)
147588
+ floor: (mark) => Math.max(mark.lastRecord, start2?.nativeFloor ?? 0),
147589
+ armed: (layer, stopped, armedNow) => {
147590
+ if (!stopped) {
147591
+ if (armedNow) noteLayerArmed(device.id, bundleId, layer);
147592
+ else noteLayerUnarmed(device.id, bundleId, layer);
147593
+ return armedNow;
147594
+ }
147595
+ return lastCaptureStart(device.id, bundleId)?.armed.has(layer) === true;
147596
+ },
147597
+ missed: (layer) => lastCaptureStart(device.id, bundleId)?.missed.get(layer)
147499
147598
  };
147500
147599
  const native = device.platform === "chromium" ? await chromiumLayer(registry2, device) : device.platform === "android" ? await androidLayer(registry2, device, bundleId, startWindow) : device.platform === "macos" ? await macosLayer(registry2, device, startWindow) : await iosLayer(registry2, device, bundleId, startWindow);
147501
147600
  if (native) layers.push(native);
@@ -147520,17 +147619,21 @@ async function iosLayer(registry2, device, bundleId, startWindow) {
147520
147619
  const stopped = api.isNetworkCaptureStopped(bundleId);
147521
147620
  const store = api.networkRecords(bundleId);
147522
147621
  const state3 = store?.state();
147523
- const armed = stopped || state3?.armed === true;
147622
+ const armed = startWindow.armed("ios-native", stopped, state3?.armed === true);
147623
+ const floor = startWindow.floor(mark);
147524
147624
  return {
147525
147625
  layer: "ios-native",
147526
147626
  readable: true,
147527
147627
  armed,
147528
147628
  stopped,
147529
- records: nativeAfter(
147530
- store?.records(mark.metroPort, { includeHidden: true }) ?? [],
147531
- startWindow.floor(mark)
147532
- ),
147533
- ...armed ? {} : { note: state3?.note ?? "the app has not connected yet; capture arms when it does" }
147629
+ records: nativeAfter(store?.records(mark.metroPort, { includeHidden: true }) ?? [], floor),
147630
+ ...windowNote(
147631
+ armed,
147632
+ stopped,
147633
+ () => state3?.note ?? "the app has not connected yet; capture arms when it does",
147634
+ startWindow.missed("ios-native"),
147635
+ (store?.evictedThrough() ?? 0) > floor
147636
+ )
147534
147637
  };
147535
147638
  }
147536
147639
  };
@@ -147549,19 +147652,25 @@ async function androidLayer(registry2, device, bundleId, startWindow) {
147549
147652
  if (!api || !mark) return unreadable("android-native", CAPTURE_ENDED);
147550
147653
  const stopped = api.isStopped();
147551
147654
  const state3 = api.state();
147552
- const armed = stopped || state3.armed && state3.capture?.state !== "unavailable";
147655
+ const armed = startWindow.armed(
147656
+ "android-native",
147657
+ stopped,
147658
+ state3.armed && state3.capture?.state !== "unavailable"
147659
+ );
147660
+ const floor = startWindow.floor(mark);
147553
147661
  return {
147554
147662
  layer: "android-native",
147555
147663
  readable: true,
147556
147664
  armed,
147557
147665
  stopped,
147558
- records: nativeAfter(
147559
- api.records(mark.metroPort, { includeHidden: true }),
147560
- startWindow.floor(mark)
147561
- ),
147562
- ...armed ? {} : {
147563
- note: state3.note ?? state3.capture?.detail ?? api.unavailableReason() ?? "the app's agent has not armed yet"
147564
- }
147666
+ records: nativeAfter(api.records(mark.metroPort, { includeHidden: true }), floor),
147667
+ ...windowNote(
147668
+ armed,
147669
+ stopped,
147670
+ () => state3.note ?? state3.capture?.detail ?? api.unavailableReason() ?? "the app's agent has not armed yet",
147671
+ startWindow.missed("android-native"),
147672
+ api.evictedThrough() > floor
147673
+ )
147565
147674
  };
147566
147675
  }
147567
147676
  };
@@ -147581,17 +147690,21 @@ async function macosLayer(registry2, device, startWindow) {
147581
147690
  const stopped = app.isNetworkCaptureStopped();
147582
147691
  const store = app.networkRecords();
147583
147692
  const state3 = store.state();
147584
- const armed = stopped || state3.armed;
147693
+ const armed = startWindow.armed("macos-native", stopped, state3.armed);
147694
+ const floor = startWindow.floor(mark);
147585
147695
  return {
147586
147696
  layer: "macos-native",
147587
147697
  readable: true,
147588
147698
  armed,
147589
147699
  stopped,
147590
- records: nativeAfter(
147591
- store.records(mark.metroPort, { includeHidden: true }),
147592
- startWindow.floor(mark)
147593
- ),
147594
- ...armed ? {} : { note: state3.note ?? "the app has not connected to argent yet" }
147700
+ records: nativeAfter(store.records(mark.metroPort, { includeHidden: true }), floor),
147701
+ ...windowNote(
147702
+ armed,
147703
+ stopped,
147704
+ () => state3.note ?? "the app has not connected to argent yet",
147705
+ startWindow.missed("macos-native"),
147706
+ store.evictedThrough() > floor
147707
+ )
147595
147708
  };
147596
147709
  }
147597
147710
  };
@@ -147619,12 +147732,14 @@ async function chromiumLayer(registry2, device) {
147619
147732
  const mark = network?.captureMark();
147620
147733
  if (!network || !mark) return unreadable("chromium", CAPTURE_ENDED);
147621
147734
  const stopped = mark.stoppedSeq !== void 0;
147735
+ const evicted = Math.min(network.evictedThrough(), mark.stoppedSeq ?? Infinity) > mark.lastSeq;
147622
147736
  return {
147623
147737
  layer: "chromium",
147624
147738
  readable: true,
147625
147739
  armed: true,
147626
147740
  stopped,
147627
- records: network.requestsAfter(mark.lastSeq).filter(({ seq }) => mark.stoppedSeq === void 0 || seq <= mark.stoppedSeq).map(({ record: record2 }) => fromChromium(record2))
147741
+ records: network.requestsAfter(mark.lastSeq).filter(({ seq }) => mark.stoppedSeq === void 0 || seq <= mark.stoppedSeq).map(({ record: record2 }) => fromChromium(record2)),
147742
+ ...evicted ? { note: EVICTED, gap: true } : {}
147628
147743
  };
147629
147744
  }
147630
147745
  };
@@ -147711,7 +147826,8 @@ function jsLayer(registry2, device, bundleId, startWindow) {
147711
147826
  armed: true,
147712
147827
  stopped,
147713
147828
  records: [],
147714
- note: "the app's JS runtime reloaded since the stop, which cleared its requests"
147829
+ note: "the app's JS runtime reloaded since the stop, which cleared its requests",
147830
+ gap: true
147715
147831
  };
147716
147832
  }
147717
147833
  const installed = await whileStarted(
@@ -147719,12 +147835,12 @@ function jsLayer(registry2, device, bundleId, startWindow) {
147719
147835
  );
147720
147836
  if ("note" in installed) return unreadable("js", installed.note);
147721
147837
  const install = installed.value;
147722
- return unreadable(
147723
- "js",
147724
- install.installed ? "the app's JS runtime had no interceptor (it reloaded, or its JavaScript had not loaded at the start), so the wait installed it: requests from now on are recorded, earlier ones in that runtime are missing" : `the interceptor did not install: ${install.reason}`
147725
- );
147838
+ const note2 = install.installed ? "the app's JS runtime had no interceptor (it reloaded, or its JavaScript had not loaded at the start), so the wait installed it: requests from now on are recorded, earlier ones in that runtime are missing" : `the interceptor did not install: ${install.reason}`;
147839
+ if (install.installed) capture.missed = note2;
147840
+ return unreadable("js", note2, false, install.installed);
147726
147841
  }
147727
147842
  let note;
147843
+ let gap = false;
147728
147844
  if (resume) {
147729
147845
  const resumed = await whileStarted(
147730
147846
  () => installNetworkInterceptor(dbg.cdp, payload, dbg.runtimeApp)
@@ -147732,6 +147848,8 @@ function jsLayer(registry2, device, bundleId, startWindow) {
147732
147848
  if ("note" in resumed) return unreadable("js", resumed.note);
147733
147849
  const install = resumed.value;
147734
147850
  note = install.installed ? "a stop's pause was still in the app's JS runtime, so the wait resumed the capture: requests sent while it was paused are missing" : `a stop's pause is still in the app's JS runtime, and the wait could not resume it: ${install.reason}`;
147851
+ gap = install.installed;
147852
+ if (install.installed) capture.missed = note;
147735
147853
  if (!install.installed) {
147736
147854
  return {
147737
147855
  layer: "js",
@@ -147744,16 +147862,25 @@ function jsLayer(registry2, device, bundleId, startWindow) {
147744
147862
  }
147745
147863
  } else if (mark.install !== null && answer.token !== mark.install) {
147746
147864
  note = "the app's JS runtime reloaded after the start, so its requests between the reload and the interceptor's reinstall are missing";
147865
+ gap = true;
147866
+ } else if (capture.missed !== void 0) {
147867
+ note = capture.missed;
147868
+ gap = true;
147747
147869
  } else if (pauseMissed) {
147748
147870
  note = "the stop's pause did not reach the app's JS runtime, which still records: requests after the stop count";
147749
147871
  }
147872
+ if (answer.lost === true) {
147873
+ note = note ? `${note}; ${JS_EVICTED}` : JS_EVICTED;
147874
+ gap = true;
147875
+ }
147750
147876
  return {
147751
147877
  layer: "js",
147752
147878
  readable: true,
147753
147879
  armed: true,
147754
147880
  stopped,
147755
147881
  records: (answer.entries ?? []).map(fromJs),
147756
- ...note ? { note } : {}
147882
+ ...note ? { note } : {},
147883
+ ...gap ? { gap: true } : {}
147757
147884
  };
147758
147885
  } catch (err) {
147759
147886
  const reason2 = classifyNotConnected(err);
@@ -147788,6 +147915,7 @@ function statusMatches(wanted, status) {
147788
147915
  return Math.floor(status / 100) === Number(wanted[0]);
147789
147916
  }
147790
147917
  function outcomeMatches(outcome, state3) {
147918
+ if (outcome === "sent") return true;
147791
147919
  if (outcome === "complete") return state3 === "complete";
147792
147920
  if (outcome === "failed") return state3 === "failed";
147793
147921
  return state3 === "complete" || state3 === "failed";
@@ -147838,7 +147966,7 @@ function describeCriteria(criteria) {
147838
147966
  criteria.method ? criteria.method.toUpperCase() : void 0,
147839
147967
  url2,
147840
147968
  criteria.status !== void 0 ? `status ${criteria.status}` : void 0,
147841
- criteria.outcome === "any" ? "complete or failed" : criteria.outcome
147969
+ criteria.outcome === "any" ? "complete or failed" : criteria.outcome === "sent" ? "sent (in any state)" : criteria.outcome
147842
147970
  ].filter(Boolean).join(", ");
147843
147971
  }
147844
147972
  function describeRecord(record2) {
@@ -147871,7 +147999,10 @@ var zodSchema45 = external_exports.object({
147871
147999
  external_exports.enum(STATUS_CLASSES),
147872
148000
  external_exports.coerce.number().int().min(100).max(599)
147873
148001
  ]).optional().describe('Exact HTTP status or class (e.g. "2xx").'),
147874
- outcome: external_exports.enum(["complete", "failed", "any"]).optional().describe("`complete` (default, incl. HTTP errors), `failed` (network error), or `any`."),
148002
+ outcome: external_exports.enum(["complete", "failed", "any", "sent"]).optional().describe(
148003
+ "`complete` includes HTTP error responses. `failed` matches network errors. `any` matches either. `sent` matches all states. Defaults to `sent` with `absent: true`, otherwise `complete`."
148004
+ ),
148005
+ absent: external_exports.boolean().optional().describe("Set to true to fail on the first match and require complete capture to pass."),
147875
148006
  timeoutMs: external_exports.number().int().positive().max(12e4).optional().describe(`Timeout in ms (default ${DEFAULT_TIMEOUT_MS4}).`),
147876
148007
  pollIntervalMs: external_exports.number().int().min(50).max(5e3).optional().describe(`Poll interval in ms (default ${DEFAULT_POLL_INTERVAL_MS2}).`)
147877
148008
  }).strict().superRefine((params, ctx) => {
@@ -147901,7 +148032,7 @@ function criteriaOf(params) {
147901
148032
  urlMatch: params.urlMatch ?? "contains",
147902
148033
  ...params.method !== void 0 ? { method: params.method } : {},
147903
148034
  ...params.status !== void 0 ? { status: params.status } : {},
147904
- outcome: params.outcome ?? "complete"
148035
+ outcome: params.outcome ?? (params.absent ? "sent" : "complete")
147905
148036
  };
147906
148037
  }
147907
148038
  function notStartedError(params) {
@@ -147922,17 +148053,23 @@ function createAwaitNetworkRequestTool(registry2) {
147922
148053
  return {
147923
148054
  // A literal, so scripts/extract-tools.mjs finds the description it scores.
147924
148055
  id: "await-network-request",
147925
- description: `Check for a matching HTTP request in the latest \`network-capture-start\` window (unsupported on physical iPhones and Vega; Chromium matches post-redirect URL/method).
147926
- Use when asserting or synchronizing on an API call after triggering a UI action.
147927
- Returns \`{ success, elapsed, match?, cause?, nearMisses?, layers? }\` (pass \`match.id\` to \`view-network-request-details\`). Fails with \`NETWORK_CAPTURE_NOT_STARTED\` if capture was not started; \`success: false\` fails e2e steps and stops \`run-sequence\`.`,
148056
+ description: `Wait for an HTTP request or check for no match with \`absent: true\`. Requires a \`network-capture-start\` window for the target. Unavailable on physical iPhones and Vega. On Chromium, match the final URL and method after redirects.
148057
+ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`note\` on failure. \`success: false\` fails an e2e step and stops \`run-sequence\`.`,
147928
148058
  zodSchema: zodSchema45,
147929
148059
  searchHint: "wait await network request http api call fetch xhr response status url match after capture start e2e assert",
147930
148060
  readOnly: true,
147931
148061
  longRunning: true,
147932
148062
  capability: CAPTURE_CAPABILITY,
147933
148063
  interaction: {
147934
- startedMsg: ({ params }) => `Waiting for a request to ${params.url}`,
147935
- completedMsg: ({ params, result }) => result.success && result.match ? `Request matched: ${result.match.method} ${result.match.url}${result.match.status !== void 0 ? ` ${result.match.status}` : ""}` : `No request to ${params.url} matched (${result.cause ?? "unmet"})`,
148064
+ startedMsg: ({ params }) => params.absent ? `Checking that no request to ${params.url} is sent` : `Waiting for a request to ${params.url}`,
148065
+ completedMsg: ({ params, result }) => {
148066
+ const sent = (match) => `${match.method} ${match.url}${match.status !== void 0 ? ` ${match.status}` : ""}`;
148067
+ if (params.absent) {
148068
+ if (result.success) return `No request to ${params.url} was sent`;
148069
+ return result.match ? `A request that must not be sent was: ${sent(result.match)}` : `Could not check that no request to ${params.url} is sent (${result.cause ?? "unmet"})`;
148070
+ }
148071
+ return result.success && result.match ? `Request matched: ${sent(result.match)}` : `No request to ${params.url} matched (${result.cause ?? "unmet"})`;
148072
+ },
147936
148073
  failedMsg: ({ failureSignal: failureSignal2 }) => `Failed while waiting for a network request: ${failureSignal2.error_code}`
147937
148074
  },
147938
148075
  // Each layer looks its service up itself, so the wait creates no native service.
@@ -147971,12 +148108,17 @@ Returns \`{ success, elapsed, match?, cause?, nearMisses?, layers? }\` (pass \`m
147971
148108
  let lastArmedJsAt;
147972
148109
  const jsBound = Math.max(pollIntervalMs, MIN_JS_READ_MS);
147973
148110
  const notesSeen = /* @__PURE__ */ new Map();
148111
+ const blind = /* @__PURE__ */ new Map();
147974
148112
  const keep = (read) => {
147975
148113
  latest.set(read.layer, read);
147976
148114
  if (read.note) {
147977
148115
  const seen = notesSeen.get(read.layer) ?? /* @__PURE__ */ new Set();
147978
148116
  notesSeen.set(read.layer, seen.add(read.note));
147979
148117
  }
148118
+ if (!blind.has(read.layer)) {
148119
+ if (read.gap) blind.set(read.layer, read.note ?? "it missed requests");
148120
+ else if (read.readable && !read.armed) blind.set(read.layer, read.note ?? "not armed");
148121
+ }
147980
148122
  if (!read.readable) return;
147981
148123
  latestReadable.set(read.layer, read);
147982
148124
  if (!read.armed) return;
@@ -147986,7 +148128,8 @@ Returns \`{ success, elapsed, match?, cause?, nearMisses?, layers? }\` (pass \`m
147986
148128
  let jsRead;
147987
148129
  const readJs = (layer, budgetMs) => {
147988
148130
  if (jsRead) return jsRead;
147989
- const read = layer.read(budgetMs).then((answer) => ({ ...answer, at: Date.now() })).finally(() => {
148131
+ const from2 = Date.now();
148132
+ const read = layer.read(budgetMs).then((answer) => ({ ...answer, from: from2, at: Date.now() })).finally(() => {
147990
148133
  if (jsRead === read) jsRead = void 0;
147991
148134
  });
147992
148135
  jsRead = read;
@@ -148004,6 +148147,7 @@ Returns \`{ success, elapsed, match?, cause?, nearMisses?, layers? }\` (pass \`m
148004
148147
  ...notes.length > 0 ? { note: notes.join("; ") } : {}
148005
148148
  };
148006
148149
  };
148150
+ const found = (match) => params.absent ? sentWhileAbsent(match) : success2(match);
148007
148151
  for (; ; ) {
148008
148152
  const atDeadline = Date.now() >= deadline;
148009
148153
  if (signal?.aborted) {
@@ -148011,15 +148155,33 @@ Returns \`{ success, elapsed, match?, cause?, nearMisses?, layers? }\` (pass \`m
148011
148155
  }
148012
148156
  const reads = [];
148013
148157
  for (const layer of native) {
148014
- const read = { ...await layer.read(0), at: Date.now() };
148158
+ const from2 = Date.now();
148159
+ const read = { ...await layer.read(0), from: from2, at: Date.now() };
148015
148160
  keep(read);
148016
148161
  reads.push(read);
148017
148162
  const match = firstMatch(criteria, read.records);
148018
- if (match) return success2(match);
148163
+ if (match) return found(match);
148019
148164
  }
148020
148165
  const remaining = deadline - Date.now();
148021
- if (js && (remaining > 0 || !latest.has("js"))) {
148022
- const bound = Math.min(jsBound, Math.max(1, remaining));
148166
+ const lastAbsentRead = params.absent === true && remaining <= 0;
148167
+ if (js && (remaining > 0 || !latest.has("js") || lastAbsentRead)) {
148168
+ if (lastAbsentRead && jsRead) {
148169
+ const pending = await settleWithin(jsRead, jsBound, signal);
148170
+ if (pending.type === "aborted") {
148171
+ return {
148172
+ success: false,
148173
+ elapsed: elapsed(),
148174
+ note: CANCELLED_NOTE,
148175
+ cause: "cancelled"
148176
+ };
148177
+ }
148178
+ if (pending.type === "value") {
148179
+ keep(pending.value);
148180
+ const match = firstMatch(criteria, pending.value.records);
148181
+ if (match) return found(match);
148182
+ }
148183
+ }
148184
+ const bound = lastAbsentRead ? jsBound : Math.min(jsBound, Math.max(1, remaining));
148023
148185
  const settled = await settleWithin(readJs(js, bound), bound, signal);
148024
148186
  if (settled.type === "aborted") {
148025
148187
  return { success: false, elapsed: elapsed(), note: CANCELLED_NOTE, cause: "cancelled" };
@@ -148028,11 +148190,12 @@ Returns \`{ success, elapsed, match?, cause?, nearMisses?, layers? }\` (pass \`m
148028
148190
  keep(settled.value);
148029
148191
  reads.push(settled.value);
148030
148192
  const match = firstMatch(criteria, settled.value.records);
148031
- if (match) return success2(match);
148193
+ if (match) return found(match);
148032
148194
  } else if (settled.type === "timeout" && bound < jsBound && latest.has("js")) {
148033
148195
  } else {
148034
148196
  const note = settled.type === "timeout" ? `the app's JS runtime did not answer within ${bound} ms` : `the read of the app's JS runtime failed: ${settled.error}`;
148035
148197
  const read = {
148198
+ from: Date.now() - bound,
148036
148199
  layer: "js",
148037
148200
  readable: false,
148038
148201
  armed: false,
@@ -148046,7 +148209,7 @@ Returns \`{ success, elapsed, match?, cause?, nearMisses?, layers? }\` (pass \`m
148046
148209
  }
148047
148210
  }
148048
148211
  if (reads.length === layers.length && reads.every((read) => read.readable && read.stopped && !read.records.some(isOpen2))) {
148049
- return timedOut3("unmet", true);
148212
+ return params.absent ? absenceVerdict(true) : timedOut3("unmet", true);
148050
148213
  }
148051
148214
  if (atDeadline) break;
148052
148215
  if (Date.now() >= deadline) continue;
@@ -148055,13 +148218,13 @@ Returns \`{ success, elapsed, match?, cause?, nearMisses?, layers? }\` (pass \`m
148055
148218
  return { success: false, elapsed: elapsed(), note: CANCELLED_NOTE, cause: "cancelled" };
148056
148219
  }
148057
148220
  }
148221
+ if (params.absent) return absenceVerdict(false);
148058
148222
  const now = Date.now();
148059
148223
  const tolerance = darkTailToleranceMs(pollIntervalMs);
148060
148224
  const fresh = lastArmedNativeAt !== void 0 && now - lastArmedNativeAt <= tolerance || lastArmedJsAt !== void 0 && now - lastArmedJsAt <= Math.max(tolerance, jsBound + pollIntervalMs);
148061
148225
  return timedOut3(fresh ? "unmet" : "unreadable", false);
148062
- function timedOut3(cause, allStopped) {
148063
- readSecretsAgain();
148064
- const summaries = layers.map(({ layer }) => {
148226
+ function layerSummaries() {
148227
+ return layers.map(({ layer }) => {
148065
148228
  const last = latest.get(layer);
148066
148229
  const readable = latestReadable.get(layer);
148067
148230
  return {
@@ -148073,11 +148236,66 @@ Returns \`{ success, elapsed, match?, cause?, nearMisses?, layers? }\` (pass \`m
148073
148236
  ...last?.note ? { note: redact2(last.note) } : {}
148074
148237
  };
148075
148238
  });
148076
- const seen = [...latestReadable.values()].flatMap((read) => read.records);
148077
- const misses = nearMisses(criteria, seen).map(shown);
148078
- const counts = summaries.map(
148239
+ }
148240
+ function requestCounts(summaries) {
148241
+ return summaries.map(
148079
148242
  (s) => `${s.layer} ${s.readable ? s.requests : "not read"}${s.armed ? "" : " (not armed)"}`
148080
148243
  ).join(", ");
148244
+ }
148245
+ function sentWhileAbsent(match) {
148246
+ readSecretsAgain();
148247
+ const shownMatch = shown(match);
148248
+ return {
148249
+ success: false,
148250
+ elapsed: elapsed(),
148251
+ cause: "unmet",
148252
+ match: shownMatch,
148253
+ note: `A request that must not be sent was captured since network-capture-start (forbidden: ${describeCriteria(criteria)}): ${describeRecord(shownMatch)}.`,
148254
+ layers: layerSummaries()
148255
+ };
148256
+ }
148257
+ function absenceVerdict(allStopped) {
148258
+ readSecretsAgain();
148259
+ const unproven = [];
148260
+ for (const { layer } of layers) {
148261
+ const read = latestReadable.get(layer);
148262
+ const why = blind.get(layer);
148263
+ if (why) unproven.push(`${layer}: ${redact2(why)}`);
148264
+ else if (!read)
148265
+ unproven.push(
148266
+ `${layer}: never read (${redact2(latest.get(layer)?.note ?? "no answer")})`
148267
+ );
148268
+ else if (!read.armed) unproven.push(`${layer}: not armed`);
148269
+ else if (!read.stopped && !allStopped && read.from < deadline) {
148270
+ unproven.push(
148271
+ `${layer}: last read ${deadline - read.from} ms before the end of the window (${redact2(latest.get(layer)?.note ?? "no answer since")})`
148272
+ );
148273
+ }
148274
+ }
148275
+ const summaries = layerSummaries();
148276
+ const window2 = allStopped ? "between network-capture-start and network-capture-stop" : `since network-capture-start, watched for ${timeoutMs} ms`;
148277
+ if (unproven.length > 0) {
148278
+ return {
148279
+ success: false,
148280
+ elapsed: elapsed(),
148281
+ cause: "unreadable",
148282
+ note: `No forbidden request was seen ${window2} (forbidden: ${describeCriteria(criteria)}), but not every capture layer recorded the whole window, so the absence is not proven: ${unproven.join("; ")}. Requests since the start: ${requestCounts(summaries)}.`,
148283
+ layers: summaries
148284
+ };
148285
+ }
148286
+ return {
148287
+ success: true,
148288
+ elapsed: elapsed(),
148289
+ note: `No forbidden request was captured ${window2} (forbidden: ${describeCriteria(criteria)}). Requests since the start: ${requestCounts(summaries)}.`,
148290
+ layers: summaries
148291
+ };
148292
+ }
148293
+ function timedOut3(cause, allStopped) {
148294
+ readSecretsAgain();
148295
+ const summaries = layerSummaries();
148296
+ const seen = [...latestReadable.values()].flatMap((read) => read.records);
148297
+ const misses = nearMisses(criteria, seen).map(shown);
148298
+ const counts = requestCounts(summaries);
148081
148299
  const head = allStopped ? `No request matched (wanted: ${describeCriteria(criteria)}): capture is stopped on every marked layer, so only the requests captured between network-capture-start and network-capture-stop were searched.` : `No request since network-capture-start matched within this ${timeoutMs} ms wait (wanted: ${describeCriteria(criteria)}).`;
148082
148300
  const notes = summaries.filter((s) => s.note).map((s) => `${s.layer}: ${s.note}`).join("; ");
148083
148301
  const note = [
@@ -168082,12 +168300,13 @@ function unmetWaitWarningFor(cause, block) {
168082
168300
  return unmetWaitWarning(block);
168083
168301
  }
168084
168302
  var UNMET_NETWORK_WAIT_WARNING = "recorded, but the wait never held: `await-network-request` returned success:false, and at replay an unmet wait FAILS the step. `toolResult.nearMisses` lists the closest requests and the criteria each missed: fix the matcher, or record the action that sends the request, then record the wait again. Delete the failed step after `e2e-finish-recording`, not mid-recording";
168085
- var UNREADABLE_NETWORK_WAIT_WARNING = "recorded, but no armed capture layer was read near the deadline, so the request was never judged and whether it is sent is UNKNOWN: `toolResult.layers` says why. Get the layer back (for example call network-capture-start again once the app's JavaScript has loaded) and record the wait again. Do not delete the step on this warning alone";
168303
+ var UNREADABLE_NETWORK_WAIT_WARNING = "recorded, but a capture layer could not be read through the window, so whether the request is sent is UNKNOWN: `toolResult.note` and `toolResult.layers` say why. Get the layer back (for example call network-capture-start again once the app's JavaScript has loaded) and record the wait again. Do not delete the step on this warning alone";
168086
168304
  var CANCELLED_NETWORK_WAIT_WARNING = "recorded, but this wait was cancelled before its deadline, so whether the request is sent is UNKNOWN: record the step again to find out";
168087
- function unmetNetworkWaitWarningFor(cause) {
168305
+ var FORBIDDEN_REQUEST_SENT_WARNING = "recorded, but a request that this `absent` wait forbids was sent: `await-network-request` returned success:false, and at replay the step FAILS the same way. `toolResult.match` is that request. If the app must not send it, the test found a real failure. Otherwise narrow the criteria or call network-capture-start after the action, then record the wait again";
168306
+ function unmetNetworkWaitWarningFor(cause, absent) {
168088
168307
  if (cause === "unreadable") return UNREADABLE_NETWORK_WAIT_WARNING;
168089
168308
  if (cause === "cancelled") return CANCELLED_NETWORK_WAIT_WARNING;
168090
- return UNMET_NETWORK_WAIT_WARNING;
168309
+ return absent ? FORBIDDEN_REQUEST_SENT_WARNING : UNMET_NETWORK_WAIT_WARNING;
168091
168310
  }
168092
168311
  function indeterminateReasonCaveat(udid) {
168093
168312
  if (platformOf(udid) !== "ios") return "";
@@ -168700,7 +168919,7 @@ Returns \`{ message, toolResult, stepCount, recorded?, savedTo }\`. Fails if no
168700
168919
  if (isUnmetWaitResult(command, toolResult)) {
168701
168920
  const cause = unmetWaitCause(command, toolResult);
168702
168921
  waitWarning = {
168703
- warning: command === AWAIT_NETWORK_REQUEST_TOOL_ID ? unmetNetworkWaitWarningFor(cause) : unmetWaitWarningFor(cause, block),
168922
+ warning: command === AWAIT_NETWORK_REQUEST_TOOL_ID ? unmetNetworkWaitWarningFor(cause, args.absent === true) : unmetWaitWarningFor(cause, block),
168704
168923
  kind: "wait"
168705
168924
  };
168706
168925
  } else if (command === AWAIT_UI_ELEMENT_TOOL_ID) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.35.1-next.38",
3
+ "version": "0.35.1-next.39",
4
4
  "mcpName": "io.github.software-mansion/argent",
5
5
  "description": "MCP server for iOS Simulator, Android Emulator, Chromium app and Mac app control",
6
6
  "license": "Apache-2.0",
@@ -98,5 +98,5 @@
98
98
  "vitest": "^5.0.5",
99
99
  "yaml": "^2.9.1"
100
100
  },
101
- "gitHead": "9193a99fada78af831f7240242b84b2e04fab45b"
101
+ "gitHead": "dd000c387a7102248dd635caf5a556bb5f656446"
102
102
  }
@@ -157,9 +157,10 @@ A warning does not reject the step. If `e2e-finish-recording` reports dropped wa
157
157
 
158
158
  On iOS simulators, Android, Mac apps, and Chromium, use `e2e-add-step` to record `network-capture-start`, the action, `await-network-request`, and `network-capture-stop` in that order. Put capture start after launch and the first-screen wait. A start before `launch:` makes the test a fragment. Use [Inspect network requests](../../argent-metro-debugger/SKILL.md#inspect-network-requests) for platform setup.
159
159
 
160
+ - Use `absent: true` for a check that should fail on a match. Keep start before the action to catch requests the action sends. For later traffic only, record the action first and allow any earlier native requests to reach capture before starting a new window.
160
161
  - Keep the wait as a raw `tool:` step. A log listing can pass with an empty log. Match a part of the URL that contains no secret. On Android, capture can slow the app: start just before the action and stop right after the wait. When collecting several related requests, stop after the last check.
161
162
  - If the recorder reports `NETWORK_CAPTURE_NOT_STARTED`, record the missing start, then repeat and record the action and the wait. Replay only uses recorded steps.
162
- - If the recorder saves a failed wait, inspect `toolResult.nearMisses` for an `unmet` wait. Restore capture and repeat the action for `unreadable`. Record a new wait if cancelled. Remove superseded steps after `e2e-finish-recording`.
163
+ - If a recorded wait reports `unmet`, inspect `toolResult.nearMisses` for a missing match or `toolResult.match` for a forbidden request. For `unreadable`, restore capture from the result's notes and record a new window with the action and wait. Record a new wait if cancelled. Remove superseded steps after `e2e-finish-recording`.
163
164
  - On replay, verify the relevant layer's `armed` and `reason` in the start and stop results. On Chromium, stop can report `armed: false` even when there was no window. If a failed step skips the stop, stop capture before replaying.
164
165
 
165
166
  On Vega, call `view-network-logs` before the action to start JavaScript capture. Read the log again after the action to inspect the requests. `await-network-request` is unavailable on Vega.
@@ -43,9 +43,9 @@ If `debugger-reload-metro` fails to reload the Mac app, use `restart-app` for an
43
43
  ### Inspect network requests
44
44
 
45
45
  1. Choose the log. Use `view-network-logs` for JavaScript or the active Chromium tab and `native-network-logs` for OkHttp or URLSession. The two logs can show the same request.
46
- 2. Start before triggering the request. On iOS simulators, Android, and Mac apps, call `network-capture-start`. Select `layer: "js"` or `layer: "native"` when you only need one. Check that the layer you need is armed. On Vega, read the JS log to start. On Chromium, read the log to attach or call start if you need a window for a request check.
47
- 3. After the action, use `await-network-request` to check for a specific request or read the logs to explore traffic. On Vega, use the log. On Chromium, use a valid placeholder bundle ID such as `argent.capture` for start, stop, and wait. The log includes traffic outside the window. For redirects, Chromium waits match the final URL and method. Other layers match the URL the app requested.
48
- 4. For an `unmet` wait, check the action and matcher against the near misses. For `unreadable`, follow the layer notes before repeating the action. A wait can restore recording while a JS window is active, but may miss requests sent before it reconnects.
46
+ 2. Open the capture window with `network-capture-start`. Start before the action to include its requests, or after it to check only later traffic. Allow earlier native requests to reach capture first in that case. Select `layer: "js"` or `layer: "native"` if you need only one, and check that it armed. On Vega, read the JS log to start capture. On Chromium, use a placeholder bundle ID such as `argent.capture` for start, stop, and wait. Read the log directly to attach without a window.
47
+ 3. Use `await-network-request` to check for a match, or set `absent: true` to check that none appears. For Chromium redirects, match the final URL and method. On Vega or when exploring traffic, read the log. Chromium logs include traffic outside the window.
48
+ 4. For `unmet`, check `nearMisses` for a missing match or `match` for a forbidden request. For `unreadable`, follow the layer notes, start a new window once capture is ready, and repeat the check. A JavaScript reconnection can resume capture with a gap.
49
49
  5. Pass an ID from the log or wait to `view-network-request-details`. Read Android native bodies you need before stopping. Stop the capture you started with `network-capture-stop`. Check `armed` and `reason` to confirm what stopped. On Chromium, a stop closes the window and leaves tab logging active.
50
50
 
51
51
  Keep the original `udid` for start, wait, stop, and native reads. On iOS simulators and Android, if shared Metro requires a logical ID, use it as `logicalDeviceId` on start and stop and as `device_id` on JS reads. For Mac apps, keep `macos-app-<bundle id>` for capture and JS reads, even on shared Metro. Check the project's Metro start script if the port is unclear. Pass the same port throughout when it differs from the device default. The wait reuses the target from start.