@camstack/server 1.2.858 → 1.2.860

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/api/trpc/generated-cap-routers.js +16 -0
  3. package/dist/core/cluster-update/cluster-update-steps.js +10 -2
  4. package/dist/server-root/index.js +1125 -45
  5. package/package.json +17 -16
  6. package/system/dist/addon-runner.js +76 -1
  7. package/system/dist/addon-runner.mjs +76 -1
  8. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  9. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  10. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  11. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  12. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  13. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  14. package/system/dist/builtins/autotrack/index.js +1 -1
  15. package/system/dist/builtins/autotrack/index.mjs +1 -1
  16. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  17. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  18. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  19. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  20. package/system/dist/builtins/camera-grid/index.js +1 -1
  21. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  22. package/system/dist/builtins/composer/composer.addon.js +4 -4
  23. package/system/dist/builtins/composer/composer.addon.mjs +4 -4
  24. package/system/dist/builtins/console-logging/index.js +1 -1
  25. package/system/dist/builtins/console-logging/index.mjs +1 -1
  26. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  27. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  28. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  29. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  30. package/system/dist/builtins/device-manager/device-manager.addon.js +32 -23
  31. package/system/dist/builtins/device-manager/device-manager.addon.mjs +32 -23
  32. package/system/dist/builtins/device-manager/device-search.d.ts +4 -3
  33. package/system/dist/builtins/device-manager/removal-fence.d.ts +2 -2
  34. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  35. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  36. package/system/dist/builtins/keychain/index.js +4 -4
  37. package/system/dist/builtins/keychain/index.mjs +4 -4
  38. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  39. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  40. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  41. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  42. package/system/dist/builtins/local-network/local-network.addon.js +3 -3
  43. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  44. package/system/dist/builtins/loki-logging/index.js +1 -1
  45. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  46. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  47. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  48. package/system/dist/builtins/platform-probe/index.js +1 -1
  49. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  50. package/system/dist/builtins/record-entries/index.js +1 -1
  51. package/system/dist/builtins/record-entries/index.mjs +1 -1
  52. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  53. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  54. package/system/dist/builtins/snapshot/index.js +1 -1
  55. package/system/dist/builtins/snapshot/index.mjs +1 -1
  56. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  57. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  58. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  59. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  60. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  61. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  62. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  63. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  64. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  65. package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
  66. package/system/dist/builtins/winston-logging/index.js +1 -1
  67. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  68. package/system/dist/{capture-engine-B4_fq2JB.mjs → capture-engine-B5OYzCH1.mjs} +1 -1
  69. package/system/dist/{capture-engine-yhFFC7F8.js → capture-engine-BManwD48.js} +1 -1
  70. package/system/dist/{composition-sources-BQOEYCJG.mjs → composition-sources-B8hoUx1K.mjs} +1 -1
  71. package/system/dist/{composition-sources-CKSSe5ny.js → composition-sources-DWu-IL2w.js} +1 -1
  72. package/system/dist/{constants-dfnEfsX7.js → constants-CUAopsxj.js} +1 -1
  73. package/system/dist/{constants-h8wJE_8O.mjs → constants-qDKQ7NaY.mjs} +1 -1
  74. package/system/dist/{device-ca-h54CenJx.mjs → device-ca-BOUTrISA.mjs} +1 -1
  75. package/system/dist/{device-ca-_o0-3jJ6.js → device-ca-DNrM4Ao-.js} +1 -1
  76. package/system/dist/{dist-atHH8IeD.mjs → dist-3MQdfUTG.mjs} +254 -71
  77. package/system/dist/{dist-WEGVb8qV.js → dist-B9Kzw974.js} +259 -70
  78. package/system/dist/file-host-worker.js +1 -1
  79. package/system/dist/file-host-worker.mjs +1 -1
  80. package/system/dist/{hub-identity-nIMYA24i.js → hub-identity-BQIE6w3g.js} +1 -1
  81. package/system/dist/{hub-identity-DLF698tj.mjs → hub-identity-DEbxcoVh.mjs} +1 -1
  82. package/system/dist/{hub-mdns-ciao-B6ZHStt1.js → hub-mdns-ciao-Bj_RdJiH.js} +2 -2
  83. package/system/dist/{hub-mdns-ciao-DchpUVAk.mjs → hub-mdns-ciao-BzKGywE2.mjs} +2 -2
  84. package/system/dist/index.js +84 -9
  85. package/system/dist/index.mjs +84 -9
  86. package/system/dist/kernel/moleculer/switch-toggle.d.ts +41 -0
  87. package/system/dist/{legacy-integration-rows-door-BbaIE1qF.js → legacy-integration-rows-door-CRfEC_HP.js} +1 -1
  88. package/system/dist/{legacy-integration-rows-door-DBO3ZLmn.mjs → legacy-integration-rows-door-rgL9olef.mjs} +1 -1
  89. package/system/dist/{rename-composition-block-IIfaFnEl.js → rename-composition-block-Bbt43q6n.js} +1 -1
  90. package/system/dist/{rename-composition-block-6ISzMLgj.mjs → rename-composition-block-DlgSgxch.mjs} +1 -1
  91. package/system/dist/{restore-archive-ChRNoqGg.js → restore-archive-DJBACMC0.js} +1 -1
  92. package/system/dist/{restore-archive-DeDRh7Lf.mjs → restore-archive-aQzQt2Kv.mjs} +82 -82
  93. package/system/dist/{wal-maintenance-BXj9xnDD.mjs → wal-maintenance-Bu6vjJlR.mjs} +0 -0
  94. package/system/dist/{wal-maintenance-l3CsKEaJ.js → wal-maintenance-BvIEU1r1.js} +0 -0
  95. package/system/package.json +1 -1
@@ -96,6 +96,8 @@ var require_dist = __commonJS({
96
96
  STAGING_FAILED_REASON: /* @__PURE__ */ __name(() => STAGING_FAILED_REASON, "STAGING_FAILED_REASON"),
97
97
  STAGING_RETRY_DELAYS_MS: /* @__PURE__ */ __name(() => STAGING_RETRY_DELAYS_MS, "STAGING_RETRY_DELAYS_MS"),
98
98
  STARTER_HOSTS_SERVER_MIN: /* @__PURE__ */ __name(() => STARTER_HOSTS_SERVER_MIN, "STARTER_HOSTS_SERVER_MIN"),
99
+ TIMEOUT_CEILING_REASON: /* @__PURE__ */ __name(() => TIMEOUT_CEILING_REASON, "TIMEOUT_CEILING_REASON"),
100
+ TIMEOUT_STALL_REASON: /* @__PURE__ */ __name(() => TIMEOUT_STALL_REASON, "TIMEOUT_STALL_REASON"),
99
101
  applyPendingRootSwap: /* @__PURE__ */ __name(() => applyPendingRootSwap, "applyPendingRootSwap"),
100
102
  assessImageContract: /* @__PURE__ */ __name(() => assessImageContract, "assessImageContract"),
101
103
  clearPendingRootSwap: /* @__PURE__ */ __name(() => clearPendingRootSwap, "clearPendingRootSwap"),
@@ -120,6 +122,8 @@ var require_dist = __commonJS({
120
122
  isDesktopInstallRequestFile: /* @__PURE__ */ __name(() => isDesktopInstallRequestFile, "isDesktopInstallRequestFile"),
121
123
  isDevChannelVersion: /* @__PURE__ */ __name(() => isDevChannelVersion, "isDevChannelVersion"),
122
124
  isHostExternal: /* @__PURE__ */ __name(() => isHostExternal, "isHostExternal"),
125
+ isInstallTimeout: /* @__PURE__ */ __name(() => isInstallTimeout, "isInstallTimeout"),
126
+ isRetryableStagingFailure: /* @__PURE__ */ __name(() => isRetryableStagingFailure, "isRetryableStagingFailure"),
123
127
  isServerRootState: /* @__PURE__ */ __name(() => isServerRootState, "isServerRootState"),
124
128
  isTransientNpmNetworkError: /* @__PURE__ */ __name(() => isTransientNpmNetworkError, "isTransientNpmNetworkError"),
125
129
  migrateToSingleCopy: /* @__PURE__ */ __name(() => migrateToSingleCopy, "migrateToSingleCopy"),
@@ -1238,11 +1242,9 @@ var require_dist = __commonJS({
1238
1242
  options.loadEntry(options.seedEntry);
1239
1243
  }
1240
1244
  __name(runNodeStarter, "runNodeStarter");
1241
- var import_node_child_process = require("child_process");
1242
- var fs8 = __toESM2(require("fs"));
1243
- var path8 = __toESM2(require("path"));
1244
1245
  var import_node_crypto = require("crypto");
1245
- var import_node_util = require("util");
1246
+ var fs12 = __toESM2(require("fs"));
1247
+ var path12 = __toESM2(require("path"));
1246
1248
  var fs7 = __toESM2(require("fs"));
1247
1249
  var path7 = __toESM2(require("path"));
1248
1250
  var MINIMUM_RE = /^>=(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
@@ -1359,7 +1361,948 @@ var require_dist = __commonJS({
1359
1361
  }
1360
1362
  }
1361
1363
  __name(describeUnmetRequirement, "describeUnmetRequirement");
1362
- var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
1364
+ var fs8 = __toESM2(require("fs"));
1365
+ var path8 = __toESM2(require("path"));
1366
+ var LOCKFILES = [
1367
+ "package-lock.json",
1368
+ "npm-shrinkwrap.json"
1369
+ ];
1370
+ async function seedStagingFromCurrent(currentDir2, stagingDir) {
1371
+ const packageJson = path8.join(currentDir2, "package.json");
1372
+ const nodeModules = path8.join(currentDir2, "node_modules");
1373
+ if (!fs8.existsSync(packageJson) || !fs8.existsSync(nodeModules)) {
1374
+ throw new Error(`current closure at ${currentDir2} has no package.json or node_modules to seed from`);
1375
+ }
1376
+ await fs8.promises.cp(packageJson, path8.join(stagingDir, "package.json"));
1377
+ for (const name of LOCKFILES) {
1378
+ const source = path8.join(currentDir2, name);
1379
+ if (!fs8.existsSync(source)) continue;
1380
+ await fs8.promises.cp(source, path8.join(stagingDir, name));
1381
+ }
1382
+ await fs8.promises.cp(nodeModules, path8.join(stagingDir, "node_modules"), {
1383
+ recursive: true,
1384
+ verbatimSymlinks: true
1385
+ });
1386
+ }
1387
+ __name(seedStagingFromCurrent, "seedStagingFromCurrent");
1388
+ var fs9 = __toESM2(require("fs"));
1389
+ var path9 = __toESM2(require("path"));
1390
+ var NPM_LS_TIMEOUT_MS = 6e4;
1391
+ var VALIDATION_FAILED_KIND = "validation-failed";
1392
+ var ClosureValidationError = class extends Error {
1393
+ static {
1394
+ __name(this, "ClosureValidationError");
1395
+ }
1396
+ kind = VALIDATION_FAILED_KIND;
1397
+ constructor(message) {
1398
+ super(message);
1399
+ this.name = "ClosureValidationError";
1400
+ }
1401
+ };
1402
+ var NPM_LS_ARGS = [
1403
+ "ls",
1404
+ "--omit=dev",
1405
+ "--all"
1406
+ ];
1407
+ var LS_PROBLEM_RE = /\b(?:invalid|missing|extraneous)\b/i;
1408
+ function isRecord2(value) {
1409
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1410
+ }
1411
+ __name(isRecord2, "isRecord2");
1412
+ function readDependencies(value) {
1413
+ if (!isRecord2(value)) return null;
1414
+ const deps = {};
1415
+ for (const [key, raw] of Object.entries(value)) {
1416
+ if (typeof raw === "string") deps[key] = raw;
1417
+ }
1418
+ return deps;
1419
+ }
1420
+ __name(readDependencies, "readDependencies");
1421
+ function readLockEntry(value) {
1422
+ if (!isRecord2(value)) return null;
1423
+ const version = value["version"];
1424
+ return {
1425
+ version: typeof version === "string" ? version : null,
1426
+ dependencies: readDependencies(value["dependencies"])
1427
+ };
1428
+ }
1429
+ __name(readLockEntry, "readLockEntry");
1430
+ function lockfilePath(stagingDir) {
1431
+ for (const name of [
1432
+ "npm-shrinkwrap.json",
1433
+ "package-lock.json"
1434
+ ]) {
1435
+ const full = path9.join(stagingDir, name);
1436
+ if (fs9.existsSync(full)) return full;
1437
+ }
1438
+ return null;
1439
+ }
1440
+ __name(lockfilePath, "lockfilePath");
1441
+ function readLockPackages(stagingDir) {
1442
+ const file = lockfilePath(stagingDir);
1443
+ if (file === null) return null;
1444
+ let raw;
1445
+ try {
1446
+ raw = JSON.parse(fs9.readFileSync(file, "utf8"));
1447
+ } catch {
1448
+ return null;
1449
+ }
1450
+ if (!isRecord2(raw) || !isRecord2(raw["packages"])) return null;
1451
+ const map = {};
1452
+ for (const [key, value] of Object.entries(raw["packages"])) {
1453
+ const entry = readLockEntry(value);
1454
+ if (entry !== null) map[key] = entry;
1455
+ }
1456
+ return map;
1457
+ }
1458
+ __name(readLockPackages, "readLockPackages");
1459
+ function readInstalledVersion(pkgJsonPath) {
1460
+ try {
1461
+ const raw = JSON.parse(fs9.readFileSync(pkgJsonPath, "utf8"));
1462
+ if (!isRecord2(raw)) return null;
1463
+ const version = raw["version"];
1464
+ return typeof version === "string" ? version : null;
1465
+ } catch {
1466
+ return null;
1467
+ }
1468
+ }
1469
+ __name(readInstalledVersion, "readInstalledVersion");
1470
+ function targetRecordMismatch(stagingDir, packages, packageName, target) {
1471
+ const rootDep = packages[""]?.dependencies?.[packageName] ?? null;
1472
+ if (rootDep !== target) {
1473
+ return `lockfile packages[""] dependency ${packageName} is ${rootDep ?? "absent"}, target is ${target}`;
1474
+ }
1475
+ const lockedKey = `node_modules/${packageName}`;
1476
+ const locked = packages[lockedKey]?.version ?? null;
1477
+ if (locked !== target) {
1478
+ return `lockfile ${lockedKey} version is ${locked ?? "absent"}, target is ${target}`;
1479
+ }
1480
+ const installed = readInstalledVersion(path9.join(stagingDir, "node_modules", ...packageName.split("/"), "package.json"));
1481
+ if (installed !== target) {
1482
+ return `installed ${packageName} version is ${installed ?? "absent"}, target is ${target}`;
1483
+ }
1484
+ return null;
1485
+ }
1486
+ __name(targetRecordMismatch, "targetRecordMismatch");
1487
+ function staleLockedPackage(stagingDir, packages) {
1488
+ for (const [key, entry] of Object.entries(packages)) {
1489
+ if (key.length === 0 || entry.version === null) continue;
1490
+ const pkgJson = path9.join(stagingDir, key, "package.json");
1491
+ if (!fs9.existsSync(pkgJson)) continue;
1492
+ const installed = readInstalledVersion(pkgJson);
1493
+ if (installed !== entry.version) {
1494
+ return `stale ${key}: installed ${installed ?? "unreadable"}, lockfile ${entry.version}`;
1495
+ }
1496
+ }
1497
+ return null;
1498
+ }
1499
+ __name(staleLockedPackage, "staleLockedPackage");
1500
+ function closureLockMismatch(stagingDir, packageName, target) {
1501
+ const packages = readLockPackages(stagingDir);
1502
+ if (packages === null) return `lockfile missing or has no packages map in ${stagingDir}`;
1503
+ return targetRecordMismatch(stagingDir, packages, packageName, target) ?? staleLockedPackage(stagingDir, packages);
1504
+ }
1505
+ __name(closureLockMismatch, "closureLockMismatch");
1506
+ function validationFailed(message) {
1507
+ return new ClosureValidationError(message);
1508
+ }
1509
+ __name(validationFailed, "validationFailed");
1510
+ async function assertInstalledClosureTree(stagingDir, packageName, target, execNpm) {
1511
+ let listed;
1512
+ try {
1513
+ listed = await execNpm(NPM_LS_ARGS, {
1514
+ cwd: stagingDir,
1515
+ timeoutMs: NPM_LS_TIMEOUT_MS
1516
+ });
1517
+ } catch (err) {
1518
+ const message = err instanceof Error ? err.message : String(err);
1519
+ throw validationFailed(`npm ls failed in ${stagingDir}: ${message}`);
1520
+ }
1521
+ if (LS_PROBLEM_RE.test(listed.stdout)) {
1522
+ throw validationFailed(`npm ls reported a broken tree in ${stagingDir}`);
1523
+ }
1524
+ const mismatch = closureLockMismatch(stagingDir, packageName, target);
1525
+ if (mismatch !== null) throw validationFailed(mismatch);
1526
+ }
1527
+ __name(assertInstalledClosureTree, "assertInstalledClosureTree");
1528
+ var import_node_child_process = require("child_process");
1529
+ var fs11 = __toESM2(require("fs"));
1530
+ var path11 = __toESM2(require("path"));
1531
+ var fs10 = __toESM2(require("fs"));
1532
+ var path10 = __toESM2(require("path"));
1533
+ var PROGRESS_WALK_ENTRY_BUDGET = 2e4;
1534
+ var PROGRESS_WALK_TIME_BUDGET_MS = 2e3;
1535
+ var NODE_MODULES_LEVELS = 2;
1536
+ var LOG_ENV_KEYS = [
1537
+ "npm_config_logs_dir",
1538
+ "NPM_CONFIG_LOGS_DIR",
1539
+ "npm_config_tmp",
1540
+ "NPM_CONFIG_TMP"
1541
+ ];
1542
+ var EMPTY_MARK = {
1543
+ newestMtimeMs: 0,
1544
+ size: 0,
1545
+ count: 0
1546
+ };
1547
+ async function measureInstallProgress(options) {
1548
+ const budget = {
1549
+ entries: 0,
1550
+ startedMs: Date.now(),
1551
+ exceeded: false,
1552
+ aborted: options.aborted,
1553
+ entryLimit: options.entryBudget ?? PROGRESS_WALK_ENTRY_BUDGET
1554
+ };
1555
+ const cheap = await collectCheap(options.stagingDir, options.progressDirs, options.env, budget);
1556
+ if (cheap === "aborted") return {
1557
+ kind: "aborted",
1558
+ entries: budget.entries
1559
+ };
1560
+ if (cheap === "budget") return unknownSample(budget);
1561
+ const token = markToken(cheap);
1562
+ if (options.previousCheap !== null && token !== options.previousCheap) {
1563
+ return {
1564
+ kind: "mark",
1565
+ cheap: token,
1566
+ bytes: null
1567
+ };
1568
+ }
1569
+ const sum = await sumTree(options.stagingDir, budget);
1570
+ if (sum === "aborted") return {
1571
+ kind: "aborted",
1572
+ entries: budget.entries
1573
+ };
1574
+ if (sum === "budget") return unknownSample(budget);
1575
+ return {
1576
+ kind: "mark",
1577
+ cheap: token,
1578
+ bytes: sum
1579
+ };
1580
+ }
1581
+ __name(measureInstallProgress, "measureInstallProgress");
1582
+ function unknownSample(budget) {
1583
+ return {
1584
+ kind: "unknown",
1585
+ entries: budget.entries,
1586
+ elapsedMs: Date.now() - budget.startedMs
1587
+ };
1588
+ }
1589
+ __name(unknownSample, "unknownSample");
1590
+ function markToken(mark) {
1591
+ return `${mark.count}:${mark.newestMtimeMs}:${mark.size}`;
1592
+ }
1593
+ __name(markToken, "markToken");
1594
+ function withStat(mark, st) {
1595
+ return {
1596
+ newestMtimeMs: Math.max(mark.newestMtimeMs, st.mtimeMs),
1597
+ size: mark.size + st.size,
1598
+ count: mark.count + 1
1599
+ };
1600
+ }
1601
+ __name(withStat, "withStat");
1602
+ function combineMarks(left, right) {
1603
+ return {
1604
+ newestMtimeMs: Math.max(left.newestMtimeMs, right.newestMtimeMs),
1605
+ size: left.size + right.size,
1606
+ count: left.count + right.count
1607
+ };
1608
+ }
1609
+ __name(combineMarks, "combineMarks");
1610
+ function consume(budget) {
1611
+ if (budget.aborted()) return "aborted";
1612
+ const overEntries = budget.entries >= budget.entryLimit;
1613
+ const overTime = Date.now() - budget.startedMs >= PROGRESS_WALK_TIME_BUDGET_MS;
1614
+ if (overEntries || overTime) {
1615
+ budget.exceeded = true;
1616
+ return "budget";
1617
+ }
1618
+ budget.entries += 1;
1619
+ return "ok";
1620
+ }
1621
+ __name(consume, "consume");
1622
+ async function readLstat(target) {
1623
+ try {
1624
+ return await fs10.promises.lstat(target);
1625
+ } catch {
1626
+ return null;
1627
+ }
1628
+ }
1629
+ __name(readLstat, "readLstat");
1630
+ async function inodeMark(target, budget) {
1631
+ if (budget.aborted()) return "aborted";
1632
+ const st = await readLstat(target);
1633
+ if (st === null) return "miss";
1634
+ const gate = consume(budget);
1635
+ if (gate !== "ok") return gate;
1636
+ return withStat(EMPTY_MARK, st);
1637
+ }
1638
+ __name(inodeMark, "inodeMark");
1639
+ function applyMark(mark, value) {
1640
+ if (value === "miss") return mark;
1641
+ if (value === "budget" || value === "aborted") return value;
1642
+ return combineMarks(mark, value);
1643
+ }
1644
+ __name(applyMark, "applyMark");
1645
+ async function levelMark(dir, budget, levels) {
1646
+ let handle;
1647
+ try {
1648
+ handle = await fs10.promises.opendir(dir);
1649
+ } catch {
1650
+ return EMPTY_MARK;
1651
+ }
1652
+ let mark = EMPTY_MARK;
1653
+ try {
1654
+ let entry;
1655
+ while ((entry = await handle.read()) !== null) {
1656
+ const gate = consume(budget);
1657
+ if (gate !== "ok") return gate;
1658
+ if (entry.isSymbolicLink()) continue;
1659
+ const full = path10.join(dir, entry.name);
1660
+ const st = await readLstat(full);
1661
+ if (st === null) continue;
1662
+ mark = withStat(mark, st);
1663
+ if (levels <= 1 || !st.isDirectory()) continue;
1664
+ const nested = await levelMark(full, budget, levels - 1);
1665
+ if (nested === "budget" || nested === "aborted") return nested;
1666
+ mark = combineMarks(mark, nested);
1667
+ }
1668
+ } finally {
1669
+ await handle.close();
1670
+ }
1671
+ return mark;
1672
+ }
1673
+ __name(levelMark, "levelMark");
1674
+ function logDirectories(progressDirs, env) {
1675
+ const dirs = [];
1676
+ for (const key of LOG_ENV_KEYS) {
1677
+ const value = env[key];
1678
+ if (typeof value === "string" && value.length > 0) dirs.push(value);
1679
+ }
1680
+ for (const cache of progressDirs) dirs.push(path10.join(cache, "_logs"));
1681
+ return dirs;
1682
+ }
1683
+ __name(logDirectories, "logDirectories");
1684
+ async function cacheInodes(mark, cacheDir, budget) {
1685
+ const content = await inodeMark(path10.join(cacheDir, "_cacache", "content-v2"), budget);
1686
+ const withContent = applyMark(mark, content);
1687
+ if (withContent === "budget" || withContent === "aborted") return withContent;
1688
+ const index = await inodeMark(path10.join(cacheDir, "_cacache", "index-v5"), budget);
1689
+ return applyMark(withContent, index);
1690
+ }
1691
+ __name(cacheInodes, "cacheInodes");
1692
+ async function collectCheap(stagingDir, progressDirs, env, budget) {
1693
+ const root = await inodeMark(stagingDir, budget);
1694
+ const rooted = applyMark(EMPTY_MARK, root);
1695
+ if (rooted === "budget" || rooted === "aborted") return rooted;
1696
+ const modules = await levelMark(path10.join(stagingDir, "node_modules"), budget, NODE_MODULES_LEVELS);
1697
+ const withModules = applyMark(rooted, modules);
1698
+ if (withModules === "budget" || withModules === "aborted") return withModules;
1699
+ let mark = withModules;
1700
+ for (const cache of progressDirs) {
1701
+ const next = await cacheInodes(mark, cache, budget);
1702
+ if (next === "budget" || next === "aborted") return next;
1703
+ mark = next;
1704
+ }
1705
+ for (const logs of logDirectories(progressDirs, env)) {
1706
+ const listed = await levelMark(logs, budget, 1);
1707
+ const next = applyMark(mark, listed);
1708
+ if (next === "budget" || next === "aborted") return next;
1709
+ mark = next;
1710
+ }
1711
+ return mark;
1712
+ }
1713
+ __name(collectCheap, "collectCheap");
1714
+ async function sumTree(root, budget) {
1715
+ let total = 0;
1716
+ let pending = [
1717
+ root
1718
+ ];
1719
+ while (pending.length > 0) {
1720
+ const dir = pending[pending.length - 1];
1721
+ if (dir === void 0) break;
1722
+ pending = pending.slice(0, -1);
1723
+ const gate = consume(budget);
1724
+ if (gate !== "ok") return gate;
1725
+ const added = await sumDirectory(dir, budget);
1726
+ if (added === "budget" || added === "aborted") return added;
1727
+ total += added.total;
1728
+ pending = [
1729
+ ...added.nested,
1730
+ ...pending
1731
+ ];
1732
+ }
1733
+ return total;
1734
+ }
1735
+ __name(sumTree, "sumTree");
1736
+ async function sumDirectory(dir, budget) {
1737
+ let handle;
1738
+ try {
1739
+ handle = await fs10.promises.opendir(dir);
1740
+ } catch {
1741
+ const st = await readLstat(dir);
1742
+ return {
1743
+ total: st !== null && st.isFile() ? st.size : 0,
1744
+ nested: []
1745
+ };
1746
+ }
1747
+ let total = 0;
1748
+ const nested = [];
1749
+ try {
1750
+ let entry;
1751
+ while ((entry = await handle.read()) !== null) {
1752
+ const gate = consume(budget);
1753
+ if (gate !== "ok") return gate;
1754
+ if (entry.isSymbolicLink()) continue;
1755
+ const full = path10.join(dir, entry.name);
1756
+ if (entry.isDirectory()) {
1757
+ nested.push(full);
1758
+ continue;
1759
+ }
1760
+ if (!entry.isFile()) continue;
1761
+ const st = await readLstat(full);
1762
+ if (st !== null) total += st.size;
1763
+ }
1764
+ } finally {
1765
+ await handle.close();
1766
+ }
1767
+ return {
1768
+ total,
1769
+ nested
1770
+ };
1771
+ }
1772
+ __name(sumDirectory, "sumDirectory");
1773
+ var NPM_INSTALL_STALL_MS = 5 * 6e4;
1774
+ var NPM_INSTALL_CEILING_MS = 3 * 60 * 6e4;
1775
+ var NPM_INSTALL_POLL_MS = 6e4;
1776
+ var NPM_INSTALL_KILL_GRACE_MS = 5e3;
1777
+ var NPM_INSTALL_EXIT_WAIT_MS = 1e4;
1778
+ var NPM_CONFIG_CACHE_TIMEOUT_MS = 1e4;
1779
+ var OUTPUT_CAP_CHARS = 64 * 1024;
1780
+ var PIPED_STDIO = [
1781
+ "ignore",
1782
+ "pipe",
1783
+ "pipe"
1784
+ ];
1785
+ var NpmInstallError = class extends Error {
1786
+ static {
1787
+ __name(this, "NpmInstallError");
1788
+ }
1789
+ kind;
1790
+ stagingDir;
1791
+ code;
1792
+ constructor(kind, stagingDir, code, message) {
1793
+ super(message);
1794
+ this.name = "NpmInstallError";
1795
+ this.kind = kind;
1796
+ this.stagingDir = stagingDir;
1797
+ this.code = code;
1798
+ }
1799
+ };
1800
+ function configuredNpmCache(env) {
1801
+ const configured = env["npm_config_cache"] ?? env["NPM_CONFIG_CACHE"];
1802
+ if (typeof configured === "string" && configured.length > 0) return configured;
1803
+ return null;
1804
+ }
1805
+ __name(configuredNpmCache, "configuredNpmCache");
1806
+ function parseNpmCacheDir(stdout) {
1807
+ const line = stdout.trim();
1808
+ if (line.length === 0 || line === "undefined" || line === "null") return null;
1809
+ return line;
1810
+ }
1811
+ __name(parseNpmCacheDir, "parseNpmCacheDir");
1812
+ function readNpmConfigCache(env) {
1813
+ const launch = npmProcessLaunch(process.platform, process.execPath, env, [
1814
+ "config",
1815
+ "get",
1816
+ "cache"
1817
+ ]);
1818
+ return new Promise((resolve4, reject) => {
1819
+ (0, import_node_child_process.execFile)(launch.command, [
1820
+ ...launch.args
1821
+ ], {
1822
+ env,
1823
+ timeout: NPM_CONFIG_CACHE_TIMEOUT_MS,
1824
+ windowsHide: true,
1825
+ shell: launch.shell
1826
+ }, (err, stdout) => {
1827
+ if (err !== null) reject(err);
1828
+ else resolve4(stdout);
1829
+ });
1830
+ });
1831
+ }
1832
+ __name(readNpmConfigCache, "readNpmConfigCache");
1833
+ async function npmInstallProgressDirs(env, readCache = readNpmConfigCache) {
1834
+ const configured = configuredNpmCache(env);
1835
+ if (configured !== null) return [
1836
+ configured
1837
+ ];
1838
+ try {
1839
+ const dir = parseNpmCacheDir(await readCache(env));
1840
+ return dir === null ? [] : [
1841
+ dir
1842
+ ];
1843
+ } catch {
1844
+ return [];
1845
+ }
1846
+ }
1847
+ __name(npmInstallProgressDirs, "npmInstallProgressDirs");
1848
+ function resolveNpmCliJs(execPath, env) {
1849
+ const fromEnv = env["npm_execpath"];
1850
+ if (typeof fromEnv === "string" && fromEnv.length > 0 && fs11.existsSync(fromEnv)) return fromEnv;
1851
+ const nodeDir = path11.dirname(execPath);
1852
+ const candidates = [
1853
+ path11.join(nodeDir, "node_modules", "npm", "bin", "npm-cli.js"),
1854
+ path11.join(nodeDir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
1855
+ path11.join(nodeDir, "..", "node_modules", "npm", "bin", "npm-cli.js")
1856
+ ];
1857
+ for (const candidate of candidates) {
1858
+ if (fs11.existsSync(candidate)) return candidate;
1859
+ }
1860
+ return null;
1861
+ }
1862
+ __name(resolveNpmCliJs, "resolveNpmCliJs");
1863
+ function quoteCmdArg(arg) {
1864
+ if (!/[\s"&|<>^%]/.test(arg)) return arg;
1865
+ return `"${arg.replaceAll('"', '""')}"`;
1866
+ }
1867
+ __name(quoteCmdArg, "quoteCmdArg");
1868
+ function npmProcessLaunch(platform, execPath, env, npmArgs) {
1869
+ const cli = resolveNpmCliJs(execPath, env);
1870
+ if (cli !== null) return {
1871
+ command: execPath,
1872
+ args: [
1873
+ cli,
1874
+ ...npmArgs
1875
+ ],
1876
+ shell: false
1877
+ };
1878
+ if (platform === "win32") {
1879
+ return {
1880
+ command: "npm.cmd",
1881
+ args: npmArgs.map(quoteCmdArg),
1882
+ shell: true
1883
+ };
1884
+ }
1885
+ return {
1886
+ command: "npm",
1887
+ args: [
1888
+ ...npmArgs
1889
+ ],
1890
+ shell: false
1891
+ };
1892
+ }
1893
+ __name(npmProcessLaunch, "npmProcessLaunch");
1894
+ function npmCommandWatchesProgress(args, cwd) {
1895
+ return args[0] === "install" && cwd !== void 0;
1896
+ }
1897
+ __name(npmCommandWatchesProgress, "npmCommandWatchesProgress");
1898
+ function watchedCommandLabel(command, args) {
1899
+ if (command !== "npm" && command !== "npm.cmd") return "npm install";
1900
+ const sub = args[0];
1901
+ if (sub === void 0 || sub.length === 0) return "npm";
1902
+ return `npm ${sub}`;
1903
+ }
1904
+ __name(watchedCommandLabel, "watchedCommandLabel");
1905
+ function shouldWatchProgress(options) {
1906
+ if (path11.resolve(options.cwd) === path11.resolve(process.cwd())) return false;
1907
+ if (options.watchProgress === false) return false;
1908
+ if (options.watchProgress === true) return true;
1909
+ if (options.command === "npm" || options.command === "npm.cmd") {
1910
+ return options.args[0] === "install";
1911
+ }
1912
+ return true;
1913
+ }
1914
+ __name(shouldWatchProgress, "shouldWatchProgress");
1915
+ function cutMessage(label, cut, options, cwd) {
1916
+ if (cut === "timeout-stall") {
1917
+ return `${label} stalled: no progress for ${options.stallMs}ms in ${cwd}`;
1918
+ }
1919
+ if (label === "npm install") {
1920
+ return `${label} hit the hard ceiling (${options.ceilingMs}ms) in ${cwd}`;
1921
+ }
1922
+ return `${label} timed out after ${options.ceilingMs}ms in ${cwd}`;
1923
+ }
1924
+ __name(cutMessage, "cutMessage");
1925
+ function tail(text) {
1926
+ return text.length > OUTPUT_CAP_CHARS ? text.slice(text.length - OUTPUT_CAP_CHARS) : text;
1927
+ }
1928
+ __name(tail, "tail");
1929
+ function groupExists(pid) {
1930
+ try {
1931
+ process.kill(-pid, 0);
1932
+ return true;
1933
+ } catch {
1934
+ return false;
1935
+ }
1936
+ }
1937
+ __name(groupExists, "groupExists");
1938
+ function asStream(stream) {
1939
+ if (stream === null) return null;
1940
+ return {
1941
+ setEncoding(encoding) {
1942
+ stream.setEncoding(encoding);
1943
+ },
1944
+ on(_event, listener) {
1945
+ stream.on("data", (chunk) => {
1946
+ listener(typeof chunk === "string" ? chunk : chunk.toString("utf8"));
1947
+ });
1948
+ }
1949
+ };
1950
+ }
1951
+ __name(asStream, "asStream");
1952
+ function adoptChild(child) {
1953
+ return {
1954
+ pid: child.pid,
1955
+ stdout: asStream(child.stdout),
1956
+ stderr: asStream(child.stderr),
1957
+ onError(listener) {
1958
+ child.once("error", listener);
1959
+ },
1960
+ onExit(listener) {
1961
+ child.once("exit", listener);
1962
+ }
1963
+ };
1964
+ }
1965
+ __name(adoptChild, "adoptChild");
1966
+ function defaultSpawn(command, args, options) {
1967
+ const child = (0, import_node_child_process.spawn)(command, [
1968
+ ...args
1969
+ ], {
1970
+ cwd: options.cwd,
1971
+ detached: options.detached,
1972
+ windowsHide: options.windowsHide,
1973
+ stdio: options.stdio === "ignore" ? "ignore" : [
1974
+ ...PIPED_STDIO
1975
+ ],
1976
+ env: options.env,
1977
+ ...options.shell ? {
1978
+ shell: true
1979
+ } : {}
1980
+ });
1981
+ return adoptChild(child);
1982
+ }
1983
+ __name(defaultSpawn, "defaultSpawn");
1984
+ function resolveLaunch(options) {
1985
+ const env = options.env ?? process.env;
1986
+ if (options.command !== "npm" && options.command !== "npm.cmd") {
1987
+ return {
1988
+ command: options.command,
1989
+ args: [
1990
+ ...options.args
1991
+ ],
1992
+ shell: false
1993
+ };
1994
+ }
1995
+ return npmProcessLaunch(options.platform ?? process.platform, options.execPath ?? process.execPath, env, options.args);
1996
+ }
1997
+ __name(resolveLaunch, "resolveLaunch");
1998
+ async function killProcessGroup(pid, platform, graceMs, sleep, spawnProcess, env) {
1999
+ if (platform === "win32") {
2000
+ await new Promise((resolve4) => {
2001
+ const killer = spawnProcess("taskkill", [
2002
+ "/PID",
2003
+ String(pid),
2004
+ "/T",
2005
+ "/F"
2006
+ ], {
2007
+ detached: false,
2008
+ windowsHide: true,
2009
+ stdio: "ignore",
2010
+ env,
2011
+ shell: false
2012
+ });
2013
+ killer.onExit(() => resolve4());
2014
+ killer.onError(() => resolve4());
2015
+ });
2016
+ return;
2017
+ }
2018
+ try {
2019
+ process.kill(-pid, "SIGTERM");
2020
+ } catch {
2021
+ }
2022
+ try {
2023
+ process.kill(pid, "SIGTERM");
2024
+ } catch {
2025
+ }
2026
+ await sleep(graceMs);
2027
+ if (!groupExists(pid)) return;
2028
+ try {
2029
+ process.kill(-pid, "SIGKILL");
2030
+ } catch {
2031
+ }
2032
+ try {
2033
+ process.kill(pid, "SIGKILL");
2034
+ } catch {
2035
+ }
2036
+ }
2037
+ __name(killProcessGroup, "killProcessGroup");
2038
+ function attachOutput(child, note) {
2039
+ child.stdout?.setEncoding("utf8");
2040
+ child.stderr?.setEncoding("utf8");
2041
+ child.stdout?.on("data", (chunk) => note(chunk, "out"));
2042
+ child.stderr?.on("data", (chunk) => note(chunk, "err"));
2043
+ }
2044
+ __name(attachOutput, "attachOutput");
2045
+ async function runWatchedCommand(options) {
2046
+ const opened = await openWatchedChild(options);
2047
+ const cut = await pollUntilCut(options, opened.exitPromise, opened.readExit, opened.watch);
2048
+ if (cut !== null) return failCut(options, opened, cut);
2049
+ const exit = opened.readExit();
2050
+ if (exitFailed(exit)) await killOpenedGroup(options, opened);
2051
+ return finishExit(exit, options.cwd, opened.stdout(), opened.stderr(), options.log, opened.label);
2052
+ }
2053
+ __name(runWatchedCommand, "runWatchedCommand");
2054
+ function exitFailed(exit) {
2055
+ return exit !== null && (exit.error !== null || exit.code !== 0);
2056
+ }
2057
+ __name(exitFailed, "exitFailed");
2058
+ function progressReader(options, previousCheap, aborted) {
2059
+ return () => measureInstallProgress({
2060
+ stagingDir: options.cwd,
2061
+ progressDirs: options.progressDirs ?? [],
2062
+ env: options.env ?? {},
2063
+ previousCheap: previousCheap(),
2064
+ aborted,
2065
+ entryBudget: options.progressEntryBudget
2066
+ });
2067
+ }
2068
+ __name(progressReader, "progressReader");
2069
+ async function seedBaseline(watch) {
2070
+ if (!watch.enabled) return;
2071
+ const initial = await watch.measure();
2072
+ if (initial.kind === "unknown") watch.noteUnknown(initial);
2073
+ if (initial.kind === "mark") {
2074
+ watch.baseline = {
2075
+ cheap: initial.cheap,
2076
+ bytes: initial.bytes
2077
+ };
2078
+ }
2079
+ }
2080
+ __name(seedBaseline, "seedBaseline");
2081
+ function budgetLogger(options) {
2082
+ let logged = false;
2083
+ return (sample) => {
2084
+ if (logged) return;
2085
+ logged = true;
2086
+ options.log.debug?.("install progress walk hit its budget", {
2087
+ meta: {
2088
+ stagingDir: options.cwd,
2089
+ entries: sample.entries,
2090
+ elapsedMs: sample.elapsedMs
2091
+ }
2092
+ });
2093
+ };
2094
+ }
2095
+ __name(budgetLogger, "budgetLogger");
2096
+ async function prepareWatch(options, readOutput) {
2097
+ const startedAt = options.now();
2098
+ const watch = {
2099
+ enabled: shouldWatchProgress(options),
2100
+ startedAt,
2101
+ baseline: {
2102
+ cheap: null,
2103
+ bytes: null
2104
+ },
2105
+ lastOutput: 0,
2106
+ lastGrowthAt: startedAt,
2107
+ readOutput,
2108
+ measure: /* @__PURE__ */ __name(() => Promise.resolve({
2109
+ kind: "aborted",
2110
+ entries: 0
2111
+ }), "measure"),
2112
+ noteUnknown: budgetLogger(options)
2113
+ };
2114
+ watch.measure = progressReader(options, () => watch.baseline.cheap, () => false);
2115
+ await seedBaseline(watch);
2116
+ return watch;
2117
+ }
2118
+ __name(prepareWatch, "prepareWatch");
2119
+ function bindAbortableMeasure(options, watch, aborted) {
2120
+ watch.measure = progressReader(options, () => watch.baseline.cheap, aborted);
2121
+ }
2122
+ __name(bindAbortableMeasure, "bindAbortableMeasure");
2123
+ function noteChildOutput(output, chunk, sink) {
2124
+ output.bytes += chunk.length;
2125
+ if (sink === "out") output.stdout = tail(output.stdout + chunk);
2126
+ else output.stderr = tail(output.stderr + chunk);
2127
+ }
2128
+ __name(noteChildOutput, "noteChildOutput");
2129
+ function listenForExit(child) {
2130
+ let exit = null;
2131
+ const promise = new Promise((resolve4) => {
2132
+ child.onError((error) => {
2133
+ exit = {
2134
+ code: null,
2135
+ signal: null,
2136
+ error
2137
+ };
2138
+ resolve4();
2139
+ });
2140
+ child.onExit((code, signal) => {
2141
+ exit = {
2142
+ code,
2143
+ signal,
2144
+ error: null
2145
+ };
2146
+ resolve4();
2147
+ });
2148
+ });
2149
+ return {
2150
+ promise,
2151
+ read: /* @__PURE__ */ __name(() => exit, "read")
2152
+ };
2153
+ }
2154
+ __name(listenForExit, "listenForExit");
2155
+ function requirePid(child, cwd, command) {
2156
+ const pid = child.pid;
2157
+ if (pid !== void 0) return pid;
2158
+ throw new NpmInstallError("nonzero-exit", cwd, null, `failed to spawn ${command}: no pid`);
2159
+ }
2160
+ __name(requirePid, "requirePid");
2161
+ async function openWatchedChild(options) {
2162
+ const env = options.env ?? process.env;
2163
+ const platform = options.platform ?? process.platform;
2164
+ const spawnProcess = options.spawnProcess ?? defaultSpawn;
2165
+ const launch = resolveLaunch(options);
2166
+ const output = {
2167
+ bytes: 0,
2168
+ stdout: "",
2169
+ stderr: ""
2170
+ };
2171
+ const watch = await prepareWatch(options, () => output.bytes);
2172
+ const child = spawnProcess(launch.command, launch.args, {
2173
+ cwd: options.cwd,
2174
+ detached: true,
2175
+ windowsHide: true,
2176
+ stdio: PIPED_STDIO,
2177
+ env,
2178
+ shell: launch.shell
2179
+ });
2180
+ const pid = requirePid(child, options.cwd, launch.command);
2181
+ attachOutput(child, (chunk, sink) => noteChildOutput(output, chunk, sink));
2182
+ const exit = listenForExit(child);
2183
+ bindAbortableMeasure(options, watch, () => exit.read() !== null);
2184
+ return {
2185
+ pid,
2186
+ platform,
2187
+ env,
2188
+ spawnProcess,
2189
+ label: watchedCommandLabel(options.command, options.args),
2190
+ exitPromise: exit.promise,
2191
+ watch,
2192
+ readExit: exit.read,
2193
+ stdout: /* @__PURE__ */ __name(() => output.stdout, "stdout"),
2194
+ stderr: /* @__PURE__ */ __name(() => output.stderr, "stderr")
2195
+ };
2196
+ }
2197
+ __name(openWatchedChild, "openWatchedChild");
2198
+ async function killOpenedGroup(options, opened) {
2199
+ await killProcessGroup(opened.pid, opened.platform, options.graceMs, options.sleep, opened.spawnProcess, opened.env);
2200
+ }
2201
+ __name(killOpenedGroup, "killOpenedGroup");
2202
+ async function failCut(options, opened, cut) {
2203
+ await killOpenedGroup(options, opened);
2204
+ const exited = await waitForExit(opened.exitPromise, options.sleep, NPM_INSTALL_EXIT_WAIT_MS);
2205
+ const message = cutMessage(opened.label, cut, options, options.cwd);
2206
+ if (!exited) {
2207
+ options.log.error(`${opened.label} did not exit after the cut`, {
2208
+ meta: {
2209
+ stagingDir: options.cwd,
2210
+ kind: cut,
2211
+ pid: opened.pid,
2212
+ error: message
2213
+ }
2214
+ });
2215
+ }
2216
+ options.log.error(`${opened.label} cut`, {
2217
+ meta: {
2218
+ stagingDir: options.cwd,
2219
+ kind: cut,
2220
+ pid: opened.pid,
2221
+ error: message
2222
+ }
2223
+ });
2224
+ throw new NpmInstallError(cut, options.cwd, null, message);
2225
+ }
2226
+ __name(failCut, "failCut");
2227
+ function noteSample(watch, sample, output, now) {
2228
+ const first = watch.baseline.cheap === null && watch.baseline.bytes === null;
2229
+ const cheapChanged = !first && sample.cheap !== watch.baseline.cheap;
2230
+ const bytesChanged = sample.bytes !== null && watch.baseline.bytes !== null && sample.bytes !== watch.baseline.bytes;
2231
+ const changed = cheapChanged || bytesChanged || output !== watch.lastOutput;
2232
+ watch.baseline = {
2233
+ cheap: sample.cheap,
2234
+ bytes: sample.bytes === null ? watch.baseline.bytes : sample.bytes
2235
+ };
2236
+ watch.lastOutput = output;
2237
+ if (changed || first) watch.lastGrowthAt = now;
2238
+ }
2239
+ __name(noteSample, "noteSample");
2240
+ async function pollUntilCut(options, exitPromise, readExit, watch) {
2241
+ while (readExit() === null) {
2242
+ await Promise.race([
2243
+ options.sleep(options.pollMs),
2244
+ exitPromise
2245
+ ]);
2246
+ if (readExit() !== null) return null;
2247
+ const now = options.now();
2248
+ if (watch.enabled) {
2249
+ const sample = await watch.measure();
2250
+ if (readExit() !== null || sample.kind === "aborted") return null;
2251
+ if (sample.kind === "unknown") watch.noteUnknown(sample);
2252
+ else {
2253
+ noteSample(watch, sample, watch.readOutput(), now);
2254
+ if (now - watch.lastGrowthAt >= options.stallMs) return "timeout-stall";
2255
+ }
2256
+ }
2257
+ if (now - watch.startedAt >= options.ceilingMs) return "timeout-ceiling";
2258
+ }
2259
+ return null;
2260
+ }
2261
+ __name(pollUntilCut, "pollUntilCut");
2262
+ async function waitForExit(exitPromise, sleep, timeoutMs) {
2263
+ let exited = false;
2264
+ const finished = exitPromise.then(() => {
2265
+ exited = true;
2266
+ });
2267
+ await Promise.race([
2268
+ finished,
2269
+ sleep(timeoutMs)
2270
+ ]);
2271
+ return exited;
2272
+ }
2273
+ __name(waitForExit, "waitForExit");
2274
+ function finishExit(exit, cwd, stdout, stderr, log, label) {
2275
+ const finished = exit ?? {
2276
+ code: null,
2277
+ signal: null,
2278
+ error: null
2279
+ };
2280
+ const code = finished.code;
2281
+ const spawnError = finished.error;
2282
+ const detail = spawnError === null ? stderr.trim() : spawnError.message;
2283
+ log.info(`${label} exited`, {
2284
+ meta: {
2285
+ stagingDir: cwd,
2286
+ kind: "exit",
2287
+ code,
2288
+ signal: finished.signal,
2289
+ ...detail.length > 0 ? {
2290
+ error: detail
2291
+ } : {}
2292
+ }
2293
+ });
2294
+ if (finished.error !== null || code !== 0) {
2295
+ throw new NpmInstallError("nonzero-exit", cwd, code, detail.length > 0 ? detail : `${label} exited ${code ?? "null"} in ${cwd}`);
2296
+ }
2297
+ return {
2298
+ stdout
2299
+ };
2300
+ }
2301
+ __name(finishExit, "finishExit");
2302
+ function isJsonObject(value) {
2303
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2304
+ }
2305
+ __name(isJsonObject, "isJsonObject");
1363
2306
  function buildNpmRegistryArgs(registry) {
1364
2307
  if (registry === void 0 || registry.length === 0) return [];
1365
2308
  return [
@@ -1370,7 +2313,6 @@ var require_dist = __commonJS({
1370
2313
  }
1371
2314
  __name(buildNpmRegistryArgs, "buildNpmRegistryArgs");
1372
2315
  var NPM_VIEW_TIMEOUT_MS = 2e4;
1373
- var NPM_INSTALL_TIMEOUT_MS = 15 * 6e4;
1374
2316
  var STAGING_ATTEMPTS = 3;
1375
2317
  var STAGING_RETRY_DELAYS_MS = [
1376
2318
  5e3,
@@ -1381,7 +2323,19 @@ var require_dist = __commonJS({
1381
2323
  return TRANSIENT_NPM_ERROR_RE.test(message);
1382
2324
  }
1383
2325
  __name(isTransientNpmNetworkError, "isTransientNpmNetworkError");
2326
+ function isInstallTimeout(err) {
2327
+ return err instanceof NpmInstallError && (err.kind === TIMEOUT_STALL_REASON || err.kind === TIMEOUT_CEILING_REASON);
2328
+ }
2329
+ __name(isInstallTimeout, "isInstallTimeout");
2330
+ function isRetryableStagingFailure(err) {
2331
+ if (isInstallTimeout(err)) return false;
2332
+ const message = err instanceof Error ? err.message : String(err);
2333
+ return isTransientNpmNetworkError(message);
2334
+ }
2335
+ __name(isRetryableStagingFailure, "isRetryableStagingFailure");
1384
2336
  var STAGING_FAILED_REASON = "staging-failed";
2337
+ var TIMEOUT_STALL_REASON = "timeout-stall";
2338
+ var TIMEOUT_CEILING_REASON = "timeout-ceiling";
1385
2339
  var ROLLBACK_UNSUPPORTED_REASON = "rollback-unsupported";
1386
2340
  var CLOSURE_ALLOW_SCRIPTS = {
1387
2341
  "@camstack/server": true,
@@ -1397,13 +2351,13 @@ var require_dist = __commonJS({
1397
2351
  function readWrapperProbes() {
1398
2352
  let proc1Cgroup = null;
1399
2353
  try {
1400
- proc1Cgroup = fs8.readFileSync("/proc/1/cgroup", "utf-8");
2354
+ proc1Cgroup = fs12.readFileSync("/proc/1/cgroup", "utf-8");
1401
2355
  } catch {
1402
2356
  proc1Cgroup = null;
1403
2357
  }
1404
2358
  let dockerEnvFileExists = false;
1405
2359
  try {
1406
- dockerEnvFileExists = fs8.existsSync("/.dockerenv");
2360
+ dockerEnvFileExists = fs12.existsSync("/.dockerenv");
1407
2361
  } catch {
1408
2362
  dockerEnvFileExists = false;
1409
2363
  }
@@ -1416,7 +2370,7 @@ var require_dist = __commonJS({
1416
2370
  __name(readWrapperProbes, "readWrapperProbes");
1417
2371
  function readPackageVersion(pkgJsonPath) {
1418
2372
  try {
1419
- const raw = JSON.parse(fs8.readFileSync(pkgJsonPath, "utf-8"));
2373
+ const raw = JSON.parse(fs12.readFileSync(pkgJsonPath, "utf-8"));
1420
2374
  if (typeof raw === "object" && raw !== null) {
1421
2375
  const version = raw["version"];
1422
2376
  if (typeof version === "string") return version;
@@ -1441,6 +2395,8 @@ var require_dist = __commonJS({
1441
2395
  installedAddonVersionsFn;
1442
2396
  runnerBootCheckFn;
1443
2397
  execNpm;
2398
+ /** `npm config get cache`, once per service — not on each progress poll. */
2399
+ npmProgressDirsPromise = null;
1444
2400
  ensureNativePrebuildsFn;
1445
2401
  applyClosurePatchesFn;
1446
2402
  env;
@@ -1471,20 +2427,44 @@ var require_dist = __commonJS({
1471
2427
  nodeId: options.nodeId ?? "unknown"
1472
2428
  };
1473
2429
  this.restartServerFn = options.restartServer;
1474
- this.dataDir = path8.resolve(options.dataDir);
2430
+ this.dataDir = path12.resolve(options.dataDir);
1475
2431
  this.updatePreflightFn = options.updatePreflight ?? null;
1476
2432
  this.installedAddonVersionsFn = options.installedAddonVersions ?? null;
1477
2433
  this.runnerBootCheckFn = options.runnerBootCheck ?? (() => void 0);
1478
2434
  this.execNpm = options.execNpm ?? (async (args, opts) => {
1479
- const { stdout } = await execFileAsync("npm", [
1480
- ...args
1481
- ], {
1482
- cwd: opts.cwd,
1483
- timeout: opts.timeoutMs
2435
+ const watchProgress = npmCommandWatchesProgress(args, opts.cwd);
2436
+ return runWatchedCommand({
2437
+ command: "npm",
2438
+ args,
2439
+ cwd: opts.cwd ?? process.cwd(),
2440
+ stallMs: NPM_INSTALL_STALL_MS,
2441
+ ceilingMs: opts.timeoutMs,
2442
+ pollMs: NPM_INSTALL_POLL_MS,
2443
+ graceMs: NPM_INSTALL_KILL_GRACE_MS,
2444
+ now: /* @__PURE__ */ __name(() => this.now(), "now"),
2445
+ sleep: /* @__PURE__ */ __name((ms) => this.sleep(ms), "sleep"),
2446
+ env: this.env,
2447
+ watchProgress,
2448
+ progressDirs: watchProgress ? await this.installProgressDirs() : void 0,
2449
+ log: {
2450
+ debug: /* @__PURE__ */ __name((message, context) => this.logger.debug(message, {
2451
+ tags: this.logTags,
2452
+ ...context
2453
+ }), "debug"),
2454
+ info: /* @__PURE__ */ __name((message, context) => this.logger.info(message, {
2455
+ tags: this.logTags,
2456
+ ...context
2457
+ }), "info"),
2458
+ warn: /* @__PURE__ */ __name((message, context) => this.logger.warn(message, {
2459
+ tags: this.logTags,
2460
+ ...context
2461
+ }), "warn"),
2462
+ error: /* @__PURE__ */ __name((message, context) => this.logger.error(message, {
2463
+ tags: this.logTags,
2464
+ ...context
2465
+ }), "error")
2466
+ }
1484
2467
  });
1485
- return {
1486
- stdout
1487
- };
1488
2468
  });
1489
2469
  this.ensureNativePrebuildsFn = options.ensureNativePrebuilds ?? (async () => void 0);
1490
2470
  this.applyClosurePatchesFn = options.applyClosurePatches ?? (async () => void 0);
@@ -1492,8 +2472,8 @@ var require_dist = __commonJS({
1492
2472
  this.readWrapperProbesFn = options.readWrapperProbes ?? readWrapperProbes;
1493
2473
  this.now = options.now ?? Date.now;
1494
2474
  this.onDesktopInstallRequested = options.onDesktopInstallRequested;
1495
- this.sleep = options.sleep ?? ((ms) => new Promise((resolve3) => {
1496
- setTimeout(resolve3, ms);
2475
+ this.sleep = options.sleep ?? ((ms) => new Promise((resolve4) => {
2476
+ setTimeout(resolve4, ms);
1497
2477
  }));
1498
2478
  this.runningPackageJsonPath = options.runningPackageJsonPath;
1499
2479
  this.workspaceProbeDir = options.workspaceProbeDir;
@@ -1528,7 +2508,7 @@ var require_dist = __commonJS({
1528
2508
  */
1529
2509
  installedVersion() {
1530
2510
  if (this.resolveBootMode() !== "data-root") return null;
1531
- return readPackageVersion(path8.join(rootPackageDir2(currentDir(this.rootDir()), this.spec), "package.json"));
2511
+ return readPackageVersion(path12.join(rootPackageDir2(currentDir(this.rootDir()), this.spec), "package.json"));
1532
2512
  }
1533
2513
  /**
1534
2514
  * The three facts a restart question needs, read together so no surface can
@@ -1556,7 +2536,7 @@ var require_dist = __commonJS({
1556
2536
  seedVersion() {
1557
2537
  const seedDir = this.env[this.envNames.seedDir];
1558
2538
  if (seedDir === void 0 || seedDir.length === 0) return null;
1559
- return readPackageVersion(path8.join(seedDir, "package.json"));
2539
+ return readPackageVersion(path12.join(seedDir, "package.json"));
1560
2540
  }
1561
2541
  /**
1562
2542
  * What this node runs INSIDE. Observed where it can be (the container
@@ -1822,7 +2802,7 @@ var require_dist = __commonJS({
1822
2802
  }
1823
2803
  if (isDevChannelVersion(target)) {
1824
2804
  const uploadsDir = devUploadVersionDir(this.rootDir(), target);
1825
- if (!fs8.existsSync(uploadsDir)) {
2805
+ if (!fs12.existsSync(uploadsDir)) {
1826
2806
  return this.refuseUpdate("dev-uploads-missing", target, `Refused: dev-channel version ${target} has no uploaded tarballs on this node (${uploadsDir} is missing). On the hub: \`camstack deploy-server\`. On an agent: \`camstack deploy-server -n <nodeId>\` (or \`--all\`) so the hub can POST /api/server-upload/propagate first.`);
1827
2807
  }
1828
2808
  }
@@ -1855,13 +2835,14 @@ var require_dist = __commonJS({
1855
2835
  stagingPath = await this.stageClosureWithRetry(target);
1856
2836
  } catch (err) {
1857
2837
  const message = err instanceof Error ? err.message : String(err);
2838
+ const timedOut = isInstallTimeout(err);
1858
2839
  return {
1859
2840
  accepted: false,
1860
2841
  targetVersion: target,
1861
2842
  restarting: false,
1862
2843
  message: `Staging failed: ${message}`,
1863
2844
  outcome: "failed",
1864
- reason: STAGING_FAILED_REASON,
2845
+ reason: timedOut ? err.kind : STAGING_FAILED_REASON,
1865
2846
  error: message
1866
2847
  };
1867
2848
  } finally {
@@ -1870,7 +2851,7 @@ var require_dist = __commonJS({
1870
2851
  const requires = readClosureRequires(stagingPath, this.spec);
1871
2852
  const unmet = unmetWrapperRequirements(requires, runningWrapperOf(this.wrapperIdentity()));
1872
2853
  if (unmet.length > 0) {
1873
- fs8.rmSync(stagingPath, {
2854
+ fs12.rmSync(stagingPath, {
1874
2855
  recursive: true,
1875
2856
  force: true
1876
2857
  });
@@ -1933,7 +2914,7 @@ var require_dist = __commonJS({
1933
2914
  } catch (err) {
1934
2915
  lastError = err;
1935
2916
  const message = err instanceof Error ? err.message : String(err);
1936
- const transient = isTransientNpmNetworkError(message);
2917
+ const transient = isRetryableStagingFailure(err);
1937
2918
  const delayMs = STAGING_RETRY_DELAYS_MS[attempt - 1];
1938
2919
  const willRetry = transient && attempt < STAGING_ATTEMPTS && delayMs !== void 0;
1939
2920
  if (!willRetry) {
@@ -1970,14 +2951,82 @@ var require_dist = __commonJS({
1970
2951
  * path for the pending-root-swap marker; the STARTER swaps it into `current`
1971
2952
  * on the next boot. Throws (cleaning up the staging dir) on any failure so
1972
2953
  * `applyServerUpdate` reports a staging error and never arms a bad swap.
2954
+ *
2955
+ * A registry install is seeded from the running `current/` copy so npm only
2956
+ * replaces packages whose version changed. The dev-upload channel is not
2957
+ * seeded: those tarballs are pinned by version string, and a copied
2958
+ * `node_modules` would let npm skip a tarball whose bytes changed under the
2959
+ * same version. A seeded attempt that fails install or validation
2960
+ * (`validation-failed`, including a slow or failed `npm ls`) is retried
2961
+ * once from an empty directory. A stall or the hard ceiling of the install
2962
+ * itself is not retried — the empty install would wait on the same download.
1973
2963
  */
1974
2964
  async stageClosure(target) {
2965
+ const devDir = devUploadVersionDir(this.rootDir(), target);
2966
+ const seed = !fs12.existsSync(devDir) && this.currentIsSeedable();
2967
+ if (!seed) {
2968
+ const stagingDir = await this.installClosure(target, "clean");
2969
+ this.logClosureSource(target, stagingDir, "clean");
2970
+ return stagingDir;
2971
+ }
2972
+ try {
2973
+ const stagingDir = await this.installClosure(target, "seeded");
2974
+ this.logClosureSource(target, stagingDir, "seeded");
2975
+ return stagingDir;
2976
+ } catch (err) {
2977
+ if (isInstallTimeout(err)) throw err;
2978
+ const message = err instanceof Error ? err.message : String(err);
2979
+ this.logger.warn("seeded closure staging failed \u2014 retrying from an empty directory", {
2980
+ tags: this.logTags,
2981
+ meta: {
2982
+ targetVersion: target,
2983
+ error: message
2984
+ }
2985
+ });
2986
+ const stagingDir = await this.installClosure(target, "clean");
2987
+ this.logClosureSource(target, stagingDir, "clean");
2988
+ return stagingDir;
2989
+ }
2990
+ }
2991
+ /** npm's cache directory, resolved once. Empty means progress ignores the cache. */
2992
+ installProgressDirs() {
2993
+ this.npmProgressDirsPromise ??= npmInstallProgressDirs(this.env).then((dirs) => {
2994
+ if (dirs.length === 0) {
2995
+ this.logger.warn("npm cache directory unknown \u2014 install progress ignores the cache", {
2996
+ tags: this.logTags
2997
+ });
2998
+ }
2999
+ return dirs;
3000
+ });
3001
+ return this.npmProgressDirsPromise;
3002
+ }
3003
+ /** The running closure has the files a seed copy needs. */
3004
+ currentIsSeedable() {
3005
+ const current = currentDir(this.rootDir());
3006
+ return fs12.existsSync(path12.join(current, "package.json")) && fs12.existsSync(path12.join(current, "node_modules"));
3007
+ }
3008
+ logClosureSource(target, stagingDir, source) {
3009
+ this.logger.info("root package closure produced", {
3010
+ tags: this.logTags,
3011
+ meta: {
3012
+ targetVersion: target,
3013
+ stagingDir,
3014
+ source
3015
+ }
3016
+ });
3017
+ }
3018
+ /**
3019
+ * One install attempt. `seeded` copies `current/` in first; `clean` is an
3020
+ * empty directory. The dev-upload branch ignores `source` — it always
3021
+ * writes its own manifest.
3022
+ */
3023
+ async installClosure(target, source) {
1975
3024
  const rootDir = this.rootDir();
1976
- fs8.mkdirSync(rootDir, {
3025
+ fs12.mkdirSync(rootDir, {
1977
3026
  recursive: true
1978
3027
  });
1979
3028
  const stagingDir = stagingDirPath(rootDir, target, process.pid, this.now());
1980
- fs8.mkdirSync(stagingDir, {
3029
+ fs12.mkdirSync(stagingDir, {
1981
3030
  recursive: true
1982
3031
  });
1983
3032
  try {
@@ -1990,17 +3039,29 @@ var require_dist = __commonJS({
1990
3039
  "--no-fund",
1991
3040
  "--loglevel=error"
1992
3041
  ];
1993
- if (fs8.existsSync(devDir)) {
1994
- fs8.writeFileSync(path8.join(stagingDir, "package.json"), JSON.stringify(this.buildDevUploadsPackageJson(devDir, target), null, 2), "utf-8");
3042
+ if (fs12.existsSync(devDir)) {
3043
+ fs12.writeFileSync(path12.join(stagingDir, "package.json"), JSON.stringify(this.buildDevUploadsPackageJson(devDir, target), null, 2), "utf-8");
1995
3044
  await this.execNpm([
1996
3045
  ...installArgs,
1997
3046
  ...buildNpmRegistryArgs(registry)
1998
3047
  ], {
1999
3048
  cwd: stagingDir,
2000
- timeoutMs: NPM_INSTALL_TIMEOUT_MS
3049
+ timeoutMs: NPM_INSTALL_CEILING_MS
2001
3050
  });
3051
+ } else if (source === "seeded") {
3052
+ await seedStagingFromCurrent(currentDir(rootDir), stagingDir);
3053
+ this.stampClosureManifest(stagingDir);
3054
+ await this.execNpm([
3055
+ ...installArgs,
3056
+ `${this.spec.packageName}@${target}`,
3057
+ ...buildNpmRegistryArgs(registry)
3058
+ ], {
3059
+ cwd: stagingDir,
3060
+ timeoutMs: NPM_INSTALL_CEILING_MS
3061
+ });
3062
+ await assertInstalledClosureTree(stagingDir, this.spec.packageName, target, this.execNpm);
2002
3063
  } else {
2003
- fs8.writeFileSync(path8.join(stagingDir, "package.json"), JSON.stringify({
3064
+ fs12.writeFileSync(path12.join(stagingDir, "package.json"), JSON.stringify({
2004
3065
  name: "camstack-node-root",
2005
3066
  private: true,
2006
3067
  allowScripts: CLOSURE_ALLOW_SCRIPTS
@@ -2011,11 +3072,11 @@ var require_dist = __commonJS({
2011
3072
  ...buildNpmRegistryArgs(registry)
2012
3073
  ], {
2013
3074
  cwd: stagingDir,
2014
- timeoutMs: NPM_INSTALL_TIMEOUT_MS
3075
+ timeoutMs: NPM_INSTALL_CEILING_MS
2015
3076
  });
2016
3077
  }
2017
3078
  const entry = rootEntryPath2(stagingDir, this.spec);
2018
- if (!fs8.existsSync(entry)) {
3079
+ if (!fs12.existsSync(entry)) {
2019
3080
  throw new Error(`staged closure is missing the root entry (${entry})`);
2020
3081
  }
2021
3082
  const nodeMajor = Number.parseInt(process.versions.node.split(".")[0] ?? "0", 10);
@@ -2051,7 +3112,7 @@ var require_dist = __commonJS({
2051
3112
  }
2052
3113
  return stagingDir;
2053
3114
  } catch (err) {
2054
- await fs8.promises.rm(stagingDir, {
3115
+ await fs12.promises.rm(stagingDir, {
2055
3116
  recursive: true,
2056
3117
  force: true
2057
3118
  }).catch(() => void 0);
@@ -2059,6 +3120,25 @@ var require_dist = __commonJS({
2059
3120
  }
2060
3121
  }
2061
3122
  /**
3123
+ * Keep the seeded manifest and force the install-script allow-list. npm 12
3124
+ * will not run a dependency's lifecycle without it; the seed's own list may
3125
+ * be older than this starter.
3126
+ */
3127
+ stampClosureManifest(stagingDir) {
3128
+ const manifestPath = path12.join(stagingDir, "package.json");
3129
+ const raw = JSON.parse(fs12.readFileSync(manifestPath, "utf-8"));
3130
+ if (!isJsonObject(raw)) {
3131
+ throw new Error(`seeded package.json at ${manifestPath} is not an object`);
3132
+ }
3133
+ const next = {
3134
+ ...raw,
3135
+ name: "camstack-node-root",
3136
+ private: true,
3137
+ allowScripts: CLOSURE_ALLOW_SCRIPTS
3138
+ };
3139
+ fs12.writeFileSync(manifestPath, JSON.stringify(next, null, 2), "utf-8");
3140
+ }
3141
+ /**
2062
3142
  * Synthetic staging package.json for the dev server-deploy channel:
2063
3143
  * `dependencies` carries the root package as a `file:` ref to its uploaded
2064
3144
  * tgz; `overrides` maps EVERY OTHER uploaded `@camstack/<name>` to its tgz.
@@ -2078,8 +3158,8 @@ var require_dist = __commonJS({
2078
3158
  throw new Error(`dev-uploads for ${target} do not include the root package ${this.spec.packageName}`);
2079
3159
  }
2080
3160
  const fileRef = /* @__PURE__ */ __name((filename) => {
2081
- const abs = path8.join(devDir, filename);
2082
- if (!fs8.existsSync(abs)) {
3161
+ const abs = path12.join(devDir, filename);
3162
+ if (!fs12.existsSync(abs)) {
2083
3163
  throw new Error(`dev-uploads tarball listed in the manifest is missing: ${abs}`);
2084
3164
  }
2085
3165
  return `file:${abs}`;
@@ -2250,15 +3330,15 @@ var require_dist = __commonJS({
2250
3330
  const dir = devUploadsDir(this.rootDir());
2251
3331
  let entries;
2252
3332
  try {
2253
- entries = fs8.readdirSync(dir);
3333
+ entries = fs12.readdirSync(dir);
2254
3334
  } catch {
2255
3335
  return;
2256
3336
  }
2257
- const graveyard = path8.join(dir, ".sweeping");
3337
+ const graveyard = path12.join(dir, ".sweeping");
2258
3338
  try {
2259
- for (const residue of fs8.readdirSync(graveyard)) {
3339
+ for (const residue of fs12.readdirSync(graveyard)) {
2260
3340
  try {
2261
- fs8.rmSync(path8.join(graveyard, residue), {
3341
+ fs12.rmSync(path12.join(graveyard, residue), {
2262
3342
  recursive: true,
2263
3343
  force: true
2264
3344
  });
@@ -2273,13 +3353,13 @@ var require_dist = __commonJS({
2273
3353
  ].sort((a, b) => (devChannelEpoch(b) ?? -1) - (devChannelEpoch(a) ?? -1));
2274
3354
  const doomed = byNewestFirst.slice(keepCount);
2275
3355
  if (doomed.length === 0) return;
2276
- fs8.mkdirSync(graveyard, {
3356
+ fs12.mkdirSync(graveyard, {
2277
3357
  recursive: true
2278
3358
  });
2279
3359
  for (const entry of doomed) {
2280
- const aside = path8.join(graveyard, `${entry}-${this.now()}`);
3360
+ const aside = path12.join(graveyard, `${entry}-${this.now()}`);
2281
3361
  try {
2282
- fs8.renameSync(path8.join(dir, entry), aside);
3362
+ fs12.renameSync(path12.join(dir, entry), aside);
2283
3363
  } catch (err) {
2284
3364
  this.logger.warn("failed to move dev-uploads entry aside for sweep", {
2285
3365
  meta: {
@@ -2290,7 +3370,7 @@ var require_dist = __commonJS({
2290
3370
  continue;
2291
3371
  }
2292
3372
  try {
2293
- fs8.rmSync(aside, {
3373
+ fs12.rmSync(aside, {
2294
3374
  recursive: true,
2295
3375
  force: true
2296
3376
  });