@swmansion/argent 0.35.1-next.73 → 0.35.1-next.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-cmds.mjs +50 -12
- package/dist/installer.mjs +1 -1
- package/dist/mcp-server.mjs +1 -1
- package/dist/tool-server.cjs +413 -274
- package/package.json +2 -2
package/dist/tool-server.cjs
CHANGED
|
@@ -22853,6 +22853,11 @@ function terminatingSignalCause(message) {
|
|
|
22853
22853
|
error_kind: "unknown"
|
|
22854
22854
|
});
|
|
22855
22855
|
}
|
|
22856
|
+
function serviceTerminatingError(urn) {
|
|
22857
|
+
return new ServiceInitializationError(urn, "Service is currently terminating", {
|
|
22858
|
+
cause: terminatingSignalCause("Service is currently terminating")
|
|
22859
|
+
});
|
|
22860
|
+
}
|
|
22856
22861
|
function valueAtPath(root, path78) {
|
|
22857
22862
|
let current = root;
|
|
22858
22863
|
for (const key2 of path78) {
|
|
@@ -22936,6 +22941,14 @@ var init_registry = __esm({
|
|
|
22936
22941
|
services = /* @__PURE__ */ new Map();
|
|
22937
22942
|
blueprints = /* @__PURE__ */ new Map();
|
|
22938
22943
|
tools = /* @__PURE__ */ new Map();
|
|
22944
|
+
/**
|
|
22945
|
+
* Teardowns of services that ended themselves without a fault, for example
|
|
22946
|
+
* after an idle window. A resolve that arrives during one waits for it and starts the
|
|
22947
|
+
* service again, unless `dispose` or `disposeService` is running.
|
|
22948
|
+
*/
|
|
22949
|
+
selfReleases = /* @__PURE__ */ new Map();
|
|
22950
|
+
disposeCalls = 0;
|
|
22951
|
+
disposingUrns = /* @__PURE__ */ new Set();
|
|
22939
22952
|
/** Alias → the id of the tool that declares it in `aliases`. */
|
|
22940
22953
|
toolAliases = /* @__PURE__ */ new Map();
|
|
22941
22954
|
/**
|
|
@@ -23142,13 +23155,28 @@ var init_registry = __esm({
|
|
|
23142
23155
|
async disposeService(urn) {
|
|
23143
23156
|
const node2 = this.services.get(urn);
|
|
23144
23157
|
if (!node2) throw new ServiceNotFoundError(urn);
|
|
23145
|
-
|
|
23158
|
+
const selfRelease = this.selfReleases.get(urn);
|
|
23159
|
+
if (!selfRelease) return this._teardown(urn);
|
|
23160
|
+
this.disposingUrns.add(urn);
|
|
23161
|
+
try {
|
|
23162
|
+
await selfRelease;
|
|
23163
|
+
await this._teardown(urn);
|
|
23164
|
+
} finally {
|
|
23165
|
+
this.disposingUrns.delete(urn);
|
|
23166
|
+
}
|
|
23146
23167
|
}
|
|
23147
23168
|
async dispose() {
|
|
23148
|
-
|
|
23149
|
-
|
|
23150
|
-
|
|
23169
|
+
this.disposeCalls++;
|
|
23170
|
+
try {
|
|
23171
|
+
for (const [urn, node2] of this.services) {
|
|
23172
|
+
const selfRelease = this.selfReleases.get(urn);
|
|
23173
|
+
if (selfRelease) await selfRelease;
|
|
23174
|
+
if (node2.state === "RUNNING" /* RUNNING */ || node2.state === "STARTING" /* STARTING */) {
|
|
23175
|
+
await this._teardown(urn);
|
|
23176
|
+
}
|
|
23151
23177
|
}
|
|
23178
|
+
} finally {
|
|
23179
|
+
this.disposeCalls--;
|
|
23152
23180
|
}
|
|
23153
23181
|
}
|
|
23154
23182
|
_resolve(urn, resolutionPath, options) {
|
|
@@ -23182,12 +23210,13 @@ var init_registry = __esm({
|
|
|
23182
23210
|
)
|
|
23183
23211
|
);
|
|
23184
23212
|
}
|
|
23213
|
+
const selfRelease = this.selfReleases.get(urn);
|
|
23214
|
+
if (selfRelease) {
|
|
23215
|
+
if (this._disposing(urn)) return Promise.reject(serviceTerminatingError(urn));
|
|
23216
|
+
return selfRelease.then(() => this._resolveAfterSelfRelease(urn, resolutionPath, options));
|
|
23217
|
+
}
|
|
23185
23218
|
if (node2.state === "TERMINATING" /* TERMINATING */) {
|
|
23186
|
-
return Promise.reject(
|
|
23187
|
-
new ServiceInitializationError(urn, "Service is currently terminating", {
|
|
23188
|
-
cause: terminatingSignalCause("Service is currently terminating")
|
|
23189
|
-
})
|
|
23190
|
-
);
|
|
23219
|
+
return Promise.reject(serviceTerminatingError(urn));
|
|
23191
23220
|
}
|
|
23192
23221
|
if (node2.state === "RUNNING" /* RUNNING */ && node2.instance) {
|
|
23193
23222
|
return Promise.resolve(node2.instance.api);
|
|
@@ -23225,7 +23254,9 @@ var init_registry = __esm({
|
|
|
23225
23254
|
this._transition(node2, "RUNNING" /* RUNNING */);
|
|
23226
23255
|
node2.instance = instance;
|
|
23227
23256
|
instance.events.on("terminated", (error63) => {
|
|
23228
|
-
|
|
23257
|
+
const selfRelease = !error63 && node2.state === "RUNNING" /* RUNNING */;
|
|
23258
|
+
const teardown = this._teardown(urn, error63);
|
|
23259
|
+
if (selfRelease) this._trackSelfRelease(urn, teardown);
|
|
23229
23260
|
});
|
|
23230
23261
|
return instance.api;
|
|
23231
23262
|
} catch (error63) {
|
|
@@ -23238,6 +23269,18 @@ var init_registry = __esm({
|
|
|
23238
23269
|
throw new ServiceInitializationError(urn, cause.message, { cause });
|
|
23239
23270
|
}
|
|
23240
23271
|
}
|
|
23272
|
+
_resolveAfterSelfRelease(urn, resolutionPath, options) {
|
|
23273
|
+
if (this._disposing(urn)) return Promise.reject(serviceTerminatingError(urn));
|
|
23274
|
+
return this._resolve(urn, resolutionPath, options);
|
|
23275
|
+
}
|
|
23276
|
+
_disposing(urn) {
|
|
23277
|
+
return this.disposeCalls > 0 || this.disposingUrns.has(urn);
|
|
23278
|
+
}
|
|
23279
|
+
_trackSelfRelease(urn, teardown) {
|
|
23280
|
+
this.selfReleases.set(urn, teardown);
|
|
23281
|
+
const forget2 = () => this.selfReleases.delete(urn);
|
|
23282
|
+
void teardown.then(forget2, forget2);
|
|
23283
|
+
}
|
|
23241
23284
|
_transition(node2, to, cause) {
|
|
23242
23285
|
const from2 = node2.state;
|
|
23243
23286
|
node2.state = to;
|
|
@@ -73314,7 +73357,7 @@ function isCi(env = process.env) {
|
|
|
73314
73357
|
var SESSION_ID = (0, import_node_crypto3.randomUUID)();
|
|
73315
73358
|
function readCliVersion() {
|
|
73316
73359
|
if (true) {
|
|
73317
|
-
return "0.35.1-next.
|
|
73360
|
+
return "0.35.1-next.74";
|
|
73318
73361
|
}
|
|
73319
73362
|
return "0.0.0";
|
|
73320
73363
|
}
|
|
@@ -81196,7 +81239,7 @@ function consumePendingSigningDetectionNote(udid) {
|
|
|
81196
81239
|
|
|
81197
81240
|
// ../tool-server/src/preview.ts
|
|
81198
81241
|
var import_node_fs11 = __toESM(require("node:fs"));
|
|
81199
|
-
var
|
|
81242
|
+
var import_node_os8 = __toESM(require("node:os"));
|
|
81200
81243
|
var import_node_path14 = __toESM(require("node:path"));
|
|
81201
81244
|
var import_express = __toESM(require_express2());
|
|
81202
81245
|
init_src();
|
|
@@ -100982,6 +101025,16 @@ function transportError(cmd, apiUrl, detail) {
|
|
|
100982
101025
|
COMMAND_TRANSPORT_FAILURE
|
|
100983
101026
|
);
|
|
100984
101027
|
}
|
|
101028
|
+
function connectionRefusedError(cmd, api) {
|
|
101029
|
+
const next = api.external ? `Check that the provider's simulator-server at ${api.apiUrl} is running.` : "The next call connects to a new simulator-server.";
|
|
101030
|
+
return new FailureError(
|
|
101031
|
+
`simulator-server did not accept the '${cmd}' command: the connection was refused. The command was NOT delivered to the device. ${next}`,
|
|
101032
|
+
{ ...COMMAND_TRANSPORT_FAILURE, failure_stage: "simulator_command_connection_refused" }
|
|
101033
|
+
);
|
|
101034
|
+
}
|
|
101035
|
+
function isConnectionRefused(err) {
|
|
101036
|
+
return err.code === "ECONNREFUSED";
|
|
101037
|
+
}
|
|
100985
101038
|
function remoteTransportError(cmd, cause) {
|
|
100986
101039
|
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
100987
101040
|
return wrapFailure(
|
|
@@ -100994,11 +101047,12 @@ function getOrCreateConnection(api) {
|
|
|
100994
101047
|
const key2 = api.apiUrl;
|
|
100995
101048
|
const existing = connections.get(key2);
|
|
100996
101049
|
if (existing && (existing.ws.readyState === wrapper_default.OPEN || existing.ws.readyState === wrapper_default.CONNECTING)) {
|
|
101050
|
+
existing.apis.add(api);
|
|
100997
101051
|
return existing;
|
|
100998
101052
|
}
|
|
100999
101053
|
const { host } = new URL(api.apiUrl);
|
|
101000
101054
|
const ws = new wrapper_default(`ws://${host}/ws`);
|
|
101001
|
-
const conn = { ws, pending: /* @__PURE__ */ new Map(), heldKeys: [] };
|
|
101055
|
+
const conn = { ws, pending: /* @__PURE__ */ new Map(), heldKeys: [], apis: /* @__PURE__ */ new Set([api]) };
|
|
101002
101056
|
ws.on("message", (data) => {
|
|
101003
101057
|
const text = Buffer.isBuffer(data) ? data.toString() : Array.isArray(data) ? Buffer.concat(data).toString() : Buffer.from(data).toString();
|
|
101004
101058
|
let ack;
|
|
@@ -101033,6 +101087,11 @@ function getOrCreateConnection(api) {
|
|
|
101033
101087
|
});
|
|
101034
101088
|
ws.on("error", (err) => {
|
|
101035
101089
|
connections.delete(key2);
|
|
101090
|
+
if (isConnectionRefused(err)) {
|
|
101091
|
+
failAllPending(conn, (cmd) => connectionRefusedError(cmd, api));
|
|
101092
|
+
for (const user of conn.apis) user.onConnectionRefused?.();
|
|
101093
|
+
return;
|
|
101094
|
+
}
|
|
101036
101095
|
failAllPending(conn, (cmd) => transportError(cmd, key2, err.message));
|
|
101037
101096
|
});
|
|
101038
101097
|
ws.on("close", () => {
|
|
@@ -101063,8 +101122,8 @@ async function sendCommandUnlocked(api, cmd, options) {
|
|
|
101063
101122
|
await sendViaTransport(api.transport, native, cmdName);
|
|
101064
101123
|
return turnWarning !== void 0 ? { warning: turnWarning } : {};
|
|
101065
101124
|
}
|
|
101066
|
-
const conn = getOrCreateConnection(api);
|
|
101067
101125
|
const { cmd: targeted, warning: screenWarning } = await withActiveScreen(api, native);
|
|
101126
|
+
const conn = getOrCreateConnection(api);
|
|
101068
101127
|
const warning = turnWarning !== void 0 && screenWarning !== void 0 ? `${screenWarning} ${turnWarning}` : screenWarning ?? turnWarning;
|
|
101069
101128
|
const id = String(++cmdId);
|
|
101070
101129
|
const payload = JSON.stringify({ id, ...targeted });
|
|
@@ -104512,10 +104571,12 @@ async function buildAttachedInstance(device, externalDevice) {
|
|
|
104512
104571
|
`${externalDevice.provider.name} did not publish a simulator-server endpoint for this device`
|
|
104513
104572
|
);
|
|
104514
104573
|
}
|
|
104574
|
+
const events = new TypedEventEmitter();
|
|
104515
104575
|
const api = {
|
|
104516
104576
|
apiUrl: externalDevice.simulatorServer.apiUrl,
|
|
104517
104577
|
deviceId: device.id,
|
|
104518
104578
|
external: true,
|
|
104579
|
+
onConnectionRefused: () => events.emit("terminated", connectionRefusedTermination()),
|
|
104519
104580
|
pressKey: async (direction, code) => {
|
|
104520
104581
|
await sendCommand(api, { cmd: "key", code, direction }, { ackTimeoutMs: KEY_ACK_TIMEOUT_MS });
|
|
104521
104582
|
},
|
|
@@ -104527,9 +104588,18 @@ async function buildAttachedInstance(device, externalDevice) {
|
|
|
104527
104588
|
api,
|
|
104528
104589
|
dispose: async () => {
|
|
104529
104590
|
},
|
|
104530
|
-
events
|
|
104591
|
+
events
|
|
104531
104592
|
};
|
|
104532
104593
|
}
|
|
104594
|
+
function connectionRefusedTermination() {
|
|
104595
|
+
return new FailureError("simulator-server refused the command connection", {
|
|
104596
|
+
error_code: FAILURE_CODES.SIMULATOR_SERVER_TERMINATED,
|
|
104597
|
+
failure_stage: "simulator_server_connection_refused",
|
|
104598
|
+
failure_area: "tool_server",
|
|
104599
|
+
error_kind: "network",
|
|
104600
|
+
network_failure: "connection_refused"
|
|
104601
|
+
});
|
|
104602
|
+
}
|
|
104533
104603
|
var SAFE_SIMULATOR_DEVICE_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]*$/;
|
|
104534
104604
|
function subcommandForDevice(device) {
|
|
104535
104605
|
if (device.platform === "ios") {
|
|
@@ -104821,6 +104891,7 @@ var simulatorServerBlueprint = {
|
|
|
104821
104891
|
apiUrl,
|
|
104822
104892
|
streamUrl,
|
|
104823
104893
|
deviceId: device.id,
|
|
104894
|
+
onConnectionRefused: () => events.emit("terminated", connectionRefusedTermination()),
|
|
104824
104895
|
/**
|
|
104825
104896
|
* Over the WebSocket, not stdin: simulator-server never replies on
|
|
104826
104897
|
* stdin, so a stdin write resolved at once and a stalled server let keys
|
|
@@ -105294,10 +105365,10 @@ init_harmony_flag();
|
|
|
105294
105365
|
|
|
105295
105366
|
// ../tool-server/src/utils/macos-apps.ts
|
|
105296
105367
|
var import_node_child_process23 = require("node:child_process");
|
|
105297
|
-
var
|
|
105298
|
-
var
|
|
105368
|
+
var import_node_crypto12 = require("node:crypto");
|
|
105369
|
+
var fs32 = __toESM(require("node:fs"));
|
|
105299
105370
|
var os8 = __toESM(require("node:os"));
|
|
105300
|
-
var
|
|
105371
|
+
var path28 = __toESM(require("node:path"));
|
|
105301
105372
|
var import_node_util18 = require("node:util");
|
|
105302
105373
|
init_src();
|
|
105303
105374
|
init_src2();
|
|
@@ -105305,6 +105376,41 @@ init_capability();
|
|
|
105305
105376
|
init_device_info();
|
|
105306
105377
|
init_macos_app_kind();
|
|
105307
105378
|
init_src();
|
|
105379
|
+
|
|
105380
|
+
// ../tool-server/src/utils/argent-home-id.ts
|
|
105381
|
+
var import_node_crypto11 = require("node:crypto");
|
|
105382
|
+
var fs31 = __toESM(require("node:fs"));
|
|
105383
|
+
var import_node_os6 = require("node:os");
|
|
105384
|
+
var path27 = __toESM(require("node:path"));
|
|
105385
|
+
init_src();
|
|
105386
|
+
var ARGENT_HOME_HEADER = "x-argent-home";
|
|
105387
|
+
function canonicalDir(dir) {
|
|
105388
|
+
const resolved = path27.resolve(dir);
|
|
105389
|
+
const parent = path27.dirname(resolved);
|
|
105390
|
+
if (fs31.existsSync(resolved) || parent === resolved) return canonicalPath(resolved);
|
|
105391
|
+
return path27.join(canonicalDir(parent), path27.basename(resolved));
|
|
105392
|
+
}
|
|
105393
|
+
function argentHomeId(dir = argentHomeDir()) {
|
|
105394
|
+
return (0, import_node_crypto11.createHash)("sha256").update(canonicalDir(dir)).digest("hex").slice(0, 12);
|
|
105395
|
+
}
|
|
105396
|
+
function peerArgentHomeId(header) {
|
|
105397
|
+
if (typeof header === "string" && header) return header;
|
|
105398
|
+
return argentHomeId(path27.join(resolveHomeDir(), ".argent"));
|
|
105399
|
+
}
|
|
105400
|
+
var LOOPBACK_ADDRESSES = /* @__PURE__ */ new Set(["127.0.0.1", "::1", "::ffff:127.0.0.1"]);
|
|
105401
|
+
function isOwnAddress(address) {
|
|
105402
|
+
const ip = address.replace(/^::ffff:(?=\d+\.\d+\.\d+\.\d+$)/, "");
|
|
105403
|
+
return Object.values((0, import_node_os6.networkInterfaces)()).some(
|
|
105404
|
+
(list) => list?.some((a) => (a.family === "IPv4" || a.scopeid === 0) && a.address === ip)
|
|
105405
|
+
);
|
|
105406
|
+
}
|
|
105407
|
+
function isLocalConnection(socket) {
|
|
105408
|
+
const remote = socket.remoteAddress;
|
|
105409
|
+
if (remote === void 0) return false;
|
|
105410
|
+
return LOOPBACK_ADDRESSES.has(remote) || remote === socket.localAddress || isOwnAddress(remote);
|
|
105411
|
+
}
|
|
105412
|
+
|
|
105413
|
+
// ../tool-server/src/utils/macos-apps.ts
|
|
105308
105414
|
var execFileAsync17 = (0, import_node_util18.promisify)(import_node_child_process23.execFile);
|
|
105309
105415
|
function isMacosAppsEnabled() {
|
|
105310
105416
|
return isFeatureEnabled(MACOS_APPS_FLAG);
|
|
@@ -105338,56 +105444,78 @@ function assertLaunchTargetsDevice(bundleId, device) {
|
|
|
105338
105444
|
}
|
|
105339
105445
|
);
|
|
105340
105446
|
}
|
|
105341
|
-
function macosArgentDir() {
|
|
105342
|
-
return path27.join(argentHomeDir(), "macos");
|
|
105343
|
-
}
|
|
105344
105447
|
function macosAppLogPath(bundleId) {
|
|
105345
|
-
return
|
|
105448
|
+
return path28.join(argentHomeDir(), "macos", "logs", `${bundleId}.log`);
|
|
105449
|
+
}
|
|
105450
|
+
function macosLibraryRoot() {
|
|
105451
|
+
return path28.join(os8.homedir(), "Library", "Caches", "com.swmansion.argent", "macos-lib");
|
|
105452
|
+
}
|
|
105453
|
+
function macosSocketDir() {
|
|
105454
|
+
try {
|
|
105455
|
+
const cache6 = (0, import_node_child_process23.execFileSync)("/usr/bin/getconf", ["DARWIN_USER_CACHE_DIR"], {
|
|
105456
|
+
encoding: "utf8",
|
|
105457
|
+
timeout: 5e3
|
|
105458
|
+
}).trim();
|
|
105459
|
+
return cache6 ? path28.join(cache6, `argent-${argentHomeId()}`) : null;
|
|
105460
|
+
} catch {
|
|
105461
|
+
return null;
|
|
105462
|
+
}
|
|
105346
105463
|
}
|
|
105347
105464
|
var BOOTSTRAP_NAME = "libArgentInjectionBootstrap.dylib";
|
|
105348
105465
|
var LIBRARY_NAME = "libNativeDevtoolsMacos.dylib";
|
|
105349
105466
|
function stageMacosLibraries(bootstrapPath, libraryPath, teamId) {
|
|
105350
|
-
const bootstrap =
|
|
105351
|
-
const library =
|
|
105467
|
+
const bootstrap = fs32.readFileSync(bootstrapPath);
|
|
105468
|
+
const library = fs32.readFileSync(libraryPath);
|
|
105352
105469
|
const hash2 = libraryHash(bootstrap, library);
|
|
105353
105470
|
const name = teamId ? `${hash2}-${teamId}` : hash2;
|
|
105354
|
-
const libRoot =
|
|
105355
|
-
const
|
|
105356
|
-
|
|
105357
|
-
const isComplete = () => fs31.existsSync(staged) && fs31.existsSync(path27.join(target, LIBRARY_NAME));
|
|
105358
|
-
fs31.mkdirSync(libRoot, { recursive: true, mode: 448 });
|
|
105359
|
-
fs31.chmodSync(macosArgentDir(), 448);
|
|
105471
|
+
const libRoot = macosLibraryRoot();
|
|
105472
|
+
const targets = STAGED_NAME_SUFFIXES.map((suffix) => path28.join(libRoot, name + suffix));
|
|
105473
|
+
fs32.mkdirSync(libRoot, { recursive: true, mode: 448 });
|
|
105360
105474
|
void removeUnusedLibraries(libRoot, hash2);
|
|
105361
|
-
|
|
105362
|
-
|
|
105363
|
-
|
|
105364
|
-
|
|
105365
|
-
|
|
105366
|
-
|
|
105367
|
-
|
|
105475
|
+
void removeUnusedLibraries(path28.join(argentHomeDir(), "macos", "lib"), void 0, hash2);
|
|
105476
|
+
const source = JSON.stringify([path28.resolve(bootstrapPath), path28.resolve(libraryPath)]);
|
|
105477
|
+
const reuse2 = (dir) => {
|
|
105478
|
+
recordLibrarySource(dir, source);
|
|
105479
|
+
return path28.join(dir, BOOTSTRAP_NAME);
|
|
105480
|
+
};
|
|
105481
|
+
const complete = targets.find(isCompleteCopy);
|
|
105482
|
+
if (complete) return reuse2(complete);
|
|
105483
|
+
const temp = fs32.mkdtempSync(path28.join(libRoot, `.tmp-${name}-`));
|
|
105484
|
+
try {
|
|
105485
|
+
fs32.writeFileSync(path28.join(temp, BOOTSTRAP_NAME), bootstrap, { mode: 493 });
|
|
105486
|
+
fs32.writeFileSync(path28.join(temp, LIBRARY_NAME), library, { mode: 493 });
|
|
105487
|
+
fs32.writeFileSync(path28.join(temp, SOURCES_NAME), `${source}
|
|
105488
|
+
`, { mode: 384 });
|
|
105489
|
+
for (const target of targets) {
|
|
105490
|
+
if (tryRename(temp, target)) return path28.join(target, BOOTSTRAP_NAME);
|
|
105491
|
+
if (isCompleteCopy(target)) return reuse2(target);
|
|
105492
|
+
}
|
|
105493
|
+
} finally {
|
|
105494
|
+
fs32.rmSync(temp, { recursive: true, force: true });
|
|
105368
105495
|
}
|
|
105369
|
-
|
|
105496
|
+
throw new Error(`${targets.join(", ")} hold incomplete copies of the library`);
|
|
105497
|
+
}
|
|
105498
|
+
var STAGED_NAME_SUFFIXES = ["", ".2", ".3"];
|
|
105499
|
+
function isCompleteCopy(dir) {
|
|
105500
|
+
return fs32.existsSync(path28.join(dir, BOOTSTRAP_NAME)) && fs32.existsSync(path28.join(dir, LIBRARY_NAME));
|
|
105501
|
+
}
|
|
105502
|
+
function tryRename(from2, to) {
|
|
105370
105503
|
try {
|
|
105371
|
-
|
|
105372
|
-
|
|
105373
|
-
|
|
105374
|
-
|
|
105375
|
-
fs31.renameSync(temp, target);
|
|
105376
|
-
} catch (err) {
|
|
105377
|
-
fs31.rmSync(temp, { recursive: true, force: true });
|
|
105378
|
-
throw err;
|
|
105504
|
+
fs32.renameSync(from2, to);
|
|
105505
|
+
return true;
|
|
105506
|
+
} catch {
|
|
105507
|
+
return false;
|
|
105379
105508
|
}
|
|
105380
|
-
return staged;
|
|
105381
105509
|
}
|
|
105382
105510
|
var SOURCES_NAME = "sources";
|
|
105383
105511
|
function libraryHash(bootstrap, library) {
|
|
105384
|
-
return (0,
|
|
105512
|
+
return (0, import_node_crypto12.createHash)("sha256").update(`${bootstrap.length}:`).update(bootstrap).update(`${library.length}:`).update(library).digest("hex").slice(0, 16);
|
|
105385
105513
|
}
|
|
105386
105514
|
function recordLibrarySource(dir, source) {
|
|
105387
|
-
const file2 =
|
|
105515
|
+
const file2 = path28.join(dir, SOURCES_NAME);
|
|
105388
105516
|
try {
|
|
105389
|
-
const known =
|
|
105390
|
-
if (!known.includes(source))
|
|
105517
|
+
const known = fs32.existsSync(file2) ? fs32.readFileSync(file2, "utf8").split("\n") : [];
|
|
105518
|
+
if (!known.includes(source)) fs32.appendFileSync(file2, `${source}
|
|
105391
105519
|
`, { mode: 384 });
|
|
105392
105520
|
} catch {
|
|
105393
105521
|
}
|
|
@@ -105395,13 +105523,13 @@ function recordLibrarySource(dir, source) {
|
|
|
105395
105523
|
function inPrivacyProtectedFolder(file2) {
|
|
105396
105524
|
const home = os8.homedir();
|
|
105397
105525
|
return ["Desktop", "Documents", "Downloads", "Library/Mobile Documents"].some(
|
|
105398
|
-
(folder) => file2.startsWith(
|
|
105526
|
+
(folder) => file2.startsWith(path28.join(home, folder) + path28.sep)
|
|
105399
105527
|
);
|
|
105400
105528
|
}
|
|
105401
105529
|
async function librarySourceInstalled(dir, name) {
|
|
105402
105530
|
let lines;
|
|
105403
105531
|
try {
|
|
105404
|
-
lines = (await
|
|
105532
|
+
lines = (await fs32.promises.readFile(path28.join(dir, SOURCES_NAME), "utf8")).split("\n");
|
|
105405
105533
|
} catch {
|
|
105406
105534
|
return false;
|
|
105407
105535
|
}
|
|
@@ -105416,7 +105544,7 @@ async function librarySourceInstalled(dir, name) {
|
|
|
105416
105544
|
if (files.some((file2) => inPrivacyProtectedFolder(String(file2)))) return true;
|
|
105417
105545
|
try {
|
|
105418
105546
|
const [bootstrap, library] = await Promise.all(
|
|
105419
|
-
files.map((file2) =>
|
|
105547
|
+
files.map((file2) => fs32.promises.readFile(String(file2)))
|
|
105420
105548
|
);
|
|
105421
105549
|
if (name.startsWith(libraryHash(bootstrap, library))) return true;
|
|
105422
105550
|
} catch (err) {
|
|
@@ -105425,9 +105553,9 @@ async function librarySourceInstalled(dir, name) {
|
|
|
105425
105553
|
}
|
|
105426
105554
|
return false;
|
|
105427
105555
|
}
|
|
105428
|
-
async function removeUnusedLibraries(libRoot, keep) {
|
|
105556
|
+
async function removeUnusedLibraries(libRoot, keep, superseded) {
|
|
105429
105557
|
try {
|
|
105430
|
-
const root =
|
|
105558
|
+
const root = fs32.realpathSync(libRoot);
|
|
105431
105559
|
let open5;
|
|
105432
105560
|
try {
|
|
105433
105561
|
({ stdout: open5 } = await execFileAsync17("lsof", ["-Fn", "+D", root], {
|
|
@@ -105442,15 +105570,25 @@ async function removeUnusedLibraries(libRoot, keep) {
|
|
|
105442
105570
|
const used = new Set(
|
|
105443
105571
|
open5.split("\n").filter((line) => line.startsWith(`n${root}/`)).map((line) => line.slice(root.length + 2).split("/")[0])
|
|
105444
105572
|
);
|
|
105445
|
-
for (const name of
|
|
105446
|
-
|
|
105447
|
-
const
|
|
105448
|
-
if (
|
|
105449
|
-
|
|
105573
|
+
for (const name of fs32.readdirSync(root)) {
|
|
105574
|
+
const dir = path28.join(root, name);
|
|
105575
|
+
const current = keep !== void 0 && name.startsWith(keep);
|
|
105576
|
+
if (used.has(name) || current && isCompleteCopy(dir)) continue;
|
|
105577
|
+
const temporary = name.startsWith(".");
|
|
105578
|
+
if (temporary && isRecent(dir)) continue;
|
|
105579
|
+
const restaged = superseded !== void 0 && name.startsWith(superseded);
|
|
105580
|
+
if (!current && !temporary && !restaged && await librarySourceInstalled(dir, name)) {
|
|
105581
|
+
continue;
|
|
105582
|
+
}
|
|
105583
|
+
fs32.rmSync(dir, { recursive: true, force: true });
|
|
105450
105584
|
}
|
|
105451
105585
|
} catch {
|
|
105452
105586
|
}
|
|
105453
105587
|
}
|
|
105588
|
+
var STAGING_TEMP_MAX_AGE_MS = 10 * 6e4;
|
|
105589
|
+
function isRecent(dir) {
|
|
105590
|
+
return Date.now() - fs32.lstatSync(dir).mtimeMs < STAGING_TEMP_MAX_AGE_MS;
|
|
105591
|
+
}
|
|
105454
105592
|
var EXPORTED_RELEASE_NOTE = "An exported or notarized Release build with the hardened runtime cannot be driven without extra entitlements.";
|
|
105455
105593
|
async function signatureTeam(file2) {
|
|
105456
105594
|
try {
|
|
@@ -105466,7 +105604,7 @@ async function stageLibraryFor(info, shipped, readTeam = signatureTeam) {
|
|
|
105466
105604
|
bootstrap = stageMacosLibraries(shipped.bootstrap, shipped.library, teamId);
|
|
105467
105605
|
} catch (err) {
|
|
105468
105606
|
throw macosFailure(
|
|
105469
|
-
`Could not copy the argent library to
|
|
105607
|
+
`Could not copy the argent library to ${macosLibraryRoot()}: ${errorMessage(err)}`,
|
|
105470
105608
|
FAILURE_CODES.MACOS_APP_LIBRARY_STAGE_FAILED,
|
|
105471
105609
|
"macos_app_stage_library",
|
|
105472
105610
|
"unknown",
|
|
@@ -105474,7 +105612,7 @@ async function stageLibraryFor(info, shipped, readTeam = signatureTeam) {
|
|
|
105474
105612
|
);
|
|
105475
105613
|
}
|
|
105476
105614
|
if (!teamId) return bootstrap;
|
|
105477
|
-
const files = [bootstrap,
|
|
105615
|
+
const files = [bootstrap, path28.join(path28.dirname(bootstrap), LIBRARY_NAME)];
|
|
105478
105616
|
const teams = await Promise.all(files.map((file2) => readTeam(file2)));
|
|
105479
105617
|
if (teams.every((team) => team === teamId)) return bootstrap;
|
|
105480
105618
|
const debug = info.entitlements.getTaskAllow;
|
|
@@ -105490,7 +105628,7 @@ then start the app again. Signing uses the keychain, so the user runs this comma
|
|
|
105490
105628
|
var MAX_SOCKET_PATH_BYTES = 103;
|
|
105491
105629
|
function macosListenSocket(bundleId, sandboxed) {
|
|
105492
105630
|
if (sandboxed) {
|
|
105493
|
-
const containerPath =
|
|
105631
|
+
const containerPath = path28.join(
|
|
105494
105632
|
os8.homedir(),
|
|
105495
105633
|
"Library",
|
|
105496
105634
|
"Containers",
|
|
@@ -105501,12 +105639,27 @@ function macosListenSocket(bundleId, sandboxed) {
|
|
|
105501
105639
|
);
|
|
105502
105640
|
return fitsSocketPath(containerPath) ? { env: "CONTAINER", path: containerPath } : null;
|
|
105503
105641
|
}
|
|
105504
|
-
const
|
|
105642
|
+
const dir = macosSocketDir();
|
|
105643
|
+
if (!dir) return null;
|
|
105644
|
+
const named = path28.join(dir, `${bundleId}.sock`);
|
|
105505
105645
|
if (fitsSocketPath(named)) return { env: named, path: named };
|
|
105506
|
-
const hash2 = (0,
|
|
105507
|
-
const hashed =
|
|
105646
|
+
const hash2 = (0, import_node_crypto12.createHash)("sha256").update(bundleId).digest("hex").slice(0, 16);
|
|
105647
|
+
const hashed = path28.join(dir, `${hash2}.sock`);
|
|
105508
105648
|
return fitsSocketPath(hashed) ? { env: hashed, path: hashed } : null;
|
|
105509
105649
|
}
|
|
105650
|
+
function prepareSocketDir(socketPath) {
|
|
105651
|
+
const dir = path28.dirname(socketPath);
|
|
105652
|
+
fs32.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
105653
|
+
const stat11 = fs32.lstatSync(dir);
|
|
105654
|
+
if (!stat11.isDirectory() || stat11.uid !== process.getuid?.() || (stat11.mode & 63) !== 0) {
|
|
105655
|
+
throw macosFailure(
|
|
105656
|
+
`${dir} belongs to another user or others can open it, so argent cannot keep the app's socket private there.`,
|
|
105657
|
+
FAILURE_CODES.MACOS_APP_SPAWN_FAILED,
|
|
105658
|
+
"macos_app_listen_socket",
|
|
105659
|
+
"validation"
|
|
105660
|
+
);
|
|
105661
|
+
}
|
|
105662
|
+
}
|
|
105510
105663
|
function fitsSocketPath(p) {
|
|
105511
105664
|
return Buffer.byteLength(p, "utf8") <= MAX_SOCKET_PATH_BYTES;
|
|
105512
105665
|
}
|
|
@@ -105524,7 +105677,7 @@ function isTrackedMacosApp(value) {
|
|
|
105524
105677
|
function readTrackedApps() {
|
|
105525
105678
|
let raw;
|
|
105526
105679
|
try {
|
|
105527
|
-
raw = JSON.parse(
|
|
105680
|
+
raw = JSON.parse(fs32.readFileSync(trackedMacosAppsFile(), "utf8"));
|
|
105528
105681
|
} catch {
|
|
105529
105682
|
return [];
|
|
105530
105683
|
}
|
|
@@ -105533,10 +105686,10 @@ function readTrackedApps() {
|
|
|
105533
105686
|
function recordTrackedMacosApp(app) {
|
|
105534
105687
|
const file2 = trackedMacosAppsFile();
|
|
105535
105688
|
const others = readTrackedApps().filter((a) => a.bundleId !== app.bundleId);
|
|
105536
|
-
|
|
105689
|
+
fs32.mkdirSync(path28.dirname(file2), { recursive: true });
|
|
105537
105690
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
105538
|
-
|
|
105539
|
-
|
|
105691
|
+
fs32.writeFileSync(tmp, JSON.stringify([...others, app], null, 2) + "\n");
|
|
105692
|
+
fs32.renameSync(tmp, file2);
|
|
105540
105693
|
}
|
|
105541
105694
|
function getTrackedMacosApp(bundleId) {
|
|
105542
105695
|
return readTrackedApps().find((a) => a.bundleId === bundleId);
|
|
@@ -105599,7 +105752,7 @@ async function findRunningCopies(bundleId, executable, skipPid) {
|
|
|
105599
105752
|
} catch {
|
|
105600
105753
|
return found;
|
|
105601
105754
|
}
|
|
105602
|
-
const suffix = `/Contents/MacOS/${
|
|
105755
|
+
const suffix = `/Contents/MacOS/${path28.basename(executable)}`;
|
|
105603
105756
|
const bundleIds = /* @__PURE__ */ new Map();
|
|
105604
105757
|
for (const line of stdout.split("\n")) {
|
|
105605
105758
|
const match = /^\s*(\d+)\s+(.*)$/.exec(line);
|
|
@@ -105612,7 +105765,7 @@ async function findRunningCopies(bundleId, executable, skipPid) {
|
|
|
105612
105765
|
if (!command2.endsWith(suffix)) continue;
|
|
105613
105766
|
let resolved;
|
|
105614
105767
|
try {
|
|
105615
|
-
resolved =
|
|
105768
|
+
resolved = fs32.realpathSync(command2);
|
|
105616
105769
|
} catch {
|
|
105617
105770
|
continue;
|
|
105618
105771
|
}
|
|
@@ -105621,7 +105774,7 @@ async function findRunningCopies(bundleId, executable, skipPid) {
|
|
|
105621
105774
|
if (!bundleIds.has(appPath)) {
|
|
105622
105775
|
bundleIds.set(
|
|
105623
105776
|
appPath,
|
|
105624
|
-
await plistValue(
|
|
105777
|
+
await plistValue(path28.join(appPath, "Contents", "Info.plist"), "CFBundleIdentifier")
|
|
105625
105778
|
);
|
|
105626
105779
|
}
|
|
105627
105780
|
if (bundleIds.get(appPath) === bundleId) found.otherBuilds.push({ pid, appPath });
|
|
@@ -105637,16 +105790,16 @@ async function gitWorktreeOf(dir) {
|
|
|
105637
105790
|
);
|
|
105638
105791
|
const [top, common] = stdout.trim().split("\n");
|
|
105639
105792
|
if (!top || !common) return null;
|
|
105640
|
-
return { top:
|
|
105793
|
+
return { top: fs32.realpathSync(top), common: fs32.realpathSync(common) };
|
|
105641
105794
|
} catch {
|
|
105642
105795
|
return null;
|
|
105643
105796
|
}
|
|
105644
105797
|
}
|
|
105645
105798
|
async function otherWorktreeOfBuild(appPath, projectRoot) {
|
|
105646
105799
|
const derivedData = /^(.*)\/Build\/Products\/[^/]+\/[^/]+\.app$/.exec(appPath)?.[1];
|
|
105647
|
-
const workspace = derivedData ? await plistValue(
|
|
105800
|
+
const workspace = derivedData ? await plistValue(path28.join(derivedData, "info.plist"), "WorkspacePath") : null;
|
|
105648
105801
|
const [build2, project] = await Promise.all([
|
|
105649
|
-
gitWorktreeOf(
|
|
105802
|
+
gitWorktreeOf(path28.dirname(workspace ?? appPath)),
|
|
105650
105803
|
gitWorktreeOf(projectRoot)
|
|
105651
105804
|
]);
|
|
105652
105805
|
if (!build2 || !project) return null;
|
|
@@ -105657,7 +105810,7 @@ var CHROMIUM_BROWSER_FRAMEWORK = /\b(chrome|chromium|edge|brave|vivaldi|opera)\b
|
|
|
105657
105810
|
function chromiumKind(appPath) {
|
|
105658
105811
|
let frameworks;
|
|
105659
105812
|
try {
|
|
105660
|
-
frameworks =
|
|
105813
|
+
frameworks = fs32.readdirSync(path28.join(appPath, "Contents", "Frameworks"));
|
|
105661
105814
|
} catch {
|
|
105662
105815
|
return void 0;
|
|
105663
105816
|
}
|
|
@@ -105674,10 +105827,10 @@ var MAX_LOAD_COMMANDS_BYTES = 1024 * 1024;
|
|
|
105674
105827
|
function isCatalystExecutable(executable) {
|
|
105675
105828
|
let fd;
|
|
105676
105829
|
try {
|
|
105677
|
-
fd =
|
|
105830
|
+
fd = fs32.openSync(executable, "r");
|
|
105678
105831
|
const read = (length, position) => {
|
|
105679
105832
|
const buffer = Buffer.alloc(length);
|
|
105680
|
-
return buffer.subarray(0,
|
|
105833
|
+
return buffer.subarray(0, fs32.readSync(fd, buffer, 0, length, position));
|
|
105681
105834
|
};
|
|
105682
105835
|
const header = read(8, 0);
|
|
105683
105836
|
if (header.length < 8) return false;
|
|
@@ -105694,7 +105847,7 @@ function isCatalystExecutable(executable) {
|
|
|
105694
105847
|
} catch {
|
|
105695
105848
|
return false;
|
|
105696
105849
|
} finally {
|
|
105697
|
-
if (fd !== void 0)
|
|
105850
|
+
if (fd !== void 0) fs32.closeSync(fd);
|
|
105698
105851
|
}
|
|
105699
105852
|
}
|
|
105700
105853
|
function isCatalystSlice(read, offset) {
|
|
@@ -105747,7 +105900,7 @@ function parseCodesignDisplay(output2) {
|
|
|
105747
105900
|
}
|
|
105748
105901
|
function isIosAppWrapper(dir) {
|
|
105749
105902
|
try {
|
|
105750
|
-
return
|
|
105903
|
+
return fs32.statSync(path28.join(dir, "Wrapper")).isDirectory() && fs32.lstatSync(path28.join(dir, "WrappedBundle")).isSymbolicLink();
|
|
105751
105904
|
} catch {
|
|
105752
105905
|
return false;
|
|
105753
105906
|
}
|
|
@@ -105788,7 +105941,7 @@ async function inspectMacosApp(appPath) {
|
|
|
105788
105941
|
const badBundle = (message) => invalid3(message, FAILURE_CODES.MACOS_APP_BUNDLE_INVALID);
|
|
105789
105942
|
let resolved;
|
|
105790
105943
|
try {
|
|
105791
|
-
resolved =
|
|
105944
|
+
resolved = fs32.realpathSync(path28.resolve(appPath));
|
|
105792
105945
|
} catch {
|
|
105793
105946
|
throw invalid3(
|
|
105794
105947
|
`No app bundle at ${appPath}.`,
|
|
@@ -105796,8 +105949,8 @@ async function inspectMacosApp(appPath) {
|
|
|
105796
105949
|
"not_found"
|
|
105797
105950
|
);
|
|
105798
105951
|
}
|
|
105799
|
-
const plist =
|
|
105800
|
-
if (!
|
|
105952
|
+
const plist = path28.join(resolved, "Contents", "Info.plist");
|
|
105953
|
+
if (!fs32.statSync(resolved).isDirectory() || !fs32.existsSync(plist)) {
|
|
105801
105954
|
if (isIosAppWrapper(resolved)) {
|
|
105802
105955
|
throw invalid3(
|
|
105803
105956
|
`${appPath} is an iPad or iPhone app that runs on the Mac ("Designed for iPad"). macOS does not let argent load its library into such an app, so argent cannot drive it. Build the app's Mac Catalyst target and boot that, or test the app on an iOS simulator.`,
|
|
@@ -105826,8 +105979,8 @@ async function inspectMacosApp(appPath) {
|
|
|
105826
105979
|
if (!executableName || executableName.includes("/")) {
|
|
105827
105980
|
throw badBundle(`${plist} has no usable CFBundleExecutable.`);
|
|
105828
105981
|
}
|
|
105829
|
-
const executable =
|
|
105830
|
-
if (!
|
|
105982
|
+
const executable = path28.join(resolved, "Contents", "MacOS", executableName);
|
|
105983
|
+
if (!fs32.existsSync(executable)) {
|
|
105831
105984
|
throw badBundle(`The executable ${executable} named by ${plist} does not exist.`);
|
|
105832
105985
|
}
|
|
105833
105986
|
const signature = await readCodeSignature(resolved) ?? parseCodesignDisplay(null);
|
|
@@ -105835,7 +105988,7 @@ async function inspectMacosApp(appPath) {
|
|
|
105835
105988
|
return {
|
|
105836
105989
|
appPath: resolved,
|
|
105837
105990
|
bundleId,
|
|
105838
|
-
name: bundleName ??
|
|
105991
|
+
name: bundleName ?? path28.basename(resolved, ".app"),
|
|
105839
105992
|
executable,
|
|
105840
105993
|
...signature,
|
|
105841
105994
|
...chromium ? { chromium } : {},
|
|
@@ -105888,12 +106041,12 @@ async function findMacosAppByBundleId(bundleId) {
|
|
|
105888
106041
|
for (const line of stdout.split("\n")) {
|
|
105889
106042
|
const appPath = line.trim();
|
|
105890
106043
|
if (!appPath.endsWith(".app")) continue;
|
|
105891
|
-
const contents =
|
|
105892
|
-
const executable = await plistValue(
|
|
106044
|
+
const contents = path28.join(appPath, "Contents");
|
|
106045
|
+
const executable = await plistValue(path28.join(contents, "Info.plist"), "CFBundleExecutable");
|
|
105893
106046
|
if (!executable) continue;
|
|
105894
106047
|
let mtimeMs;
|
|
105895
106048
|
try {
|
|
105896
|
-
mtimeMs =
|
|
106049
|
+
mtimeMs = fs32.statSync(path28.join(contents, "MacOS", executable)).mtimeMs;
|
|
105897
106050
|
} catch {
|
|
105898
106051
|
continue;
|
|
105899
106052
|
}
|
|
@@ -105902,7 +106055,7 @@ async function findMacosAppByBundleId(bundleId) {
|
|
|
105902
106055
|
return best?.appPath ?? null;
|
|
105903
106056
|
}
|
|
105904
106057
|
async function issueSandboxExtension(filePath, opts = {}) {
|
|
105905
|
-
const args = ["issue-extension", "--path",
|
|
106058
|
+
const args = ["issue-extension", "--path", path28.resolve(filePath)];
|
|
105906
106059
|
if (opts.readOnly) args.push("--read-only");
|
|
105907
106060
|
try {
|
|
105908
106061
|
const { stdout } = await execFileAsync17(macosArtifacts().helper, args, { timeout: 1e4 });
|
|
@@ -105922,8 +106075,8 @@ async function issueSandboxExtension(filePath, opts = {}) {
|
|
|
105922
106075
|
}
|
|
105923
106076
|
|
|
105924
106077
|
// ../tool-server/src/utils/chromium-discovery.ts
|
|
105925
|
-
var
|
|
105926
|
-
var
|
|
106078
|
+
var fs35 = __toESM(require("node:fs"));
|
|
106079
|
+
var path31 = __toESM(require("node:path"));
|
|
105927
106080
|
init_src2();
|
|
105928
106081
|
init_device_info();
|
|
105929
106082
|
|
|
@@ -105934,9 +106087,9 @@ init_src2();
|
|
|
105934
106087
|
init_src2();
|
|
105935
106088
|
|
|
105936
106089
|
// ../tool-server/src/chromium-server/cdp-session.ts
|
|
105937
|
-
var
|
|
106090
|
+
var fs33 = __toESM(require("node:fs"));
|
|
105938
106091
|
var os10 = __toESM(require("node:os"));
|
|
105939
|
-
var
|
|
106092
|
+
var path29 = __toESM(require("node:path"));
|
|
105940
106093
|
init_src2();
|
|
105941
106094
|
|
|
105942
106095
|
// ../tool-server/src/utils/debugger/cdp-client.ts
|
|
@@ -106771,8 +106924,8 @@ async function primePageSession(cdp) {
|
|
|
106771
106924
|
}
|
|
106772
106925
|
}
|
|
106773
106926
|
function mediaDir() {
|
|
106774
|
-
const dir =
|
|
106775
|
-
|
|
106927
|
+
const dir = path29.join(os10.tmpdir(), "argent-chromium-media");
|
|
106928
|
+
fs33.mkdirSync(dir, { recursive: true });
|
|
106776
106929
|
return dir;
|
|
106777
106930
|
}
|
|
106778
106931
|
|
|
@@ -107206,8 +107359,8 @@ var ScreencastManager = class {
|
|
|
107206
107359
|
};
|
|
107207
107360
|
|
|
107208
107361
|
// ../tool-server/src/chromium-server/screenshot.ts
|
|
107209
|
-
var
|
|
107210
|
-
var
|
|
107362
|
+
var fs34 = __toESM(require("node:fs"));
|
|
107363
|
+
var path30 = __toESM(require("node:path"));
|
|
107211
107364
|
init_src2();
|
|
107212
107365
|
var sharpCache;
|
|
107213
107366
|
var sharpLoadWarningEmitted = false;
|
|
@@ -107294,8 +107447,8 @@ async function captureScreenshot(ctx, opts = {}) {
|
|
|
107294
107447
|
}
|
|
107295
107448
|
const stem = opts.id ?? `${Date.now()}-${process.pid}`;
|
|
107296
107449
|
const safeDeviceId = ctx.deviceId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
107297
|
-
const filePath =
|
|
107298
|
-
|
|
107450
|
+
const filePath = path30.join(mediaDir(), `argent-screenshot-${safeDeviceId}-${stem}.png`);
|
|
107451
|
+
fs34.writeFileSync(filePath, bytes);
|
|
107299
107452
|
return {
|
|
107300
107453
|
url: `file://${filePath}`,
|
|
107301
107454
|
path: filePath,
|
|
@@ -107312,7 +107465,7 @@ function readPngSize(buf) {
|
|
|
107312
107465
|
}
|
|
107313
107466
|
async function copyScreenshotToClipboard(ctx, opts = {}) {
|
|
107314
107467
|
const shot = await captureScreenshot(ctx, { rotation: opts.rotation });
|
|
107315
|
-
const bytes =
|
|
107468
|
+
const bytes = fs34.readFileSync(shot.path);
|
|
107316
107469
|
const b64 = bytes.toString("base64");
|
|
107317
107470
|
const script = `(async () => {
|
|
107318
107471
|
const b64 = "${b64}";
|
|
@@ -108019,11 +108172,11 @@ function parsePortList(raw) {
|
|
|
108019
108172
|
}
|
|
108020
108173
|
var TRACKED_PORTS = /* @__PURE__ */ new Set();
|
|
108021
108174
|
function portsFilePath() {
|
|
108022
|
-
return process.env.ARGENT_CHROMIUM_PORTS_FILE ??
|
|
108175
|
+
return process.env.ARGENT_CHROMIUM_PORTS_FILE ?? path31.join(argentHomeDir(), "chromium-cdp-ports.json");
|
|
108023
108176
|
}
|
|
108024
108177
|
function loadPersistedPorts() {
|
|
108025
108178
|
try {
|
|
108026
|
-
const raw = JSON.parse(
|
|
108179
|
+
const raw = JSON.parse(fs35.readFileSync(portsFilePath(), "utf8"));
|
|
108027
108180
|
if (!Array.isArray(raw)) return [];
|
|
108028
108181
|
return raw.filter((p) => typeof p === "number" && p > 0 && p <= 65535);
|
|
108029
108182
|
} catch {
|
|
@@ -108035,8 +108188,8 @@ function persistPorts(mutate) {
|
|
|
108035
108188
|
const file2 = portsFilePath();
|
|
108036
108189
|
const merged = new Set(loadPersistedPorts());
|
|
108037
108190
|
mutate(merged);
|
|
108038
|
-
|
|
108039
|
-
|
|
108191
|
+
fs35.mkdirSync(path31.dirname(file2), { recursive: true });
|
|
108192
|
+
fs35.writeFileSync(file2, JSON.stringify(Array.from(merged)));
|
|
108040
108193
|
} catch {
|
|
108041
108194
|
}
|
|
108042
108195
|
}
|
|
@@ -108100,12 +108253,12 @@ init_src2();
|
|
|
108100
108253
|
// ../tool-server/src/utils/vega-sdk.ts
|
|
108101
108254
|
var import_promises10 = require("node:fs/promises");
|
|
108102
108255
|
var import_node_fs9 = require("node:fs");
|
|
108103
|
-
var
|
|
108256
|
+
var import_node_os7 = require("node:os");
|
|
108104
108257
|
var import_node_path13 = require("node:path");
|
|
108105
108258
|
var import_semver4 = __toESM(require_semver2());
|
|
108106
108259
|
async function readVegaConfig() {
|
|
108107
108260
|
try {
|
|
108108
|
-
const raw = await (0, import_promises10.readFile)((0, import_node_path13.join)((0,
|
|
108261
|
+
const raw = await (0, import_promises10.readFile)((0, import_node_path13.join)((0, import_node_os7.homedir)(), "vega", "config.json"), "utf-8");
|
|
108109
108262
|
return JSON.parse(raw);
|
|
108110
108263
|
} catch {
|
|
108111
108264
|
return {};
|
|
@@ -108117,7 +108270,7 @@ function bareVersion(version3) {
|
|
|
108117
108270
|
function sdkComponentRoots(config2) {
|
|
108118
108271
|
const roots = [
|
|
108119
108272
|
config2.sdkPath && (0, import_node_path13.join)(config2.sdkPath, "vega-sdk"),
|
|
108120
|
-
(0, import_node_path13.join)((0,
|
|
108273
|
+
(0, import_node_path13.join)((0, import_node_os7.homedir)(), "vega", "sdk", "vega-sdk")
|
|
108121
108274
|
].filter((p) => Boolean(p));
|
|
108122
108275
|
return Array.from(new Set(roots));
|
|
108123
108276
|
}
|
|
@@ -109179,7 +109332,7 @@ init_src2();
|
|
|
109179
109332
|
|
|
109180
109333
|
// ../tool-server/src/blueprints/ax-service.ts
|
|
109181
109334
|
var net4 = __toESM(require("node:net"));
|
|
109182
|
-
var
|
|
109335
|
+
var fs36 = __toESM(require("node:fs"));
|
|
109183
109336
|
init_src2();
|
|
109184
109337
|
init_external_devices();
|
|
109185
109338
|
|
|
@@ -109258,7 +109411,7 @@ function startListener(endpoint, onConnection) {
|
|
|
109258
109411
|
return new Promise((resolve24, reject) => {
|
|
109259
109412
|
if (endpoint.transport === "unix") {
|
|
109260
109413
|
try {
|
|
109261
|
-
|
|
109414
|
+
fs36.unlinkSync(endpoint.socketPath);
|
|
109262
109415
|
} catch {
|
|
109263
109416
|
}
|
|
109264
109417
|
}
|
|
@@ -109575,7 +109728,7 @@ var axServiceBlueprint = {
|
|
|
109575
109728
|
server.close();
|
|
109576
109729
|
if (endpoint.transport === "unix") {
|
|
109577
109730
|
try {
|
|
109578
|
-
|
|
109731
|
+
fs36.unlinkSync(endpoint.socketPath);
|
|
109579
109732
|
} catch {
|
|
109580
109733
|
}
|
|
109581
109734
|
}
|
|
@@ -109806,7 +109959,7 @@ var axServiceBlueprint = {
|
|
|
109806
109959
|
server.close();
|
|
109807
109960
|
if (endpoint.transport === "unix") {
|
|
109808
109961
|
try {
|
|
109809
|
-
|
|
109962
|
+
fs36.unlinkSync(endpoint.socketPath);
|
|
109810
109963
|
} catch {
|
|
109811
109964
|
}
|
|
109812
109965
|
}
|
|
@@ -110779,8 +110932,8 @@ var readline2 = __toESM(require("node:readline"));
|
|
|
110779
110932
|
init_src2();
|
|
110780
110933
|
|
|
110781
110934
|
// ../native-devtools-android/src/index.ts
|
|
110782
|
-
var
|
|
110783
|
-
var
|
|
110935
|
+
var path33 = __toESM(require("node:path"));
|
|
110936
|
+
var fs37 = __toESM(require("node:fs"));
|
|
110784
110937
|
|
|
110785
110938
|
// ../native-devtools-android/src/errors.ts
|
|
110786
110939
|
function buildMessage(kind, details) {
|
|
@@ -110813,7 +110966,7 @@ var TraceProcessorUnavailableError = class _TraceProcessorUnavailableError exten
|
|
|
110813
110966
|
// ../native-devtools-android/src/wasm-trace-processor.ts
|
|
110814
110967
|
var import_node_fs10 = require("node:fs");
|
|
110815
110968
|
var import_promises11 = require("node:fs/promises");
|
|
110816
|
-
var
|
|
110969
|
+
var path32 = __toESM(require("node:path"));
|
|
110817
110970
|
var import_node_url2 = require("node:url");
|
|
110818
110971
|
var import_node_vm = __toESM(require("node:vm"));
|
|
110819
110972
|
|
|
@@ -111138,14 +111291,14 @@ function engineGlobals() {
|
|
|
111138
111291
|
return globalThis;
|
|
111139
111292
|
}
|
|
111140
111293
|
function resolveTraceProcessorAssets() {
|
|
111141
|
-
const dir =
|
|
111294
|
+
const dir = path32.join(__dirname, "..", "assets", "trace-processor");
|
|
111142
111295
|
const wasmOverride = process.env.ARGENT_TRACE_PROCESSOR_WASM;
|
|
111143
111296
|
if (wasmOverride && !(0, import_node_fs10.existsSync)(wasmOverride)) {
|
|
111144
111297
|
throw new TraceProcessorUnavailableError("wasm_path_invalid", { path: wasmOverride });
|
|
111145
111298
|
}
|
|
111146
111299
|
return {
|
|
111147
|
-
wasmPath: wasmOverride ??
|
|
111148
|
-
gluePath:
|
|
111300
|
+
wasmPath: wasmOverride ?? path32.join(dir, "trace_processor.wasm"),
|
|
111301
|
+
gluePath: path32.join(dir, "engine_bundle.node.js")
|
|
111149
111302
|
};
|
|
111150
111303
|
}
|
|
111151
111304
|
function patchGlueForNode(src) {
|
|
@@ -111233,7 +111386,7 @@ async function createEngine() {
|
|
|
111233
111386
|
});
|
|
111234
111387
|
try {
|
|
111235
111388
|
const { wasmPath, gluePath } = resolveTraceProcessorAssets();
|
|
111236
|
-
const dir =
|
|
111389
|
+
const dir = path32.dirname(wasmPath);
|
|
111237
111390
|
setupWorkerScope(dir);
|
|
111238
111391
|
const g = engineGlobals();
|
|
111239
111392
|
const wasmModule = await g.WebAssembly.compile(await (0, import_promises11.readFile)(wasmPath));
|
|
@@ -111358,25 +111511,25 @@ async function ensureTraceProcessorReady(tracePath) {
|
|
|
111358
111511
|
|
|
111359
111512
|
// ../native-devtools-android/src/index.ts
|
|
111360
111513
|
function binDir() {
|
|
111361
|
-
return process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_BIN_DIR ??
|
|
111514
|
+
return process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_BIN_DIR ?? path33.join(__dirname, "..", "bin");
|
|
111362
111515
|
}
|
|
111363
111516
|
function traceProcessorQueriesDir() {
|
|
111364
|
-
return process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_QUERIES_DIR ??
|
|
111517
|
+
return process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_QUERIES_DIR ?? path33.join(__dirname, "..", "assets", "queries");
|
|
111365
111518
|
}
|
|
111366
111519
|
function traceConfigPath() {
|
|
111367
|
-
return process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_TRACECFG ??
|
|
111520
|
+
return process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_TRACECFG ?? path33.join(__dirname, "..", "assets", "argent.tracecfg.pbtxt");
|
|
111368
111521
|
}
|
|
111369
111522
|
var cachedManifest = null;
|
|
111370
111523
|
function helperManifest() {
|
|
111371
111524
|
if (cachedManifest) return cachedManifest;
|
|
111372
|
-
const manifestPath =
|
|
111373
|
-
cachedManifest = JSON.parse(
|
|
111525
|
+
const manifestPath = path33.join(__dirname, "..", "assets", "manifest.json");
|
|
111526
|
+
cachedManifest = JSON.parse(fs37.readFileSync(manifestPath, "utf-8"));
|
|
111374
111527
|
return cachedManifest;
|
|
111375
111528
|
}
|
|
111376
111529
|
function bundledHelperApkPath() {
|
|
111377
111530
|
const manifest = helperManifest();
|
|
111378
|
-
const apk =
|
|
111379
|
-
if (!
|
|
111531
|
+
const apk = path33.join(binDir(), `argent-android-devtools-${manifest.versionName}.apk`);
|
|
111532
|
+
if (!fs37.existsSync(apk)) {
|
|
111380
111533
|
throw new Error(
|
|
111381
111534
|
`Bundled Android devtools helper APK not found at ${apk}. Run \`bash packages/native-devtools-android/scripts/build.sh\` to build it.`
|
|
111382
111535
|
);
|
|
@@ -111588,6 +111741,7 @@ var READY_TIMEOUT_MS2 = 3e4;
|
|
|
111588
111741
|
var EXIT_GRACE_MS2 = 200;
|
|
111589
111742
|
var HELPER_EXIT_TIMEOUT_MS = 3e3;
|
|
111590
111743
|
var DISPOSE_FORCE_STOP_WAIT_MS = 2e3;
|
|
111744
|
+
var HELPER_IDLE_RELEASE_MS = 18e4;
|
|
111591
111745
|
var HELPER_PORT_MARKER = /^INSTRUMENTATION_STATUS:\s*port=(\d+)/;
|
|
111592
111746
|
var ADB_FORWARD_PORT_MARKER = /^(\d+)\s*$/;
|
|
111593
111747
|
var HELPER_STATUS_MARKER = /^INSTRUMENTATION_STATUS:\s*Error=/;
|
|
@@ -111965,7 +112119,50 @@ var androidDevtoolsBlueprint = {
|
|
|
111965
112119
|
throw err;
|
|
111966
112120
|
}
|
|
111967
112121
|
};
|
|
111968
|
-
|
|
112122
|
+
let idleTimer;
|
|
112123
|
+
const armIdleRelease = () => {
|
|
112124
|
+
clearTimeout(idleTimer);
|
|
112125
|
+
idleTimer = setTimeout(() => events.emit("terminated"), HELPER_IDLE_RELEASE_MS);
|
|
112126
|
+
idleTimer.unref();
|
|
112127
|
+
};
|
|
112128
|
+
const tracked = (call) => {
|
|
112129
|
+
clearTimeout(idleTimer);
|
|
112130
|
+
return call().finally(() => {
|
|
112131
|
+
if (!disposed) armIdleRelease();
|
|
112132
|
+
});
|
|
112133
|
+
};
|
|
112134
|
+
armIdleRelease();
|
|
112135
|
+
const request4 = (method, params) => tracked(async () => send(await connected(), method, params));
|
|
112136
|
+
const sendSetText = async (text, setOpts) => {
|
|
112137
|
+
const current = await connected();
|
|
112138
|
+
let result;
|
|
112139
|
+
try {
|
|
112140
|
+
result = await send(current, "setText", {
|
|
112141
|
+
text,
|
|
112142
|
+
...setOpts.check ? { check: true } : {}
|
|
112143
|
+
});
|
|
112144
|
+
} catch (err) {
|
|
112145
|
+
if (err instanceof Error && err.message.includes("Unknown method: setText")) {
|
|
112146
|
+
throw new FailureError("The devtools helper predates `setText`; update argent", {
|
|
112147
|
+
error_code: FAILURE_CODES.ANDROID_DEVTOOLS_RPC_ERROR,
|
|
112148
|
+
failure_stage: "android_devtools_set_text",
|
|
112149
|
+
failure_area: "tool_server",
|
|
112150
|
+
error_kind: "unknown"
|
|
112151
|
+
});
|
|
112152
|
+
}
|
|
112153
|
+
if (getFailureSignal(err)?.error_code === FAILURE_CODES.ANDROID_DEVTOOLS_RPC_TIMEOUT || err instanceof Error && err.message.includes("Helper worker timed out")) {
|
|
112154
|
+
return { focused: true, verified: false, timedOut: true };
|
|
112155
|
+
}
|
|
112156
|
+
throw err;
|
|
112157
|
+
}
|
|
112158
|
+
return {
|
|
112159
|
+
focused: result.focused === true,
|
|
112160
|
+
verified: result.verified === true,
|
|
112161
|
+
...typeof result.performed === "boolean" ? { performed: result.performed } : {},
|
|
112162
|
+
...typeof result.password === "boolean" ? { password: result.password } : {},
|
|
112163
|
+
...result.singleLine === true ? { singleLine: true } : {}
|
|
112164
|
+
};
|
|
112165
|
+
};
|
|
111969
112166
|
const api = {
|
|
111970
112167
|
isReady: () => ready2 && !disposed,
|
|
111971
112168
|
getHierarchy(getOpts = {}) {
|
|
@@ -111982,35 +112179,8 @@ var androidDevtoolsBlueprint = {
|
|
|
111982
112179
|
ping() {
|
|
111983
112180
|
return request4("ping");
|
|
111984
112181
|
},
|
|
111985
|
-
|
|
111986
|
-
|
|
111987
|
-
let result;
|
|
111988
|
-
try {
|
|
111989
|
-
result = await send(current, "setText", {
|
|
111990
|
-
text,
|
|
111991
|
-
...setOpts.check ? { check: true } : {}
|
|
111992
|
-
});
|
|
111993
|
-
} catch (err) {
|
|
111994
|
-
if (err instanceof Error && err.message.includes("Unknown method: setText")) {
|
|
111995
|
-
throw new FailureError("The devtools helper predates `setText`; update argent", {
|
|
111996
|
-
error_code: FAILURE_CODES.ANDROID_DEVTOOLS_RPC_ERROR,
|
|
111997
|
-
failure_stage: "android_devtools_set_text",
|
|
111998
|
-
failure_area: "tool_server",
|
|
111999
|
-
error_kind: "unknown"
|
|
112000
|
-
});
|
|
112001
|
-
}
|
|
112002
|
-
if (getFailureSignal(err)?.error_code === FAILURE_CODES.ANDROID_DEVTOOLS_RPC_TIMEOUT || err instanceof Error && err.message.includes("Helper worker timed out")) {
|
|
112003
|
-
return { focused: true, verified: false, timedOut: true };
|
|
112004
|
-
}
|
|
112005
|
-
throw err;
|
|
112006
|
-
}
|
|
112007
|
-
return {
|
|
112008
|
-
focused: result.focused === true,
|
|
112009
|
-
verified: result.verified === true,
|
|
112010
|
-
...typeof result.performed === "boolean" ? { performed: result.performed } : {},
|
|
112011
|
-
...typeof result.password === "boolean" ? { password: result.password } : {},
|
|
112012
|
-
...result.singleLine === true ? { singleLine: true } : {}
|
|
112013
|
-
};
|
|
112182
|
+
setText(text, setOpts = {}) {
|
|
112183
|
+
return tracked(() => sendSetText(text, setOpts));
|
|
112014
112184
|
}
|
|
112015
112185
|
};
|
|
112016
112186
|
const instance = {
|
|
@@ -112018,6 +112188,7 @@ var androidDevtoolsBlueprint = {
|
|
|
112018
112188
|
dispose: async () => {
|
|
112019
112189
|
disposed = true;
|
|
112020
112190
|
ready2 = false;
|
|
112191
|
+
clearTimeout(idleTimer);
|
|
112021
112192
|
let opening;
|
|
112022
112193
|
let acknowledged = false;
|
|
112023
112194
|
if (!procExited) {
|
|
@@ -115377,7 +115548,7 @@ data: ${JSON.stringify(data)}
|
|
|
115377
115548
|
const MAX_PREVIEW_BYTES = 25 * 1024 * 1024;
|
|
115378
115549
|
const allowedRoots = (() => {
|
|
115379
115550
|
const roots = /* @__PURE__ */ new Set();
|
|
115380
|
-
for (const r of [
|
|
115551
|
+
for (const r of [import_node_os8.default.tmpdir(), process.cwd(), "/tmp"]) {
|
|
115381
115552
|
try {
|
|
115382
115553
|
roots.add(import_node_fs11.default.realpathSync(r));
|
|
115383
115554
|
} catch {
|
|
@@ -115555,7 +115726,7 @@ function streamDirectoryAsArchive(id, entry, req, res) {
|
|
|
115555
115726
|
|
|
115556
115727
|
// ../tool-server/src/file-inputs.ts
|
|
115557
115728
|
var import_promises13 = require("node:fs/promises");
|
|
115558
|
-
var
|
|
115729
|
+
var import_node_os9 = require("node:os");
|
|
115559
115730
|
var import_node_path15 = require("node:path");
|
|
115560
115731
|
var import_bytes = __toESM(require_bytes());
|
|
115561
115732
|
init_src2();
|
|
@@ -115612,7 +115783,7 @@ function decodeContent(wire) {
|
|
|
115612
115783
|
}
|
|
115613
115784
|
async function materializeUpload(wire) {
|
|
115614
115785
|
const data = decodeContent(wire);
|
|
115615
|
-
const dir = await (0, import_promises13.mkdtemp)((0, import_node_path15.join)((0,
|
|
115786
|
+
const dir = await (0, import_promises13.mkdtemp)((0, import_node_path15.join)((0, import_node_os9.tmpdir)(), "argent-file-input-"));
|
|
115616
115787
|
const filePath = (0, import_node_path15.join)(dir, sanitizeFilename((0, import_node_path15.basename)(wire.path)));
|
|
115617
115788
|
await (0, import_promises13.writeFile)(filePath, data);
|
|
115618
115789
|
return { filePath, dir };
|
|
@@ -115636,7 +115807,7 @@ async function extractTarUpload(wire, uploadId, meta3, tempDirs, lookupUpload) {
|
|
|
115636
115807
|
);
|
|
115637
115808
|
}
|
|
115638
115809
|
const extractDir = await (0, import_promises13.mkdtemp)(
|
|
115639
|
-
(0, import_node_path15.join)((0,
|
|
115810
|
+
(0, import_node_path15.join)((0, import_node_os9.tmpdir)(), `argent-tar-upload-${entry.sha256.slice(0, 16)}-`)
|
|
115640
115811
|
);
|
|
115641
115812
|
tempDirs.push(extractDir);
|
|
115642
115813
|
const uploaded = await safeExtractArchive(entry.tarPath, extractDir, (0, import_node_path15.basename)(wire.path));
|
|
@@ -116364,7 +116535,7 @@ init_device_info();
|
|
|
116364
116535
|
|
|
116365
116536
|
// ../tool-server/src/blueprints/tv-control.ts
|
|
116366
116537
|
var net6 = __toESM(require("node:net"));
|
|
116367
|
-
var
|
|
116538
|
+
var fs39 = __toESM(require("node:fs"));
|
|
116368
116539
|
var import_node_child_process27 = require("node:child_process");
|
|
116369
116540
|
init_src2();
|
|
116370
116541
|
init_capability();
|
|
@@ -116662,7 +116833,7 @@ async function waitForSocket(socketPath, proc, timeoutMs) {
|
|
|
116662
116833
|
if (exited !== void 0) {
|
|
116663
116834
|
throw new Error(`tv daemon exited with code ${exited} before its socket was ready`);
|
|
116664
116835
|
}
|
|
116665
|
-
if (
|
|
116836
|
+
if (fs39.existsSync(socketPath)) {
|
|
116666
116837
|
const ok = await new Promise((resolve24) => {
|
|
116667
116838
|
const s = net6.createConnection(socketPath);
|
|
116668
116839
|
s.on("connect", () => {
|
|
@@ -116766,7 +116937,7 @@ var tvControlBlueprint = {
|
|
|
116766
116937
|
await reapDaemons(axSock);
|
|
116767
116938
|
for (const p of [axSock, hidSock]) {
|
|
116768
116939
|
try {
|
|
116769
|
-
|
|
116940
|
+
fs39.unlinkSync(p);
|
|
116770
116941
|
} catch {
|
|
116771
116942
|
}
|
|
116772
116943
|
}
|
|
@@ -116782,7 +116953,7 @@ var tvControlBlueprint = {
|
|
|
116782
116953
|
}
|
|
116783
116954
|
axExited = false;
|
|
116784
116955
|
try {
|
|
116785
|
-
|
|
116956
|
+
fs39.unlinkSync(axSock);
|
|
116786
116957
|
} catch {
|
|
116787
116958
|
}
|
|
116788
116959
|
await reapDaemons(axSock);
|
|
@@ -116807,7 +116978,7 @@ var tvControlBlueprint = {
|
|
|
116807
116978
|
axProc.kill("SIGKILL");
|
|
116808
116979
|
}
|
|
116809
116980
|
try {
|
|
116810
|
-
|
|
116981
|
+
fs39.unlinkSync(axSock);
|
|
116811
116982
|
} catch {
|
|
116812
116983
|
}
|
|
116813
116984
|
}
|
|
@@ -116914,7 +117085,7 @@ var tvControlBlueprint = {
|
|
|
116914
117085
|
await reapDaemons(axSock);
|
|
116915
117086
|
for (const p of [axSock, hidSock]) {
|
|
116916
117087
|
try {
|
|
116917
|
-
|
|
117088
|
+
fs39.unlinkSync(p);
|
|
116918
117089
|
} catch {
|
|
116919
117090
|
}
|
|
116920
117091
|
}
|
|
@@ -117436,10 +117607,10 @@ function reserveLaunchMeasurement(udid) {
|
|
|
117436
117607
|
// ../tool-server/src/utils/ios-device/runner-artifact.ts
|
|
117437
117608
|
var import_node_child_process29 = require("node:child_process");
|
|
117438
117609
|
var import_node_util21 = require("node:util");
|
|
117439
|
-
var
|
|
117440
|
-
var
|
|
117610
|
+
var import_node_crypto13 = require("node:crypto");
|
|
117611
|
+
var fs41 = __toESM(require("node:fs"));
|
|
117441
117612
|
var fsp = __toESM(require("node:fs/promises"));
|
|
117442
|
-
var
|
|
117613
|
+
var path36 = __toESM(require("node:path"));
|
|
117443
117614
|
init_src2();
|
|
117444
117615
|
|
|
117445
117616
|
// ../tool-server/src/utils/ios-device/runner-signing.ts
|
|
@@ -117448,13 +117619,13 @@ init_src2();
|
|
|
117448
117619
|
// ../tool-server/src/utils/ios-device/provisioning-profiles.ts
|
|
117449
117620
|
var import_node_child_process28 = require("node:child_process");
|
|
117450
117621
|
var import_node_fs13 = require("node:fs");
|
|
117451
|
-
var
|
|
117452
|
-
var
|
|
117622
|
+
var import_node_os10 = require("node:os");
|
|
117623
|
+
var path35 = __toESM(require("node:path"));
|
|
117453
117624
|
var import_node_util20 = require("node:util");
|
|
117454
117625
|
var execFileAsync19 = (0, import_node_util20.promisify)(import_node_child_process28.execFile);
|
|
117455
117626
|
var PROFILE_DIRECTORIES = [
|
|
117456
|
-
|
|
117457
|
-
|
|
117627
|
+
path35.join("Library", "Developer", "Xcode", "UserData", "Provisioning Profiles"),
|
|
117628
|
+
path35.join("Library", "MobileDevice", "Provisioning Profiles")
|
|
117458
117629
|
];
|
|
117459
117630
|
var PROFILE_DECODE_TIMEOUT_MS = 5e3;
|
|
117460
117631
|
var PROFILE_MAX_BYTES = 16 * 1024 * 1024;
|
|
@@ -117475,9 +117646,9 @@ function parseProvisioningProfile(xml) {
|
|
|
117475
117646
|
async function readInstalledProfiles() {
|
|
117476
117647
|
const files = (await Promise.all(
|
|
117477
117648
|
PROFILE_DIRECTORIES.map(async (directory) => {
|
|
117478
|
-
const absolute =
|
|
117649
|
+
const absolute = path35.join((0, import_node_os10.homedir)(), directory);
|
|
117479
117650
|
const names = await import_node_fs13.promises.readdir(absolute).catch(() => []);
|
|
117480
|
-
return names.filter((name) => name.endsWith(".mobileprovision")).map((name) =>
|
|
117651
|
+
return names.filter((name) => name.endsWith(".mobileprovision")).map((name) => path35.join(absolute, name));
|
|
117481
117652
|
})
|
|
117482
117653
|
)).flat();
|
|
117483
117654
|
const decoded2 = await Promise.all(
|
|
@@ -117568,8 +117739,8 @@ function resolveRunnerProjectPath() {
|
|
|
117568
117739
|
if (override) {
|
|
117569
117740
|
return override;
|
|
117570
117741
|
}
|
|
117571
|
-
const candidate =
|
|
117572
|
-
if (
|
|
117742
|
+
const candidate = path36.resolve(__dirname, PROJECT_SUFFIX);
|
|
117743
|
+
if (fs41.existsSync(candidate)) {
|
|
117573
117744
|
return candidate;
|
|
117574
117745
|
}
|
|
117575
117746
|
throw withFailureSignal(
|
|
@@ -117594,8 +117765,8 @@ var FINGERPRINT_NOISE = /* @__PURE__ */ new Set([
|
|
|
117594
117765
|
".DS_Store"
|
|
117595
117766
|
]);
|
|
117596
117767
|
async function fingerprintRunnerSources(projectPath) {
|
|
117597
|
-
const root =
|
|
117598
|
-
const hash2 = (0,
|
|
117768
|
+
const root = path36.dirname(projectPath);
|
|
117769
|
+
const hash2 = (0, import_node_crypto13.createHash)("sha256");
|
|
117599
117770
|
const walk = async (dir) => {
|
|
117600
117771
|
const entries = (await fsp.readdir(dir, { withFileTypes: true })).sort(
|
|
117601
117772
|
(a, b) => a.name.localeCompare(b.name)
|
|
@@ -117604,12 +117775,12 @@ async function fingerprintRunnerSources(projectPath) {
|
|
|
117604
117775
|
if (FINGERPRINT_NOISE.has(entry.name)) {
|
|
117605
117776
|
continue;
|
|
117606
117777
|
}
|
|
117607
|
-
const full =
|
|
117778
|
+
const full = path36.join(dir, entry.name);
|
|
117608
117779
|
if (entry.isDirectory()) {
|
|
117609
117780
|
await walk(full);
|
|
117610
117781
|
} else if (entry.isFile()) {
|
|
117611
117782
|
const content = await fsp.readFile(full);
|
|
117612
|
-
hash2.update(`${
|
|
117783
|
+
hash2.update(`${path36.relative(root, full)}|${content.length}
|
|
117613
117784
|
`);
|
|
117614
117785
|
hash2.update(content);
|
|
117615
117786
|
}
|
|
@@ -117627,10 +117798,10 @@ async function xcodeVersionFingerprint() {
|
|
|
117627
117798
|
}
|
|
117628
117799
|
}
|
|
117629
117800
|
function derivedRoot() {
|
|
117630
|
-
return
|
|
117801
|
+
return path36.join(argentHomeDir(), "ios-device-runner", "derived");
|
|
117631
117802
|
}
|
|
117632
117803
|
function derivedDirForTeam(teamId) {
|
|
117633
|
-
return
|
|
117804
|
+
return path36.join(derivedRoot(), teamId);
|
|
117634
117805
|
}
|
|
117635
117806
|
var CACHE_KEY_FILE = ".argent-cache-key";
|
|
117636
117807
|
var TEAM_DIRECTORY_RE = /^[A-Z0-9]{10}$/;
|
|
@@ -117638,24 +117809,24 @@ async function removeBuildSharedByAllTeams(currentTeamId) {
|
|
|
117638
117809
|
const root = derivedRoot();
|
|
117639
117810
|
const entries = await fsp.readdir(root).catch(() => []);
|
|
117640
117811
|
await Promise.all(
|
|
117641
|
-
entries.filter((entry) => entry !== currentTeamId && !TEAM_DIRECTORY_RE.test(entry)).map((entry) => fsp.rm(
|
|
117812
|
+
entries.filter((entry) => entry !== currentTeamId && !TEAM_DIRECTORY_RE.test(entry)).map((entry) => fsp.rm(path36.join(root, entry), { recursive: true, force: true }))
|
|
117642
117813
|
);
|
|
117643
117814
|
}
|
|
117644
117815
|
function runnerProductsDir(derivedDataPath) {
|
|
117645
|
-
return
|
|
117816
|
+
return path36.join(derivedDataPath, "Build", "Products");
|
|
117646
117817
|
}
|
|
117647
117818
|
function findBaseXctestrun(derivedDataPath) {
|
|
117648
117819
|
const productsDir = runnerProductsDir(derivedDataPath);
|
|
117649
|
-
if (!
|
|
117820
|
+
if (!fs41.existsSync(productsDir)) {
|
|
117650
117821
|
return null;
|
|
117651
117822
|
}
|
|
117652
|
-
const candidates =
|
|
117823
|
+
const candidates = fs41.readdirSync(productsDir).filter((name) => {
|
|
117653
117824
|
return name.endsWith(".xctestrun") && name.includes("iphoneos");
|
|
117654
117825
|
});
|
|
117655
117826
|
if (candidates.length === 0) {
|
|
117656
117827
|
return null;
|
|
117657
117828
|
}
|
|
117658
|
-
return
|
|
117829
|
+
return path36.join(productsDir, candidates.sort()[0]);
|
|
117659
117830
|
}
|
|
117660
117831
|
function xcodebuildFailureSummary(output2) {
|
|
117661
117832
|
const lines = output2.split("\n");
|
|
@@ -117692,19 +117863,19 @@ function runnerBuildStaticArgs(projectPath, config2) {
|
|
|
117692
117863
|
];
|
|
117693
117864
|
}
|
|
117694
117865
|
function runnerBuildLocationArgs(derivedDataPath) {
|
|
117695
|
-
const root =
|
|
117696
|
-
const intermediatesDir =
|
|
117866
|
+
const root = path36.resolve(derivedDataPath);
|
|
117867
|
+
const intermediatesDir = path36.join(root, "Build", "Intermediates.noindex");
|
|
117697
117868
|
return [
|
|
117698
117869
|
"-derivedDataPath",
|
|
117699
117870
|
derivedDataPath,
|
|
117700
117871
|
`SYMROOT=${runnerProductsDir(root)}`,
|
|
117701
117872
|
`OBJROOT=${intermediatesDir}`,
|
|
117702
117873
|
// Set from the same preference, and OBJROOT does not move it.
|
|
117703
|
-
`SHARED_PRECOMPS_DIR=${
|
|
117874
|
+
`SHARED_PRECOMPS_DIR=${path36.join(intermediatesDir, "PrecompiledHeaders")}`
|
|
117704
117875
|
];
|
|
117705
117876
|
}
|
|
117706
117877
|
function computeRunnerCacheKey(sourcesHash, xcodeVersion2, staticArgs) {
|
|
117707
|
-
return (0,
|
|
117878
|
+
return (0, import_node_crypto13.createHash)("sha256").update([sourcesHash, xcodeVersion2, ...staticArgs].join("\n")).digest("hex").slice(0, 16);
|
|
117708
117879
|
}
|
|
117709
117880
|
function isProfileMissingDeviceFailure(logText) {
|
|
117710
117881
|
return logText.includes("0xe8008012") || /doesn't include the currently selected device/i.test(logText) || /provisioning profile cannot be installed on this device/i.test(logText) || /team has no devices/i.test(logText);
|
|
@@ -117715,7 +117886,7 @@ function isProfileExpiredFailure(logText) {
|
|
|
117715
117886
|
var EXPIRY_RE = /<key>ExpirationDate<\/key>\s*<date>([^<]+)<\/date>/;
|
|
117716
117887
|
var PROFILE_RENEWAL_MARGIN_MS = 60 * 60 * 1e3;
|
|
117717
117888
|
async function readRunnerExpiryDate(derivedDataPath) {
|
|
117718
|
-
const file2 =
|
|
117889
|
+
const file2 = path36.join(
|
|
117719
117890
|
runnerProductsDir(derivedDataPath),
|
|
117720
117891
|
"Debug-iphoneos",
|
|
117721
117892
|
"ArgentRunnerUITests-Runner.app",
|
|
@@ -117745,7 +117916,7 @@ async function ensureRunnerArtifact(config2, opts = {}) {
|
|
|
117745
117916
|
const build2 = opts.build ?? buildRunnerArtifact;
|
|
117746
117917
|
return withRunnerBuildLock(async () => {
|
|
117747
117918
|
await removeBuildSharedByAllTeams(config2.teamId);
|
|
117748
|
-
const stampPath =
|
|
117919
|
+
const stampPath = path36.join(derivedDataPath, CACHE_KEY_FILE);
|
|
117749
117920
|
const stamped = await fsp.readFile(stampPath, "utf8").catch(() => null);
|
|
117750
117921
|
if (!opts.force && stamped === cacheKey2) {
|
|
117751
117922
|
const cached3 = findBaseXctestrun(derivedDataPath);
|
|
@@ -117831,18 +118002,18 @@ ${xcodebuildFailureSummary(output2)}`,
|
|
|
117831
118002
|
// ../tool-server/src/utils/ios-device/runner-launch.ts
|
|
117832
118003
|
var import_node_child_process30 = require("node:child_process");
|
|
117833
118004
|
var import_node_events2 = require("node:events");
|
|
117834
|
-
var
|
|
118005
|
+
var fs42 = __toESM(require("node:fs"));
|
|
117835
118006
|
var fsp2 = __toESM(require("node:fs/promises"));
|
|
117836
|
-
var
|
|
118007
|
+
var path37 = __toESM(require("node:path"));
|
|
117837
118008
|
var import_node_util22 = require("node:util");
|
|
117838
118009
|
init_src2();
|
|
117839
118010
|
init_src();
|
|
117840
118011
|
var execFileAsync21 = (0, import_node_util22.promisify)(import_node_child_process30.execFile);
|
|
117841
118012
|
function logsRoot() {
|
|
117842
|
-
return
|
|
118013
|
+
return path37.join(argentHomeDir(), "ios-device-runner", "logs");
|
|
117843
118014
|
}
|
|
117844
118015
|
function resultsRoot() {
|
|
117845
|
-
return
|
|
118016
|
+
return path37.join(argentHomeDir(), "ios-device-runner", "results");
|
|
117846
118017
|
}
|
|
117847
118018
|
var RUNNER_ATTACHMENT_SETTINGS = [
|
|
117848
118019
|
["PreferredScreenCaptureFormat", "screenshots"],
|
|
@@ -117875,11 +118046,11 @@ async function launchRunner(opts) {
|
|
|
117875
118046
|
fsp2.mkdir(resultsDir, { recursive: true })
|
|
117876
118047
|
]);
|
|
117877
118048
|
const deviceTag = opts.udid.slice(0, 8);
|
|
117878
|
-
const logPath =
|
|
117879
|
-
const resultBundlePath =
|
|
118049
|
+
const logPath = path37.join(logDir, `runner-${deviceTag}.log`);
|
|
118050
|
+
const resultBundlePath = path37.join(resultsDir, `argent-${deviceTag}.xcresult`);
|
|
117880
118051
|
await fsp2.rm(resultBundlePath, { recursive: true, force: true });
|
|
117881
118052
|
await disableRunnerAttachments(opts.xctestrunPath);
|
|
117882
|
-
const logFd =
|
|
118053
|
+
const logFd = fs42.openSync(logPath, "w");
|
|
117883
118054
|
const child = (0, import_node_child_process30.spawn)(
|
|
117884
118055
|
"xcodebuild",
|
|
117885
118056
|
[
|
|
@@ -117916,7 +118087,7 @@ async function launchRunner(opts) {
|
|
|
117916
118087
|
}
|
|
117917
118088
|
);
|
|
117918
118089
|
child.unref();
|
|
117919
|
-
|
|
118090
|
+
fs42.closeSync(logFd);
|
|
117920
118091
|
try {
|
|
117921
118092
|
await (0, import_node_events2.once)(child, "spawn");
|
|
117922
118093
|
} catch (error63) {
|
|
@@ -117967,7 +118138,7 @@ function killRunnerProcess(child) {
|
|
|
117967
118138
|
// ../tool-server/src/utils/ios-device/runner-sweep.ts
|
|
117968
118139
|
var import_node_child_process31 = require("node:child_process");
|
|
117969
118140
|
var import_node_util23 = require("node:util");
|
|
117970
|
-
var
|
|
118141
|
+
var path38 = __toESM(require("node:path"));
|
|
117971
118142
|
init_src();
|
|
117972
118143
|
var execFileAsync22 = (0, import_node_util23.promisify)(import_node_child_process31.execFile);
|
|
117973
118144
|
var PROCESS_TABLE_MAX_BYTES = 16 * 1024 * 1024;
|
|
@@ -117989,7 +118160,7 @@ async function killStaleRunnersForDevice(udid, listProcesses = listProcessTable)
|
|
|
117989
118160
|
const kill = process.kill.bind(process);
|
|
117990
118161
|
const signaled = [];
|
|
117991
118162
|
for (const line of stdout.split("\n")) {
|
|
117992
|
-
if (!line.includes("test-without-building") || !line.includes(`platform=iOS,id=${udid}`) || !line.includes(` ${
|
|
118163
|
+
if (!line.includes("test-without-building") || !line.includes(`platform=iOS,id=${udid}`) || !line.includes(` ${path38.join(argentHomeDir(), "ios-device-runner")}${path38.sep}`)) {
|
|
117993
118164
|
continue;
|
|
117994
118165
|
}
|
|
117995
118166
|
const [pidField, ppidField] = line.trim().split(/\s+/);
|
|
@@ -118017,7 +118188,7 @@ async function killStaleRunnersForDevice(udid, listProcesses = listProcessTable)
|
|
|
118017
118188
|
}
|
|
118018
118189
|
|
|
118019
118190
|
// ../tool-server/src/blueprints/ios-device-runner.ts
|
|
118020
|
-
var
|
|
118191
|
+
var fs44 = __toESM(require("node:fs/promises"));
|
|
118021
118192
|
|
|
118022
118193
|
// ../tool-server/src/utils/ios-device/runner-route.ts
|
|
118023
118194
|
var import_node_net3 = __toESM(require("node:net"));
|
|
@@ -118405,7 +118576,7 @@ function defaultSendViaUsbmux(udid, port, body, deadline) {
|
|
|
118405
118576
|
// ../tool-server/src/utils/ios-device/runner-crash.ts
|
|
118406
118577
|
var import_node_child_process32 = require("node:child_process");
|
|
118407
118578
|
var import_node_util24 = require("node:util");
|
|
118408
|
-
var
|
|
118579
|
+
var fs43 = __toESM(require("node:fs/promises"));
|
|
118409
118580
|
var execFileAsync23 = (0, import_node_util24.promisify)(import_node_child_process32.execFile);
|
|
118410
118581
|
var XCRESULTTOOL_TIMEOUT_MS = 15e3;
|
|
118411
118582
|
var XCRESULTTOOL_MAX_JSON_BYTES = 32 * 1024 * 1024;
|
|
@@ -118425,7 +118596,7 @@ function extractCrashFailureText(summary) {
|
|
|
118425
118596
|
}
|
|
118426
118597
|
async function readRunnerCrashSummary(resultBundlePath) {
|
|
118427
118598
|
try {
|
|
118428
|
-
await
|
|
118599
|
+
await fs43.access(resultBundlePath);
|
|
118429
118600
|
const { stdout } = await execFileAsync23(
|
|
118430
118601
|
"xcrun",
|
|
118431
118602
|
["xcresulttool", "get", "test-results", "summary", "--path", resultBundlePath],
|
|
@@ -118438,7 +118609,7 @@ async function readRunnerCrashSummary(resultBundlePath) {
|
|
|
118438
118609
|
}
|
|
118439
118610
|
|
|
118440
118611
|
// ../tool-server/src/utils/ios-device/runner-client.ts
|
|
118441
|
-
var
|
|
118612
|
+
var import_node_crypto14 = require("node:crypto");
|
|
118442
118613
|
init_src2();
|
|
118443
118614
|
var RUNNER_COMMAND_TIMEOUT_MS = 45e3;
|
|
118444
118615
|
var RUNNER_STATUS_RECOVERY_TIMEOUT_MS = 3e3;
|
|
@@ -118651,7 +118822,7 @@ function withCommandId(command2) {
|
|
|
118651
118822
|
if (command2.command === "status" || typeof command2.commandId === "string") {
|
|
118652
118823
|
return command2;
|
|
118653
118824
|
}
|
|
118654
|
-
return { ...command2, commandId: `argent-${(0,
|
|
118825
|
+
return { ...command2, commandId: `argent-${(0, import_node_crypto14.randomUUID)()}` };
|
|
118655
118826
|
}
|
|
118656
118827
|
function unwrapEnvelope(response, udid) {
|
|
118657
118828
|
const envelope = asEnvelope(response);
|
|
@@ -118798,7 +118969,7 @@ async function startRunner(udid, artifact, tunnelAddress) {
|
|
|
118798
118969
|
launched.child.once("exit", reserveInteractionRunner(udid));
|
|
118799
118970
|
}
|
|
118800
118971
|
killRunnerProcess(launched.child);
|
|
118801
|
-
const logText = await
|
|
118972
|
+
const logText = await fs44.readFile(launched.logPath, "utf8").catch(() => "");
|
|
118802
118973
|
throw Object.assign(
|
|
118803
118974
|
withFailureSignal(
|
|
118804
118975
|
new Error(
|
|
@@ -123779,7 +123950,7 @@ async function describeVega(_serial) {
|
|
|
123779
123950
|
}
|
|
123780
123951
|
|
|
123781
123952
|
// ../tool-server/src/tools/describe/platforms/harmony/index.ts
|
|
123782
|
-
var
|
|
123953
|
+
var import_node_os11 = require("node:os");
|
|
123783
123954
|
var import_node_path16 = require("node:path");
|
|
123784
123955
|
var import_promises15 = require("node:fs/promises");
|
|
123785
123956
|
|
|
@@ -124303,7 +124474,7 @@ function pollHarmonyTree(connectKey, budgetMs) {
|
|
|
124303
124474
|
return describeHarmony(connectKey, budgetMs);
|
|
124304
124475
|
}
|
|
124305
124476
|
async function describeHarmony(connectKey, timeoutMs = HARMONY_INTERACTION_TIMEOUT_MS) {
|
|
124306
|
-
const localPath = (0, import_node_path16.join)((0,
|
|
124477
|
+
const localPath = (0, import_node_path16.join)((0, import_node_os11.tmpdir)(), `argent-harmony-dump-${process.hrtime.bigint()}.json`);
|
|
124307
124478
|
const deadline = Date.now() + timeoutMs;
|
|
124308
124479
|
const display = await harmonyDisplay(
|
|
124309
124480
|
connectKey,
|
|
@@ -124339,12 +124510,12 @@ init_src2();
|
|
|
124339
124510
|
|
|
124340
124511
|
// ../tool-server/src/blueprints/macos-app.ts
|
|
124341
124512
|
var import_node_child_process33 = require("node:child_process");
|
|
124342
|
-
var
|
|
124513
|
+
var import_node_crypto15 = require("node:crypto");
|
|
124343
124514
|
var import_node_events5 = require("node:events");
|
|
124344
|
-
var
|
|
124515
|
+
var fs45 = __toESM(require("node:fs"));
|
|
124345
124516
|
var net9 = __toESM(require("node:net"));
|
|
124346
124517
|
var os12 = __toESM(require("node:os"));
|
|
124347
|
-
var
|
|
124518
|
+
var path39 = __toESM(require("node:path"));
|
|
124348
124519
|
init_src2();
|
|
124349
124520
|
init_device_info();
|
|
124350
124521
|
|
|
@@ -124582,7 +124753,7 @@ async function stopProcesses(pids, executable, group) {
|
|
|
124582
124753
|
}
|
|
124583
124754
|
function readLogTail(logPath) {
|
|
124584
124755
|
try {
|
|
124585
|
-
const lines =
|
|
124756
|
+
const lines = fs45.readFileSync(logPath, "utf8").trimEnd().split("\n");
|
|
124586
124757
|
const tail = lines.slice(-20).join("\n").trim();
|
|
124587
124758
|
return tail ? `
|
|
124588
124759
|
Last lines of ${logPath}:
|
|
@@ -124626,7 +124797,7 @@ function closedByArgentError(bundleId, method) {
|
|
|
124626
124797
|
"unknown"
|
|
124627
124798
|
);
|
|
124628
124799
|
}
|
|
124629
|
-
var nextCdpWireId = (0,
|
|
124800
|
+
var nextCdpWireId = (0, import_node_crypto15.randomInt)(2 ** 47);
|
|
124630
124801
|
var LibraryChannel = class {
|
|
124631
124802
|
/**
|
|
124632
124803
|
* @param expectedPid the app's pid when known; a launch learns it from the helper after the spawn.
|
|
@@ -125287,7 +125458,7 @@ function createMacosAppApi(bundleId) {
|
|
|
125287
125458
|
"not_found"
|
|
125288
125459
|
);
|
|
125289
125460
|
}
|
|
125290
|
-
if (!opts.appPath && tracked && !
|
|
125461
|
+
if (!opts.appPath && tracked && !fs45.existsSync(appPath)) {
|
|
125291
125462
|
throw macosFailure(
|
|
125292
125463
|
`argent last started ${bundleId} from ${appPath}, which no longer exists. Pass the .app path to boot-device as macosAppPath.`,
|
|
125293
125464
|
FAILURE_CODES.MACOS_APP_PATH_INVALID,
|
|
@@ -125347,6 +125518,10 @@ function createMacosAppApi(bundleId) {
|
|
|
125347
125518
|
);
|
|
125348
125519
|
}
|
|
125349
125520
|
const bootstrapPath = await stageLibraryFor(info, artifacts);
|
|
125521
|
+
const listen4 = macosListenSocket(bundleId, info.sandboxed);
|
|
125522
|
+
const logPath = macosAppLogPath(bundleId);
|
|
125523
|
+
fs45.mkdirSync(path39.dirname(logPath), { recursive: true, mode: 448 });
|
|
125524
|
+
if (listen4 && !info.sandboxed) prepareSocketDir(listen4.path);
|
|
125350
125525
|
const forceQuit = own2 ? await terminate(own2) : void 0;
|
|
125351
125526
|
let tookOver;
|
|
125352
125527
|
if (copies.same.length > 0) {
|
|
@@ -125363,11 +125538,8 @@ function createMacosAppApi(bundleId) {
|
|
|
125363
125538
|
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.`;
|
|
125364
125539
|
}
|
|
125365
125540
|
}
|
|
125366
|
-
|
|
125367
|
-
|
|
125368
|
-
fs44.mkdirSync(path38.dirname(logPath), { recursive: true, mode: 448 });
|
|
125369
|
-
if (listen4 && !info.sandboxed) fs44.rmSync(listen4.path, { force: true });
|
|
125370
|
-
fs44.writeFileSync(logPath, "");
|
|
125541
|
+
if (listen4 && !info.sandboxed) fs45.rmSync(listen4.path, { force: true });
|
|
125542
|
+
fs45.writeFileSync(logPath, "");
|
|
125371
125543
|
const args = opts.args ?? (opts.noLastArgs ? void 0 : tracked?.args) ?? [];
|
|
125372
125544
|
const helper = (0, import_node_child_process33.spawn)(
|
|
125373
125545
|
artifacts.helper,
|
|
@@ -126955,8 +127127,8 @@ var SourceMapsRegistry = class {
|
|
|
126955
127127
|
};
|
|
126956
127128
|
|
|
126957
127129
|
// ../tool-server/src/utils/debugger/log-file-writer.ts
|
|
126958
|
-
var
|
|
126959
|
-
var
|
|
127130
|
+
var fs46 = __toESM(require("node:fs"));
|
|
127131
|
+
var path40 = __toESM(require("node:path"));
|
|
126960
127132
|
init_src();
|
|
126961
127133
|
var MAX_ENTRIES = 5e4;
|
|
126962
127134
|
var STALE_LOG_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -126982,19 +127154,19 @@ var LogFileWriter = class {
|
|
|
126982
127154
|
closed = false;
|
|
126983
127155
|
constructor(port) {
|
|
126984
127156
|
const timestamp = lastTimestamp = Math.max(Date.now(), lastTimestamp + 1);
|
|
126985
|
-
const dir =
|
|
127157
|
+
const dir = path40.join(argentHomeDir(), "tmp");
|
|
126986
127158
|
try {
|
|
126987
|
-
|
|
127159
|
+
fs46.mkdirSync(dir, { recursive: true });
|
|
126988
127160
|
} catch {
|
|
126989
127161
|
}
|
|
126990
127162
|
pruneStaleLogs(dir);
|
|
126991
|
-
this.filePath =
|
|
127163
|
+
this.filePath = path40.join(dir, `argent-logs-${port}-${timestamp}-p${process.pid}.log`);
|
|
126992
127164
|
liveLogFiles.add(this.filePath);
|
|
126993
127165
|
this.open();
|
|
126994
127166
|
}
|
|
126995
127167
|
open() {
|
|
126996
127168
|
try {
|
|
126997
|
-
this.fd =
|
|
127169
|
+
this.fd = fs46.openSync(this.filePath, "w");
|
|
126998
127170
|
this.ready = true;
|
|
126999
127171
|
} catch {
|
|
127000
127172
|
}
|
|
@@ -127020,7 +127192,7 @@ var LogFileWriter = class {
|
|
|
127020
127192
|
try {
|
|
127021
127193
|
const bytes = Buffer.from(this.midLine ? `
|
|
127022
127194
|
${line}` : line);
|
|
127023
|
-
const written =
|
|
127195
|
+
const written = fs46.writeSync(this.fd, bytes, 0, bytes.length, this.bytesWritten);
|
|
127024
127196
|
if (written === bytes.length) {
|
|
127025
127197
|
this.bytesWritten += written;
|
|
127026
127198
|
this.midLine = false;
|
|
@@ -127072,7 +127244,7 @@ ${line}` : line);
|
|
|
127072
127244
|
/** A torn line past " | " would parse as a whole entry with its message cut. */
|
|
127073
127245
|
dropTornLine(fd, bytes, written) {
|
|
127074
127246
|
try {
|
|
127075
|
-
|
|
127247
|
+
fs46.ftruncateSync(fd, this.bytesWritten);
|
|
127076
127248
|
} catch {
|
|
127077
127249
|
this.bytesWritten += written;
|
|
127078
127250
|
if (written > 0) this.midLine = bytes[written - 1] !== 10;
|
|
@@ -127086,7 +127258,7 @@ ${line}` : line);
|
|
|
127086
127258
|
return this.fileEntryCount;
|
|
127087
127259
|
}
|
|
127088
127260
|
hasFile() {
|
|
127089
|
-
return
|
|
127261
|
+
return fs46.existsSync(this.filePath);
|
|
127090
127262
|
}
|
|
127091
127263
|
getStats() {
|
|
127092
127264
|
return {
|
|
@@ -127111,7 +127283,7 @@ ${line}` : line);
|
|
|
127111
127283
|
readAll() {
|
|
127112
127284
|
if (this.closed || !this.ready) return [];
|
|
127113
127285
|
try {
|
|
127114
|
-
const content =
|
|
127286
|
+
const content = fs46.readFileSync(this.filePath, "utf-8");
|
|
127115
127287
|
return content.split("\n").filter((line) => line.length > 0).map(parseFlatLine).filter((entry) => entry !== null);
|
|
127116
127288
|
} catch {
|
|
127117
127289
|
return [];
|
|
@@ -127133,7 +127305,7 @@ ${line}` : line);
|
|
|
127133
127305
|
liveLogFiles.delete(this.filePath);
|
|
127134
127306
|
if (this.fd !== null) {
|
|
127135
127307
|
try {
|
|
127136
|
-
|
|
127308
|
+
fs46.closeSync(this.fd);
|
|
127137
127309
|
} catch {
|
|
127138
127310
|
}
|
|
127139
127311
|
this.fd = null;
|
|
@@ -127141,13 +127313,13 @@ ${line}` : line);
|
|
|
127141
127313
|
if (keepFile) {
|
|
127142
127314
|
try {
|
|
127143
127315
|
const now = /* @__PURE__ */ new Date();
|
|
127144
|
-
|
|
127316
|
+
fs46.utimesSync(this.filePath, now, now);
|
|
127145
127317
|
} catch {
|
|
127146
127318
|
}
|
|
127147
127319
|
return;
|
|
127148
127320
|
}
|
|
127149
127321
|
try {
|
|
127150
|
-
|
|
127322
|
+
fs46.unlinkSync(this.filePath);
|
|
127151
127323
|
} catch {
|
|
127152
127324
|
}
|
|
127153
127325
|
}
|
|
@@ -127156,17 +127328,17 @@ function pruneStaleLogs(dir) {
|
|
|
127156
127328
|
const cutoff = Date.now() - STALE_LOG_MS;
|
|
127157
127329
|
let names;
|
|
127158
127330
|
try {
|
|
127159
|
-
names =
|
|
127331
|
+
names = fs46.readdirSync(dir);
|
|
127160
127332
|
} catch {
|
|
127161
127333
|
return;
|
|
127162
127334
|
}
|
|
127163
127335
|
for (const name of names) {
|
|
127164
127336
|
const pid = Number(/^argent-logs-.*-p(\d+)\.log$/.exec(name)?.[1]);
|
|
127165
127337
|
if (!pid) continue;
|
|
127166
|
-
const file2 =
|
|
127338
|
+
const file2 = path40.join(dir, name);
|
|
127167
127339
|
if (pid === process.pid ? liveLogFiles.has(file2) : isAlive(pid)) continue;
|
|
127168
127340
|
try {
|
|
127169
|
-
if (
|
|
127341
|
+
if (fs46.statSync(file2).mtimeMs < cutoff) fs46.unlinkSync(file2);
|
|
127170
127342
|
} catch {
|
|
127171
127343
|
}
|
|
127172
127344
|
}
|
|
@@ -127830,39 +128002,6 @@ function directCallFailure(tool, result) {
|
|
|
127830
128002
|
return toolResultVerdict(tool, result)?.reason;
|
|
127831
128003
|
}
|
|
127832
128004
|
|
|
127833
|
-
// ../tool-server/src/utils/argent-home-id.ts
|
|
127834
|
-
var import_node_crypto15 = require("node:crypto");
|
|
127835
|
-
var fs46 = __toESM(require("node:fs"));
|
|
127836
|
-
var import_node_os11 = require("node:os");
|
|
127837
|
-
var path40 = __toESM(require("node:path"));
|
|
127838
|
-
init_src();
|
|
127839
|
-
var ARGENT_HOME_HEADER = "x-argent-home";
|
|
127840
|
-
function canonicalDir(dir) {
|
|
127841
|
-
const resolved = path40.resolve(dir);
|
|
127842
|
-
const parent = path40.dirname(resolved);
|
|
127843
|
-
if (fs46.existsSync(resolved) || parent === resolved) return canonicalPath(resolved);
|
|
127844
|
-
return path40.join(canonicalDir(parent), path40.basename(resolved));
|
|
127845
|
-
}
|
|
127846
|
-
function argentHomeId(dir = argentHomeDir()) {
|
|
127847
|
-
return (0, import_node_crypto15.createHash)("sha256").update(canonicalDir(dir)).digest("hex").slice(0, 12);
|
|
127848
|
-
}
|
|
127849
|
-
function peerArgentHomeId(header) {
|
|
127850
|
-
if (typeof header === "string" && header) return header;
|
|
127851
|
-
return argentHomeId(path40.join(resolveHomeDir(), ".argent"));
|
|
127852
|
-
}
|
|
127853
|
-
var LOOPBACK_ADDRESSES = /* @__PURE__ */ new Set(["127.0.0.1", "::1", "::ffff:127.0.0.1"]);
|
|
127854
|
-
function isOwnAddress(address) {
|
|
127855
|
-
const ip = address.replace(/^::ffff:(?=\d+\.\d+\.\d+\.\d+$)/, "");
|
|
127856
|
-
return Object.values((0, import_node_os11.networkInterfaces)()).some(
|
|
127857
|
-
(list) => list?.some((a) => (a.family === "IPv4" || a.scopeid === 0) && a.address === ip)
|
|
127858
|
-
);
|
|
127859
|
-
}
|
|
127860
|
-
function isLocalConnection(socket) {
|
|
127861
|
-
const remote = socket.remoteAddress;
|
|
127862
|
-
if (remote === void 0) return false;
|
|
127863
|
-
return LOOPBACK_ADDRESSES.has(remote) || remote === socket.localAddress || isOwnAddress(remote);
|
|
127864
|
-
}
|
|
127865
|
-
|
|
127866
128005
|
// ../tool-server/src/http.ts
|
|
127867
128006
|
var AUTO_SUPPRESS_MS = 30 * 60 * 1e3;
|
|
127868
128007
|
var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
|