@swmansion/argent 0.35.1-next.40 → 0.35.1-next.41
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 +31 -1
- package/dist/tool-server.cjs +529 -56
- 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,36 @@ 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 a request body using exactly one of `equals`, `contains`, `matches`, or `exists`. */
|
|
34
|
+
requestBody?: {
|
|
35
|
+
/** JSON field specified as keys and array indexes joined by dots, e.g. `data.items.0.id`. Omit to use the whole body. */
|
|
36
|
+
path?: 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
|
+
/** Use the same check as `requestBody` on a finished response. */
|
|
49
|
+
responseBody?: {
|
|
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
|
+
};
|
|
33
63
|
/** Set to true to fail on the first match and require complete capture to pass. */
|
|
34
64
|
absent?: boolean;
|
|
35
65
|
/** 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
|
|
|
@@ -105556,6 +105567,7 @@ function createNetworkManager(deps) {
|
|
|
105556
105567
|
rec.url = r.url ?? rec.url;
|
|
105557
105568
|
if (r.headers) rec.requestHeaders = { ...rec.requestHeaders ?? {}, ...r.headers };
|
|
105558
105569
|
if (r.postData != null) rec.postData = r.postData;
|
|
105570
|
+
if (r.hasPostData) rec.hasPostData = true;
|
|
105559
105571
|
rec.resourceType = params.type ?? rec.resourceType;
|
|
105560
105572
|
rec.initiator = params.initiator ?? rec.initiator;
|
|
105561
105573
|
rec.startTs = params.timestamp ?? rec.startTs;
|
|
@@ -131192,6 +131204,8 @@ var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
|
|
|
131192
131204
|
// Expo hands its native request the body as bytes: they show as text when they are UTF-8.
|
|
131193
131205
|
var post = utf8Text(entry.postBytes);
|
|
131194
131206
|
entry.request.postData = post === undefined ? '[binary ' + entry.postSize + ' bytes]' : post;
|
|
131207
|
+
// Without a decoder, the bytes may be text.
|
|
131208
|
+
if (post === undefined) entry.request.postDataShown = typeof TextDecoder === 'function' ? 'binary' : 'bytes';
|
|
131195
131209
|
if (post !== undefined && entry.postSize > BODY_CAP) entry.request.postDataTruncated = true;
|
|
131196
131210
|
delete entry.postBytes;
|
|
131197
131211
|
delete entry.postSize;
|
|
@@ -131212,21 +131226,26 @@ var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
|
|
|
131212
131226
|
}
|
|
131213
131227
|
g.__argent_network_decode = decodeBodies;
|
|
131214
131228
|
|
|
131215
|
-
// What a request body shows,
|
|
131229
|
+
// What a request body shows, whether that is only its start, and what stands in for a body
|
|
131230
|
+
// that is not text (shown: 'form', 'blob' or 'binary').
|
|
131216
131231
|
function describeBody(body) {
|
|
131217
|
-
var text;
|
|
131232
|
+
var text, shown;
|
|
131218
131233
|
try {
|
|
131219
131234
|
if (body == null) return undefined;
|
|
131220
131235
|
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]';
|
|
131236
|
+
else if (typeof FormData === 'function' && body instanceof FormData) { text = describeFormData(body); shown = 'form'; }
|
|
131237
|
+
else if (typeof Blob === 'function' && body instanceof Blob) { text = '[Blob ' + body.size + ' bytes]'; shown = 'blob'; }
|
|
131223
131238
|
else if (typeof Uint8Array === 'function' && body instanceof Uint8Array) return { bytes: keepBytes(body), size: body.byteLength };
|
|
131224
131239
|
else if (typeof ArrayBuffer === 'function' && (body instanceof ArrayBuffer || ArrayBuffer.isView(body))) {
|
|
131225
131240
|
text = '[binary ' + body.byteLength + ' bytes]';
|
|
131241
|
+
// Bytes the interceptor does not read, which may be text.
|
|
131242
|
+
shown = 'bytes';
|
|
131226
131243
|
}
|
|
131227
131244
|
} catch (e) {}
|
|
131228
131245
|
if (text === undefined) return undefined;
|
|
131229
|
-
|
|
131246
|
+
var out = text.length > BODY_CAP ? { text: text.slice(0, BODY_CAP), cut: true } : { text: text, cut: false };
|
|
131247
|
+
if (shown) out.shown = shown;
|
|
131248
|
+
return out;
|
|
131230
131249
|
}
|
|
131231
131250
|
|
|
131232
131251
|
function createRecord(resourceType, method, url, headers, body, startedAt) {
|
|
@@ -131246,6 +131265,7 @@ var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
|
|
|
131246
131265
|
} else if (postData) {
|
|
131247
131266
|
entry.request.postData = postData.text;
|
|
131248
131267
|
if (postData.cut) entry.request.postDataTruncated = true;
|
|
131268
|
+
if (postData.shown) entry.request.postDataShown = postData.shown;
|
|
131249
131269
|
}
|
|
131250
131270
|
log.push(entry);
|
|
131251
131271
|
byId[entry.requestId] = entry;
|
|
@@ -145807,6 +145827,134 @@ async function readNativeBody(read, framing, redact2) {
|
|
|
145807
145827
|
}
|
|
145808
145828
|
return body.truncated ? cutByAgent(text, mimeType, kept.length, framing, redact2, body.incomplete) : truncateBody(text, mimeType, redact2);
|
|
145809
145829
|
}
|
|
145830
|
+
var CUT_AT_CAPTURE = "the capture kept only the start of the body";
|
|
145831
|
+
async function nativeBodyText(record2, bodies, kind) {
|
|
145832
|
+
const id = record2.id;
|
|
145833
|
+
if (kind === "request") {
|
|
145834
|
+
if (!record2.request.hasPostData) return { kind: "none" };
|
|
145835
|
+
const bodyHeaders = record2.redirects?.[0]?.requestHeaders ?? record2.request.wireHeaders ?? {};
|
|
145836
|
+
const requestHeader = (name) => headerValue(bodyHeaders, name) || headerValue(record2.request.headers, name);
|
|
145837
|
+
return decodedNativeText(() => bodies.requestPostData(id), {
|
|
145838
|
+
contentType: requestHeader("content-type"),
|
|
145839
|
+
contentEncoding: requestHeader("content-encoding")
|
|
145840
|
+
});
|
|
145841
|
+
}
|
|
145842
|
+
if (record2.state !== "complete" || !record2.response) {
|
|
145843
|
+
return { kind: "unknown", reason: "the response has not finished", final: false };
|
|
145844
|
+
}
|
|
145845
|
+
if (record2.encodedDataLength === 0) return { kind: "none" };
|
|
145846
|
+
return decodedNativeText(() => bodies.responseBody(id), {
|
|
145847
|
+
mimeType: record2.response.mimeType,
|
|
145848
|
+
contentType: headerValue(record2.response.headers, "content-type"),
|
|
145849
|
+
// An iOS or Mac app response body is read decoded, so its Content-Encoding is not applied again.
|
|
145850
|
+
contentEncoding: record2.layer === "ios-native" || record2.layer === "macos-native" ? "" : headerValue(record2.response.headers, "content-encoding")
|
|
145851
|
+
});
|
|
145852
|
+
}
|
|
145853
|
+
async function decodedNativeText(read, framing) {
|
|
145854
|
+
const mimeType = framing.mimeType ?? framing.contentType.split(";")[0].trim();
|
|
145855
|
+
let body;
|
|
145856
|
+
try {
|
|
145857
|
+
body = await read();
|
|
145858
|
+
} catch (err) {
|
|
145859
|
+
return {
|
|
145860
|
+
kind: "unknown",
|
|
145861
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
145862
|
+
final: false
|
|
145863
|
+
};
|
|
145864
|
+
}
|
|
145865
|
+
if (!body.available) return { kind: "unknown", reason: body.reason ?? "no body", final: false };
|
|
145866
|
+
if (body.truncated || body.incomplete) {
|
|
145867
|
+
return { kind: "unknown", reason: CUT_AT_CAPTURE, final: true };
|
|
145868
|
+
}
|
|
145869
|
+
const tooLarge = {
|
|
145870
|
+
kind: "unknown",
|
|
145871
|
+
reason: `the body decodes to more than ${MAX_DECODED_BODY_BYTES / (1024 * 1024)} MiB`,
|
|
145872
|
+
final: true
|
|
145873
|
+
};
|
|
145874
|
+
const binary = { kind: "binary", mimeType };
|
|
145875
|
+
const codings = contentCodings(framing.contentEncoding).length > 0;
|
|
145876
|
+
if (body.inlineChars !== void 0) {
|
|
145877
|
+
if (BINARY_BODY_TYPES.test(mimeType.toLowerCase())) return binary;
|
|
145878
|
+
if (!codings)
|
|
145879
|
+
return { kind: "text", text: inDeclaredCharset(body.body, framing.contentType, false) };
|
|
145880
|
+
} else if (!body.base64Encoded && !codings) {
|
|
145881
|
+
return { kind: "text", text: inDeclaredCharset(body.body, framing.contentType, false) };
|
|
145882
|
+
}
|
|
145883
|
+
const kept = Buffer.from(body.body, body.base64Encoded ? "base64" : "utf8");
|
|
145884
|
+
const bytes = decodeContent2(kept, framing.contentEncoding);
|
|
145885
|
+
if (!bytes) return tooLarge;
|
|
145886
|
+
if (!body.base64Encoded && bytes === kept) {
|
|
145887
|
+
return { kind: "text", text: inDeclaredCharset(body.body, framing.contentType, false) };
|
|
145888
|
+
}
|
|
145889
|
+
const text = decodeText(bytes, charsetOf(framing.contentType), false);
|
|
145890
|
+
return text === null ? binary : { kind: "text", text };
|
|
145891
|
+
}
|
|
145892
|
+
var PLACEHOLDER_BODY = /^\[(FormData\]|Blob \d+ bytes\]$|binary \d+ bytes\]$)/;
|
|
145893
|
+
function bodiless(method, status) {
|
|
145894
|
+
return method?.toUpperCase() === "HEAD" || status === 204 || status === 304 || status !== void 0 && status >= 100 && status < 200;
|
|
145895
|
+
}
|
|
145896
|
+
function jsBodyText(entry, kind) {
|
|
145897
|
+
if (kind === "request") {
|
|
145898
|
+
const post = entry.request?.postData;
|
|
145899
|
+
if (post == null) return { kind: "none" };
|
|
145900
|
+
const shown = entry.request?.postDataShown ?? (PLACEHOLDER_BODY.test(post) ? "described" : void 0);
|
|
145901
|
+
if (shown === "binary") {
|
|
145902
|
+
const type = Object.entries(entry.request?.headers ?? {}).find(
|
|
145903
|
+
([name]) => name.toLowerCase() === "content-type"
|
|
145904
|
+
);
|
|
145905
|
+
return { kind: "binary", mimeType: type?.[1] ?? "" };
|
|
145906
|
+
}
|
|
145907
|
+
if (shown === "form" || shown === "blob" || shown === "described") {
|
|
145908
|
+
const what = shown === "form" ? "a FormData body" : shown === "blob" ? "a Blob body" : "a body";
|
|
145909
|
+
return {
|
|
145910
|
+
kind: "unknown",
|
|
145911
|
+
reason: `the app sent ${what} that the capture keeps only as a description`,
|
|
145912
|
+
final: true
|
|
145913
|
+
};
|
|
145914
|
+
}
|
|
145915
|
+
if (shown === "bytes") {
|
|
145916
|
+
return {
|
|
145917
|
+
kind: "unknown",
|
|
145918
|
+
reason: "the app sent the body as bytes, which the capture did not decode",
|
|
145919
|
+
final: true
|
|
145920
|
+
};
|
|
145921
|
+
}
|
|
145922
|
+
if (entry.request?.postDataTruncated) {
|
|
145923
|
+
return { kind: "unknown", reason: CUT_AT_CAPTURE, final: true };
|
|
145924
|
+
}
|
|
145925
|
+
return { kind: "text", text: post };
|
|
145926
|
+
}
|
|
145927
|
+
if (entry.state !== "finished") {
|
|
145928
|
+
return { kind: "unknown", reason: "the response has not finished", final: false };
|
|
145929
|
+
}
|
|
145930
|
+
if (entry.bodyOmitted) return { kind: "binary", mimeType: entry.response?.mimeType ?? "" };
|
|
145931
|
+
if (entry.bodyTruncated) return { kind: "unknown", reason: CUT_AT_CAPTURE, final: true };
|
|
145932
|
+
if (entry.responseBody == null) {
|
|
145933
|
+
if (bodiless(entry.request?.method, entry.response?.status) || entry.encodedDataLength === 0) {
|
|
145934
|
+
return { kind: "none" };
|
|
145935
|
+
}
|
|
145936
|
+
return {
|
|
145937
|
+
kind: "unknown",
|
|
145938
|
+
reason: "the capture did not keep the response body",
|
|
145939
|
+
final: entry.encodedDataLength !== void 0
|
|
145940
|
+
};
|
|
145941
|
+
}
|
|
145942
|
+
return { kind: "text", text: entry.responseBody };
|
|
145943
|
+
}
|
|
145944
|
+
async function chromiumBodyText(cdp, rec, kind) {
|
|
145945
|
+
if (kind === "request") {
|
|
145946
|
+
if (rec.postData != null) return { kind: "text", text: rec.postData };
|
|
145947
|
+
return rec.hasPostData ? { kind: "unknown", reason: "Chrome did not report the request body", final: true } : { kind: "none" };
|
|
145948
|
+
}
|
|
145949
|
+
if (!rec.finished || rec.failed) {
|
|
145950
|
+
return { kind: "unknown", reason: "the response has not finished", final: false };
|
|
145951
|
+
}
|
|
145952
|
+
const out = await chromiumResponseBody(cdp, rec);
|
|
145953
|
+
if (!out)
|
|
145954
|
+
return { kind: "unknown", reason: "Chrome holds no body for the response", final: false };
|
|
145955
|
+
const body = out.base64Encoded ? utf8Text(Buffer.from(out.body, "base64")) : out.body;
|
|
145956
|
+
return typeof body === "string" ? { kind: "text", text: body } : { kind: "binary", mimeType: rec.mimeType ?? "" };
|
|
145957
|
+
}
|
|
145810
145958
|
function inDeclaredCharset(text, contentType, truncated) {
|
|
145811
145959
|
if (namesUtf8(contentType)) return text;
|
|
145812
145960
|
return decodeText(Buffer.from(text, "utf8"), charsetOf(contentType), truncated) ?? text;
|
|
@@ -147528,6 +147676,14 @@ init_device_info();
|
|
|
147528
147676
|
init_capability();
|
|
147529
147677
|
|
|
147530
147678
|
// ../tool-server/src/tools/await-network-request/layers.ts
|
|
147679
|
+
function unknownBody(reason2, final = false) {
|
|
147680
|
+
return { kind: "unknown", reason: reason2, final };
|
|
147681
|
+
}
|
|
147682
|
+
function nativeBody(store, record2, kind) {
|
|
147683
|
+
const held = store?.record(record2.id);
|
|
147684
|
+
if (!store || !held) return Promise.resolve(unknownBody(CAPTURE_ENDED));
|
|
147685
|
+
return nativeBodyText(held, store, kind).catch((err) => unknownBody(errorMessage4(err)));
|
|
147686
|
+
}
|
|
147531
147687
|
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
147688
|
var SWEEP_UNDER_WAY = "stop-all-simulator-servers or the tool-server's exit is ending the app's capture";
|
|
147533
147689
|
var STOPPED_UNARMED = "the layer was not armed when network-capture-stop stopped it, so it may have missed requests in the window";
|
|
@@ -147612,6 +147768,9 @@ async function iosLayer(registry2, device, bundleId, startWindow) {
|
|
|
147612
147768
|
if (!startWindow.current("ios-native", found.isNetworkCaptureStopped(bundleId))) return void 0;
|
|
147613
147769
|
return {
|
|
147614
147770
|
layer: "ios-native",
|
|
147771
|
+
async body(record2, kind) {
|
|
147772
|
+
return nativeBody((await resolve24())?.networkRecords(bundleId), record2, kind);
|
|
147773
|
+
},
|
|
147615
147774
|
async read() {
|
|
147616
147775
|
const api = await resolve24();
|
|
147617
147776
|
const mark = api?.networkCaptureMark(bundleId);
|
|
@@ -147646,6 +147805,9 @@ async function androidLayer(registry2, device, bundleId, startWindow) {
|
|
|
147646
147805
|
if (!startWindow.current("android-native", found.isStopped())) return void 0;
|
|
147647
147806
|
return {
|
|
147648
147807
|
layer: "android-native",
|
|
147808
|
+
async body(record2, kind) {
|
|
147809
|
+
return nativeBody(await resolve24(), record2, kind);
|
|
147810
|
+
},
|
|
147649
147811
|
async read() {
|
|
147650
147812
|
const api = await resolve24();
|
|
147651
147813
|
const mark = api?.captureMark();
|
|
@@ -147683,6 +147845,9 @@ async function macosLayer(registry2, device, startWindow) {
|
|
|
147683
147845
|
if (!startWindow.current("macos-native", found.isNetworkCaptureStopped())) return void 0;
|
|
147684
147846
|
return {
|
|
147685
147847
|
layer: "macos-native",
|
|
147848
|
+
async body(record2, kind) {
|
|
147849
|
+
return nativeBody((await resolve24())?.networkRecords(), record2, kind);
|
|
147850
|
+
},
|
|
147686
147851
|
async read() {
|
|
147687
147852
|
const app = await resolve24();
|
|
147688
147853
|
const mark = app?.networkCaptureMark();
|
|
@@ -147727,6 +147892,14 @@ async function chromiumLayer(registry2, device) {
|
|
|
147727
147892
|
if (!(await resolve24())?.server.network.captureMark()) return void 0;
|
|
147728
147893
|
return {
|
|
147729
147894
|
layer: "chromium",
|
|
147895
|
+
async body(record2, kind) {
|
|
147896
|
+
const api = await resolve24();
|
|
147897
|
+
const rec = api?.server.network.get(record2.id);
|
|
147898
|
+
if (!api || !rec) return unknownBody("argent no longer holds the request", true);
|
|
147899
|
+
return chromiumBodyText(api.cdp, rec, kind).catch(
|
|
147900
|
+
(err) => unknownBody(errorMessage4(err))
|
|
147901
|
+
);
|
|
147902
|
+
},
|
|
147730
147903
|
async read() {
|
|
147731
147904
|
const network = (await resolve24())?.server.network;
|
|
147732
147905
|
const mark = network?.captureMark();
|
|
@@ -147744,7 +147917,7 @@ async function chromiumLayer(registry2, device) {
|
|
|
147744
147917
|
}
|
|
147745
147918
|
};
|
|
147746
147919
|
}
|
|
147747
|
-
function fromJs(entry) {
|
|
147920
|
+
function fromJs(entry, install) {
|
|
147748
147921
|
const state3 = entry.state === "finished" ? "complete" : entry.state === "failed" ? "failed" : entry.status !== void 0 ? "headers" : "pending";
|
|
147749
147922
|
return {
|
|
147750
147923
|
id: entry.requestId ?? "",
|
|
@@ -147755,7 +147928,8 @@ function fromJs(entry) {
|
|
|
147755
147928
|
state: state3,
|
|
147756
147929
|
...typeof entry.durationMs === "number" ? { durationMs: Math.round(entry.durationMs) } : {},
|
|
147757
147930
|
...entry.errorText ? { errorText: entry.errorText } : {},
|
|
147758
|
-
...typeof entry.timestamp === "number" ? { startedAt: entry.timestamp * 1e3 } : {}
|
|
147931
|
+
...typeof entry.timestamp === "number" ? { startedAt: entry.timestamp * 1e3 } : {},
|
|
147932
|
+
...install ? { install } : {}
|
|
147759
147933
|
};
|
|
147760
147934
|
}
|
|
147761
147935
|
function jsLayer(registry2, device, bundleId, startWindow) {
|
|
@@ -147764,6 +147938,34 @@ function jsLayer(registry2, device, bundleId, startWindow) {
|
|
|
147764
147938
|
if (!startWindow.current("js", found.capture.intent === "stopped")) return void 0;
|
|
147765
147939
|
return {
|
|
147766
147940
|
layer: "js",
|
|
147941
|
+
async body(record2, kind, budgetMs) {
|
|
147942
|
+
const found2 = findJsCaptureOfDevice(device.id, bundleId);
|
|
147943
|
+
if (!found2?.capture.mark) return unknownBody(CAPTURE_ENDED);
|
|
147944
|
+
const physical = found2.capture.physicalDeviceId ?? device.id;
|
|
147945
|
+
if (captureSweepUnderWay(physical)) return unknownBody(SWEEP_UNDER_WAY);
|
|
147946
|
+
const urn = `${JS_RUNTIME_DEBUGGER_NAMESPACE}:${found2.payload}`;
|
|
147947
|
+
if (!isLiveService(registry2, urn)) {
|
|
147948
|
+
return unknownBody("the app's JS runtime is not connected");
|
|
147949
|
+
}
|
|
147950
|
+
try {
|
|
147951
|
+
const dbg = await registry2.resolveService(urn);
|
|
147952
|
+
const read = makeNetworkDetailReadScript(record2.id);
|
|
147953
|
+
const script = record2.install === void 0 ? read : `(globalThis.__argent_network_install === ${JSON.stringify(record2.install)} ? ${read} : JSON.stringify({ reloaded: true }))`;
|
|
147954
|
+
const answer = JSON.parse(
|
|
147955
|
+
String(await dbg.cdp.evaluate(script, { timeout: Math.max(1, budgetMs) }))
|
|
147956
|
+
);
|
|
147957
|
+
if ("reloaded" in answer) {
|
|
147958
|
+
return unknownBody(
|
|
147959
|
+
"the app's JS runtime reloaded since the request, which cleared its body",
|
|
147960
|
+
true
|
|
147961
|
+
);
|
|
147962
|
+
}
|
|
147963
|
+
if ("error" in answer) return unknownBody(`the app's JS runtime: ${answer.error}`, true);
|
|
147964
|
+
return jsBodyText(answer, kind);
|
|
147965
|
+
} catch (err) {
|
|
147966
|
+
return unknownBody(`the app's JS runtime did not answer: ${errorMessage4(err)}`);
|
|
147967
|
+
}
|
|
147968
|
+
},
|
|
147767
147969
|
async read(budgetMs) {
|
|
147768
147970
|
const found2 = findJsCaptureOfDevice(device.id, bundleId);
|
|
147769
147971
|
const mark = found2?.capture.mark;
|
|
@@ -147856,7 +148058,7 @@ function jsLayer(registry2, device, bundleId, startWindow) {
|
|
|
147856
148058
|
readable: true,
|
|
147857
148059
|
armed: false,
|
|
147858
148060
|
stopped,
|
|
147859
|
-
records: (answer.entries ?? []).map(fromJs),
|
|
148061
|
+
records: (answer.entries ?? []).map((entry) => fromJs(entry, answer.token)),
|
|
147860
148062
|
note
|
|
147861
148063
|
};
|
|
147862
148064
|
}
|
|
@@ -147878,7 +148080,7 @@ function jsLayer(registry2, device, bundleId, startWindow) {
|
|
|
147878
148080
|
readable: true,
|
|
147879
148081
|
armed: true,
|
|
147880
148082
|
stopped,
|
|
147881
|
-
records: (answer.entries ?? []).map(fromJs),
|
|
148083
|
+
records: (answer.entries ?? []).map((entry) => fromJs(entry, answer.token)),
|
|
147882
148084
|
...note ? { note } : {},
|
|
147883
148085
|
...gap ? { gap: true } : {}
|
|
147884
148086
|
};
|
|
@@ -147894,10 +148096,153 @@ function jsLayer(registry2, device, bundleId, startWindow) {
|
|
|
147894
148096
|
};
|
|
147895
148097
|
}
|
|
147896
148098
|
|
|
148099
|
+
// ../tool-server/src/tools/await-network-request/value-check.ts
|
|
148100
|
+
init_zod();
|
|
148101
|
+
init_src();
|
|
148102
|
+
var COMPARATORS = ["equals", "contains", "matches", "exists"];
|
|
148103
|
+
var PATH_HELP = "keys and array indexes joined by dots, e.g. `data.items.0.id`";
|
|
148104
|
+
var valueCheckSchema = external_exports.object({
|
|
148105
|
+
path: external_exports.string().optional().describe(`JSON field specified as ${PATH_HELP}. Omit to use the whole body.`),
|
|
148106
|
+
claim: external_exports.string().optional().describe(
|
|
148107
|
+
"Dot-separated JWT payload claim, such as `consents.analytics`. Accepts a `Bearer ` prefix and reads the payload without validating the signature."
|
|
148108
|
+
),
|
|
148109
|
+
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."),
|
|
148110
|
+
contains: external_exports.string().optional().describe("Case-sensitive substring."),
|
|
148111
|
+
matches: external_exports.string().optional().describe("Case-sensitive JavaScript regular expression."),
|
|
148112
|
+
exists: external_exports.boolean().optional().describe("Use true for a present value or false for a missing or null value.")
|
|
148113
|
+
}).strict().superRefine((check3, ctx) => {
|
|
148114
|
+
const given = COMPARATORS.filter((name) => check3[name] !== void 0);
|
|
148115
|
+
if (given.length !== 1) {
|
|
148116
|
+
ctx.addIssue({
|
|
148117
|
+
code: external_exports.ZodIssueCode.custom,
|
|
148118
|
+
message: `give exactly one of ${COMPARATORS.join(", ")}${given.length ? ` (got ${given.join(", ")})` : ""}`
|
|
148119
|
+
});
|
|
148120
|
+
}
|
|
148121
|
+
for (const key2 of ["path", "claim"]) {
|
|
148122
|
+
if (check3[key2] !== void 0 && !isValuePath(check3[key2])) {
|
|
148123
|
+
ctx.addIssue({
|
|
148124
|
+
code: external_exports.ZodIssueCode.custom,
|
|
148125
|
+
path: [key2],
|
|
148126
|
+
message: `${key2} must be ${PATH_HELP}`
|
|
148127
|
+
});
|
|
148128
|
+
}
|
|
148129
|
+
}
|
|
148130
|
+
if (check3.matches !== void 0) {
|
|
148131
|
+
const problem = regexProblem(check3.matches);
|
|
148132
|
+
if (problem)
|
|
148133
|
+
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["matches"], message: problem });
|
|
148134
|
+
}
|
|
148135
|
+
});
|
|
148136
|
+
function regexProblem(pattern) {
|
|
148137
|
+
try {
|
|
148138
|
+
new RegExp(pattern.replace(SECRET_PLACEHOLDER_RE, "x"));
|
|
148139
|
+
return void 0;
|
|
148140
|
+
} catch (err) {
|
|
148141
|
+
return `not a valid regular expression: ${err instanceof Error ? err.message : String(err)}`;
|
|
148142
|
+
}
|
|
148143
|
+
}
|
|
148144
|
+
function fillSecrets(text, regex, options) {
|
|
148145
|
+
if (!regex) return resolveSecretPlaceholders(text, options).text;
|
|
148146
|
+
return text.replace(
|
|
148147
|
+
SECRET_PLACEHOLDER_RE,
|
|
148148
|
+
(placeholder) => escapeRegExp2(resolveSecretPlaceholders(placeholder, options).text)
|
|
148149
|
+
);
|
|
148150
|
+
}
|
|
148151
|
+
function escapeRegExp2(text) {
|
|
148152
|
+
return text.replace(/[.*+?^${}()|[\]\\/-]/g, "\\$&");
|
|
148153
|
+
}
|
|
148154
|
+
function valueCheckOf(params, options) {
|
|
148155
|
+
const test = COMPARATORS.find((name) => params[name] !== void 0);
|
|
148156
|
+
const raw = params[test];
|
|
148157
|
+
const expected = test === "exists" ? raw === true : fillSecrets(String(raw), test === "matches", options);
|
|
148158
|
+
const target = [params.path, params.claim !== void 0 ? `JWT claim ${params.claim}` : void 0].filter(Boolean).join(" ");
|
|
148159
|
+
const wanted = test === "exists" ? raw === true ? "exists" : "is absent" : `${test} ${JSON.stringify(String(raw))}`;
|
|
148160
|
+
return {
|
|
148161
|
+
...params.path !== void 0 ? { path: params.path } : {},
|
|
148162
|
+
...params.claim !== void 0 ? { claim: params.claim } : {},
|
|
148163
|
+
test,
|
|
148164
|
+
expected,
|
|
148165
|
+
description: `${target ? `${target} ` : ""}${wanted}`
|
|
148166
|
+
};
|
|
148167
|
+
}
|
|
148168
|
+
function jwtPayload(token) {
|
|
148169
|
+
const compact = token.trim().replace(/^bearer\s+/i, "");
|
|
148170
|
+
const parts2 = compact.split(".");
|
|
148171
|
+
if (parts2.length !== 3) {
|
|
148172
|
+
return {
|
|
148173
|
+
ok: false,
|
|
148174
|
+
why: `is not a JWT: it has ${parts2.length} dot-separated part${parts2.length === 1 ? "" : "s"}, a signed JWT has 3`
|
|
148175
|
+
};
|
|
148176
|
+
}
|
|
148177
|
+
if (!/^[A-Za-z0-9_-]+$/.test(parts2[1])) {
|
|
148178
|
+
return { ok: false, why: "is not a JWT: its payload is not base64url" };
|
|
148179
|
+
}
|
|
148180
|
+
try {
|
|
148181
|
+
const payload = parseJson(Buffer.from(parts2[1], "base64url").toString("utf8"));
|
|
148182
|
+
if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
148183
|
+
return { ok: false, why: "is not a JWT: its payload is not a JSON object" };
|
|
148184
|
+
}
|
|
148185
|
+
return { ok: true, payload };
|
|
148186
|
+
} catch {
|
|
148187
|
+
return { ok: false, why: "is not a JWT: its payload is not JSON" };
|
|
148188
|
+
}
|
|
148189
|
+
}
|
|
148190
|
+
function parseJson(text) {
|
|
148191
|
+
const keepDigits = (_key, value, context2) => typeof value === "number" && context2?.source !== void 0 && /^-?\d+$/.test(context2.source) && String(value) !== context2.source ? context2.source : value;
|
|
148192
|
+
return JSON.parse(text, keepDigits);
|
|
148193
|
+
}
|
|
148194
|
+
function textOf(hit) {
|
|
148195
|
+
if (!hit.found) return "";
|
|
148196
|
+
return typeof hit.value === "string" ? hit.value : JSON.stringify(hit.value);
|
|
148197
|
+
}
|
|
148198
|
+
function checkValue(check3, source, label) {
|
|
148199
|
+
if (source.kind === "unknown")
|
|
148200
|
+
return { verdict: "unknown", reason: `${label}: ${source.reason}` };
|
|
148201
|
+
let at = label;
|
|
148202
|
+
let hit;
|
|
148203
|
+
if (source.kind === "none") {
|
|
148204
|
+
hit = { found: false, why: `${label} is empty` };
|
|
148205
|
+
} else if (source.kind === "binary") {
|
|
148206
|
+
hit = check3.path === void 0 && check3.claim === void 0 ? { found: true, value: `[binary${source.mimeType ? ` ${source.mimeType}` : ""}]` } : {
|
|
148207
|
+
found: false,
|
|
148208
|
+
why: `${label} is binary${source.mimeType ? ` (${source.mimeType})` : ""}`
|
|
148209
|
+
};
|
|
148210
|
+
if (check3.test !== "exists" && hit.found) {
|
|
148211
|
+
return {
|
|
148212
|
+
verdict: "fail",
|
|
148213
|
+
reason: `${label} is binary${source.mimeType ? ` (${source.mimeType})` : ""}`
|
|
148214
|
+
};
|
|
148215
|
+
}
|
|
148216
|
+
} else if (check3.path !== void 0) {
|
|
148217
|
+
let json2;
|
|
148218
|
+
try {
|
|
148219
|
+
json2 = parseJson(source.text);
|
|
148220
|
+
hit = lookupPath(json2, check3.path, label);
|
|
148221
|
+
at = `${label}.${check3.path}`;
|
|
148222
|
+
} catch {
|
|
148223
|
+
hit = { found: false, why: `${label} is not JSON` };
|
|
148224
|
+
}
|
|
148225
|
+
} else {
|
|
148226
|
+
hit = { found: true, value: source.text };
|
|
148227
|
+
}
|
|
148228
|
+
if (check3.claim !== void 0 && hit.found) {
|
|
148229
|
+
if (typeof hit.value !== "string") {
|
|
148230
|
+
hit = { found: false, why: `${at} is not a string, so it is not a JWT` };
|
|
148231
|
+
} else {
|
|
148232
|
+
const decoded2 = jwtPayload(hit.value);
|
|
148233
|
+
hit = decoded2.ok ? lookupPath(decoded2.payload, check3.claim, `${at} JWT`) : { found: false, why: `${at} ${decoded2.why}` };
|
|
148234
|
+
at = `${at} JWT ${check3.claim}`;
|
|
148235
|
+
}
|
|
148236
|
+
}
|
|
148237
|
+
const { ok, reason: reason2 } = evaluateValueCheck(check3.test, check3.expected, hit, at);
|
|
148238
|
+
return ok ? { verdict: "pass", reason: reason2, value: textOf(hit) } : { verdict: "fail", reason: reason2 };
|
|
148239
|
+
}
|
|
148240
|
+
|
|
147897
148241
|
// ../tool-server/src/tools/await-network-request/match.ts
|
|
147898
|
-
function withoutStart({ startedAt: _, ...record2 }) {
|
|
148242
|
+
function withoutStart({ startedAt: _, install: __, ...record2 }) {
|
|
147899
148243
|
return record2;
|
|
147900
148244
|
}
|
|
148245
|
+
var BODY_CRITERIA = ["requestBody", "responseBody"];
|
|
147901
148246
|
var STATUS_CLASSES = ["1xx", "2xx", "3xx", "4xx", "5xx"];
|
|
147902
148247
|
function urlMatches(criteria, url2) {
|
|
147903
148248
|
switch (criteria.urlMatch) {
|
|
@@ -147942,31 +148287,43 @@ function sameRequest(a, b) {
|
|
|
147942
148287
|
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
148288
|
(a.startedAt === void 0 || b.startedAt === void 0 || Math.abs(a.startedAt - b.startedAt) <= SAME_REQUEST_MS);
|
|
147944
148289
|
}
|
|
147945
|
-
function nearMisses(criteria, records) {
|
|
147946
|
-
const ranked = records.map((record2, index) =>
|
|
148290
|
+
function nearMisses(criteria, records, judged = () => void 0) {
|
|
148291
|
+
const ranked = records.map((record2, index) => {
|
|
148292
|
+
const mismatch2 = mismatches(criteria, record2);
|
|
148293
|
+
const body = mismatch2.length === 0 ? judged(record2) : void 0;
|
|
148294
|
+
if (body) mismatch2.push(...body.mismatch);
|
|
148295
|
+
return { record: record2, mismatch: mismatch2, index, reason: body?.reason };
|
|
148296
|
+
}).sort(
|
|
147947
148297
|
(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
148298
|
(b.record.startedAt ?? -Infinity) - (a.record.startedAt ?? -Infinity) || b.index - a.index
|
|
147949
148299
|
);
|
|
147950
148300
|
const listed = [];
|
|
147951
|
-
for (const { record: record2, mismatch: mismatch2 } of ranked) {
|
|
148301
|
+
for (const { record: record2, mismatch: mismatch2, reason: reason2 } of ranked) {
|
|
147952
148302
|
if (listed.length === MAX_NEAR_MISSES) break;
|
|
147953
148303
|
const of = listed.find((entry) => !entry.twin && sameRequest(entry.record, record2));
|
|
147954
148304
|
if (of) of.twin = true;
|
|
147955
|
-
else listed.push({ record: record2, mismatch: mismatch2, twin: false });
|
|
148305
|
+
else listed.push({ record: record2, mismatch: mismatch2, reason: reason2, twin: false });
|
|
147956
148306
|
}
|
|
147957
|
-
return listed.map(({ record: record2, mismatch: mismatch2 }) => ({
|
|
148307
|
+
return listed.map(({ record: record2, mismatch: mismatch2, reason: reason2 }) => ({
|
|
148308
|
+
...withoutStart(record2),
|
|
148309
|
+
mismatch: mismatch2,
|
|
148310
|
+
...reason2 !== void 0 ? { reason: reason2 } : {}
|
|
148311
|
+
}));
|
|
147958
148312
|
}
|
|
147959
148313
|
var NOTE_URL_CHARS = 120;
|
|
147960
148314
|
function shortUrl(url2) {
|
|
147961
148315
|
return url2.length > NOTE_URL_CHARS ? `${url2.slice(0, NOTE_URL_CHARS)}...` : url2;
|
|
147962
148316
|
}
|
|
147963
148317
|
function describeCriteria(criteria) {
|
|
147964
|
-
const
|
|
148318
|
+
const wanted = shortUrl(criteria.urlShown ?? criteria.url);
|
|
148319
|
+
const url2 = criteria.urlMatch === "matches" ? `URL matching the regular expression "${wanted}"` : `URL ${criteria.urlMatch === "equals" ? "equal to" : "containing"} "${wanted}"`;
|
|
147965
148320
|
return [
|
|
147966
148321
|
criteria.method ? criteria.method.toUpperCase() : void 0,
|
|
147967
148322
|
url2,
|
|
147968
148323
|
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
|
|
148324
|
+
criteria.outcome === "any" ? "complete or failed" : criteria.outcome === "sent" ? "sent (in any state)" : criteria.outcome,
|
|
148325
|
+
criteria.requestBody ? `request body ${criteria.requestBody.description}` : void 0,
|
|
148326
|
+
criteria.responseBody ? `response body ${criteria.responseBody.description}` : void 0
|
|
147970
148327
|
].filter(Boolean).join(", ");
|
|
147971
148328
|
}
|
|
147972
148329
|
function describeRecord(record2) {
|
|
@@ -147977,7 +148334,7 @@ function describeRecord(record2) {
|
|
|
147977
148334
|
record2.errorText ? `"${shortUrl(record2.errorText)}"` : void 0,
|
|
147978
148335
|
`[${record2.layer} ${record2.id}]`
|
|
147979
148336
|
];
|
|
147980
|
-
const mismatch2 = "mismatch" in record2 ? ` (mismatch: ${record2.mismatch.join(", ")})` : "";
|
|
148337
|
+
const mismatch2 = "mismatch" in record2 ? ` (mismatch: ${record2.mismatch.join(", ")}${record2.reason ? `: ${shortUrl(record2.reason)}` : ""})` : "";
|
|
147981
148338
|
return `${parts2.filter(Boolean).join(" ")}${mismatch2}`;
|
|
147982
148339
|
}
|
|
147983
148340
|
|
|
@@ -147985,12 +148342,15 @@ function describeRecord(record2) {
|
|
|
147985
148342
|
var DEFAULT_TIMEOUT_MS4 = 1e4;
|
|
147986
148343
|
var DEFAULT_POLL_INTERVAL_MS2 = 400;
|
|
147987
148344
|
var MIN_JS_READ_MS = 1e3;
|
|
148345
|
+
var BODY_READ_GRACE_MS = 1e3;
|
|
148346
|
+
var MAX_BODY_READ_MS = 1e4;
|
|
148347
|
+
var SHOWN_VALUE_CHARS = 200;
|
|
147988
148348
|
var zodSchema45 = external_exports.object({
|
|
147989
148349
|
udid: external_exports.string().min(1).describe("Device ID used in `network-capture-start`."),
|
|
147990
148350
|
bundleId: external_exports.string().regex(BUNDLE_ID_PATTERN, BUNDLE_ID_MESSAGE).describe(
|
|
147991
148351
|
"`bundleId` used in `network-capture-start` (Chromium: placeholder like `argent.capture`)."
|
|
147992
148352
|
),
|
|
147993
|
-
url: external_exports.string().min(1).describe("URL text
|
|
148353
|
+
url: external_exports.string().min(1).describe("URL text or pattern. `{{secret:NAME}}` expands to the secret value."),
|
|
147994
148354
|
urlMatch: external_exports.enum(["contains", "equals", "matches"]).optional().describe(
|
|
147995
148355
|
"`contains` (default) / `equals` (case-insensitive) or `matches` (case-sensitive JS regex)."
|
|
147996
148356
|
),
|
|
@@ -148002,37 +148362,34 @@ var zodSchema45 = external_exports.object({
|
|
|
148002
148362
|
outcome: external_exports.enum(["complete", "failed", "any", "sent"]).optional().describe(
|
|
148003
148363
|
"`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
148364
|
),
|
|
148365
|
+
requestBody: valueCheckSchema.optional().describe(
|
|
148366
|
+
"Check a request body using exactly one of `equals`, `contains`, `matches`, or `exists`."
|
|
148367
|
+
),
|
|
148368
|
+
responseBody: valueCheckSchema.optional().describe("Use the same check as `requestBody` on a finished response."),
|
|
148005
148369
|
absent: external_exports.boolean().optional().describe("Set to true to fail on the first match and require complete capture to pass."),
|
|
148006
148370
|
timeoutMs: external_exports.number().int().positive().max(12e4).optional().describe(`Timeout in ms (default ${DEFAULT_TIMEOUT_MS4}).`),
|
|
148007
148371
|
pollIntervalMs: external_exports.number().int().min(50).max(5e3).optional().describe(`Poll interval in ms (default ${DEFAULT_POLL_INTERVAL_MS2}).`)
|
|
148008
148372
|
}).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
148373
|
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
|
-
});
|
|
148374
|
+
const problem = regexProblem(params.url);
|
|
148375
|
+
if (problem) {
|
|
148376
|
+
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["url"], message: `url is ${problem}` });
|
|
148025
148377
|
}
|
|
148026
148378
|
}
|
|
148027
148379
|
});
|
|
148028
148380
|
var CANCELLED_NOTE = "the wait was cancelled before a request matched";
|
|
148029
|
-
function criteriaOf(params) {
|
|
148381
|
+
function criteriaOf(params, ctx) {
|
|
148382
|
+
const secrets = { clientSecrets: ctx?.clientSecrets };
|
|
148383
|
+
const url2 = fillSecrets(params.url, params.urlMatch === "matches", secrets);
|
|
148030
148384
|
return {
|
|
148031
|
-
url:
|
|
148385
|
+
url: url2,
|
|
148386
|
+
...url2 !== params.url ? { urlShown: params.url } : {},
|
|
148032
148387
|
urlMatch: params.urlMatch ?? "contains",
|
|
148033
148388
|
...params.method !== void 0 ? { method: params.method } : {},
|
|
148034
148389
|
...params.status !== void 0 ? { status: params.status } : {},
|
|
148035
|
-
outcome: params.outcome ?? (params.absent ? "sent" : "complete")
|
|
148390
|
+
outcome: params.outcome ?? (params.absent ? "sent" : "complete"),
|
|
148391
|
+
...params.requestBody ? { requestBody: valueCheckOf(params.requestBody, secrets) } : {},
|
|
148392
|
+
...params.responseBody ? { responseBody: valueCheckOf(params.responseBody, secrets) } : {}
|
|
148036
148393
|
};
|
|
148037
148394
|
}
|
|
148038
148395
|
function notStartedError(params) {
|
|
@@ -148054,7 +148411,7 @@ function createAwaitNetworkRequestTool(registry2) {
|
|
|
148054
148411
|
// A literal, so scripts/extract-tools.mjs finds the description it scores.
|
|
148055
148412
|
id: "await-network-request",
|
|
148056
148413
|
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\`.`,
|
|
148414
|
+
Pass \`match.id\` to \`view-network-request-details\`. \`values\` shows previews of matched body values. Check \`cause\` and \`note\` on failure. \`success: false\` fails an e2e step and stops \`run-sequence\`.`,
|
|
148058
148415
|
zodSchema: zodSchema45,
|
|
148059
148416
|
searchHint: "wait await network request http api call fetch xhr response status url match after capture start e2e assert",
|
|
148060
148417
|
readOnly: true,
|
|
@@ -148083,7 +148440,7 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148083
148440
|
}
|
|
148084
148441
|
const layers = await markedLayers(registry2, device, params.bundleId);
|
|
148085
148442
|
if (layers.length === 0) throw notStartedError(params);
|
|
148086
|
-
const criteria = criteriaOf(params);
|
|
148443
|
+
const criteria = criteriaOf(params, ctx);
|
|
148087
148444
|
const atStart = networkSecrets(ctx);
|
|
148088
148445
|
let redact2 = networkRedactorOf(atStart);
|
|
148089
148446
|
const readSecretsAgain = () => {
|
|
@@ -148135,7 +148492,102 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148135
148492
|
jsRead = read;
|
|
148136
148493
|
return read;
|
|
148137
148494
|
};
|
|
148138
|
-
const
|
|
148495
|
+
const bodyChecks = BODY_CRITERIA.filter((name) => criteria[name] !== void 0);
|
|
148496
|
+
const keyOf = (record2) => `${record2.layer} ${record2.install ?? ""} ${record2.id}`;
|
|
148497
|
+
const bodies = /* @__PURE__ */ new Map();
|
|
148498
|
+
const judged = /* @__PURE__ */ new Map();
|
|
148499
|
+
const ended = (record2) => !isOpen2(record2) && record2.state !== "pending";
|
|
148500
|
+
const readBody = async (layer, record2, kind) => {
|
|
148501
|
+
const key2 = `${keyOf(record2)} ${kind}`;
|
|
148502
|
+
const kept = bodies.get(key2);
|
|
148503
|
+
if (kept) return kept;
|
|
148504
|
+
if (kind === "response" && record2.state === "failed") {
|
|
148505
|
+
const failed3 = record2.status === void 0 ? { kind: "none" } : {
|
|
148506
|
+
kind: "unknown",
|
|
148507
|
+
reason: "the request failed after its response began, so its body is not whole",
|
|
148508
|
+
final: true
|
|
148509
|
+
};
|
|
148510
|
+
bodies.set(key2, failed3);
|
|
148511
|
+
return failed3;
|
|
148512
|
+
}
|
|
148513
|
+
if (kind === "response" && record2.state === "lost") {
|
|
148514
|
+
const lost = {
|
|
148515
|
+
kind: "unknown",
|
|
148516
|
+
reason: "argent lost sight of the request before it ended",
|
|
148517
|
+
final: true
|
|
148518
|
+
};
|
|
148519
|
+
bodies.set(key2, lost);
|
|
148520
|
+
return lost;
|
|
148521
|
+
}
|
|
148522
|
+
const budget = Math.min(MAX_BODY_READ_MS, deadline + BODY_READ_GRACE_MS - Date.now());
|
|
148523
|
+
if (budget <= 0) {
|
|
148524
|
+
return {
|
|
148525
|
+
kind: "unknown",
|
|
148526
|
+
reason: "the wait ended before the body was read",
|
|
148527
|
+
final: false
|
|
148528
|
+
};
|
|
148529
|
+
}
|
|
148530
|
+
const settled = await settleWithin(layer.body(record2, kind, budget), budget, signal);
|
|
148531
|
+
const body = settled.type === "value" ? settled.value : {
|
|
148532
|
+
kind: "unknown",
|
|
148533
|
+
reason: settled.type === "timeout" ? `the body was not read within ${budget} ms` : settled.type === "aborted" ? CANCELLED_NOTE : settled.error,
|
|
148534
|
+
final: false
|
|
148535
|
+
};
|
|
148536
|
+
if (body.kind === "unknown" ? body.final : ended(record2)) bodies.set(key2, body);
|
|
148537
|
+
return body;
|
|
148538
|
+
};
|
|
148539
|
+
const judge = async (layer, record2) => {
|
|
148540
|
+
const verdicts = [];
|
|
148541
|
+
for (const name of bodyChecks) {
|
|
148542
|
+
const kind = name === "requestBody" ? "request" : "response";
|
|
148543
|
+
const body = await readBody(layer, record2, kind);
|
|
148544
|
+
verdicts.push({
|
|
148545
|
+
name,
|
|
148546
|
+
verdict: checkValue(criteria[name], body, `${kind} body`)
|
|
148547
|
+
});
|
|
148548
|
+
if (verdicts.at(-1).verdict.verdict === "fail") break;
|
|
148549
|
+
}
|
|
148550
|
+
const failed3 = verdicts.filter(({ verdict }) => verdict.verdict === "fail");
|
|
148551
|
+
const open5 = verdicts.filter(({ verdict }) => verdict.verdict === "unknown");
|
|
148552
|
+
const missed = failed3.length > 0 ? failed3 : open5;
|
|
148553
|
+
const judgement = {
|
|
148554
|
+
mismatch: missed.map(({ name }) => name),
|
|
148555
|
+
...missed.length > 0 ? { reason: missed.map(({ verdict }) => verdict.reason).join("; ") } : {},
|
|
148556
|
+
values: Object.fromEntries(
|
|
148557
|
+
verdicts.flatMap(
|
|
148558
|
+
({ name, verdict }) => verdict.verdict === "pass" ? [[name, verdict.value]] : []
|
|
148559
|
+
)
|
|
148560
|
+
),
|
|
148561
|
+
/** Not judged: a body argent could not read whole. */
|
|
148562
|
+
unknown: failed3.length === 0 && open5.length > 0
|
|
148563
|
+
};
|
|
148564
|
+
judged.set(keyOf(record2), judgement);
|
|
148565
|
+
return judgement;
|
|
148566
|
+
};
|
|
148567
|
+
const matchIn = async (layer, records) => {
|
|
148568
|
+
if (bodyChecks.length === 0) {
|
|
148569
|
+
const record2 = firstMatch(criteria, records);
|
|
148570
|
+
return record2 && { record: record2 };
|
|
148571
|
+
}
|
|
148572
|
+
for (const record2 of records) {
|
|
148573
|
+
if (mismatches(criteria, record2).length > 0) continue;
|
|
148574
|
+
const { mismatch: mismatch2, values } = await judge(layer, record2);
|
|
148575
|
+
if (mismatch2.length === 0) return { record: withoutStart(record2), values };
|
|
148576
|
+
if (signal?.aborted) return void 0;
|
|
148577
|
+
}
|
|
148578
|
+
return void 0;
|
|
148579
|
+
};
|
|
148580
|
+
const cut = (text) => {
|
|
148581
|
+
const redacted = redact2(text);
|
|
148582
|
+
return redacted.length > SHOWN_VALUE_CHARS ? `${redacted.slice(0, SHOWN_VALUE_CHARS)}...` : redacted;
|
|
148583
|
+
};
|
|
148584
|
+
const shownValues = (values) => {
|
|
148585
|
+
if (!values || Object.keys(values).length === 0) return {};
|
|
148586
|
+
return {
|
|
148587
|
+
values: Object.fromEntries(Object.entries(values).map(([k, v]) => [k, cut(v)]))
|
|
148588
|
+
};
|
|
148589
|
+
};
|
|
148590
|
+
const success2 = (match, values) => {
|
|
148139
148591
|
readSecretsAgain();
|
|
148140
148592
|
const notes = [...notesSeen].flatMap(
|
|
148141
148593
|
([layer, seen]) => [...seen].map((note) => `${layer}: ${redact2(note)}`)
|
|
@@ -148144,10 +148596,14 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148144
148596
|
success: true,
|
|
148145
148597
|
elapsed: elapsed(),
|
|
148146
148598
|
match: shown(match),
|
|
148599
|
+
...shownValues(values),
|
|
148147
148600
|
...notes.length > 0 ? { note: notes.join("; ") } : {}
|
|
148148
148601
|
};
|
|
148149
148602
|
};
|
|
148150
|
-
const found = (
|
|
148603
|
+
const found = ({
|
|
148604
|
+
record: record2,
|
|
148605
|
+
values
|
|
148606
|
+
}) => params.absent ? sentWhileAbsent(record2, values) : success2(record2, values);
|
|
148151
148607
|
for (; ; ) {
|
|
148152
148608
|
const atDeadline = Date.now() >= deadline;
|
|
148153
148609
|
if (signal?.aborted) {
|
|
@@ -148159,7 +148615,7 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148159
148615
|
const read = { ...await layer.read(0), from: from2, at: Date.now() };
|
|
148160
148616
|
keep(read);
|
|
148161
148617
|
reads.push(read);
|
|
148162
|
-
const match =
|
|
148618
|
+
const match = await matchIn(layer, read.records);
|
|
148163
148619
|
if (match) return found(match);
|
|
148164
148620
|
}
|
|
148165
148621
|
const remaining = deadline - Date.now();
|
|
@@ -148177,7 +148633,7 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148177
148633
|
}
|
|
148178
148634
|
if (pending.type === "value") {
|
|
148179
148635
|
keep(pending.value);
|
|
148180
|
-
const match =
|
|
148636
|
+
const match = await matchIn(js, pending.value.records);
|
|
148181
148637
|
if (match) return found(match);
|
|
148182
148638
|
}
|
|
148183
148639
|
}
|
|
@@ -148189,7 +148645,7 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148189
148645
|
if (settled.type === "value") {
|
|
148190
148646
|
keep(settled.value);
|
|
148191
148647
|
reads.push(settled.value);
|
|
148192
|
-
const match =
|
|
148648
|
+
const match = await matchIn(js, settled.value.records);
|
|
148193
148649
|
if (match) return found(match);
|
|
148194
148650
|
} else if (settled.type === "timeout" && bound < jsBound && latest.has("js")) {
|
|
148195
148651
|
} else {
|
|
@@ -148242,7 +148698,7 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148242
148698
|
(s) => `${s.layer} ${s.readable ? s.requests : "not read"}${s.armed ? "" : " (not armed)"}`
|
|
148243
148699
|
).join(", ");
|
|
148244
148700
|
}
|
|
148245
|
-
function sentWhileAbsent(match) {
|
|
148701
|
+
function sentWhileAbsent(match, values) {
|
|
148246
148702
|
readSecretsAgain();
|
|
148247
148703
|
const shownMatch = shown(match);
|
|
148248
148704
|
return {
|
|
@@ -148250,6 +148706,7 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148250
148706
|
elapsed: elapsed(),
|
|
148251
148707
|
cause: "unmet",
|
|
148252
148708
|
match: shownMatch,
|
|
148709
|
+
...shownValues(values),
|
|
148253
148710
|
note: `A request that must not be sent was captured since network-capture-start (forbidden: ${describeCriteria(criteria)}): ${describeRecord(shownMatch)}.`,
|
|
148254
148711
|
layers: layerSummaries()
|
|
148255
148712
|
};
|
|
@@ -148272,6 +148729,17 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148272
148729
|
);
|
|
148273
148730
|
}
|
|
148274
148731
|
}
|
|
148732
|
+
const candidates = [...latestReadable.values()].flatMap(
|
|
148733
|
+
(read) => read.records.filter((record2) => mismatches(criteria, record2).length === 0)
|
|
148734
|
+
);
|
|
148735
|
+
for (const record2 of candidates) {
|
|
148736
|
+
const judgement = judged.get(keyOf(record2));
|
|
148737
|
+
if (judgement?.unknown) {
|
|
148738
|
+
unproven.push(
|
|
148739
|
+
`${record2.layer} ${record2.id}: ${redact2(judgement.reason ?? "its body was not read")}`
|
|
148740
|
+
);
|
|
148741
|
+
}
|
|
148742
|
+
}
|
|
148275
148743
|
const summaries = layerSummaries();
|
|
148276
148744
|
const window2 = allStopped ? "between network-capture-start and network-capture-stop" : `since network-capture-start, watched for ${timeoutMs} ms`;
|
|
148277
148745
|
if (unproven.length > 0) {
|
|
@@ -148294,7 +148762,12 @@ Pass \`match.id\` to \`view-network-request-details\`. Check \`cause\` and \`not
|
|
|
148294
148762
|
readSecretsAgain();
|
|
148295
148763
|
const summaries = layerSummaries();
|
|
148296
148764
|
const seen = [...latestReadable.values()].flatMap((read) => read.records);
|
|
148297
|
-
const misses = nearMisses(criteria, seen).map(
|
|
148765
|
+
const misses = nearMisses(criteria, seen, (record2) => judged.get(keyOf(record2))).map(
|
|
148766
|
+
(miss) => ({
|
|
148767
|
+
...shown(miss),
|
|
148768
|
+
...miss.reason !== void 0 ? { reason: cut(miss.reason) } : {}
|
|
148769
|
+
})
|
|
148770
|
+
);
|
|
148298
148771
|
const counts = requestCounts(summaries);
|
|
148299
148772
|
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
148773
|
const notes = summaries.filter((s) => s.note).map((s) => `${s.layer}: ${s.note}`).join("; ");
|
|
@@ -168300,7 +168773,7 @@ function unmetWaitWarningFor(cause, block) {
|
|
|
168300
168773
|
return unmetWaitWarning(block);
|
|
168301
168774
|
}
|
|
168302
168775
|
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";
|
|
168776
|
+
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
168777
|
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
168778
|
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
168779
|
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.41",
|
|
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": "fcb62b9367b202e2c936caa748f64597b838f699"
|
|
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 or body 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 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.
|