@swmansion/argent 0.35.1-next.40 → 0.35.1-next.42
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 +1 -1
- package/dist/installer.mjs +1 -1
- package/dist/mcp-server.mjs +1 -1
- package/dist/tool-args.generated.d.ts +46 -1
- package/dist/tool-server.cjs +650 -71
- package/package.json +2 -2
- package/skills/argent-create-e2e/references/live-authoring.md +2 -1
- package/skills/argent-metro-debugger/SKILL.md +2 -2
package/dist/cli-cmds.mjs
CHANGED
|
@@ -38596,7 +38596,7 @@ function isCi(env = process.env) {
|
|
|
38596
38596
|
var SESSION_ID2 = randomUUID5();
|
|
38597
38597
|
function readCliVersion() {
|
|
38598
38598
|
if (true) {
|
|
38599
|
-
return "0.35.1-next.
|
|
38599
|
+
return "0.35.1-next.41";
|
|
38600
38600
|
}
|
|
38601
38601
|
return "0.0.0";
|
|
38602
38602
|
}
|
package/dist/installer.mjs
CHANGED
|
@@ -17118,7 +17118,7 @@ function isCi(env = process.env) {
|
|
|
17118
17118
|
var SESSION_ID = randomUUID4();
|
|
17119
17119
|
function readCliVersion() {
|
|
17120
17120
|
if (true) {
|
|
17121
|
-
return "0.35.1-next.
|
|
17121
|
+
return "0.35.1-next.41";
|
|
17122
17122
|
}
|
|
17123
17123
|
return "0.0.0";
|
|
17124
17124
|
}
|
package/dist/mcp-server.mjs
CHANGED
|
@@ -38155,7 +38155,7 @@ async function startMcpServer(options) {
|
|
|
38155
38155
|
const autoDescribeOn = autoDescribeEnabled();
|
|
38156
38156
|
const whatsNewOn = whatsNewEnabled();
|
|
38157
38157
|
const installedVersion = getInstalledVersion();
|
|
38158
|
-
const highlightsVersion = true ? "0.35.1-next.
|
|
38158
|
+
const highlightsVersion = true ? "0.35.1-next.41" : installedVersion;
|
|
38159
38159
|
const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
|
|
38160
38160
|
const trees = createTreeMemory();
|
|
38161
38161
|
const screenshots = createScreenshotMemory();
|
|
@@ -20,7 +20,7 @@ export interface ArgentToolArgs {
|
|
|
20
20
|
udid: string;
|
|
21
21
|
/** `bundleId` used in `network-capture-start` (Chromium: placeholder like `argent.capture`). */
|
|
22
22
|
bundleId: string;
|
|
23
|
-
/** URL text
|
|
23
|
+
/** URL text or pattern. `{{secret:NAME}}` expands to the secret value. */
|
|
24
24
|
url: string;
|
|
25
25
|
/** `contains` (default) / `equals` (case-insensitive) or `matches` (case-sensitive JS regex). */
|
|
26
26
|
urlMatch?: "contains" | "equals" | "matches";
|
|
@@ -30,6 +30,51 @@ export interface ArgentToolArgs {
|
|
|
30
30
|
status?: "1xx" | "2xx" | "3xx" | "4xx" | "5xx" | number;
|
|
31
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
32
|
outcome?: "complete" | "failed" | "any" | "sent";
|
|
33
|
+
/** Check one request header using exactly one of `equals`, `contains`, `matches`, or `exists`. */
|
|
34
|
+
header?: {
|
|
35
|
+
/** Case-insensitive header name, such as `authorization`. Names of only digits are invalid. */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Dot-separated JWT payload claim, such as `consents.analytics`. Accepts a `Bearer ` prefix and reads the payload without validating the signature. */
|
|
38
|
+
claim?: string;
|
|
39
|
+
/** Exact, case-sensitive match. Compares numbers and booleans as text. */
|
|
40
|
+
equals?: string | number | boolean;
|
|
41
|
+
/** Case-sensitive substring. */
|
|
42
|
+
contains?: string;
|
|
43
|
+
/** Case-sensitive JavaScript regular expression. */
|
|
44
|
+
matches?: string;
|
|
45
|
+
/** Use true for a present value or false for a missing or null value. */
|
|
46
|
+
exists?: boolean;
|
|
47
|
+
};
|
|
48
|
+
/** Check a request body using exactly one of `equals`, `contains`, `matches`, or `exists`. */
|
|
49
|
+
requestBody?: {
|
|
50
|
+
/** JSON field specified as keys and array indexes joined by dots, e.g. `data.items.0.id`. Omit to use the whole body. */
|
|
51
|
+
path?: string;
|
|
52
|
+
/** Dot-separated JWT payload claim, such as `consents.analytics`. Accepts a `Bearer ` prefix and reads the payload without validating the signature. */
|
|
53
|
+
claim?: string;
|
|
54
|
+
/** Exact, case-sensitive match. Compares numbers and booleans as text. */
|
|
55
|
+
equals?: string | number | boolean;
|
|
56
|
+
/** Case-sensitive substring. */
|
|
57
|
+
contains?: string;
|
|
58
|
+
/** Case-sensitive JavaScript regular expression. */
|
|
59
|
+
matches?: string;
|
|
60
|
+
/** Use true for a present value or false for a missing or null value. */
|
|
61
|
+
exists?: boolean;
|
|
62
|
+
};
|
|
63
|
+
/** Use the same check as `requestBody` on a finished response. */
|
|
64
|
+
responseBody?: {
|
|
65
|
+
/** JSON field specified as keys and array indexes joined by dots, e.g. `data.items.0.id`. Omit to use the whole body. */
|
|
66
|
+
path?: string;
|
|
67
|
+
/** Dot-separated JWT payload claim, such as `consents.analytics`. Accepts a `Bearer ` prefix and reads the payload without validating the signature. */
|
|
68
|
+
claim?: string;
|
|
69
|
+
/** Exact, case-sensitive match. Compares numbers and booleans as text. */
|
|
70
|
+
equals?: string | number | boolean;
|
|
71
|
+
/** Case-sensitive substring. */
|
|
72
|
+
contains?: string;
|
|
73
|
+
/** Case-sensitive JavaScript regular expression. */
|
|
74
|
+
matches?: string;
|
|
75
|
+
/** Use true for a present value or false for a missing or null value. */
|
|
76
|
+
exists?: boolean;
|
|
77
|
+
};
|
|
33
78
|
/** Set to true to fail on the first match and require complete capture to pass. */
|
|
34
79
|
absent?: boolean;
|
|
35
80
|
/** Timeout in ms (default 10000). */
|
package/dist/tool-server.cjs
CHANGED
|
@@ -72982,7 +72982,7 @@ function isCi(env = process.env) {
|
|
|
72982
72982
|
var SESSION_ID = (0, import_node_crypto3.randomUUID)();
|
|
72983
72983
|
function readCliVersion() {
|
|
72984
72984
|
if (true) {
|
|
72985
|
-
return "0.35.1-next.
|
|
72985
|
+
return "0.35.1-next.41";
|
|
72986
72986
|
}
|
|
72987
72987
|
return "0.0.0";
|
|
72988
72988
|
}
|
|
@@ -76032,8 +76032,11 @@ function isRecord(value) {
|
|
|
76032
76032
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
76033
76033
|
}
|
|
76034
76034
|
function lookupOutput(output2, path77) {
|
|
76035
|
-
|
|
76036
|
-
|
|
76035
|
+
return lookupPath(output2, path77, "output");
|
|
76036
|
+
}
|
|
76037
|
+
function lookupPath(root, path77, rootName) {
|
|
76038
|
+
let node2 = root;
|
|
76039
|
+
let walked = rootName;
|
|
76037
76040
|
for (const segment of path77.split(".")) {
|
|
76038
76041
|
if (Array.isArray(node2)) {
|
|
76039
76042
|
const index = /^\d+$/.test(segment) ? Number(segment) : -1;
|
|
@@ -76121,15 +76124,23 @@ function resolveOutputValue(text, output2) {
|
|
|
76121
76124
|
return structuredClone(value);
|
|
76122
76125
|
}
|
|
76123
76126
|
var OUTPUT_CHECK_TESTS = ["exists", "equals", "contains", "matches"];
|
|
76127
|
+
function isValuePath(path77) {
|
|
76128
|
+
return typeof path77 === "string" && PATH_RE.test(path77);
|
|
76129
|
+
}
|
|
76124
76130
|
function outputPathProblem(path77) {
|
|
76125
|
-
if (
|
|
76131
|
+
if (isValuePath(path77)) return void 0;
|
|
76126
76132
|
return "output needs a path of keys and array indexes joined by dots, without braces, e.g. `output: user.id`";
|
|
76127
76133
|
}
|
|
76128
76134
|
function evaluateOutputCheck(check3, output2) {
|
|
76129
|
-
|
|
76130
|
-
|
|
76131
|
-
|
|
76132
|
-
|
|
76135
|
+
return evaluateValueCheck(
|
|
76136
|
+
check3.test,
|
|
76137
|
+
check3.expected,
|
|
76138
|
+
lookupOutput(output2, check3.path),
|
|
76139
|
+
`output.${check3.path}`
|
|
76140
|
+
);
|
|
76141
|
+
}
|
|
76142
|
+
function evaluateValueCheck(test, expected, hit, at) {
|
|
76143
|
+
if (test === "exists") {
|
|
76133
76144
|
const ok2 = hit.found === expected;
|
|
76134
76145
|
return { ok: ok2, reason: hit.found ? `${at} is set` : hit.why };
|
|
76135
76146
|
}
|
|
@@ -76143,7 +76154,7 @@ function evaluateOutputCheck(check3, output2) {
|
|
|
76143
76154
|
}
|
|
76144
76155
|
const actual = String(value);
|
|
76145
76156
|
const want = String(expected);
|
|
76146
|
-
const ok =
|
|
76157
|
+
const ok = test === "equals" ? actual === want : test === "contains" ? actual.includes(want) : new RegExp(want).test(actual);
|
|
76147
76158
|
return { ok, reason: `${at} is ${JSON.stringify(actual)}` };
|
|
76148
76159
|
}
|
|
76149
76160
|
|
|
@@ -105529,6 +105540,30 @@ function createNetworkManager(deps) {
|
|
|
105529
105540
|
let mark;
|
|
105530
105541
|
let conditions = null;
|
|
105531
105542
|
const bodyBytesLeft = /* @__PURE__ */ new WeakMap();
|
|
105543
|
+
const hopsOf = /* @__PURE__ */ new WeakMap();
|
|
105544
|
+
function noteHeaders(rec, change) {
|
|
105545
|
+
const of = hopsOf.get(rec) ?? { set: [], wire: [], noWire: /* @__PURE__ */ new Set() };
|
|
105546
|
+
hopsOf.set(rec, of);
|
|
105547
|
+
if (change.kind === "set") {
|
|
105548
|
+
of.set.push(change.headers ?? {});
|
|
105549
|
+
if (change.previousHasWire === false) of.noWire.add(of.set.length - 2);
|
|
105550
|
+
} else if (change.kind === "wire") {
|
|
105551
|
+
of.wire.push(change.headers ?? {});
|
|
105552
|
+
} else if (change.kind === "response") {
|
|
105553
|
+
of.responded = true;
|
|
105554
|
+
if (change.hasExtraInfo === false) of.none = true;
|
|
105555
|
+
}
|
|
105556
|
+
const hop = of.set.length - 1;
|
|
105557
|
+
if (hop < 0) return;
|
|
105558
|
+
let index = hop;
|
|
105559
|
+
for (const skipped of of.noWire) if (skipped < hop) index--;
|
|
105560
|
+
const wire = of.wire[index];
|
|
105561
|
+
rec.requestHeaders = { ...of.set[hop], ...wire };
|
|
105562
|
+
const ended = rec.finished || rec.failed;
|
|
105563
|
+
const pending = !ended && !of.none && (wire === void 0 || !of.responded);
|
|
105564
|
+
if (pending) rec.wireHeadersPending = true;
|
|
105565
|
+
else delete rec.wireHeadersPending;
|
|
105566
|
+
}
|
|
105532
105567
|
function record2(requestId) {
|
|
105533
105568
|
let rec = byId.get(requestId);
|
|
105534
105569
|
if (!rec) {
|
|
@@ -105554,14 +105589,19 @@ function createNetworkManager(deps) {
|
|
|
105554
105589
|
const rec = record2(params.requestId);
|
|
105555
105590
|
rec.method = r.method ?? rec.method;
|
|
105556
105591
|
rec.url = r.url ?? rec.url;
|
|
105557
|
-
if (r.headers) rec.requestHeaders = { ...rec.requestHeaders ?? {}, ...r.headers };
|
|
105558
105592
|
if (r.postData != null) rec.postData = r.postData;
|
|
105593
|
+
if (r.hasPostData) rec.hasPostData = true;
|
|
105559
105594
|
rec.resourceType = params.type ?? rec.resourceType;
|
|
105560
105595
|
rec.initiator = params.initiator ?? rec.initiator;
|
|
105561
105596
|
rec.startTs = params.timestamp ?? rec.startTs;
|
|
105562
105597
|
if (params.wallTime) {
|
|
105563
105598
|
rec.startedDateTime = new Date(params.wallTime * 1e3).toISOString();
|
|
105564
105599
|
}
|
|
105600
|
+
noteHeaders(rec, {
|
|
105601
|
+
kind: "set",
|
|
105602
|
+
headers: r.headers,
|
|
105603
|
+
...params.redirectResponse ? { previousHasWire: params.redirectHasExtraInfo } : {}
|
|
105604
|
+
});
|
|
105565
105605
|
break;
|
|
105566
105606
|
}
|
|
105567
105607
|
case "Network.responseReceived": {
|
|
@@ -105573,6 +105613,10 @@ function createNetworkManager(deps) {
|
|
|
105573
105613
|
if (resp.headers) rec.responseHeaders = { ...rec.responseHeaders ?? {}, ...resp.headers };
|
|
105574
105614
|
rec.fromCache = resp.fromDiskCache;
|
|
105575
105615
|
rec.resourceType = params.type ?? rec.resourceType;
|
|
105616
|
+
noteHeaders(rec, {
|
|
105617
|
+
kind: "response",
|
|
105618
|
+
hasExtraInfo: params.hasExtraInfo
|
|
105619
|
+
});
|
|
105576
105620
|
const length = params.type === "Fetch" ? unreadBodyLength(resp.headers) : void 0;
|
|
105577
105621
|
if (length !== void 0) bodyBytesLeft.set(rec, length);
|
|
105578
105622
|
break;
|
|
@@ -105588,6 +105632,7 @@ function createNetworkManager(deps) {
|
|
|
105588
105632
|
bodyBytesLeft.set(rec, after);
|
|
105589
105633
|
if (after <= 0 && !rec.finished) {
|
|
105590
105634
|
rec.finished = true;
|
|
105635
|
+
noteHeaders(rec, { kind: "ended" });
|
|
105591
105636
|
const at = params.timestamp;
|
|
105592
105637
|
if (rec.startTs && at !== void 0) rec.durationMs = (at - rec.startTs) * 1e3;
|
|
105593
105638
|
}
|
|
@@ -105597,11 +105642,11 @@ function createNetworkManager(deps) {
|
|
|
105597
105642
|
// The *ExtraInfo events carry on-the-wire headers (Authorization, Set-Cookie, …)
|
|
105598
105643
|
// the base events omit, and may arrive before them — hence `record()`, not `get()`.
|
|
105599
105644
|
case "Network.requestWillBeSentExtraInfo": {
|
|
105600
|
-
const
|
|
105601
|
-
|
|
105602
|
-
|
|
105603
|
-
|
|
105604
|
-
}
|
|
105645
|
+
const rec = record2(params.requestId);
|
|
105646
|
+
noteHeaders(rec, {
|
|
105647
|
+
kind: "wire",
|
|
105648
|
+
headers: params.headers
|
|
105649
|
+
});
|
|
105605
105650
|
break;
|
|
105606
105651
|
}
|
|
105607
105652
|
case "Network.responseReceivedExtraInfo": {
|
|
@@ -105616,6 +105661,7 @@ function createNetworkManager(deps) {
|
|
|
105616
105661
|
const rec = byId.get(params.requestId);
|
|
105617
105662
|
if (rec) {
|
|
105618
105663
|
rec.finished = true;
|
|
105664
|
+
noteHeaders(rec, { kind: "ended" });
|
|
105619
105665
|
rec.encodedDataLength = params.encodedDataLength;
|
|
105620
105666
|
if (rec.startTs) rec.durationMs = (params.timestamp - rec.startTs) * 1e3;
|
|
105621
105667
|
}
|
|
@@ -105625,6 +105671,7 @@ function createNetworkManager(deps) {
|
|
|
105625
105671
|
const rec = byId.get(params.requestId);
|
|
105626
105672
|
if (rec) {
|
|
105627
105673
|
rec.failed = true;
|
|
105674
|
+
noteHeaders(rec, { kind: "ended" });
|
|
105628
105675
|
rec.errorText = params.errorText;
|
|
105629
105676
|
rec.resourceType = params.type ?? rec.resourceType;
|
|
105630
105677
|
}
|
|
@@ -131192,6 +131239,8 @@ var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
|
|
|
131192
131239
|
// Expo hands its native request the body as bytes: they show as text when they are UTF-8.
|
|
131193
131240
|
var post = utf8Text(entry.postBytes);
|
|
131194
131241
|
entry.request.postData = post === undefined ? '[binary ' + entry.postSize + ' bytes]' : post;
|
|
131242
|
+
// Without a decoder, the bytes may be text.
|
|
131243
|
+
if (post === undefined) entry.request.postDataShown = typeof TextDecoder === 'function' ? 'binary' : 'bytes';
|
|
131195
131244
|
if (post !== undefined && entry.postSize > BODY_CAP) entry.request.postDataTruncated = true;
|
|
131196
131245
|
delete entry.postBytes;
|
|
131197
131246
|
delete entry.postSize;
|
|
@@ -131212,21 +131261,26 @@ var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
|
|
|
131212
131261
|
}
|
|
131213
131262
|
g.__argent_network_decode = decodeBodies;
|
|
131214
131263
|
|
|
131215
|
-
// What a request body shows,
|
|
131264
|
+
// What a request body shows, whether that is only its start, and what stands in for a body
|
|
131265
|
+
// that is not text (shown: 'form', 'blob' or 'binary').
|
|
131216
131266
|
function describeBody(body) {
|
|
131217
|
-
var text;
|
|
131267
|
+
var text, shown;
|
|
131218
131268
|
try {
|
|
131219
131269
|
if (body == null) return undefined;
|
|
131220
131270
|
if (typeof body === 'string') text = body;
|
|
131221
|
-
else if (typeof FormData === 'function' && body instanceof FormData) text = describeFormData(body);
|
|
131222
|
-
else if (typeof Blob === 'function' && body instanceof Blob) text = '[Blob ' + body.size + ' bytes]';
|
|
131271
|
+
else if (typeof FormData === 'function' && body instanceof FormData) { text = describeFormData(body); shown = 'form'; }
|
|
131272
|
+
else if (typeof Blob === 'function' && body instanceof Blob) { text = '[Blob ' + body.size + ' bytes]'; shown = 'blob'; }
|
|
131223
131273
|
else if (typeof Uint8Array === 'function' && body instanceof Uint8Array) return { bytes: keepBytes(body), size: body.byteLength };
|
|
131224
131274
|
else if (typeof ArrayBuffer === 'function' && (body instanceof ArrayBuffer || ArrayBuffer.isView(body))) {
|
|
131225
131275
|
text = '[binary ' + body.byteLength + ' bytes]';
|
|
131276
|
+
// Bytes the interceptor does not read, which may be text.
|
|
131277
|
+
shown = 'bytes';
|
|
131226
131278
|
}
|
|
131227
131279
|
} catch (e) {}
|
|
131228
131280
|
if (text === undefined) return undefined;
|
|
131229
|
-
|
|
131281
|
+
var out = text.length > BODY_CAP ? { text: text.slice(0, BODY_CAP), cut: true } : { text: text, cut: false };
|
|
131282
|
+
if (shown) out.shown = shown;
|
|
131283
|
+
return out;
|
|
131230
131284
|
}
|
|
131231
131285
|
|
|
131232
131286
|
function createRecord(resourceType, method, url, headers, body, startedAt) {
|
|
@@ -131246,6 +131300,7 @@ var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
|
|
|
131246
131300
|
} else if (postData) {
|
|
131247
131301
|
entry.request.postData = postData.text;
|
|
131248
131302
|
if (postData.cut) entry.request.postDataTruncated = true;
|
|
131303
|
+
if (postData.shown) entry.request.postDataShown = postData.shown;
|
|
131249
131304
|
}
|
|
131250
131305
|
log.push(entry);
|
|
131251
131306
|
byId[entry.requestId] = entry;
|
|
@@ -132146,7 +132201,7 @@ function metroFilter(metroPort2) {
|
|
|
132146
132201
|
return typeof u === 'string' && (u.indexOf('://localhost:${metroPort2}') !== -1 || u.indexOf('://127.0.0.1:${metroPort2}') !== -1);
|
|
132147
132202
|
}`;
|
|
132148
132203
|
}
|
|
132149
|
-
function makeNetworkWaitReadScript(mark, metroPort2) {
|
|
132204
|
+
function makeNetworkWaitReadScript(mark, metroPort2, withHeaders = false) {
|
|
132150
132205
|
return `(function() {
|
|
132151
132206
|
var g = globalThis;
|
|
132152
132207
|
var xhr = typeof g.XMLHttpRequest === 'function';
|
|
@@ -132184,7 +132239,7 @@ function makeNetworkWaitReadScript(mark, metroPort2) {
|
|
|
132184
132239
|
status: e.response ? e.response.status : undefined,
|
|
132185
132240
|
durationMs: e.durationMs,
|
|
132186
132241
|
errorText: e.errorText,
|
|
132187
|
-
timestamp: e.timestamp
|
|
132242
|
+
timestamp: e.timestamp${withHeaders ? ",\n headers: e.request ? e.request.headers : undefined" : ""}
|
|
132188
132243
|
});
|
|
132189
132244
|
}
|
|
132190
132245
|
return JSON.stringify({
|
|
@@ -145807,6 +145862,134 @@ async function readNativeBody(read, framing, redact2) {
|
|
|
145807
145862
|
}
|
|
145808
145863
|
return body.truncated ? cutByAgent(text, mimeType, kept.length, framing, redact2, body.incomplete) : truncateBody(text, mimeType, redact2);
|
|
145809
145864
|
}
|
|
145865
|
+
var CUT_AT_CAPTURE = "the capture kept only the start of the body";
|
|
145866
|
+
async function nativeBodyText(record2, bodies, kind) {
|
|
145867
|
+
const id = record2.id;
|
|
145868
|
+
if (kind === "request") {
|
|
145869
|
+
if (!record2.request.hasPostData) return { kind: "none" };
|
|
145870
|
+
const bodyHeaders = record2.redirects?.[0]?.requestHeaders ?? record2.request.wireHeaders ?? {};
|
|
145871
|
+
const requestHeader = (name) => headerValue(bodyHeaders, name) || headerValue(record2.request.headers, name);
|
|
145872
|
+
return decodedNativeText(() => bodies.requestPostData(id), {
|
|
145873
|
+
contentType: requestHeader("content-type"),
|
|
145874
|
+
contentEncoding: requestHeader("content-encoding")
|
|
145875
|
+
});
|
|
145876
|
+
}
|
|
145877
|
+
if (record2.state !== "complete" || !record2.response) {
|
|
145878
|
+
return { kind: "unknown", reason: "the response has not finished", final: false };
|
|
145879
|
+
}
|
|
145880
|
+
if (record2.encodedDataLength === 0) return { kind: "none" };
|
|
145881
|
+
return decodedNativeText(() => bodies.responseBody(id), {
|
|
145882
|
+
mimeType: record2.response.mimeType,
|
|
145883
|
+
contentType: headerValue(record2.response.headers, "content-type"),
|
|
145884
|
+
// An iOS or Mac app response body is read decoded, so its Content-Encoding is not applied again.
|
|
145885
|
+
contentEncoding: record2.layer === "ios-native" || record2.layer === "macos-native" ? "" : headerValue(record2.response.headers, "content-encoding")
|
|
145886
|
+
});
|
|
145887
|
+
}
|
|
145888
|
+
async function decodedNativeText(read, framing) {
|
|
145889
|
+
const mimeType = framing.mimeType ?? framing.contentType.split(";")[0].trim();
|
|
145890
|
+
let body;
|
|
145891
|
+
try {
|
|
145892
|
+
body = await read();
|
|
145893
|
+
} catch (err) {
|
|
145894
|
+
return {
|
|
145895
|
+
kind: "unknown",
|
|
145896
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
145897
|
+
final: false
|
|
145898
|
+
};
|
|
145899
|
+
}
|
|
145900
|
+
if (!body.available) return { kind: "unknown", reason: body.reason ?? "no body", final: false };
|
|
145901
|
+
if (body.truncated || body.incomplete) {
|
|
145902
|
+
return { kind: "unknown", reason: CUT_AT_CAPTURE, final: true };
|
|
145903
|
+
}
|
|
145904
|
+
const tooLarge = {
|
|
145905
|
+
kind: "unknown",
|
|
145906
|
+
reason: `the body decodes to more than ${MAX_DECODED_BODY_BYTES / (1024 * 1024)} MiB`,
|
|
145907
|
+
final: true
|
|
145908
|
+
};
|
|
145909
|
+
const binary = { kind: "binary", mimeType };
|
|
145910
|
+
const codings = contentCodings(framing.contentEncoding).length > 0;
|
|
145911
|
+
if (body.inlineChars !== void 0) {
|
|
145912
|
+
if (BINARY_BODY_TYPES.test(mimeType.toLowerCase())) return binary;
|
|
145913
|
+
if (!codings)
|
|
145914
|
+
return { kind: "text", text: inDeclaredCharset(body.body, framing.contentType, false) };
|
|
145915
|
+
} else if (!body.base64Encoded && !codings) {
|
|
145916
|
+
return { kind: "text", text: inDeclaredCharset(body.body, framing.contentType, false) };
|
|
145917
|
+
}
|
|
145918
|
+
const kept = Buffer.from(body.body, body.base64Encoded ? "base64" : "utf8");
|
|
145919
|
+
const bytes = decodeContent2(kept, framing.contentEncoding);
|
|
145920
|
+
if (!bytes) return tooLarge;
|
|
145921
|
+
if (!body.base64Encoded && bytes === kept) {
|
|
145922
|
+
return { kind: "text", text: inDeclaredCharset(body.body, framing.contentType, false) };
|
|
145923
|
+
}
|
|
145924
|
+
const text = decodeText(bytes, charsetOf(framing.contentType), false);
|
|
145925
|
+
return text === null ? binary : { kind: "text", text };
|
|
145926
|
+
}
|
|
145927
|
+
var PLACEHOLDER_BODY = /^\[(FormData\]|Blob \d+ bytes\]$|binary \d+ bytes\]$)/;
|
|
145928
|
+
function bodiless(method, status) {
|
|
145929
|
+
return method?.toUpperCase() === "HEAD" || status === 204 || status === 304 || status !== void 0 && status >= 100 && status < 200;
|
|
145930
|
+
}
|
|
145931
|
+
function jsBodyText(entry, kind) {
|
|
145932
|
+
if (kind === "request") {
|
|
145933
|
+
const post = entry.request?.postData;
|
|
145934
|
+
if (post == null) return { kind: "none" };
|
|
145935
|
+
const shown = entry.request?.postDataShown ?? (PLACEHOLDER_BODY.test(post) ? "described" : void 0);
|
|
145936
|
+
if (shown === "binary") {
|
|
145937
|
+
const type = Object.entries(entry.request?.headers ?? {}).find(
|
|
145938
|
+
([name]) => name.toLowerCase() === "content-type"
|
|
145939
|
+
);
|
|
145940
|
+
return { kind: "binary", mimeType: type?.[1] ?? "" };
|
|
145941
|
+
}
|
|
145942
|
+
if (shown === "form" || shown === "blob" || shown === "described") {
|
|
145943
|
+
const what = shown === "form" ? "a FormData body" : shown === "blob" ? "a Blob body" : "a body";
|
|
145944
|
+
return {
|
|
145945
|
+
kind: "unknown",
|
|
145946
|
+
reason: `the app sent ${what} that the capture keeps only as a description`,
|
|
145947
|
+
final: true
|
|
145948
|
+
};
|
|
145949
|
+
}
|
|
145950
|
+
if (shown === "bytes") {
|
|
145951
|
+
return {
|
|
145952
|
+
kind: "unknown",
|
|
145953
|
+
reason: "the app sent the body as bytes, which the capture did not decode",
|
|
145954
|
+
final: true
|
|
145955
|
+
};
|
|
145956
|
+
}
|
|
145957
|
+
if (entry.request?.postDataTruncated) {
|
|
145958
|
+
return { kind: "unknown", reason: CUT_AT_CAPTURE, final: true };
|
|
145959
|
+
}
|
|
145960
|
+
return { kind: "text", text: post };
|
|
145961
|
+
}
|
|
145962
|
+
if (entry.state !== "finished") {
|
|
145963
|
+
return { kind: "unknown", reason: "the response has not finished", final: false };
|
|
145964
|
+
}
|
|
145965
|
+
if (entry.bodyOmitted) return { kind: "binary", mimeType: entry.response?.mimeType ?? "" };
|
|
145966
|
+
if (entry.bodyTruncated) return { kind: "unknown", reason: CUT_AT_CAPTURE, final: true };
|
|
145967
|
+
if (entry.responseBody == null) {
|
|
145968
|
+
if (bodiless(entry.request?.method, entry.response?.status) || entry.encodedDataLength === 0) {
|
|
145969
|
+
return { kind: "none" };
|
|
145970
|
+
}
|
|
145971
|
+
return {
|
|
145972
|
+
kind: "unknown",
|
|
145973
|
+
reason: "the capture did not keep the response body",
|
|
145974
|
+
final: entry.encodedDataLength !== void 0
|
|
145975
|
+
};
|
|
145976
|
+
}
|
|
145977
|
+
return { kind: "text", text: entry.responseBody };
|
|
145978
|
+
}
|
|
145979
|
+
async function chromiumBodyText(cdp, rec, kind) {
|
|
145980
|
+
if (kind === "request") {
|
|
145981
|
+
if (rec.postData != null) return { kind: "text", text: rec.postData };
|
|
145982
|
+
return rec.hasPostData ? { kind: "unknown", reason: "Chrome did not report the request body", final: true } : { kind: "none" };
|
|
145983
|
+
}
|
|
145984
|
+
if (!rec.finished || rec.failed) {
|
|
145985
|
+
return { kind: "unknown", reason: "the response has not finished", final: false };
|
|
145986
|
+
}
|
|
145987
|
+
const out = await chromiumResponseBody(cdp, rec);
|
|
145988
|
+
if (!out)
|
|
145989
|
+
return { kind: "unknown", reason: "Chrome holds no body for the response", final: false };
|
|
145990
|
+
const body = out.base64Encoded ? utf8Text(Buffer.from(out.body, "base64")) : out.body;
|
|
145991
|
+
return typeof body === "string" ? { kind: "text", text: body } : { kind: "binary", mimeType: rec.mimeType ?? "" };
|
|
145992
|
+
}
|
|
145810
145993
|
function inDeclaredCharset(text, contentType, truncated) {
|
|
145811
145994
|
if (namesUtf8(contentType)) return text;
|
|
145812
145995
|
return decodeText(Buffer.from(text, "utf8"), charsetOf(contentType), truncated) ?? text;
|
|
@@ -147528,6 +147711,14 @@ init_device_info();
|
|
|
147528
147711
|
init_capability();
|
|
147529
147712
|
|
|
147530
147713
|
// ../tool-server/src/tools/await-network-request/layers.ts
|
|
147714
|
+
function unknownBody(reason2, final = false) {
|
|
147715
|
+
return { kind: "unknown", reason: reason2, final };
|
|
147716
|
+
}
|
|
147717
|
+
function nativeBody(store, record2, kind) {
|
|
147718
|
+
const held = store?.record(record2.id);
|
|
147719
|
+
if (!store || !held) return Promise.resolve(unknownBody(CAPTURE_ENDED));
|
|
147720
|
+
return nativeBodyText(held, store, kind).catch((err) => unknownBody(errorMessage4(err)));
|
|
147721
|
+
}
|
|
147531
147722
|
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";
|
|
147532
147723
|
var SWEEP_UNDER_WAY = "stop-all-simulator-servers or the tool-server's exit is ending the app's capture";
|
|
147533
147724
|
var STOPPED_UNARMED = "the layer was not armed when network-capture-stop stopped it, so it may have missed requests in the window";
|
|
@@ -147568,7 +147759,11 @@ function fromNative(record2) {
|
|
|
147568
147759
|
...record2.timing.durationMs !== void 0 ? { durationMs: Math.round(record2.timing.durationMs) } : {},
|
|
147569
147760
|
...record2.errorText ? { errorText: record2.errorText } : {},
|
|
147570
147761
|
// From the agent's wallTime, on the app's clock, as the start of a JS request.
|
|
147571
|
-
startedAt: record2.timing.startedAt
|
|
147762
|
+
startedAt: record2.timing.startedAt,
|
|
147763
|
+
// The headers sent on the wire hold what the app's HTTP stack added, so they come first.
|
|
147764
|
+
requestHeaders: record2.request.wireHeaders ? [record2.request.wireHeaders, record2.request.headers] : [record2.request.headers],
|
|
147765
|
+
// The Android agent reports them in a later event, before the response or a failure.
|
|
147766
|
+
...record2.layer === "android-native" && record2.state === "pending" && !record2.request.wireHeaders ? { headersPending: true } : {}
|
|
147572
147767
|
};
|
|
147573
147768
|
}
|
|
147574
147769
|
function windowNote(armed, stopped, unarmed, missed, evicted) {
|
|
@@ -147580,7 +147775,7 @@ function windowNote(armed, stopped, unarmed, missed, evicted) {
|
|
|
147580
147775
|
function nativeAfter(records, floor) {
|
|
147581
147776
|
return records.filter((r) => recordNumber(r.id) > floor).map(fromNative);
|
|
147582
147777
|
}
|
|
147583
|
-
async function markedLayers(registry2, device, bundleId) {
|
|
147778
|
+
async function markedLayers(registry2, device, bundleId, options = {}) {
|
|
147584
147779
|
const layers = [];
|
|
147585
147780
|
const start2 = lastCaptureStart(device.id, bundleId);
|
|
147586
147781
|
const startWindow = {
|
|
@@ -147599,7 +147794,7 @@ async function markedLayers(registry2, device, bundleId) {
|
|
|
147599
147794
|
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);
|
|
147600
147795
|
if (native) layers.push(native);
|
|
147601
147796
|
if (device.platform !== "chromium") {
|
|
147602
|
-
const js = jsLayer(registry2, device, bundleId, startWindow);
|
|
147797
|
+
const js = jsLayer(registry2, device, bundleId, startWindow, options.headers === true);
|
|
147603
147798
|
if (js) layers.push(js);
|
|
147604
147799
|
}
|
|
147605
147800
|
return layers;
|
|
@@ -147612,6 +147807,9 @@ async function iosLayer(registry2, device, bundleId, startWindow) {
|
|
|
147612
147807
|
if (!startWindow.current("ios-native", found.isNetworkCaptureStopped(bundleId))) return void 0;
|
|
147613
147808
|
return {
|
|
147614
147809
|
layer: "ios-native",
|
|
147810
|
+
async body(record2, kind) {
|
|
147811
|
+
return nativeBody((await resolve24())?.networkRecords(bundleId), record2, kind);
|
|
147812
|
+
},
|
|
147615
147813
|
async read() {
|
|
147616
147814
|
const api = await resolve24();
|
|
147617
147815
|
const mark = api?.networkCaptureMark(bundleId);
|
|
@@ -147646,6 +147844,9 @@ async function androidLayer(registry2, device, bundleId, startWindow) {
|
|
|
147646
147844
|
if (!startWindow.current("android-native", found.isStopped())) return void 0;
|
|
147647
147845
|
return {
|
|
147648
147846
|
layer: "android-native",
|
|
147847
|
+
async body(record2, kind) {
|
|
147848
|
+
return nativeBody(await resolve24(), record2, kind);
|
|
147849
|
+
},
|
|
147649
147850
|
async read() {
|
|
147650
147851
|
const api = await resolve24();
|
|
147651
147852
|
const mark = api?.captureMark();
|
|
@@ -147683,6 +147884,9 @@ async function macosLayer(registry2, device, startWindow) {
|
|
|
147683
147884
|
if (!startWindow.current("macos-native", found.isNetworkCaptureStopped())) return void 0;
|
|
147684
147885
|
return {
|
|
147685
147886
|
layer: "macos-native",
|
|
147887
|
+
async body(record2, kind) {
|
|
147888
|
+
return nativeBody((await resolve24())?.networkRecords(), record2, kind);
|
|
147889
|
+
},
|
|
147686
147890
|
async read() {
|
|
147687
147891
|
const app = await resolve24();
|
|
147688
147892
|
const mark = app?.networkCaptureMark();
|
|
@@ -147718,7 +147922,9 @@ function fromChromium(record2) {
|
|
|
147718
147922
|
...record2.status !== void 0 ? { status: record2.status } : {},
|
|
147719
147923
|
state: record2.failed ? "failed" : record2.finished ? "complete" : record2.status !== void 0 ? "headers" : "pending",
|
|
147720
147924
|
...record2.durationMs !== void 0 ? { durationMs: Math.round(record2.durationMs) } : {},
|
|
147721
|
-
...record2.errorText ? { errorText: record2.errorText } : {}
|
|
147925
|
+
...record2.errorText ? { errorText: record2.errorText } : {},
|
|
147926
|
+
requestHeaders: [record2.requestHeaders ?? {}],
|
|
147927
|
+
...record2.wireHeadersPending ? { headersPending: true } : {}
|
|
147722
147928
|
};
|
|
147723
147929
|
}
|
|
147724
147930
|
async function chromiumLayer(registry2, device) {
|
|
@@ -147727,6 +147933,14 @@ async function chromiumLayer(registry2, device) {
|
|
|
147727
147933
|
if (!(await resolve24())?.server.network.captureMark()) return void 0;
|
|
147728
147934
|
return {
|
|
147729
147935
|
layer: "chromium",
|
|
147936
|
+
async body(record2, kind) {
|
|
147937
|
+
const api = await resolve24();
|
|
147938
|
+
const rec = api?.server.network.get(record2.id);
|
|
147939
|
+
if (!api || !rec) return unknownBody("argent no longer holds the request", true);
|
|
147940
|
+
return chromiumBodyText(api.cdp, rec, kind).catch(
|
|
147941
|
+
(err) => unknownBody(errorMessage4(err))
|
|
147942
|
+
);
|
|
147943
|
+
},
|
|
147730
147944
|
async read() {
|
|
147731
147945
|
const network = (await resolve24())?.server.network;
|
|
147732
147946
|
const mark = network?.captureMark();
|
|
@@ -147744,7 +147958,7 @@ async function chromiumLayer(registry2, device) {
|
|
|
147744
147958
|
}
|
|
147745
147959
|
};
|
|
147746
147960
|
}
|
|
147747
|
-
function fromJs(entry) {
|
|
147961
|
+
function fromJs(entry, install) {
|
|
147748
147962
|
const state3 = entry.state === "finished" ? "complete" : entry.state === "failed" ? "failed" : entry.status !== void 0 ? "headers" : "pending";
|
|
147749
147963
|
return {
|
|
147750
147964
|
id: entry.requestId ?? "",
|
|
@@ -147755,15 +147969,45 @@ function fromJs(entry) {
|
|
|
147755
147969
|
state: state3,
|
|
147756
147970
|
...typeof entry.durationMs === "number" ? { durationMs: Math.round(entry.durationMs) } : {},
|
|
147757
147971
|
...entry.errorText ? { errorText: entry.errorText } : {},
|
|
147758
|
-
...typeof entry.timestamp === "number" ? { startedAt: entry.timestamp * 1e3 } : {}
|
|
147972
|
+
...typeof entry.timestamp === "number" ? { startedAt: entry.timestamp * 1e3 } : {},
|
|
147973
|
+
..."headers" in entry ? { requestHeaders: [entry.headers ?? {}] } : {},
|
|
147974
|
+
...install ? { install } : {}
|
|
147759
147975
|
};
|
|
147760
147976
|
}
|
|
147761
|
-
function jsLayer(registry2, device, bundleId, startWindow) {
|
|
147977
|
+
function jsLayer(registry2, device, bundleId, startWindow, withHeaders) {
|
|
147762
147978
|
const found = findJsCaptureOfDevice(device.id, bundleId);
|
|
147763
147979
|
if (!found?.capture.mark) return void 0;
|
|
147764
147980
|
if (!startWindow.current("js", found.capture.intent === "stopped")) return void 0;
|
|
147765
147981
|
return {
|
|
147766
147982
|
layer: "js",
|
|
147983
|
+
async body(record2, kind, budgetMs) {
|
|
147984
|
+
const found2 = findJsCaptureOfDevice(device.id, bundleId);
|
|
147985
|
+
if (!found2?.capture.mark) return unknownBody(CAPTURE_ENDED);
|
|
147986
|
+
const physical = found2.capture.physicalDeviceId ?? device.id;
|
|
147987
|
+
if (captureSweepUnderWay(physical)) return unknownBody(SWEEP_UNDER_WAY);
|
|
147988
|
+
const urn = `${JS_RUNTIME_DEBUGGER_NAMESPACE}:${found2.payload}`;
|
|
147989
|
+
if (!isLiveService(registry2, urn)) {
|
|
147990
|
+
return unknownBody("the app's JS runtime is not connected");
|
|
147991
|
+
}
|
|
147992
|
+
try {
|
|
147993
|
+
const dbg = await registry2.resolveService(urn);
|
|
147994
|
+
const read = makeNetworkDetailReadScript(record2.id);
|
|
147995
|
+
const script = record2.install === void 0 ? read : `(globalThis.__argent_network_install === ${JSON.stringify(record2.install)} ? ${read} : JSON.stringify({ reloaded: true }))`;
|
|
147996
|
+
const answer = JSON.parse(
|
|
147997
|
+
String(await dbg.cdp.evaluate(script, { timeout: Math.max(1, budgetMs) }))
|
|
147998
|
+
);
|
|
147999
|
+
if ("reloaded" in answer) {
|
|
148000
|
+
return unknownBody(
|
|
148001
|
+
"the app's JS runtime reloaded since the request, which cleared its body",
|
|
148002
|
+
true
|
|
148003
|
+
);
|
|
148004
|
+
}
|
|
148005
|
+
if ("error" in answer) return unknownBody(`the app's JS runtime: ${answer.error}`, true);
|
|
148006
|
+
return jsBodyText(answer, kind);
|
|
148007
|
+
} catch (err) {
|
|
148008
|
+
return unknownBody(`the app's JS runtime did not answer: ${errorMessage4(err)}`);
|
|
148009
|
+
}
|
|
148010
|
+
},
|
|
147767
148011
|
async read(budgetMs) {
|
|
147768
148012
|
const found2 = findJsCaptureOfDevice(device.id, bundleId);
|
|
147769
148013
|
const mark = found2?.capture.mark;
|
|
@@ -147807,7 +148051,7 @@ function jsLayer(registry2, device, bundleId, startWindow) {
|
|
|
147807
148051
|
}
|
|
147808
148052
|
const answer = JSON.parse(
|
|
147809
148053
|
String(
|
|
147810
|
-
await dbg.cdp.evaluate(makeNetworkWaitReadScript(mark, port), {
|
|
148054
|
+
await dbg.cdp.evaluate(makeNetworkWaitReadScript(mark, port, withHeaders), {
|
|
147811
148055
|
timeout: Math.max(1, budgetMs)
|
|
147812
148056
|
})
|
|
147813
148057
|
)
|
|
@@ -147856,7 +148100,7 @@ function jsLayer(registry2, device, bundleId, startWindow) {
|
|
|
147856
148100
|
readable: true,
|
|
147857
148101
|
armed: false,
|
|
147858
148102
|
stopped,
|
|
147859
|
-
records: (answer.entries ?? []).map(fromJs),
|
|
148103
|
+
records: (answer.entries ?? []).map((entry) => fromJs(entry, answer.token)),
|
|
147860
148104
|
note
|
|
147861
148105
|
};
|
|
147862
148106
|
}
|
|
@@ -147878,7 +148122,7 @@ function jsLayer(registry2, device, bundleId, startWindow) {
|
|
|
147878
148122
|
readable: true,
|
|
147879
148123
|
armed: true,
|
|
147880
148124
|
stopped,
|
|
147881
|
-
records: (answer.entries ?? []).map(fromJs),
|
|
148125
|
+
records: (answer.entries ?? []).map((entry) => fromJs(entry, answer.token)),
|
|
147882
148126
|
...note ? { note } : {},
|
|
147883
148127
|
...gap ? { gap: true } : {}
|
|
147884
148128
|
};
|
|
@@ -147894,10 +148138,203 @@ function jsLayer(registry2, device, bundleId, startWindow) {
|
|
|
147894
148138
|
};
|
|
147895
148139
|
}
|
|
147896
148140
|
|
|
148141
|
+
// ../tool-server/src/tools/await-network-request/value-check.ts
|
|
148142
|
+
init_zod();
|
|
148143
|
+
init_src();
|
|
148144
|
+
var COMPARATORS = ["equals", "contains", "matches", "exists"];
|
|
148145
|
+
var PATH_HELP = "keys and array indexes joined by dots, e.g. `data.items.0.id`";
|
|
148146
|
+
var valueFields = {
|
|
148147
|
+
path: external_exports.string().optional().describe(`JSON field specified as ${PATH_HELP}. Omit to use the whole body.`),
|
|
148148
|
+
claim: external_exports.string().optional().describe(
|
|
148149
|
+
"Dot-separated JWT payload claim, such as `consents.analytics`. Accepts a `Bearer ` prefix and reads the payload without validating the signature."
|
|
148150
|
+
),
|
|
148151
|
+
equals: external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()]).optional().describe("Exact, case-sensitive match. Compares numbers and booleans as text."),
|
|
148152
|
+
contains: external_exports.string().optional().describe("Case-sensitive substring."),
|
|
148153
|
+
matches: external_exports.string().optional().describe("Case-sensitive JavaScript regular expression."),
|
|
148154
|
+
exists: external_exports.boolean().optional().describe("Use true for a present value or false for a missing or null value.")
|
|
148155
|
+
};
|
|
148156
|
+
function refineValueCheck(check3, ctx) {
|
|
148157
|
+
const given = COMPARATORS.filter((name) => check3[name] !== void 0);
|
|
148158
|
+
if (given.length !== 1) {
|
|
148159
|
+
ctx.addIssue({
|
|
148160
|
+
code: external_exports.ZodIssueCode.custom,
|
|
148161
|
+
message: `give exactly one of ${COMPARATORS.join(", ")}${given.length ? ` (got ${given.join(", ")})` : ""}`
|
|
148162
|
+
});
|
|
148163
|
+
}
|
|
148164
|
+
for (const key2 of ["path", "claim"]) {
|
|
148165
|
+
if (check3[key2] !== void 0 && !isValuePath(check3[key2])) {
|
|
148166
|
+
ctx.addIssue({
|
|
148167
|
+
code: external_exports.ZodIssueCode.custom,
|
|
148168
|
+
path: [key2],
|
|
148169
|
+
message: `${key2} must be ${PATH_HELP}`
|
|
148170
|
+
});
|
|
148171
|
+
}
|
|
148172
|
+
}
|
|
148173
|
+
if (typeof check3.matches === "string") {
|
|
148174
|
+
const problem = regexProblem(check3.matches);
|
|
148175
|
+
if (problem) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["matches"], message: problem });
|
|
148176
|
+
}
|
|
148177
|
+
}
|
|
148178
|
+
var valueCheckSchema = external_exports.object(valueFields).strict().superRefine(refineValueCheck);
|
|
148179
|
+
var headerCheckSchema = external_exports.object({
|
|
148180
|
+
name: external_exports.string().min(1).regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/, "a header name, such as authorization").refine((name) => !/^\d+$/.test(name), "a header name, not a number").describe(
|
|
148181
|
+
"Case-insensitive header name, such as `authorization`. Names of only digits are invalid."
|
|
148182
|
+
),
|
|
148183
|
+
claim: valueFields.claim,
|
|
148184
|
+
equals: valueFields.equals,
|
|
148185
|
+
contains: valueFields.contains,
|
|
148186
|
+
matches: valueFields.matches,
|
|
148187
|
+
exists: valueFields.exists
|
|
148188
|
+
}).strict().superRefine(refineValueCheck);
|
|
148189
|
+
function regexProblem(pattern) {
|
|
148190
|
+
try {
|
|
148191
|
+
new RegExp(pattern.replace(SECRET_PLACEHOLDER_RE, "x"));
|
|
148192
|
+
return void 0;
|
|
148193
|
+
} catch (err) {
|
|
148194
|
+
return `not a valid regular expression: ${err instanceof Error ? err.message : String(err)}`;
|
|
148195
|
+
}
|
|
148196
|
+
}
|
|
148197
|
+
function fillSecrets(text, regex, options) {
|
|
148198
|
+
if (!regex) return resolveSecretPlaceholders(text, options).text;
|
|
148199
|
+
return text.replace(
|
|
148200
|
+
SECRET_PLACEHOLDER_RE,
|
|
148201
|
+
(placeholder) => escapeRegExp2(resolveSecretPlaceholders(placeholder, options).text)
|
|
148202
|
+
);
|
|
148203
|
+
}
|
|
148204
|
+
function escapeRegExp2(text) {
|
|
148205
|
+
return text.replace(/[.*+?^${}()|[\]\\/-]/g, "\\$&");
|
|
148206
|
+
}
|
|
148207
|
+
function headerCheckOf(params, options, sensitive) {
|
|
148208
|
+
const { name, ...check3 } = params;
|
|
148209
|
+
const lower = name.toLowerCase();
|
|
148210
|
+
return { ...valueCheckOf(check3, options), name: lower, sensitive: sensitive(lower) };
|
|
148211
|
+
}
|
|
148212
|
+
function headerIn(headers, name) {
|
|
148213
|
+
for (const map2 of headers) {
|
|
148214
|
+
for (const [key2, value] of Object.entries(map2)) {
|
|
148215
|
+
if (key2.toLowerCase() === name) return String(value);
|
|
148216
|
+
if (/^\d+$/.test(key2) && typeof value === "string") {
|
|
148217
|
+
const comma = value.indexOf(",");
|
|
148218
|
+
if (comma > 0 && value.slice(0, comma).trim().toLowerCase() === name) {
|
|
148219
|
+
return value.slice(comma + 1);
|
|
148220
|
+
}
|
|
148221
|
+
}
|
|
148222
|
+
}
|
|
148223
|
+
}
|
|
148224
|
+
return void 0;
|
|
148225
|
+
}
|
|
148226
|
+
function checkHeader(check3, headers) {
|
|
148227
|
+
const label = `header ${check3.name}`;
|
|
148228
|
+
if (!headers) return { verdict: "unknown", reason: `${label}: the layer gave no headers` };
|
|
148229
|
+
const value = headerIn(headers, check3.name);
|
|
148230
|
+
const source = value === void 0 ? { kind: "none" } : { kind: "text", text: value };
|
|
148231
|
+
const verdict = checkValue(check3, source, label);
|
|
148232
|
+
if (value === void 0) {
|
|
148233
|
+
const reason2 = `${label} was not sent`;
|
|
148234
|
+
return verdict.verdict === "pass" ? { verdict: "pass", reason: reason2, value: "" } : { verdict: "fail", reason: reason2 };
|
|
148235
|
+
}
|
|
148236
|
+
if (!check3.sensitive || check3.claim !== void 0) return verdict;
|
|
148237
|
+
const hidden = `the value of the sensitive ${label} stays hidden`;
|
|
148238
|
+
return verdict.verdict === "pass" ? { verdict: "pass", reason: hidden, value: "[REDACTED]" } : { verdict: verdict.verdict, reason: `${label} does not match (${hidden})` };
|
|
148239
|
+
}
|
|
148240
|
+
function valueCheckOf(params, options) {
|
|
148241
|
+
const test = COMPARATORS.find((name) => params[name] !== void 0);
|
|
148242
|
+
const raw = params[test];
|
|
148243
|
+
const expected = test === "exists" ? raw === true : fillSecrets(String(raw), test === "matches", options);
|
|
148244
|
+
const target = [params.path, params.claim !== void 0 ? `JWT claim ${params.claim}` : void 0].filter(Boolean).join(" ");
|
|
148245
|
+
const wanted = test === "exists" ? raw === true ? "exists" : "is absent" : `${test} ${JSON.stringify(String(raw))}`;
|
|
148246
|
+
return {
|
|
148247
|
+
...params.path !== void 0 ? { path: params.path } : {},
|
|
148248
|
+
...params.claim !== void 0 ? { claim: params.claim } : {},
|
|
148249
|
+
test,
|
|
148250
|
+
expected,
|
|
148251
|
+
description: `${target ? `${target} ` : ""}${wanted}`
|
|
148252
|
+
};
|
|
148253
|
+
}
|
|
148254
|
+
function jwtPayload(token) {
|
|
148255
|
+
const compact = token.trim().replace(/^bearer\s+/i, "");
|
|
148256
|
+
const parts2 = compact.split(".");
|
|
148257
|
+
if (parts2.length !== 3) {
|
|
148258
|
+
return {
|
|
148259
|
+
ok: false,
|
|
148260
|
+
why: `is not a JWT: it has ${parts2.length} dot-separated part${parts2.length === 1 ? "" : "s"}, a signed JWT has 3`
|
|
148261
|
+
};
|
|
148262
|
+
}
|
|
148263
|
+
if (!/^[A-Za-z0-9_-]+$/.test(parts2[1])) {
|
|
148264
|
+
return { ok: false, why: "is not a JWT: its payload is not base64url" };
|
|
148265
|
+
}
|
|
148266
|
+
try {
|
|
148267
|
+
const payload = parseJson(Buffer.from(parts2[1], "base64url").toString("utf8"));
|
|
148268
|
+
if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
148269
|
+
return { ok: false, why: "is not a JWT: its payload is not a JSON object" };
|
|
148270
|
+
}
|
|
148271
|
+
return { ok: true, payload };
|
|
148272
|
+
} catch {
|
|
148273
|
+
return { ok: false, why: "is not a JWT: its payload is not JSON" };
|
|
148274
|
+
}
|
|
148275
|
+
}
|
|
148276
|
+
function parseJson(text) {
|
|
148277
|
+
const keepDigits = (_key, value, context2) => typeof value === "number" && context2?.source !== void 0 && /^-?\d+$/.test(context2.source) && String(value) !== context2.source ? context2.source : value;
|
|
148278
|
+
return JSON.parse(text, keepDigits);
|
|
148279
|
+
}
|
|
148280
|
+
function textOf(hit) {
|
|
148281
|
+
if (!hit.found) return "";
|
|
148282
|
+
return typeof hit.value === "string" ? hit.value : JSON.stringify(hit.value);
|
|
148283
|
+
}
|
|
148284
|
+
function checkValue(check3, source, label) {
|
|
148285
|
+
if (source.kind === "unknown")
|
|
148286
|
+
return { verdict: "unknown", reason: `${label}: ${source.reason}` };
|
|
148287
|
+
let at = label;
|
|
148288
|
+
let hit;
|
|
148289
|
+
if (source.kind === "none") {
|
|
148290
|
+
hit = { found: false, why: `${label} is empty` };
|
|
148291
|
+
} else if (source.kind === "binary") {
|
|
148292
|
+
hit = check3.path === void 0 && check3.claim === void 0 ? { found: true, value: `[binary${source.mimeType ? ` ${source.mimeType}` : ""}]` } : {
|
|
148293
|
+
found: false,
|
|
148294
|
+
why: `${label} is binary${source.mimeType ? ` (${source.mimeType})` : ""}`
|
|
148295
|
+
};
|
|
148296
|
+
if (check3.test !== "exists" && hit.found) {
|
|
148297
|
+
return {
|
|
148298
|
+
verdict: "fail",
|
|
148299
|
+
reason: `${label} is binary${source.mimeType ? ` (${source.mimeType})` : ""}`
|
|
148300
|
+
};
|
|
148301
|
+
}
|
|
148302
|
+
} else if (check3.path !== void 0) {
|
|
148303
|
+
let json2;
|
|
148304
|
+
try {
|
|
148305
|
+
json2 = parseJson(source.text);
|
|
148306
|
+
hit = lookupPath(json2, check3.path, label);
|
|
148307
|
+
at = `${label}.${check3.path}`;
|
|
148308
|
+
} catch {
|
|
148309
|
+
hit = { found: false, why: `${label} is not JSON` };
|
|
148310
|
+
}
|
|
148311
|
+
} else {
|
|
148312
|
+
hit = { found: true, value: source.text };
|
|
148313
|
+
}
|
|
148314
|
+
if (check3.claim !== void 0 && hit.found) {
|
|
148315
|
+
if (typeof hit.value !== "string") {
|
|
148316
|
+
hit = { found: false, why: `${at} is not a string, so it is not a JWT` };
|
|
148317
|
+
} else {
|
|
148318
|
+
const decoded2 = jwtPayload(hit.value);
|
|
148319
|
+
hit = decoded2.ok ? lookupPath(decoded2.payload, check3.claim, `${at} JWT`) : { found: false, why: `${at} ${decoded2.why}` };
|
|
148320
|
+
at = `${at} JWT ${check3.claim}`;
|
|
148321
|
+
}
|
|
148322
|
+
}
|
|
148323
|
+
const { ok, reason: reason2 } = evaluateValueCheck(check3.test, check3.expected, hit, at);
|
|
148324
|
+
return ok ? { verdict: "pass", reason: reason2, value: textOf(hit) } : { verdict: "fail", reason: reason2 };
|
|
148325
|
+
}
|
|
148326
|
+
|
|
147897
148327
|
// ../tool-server/src/tools/await-network-request/match.ts
|
|
147898
|
-
function withoutStart({
|
|
148328
|
+
function withoutStart({
|
|
148329
|
+
startedAt: _,
|
|
148330
|
+
requestHeaders: __,
|
|
148331
|
+
install: ___,
|
|
148332
|
+
headersPending: ____,
|
|
148333
|
+
...record2
|
|
148334
|
+
}) {
|
|
147899
148335
|
return record2;
|
|
147900
148336
|
}
|
|
148337
|
+
var BODY_CRITERIA = ["header", "requestBody", "responseBody"];
|
|
147901
148338
|
var STATUS_CLASSES = ["1xx", "2xx", "3xx", "4xx", "5xx"];
|
|
147902
148339
|
function urlMatches(criteria, url2) {
|
|
147903
148340
|
switch (criteria.urlMatch) {
|
|
@@ -147942,31 +148379,44 @@ function sameRequest(a, b) {
|
|
|
147942
148379
|
return a.layer !== b.layer && a.method.toLowerCase() === b.method.toLowerCase() && a.url === b.url && a.status === b.status && a.state === b.state && // A retry with the same fields starts later.
|
|
147943
148380
|
(a.startedAt === void 0 || b.startedAt === void 0 || Math.abs(a.startedAt - b.startedAt) <= SAME_REQUEST_MS);
|
|
147944
148381
|
}
|
|
147945
|
-
function nearMisses(criteria, records) {
|
|
147946
|
-
const ranked = records.map((record2, index) =>
|
|
148382
|
+
function nearMisses(criteria, records, judged = () => void 0) {
|
|
148383
|
+
const ranked = records.map((record2, index) => {
|
|
148384
|
+
const mismatch2 = mismatches(criteria, record2);
|
|
148385
|
+
const body = mismatch2.length === 0 ? judged(record2) : void 0;
|
|
148386
|
+
if (body) mismatch2.push(...body.mismatch);
|
|
148387
|
+
return { record: record2, mismatch: mismatch2, index, reason: body?.reason };
|
|
148388
|
+
}).sort(
|
|
147947
148389
|
(a, b) => Number(a.mismatch.includes("url")) - Number(b.mismatch.includes("url")) || a.mismatch.length - b.mismatch.length || // A record without a start counts as the oldest; NaN, when neither has one, falls through.
|
|
147948
148390
|
(b.record.startedAt ?? -Infinity) - (a.record.startedAt ?? -Infinity) || b.index - a.index
|
|
147949
148391
|
);
|
|
147950
148392
|
const listed = [];
|
|
147951
|
-
for (const { record: record2, mismatch: mismatch2 } of ranked) {
|
|
148393
|
+
for (const { record: record2, mismatch: mismatch2, reason: reason2 } of ranked) {
|
|
147952
148394
|
if (listed.length === MAX_NEAR_MISSES) break;
|
|
147953
148395
|
const of = listed.find((entry) => !entry.twin && sameRequest(entry.record, record2));
|
|
147954
148396
|
if (of) of.twin = true;
|
|
147955
|
-
else listed.push({ record: record2, mismatch: mismatch2, twin: false });
|
|
148397
|
+
else listed.push({ record: record2, mismatch: mismatch2, reason: reason2, twin: false });
|
|
147956
148398
|
}
|
|
147957
|
-
return listed.map(({ record: record2, mismatch: mismatch2 }) => ({
|
|
148399
|
+
return listed.map(({ record: record2, mismatch: mismatch2, reason: reason2 }) => ({
|
|
148400
|
+
...withoutStart(record2),
|
|
148401
|
+
mismatch: mismatch2,
|
|
148402
|
+
...reason2 !== void 0 ? { reason: reason2 } : {}
|
|
148403
|
+
}));
|
|
147958
148404
|
}
|
|
147959
148405
|
var NOTE_URL_CHARS = 120;
|
|
147960
148406
|
function shortUrl(url2) {
|
|
147961
148407
|
return url2.length > NOTE_URL_CHARS ? `${url2.slice(0, NOTE_URL_CHARS)}...` : url2;
|
|
147962
148408
|
}
|
|
147963
148409
|
function describeCriteria(criteria) {
|
|
147964
|
-
const
|
|
148410
|
+
const wanted = shortUrl(criteria.urlShown ?? criteria.url);
|
|
148411
|
+
const url2 = criteria.urlMatch === "matches" ? `URL matching the regular expression "${wanted}"` : `URL ${criteria.urlMatch === "equals" ? "equal to" : "containing"} "${wanted}"`;
|
|
147965
148412
|
return [
|
|
147966
148413
|
criteria.method ? criteria.method.toUpperCase() : void 0,
|
|
147967
148414
|
url2,
|
|
147968
148415
|
criteria.status !== void 0 ? `status ${criteria.status}` : void 0,
|
|
147969
|
-
criteria.outcome === "any" ? "complete or failed" : criteria.outcome === "sent" ? "sent (in any state)" : criteria.outcome
|
|
148416
|
+
criteria.outcome === "any" ? "complete or failed" : criteria.outcome === "sent" ? "sent (in any state)" : criteria.outcome,
|
|
148417
|
+
criteria.header ? `header ${criteria.header.name}${criteria.header.description ? ` ${criteria.header.description}` : ""}` : void 0,
|
|
148418
|
+
criteria.requestBody ? `request body ${criteria.requestBody.description}` : void 0,
|
|
148419
|
+
criteria.responseBody ? `response body ${criteria.responseBody.description}` : void 0
|
|
147970
148420
|
].filter(Boolean).join(", ");
|
|
147971
148421
|
}
|
|
147972
148422
|
function describeRecord(record2) {
|
|
@@ -147977,7 +148427,7 @@ function describeRecord(record2) {
|
|
|
147977
148427
|
record2.errorText ? `"${shortUrl(record2.errorText)}"` : void 0,
|
|
147978
148428
|
`[${record2.layer} ${record2.id}]`
|
|
147979
148429
|
];
|
|
147980
|
-
const mismatch2 = "mismatch" in record2 ? ` (mismatch: ${record2.mismatch.join(", ")})` : "";
|
|
148430
|
+
const mismatch2 = "mismatch" in record2 ? ` (mismatch: ${record2.mismatch.join(", ")}${record2.reason ? `: ${shortUrl(record2.reason)}` : ""})` : "";
|
|
147981
148431
|
return `${parts2.filter(Boolean).join(" ")}${mismatch2}`;
|
|
147982
148432
|
}
|
|
147983
148433
|
|
|
@@ -147985,12 +148435,15 @@ function describeRecord(record2) {
|
|
|
147985
148435
|
var DEFAULT_TIMEOUT_MS4 = 1e4;
|
|
147986
148436
|
var DEFAULT_POLL_INTERVAL_MS2 = 400;
|
|
147987
148437
|
var MIN_JS_READ_MS = 1e3;
|
|
148438
|
+
var BODY_READ_GRACE_MS = 1e3;
|
|
148439
|
+
var MAX_BODY_READ_MS = 1e4;
|
|
148440
|
+
var SHOWN_VALUE_CHARS = 200;
|
|
147988
148441
|
var zodSchema45 = external_exports.object({
|
|
147989
148442
|
udid: external_exports.string().min(1).describe("Device ID used in `network-capture-start`."),
|
|
147990
148443
|
bundleId: external_exports.string().regex(BUNDLE_ID_PATTERN, BUNDLE_ID_MESSAGE).describe(
|
|
147991
148444
|
"`bundleId` used in `network-capture-start` (Chromium: placeholder like `argent.capture`)."
|
|
147992
148445
|
),
|
|
147993
|
-
url: external_exports.string().min(1).describe("URL text
|
|
148446
|
+
url: external_exports.string().min(1).describe("URL text or pattern. `{{secret:NAME}}` expands to the secret value."),
|
|
147994
148447
|
urlMatch: external_exports.enum(["contains", "equals", "matches"]).optional().describe(
|
|
147995
148448
|
"`contains` (default) / `equals` (case-insensitive) or `matches` (case-sensitive JS regex)."
|
|
147996
148449
|
),
|
|
@@ -148002,37 +148455,38 @@ var zodSchema45 = external_exports.object({
|
|
|
148002
148455
|
outcome: external_exports.enum(["complete", "failed", "any", "sent"]).optional().describe(
|
|
148003
148456
|
"`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
148457
|
),
|
|
148458
|
+
header: headerCheckSchema.optional().describe(
|
|
148459
|
+
"Check one request header using exactly one of `equals`, `contains`, `matches`, or `exists`."
|
|
148460
|
+
),
|
|
148461
|
+
requestBody: valueCheckSchema.optional().describe(
|
|
148462
|
+
"Check a request body using exactly one of `equals`, `contains`, `matches`, or `exists`."
|
|
148463
|
+
),
|
|
148464
|
+
responseBody: valueCheckSchema.optional().describe("Use the same check as `requestBody` on a finished response."),
|
|
148005
148465
|
absent: external_exports.boolean().optional().describe("Set to true to fail on the first match and require complete capture to pass."),
|
|
148006
148466
|
timeoutMs: external_exports.number().int().positive().max(12e4).optional().describe(`Timeout in ms (default ${DEFAULT_TIMEOUT_MS4}).`),
|
|
148007
148467
|
pollIntervalMs: external_exports.number().int().min(50).max(5e3).optional().describe(`Poll interval in ms (default ${DEFAULT_POLL_INTERVAL_MS2}).`)
|
|
148008
148468
|
}).strict().superRefine((params, ctx) => {
|
|
148009
|
-
if (params.url.includes(SECRET_PLACEHOLDER_MARKER)) {
|
|
148010
|
-
ctx.addIssue({
|
|
148011
|
-
code: external_exports.ZodIssueCode.custom,
|
|
148012
|
-
path: ["url"],
|
|
148013
|
-
message: "url takes no {{secret:...}} placeholder: a matcher never resolves secrets. Match on another part of the URL."
|
|
148014
|
-
});
|
|
148015
|
-
}
|
|
148016
148469
|
if (params.urlMatch === "matches") {
|
|
148017
|
-
|
|
148018
|
-
|
|
148019
|
-
|
|
148020
|
-
ctx.addIssue({
|
|
148021
|
-
code: external_exports.ZodIssueCode.custom,
|
|
148022
|
-
path: ["url"],
|
|
148023
|
-
message: `url is not a valid regular expression: ${err instanceof Error ? err.message : String(err)}`
|
|
148024
|
-
});
|
|
148470
|
+
const problem = regexProblem(params.url);
|
|
148471
|
+
if (problem) {
|
|
148472
|
+
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["url"], message: `url is ${problem}` });
|
|
148025
148473
|
}
|
|
148026
148474
|
}
|
|
148027
148475
|
});
|
|
148028
148476
|
var CANCELLED_NOTE = "the wait was cancelled before a request matched";
|
|
148029
|
-
function criteriaOf(params) {
|
|
148477
|
+
function criteriaOf(params, ctx) {
|
|
148478
|
+
const secrets = { clientSecrets: ctx?.clientSecrets };
|
|
148479
|
+
const url2 = fillSecrets(params.url, params.urlMatch === "matches", secrets);
|
|
148030
148480
|
return {
|
|
148031
|
-
url:
|
|
148481
|
+
url: url2,
|
|
148482
|
+
...url2 !== params.url ? { urlShown: params.url } : {},
|
|
148032
148483
|
urlMatch: params.urlMatch ?? "contains",
|
|
148033
148484
|
...params.method !== void 0 ? { method: params.method } : {},
|
|
148034
148485
|
...params.status !== void 0 ? { status: params.status } : {},
|
|
148035
|
-
outcome: params.outcome ?? (params.absent ? "sent" : "complete")
|
|
148486
|
+
outcome: params.outcome ?? (params.absent ? "sent" : "complete"),
|
|
148487
|
+
...params.header ? { header: headerCheckOf(params.header, secrets, (name) => isSensitiveHeader(name)) } : {},
|
|
148488
|
+
...params.requestBody ? { requestBody: valueCheckOf(params.requestBody, secrets) } : {},
|
|
148489
|
+
...params.responseBody ? { responseBody: valueCheckOf(params.responseBody, secrets) } : {}
|
|
148036
148490
|
};
|
|
148037
148491
|
}
|
|
148038
148492
|
function notStartedError(params) {
|
|
@@ -148054,7 +148508,7 @@ function createAwaitNetworkRequestTool(registry2) {
|
|
|
148054
148508
|
// A literal, so scripts/extract-tools.mjs finds the description it scores.
|
|
148055
148509
|
id: "await-network-request",
|
|
148056
148510
|
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\`.`,
|
|
148511
|
+
Pass \`match.id\` to \`view-network-request-details\`. \`values\` shows previews of matched values and redacts sensitive headers. A header claim check can show the claim. Check \`cause\` and \`note\` on failure. \`success: false\` fails an e2e step and stops \`run-sequence\`.`,
|
|
148058
148512
|
zodSchema: zodSchema45,
|
|
148059
148513
|
searchHint: "wait await network request http api call fetch xhr response status url match after capture start e2e assert",
|
|
148060
148514
|
readOnly: true,
|
|
@@ -148081,9 +148535,11 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148081
148535
|
if (device.platform === "macos") {
|
|
148082
148536
|
assertMacosAppBundle(parseMacosAppBundleId(device.id) ?? device.id, params.bundleId);
|
|
148083
148537
|
}
|
|
148084
|
-
const layers = await markedLayers(registry2, device, params.bundleId
|
|
148538
|
+
const layers = await markedLayers(registry2, device, params.bundleId, {
|
|
148539
|
+
headers: params.header !== void 0
|
|
148540
|
+
});
|
|
148085
148541
|
if (layers.length === 0) throw notStartedError(params);
|
|
148086
|
-
const criteria = criteriaOf(params);
|
|
148542
|
+
const criteria = criteriaOf(params, ctx);
|
|
148087
148543
|
const atStart = networkSecrets(ctx);
|
|
148088
148544
|
let redact2 = networkRedactorOf(atStart);
|
|
148089
148545
|
const readSecretsAgain = () => {
|
|
@@ -148135,7 +148591,109 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148135
148591
|
jsRead = read;
|
|
148136
148592
|
return read;
|
|
148137
148593
|
};
|
|
148138
|
-
const
|
|
148594
|
+
const bodyChecks = BODY_CRITERIA.filter((name) => criteria[name] !== void 0);
|
|
148595
|
+
const keyOf = (record2) => `${record2.layer} ${record2.install ?? ""} ${record2.id}`;
|
|
148596
|
+
const bodies = /* @__PURE__ */ new Map();
|
|
148597
|
+
const judged = /* @__PURE__ */ new Map();
|
|
148598
|
+
const ended = (record2) => !isOpen2(record2) && record2.state !== "pending";
|
|
148599
|
+
const readBody = async (layer, record2, kind) => {
|
|
148600
|
+
const key2 = `${keyOf(record2)} ${kind}`;
|
|
148601
|
+
const kept = bodies.get(key2);
|
|
148602
|
+
if (kept) return kept;
|
|
148603
|
+
if (kind === "response" && record2.state === "failed") {
|
|
148604
|
+
const failed3 = record2.status === void 0 ? { kind: "none" } : {
|
|
148605
|
+
kind: "unknown",
|
|
148606
|
+
reason: "the request failed after its response began, so its body is not whole",
|
|
148607
|
+
final: true
|
|
148608
|
+
};
|
|
148609
|
+
bodies.set(key2, failed3);
|
|
148610
|
+
return failed3;
|
|
148611
|
+
}
|
|
148612
|
+
if (kind === "response" && record2.state === "lost") {
|
|
148613
|
+
const lost = {
|
|
148614
|
+
kind: "unknown",
|
|
148615
|
+
reason: "argent lost sight of the request before it ended",
|
|
148616
|
+
final: true
|
|
148617
|
+
};
|
|
148618
|
+
bodies.set(key2, lost);
|
|
148619
|
+
return lost;
|
|
148620
|
+
}
|
|
148621
|
+
const budget = Math.min(MAX_BODY_READ_MS, deadline + BODY_READ_GRACE_MS - Date.now());
|
|
148622
|
+
if (budget <= 0) {
|
|
148623
|
+
return {
|
|
148624
|
+
kind: "unknown",
|
|
148625
|
+
reason: "the wait ended before the body was read",
|
|
148626
|
+
final: false
|
|
148627
|
+
};
|
|
148628
|
+
}
|
|
148629
|
+
const settled = await settleWithin(layer.body(record2, kind, budget), budget, signal);
|
|
148630
|
+
const body = settled.type === "value" ? settled.value : {
|
|
148631
|
+
kind: "unknown",
|
|
148632
|
+
reason: settled.type === "timeout" ? `the body was not read within ${budget} ms` : settled.type === "aborted" ? CANCELLED_NOTE : settled.error,
|
|
148633
|
+
final: false
|
|
148634
|
+
};
|
|
148635
|
+
if (body.kind === "unknown" ? body.final : ended(record2)) bodies.set(key2, body);
|
|
148636
|
+
return body;
|
|
148637
|
+
};
|
|
148638
|
+
const judge = async (layer, record2) => {
|
|
148639
|
+
const verdicts = [];
|
|
148640
|
+
for (const name of bodyChecks) {
|
|
148641
|
+
if (name === "header") {
|
|
148642
|
+
verdicts.push({
|
|
148643
|
+
name,
|
|
148644
|
+
verdict: record2.headersPending ? {
|
|
148645
|
+
verdict: "unknown",
|
|
148646
|
+
reason: `header ${criteria.header.name}: the headers sent on the wire are not known yet`
|
|
148647
|
+
} : checkHeader(criteria.header, record2.requestHeaders)
|
|
148648
|
+
});
|
|
148649
|
+
} else {
|
|
148650
|
+
const kind = name === "requestBody" ? "request" : "response";
|
|
148651
|
+
const body = await readBody(layer, record2, kind);
|
|
148652
|
+
verdicts.push({ name, verdict: checkValue(criteria[name], body, `${kind} body`) });
|
|
148653
|
+
}
|
|
148654
|
+
if (verdicts.at(-1).verdict.verdict === "fail") break;
|
|
148655
|
+
}
|
|
148656
|
+
const failed3 = verdicts.filter(({ verdict }) => verdict.verdict === "fail");
|
|
148657
|
+
const open5 = verdicts.filter(({ verdict }) => verdict.verdict === "unknown");
|
|
148658
|
+
const missed = failed3.length > 0 ? failed3 : open5;
|
|
148659
|
+
const judgement = {
|
|
148660
|
+
mismatch: missed.map(({ name }) => name),
|
|
148661
|
+
...missed.length > 0 ? { reason: missed.map(({ verdict }) => verdict.reason).join("; ") } : {},
|
|
148662
|
+
values: Object.fromEntries(
|
|
148663
|
+
verdicts.flatMap(
|
|
148664
|
+
({ name, verdict }) => verdict.verdict === "pass" ? [[name, verdict.value]] : []
|
|
148665
|
+
)
|
|
148666
|
+
),
|
|
148667
|
+
/** Not judged: a body argent could not read whole. */
|
|
148668
|
+
unknown: failed3.length === 0 && open5.length > 0
|
|
148669
|
+
};
|
|
148670
|
+
judged.set(keyOf(record2), judgement);
|
|
148671
|
+
return judgement;
|
|
148672
|
+
};
|
|
148673
|
+
const matchIn = async (layer, records) => {
|
|
148674
|
+
if (bodyChecks.length === 0) {
|
|
148675
|
+
const record2 = firstMatch(criteria, records);
|
|
148676
|
+
return record2 && { record: record2 };
|
|
148677
|
+
}
|
|
148678
|
+
for (const record2 of records) {
|
|
148679
|
+
if (mismatches(criteria, record2).length > 0) continue;
|
|
148680
|
+
const { mismatch: mismatch2, values } = await judge(layer, record2);
|
|
148681
|
+
if (mismatch2.length === 0) return { record: withoutStart(record2), values };
|
|
148682
|
+
if (signal?.aborted) return void 0;
|
|
148683
|
+
}
|
|
148684
|
+
return void 0;
|
|
148685
|
+
};
|
|
148686
|
+
const cut = (text) => {
|
|
148687
|
+
const redacted = redact2(text);
|
|
148688
|
+
return redacted.length > SHOWN_VALUE_CHARS ? `${redacted.slice(0, SHOWN_VALUE_CHARS)}...` : redacted;
|
|
148689
|
+
};
|
|
148690
|
+
const shownValues = (values) => {
|
|
148691
|
+
if (!values || Object.keys(values).length === 0) return {};
|
|
148692
|
+
return {
|
|
148693
|
+
values: Object.fromEntries(Object.entries(values).map(([k, v]) => [k, cut(v)]))
|
|
148694
|
+
};
|
|
148695
|
+
};
|
|
148696
|
+
const success2 = (match, values) => {
|
|
148139
148697
|
readSecretsAgain();
|
|
148140
148698
|
const notes = [...notesSeen].flatMap(
|
|
148141
148699
|
([layer, seen]) => [...seen].map((note) => `${layer}: ${redact2(note)}`)
|
|
@@ -148144,10 +148702,14 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148144
148702
|
success: true,
|
|
148145
148703
|
elapsed: elapsed(),
|
|
148146
148704
|
match: shown(match),
|
|
148705
|
+
...shownValues(values),
|
|
148147
148706
|
...notes.length > 0 ? { note: notes.join("; ") } : {}
|
|
148148
148707
|
};
|
|
148149
148708
|
};
|
|
148150
|
-
const found = (
|
|
148709
|
+
const found = ({
|
|
148710
|
+
record: record2,
|
|
148711
|
+
values
|
|
148712
|
+
}) => params.absent ? sentWhileAbsent(record2, values) : success2(record2, values);
|
|
148151
148713
|
for (; ; ) {
|
|
148152
148714
|
const atDeadline = Date.now() >= deadline;
|
|
148153
148715
|
if (signal?.aborted) {
|
|
@@ -148159,7 +148721,7 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148159
148721
|
const read = { ...await layer.read(0), from: from2, at: Date.now() };
|
|
148160
148722
|
keep(read);
|
|
148161
148723
|
reads.push(read);
|
|
148162
|
-
const match =
|
|
148724
|
+
const match = await matchIn(layer, read.records);
|
|
148163
148725
|
if (match) return found(match);
|
|
148164
148726
|
}
|
|
148165
148727
|
const remaining = deadline - Date.now();
|
|
@@ -148177,7 +148739,7 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148177
148739
|
}
|
|
148178
148740
|
if (pending.type === "value") {
|
|
148179
148741
|
keep(pending.value);
|
|
148180
|
-
const match =
|
|
148742
|
+
const match = await matchIn(js, pending.value.records);
|
|
148181
148743
|
if (match) return found(match);
|
|
148182
148744
|
}
|
|
148183
148745
|
}
|
|
@@ -148189,7 +148751,7 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148189
148751
|
if (settled.type === "value") {
|
|
148190
148752
|
keep(settled.value);
|
|
148191
148753
|
reads.push(settled.value);
|
|
148192
|
-
const match =
|
|
148754
|
+
const match = await matchIn(js, settled.value.records);
|
|
148193
148755
|
if (match) return found(match);
|
|
148194
148756
|
} else if (settled.type === "timeout" && bound < jsBound && latest.has("js")) {
|
|
148195
148757
|
} else {
|
|
@@ -148242,7 +148804,7 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148242
148804
|
(s) => `${s.layer} ${s.readable ? s.requests : "not read"}${s.armed ? "" : " (not armed)"}`
|
|
148243
148805
|
).join(", ");
|
|
148244
148806
|
}
|
|
148245
|
-
function sentWhileAbsent(match) {
|
|
148807
|
+
function sentWhileAbsent(match, values) {
|
|
148246
148808
|
readSecretsAgain();
|
|
148247
148809
|
const shownMatch = shown(match);
|
|
148248
148810
|
return {
|
|
@@ -148250,6 +148812,7 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148250
148812
|
elapsed: elapsed(),
|
|
148251
148813
|
cause: "unmet",
|
|
148252
148814
|
match: shownMatch,
|
|
148815
|
+
...shownValues(values),
|
|
148253
148816
|
note: `A request that must not be sent was captured since network-capture-start (forbidden: ${describeCriteria(criteria)}): ${describeRecord(shownMatch)}.`,
|
|
148254
148817
|
layers: layerSummaries()
|
|
148255
148818
|
};
|
|
@@ -148272,6 +148835,17 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148272
148835
|
);
|
|
148273
148836
|
}
|
|
148274
148837
|
}
|
|
148838
|
+
const candidates = [...latestReadable.values()].flatMap(
|
|
148839
|
+
(read) => read.records.filter((record2) => mismatches(criteria, record2).length === 0)
|
|
148840
|
+
);
|
|
148841
|
+
for (const record2 of candidates) {
|
|
148842
|
+
const judgement = judged.get(keyOf(record2));
|
|
148843
|
+
if (judgement?.unknown) {
|
|
148844
|
+
unproven.push(
|
|
148845
|
+
`${record2.layer} ${record2.id}: ${redact2(judgement.reason ?? "its body was not read")}`
|
|
148846
|
+
);
|
|
148847
|
+
}
|
|
148848
|
+
}
|
|
148275
148849
|
const summaries = layerSummaries();
|
|
148276
148850
|
const window2 = allStopped ? "between network-capture-start and network-capture-stop" : `since network-capture-start, watched for ${timeoutMs} ms`;
|
|
148277
148851
|
if (unproven.length > 0) {
|
|
@@ -148294,7 +148868,12 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148294
148868
|
readSecretsAgain();
|
|
148295
148869
|
const summaries = layerSummaries();
|
|
148296
148870
|
const seen = [...latestReadable.values()].flatMap((read) => read.records);
|
|
148297
|
-
const misses = nearMisses(criteria, seen).map(
|
|
148871
|
+
const misses = nearMisses(criteria, seen, (record2) => judged.get(keyOf(record2))).map(
|
|
148872
|
+
(miss) => ({
|
|
148873
|
+
...shown(miss),
|
|
148874
|
+
...miss.reason !== void 0 ? { reason: cut(miss.reason) } : {}
|
|
148875
|
+
})
|
|
148876
|
+
);
|
|
148298
148877
|
const counts = requestCounts(summaries);
|
|
148299
148878
|
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)}).`;
|
|
148300
148879
|
const notes = summaries.filter((s) => s.note).map((s) => `${s.layer}: ${s.note}`).join("; ");
|
|
@@ -168300,7 +168879,7 @@ function unmetWaitWarningFor(cause, block) {
|
|
|
168300
168879
|
return unmetWaitWarning(block);
|
|
168301
168880
|
}
|
|
168302
168881
|
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";
|
|
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";
|
|
168882
|
+
var UNREADABLE_NETWORK_WAIT_WARNING = "recorded, but a capture layer or a body 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";
|
|
168304
168883
|
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";
|
|
168305
168884
|
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
168885
|
function unmetNetworkWaitWarningFor(cause, absent) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swmansion/argent",
|
|
3
|
-
"version": "0.35.1-next.
|
|
3
|
+
"version": "0.35.1-next.42",
|
|
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": "
|
|
101
|
+
"gitHead": "8fd7190b502237688fdd9bef4570c77b67d9feb3"
|
|
102
102
|
}
|
|
@@ -158,7 +158,8 @@ A warning does not reject the step. If `e2e-finish-recording` reports dropped wa
|
|
|
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
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.
|
|
161
|
-
-
|
|
161
|
+
- When recording a URL, body, or header comparison against a secret, use `{{secret:NAME}}` in the step.
|
|
162
|
+
- Keep the wait as a raw `tool:` step. A log listing can pass with an empty log. 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.
|
|
162
163
|
- 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.
|
|
163
164
|
- 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`.
|
|
164
165
|
- 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.
|
|
@@ -44,8 +44,8 @@ If `debugger-reload-metro` fails to reload the Mac app, use `restart-app` for an
|
|
|
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
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`,
|
|
47
|
+
3. Use `await-network-request` to check for a match, or set `absent: true` to check that none appears. Add a body or request header check when the URL and status alone cannot identify the expected call. 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`, use `note` to find what Argent could not verify. If capture had a gap, 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.
|