@camstack/server 1.2.943 → 1.2.945

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 (170) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/closure-pins.json +350 -0
  3. package/dist/api/core/auth-sessions.procedures.js +18 -0
  4. package/dist/api/core/auth.router.js +19 -6
  5. package/dist/api/server-upload.js +17 -1
  6. package/dist/api/trpc/generated-cap-mounts.js +18 -1
  7. package/dist/api/trpc/generated-cap-routers.js +2662 -2542
  8. package/dist/auth/native-return.js +9 -3
  9. package/dist/auth/sso-routes.js +5 -1
  10. package/dist/core/addon/instance-lifecycle.js +4 -1
  11. package/dist/core/auth/handoff-code.service.js +35 -1
  12. package/dist/server-root/index.js +313 -70
  13. package/package.json +15 -11
  14. package/system/assets/apps-aggregator/icon.svg +5 -0
  15. package/system/dist/{action-index-B_cLRwXJ.js → action-index-Bcnb-jyg.js} +9 -1
  16. package/system/dist/{action-index-B1fgpQBt.mjs → action-index-DwPHO2nz.mjs} +9 -1
  17. package/system/dist/{addon-settings.cap-CZ4MC7ha.mjs → addon-settings.cap-CHpmuaQG.mjs} +1 -1
  18. package/system/dist/{addon-settings.cap-DrLdMFIe.js → addon-settings.cap-nZVHPo3X.js} +1 -1
  19. package/system/dist/{alert-episode-Be--PngO.mjs → alert-episode-D-1VUUkZ.mjs} +1 -1
  20. package/system/dist/{alert-episode-Bqktmt-i.js → alert-episode-DaQ3prSe.js} +1 -1
  21. package/system/dist/apps.cap-Bqb9NpYx.mjs +130 -0
  22. package/system/dist/apps.cap-CLjgnuUe.js +141 -0
  23. package/system/dist/{base-addon-CRsXtYFG.js → base-addon-BG7p06Hb.js} +136 -15
  24. package/system/dist/{base-addon-BcS6r1cT.mjs → base-addon-BcVoYZbC.mjs} +136 -15
  25. package/system/dist/{base-device-DAdWzDOl.js → base-device-DeSNiwZ4.js} +4 -4
  26. package/system/dist/{base-device-DJXF5eDN.mjs → base-device-w_MD0Bf4.mjs} +4 -4
  27. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  28. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  29. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  30. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  31. package/system/dist/builtins/alerts/alerts.addon.js +3 -3
  32. package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
  33. package/system/dist/builtins/apps-aggregator/aggregate-apps.d.ts +24 -0
  34. package/system/dist/builtins/apps-aggregator/apps-aggregator.addon.d.ts +16 -0
  35. package/system/dist/builtins/apps-aggregator/apps-aggregator.addon.js +109 -0
  36. package/system/dist/builtins/apps-aggregator/apps-aggregator.addon.mjs +103 -0
  37. package/system/dist/builtins/apps-aggregator/index.d.ts +1 -0
  38. package/system/dist/builtins/apps-aggregator/index.js +8 -0
  39. package/system/dist/builtins/apps-aggregator/index.mjs +2 -0
  40. package/system/dist/builtins/autotrack/index.js +1 -1
  41. package/system/dist/builtins/autotrack/index.mjs +1 -1
  42. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  43. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  44. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  45. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  46. package/system/dist/builtins/camera-grid/index.js +3 -3
  47. package/system/dist/builtins/camera-grid/index.mjs +3 -3
  48. package/system/dist/builtins/composer/composer.addon.js +7 -7
  49. package/system/dist/builtins/composer/composer.addon.mjs +7 -7
  50. package/system/dist/builtins/console-logging/index.js +1 -1
  51. package/system/dist/builtins/console-logging/index.mjs +1 -1
  52. package/system/dist/builtins/core-blocks/actions-store.d.ts +2 -0
  53. package/system/dist/builtins/core-blocks/block-supervisor.d.ts +16 -4
  54. package/system/dist/builtins/core-blocks/core-block-store.d.ts +2 -0
  55. package/system/dist/builtins/core-blocks/core-blocks.addon.js +1018 -323
  56. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +986 -291
  57. package/system/dist/builtins/core-blocks/migrations/index.d.ts +5 -2
  58. package/system/dist/builtins/core-blocks/migrations/tag-ids.d.ts +42 -0
  59. package/system/dist/builtins/core-blocks/migrations/tags-as-records.d.ts +47 -0
  60. package/system/dist/builtins/core-blocks/record-kinds.d.ts +12 -1
  61. package/system/dist/builtins/core-blocks/runs-api.d.ts +3 -1
  62. package/system/dist/builtins/core-blocks/runs-ledger.d.ts +3 -1
  63. package/system/dist/builtins/core-blocks/scheduler/scheduler-store.d.ts +2 -0
  64. package/system/dist/builtins/core-blocks/tags-service.d.ts +52 -27
  65. package/system/dist/builtins/core-blocks/tags-wiring.d.ts +2 -0
  66. package/system/dist/builtins/core-notifier/core-notifier.addon.js +76 -67
  67. package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +76 -67
  68. package/system/dist/builtins/device-history/device-history.addon.js +4 -4
  69. package/system/dist/builtins/device-history/device-history.addon.mjs +4 -4
  70. package/system/dist/builtins/device-manager/device-manager.addon.js +1618 -755
  71. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1604 -741
  72. package/system/dist/builtins/device-manager/device-meta-actions.d.ts +13 -136
  73. package/system/dist/builtins/device-manager/device-meta-types.d.ts +5 -1
  74. package/system/dist/builtins/device-manager/device-provider-context.d.ts +9 -0
  75. package/system/dist/builtins/device-manager/device-row-store.d.ts +21 -4
  76. package/system/dist/builtins/device-manager/device-search.d.ts +6 -0
  77. package/system/dist/builtins/device-manager/location-alignment.d.ts +9 -2
  78. package/system/dist/builtins/device-manager/migrate-device.d.ts +7 -2
  79. package/system/dist/builtins/device-manager/migrate-hardware-state.d.ts +132 -1
  80. package/system/dist/builtins/device-manager/migrations/device-tag-ids.d.ts +25 -0
  81. package/system/dist/builtins/device-manager/migrations/index.d.ts +16 -0
  82. package/system/dist/builtins/device-manager/migrations/orphan-children.d.ts +33 -0
  83. package/system/dist/builtins/device-manager/migrations/ports.d.ts +17 -0
  84. package/system/dist/builtins/device-manager/migrations/rooms-as-records.d.ts +52 -0
  85. package/system/dist/builtins/device-manager/record-kinds.d.ts +3 -1
  86. package/system/dist/builtins/device-manager/removal-cleanup.d.ts +7 -0
  87. package/system/dist/builtins/device-manager/room-actions.d.ts +27 -0
  88. package/system/dist/builtins/device-manager/room-store.d.ts +19 -0
  89. package/system/dist/builtins/device-manager/tag-names.d.ts +32 -0
  90. package/system/dist/builtins/device-manager/wireable-enum-catalog.d.ts +18 -0
  91. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  92. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  93. package/system/dist/builtins/keychain/index.js +3 -3
  94. package/system/dist/builtins/keychain/index.mjs +3 -3
  95. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  96. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  97. package/system/dist/builtins/local-auth/local-auth.addon.js +1 -1
  98. package/system/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  99. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  100. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  101. package/system/dist/builtins/loki-logging/index.js +2 -2
  102. package/system/dist/builtins/loki-logging/index.mjs +2 -2
  103. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  104. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  105. package/system/dist/builtins/platform-probe/index.js +1 -1
  106. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  107. package/system/dist/builtins/record-entries/index.js +1 -1
  108. package/system/dist/builtins/record-entries/index.mjs +1 -1
  109. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  110. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  111. package/system/dist/builtins/snapshot/index.js +1 -1
  112. package/system/dist/builtins/snapshot/index.mjs +1 -1
  113. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  114. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  115. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  116. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  117. package/system/dist/builtins/sqlite-storage/migrations/migration-engine.d.ts +3 -1
  118. package/system/dist/builtins/sqlite-storage/migrations/migrations-provider.d.ts +1 -0
  119. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +15 -10
  120. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +15 -10
  121. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  122. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  123. package/system/dist/builtins/system-config/system-config.addon.js +2 -2
  124. package/system/dist/builtins/system-config/system-config.addon.mjs +2 -2
  125. package/system/dist/builtins/winston-logging/index.js +2 -2
  126. package/system/dist/builtins/winston-logging/index.mjs +2 -2
  127. package/system/dist/{command-catalog-C29hVOOg.js → command-catalog-A_ONlLfF.js} +1 -1
  128. package/system/dist/{command-catalog-xAeqxbZk.mjs → command-catalog-CZDlLhxO.mjs} +1 -1
  129. package/system/dist/{composition-sources-Do5qM6EB.js → composition-sources-D1nPv7dJ.js} +1 -1
  130. package/system/dist/{composition-sources-C327LGFn.mjs → composition-sources-DubMf_ii.mjs} +1 -1
  131. package/system/dist/{core-blocks.cap-CdTGUKtr.js → core-blocks.cap-DEYCvF9J.js} +125 -373
  132. package/system/dist/{core-blocks.cap-DLkEfV5b.mjs → core-blocks.cap-sW5HLDlB.mjs} +109 -327
  133. package/system/dist/{device-manager.cap-DJs8izI6.js → device-manager.cap-B9qVf7ag.js} +163 -22
  134. package/system/dist/{device-manager.cap-eYrj1Ezp.mjs → device-manager.cap-CV4KGp3e.mjs} +134 -17
  135. package/system/dist/{error.cap-CU1FB6uE.mjs → error.cap-B8l7L8e4.mjs} +7 -1
  136. package/system/dist/{error.cap-BuKbL3Ac.js → error.cap-BqlvgBJd.js} +7 -1
  137. package/system/dist/file-host-worker.js +1 -1
  138. package/system/dist/file-host-worker.mjs +1 -1
  139. package/system/dist/index.js +8 -8
  140. package/system/dist/index.mjs +7 -7
  141. package/system/dist/{legacy-integration-rows-door-CdqYAj-o.js → legacy-integration-rows-door-BK8eoGlF.js} +1 -1
  142. package/system/dist/{legacy-integration-rows-door-LSgpClpX.mjs → legacy-integration-rows-door-CwzC5XNk.mjs} +1 -1
  143. package/system/dist/{migration-DGAc6ywR.mjs → migration-BvbfW9g-.mjs} +6 -0
  144. package/system/dist/{migration-BOQlFZCN.js → migration-CHPdAdNh.js} +6 -0
  145. package/system/dist/{prefix-walk-Mtij0NNT.mjs → named-entity-store-Cq2oVrN5.mjs} +195 -89
  146. package/system/dist/{prefix-walk-BFnw8NBu.js → named-entity-store-O_hi1y_o.js} +244 -90
  147. package/system/dist/{notification-rules.cap-BUIuYPlQ.mjs → notification-rules.cap-ClvK6QT1.mjs} +10 -5
  148. package/system/dist/{notification-rules.cap-BJKUjizS.js → notification-rules.cap-uSLoe2pA.js} +10 -5
  149. package/system/dist/{notification-targets-DMW7xgR2.js → notification-targets-ChqpBbtR.js} +2 -2
  150. package/system/dist/{notification-targets-4bGYH5J7.mjs → notification-targets-DUA6-F2t.mjs} +2 -2
  151. package/system/dist/{device-row-store-CTocYKqC.mjs → record-kinds-BD2xv4Pd.mjs} +222 -93
  152. package/system/dist/{device-row-store-C0P2H18h.js → record-kinds-BV8Gcpsx.js} +246 -93
  153. package/system/dist/records/named-entity-store.d.ts +60 -0
  154. package/system/dist/{rename-composition-block-D9Uc1AF7.js → rename-composition-block-C60O0P16.js} +137 -33
  155. package/system/dist/{rename-composition-block-Cdh-dRmY.mjs → rename-composition-block-DcX3vkwS.mjs} +137 -33
  156. package/system/dist/{retention-source.cap-C6Hy0hlM.js → retention-source.cap-A-TMhU5O.js} +1 -1
  157. package/system/dist/{retention-source.cap-550kkyp5.mjs → retention-source.cap-Ct07pM30.mjs} +1 -1
  158. package/system/dist/{storage-admin.cap-Ci4QbL6P.mjs → storage-admin.cap-C54s9_B9.mjs} +8 -2
  159. package/system/dist/{storage-admin.cap-DqW1ol4j.js → storage-admin.cap-DSPHi7ut.js} +8 -2
  160. package/system/dist/{stream-catalog.cap-CjEQFknc.js → stream-catalog.cap-7WPsugOy.js} +1 -1
  161. package/system/dist/{stream-catalog.cap-DVniDdRD.mjs → stream-catalog.cap-CzwRDaqT.mjs} +1 -1
  162. package/system/dist/{tag-BxLazvVb.js → tag-BLraBqvp.js} +12 -0
  163. package/system/dist/{tag-uZBAq6ox.mjs → tag-DU8pm9Bi.mjs} +7 -1
  164. package/system/dist/time-window-B6UhCArd.js +679 -0
  165. package/system/dist/time-window-BnUBULgu.mjs +578 -0
  166. package/system/dist/{wal-maintenance-BgYiAy5b.js → wal-maintenance-CkPfVApC.js} +0 -0
  167. package/system/dist/{wal-maintenance-Bey5ChBb.mjs → wal-maintenance-u84_1sVl.mjs} +0 -0
  168. package/system/package.json +16 -1
  169. /package/system/dist/{constants-Ba3FTIHl.js → constants-Ba3FTIHl2.js} +0 -0
  170. /package/system/dist/{constants-DB4piTD5.mjs → constants-DB4piTD52.mjs} +0 -0
@@ -80,6 +80,7 @@ var require_dist = __commonJS({
80
80
  DESKTOP_INSTALL_REQUEST_MAX_AGE_MS: /* @__PURE__ */ __name(() => DESKTOP_INSTALL_REQUEST_MAX_AGE_MS, "DESKTOP_INSTALL_REQUEST_MAX_AGE_MS"),
81
81
  DEV_UPLOADS_DIRNAME: /* @__PURE__ */ __name(() => DEV_UPLOADS_DIRNAME, "DEV_UPLOADS_DIRNAME"),
82
82
  DEV_UPLOADS_KEEP_COUNT: /* @__PURE__ */ __name(() => DEV_UPLOADS_KEEP_COUNT, "DEV_UPLOADS_KEEP_COUNT"),
83
+ DEV_UPLOAD_BEFORE_MARGIN_MS: /* @__PURE__ */ __name(() => DEV_UPLOAD_BEFORE_MARGIN_MS, "DEV_UPLOAD_BEFORE_MARGIN_MS"),
83
84
  DEV_UPLOAD_MANIFEST_FILE: /* @__PURE__ */ __name(() => DEV_UPLOAD_MANIFEST_FILE, "DEV_UPLOAD_MANIFEST_FILE"),
84
85
  ELECTRON_APP_VERSION_ENV: /* @__PURE__ */ __name(() => ELECTRON_APP_VERSION_ENV, "ELECTRON_APP_VERSION_ENV"),
85
86
  HOST_EXTERNAL_SPECIFIERS: /* @__PURE__ */ __name(() => HOST_EXTERNAL_SPECIFIERS, "HOST_EXTERNAL_SPECIFIERS"),
@@ -117,6 +118,7 @@ var require_dist = __commonJS({
117
118
  detectWorkspaceRoot: /* @__PURE__ */ __name(() => detectWorkspaceRoot, "detectWorkspaceRoot"),
118
119
  detectWrapperIdentity: /* @__PURE__ */ __name(() => detectWrapperIdentity, "detectWrapperIdentity"),
119
120
  devChannelEpoch: /* @__PURE__ */ __name(() => devChannelEpoch, "devChannelEpoch"),
121
+ devUploadBeforeArg: /* @__PURE__ */ __name(() => devUploadBeforeArg, "devUploadBeforeArg"),
120
122
  devUploadManifestPath: /* @__PURE__ */ __name(() => devUploadManifestPath, "devUploadManifestPath"),
121
123
  devUploadVersionDir: /* @__PURE__ */ __name(() => devUploadVersionDir, "devUploadVersionDir"),
122
124
  devUploadsDir: /* @__PURE__ */ __name(() => devUploadsDir, "devUploadsDir"),
@@ -205,7 +207,9 @@ var require_dist = __commonJS({
205
207
  if (typeof m["version"] !== "string") return false;
206
208
  const packages = m["packages"];
207
209
  if (typeof packages !== "object" || packages === null || Array.isArray(packages)) return false;
208
- return Object.values(packages).every((filename) => typeof filename === "string");
210
+ if (!Object.values(packages).every((filename) => typeof filename === "string")) return false;
211
+ const buildTimeMs = m["buildTimeMs"];
212
+ return buildTimeMs === void 0 || typeof buildTimeMs === "number" && Number.isFinite(buildTimeMs);
209
213
  }
210
214
  __name(isDevUploadManifest, "isDevUploadManifest");
211
215
  function readDevUploadManifest(versionDirPath) {
@@ -227,6 +231,12 @@ var require_dist = __commonJS({
227
231
  fs.renameSync(tmp, target);
228
232
  }
229
233
  __name(writeDevUploadManifest, "writeDevUploadManifest");
234
+ var DEV_UPLOAD_BEFORE_MARGIN_MS = 5 * 6e4;
235
+ function devUploadBeforeArg(manifest) {
236
+ if (manifest.buildTimeMs === void 0) return null;
237
+ return `--before=${new Date(manifest.buildTimeMs + DEV_UPLOAD_BEFORE_MARGIN_MS).toISOString()}`;
238
+ }
239
+ __name(devUploadBeforeArg, "devUploadBeforeArg");
230
240
  var HUB_ROOT_SPEC2 = {
231
241
  packageName: "@camstack/server",
232
242
  entryRelPath: [
@@ -1255,8 +1265,8 @@ var require_dist = __commonJS({
1255
1265
  }
1256
1266
  __name(runNodeStarter, "runNodeStarter");
1257
1267
  var import_node_crypto = require("crypto");
1258
- var fs12 = __toESM2(require("fs"));
1259
- var path12 = __toESM2(require("path"));
1268
+ var fs13 = __toESM2(require("fs"));
1269
+ var path13 = __toESM2(require("path"));
1260
1270
  var fs7 = __toESM2(require("fs"));
1261
1271
  var path7 = __toESM2(require("path"));
1262
1272
  var MINIMUM_RE = /^>=(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
@@ -1374,31 +1384,154 @@ var require_dist = __commonJS({
1374
1384
  }
1375
1385
  __name(describeUnmetRequirement, "describeUnmetRequirement");
1376
1386
  var fs8 = __toESM2(require("fs"));
1387
+ var os = __toESM2(require("os"));
1377
1388
  var path8 = __toESM2(require("path"));
1389
+ var zlib = __toESM2(require("zlib"));
1390
+ var CLOSURE_PINS_FILE = "closure-pins.json";
1391
+ var TAR_BLOCK = 512;
1392
+ var PACK_TIMEOUT_MS = 12e4;
1393
+ function readTarballEntry(tgz, entryPath) {
1394
+ const tar = zlib.gunzipSync(tgz);
1395
+ let offset = 0;
1396
+ while (offset + TAR_BLOCK <= tar.length) {
1397
+ const header = tar.subarray(offset, offset + TAR_BLOCK);
1398
+ if (header.every((byte) => byte === 0)) return null;
1399
+ const nameEnd = header.indexOf(0);
1400
+ const name = header.toString("utf8", 0, nameEnd === -1 || nameEnd > 100 ? 100 : nameEnd);
1401
+ const size = Number.parseInt(header.toString("ascii", 124, 135).trim(), 8);
1402
+ if (!Number.isFinite(size)) return null;
1403
+ const start = offset + TAR_BLOCK;
1404
+ if (name === entryPath) return tar.subarray(start, start + size);
1405
+ offset = start + Math.ceil(size / TAR_BLOCK) * TAR_BLOCK;
1406
+ }
1407
+ return null;
1408
+ }
1409
+ __name(readTarballEntry, "readTarballEntry");
1410
+ function isRejectedPinsMiss(miss) {
1411
+ return miss === "unparseable" || miss === "non-exact-version" || miss === "empty";
1412
+ }
1413
+ __name(isRejectedPinsMiss, "isRejectedPinsMiss");
1414
+ function parseClosurePins(raw) {
1415
+ let parsed;
1416
+ try {
1417
+ parsed = JSON.parse(raw);
1418
+ } catch {
1419
+ return {
1420
+ pins: null,
1421
+ miss: "unparseable"
1422
+ };
1423
+ }
1424
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
1425
+ return {
1426
+ pins: null,
1427
+ miss: "unparseable"
1428
+ };
1429
+ }
1430
+ const pins = {};
1431
+ for (const [name, version] of Object.entries(parsed)) {
1432
+ if (typeof version !== "string" || !/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]+)?$/.test(version)) {
1433
+ return {
1434
+ pins: null,
1435
+ miss: "non-exact-version"
1436
+ };
1437
+ }
1438
+ if (name.startsWith("@camstack/")) continue;
1439
+ pins[name] = version;
1440
+ }
1441
+ return Object.keys(pins).length === 0 ? {
1442
+ pins: null,
1443
+ miss: "empty"
1444
+ } : {
1445
+ pins,
1446
+ miss: null
1447
+ };
1448
+ }
1449
+ __name(parseClosurePins, "parseClosurePins");
1450
+ function readClosurePinsFromTarball(tgz) {
1451
+ let entry;
1452
+ try {
1453
+ entry = readTarballEntry(tgz, `package/${CLOSURE_PINS_FILE}`);
1454
+ } catch {
1455
+ return {
1456
+ pins: null,
1457
+ miss: "no-tarball"
1458
+ };
1459
+ }
1460
+ if (entry === null) return {
1461
+ pins: null,
1462
+ miss: "entry-missing"
1463
+ };
1464
+ return parseClosurePins(entry.toString("utf8"));
1465
+ }
1466
+ __name(readClosurePinsFromTarball, "readClosurePinsFromTarball");
1467
+ async function fetchClosurePins(execNpm, packageName, target, registryArgs, cwd) {
1468
+ const dir = fs8.mkdtempSync(path8.join(os.tmpdir(), "camstack-pins-"));
1469
+ try {
1470
+ await execNpm([
1471
+ "pack",
1472
+ `${packageName}@${target}`,
1473
+ "--pack-destination",
1474
+ dir,
1475
+ "--ignore-scripts",
1476
+ "--no-audit",
1477
+ "--no-fund",
1478
+ "--loglevel=error",
1479
+ ...registryArgs
1480
+ ], {
1481
+ cwd,
1482
+ timeoutMs: PACK_TIMEOUT_MS
1483
+ });
1484
+ const tgz = fs8.readdirSync(dir).find((f) => f.endsWith(".tgz"));
1485
+ if (tgz === void 0) return {
1486
+ pins: null,
1487
+ miss: "no-tarball"
1488
+ };
1489
+ return readClosurePinsFromTarball(fs8.readFileSync(path8.join(dir, tgz)));
1490
+ } finally {
1491
+ fs8.rmSync(dir, {
1492
+ recursive: true,
1493
+ force: true
1494
+ });
1495
+ }
1496
+ }
1497
+ __name(fetchClosurePins, "fetchClosurePins");
1498
+ function withClosureOverrides(manifest, pins) {
1499
+ const next = {
1500
+ ...manifest
1501
+ };
1502
+ delete next["overrides"];
1503
+ return pins === null ? next : {
1504
+ ...next,
1505
+ overrides: pins
1506
+ };
1507
+ }
1508
+ __name(withClosureOverrides, "withClosureOverrides");
1509
+ var fs9 = __toESM2(require("fs"));
1510
+ var path9 = __toESM2(require("path"));
1378
1511
  var LOCKFILES = [
1379
1512
  "package-lock.json",
1380
1513
  "npm-shrinkwrap.json"
1381
1514
  ];
1382
1515
  async function seedStagingFromCurrent(currentDir2, stagingDir) {
1383
- const packageJson = path8.join(currentDir2, "package.json");
1384
- const nodeModules = path8.join(currentDir2, "node_modules");
1385
- if (!fs8.existsSync(packageJson) || !fs8.existsSync(nodeModules)) {
1516
+ const packageJson = path9.join(currentDir2, "package.json");
1517
+ const nodeModules = path9.join(currentDir2, "node_modules");
1518
+ if (!fs9.existsSync(packageJson) || !fs9.existsSync(nodeModules)) {
1386
1519
  throw new Error(`current closure at ${currentDir2} has no package.json or node_modules to seed from`);
1387
1520
  }
1388
- await fs8.promises.cp(packageJson, path8.join(stagingDir, "package.json"));
1521
+ await fs9.promises.cp(packageJson, path9.join(stagingDir, "package.json"));
1389
1522
  for (const name of LOCKFILES) {
1390
- const source = path8.join(currentDir2, name);
1391
- if (!fs8.existsSync(source)) continue;
1392
- await fs8.promises.cp(source, path8.join(stagingDir, name));
1523
+ const source = path9.join(currentDir2, name);
1524
+ if (!fs9.existsSync(source)) continue;
1525
+ await fs9.promises.cp(source, path9.join(stagingDir, name));
1393
1526
  }
1394
- await fs8.promises.cp(nodeModules, path8.join(stagingDir, "node_modules"), {
1527
+ await fs9.promises.cp(nodeModules, path9.join(stagingDir, "node_modules"), {
1395
1528
  recursive: true,
1396
1529
  verbatimSymlinks: true
1397
1530
  });
1398
1531
  }
1399
1532
  __name(seedStagingFromCurrent, "seedStagingFromCurrent");
1400
- var fs9 = __toESM2(require("fs"));
1401
- var path9 = __toESM2(require("path"));
1533
+ var fs10 = __toESM2(require("fs"));
1534
+ var path10 = __toESM2(require("path"));
1402
1535
  var NPM_LS_TIMEOUT_MS = 6e4;
1403
1536
  var VALIDATION_FAILED_KIND = "validation-failed";
1404
1537
  var ClosureValidationError = class extends Error {
@@ -1444,8 +1577,8 @@ var require_dist = __commonJS({
1444
1577
  "npm-shrinkwrap.json",
1445
1578
  "package-lock.json"
1446
1579
  ]) {
1447
- const full = path9.join(stagingDir, name);
1448
- if (fs9.existsSync(full)) return full;
1580
+ const full = path10.join(stagingDir, name);
1581
+ if (fs10.existsSync(full)) return full;
1449
1582
  }
1450
1583
  return null;
1451
1584
  }
@@ -1455,7 +1588,7 @@ var require_dist = __commonJS({
1455
1588
  if (file === null) return null;
1456
1589
  let raw;
1457
1590
  try {
1458
- raw = JSON.parse(fs9.readFileSync(file, "utf8"));
1591
+ raw = JSON.parse(fs10.readFileSync(file, "utf8"));
1459
1592
  } catch {
1460
1593
  return null;
1461
1594
  }
@@ -1470,7 +1603,7 @@ var require_dist = __commonJS({
1470
1603
  __name(readLockPackages, "readLockPackages");
1471
1604
  function readInstalledVersion(pkgJsonPath) {
1472
1605
  try {
1473
- const raw = JSON.parse(fs9.readFileSync(pkgJsonPath, "utf8"));
1606
+ const raw = JSON.parse(fs10.readFileSync(pkgJsonPath, "utf8"));
1474
1607
  if (!isRecord2(raw)) return null;
1475
1608
  const version = raw["version"];
1476
1609
  return typeof version === "string" ? version : null;
@@ -1489,7 +1622,7 @@ var require_dist = __commonJS({
1489
1622
  if (locked !== target) {
1490
1623
  return `lockfile ${lockedKey} version is ${locked ?? "absent"}, target is ${target}`;
1491
1624
  }
1492
- const installed = readInstalledVersion(path9.join(stagingDir, "node_modules", ...packageName.split("/"), "package.json"));
1625
+ const installed = readInstalledVersion(path10.join(stagingDir, "node_modules", ...packageName.split("/"), "package.json"));
1493
1626
  if (installed !== target) {
1494
1627
  return `installed ${packageName} version is ${installed ?? "absent"}, target is ${target}`;
1495
1628
  }
@@ -1499,8 +1632,8 @@ var require_dist = __commonJS({
1499
1632
  function staleLockedPackage(stagingDir, packages) {
1500
1633
  for (const [key, entry] of Object.entries(packages)) {
1501
1634
  if (key.length === 0 || entry.version === null) continue;
1502
- const pkgJson = path9.join(stagingDir, key, "package.json");
1503
- if (!fs9.existsSync(pkgJson)) continue;
1635
+ const pkgJson = path10.join(stagingDir, key, "package.json");
1636
+ if (!fs10.existsSync(pkgJson)) continue;
1504
1637
  const installed = readInstalledVersion(pkgJson);
1505
1638
  if (installed !== entry.version) {
1506
1639
  return `stale ${key}: installed ${installed ?? "unreadable"}, lockfile ${entry.version}`;
@@ -1538,10 +1671,10 @@ var require_dist = __commonJS({
1538
1671
  }
1539
1672
  __name(assertInstalledClosureTree, "assertInstalledClosureTree");
1540
1673
  var import_node_child_process = require("child_process");
1674
+ var fs12 = __toESM2(require("fs"));
1675
+ var path12 = __toESM2(require("path"));
1541
1676
  var fs11 = __toESM2(require("fs"));
1542
1677
  var path11 = __toESM2(require("path"));
1543
- var fs10 = __toESM2(require("fs"));
1544
- var path10 = __toESM2(require("path"));
1545
1678
  var PROGRESS_WALK_ENTRY_BUDGET = 2e4;
1546
1679
  var PROGRESS_WALK_TIME_BUDGET_MS = 2e3;
1547
1680
  var NODE_MODULES_LEVELS = 2;
@@ -1634,7 +1767,7 @@ var require_dist = __commonJS({
1634
1767
  __name(consume, "consume");
1635
1768
  async function readLstat(target) {
1636
1769
  try {
1637
- return await fs10.promises.lstat(target);
1770
+ return await fs11.promises.lstat(target);
1638
1771
  } catch {
1639
1772
  return null;
1640
1773
  }
@@ -1658,7 +1791,7 @@ var require_dist = __commonJS({
1658
1791
  async function levelMark(dir, budget, levels) {
1659
1792
  let handle;
1660
1793
  try {
1661
- handle = await fs10.promises.opendir(dir);
1794
+ handle = await fs11.promises.opendir(dir);
1662
1795
  } catch {
1663
1796
  return EMPTY_MARK;
1664
1797
  }
@@ -1669,7 +1802,7 @@ var require_dist = __commonJS({
1669
1802
  const gate = consume(budget);
1670
1803
  if (gate !== "ok") return gate;
1671
1804
  if (entry.isSymbolicLink()) continue;
1672
- const full = path10.join(dir, entry.name);
1805
+ const full = path11.join(dir, entry.name);
1673
1806
  const st = await readLstat(full);
1674
1807
  if (st === null) continue;
1675
1808
  mark = withStat(mark, st);
@@ -1690,15 +1823,15 @@ var require_dist = __commonJS({
1690
1823
  const value = env[key];
1691
1824
  if (typeof value === "string" && value.length > 0) dirs.push(value);
1692
1825
  }
1693
- for (const cache of progressDirs) dirs.push(path10.join(cache, "_logs"));
1826
+ for (const cache of progressDirs) dirs.push(path11.join(cache, "_logs"));
1694
1827
  return dirs;
1695
1828
  }
1696
1829
  __name(logDirectories, "logDirectories");
1697
1830
  async function cacheInodes(mark, cacheDir, budget) {
1698
- const content = await inodeMark(path10.join(cacheDir, "_cacache", "content-v2"), budget);
1831
+ const content = await inodeMark(path11.join(cacheDir, "_cacache", "content-v2"), budget);
1699
1832
  const withContent = applyMark(mark, content);
1700
1833
  if (withContent === "budget" || withContent === "aborted") return withContent;
1701
- const index = await inodeMark(path10.join(cacheDir, "_cacache", "index-v5"), budget);
1834
+ const index = await inodeMark(path11.join(cacheDir, "_cacache", "index-v5"), budget);
1702
1835
  return applyMark(withContent, index);
1703
1836
  }
1704
1837
  __name(cacheInodes, "cacheInodes");
@@ -1706,7 +1839,7 @@ var require_dist = __commonJS({
1706
1839
  const root = await inodeMark(stagingDir, budget);
1707
1840
  const rooted = applyMark(EMPTY_MARK, root);
1708
1841
  if (rooted === "budget" || rooted === "aborted") return rooted;
1709
- const modules = await levelMark(path10.join(stagingDir, "node_modules"), budget, NODE_MODULES_LEVELS);
1842
+ const modules = await levelMark(path11.join(stagingDir, "node_modules"), budget, NODE_MODULES_LEVELS);
1710
1843
  const withModules = applyMark(rooted, modules);
1711
1844
  if (withModules === "budget" || withModules === "aborted") return withModules;
1712
1845
  let mark = withModules;
@@ -1749,7 +1882,7 @@ var require_dist = __commonJS({
1749
1882
  async function sumDirectory(dir, budget) {
1750
1883
  let handle;
1751
1884
  try {
1752
- handle = await fs10.promises.opendir(dir);
1885
+ handle = await fs11.promises.opendir(dir);
1753
1886
  } catch {
1754
1887
  const st = await readLstat(dir);
1755
1888
  return {
@@ -1765,7 +1898,7 @@ var require_dist = __commonJS({
1765
1898
  const gate = consume(budget);
1766
1899
  if (gate !== "ok") return gate;
1767
1900
  if (entry.isSymbolicLink()) continue;
1768
- const full = path10.join(dir, entry.name);
1901
+ const full = path11.join(dir, entry.name);
1769
1902
  if (entry.isDirectory()) {
1770
1903
  nested.push(full);
1771
1904
  continue;
@@ -1860,15 +1993,15 @@ var require_dist = __commonJS({
1860
1993
  __name(npmInstallProgressDirs, "npmInstallProgressDirs");
1861
1994
  function resolveNpmCliJs(execPath, env) {
1862
1995
  const fromEnv = env["npm_execpath"];
1863
- if (typeof fromEnv === "string" && fromEnv.length > 0 && fs11.existsSync(fromEnv)) return fromEnv;
1864
- const nodeDir = path11.dirname(execPath);
1996
+ if (typeof fromEnv === "string" && fromEnv.length > 0 && fs12.existsSync(fromEnv)) return fromEnv;
1997
+ const nodeDir = path12.dirname(execPath);
1865
1998
  const candidates = [
1866
- path11.join(nodeDir, "node_modules", "npm", "bin", "npm-cli.js"),
1867
- path11.join(nodeDir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
1868
- path11.join(nodeDir, "..", "node_modules", "npm", "bin", "npm-cli.js")
1999
+ path12.join(nodeDir, "node_modules", "npm", "bin", "npm-cli.js"),
2000
+ path12.join(nodeDir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
2001
+ path12.join(nodeDir, "..", "node_modules", "npm", "bin", "npm-cli.js")
1869
2002
  ];
1870
2003
  for (const candidate of candidates) {
1871
- if (fs11.existsSync(candidate)) return candidate;
2004
+ if (fs12.existsSync(candidate)) return candidate;
1872
2005
  }
1873
2006
  return null;
1874
2007
  }
@@ -1916,7 +2049,7 @@ var require_dist = __commonJS({
1916
2049
  }
1917
2050
  __name(watchedCommandLabel, "watchedCommandLabel");
1918
2051
  function shouldWatchProgress(options) {
1919
- if (path11.resolve(options.cwd) === path11.resolve(process.cwd())) return false;
2052
+ if (path12.resolve(options.cwd) === path12.resolve(process.cwd())) return false;
1920
2053
  if (options.watchProgress === false) return false;
1921
2054
  if (options.watchProgress === true) return true;
1922
2055
  if (options.command === "npm" || options.command === "npm.cmd") {
@@ -2408,13 +2541,13 @@ var require_dist = __commonJS({
2408
2541
  function readWrapperProbes() {
2409
2542
  let proc1Cgroup = null;
2410
2543
  try {
2411
- proc1Cgroup = fs12.readFileSync("/proc/1/cgroup", "utf-8");
2544
+ proc1Cgroup = fs13.readFileSync("/proc/1/cgroup", "utf-8");
2412
2545
  } catch {
2413
2546
  proc1Cgroup = null;
2414
2547
  }
2415
2548
  let dockerEnvFileExists = false;
2416
2549
  try {
2417
- dockerEnvFileExists = fs12.existsSync("/.dockerenv");
2550
+ dockerEnvFileExists = fs13.existsSync("/.dockerenv");
2418
2551
  } catch {
2419
2552
  dockerEnvFileExists = false;
2420
2553
  }
@@ -2427,7 +2560,7 @@ var require_dist = __commonJS({
2427
2560
  __name(readWrapperProbes, "readWrapperProbes");
2428
2561
  function readPackageVersion(pkgJsonPath) {
2429
2562
  try {
2430
- const raw = JSON.parse(fs12.readFileSync(pkgJsonPath, "utf-8"));
2563
+ const raw = JSON.parse(fs13.readFileSync(pkgJsonPath, "utf-8"));
2431
2564
  if (typeof raw === "object" && raw !== null) {
2432
2565
  const version = raw["version"];
2433
2566
  if (typeof version === "string") return version;
@@ -2484,7 +2617,7 @@ var require_dist = __commonJS({
2484
2617
  nodeId: options.nodeId ?? "unknown"
2485
2618
  };
2486
2619
  this.restartServerFn = options.restartServer;
2487
- this.dataDir = path12.resolve(options.dataDir);
2620
+ this.dataDir = path13.resolve(options.dataDir);
2488
2621
  this.updatePreflightFn = options.updatePreflight ?? null;
2489
2622
  this.installedAddonVersionsFn = options.installedAddonVersions ?? null;
2490
2623
  this.runnerBootCheckFn = options.runnerBootCheck ?? (() => void 0);
@@ -2565,7 +2698,7 @@ var require_dist = __commonJS({
2565
2698
  */
2566
2699
  installedVersion() {
2567
2700
  if (this.resolveBootMode() !== "data-root") return null;
2568
- return readPackageVersion(path12.join(rootPackageDir2(currentDir(this.rootDir()), this.spec), "package.json"));
2701
+ return readPackageVersion(path13.join(rootPackageDir2(currentDir(this.rootDir()), this.spec), "package.json"));
2569
2702
  }
2570
2703
  /**
2571
2704
  * The three facts a restart question needs, read together so no surface can
@@ -2593,7 +2726,7 @@ var require_dist = __commonJS({
2593
2726
  seedVersion() {
2594
2727
  const seedDir = this.env[this.envNames.seedDir];
2595
2728
  if (seedDir === void 0 || seedDir.length === 0) return null;
2596
- return readPackageVersion(path12.join(seedDir, "package.json"));
2729
+ return readPackageVersion(path13.join(seedDir, "package.json"));
2597
2730
  }
2598
2731
  /**
2599
2732
  * What this node runs INSIDE. Observed where it can be (the container
@@ -2859,7 +2992,7 @@ var require_dist = __commonJS({
2859
2992
  }
2860
2993
  if (isDevChannelVersion(target)) {
2861
2994
  const uploadsDir = devUploadVersionDir(this.rootDir(), target);
2862
- if (!fs12.existsSync(uploadsDir)) {
2995
+ if (!fs13.existsSync(uploadsDir)) {
2863
2996
  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.`);
2864
2997
  }
2865
2998
  }
@@ -2908,7 +3041,7 @@ var require_dist = __commonJS({
2908
3041
  const requires = readClosureRequires(stagingPath, this.spec);
2909
3042
  const unmet = unmetWrapperRequirements(requires, runningWrapperOf(this.wrapperIdentity()));
2910
3043
  if (unmet.length > 0) {
2911
- fs12.rmSync(stagingPath, {
3044
+ fs13.rmSync(stagingPath, {
2912
3045
  recursive: true,
2913
3046
  force: true
2914
3047
  });
@@ -3020,7 +3153,7 @@ var require_dist = __commonJS({
3020
3153
  */
3021
3154
  async stageClosure(target) {
3022
3155
  const devDir = devUploadVersionDir(this.rootDir(), target);
3023
- const seed = !fs12.existsSync(devDir) && this.currentIsSeedable();
3156
+ const seed = !fs13.existsSync(devDir) && this.currentIsSeedable();
3024
3157
  if (!seed) {
3025
3158
  const stagingDir = await this.installClosure(target, "clean");
3026
3159
  this.logClosureSource(target, stagingDir, "clean");
@@ -3060,7 +3193,7 @@ var require_dist = __commonJS({
3060
3193
  /** The running closure has the files a seed copy needs. */
3061
3194
  currentIsSeedable() {
3062
3195
  const current = currentDir(this.rootDir());
3063
- return fs12.existsSync(path12.join(current, "package.json")) && fs12.existsSync(path12.join(current, "node_modules"));
3196
+ return fs13.existsSync(path13.join(current, "package.json")) && fs13.existsSync(path13.join(current, "node_modules"));
3064
3197
  }
3065
3198
  logClosureSource(target, stagingDir, source) {
3066
3199
  this.logger.info("root package closure produced", {
@@ -3073,17 +3206,45 @@ var require_dist = __commonJS({
3073
3206
  });
3074
3207
  }
3075
3208
  /**
3209
+ * `--before=<build time + margin>` for a dev-uploads install, so a package
3210
+ * published after the closure was built cannot enter it (#681). Logged on the
3211
+ * staging line; a manifest without a build time (older CLI) is unbounded.
3212
+ */
3213
+ devUploadsBeforeArg(devDir, target) {
3214
+ const manifest = readDevUploadManifest(devDir);
3215
+ const arg = manifest === null ? null : devUploadBeforeArg(manifest);
3216
+ if (arg === null) {
3217
+ this.logger.warn("dev-uploads install is unbounded: the manifest carries no build time", {
3218
+ tags: this.logTags,
3219
+ meta: {
3220
+ targetVersion: target
3221
+ }
3222
+ });
3223
+ return [];
3224
+ }
3225
+ this.logger.info("dev-uploads install bounded by the closure build time", {
3226
+ tags: this.logTags,
3227
+ meta: {
3228
+ targetVersion: target,
3229
+ npmBefore: arg
3230
+ }
3231
+ });
3232
+ return [
3233
+ arg
3234
+ ];
3235
+ }
3236
+ /**
3076
3237
  * One install attempt. `seeded` copies `current/` in first; `clean` is an
3077
3238
  * empty directory. The dev-upload branch ignores `source` — it always
3078
3239
  * writes its own manifest.
3079
3240
  */
3080
3241
  async installClosure(target, source) {
3081
3242
  const rootDir = this.rootDir();
3082
- fs12.mkdirSync(rootDir, {
3243
+ fs13.mkdirSync(rootDir, {
3083
3244
  recursive: true
3084
3245
  });
3085
3246
  const stagingDir = stagingDirPath(rootDir, target, process.pid, this.now());
3086
- fs12.mkdirSync(stagingDir, {
3247
+ fs13.mkdirSync(stagingDir, {
3087
3248
  recursive: true
3088
3249
  });
3089
3250
  try {
@@ -3097,10 +3258,13 @@ var require_dist = __commonJS({
3097
3258
  "--no-fund",
3098
3259
  "--loglevel=error"
3099
3260
  ];
3100
- if (fs12.existsSync(devDir)) {
3101
- fs12.writeFileSync(path12.join(stagingDir, "package.json"), JSON.stringify(this.buildDevUploadsPackageJson(devDir, target), null, 2), "utf-8");
3261
+ if (fs13.existsSync(devDir)) {
3262
+ const devPins = this.devUploadPins(devDir, target);
3263
+ fs13.writeFileSync(path13.join(stagingDir, "package.json"), JSON.stringify(this.buildDevUploadsPackageJson(devDir, target, devPins.pins), null, 2), "utf-8");
3264
+ const before = devPins.pins === null ? this.devUploadsBeforeArg(devDir, target) : [];
3102
3265
  await this.execNpm([
3103
3266
  ...installArgs,
3267
+ ...before,
3104
3268
  ...buildNpmRegistryArgs(registry)
3105
3269
  ], {
3106
3270
  cwd: stagingDir,
@@ -3109,6 +3273,7 @@ var require_dist = __commonJS({
3109
3273
  } else if (source === "seeded") {
3110
3274
  await seedStagingFromCurrent(currentDir(rootDir), stagingDir);
3111
3275
  this.stampClosureManifest(stagingDir);
3276
+ await this.pinClosure(stagingDir, target, registry);
3112
3277
  await this.execNpm([
3113
3278
  ...installArgs,
3114
3279
  `${this.spec.packageName}@${target}`,
@@ -3119,11 +3284,12 @@ var require_dist = __commonJS({
3119
3284
  });
3120
3285
  await assertInstalledClosureTree(stagingDir, this.spec.packageName, target, this.execNpm);
3121
3286
  } else {
3122
- fs12.writeFileSync(path12.join(stagingDir, "package.json"), JSON.stringify({
3287
+ fs13.writeFileSync(path13.join(stagingDir, "package.json"), JSON.stringify({
3123
3288
  name: "camstack-node-root",
3124
3289
  private: true,
3125
3290
  allowScripts: CLOSURE_ALLOW_SCRIPTS
3126
3291
  }, null, 2), "utf-8");
3292
+ await this.pinClosure(stagingDir, target, registry);
3127
3293
  await this.execNpm([
3128
3294
  ...installArgs,
3129
3295
  `${this.spec.packageName}@${target}`,
@@ -3134,7 +3300,7 @@ var require_dist = __commonJS({
3134
3300
  });
3135
3301
  }
3136
3302
  const entry = rootEntryPath2(stagingDir, this.spec);
3137
- if (!fs12.existsSync(entry)) {
3303
+ if (!fs13.existsSync(entry)) {
3138
3304
  throw new Error(`staged closure is missing the root entry (${entry})`);
3139
3305
  }
3140
3306
  const nodeMajor = Number.parseInt(process.versions.node.split(".")[0] ?? "0", 10);
@@ -3170,7 +3336,7 @@ var require_dist = __commonJS({
3170
3336
  }
3171
3337
  return stagingDir;
3172
3338
  } catch (err) {
3173
- await fs12.promises.rm(stagingDir, {
3339
+ await fs13.promises.rm(stagingDir, {
3174
3340
  recursive: true,
3175
3341
  force: true
3176
3342
  }).catch(() => void 0);
@@ -3178,13 +3344,88 @@ var require_dist = __commonJS({
3178
3344
  }
3179
3345
  }
3180
3346
  /**
3347
+ * Registry installs only: write the target's `closure-pins.json` as the
3348
+ * staging manifest's `overrides`, so every third-party package installs at
3349
+ * the version the release was tested with (#681). A target that ships none
3350
+ * (an older server), or a pack that fails, installs unpinned as before —
3351
+ * and says so. The dev-uploads branch does not call this.
3352
+ */
3353
+ async pinClosure(stagingDir, target, registry) {
3354
+ const manifestPath = path13.join(stagingDir, "package.json");
3355
+ const raw = JSON.parse(fs13.readFileSync(manifestPath, "utf-8"));
3356
+ if (!isJsonObject(raw)) return;
3357
+ let read;
3358
+ try {
3359
+ read = await fetchClosurePins(this.execNpm, this.spec.packageName, target, buildNpmRegistryArgs(registry), stagingDir);
3360
+ } catch (error) {
3361
+ this.logger.warn("closure pins could not be read: installing unpinned", {
3362
+ tags: this.logTags,
3363
+ meta: {
3364
+ targetVersion: target,
3365
+ reason: "pack-failed",
3366
+ error: error instanceof Error ? error.message : String(error)
3367
+ }
3368
+ });
3369
+ read = {
3370
+ pins: null,
3371
+ miss: "no-tarball"
3372
+ };
3373
+ }
3374
+ this.logPinsRead(read, target);
3375
+ fs13.writeFileSync(manifestPath, JSON.stringify(withClosureOverrides(raw, read.pins), null, 2), "utf-8");
3376
+ }
3377
+ logPinsRead(read, target) {
3378
+ if (read.pins !== null) {
3379
+ this.logger.info("closure install pinned", {
3380
+ tags: this.logTags,
3381
+ meta: {
3382
+ targetVersion: target,
3383
+ pins: Object.keys(read.pins).length
3384
+ }
3385
+ });
3386
+ return;
3387
+ }
3388
+ const context = {
3389
+ tags: this.logTags,
3390
+ meta: {
3391
+ targetVersion: target,
3392
+ reason: read.miss
3393
+ }
3394
+ };
3395
+ if (isRejectedPinsMiss(read.miss)) {
3396
+ this.logger.warn("closure install unpinned: pins file rejected", context);
3397
+ } else {
3398
+ this.logger.info("closure install unpinned", context);
3399
+ }
3400
+ }
3401
+ /** The pins inside the uploaded server tarball; a tarball that cannot be read ships none. */
3402
+ devUploadPins(devDir, target) {
3403
+ const manifest = readDevUploadManifest(devDir);
3404
+ const rootTgz = manifest?.packages[this.spec.packageName];
3405
+ if (rootTgz === void 0) return {
3406
+ pins: null,
3407
+ miss: "no-tarball"
3408
+ };
3409
+ let read;
3410
+ try {
3411
+ read = readClosurePinsFromTarball(fs13.readFileSync(path13.join(devDir, rootTgz)));
3412
+ } catch {
3413
+ read = {
3414
+ pins: null,
3415
+ miss: "no-tarball"
3416
+ };
3417
+ }
3418
+ this.logPinsRead(read, target);
3419
+ return read;
3420
+ }
3421
+ /**
3181
3422
  * Keep the seeded manifest and force the install-script allow-list. npm 12
3182
3423
  * will not run a dependency's lifecycle without it; the seed's own list may
3183
3424
  * be older than this starter.
3184
3425
  */
3185
3426
  stampClosureManifest(stagingDir) {
3186
- const manifestPath = path12.join(stagingDir, "package.json");
3187
- const raw = JSON.parse(fs12.readFileSync(manifestPath, "utf-8"));
3427
+ const manifestPath = path13.join(stagingDir, "package.json");
3428
+ const raw = JSON.parse(fs13.readFileSync(manifestPath, "utf-8"));
3188
3429
  if (!isJsonObject(raw)) {
3189
3430
  throw new Error(`seeded package.json at ${manifestPath} is not an object`);
3190
3431
  }
@@ -3194,7 +3435,7 @@ var require_dist = __commonJS({
3194
3435
  private: true,
3195
3436
  allowScripts: CLOSURE_ALLOW_SCRIPTS
3196
3437
  };
3197
- fs12.writeFileSync(manifestPath, JSON.stringify(next, null, 2), "utf-8");
3438
+ fs13.writeFileSync(manifestPath, JSON.stringify(next, null, 2), "utf-8");
3198
3439
  }
3199
3440
  /**
3200
3441
  * Synthetic staging package.json for the dev server-deploy channel:
@@ -3203,7 +3444,7 @@ var require_dist = __commonJS({
3203
3444
  * Fail-closed: a missing/invalid manifest, a manifest for a different
3204
3445
  * version, a missing root package, or a listed-but-absent tgz all throw.
3205
3446
  */
3206
- buildDevUploadsPackageJson(devDir, target) {
3447
+ buildDevUploadsPackageJson(devDir, target, pins) {
3207
3448
  const manifest = readDevUploadManifest(devDir);
3208
3449
  if (manifest === null) {
3209
3450
  throw new Error(`dev-uploads manifest missing or invalid in ${devDir}`);
@@ -3216,13 +3457,15 @@ var require_dist = __commonJS({
3216
3457
  throw new Error(`dev-uploads for ${target} do not include the root package ${this.spec.packageName}`);
3217
3458
  }
3218
3459
  const fileRef = /* @__PURE__ */ __name((filename) => {
3219
- const abs = path12.join(devDir, filename);
3220
- if (!fs12.existsSync(abs)) {
3460
+ const abs = path13.join(devDir, filename);
3461
+ if (!fs13.existsSync(abs)) {
3221
3462
  throw new Error(`dev-uploads tarball listed in the manifest is missing: ${abs}`);
3222
3463
  }
3223
3464
  return `file:${abs}`;
3224
3465
  }, "fileRef");
3225
- const overrides = {};
3466
+ const overrides = {
3467
+ ...pins
3468
+ };
3226
3469
  for (const [pkgName, filename] of Object.entries(manifest.packages)) {
3227
3470
  if (pkgName === this.spec.packageName) continue;
3228
3471
  overrides[pkgName] = fileRef(filename);
@@ -3388,15 +3631,15 @@ var require_dist = __commonJS({
3388
3631
  const dir = devUploadsDir(this.rootDir());
3389
3632
  let entries;
3390
3633
  try {
3391
- entries = fs12.readdirSync(dir);
3634
+ entries = fs13.readdirSync(dir);
3392
3635
  } catch {
3393
3636
  return;
3394
3637
  }
3395
- const graveyard = path12.join(dir, ".sweeping");
3638
+ const graveyard = path13.join(dir, ".sweeping");
3396
3639
  try {
3397
- for (const residue of fs12.readdirSync(graveyard)) {
3640
+ for (const residue of fs13.readdirSync(graveyard)) {
3398
3641
  try {
3399
- fs12.rmSync(path12.join(graveyard, residue), {
3642
+ fs13.rmSync(path13.join(graveyard, residue), {
3400
3643
  recursive: true,
3401
3644
  force: true
3402
3645
  });
@@ -3411,13 +3654,13 @@ var require_dist = __commonJS({
3411
3654
  ].sort((a, b) => (devChannelEpoch(b) ?? -1) - (devChannelEpoch(a) ?? -1));
3412
3655
  const doomed = byNewestFirst.slice(keepCount);
3413
3656
  if (doomed.length === 0) return;
3414
- fs12.mkdirSync(graveyard, {
3657
+ fs13.mkdirSync(graveyard, {
3415
3658
  recursive: true
3416
3659
  });
3417
3660
  for (const entry of doomed) {
3418
- const aside = path12.join(graveyard, `${entry}-${this.now()}`);
3661
+ const aside = path13.join(graveyard, `${entry}-${this.now()}`);
3419
3662
  try {
3420
- fs12.renameSync(path12.join(dir, entry), aside);
3663
+ fs13.renameSync(path13.join(dir, entry), aside);
3421
3664
  } catch (err) {
3422
3665
  this.logger.warn("failed to move dev-uploads entry aside for sweep", {
3423
3666
  meta: {
@@ -3428,7 +3671,7 @@ var require_dist = __commonJS({
3428
3671
  continue;
3429
3672
  }
3430
3673
  try {
3431
- fs12.rmSync(aside, {
3674
+ fs13.rmSync(aside, {
3432
3675
  recursive: true,
3433
3676
  force: true
3434
3677
  });