@swmansion/argent 0.35.1-next.73 → 0.35.1-next.74

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.
@@ -73314,7 +73314,7 @@ function isCi(env = process.env) {
73314
73314
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
73315
73315
  function readCliVersion() {
73316
73316
  if (true) {
73317
- return "0.35.1-next.73";
73317
+ return "0.35.1-next.74";
73318
73318
  }
73319
73319
  return "0.0.0";
73320
73320
  }
@@ -81196,7 +81196,7 @@ function consumePendingSigningDetectionNote(udid) {
81196
81196
 
81197
81197
  // ../tool-server/src/preview.ts
81198
81198
  var import_node_fs11 = __toESM(require("node:fs"));
81199
- var import_node_os7 = __toESM(require("node:os"));
81199
+ var import_node_os8 = __toESM(require("node:os"));
81200
81200
  var import_node_path14 = __toESM(require("node:path"));
81201
81201
  var import_express = __toESM(require_express2());
81202
81202
  init_src();
@@ -105294,10 +105294,10 @@ init_harmony_flag();
105294
105294
 
105295
105295
  // ../tool-server/src/utils/macos-apps.ts
105296
105296
  var import_node_child_process23 = require("node:child_process");
105297
- var import_node_crypto11 = require("node:crypto");
105298
- var fs31 = __toESM(require("node:fs"));
105297
+ var import_node_crypto12 = require("node:crypto");
105298
+ var fs32 = __toESM(require("node:fs"));
105299
105299
  var os8 = __toESM(require("node:os"));
105300
- var path27 = __toESM(require("node:path"));
105300
+ var path28 = __toESM(require("node:path"));
105301
105301
  var import_node_util18 = require("node:util");
105302
105302
  init_src();
105303
105303
  init_src2();
@@ -105305,6 +105305,41 @@ init_capability();
105305
105305
  init_device_info();
105306
105306
  init_macos_app_kind();
105307
105307
  init_src();
105308
+
105309
+ // ../tool-server/src/utils/argent-home-id.ts
105310
+ var import_node_crypto11 = require("node:crypto");
105311
+ var fs31 = __toESM(require("node:fs"));
105312
+ var import_node_os6 = require("node:os");
105313
+ var path27 = __toESM(require("node:path"));
105314
+ init_src();
105315
+ var ARGENT_HOME_HEADER = "x-argent-home";
105316
+ function canonicalDir(dir) {
105317
+ const resolved = path27.resolve(dir);
105318
+ const parent = path27.dirname(resolved);
105319
+ if (fs31.existsSync(resolved) || parent === resolved) return canonicalPath(resolved);
105320
+ return path27.join(canonicalDir(parent), path27.basename(resolved));
105321
+ }
105322
+ function argentHomeId(dir = argentHomeDir()) {
105323
+ return (0, import_node_crypto11.createHash)("sha256").update(canonicalDir(dir)).digest("hex").slice(0, 12);
105324
+ }
105325
+ function peerArgentHomeId(header) {
105326
+ if (typeof header === "string" && header) return header;
105327
+ return argentHomeId(path27.join(resolveHomeDir(), ".argent"));
105328
+ }
105329
+ var LOOPBACK_ADDRESSES = /* @__PURE__ */ new Set(["127.0.0.1", "::1", "::ffff:127.0.0.1"]);
105330
+ function isOwnAddress(address) {
105331
+ const ip = address.replace(/^::ffff:(?=\d+\.\d+\.\d+\.\d+$)/, "");
105332
+ return Object.values((0, import_node_os6.networkInterfaces)()).some(
105333
+ (list) => list?.some((a) => (a.family === "IPv4" || a.scopeid === 0) && a.address === ip)
105334
+ );
105335
+ }
105336
+ function isLocalConnection(socket) {
105337
+ const remote = socket.remoteAddress;
105338
+ if (remote === void 0) return false;
105339
+ return LOOPBACK_ADDRESSES.has(remote) || remote === socket.localAddress || isOwnAddress(remote);
105340
+ }
105341
+
105342
+ // ../tool-server/src/utils/macos-apps.ts
105308
105343
  var execFileAsync17 = (0, import_node_util18.promisify)(import_node_child_process23.execFile);
105309
105344
  function isMacosAppsEnabled() {
105310
105345
  return isFeatureEnabled(MACOS_APPS_FLAG);
@@ -105338,56 +105373,78 @@ function assertLaunchTargetsDevice(bundleId, device) {
105338
105373
  }
105339
105374
  );
105340
105375
  }
105341
- function macosArgentDir() {
105342
- return path27.join(argentHomeDir(), "macos");
105343
- }
105344
105376
  function macosAppLogPath(bundleId) {
105345
- return path27.join(macosArgentDir(), "logs", `${bundleId}.log`);
105377
+ return path28.join(argentHomeDir(), "macos", "logs", `${bundleId}.log`);
105378
+ }
105379
+ function macosLibraryRoot() {
105380
+ return path28.join(os8.homedir(), "Library", "Caches", "com.swmansion.argent", "macos-lib");
105381
+ }
105382
+ function macosSocketDir() {
105383
+ try {
105384
+ const cache6 = (0, import_node_child_process23.execFileSync)("/usr/bin/getconf", ["DARWIN_USER_CACHE_DIR"], {
105385
+ encoding: "utf8",
105386
+ timeout: 5e3
105387
+ }).trim();
105388
+ return cache6 ? path28.join(cache6, `argent-${argentHomeId()}`) : null;
105389
+ } catch {
105390
+ return null;
105391
+ }
105346
105392
  }
105347
105393
  var BOOTSTRAP_NAME = "libArgentInjectionBootstrap.dylib";
105348
105394
  var LIBRARY_NAME = "libNativeDevtoolsMacos.dylib";
105349
105395
  function stageMacosLibraries(bootstrapPath, libraryPath, teamId) {
105350
- const bootstrap = fs31.readFileSync(bootstrapPath);
105351
- const library = fs31.readFileSync(libraryPath);
105396
+ const bootstrap = fs32.readFileSync(bootstrapPath);
105397
+ const library = fs32.readFileSync(libraryPath);
105352
105398
  const hash2 = libraryHash(bootstrap, library);
105353
105399
  const name = teamId ? `${hash2}-${teamId}` : hash2;
105354
- const libRoot = path27.join(macosArgentDir(), "lib");
105355
- const target = path27.join(libRoot, name);
105356
- const staged = path27.join(target, BOOTSTRAP_NAME);
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);
105400
+ const libRoot = macosLibraryRoot();
105401
+ const targets = STAGED_NAME_SUFFIXES.map((suffix) => path28.join(libRoot, name + suffix));
105402
+ fs32.mkdirSync(libRoot, { recursive: true, mode: 448 });
105360
105403
  void removeUnusedLibraries(libRoot, hash2);
105361
- const source = JSON.stringify([path27.resolve(bootstrapPath), path27.resolve(libraryPath)]);
105362
- if (isComplete()) {
105363
- recordLibrarySource(target, source);
105364
- return staged;
105365
- }
105366
- if (fs31.existsSync(target)) {
105367
- fs31.renameSync(target, path27.join(libRoot, `.damaged-${name}-${process.pid}-${Date.now()}`));
105404
+ void removeUnusedLibraries(path28.join(argentHomeDir(), "macos", "lib"), void 0, hash2);
105405
+ const source = JSON.stringify([path28.resolve(bootstrapPath), path28.resolve(libraryPath)]);
105406
+ const reuse2 = (dir) => {
105407
+ recordLibrarySource(dir, source);
105408
+ return path28.join(dir, BOOTSTRAP_NAME);
105409
+ };
105410
+ const complete = targets.find(isCompleteCopy);
105411
+ if (complete) return reuse2(complete);
105412
+ const temp = fs32.mkdtempSync(path28.join(libRoot, `.tmp-${name}-`));
105413
+ try {
105414
+ fs32.writeFileSync(path28.join(temp, BOOTSTRAP_NAME), bootstrap, { mode: 493 });
105415
+ fs32.writeFileSync(path28.join(temp, LIBRARY_NAME), library, { mode: 493 });
105416
+ fs32.writeFileSync(path28.join(temp, SOURCES_NAME), `${source}
105417
+ `, { mode: 384 });
105418
+ for (const target of targets) {
105419
+ if (tryRename(temp, target)) return path28.join(target, BOOTSTRAP_NAME);
105420
+ if (isCompleteCopy(target)) return reuse2(target);
105421
+ }
105422
+ } finally {
105423
+ fs32.rmSync(temp, { recursive: true, force: true });
105368
105424
  }
105369
- const temp = fs31.mkdtempSync(path27.join(libRoot, `.tmp-${name}-`));
105425
+ throw new Error(`${targets.join(", ")} hold incomplete copies of the library`);
105426
+ }
105427
+ var STAGED_NAME_SUFFIXES = ["", ".2", ".3"];
105428
+ function isCompleteCopy(dir) {
105429
+ return fs32.existsSync(path28.join(dir, BOOTSTRAP_NAME)) && fs32.existsSync(path28.join(dir, LIBRARY_NAME));
105430
+ }
105431
+ function tryRename(from2, to) {
105370
105432
  try {
105371
- fs31.writeFileSync(path27.join(temp, BOOTSTRAP_NAME), bootstrap, { mode: 493 });
105372
- fs31.writeFileSync(path27.join(temp, LIBRARY_NAME), library, { mode: 493 });
105373
- fs31.writeFileSync(path27.join(temp, SOURCES_NAME), `${source}
105374
- `, { mode: 384 });
105375
- fs31.renameSync(temp, target);
105376
- } catch (err) {
105377
- fs31.rmSync(temp, { recursive: true, force: true });
105378
- throw err;
105433
+ fs32.renameSync(from2, to);
105434
+ return true;
105435
+ } catch {
105436
+ return false;
105379
105437
  }
105380
- return staged;
105381
105438
  }
105382
105439
  var SOURCES_NAME = "sources";
105383
105440
  function libraryHash(bootstrap, library) {
105384
- return (0, import_node_crypto11.createHash)("sha256").update(`${bootstrap.length}:`).update(bootstrap).update(`${library.length}:`).update(library).digest("hex").slice(0, 16);
105441
+ return (0, import_node_crypto12.createHash)("sha256").update(`${bootstrap.length}:`).update(bootstrap).update(`${library.length}:`).update(library).digest("hex").slice(0, 16);
105385
105442
  }
105386
105443
  function recordLibrarySource(dir, source) {
105387
- const file2 = path27.join(dir, SOURCES_NAME);
105444
+ const file2 = path28.join(dir, SOURCES_NAME);
105388
105445
  try {
105389
- const known = fs31.existsSync(file2) ? fs31.readFileSync(file2, "utf8").split("\n") : [];
105390
- if (!known.includes(source)) fs31.appendFileSync(file2, `${source}
105446
+ const known = fs32.existsSync(file2) ? fs32.readFileSync(file2, "utf8").split("\n") : [];
105447
+ if (!known.includes(source)) fs32.appendFileSync(file2, `${source}
105391
105448
  `, { mode: 384 });
105392
105449
  } catch {
105393
105450
  }
@@ -105395,13 +105452,13 @@ function recordLibrarySource(dir, source) {
105395
105452
  function inPrivacyProtectedFolder(file2) {
105396
105453
  const home = os8.homedir();
105397
105454
  return ["Desktop", "Documents", "Downloads", "Library/Mobile Documents"].some(
105398
- (folder) => file2.startsWith(path27.join(home, folder) + path27.sep)
105455
+ (folder) => file2.startsWith(path28.join(home, folder) + path28.sep)
105399
105456
  );
105400
105457
  }
105401
105458
  async function librarySourceInstalled(dir, name) {
105402
105459
  let lines;
105403
105460
  try {
105404
- lines = (await fs31.promises.readFile(path27.join(dir, SOURCES_NAME), "utf8")).split("\n");
105461
+ lines = (await fs32.promises.readFile(path28.join(dir, SOURCES_NAME), "utf8")).split("\n");
105405
105462
  } catch {
105406
105463
  return false;
105407
105464
  }
@@ -105416,7 +105473,7 @@ async function librarySourceInstalled(dir, name) {
105416
105473
  if (files.some((file2) => inPrivacyProtectedFolder(String(file2)))) return true;
105417
105474
  try {
105418
105475
  const [bootstrap, library] = await Promise.all(
105419
- files.map((file2) => fs31.promises.readFile(String(file2)))
105476
+ files.map((file2) => fs32.promises.readFile(String(file2)))
105420
105477
  );
105421
105478
  if (name.startsWith(libraryHash(bootstrap, library))) return true;
105422
105479
  } catch (err) {
@@ -105425,9 +105482,9 @@ async function librarySourceInstalled(dir, name) {
105425
105482
  }
105426
105483
  return false;
105427
105484
  }
105428
- async function removeUnusedLibraries(libRoot, keep) {
105485
+ async function removeUnusedLibraries(libRoot, keep, superseded) {
105429
105486
  try {
105430
- const root = fs31.realpathSync(libRoot);
105487
+ const root = fs32.realpathSync(libRoot);
105431
105488
  let open5;
105432
105489
  try {
105433
105490
  ({ stdout: open5 } = await execFileAsync17("lsof", ["-Fn", "+D", root], {
@@ -105442,15 +105499,25 @@ async function removeUnusedLibraries(libRoot, keep) {
105442
105499
  const used = new Set(
105443
105500
  open5.split("\n").filter((line) => line.startsWith(`n${root}/`)).map((line) => line.slice(root.length + 2).split("/")[0])
105444
105501
  );
105445
- for (const name of fs31.readdirSync(root)) {
105446
- if (name.startsWith(keep) || used.has(name)) continue;
105447
- const dir = path27.join(root, name);
105448
- if (!name.startsWith(".") && await librarySourceInstalled(dir, name)) continue;
105449
- fs31.rmSync(dir, { recursive: true, force: true });
105502
+ for (const name of fs32.readdirSync(root)) {
105503
+ const dir = path28.join(root, name);
105504
+ const current = keep !== void 0 && name.startsWith(keep);
105505
+ if (used.has(name) || current && isCompleteCopy(dir)) continue;
105506
+ const temporary = name.startsWith(".");
105507
+ if (temporary && isRecent(dir)) continue;
105508
+ const restaged = superseded !== void 0 && name.startsWith(superseded);
105509
+ if (!current && !temporary && !restaged && await librarySourceInstalled(dir, name)) {
105510
+ continue;
105511
+ }
105512
+ fs32.rmSync(dir, { recursive: true, force: true });
105450
105513
  }
105451
105514
  } catch {
105452
105515
  }
105453
105516
  }
105517
+ var STAGING_TEMP_MAX_AGE_MS = 10 * 6e4;
105518
+ function isRecent(dir) {
105519
+ return Date.now() - fs32.lstatSync(dir).mtimeMs < STAGING_TEMP_MAX_AGE_MS;
105520
+ }
105454
105521
  var EXPORTED_RELEASE_NOTE = "An exported or notarized Release build with the hardened runtime cannot be driven without extra entitlements.";
105455
105522
  async function signatureTeam(file2) {
105456
105523
  try {
@@ -105466,7 +105533,7 @@ async function stageLibraryFor(info, shipped, readTeam = signatureTeam) {
105466
105533
  bootstrap = stageMacosLibraries(shipped.bootstrap, shipped.library, teamId);
105467
105534
  } catch (err) {
105468
105535
  throw macosFailure(
105469
- `Could not copy the argent library to ~/.argent/macos/lib: ${errorMessage(err)}`,
105536
+ `Could not copy the argent library to ${macosLibraryRoot()}: ${errorMessage(err)}`,
105470
105537
  FAILURE_CODES.MACOS_APP_LIBRARY_STAGE_FAILED,
105471
105538
  "macos_app_stage_library",
105472
105539
  "unknown",
@@ -105474,7 +105541,7 @@ async function stageLibraryFor(info, shipped, readTeam = signatureTeam) {
105474
105541
  );
105475
105542
  }
105476
105543
  if (!teamId) return bootstrap;
105477
- const files = [bootstrap, path27.join(path27.dirname(bootstrap), LIBRARY_NAME)];
105544
+ const files = [bootstrap, path28.join(path28.dirname(bootstrap), LIBRARY_NAME)];
105478
105545
  const teams = await Promise.all(files.map((file2) => readTeam(file2)));
105479
105546
  if (teams.every((team) => team === teamId)) return bootstrap;
105480
105547
  const debug = info.entitlements.getTaskAllow;
@@ -105490,7 +105557,7 @@ then start the app again. Signing uses the keychain, so the user runs this comma
105490
105557
  var MAX_SOCKET_PATH_BYTES = 103;
105491
105558
  function macosListenSocket(bundleId, sandboxed) {
105492
105559
  if (sandboxed) {
105493
- const containerPath = path27.join(
105560
+ const containerPath = path28.join(
105494
105561
  os8.homedir(),
105495
105562
  "Library",
105496
105563
  "Containers",
@@ -105501,12 +105568,27 @@ function macosListenSocket(bundleId, sandboxed) {
105501
105568
  );
105502
105569
  return fitsSocketPath(containerPath) ? { env: "CONTAINER", path: containerPath } : null;
105503
105570
  }
105504
- const named = path27.join(macosArgentDir(), `${bundleId}.sock`);
105571
+ const dir = macosSocketDir();
105572
+ if (!dir) return null;
105573
+ const named = path28.join(dir, `${bundleId}.sock`);
105505
105574
  if (fitsSocketPath(named)) return { env: named, path: named };
105506
- const hash2 = (0, import_node_crypto11.createHash)("sha256").update(bundleId).digest("hex").slice(0, 16);
105507
- const hashed = path27.join(macosArgentDir(), `${hash2}.sock`);
105575
+ const hash2 = (0, import_node_crypto12.createHash)("sha256").update(bundleId).digest("hex").slice(0, 16);
105576
+ const hashed = path28.join(dir, `${hash2}.sock`);
105508
105577
  return fitsSocketPath(hashed) ? { env: hashed, path: hashed } : null;
105509
105578
  }
105579
+ function prepareSocketDir(socketPath) {
105580
+ const dir = path28.dirname(socketPath);
105581
+ fs32.mkdirSync(dir, { recursive: true, mode: 448 });
105582
+ const stat11 = fs32.lstatSync(dir);
105583
+ if (!stat11.isDirectory() || stat11.uid !== process.getuid?.() || (stat11.mode & 63) !== 0) {
105584
+ throw macosFailure(
105585
+ `${dir} belongs to another user or others can open it, so argent cannot keep the app's socket private there.`,
105586
+ FAILURE_CODES.MACOS_APP_SPAWN_FAILED,
105587
+ "macos_app_listen_socket",
105588
+ "validation"
105589
+ );
105590
+ }
105591
+ }
105510
105592
  function fitsSocketPath(p) {
105511
105593
  return Buffer.byteLength(p, "utf8") <= MAX_SOCKET_PATH_BYTES;
105512
105594
  }
@@ -105524,7 +105606,7 @@ function isTrackedMacosApp(value) {
105524
105606
  function readTrackedApps() {
105525
105607
  let raw;
105526
105608
  try {
105527
- raw = JSON.parse(fs31.readFileSync(trackedMacosAppsFile(), "utf8"));
105609
+ raw = JSON.parse(fs32.readFileSync(trackedMacosAppsFile(), "utf8"));
105528
105610
  } catch {
105529
105611
  return [];
105530
105612
  }
@@ -105533,10 +105615,10 @@ function readTrackedApps() {
105533
105615
  function recordTrackedMacosApp(app) {
105534
105616
  const file2 = trackedMacosAppsFile();
105535
105617
  const others = readTrackedApps().filter((a) => a.bundleId !== app.bundleId);
105536
- fs31.mkdirSync(path27.dirname(file2), { recursive: true });
105618
+ fs32.mkdirSync(path28.dirname(file2), { recursive: true });
105537
105619
  const tmp = `${file2}.${process.pid}.tmp`;
105538
- fs31.writeFileSync(tmp, JSON.stringify([...others, app], null, 2) + "\n");
105539
- fs31.renameSync(tmp, file2);
105620
+ fs32.writeFileSync(tmp, JSON.stringify([...others, app], null, 2) + "\n");
105621
+ fs32.renameSync(tmp, file2);
105540
105622
  }
105541
105623
  function getTrackedMacosApp(bundleId) {
105542
105624
  return readTrackedApps().find((a) => a.bundleId === bundleId);
@@ -105599,7 +105681,7 @@ async function findRunningCopies(bundleId, executable, skipPid) {
105599
105681
  } catch {
105600
105682
  return found;
105601
105683
  }
105602
- const suffix = `/Contents/MacOS/${path27.basename(executable)}`;
105684
+ const suffix = `/Contents/MacOS/${path28.basename(executable)}`;
105603
105685
  const bundleIds = /* @__PURE__ */ new Map();
105604
105686
  for (const line of stdout.split("\n")) {
105605
105687
  const match = /^\s*(\d+)\s+(.*)$/.exec(line);
@@ -105612,7 +105694,7 @@ async function findRunningCopies(bundleId, executable, skipPid) {
105612
105694
  if (!command2.endsWith(suffix)) continue;
105613
105695
  let resolved;
105614
105696
  try {
105615
- resolved = fs31.realpathSync(command2);
105697
+ resolved = fs32.realpathSync(command2);
105616
105698
  } catch {
105617
105699
  continue;
105618
105700
  }
@@ -105621,7 +105703,7 @@ async function findRunningCopies(bundleId, executable, skipPid) {
105621
105703
  if (!bundleIds.has(appPath)) {
105622
105704
  bundleIds.set(
105623
105705
  appPath,
105624
- await plistValue(path27.join(appPath, "Contents", "Info.plist"), "CFBundleIdentifier")
105706
+ await plistValue(path28.join(appPath, "Contents", "Info.plist"), "CFBundleIdentifier")
105625
105707
  );
105626
105708
  }
105627
105709
  if (bundleIds.get(appPath) === bundleId) found.otherBuilds.push({ pid, appPath });
@@ -105637,16 +105719,16 @@ async function gitWorktreeOf(dir) {
105637
105719
  );
105638
105720
  const [top, common] = stdout.trim().split("\n");
105639
105721
  if (!top || !common) return null;
105640
- return { top: fs31.realpathSync(top), common: fs31.realpathSync(common) };
105722
+ return { top: fs32.realpathSync(top), common: fs32.realpathSync(common) };
105641
105723
  } catch {
105642
105724
  return null;
105643
105725
  }
105644
105726
  }
105645
105727
  async function otherWorktreeOfBuild(appPath, projectRoot) {
105646
105728
  const derivedData = /^(.*)\/Build\/Products\/[^/]+\/[^/]+\.app$/.exec(appPath)?.[1];
105647
- const workspace = derivedData ? await plistValue(path27.join(derivedData, "info.plist"), "WorkspacePath") : null;
105729
+ const workspace = derivedData ? await plistValue(path28.join(derivedData, "info.plist"), "WorkspacePath") : null;
105648
105730
  const [build2, project] = await Promise.all([
105649
- gitWorktreeOf(path27.dirname(workspace ?? appPath)),
105731
+ gitWorktreeOf(path28.dirname(workspace ?? appPath)),
105650
105732
  gitWorktreeOf(projectRoot)
105651
105733
  ]);
105652
105734
  if (!build2 || !project) return null;
@@ -105657,7 +105739,7 @@ var CHROMIUM_BROWSER_FRAMEWORK = /\b(chrome|chromium|edge|brave|vivaldi|opera)\b
105657
105739
  function chromiumKind(appPath) {
105658
105740
  let frameworks;
105659
105741
  try {
105660
- frameworks = fs31.readdirSync(path27.join(appPath, "Contents", "Frameworks"));
105742
+ frameworks = fs32.readdirSync(path28.join(appPath, "Contents", "Frameworks"));
105661
105743
  } catch {
105662
105744
  return void 0;
105663
105745
  }
@@ -105674,10 +105756,10 @@ var MAX_LOAD_COMMANDS_BYTES = 1024 * 1024;
105674
105756
  function isCatalystExecutable(executable) {
105675
105757
  let fd;
105676
105758
  try {
105677
- fd = fs31.openSync(executable, "r");
105759
+ fd = fs32.openSync(executable, "r");
105678
105760
  const read = (length, position) => {
105679
105761
  const buffer = Buffer.alloc(length);
105680
- return buffer.subarray(0, fs31.readSync(fd, buffer, 0, length, position));
105762
+ return buffer.subarray(0, fs32.readSync(fd, buffer, 0, length, position));
105681
105763
  };
105682
105764
  const header = read(8, 0);
105683
105765
  if (header.length < 8) return false;
@@ -105694,7 +105776,7 @@ function isCatalystExecutable(executable) {
105694
105776
  } catch {
105695
105777
  return false;
105696
105778
  } finally {
105697
- if (fd !== void 0) fs31.closeSync(fd);
105779
+ if (fd !== void 0) fs32.closeSync(fd);
105698
105780
  }
105699
105781
  }
105700
105782
  function isCatalystSlice(read, offset) {
@@ -105747,7 +105829,7 @@ function parseCodesignDisplay(output2) {
105747
105829
  }
105748
105830
  function isIosAppWrapper(dir) {
105749
105831
  try {
105750
- return fs31.statSync(path27.join(dir, "Wrapper")).isDirectory() && fs31.lstatSync(path27.join(dir, "WrappedBundle")).isSymbolicLink();
105832
+ return fs32.statSync(path28.join(dir, "Wrapper")).isDirectory() && fs32.lstatSync(path28.join(dir, "WrappedBundle")).isSymbolicLink();
105751
105833
  } catch {
105752
105834
  return false;
105753
105835
  }
@@ -105788,7 +105870,7 @@ async function inspectMacosApp(appPath) {
105788
105870
  const badBundle = (message) => invalid3(message, FAILURE_CODES.MACOS_APP_BUNDLE_INVALID);
105789
105871
  let resolved;
105790
105872
  try {
105791
- resolved = fs31.realpathSync(path27.resolve(appPath));
105873
+ resolved = fs32.realpathSync(path28.resolve(appPath));
105792
105874
  } catch {
105793
105875
  throw invalid3(
105794
105876
  `No app bundle at ${appPath}.`,
@@ -105796,8 +105878,8 @@ async function inspectMacosApp(appPath) {
105796
105878
  "not_found"
105797
105879
  );
105798
105880
  }
105799
- const plist = path27.join(resolved, "Contents", "Info.plist");
105800
- if (!fs31.statSync(resolved).isDirectory() || !fs31.existsSync(plist)) {
105881
+ const plist = path28.join(resolved, "Contents", "Info.plist");
105882
+ if (!fs32.statSync(resolved).isDirectory() || !fs32.existsSync(plist)) {
105801
105883
  if (isIosAppWrapper(resolved)) {
105802
105884
  throw invalid3(
105803
105885
  `${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 +105908,8 @@ async function inspectMacosApp(appPath) {
105826
105908
  if (!executableName || executableName.includes("/")) {
105827
105909
  throw badBundle(`${plist} has no usable CFBundleExecutable.`);
105828
105910
  }
105829
- const executable = path27.join(resolved, "Contents", "MacOS", executableName);
105830
- if (!fs31.existsSync(executable)) {
105911
+ const executable = path28.join(resolved, "Contents", "MacOS", executableName);
105912
+ if (!fs32.existsSync(executable)) {
105831
105913
  throw badBundle(`The executable ${executable} named by ${plist} does not exist.`);
105832
105914
  }
105833
105915
  const signature = await readCodeSignature(resolved) ?? parseCodesignDisplay(null);
@@ -105835,7 +105917,7 @@ async function inspectMacosApp(appPath) {
105835
105917
  return {
105836
105918
  appPath: resolved,
105837
105919
  bundleId,
105838
- name: bundleName ?? path27.basename(resolved, ".app"),
105920
+ name: bundleName ?? path28.basename(resolved, ".app"),
105839
105921
  executable,
105840
105922
  ...signature,
105841
105923
  ...chromium ? { chromium } : {},
@@ -105888,12 +105970,12 @@ async function findMacosAppByBundleId(bundleId) {
105888
105970
  for (const line of stdout.split("\n")) {
105889
105971
  const appPath = line.trim();
105890
105972
  if (!appPath.endsWith(".app")) continue;
105891
- const contents = path27.join(appPath, "Contents");
105892
- const executable = await plistValue(path27.join(contents, "Info.plist"), "CFBundleExecutable");
105973
+ const contents = path28.join(appPath, "Contents");
105974
+ const executable = await plistValue(path28.join(contents, "Info.plist"), "CFBundleExecutable");
105893
105975
  if (!executable) continue;
105894
105976
  let mtimeMs;
105895
105977
  try {
105896
- mtimeMs = fs31.statSync(path27.join(contents, "MacOS", executable)).mtimeMs;
105978
+ mtimeMs = fs32.statSync(path28.join(contents, "MacOS", executable)).mtimeMs;
105897
105979
  } catch {
105898
105980
  continue;
105899
105981
  }
@@ -105902,7 +105984,7 @@ async function findMacosAppByBundleId(bundleId) {
105902
105984
  return best?.appPath ?? null;
105903
105985
  }
105904
105986
  async function issueSandboxExtension(filePath, opts = {}) {
105905
- const args = ["issue-extension", "--path", path27.resolve(filePath)];
105987
+ const args = ["issue-extension", "--path", path28.resolve(filePath)];
105906
105988
  if (opts.readOnly) args.push("--read-only");
105907
105989
  try {
105908
105990
  const { stdout } = await execFileAsync17(macosArtifacts().helper, args, { timeout: 1e4 });
@@ -105922,8 +106004,8 @@ async function issueSandboxExtension(filePath, opts = {}) {
105922
106004
  }
105923
106005
 
105924
106006
  // ../tool-server/src/utils/chromium-discovery.ts
105925
- var fs34 = __toESM(require("node:fs"));
105926
- var path30 = __toESM(require("node:path"));
106007
+ var fs35 = __toESM(require("node:fs"));
106008
+ var path31 = __toESM(require("node:path"));
105927
106009
  init_src2();
105928
106010
  init_device_info();
105929
106011
 
@@ -105934,9 +106016,9 @@ init_src2();
105934
106016
  init_src2();
105935
106017
 
105936
106018
  // ../tool-server/src/chromium-server/cdp-session.ts
105937
- var fs32 = __toESM(require("node:fs"));
106019
+ var fs33 = __toESM(require("node:fs"));
105938
106020
  var os10 = __toESM(require("node:os"));
105939
- var path28 = __toESM(require("node:path"));
106021
+ var path29 = __toESM(require("node:path"));
105940
106022
  init_src2();
105941
106023
 
105942
106024
  // ../tool-server/src/utils/debugger/cdp-client.ts
@@ -106771,8 +106853,8 @@ async function primePageSession(cdp) {
106771
106853
  }
106772
106854
  }
106773
106855
  function mediaDir() {
106774
- const dir = path28.join(os10.tmpdir(), "argent-chromium-media");
106775
- fs32.mkdirSync(dir, { recursive: true });
106856
+ const dir = path29.join(os10.tmpdir(), "argent-chromium-media");
106857
+ fs33.mkdirSync(dir, { recursive: true });
106776
106858
  return dir;
106777
106859
  }
106778
106860
 
@@ -107206,8 +107288,8 @@ var ScreencastManager = class {
107206
107288
  };
107207
107289
 
107208
107290
  // ../tool-server/src/chromium-server/screenshot.ts
107209
- var fs33 = __toESM(require("node:fs"));
107210
- var path29 = __toESM(require("node:path"));
107291
+ var fs34 = __toESM(require("node:fs"));
107292
+ var path30 = __toESM(require("node:path"));
107211
107293
  init_src2();
107212
107294
  var sharpCache;
107213
107295
  var sharpLoadWarningEmitted = false;
@@ -107294,8 +107376,8 @@ async function captureScreenshot(ctx, opts = {}) {
107294
107376
  }
107295
107377
  const stem = opts.id ?? `${Date.now()}-${process.pid}`;
107296
107378
  const safeDeviceId = ctx.deviceId.replace(/[^A-Za-z0-9_-]/g, "_");
107297
- const filePath = path29.join(mediaDir(), `argent-screenshot-${safeDeviceId}-${stem}.png`);
107298
- fs33.writeFileSync(filePath, bytes);
107379
+ const filePath = path30.join(mediaDir(), `argent-screenshot-${safeDeviceId}-${stem}.png`);
107380
+ fs34.writeFileSync(filePath, bytes);
107299
107381
  return {
107300
107382
  url: `file://${filePath}`,
107301
107383
  path: filePath,
@@ -107312,7 +107394,7 @@ function readPngSize(buf) {
107312
107394
  }
107313
107395
  async function copyScreenshotToClipboard(ctx, opts = {}) {
107314
107396
  const shot = await captureScreenshot(ctx, { rotation: opts.rotation });
107315
- const bytes = fs33.readFileSync(shot.path);
107397
+ const bytes = fs34.readFileSync(shot.path);
107316
107398
  const b64 = bytes.toString("base64");
107317
107399
  const script = `(async () => {
107318
107400
  const b64 = "${b64}";
@@ -108019,11 +108101,11 @@ function parsePortList(raw) {
108019
108101
  }
108020
108102
  var TRACKED_PORTS = /* @__PURE__ */ new Set();
108021
108103
  function portsFilePath() {
108022
- return process.env.ARGENT_CHROMIUM_PORTS_FILE ?? path30.join(argentHomeDir(), "chromium-cdp-ports.json");
108104
+ return process.env.ARGENT_CHROMIUM_PORTS_FILE ?? path31.join(argentHomeDir(), "chromium-cdp-ports.json");
108023
108105
  }
108024
108106
  function loadPersistedPorts() {
108025
108107
  try {
108026
- const raw = JSON.parse(fs34.readFileSync(portsFilePath(), "utf8"));
108108
+ const raw = JSON.parse(fs35.readFileSync(portsFilePath(), "utf8"));
108027
108109
  if (!Array.isArray(raw)) return [];
108028
108110
  return raw.filter((p) => typeof p === "number" && p > 0 && p <= 65535);
108029
108111
  } catch {
@@ -108035,8 +108117,8 @@ function persistPorts(mutate) {
108035
108117
  const file2 = portsFilePath();
108036
108118
  const merged = new Set(loadPersistedPorts());
108037
108119
  mutate(merged);
108038
- fs34.mkdirSync(path30.dirname(file2), { recursive: true });
108039
- fs34.writeFileSync(file2, JSON.stringify(Array.from(merged)));
108120
+ fs35.mkdirSync(path31.dirname(file2), { recursive: true });
108121
+ fs35.writeFileSync(file2, JSON.stringify(Array.from(merged)));
108040
108122
  } catch {
108041
108123
  }
108042
108124
  }
@@ -108100,12 +108182,12 @@ init_src2();
108100
108182
  // ../tool-server/src/utils/vega-sdk.ts
108101
108183
  var import_promises10 = require("node:fs/promises");
108102
108184
  var import_node_fs9 = require("node:fs");
108103
- var import_node_os6 = require("node:os");
108185
+ var import_node_os7 = require("node:os");
108104
108186
  var import_node_path13 = require("node:path");
108105
108187
  var import_semver4 = __toESM(require_semver2());
108106
108188
  async function readVegaConfig() {
108107
108189
  try {
108108
- const raw = await (0, import_promises10.readFile)((0, import_node_path13.join)((0, import_node_os6.homedir)(), "vega", "config.json"), "utf-8");
108190
+ const raw = await (0, import_promises10.readFile)((0, import_node_path13.join)((0, import_node_os7.homedir)(), "vega", "config.json"), "utf-8");
108109
108191
  return JSON.parse(raw);
108110
108192
  } catch {
108111
108193
  return {};
@@ -108117,7 +108199,7 @@ function bareVersion(version3) {
108117
108199
  function sdkComponentRoots(config2) {
108118
108200
  const roots = [
108119
108201
  config2.sdkPath && (0, import_node_path13.join)(config2.sdkPath, "vega-sdk"),
108120
- (0, import_node_path13.join)((0, import_node_os6.homedir)(), "vega", "sdk", "vega-sdk")
108202
+ (0, import_node_path13.join)((0, import_node_os7.homedir)(), "vega", "sdk", "vega-sdk")
108121
108203
  ].filter((p) => Boolean(p));
108122
108204
  return Array.from(new Set(roots));
108123
108205
  }
@@ -109179,7 +109261,7 @@ init_src2();
109179
109261
 
109180
109262
  // ../tool-server/src/blueprints/ax-service.ts
109181
109263
  var net4 = __toESM(require("node:net"));
109182
- var fs35 = __toESM(require("node:fs"));
109264
+ var fs36 = __toESM(require("node:fs"));
109183
109265
  init_src2();
109184
109266
  init_external_devices();
109185
109267
 
@@ -109258,7 +109340,7 @@ function startListener(endpoint, onConnection) {
109258
109340
  return new Promise((resolve24, reject) => {
109259
109341
  if (endpoint.transport === "unix") {
109260
109342
  try {
109261
- fs35.unlinkSync(endpoint.socketPath);
109343
+ fs36.unlinkSync(endpoint.socketPath);
109262
109344
  } catch {
109263
109345
  }
109264
109346
  }
@@ -109575,7 +109657,7 @@ var axServiceBlueprint = {
109575
109657
  server.close();
109576
109658
  if (endpoint.transport === "unix") {
109577
109659
  try {
109578
- fs35.unlinkSync(endpoint.socketPath);
109660
+ fs36.unlinkSync(endpoint.socketPath);
109579
109661
  } catch {
109580
109662
  }
109581
109663
  }
@@ -109806,7 +109888,7 @@ var axServiceBlueprint = {
109806
109888
  server.close();
109807
109889
  if (endpoint.transport === "unix") {
109808
109890
  try {
109809
- fs35.unlinkSync(endpoint.socketPath);
109891
+ fs36.unlinkSync(endpoint.socketPath);
109810
109892
  } catch {
109811
109893
  }
109812
109894
  }
@@ -110779,8 +110861,8 @@ var readline2 = __toESM(require("node:readline"));
110779
110861
  init_src2();
110780
110862
 
110781
110863
  // ../native-devtools-android/src/index.ts
110782
- var path32 = __toESM(require("node:path"));
110783
- var fs36 = __toESM(require("node:fs"));
110864
+ var path33 = __toESM(require("node:path"));
110865
+ var fs37 = __toESM(require("node:fs"));
110784
110866
 
110785
110867
  // ../native-devtools-android/src/errors.ts
110786
110868
  function buildMessage(kind, details) {
@@ -110813,7 +110895,7 @@ var TraceProcessorUnavailableError = class _TraceProcessorUnavailableError exten
110813
110895
  // ../native-devtools-android/src/wasm-trace-processor.ts
110814
110896
  var import_node_fs10 = require("node:fs");
110815
110897
  var import_promises11 = require("node:fs/promises");
110816
- var path31 = __toESM(require("node:path"));
110898
+ var path32 = __toESM(require("node:path"));
110817
110899
  var import_node_url2 = require("node:url");
110818
110900
  var import_node_vm = __toESM(require("node:vm"));
110819
110901
 
@@ -111138,14 +111220,14 @@ function engineGlobals() {
111138
111220
  return globalThis;
111139
111221
  }
111140
111222
  function resolveTraceProcessorAssets() {
111141
- const dir = path31.join(__dirname, "..", "assets", "trace-processor");
111223
+ const dir = path32.join(__dirname, "..", "assets", "trace-processor");
111142
111224
  const wasmOverride = process.env.ARGENT_TRACE_PROCESSOR_WASM;
111143
111225
  if (wasmOverride && !(0, import_node_fs10.existsSync)(wasmOverride)) {
111144
111226
  throw new TraceProcessorUnavailableError("wasm_path_invalid", { path: wasmOverride });
111145
111227
  }
111146
111228
  return {
111147
- wasmPath: wasmOverride ?? path31.join(dir, "trace_processor.wasm"),
111148
- gluePath: path31.join(dir, "engine_bundle.node.js")
111229
+ wasmPath: wasmOverride ?? path32.join(dir, "trace_processor.wasm"),
111230
+ gluePath: path32.join(dir, "engine_bundle.node.js")
111149
111231
  };
111150
111232
  }
111151
111233
  function patchGlueForNode(src) {
@@ -111233,7 +111315,7 @@ async function createEngine() {
111233
111315
  });
111234
111316
  try {
111235
111317
  const { wasmPath, gluePath } = resolveTraceProcessorAssets();
111236
- const dir = path31.dirname(wasmPath);
111318
+ const dir = path32.dirname(wasmPath);
111237
111319
  setupWorkerScope(dir);
111238
111320
  const g = engineGlobals();
111239
111321
  const wasmModule = await g.WebAssembly.compile(await (0, import_promises11.readFile)(wasmPath));
@@ -111358,25 +111440,25 @@ async function ensureTraceProcessorReady(tracePath) {
111358
111440
 
111359
111441
  // ../native-devtools-android/src/index.ts
111360
111442
  function binDir() {
111361
- return process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_BIN_DIR ?? path32.join(__dirname, "..", "bin");
111443
+ return process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_BIN_DIR ?? path33.join(__dirname, "..", "bin");
111362
111444
  }
111363
111445
  function traceProcessorQueriesDir() {
111364
- return process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_QUERIES_DIR ?? path32.join(__dirname, "..", "assets", "queries");
111446
+ return process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_QUERIES_DIR ?? path33.join(__dirname, "..", "assets", "queries");
111365
111447
  }
111366
111448
  function traceConfigPath() {
111367
- return process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_TRACECFG ?? path32.join(__dirname, "..", "assets", "argent.tracecfg.pbtxt");
111449
+ return process.env.ARGENT_NATIVE_DEVTOOLS_ANDROID_TRACECFG ?? path33.join(__dirname, "..", "assets", "argent.tracecfg.pbtxt");
111368
111450
  }
111369
111451
  var cachedManifest = null;
111370
111452
  function helperManifest() {
111371
111453
  if (cachedManifest) return cachedManifest;
111372
- const manifestPath = path32.join(__dirname, "..", "assets", "manifest.json");
111373
- cachedManifest = JSON.parse(fs36.readFileSync(manifestPath, "utf-8"));
111454
+ const manifestPath = path33.join(__dirname, "..", "assets", "manifest.json");
111455
+ cachedManifest = JSON.parse(fs37.readFileSync(manifestPath, "utf-8"));
111374
111456
  return cachedManifest;
111375
111457
  }
111376
111458
  function bundledHelperApkPath() {
111377
111459
  const manifest = helperManifest();
111378
- const apk = path32.join(binDir(), `argent-android-devtools-${manifest.versionName}.apk`);
111379
- if (!fs36.existsSync(apk)) {
111460
+ const apk = path33.join(binDir(), `argent-android-devtools-${manifest.versionName}.apk`);
111461
+ if (!fs37.existsSync(apk)) {
111380
111462
  throw new Error(
111381
111463
  `Bundled Android devtools helper APK not found at ${apk}. Run \`bash packages/native-devtools-android/scripts/build.sh\` to build it.`
111382
111464
  );
@@ -115377,7 +115459,7 @@ data: ${JSON.stringify(data)}
115377
115459
  const MAX_PREVIEW_BYTES = 25 * 1024 * 1024;
115378
115460
  const allowedRoots = (() => {
115379
115461
  const roots = /* @__PURE__ */ new Set();
115380
- for (const r of [import_node_os7.default.tmpdir(), process.cwd(), "/tmp"]) {
115462
+ for (const r of [import_node_os8.default.tmpdir(), process.cwd(), "/tmp"]) {
115381
115463
  try {
115382
115464
  roots.add(import_node_fs11.default.realpathSync(r));
115383
115465
  } catch {
@@ -115555,7 +115637,7 @@ function streamDirectoryAsArchive(id, entry, req, res) {
115555
115637
 
115556
115638
  // ../tool-server/src/file-inputs.ts
115557
115639
  var import_promises13 = require("node:fs/promises");
115558
- var import_node_os8 = require("node:os");
115640
+ var import_node_os9 = require("node:os");
115559
115641
  var import_node_path15 = require("node:path");
115560
115642
  var import_bytes = __toESM(require_bytes());
115561
115643
  init_src2();
@@ -115612,7 +115694,7 @@ function decodeContent(wire) {
115612
115694
  }
115613
115695
  async function materializeUpload(wire) {
115614
115696
  const data = decodeContent(wire);
115615
- const dir = await (0, import_promises13.mkdtemp)((0, import_node_path15.join)((0, import_node_os8.tmpdir)(), "argent-file-input-"));
115697
+ const dir = await (0, import_promises13.mkdtemp)((0, import_node_path15.join)((0, import_node_os9.tmpdir)(), "argent-file-input-"));
115616
115698
  const filePath = (0, import_node_path15.join)(dir, sanitizeFilename((0, import_node_path15.basename)(wire.path)));
115617
115699
  await (0, import_promises13.writeFile)(filePath, data);
115618
115700
  return { filePath, dir };
@@ -115636,7 +115718,7 @@ async function extractTarUpload(wire, uploadId, meta3, tempDirs, lookupUpload) {
115636
115718
  );
115637
115719
  }
115638
115720
  const extractDir = await (0, import_promises13.mkdtemp)(
115639
- (0, import_node_path15.join)((0, import_node_os8.tmpdir)(), `argent-tar-upload-${entry.sha256.slice(0, 16)}-`)
115721
+ (0, import_node_path15.join)((0, import_node_os9.tmpdir)(), `argent-tar-upload-${entry.sha256.slice(0, 16)}-`)
115640
115722
  );
115641
115723
  tempDirs.push(extractDir);
115642
115724
  const uploaded = await safeExtractArchive(entry.tarPath, extractDir, (0, import_node_path15.basename)(wire.path));
@@ -116364,7 +116446,7 @@ init_device_info();
116364
116446
 
116365
116447
  // ../tool-server/src/blueprints/tv-control.ts
116366
116448
  var net6 = __toESM(require("node:net"));
116367
- var fs38 = __toESM(require("node:fs"));
116449
+ var fs39 = __toESM(require("node:fs"));
116368
116450
  var import_node_child_process27 = require("node:child_process");
116369
116451
  init_src2();
116370
116452
  init_capability();
@@ -116662,7 +116744,7 @@ async function waitForSocket(socketPath, proc, timeoutMs) {
116662
116744
  if (exited !== void 0) {
116663
116745
  throw new Error(`tv daemon exited with code ${exited} before its socket was ready`);
116664
116746
  }
116665
- if (fs38.existsSync(socketPath)) {
116747
+ if (fs39.existsSync(socketPath)) {
116666
116748
  const ok = await new Promise((resolve24) => {
116667
116749
  const s = net6.createConnection(socketPath);
116668
116750
  s.on("connect", () => {
@@ -116766,7 +116848,7 @@ var tvControlBlueprint = {
116766
116848
  await reapDaemons(axSock);
116767
116849
  for (const p of [axSock, hidSock]) {
116768
116850
  try {
116769
- fs38.unlinkSync(p);
116851
+ fs39.unlinkSync(p);
116770
116852
  } catch {
116771
116853
  }
116772
116854
  }
@@ -116782,7 +116864,7 @@ var tvControlBlueprint = {
116782
116864
  }
116783
116865
  axExited = false;
116784
116866
  try {
116785
- fs38.unlinkSync(axSock);
116867
+ fs39.unlinkSync(axSock);
116786
116868
  } catch {
116787
116869
  }
116788
116870
  await reapDaemons(axSock);
@@ -116807,7 +116889,7 @@ var tvControlBlueprint = {
116807
116889
  axProc.kill("SIGKILL");
116808
116890
  }
116809
116891
  try {
116810
- fs38.unlinkSync(axSock);
116892
+ fs39.unlinkSync(axSock);
116811
116893
  } catch {
116812
116894
  }
116813
116895
  }
@@ -116914,7 +116996,7 @@ var tvControlBlueprint = {
116914
116996
  await reapDaemons(axSock);
116915
116997
  for (const p of [axSock, hidSock]) {
116916
116998
  try {
116917
- fs38.unlinkSync(p);
116999
+ fs39.unlinkSync(p);
116918
117000
  } catch {
116919
117001
  }
116920
117002
  }
@@ -117436,10 +117518,10 @@ function reserveLaunchMeasurement(udid) {
117436
117518
  // ../tool-server/src/utils/ios-device/runner-artifact.ts
117437
117519
  var import_node_child_process29 = require("node:child_process");
117438
117520
  var import_node_util21 = require("node:util");
117439
- var import_node_crypto12 = require("node:crypto");
117440
- var fs40 = __toESM(require("node:fs"));
117521
+ var import_node_crypto13 = require("node:crypto");
117522
+ var fs41 = __toESM(require("node:fs"));
117441
117523
  var fsp = __toESM(require("node:fs/promises"));
117442
- var path35 = __toESM(require("node:path"));
117524
+ var path36 = __toESM(require("node:path"));
117443
117525
  init_src2();
117444
117526
 
117445
117527
  // ../tool-server/src/utils/ios-device/runner-signing.ts
@@ -117448,13 +117530,13 @@ init_src2();
117448
117530
  // ../tool-server/src/utils/ios-device/provisioning-profiles.ts
117449
117531
  var import_node_child_process28 = require("node:child_process");
117450
117532
  var import_node_fs13 = require("node:fs");
117451
- var import_node_os9 = require("node:os");
117452
- var path34 = __toESM(require("node:path"));
117533
+ var import_node_os10 = require("node:os");
117534
+ var path35 = __toESM(require("node:path"));
117453
117535
  var import_node_util20 = require("node:util");
117454
117536
  var execFileAsync19 = (0, import_node_util20.promisify)(import_node_child_process28.execFile);
117455
117537
  var PROFILE_DIRECTORIES = [
117456
- path34.join("Library", "Developer", "Xcode", "UserData", "Provisioning Profiles"),
117457
- path34.join("Library", "MobileDevice", "Provisioning Profiles")
117538
+ path35.join("Library", "Developer", "Xcode", "UserData", "Provisioning Profiles"),
117539
+ path35.join("Library", "MobileDevice", "Provisioning Profiles")
117458
117540
  ];
117459
117541
  var PROFILE_DECODE_TIMEOUT_MS = 5e3;
117460
117542
  var PROFILE_MAX_BYTES = 16 * 1024 * 1024;
@@ -117475,9 +117557,9 @@ function parseProvisioningProfile(xml) {
117475
117557
  async function readInstalledProfiles() {
117476
117558
  const files = (await Promise.all(
117477
117559
  PROFILE_DIRECTORIES.map(async (directory) => {
117478
- const absolute = path34.join((0, import_node_os9.homedir)(), directory);
117560
+ const absolute = path35.join((0, import_node_os10.homedir)(), directory);
117479
117561
  const names = await import_node_fs13.promises.readdir(absolute).catch(() => []);
117480
- return names.filter((name) => name.endsWith(".mobileprovision")).map((name) => path34.join(absolute, name));
117562
+ return names.filter((name) => name.endsWith(".mobileprovision")).map((name) => path35.join(absolute, name));
117481
117563
  })
117482
117564
  )).flat();
117483
117565
  const decoded2 = await Promise.all(
@@ -117568,8 +117650,8 @@ function resolveRunnerProjectPath() {
117568
117650
  if (override) {
117569
117651
  return override;
117570
117652
  }
117571
- const candidate = path35.resolve(__dirname, PROJECT_SUFFIX);
117572
- if (fs40.existsSync(candidate)) {
117653
+ const candidate = path36.resolve(__dirname, PROJECT_SUFFIX);
117654
+ if (fs41.existsSync(candidate)) {
117573
117655
  return candidate;
117574
117656
  }
117575
117657
  throw withFailureSignal(
@@ -117594,8 +117676,8 @@ var FINGERPRINT_NOISE = /* @__PURE__ */ new Set([
117594
117676
  ".DS_Store"
117595
117677
  ]);
117596
117678
  async function fingerprintRunnerSources(projectPath) {
117597
- const root = path35.dirname(projectPath);
117598
- const hash2 = (0, import_node_crypto12.createHash)("sha256");
117679
+ const root = path36.dirname(projectPath);
117680
+ const hash2 = (0, import_node_crypto13.createHash)("sha256");
117599
117681
  const walk = async (dir) => {
117600
117682
  const entries = (await fsp.readdir(dir, { withFileTypes: true })).sort(
117601
117683
  (a, b) => a.name.localeCompare(b.name)
@@ -117604,12 +117686,12 @@ async function fingerprintRunnerSources(projectPath) {
117604
117686
  if (FINGERPRINT_NOISE.has(entry.name)) {
117605
117687
  continue;
117606
117688
  }
117607
- const full = path35.join(dir, entry.name);
117689
+ const full = path36.join(dir, entry.name);
117608
117690
  if (entry.isDirectory()) {
117609
117691
  await walk(full);
117610
117692
  } else if (entry.isFile()) {
117611
117693
  const content = await fsp.readFile(full);
117612
- hash2.update(`${path35.relative(root, full)}|${content.length}
117694
+ hash2.update(`${path36.relative(root, full)}|${content.length}
117613
117695
  `);
117614
117696
  hash2.update(content);
117615
117697
  }
@@ -117627,10 +117709,10 @@ async function xcodeVersionFingerprint() {
117627
117709
  }
117628
117710
  }
117629
117711
  function derivedRoot() {
117630
- return path35.join(argentHomeDir(), "ios-device-runner", "derived");
117712
+ return path36.join(argentHomeDir(), "ios-device-runner", "derived");
117631
117713
  }
117632
117714
  function derivedDirForTeam(teamId) {
117633
- return path35.join(derivedRoot(), teamId);
117715
+ return path36.join(derivedRoot(), teamId);
117634
117716
  }
117635
117717
  var CACHE_KEY_FILE = ".argent-cache-key";
117636
117718
  var TEAM_DIRECTORY_RE = /^[A-Z0-9]{10}$/;
@@ -117638,24 +117720,24 @@ async function removeBuildSharedByAllTeams(currentTeamId) {
117638
117720
  const root = derivedRoot();
117639
117721
  const entries = await fsp.readdir(root).catch(() => []);
117640
117722
  await Promise.all(
117641
- entries.filter((entry) => entry !== currentTeamId && !TEAM_DIRECTORY_RE.test(entry)).map((entry) => fsp.rm(path35.join(root, entry), { recursive: true, force: true }))
117723
+ entries.filter((entry) => entry !== currentTeamId && !TEAM_DIRECTORY_RE.test(entry)).map((entry) => fsp.rm(path36.join(root, entry), { recursive: true, force: true }))
117642
117724
  );
117643
117725
  }
117644
117726
  function runnerProductsDir(derivedDataPath) {
117645
- return path35.join(derivedDataPath, "Build", "Products");
117727
+ return path36.join(derivedDataPath, "Build", "Products");
117646
117728
  }
117647
117729
  function findBaseXctestrun(derivedDataPath) {
117648
117730
  const productsDir = runnerProductsDir(derivedDataPath);
117649
- if (!fs40.existsSync(productsDir)) {
117731
+ if (!fs41.existsSync(productsDir)) {
117650
117732
  return null;
117651
117733
  }
117652
- const candidates = fs40.readdirSync(productsDir).filter((name) => {
117734
+ const candidates = fs41.readdirSync(productsDir).filter((name) => {
117653
117735
  return name.endsWith(".xctestrun") && name.includes("iphoneos");
117654
117736
  });
117655
117737
  if (candidates.length === 0) {
117656
117738
  return null;
117657
117739
  }
117658
- return path35.join(productsDir, candidates.sort()[0]);
117740
+ return path36.join(productsDir, candidates.sort()[0]);
117659
117741
  }
117660
117742
  function xcodebuildFailureSummary(output2) {
117661
117743
  const lines = output2.split("\n");
@@ -117692,19 +117774,19 @@ function runnerBuildStaticArgs(projectPath, config2) {
117692
117774
  ];
117693
117775
  }
117694
117776
  function runnerBuildLocationArgs(derivedDataPath) {
117695
- const root = path35.resolve(derivedDataPath);
117696
- const intermediatesDir = path35.join(root, "Build", "Intermediates.noindex");
117777
+ const root = path36.resolve(derivedDataPath);
117778
+ const intermediatesDir = path36.join(root, "Build", "Intermediates.noindex");
117697
117779
  return [
117698
117780
  "-derivedDataPath",
117699
117781
  derivedDataPath,
117700
117782
  `SYMROOT=${runnerProductsDir(root)}`,
117701
117783
  `OBJROOT=${intermediatesDir}`,
117702
117784
  // Set from the same preference, and OBJROOT does not move it.
117703
- `SHARED_PRECOMPS_DIR=${path35.join(intermediatesDir, "PrecompiledHeaders")}`
117785
+ `SHARED_PRECOMPS_DIR=${path36.join(intermediatesDir, "PrecompiledHeaders")}`
117704
117786
  ];
117705
117787
  }
117706
117788
  function computeRunnerCacheKey(sourcesHash, xcodeVersion2, staticArgs) {
117707
- return (0, import_node_crypto12.createHash)("sha256").update([sourcesHash, xcodeVersion2, ...staticArgs].join("\n")).digest("hex").slice(0, 16);
117789
+ return (0, import_node_crypto13.createHash)("sha256").update([sourcesHash, xcodeVersion2, ...staticArgs].join("\n")).digest("hex").slice(0, 16);
117708
117790
  }
117709
117791
  function isProfileMissingDeviceFailure(logText) {
117710
117792
  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 +117797,7 @@ function isProfileExpiredFailure(logText) {
117715
117797
  var EXPIRY_RE = /<key>ExpirationDate<\/key>\s*<date>([^<]+)<\/date>/;
117716
117798
  var PROFILE_RENEWAL_MARGIN_MS = 60 * 60 * 1e3;
117717
117799
  async function readRunnerExpiryDate(derivedDataPath) {
117718
- const file2 = path35.join(
117800
+ const file2 = path36.join(
117719
117801
  runnerProductsDir(derivedDataPath),
117720
117802
  "Debug-iphoneos",
117721
117803
  "ArgentRunnerUITests-Runner.app",
@@ -117745,7 +117827,7 @@ async function ensureRunnerArtifact(config2, opts = {}) {
117745
117827
  const build2 = opts.build ?? buildRunnerArtifact;
117746
117828
  return withRunnerBuildLock(async () => {
117747
117829
  await removeBuildSharedByAllTeams(config2.teamId);
117748
- const stampPath = path35.join(derivedDataPath, CACHE_KEY_FILE);
117830
+ const stampPath = path36.join(derivedDataPath, CACHE_KEY_FILE);
117749
117831
  const stamped = await fsp.readFile(stampPath, "utf8").catch(() => null);
117750
117832
  if (!opts.force && stamped === cacheKey2) {
117751
117833
  const cached3 = findBaseXctestrun(derivedDataPath);
@@ -117831,18 +117913,18 @@ ${xcodebuildFailureSummary(output2)}`,
117831
117913
  // ../tool-server/src/utils/ios-device/runner-launch.ts
117832
117914
  var import_node_child_process30 = require("node:child_process");
117833
117915
  var import_node_events2 = require("node:events");
117834
- var fs41 = __toESM(require("node:fs"));
117916
+ var fs42 = __toESM(require("node:fs"));
117835
117917
  var fsp2 = __toESM(require("node:fs/promises"));
117836
- var path36 = __toESM(require("node:path"));
117918
+ var path37 = __toESM(require("node:path"));
117837
117919
  var import_node_util22 = require("node:util");
117838
117920
  init_src2();
117839
117921
  init_src();
117840
117922
  var execFileAsync21 = (0, import_node_util22.promisify)(import_node_child_process30.execFile);
117841
117923
  function logsRoot() {
117842
- return path36.join(argentHomeDir(), "ios-device-runner", "logs");
117924
+ return path37.join(argentHomeDir(), "ios-device-runner", "logs");
117843
117925
  }
117844
117926
  function resultsRoot() {
117845
- return path36.join(argentHomeDir(), "ios-device-runner", "results");
117927
+ return path37.join(argentHomeDir(), "ios-device-runner", "results");
117846
117928
  }
117847
117929
  var RUNNER_ATTACHMENT_SETTINGS = [
117848
117930
  ["PreferredScreenCaptureFormat", "screenshots"],
@@ -117875,11 +117957,11 @@ async function launchRunner(opts) {
117875
117957
  fsp2.mkdir(resultsDir, { recursive: true })
117876
117958
  ]);
117877
117959
  const deviceTag = opts.udid.slice(0, 8);
117878
- const logPath = path36.join(logDir, `runner-${deviceTag}.log`);
117879
- const resultBundlePath = path36.join(resultsDir, `argent-${deviceTag}.xcresult`);
117960
+ const logPath = path37.join(logDir, `runner-${deviceTag}.log`);
117961
+ const resultBundlePath = path37.join(resultsDir, `argent-${deviceTag}.xcresult`);
117880
117962
  await fsp2.rm(resultBundlePath, { recursive: true, force: true });
117881
117963
  await disableRunnerAttachments(opts.xctestrunPath);
117882
- const logFd = fs41.openSync(logPath, "w");
117964
+ const logFd = fs42.openSync(logPath, "w");
117883
117965
  const child = (0, import_node_child_process30.spawn)(
117884
117966
  "xcodebuild",
117885
117967
  [
@@ -117916,7 +117998,7 @@ async function launchRunner(opts) {
117916
117998
  }
117917
117999
  );
117918
118000
  child.unref();
117919
- fs41.closeSync(logFd);
118001
+ fs42.closeSync(logFd);
117920
118002
  try {
117921
118003
  await (0, import_node_events2.once)(child, "spawn");
117922
118004
  } catch (error63) {
@@ -117967,7 +118049,7 @@ function killRunnerProcess(child) {
117967
118049
  // ../tool-server/src/utils/ios-device/runner-sweep.ts
117968
118050
  var import_node_child_process31 = require("node:child_process");
117969
118051
  var import_node_util23 = require("node:util");
117970
- var path37 = __toESM(require("node:path"));
118052
+ var path38 = __toESM(require("node:path"));
117971
118053
  init_src();
117972
118054
  var execFileAsync22 = (0, import_node_util23.promisify)(import_node_child_process31.execFile);
117973
118055
  var PROCESS_TABLE_MAX_BYTES = 16 * 1024 * 1024;
@@ -117989,7 +118071,7 @@ async function killStaleRunnersForDevice(udid, listProcesses = listProcessTable)
117989
118071
  const kill = process.kill.bind(process);
117990
118072
  const signaled = [];
117991
118073
  for (const line of stdout.split("\n")) {
117992
- if (!line.includes("test-without-building") || !line.includes(`platform=iOS,id=${udid}`) || !line.includes(` ${path37.join(argentHomeDir(), "ios-device-runner")}${path37.sep}`)) {
118074
+ if (!line.includes("test-without-building") || !line.includes(`platform=iOS,id=${udid}`) || !line.includes(` ${path38.join(argentHomeDir(), "ios-device-runner")}${path38.sep}`)) {
117993
118075
  continue;
117994
118076
  }
117995
118077
  const [pidField, ppidField] = line.trim().split(/\s+/);
@@ -118017,7 +118099,7 @@ async function killStaleRunnersForDevice(udid, listProcesses = listProcessTable)
118017
118099
  }
118018
118100
 
118019
118101
  // ../tool-server/src/blueprints/ios-device-runner.ts
118020
- var fs43 = __toESM(require("node:fs/promises"));
118102
+ var fs44 = __toESM(require("node:fs/promises"));
118021
118103
 
118022
118104
  // ../tool-server/src/utils/ios-device/runner-route.ts
118023
118105
  var import_node_net3 = __toESM(require("node:net"));
@@ -118405,7 +118487,7 @@ function defaultSendViaUsbmux(udid, port, body, deadline) {
118405
118487
  // ../tool-server/src/utils/ios-device/runner-crash.ts
118406
118488
  var import_node_child_process32 = require("node:child_process");
118407
118489
  var import_node_util24 = require("node:util");
118408
- var fs42 = __toESM(require("node:fs/promises"));
118490
+ var fs43 = __toESM(require("node:fs/promises"));
118409
118491
  var execFileAsync23 = (0, import_node_util24.promisify)(import_node_child_process32.execFile);
118410
118492
  var XCRESULTTOOL_TIMEOUT_MS = 15e3;
118411
118493
  var XCRESULTTOOL_MAX_JSON_BYTES = 32 * 1024 * 1024;
@@ -118425,7 +118507,7 @@ function extractCrashFailureText(summary) {
118425
118507
  }
118426
118508
  async function readRunnerCrashSummary(resultBundlePath) {
118427
118509
  try {
118428
- await fs42.access(resultBundlePath);
118510
+ await fs43.access(resultBundlePath);
118429
118511
  const { stdout } = await execFileAsync23(
118430
118512
  "xcrun",
118431
118513
  ["xcresulttool", "get", "test-results", "summary", "--path", resultBundlePath],
@@ -118438,7 +118520,7 @@ async function readRunnerCrashSummary(resultBundlePath) {
118438
118520
  }
118439
118521
 
118440
118522
  // ../tool-server/src/utils/ios-device/runner-client.ts
118441
- var import_node_crypto13 = require("node:crypto");
118523
+ var import_node_crypto14 = require("node:crypto");
118442
118524
  init_src2();
118443
118525
  var RUNNER_COMMAND_TIMEOUT_MS = 45e3;
118444
118526
  var RUNNER_STATUS_RECOVERY_TIMEOUT_MS = 3e3;
@@ -118651,7 +118733,7 @@ function withCommandId(command2) {
118651
118733
  if (command2.command === "status" || typeof command2.commandId === "string") {
118652
118734
  return command2;
118653
118735
  }
118654
- return { ...command2, commandId: `argent-${(0, import_node_crypto13.randomUUID)()}` };
118736
+ return { ...command2, commandId: `argent-${(0, import_node_crypto14.randomUUID)()}` };
118655
118737
  }
118656
118738
  function unwrapEnvelope(response, udid) {
118657
118739
  const envelope = asEnvelope(response);
@@ -118798,7 +118880,7 @@ async function startRunner(udid, artifact, tunnelAddress) {
118798
118880
  launched.child.once("exit", reserveInteractionRunner(udid));
118799
118881
  }
118800
118882
  killRunnerProcess(launched.child);
118801
- const logText = await fs43.readFile(launched.logPath, "utf8").catch(() => "");
118883
+ const logText = await fs44.readFile(launched.logPath, "utf8").catch(() => "");
118802
118884
  throw Object.assign(
118803
118885
  withFailureSignal(
118804
118886
  new Error(
@@ -123779,7 +123861,7 @@ async function describeVega(_serial) {
123779
123861
  }
123780
123862
 
123781
123863
  // ../tool-server/src/tools/describe/platforms/harmony/index.ts
123782
- var import_node_os10 = require("node:os");
123864
+ var import_node_os11 = require("node:os");
123783
123865
  var import_node_path16 = require("node:path");
123784
123866
  var import_promises15 = require("node:fs/promises");
123785
123867
 
@@ -124303,7 +124385,7 @@ function pollHarmonyTree(connectKey, budgetMs) {
124303
124385
  return describeHarmony(connectKey, budgetMs);
124304
124386
  }
124305
124387
  async function describeHarmony(connectKey, timeoutMs = HARMONY_INTERACTION_TIMEOUT_MS) {
124306
- const localPath = (0, import_node_path16.join)((0, import_node_os10.tmpdir)(), `argent-harmony-dump-${process.hrtime.bigint()}.json`);
124388
+ const localPath = (0, import_node_path16.join)((0, import_node_os11.tmpdir)(), `argent-harmony-dump-${process.hrtime.bigint()}.json`);
124307
124389
  const deadline = Date.now() + timeoutMs;
124308
124390
  const display = await harmonyDisplay(
124309
124391
  connectKey,
@@ -124339,12 +124421,12 @@ init_src2();
124339
124421
 
124340
124422
  // ../tool-server/src/blueprints/macos-app.ts
124341
124423
  var import_node_child_process33 = require("node:child_process");
124342
- var import_node_crypto14 = require("node:crypto");
124424
+ var import_node_crypto15 = require("node:crypto");
124343
124425
  var import_node_events5 = require("node:events");
124344
- var fs44 = __toESM(require("node:fs"));
124426
+ var fs45 = __toESM(require("node:fs"));
124345
124427
  var net9 = __toESM(require("node:net"));
124346
124428
  var os12 = __toESM(require("node:os"));
124347
- var path38 = __toESM(require("node:path"));
124429
+ var path39 = __toESM(require("node:path"));
124348
124430
  init_src2();
124349
124431
  init_device_info();
124350
124432
 
@@ -124582,7 +124664,7 @@ async function stopProcesses(pids, executable, group) {
124582
124664
  }
124583
124665
  function readLogTail(logPath) {
124584
124666
  try {
124585
- const lines = fs44.readFileSync(logPath, "utf8").trimEnd().split("\n");
124667
+ const lines = fs45.readFileSync(logPath, "utf8").trimEnd().split("\n");
124586
124668
  const tail = lines.slice(-20).join("\n").trim();
124587
124669
  return tail ? `
124588
124670
  Last lines of ${logPath}:
@@ -124626,7 +124708,7 @@ function closedByArgentError(bundleId, method) {
124626
124708
  "unknown"
124627
124709
  );
124628
124710
  }
124629
- var nextCdpWireId = (0, import_node_crypto14.randomInt)(2 ** 47);
124711
+ var nextCdpWireId = (0, import_node_crypto15.randomInt)(2 ** 47);
124630
124712
  var LibraryChannel = class {
124631
124713
  /**
124632
124714
  * @param expectedPid the app's pid when known; a launch learns it from the helper after the spawn.
@@ -125287,7 +125369,7 @@ function createMacosAppApi(bundleId) {
125287
125369
  "not_found"
125288
125370
  );
125289
125371
  }
125290
- if (!opts.appPath && tracked && !fs44.existsSync(appPath)) {
125372
+ if (!opts.appPath && tracked && !fs45.existsSync(appPath)) {
125291
125373
  throw macosFailure(
125292
125374
  `argent last started ${bundleId} from ${appPath}, which no longer exists. Pass the .app path to boot-device as macosAppPath.`,
125293
125375
  FAILURE_CODES.MACOS_APP_PATH_INVALID,
@@ -125347,6 +125429,10 @@ function createMacosAppApi(bundleId) {
125347
125429
  );
125348
125430
  }
125349
125431
  const bootstrapPath = await stageLibraryFor(info, artifacts);
125432
+ const listen4 = macosListenSocket(bundleId, info.sandboxed);
125433
+ const logPath = macosAppLogPath(bundleId);
125434
+ fs45.mkdirSync(path39.dirname(logPath), { recursive: true, mode: 448 });
125435
+ if (listen4 && !info.sandboxed) prepareSocketDir(listen4.path);
125350
125436
  const forceQuit = own2 ? await terminate(own2) : void 0;
125351
125437
  let tookOver;
125352
125438
  if (copies.same.length > 0) {
@@ -125363,11 +125449,8 @@ function createMacosAppApi(bundleId) {
125363
125449
  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
125450
  }
125365
125451
  }
125366
- const listen4 = macosListenSocket(bundleId, info.sandboxed);
125367
- const logPath = macosAppLogPath(bundleId);
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, "");
125452
+ if (listen4 && !info.sandboxed) fs45.rmSync(listen4.path, { force: true });
125453
+ fs45.writeFileSync(logPath, "");
125371
125454
  const args = opts.args ?? (opts.noLastArgs ? void 0 : tracked?.args) ?? [];
125372
125455
  const helper = (0, import_node_child_process33.spawn)(
125373
125456
  artifacts.helper,
@@ -126955,8 +127038,8 @@ var SourceMapsRegistry = class {
126955
127038
  };
126956
127039
 
126957
127040
  // ../tool-server/src/utils/debugger/log-file-writer.ts
126958
- var fs45 = __toESM(require("node:fs"));
126959
- var path39 = __toESM(require("node:path"));
127041
+ var fs46 = __toESM(require("node:fs"));
127042
+ var path40 = __toESM(require("node:path"));
126960
127043
  init_src();
126961
127044
  var MAX_ENTRIES = 5e4;
126962
127045
  var STALE_LOG_MS = 24 * 60 * 60 * 1e3;
@@ -126982,19 +127065,19 @@ var LogFileWriter = class {
126982
127065
  closed = false;
126983
127066
  constructor(port) {
126984
127067
  const timestamp = lastTimestamp = Math.max(Date.now(), lastTimestamp + 1);
126985
- const dir = path39.join(argentHomeDir(), "tmp");
127068
+ const dir = path40.join(argentHomeDir(), "tmp");
126986
127069
  try {
126987
- fs45.mkdirSync(dir, { recursive: true });
127070
+ fs46.mkdirSync(dir, { recursive: true });
126988
127071
  } catch {
126989
127072
  }
126990
127073
  pruneStaleLogs(dir);
126991
- this.filePath = path39.join(dir, `argent-logs-${port}-${timestamp}-p${process.pid}.log`);
127074
+ this.filePath = path40.join(dir, `argent-logs-${port}-${timestamp}-p${process.pid}.log`);
126992
127075
  liveLogFiles.add(this.filePath);
126993
127076
  this.open();
126994
127077
  }
126995
127078
  open() {
126996
127079
  try {
126997
- this.fd = fs45.openSync(this.filePath, "w");
127080
+ this.fd = fs46.openSync(this.filePath, "w");
126998
127081
  this.ready = true;
126999
127082
  } catch {
127000
127083
  }
@@ -127020,7 +127103,7 @@ var LogFileWriter = class {
127020
127103
  try {
127021
127104
  const bytes = Buffer.from(this.midLine ? `
127022
127105
  ${line}` : line);
127023
- const written = fs45.writeSync(this.fd, bytes, 0, bytes.length, this.bytesWritten);
127106
+ const written = fs46.writeSync(this.fd, bytes, 0, bytes.length, this.bytesWritten);
127024
127107
  if (written === bytes.length) {
127025
127108
  this.bytesWritten += written;
127026
127109
  this.midLine = false;
@@ -127072,7 +127155,7 @@ ${line}` : line);
127072
127155
  /** A torn line past " | " would parse as a whole entry with its message cut. */
127073
127156
  dropTornLine(fd, bytes, written) {
127074
127157
  try {
127075
- fs45.ftruncateSync(fd, this.bytesWritten);
127158
+ fs46.ftruncateSync(fd, this.bytesWritten);
127076
127159
  } catch {
127077
127160
  this.bytesWritten += written;
127078
127161
  if (written > 0) this.midLine = bytes[written - 1] !== 10;
@@ -127086,7 +127169,7 @@ ${line}` : line);
127086
127169
  return this.fileEntryCount;
127087
127170
  }
127088
127171
  hasFile() {
127089
- return fs45.existsSync(this.filePath);
127172
+ return fs46.existsSync(this.filePath);
127090
127173
  }
127091
127174
  getStats() {
127092
127175
  return {
@@ -127111,7 +127194,7 @@ ${line}` : line);
127111
127194
  readAll() {
127112
127195
  if (this.closed || !this.ready) return [];
127113
127196
  try {
127114
- const content = fs45.readFileSync(this.filePath, "utf-8");
127197
+ const content = fs46.readFileSync(this.filePath, "utf-8");
127115
127198
  return content.split("\n").filter((line) => line.length > 0).map(parseFlatLine).filter((entry) => entry !== null);
127116
127199
  } catch {
127117
127200
  return [];
@@ -127133,7 +127216,7 @@ ${line}` : line);
127133
127216
  liveLogFiles.delete(this.filePath);
127134
127217
  if (this.fd !== null) {
127135
127218
  try {
127136
- fs45.closeSync(this.fd);
127219
+ fs46.closeSync(this.fd);
127137
127220
  } catch {
127138
127221
  }
127139
127222
  this.fd = null;
@@ -127141,13 +127224,13 @@ ${line}` : line);
127141
127224
  if (keepFile) {
127142
127225
  try {
127143
127226
  const now = /* @__PURE__ */ new Date();
127144
- fs45.utimesSync(this.filePath, now, now);
127227
+ fs46.utimesSync(this.filePath, now, now);
127145
127228
  } catch {
127146
127229
  }
127147
127230
  return;
127148
127231
  }
127149
127232
  try {
127150
- fs45.unlinkSync(this.filePath);
127233
+ fs46.unlinkSync(this.filePath);
127151
127234
  } catch {
127152
127235
  }
127153
127236
  }
@@ -127156,17 +127239,17 @@ function pruneStaleLogs(dir) {
127156
127239
  const cutoff = Date.now() - STALE_LOG_MS;
127157
127240
  let names;
127158
127241
  try {
127159
- names = fs45.readdirSync(dir);
127242
+ names = fs46.readdirSync(dir);
127160
127243
  } catch {
127161
127244
  return;
127162
127245
  }
127163
127246
  for (const name of names) {
127164
127247
  const pid = Number(/^argent-logs-.*-p(\d+)\.log$/.exec(name)?.[1]);
127165
127248
  if (!pid) continue;
127166
- const file2 = path39.join(dir, name);
127249
+ const file2 = path40.join(dir, name);
127167
127250
  if (pid === process.pid ? liveLogFiles.has(file2) : isAlive(pid)) continue;
127168
127251
  try {
127169
- if (fs45.statSync(file2).mtimeMs < cutoff) fs45.unlinkSync(file2);
127252
+ if (fs46.statSync(file2).mtimeMs < cutoff) fs46.unlinkSync(file2);
127170
127253
  } catch {
127171
127254
  }
127172
127255
  }
@@ -127830,39 +127913,6 @@ function directCallFailure(tool, result) {
127830
127913
  return toolResultVerdict(tool, result)?.reason;
127831
127914
  }
127832
127915
 
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
127916
  // ../tool-server/src/http.ts
127867
127917
  var AUTO_SUPPRESS_MS = 30 * 60 * 1e3;
127868
127918
  var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";