@swmansion/argent 0.34.1-next.76 → 0.34.1-next.78
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/tool-server.cjs
CHANGED
|
@@ -45538,7 +45538,7 @@ var require_application = __commonJS({
|
|
|
45538
45538
|
var finalhandler = require_finalhandler();
|
|
45539
45539
|
var debug = require_src()("express:application");
|
|
45540
45540
|
var View = require_view();
|
|
45541
|
-
var
|
|
45541
|
+
var http7 = require("node:http");
|
|
45542
45542
|
var methods = require_utils3().methods;
|
|
45543
45543
|
var compileETag = require_utils3().compileETag;
|
|
45544
45544
|
var compileQueryParser = require_utils3().compileQueryParser;
|
|
@@ -45770,8 +45770,8 @@ var require_application = __commonJS({
|
|
|
45770
45770
|
}
|
|
45771
45771
|
tryRender(view, renderOptions, done);
|
|
45772
45772
|
};
|
|
45773
|
-
app.listen = function
|
|
45774
|
-
var server =
|
|
45773
|
+
app.listen = function listen3() {
|
|
45774
|
+
var server = http7.createServer(this);
|
|
45775
45775
|
var args = slice.call(arguments);
|
|
45776
45776
|
if (typeof args[args.length - 1] === "function") {
|
|
45777
45777
|
var done = args[args.length - 1] = once5(args[args.length - 1]);
|
|
@@ -46259,11 +46259,11 @@ var require_negotiator = __commonJS({
|
|
|
46259
46259
|
var preferredMediaTypes = require_mediaType();
|
|
46260
46260
|
module2.exports = Negotiator;
|
|
46261
46261
|
module2.exports.Negotiator = Negotiator;
|
|
46262
|
-
function Negotiator(
|
|
46262
|
+
function Negotiator(request4) {
|
|
46263
46263
|
if (!(this instanceof Negotiator)) {
|
|
46264
|
-
return new Negotiator(
|
|
46264
|
+
return new Negotiator(request4);
|
|
46265
46265
|
}
|
|
46266
|
-
this.request =
|
|
46266
|
+
this.request = request4;
|
|
46267
46267
|
}
|
|
46268
46268
|
Negotiator.prototype.charset = function charset(available) {
|
|
46269
46269
|
var set2 = this.charsets(available);
|
|
@@ -46546,12 +46546,12 @@ var require_request = __commonJS({
|
|
|
46546
46546
|
var accepts = require_accepts();
|
|
46547
46547
|
var isIP = require("node:net").isIP;
|
|
46548
46548
|
var typeis = require_type_is();
|
|
46549
|
-
var
|
|
46549
|
+
var http7 = require("node:http");
|
|
46550
46550
|
var fresh = require_fresh();
|
|
46551
46551
|
var parseRange = require_range_parser();
|
|
46552
46552
|
var parse4 = require_parseurl();
|
|
46553
46553
|
var proxyaddr = require_proxy_addr();
|
|
46554
|
-
var req = Object.create(
|
|
46554
|
+
var req = Object.create(http7.IncomingMessage.prototype);
|
|
46555
46555
|
module2.exports = req;
|
|
46556
46556
|
req.get = req.header = function header(name) {
|
|
46557
46557
|
if (!name) {
|
|
@@ -47725,7 +47725,7 @@ var require_response = __commonJS({
|
|
|
47725
47725
|
var deprecate = require_depd()("express");
|
|
47726
47726
|
var encodeUrl = require_encodeurl();
|
|
47727
47727
|
var escapeHtml = require_escape_html();
|
|
47728
|
-
var
|
|
47728
|
+
var http7 = require("node:http");
|
|
47729
47729
|
var onFinished = require_on_finished();
|
|
47730
47730
|
var mime = require_mime_types();
|
|
47731
47731
|
var path71 = require("node:path");
|
|
@@ -47742,7 +47742,7 @@ var require_response = __commonJS({
|
|
|
47742
47742
|
var basename22 = path71.basename;
|
|
47743
47743
|
var vary = require_vary();
|
|
47744
47744
|
var { Buffer: Buffer2 } = require("node:buffer");
|
|
47745
|
-
var res = Object.create(
|
|
47745
|
+
var res = Object.create(http7.ServerResponse.prototype);
|
|
47746
47746
|
module2.exports = res;
|
|
47747
47747
|
res.status = function status(code) {
|
|
47748
47748
|
if (!Number.isInteger(code)) {
|
|
@@ -52999,7 +52999,7 @@ var require_receiver = __commonJS({
|
|
|
52999
52999
|
var require_sender = __commonJS({
|
|
53000
53000
|
"../../node_modules/ws/lib/sender.js"(exports2, module2) {
|
|
53001
53001
|
"use strict";
|
|
53002
|
-
var { Duplex } = require("stream");
|
|
53002
|
+
var { Duplex: Duplex2 } = require("stream");
|
|
53003
53003
|
var { randomFillSync } = require("crypto");
|
|
53004
53004
|
var {
|
|
53005
53005
|
types: { isUint8Array }
|
|
@@ -53876,11 +53876,11 @@ var require_websocket = __commonJS({
|
|
|
53876
53876
|
"use strict";
|
|
53877
53877
|
var EventEmitter2 = require("events");
|
|
53878
53878
|
var https = require("https");
|
|
53879
|
-
var
|
|
53880
|
-
var
|
|
53879
|
+
var http7 = require("http");
|
|
53880
|
+
var net12 = require("net");
|
|
53881
53881
|
var tls = require("tls");
|
|
53882
53882
|
var { randomBytes: randomBytes3, createHash: createHash10 } = require("crypto");
|
|
53883
|
-
var { Duplex, Readable: Readable2 } = require("stream");
|
|
53883
|
+
var { Duplex: Duplex2, Readable: Readable2 } = require("stream");
|
|
53884
53884
|
var { URL: URL2 } = require("url");
|
|
53885
53885
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
53886
53886
|
var Receiver2 = require_receiver();
|
|
@@ -54431,7 +54431,7 @@ var require_websocket = __commonJS({
|
|
|
54431
54431
|
}
|
|
54432
54432
|
const defaultPort = isSecure2 ? 443 : 80;
|
|
54433
54433
|
const key2 = randomBytes3(16).toString("base64");
|
|
54434
|
-
const
|
|
54434
|
+
const request4 = isSecure2 ? https.request : http7.request;
|
|
54435
54435
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
54436
54436
|
let perMessageDeflate;
|
|
54437
54437
|
opts.createConnection = opts.createConnection || (isSecure2 ? tlsConnect : netConnect);
|
|
@@ -54508,12 +54508,12 @@ var require_websocket = __commonJS({
|
|
|
54508
54508
|
if (opts.auth && !options.headers.authorization) {
|
|
54509
54509
|
options.headers.authorization = "Basic " + Buffer.from(opts.auth).toString("base64");
|
|
54510
54510
|
}
|
|
54511
|
-
req = websocket._req =
|
|
54511
|
+
req = websocket._req = request4(opts);
|
|
54512
54512
|
if (websocket._redirects) {
|
|
54513
54513
|
websocket.emit("redirect", websocket.url, req);
|
|
54514
54514
|
}
|
|
54515
54515
|
} else {
|
|
54516
|
-
req = websocket._req =
|
|
54516
|
+
req = websocket._req = request4(opts);
|
|
54517
54517
|
}
|
|
54518
54518
|
if (opts.timeout) {
|
|
54519
54519
|
req.on("timeout", () => {
|
|
@@ -54634,12 +54634,12 @@ var require_websocket = __commonJS({
|
|
|
54634
54634
|
}
|
|
54635
54635
|
function netConnect(options) {
|
|
54636
54636
|
options.path = options.socketPath;
|
|
54637
|
-
return
|
|
54637
|
+
return net12.connect(options);
|
|
54638
54638
|
}
|
|
54639
54639
|
function tlsConnect(options) {
|
|
54640
54640
|
options.path = void 0;
|
|
54641
54641
|
if (!options.servername && options.servername !== "") {
|
|
54642
|
-
options.servername =
|
|
54642
|
+
options.servername = net12.isIP(options.host) ? "" : options.host;
|
|
54643
54643
|
}
|
|
54644
54644
|
return tls.connect(options);
|
|
54645
54645
|
}
|
|
@@ -54784,7 +54784,7 @@ var require_stream = __commonJS({
|
|
|
54784
54784
|
"../../node_modules/ws/lib/stream.js"(exports2, module2) {
|
|
54785
54785
|
"use strict";
|
|
54786
54786
|
var WebSocket2 = require_websocket();
|
|
54787
|
-
var { Duplex } = require("stream");
|
|
54787
|
+
var { Duplex: Duplex2 } = require("stream");
|
|
54788
54788
|
function emitClose(stream) {
|
|
54789
54789
|
stream.emit("close");
|
|
54790
54790
|
}
|
|
@@ -54802,7 +54802,7 @@ var require_stream = __commonJS({
|
|
|
54802
54802
|
}
|
|
54803
54803
|
function createWebSocketStream2(ws, options) {
|
|
54804
54804
|
let terminateOnDestroy = true;
|
|
54805
|
-
const duplex = new
|
|
54805
|
+
const duplex = new Duplex2({
|
|
54806
54806
|
...options,
|
|
54807
54807
|
autoDestroy: false,
|
|
54808
54808
|
emitClose: false,
|
|
@@ -54927,8 +54927,8 @@ var require_websocket_server = __commonJS({
|
|
|
54927
54927
|
"../../node_modules/ws/lib/websocket-server.js"(exports2, module2) {
|
|
54928
54928
|
"use strict";
|
|
54929
54929
|
var EventEmitter2 = require("events");
|
|
54930
|
-
var
|
|
54931
|
-
var { Duplex } = require("stream");
|
|
54930
|
+
var http7 = require("http");
|
|
54931
|
+
var { Duplex: Duplex2 } = require("stream");
|
|
54932
54932
|
var { createHash: createHash10 } = require("crypto");
|
|
54933
54933
|
var extension2 = require_extension();
|
|
54934
54934
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -55008,8 +55008,8 @@ var require_websocket_server = __commonJS({
|
|
|
55008
55008
|
);
|
|
55009
55009
|
}
|
|
55010
55010
|
if (options.port != null) {
|
|
55011
|
-
this._server =
|
|
55012
|
-
const body =
|
|
55011
|
+
this._server = http7.createServer((req, res) => {
|
|
55012
|
+
const body = http7.STATUS_CODES[426];
|
|
55013
55013
|
res.writeHead(426, {
|
|
55014
55014
|
"Content-Length": body.length,
|
|
55015
55015
|
"Content-Type": "text/plain"
|
|
@@ -55298,7 +55298,7 @@ var require_websocket_server = __commonJS({
|
|
|
55298
55298
|
this.destroy();
|
|
55299
55299
|
}
|
|
55300
55300
|
function abortHandshake(socket, code, message, headers) {
|
|
55301
|
-
message = message ||
|
|
55301
|
+
message = message || http7.STATUS_CODES[code];
|
|
55302
55302
|
headers = {
|
|
55303
55303
|
Connection: "close",
|
|
55304
55304
|
"Content-Type": "text/html",
|
|
@@ -55307,7 +55307,7 @@ var require_websocket_server = __commonJS({
|
|
|
55307
55307
|
};
|
|
55308
55308
|
socket.once("finish", socket.destroy);
|
|
55309
55309
|
socket.end(
|
|
55310
|
-
`HTTP/1.1 ${code} ${
|
|
55310
|
+
`HTTP/1.1 ${code} ${http7.STATUS_CODES[code]}\r
|
|
55311
55311
|
` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
|
|
55312
55312
|
);
|
|
55313
55313
|
}
|
|
@@ -71214,8 +71214,8 @@ var ExporterMetrics = class {
|
|
|
71214
71214
|
}
|
|
71215
71215
|
});
|
|
71216
71216
|
}
|
|
71217
|
-
startExport(
|
|
71218
|
-
const numItems = this.helper.countItems(
|
|
71217
|
+
startExport(request4) {
|
|
71218
|
+
const numItems = this.helper.countItems(request4);
|
|
71219
71219
|
const startTime = hrTime();
|
|
71220
71220
|
this.inflight.add(numItems, this.standardAttrs);
|
|
71221
71221
|
return (error63) => {
|
|
@@ -71239,7 +71239,7 @@ var ExporterMetrics = class {
|
|
|
71239
71239
|
// ../../node_modules/@opentelemetry/otlp-transformer/build/esm/logs/index.js
|
|
71240
71240
|
var LogsExporterMetricsHelper = {
|
|
71241
71241
|
name: "log",
|
|
71242
|
-
countItems: (
|
|
71242
|
+
countItems: (request4) => request4.length
|
|
71243
71243
|
};
|
|
71244
71244
|
|
|
71245
71245
|
// ../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/internal.js
|
|
@@ -71400,9 +71400,9 @@ var JSON_ENCODER = {
|
|
|
71400
71400
|
init_esm();
|
|
71401
71401
|
var JsonLogsSerializer = {
|
|
71402
71402
|
serializeRequest: (arg) => {
|
|
71403
|
-
const
|
|
71403
|
+
const request4 = createExportLogsServiceRequest(arg, JSON_ENCODER);
|
|
71404
71404
|
const encoder = new TextEncoder();
|
|
71405
|
-
return encoder.encode(JSON.stringify(
|
|
71405
|
+
return encoder.encode(JSON.stringify(request4));
|
|
71406
71406
|
},
|
|
71407
71407
|
deserializeResponse: (arg) => {
|
|
71408
71408
|
if (arg.length === 0) {
|
|
@@ -71479,12 +71479,12 @@ function httpAgentFactoryFromOptions(options) {
|
|
|
71479
71479
|
return async (protocol) => {
|
|
71480
71480
|
const isInsecure = protocol === "http:";
|
|
71481
71481
|
const module2 = isInsecure ? import("http") : import("https");
|
|
71482
|
-
const { Agent } = await module2;
|
|
71482
|
+
const { Agent: Agent2 } = await module2;
|
|
71483
71483
|
if (isInsecure) {
|
|
71484
71484
|
const { ca, cert, key: key2, ...insecureOptions } = options;
|
|
71485
|
-
return new
|
|
71485
|
+
return new Agent2(insecureOptions);
|
|
71486
71486
|
}
|
|
71487
|
-
return new
|
|
71487
|
+
return new Agent2(options);
|
|
71488
71488
|
};
|
|
71489
71489
|
}
|
|
71490
71490
|
function mergeOtlpNodeHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
|
|
@@ -71527,7 +71527,7 @@ function parseRetryAfterToMills(retryAfter2) {
|
|
|
71527
71527
|
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js
|
|
71528
71528
|
var DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION4}`;
|
|
71529
71529
|
var MAX_RESPONSE_BODY_SIZE = 4 * 1024 * 1024;
|
|
71530
|
-
function sendWithHttp(
|
|
71530
|
+
function sendWithHttp(request4, url2, headers, compression, userAgent, agent, data, timeoutMillis) {
|
|
71531
71531
|
return new Promise((resolve21) => {
|
|
71532
71532
|
const parsedUrl = new URL(url2);
|
|
71533
71533
|
if (userAgent) {
|
|
@@ -71540,7 +71540,7 @@ function sendWithHttp(request3, url2, headers, compression, userAgent, agent, da
|
|
|
71540
71540
|
headers,
|
|
71541
71541
|
agent
|
|
71542
71542
|
};
|
|
71543
|
-
const req =
|
|
71543
|
+
const req = request4(parsedUrl, options, (res) => {
|
|
71544
71544
|
const responseData = [];
|
|
71545
71545
|
let responseSize = 0;
|
|
71546
71546
|
res.on("data", (chunk) => {
|
|
@@ -71658,9 +71658,9 @@ var HttpExporterTransport = class {
|
|
|
71658
71658
|
this._parameters = parameters;
|
|
71659
71659
|
}
|
|
71660
71660
|
async send(data, timeoutMillis) {
|
|
71661
|
-
const { agent, request:
|
|
71661
|
+
const { agent, request: request4 } = await this._loadUtils();
|
|
71662
71662
|
const headers = await this._parameters.headers();
|
|
71663
|
-
return sendWithHttp(
|
|
71663
|
+
return sendWithHttp(request4, this._parameters.url, headers, this._parameters.compression, this._parameters.userAgent, agent, data, timeoutMillis);
|
|
71664
71664
|
}
|
|
71665
71665
|
shutdown() {
|
|
71666
71666
|
}
|
|
@@ -71668,19 +71668,19 @@ var HttpExporterTransport = class {
|
|
|
71668
71668
|
let utils = this._utils;
|
|
71669
71669
|
if (utils === null) {
|
|
71670
71670
|
const protocol = new URL(this._parameters.url).protocol;
|
|
71671
|
-
const [agent,
|
|
71671
|
+
const [agent, request4] = await Promise.all([
|
|
71672
71672
|
this._parameters.agentFactory(protocol),
|
|
71673
71673
|
requestFunctionFactory(protocol)
|
|
71674
71674
|
]);
|
|
71675
|
-
utils = this._utils = { agent, request:
|
|
71675
|
+
utils = this._utils = { agent, request: request4 };
|
|
71676
71676
|
}
|
|
71677
71677
|
return utils;
|
|
71678
71678
|
}
|
|
71679
71679
|
};
|
|
71680
71680
|
async function requestFunctionFactory(protocol) {
|
|
71681
71681
|
const module2 = protocol === "http:" ? import("http") : import("https");
|
|
71682
|
-
const { request:
|
|
71683
|
-
return
|
|
71682
|
+
const { request: request4 } = await module2;
|
|
71683
|
+
return request4;
|
|
71684
71684
|
}
|
|
71685
71685
|
function createHttpExporterTransport(parameters) {
|
|
71686
71686
|
return new HttpExporterTransport(parameters);
|
|
@@ -72947,7 +72947,7 @@ function isCi(env = process.env) {
|
|
|
72947
72947
|
var SESSION_ID = (0, import_node_crypto3.randomUUID)();
|
|
72948
72948
|
function readCliVersion() {
|
|
72949
72949
|
if (true) {
|
|
72950
|
-
return "0.34.1-next.
|
|
72950
|
+
return "0.34.1-next.77";
|
|
72951
72951
|
}
|
|
72952
72952
|
return "0.0.0";
|
|
72953
72953
|
}
|
|
@@ -77941,8 +77941,8 @@ function closeState2(state3, abort) {
|
|
|
77941
77941
|
if (state3.closed.peek() !== void 0)
|
|
77942
77942
|
return;
|
|
77943
77943
|
state3.closed.set(abort ?? null);
|
|
77944
|
-
for (const
|
|
77945
|
-
|
|
77944
|
+
for (const request4 of state3.pending)
|
|
77945
|
+
request4.reject(abort);
|
|
77946
77946
|
state3.requested.mutate((requests) => {
|
|
77947
77947
|
requests.length = 0;
|
|
77948
77948
|
});
|
|
@@ -78025,9 +78025,9 @@ var Producer4 = class {
|
|
|
78025
78025
|
/** Return the next track requested by a peer. */
|
|
78026
78026
|
async requested() {
|
|
78027
78027
|
for (; ; ) {
|
|
78028
|
-
const
|
|
78029
|
-
if (
|
|
78030
|
-
return
|
|
78028
|
+
const request4 = dequeueRequest(this.#state);
|
|
78029
|
+
if (request4)
|
|
78030
|
+
return request4;
|
|
78031
78031
|
const closed = this.#state.closed.peek();
|
|
78032
78032
|
if (closed instanceof Error)
|
|
78033
78033
|
throw closed;
|
|
@@ -78132,9 +78132,9 @@ var Consumer4 = class _Consumer {
|
|
|
78132
78132
|
/** Return the next track requested by the local consumer. Used by the subscribing wire layer. */
|
|
78133
78133
|
async requested() {
|
|
78134
78134
|
for (; ; ) {
|
|
78135
|
-
const
|
|
78136
|
-
if (
|
|
78137
|
-
return
|
|
78135
|
+
const request4 = dequeueRequest(this.#state);
|
|
78136
|
+
if (request4)
|
|
78137
|
+
return request4;
|
|
78138
78138
|
const closed = this.#state.closed.peek();
|
|
78139
78139
|
if (closed instanceof Error)
|
|
78140
78140
|
throw closed;
|
|
@@ -85436,10 +85436,10 @@ var Publisher = class {
|
|
|
85436
85436
|
const requestId = await this.#session.nextRequestId();
|
|
85437
85437
|
if (requestId === void 0)
|
|
85438
85438
|
return false;
|
|
85439
|
-
let
|
|
85439
|
+
let request4;
|
|
85440
85440
|
try {
|
|
85441
|
-
|
|
85442
|
-
const stream =
|
|
85441
|
+
request4 = await this.#session.openBi();
|
|
85442
|
+
const stream = request4;
|
|
85443
85443
|
await withTimeout((async () => {
|
|
85444
85444
|
await stream.writer.u53(PublishNamespace.id);
|
|
85445
85445
|
const msg = new PublishNamespace({ requestId, trackNamespace: path71, cluster: this.#advert });
|
|
@@ -85462,12 +85462,12 @@ var Publisher = class {
|
|
|
85462
85462
|
await RequestOk.decode(stream.reader, this.#session.version);
|
|
85463
85463
|
}
|
|
85464
85464
|
})(), ADVERTISE_TIMEOUT_MS, `advertisement timed out after ${ADVERTISE_TIMEOUT_MS}ms waiting for the peer's answer`);
|
|
85465
|
-
requests.set(path71, { path: path71, requestId, stream:
|
|
85465
|
+
requests.set(path71, { path: path71, requestId, stream: request4 });
|
|
85466
85466
|
return true;
|
|
85467
85467
|
} catch (err) {
|
|
85468
85468
|
const e = error62(err);
|
|
85469
85469
|
console.warn(`announce failed: broadcast=${path71} error=${reason(e)}`);
|
|
85470
|
-
|
|
85470
|
+
request4?.abort(e);
|
|
85471
85471
|
return false;
|
|
85472
85472
|
}
|
|
85473
85473
|
}
|
|
@@ -85475,23 +85475,23 @@ var Publisher = class {
|
|
|
85475
85475
|
* Close out a namespace's PUBLISH_NAMESPACE request with PUBLISH_NAMESPACE_DONE.
|
|
85476
85476
|
*/
|
|
85477
85477
|
async #withdraw(path71, requests) {
|
|
85478
|
-
const
|
|
85479
|
-
if (!
|
|
85478
|
+
const request4 = requests.get(path71);
|
|
85479
|
+
if (!request4)
|
|
85480
85480
|
return;
|
|
85481
85481
|
requests.delete(path71);
|
|
85482
85482
|
const version3 = this.#session.version;
|
|
85483
85483
|
if (version3 === Version.DRAFT_14 || version3 === Version.DRAFT_15 || version3 === Version.DRAFT_16) {
|
|
85484
85484
|
try {
|
|
85485
|
-
await
|
|
85486
|
-
const done = new PublishNamespaceDone({ trackNamespace:
|
|
85487
|
-
await done.encode(
|
|
85485
|
+
await request4.stream.writer.u53(PublishNamespaceDone.id);
|
|
85486
|
+
const done = new PublishNamespaceDone({ trackNamespace: request4.path, requestId: request4.requestId });
|
|
85487
|
+
await done.encode(request4.stream.writer, version3);
|
|
85488
85488
|
} catch {
|
|
85489
85489
|
}
|
|
85490
|
-
|
|
85490
|
+
request4.stream.close();
|
|
85491
85491
|
return;
|
|
85492
85492
|
}
|
|
85493
|
-
|
|
85494
|
-
await
|
|
85493
|
+
request4.stream.close();
|
|
85494
|
+
await request4.stream.writer.closed;
|
|
85495
85495
|
}
|
|
85496
85496
|
/**
|
|
85497
85497
|
* Handles an incoming TRACK_STATUS_REQUEST on a bidi stream.
|
|
@@ -86031,24 +86031,24 @@ var Subscriber2 = class {
|
|
|
86031
86031
|
const consumer = new ConsumeBroadcast();
|
|
86032
86032
|
void (async () => {
|
|
86033
86033
|
for (; ; ) {
|
|
86034
|
-
const
|
|
86035
|
-
if (!
|
|
86034
|
+
const request4 = await consumer.requested();
|
|
86035
|
+
if (!request4)
|
|
86036
86036
|
break;
|
|
86037
|
-
void this.#runSubscribe(path71,
|
|
86037
|
+
void this.#runSubscribe(path71, request4);
|
|
86038
86038
|
}
|
|
86039
86039
|
})();
|
|
86040
86040
|
return consumer;
|
|
86041
86041
|
}
|
|
86042
|
-
async #runSubscribe(broadcast,
|
|
86042
|
+
async #runSubscribe(broadcast, request4) {
|
|
86043
86043
|
const requestId = await this.#session.nextRequestId();
|
|
86044
86044
|
if (requestId === void 0) {
|
|
86045
|
-
|
|
86045
|
+
request4.reject(new Error("session closed"));
|
|
86046
86046
|
return;
|
|
86047
86047
|
}
|
|
86048
|
-
console.debug(`subscribe start: id=${requestId} broadcast=${broadcast} track=${
|
|
86049
|
-
const producer =
|
|
86048
|
+
console.debug(`subscribe start: id=${requestId} broadcast=${broadcast} track=${request4.name}`);
|
|
86049
|
+
const producer = request4.accept({ ordered: false });
|
|
86050
86050
|
const state3 = {};
|
|
86051
|
-
const setup = this.#openSubscribe(state3, broadcast,
|
|
86051
|
+
const setup = this.#openSubscribe(state3, broadcast, request4, producer, requestId);
|
|
86052
86052
|
const waitAbandoned = async () => {
|
|
86053
86053
|
for (; ; ) {
|
|
86054
86054
|
await producer.unused();
|
|
@@ -86067,11 +86067,11 @@ var Subscriber2 = class {
|
|
|
86067
86067
|
throw new Error("subscribe abandoned before it was accepted");
|
|
86068
86068
|
stream = result.stream;
|
|
86069
86069
|
trackAlias = result.alias;
|
|
86070
|
-
console.debug(`subscribe ok: id=${requestId} broadcast=${broadcast} track=${
|
|
86070
|
+
console.debug(`subscribe ok: id=${requestId} broadcast=${broadcast} track=${request4.name}`);
|
|
86071
86071
|
} catch (err) {
|
|
86072
86072
|
const e = error62(err);
|
|
86073
86073
|
producer.close(e);
|
|
86074
|
-
console.warn(`subscribe error: id=${requestId} broadcast=${broadcast} track=${
|
|
86074
|
+
console.warn(`subscribe error: id=${requestId} broadcast=${broadcast} track=${request4.name} error=${reason(e)}`);
|
|
86075
86075
|
let torn = false;
|
|
86076
86076
|
const cleanup = async (afterSetup) => {
|
|
86077
86077
|
state3.cancelled = true;
|
|
@@ -86111,12 +86111,12 @@ var Subscriber2 = class {
|
|
|
86111
86111
|
await this.#cancelSubscribe(stream, requestId);
|
|
86112
86112
|
producer.close();
|
|
86113
86113
|
stream.close();
|
|
86114
|
-
console.debug(`subscribe close: id=${requestId} broadcast=${broadcast} track=${
|
|
86114
|
+
console.debug(`subscribe close: id=${requestId} broadcast=${broadcast} track=${request4.name}`);
|
|
86115
86115
|
} catch (err) {
|
|
86116
86116
|
const e = error62(err);
|
|
86117
86117
|
producer.close(e);
|
|
86118
86118
|
stream.abort(e);
|
|
86119
|
-
console.warn(`subscribe error: id=${requestId} broadcast=${broadcast} track=${
|
|
86119
|
+
console.warn(`subscribe error: id=${requestId} broadcast=${broadcast} track=${request4.name} error=${reason(e)}`);
|
|
86120
86120
|
} finally {
|
|
86121
86121
|
if (this.#aliases.retire(trackAlias, producer))
|
|
86122
86122
|
this.#timescales.delete(trackAlias);
|
|
@@ -86145,7 +86145,7 @@ var Subscriber2 = class {
|
|
|
86145
86145
|
// `state` is populated as soon as the stream opens and again when the
|
|
86146
86146
|
// trackAlias is registered, so the caller can clean both up on timeout
|
|
86147
86147
|
// even before this promise settles.
|
|
86148
|
-
async #openSubscribe(state3, broadcast,
|
|
86148
|
+
async #openSubscribe(state3, broadcast, request4, producer, requestId) {
|
|
86149
86149
|
const version3 = this.#session.version;
|
|
86150
86150
|
state3.stream = await this.#session.openBi();
|
|
86151
86151
|
if (state3.cancelled)
|
|
@@ -86154,8 +86154,8 @@ var Subscriber2 = class {
|
|
|
86154
86154
|
const msg = new Subscribe({
|
|
86155
86155
|
requestId,
|
|
86156
86156
|
trackNamespace: broadcast,
|
|
86157
|
-
trackName:
|
|
86158
|
-
subscriberPriority: toWire(
|
|
86157
|
+
trackName: request4.name,
|
|
86158
|
+
subscriberPriority: toWire(request4.priority),
|
|
86159
86159
|
// No fill is requested: the fill's fetch stream and the live subscription split
|
|
86160
86160
|
// the group across two streams, and this subscriber does not reassemble them into
|
|
86161
86161
|
// one group yet. A lenient publisher (like ours) replays the whole in-range group
|
|
@@ -86168,7 +86168,7 @@ var Subscriber2 = class {
|
|
|
86168
86168
|
state3.sent = true;
|
|
86169
86169
|
if (state3.cancelled)
|
|
86170
86170
|
throw new Error("subscribe cancelled while it was being sent");
|
|
86171
|
-
console.debug(`subscribe written: id=${requestId} broadcast=${broadcast} track=${
|
|
86171
|
+
console.debug(`subscribe written: id=${requestId} broadcast=${broadcast} track=${request4.name}`);
|
|
86172
86172
|
const respTypeId = await state3.stream.reader.u53();
|
|
86173
86173
|
if (respTypeId !== SubscribeOk.id) {
|
|
86174
86174
|
let reasonPhrase2 = "unknown error";
|
|
@@ -86184,7 +86184,7 @@ var Subscriber2 = class {
|
|
|
86184
86184
|
}
|
|
86185
86185
|
const ok = await SubscribeOk.decode(state3.stream.reader, version3);
|
|
86186
86186
|
try {
|
|
86187
|
-
this.#aliases.set(ok.trackAlias, producer, { broadcast, name:
|
|
86187
|
+
this.#aliases.set(ok.trackAlias, producer, { broadcast, name: request4.name });
|
|
86188
86188
|
const timescale = ok.properties.timescale;
|
|
86189
86189
|
if (timescale !== void 0) {
|
|
86190
86190
|
this.#timescales.set(ok.trackAlias, timescale);
|
|
@@ -88895,23 +88895,23 @@ var Subscriber3 = class {
|
|
|
88895
88895
|
const consumer = new ConsumeBroadcast2(this, path71);
|
|
88896
88896
|
void (async () => {
|
|
88897
88897
|
for (; ; ) {
|
|
88898
|
-
const
|
|
88899
|
-
if (!
|
|
88898
|
+
const request4 = await consumer.requested();
|
|
88899
|
+
if (!request4)
|
|
88900
88900
|
break;
|
|
88901
|
-
void this.#runSubscribe(path71,
|
|
88901
|
+
void this.#runSubscribe(path71, request4);
|
|
88902
88902
|
}
|
|
88903
88903
|
})();
|
|
88904
88904
|
return consumer;
|
|
88905
88905
|
}
|
|
88906
|
-
async #runSubscribe(broadcast,
|
|
88906
|
+
async #runSubscribe(broadcast, request4) {
|
|
88907
88907
|
const id = this.#subscribeNext++;
|
|
88908
|
-
const subscription =
|
|
88908
|
+
const subscription = request4.subscription;
|
|
88909
88909
|
const timescale = new Signal(void 0);
|
|
88910
|
-
console.debug(`subscribe start: id=${id} broadcast=${broadcast} track=${
|
|
88910
|
+
console.debug(`subscribe start: id=${id} broadcast=${broadcast} track=${request4.name}`);
|
|
88911
88911
|
const msg = new Subscribe2({
|
|
88912
88912
|
id,
|
|
88913
88913
|
broadcast,
|
|
88914
|
-
track:
|
|
88914
|
+
track: request4.name,
|
|
88915
88915
|
priority: subscription.priority ?? 0,
|
|
88916
88916
|
ordered: subscription.ordered,
|
|
88917
88917
|
maxLatency: subscription.latencyMax,
|
|
@@ -88919,16 +88919,16 @@ var Subscriber3 = class {
|
|
|
88919
88919
|
endGroup: subscription.endGroup
|
|
88920
88920
|
});
|
|
88921
88921
|
const state3 = {};
|
|
88922
|
-
const setup = this.#openSubscribe(state3, msg,
|
|
88922
|
+
const setup = this.#openSubscribe(state3, msg, request4, id, timescale);
|
|
88923
88923
|
let opened;
|
|
88924
88924
|
try {
|
|
88925
88925
|
opened = await withTimeout(setup, SUBSCRIBE_SETUP_TIMEOUT_MS, `subscribe timed out after ${SUBSCRIBE_SETUP_TIMEOUT_MS}ms waiting for the first response (browser stream limit reached?)`);
|
|
88926
|
-
console.debug(`subscribe ok: id=${id} broadcast=${broadcast} track=${
|
|
88926
|
+
console.debug(`subscribe ok: id=${id} broadcast=${broadcast} track=${request4.name}`);
|
|
88927
88927
|
} catch (err) {
|
|
88928
88928
|
const e = error62(err);
|
|
88929
|
-
|
|
88929
|
+
request4.reject(e);
|
|
88930
88930
|
this.#subscribes.delete(id);
|
|
88931
|
-
console.warn(`subscribe error: id=${id} broadcast=${broadcast} track=${
|
|
88931
|
+
console.warn(`subscribe error: id=${id} broadcast=${broadcast} track=${request4.name} error=${reason(e)}`);
|
|
88932
88932
|
setup.then(() => state3.stream?.abort(e), () => state3.stream?.abort(e));
|
|
88933
88933
|
return;
|
|
88934
88934
|
}
|
|
@@ -88949,11 +88949,11 @@ var Subscriber3 = class {
|
|
|
88949
88949
|
}
|
|
88950
88950
|
producer.close();
|
|
88951
88951
|
stream.close();
|
|
88952
|
-
console.debug(`subscribe close: id=${id} broadcast=${broadcast} track=${
|
|
88952
|
+
console.debug(`subscribe close: id=${id} broadcast=${broadcast} track=${request4.name}`);
|
|
88953
88953
|
} catch (err) {
|
|
88954
88954
|
const e = error62(err);
|
|
88955
88955
|
producer.close(e);
|
|
88956
|
-
console.warn(`subscribe error: id=${id} broadcast=${broadcast} track=${
|
|
88956
|
+
console.warn(`subscribe error: id=${id} broadcast=${broadcast} track=${request4.name} error=${reason(e)}`);
|
|
88957
88957
|
stream.abort(e);
|
|
88958
88958
|
} finally {
|
|
88959
88959
|
this.#subscribes.delete(id);
|
|
@@ -88968,15 +88968,15 @@ var Subscriber3 = class {
|
|
|
88968
88968
|
// On lite-05+ the properties come from a TRACK stream opened first, and the
|
|
88969
88969
|
// SUBSCRIBE is accepted implicitly (no SUBSCRIBE_OK). Older drafts carry no
|
|
88970
88970
|
// per-track properties, so they resolve to defaults and just drain SUBSCRIBE_OK.
|
|
88971
|
-
async #openSubscribe(state3, msg,
|
|
88971
|
+
async #openSubscribe(state3, msg, request4, id, timescale) {
|
|
88972
88972
|
let producer;
|
|
88973
88973
|
let drainOk = false;
|
|
88974
88974
|
if (supportsTrackStream2(this.version)) {
|
|
88975
88975
|
const info = await this.#trackInfo(msg.broadcast, msg.track);
|
|
88976
|
-
producer =
|
|
88976
|
+
producer = request4.accept(this.#toModelInfo(info));
|
|
88977
88977
|
timescale.set(info.timescale);
|
|
88978
88978
|
} else {
|
|
88979
|
-
producer =
|
|
88979
|
+
producer = request4.accept();
|
|
88980
88980
|
timescale.set(0);
|
|
88981
88981
|
drainOk = true;
|
|
88982
88982
|
}
|
|
@@ -93588,9 +93588,9 @@ var MoqDeviceSession = class {
|
|
|
93588
93588
|
async pumpTrackRequests() {
|
|
93589
93589
|
try {
|
|
93590
93590
|
for (; ; ) {
|
|
93591
|
-
const
|
|
93592
|
-
if (!
|
|
93593
|
-
const track2 =
|
|
93591
|
+
const request4 = await this.controlBroadcast.requested();
|
|
93592
|
+
if (!request4) break;
|
|
93593
|
+
const track2 = request4.accept();
|
|
93594
93594
|
this.requestedTracks.set(track2.name, track2);
|
|
93595
93595
|
const waiters = this.trackWaiters.get(track2.name);
|
|
93596
93596
|
if (waiters) {
|
|
@@ -93928,8 +93928,8 @@ function streamFailure(message, stage, kind = "network", cause) {
|
|
|
93928
93928
|
function openMjpegStream(url2, connectTimeoutMs = 1e4) {
|
|
93929
93929
|
return new Promise((resolve21, reject) => {
|
|
93930
93930
|
let settled = false;
|
|
93931
|
-
const
|
|
93932
|
-
|
|
93931
|
+
const request4 = import_http.default.get(url2, (res) => {
|
|
93932
|
+
request4.setTimeout(0);
|
|
93933
93933
|
res.socket?.setTimeout(0);
|
|
93934
93934
|
if (res.statusCode !== 200) {
|
|
93935
93935
|
res.resume();
|
|
@@ -94044,12 +94044,12 @@ function openMjpegStream(url2, connectTimeoutMs = 1e4) {
|
|
|
94044
94044
|
firstFrameResolve = null;
|
|
94045
94045
|
firstFrameReject = null;
|
|
94046
94046
|
res.destroy();
|
|
94047
|
-
|
|
94047
|
+
request4.destroy();
|
|
94048
94048
|
}
|
|
94049
94049
|
});
|
|
94050
94050
|
});
|
|
94051
|
-
|
|
94052
|
-
|
|
94051
|
+
request4.setTimeout(connectTimeoutMs, () => {
|
|
94052
|
+
request4.destroy(
|
|
94053
94053
|
streamFailure(
|
|
94054
94054
|
`Connecting to simulator-server's frame stream at ${url2} timed out after ${connectTimeoutMs} ms.`,
|
|
94055
94055
|
"screen_recording_stream_connect",
|
|
@@ -94057,7 +94057,7 @@ function openMjpegStream(url2, connectTimeoutMs = 1e4) {
|
|
|
94057
94057
|
)
|
|
94058
94058
|
);
|
|
94059
94059
|
});
|
|
94060
|
-
|
|
94060
|
+
request4.on("error", (err) => {
|
|
94061
94061
|
if (settled) return;
|
|
94062
94062
|
settled = true;
|
|
94063
94063
|
reject(
|
|
@@ -94863,7 +94863,7 @@ async function fetchDisplayState(api, signal) {
|
|
|
94863
94863
|
return null;
|
|
94864
94864
|
}
|
|
94865
94865
|
}
|
|
94866
|
-
async function postHinge(api,
|
|
94866
|
+
async function postHinge(api, request4, signal) {
|
|
94867
94867
|
if (api.deviceId) forgetUiOrientation(api.deviceId);
|
|
94868
94868
|
if (api.transport) {
|
|
94869
94869
|
throw new FailureError(
|
|
@@ -94882,7 +94882,7 @@ async function postHinge(api, request3, signal) {
|
|
|
94882
94882
|
res = await fetch(`${api.apiUrl}/api/hinge`, {
|
|
94883
94883
|
method: "POST",
|
|
94884
94884
|
headers: { "Content-Type": "application/json" },
|
|
94885
|
-
body: JSON.stringify(
|
|
94885
|
+
body: JSON.stringify(request4),
|
|
94886
94886
|
signal
|
|
94887
94887
|
});
|
|
94888
94888
|
} catch (err) {
|
|
@@ -105468,11 +105468,11 @@ var androidDevtoolsBlueprint = {
|
|
|
105468
105468
|
throw err;
|
|
105469
105469
|
}
|
|
105470
105470
|
};
|
|
105471
|
-
const
|
|
105471
|
+
const request4 = async (method, params) => send(await connected(), method, params);
|
|
105472
105472
|
const api = {
|
|
105473
105473
|
isReady: () => ready2 && !disposed,
|
|
105474
105474
|
getHierarchy(getOpts = {}) {
|
|
105475
|
-
return
|
|
105475
|
+
return request4("getHierarchy", {
|
|
105476
105476
|
waitForIdleMs: getOpts.waitForIdleMs ?? 500,
|
|
105477
105477
|
maxDepth: getOpts.maxDepth ?? 128,
|
|
105478
105478
|
maxNodes: getOpts.maxNodes ?? 5e3,
|
|
@@ -105480,10 +105480,10 @@ var androidDevtoolsBlueprint = {
|
|
|
105480
105480
|
});
|
|
105481
105481
|
},
|
|
105482
105482
|
getScreenSize() {
|
|
105483
|
-
return
|
|
105483
|
+
return request4("getScreenSize");
|
|
105484
105484
|
},
|
|
105485
105485
|
ping() {
|
|
105486
|
-
return
|
|
105486
|
+
return request4("ping");
|
|
105487
105487
|
},
|
|
105488
105488
|
async setText(text, setOpts = {}) {
|
|
105489
105489
|
const current = await connected();
|
|
@@ -108704,7 +108704,7 @@ async function requestOverAgent(agent, socket, payload, timeoutMs) {
|
|
|
108704
108704
|
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
108705
108705
|
try {
|
|
108706
108706
|
return await new Promise((resolve21, reject) => {
|
|
108707
|
-
const
|
|
108707
|
+
const request4 = import_node_http3.default.request(
|
|
108708
108708
|
{
|
|
108709
108709
|
method: "POST",
|
|
108710
108710
|
// Host header only because the connection is the injected socket.
|
|
@@ -108725,9 +108725,9 @@ async function requestOverAgent(agent, socket, payload, timeoutMs) {
|
|
|
108725
108725
|
);
|
|
108726
108726
|
}
|
|
108727
108727
|
);
|
|
108728
|
-
|
|
108728
|
+
request4.once("error", reject);
|
|
108729
108729
|
socket.resume();
|
|
108730
|
-
|
|
108730
|
+
request4.end(payload);
|
|
108731
108731
|
});
|
|
108732
108732
|
} catch (error63) {
|
|
108733
108733
|
if (timeoutSignal.aborted) {
|
|
@@ -109563,7 +109563,7 @@ async function captureSnapshot(api, bundleId) {
|
|
|
109563
109563
|
if (pending) {
|
|
109564
109564
|
return pending;
|
|
109565
109565
|
}
|
|
109566
|
-
const
|
|
109566
|
+
const request4 = (async () => {
|
|
109567
109567
|
let data;
|
|
109568
109568
|
try {
|
|
109569
109569
|
data = await api.run(
|
|
@@ -109578,9 +109578,9 @@ async function captureSnapshot(api, bundleId) {
|
|
|
109578
109578
|
quality: data.quality ?? null
|
|
109579
109579
|
};
|
|
109580
109580
|
})();
|
|
109581
|
-
inFlightSnapshots.set(key2,
|
|
109581
|
+
inFlightSnapshots.set(key2, request4);
|
|
109582
109582
|
try {
|
|
109583
|
-
return await
|
|
109583
|
+
return await request4;
|
|
109584
109584
|
} finally {
|
|
109585
109585
|
inFlightSnapshots.delete(key2);
|
|
109586
109586
|
}
|
|
@@ -118260,10 +118260,10 @@ function createMacosAppApi(bundleId) {
|
|
|
118260
118260
|
tookOver = `argent quit the copy of ${bundleId} that ran without the argent library (pid ${signalled.join(", ")}) and started the app with the library. Unsaved changes in that copy are lost.`;
|
|
118261
118261
|
}
|
|
118262
118262
|
}
|
|
118263
|
-
const
|
|
118263
|
+
const listen3 = macosListenSocket(bundleId, info.sandboxed);
|
|
118264
118264
|
const logPath = macosAppLogPath(bundleId);
|
|
118265
118265
|
fs39.mkdirSync(path33.dirname(logPath), { recursive: true, mode: 448 });
|
|
118266
|
-
if (
|
|
118266
|
+
if (listen3 && !info.sandboxed) fs39.rmSync(listen3.path, { force: true });
|
|
118267
118267
|
fs39.writeFileSync(logPath, "");
|
|
118268
118268
|
const args = opts.args ?? (opts.noLastArgs ? void 0 : tracked?.args) ?? [];
|
|
118269
118269
|
const helper = (0, import_node_child_process31.spawn)(
|
|
@@ -118288,7 +118288,7 @@ function createMacosAppApi(bundleId) {
|
|
|
118288
118288
|
// The app inherits the working directory, which a Finder launch sets to /.
|
|
118289
118289
|
{
|
|
118290
118290
|
stdio: ["ignore", "pipe", "pipe", "pipe"],
|
|
118291
|
-
env: macosLaunchEnv(bundleId,
|
|
118291
|
+
env: macosLaunchEnv(bundleId, listen3?.env, opts.env),
|
|
118292
118292
|
cwd: "/"
|
|
118293
118293
|
}
|
|
118294
118294
|
);
|
|
@@ -118313,7 +118313,7 @@ function createMacosAppApi(bundleId) {
|
|
|
118313
118313
|
pid,
|
|
118314
118314
|
sandboxed: info.sandboxed,
|
|
118315
118315
|
userSelectedReadOnly: info.userSelectedReadOnly,
|
|
118316
|
-
listenSocket:
|
|
118316
|
+
listenSocket: listen3?.path ?? null,
|
|
118317
118317
|
logPath,
|
|
118318
118318
|
args,
|
|
118319
118319
|
startedAt: Date.now(),
|
|
@@ -118366,7 +118366,7 @@ function createMacosAppApi(bundleId) {
|
|
|
118366
118366
|
sandboxed: info.sandboxed,
|
|
118367
118367
|
logPath
|
|
118368
118368
|
};
|
|
118369
|
-
adopt(ch, true,
|
|
118369
|
+
adopt(ch, true, listen3 !== null);
|
|
118370
118370
|
const { note: noWindow, refusal: noDrivableWindow } = await waitForFirstWindow(
|
|
118371
118371
|
ch,
|
|
118372
118372
|
pid,
|
|
@@ -118383,7 +118383,7 @@ function createMacosAppApi(bundleId) {
|
|
|
118383
118383
|
"unsupported"
|
|
118384
118384
|
);
|
|
118385
118385
|
}
|
|
118386
|
-
const note = [forceQuit, tookOver, noWindow,
|
|
118386
|
+
const note = [forceQuit, tookOver, noWindow, listen3 ? void 0 : noListenSocketNote(bundleId)].filter(Boolean).join(" ");
|
|
118387
118387
|
return note ? { ...result, note } : result;
|
|
118388
118388
|
};
|
|
118389
118389
|
const api = {
|
|
@@ -122231,7 +122231,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
122231
122231
|
checkpoint();
|
|
122232
122232
|
staged = true;
|
|
122233
122233
|
}
|
|
122234
|
-
if (!server) await
|
|
122234
|
+
if (!server) await listen3();
|
|
122235
122235
|
await assertReverse();
|
|
122236
122236
|
ready2 = true;
|
|
122237
122237
|
return null;
|
|
@@ -122377,7 +122377,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
122377
122377
|
}
|
|
122378
122378
|
);
|
|
122379
122379
|
}
|
|
122380
|
-
function
|
|
122380
|
+
function listen3() {
|
|
122381
122381
|
return new Promise((resolve21, reject) => {
|
|
122382
122382
|
const srv = net9.createServer(serveAgent);
|
|
122383
122383
|
srv.once("error", reject);
|
|
@@ -123618,6 +123618,700 @@ function sleep3(ms3) {
|
|
|
123618
123618
|
});
|
|
123619
123619
|
}
|
|
123620
123620
|
|
|
123621
|
+
// ../tool-server/src/blueprints/android-network-shaper.ts
|
|
123622
|
+
init_src2();
|
|
123623
|
+
|
|
123624
|
+
// ../tool-server/src/utils/network-shaping-proxy.ts
|
|
123625
|
+
var http4 = __toESM(require("node:http"));
|
|
123626
|
+
var net10 = __toESM(require("node:net"));
|
|
123627
|
+
|
|
123628
|
+
// ../tool-server/src/utils/shaped-link.ts
|
|
123629
|
+
var import_node_stream2 = require("node:stream");
|
|
123630
|
+
var SLICE_BYTES = 16 * 1024;
|
|
123631
|
+
var MAX_QUEUED_BYTES = 64 * 1024 * 1024;
|
|
123632
|
+
var SEND_CREDIT_MS = 20;
|
|
123633
|
+
var MAX_REQUEST_LINE = 8192;
|
|
123634
|
+
var LinkDirection = class {
|
|
123635
|
+
freeAt = 0;
|
|
123636
|
+
bytesPerMs = null;
|
|
123637
|
+
delayMs = 0;
|
|
123638
|
+
configure(kbps, latencyMs) {
|
|
123639
|
+
const bytesPerMs = kbps === void 0 ? null : kbps / 8;
|
|
123640
|
+
const delayMs = (latencyMs ?? 0) / 2;
|
|
123641
|
+
if (bytesPerMs === this.bytesPerMs && delayMs === this.delayMs) return false;
|
|
123642
|
+
this.bytesPerMs = bytesPerMs;
|
|
123643
|
+
this.delayMs = delayMs;
|
|
123644
|
+
this.freeAt = 0;
|
|
123645
|
+
return true;
|
|
123646
|
+
}
|
|
123647
|
+
get shaping() {
|
|
123648
|
+
return this.bytesPerMs !== null || this.delayMs > 0;
|
|
123649
|
+
}
|
|
123650
|
+
send(bytes, now) {
|
|
123651
|
+
if (this.bytesPerMs === null) return { sentAt: now, arrivesAt: now + this.delayMs };
|
|
123652
|
+
const start2 = Math.max(now - SEND_CREDIT_MS, this.freeAt);
|
|
123653
|
+
this.freeAt = start2 + bytes / this.bytesPerMs;
|
|
123654
|
+
return { sentAt: this.freeAt, arrivesAt: Math.max(this.freeAt, now) + this.delayMs };
|
|
123655
|
+
}
|
|
123656
|
+
startOf(bytes, sentAt) {
|
|
123657
|
+
return this.bytesPerMs === null ? sentAt : sentAt - bytes / this.bytesPerMs;
|
|
123658
|
+
}
|
|
123659
|
+
release(bytes, sentAt, now) {
|
|
123660
|
+
if (this.bytesPerMs === null) return;
|
|
123661
|
+
const unsentMs = Math.min(sentAt - now, bytes / this.bytesPerMs);
|
|
123662
|
+
if (unsentMs > 0) this.freeAt -= unsentMs;
|
|
123663
|
+
}
|
|
123664
|
+
};
|
|
123665
|
+
var UNSHAPED = new LinkDirection();
|
|
123666
|
+
function slicesOf(chunk) {
|
|
123667
|
+
const slices = [];
|
|
123668
|
+
for (let offset = 0; offset < chunk.length; offset += SLICE_BYTES) {
|
|
123669
|
+
slices.push(chunk.subarray(offset, offset + SLICE_BYTES));
|
|
123670
|
+
}
|
|
123671
|
+
return slices;
|
|
123672
|
+
}
|
|
123673
|
+
var DelayedQueue = class {
|
|
123674
|
+
constructor(link, deliver, onDrain) {
|
|
123675
|
+
this.link = link;
|
|
123676
|
+
this.deliver = deliver;
|
|
123677
|
+
this.onDrain = onDrain;
|
|
123678
|
+
}
|
|
123679
|
+
link;
|
|
123680
|
+
deliver;
|
|
123681
|
+
onDrain;
|
|
123682
|
+
slices = [];
|
|
123683
|
+
timer = null;
|
|
123684
|
+
sendTimers = /* @__PURE__ */ new Map();
|
|
123685
|
+
lastArrival = 0;
|
|
123686
|
+
queuedBytes = 0;
|
|
123687
|
+
get empty() {
|
|
123688
|
+
return this.slices.length === 0;
|
|
123689
|
+
}
|
|
123690
|
+
push(chunk, done) {
|
|
123691
|
+
const link = this.link();
|
|
123692
|
+
if (!link.shaping && this.empty) {
|
|
123693
|
+
this.deliver(Buffer.from(chunk));
|
|
123694
|
+
done?.();
|
|
123695
|
+
return;
|
|
123696
|
+
}
|
|
123697
|
+
let sentAt = 0;
|
|
123698
|
+
for (const slice of slicesOf(Buffer.from(chunk))) {
|
|
123699
|
+
const queued = { sentAt: 0, arrivesAt: 0, chunk: slice };
|
|
123700
|
+
sentAt = this.pace(queued, link);
|
|
123701
|
+
this.slices.push(queued);
|
|
123702
|
+
this.queuedBytes += slice.length;
|
|
123703
|
+
}
|
|
123704
|
+
this.schedule();
|
|
123705
|
+
if (done) this.whenSent(sentAt, done);
|
|
123706
|
+
}
|
|
123707
|
+
repace() {
|
|
123708
|
+
this.lastArrival = 0;
|
|
123709
|
+
this.repaceSlices(this.slices);
|
|
123710
|
+
}
|
|
123711
|
+
releaseWaiting(now) {
|
|
123712
|
+
this.release(this.waitingToSend(now), now);
|
|
123713
|
+
}
|
|
123714
|
+
repaceWaiting(now) {
|
|
123715
|
+
const waiting = this.waitingToSend(now);
|
|
123716
|
+
if (waiting.length === 0) return;
|
|
123717
|
+
this.lastArrival = this.slices[this.slices.length - waiting.length - 1]?.arrivesAt ?? 0;
|
|
123718
|
+
this.repaceSlices(waiting);
|
|
123719
|
+
}
|
|
123720
|
+
clear() {
|
|
123721
|
+
this.stopTimers();
|
|
123722
|
+
this.release(this.slices, performance.now());
|
|
123723
|
+
this.slices = [];
|
|
123724
|
+
this.queuedBytes = 0;
|
|
123725
|
+
}
|
|
123726
|
+
stopTimers() {
|
|
123727
|
+
if (this.timer) clearTimeout(this.timer);
|
|
123728
|
+
for (const timer of this.sendTimers.keys()) clearTimeout(timer);
|
|
123729
|
+
this.sendTimers.clear();
|
|
123730
|
+
this.timer = null;
|
|
123731
|
+
}
|
|
123732
|
+
pace(slice, link) {
|
|
123733
|
+
const timing = link.send(slice.chunk.length, performance.now());
|
|
123734
|
+
this.lastArrival = Math.max(this.lastArrival, timing.arrivesAt);
|
|
123735
|
+
slice.sentAt = timing.sentAt;
|
|
123736
|
+
slice.arrivesAt = this.lastArrival;
|
|
123737
|
+
return timing.sentAt;
|
|
123738
|
+
}
|
|
123739
|
+
waitingToSend(now) {
|
|
123740
|
+
const link = this.link();
|
|
123741
|
+
const first = this.slices.findIndex(
|
|
123742
|
+
(slice) => link.startOf(slice.chunk.length, slice.sentAt) > now
|
|
123743
|
+
);
|
|
123744
|
+
return first === -1 ? [] : this.slices.slice(first);
|
|
123745
|
+
}
|
|
123746
|
+
release(slices, now) {
|
|
123747
|
+
const link = this.link();
|
|
123748
|
+
for (const slice of slices) link.release(slice.chunk.length, slice.sentAt, now);
|
|
123749
|
+
}
|
|
123750
|
+
repaceSlices(slices) {
|
|
123751
|
+
const link = this.link();
|
|
123752
|
+
const waiting = [...this.sendTimers.values()];
|
|
123753
|
+
this.stopTimers();
|
|
123754
|
+
let sentAt = 0;
|
|
123755
|
+
for (const slice of slices) sentAt = this.pace(slice, link);
|
|
123756
|
+
this.schedule();
|
|
123757
|
+
for (const done of waiting) this.whenSent(sentAt, done);
|
|
123758
|
+
}
|
|
123759
|
+
whenSent(sentAt, done) {
|
|
123760
|
+
const wait = sentAt - performance.now();
|
|
123761
|
+
if (wait <= 0) {
|
|
123762
|
+
done();
|
|
123763
|
+
return;
|
|
123764
|
+
}
|
|
123765
|
+
const timer = setTimeout(() => {
|
|
123766
|
+
this.sendTimers.delete(timer);
|
|
123767
|
+
done();
|
|
123768
|
+
}, wait);
|
|
123769
|
+
this.sendTimers.set(timer, done);
|
|
123770
|
+
}
|
|
123771
|
+
schedule() {
|
|
123772
|
+
const next = this.slices[0];
|
|
123773
|
+
if (this.timer || !next) return;
|
|
123774
|
+
const wait = Math.max(0, next.arrivesAt - performance.now());
|
|
123775
|
+
this.timer = setTimeout(() => this.deliverDue(), wait);
|
|
123776
|
+
}
|
|
123777
|
+
deliverDue() {
|
|
123778
|
+
this.timer = null;
|
|
123779
|
+
const now = performance.now();
|
|
123780
|
+
while (this.slices[0] && this.slices[0].arrivesAt <= now) {
|
|
123781
|
+
const slice = this.slices.shift();
|
|
123782
|
+
this.queuedBytes -= slice.chunk.length;
|
|
123783
|
+
this.deliver(slice.chunk);
|
|
123784
|
+
}
|
|
123785
|
+
if (this.empty) this.onDrain();
|
|
123786
|
+
this.schedule();
|
|
123787
|
+
}
|
|
123788
|
+
};
|
|
123789
|
+
var ShapedSocket = class extends import_node_stream2.Duplex {
|
|
123790
|
+
constructor(socket, links, isBypassed) {
|
|
123791
|
+
super();
|
|
123792
|
+
this.socket = socket;
|
|
123793
|
+
this.links = links;
|
|
123794
|
+
this.isBypassed = isBypassed;
|
|
123795
|
+
this.upload = new DelayedQueue(
|
|
123796
|
+
() => this.linkFor("upload"),
|
|
123797
|
+
(chunk) => this.deliverToProxy(chunk),
|
|
123798
|
+
() => this.onUploadDrain()
|
|
123799
|
+
);
|
|
123800
|
+
this.download = new DelayedQueue(
|
|
123801
|
+
() => this.linkFor("download"),
|
|
123802
|
+
(chunk) => this.deliverToDevice(chunk),
|
|
123803
|
+
() => this.onDownloadDrain()
|
|
123804
|
+
);
|
|
123805
|
+
socket.on("data", (chunk) => this.onDeviceData(chunk));
|
|
123806
|
+
socket.on("end", () => this.onDeviceEnd());
|
|
123807
|
+
socket.on("error", (err) => this.destroy(err));
|
|
123808
|
+
socket.on("close", () => this.destroy());
|
|
123809
|
+
}
|
|
123810
|
+
socket;
|
|
123811
|
+
links;
|
|
123812
|
+
isBypassed;
|
|
123813
|
+
requestHead = "";
|
|
123814
|
+
heldRequest = [];
|
|
123815
|
+
requestLine = null;
|
|
123816
|
+
upload;
|
|
123817
|
+
download;
|
|
123818
|
+
deviceEnded = false;
|
|
123819
|
+
pendingFinal = null;
|
|
123820
|
+
writerWaiting = null;
|
|
123821
|
+
uploadsSending = 0;
|
|
123822
|
+
proxyFull = false;
|
|
123823
|
+
setNoDelay(noDelay) {
|
|
123824
|
+
this.socket.setNoDelay(noDelay);
|
|
123825
|
+
return this;
|
|
123826
|
+
}
|
|
123827
|
+
repace(direction) {
|
|
123828
|
+
this[direction].repace();
|
|
123829
|
+
}
|
|
123830
|
+
releaseWaiting(now) {
|
|
123831
|
+
this.upload.releaseWaiting(now);
|
|
123832
|
+
this.download.releaseWaiting(now);
|
|
123833
|
+
}
|
|
123834
|
+
repaceWaiting(now) {
|
|
123835
|
+
this.upload.repaceWaiting(now);
|
|
123836
|
+
this.download.repaceWaiting(now);
|
|
123837
|
+
}
|
|
123838
|
+
_read() {
|
|
123839
|
+
this.proxyFull = false;
|
|
123840
|
+
this.resumeDevice();
|
|
123841
|
+
}
|
|
123842
|
+
_write(chunk, _encoding, callback) {
|
|
123843
|
+
this.download.push(chunk, () => this.whenDeviceHasRoom(callback));
|
|
123844
|
+
}
|
|
123845
|
+
_final(callback) {
|
|
123846
|
+
this.pendingFinal = () => this.socket.end(callback);
|
|
123847
|
+
if (this.download.empty) this.onDownloadDrain();
|
|
123848
|
+
}
|
|
123849
|
+
_destroy(err, callback) {
|
|
123850
|
+
this.upload.clear();
|
|
123851
|
+
this.download.clear();
|
|
123852
|
+
this.socket.destroy();
|
|
123853
|
+
callback(err);
|
|
123854
|
+
}
|
|
123855
|
+
linkFor(direction) {
|
|
123856
|
+
const bypassed = this.requestLine !== null && this.isBypassed(this.requestLine);
|
|
123857
|
+
return bypassed ? UNSHAPED : this.links[direction];
|
|
123858
|
+
}
|
|
123859
|
+
onDeviceData(chunk) {
|
|
123860
|
+
if (this.requestLine !== null) return this.sendUpload(chunk);
|
|
123861
|
+
this.heldRequest.push(chunk);
|
|
123862
|
+
if (this.readRequestLine(chunk)) this.sendHeldRequest();
|
|
123863
|
+
}
|
|
123864
|
+
sendHeldRequest() {
|
|
123865
|
+
const held = Buffer.concat(this.heldRequest);
|
|
123866
|
+
this.heldRequest = [];
|
|
123867
|
+
this.sendUpload(held);
|
|
123868
|
+
}
|
|
123869
|
+
sendUpload(chunk) {
|
|
123870
|
+
this.uploadsSending++;
|
|
123871
|
+
this.socket.pause();
|
|
123872
|
+
this.upload.push(chunk, () => {
|
|
123873
|
+
this.uploadsSending--;
|
|
123874
|
+
this.resumeDevice();
|
|
123875
|
+
});
|
|
123876
|
+
}
|
|
123877
|
+
onDeviceEnd() {
|
|
123878
|
+
this.deviceEnded = true;
|
|
123879
|
+
if (this.requestLine === null && this.heldRequest.length > 0) {
|
|
123880
|
+
this.requestLine = this.requestHead;
|
|
123881
|
+
this.sendHeldRequest();
|
|
123882
|
+
}
|
|
123883
|
+
if (this.upload.empty) this.push(null);
|
|
123884
|
+
}
|
|
123885
|
+
readRequestLine(chunk) {
|
|
123886
|
+
this.requestHead += chunk.toString("latin1", 0, MAX_REQUEST_LINE - this.requestHead.length);
|
|
123887
|
+
const end = this.requestHead.indexOf("\r\n");
|
|
123888
|
+
if (end === -1 && this.requestHead.length < MAX_REQUEST_LINE) return false;
|
|
123889
|
+
this.requestLine = end === -1 ? this.requestHead : this.requestHead.slice(0, end);
|
|
123890
|
+
this.requestHead = "";
|
|
123891
|
+
return true;
|
|
123892
|
+
}
|
|
123893
|
+
whenDeviceHasRoom(callback) {
|
|
123894
|
+
if (this.download.queuedBytes >= MAX_QUEUED_BYTES) this.writerWaiting = callback;
|
|
123895
|
+
else if (this.socket.writableNeedDrain) this.socket.once("drain", callback);
|
|
123896
|
+
else callback();
|
|
123897
|
+
}
|
|
123898
|
+
deliverToDevice(chunk) {
|
|
123899
|
+
this.socket.write(chunk);
|
|
123900
|
+
const waiting = this.writerWaiting;
|
|
123901
|
+
if (waiting && this.download.queuedBytes < MAX_QUEUED_BYTES / 2) {
|
|
123902
|
+
this.writerWaiting = null;
|
|
123903
|
+
this.whenDeviceHasRoom(waiting);
|
|
123904
|
+
}
|
|
123905
|
+
}
|
|
123906
|
+
resumeDevice() {
|
|
123907
|
+
const hasRoom = this.upload.queuedBytes < MAX_QUEUED_BYTES / 2;
|
|
123908
|
+
if (this.uploadsSending === 0 && !this.proxyFull && hasRoom) this.socket.resume();
|
|
123909
|
+
}
|
|
123910
|
+
deliverToProxy(chunk) {
|
|
123911
|
+
if (this.push(chunk)) {
|
|
123912
|
+
this.resumeDevice();
|
|
123913
|
+
return;
|
|
123914
|
+
}
|
|
123915
|
+
this.proxyFull = true;
|
|
123916
|
+
this.socket.pause();
|
|
123917
|
+
}
|
|
123918
|
+
onUploadDrain() {
|
|
123919
|
+
if (this.deviceEnded) this.push(null);
|
|
123920
|
+
}
|
|
123921
|
+
onDownloadDrain() {
|
|
123922
|
+
const final = this.pendingFinal;
|
|
123923
|
+
this.pendingFinal = null;
|
|
123924
|
+
final?.();
|
|
123925
|
+
}
|
|
123926
|
+
};
|
|
123927
|
+
var ShapedLink = class {
|
|
123928
|
+
links = { upload: new LinkDirection(), download: new LinkDirection() };
|
|
123929
|
+
sockets = /* @__PURE__ */ new Set();
|
|
123930
|
+
attach(socket, isBypassed) {
|
|
123931
|
+
const shaped = new ShapedSocket(socket, this.links, isBypassed);
|
|
123932
|
+
this.sockets.add(shaped);
|
|
123933
|
+
socket.on("close", () => {
|
|
123934
|
+
this.sockets.delete(shaped);
|
|
123935
|
+
this.reclaimWaiting();
|
|
123936
|
+
});
|
|
123937
|
+
return shaped;
|
|
123938
|
+
}
|
|
123939
|
+
reclaimWaiting() {
|
|
123940
|
+
const now = performance.now();
|
|
123941
|
+
for (const shaped of this.sockets) shaped.releaseWaiting(now);
|
|
123942
|
+
for (const shaped of this.sockets) shaped.repaceWaiting(now);
|
|
123943
|
+
}
|
|
123944
|
+
setConditions(conditions) {
|
|
123945
|
+
const { upload, download } = this.links;
|
|
123946
|
+
const uploadChanged = upload.configure(conditions?.uploadKbps, conditions?.latencyMs);
|
|
123947
|
+
const downloadChanged = download.configure(conditions?.downloadKbps, conditions?.latencyMs);
|
|
123948
|
+
if (!uploadChanged && !downloadChanged) return;
|
|
123949
|
+
for (const shaped of this.sockets) {
|
|
123950
|
+
if (uploadChanged) shaped.repace("upload");
|
|
123951
|
+
if (downloadChanged) shaped.repace("download");
|
|
123952
|
+
}
|
|
123953
|
+
}
|
|
123954
|
+
};
|
|
123955
|
+
|
|
123956
|
+
// ../tool-server/src/utils/network-shaping-proxy.ts
|
|
123957
|
+
var TUNNEL_ESTABLISHED = "HTTP/1.1 200 Connection Established\r\n\r\n";
|
|
123958
|
+
var BAD_GATEWAY = "HTTP/1.1 502 Bad Gateway\r\nContent-Length: 0\r\n\r\n";
|
|
123959
|
+
var BAD_REQUEST = "HTTP/1.1 400 Bad Request\r\nContent-Length: 0\r\n\r\n";
|
|
123960
|
+
var PROXY_HEADERS = /* @__PURE__ */ new Set(["proxy-authorization", "proxy-connection"]);
|
|
123961
|
+
var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
123962
|
+
...PROXY_HEADERS,
|
|
123963
|
+
"connection",
|
|
123964
|
+
"keep-alive",
|
|
123965
|
+
"te",
|
|
123966
|
+
"trailer",
|
|
123967
|
+
"transfer-encoding",
|
|
123968
|
+
"upgrade"
|
|
123969
|
+
]);
|
|
123970
|
+
function parseAuthority(authority) {
|
|
123971
|
+
const match = /^\[?([^\]]+?)\]?:(\d+)$/.exec(authority);
|
|
123972
|
+
const port = Number(match?.[2]);
|
|
123973
|
+
return match && port <= 65535 ? { host: match[1], port } : null;
|
|
123974
|
+
}
|
|
123975
|
+
function httpTarget(url2) {
|
|
123976
|
+
if (!url2 || url2.protocol !== "http:") return null;
|
|
123977
|
+
return { host: url2.hostname.replace(/^\[|\]$/g, ""), port: Number(url2.port || 80) };
|
|
123978
|
+
}
|
|
123979
|
+
function requestLineTarget(line) {
|
|
123980
|
+
const [method, target = ""] = line.split(" ");
|
|
123981
|
+
return method === "CONNECT" ? parseAuthority(target) : httpTarget(URL.parse(target));
|
|
123982
|
+
}
|
|
123983
|
+
function connectionOptions(headers) {
|
|
123984
|
+
return (headers.connection ?? "").split(",").map((name) => name.trim().toLowerCase());
|
|
123985
|
+
}
|
|
123986
|
+
function forwardedHeaders(headers) {
|
|
123987
|
+
const dropped = /* @__PURE__ */ new Set([...HOP_BY_HOP_HEADERS, ...connectionOptions(headers)]);
|
|
123988
|
+
return Object.fromEntries(Object.entries(headers).filter(([name]) => !dropped.has(name)));
|
|
123989
|
+
}
|
|
123990
|
+
function earlyHints(headers) {
|
|
123991
|
+
const hints = forwardedHeaders(headers);
|
|
123992
|
+
const { link } = hints;
|
|
123993
|
+
return typeof link === "string" ? { ...hints, link: link.split(/,\s*(?=<)/) } : hints;
|
|
123994
|
+
}
|
|
123995
|
+
function relayEarlyHints(info, res) {
|
|
123996
|
+
if (info.statusCode !== 103) return;
|
|
123997
|
+
try {
|
|
123998
|
+
res.writeEarlyHints(earlyHints(info.headers));
|
|
123999
|
+
} catch {
|
|
124000
|
+
}
|
|
124001
|
+
}
|
|
124002
|
+
function originRequestHead(req, path71) {
|
|
124003
|
+
const lines = [`${req.method} ${path71} HTTP/${req.httpVersion}`];
|
|
124004
|
+
for (let i = 0; i < req.rawHeaders.length; i += 2) {
|
|
124005
|
+
const name = req.rawHeaders[i];
|
|
124006
|
+
if (!PROXY_HEADERS.has(name.toLowerCase())) lines.push(`${name}: ${req.rawHeaders[i + 1]}`);
|
|
124007
|
+
}
|
|
124008
|
+
return `${lines.join("\r\n")}\r
|
|
124009
|
+
\r
|
|
124010
|
+
`;
|
|
124011
|
+
}
|
|
124012
|
+
function pathOf(url2) {
|
|
124013
|
+
return `${url2.pathname}${url2.search}`;
|
|
124014
|
+
}
|
|
124015
|
+
function listen2(server) {
|
|
124016
|
+
return new Promise((resolve21, reject) => {
|
|
124017
|
+
server.once("error", reject);
|
|
124018
|
+
server.listen(0, "127.0.0.1", () => {
|
|
124019
|
+
server.off("error", reject);
|
|
124020
|
+
resolve21(server.address().port);
|
|
124021
|
+
});
|
|
124022
|
+
});
|
|
124023
|
+
}
|
|
124024
|
+
async function startShapingProxy(options) {
|
|
124025
|
+
const link = new ShapedLink();
|
|
124026
|
+
const sockets = /* @__PURE__ */ new Set();
|
|
124027
|
+
const agent = new http4.Agent({ keepAlive: true });
|
|
124028
|
+
const track2 = (socket) => {
|
|
124029
|
+
sockets.add(socket);
|
|
124030
|
+
socket.on("close", () => sockets.delete(socket));
|
|
124031
|
+
};
|
|
124032
|
+
const resolve21 = (target) => options.resolveTarget(target.host, target.port).catch(() => null);
|
|
124033
|
+
const relayResponse = (upstream, res) => {
|
|
124034
|
+
upstream.on("information", (info) => relayEarlyHints(info, res));
|
|
124035
|
+
upstream.on("response", (response) => {
|
|
124036
|
+
try {
|
|
124037
|
+
const headers = forwardedHeaders(response.headers);
|
|
124038
|
+
res.writeHead(response.statusCode ?? 502, response.statusMessage, headers);
|
|
124039
|
+
} catch {
|
|
124040
|
+
res.destroy();
|
|
124041
|
+
return;
|
|
124042
|
+
}
|
|
124043
|
+
response.pipe(res);
|
|
124044
|
+
response.on("close", () => {
|
|
124045
|
+
if (!response.complete) res.destroy();
|
|
124046
|
+
});
|
|
124047
|
+
});
|
|
124048
|
+
upstream.on("error", () => {
|
|
124049
|
+
if (res.headersSent) res.destroy();
|
|
124050
|
+
else res.writeHead(502).end();
|
|
124051
|
+
});
|
|
124052
|
+
res.on("close", () => {
|
|
124053
|
+
if (!res.writableFinished) upstream.destroy();
|
|
124054
|
+
});
|
|
124055
|
+
};
|
|
124056
|
+
const onRequest = async (req, res) => {
|
|
124057
|
+
const url2 = URL.parse(req.url ?? "");
|
|
124058
|
+
const requested = httpTarget(url2);
|
|
124059
|
+
if (!url2 || !requested) return void res.writeHead(400).end();
|
|
124060
|
+
const target = await resolve21(requested);
|
|
124061
|
+
if (res.destroyed) return;
|
|
124062
|
+
if (!target) return void res.writeHead(502).end();
|
|
124063
|
+
const upstream = http4.request({
|
|
124064
|
+
agent,
|
|
124065
|
+
host: target.host,
|
|
124066
|
+
port: target.port,
|
|
124067
|
+
method: req.method,
|
|
124068
|
+
path: pathOf(url2),
|
|
124069
|
+
headers: forwardedHeaders(req.headers)
|
|
124070
|
+
});
|
|
124071
|
+
relayResponse(upstream, res);
|
|
124072
|
+
req.pipe(upstream);
|
|
124073
|
+
};
|
|
124074
|
+
const pipeToTarget = async (client2, requested, start2) => {
|
|
124075
|
+
let upstream = null;
|
|
124076
|
+
client2.on("error", () => upstream?.destroy());
|
|
124077
|
+
const target = await resolve21(requested);
|
|
124078
|
+
if (client2.destroyed) return;
|
|
124079
|
+
if (!target) return void client2.end(BAD_GATEWAY);
|
|
124080
|
+
const connection = net10.connect(target.port, target.host);
|
|
124081
|
+
upstream = connection;
|
|
124082
|
+
track2(connection);
|
|
124083
|
+
let established = false;
|
|
124084
|
+
connection.once("connect", () => {
|
|
124085
|
+
established = true;
|
|
124086
|
+
start2(connection);
|
|
124087
|
+
connection.pipe(client2);
|
|
124088
|
+
client2.pipe(connection);
|
|
124089
|
+
});
|
|
124090
|
+
connection.on("error", () => {
|
|
124091
|
+
if (!established) client2.end(BAD_GATEWAY);
|
|
124092
|
+
});
|
|
124093
|
+
connection.on("close", (hadError) => {
|
|
124094
|
+
if (hadError && established) client2.destroy();
|
|
124095
|
+
});
|
|
124096
|
+
};
|
|
124097
|
+
const refuse = (client2, response) => {
|
|
124098
|
+
client2.on("error", () => client2.destroy());
|
|
124099
|
+
client2.end(response);
|
|
124100
|
+
};
|
|
124101
|
+
const onConnect = async (req, client2, head) => {
|
|
124102
|
+
const requested = parseAuthority(req.url ?? "");
|
|
124103
|
+
if (!requested) return refuse(client2, BAD_GATEWAY);
|
|
124104
|
+
await pipeToTarget(client2, requested, (upstream) => {
|
|
124105
|
+
client2.write(TUNNEL_ESTABLISHED);
|
|
124106
|
+
if (head.length > 0) upstream.write(head);
|
|
124107
|
+
});
|
|
124108
|
+
};
|
|
124109
|
+
const onUpgrade = async (req, client2, head) => {
|
|
124110
|
+
const url2 = URL.parse(req.url ?? "");
|
|
124111
|
+
const requested = httpTarget(url2);
|
|
124112
|
+
if (!url2 || !requested) return refuse(client2, BAD_REQUEST);
|
|
124113
|
+
await pipeToTarget(client2, requested, (upstream) => {
|
|
124114
|
+
upstream.write(originRequestHead(req, pathOf(url2)));
|
|
124115
|
+
if (head.length > 0) upstream.write(head);
|
|
124116
|
+
});
|
|
124117
|
+
};
|
|
124118
|
+
const isBypassed = (requestLine) => {
|
|
124119
|
+
const target = requestLineTarget(requestLine);
|
|
124120
|
+
return target !== null && options.bypass(target.host, target.port);
|
|
124121
|
+
};
|
|
124122
|
+
const server = http4.createServer({ requestTimeout: 0 });
|
|
124123
|
+
server.on("request", (req, res) => void onRequest(req, res).catch(() => res.destroy()));
|
|
124124
|
+
server.on("connect", (req, client2, head) => {
|
|
124125
|
+
void onConnect(req, client2, head).catch(() => client2.destroy());
|
|
124126
|
+
});
|
|
124127
|
+
server.on("upgrade", (req, client2, head) => {
|
|
124128
|
+
void onUpgrade(req, client2, head).catch(() => client2.destroy());
|
|
124129
|
+
});
|
|
124130
|
+
const listener = net10.createServer({ allowHalfOpen: true }, (socket) => {
|
|
124131
|
+
track2(socket);
|
|
124132
|
+
server.emit("connection", link.attach(socket, isBypassed));
|
|
124133
|
+
});
|
|
124134
|
+
const port = await listen2(listener);
|
|
124135
|
+
return {
|
|
124136
|
+
port,
|
|
124137
|
+
setConditions: (conditions) => link.setConditions(conditions),
|
|
124138
|
+
async close() {
|
|
124139
|
+
for (const socket of sockets) socket.destroy();
|
|
124140
|
+
agent.destroy();
|
|
124141
|
+
await new Promise((done) => listener.close(() => done()));
|
|
124142
|
+
server.close();
|
|
124143
|
+
}
|
|
124144
|
+
};
|
|
124145
|
+
}
|
|
124146
|
+
|
|
124147
|
+
// ../tool-server/src/utils/android-global-proxy.ts
|
|
124148
|
+
init_src2();
|
|
124149
|
+
init_adb();
|
|
124150
|
+
var EMULATOR_HOST_ALIAS = "10.0.2.2";
|
|
124151
|
+
var MARKER_PATH = "/data/local/tmp/argent-network-proxy";
|
|
124152
|
+
var PROXY_KEYS = [
|
|
124153
|
+
"http_proxy",
|
|
124154
|
+
"global_http_proxy_host",
|
|
124155
|
+
"global_http_proxy_port",
|
|
124156
|
+
"global_http_proxy_exclusion_list"
|
|
124157
|
+
];
|
|
124158
|
+
var READ_STATE = `settings get global http_proxy; settings get global global_http_proxy_host; settings get global global_http_proxy_port; cat ${MARKER_PATH} 2>/dev/null; true`;
|
|
124159
|
+
var READ_APPLIED = "settings get global global_http_proxy_host; settings get global global_http_proxy_port";
|
|
124160
|
+
var APPLY_TIMEOUT_MS = 5e3;
|
|
124161
|
+
var APPLY_POLL_MS = 100;
|
|
124162
|
+
function parseGlobalProxyState(output2) {
|
|
124163
|
+
const [setting = "", host = "", port = "", marker = ""] = output2.split(/\r?\n/).map((line) => line.trim());
|
|
124164
|
+
const requested = /^[^:\s]+:[1-9]\d*$/.test(setting) ? setting : null;
|
|
124165
|
+
const hasProxy = host !== "" && host !== "null" && port !== "" && port !== "null" && port !== "0";
|
|
124166
|
+
return {
|
|
124167
|
+
active: requested ?? (hasProxy ? `${host}:${port}` : null),
|
|
124168
|
+
argent: marker.split(/\s+/).filter(Boolean)
|
|
124169
|
+
};
|
|
124170
|
+
}
|
|
124171
|
+
async function readGlobalProxyState(serial) {
|
|
124172
|
+
return parseGlobalProxyState(await adbShell(serial, READ_STATE));
|
|
124173
|
+
}
|
|
124174
|
+
function writeMarker(serial, proxies) {
|
|
124175
|
+
return adbShell(serial, `echo ${proxies.filter(Boolean).join(" ")} > ${MARKER_PATH}`);
|
|
124176
|
+
}
|
|
124177
|
+
function putHttpProxy(serial, value) {
|
|
124178
|
+
return runAdb(["-s", serial, "shell", "settings", "put", "global", "http_proxy", value]);
|
|
124179
|
+
}
|
|
124180
|
+
function foreignProxy(active) {
|
|
124181
|
+
return new FailureError(
|
|
124182
|
+
`The emulator already uses the HTTP proxy ${active}, which Argent did not set. network-conditions shapes the network through its own proxy and leaves this one in place. Remove it (adb shell settings put global http_proxy :0) to throttle the emulator.`,
|
|
124183
|
+
{
|
|
124184
|
+
error_code: FAILURE_CODES.TOOL_INPUT_INVALID,
|
|
124185
|
+
failure_stage: "network_conditions_proxy",
|
|
124186
|
+
failure_area: "tool_server",
|
|
124187
|
+
error_kind: "unsupported"
|
|
124188
|
+
}
|
|
124189
|
+
);
|
|
124190
|
+
}
|
|
124191
|
+
function installNotApplied(serial) {
|
|
124192
|
+
return new FailureError(
|
|
124193
|
+
`Asked ${serial} to use Argent's HTTP proxy, but Android did not apply it within ${APPLY_TIMEOUT_MS / 1e3} s, so apps may bypass the network conditions. Call network-conditions again.`,
|
|
124194
|
+
{
|
|
124195
|
+
error_code: FAILURE_CODES.ANDROID_NETWORK_PROXY_TIMEOUT,
|
|
124196
|
+
failure_stage: "network_conditions_proxy",
|
|
124197
|
+
failure_area: "tool_server",
|
|
124198
|
+
error_kind: "timeout"
|
|
124199
|
+
}
|
|
124200
|
+
);
|
|
124201
|
+
}
|
|
124202
|
+
function removalNotApplied(serial) {
|
|
124203
|
+
return new FailureError(
|
|
124204
|
+
`Asked ${serial} to drop Argent's HTTP proxy, but Android did not apply it within ${APPLY_TIMEOUT_MS / 1e3} s, so apps may still use the proxy. Call network-conditions again with no conditions.`,
|
|
124205
|
+
{
|
|
124206
|
+
error_code: FAILURE_CODES.ANDROID_NETWORK_RESTORE_TIMEOUT,
|
|
124207
|
+
failure_stage: "network_conditions_proxy",
|
|
124208
|
+
failure_area: "tool_server",
|
|
124209
|
+
error_kind: "timeout"
|
|
124210
|
+
}
|
|
124211
|
+
);
|
|
124212
|
+
}
|
|
124213
|
+
async function setArgentProxy(serial, port) {
|
|
124214
|
+
const proxy = `${EMULATOR_HOST_ALIAS}:${port}`;
|
|
124215
|
+
const state3 = await readGlobalProxyState(serial);
|
|
124216
|
+
const replaced = state3.active === proxy ? null : state3.active;
|
|
124217
|
+
if (state3.active !== proxy) {
|
|
124218
|
+
if (replaced && !state3.argent.includes(replaced)) throw foreignProxy(replaced);
|
|
124219
|
+
await writeMarker(serial, [replaced, proxy]);
|
|
124220
|
+
await putHttpProxy(serial, proxy);
|
|
124221
|
+
}
|
|
124222
|
+
const applied = await proxyApplied(serial, (host, port2) => `${host}:${port2}` === proxy);
|
|
124223
|
+
if (!applied) throw installNotApplied(serial);
|
|
124224
|
+
const inTransition = state3.argent.includes(proxy) && state3.argent.length > 1;
|
|
124225
|
+
if (replaced || inTransition) await writeMarker(serial, [proxy]);
|
|
124226
|
+
}
|
|
124227
|
+
async function clearArgentProxy(serial) {
|
|
124228
|
+
const state3 = await readGlobalProxyState(serial);
|
|
124229
|
+
if (state3.active && state3.argent.includes(state3.active)) {
|
|
124230
|
+
await putHttpProxy(serial, ":0");
|
|
124231
|
+
if (!await proxyApplied(serial, (_host, port) => port === "0"))
|
|
124232
|
+
throw removalNotApplied(serial);
|
|
124233
|
+
await adbShell(serial, PROXY_KEYS.map((key2) => `settings delete global ${key2}`).join("; "));
|
|
124234
|
+
}
|
|
124235
|
+
if (state3.argent.length > 0) await adbShell(serial, `rm -f ${MARKER_PATH}`);
|
|
124236
|
+
}
|
|
124237
|
+
async function proxyApplied(serial, isApplied) {
|
|
124238
|
+
const deadline = Date.now() + APPLY_TIMEOUT_MS;
|
|
124239
|
+
while (Date.now() < deadline) {
|
|
124240
|
+
const [host = "", port = ""] = (await adbShell(serial, READ_APPLIED)).split(/\r?\n/).map((line) => line.trim());
|
|
124241
|
+
if (isApplied(host, port)) return true;
|
|
124242
|
+
await new Promise((resolve21) => setTimeout(resolve21, APPLY_POLL_MS));
|
|
124243
|
+
}
|
|
124244
|
+
return false;
|
|
124245
|
+
}
|
|
124246
|
+
function parseAdbReverses(output2) {
|
|
124247
|
+
const reverses = /* @__PURE__ */ new Map();
|
|
124248
|
+
for (const match of output2.matchAll(/\btcp:(\d+)\s+tcp:(\d+)\b/g)) {
|
|
124249
|
+
reverses.set(Number(match[1]), Number(match[2]));
|
|
124250
|
+
}
|
|
124251
|
+
return reverses;
|
|
124252
|
+
}
|
|
124253
|
+
async function listAdbReverses(serial) {
|
|
124254
|
+
const { stdout } = await runAdb(["-s", serial, "reverse", "--list"], { timeoutMs: 5e3 });
|
|
124255
|
+
return parseAdbReverses(stdout);
|
|
124256
|
+
}
|
|
124257
|
+
|
|
124258
|
+
// ../tool-server/src/blueprints/android-network-shaper.ts
|
|
124259
|
+
var ANDROID_NETWORK_SHAPER_NAMESPACE = "AndroidNetworkShaper";
|
|
124260
|
+
function androidNetworkShaperRef(serial) {
|
|
124261
|
+
return `${ANDROID_NETWORK_SHAPER_NAMESPACE}:${serial}`;
|
|
124262
|
+
}
|
|
124263
|
+
function isLoopback(host) {
|
|
124264
|
+
return host === "localhost" || host === "::1" || host.startsWith("127.");
|
|
124265
|
+
}
|
|
124266
|
+
async function resolveDeviceTarget(serial, host, port) {
|
|
124267
|
+
if (host === EMULATOR_HOST_ALIAS) return { host: "127.0.0.1", port };
|
|
124268
|
+
if (!isLoopback(host)) return { host, port };
|
|
124269
|
+
const hostPort = (await listAdbReverses(serial)).get(port);
|
|
124270
|
+
return hostPort === void 0 ? null : { host: "localhost", port: hostPort };
|
|
124271
|
+
}
|
|
124272
|
+
var androidNetworkShaperBlueprint = {
|
|
124273
|
+
namespace: ANDROID_NETWORK_SHAPER_NAMESPACE,
|
|
124274
|
+
getURN(serial) {
|
|
124275
|
+
return androidNetworkShaperRef(serial);
|
|
124276
|
+
},
|
|
124277
|
+
async factory(_deps, serial) {
|
|
124278
|
+
let metroPort2 = 0;
|
|
124279
|
+
let proxyOnDevice = false;
|
|
124280
|
+
const locks = /* @__PURE__ */ new Map();
|
|
124281
|
+
const proxy = await startShapingProxy({
|
|
124282
|
+
resolveTarget: (host, port) => resolveDeviceTarget(serial, host, port),
|
|
124283
|
+
bypass: (host, port) => port === metroPort2 && (host === EMULATOR_HOST_ALIAS || isLoopback(host))
|
|
124284
|
+
});
|
|
124285
|
+
const clear = async () => {
|
|
124286
|
+
proxy.setConditions(null);
|
|
124287
|
+
await clearArgentProxy(serial);
|
|
124288
|
+
proxyOnDevice = false;
|
|
124289
|
+
};
|
|
124290
|
+
const api = {
|
|
124291
|
+
throttle: (conditions, port) => withKeyedLock(locks, serial, async () => {
|
|
124292
|
+
metroPort2 = port;
|
|
124293
|
+
proxy.setConditions(conditions);
|
|
124294
|
+
proxyOnDevice = true;
|
|
124295
|
+
await setArgentProxy(serial, proxy.port);
|
|
124296
|
+
}),
|
|
124297
|
+
clear: () => withKeyedLock(locks, serial, clear)
|
|
124298
|
+
};
|
|
124299
|
+
const removeProxyOnStop = async () => {
|
|
124300
|
+
if (proxyOnDevice) await clear();
|
|
124301
|
+
};
|
|
124302
|
+
const dispose = async () => {
|
|
124303
|
+
await withKeyedLock(locks, serial, removeProxyOnStop).catch((err) => {
|
|
124304
|
+
process.stderr.write(
|
|
124305
|
+
`[${ANDROID_NETWORK_SHAPER_NAMESPACE}:${serial}] could not remove the proxy: ${String(err)}
|
|
124306
|
+
`
|
|
124307
|
+
);
|
|
124308
|
+
});
|
|
124309
|
+
await proxy.close();
|
|
124310
|
+
};
|
|
124311
|
+
return { api, dispose, events: new TypedEventEmitter() };
|
|
124312
|
+
}
|
|
124313
|
+
};
|
|
124314
|
+
|
|
123621
124315
|
// ../tool-server/src/tools/native-devtools/native-devtools-status.ts
|
|
123622
124316
|
init_zod();
|
|
123623
124317
|
init_device_info();
|
|
@@ -125335,7 +126029,7 @@ var DISABLE_LOGBOX_SCRIPT = `(function() {
|
|
|
125335
126029
|
|
|
125336
126030
|
// ../tool-server/src/blueprints/js-runtime-debugger.ts
|
|
125337
126031
|
init_wrapper();
|
|
125338
|
-
var
|
|
126032
|
+
var http5 = __toESM(require("node:http"));
|
|
125339
126033
|
var JS_RUNTIME_DEBUGGER_NAMESPACE = "JsRuntimeDebugger";
|
|
125340
126034
|
function unconfirmedMatchError(deviceId, port, deviceName, where, targets) {
|
|
125341
126035
|
const listed = [
|
|
@@ -125373,7 +126067,7 @@ function formatConsoleArgs2(params) {
|
|
|
125373
126067
|
}
|
|
125374
126068
|
function createConsoleLogServer2(consoleEvents, logWriter) {
|
|
125375
126069
|
return new Promise((resolve21, reject) => {
|
|
125376
|
-
const server =
|
|
126070
|
+
const server = http5.createServer();
|
|
125377
126071
|
const wss = new import_websocket_server.default({ server });
|
|
125378
126072
|
wss.on("connection", (ws) => {
|
|
125379
126073
|
for (const entry of logWriter.readAll()) {
|
|
@@ -128148,10 +128842,10 @@ function electronGuiChildEnv(overrides = {}) {
|
|
|
128148
128842
|
}
|
|
128149
128843
|
|
|
128150
128844
|
// ../tool-server/src/utils/free-port.ts
|
|
128151
|
-
var
|
|
128845
|
+
var net11 = __toESM(require("node:net"));
|
|
128152
128846
|
async function pickFreePort() {
|
|
128153
128847
|
return new Promise((resolve21, reject) => {
|
|
128154
|
-
const srv =
|
|
128848
|
+
const srv = net11.createServer();
|
|
128155
128849
|
srv.unref();
|
|
128156
128850
|
srv.on("error", reject);
|
|
128157
128851
|
srv.listen(0, "127.0.0.1", () => {
|
|
@@ -135342,13 +136036,11 @@ var networkConditionsZodSchema = external_exports.object({
|
|
|
135342
136036
|
),
|
|
135343
136037
|
bundleId: external_exports.string().min(1).optional().describe("iOS only, and required there: the bundle id of the app to throttle."),
|
|
135344
136038
|
port: metroPortField.describe(
|
|
135345
|
-
"iOS
|
|
135346
|
-
),
|
|
135347
|
-
latencyMs: external_exports.number().int().min(0).max(6e4).optional().describe(
|
|
135348
|
-
"Minimum time in milliseconds from sending a request to its response. iOS and Chromium only."
|
|
136039
|
+
"iOS and Android: the Metro port the throttle leaves alone. Omit it to use this device's port (8081 by default)."
|
|
135349
136040
|
),
|
|
135350
|
-
|
|
135351
|
-
|
|
136041
|
+
latencyMs: external_exports.number().int().min(0).max(6e4).optional().describe("Minimum time in milliseconds from sending a request to its response."),
|
|
136042
|
+
downloadKbps: external_exports.number().int().min(1).optional().describe("Download limit in kilobits per second."),
|
|
136043
|
+
uploadKbps: external_exports.number().int().min(1).optional().describe("Upload limit in kilobits per second."),
|
|
135352
136044
|
offline: external_exports.boolean().optional().describe(
|
|
135353
136045
|
"Make requests fail as if the network were down. On Android, ports forwarded with adb reverse stay reachable."
|
|
135354
136046
|
)
|
|
@@ -135437,12 +136129,14 @@ var iosImpl5 = {
|
|
|
135437
136129
|
// ../tool-server/src/tools/network-conditions/platforms/android.ts
|
|
135438
136130
|
init_src2();
|
|
135439
136131
|
init_adb();
|
|
136132
|
+
init_external_devices();
|
|
135440
136133
|
var NETWORK_UP_TIMEOUT_MS = 15e3;
|
|
135441
136134
|
var NETWORK_DOWN_TIMEOUT_MS = 15e3;
|
|
135442
136135
|
var NETWORK_POLL_MS = 500;
|
|
135443
|
-
|
|
136136
|
+
var transitionLocks = /* @__PURE__ */ new Map();
|
|
136137
|
+
function providerEmulator() {
|
|
135444
136138
|
return new FailureError(
|
|
135445
|
-
"On an
|
|
136139
|
+
"On an emulator from a device provider network-conditions supports only `offline`. Argent throttles an emulator through a proxy on this machine, which a provider's emulator may not reach.",
|
|
135446
136140
|
{
|
|
135447
136141
|
error_code: FAILURE_CODES.TOOL_INPUT_INVALID,
|
|
135448
136142
|
failure_stage: "network_conditions_params",
|
|
@@ -135526,21 +136220,32 @@ async function goOffline(serial) {
|
|
|
135526
136220
|
await setRadios(serial, true);
|
|
135527
136221
|
throw ethernet ? networkStayedUp(serial) : networkDidNotDrop(serial);
|
|
135528
136222
|
}
|
|
136223
|
+
var shapesTraffic2 = (conditions) => Boolean(conditions.latencyMs || conditions.downloadKbps || conditions.uploadKbps);
|
|
136224
|
+
async function turnRadiosOn(serial) {
|
|
136225
|
+
if (await readNetworkState(serial) === "online") return;
|
|
136226
|
+
await setRadios(serial, true);
|
|
136227
|
+
await waitForNetwork(serial);
|
|
136228
|
+
}
|
|
136229
|
+
async function applyConditions(services, params) {
|
|
136230
|
+
const serial = params.udid;
|
|
136231
|
+
const conditions = requestedConditions(params);
|
|
136232
|
+
const shaper = services.networkShaper;
|
|
136233
|
+
if (conditions?.offline) {
|
|
136234
|
+
await shaper.clear();
|
|
136235
|
+
await goOffline(serial);
|
|
136236
|
+
} else if (conditions && shapesTraffic2(conditions)) {
|
|
136237
|
+
if (externalClaimForAnyId(serial)) throw providerEmulator();
|
|
136238
|
+
await turnRadiosOn(serial);
|
|
136239
|
+
await shaper.throttle(conditions, metroPort({ device_id: serial, port: params.port }));
|
|
136240
|
+
} else {
|
|
136241
|
+
await shaper.clear();
|
|
136242
|
+
await turnRadiosOn(serial);
|
|
136243
|
+
}
|
|
136244
|
+
return { scope: "device", conditions };
|
|
136245
|
+
}
|
|
135529
136246
|
var androidImpl7 = {
|
|
135530
136247
|
requires: ["adb"],
|
|
135531
|
-
|
|
135532
|
-
const serial = params.udid;
|
|
135533
|
-
const conditions = requestedConditions(params);
|
|
135534
|
-
const offlineOnly = conditions?.offline === true && Object.keys(conditions).length === 1;
|
|
135535
|
-
if (conditions && !offlineOnly) throw onlyOfflineSupported();
|
|
135536
|
-
if (conditions) {
|
|
135537
|
-
await goOffline(serial);
|
|
135538
|
-
} else if (await readNetworkState(serial) !== "online") {
|
|
135539
|
-
await setRadios(serial, true);
|
|
135540
|
-
await waitForNetwork(serial);
|
|
135541
|
-
}
|
|
135542
|
-
return { scope: "device", conditions };
|
|
135543
|
-
}
|
|
136248
|
+
handler: (services, params) => withKeyedLock(transitionLocks, params.udid, () => applyConditions(services, params))
|
|
135544
136249
|
};
|
|
135545
136250
|
|
|
135546
136251
|
// ../tool-server/src/tools/network-conditions/platforms/chromium.ts
|
|
@@ -135564,7 +136269,7 @@ var networkConditionsTool = {
|
|
|
135564
136269
|
Use to test loading states, timeouts, retries and offline handling. Each call replaces the previous conditions. Call it with no condition (only udid, plus bundleId on iOS) to remove the throttle.
|
|
135565
136270
|
Returns { scope, conditions }. scope names what was shaped:
|
|
135566
136271
|
- "app" on an iOS simulator: only the app named by bundleId, a non-Apple app with native devtools connected. Shapes its http/https URLSession requests, except WebSockets and requests to the Metro port (port). The server gets each request at once: Argent delays what the app receives. Argent applies the conditions again when the app restarts and reconnects; the app drops them when the tool-server stops. If status is restart_required, service_stale, connect_pending or init_failed, follow the message as for native-network-logs.
|
|
135567
|
-
- "device" on an Android emulator:
|
|
136272
|
+
- "device" on an Android emulator: Argent points the emulator's global HTTP proxy at its own proxy on the host, which adds latencyMs to every round trip (a new HTTPS connection pays it several times) and caps the total speed of http/https requests and WebSockets. Not shaped: the Metro port (port), raw sockets, UDP, QUIC, DNS, apps that ignore the system proxy (such as Flutter dart:io) and connections opened before the call until they close (restart the app to shape all of them). A localhost request without adb reverse fails with 502 while throttled. Fails when the emulator has a proxy Argent did not set. A reset or a tool-server stop removes the proxy; after a crash apps cannot connect until a reset. offline removes the proxy and turns Wi-Fi and mobile data off, and fails on an emulator that keeps a network (an Android TV emulator uses Ethernet); adb reverse ports stay reachable and an app that reaches Metro at 10.0.2.2 loses it. Any call other than offline turns both radios on when no network is up and fails if none comes up within 15 s.
|
|
135568
136273
|
- "tab" on Chromium: requests of the active tab's page, not its workers, service workers or cross-site iframes. Argent applies the conditions again after a tab switch and before a tab opened by chromium-tabs loads.
|
|
135569
136274
|
conditions is null after a reset. Fails on a physical iOS or Android device.`,
|
|
135570
136275
|
zodSchema: networkConditionsZodSchema,
|
|
@@ -135580,6 +136285,8 @@ conditions is null after a reset. Fails on a physical iOS or Android device.`,
|
|
|
135580
136285
|
if (device.platform === "chromium") return { chromium: chromiumCdpRef(device) };
|
|
135581
136286
|
if (device.platform === "ios" && device.kind === "simulator")
|
|
135582
136287
|
return { nativeDevtools: nativeDevtoolsRef(device) };
|
|
136288
|
+
if (device.platform === "android" && device.kind === "emulator")
|
|
136289
|
+
return { networkShaper: androidNetworkShaperRef(device.id) };
|
|
135583
136290
|
return {};
|
|
135584
136291
|
},
|
|
135585
136292
|
execute: dispatchByPlatform({
|
|
@@ -135887,10 +136594,10 @@ function classifyHingeRefusal(err, known) {
|
|
|
135887
136594
|
);
|
|
135888
136595
|
}
|
|
135889
136596
|
function hingeRequest(params) {
|
|
135890
|
-
const
|
|
135891
|
-
if (params.posture !== void 0)
|
|
135892
|
-
if (params.angle !== void 0)
|
|
135893
|
-
return
|
|
136597
|
+
const request4 = {};
|
|
136598
|
+
if (params.posture !== void 0) request4.posture = params.posture;
|
|
136599
|
+
if (params.angle !== void 0) request4.angle = params.angle;
|
|
136600
|
+
return request4;
|
|
135894
136601
|
}
|
|
135895
136602
|
function targetLabel2(params) {
|
|
135896
136603
|
return params.posture ?? `${params.angle}\xB0`;
|
|
@@ -135926,15 +136633,15 @@ var iosImpl6 = {
|
|
|
135926
136633
|
const known = await fetchDisplayState(api, signal) ?? api.display;
|
|
135927
136634
|
const before = known?.foldable ? await resolveLivePanel(udid) : null;
|
|
135928
136635
|
const beforeScreen = before && before.source !== "unknown" ? before.screen : void 0;
|
|
135929
|
-
const
|
|
136636
|
+
const request4 = hingeRequest(params);
|
|
135930
136637
|
let start2;
|
|
135931
136638
|
if (known && beforeScreen !== void 0) {
|
|
135932
136639
|
start2 = sweepStartFor(known.hingeAngle, beforeScreen, known.panels);
|
|
135933
|
-
if (start2 !== void 0)
|
|
136640
|
+
if (start2 !== void 0) request4.from = start2;
|
|
135934
136641
|
}
|
|
135935
136642
|
let display;
|
|
135936
136643
|
try {
|
|
135937
|
-
display = await postHinge(api,
|
|
136644
|
+
display = await postHinge(api, request4, signal);
|
|
135938
136645
|
} catch (err) {
|
|
135939
136646
|
throw classifyHingeRefusal(err, known);
|
|
135940
136647
|
}
|
|
@@ -138739,15 +139446,15 @@ async function nativeRequestDetails(record2, bodies, includeBody) {
|
|
|
138739
139446
|
const { wireHeaders } = record2.request;
|
|
138740
139447
|
const bodyHeaders = record2.redirects?.[0]?.requestHeaders ?? wireHeaders ?? {};
|
|
138741
139448
|
const requestHeader = (name) => headerValue(bodyHeaders, name) || headerValue(record2.request.headers, name);
|
|
138742
|
-
const
|
|
139449
|
+
const request4 = {
|
|
138743
139450
|
url: record2.request.url,
|
|
138744
139451
|
method: record2.request.method,
|
|
138745
139452
|
headers: redactHeaders(wireHeaders ?? record2.request.headers)
|
|
138746
139453
|
};
|
|
138747
139454
|
const headersNote = requestHeadersNote(record2);
|
|
138748
|
-
if (headersNote)
|
|
139455
|
+
if (headersNote) request4.headersNote = headersNote;
|
|
138749
139456
|
if (record2.request.hasPostData) {
|
|
138750
|
-
|
|
139457
|
+
request4.postData = await readNativeBody(() => bodies.requestPostData(record2.id), {
|
|
138751
139458
|
contentType: requestHeader("content-type"),
|
|
138752
139459
|
contentEncoding: requestHeader("content-encoding"),
|
|
138753
139460
|
wholeSize: sizeInBytes(
|
|
@@ -138763,7 +139470,7 @@ async function nativeRequestDetails(record2, bodies, includeBody) {
|
|
|
138763
139470
|
durationMs: record2.timing.durationMs,
|
|
138764
139471
|
encodedDataLength: record2.encodedDataLength,
|
|
138765
139472
|
errorText: record2.errorText,
|
|
138766
|
-
request:
|
|
139473
|
+
request: request4
|
|
138767
139474
|
};
|
|
138768
139475
|
if (record2.redirects?.length) {
|
|
138769
139476
|
details.redirects = record2.redirects.map((hop) => ({
|
|
@@ -150102,9 +150809,9 @@ function deviceUnavailable(message, error_kind) {
|
|
|
150102
150809
|
error_kind
|
|
150103
150810
|
});
|
|
150104
150811
|
}
|
|
150105
|
-
async function selectDevice(
|
|
150812
|
+
async function selectDevice(request4, onProgress, signal) {
|
|
150106
150813
|
const devices2 = await listIosPhysicalDevices();
|
|
150107
|
-
const selected =
|
|
150814
|
+
const selected = request4.deviceId ? devices2.find((device) => device.udid === request4.deviceId) : void 0;
|
|
150108
150815
|
if (selected && selected.transportType !== "wired") {
|
|
150109
150816
|
throw deviceUnavailable(
|
|
150110
150817
|
`iPhone ${selected.udid} is not connected by USB cable (transport: ${selected.transportType ?? "none"}). Launch measurement runs over the cable; connect it and retry.`,
|
|
@@ -150122,20 +150829,20 @@ async function selectDevice(request3, onProgress, signal) {
|
|
|
150122
150829
|
destination: `platform=iOS,id=${selected.udid}`
|
|
150123
150830
|
};
|
|
150124
150831
|
}
|
|
150125
|
-
if (physical.length > 0 && !
|
|
150832
|
+
if (physical.length > 0 && !request4.deviceId) {
|
|
150126
150833
|
throw deviceUnavailable(
|
|
150127
|
-
`Connected iPhones: ${physical.map((d) => d.udid).join(", ")}. Pass device_id to select one.` + (
|
|
150834
|
+
`Connected iPhones: ${physical.map((d) => d.udid).join(", ")}. Pass device_id to select one.` + (request4.allowSimulator ? " To use a booted simulator while an iPhone is connected, pass the simulator's UDID as device_id." : ""),
|
|
150128
150835
|
"validation"
|
|
150129
150836
|
);
|
|
150130
150837
|
}
|
|
150131
|
-
if (!
|
|
150838
|
+
if (!request4.allowSimulator) {
|
|
150132
150839
|
throw deviceUnavailable(
|
|
150133
150840
|
"No selected connected iPhone is available. Connect and unlock one, pass device_id, or explicitly set allow_simulator. Simulator launch timings reflect Mac hardware rather than a physical iPhone.",
|
|
150134
150841
|
"not_found"
|
|
150135
150842
|
);
|
|
150136
150843
|
}
|
|
150137
150844
|
const all = (await listIosSimulators()).filter((device) => device.runtimeKind !== "tv");
|
|
150138
|
-
const requested =
|
|
150845
|
+
const requested = request4.deviceId ? all.find((device) => device.udid === request4.deviceId) : void 0;
|
|
150139
150846
|
if (requested && requested.state !== "Booted") {
|
|
150140
150847
|
throw deviceUnavailable(
|
|
150141
150848
|
`Simulator ${requested.udid} is not booted (state: ${requested.state}). Boot it with boot-device, then retry.`,
|
|
@@ -150149,11 +150856,11 @@ async function selectDevice(request3, onProgress, signal) {
|
|
|
150149
150856
|
);
|
|
150150
150857
|
}
|
|
150151
150858
|
const simulators = all.filter((device) => device.state === "Booted" && !device.deviceSet);
|
|
150152
|
-
const simulator =
|
|
150859
|
+
const simulator = request4.deviceId ? simulators.find((device) => device.udid === request4.deviceId) : simulators.length === 1 ? simulators[0] : void 0;
|
|
150153
150860
|
if (!simulator) {
|
|
150154
150861
|
throw deviceUnavailable(
|
|
150155
|
-
|
|
150156
|
-
|
|
150862
|
+
request4.deviceId ? `No connected iPhone or booted simulator has the UDID ${request4.deviceId}.` : "Boot a single iOS simulator or select one with device_id.",
|
|
150863
|
+
request4.deviceId || simulators.length === 0 ? "not_found" : "validation"
|
|
150157
150864
|
);
|
|
150158
150865
|
}
|
|
150159
150866
|
return {
|
|
@@ -150203,7 +150910,7 @@ async function findInstalledApp(device, bundleId, signal) {
|
|
|
150203
150910
|
throw simctlFailure(error63, "launch_analysis_find_app");
|
|
150204
150911
|
}
|
|
150205
150912
|
}
|
|
150206
|
-
async function prepareLaunch(
|
|
150913
|
+
async function prepareLaunch(request4, onProgress, signal) {
|
|
150207
150914
|
signal?.throwIfAborted();
|
|
150208
150915
|
if (process.platform !== "darwin")
|
|
150209
150916
|
throw new FailureError("iOS launch measurement requires macOS and Xcode.", {
|
|
@@ -150212,8 +150919,8 @@ async function prepareLaunch(request3, onProgress, signal) {
|
|
|
150212
150919
|
failure_area: "tool_server",
|
|
150213
150920
|
error_kind: "unsupported"
|
|
150214
150921
|
});
|
|
150215
|
-
const device = await selectDevice(
|
|
150216
|
-
await
|
|
150922
|
+
const device = await selectDevice(request4, onProgress, signal);
|
|
150923
|
+
await request4.checkDevice?.(device);
|
|
150217
150924
|
const simctl = simctlPrefix(device.deviceSet);
|
|
150218
150925
|
if (device.simulator) {
|
|
150219
150926
|
await runSimctl(
|
|
@@ -150223,16 +150930,16 @@ async function prepareLaunch(request3, onProgress, signal) {
|
|
|
150223
150930
|
BOOTSTATUS_TIMEOUT_MS
|
|
150224
150931
|
);
|
|
150225
150932
|
}
|
|
150226
|
-
const appPath = await findInstalledApp(device,
|
|
150933
|
+
const appPath = await findInstalledApp(device, request4.bundleId, signal);
|
|
150227
150934
|
if (device.simulator) {
|
|
150228
150935
|
await runSimctl(
|
|
150229
|
-
[...simctl, "launch", device.id,
|
|
150936
|
+
[...simctl, "launch", device.id, request4.bundleId],
|
|
150230
150937
|
"launch_analysis_simulator_prelaunch",
|
|
150231
150938
|
signal
|
|
150232
150939
|
);
|
|
150233
150940
|
} else {
|
|
150234
150941
|
await waitForDeviceAction(
|
|
150235
|
-
() => launchApp(device.id,
|
|
150942
|
+
() => launchApp(device.id, request4.bundleId, { terminateExisting: true }),
|
|
150236
150943
|
onProgress,
|
|
150237
150944
|
signal
|
|
150238
150945
|
);
|
|
@@ -150245,7 +150952,7 @@ async function prepareLaunch(request3, onProgress, signal) {
|
|
|
150245
150952
|
simulator: device.simulator,
|
|
150246
150953
|
simulatorDeviceSet: device.deviceSet,
|
|
150247
150954
|
destination: device.destination,
|
|
150248
|
-
bundleId:
|
|
150955
|
+
bundleId: request4.bundleId,
|
|
150249
150956
|
appPath,
|
|
150250
150957
|
warning: device.simulator ? "Simulator timings reflect Mac hardware; validate performance on a physical iPhone." : null
|
|
150251
150958
|
};
|
|
@@ -155840,6 +156547,7 @@ var DEVICE_OWNED_NAMESPACES = [
|
|
|
155840
156547
|
IOS_DEVICE_RUNNER_NAMESPACE,
|
|
155841
156548
|
NATIVE_DEVTOOLS_NAMESPACE,
|
|
155842
156549
|
ANDROID_DEVTOOLS_NAMESPACE,
|
|
156550
|
+
ANDROID_NETWORK_SHAPER_NAMESPACE,
|
|
155843
156551
|
CHROMIUM_CDP_NAMESPACE,
|
|
155844
156552
|
CHROMIUM_JS_RUNTIME_DEBUGGER_NAMESPACE,
|
|
155845
156553
|
TV_CONTROL_NAMESPACE,
|
|
@@ -155959,7 +156667,7 @@ var zodSchema66 = external_exports.object({
|
|
|
155959
156667
|
function createStopAllSimulatorServersTool(registry2) {
|
|
155960
156668
|
return {
|
|
155961
156669
|
id: "stop-all-simulator-servers",
|
|
155962
|
-
description: `Stop the services a device owns - simulator-server processes (iOS + Android), native devtools, the iOS accessibility service, TV-control daemons, Chromium CDP sessions, screen recordings, native profiler sessions, native network capture with the requests it recorded, and JS-runtime debugger sessions along with the network inspectors and React profiler sessions that ride on them - freeing their spawned processes, sockets and ports. Network capture started by network-capture-start ends here too, with the requests it recorded, except in a JS runtime this call does not reach, for example after Metro restarted: this call does not connect to it again, so its JS capture keeps recording and keeps its requests, and the result does not say so. A later network-capture-stop that reaches that runtime stops the recording. Call this when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services mid-flow - not just because a task finished, since the next task reuses these services and would start cold again. To stop the network capture of one app and keep its requests, call network-capture-stop instead.
|
|
156670
|
+
description: `Stop the services a device owns - simulator-server processes (iOS + Android), native devtools, the iOS accessibility service, TV-control daemons, Chromium CDP sessions, screen recordings, native profiler sessions, native network capture with the requests it recorded, the Android network throttle proxy (set by network-conditions), and JS-runtime debugger sessions along with the network inspectors and React profiler sessions that ride on them - freeing their spawned processes, sockets and ports. Network capture started by network-capture-start ends here too, with the requests it recorded, except in a JS runtime this call does not reach, for example after Metro restarted: this call does not connect to it again, so its JS capture keeps recording and keeps its requests, and the result does not say so. A later network-capture-stop that reaches that runtime stops the recording. Call this when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services mid-flow - not just because a task finished, since the next task reuses these services and would start cold again. To stop the network capture of one app and keep its requests, call network-capture-stop instead.
|
|
155963
156671
|
PASS \`devices\` with the device ids this session used: one tool-server serves every agent, subagent and CLI call using this argent install, and an unscoped call tears down THEIR devices too. Omit \`devices\` only when a machine-wide cleanup is what you actually want. An EMPTY array stops nothing; it does not ask for the machine-wide sweep.
|
|
155964
156672
|
A JS-runtime debugger session is keyed by the id you called \`debugger-connect\` with. On a Metro serving two or more devices that id can be a \`logicalDeviceId\`: connect refuses a udid or serial it cannot match to one Metro device by name, and tells you to re-target with the \`logicalDeviceId\` it returns. A scope built from \`list-devices\` ids cannot reach that session. Pass any such \`logicalDeviceId\` in \`devices\` ALONGSIDE the device id.
|
|
155965
156673
|
Returns { stopped }: the URNs of the live services that were shut down; empty means nothing was still running. { unmatched }, present only when a supplied id owns no service here, lists those ids, so a typo or a device NAME passed instead of an id does not read as a clean machine. It is NOT proof the id is wrong: a Vega device you only booted and drove with the remote registers no service and lands here, as does any device this session never started anything on. { left_running } lists the URNs of live debugger sessions (and the network inspectors / React profiler sessions riding on them) whose id no device scope can name; re-call with the id after each URN's \`<namespace>:<port>:\` prefix to reap them. { aborted: true } means the request was cancelled part-way: the rest was left untouched and \`unmatched\` / \`left_running\` were not computed.
|
|
@@ -162610,13 +163318,13 @@ var FlowScriptExecutor = class {
|
|
|
162610
163318
|
this.typeStripping ??= probeTypeStripping(this.options.nodeOptions ?? []);
|
|
162611
163319
|
return this.typeStripping;
|
|
162612
163320
|
}
|
|
162613
|
-
async execute(
|
|
163321
|
+
async execute(request4) {
|
|
162614
163322
|
const bounds = this.resolveBounds();
|
|
162615
163323
|
const queueStarted = Date.now();
|
|
162616
163324
|
let release2;
|
|
162617
163325
|
try {
|
|
162618
163326
|
release2 = await this.acquireSlot(
|
|
162619
|
-
|
|
163327
|
+
request4.signal,
|
|
162620
163328
|
Math.min(MAX_TIMER_MS, positive(this.options.queueWaitMs) ?? bounds.maxTimeoutMs * 2)
|
|
162621
163329
|
);
|
|
162622
163330
|
} catch (err) {
|
|
@@ -162625,7 +163333,7 @@ var FlowScriptExecutor = class {
|
|
|
162625
163333
|
}
|
|
162626
163334
|
const queuedMs = Date.now() - queueStarted;
|
|
162627
163335
|
try {
|
|
162628
|
-
const result = await this.runOne(
|
|
163336
|
+
const result = await this.runOne(request4, bounds);
|
|
162629
163337
|
result.queuedMs = queuedMs;
|
|
162630
163338
|
if (queuedMs > QUEUE_WAIT_REPORT_MS) {
|
|
162631
163339
|
result.notes.push(
|
|
@@ -162712,10 +163420,10 @@ var FlowScriptExecutor = class {
|
|
|
162712
163420
|
waiter.grant();
|
|
162713
163421
|
}
|
|
162714
163422
|
}
|
|
162715
|
-
async runOne(
|
|
163423
|
+
async runOne(request4, bounds) {
|
|
162716
163424
|
const notes = [];
|
|
162717
163425
|
const startedAt = Date.now();
|
|
162718
|
-
if (
|
|
163426
|
+
if (request4.signal?.aborted) {
|
|
162719
163427
|
return emptyResult(
|
|
162720
163428
|
{ kind: "cancelled", message: "The run was cancelled before the script started." },
|
|
162721
163429
|
{ notes }
|
|
@@ -162726,10 +163434,10 @@ var FlowScriptExecutor = class {
|
|
|
162726
163434
|
let runnerPath;
|
|
162727
163435
|
let outputJson;
|
|
162728
163436
|
try {
|
|
162729
|
-
cwd = resolveWorkingDirectory(
|
|
162730
|
-
env = buildChildEnv(
|
|
162731
|
-
runnerPath = resolveRunnerPath(
|
|
162732
|
-
outputJson = encodeRequestOutput(
|
|
163437
|
+
cwd = resolveWorkingDirectory(request4, notes);
|
|
163438
|
+
env = buildChildEnv(request4.env);
|
|
163439
|
+
runnerPath = resolveRunnerPath(request4.runnerDir);
|
|
163440
|
+
outputJson = encodeRequestOutput(request4.output);
|
|
162733
163441
|
} catch (err) {
|
|
162734
163442
|
const kind = err instanceof ScriptSetupError ? err.kind : "spawn";
|
|
162735
163443
|
return emptyResult(
|
|
@@ -162737,13 +163445,13 @@ var FlowScriptExecutor = class {
|
|
|
162737
163445
|
{ notes, durationMs: Date.now() - startedAt }
|
|
162738
163446
|
);
|
|
162739
163447
|
}
|
|
162740
|
-
const timeoutMs = clampTimeout(
|
|
163448
|
+
const timeoutMs = clampTimeout(request4.timeoutMs, bounds.maxTimeoutMs, notes);
|
|
162741
163449
|
const capture = new ScriptLogCapture(
|
|
162742
|
-
() =>
|
|
163450
|
+
() => request4.secrets ?? [],
|
|
162743
163451
|
SCRIPT_STEP_LOG_LIMIT_BYTES,
|
|
162744
|
-
|
|
163452
|
+
request4.logBudget
|
|
162745
163453
|
);
|
|
162746
|
-
const scriptPath = realPathOrSelf(path61.resolve(cwd,
|
|
163454
|
+
const scriptPath = realPathOrSelf(path61.resolve(cwd, request4.scriptPath));
|
|
162747
163455
|
let child;
|
|
162748
163456
|
try {
|
|
162749
163457
|
const forkOptions = {
|
|
@@ -162844,8 +163552,8 @@ var FlowScriptExecutor = class {
|
|
|
162844
163552
|
const deadlineAt = Date.now() + timeoutMs;
|
|
162845
163553
|
const timer = setTimeout(() => interrupt("timeout"), timeoutMs);
|
|
162846
163554
|
const onAbort = () => interrupt("cancelled");
|
|
162847
|
-
|
|
162848
|
-
if (
|
|
163555
|
+
request4.signal?.addEventListener("abort", onAbort, { once: true });
|
|
163556
|
+
if (request4.signal?.aborted) onAbort();
|
|
162849
163557
|
const message = {
|
|
162850
163558
|
type: "execute",
|
|
162851
163559
|
scriptUrl: (0, import_node_url3.pathToFileURL)(scriptPath).href,
|
|
@@ -162866,7 +163574,7 @@ var FlowScriptExecutor = class {
|
|
|
162866
163574
|
const exit = await exited;
|
|
162867
163575
|
const deadlinePassed = Date.now() >= deadlineAt;
|
|
162868
163576
|
clearTimeout(timer);
|
|
162869
|
-
|
|
163577
|
+
request4.signal?.removeEventListener("abort", onAbort);
|
|
162870
163578
|
await Promise.race([closed, sleep(SETTLE_TIMEOUT_MS4)]);
|
|
162871
163579
|
await stop();
|
|
162872
163580
|
capture.end();
|
|
@@ -162888,7 +163596,7 @@ var FlowScriptExecutor = class {
|
|
|
162888
163596
|
heapFatalSeen: capture.heapFatalSeen,
|
|
162889
163597
|
heapLimitMb: bounds.heapLimitMb
|
|
162890
163598
|
}),
|
|
162891
|
-
|
|
163599
|
+
request4.secrets ?? []
|
|
162892
163600
|
);
|
|
162893
163601
|
return {
|
|
162894
163602
|
...verdict,
|
|
@@ -163091,10 +163799,10 @@ function describeExit(exit) {
|
|
|
163091
163799
|
if (exit.signal) return `signal ${exit.signal}`;
|
|
163092
163800
|
return `exit code ${exit.code ?? 0}`;
|
|
163093
163801
|
}
|
|
163094
|
-
function resolveWorkingDirectory(
|
|
163802
|
+
function resolveWorkingDirectory(request4, notes) {
|
|
163095
163803
|
const candidates = [
|
|
163096
|
-
{ label: "project_root", value:
|
|
163097
|
-
{ label: "the e2e test file's directory", value:
|
|
163804
|
+
{ label: "project_root", value: request4.projectRoot },
|
|
163805
|
+
{ label: "the e2e test file's directory", value: request4.flowDir }
|
|
163098
163806
|
];
|
|
163099
163807
|
const named = candidates.filter((c) => c.value);
|
|
163100
163808
|
const problems = [];
|
|
@@ -163558,8 +164266,8 @@ function describeDuration(ms3) {
|
|
|
163558
164266
|
}
|
|
163559
164267
|
|
|
163560
164268
|
// ../tool-server/src/tools/flows/flow-script-step.ts
|
|
163561
|
-
async function runFlowScriptStep(
|
|
163562
|
-
const { flowDir, step } =
|
|
164269
|
+
async function runFlowScriptStep(request4) {
|
|
164270
|
+
const { flowDir, step } = request4;
|
|
163563
164271
|
const target = step.path;
|
|
163564
164272
|
const { canonical, spelling } = await resolveFlowRelativeFile(
|
|
163565
164273
|
flowDir,
|
|
@@ -163595,14 +164303,14 @@ async function runFlowScriptStep(request3) {
|
|
|
163595
164303
|
scriptPath: canonical,
|
|
163596
164304
|
output: {},
|
|
163597
164305
|
...step.timeout !== void 0 ? { timeoutMs: step.timeout } : {},
|
|
163598
|
-
projectRoot:
|
|
164306
|
+
projectRoot: request4.projectRoot,
|
|
163599
164307
|
flowDir,
|
|
163600
164308
|
// No `secrets`: nothing resolves one into a script step yet, so there is
|
|
163601
164309
|
// nothing for the executor to redact out of the captured log.
|
|
163602
|
-
...
|
|
163603
|
-
...
|
|
164310
|
+
...request4.logBudget ? { logBudget: request4.logBudget } : {},
|
|
164311
|
+
...request4.signal ? { signal: request4.signal } : {}
|
|
163604
164312
|
});
|
|
163605
|
-
const roots = result.ok ? [] : [
|
|
164313
|
+
const roots = result.ok ? [] : [request4.projectRoot, await canonicalFlowPath(request4.projectRoot)];
|
|
163606
164314
|
const hostLimit = await typeScriptLoadRefusal(target, result, roots);
|
|
163607
164315
|
const verdict = hostLimit !== void 0 ? { status: "error", reason: [hostLimit, ...result.notes].join(" ") } : scriptVerdict(result);
|
|
163608
164316
|
const tail = result.ok || hostLimit !== void 0 ? "" : cjsRenameNote(result.failure, canonical) + scriptFrames(result.failure?.stack, roots);
|
|
@@ -170066,6 +170774,7 @@ function createRegistry() {
|
|
|
170066
170774
|
registry2.registerBlueprint(androidTvControlBlueprint);
|
|
170067
170775
|
registry2.registerBlueprint(macosAppBlueprint);
|
|
170068
170776
|
registry2.registerBlueprint(androidNetworkInspectorBlueprint);
|
|
170777
|
+
registry2.registerBlueprint(androidNetworkShaperBlueprint);
|
|
170069
170778
|
registry2.registerTool(listDevicesTool);
|
|
170070
170779
|
registry2.registerTool(createBootDeviceTool(registry2));
|
|
170071
170780
|
registry2.registerTool(createLaunchAppTool(registry2));
|
|
@@ -170164,10 +170873,10 @@ function createLensTools(registry2) {
|
|
|
170164
170873
|
}
|
|
170165
170874
|
|
|
170166
170875
|
// ../tool-server/src/utils/probe-argent-tool-server.ts
|
|
170167
|
-
var
|
|
170876
|
+
var http6 = __toESM(require("node:http"));
|
|
170168
170877
|
function probeArgentToolServer(host, port, timeoutMs = 500) {
|
|
170169
170878
|
return new Promise((resolve21) => {
|
|
170170
|
-
const req =
|
|
170879
|
+
const req = http6.request(
|
|
170171
170880
|
{ host, port, path: "/tools", method: "GET", timeout: timeoutMs },
|
|
170172
170881
|
(res) => {
|
|
170173
170882
|
const isArgentPeer = res.statusCode === 200 || res.statusCode === 401;
|