@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
@@ -461,7 +461,9 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
461
461
  * only way to keep the broker dialable. Camera providers (Reolink
462
462
  * Baichuan native, …) subscribe and respond by re-running their publish
463
463
  * pipeline.
464
- * Payload: `{ deviceId, camStreamId, brokerId }`.
464
+ * Payload: `{ deviceId, camStreamId, brokerId, reason? }`. `reason` is
465
+ * `'source-silent'` when a no-packet watchdog asked: a still-listening cached
466
+ * server is then the dead one and must be recreated.
465
467
  */
466
468
  EventCategory["StreamBrokerOnRequestStreamSourceRefresh"] = "stream-broker.onRequestStreamSourceRefresh";
467
469
  /**
@@ -1321,7 +1323,8 @@ function typeOf(field) {
1321
1323
  case "timezone":
1322
1324
  case "datetime": return "string";
1323
1325
  case "number":
1324
- case "slider": return "number";
1326
+ case "slider":
1327
+ case "duration": return "number";
1325
1328
  case "boolean": return "boolean";
1326
1329
  default: return "other";
1327
1330
  }
@@ -1435,12 +1438,41 @@ async function guarded(work) {
1435
1438
  };
1436
1439
  }
1437
1440
  }
1441
+ var WAITING_REASON = /^dependency-(?:pending|blocked):(.+)$/;
1442
+ /**
1443
+ * What an owner keeps between runs: the steps blocked only on a predecessor not yet applied.
1444
+ * The engine announces every applied id (`migration.applied`); {@link releasedBy} says which
1445
+ * waiting steps that frees, so the owner runs them again without a restart or a timer.
1446
+ */
1447
+ var MigrationDependencyWaits = class {
1448
+ waiting = /* @__PURE__ */ new Map();
1449
+ /** Replace what is waiting for the ids this run judged (a step that moved on stops waiting). */
1450
+ record(report, judged) {
1451
+ for (const id of judged) this.waiting.delete(id);
1452
+ for (const entry of report.awaiting) this.waiting.set(entry.id, entry.on);
1453
+ }
1454
+ /** Waiting steps whose predecessor is among `applied`; they stop waiting (the rerun re-records). */
1455
+ releasedBy(applied) {
1456
+ const freed = [...this.waiting].filter(([, on]) => applied.includes(on)).map(([id]) => id);
1457
+ for (const id of freed) this.waiting.delete(id);
1458
+ return freed;
1459
+ }
1460
+ get size() {
1461
+ return this.waiting.size;
1462
+ }
1463
+ };
1464
+ /** The ids a `migration.applied` event carries; anything else yields none. */
1465
+ function appliedIdsOf(data) {
1466
+ if (typeof data !== "object" || data === null || !("ids" in data) || !Array.isArray(data.ids)) return [];
1467
+ return data.ids.filter((id) => typeof id === "string");
1468
+ }
1438
1469
  var NOT_RUN = {
1439
1470
  declared: false,
1440
1471
  snapshot: null,
1441
1472
  applied: [],
1442
1473
  failed: [],
1443
1474
  blocked: [],
1475
+ awaiting: [],
1444
1476
  skipped: [],
1445
1477
  blockOwner: []
1446
1478
  };
@@ -1460,7 +1492,8 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
1460
1492
  declaration = await host.declareOwner({
1461
1493
  owner,
1462
1494
  metas: migrations.map((m) => m.meta),
1463
- ...options.retired === void 0 ? {} : { retired: [...options.retired] }
1495
+ ...options.retired === void 0 ? {} : { retired: [...options.retired] },
1496
+ ...options.complete === void 0 ? {} : { complete: options.complete }
1464
1497
  });
1465
1498
  } catch (err) {
1466
1499
  log.error("the migration engine refused or could not take this addon catalogue — none ran", { meta: { error: require_scoped_settings.errMsg(err) } });
@@ -1472,6 +1505,7 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
1472
1505
  const applied = [];
1473
1506
  const failed = [];
1474
1507
  const blocked = [];
1508
+ const awaiting = [];
1475
1509
  const skipped = [];
1476
1510
  const settle = (id, status) => {
1477
1511
  if (status === "applied") applied.push(id);
@@ -1481,10 +1515,12 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
1481
1515
  };
1482
1516
  const selected = options.only === void 0 ? null : new Set(options.only);
1483
1517
  const deferred = /* @__PURE__ */ new Set();
1518
+ const settledEarlier = new Set(options.settledEarlier ?? []);
1484
1519
  const deferredBy = (reason) => {
1485
1520
  if (selected === null || reason === null) return null;
1486
1521
  const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
1487
1522
  if (dep === void 0 || !byId.has(dep)) return null;
1523
+ if (settledEarlier.has(dep)) return null;
1488
1524
  return !selected.has(dep) || deferred.has(dep) ? dep : null;
1489
1525
  };
1490
1526
  for (const step of declaration.steps) {
@@ -1518,6 +1554,11 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
1518
1554
  reason: gate.reason
1519
1555
  }
1520
1556
  });
1557
+ const on = WAITING_REASON.exec(gate.reason ?? "")?.[1];
1558
+ if (on !== void 0) awaiting.push({
1559
+ id: step.id,
1560
+ on
1561
+ });
1521
1562
  settle(step.id, gate.state === "pending" ? "blocked" : gate.state);
1522
1563
  continue;
1523
1564
  }
@@ -1550,6 +1591,7 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
1550
1591
  applied,
1551
1592
  failed,
1552
1593
  blocked,
1594
+ awaiting,
1553
1595
  skipped,
1554
1596
  blockOwner
1555
1597
  };
@@ -3249,6 +3291,7 @@ var BaseAddon = class {
3249
3291
  });
3250
3292
  await this.hydrateSwitches();
3251
3293
  const result = await this.onInitialize();
3294
+ this.catalogueOpen = false;
3252
3295
  await this.moveLateInstanceKinds();
3253
3296
  await this.adoptUnrowed();
3254
3297
  if (this.switchesHydrated) {
@@ -3296,7 +3339,14 @@ var BaseAddon = class {
3296
3339
  registrySwitchSpec = null;
3297
3340
  /** The instance kinds whose switch move this process already ran (or tried), by record kind name. */
3298
3341
  switchMoved = /* @__PURE__ */ new Set();
3299
- lastDeclared = [];
3342
+ /**
3343
+ * Every migration any `runMigrations` call of this process declared, by id. The engine replaces
3344
+ * an owner's catalogue on each declare, so each call carries the union, phased to its own ids.
3345
+ */
3346
+ declaredAll = /* @__PURE__ */ new Map();
3347
+ /** True until `initialize` has run `onInitialize`: more kinds and calls may still declare. */
3348
+ catalogueOpen = true;
3349
+ declaredIncomplete = false;
3300
3350
  /**
3301
3351
  * Every switch migration this process added to a declaration so far, by id. The engine replaces
3302
3352
  * an owner's catalogue on each declare, so a later one (a late kind) carries them all: dropping
@@ -3360,34 +3410,105 @@ var BaseAddon = class {
3360
3410
  */
3361
3411
  async moveLateInstanceKinds() {
3362
3412
  const late = servedInstanceKindsOf(this.ctx.id).filter((k) => !this.switchMoved.has(k.kind.name));
3363
- if (late.length === 0) return;
3413
+ if (late.length === 0) {
3414
+ if (!this.declaredIncomplete) return;
3415
+ try {
3416
+ await this.runBound([], { only: [] });
3417
+ } catch (err) {
3418
+ if (err instanceof AddonMigrationsBlockedError) throw err;
3419
+ this.ctx.logger.error("the closing migration declare failed", { meta: { error: require_scoped_settings.errMsg(err) } });
3420
+ }
3421
+ return;
3422
+ }
3364
3423
  try {
3365
3424
  const only = late.map((k) => bodySwitchToRegistryId(this.ctx.id, "2026-11-19", k.kind.name));
3366
- await this.runBound(this.lastDeclared, { only });
3425
+ await this.runBound([], { only });
3367
3426
  } catch (err) {
3368
3427
  if (err instanceof AddonMigrationsBlockedError) throw err;
3369
3428
  this.ctx.logger.error("the late instance switch move failed", { meta: { error: require_scoped_settings.errMsg(err) } });
3370
3429
  }
3371
3430
  }
3431
+ /** Steps blocked only on another owner's step that has not applied yet (run again when it does). */
3432
+ migrationWaits = new MigrationDependencyWaits();
3433
+ migrationWatch = false;
3434
+ /** Every id announced applied since the subscription: closes the in-flight-run window. */
3435
+ migrationAppliedSeen = /* @__PURE__ */ new Set();
3436
+ migrationRerunTail = Promise.resolve();
3437
+ /**
3438
+ * The engine announces every applied step (`migration.applied`). Subscribed BEFORE the first
3439
+ * declare, so a predecessor that lands between this owner's read and its subscription is not
3440
+ * missed; a step the engine blocked on one runs when that predecessor applies, with no restart.
3441
+ */
3442
+ watchAppliedMigrations() {
3443
+ if (this.migrationWatch) return;
3444
+ this.migrationWatch = true;
3445
+ this.subscribe({ category: EventCategory.MigrationApplied }, (event) => {
3446
+ const ids = appliedIdsOf(event.data);
3447
+ for (const id of ids) this.migrationAppliedSeen.add(id);
3448
+ this.releaseBlockedMigrations(ids);
3449
+ });
3450
+ }
3451
+ /**
3452
+ * Run again the waiting steps whose predecessor is among `applied`. The event is a hint (D8):
3453
+ * a dropped one leaves the step blocked until this addon's next boot, which reads the ledger.
3454
+ */
3455
+ releaseBlockedMigrations(applied) {
3456
+ const freed = this.migrationWaits.releasedBy(applied);
3457
+ if (freed.length === 0) return;
3458
+ this.migrationRerunTail = this.migrationRerunTail.catch(() => void 0).then(async () => {
3459
+ this.ctx.logger.info("a migration predecessor applied — running the blocked steps", { meta: { ids: freed } });
3460
+ await this.runBound([], { only: freed });
3461
+ }).then(() => void 0, (err) => {
3462
+ this.ctx.logger.error("the blocked migration steps could not run again", { meta: {
3463
+ ids: freed,
3464
+ error: require_scoped_settings.errMsg(err)
3465
+ } });
3466
+ });
3467
+ }
3372
3468
  async runBound(declared, options) {
3373
- this.lastDeclared = declared;
3469
+ this.watchAppliedMigrations();
3470
+ const priorIds = new Set([...this.declaredAll.keys(), ...this.switchDeclared.keys()]);
3374
3471
  const added = this.registrySwitchBound();
3375
3472
  for (const m of added) this.switchDeclared.set(m.meta.id, m);
3376
- const migrations = [...declared, ...[...this.switchDeclared.values()].filter((m) => !declared.some((d) => d.meta.id === m.meta.id))];
3377
- const widened = options?.only === void 0 || added.length === 0 ? options : {
3473
+ for (const m of declared) this.declaredAll.set(m.meta.id, m);
3474
+ const migrations = [...this.declaredAll.values(), ...[...this.switchDeclared.values()].filter((m) => !this.declaredAll.has(m.meta.id))];
3475
+ const settledEarlier = [...priorIds].filter((id) => !declared.some((d) => d.meta.id === id));
3476
+ const own = settledEarlier.length === 0 ? options ?? {} : {
3378
3477
  ...options,
3379
- only: [...new Set([...options.only, ...added.map((m) => m.meta.id)])]
3478
+ ...options?.only === void 0 ? { only: declared.map((m) => m.meta.id) } : {},
3479
+ settledEarlier
3380
3480
  };
3381
- const phased = this.retiredMigrationIds.length === 0 ? widened ?? {} : {
3382
- ...widened,
3383
- retired: this.retiredMigrationIds
3481
+ const widened = own?.only === void 0 || added.length === 0 ? own : {
3482
+ ...own,
3483
+ only: [...new Set([...own.only, ...added.map((m) => m.meta.id)])]
3484
+ };
3485
+ if (this.catalogueOpen) this.declaredIncomplete = true;
3486
+ const declare = {
3487
+ ...this.retiredMigrationIds.length === 0 ? widened ?? {} : {
3488
+ ...widened,
3489
+ retired: this.retiredMigrationIds
3490
+ },
3491
+ complete: !this.catalogueOpen
3384
3492
  };
3385
3493
  const api = this.ctx.api.migrations;
3386
- const report = await runAddonMigrations({
3494
+ const host = {
3387
3495
  declareOwner: (input) => api.declareOwner.mutate(input),
3388
3496
  startMigration: (input) => api.startMigration.mutate(input),
3389
3497
  finishMigration: (input) => api.finishMigration.mutate(input)
3390
- }, migrations, this.ctx.logger, phased);
3498
+ };
3499
+ const report = await runAddonMigrations(host, migrations, this.ctx.logger, declare);
3500
+ if (declare.complete === false && !this.catalogueOpen) await runAddonMigrations(host, [...new Map([...this.declaredAll, ...this.switchDeclared]).values()], this.ctx.logger, {
3501
+ ...this.retiredMigrationIds.length === 0 ? {} : { retired: this.retiredMigrationIds },
3502
+ only: [],
3503
+ complete: true
3504
+ });
3505
+ this.migrationWaits.record(report, [
3506
+ ...report.applied,
3507
+ ...report.failed,
3508
+ ...report.blocked,
3509
+ ...report.skipped
3510
+ ]);
3511
+ this.releaseBlockedMigrations([...this.migrationAppliedSeen]);
3391
3512
  if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
3392
3513
  await this.hydrateSwitches();
3393
3514
  await this.adoptUnrowed();
@@ -461,7 +461,9 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
461
461
  * only way to keep the broker dialable. Camera providers (Reolink
462
462
  * Baichuan native, …) subscribe and respond by re-running their publish
463
463
  * pipeline.
464
- * Payload: `{ deviceId, camStreamId, brokerId }`.
464
+ * Payload: `{ deviceId, camStreamId, brokerId, reason? }`. `reason` is
465
+ * `'source-silent'` when a no-packet watchdog asked: a still-listening cached
466
+ * server is then the dead one and must be recreated.
465
467
  */
466
468
  EventCategory["StreamBrokerOnRequestStreamSourceRefresh"] = "stream-broker.onRequestStreamSourceRefresh";
467
469
  /**
@@ -1321,7 +1323,8 @@ function typeOf(field) {
1321
1323
  case "timezone":
1322
1324
  case "datetime": return "string";
1323
1325
  case "number":
1324
- case "slider": return "number";
1326
+ case "slider":
1327
+ case "duration": return "number";
1325
1328
  case "boolean": return "boolean";
1326
1329
  default: return "other";
1327
1330
  }
@@ -1435,12 +1438,41 @@ async function guarded(work) {
1435
1438
  };
1436
1439
  }
1437
1440
  }
1441
+ var WAITING_REASON = /^dependency-(?:pending|blocked):(.+)$/;
1442
+ /**
1443
+ * What an owner keeps between runs: the steps blocked only on a predecessor not yet applied.
1444
+ * The engine announces every applied id (`migration.applied`); {@link releasedBy} says which
1445
+ * waiting steps that frees, so the owner runs them again without a restart or a timer.
1446
+ */
1447
+ var MigrationDependencyWaits = class {
1448
+ waiting = /* @__PURE__ */ new Map();
1449
+ /** Replace what is waiting for the ids this run judged (a step that moved on stops waiting). */
1450
+ record(report, judged) {
1451
+ for (const id of judged) this.waiting.delete(id);
1452
+ for (const entry of report.awaiting) this.waiting.set(entry.id, entry.on);
1453
+ }
1454
+ /** Waiting steps whose predecessor is among `applied`; they stop waiting (the rerun re-records). */
1455
+ releasedBy(applied) {
1456
+ const freed = [...this.waiting].filter(([, on]) => applied.includes(on)).map(([id]) => id);
1457
+ for (const id of freed) this.waiting.delete(id);
1458
+ return freed;
1459
+ }
1460
+ get size() {
1461
+ return this.waiting.size;
1462
+ }
1463
+ };
1464
+ /** The ids a `migration.applied` event carries; anything else yields none. */
1465
+ function appliedIdsOf(data) {
1466
+ if (typeof data !== "object" || data === null || !("ids" in data) || !Array.isArray(data.ids)) return [];
1467
+ return data.ids.filter((id) => typeof id === "string");
1468
+ }
1438
1469
  var NOT_RUN = {
1439
1470
  declared: false,
1440
1471
  snapshot: null,
1441
1472
  applied: [],
1442
1473
  failed: [],
1443
1474
  blocked: [],
1475
+ awaiting: [],
1444
1476
  skipped: [],
1445
1477
  blockOwner: []
1446
1478
  };
@@ -1460,7 +1492,8 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
1460
1492
  declaration = await host.declareOwner({
1461
1493
  owner,
1462
1494
  metas: migrations.map((m) => m.meta),
1463
- ...options.retired === void 0 ? {} : { retired: [...options.retired] }
1495
+ ...options.retired === void 0 ? {} : { retired: [...options.retired] },
1496
+ ...options.complete === void 0 ? {} : { complete: options.complete }
1464
1497
  });
1465
1498
  } catch (err) {
1466
1499
  log.error("the migration engine refused or could not take this addon catalogue — none ran", { meta: { error: errMsg(err) } });
@@ -1472,6 +1505,7 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
1472
1505
  const applied = [];
1473
1506
  const failed = [];
1474
1507
  const blocked = [];
1508
+ const awaiting = [];
1475
1509
  const skipped = [];
1476
1510
  const settle = (id, status) => {
1477
1511
  if (status === "applied") applied.push(id);
@@ -1481,10 +1515,12 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
1481
1515
  };
1482
1516
  const selected = options.only === void 0 ? null : new Set(options.only);
1483
1517
  const deferred = /* @__PURE__ */ new Set();
1518
+ const settledEarlier = new Set(options.settledEarlier ?? []);
1484
1519
  const deferredBy = (reason) => {
1485
1520
  if (selected === null || reason === null) return null;
1486
1521
  const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
1487
1522
  if (dep === void 0 || !byId.has(dep)) return null;
1523
+ if (settledEarlier.has(dep)) return null;
1488
1524
  return !selected.has(dep) || deferred.has(dep) ? dep : null;
1489
1525
  };
1490
1526
  for (const step of declaration.steps) {
@@ -1518,6 +1554,11 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
1518
1554
  reason: gate.reason
1519
1555
  }
1520
1556
  });
1557
+ const on = WAITING_REASON.exec(gate.reason ?? "")?.[1];
1558
+ if (on !== void 0) awaiting.push({
1559
+ id: step.id,
1560
+ on
1561
+ });
1521
1562
  settle(step.id, gate.state === "pending" ? "blocked" : gate.state);
1522
1563
  continue;
1523
1564
  }
@@ -1550,6 +1591,7 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
1550
1591
  applied,
1551
1592
  failed,
1552
1593
  blocked,
1594
+ awaiting,
1553
1595
  skipped,
1554
1596
  blockOwner
1555
1597
  };
@@ -3249,6 +3291,7 @@ var BaseAddon = class {
3249
3291
  });
3250
3292
  await this.hydrateSwitches();
3251
3293
  const result = await this.onInitialize();
3294
+ this.catalogueOpen = false;
3252
3295
  await this.moveLateInstanceKinds();
3253
3296
  await this.adoptUnrowed();
3254
3297
  if (this.switchesHydrated) {
@@ -3296,7 +3339,14 @@ var BaseAddon = class {
3296
3339
  registrySwitchSpec = null;
3297
3340
  /** The instance kinds whose switch move this process already ran (or tried), by record kind name. */
3298
3341
  switchMoved = /* @__PURE__ */ new Set();
3299
- lastDeclared = [];
3342
+ /**
3343
+ * Every migration any `runMigrations` call of this process declared, by id. The engine replaces
3344
+ * an owner's catalogue on each declare, so each call carries the union, phased to its own ids.
3345
+ */
3346
+ declaredAll = /* @__PURE__ */ new Map();
3347
+ /** True until `initialize` has run `onInitialize`: more kinds and calls may still declare. */
3348
+ catalogueOpen = true;
3349
+ declaredIncomplete = false;
3300
3350
  /**
3301
3351
  * Every switch migration this process added to a declaration so far, by id. The engine replaces
3302
3352
  * an owner's catalogue on each declare, so a later one (a late kind) carries them all: dropping
@@ -3360,34 +3410,105 @@ var BaseAddon = class {
3360
3410
  */
3361
3411
  async moveLateInstanceKinds() {
3362
3412
  const late = servedInstanceKindsOf(this.ctx.id).filter((k) => !this.switchMoved.has(k.kind.name));
3363
- if (late.length === 0) return;
3413
+ if (late.length === 0) {
3414
+ if (!this.declaredIncomplete) return;
3415
+ try {
3416
+ await this.runBound([], { only: [] });
3417
+ } catch (err) {
3418
+ if (err instanceof AddonMigrationsBlockedError) throw err;
3419
+ this.ctx.logger.error("the closing migration declare failed", { meta: { error: errMsg(err) } });
3420
+ }
3421
+ return;
3422
+ }
3364
3423
  try {
3365
3424
  const only = late.map((k) => bodySwitchToRegistryId(this.ctx.id, "2026-11-19", k.kind.name));
3366
- await this.runBound(this.lastDeclared, { only });
3425
+ await this.runBound([], { only });
3367
3426
  } catch (err) {
3368
3427
  if (err instanceof AddonMigrationsBlockedError) throw err;
3369
3428
  this.ctx.logger.error("the late instance switch move failed", { meta: { error: errMsg(err) } });
3370
3429
  }
3371
3430
  }
3431
+ /** Steps blocked only on another owner's step that has not applied yet (run again when it does). */
3432
+ migrationWaits = new MigrationDependencyWaits();
3433
+ migrationWatch = false;
3434
+ /** Every id announced applied since the subscription: closes the in-flight-run window. */
3435
+ migrationAppliedSeen = /* @__PURE__ */ new Set();
3436
+ migrationRerunTail = Promise.resolve();
3437
+ /**
3438
+ * The engine announces every applied step (`migration.applied`). Subscribed BEFORE the first
3439
+ * declare, so a predecessor that lands between this owner's read and its subscription is not
3440
+ * missed; a step the engine blocked on one runs when that predecessor applies, with no restart.
3441
+ */
3442
+ watchAppliedMigrations() {
3443
+ if (this.migrationWatch) return;
3444
+ this.migrationWatch = true;
3445
+ this.subscribe({ category: EventCategory.MigrationApplied }, (event) => {
3446
+ const ids = appliedIdsOf(event.data);
3447
+ for (const id of ids) this.migrationAppliedSeen.add(id);
3448
+ this.releaseBlockedMigrations(ids);
3449
+ });
3450
+ }
3451
+ /**
3452
+ * Run again the waiting steps whose predecessor is among `applied`. The event is a hint (D8):
3453
+ * a dropped one leaves the step blocked until this addon's next boot, which reads the ledger.
3454
+ */
3455
+ releaseBlockedMigrations(applied) {
3456
+ const freed = this.migrationWaits.releasedBy(applied);
3457
+ if (freed.length === 0) return;
3458
+ this.migrationRerunTail = this.migrationRerunTail.catch(() => void 0).then(async () => {
3459
+ this.ctx.logger.info("a migration predecessor applied — running the blocked steps", { meta: { ids: freed } });
3460
+ await this.runBound([], { only: freed });
3461
+ }).then(() => void 0, (err) => {
3462
+ this.ctx.logger.error("the blocked migration steps could not run again", { meta: {
3463
+ ids: freed,
3464
+ error: errMsg(err)
3465
+ } });
3466
+ });
3467
+ }
3372
3468
  async runBound(declared, options) {
3373
- this.lastDeclared = declared;
3469
+ this.watchAppliedMigrations();
3470
+ const priorIds = new Set([...this.declaredAll.keys(), ...this.switchDeclared.keys()]);
3374
3471
  const added = this.registrySwitchBound();
3375
3472
  for (const m of added) this.switchDeclared.set(m.meta.id, m);
3376
- const migrations = [...declared, ...[...this.switchDeclared.values()].filter((m) => !declared.some((d) => d.meta.id === m.meta.id))];
3377
- const widened = options?.only === void 0 || added.length === 0 ? options : {
3473
+ for (const m of declared) this.declaredAll.set(m.meta.id, m);
3474
+ const migrations = [...this.declaredAll.values(), ...[...this.switchDeclared.values()].filter((m) => !this.declaredAll.has(m.meta.id))];
3475
+ const settledEarlier = [...priorIds].filter((id) => !declared.some((d) => d.meta.id === id));
3476
+ const own = settledEarlier.length === 0 ? options ?? {} : {
3378
3477
  ...options,
3379
- only: [...new Set([...options.only, ...added.map((m) => m.meta.id)])]
3478
+ ...options?.only === void 0 ? { only: declared.map((m) => m.meta.id) } : {},
3479
+ settledEarlier
3380
3480
  };
3381
- const phased = this.retiredMigrationIds.length === 0 ? widened ?? {} : {
3382
- ...widened,
3383
- retired: this.retiredMigrationIds
3481
+ const widened = own?.only === void 0 || added.length === 0 ? own : {
3482
+ ...own,
3483
+ only: [...new Set([...own.only, ...added.map((m) => m.meta.id)])]
3484
+ };
3485
+ if (this.catalogueOpen) this.declaredIncomplete = true;
3486
+ const declare = {
3487
+ ...this.retiredMigrationIds.length === 0 ? widened ?? {} : {
3488
+ ...widened,
3489
+ retired: this.retiredMigrationIds
3490
+ },
3491
+ complete: !this.catalogueOpen
3384
3492
  };
3385
3493
  const api = this.ctx.api.migrations;
3386
- const report = await runAddonMigrations({
3494
+ const host = {
3387
3495
  declareOwner: (input) => api.declareOwner.mutate(input),
3388
3496
  startMigration: (input) => api.startMigration.mutate(input),
3389
3497
  finishMigration: (input) => api.finishMigration.mutate(input)
3390
- }, migrations, this.ctx.logger, phased);
3498
+ };
3499
+ const report = await runAddonMigrations(host, migrations, this.ctx.logger, declare);
3500
+ if (declare.complete === false && !this.catalogueOpen) await runAddonMigrations(host, [...new Map([...this.declaredAll, ...this.switchDeclared]).values()], this.ctx.logger, {
3501
+ ...this.retiredMigrationIds.length === 0 ? {} : { retired: this.retiredMigrationIds },
3502
+ only: [],
3503
+ complete: true
3504
+ });
3505
+ this.migrationWaits.record(report, [
3506
+ ...report.applied,
3507
+ ...report.failed,
3508
+ ...report.blocked,
3509
+ ...report.skipped
3510
+ ]);
3511
+ this.releaseBlockedMigrations([...this.migrationAppliedSeen]);
3391
3512
  if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
3392
3513
  await this.hydrateSwitches();
3393
3514
  await this.adoptUnrowed();
@@ -1,11 +1,11 @@
1
- const require_stream_catalog_cap = require("./stream-catalog.cap-CjEQFknc.js");
2
- const require_base_addon = require("./base-addon-CRsXtYFG.js");
1
+ const require_stream_catalog_cap = require("./stream-catalog.cap-7WPsugOy.js");
2
+ const require_base_addon = require("./base-addon-BG7p06Hb.js");
3
3
  const require_scoped_settings = require("./scoped-settings-CylSSq_8.js");
4
4
  const require_zod_secret = require("./zod-secret-DS7mj1bk.js");
5
5
  const require_device_identifiers = require("./device-identifiers-BQg9EQi1.js");
6
6
  const require_source_info = require("./source-info-DtWf4k2j.js");
7
- const require_error_cap = require("./error.cap-BuKbL3Ac.js");
8
- const require_alert_episode = require("./alert-episode-Bqktmt-i.js");
7
+ const require_error_cap = require("./error.cap-BqlvgBJd.js");
8
+ const require_alert_episode = require("./alert-episode-DaQ3prSe.js");
9
9
  //#region ../types/dist/esm/device/device-config.mjs
10
10
  var DeviceConfig = class DeviceConfig {
11
11
  schema;
@@ -1,11 +1,11 @@
1
- import { E as deviceStatusCapability, w as featureProbeCapability } from "./stream-catalog.cap-DVniDdRD.mjs";
2
- import { p as createEvent } from "./base-addon-BcS6r1cT.mjs";
1
+ import { E as deviceStatusCapability, w as featureProbeCapability } from "./stream-catalog.cap-CzwRDaqT.mjs";
2
+ import { p as createEvent } from "./base-addon-BcVoYZbC.mjs";
3
3
  import { Z as errMsg } from "./scoped-settings-DVWUIP7Z.mjs";
4
4
  import { t as collectZodSecretPaths } from "./zod-secret-zY4nM61M.mjs";
5
5
  import { a as isEmptyIdentifiers, s as normaliseIdentifiers, t as DEVICE_IDENTIFIER_KEYS } from "./device-identifiers-iSuQCKmK.mjs";
6
6
  import { i as mergeSourceInfo, o as synthesizeSourceInfo, r as extractSourceInfoFromMetadata, t as SOURCE_INFO_METADATA_KEY } from "./source-info-DGB7SdB_.mjs";
7
- import { i as errorCapability, r as ERROR_STATUS_COLD } from "./error.cap-CU1FB6uE.mjs";
8
- import { t as DEVICE_ERROR_ALERT_CATEGORY } from "./alert-episode-Be--PngO.mjs";
7
+ import { i as errorCapability, r as ERROR_STATUS_COLD } from "./error.cap-B8l7L8e4.mjs";
8
+ import { t as DEVICE_ERROR_ALERT_CATEGORY } from "./alert-episode-D-1VUUkZ.mjs";
9
9
  //#region ../types/dist/esm/device/device-config.mjs
10
10
  var DeviceConfig = class DeviceConfig {
11
11
  schema;
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_base_addon = require("../../base-addon-CRsXtYFG.js");
6
+ const require_base_addon = require("../../base-addon-BG7p06Hb.js");
7
7
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
8
8
  const require_addon_pages_cap = require("../../addon-pages.cap-B3gHFDYW.js");
9
9
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
@@ -1,4 +1,4 @@
1
- import { b as EventCategory, t as BaseAddon } from "../../base-addon-BcS6r1cT.mjs";
1
+ import { b as EventCategory, t as BaseAddon } from "../../base-addon-BcVoYZbC.mjs";
2
2
  import { Z as errMsg } from "../../scoped-settings-DVWUIP7Z.mjs";
3
3
  import { t as addonPagesCapability } from "../../addon-pages.cap-BLNN6ypr.mjs";
4
4
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_base_addon = require("../../base-addon-CRsXtYFG.js");
6
+ const require_base_addon = require("../../base-addon-BG7p06Hb.js");
7
7
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
8
8
  const require_addon_widgets_cap = require("../../addon-widgets.cap-DuCe2VRj.js");
9
9
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
@@ -1,4 +1,4 @@
1
- import { b as EventCategory, t as BaseAddon } from "../../base-addon-BcS6r1cT.mjs";
1
+ import { b as EventCategory, t as BaseAddon } from "../../base-addon-BcVoYZbC.mjs";
2
2
  import { Z as errMsg } from "../../scoped-settings-DVWUIP7Z.mjs";
3
3
  import { t as addonWidgetsCapability } from "../../addon-widgets.cap-BbmWMzIH.mjs";
4
4
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
@@ -3,12 +3,12 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_base_addon = require("../../base-addon-CRsXtYFG.js");
6
+ const require_base_addon = require("../../base-addon-BG7p06Hb.js");
7
7
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
8
8
  const require_record_kind = require("../../record-kind-DoBfYHCs.js");
9
- const require_core_blocks_cap = require("../../core-blocks.cap-CdTGUKtr.js");
9
+ const require_core_blocks_cap = require("../../core-blocks.cap-DEYCvF9J.js");
10
10
  const require_compile = require("../../compile-SpeAhaZ6.js");
11
- const require_alert_episode = require("../../alert-episode-Bqktmt-i.js");
11
+ const require_alert_episode = require("../../alert-episode-DaQ3prSe.js");
12
12
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
13
13
  const require_log_redactor = require("../../log-redactor-BhIEMaG9.js");
14
14
  let node_fs = require("node:fs");
@@ -1,9 +1,9 @@
1
- import { b as EventCategory, p as createEvent, t as BaseAddon } from "../../base-addon-BcS6r1cT.mjs";
1
+ import { b as EventCategory, p as createEvent, t as BaseAddon } from "../../base-addon-BcVoYZbC.mjs";
2
2
  import { Z as errMsg } from "../../scoped-settings-DVWUIP7Z.mjs";
3
3
  import { s as defineRecordKinds } from "../../record-kind-ub6NXqfh.mjs";
4
- import { n as CORE_BLOCK_ADDON_PREFIX } from "../../core-blocks.cap-DLkEfV5b.mjs";
4
+ import { n as CORE_BLOCK_ADDON_PREFIX } from "../../core-blocks.cap-sW5HLDlB.mjs";
5
5
  import { it as alertsCapability, rt as AlertSchema } from "../../compile-OBMHlqD-.mjs";
6
- import { a as isAlertEpisodeOpen, i as alertEpisodeRank, n as alertEpisodeId, r as alertEpisodePayload } from "../../alert-episode-Be--PngO.mjs";
6
+ import { a as isAlertEpisodeOpen, i as alertEpisodeRank, n as alertEpisodeId, r as alertEpisodePayload } from "../../alert-episode-D-1VUUkZ.mjs";
7
7
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
8
8
  import { a as redactLogText } from "../../log-redactor-XLDrPzOi.mjs";
9
9
  import * as fs$1 from "node:fs";
@@ -0,0 +1,24 @@
1
+ import type { AppDeclaration, AppInfo, IAppSourceProvider } from "@camstack/types";
2
+ /** Per-source ceiling: one dead provider must not stall the shell's app list. */
3
+ export declare const APPS_PER_SOURCE_TIMEOUT_MS = 2500;
4
+ export interface AppsCaller {
5
+ readonly isAdmin: boolean;
6
+ }
7
+ export interface AppsLogger {
8
+ warn(message: string, context?: {
9
+ readonly meta?: Readonly<Record<string, unknown>>;
10
+ }): void;
11
+ }
12
+ export type AppSourceEntry = IAppSourceProvider & {
13
+ readonly id: string;
14
+ };
15
+ /**
16
+ * Merge every `app-source` provider into the caller's list (D1096): stamp the
17
+ * provider id, drop what the caller's role may not see, order by `order`.
18
+ * A provider that fails or times out is logged with its reason and answered
19
+ * from its last good snapshot (`lastGood`, owned by the caller) or skipped when
20
+ * it has none. The same app reported by several nodes (a collection registers
21
+ * one provider per node) is listed once, keyed on `(addonId, app.id)`, the
22
+ * first provider winning: the hub-local one precedes remote ones.
23
+ */
24
+ export declare function aggregateApps(sources: readonly AppSourceEntry[], caller: AppsCaller, logger: AppsLogger, lastGood?: Map<string, readonly AppDeclaration[]>): Promise<readonly AppInfo[]>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Apps Aggregator — hub-local builtin that owns the singleton `apps` cap (D1096).
3
+ *
4
+ * Walks every `app-source` (collection) provider, stamps each app with the
5
+ * provider's addon id and filters by the caller's role. The shell reads it; no
6
+ * app id is spelled anywhere else.
7
+ */
8
+ import { BaseAddon, type ProviderRegistration } from "@camstack/types";
9
+ export declare class AppsAggregatorAddon extends BaseAddon {
10
+ readonly id = "apps-aggregator";
11
+ /** Last good declarations per source, the fallback for a transient failure. */
12
+ private readonly lastGood;
13
+ constructor();
14
+ protected onInitialize(): Promise<ProviderRegistration[]>;
15
+ }
16
+ export default AppsAggregatorAddon;