@swmansion/argent 0.34.1-next.42 → 0.34.1-next.44
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/ios-device-runner/ArgentRunner/ArgentRunner.xcodeproj/xcshareddata/xcschemes/ArgentRunner.xcscheme +1 -0
- package/dist/ios-device-runner/ArgentRunner/ArgentRunnerUITests/ArgentRunnerSession.swift +3 -0
- package/dist/ios-device-runner/ArgentRunner/ArgentRunnerUITests/RunnerHTTPServer.swift +21 -9
- package/dist/tool-args.generated.d.ts +3 -3
- package/dist/tool-server.cjs +492 -135
- package/package.json +1 -1
- package/skills/argent-ios-device-interact/SKILL.md +1 -1
- package/skills/argent-ios-device-setup/SKILL.md +4 -2
package/dist/tool-server.cjs
CHANGED
|
@@ -53933,12 +53933,12 @@ var require_wrappy = __commonJS({
|
|
|
53933
53933
|
var require_once = __commonJS({
|
|
53934
53934
|
"../../node_modules/once/once.js"(exports2, module2) {
|
|
53935
53935
|
var wrappy = require_wrappy();
|
|
53936
|
-
module2.exports = wrappy(
|
|
53936
|
+
module2.exports = wrappy(once5);
|
|
53937
53937
|
module2.exports.strict = wrappy(onceStrict);
|
|
53938
|
-
|
|
53938
|
+
once5.proto = once5(function() {
|
|
53939
53939
|
Object.defineProperty(Function.prototype, "once", {
|
|
53940
53940
|
value: function() {
|
|
53941
|
-
return
|
|
53941
|
+
return once5(this);
|
|
53942
53942
|
},
|
|
53943
53943
|
configurable: true
|
|
53944
53944
|
});
|
|
@@ -53949,7 +53949,7 @@ var require_once = __commonJS({
|
|
|
53949
53949
|
configurable: true
|
|
53950
53950
|
});
|
|
53951
53951
|
});
|
|
53952
|
-
function
|
|
53952
|
+
function once5(fn) {
|
|
53953
53953
|
var f = function() {
|
|
53954
53954
|
if (f.called) return f.value;
|
|
53955
53955
|
f.called = true;
|
|
@@ -55034,7 +55034,7 @@ var require_application = __commonJS({
|
|
|
55034
55034
|
var compileQueryParser = require_utils3().compileQueryParser;
|
|
55035
55035
|
var compileTrust = require_utils3().compileTrust;
|
|
55036
55036
|
var resolve21 = require("node:path").resolve;
|
|
55037
|
-
var
|
|
55037
|
+
var once5 = require_once();
|
|
55038
55038
|
var Router2 = require_router();
|
|
55039
55039
|
var slice = Array.prototype.slice;
|
|
55040
55040
|
var flatten = Array.prototype.flat;
|
|
@@ -55264,7 +55264,7 @@ var require_application = __commonJS({
|
|
|
55264
55264
|
var server = http6.createServer(this);
|
|
55265
55265
|
var args = slice.call(arguments);
|
|
55266
55266
|
if (typeof args[args.length - 1] === "function") {
|
|
55267
|
-
var done = args[args.length - 1] =
|
|
55267
|
+
var done = args[args.length - 1] = once5(args[args.length - 1]);
|
|
55268
55268
|
server.once("error", done);
|
|
55269
55269
|
}
|
|
55270
55270
|
return server.listen.apply(server, args);
|
|
@@ -82373,7 +82373,7 @@ var require_websocket = __commonJS({
|
|
|
82373
82373
|
var EventEmitter2 = require("events");
|
|
82374
82374
|
var https = require("https");
|
|
82375
82375
|
var http6 = require("http");
|
|
82376
|
-
var
|
|
82376
|
+
var net11 = require("net");
|
|
82377
82377
|
var tls = require("tls");
|
|
82378
82378
|
var { randomBytes: randomBytes3, createHash: createHash9 } = require("crypto");
|
|
82379
82379
|
var { Duplex, Readable: Readable2 } = require("stream");
|
|
@@ -83130,12 +83130,12 @@ var require_websocket = __commonJS({
|
|
|
83130
83130
|
}
|
|
83131
83131
|
function netConnect(options) {
|
|
83132
83132
|
options.path = options.socketPath;
|
|
83133
|
-
return
|
|
83133
|
+
return net11.connect(options);
|
|
83134
83134
|
}
|
|
83135
83135
|
function tlsConnect(options) {
|
|
83136
83136
|
options.path = void 0;
|
|
83137
83137
|
if (!options.servername && options.servername !== "") {
|
|
83138
|
-
options.servername =
|
|
83138
|
+
options.servername = net11.isIP(options.host) ? "" : options.host;
|
|
83139
83139
|
}
|
|
83140
83140
|
return tls.connect(options);
|
|
83141
83141
|
}
|
|
@@ -88390,7 +88390,7 @@ var require_inflight = __commonJS({
|
|
|
88390
88390
|
"../../node_modules/inflight/inflight.js"(exports2, module2) {
|
|
88391
88391
|
var wrappy = require_wrappy();
|
|
88392
88392
|
var reqs = /* @__PURE__ */ Object.create(null);
|
|
88393
|
-
var
|
|
88393
|
+
var once5 = require_once();
|
|
88394
88394
|
module2.exports = wrappy(inflight);
|
|
88395
88395
|
function inflight(key2, cb) {
|
|
88396
88396
|
if (reqs[key2]) {
|
|
@@ -88402,7 +88402,7 @@ var require_inflight = __commonJS({
|
|
|
88402
88402
|
}
|
|
88403
88403
|
}
|
|
88404
88404
|
function makeres(key2) {
|
|
88405
|
-
return
|
|
88405
|
+
return once5(function RES() {
|
|
88406
88406
|
var cbs = reqs[key2];
|
|
88407
88407
|
var len = cbs.length;
|
|
88408
88408
|
var args = slice(arguments);
|
|
@@ -88453,7 +88453,7 @@ var require_glob = __commonJS({
|
|
|
88453
88453
|
var util = require("util");
|
|
88454
88454
|
var childrenIgnored = common.childrenIgnored;
|
|
88455
88455
|
var isIgnored = common.isIgnored;
|
|
88456
|
-
var
|
|
88456
|
+
var once5 = require_once();
|
|
88457
88457
|
function glob(pattern, options, cb) {
|
|
88458
88458
|
if (typeof options === "function") cb = options, options = {};
|
|
88459
88459
|
if (!options) options = {};
|
|
@@ -88510,7 +88510,7 @@ var require_glob = __commonJS({
|
|
|
88510
88510
|
var n = this.minimatch.set.length;
|
|
88511
88511
|
this.matches = new Array(n);
|
|
88512
88512
|
if (typeof cb === "function") {
|
|
88513
|
-
cb =
|
|
88513
|
+
cb = once5(cb);
|
|
88514
88514
|
this.on("error", cb);
|
|
88515
88515
|
this.on("end", function(matches2) {
|
|
88516
88516
|
cb(null, matches2);
|
|
@@ -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.44";
|
|
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) {
|
|
@@ -126516,6 +126796,7 @@ var fs25 = __toESM(require("node:fs/promises"));
|
|
|
126516
126796
|
var os7 = __toESM(require("node:os"));
|
|
126517
126797
|
var path21 = __toESM(require("node:path"));
|
|
126518
126798
|
var import_node_crypto8 = require("node:crypto");
|
|
126799
|
+
var import_node_net = require("node:net");
|
|
126519
126800
|
init_src2();
|
|
126520
126801
|
|
|
126521
126802
|
// ../tool-server/src/utils/ios-device/usbmux-protocol.ts
|
|
@@ -126961,6 +127242,10 @@ async function launchApp(udid, bundleId, opts = {}) {
|
|
|
126961
127242
|
}
|
|
126962
127243
|
await runDevicectl(args, `launch ${bundleId}`, { bundleId });
|
|
126963
127244
|
}
|
|
127245
|
+
function coreDeviceTunnelAddress(connection) {
|
|
127246
|
+
const address = connection?.tunnelIPAddress;
|
|
127247
|
+
return connection?.transportType === "localNetwork" && connection.tunnelState === "connected" && typeof address === "string" && (0, import_node_net.isIPv6)(address) && /^f[cd]/i.test(address) ? address : null;
|
|
127248
|
+
}
|
|
126964
127249
|
async function deviceInfoDetails(udid, opts = {}) {
|
|
126965
127250
|
const timeoutSeconds = opts.timeoutSeconds ?? 10;
|
|
126966
127251
|
const { json: json2 } = await runDevicectl(
|
|
@@ -126972,11 +127257,10 @@ async function deviceInfoDetails(udid, opts = {}) {
|
|
|
126972
127257
|
const conn = payload?.result?.connectionProperties ?? payload?.result?.device?.connectionProperties;
|
|
126973
127258
|
return {
|
|
126974
127259
|
transportType: conn?.transportType ?? null,
|
|
126975
|
-
tunnelState: conn?.tunnelState ?? null
|
|
127260
|
+
tunnelState: conn?.tunnelState ?? null,
|
|
127261
|
+
tunnelAddress: coreDeviceTunnelAddress(conn)
|
|
126976
127262
|
};
|
|
126977
127263
|
}
|
|
126978
|
-
var READY_MEMO_TTL_MS = 5e3;
|
|
126979
|
-
var readyMemo = /* @__PURE__ */ new Map();
|
|
126980
127264
|
function readyFailureSignal(error_kind) {
|
|
126981
127265
|
return {
|
|
126982
127266
|
error_code: FAILURE_CODES.IOS_DEVICECTL_COMMAND_FAILED,
|
|
@@ -126987,11 +127271,18 @@ function readyFailureSignal(error_kind) {
|
|
|
126987
127271
|
};
|
|
126988
127272
|
}
|
|
126989
127273
|
async function ensureDeviceReady(udid) {
|
|
126990
|
-
const at = readyMemo.get(udid);
|
|
126991
|
-
if (at != null && Date.now() - at < READY_MEMO_TTL_MS) {
|
|
126992
|
-
return;
|
|
126993
|
-
}
|
|
126994
127274
|
const info = await deviceInfoDetails(udid, { timeoutSeconds: 15 });
|
|
127275
|
+
if (info.tunnelAddress) {
|
|
127276
|
+
return info.tunnelAddress;
|
|
127277
|
+
}
|
|
127278
|
+
if (info.transportType === "localNetwork") {
|
|
127279
|
+
throw withFailureSignal(
|
|
127280
|
+
new IosDeviceControlError("The device has no connected CoreDevice IPv6 tunnel", {
|
|
127281
|
+
hint: "Keep the device unlocked and connected in Xcode, then retry."
|
|
127282
|
+
}),
|
|
127283
|
+
readyFailureSignal("network")
|
|
127284
|
+
);
|
|
127285
|
+
}
|
|
126995
127286
|
if (info.transportType != null && info.transportType !== "wired") {
|
|
126996
127287
|
throw withFailureSignal(
|
|
126997
127288
|
new IosDeviceControlError(`Device transport is ${info.transportType}, not wired`, {
|
|
@@ -127008,7 +127299,7 @@ async function ensureDeviceReady(udid) {
|
|
|
127008
127299
|
readyFailureSignal("network")
|
|
127009
127300
|
);
|
|
127010
127301
|
}
|
|
127011
|
-
|
|
127302
|
+
return null;
|
|
127012
127303
|
}
|
|
127013
127304
|
|
|
127014
127305
|
// ../tool-server/src/tools/devices/list-devices.ts
|
|
@@ -130073,7 +130364,7 @@ Call this at the start of a session to pick a target id ('udid' for iOS<flag:har
|
|
|
130073
130364
|
Returns { devices, avds } where each device carries a 'platform' discriminator ('ios', 'android', 'chromium', <flag:harmonyos>'harmony', </flag:harmonyos>or 'vega'); 'avds' lists Android AVDs bootable via boot-device. A Vega VVD is listed under 'devices' whether running or stopped (state 'running'/'stopped'); start a stopped one with boot-device using its 'vvdImage'.
|
|
130074
130365
|
<flag:harmonyos>HarmonyOS entries carry a 'kind': 'device' is a target connected over \`hdc\` (a phone on USB, or a booted emulator) and is what the interaction tools drive; 'emulator' is a DevEco Studio instance, running or not, and is what boot-device starts. A running emulator appears under both, exactly as a running Android AVD appears in both 'avds' and the device list. Instance state is 'running'/'stopped'; connected-target state is 'Connected'/'Offline'.
|
|
130075
130366
|
</flag:harmonyos>Android entries also carry a 'kind' ('emulator' for a local AVD, 'device' for a physical phone on USB / wireless adb). Physical phones use the same interaction tools as emulators and need no boot-device (just connect the phone with USB debugging authorised).
|
|
130076
|
-
Physical iPhones appear as iOS entries with kind 'device' (no iPads); no boot-device. State 'connected' =
|
|
130367
|
+
Physical iPhones appear as iOS entries with kind 'device' (no iPads); no boot-device. State 'connected' = reachable over USB or the network (a network phone's tunnel comes up on first use); 'paired' = remembered but unreachable, never auto-bound.
|
|
130077
130368
|
TV targets are tagged with runtimeKind 'tv' (Apple TV simulators, Android TV / leanback devices). They are focus-driven, not touch-driven: use \`describe\` to read focus, \`tv-remote\` for remote presses, and \`keyboard\` to type, rather than the coordinate/gesture tools.
|
|
130078
130369
|
iOS simulators from an additional CoreSimulator device set (the 'ios.additionalDeviceSets' configuration, e.g. devices created by Radon IDE) are tagged with their 'deviceSet' path; the same tools drive them by udid, but they run headless (no Simulator.app window).
|
|
130079
130370
|
A foldable iOS simulator (the iPhone Duo) or Android emulator (and its AVD) has 'foldable: true'; use the \`fold\` tool to fold or unfold it.
|
|
@@ -130171,7 +130462,7 @@ Chromium apps are discovered by probing CDP debugging ports (default 9222; exten
|
|
|
130171
130462
|
kind: "device",
|
|
130172
130463
|
udid: d.udid,
|
|
130173
130464
|
name: d.name,
|
|
130174
|
-
state: d.transportType === "wired" ? "connected" : "paired",
|
|
130465
|
+
state: d.transportType === "wired" || d.transportType === "localNetwork" ? "connected" : "paired",
|
|
130175
130466
|
runtime: d.osVersion ? `iOS ${d.osVersion} (physical device)` : "iOS (physical device)",
|
|
130176
130467
|
model: d.model,
|
|
130177
130468
|
developerModeEnabled: d.developerModeEnabled,
|
|
@@ -135872,19 +136163,6 @@ var os13 = __toESM(require("node:os"));
|
|
|
135872
136163
|
var path30 = __toESM(require("node:path"));
|
|
135873
136164
|
init_src2();
|
|
135874
136165
|
|
|
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
136166
|
// ../tool-server/src/utils/ios-device/runner-signing.ts
|
|
135889
136167
|
init_src2();
|
|
135890
136168
|
|
|
@@ -136349,7 +136627,12 @@ async function launchRunner(opts) {
|
|
|
136349
136627
|
],
|
|
136350
136628
|
{
|
|
136351
136629
|
detached: true,
|
|
136352
|
-
stdio: ["ignore", logFd, logFd]
|
|
136630
|
+
stdio: ["ignore", logFd, logFd],
|
|
136631
|
+
env: {
|
|
136632
|
+
...process.env,
|
|
136633
|
+
// Xcode strips TEST_RUNNER_ before passing this non-secret address to XCTest.
|
|
136634
|
+
TEST_RUNNER_ARGENT_RUNNER_ADDRESS: opts.tunnelAddress ?? ""
|
|
136635
|
+
}
|
|
136353
136636
|
}
|
|
136354
136637
|
);
|
|
136355
136638
|
child.unref();
|
|
@@ -136455,12 +136738,16 @@ async function killStaleRunnersForDevice(udid, listProcesses = listProcessTable)
|
|
|
136455
136738
|
// ../tool-server/src/blueprints/ios-device-runner.ts
|
|
136456
136739
|
var fs38 = __toESM(require("node:fs/promises"));
|
|
136457
136740
|
|
|
136741
|
+
// ../tool-server/src/utils/ios-device/runner-route.ts
|
|
136742
|
+
var import_node_net3 = __toESM(require("node:net"));
|
|
136743
|
+
var import_node_events4 = require("node:events");
|
|
136744
|
+
|
|
136458
136745
|
// ../tool-server/src/utils/ios-device/runner-http.ts
|
|
136459
136746
|
var import_node_http3 = __toESM(require("node:http"));
|
|
136460
136747
|
|
|
136461
136748
|
// ../tool-server/src/utils/ios-device/usbmux.ts
|
|
136462
136749
|
var import_node_events3 = require("node:events");
|
|
136463
|
-
var
|
|
136750
|
+
var import_node_net2 = __toESM(require("node:net"));
|
|
136464
136751
|
var USBMUXD_SOCKET_PATH = "/var/run/usbmuxd";
|
|
136465
136752
|
var USBMUX_DEFAULT_TIMEOUT_MS = 5e3;
|
|
136466
136753
|
var USBMUX_RESULT_OK = 0;
|
|
@@ -136536,7 +136823,7 @@ async function connectToDevicePort(socketPath, udid, deviceId, port, deadline) {
|
|
|
136536
136823
|
async function connectToUsbmuxd(socketPath, deadline) {
|
|
136537
136824
|
const timeoutMs = deadline.remainingMs();
|
|
136538
136825
|
requireTimeRemaining(timeoutMs, "connect to usbmuxd");
|
|
136539
|
-
const socket =
|
|
136826
|
+
const socket = import_node_net2.default.createConnection(socketPath);
|
|
136540
136827
|
const abort = new AbortController();
|
|
136541
136828
|
const timer = setTimeout(() => {
|
|
136542
136829
|
abort.abort(
|
|
@@ -136768,17 +137055,25 @@ function parseRunnerResponseBody(statusCode, body) {
|
|
|
136768
137055
|
var READ_ONLY_MAX_ATTEMPTS = 3;
|
|
136769
137056
|
var RETRY_BASE_DELAY_MS = 300;
|
|
136770
137057
|
var RETRY_MAX_DELAY_MS = 2e3;
|
|
136771
|
-
|
|
136772
|
-
|
|
137058
|
+
var TUNNEL_CONNECT_TIMEOUT_MS = 5e3;
|
|
137059
|
+
var TunnelConnectError = class extends IosDeviceTransportError {
|
|
137060
|
+
};
|
|
137061
|
+
function createRunnerCommandSender(options = {}) {
|
|
137062
|
+
const tunnelAddress = options.tunnelAddress;
|
|
137063
|
+
const send = tunnelAddress ? (_udid, port, body, deadline) => postRunnerCommand({
|
|
137064
|
+
socketFactory: () => openTunnelSocket(tunnelAddress, port, deadline),
|
|
137065
|
+
body,
|
|
137066
|
+
deadline
|
|
137067
|
+
}) : options.sendViaUsbmux ?? defaultSendViaUsbmux;
|
|
136773
137068
|
return {
|
|
136774
137069
|
sendCommand: async (udid, port, body, sendOptions2) => {
|
|
136775
137070
|
if (!sendOptions2.readOnly) {
|
|
136776
|
-
return
|
|
137071
|
+
return send(udid, port, body, createDeadline(sendOptions2.timeoutMs));
|
|
136777
137072
|
}
|
|
136778
137073
|
let lastError;
|
|
136779
137074
|
for (let attempt = 1; attempt <= READ_ONLY_MAX_ATTEMPTS; attempt += 1) {
|
|
136780
137075
|
try {
|
|
136781
|
-
return await
|
|
137076
|
+
return await send(udid, port, body, createDeadline(sendOptions2.timeoutMs));
|
|
136782
137077
|
} catch (error63) {
|
|
136783
137078
|
lastError = error63;
|
|
136784
137079
|
const retryable = isIosDeviceTransportError(error63) && error63.retryable;
|
|
@@ -136792,6 +137087,32 @@ function createUsbmuxCommandSender(options = {}) {
|
|
|
136792
137087
|
}
|
|
136793
137088
|
};
|
|
136794
137089
|
}
|
|
137090
|
+
async function openTunnelSocket(address, port, deadline) {
|
|
137091
|
+
const timeoutMs = Math.min(deadline.remainingMs(), TUNNEL_CONNECT_TIMEOUT_MS);
|
|
137092
|
+
if (timeoutMs <= 0) {
|
|
137093
|
+
throw new IosDeviceTransportError("timeout", "CoreDevice connection deadline elapsed", {
|
|
137094
|
+
retryable: true
|
|
137095
|
+
});
|
|
137096
|
+
}
|
|
137097
|
+
const socket = import_node_net3.default.createConnection({ host: address, port, family: 6 });
|
|
137098
|
+
const signal = AbortSignal.timeout(timeoutMs);
|
|
137099
|
+
try {
|
|
137100
|
+
await (0, import_node_events4.once)(socket, "connect", { signal });
|
|
137101
|
+
socket.pause();
|
|
137102
|
+
return socket;
|
|
137103
|
+
} catch (error63) {
|
|
137104
|
+
socket.destroy();
|
|
137105
|
+
throw new TunnelConnectError(
|
|
137106
|
+
signal.aborted ? "timeout" : "runner-not-listening",
|
|
137107
|
+
"Cannot connect to the runner through the CoreDevice tunnel",
|
|
137108
|
+
{
|
|
137109
|
+
retryable: true,
|
|
137110
|
+
hint: "Keep the device unlocked and connected in Xcode or through its fleet provider, then retry.",
|
|
137111
|
+
cause: error63
|
|
137112
|
+
}
|
|
137113
|
+
);
|
|
137114
|
+
}
|
|
137115
|
+
}
|
|
136795
137116
|
function defaultSendViaUsbmux(udid, port, body, deadline) {
|
|
136796
137117
|
return postRunnerCommand({
|
|
136797
137118
|
socketFactory: () => openUsbmuxRunnerSocket({ udid, port, timeoutMs: deadline.remainingMs() }),
|
|
@@ -137161,11 +137482,12 @@ function iosDeviceRunnerRef(device) {
|
|
|
137161
137482
|
}
|
|
137162
137483
|
var RUNNER_READY_TIMEOUT_MS = 12e4;
|
|
137163
137484
|
var RUNNER_CLEAN_EXIT_TIMEOUT_MS = 1e4;
|
|
137164
|
-
async function startRunner(udid, artifact) {
|
|
137485
|
+
async function startRunner(udid, artifact, tunnelAddress) {
|
|
137165
137486
|
const launched = await launchRunner({
|
|
137166
137487
|
udid,
|
|
137167
137488
|
xctestrunPath: artifact.xctestrunPath,
|
|
137168
|
-
derivedDataPath: artifact.derivedDataPath
|
|
137489
|
+
derivedDataPath: artifact.derivedDataPath,
|
|
137490
|
+
...tunnelAddress ? { tunnelAddress } : {}
|
|
137169
137491
|
});
|
|
137170
137492
|
let onExit;
|
|
137171
137493
|
const exited = new Promise((_resolve, reject) => {
|
|
@@ -137184,7 +137506,7 @@ async function startRunner(udid, artifact) {
|
|
|
137184
137506
|
client2 = createRunnerClient({
|
|
137185
137507
|
udid,
|
|
137186
137508
|
port,
|
|
137187
|
-
send:
|
|
137509
|
+
send: createRunnerCommandSender({ tunnelAddress }).sendCommand
|
|
137188
137510
|
});
|
|
137189
137511
|
await Promise.race([
|
|
137190
137512
|
waitForRunnerReady(client2, { timeoutMs: Math.max(1, expiresAt - Date.now()) }),
|
|
@@ -137219,7 +137541,7 @@ async function startRunner(udid, artifact) {
|
|
|
137219
137541
|
client: client2
|
|
137220
137542
|
};
|
|
137221
137543
|
}
|
|
137222
|
-
async function buildAndStartRunner(udid, signing) {
|
|
137544
|
+
async function buildAndStartRunner(udid, signing, tunnelAddress) {
|
|
137223
137545
|
let artifact;
|
|
137224
137546
|
try {
|
|
137225
137547
|
artifact = await ensureRunnerArtifact(signing);
|
|
@@ -137229,13 +137551,14 @@ async function buildAndStartRunner(udid, signing) {
|
|
|
137229
137551
|
artifact = await ensureRunnerArtifact(signing, { destinationUdid: udid, force: true });
|
|
137230
137552
|
}
|
|
137231
137553
|
try {
|
|
137232
|
-
return await startRunner(udid, artifact);
|
|
137554
|
+
return await startRunner(udid, artifact, tunnelAddress);
|
|
137233
137555
|
} catch (error63) {
|
|
137234
137556
|
const logText = error63.runnerLogText ?? "";
|
|
137235
137557
|
if (!isProfileMissingDeviceFailure(logText) && !isProfileExpiredFailure(logText)) throw error63;
|
|
137236
137558
|
return await startRunner(
|
|
137237
137559
|
udid,
|
|
137238
|
-
await ensureRunnerArtifact(signing, { destinationUdid: udid, force: true })
|
|
137560
|
+
await ensureRunnerArtifact(signing, { destinationUdid: udid, force: true }),
|
|
137561
|
+
tunnelAddress
|
|
137239
137562
|
);
|
|
137240
137563
|
}
|
|
137241
137564
|
}
|
|
@@ -137261,9 +137584,13 @@ var iosDeviceRunnerBlueprint = {
|
|
|
137261
137584
|
const release2 = reserveInteractionRunner(udid);
|
|
137262
137585
|
let runner;
|
|
137263
137586
|
try {
|
|
137264
|
-
await ensureDeviceReady(udid);
|
|
137587
|
+
const tunnelAddress = await ensureDeviceReady(udid);
|
|
137265
137588
|
await killStaleRunnersForDevice(udid);
|
|
137266
|
-
runner = await buildAndStartRunner(
|
|
137589
|
+
runner = await buildAndStartRunner(
|
|
137590
|
+
udid,
|
|
137591
|
+
await resolveRunnerSigningConfig(udid),
|
|
137592
|
+
tunnelAddress
|
|
137593
|
+
);
|
|
137267
137594
|
} catch (error63) {
|
|
137268
137595
|
release2();
|
|
137269
137596
|
throw error63;
|
|
@@ -137333,7 +137660,7 @@ var iosDeviceRunnerBlueprint = {
|
|
|
137333
137660
|
};
|
|
137334
137661
|
},
|
|
137335
137662
|
recoverable(error63) {
|
|
137336
|
-
return isRunnerExitedError(error63) || isRunnerWedgedError(error63);
|
|
137663
|
+
return isRunnerExitedError(error63) || isRunnerWedgedError(error63) || error63 instanceof TunnelConnectError;
|
|
137337
137664
|
}
|
|
137338
137665
|
};
|
|
137339
137666
|
|
|
@@ -145178,9 +145505,9 @@ init_src2();
|
|
|
145178
145505
|
|
|
145179
145506
|
// ../tool-server/src/blueprints/macos-app.ts
|
|
145180
145507
|
var import_node_child_process30 = require("node:child_process");
|
|
145181
|
-
var
|
|
145508
|
+
var import_node_events5 = require("node:events");
|
|
145182
145509
|
var fs39 = __toESM(require("node:fs"));
|
|
145183
|
-
var
|
|
145510
|
+
var net8 = __toESM(require("node:net"));
|
|
145184
145511
|
var os15 = __toESM(require("node:os"));
|
|
145185
145512
|
var path33 = __toESM(require("node:path"));
|
|
145186
145513
|
init_src2();
|
|
@@ -145612,9 +145939,9 @@ async function helperPid(child, executable) {
|
|
|
145612
145939
|
let signal;
|
|
145613
145940
|
try {
|
|
145614
145941
|
[[code, signal]] = await Promise.all([
|
|
145615
|
-
(0,
|
|
145616
|
-
(0,
|
|
145617
|
-
(0,
|
|
145942
|
+
(0, import_node_events5.once)(child, "exit"),
|
|
145943
|
+
(0, import_node_events5.once)(child.stdout, "close"),
|
|
145944
|
+
(0, import_node_events5.once)(child.stderr, "close")
|
|
145618
145945
|
]);
|
|
145619
145946
|
} catch (err) {
|
|
145620
145947
|
throw helperLaunchFailure(executable, errorMessage2(err), err);
|
|
@@ -145700,7 +146027,7 @@ function createMacosAppApi(bundleId) {
|
|
|
145700
146027
|
);
|
|
145701
146028
|
}
|
|
145702
146029
|
const ch = new LibraryChannel(
|
|
145703
|
-
|
|
146030
|
+
net8.createConnection(app.listenSocket),
|
|
145704
146031
|
bundleId,
|
|
145705
146032
|
app.pid,
|
|
145706
146033
|
recordNetworkEvent
|
|
@@ -145988,7 +146315,7 @@ function createMacosAppApi(bundleId) {
|
|
|
145988
146315
|
}
|
|
145989
146316
|
);
|
|
145990
146317
|
try {
|
|
145991
|
-
await (0,
|
|
146318
|
+
await (0, import_node_events5.once)(helper, "spawn");
|
|
145992
146319
|
} catch (err) {
|
|
145993
146320
|
throw helperLaunchFailure(info.executable, errorMessage2(err), err);
|
|
145994
146321
|
}
|
|
@@ -149429,7 +149756,7 @@ init_src();
|
|
|
149429
149756
|
// ../tool-server/src/blueprints/android-network-inspector.ts
|
|
149430
149757
|
var import_node_crypto13 = require("node:crypto");
|
|
149431
149758
|
var fs41 = __toESM(require("node:fs"));
|
|
149432
|
-
var
|
|
149759
|
+
var net9 = __toESM(require("node:net"));
|
|
149433
149760
|
var path35 = __toESM(require("node:path"));
|
|
149434
149761
|
init_src2();
|
|
149435
149762
|
init_adb();
|
|
@@ -149608,7 +149935,6 @@ var MIN_SDK = 26;
|
|
|
149608
149935
|
var PACKAGE_NAME2 = /^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z0-9_]+)*$/;
|
|
149609
149936
|
var PROTOCOL_VERSION = 2;
|
|
149610
149937
|
var MAX_REDIRECTS = 32;
|
|
149611
|
-
var MAX_CACHED_BODIES = 64;
|
|
149612
149938
|
var MAX_FRAME_CHARS = 8 * 1024 * 1024;
|
|
149613
149939
|
var HANDSHAKE_FRAME_CHARS = 4 * 1024;
|
|
149614
149940
|
var MAX_PENDING_HANDSHAKES = 32;
|
|
@@ -149980,7 +150306,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
149980
150306
|
}
|
|
149981
150307
|
function listen2() {
|
|
149982
150308
|
return new Promise((resolve21, reject) => {
|
|
149983
|
-
const srv =
|
|
150309
|
+
const srv = net9.createServer(serveAgent);
|
|
149984
150310
|
srv.once("error", reject);
|
|
149985
150311
|
srv.listen(0, "127.0.0.1", () => {
|
|
149986
150312
|
srv.off("error", reject);
|
|
@@ -150664,9 +150990,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
150664
150990
|
const conn = liveConnectionFor(entry.conn);
|
|
150665
150991
|
if (!conn) {
|
|
150666
150992
|
return Promise.resolve(
|
|
150667
|
-
unavailable(
|
|
150668
|
-
agentGoneFor(entry.conn) ? AGENT_GONE_REASON : "the app process that made the request is gone"
|
|
150669
|
-
)
|
|
150993
|
+
unavailable(agentGoneFor(entry.conn) ? AGENT_GONE_REASON : PROCESS_GONE)
|
|
150670
150994
|
);
|
|
150671
150995
|
}
|
|
150672
150996
|
const sending = kind === "post" && record2.state === "pending";
|
|
@@ -150976,24 +151300,6 @@ function agentFiles() {
|
|
|
150976
151300
|
function isAgentAbi(abi) {
|
|
150977
151301
|
return AGENT_ABIS.includes(abi);
|
|
150978
151302
|
}
|
|
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
151303
|
function isOwnFailure(err) {
|
|
150998
151304
|
const code = getFailureSignal(err)?.error_code;
|
|
150999
151305
|
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 +151632,7 @@ var zodSchema4 = external_exports.object({
|
|
|
151326
151632
|
"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
151633
|
),
|
|
151328
151634
|
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"
|
|
151635
|
+
"Clear the log after reading. On iOS and Android, the IDs of cleared requests still work in view-network-request-details"
|
|
151330
151636
|
),
|
|
151331
151637
|
stop: external_exports.boolean().optional().describe(
|
|
151332
151638
|
"Android only: turn native capture off for this app instead of listing. Other apps keep theirs."
|
|
@@ -151349,7 +151655,7 @@ function createNativeNetworkLogsTool(registry2) {
|
|
|
151349
151655
|
description: `Retrieve network requests captured at the native level: NSURLProtocol on iOS, OkHttp on Android.
|
|
151350
151656
|
Use when inspecting native-level HTTP traffic that view-network-logs cannot see: requests that never pass through JS XMLHttpRequest or fetch.
|
|
151351
151657
|
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.
|
|
151658
|
+
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
151659
|
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
151660
|
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
151661
|
<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 +151663,7 @@ On iOS: the first call waits until the app acknowledges capture. When capture st
|
|
|
151357
151663
|
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
151664
|
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
151665
|
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.
|
|
151666
|
+
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
151667
|
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
151668
|
When status is not_attachable, use view-network-logs and do not retry.`,
|
|
151363
151669
|
zodSchema: zodSchema4,
|
|
@@ -152565,6 +152871,7 @@ var jsRuntimeDebuggerBlueprint = {
|
|
|
152565
152871
|
init_src2();
|
|
152566
152872
|
|
|
152567
152873
|
// ../tool-server/src/utils/debugger/scripts/network-interceptor.ts
|
|
152874
|
+
var BINARY_BODY_TYPES = /^(image\/(?!svg)|audio\/|video\/|font\/|application\/(octet-stream|pdf|zip|gzip|wasm|x-protobuf)$)/;
|
|
152568
152875
|
var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
|
|
152569
152876
|
var g = globalThis;
|
|
152570
152877
|
if (g.__argent_network_v2) return JSON.stringify({ installed: false, reason: 'already installed' });
|
|
@@ -152643,7 +152950,7 @@ var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
|
|
|
152643
152950
|
}
|
|
152644
152951
|
|
|
152645
152952
|
// 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 =
|
|
152953
|
+
var BINARY_TYPES = ${BINARY_BODY_TYPES};
|
|
152647
152954
|
function isBinaryType(mime) {
|
|
152648
152955
|
return typeof mime === 'string' && BINARY_TYPES.test(mime.toLowerCase());
|
|
152649
152956
|
}
|
|
@@ -154806,10 +155113,10 @@ function electronGuiChildEnv(overrides = {}) {
|
|
|
154806
155113
|
}
|
|
154807
155114
|
|
|
154808
155115
|
// ../tool-server/src/utils/free-port.ts
|
|
154809
|
-
var
|
|
155116
|
+
var net10 = __toESM(require("node:net"));
|
|
154810
155117
|
async function pickFreePort() {
|
|
154811
155118
|
return new Promise((resolve21, reject) => {
|
|
154812
|
-
const srv =
|
|
155119
|
+
const srv = net10.createServer();
|
|
154813
155120
|
srv.unref();
|
|
154814
155121
|
srv.on("error", reject);
|
|
154815
155122
|
srv.listen(0, "127.0.0.1", () => {
|
|
@@ -164961,11 +165268,16 @@ function redactHeaders(headers) {
|
|
|
164961
165268
|
}
|
|
164962
165269
|
return result;
|
|
164963
165270
|
}
|
|
164964
|
-
var
|
|
165271
|
+
var NATIVE_ID_PREFIXES = { android: "android-", ios: "ios-" };
|
|
165272
|
+
function nativeIdPlatform2(requestId) {
|
|
165273
|
+
if (requestId.startsWith(NATIVE_ID_PREFIXES.android)) return "android";
|
|
165274
|
+
if (requestId.startsWith(NATIVE_ID_PREFIXES.ios)) return "ios";
|
|
165275
|
+
return void 0;
|
|
165276
|
+
}
|
|
164965
165277
|
var MAX_BODY_SIZE = 1e3;
|
|
164966
165278
|
var MAX_DECODED_BODY_BYTES = 16 * 1024 * 1024;
|
|
164967
165279
|
function cutMarker(fullSize, mimeType, shown = MAX_BODY_SIZE) {
|
|
164968
|
-
const mime = mimeType
|
|
165280
|
+
const mime = mimeType ? `, MIME: ${mimeType}` : "";
|
|
164969
165281
|
return `[TRUNCATED: first ${shown} chars shown, full size: ${fullSize}${mime}]`;
|
|
164970
165282
|
}
|
|
164971
165283
|
function truncateBody(body, mimeType) {
|
|
@@ -164988,16 +165300,18 @@ ${postData.slice(0, MAX_BODY_SIZE)}...`;
|
|
|
164988
165300
|
var zodSchema39 = external_exports.object({
|
|
164989
165301
|
port: metroPortField,
|
|
164990
165302
|
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."
|
|
165303
|
+
"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."
|
|
165304
|
+
),
|
|
165305
|
+
requestId: external_exports.string().describe(
|
|
165306
|
+
"The requestId from view-network-logs, or an ios- or android- ID from native-network-logs."
|
|
164992
165307
|
),
|
|
164993
|
-
requestId: external_exports.string().describe("The requestId from view-network-logs, or an android- ID from native-network-logs."),
|
|
164994
165308
|
includeBody: external_exports.boolean().default(true).describe("Whether to include the response body (if captured).")
|
|
164995
165309
|
});
|
|
164996
165310
|
var networkRequestTool = {
|
|
164997
165311
|
id: "view-network-request-details",
|
|
164998
|
-
description: `Get full details of a specific network request by its requestId.
|
|
165312
|
+
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
165313
|
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.
|
|
165314
|
+
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
165315
|
Returns an error message string if the requestId is not found.`,
|
|
165002
165316
|
zodSchema: zodSchema39,
|
|
165003
165317
|
readOnly: true,
|
|
@@ -165008,19 +165322,24 @@ Returns an error message string if the requestId is not found.`,
|
|
|
165008
165322
|
},
|
|
165009
165323
|
capability: DEBUGGER_TOOL_CAPABILITY,
|
|
165010
165324
|
services: (params) => {
|
|
165011
|
-
if (
|
|
165325
|
+
if (isNativeRequestId(params.requestId)) return {};
|
|
165012
165326
|
const device = resolveDevice(params.device_id);
|
|
165013
165327
|
if (device.platform === "chromium") {
|
|
165014
165328
|
return { chromium: chromiumCdpRef(device) };
|
|
165015
165329
|
}
|
|
165016
|
-
if (params.requestId
|
|
165330
|
+
if (nativeIdPlatform2(params.requestId)) return {};
|
|
165017
165331
|
return {
|
|
165018
165332
|
inspector: `NetworkInspector:${metroPort(params)}:${canonicalDeviceId(params.device_id)}`
|
|
165019
165333
|
};
|
|
165020
165334
|
},
|
|
165021
165335
|
async execute(services, params) {
|
|
165022
165336
|
if (ANDROID_NATIVE_REQUEST_ID.test(params.requestId)) {
|
|
165023
|
-
|
|
165337
|
+
const found = findAndroidNativeRecord(params.requestId);
|
|
165338
|
+
return found ? nativeRequestDetails(found.record, found.inspector, params.includeBody) : nativeNotFound(params.requestId, params.device_id, "android");
|
|
165339
|
+
}
|
|
165340
|
+
if (IOS_NATIVE_REQUEST_ID.test(params.requestId)) {
|
|
165341
|
+
const found = findIosNativeRecord(params.requestId);
|
|
165342
|
+
return found ? nativeRequestDetails(found.record, found.records, params.includeBody) : nativeNotFound(params.requestId, params.device_id, "ios");
|
|
165024
165343
|
}
|
|
165025
165344
|
const device = resolveDevice(params.device_id);
|
|
165026
165345
|
if (device.platform === "chromium") {
|
|
@@ -165073,9 +165392,8 @@ Returns an error message string if the requestId is not found.`,
|
|
|
165073
165392
|
}
|
|
165074
165393
|
return details2;
|
|
165075
165394
|
}
|
|
165076
|
-
|
|
165077
|
-
|
|
165078
|
-
}
|
|
165395
|
+
const nativePlatform = nativeIdPlatform2(params.requestId);
|
|
165396
|
+
if (nativePlatform) return nativeNotFound(params.requestId, params.device_id, nativePlatform);
|
|
165079
165397
|
const api = services.inspector;
|
|
165080
165398
|
await api.cdp.evaluate(NETWORK_INTERCEPTOR_SCRIPT).catch(() => {
|
|
165081
165399
|
});
|
|
@@ -165130,14 +165448,15 @@ ${body.slice(0, MAX_BODY_SIZE)}...`;
|
|
|
165130
165448
|
return details;
|
|
165131
165449
|
}
|
|
165132
165450
|
};
|
|
165133
|
-
function
|
|
165451
|
+
function isNativeRequestId(requestId) {
|
|
165452
|
+
return ANDROID_NATIVE_REQUEST_ID.test(requestId) || IOS_NATIVE_REQUEST_ID.test(requestId);
|
|
165453
|
+
}
|
|
165454
|
+
function nativeNotFound(requestId, deviceId, layer) {
|
|
165134
165455
|
const { platform } = resolveDevice(deviceId);
|
|
165135
|
-
|
|
165456
|
+
const prefix = NATIVE_ID_PREFIXES[layer];
|
|
165457
|
+
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
165458
|
}
|
|
165137
|
-
async function
|
|
165138
|
-
const found = findAndroidNativeRecord(requestId);
|
|
165139
|
-
if (!found) return androidNativeNotFound(requestId, deviceId);
|
|
165140
|
-
const { inspector, record: record2 } = found;
|
|
165459
|
+
async function nativeRequestDetails(record2, bodies, includeBody) {
|
|
165141
165460
|
const { wireHeaders } = record2.request;
|
|
165142
165461
|
const bodyHeaders = record2.redirects?.[0]?.requestHeaders ?? wireHeaders ?? {};
|
|
165143
165462
|
const requestHeader = (name) => headerValue(bodyHeaders, name) || headerValue(record2.request.headers, name);
|
|
@@ -165149,7 +165468,7 @@ async function androidNativeRequestDetails(requestId, includeBody, deviceId) {
|
|
|
165149
165468
|
const headersNote = requestHeadersNote(record2);
|
|
165150
165469
|
if (headersNote) request3.headersNote = headersNote;
|
|
165151
165470
|
if (record2.request.hasPostData) {
|
|
165152
|
-
request3.postData = await
|
|
165471
|
+
request3.postData = await readNativeBody(() => bodies.requestPostData(record2.id), {
|
|
165153
165472
|
contentType: requestHeader("content-type"),
|
|
165154
165473
|
contentEncoding: requestHeader("content-encoding"),
|
|
165155
165474
|
wholeSize: sizeInBytes(
|
|
@@ -165187,10 +165506,11 @@ async function androidNativeRequestDetails(requestId, includeBody, deviceId) {
|
|
|
165187
165506
|
};
|
|
165188
165507
|
if (record2.response.fromCache) resp.fromCache = true;
|
|
165189
165508
|
if (includeBody) {
|
|
165190
|
-
resp.body = await
|
|
165509
|
+
resp.body = await readNativeBody(() => bodies.responseBody(record2.id), {
|
|
165191
165510
|
mimeType: record2.response.mimeType,
|
|
165192
165511
|
contentType: headerValue(record2.response.headers, "content-type"),
|
|
165193
|
-
|
|
165512
|
+
// An iOS response body is read decoded, so its Content-Encoding is not applied again.
|
|
165513
|
+
contentEncoding: record2.layer === "ios-native" ? "" : headerValue(record2.response.headers, "content-encoding"),
|
|
165194
165514
|
wholeSize: sizeInBytes(record2.encodedDataLength ?? NaN, "as the app received them")
|
|
165195
165515
|
});
|
|
165196
165516
|
}
|
|
@@ -165207,7 +165527,7 @@ function requestHeadersNote(record2) {
|
|
|
165207
165527
|
}
|
|
165208
165528
|
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
165529
|
}
|
|
165210
|
-
async function
|
|
165530
|
+
async function readNativeBody(read, framing) {
|
|
165211
165531
|
const mimeType = framing.mimeType ?? framing.contentType.split(";")[0].trim();
|
|
165212
165532
|
let body;
|
|
165213
165533
|
try {
|
|
@@ -165216,36 +165536,70 @@ async function readAndroidBody(read, framing) {
|
|
|
165216
165536
|
return `[unavailable: ${err instanceof Error ? err.message : String(err)}]`;
|
|
165217
165537
|
}
|
|
165218
165538
|
if (!body.available) return `[unavailable: ${body.reason ?? "no body"}]`;
|
|
165219
|
-
if (
|
|
165220
|
-
|
|
165539
|
+
if (body.incomplete) framing = { ...framing, wholeSize: void 0 };
|
|
165540
|
+
if (body.inlineChars !== void 0) {
|
|
165541
|
+
return inlineBody(body.body, body.inlineChars, body.truncated, mimeType, framing);
|
|
165221
165542
|
}
|
|
165222
|
-
const
|
|
165543
|
+
const asSent = () => {
|
|
165544
|
+
const text2 = inDeclaredCharset(body.body, framing.contentType, body.truncated);
|
|
165545
|
+
return body.truncated ? cutByAgent(text2, mimeType, Buffer.byteLength(body.body), framing, body.incomplete) : truncateBody(text2, mimeType);
|
|
165546
|
+
};
|
|
165547
|
+
if (!body.base64Encoded && contentCodings(framing.contentEncoding).length === 0) return asSent();
|
|
165548
|
+
const kept = Buffer.from(body.body, body.base64Encoded ? "base64" : "utf8");
|
|
165223
165549
|
const bytes = decodeContent2(kept, framing.contentEncoding, body.truncated);
|
|
165224
|
-
if (!bytes)
|
|
165225
|
-
|
|
165226
|
-
}
|
|
165550
|
+
if (!bytes) return decodesTooLarge(framing);
|
|
165551
|
+
if (!body.base64Encoded && bytes === kept) return asSent();
|
|
165227
165552
|
const text = decodeText(bytes, charsetOf(framing.contentType), body.truncated);
|
|
165228
165553
|
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);
|
|
165554
|
+
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]`;
|
|
165555
|
+
}
|
|
165556
|
+
return body.truncated ? cutByAgent(text, mimeType, kept.length, framing, body.incomplete) : truncateBody(text, mimeType);
|
|
165557
|
+
}
|
|
165558
|
+
function inDeclaredCharset(text, contentType, truncated) {
|
|
165559
|
+
if (namesUtf8(contentType)) return text;
|
|
165560
|
+
return decodeText(Buffer.from(text, "utf8"), charsetOf(contentType), truncated) ?? text;
|
|
165561
|
+
}
|
|
165562
|
+
function namesUtf8(contentType) {
|
|
165563
|
+
const charset = charsetOf(contentType);
|
|
165564
|
+
return !charset || /^utf-?8$/i.test(charset);
|
|
165565
|
+
}
|
|
165566
|
+
function inlineBody(text, wholeChars, truncated, mimeType, framing) {
|
|
165567
|
+
if (BINARY_BODY_TYPES.test(mimeType.toLowerCase())) {
|
|
165568
|
+
return `[body omitted: binary ${mimeType}, ${framing.wholeSize ?? "size unknown"}]`;
|
|
165569
|
+
}
|
|
165570
|
+
const sent = contentCodings(framing.contentEncoding).length ? Buffer.from(text, "utf8") : null;
|
|
165571
|
+
const bytes = sent && decodeContent2(sent, framing.contentEncoding, truncated);
|
|
165572
|
+
if (sent && !bytes) return decodesTooLarge(framing);
|
|
165573
|
+
const encoded = bytes && bytes !== sent ? bytes : null;
|
|
165574
|
+
const decoded2 = encoded ? decodeText(encoded, charsetOf(framing.contentType), truncated) : inDeclaredCharset(text, framing.contentType, truncated);
|
|
165575
|
+
if (decoded2 === null) {
|
|
165576
|
+
const size = truncated ? framing.wholeSize ?? "size unknown" : `${encoded.length} bytes`;
|
|
165577
|
+
return `[body omitted: binary ${mimeType || "data"}, ${size}]`;
|
|
165578
|
+
}
|
|
165579
|
+
if (!truncated) return truncateBody(decoded2, mimeType);
|
|
165580
|
+
const fullSize = !encoded && namesUtf8(framing.contentType) ? `${wholeChars} chars` : `more than ${decoded2.length} chars`;
|
|
165581
|
+
const shown = Math.min(decoded2.length, MAX_BODY_SIZE);
|
|
165582
|
+
return `${cutMarker(fullSize, mimeType, shown)}
|
|
165583
|
+
${decoded2.slice(0, shown)}${decoded2.length > shown ? "..." : ""}`;
|
|
165232
165584
|
}
|
|
165233
|
-
function
|
|
165585
|
+
function decodesTooLarge(framing) {
|
|
165586
|
+
return `[unavailable: the ${framing.contentEncoding.trim()} body decodes to more than ${MAX_DECODED_BODY_BYTES / (1024 * 1024)} MiB]`;
|
|
165587
|
+
}
|
|
165588
|
+
function cutByAgent(text, mimeType, keptBytes, framing, incomplete) {
|
|
165234
165589
|
const shown = Math.min(text.length, MAX_BODY_SIZE);
|
|
165235
|
-
const fullSize = `${framing.wholeSize ?? "unknown"}; ${agentKept(keptBytes)}`;
|
|
165590
|
+
const fullSize = `${framing.wholeSize ?? "unknown"}; ${agentKept(keptBytes, incomplete)}`;
|
|
165236
165591
|
return `${cutMarker(fullSize, mimeType, shown)}
|
|
165237
165592
|
${text.slice(0, shown)}${text.length > shown ? "..." : ""}`;
|
|
165238
165593
|
}
|
|
165239
|
-
function agentKept(keptBytes) {
|
|
165240
|
-
return `the agent kept only the first ${keptBytes} bytes`;
|
|
165594
|
+
function agentKept(keptBytes, incomplete) {
|
|
165595
|
+
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
165596
|
}
|
|
165242
165597
|
function sizeInBytes(bytes, how) {
|
|
165243
165598
|
return Number.isSafeInteger(bytes) && bytes > 0 ? `${bytes} bytes ${how}` : void 0;
|
|
165244
165599
|
}
|
|
165245
165600
|
function decodeContent2(bytes, contentEncoding, truncated = false) {
|
|
165246
|
-
const codings = contentEncoding.split(",").map((coding) => coding.trim().toLowerCase()).filter((coding) => coding !== "" && coding !== "identity");
|
|
165247
165601
|
let decoded2 = bytes;
|
|
165248
|
-
for (const coding of
|
|
165602
|
+
for (const coding of contentCodings(contentEncoding).reverse()) {
|
|
165249
165603
|
const next = decodeOne(decoded2, coding, truncated);
|
|
165250
165604
|
if (next === null) return null;
|
|
165251
165605
|
if (next === void 0) return bytes;
|
|
@@ -165253,6 +165607,9 @@ function decodeContent2(bytes, contentEncoding, truncated = false) {
|
|
|
165253
165607
|
}
|
|
165254
165608
|
return decoded2;
|
|
165255
165609
|
}
|
|
165610
|
+
function contentCodings(contentEncoding) {
|
|
165611
|
+
return contentEncoding.split(",").map((coding) => coding.trim().toLowerCase()).filter((coding) => coding !== "" && coding !== "identity");
|
|
165612
|
+
}
|
|
165256
165613
|
function decodeOne(bytes, coding, truncated) {
|
|
165257
165614
|
const maxOutputLength = MAX_DECODED_BODY_BYTES;
|
|
165258
165615
|
const flush = (mode) => truncated ? { finishFlush: mode } : {};
|