@swmansion/argent 0.34.1-next.42 → 0.34.1-next.43
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/tool-args.generated.d.ts +3 -3
- package/dist/tool-server.cjs +382 -85
- package/package.json +1 -1
package/dist/cli-cmds.mjs
CHANGED
|
@@ -36259,7 +36259,7 @@ function isCi(env = process.env) {
|
|
|
36259
36259
|
var SESSION_ID2 = randomUUID5();
|
|
36260
36260
|
function readCliVersion() {
|
|
36261
36261
|
if (true) {
|
|
36262
|
-
return "0.34.1-next.
|
|
36262
|
+
return "0.34.1-next.43";
|
|
36263
36263
|
}
|
|
36264
36264
|
return "0.0.0";
|
|
36265
36265
|
}
|
package/dist/installer.mjs
CHANGED
|
@@ -16945,7 +16945,7 @@ function isCi(env = process.env) {
|
|
|
16945
16945
|
var SESSION_ID = randomUUID4();
|
|
16946
16946
|
function readCliVersion() {
|
|
16947
16947
|
if (true) {
|
|
16948
|
-
return "0.34.1-next.
|
|
16948
|
+
return "0.34.1-next.43";
|
|
16949
16949
|
}
|
|
16950
16950
|
return "0.0.0";
|
|
16951
16951
|
}
|
|
@@ -550,7 +550,7 @@ export interface ArgentToolArgs {
|
|
|
550
550
|
port?: number;
|
|
551
551
|
/** Maximum number of requests to return: the most recent ones, oldest first. 0 returns only the header and the total. On a Mac app it counts events, not requests: one request gives several events. 0 returns no events. */
|
|
552
552
|
limit?: number;
|
|
553
|
-
/** Clear the log after reading. On Android, the IDs of cleared requests still work in view-network-request-details */
|
|
553
|
+
/** Clear the log after reading. On iOS and Android, the IDs of cleared requests still work in view-network-request-details */
|
|
554
554
|
clear?: boolean;
|
|
555
555
|
/** Android only: turn native capture off for this app instead of listing. Other apps keep theirs. */
|
|
556
556
|
stop?: boolean;
|
|
@@ -991,9 +991,9 @@ export interface ArgentToolArgs {
|
|
|
991
991
|
"view-network-request-details": {
|
|
992
992
|
/** Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. */
|
|
993
993
|
port?: number;
|
|
994
|
-
/** Device id from list-devices (iOS simulator UDID or Android serial), the same id used with debugger-connect. An android- ID needs no debugger connection. */
|
|
994
|
+
/** Device id from list-devices (iOS simulator UDID or Android serial), the same id used with debugger-connect. An ios- or android- ID needs no debugger connection. */
|
|
995
995
|
device_id: string;
|
|
996
|
-
/** The requestId from view-network-logs, or an android- ID from native-network-logs. */
|
|
996
|
+
/** The requestId from view-network-logs, or an ios- or android- ID from native-network-logs. */
|
|
997
997
|
requestId: string;
|
|
998
998
|
/** Whether to include the response body (if captured). */
|
|
999
999
|
includeBody?: boolean;
|
package/dist/tool-server.cjs
CHANGED
|
@@ -101443,7 +101443,7 @@ function isCi(env = process.env) {
|
|
|
101443
101443
|
var SESSION_ID = (0, import_node_crypto3.randomUUID)();
|
|
101444
101444
|
function readCliVersion() {
|
|
101445
101445
|
if (true) {
|
|
101446
|
-
return "0.34.1-next.
|
|
101446
|
+
return "0.34.1-next.43";
|
|
101447
101447
|
}
|
|
101448
101448
|
return "0.0.0";
|
|
101449
101449
|
}
|
|
@@ -124521,6 +124521,20 @@ function pickIosHost(device) {
|
|
|
124521
124521
|
// ../tool-server/src/blueprints/ios-network-records.ts
|
|
124522
124522
|
var import_node_crypto7 = require("node:crypto");
|
|
124523
124523
|
var import_node_http2 = require("node:http");
|
|
124524
|
+
init_src2();
|
|
124525
|
+
|
|
124526
|
+
// ../tool-server/src/utils/keyed-lock.ts
|
|
124527
|
+
async function withKeyedLock(locks, key2, fn) {
|
|
124528
|
+
const previous = locks.get(key2) ?? Promise.resolve();
|
|
124529
|
+
const run2 = previous.then(() => fn());
|
|
124530
|
+
const held = run2.catch(() => {
|
|
124531
|
+
});
|
|
124532
|
+
locks.set(key2, held);
|
|
124533
|
+
void held.then(() => {
|
|
124534
|
+
if (locks.get(key2) === held) locks.delete(key2);
|
|
124535
|
+
});
|
|
124536
|
+
return run2;
|
|
124537
|
+
}
|
|
124524
124538
|
|
|
124525
124539
|
// ../tool-server/src/utils/debugger/device-alias.ts
|
|
124526
124540
|
var logicalIdToConnectId = /* @__PURE__ */ new Map();
|
|
@@ -124564,8 +124578,10 @@ var MAX_VALUE_CHARS = 64 * 1024;
|
|
|
124564
124578
|
var MAX_HEADERS = 256;
|
|
124565
124579
|
var MAX_HEADER_MAP_CHARS = 256 * 1024;
|
|
124566
124580
|
var MAX_LAYER_ID_CHARS = 200;
|
|
124581
|
+
var MAX_CACHED_BODIES = 64;
|
|
124567
124582
|
var NOT_RECONNECTED = "the agent did not reconnect after its connection dropped, so this request's final events never arrived";
|
|
124568
124583
|
var PROCESS_ENDED = "the app process ended before the request finished";
|
|
124584
|
+
var PROCESS_GONE = "the app process that made the request is gone";
|
|
124569
124585
|
function isOpen(record2) {
|
|
124570
124586
|
return record2.state === "pending" || record2.state === "headers";
|
|
124571
124587
|
}
|
|
@@ -124627,6 +124643,26 @@ function recordSize(record2) {
|
|
|
124627
124643
|
}
|
|
124628
124644
|
return chars;
|
|
124629
124645
|
}
|
|
124646
|
+
function toBody(result, kind) {
|
|
124647
|
+
const r = asObject(result);
|
|
124648
|
+
const text = kind === "response" ? r.body : r.postData;
|
|
124649
|
+
if (r.bodyAvailable === false || typeof text !== "string") {
|
|
124650
|
+
return unavailable(
|
|
124651
|
+
kind === "response" ? "the agent holds no body for this response" : "the agent holds no body for this request"
|
|
124652
|
+
);
|
|
124653
|
+
}
|
|
124654
|
+
const incomplete = kind === "post" && r.incomplete === true;
|
|
124655
|
+
return {
|
|
124656
|
+
available: true,
|
|
124657
|
+
body: text,
|
|
124658
|
+
base64Encoded: r.base64Encoded === true,
|
|
124659
|
+
truncated: r.wasTruncated === true || incomplete,
|
|
124660
|
+
...incomplete ? { incomplete } : {}
|
|
124661
|
+
};
|
|
124662
|
+
}
|
|
124663
|
+
function unavailable(reason2) {
|
|
124664
|
+
return { available: false, body: "", base64Encoded: false, truncated: false, reason: reason2 };
|
|
124665
|
+
}
|
|
124630
124666
|
function asObject(value) {
|
|
124631
124667
|
return typeof value === "object" && value !== null ? value : {};
|
|
124632
124668
|
}
|
|
@@ -124636,8 +124672,20 @@ function asString2(value) {
|
|
|
124636
124672
|
|
|
124637
124673
|
// ../tool-server/src/blueprints/ios-network-records.ts
|
|
124638
124674
|
var RUN_TAG = (0, import_node_crypto7.randomBytes)(2).toString("hex");
|
|
124675
|
+
var IOS_NATIVE_REQUEST_ID = /^ios-[0-9a-f]{4}-\d+$/;
|
|
124639
124676
|
var nextRecordNumber = 1;
|
|
124640
|
-
|
|
124677
|
+
var POST_DATA_WAIT_MS = 5e3;
|
|
124678
|
+
var POST_DATA_TIMEOUT_MS = 2 ** 31 - 1;
|
|
124679
|
+
var RESPONSE_BODY_TIMEOUT_MS = 1e4;
|
|
124680
|
+
var KEPT_BODY_CHARS_BUDGET = 64 * 1024 * 1024;
|
|
124681
|
+
var STILL_SENDING = "the app may still be sending this request body; read it again after the request ends";
|
|
124682
|
+
var NO_ANSWER = `the app did not answer within ${POST_DATA_WAIT_MS / 1e3} s; read it again later`;
|
|
124683
|
+
var NO_EARLIER_ANSWER = `the app did not answer an earlier body read within ${RESPONSE_BODY_TIMEOUT_MS / 1e3} s; read it again later`;
|
|
124684
|
+
var CONNECTION_CLOSED = "the agent's connection closed before this body was read";
|
|
124685
|
+
var REQUEST_BODY_GONE = "the agent holds no body for this request";
|
|
124686
|
+
var BODY_NO_LONGER_HELD = "the agent no longer holds this body";
|
|
124687
|
+
var NO_RESPONSE_BODY = "the response has no body";
|
|
124688
|
+
function createIosNetworkRecords(state3, link) {
|
|
124641
124689
|
const records = [];
|
|
124642
124690
|
let recordChars = 0;
|
|
124643
124691
|
const recordSizes = /* @__PURE__ */ new WeakMap();
|
|
@@ -124645,11 +124693,21 @@ function createIosNetworkRecords(state3) {
|
|
|
124645
124693
|
const byLayerId = /* @__PURE__ */ new Map();
|
|
124646
124694
|
const cleared = /* @__PURE__ */ new WeakSet();
|
|
124647
124695
|
const startArrivals = /* @__PURE__ */ new WeakMap();
|
|
124696
|
+
const uploadEnds = /* @__PURE__ */ new WeakMap();
|
|
124697
|
+
const inlineBodies = /* @__PURE__ */ new WeakMap();
|
|
124698
|
+
const bodies = /* @__PURE__ */ new Map();
|
|
124699
|
+
const bodyReads = /* @__PURE__ */ new Map();
|
|
124700
|
+
const stalls = /* @__PURE__ */ new Map();
|
|
124701
|
+
const endedConnections = /* @__PURE__ */ new Set();
|
|
124702
|
+
let newestConnection = -1;
|
|
124703
|
+
const sawConnection = (connection) => {
|
|
124704
|
+
if (connection > newestConnection) newestConnection = connection;
|
|
124705
|
+
};
|
|
124648
124706
|
const keyOf = (connection, layerId) => `${connection}:${layerId}`;
|
|
124649
124707
|
function startRecord(connection, layerId, p) {
|
|
124650
124708
|
const req = asObject(p.request);
|
|
124651
124709
|
const startedAt = typeof p.wallTime === "number" ? p.wallTime * 1e3 : typeof p.timestamp === "number" ? p.timestamp * 1e3 : Date.now();
|
|
124652
|
-
const postData = req.postData;
|
|
124710
|
+
const postData = typeof req.postData === "string" ? req.postData : "";
|
|
124653
124711
|
const record2 = {
|
|
124654
124712
|
id: `ios-${RUN_TAG}-${nextRecordNumber++}`,
|
|
124655
124713
|
layer: "ios-native",
|
|
@@ -124660,10 +124718,16 @@ function createIosNetworkRecords(state3) {
|
|
|
124660
124718
|
url: capString(asString2(req.url)),
|
|
124661
124719
|
method: capString(asString2(req.method), 100) || "GET",
|
|
124662
124720
|
headers: headerMap(req.headers),
|
|
124663
|
-
...req.hasPostData === true ||
|
|
124721
|
+
...req.hasPostData === true || postData.length > 0 ? { hasPostData: true } : {}
|
|
124664
124722
|
},
|
|
124665
124723
|
timing: { startedAt: Math.round(startedAt) }
|
|
124666
124724
|
};
|
|
124725
|
+
if (postData.length > 0) {
|
|
124726
|
+
inlineBodies.set(record2, {
|
|
124727
|
+
text: ownCopy(postData.slice(0, MAX_VALUE_CHARS)),
|
|
124728
|
+
chars: postData.length
|
|
124729
|
+
});
|
|
124730
|
+
}
|
|
124667
124731
|
byLayerId.set(keyOf(connection, layerId), record2);
|
|
124668
124732
|
startArrivals.set(record2, performance.now());
|
|
124669
124733
|
records.push(record2);
|
|
@@ -124681,7 +124745,7 @@ function createIosNetworkRecords(state3) {
|
|
|
124681
124745
|
}
|
|
124682
124746
|
function resize(record2) {
|
|
124683
124747
|
if (!byId.has(record2.id)) return;
|
|
124684
|
-
const size = recordSize(record2);
|
|
124748
|
+
const size = recordSize(record2) + (inlineBodies.get(record2)?.text.length ?? 0);
|
|
124685
124749
|
recordChars += size - (recordSizes.get(record2) ?? 0);
|
|
124686
124750
|
recordSizes.set(record2, size);
|
|
124687
124751
|
while (records.length > MAX_RECORDS || records.length > 1 && recordChars > RECORD_CHARS_BUDGET) {
|
|
@@ -124694,10 +124758,161 @@ function createIosNetworkRecords(state3) {
|
|
|
124694
124758
|
byId.delete(record2.id);
|
|
124695
124759
|
recordChars -= recordSizes.get(record2) ?? 0;
|
|
124696
124760
|
recordSizes.delete(record2);
|
|
124761
|
+
bodies.delete(`response:${record2.id}`);
|
|
124762
|
+
bodies.delete(`post:${record2.id}`);
|
|
124763
|
+
}
|
|
124764
|
+
function closedReason(connection) {
|
|
124765
|
+
const live = link.liveConnection();
|
|
124766
|
+
if (live !== void 0) sawConnection(live);
|
|
124767
|
+
return endedConnections.has(connection) || newestConnection > connection ? PROCESS_GONE : CONNECTION_CLOSED;
|
|
124768
|
+
}
|
|
124769
|
+
function readBody(id, kind) {
|
|
124770
|
+
const record2 = byId.get(id);
|
|
124771
|
+
if (!record2) return Promise.resolve(unavailable("no such request"));
|
|
124772
|
+
if (kind === "post") {
|
|
124773
|
+
if (!record2.request.hasPostData) {
|
|
124774
|
+
return Promise.resolve(unavailable("the request has no body"));
|
|
124775
|
+
}
|
|
124776
|
+
const inline = inlineBodies.get(record2);
|
|
124777
|
+
if (inline) {
|
|
124778
|
+
return Promise.resolve({
|
|
124779
|
+
available: true,
|
|
124780
|
+
body: inline.text,
|
|
124781
|
+
base64Encoded: false,
|
|
124782
|
+
truncated: inline.text.length < inline.chars,
|
|
124783
|
+
inlineChars: inline.chars
|
|
124784
|
+
});
|
|
124785
|
+
}
|
|
124786
|
+
} else if (record2.state !== "complete") {
|
|
124787
|
+
return Promise.resolve(
|
|
124788
|
+
unavailable(
|
|
124789
|
+
record2.state !== "failed" ? "the response has not finished yet" : record2.response ? "the response failed before its body finished" : "the request failed before a response arrived"
|
|
124790
|
+
)
|
|
124791
|
+
);
|
|
124792
|
+
} else if (record2.encodedDataLength === 0) {
|
|
124793
|
+
return Promise.resolve(unavailable(NO_RESPONSE_BODY));
|
|
124794
|
+
}
|
|
124795
|
+
const cacheKey2 = `${kind}:${id}`;
|
|
124796
|
+
const cached3 = bodies.get(cacheKey2);
|
|
124797
|
+
if (cached3 && !(kind === "post" && lostRead(cached3, record2))) {
|
|
124798
|
+
bodies.delete(cacheKey2);
|
|
124799
|
+
bodies.set(cacheKey2, cached3);
|
|
124800
|
+
return shownOf(cached3, kind, record2);
|
|
124801
|
+
}
|
|
124802
|
+
if (link.liveConnection() !== record2.connection) {
|
|
124803
|
+
return Promise.resolve(unavailable(closedReason(record2.connection)));
|
|
124804
|
+
}
|
|
124805
|
+
let adoptAnswer;
|
|
124806
|
+
const answer = new Promise((resolve21) => {
|
|
124807
|
+
adoptAnswer = resolve21;
|
|
124808
|
+
});
|
|
124809
|
+
let markSent;
|
|
124810
|
+
const sent = new Promise((resolve21) => {
|
|
124811
|
+
markSent = resolve21;
|
|
124812
|
+
});
|
|
124813
|
+
const read = { sent, answer, settled: false, chars: 0 };
|
|
124814
|
+
bodies.delete(cacheKey2);
|
|
124815
|
+
bodies.set(cacheKey2, read);
|
|
124816
|
+
if (cached3) adoptLateBody(cached3.answer, answer, adoptAnswer);
|
|
124817
|
+
void answer.then((body) => {
|
|
124818
|
+
read.settled = true;
|
|
124819
|
+
read.chars = body.body.length;
|
|
124820
|
+
if (bodies.get(cacheKey2) === read) {
|
|
124821
|
+
bodies.delete(cacheKey2);
|
|
124822
|
+
if (body.available) bodies.set(cacheKey2, read);
|
|
124823
|
+
}
|
|
124824
|
+
dropOldBodies();
|
|
124825
|
+
});
|
|
124826
|
+
const askedAt = performance.now();
|
|
124827
|
+
void withKeyedLock(bodyReads, String(record2.connection), () => {
|
|
124828
|
+
if (read.settled) {
|
|
124829
|
+
markSent();
|
|
124830
|
+
return answer;
|
|
124831
|
+
}
|
|
124832
|
+
if (kind === "response" && (stalls.get(record2.connection) ?? -Infinity) > askedAt) {
|
|
124833
|
+
adoptAnswer(unavailable(NO_EARLIER_ANSWER));
|
|
124834
|
+
markSent();
|
|
124835
|
+
return answer;
|
|
124836
|
+
}
|
|
124837
|
+
read.heldOpen = kind === "post" && record2.state === "pending";
|
|
124838
|
+
void sendBodyRead(record2, kind).then(adoptAnswer);
|
|
124839
|
+
markSent();
|
|
124840
|
+
return kind === "post" ? withinWait(answer, record2) : answer;
|
|
124841
|
+
});
|
|
124842
|
+
return shownOf(read, kind, record2);
|
|
124843
|
+
}
|
|
124844
|
+
function lostRead(read, record2) {
|
|
124845
|
+
const ended = uploadEnds.get(record2);
|
|
124846
|
+
return read.heldOpen === true && !read.settled && ended !== void 0 && performance.now() - ended >= POST_DATA_WAIT_MS;
|
|
124847
|
+
}
|
|
124848
|
+
function dropOldBodies() {
|
|
124849
|
+
let kept = 0;
|
|
124850
|
+
let chars = 0;
|
|
124851
|
+
for (const read of bodies.values()) {
|
|
124852
|
+
if (!read.settled) continue;
|
|
124853
|
+
kept++;
|
|
124854
|
+
chars += read.chars;
|
|
124855
|
+
}
|
|
124856
|
+
for (const [key2, read] of bodies) {
|
|
124857
|
+
if (kept <= MAX_CACHED_BODIES && (kept <= 1 || chars <= KEPT_BODY_CHARS_BUDGET)) return;
|
|
124858
|
+
if (read.settled) {
|
|
124859
|
+
bodies.delete(key2);
|
|
124860
|
+
kept--;
|
|
124861
|
+
chars -= read.chars;
|
|
124862
|
+
}
|
|
124863
|
+
}
|
|
124864
|
+
}
|
|
124865
|
+
function sendBodyRead(record2, kind) {
|
|
124866
|
+
const method = kind === "response" ? "Network.getResponseBody" : "Network.getRequestPostData";
|
|
124867
|
+
return new Promise((resolve21) => {
|
|
124868
|
+
resolve21(
|
|
124869
|
+
link.request(
|
|
124870
|
+
record2.connection,
|
|
124871
|
+
method,
|
|
124872
|
+
{ requestId: record2.layerId },
|
|
124873
|
+
kind === "response" ? RESPONSE_BODY_TIMEOUT_MS : POST_DATA_TIMEOUT_MS
|
|
124874
|
+
)
|
|
124875
|
+
);
|
|
124876
|
+
}).then(
|
|
124877
|
+
(result) => {
|
|
124878
|
+
stalls.delete(record2.connection);
|
|
124879
|
+
return toBody(result, kind);
|
|
124880
|
+
},
|
|
124881
|
+
(err) => {
|
|
124882
|
+
if (getFailureSignal(err)?.error_code === FAILURE_CODES.NDJSON_CDP_REQUEST_TIMEOUT) {
|
|
124883
|
+
stalls.set(record2.connection, performance.now());
|
|
124884
|
+
} else {
|
|
124885
|
+
stalls.delete(record2.connection);
|
|
124886
|
+
}
|
|
124887
|
+
return unavailable(failureReason(record2, kind, method, err));
|
|
124888
|
+
}
|
|
124889
|
+
);
|
|
124890
|
+
}
|
|
124891
|
+
function failureReason(record2, kind, method, err) {
|
|
124892
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
124893
|
+
switch (getFailureSignal(err)?.error_code) {
|
|
124894
|
+
case FAILURE_CODES.NDJSON_CDP_CONNECTION_CLOSED:
|
|
124895
|
+
return closedReason(record2.connection);
|
|
124896
|
+
case FAILURE_CODES.NDJSON_CDP_REQUEST_FAILED: {
|
|
124897
|
+
const marker = `${method} failed: `;
|
|
124898
|
+
const at = message.indexOf(marker);
|
|
124899
|
+
const detail = at === -1 ? message : message.slice(at + marker.length);
|
|
124900
|
+
if (/^no /i.test(detail)) {
|
|
124901
|
+
if (kind === "response") return BODY_NO_LONGER_HELD;
|
|
124902
|
+
if (/^no request stored\b/i.test(detail)) {
|
|
124903
|
+
return record2.state === "pending" ? STILL_SENDING : BODY_NO_LONGER_HELD;
|
|
124904
|
+
}
|
|
124905
|
+
return REQUEST_BODY_GONE;
|
|
124906
|
+
}
|
|
124907
|
+
return `the agent did not return the body: ${detail}`;
|
|
124908
|
+
}
|
|
124909
|
+
}
|
|
124910
|
+
return `the agent did not return the body: ${message}`;
|
|
124697
124911
|
}
|
|
124698
124912
|
return {
|
|
124699
124913
|
state: state3,
|
|
124700
124914
|
fold(connection, method, params) {
|
|
124915
|
+
sawConnection(connection);
|
|
124701
124916
|
if (typeof params !== "object" || params === null) return;
|
|
124702
124917
|
const p = params;
|
|
124703
124918
|
const layerId = typeof p.requestId === "string" ? p.requestId : null;
|
|
@@ -124709,6 +124924,7 @@ function createIosNetworkRecords(state3) {
|
|
|
124709
124924
|
}
|
|
124710
124925
|
const record2 = byLayerId.get(keyOf(connection, layerId));
|
|
124711
124926
|
if (!record2) return;
|
|
124927
|
+
const uploading = record2.state === "pending" && record2.request.hasPostData === true;
|
|
124712
124928
|
switch (method) {
|
|
124713
124929
|
case "Network.responseReceived": {
|
|
124714
124930
|
const r = asObject(p.response);
|
|
@@ -124741,11 +124957,14 @@ function createIosNetworkRecords(state3) {
|
|
|
124741
124957
|
default:
|
|
124742
124958
|
return;
|
|
124743
124959
|
}
|
|
124960
|
+
if (uploading) uploadEnds.set(record2, performance.now());
|
|
124744
124961
|
resize(record2);
|
|
124745
124962
|
},
|
|
124746
|
-
|
|
124963
|
+
holdsRecordsOf: (connection) => records.some((record2) => record2.connection === connection),
|
|
124747
124964
|
connectionClosed(connection, check3) {
|
|
124965
|
+
sawConnection(connection);
|
|
124748
124966
|
const ended = check3.superseded || check3.running === false || check3.runningPid !== void 0 && check3.connectionPid !== void 0 && check3.runningPid !== check3.connectionPid;
|
|
124967
|
+
if (ended) endedConnections.add(connection);
|
|
124749
124968
|
const open5 = records.filter((r) => r.connection === connection && isOpen(r));
|
|
124750
124969
|
for (const record2 of open5) {
|
|
124751
124970
|
record2.state = "failed";
|
|
@@ -124758,9 +124977,39 @@ function createIosNetworkRecords(state3) {
|
|
|
124758
124977
|
record: (id) => byId.get(id),
|
|
124759
124978
|
clear() {
|
|
124760
124979
|
for (const record2 of records) cleared.add(record2);
|
|
124761
|
-
}
|
|
124980
|
+
},
|
|
124981
|
+
responseBody: (id) => readBody(id, "response"),
|
|
124982
|
+
requestPostData: (id) => readBody(id, "post")
|
|
124762
124983
|
};
|
|
124763
124984
|
}
|
|
124985
|
+
function ownCopy(text) {
|
|
124986
|
+
return Buffer.from(text, "utf16le").toString("utf16le");
|
|
124987
|
+
}
|
|
124988
|
+
function adoptLateBody(lost, replacing, adopt) {
|
|
124989
|
+
let take2 = adopt;
|
|
124990
|
+
void replacing.then(() => {
|
|
124991
|
+
take2 = void 0;
|
|
124992
|
+
});
|
|
124993
|
+
void lost.then((body) => {
|
|
124994
|
+
if (body.available) take2?.(body);
|
|
124995
|
+
});
|
|
124996
|
+
}
|
|
124997
|
+
function shownOf(read, kind, record2) {
|
|
124998
|
+
return kind === "post" ? read.sent.then(() => withinWait(read.answer, record2)) : read.answer;
|
|
124999
|
+
}
|
|
125000
|
+
function withinWait(answer, record2) {
|
|
125001
|
+
return new Promise((resolve21) => {
|
|
125002
|
+
const timer = setTimeout(
|
|
125003
|
+
() => resolve21(unavailable(record2.state === "pending" ? STILL_SENDING : NO_ANSWER)),
|
|
125004
|
+
POST_DATA_WAIT_MS
|
|
125005
|
+
);
|
|
125006
|
+
timer.unref();
|
|
125007
|
+
void answer.then((body) => {
|
|
125008
|
+
clearTimeout(timer);
|
|
125009
|
+
resolve21(body);
|
|
125010
|
+
});
|
|
125011
|
+
});
|
|
125012
|
+
}
|
|
124764
125013
|
var liveCaptures = /* @__PURE__ */ new Set();
|
|
124765
125014
|
function registerIosNetworkCaptures(captures) {
|
|
124766
125015
|
liveCaptures.add(captures);
|
|
@@ -124768,6 +125017,15 @@ function registerIosNetworkCaptures(captures) {
|
|
|
124768
125017
|
liveCaptures.delete(captures);
|
|
124769
125018
|
};
|
|
124770
125019
|
}
|
|
125020
|
+
function findIosNativeRecord(id) {
|
|
125021
|
+
for (const captures of liveCaptures) {
|
|
125022
|
+
for (const records of captures.stores.values()) {
|
|
125023
|
+
const record2 = records.record(id);
|
|
125024
|
+
if (record2) return { records, record: record2 };
|
|
125025
|
+
}
|
|
125026
|
+
}
|
|
125027
|
+
return void 0;
|
|
125028
|
+
}
|
|
124771
125029
|
function capturing(captures, bundleId) {
|
|
124772
125030
|
return captures.bundleIds.has(bundleId) && captures.stores.has(bundleId);
|
|
124773
125031
|
}
|
|
@@ -124905,6 +125163,17 @@ var LENT_HANDSHAKE_PROMPT_MS = 1e3;
|
|
|
124905
125163
|
var WAITING_FOR_ENABLE = "waiting for the agent to acknowledge Network.enable";
|
|
124906
125164
|
var WAITING_FOR_CAPTURE_STATE = "waiting for the agent to say whether capture is on";
|
|
124907
125165
|
var PROVIDER_CAPTURE_OFF = "the device provider has capture off for the app; argent does not turn it on, because that resets the provider's network settings: turn capture on in the provider";
|
|
125166
|
+
function closedBeforeRequest(bundleId, method) {
|
|
125167
|
+
return new FailureError(
|
|
125168
|
+
`native-devtools ${bundleId}: the connection closed before ${method} was answered`,
|
|
125169
|
+
{
|
|
125170
|
+
error_code: FAILURE_CODES.NDJSON_CDP_CONNECTION_CLOSED,
|
|
125171
|
+
failure_stage: "ndjson_cdp_request",
|
|
125172
|
+
failure_area: "tool_server",
|
|
125173
|
+
error_kind: "network"
|
|
125174
|
+
}
|
|
125175
|
+
);
|
|
125176
|
+
}
|
|
124908
125177
|
function getNativeDevtoolsSocketPath(udid) {
|
|
124909
125178
|
return `/tmp/argent-nd-${udid.slice(0, 8)}.sock`;
|
|
124910
125179
|
}
|
|
@@ -125158,7 +125427,12 @@ var nativeDevtoolsBlueprint = {
|
|
|
125158
125427
|
};
|
|
125159
125428
|
const settleClosedConnection = async (bundleId, conn) => {
|
|
125160
125429
|
const store = networkStores.get(bundleId);
|
|
125161
|
-
if (lentSocketPath || disposed || !store
|
|
125430
|
+
if (lentSocketPath || disposed || !store) return;
|
|
125431
|
+
if (!store.holdsRecordsOf(conn.index)) {
|
|
125432
|
+
const live2 = connections2.get(bundleId);
|
|
125433
|
+
store.connectionClosed(conn.index, { superseded: live2 !== void 0 && live2 !== conn });
|
|
125434
|
+
return;
|
|
125435
|
+
}
|
|
125162
125436
|
const inspection = await host.inspectRunningApp(udid, bundleId).catch(() => null);
|
|
125163
125437
|
if (disposed) return;
|
|
125164
125438
|
const live = connections2.get(bundleId);
|
|
@@ -125304,7 +125578,13 @@ var nativeDevtoolsBlueprint = {
|
|
|
125304
125578
|
const app = bundleId;
|
|
125305
125579
|
networkStores.set(
|
|
125306
125580
|
app,
|
|
125307
|
-
createIosNetworkRecords(() => captureState(app)
|
|
125581
|
+
createIosNetworkRecords(() => captureState(app), {
|
|
125582
|
+
liveConnection: () => connections2.get(app)?.index,
|
|
125583
|
+
request: (index, method, params, timeoutMs) => {
|
|
125584
|
+
const live = connections2.get(app);
|
|
125585
|
+
return live?.index === index ? live.cdp.request(method, params, { timeoutMs }) : Promise.reject(closedBeforeRequest(app, method));
|
|
125586
|
+
}
|
|
125587
|
+
})
|
|
125308
125588
|
);
|
|
125309
125589
|
}
|
|
125310
125590
|
if (lentSocketPath && performance.now() - lentConnectedAt < LENT_HANDSHAKE_PROMPT_MS) {
|
|
@@ -135872,19 +136152,6 @@ var os13 = __toESM(require("node:os"));
|
|
|
135872
136152
|
var path30 = __toESM(require("node:path"));
|
|
135873
136153
|
init_src2();
|
|
135874
136154
|
|
|
135875
|
-
// ../tool-server/src/utils/keyed-lock.ts
|
|
135876
|
-
async function withKeyedLock(locks, key2, fn) {
|
|
135877
|
-
const previous = locks.get(key2) ?? Promise.resolve();
|
|
135878
|
-
const run2 = previous.then(() => fn());
|
|
135879
|
-
const held = run2.catch(() => {
|
|
135880
|
-
});
|
|
135881
|
-
locks.set(key2, held);
|
|
135882
|
-
void held.then(() => {
|
|
135883
|
-
if (locks.get(key2) === held) locks.delete(key2);
|
|
135884
|
-
});
|
|
135885
|
-
return run2;
|
|
135886
|
-
}
|
|
135887
|
-
|
|
135888
136155
|
// ../tool-server/src/utils/ios-device/runner-signing.ts
|
|
135889
136156
|
init_src2();
|
|
135890
136157
|
|
|
@@ -149608,7 +149875,6 @@ var MIN_SDK = 26;
|
|
|
149608
149875
|
var PACKAGE_NAME2 = /^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z0-9_]+)*$/;
|
|
149609
149876
|
var PROTOCOL_VERSION = 2;
|
|
149610
149877
|
var MAX_REDIRECTS = 32;
|
|
149611
|
-
var MAX_CACHED_BODIES = 64;
|
|
149612
149878
|
var MAX_FRAME_CHARS = 8 * 1024 * 1024;
|
|
149613
149879
|
var HANDSHAKE_FRAME_CHARS = 4 * 1024;
|
|
149614
149880
|
var MAX_PENDING_HANDSHAKES = 32;
|
|
@@ -150664,9 +150930,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
150664
150930
|
const conn = liveConnectionFor(entry.conn);
|
|
150665
150931
|
if (!conn) {
|
|
150666
150932
|
return Promise.resolve(
|
|
150667
|
-
unavailable(
|
|
150668
|
-
agentGoneFor(entry.conn) ? AGENT_GONE_REASON : "the app process that made the request is gone"
|
|
150669
|
-
)
|
|
150933
|
+
unavailable(agentGoneFor(entry.conn) ? AGENT_GONE_REASON : PROCESS_GONE)
|
|
150670
150934
|
);
|
|
150671
150935
|
}
|
|
150672
150936
|
const sending = kind === "post" && record2.state === "pending";
|
|
@@ -150976,24 +151240,6 @@ function agentFiles() {
|
|
|
150976
151240
|
function isAgentAbi(abi) {
|
|
150977
151241
|
return AGENT_ABIS.includes(abi);
|
|
150978
151242
|
}
|
|
150979
|
-
function toBody(result, kind) {
|
|
150980
|
-
const r = asObject(result);
|
|
150981
|
-
const text = kind === "response" ? r.body : r.postData;
|
|
150982
|
-
if (r.bodyAvailable === false || typeof text !== "string") {
|
|
150983
|
-
return unavailable(
|
|
150984
|
-
kind === "response" ? "the agent holds no body for this response" : "the agent holds no body for this request"
|
|
150985
|
-
);
|
|
150986
|
-
}
|
|
150987
|
-
return {
|
|
150988
|
-
available: true,
|
|
150989
|
-
body: text,
|
|
150990
|
-
base64Encoded: r.base64Encoded === true,
|
|
150991
|
-
truncated: r.wasTruncated === true
|
|
150992
|
-
};
|
|
150993
|
-
}
|
|
150994
|
-
function unavailable(reason2) {
|
|
150995
|
-
return { available: false, body: "", base64Encoded: false, truncated: false, reason: reason2 };
|
|
150996
|
-
}
|
|
150997
151243
|
function isOwnFailure(err) {
|
|
150998
151244
|
const code = getFailureSignal(err)?.error_code;
|
|
150999
151245
|
return code === FAILURE_CODES.ANDROID_NETWORK_INSPECTOR_UNKNOWN_PACKAGE || code === FAILURE_CODES.ANDROID_NETWORK_INSPECTOR_RUN_AS_FAILED || code === FAILURE_CODES.ANDROID_NETWORK_INSPECTOR_DEVICE_IN_USE || code === FAILURE_CODES.ANDROID_NETWORK_INSPECTOR_NO_DEVICE_PORT;
|
|
@@ -151326,7 +151572,7 @@ var zodSchema4 = external_exports.object({
|
|
|
151326
151572
|
"Maximum number of requests to return: the most recent ones, oldest first. 0 returns only the header and the total.<flag:macos-apps> On a Mac app it counts events, not requests: one request gives several events. 0 returns no events.</flag:macos-apps>"
|
|
151327
151573
|
),
|
|
151328
151574
|
clear: external_exports.boolean().optional().default(false).describe(
|
|
151329
|
-
"Clear the log after reading. On Android, the IDs of cleared requests still work in view-network-request-details"
|
|
151575
|
+
"Clear the log after reading. On iOS and Android, the IDs of cleared requests still work in view-network-request-details"
|
|
151330
151576
|
),
|
|
151331
151577
|
stop: external_exports.boolean().optional().describe(
|
|
151332
151578
|
"Android only: turn native capture off for this app instead of listing. Other apps keep theirs."
|
|
@@ -151349,7 +151595,7 @@ function createNativeNetworkLogsTool(registry2) {
|
|
|
151349
151595
|
description: `Retrieve network requests captured at the native level: NSURLProtocol on iOS, OkHttp on Android.
|
|
151350
151596
|
Use when inspecting native-level HTTP traffic that view-network-logs cannot see: requests that never pass through JS XMLHttpRequest or fetch.
|
|
151351
151597
|
On iOS it sees URLSession requests (default and ephemeral session configurations, and URLSession.shared) from native modules and Swift/Objective-C code. It does not see background URLSession transfers, WKWebView, Network.framework, or HTTP stacks that bypass URLSession (e.g. Flutter), so an empty result does not mean the app sent nothing.
|
|
151352
|
-
Returns { status, header, armed, count, total, requests }: one line per request, oldest first, with its id (ios-3f9a-12, android-3f9a-12), method, URL, state (pending, headers, complete or failed), status, mimeType, durationMs and errorText. The header says whether capture is armed, how many requests there are and the app's pid once read, and why capture is not armed when it is not. Requests to Metro on \`port\` are left out. The history is kept across relaunches of the app.
|
|
151598
|
+
Returns { status, header, armed, count, total, requests }: one line per request, oldest first, with its id (ios-3f9a-12, android-3f9a-12), method, URL, state (pending, headers, complete or failed), status, mimeType, durationMs and errorText. The header says whether capture is armed, how many requests there are and the app's pid once read, and why capture is not armed when it is not. Requests to Metro on \`port\` are left out. Pass a request's id to view-network-request-details for its headers and bodies, and on Android its redirects. The history is kept across relaunches of the app.
|
|
151353
151599
|
The first call for an app starts capture, so earlier requests are not captured: repeat the action whose requests you need, then call again.
|
|
151354
151600
|
On iOS: the first call waits until the app acknowledges capture. When capture started while the app was already running, the header of the first answer says that the app's launch was not recorded; to capture the launch, restart-app and call again, unless the header says the launch cannot be recorded on that device. Capture stays on for later processes of the app.
|
|
151355
151601
|
<flag:macos-apps>On a Mac app: { status, count, events } of NSURLSession requests, react-native-macos fetch included; capture stays on across restart-app, a new log per process.
|
|
@@ -151357,7 +151603,7 @@ On iOS: the first call waits until the app acknowledges capture. When capture st
|
|
|
151357
151603
|
On a device whose devtools agent argent attached to rather than armed itself, only the agent's owner turns capture off; the list starts at argent's connection, not at the first call; a relaunch ends capture and clears the list; a not-connected app fails with \`NATIVE_DEVTOOLS_NOT_CONNECTED\` instead of a status, and no restart on argent's side fixes it. An Apple system app is rejected outright (terminal: never retry it).
|
|
151358
151604
|
On Android: needs a debuggable build. The first call usually returns armed: false. Call it again every few seconds until armed is true, then repeat the action whose requests you need.
|
|
151359
151605
|
Capture also misses a request already in flight at the attach and requests from clients other than OkHttp (e.g. HttpURLConnection, Cronet); an app whose OkHttp is fully minified reports capture unavailable.
|
|
151360
|
-
Android results also carry capture and captureDetail. When capture is active, captureDetail and the header can say that only some requests are captured: then an empty or short list does not mean the app sent nothing.
|
|
151606
|
+
Android results also carry capture and captureDetail. When capture is active, captureDetail and the header can say that only some requests are captured: then an empty or short list does not mean the app sent nothing.
|
|
151361
151607
|
Capture can slow the app. It stays on, and launch-app and restart-app attach it to each new process, until a call with stop: true turns it off for this app (stop-all-simulator-servers for the device also does); restart-app then starts the app without the agent. stop: true returns { status, stopped, message }, where stopped is false when capture was not on for the app. On iOS stop: true fails: capture ends only with stop-all-simulator-servers for this device or a local simulator shutdown, and in the running process only when the app restarts.
|
|
151362
151608
|
When status is not_attachable, use view-network-logs and do not retry.`,
|
|
151363
151609
|
zodSchema: zodSchema4,
|
|
@@ -152565,6 +152811,7 @@ var jsRuntimeDebuggerBlueprint = {
|
|
|
152565
152811
|
init_src2();
|
|
152566
152812
|
|
|
152567
152813
|
// ../tool-server/src/utils/debugger/scripts/network-interceptor.ts
|
|
152814
|
+
var BINARY_BODY_TYPES = /^(image\/(?!svg)|audio\/|video\/|font\/|application\/(octet-stream|pdf|zip|gzip|wasm|x-protobuf)$)/;
|
|
152568
152815
|
var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
|
|
152569
152816
|
var g = globalThis;
|
|
152570
152817
|
if (g.__argent_network_v2) return JSON.stringify({ installed: false, reason: 'already installed' });
|
|
@@ -152643,7 +152890,7 @@ var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
|
|
|
152643
152890
|
}
|
|
152644
152891
|
|
|
152645
152892
|
// A body of one of these types is not text: its size is recorded and it is not read as text.
|
|
152646
|
-
var BINARY_TYPES =
|
|
152893
|
+
var BINARY_TYPES = ${BINARY_BODY_TYPES};
|
|
152647
152894
|
function isBinaryType(mime) {
|
|
152648
152895
|
return typeof mime === 'string' && BINARY_TYPES.test(mime.toLowerCase());
|
|
152649
152896
|
}
|
|
@@ -164961,11 +165208,16 @@ function redactHeaders(headers) {
|
|
|
164961
165208
|
}
|
|
164962
165209
|
return result;
|
|
164963
165210
|
}
|
|
164964
|
-
var
|
|
165211
|
+
var NATIVE_ID_PREFIXES = { android: "android-", ios: "ios-" };
|
|
165212
|
+
function nativeIdPlatform2(requestId) {
|
|
165213
|
+
if (requestId.startsWith(NATIVE_ID_PREFIXES.android)) return "android";
|
|
165214
|
+
if (requestId.startsWith(NATIVE_ID_PREFIXES.ios)) return "ios";
|
|
165215
|
+
return void 0;
|
|
165216
|
+
}
|
|
164965
165217
|
var MAX_BODY_SIZE = 1e3;
|
|
164966
165218
|
var MAX_DECODED_BODY_BYTES = 16 * 1024 * 1024;
|
|
164967
165219
|
function cutMarker(fullSize, mimeType, shown = MAX_BODY_SIZE) {
|
|
164968
|
-
const mime = mimeType
|
|
165220
|
+
const mime = mimeType ? `, MIME: ${mimeType}` : "";
|
|
164969
165221
|
return `[TRUNCATED: first ${shown} chars shown, full size: ${fullSize}${mime}]`;
|
|
164970
165222
|
}
|
|
164971
165223
|
function truncateBody(body, mimeType) {
|
|
@@ -164988,16 +165240,18 @@ ${postData.slice(0, MAX_BODY_SIZE)}...`;
|
|
|
164988
165240
|
var zodSchema39 = external_exports.object({
|
|
164989
165241
|
port: metroPortField,
|
|
164990
165242
|
device_id: external_exports.string().describe(
|
|
164991
|
-
"Device id from list-devices (iOS simulator UDID or Android serial), the same id used with debugger-connect. An android- ID needs no debugger connection."
|
|
165243
|
+
"Device id from list-devices (iOS simulator UDID or Android serial), the same id used with debugger-connect. An ios- or android- ID needs no debugger connection."
|
|
165244
|
+
),
|
|
165245
|
+
requestId: external_exports.string().describe(
|
|
165246
|
+
"The requestId from view-network-logs, or an ios- or android- ID from native-network-logs."
|
|
164992
165247
|
),
|
|
164993
|
-
requestId: external_exports.string().describe("The requestId from view-network-logs, or an android- ID from native-network-logs."),
|
|
164994
165248
|
includeBody: external_exports.boolean().default(true).describe("Whether to include the response body (if captured).")
|
|
164995
165249
|
});
|
|
164996
165250
|
var networkRequestTool = {
|
|
164997
165251
|
id: "view-network-request-details",
|
|
164998
|
-
description: `Get full details of a specific network request by its requestId.
|
|
165252
|
+
description: `Get full details of a specific network request by its requestId: one from view-network-logs, or an ios- or android- ID from native-network-logs, which needs no debugger connection.
|
|
164999
165253
|
Returns request/response headers (sensitive headers redacted), status, timing, the request body, and optionally the response body.
|
|
165000
|
-
Request and response bodies over 1000 chars are cut to 1000 under a "[TRUNCATED: ...]" line that gives the full size; a binary response body is omitted. Use when you need headers, body, or timing for a specific request after listing logs.
|
|
165254
|
+
Request and response bodies over 1000 chars are cut to 1000 under a "[TRUNCATED: ...]" line that gives the full size; a binary response body is omitted, as is a binary request body of an ios- or android- ID. For an ios- or android- ID, a body that cannot be read shows "[unavailable: <reason>]"; when the reason says the app may still be sending the request body, call again once the request has ended. Use when you need headers, body, or timing for a specific request after listing logs.
|
|
165001
165255
|
Returns an error message string if the requestId is not found.`,
|
|
165002
165256
|
zodSchema: zodSchema39,
|
|
165003
165257
|
readOnly: true,
|
|
@@ -165008,19 +165262,24 @@ Returns an error message string if the requestId is not found.`,
|
|
|
165008
165262
|
},
|
|
165009
165263
|
capability: DEBUGGER_TOOL_CAPABILITY,
|
|
165010
165264
|
services: (params) => {
|
|
165011
|
-
if (
|
|
165265
|
+
if (isNativeRequestId(params.requestId)) return {};
|
|
165012
165266
|
const device = resolveDevice(params.device_id);
|
|
165013
165267
|
if (device.platform === "chromium") {
|
|
165014
165268
|
return { chromium: chromiumCdpRef(device) };
|
|
165015
165269
|
}
|
|
165016
|
-
if (params.requestId
|
|
165270
|
+
if (nativeIdPlatform2(params.requestId)) return {};
|
|
165017
165271
|
return {
|
|
165018
165272
|
inspector: `NetworkInspector:${metroPort(params)}:${canonicalDeviceId(params.device_id)}`
|
|
165019
165273
|
};
|
|
165020
165274
|
},
|
|
165021
165275
|
async execute(services, params) {
|
|
165022
165276
|
if (ANDROID_NATIVE_REQUEST_ID.test(params.requestId)) {
|
|
165023
|
-
|
|
165277
|
+
const found = findAndroidNativeRecord(params.requestId);
|
|
165278
|
+
return found ? nativeRequestDetails(found.record, found.inspector, params.includeBody) : nativeNotFound(params.requestId, params.device_id, "android");
|
|
165279
|
+
}
|
|
165280
|
+
if (IOS_NATIVE_REQUEST_ID.test(params.requestId)) {
|
|
165281
|
+
const found = findIosNativeRecord(params.requestId);
|
|
165282
|
+
return found ? nativeRequestDetails(found.record, found.records, params.includeBody) : nativeNotFound(params.requestId, params.device_id, "ios");
|
|
165024
165283
|
}
|
|
165025
165284
|
const device = resolveDevice(params.device_id);
|
|
165026
165285
|
if (device.platform === "chromium") {
|
|
@@ -165073,9 +165332,8 @@ Returns an error message string if the requestId is not found.`,
|
|
|
165073
165332
|
}
|
|
165074
165333
|
return details2;
|
|
165075
165334
|
}
|
|
165076
|
-
|
|
165077
|
-
|
|
165078
|
-
}
|
|
165335
|
+
const nativePlatform = nativeIdPlatform2(params.requestId);
|
|
165336
|
+
if (nativePlatform) return nativeNotFound(params.requestId, params.device_id, nativePlatform);
|
|
165079
165337
|
const api = services.inspector;
|
|
165080
165338
|
await api.cdp.evaluate(NETWORK_INTERCEPTOR_SCRIPT).catch(() => {
|
|
165081
165339
|
});
|
|
@@ -165130,14 +165388,15 @@ ${body.slice(0, MAX_BODY_SIZE)}...`;
|
|
|
165130
165388
|
return details;
|
|
165131
165389
|
}
|
|
165132
165390
|
};
|
|
165133
|
-
function
|
|
165391
|
+
function isNativeRequestId(requestId) {
|
|
165392
|
+
return ANDROID_NATIVE_REQUEST_ID.test(requestId) || IOS_NATIVE_REQUEST_ID.test(requestId);
|
|
165393
|
+
}
|
|
165394
|
+
function nativeNotFound(requestId, deviceId, layer) {
|
|
165134
165395
|
const { platform } = resolveDevice(deviceId);
|
|
165135
|
-
|
|
165396
|
+
const prefix = NATIVE_ID_PREFIXES[layer];
|
|
165397
|
+
return platform === "chromium" || platform === "vega" ? `Request ${requestId} not found. An ${prefix} ID comes from ${layer === "android" ? "an Android device" : "an iOS simulator"}. Use view-network-logs to list this device's requests.` : `Request ${requestId} not found. Use native-network-logs to list the requests the ${layer === "android" ? "Android" : "iOS"} native layer recorded.`;
|
|
165136
165398
|
}
|
|
165137
|
-
async function
|
|
165138
|
-
const found = findAndroidNativeRecord(requestId);
|
|
165139
|
-
if (!found) return androidNativeNotFound(requestId, deviceId);
|
|
165140
|
-
const { inspector, record: record2 } = found;
|
|
165399
|
+
async function nativeRequestDetails(record2, bodies, includeBody) {
|
|
165141
165400
|
const { wireHeaders } = record2.request;
|
|
165142
165401
|
const bodyHeaders = record2.redirects?.[0]?.requestHeaders ?? wireHeaders ?? {};
|
|
165143
165402
|
const requestHeader = (name) => headerValue(bodyHeaders, name) || headerValue(record2.request.headers, name);
|
|
@@ -165149,7 +165408,7 @@ async function androidNativeRequestDetails(requestId, includeBody, deviceId) {
|
|
|
165149
165408
|
const headersNote = requestHeadersNote(record2);
|
|
165150
165409
|
if (headersNote) request3.headersNote = headersNote;
|
|
165151
165410
|
if (record2.request.hasPostData) {
|
|
165152
|
-
request3.postData = await
|
|
165411
|
+
request3.postData = await readNativeBody(() => bodies.requestPostData(record2.id), {
|
|
165153
165412
|
contentType: requestHeader("content-type"),
|
|
165154
165413
|
contentEncoding: requestHeader("content-encoding"),
|
|
165155
165414
|
wholeSize: sizeInBytes(
|
|
@@ -165187,10 +165446,11 @@ async function androidNativeRequestDetails(requestId, includeBody, deviceId) {
|
|
|
165187
165446
|
};
|
|
165188
165447
|
if (record2.response.fromCache) resp.fromCache = true;
|
|
165189
165448
|
if (includeBody) {
|
|
165190
|
-
resp.body = await
|
|
165449
|
+
resp.body = await readNativeBody(() => bodies.responseBody(record2.id), {
|
|
165191
165450
|
mimeType: record2.response.mimeType,
|
|
165192
165451
|
contentType: headerValue(record2.response.headers, "content-type"),
|
|
165193
|
-
|
|
165452
|
+
// An iOS response body is read decoded, so its Content-Encoding is not applied again.
|
|
165453
|
+
contentEncoding: record2.layer === "ios-native" ? "" : headerValue(record2.response.headers, "content-encoding"),
|
|
165194
165454
|
wholeSize: sizeInBytes(record2.encodedDataLength ?? NaN, "as the app received them")
|
|
165195
165455
|
});
|
|
165196
165456
|
}
|
|
@@ -165207,7 +165467,7 @@ function requestHeadersNote(record2) {
|
|
|
165207
165467
|
}
|
|
165208
165468
|
return "These are the headers the app set. The headers sent on the wire (such as Cookie and User-Agent) were not reported for this request.";
|
|
165209
165469
|
}
|
|
165210
|
-
async function
|
|
165470
|
+
async function readNativeBody(read, framing) {
|
|
165211
165471
|
const mimeType = framing.mimeType ?? framing.contentType.split(";")[0].trim();
|
|
165212
165472
|
let body;
|
|
165213
165473
|
try {
|
|
@@ -165216,36 +165476,70 @@ async function readAndroidBody(read, framing) {
|
|
|
165216
165476
|
return `[unavailable: ${err instanceof Error ? err.message : String(err)}]`;
|
|
165217
165477
|
}
|
|
165218
165478
|
if (!body.available) return `[unavailable: ${body.reason ?? "no body"}]`;
|
|
165219
|
-
if (
|
|
165220
|
-
|
|
165479
|
+
if (body.incomplete) framing = { ...framing, wholeSize: void 0 };
|
|
165480
|
+
if (body.inlineChars !== void 0) {
|
|
165481
|
+
return inlineBody(body.body, body.inlineChars, body.truncated, mimeType, framing);
|
|
165221
165482
|
}
|
|
165222
|
-
const
|
|
165483
|
+
const asSent = () => {
|
|
165484
|
+
const text2 = inDeclaredCharset(body.body, framing.contentType, body.truncated);
|
|
165485
|
+
return body.truncated ? cutByAgent(text2, mimeType, Buffer.byteLength(body.body), framing, body.incomplete) : truncateBody(text2, mimeType);
|
|
165486
|
+
};
|
|
165487
|
+
if (!body.base64Encoded && contentCodings(framing.contentEncoding).length === 0) return asSent();
|
|
165488
|
+
const kept = Buffer.from(body.body, body.base64Encoded ? "base64" : "utf8");
|
|
165223
165489
|
const bytes = decodeContent2(kept, framing.contentEncoding, body.truncated);
|
|
165224
|
-
if (!bytes)
|
|
165225
|
-
|
|
165226
|
-
}
|
|
165490
|
+
if (!bytes) return decodesTooLarge(framing);
|
|
165491
|
+
if (!body.base64Encoded && bytes === kept) return asSent();
|
|
165227
165492
|
const text = decodeText(bytes, charsetOf(framing.contentType), body.truncated);
|
|
165228
165493
|
if (text === null) {
|
|
165229
|
-
return body.truncated ? `[body omitted: binary ${mimeType || "data"}, ${framing.wholeSize ?? "size unknown"}; ${agentKept(kept.length)}]` : `[body omitted: binary ${mimeType || "data"}, ${bytes.length} bytes]`;
|
|
165230
|
-
}
|
|
165231
|
-
return body.truncated ? cutByAgent(text, mimeType, kept.length, framing) : truncateBody(text, mimeType);
|
|
165494
|
+
return body.truncated ? `[body omitted: binary ${mimeType || "data"}, ${framing.wholeSize ?? "size unknown"}; ${agentKept(kept.length, body.incomplete)}]` : `[body omitted: binary ${mimeType || "data"}, ${bytes.length} bytes]`;
|
|
165495
|
+
}
|
|
165496
|
+
return body.truncated ? cutByAgent(text, mimeType, kept.length, framing, body.incomplete) : truncateBody(text, mimeType);
|
|
165497
|
+
}
|
|
165498
|
+
function inDeclaredCharset(text, contentType, truncated) {
|
|
165499
|
+
if (namesUtf8(contentType)) return text;
|
|
165500
|
+
return decodeText(Buffer.from(text, "utf8"), charsetOf(contentType), truncated) ?? text;
|
|
165501
|
+
}
|
|
165502
|
+
function namesUtf8(contentType) {
|
|
165503
|
+
const charset = charsetOf(contentType);
|
|
165504
|
+
return !charset || /^utf-?8$/i.test(charset);
|
|
165505
|
+
}
|
|
165506
|
+
function inlineBody(text, wholeChars, truncated, mimeType, framing) {
|
|
165507
|
+
if (BINARY_BODY_TYPES.test(mimeType.toLowerCase())) {
|
|
165508
|
+
return `[body omitted: binary ${mimeType}, ${framing.wholeSize ?? "size unknown"}]`;
|
|
165509
|
+
}
|
|
165510
|
+
const sent = contentCodings(framing.contentEncoding).length ? Buffer.from(text, "utf8") : null;
|
|
165511
|
+
const bytes = sent && decodeContent2(sent, framing.contentEncoding, truncated);
|
|
165512
|
+
if (sent && !bytes) return decodesTooLarge(framing);
|
|
165513
|
+
const encoded = bytes && bytes !== sent ? bytes : null;
|
|
165514
|
+
const decoded2 = encoded ? decodeText(encoded, charsetOf(framing.contentType), truncated) : inDeclaredCharset(text, framing.contentType, truncated);
|
|
165515
|
+
if (decoded2 === null) {
|
|
165516
|
+
const size = truncated ? framing.wholeSize ?? "size unknown" : `${encoded.length} bytes`;
|
|
165517
|
+
return `[body omitted: binary ${mimeType || "data"}, ${size}]`;
|
|
165518
|
+
}
|
|
165519
|
+
if (!truncated) return truncateBody(decoded2, mimeType);
|
|
165520
|
+
const fullSize = !encoded && namesUtf8(framing.contentType) ? `${wholeChars} chars` : `more than ${decoded2.length} chars`;
|
|
165521
|
+
const shown = Math.min(decoded2.length, MAX_BODY_SIZE);
|
|
165522
|
+
return `${cutMarker(fullSize, mimeType, shown)}
|
|
165523
|
+
${decoded2.slice(0, shown)}${decoded2.length > shown ? "..." : ""}`;
|
|
165232
165524
|
}
|
|
165233
|
-
function
|
|
165525
|
+
function decodesTooLarge(framing) {
|
|
165526
|
+
return `[unavailable: the ${framing.contentEncoding.trim()} body decodes to more than ${MAX_DECODED_BODY_BYTES / (1024 * 1024)} MiB]`;
|
|
165527
|
+
}
|
|
165528
|
+
function cutByAgent(text, mimeType, keptBytes, framing, incomplete) {
|
|
165234
165529
|
const shown = Math.min(text.length, MAX_BODY_SIZE);
|
|
165235
|
-
const fullSize = `${framing.wholeSize ?? "unknown"}; ${agentKept(keptBytes)}`;
|
|
165530
|
+
const fullSize = `${framing.wholeSize ?? "unknown"}; ${agentKept(keptBytes, incomplete)}`;
|
|
165236
165531
|
return `${cutMarker(fullSize, mimeType, shown)}
|
|
165237
165532
|
${text.slice(0, shown)}${text.length > shown ? "..." : ""}`;
|
|
165238
165533
|
}
|
|
165239
|
-
function agentKept(keptBytes) {
|
|
165240
|
-
return `the agent kept only the first ${keptBytes} bytes`;
|
|
165534
|
+
function agentKept(keptBytes, incomplete) {
|
|
165535
|
+
return incomplete ? `the upload ended after the first ${keptBytes} bytes, before the app's body stream reached its end` : `the agent kept only the first ${keptBytes} bytes`;
|
|
165241
165536
|
}
|
|
165242
165537
|
function sizeInBytes(bytes, how) {
|
|
165243
165538
|
return Number.isSafeInteger(bytes) && bytes > 0 ? `${bytes} bytes ${how}` : void 0;
|
|
165244
165539
|
}
|
|
165245
165540
|
function decodeContent2(bytes, contentEncoding, truncated = false) {
|
|
165246
|
-
const codings = contentEncoding.split(",").map((coding) => coding.trim().toLowerCase()).filter((coding) => coding !== "" && coding !== "identity");
|
|
165247
165541
|
let decoded2 = bytes;
|
|
165248
|
-
for (const coding of
|
|
165542
|
+
for (const coding of contentCodings(contentEncoding).reverse()) {
|
|
165249
165543
|
const next = decodeOne(decoded2, coding, truncated);
|
|
165250
165544
|
if (next === null) return null;
|
|
165251
165545
|
if (next === void 0) return bytes;
|
|
@@ -165253,6 +165547,9 @@ function decodeContent2(bytes, contentEncoding, truncated = false) {
|
|
|
165253
165547
|
}
|
|
165254
165548
|
return decoded2;
|
|
165255
165549
|
}
|
|
165550
|
+
function contentCodings(contentEncoding) {
|
|
165551
|
+
return contentEncoding.split(",").map((coding) => coding.trim().toLowerCase()).filter((coding) => coding !== "" && coding !== "identity");
|
|
165552
|
+
}
|
|
165256
165553
|
function decodeOne(bytes, coding, truncated) {
|
|
165257
165554
|
const maxOutputLength = MAX_DECODED_BODY_BYTES;
|
|
165258
165555
|
const flush = (mode) => truncated ? { finishFlush: mode } : {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swmansion/argent",
|
|
3
|
-
"version": "0.34.1-next.
|
|
3
|
+
"version": "0.34.1-next.43",
|
|
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",
|