@camstack/server 1.2.789 → 1.2.791

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 (131) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/agent/agent-child-manifest.js +39 -0
  3. package/dist/agent/agent-hub-registration.js +11 -1
  4. package/dist/agent/forward-to-hub.js +43 -0
  5. package/dist/agent/main.js +31 -81
  6. package/dist/agent/stale-addon-gate.js +70 -34
  7. package/dist/api/trpc/device-config-secret-redaction.js +14 -1
  8. package/dist/api/trpc/generated-cap-mounts.js +1 -6
  9. package/dist/api/trpc/generated-cap-routers.js +1245 -1417
  10. package/dist/api/trpc/localized-schema-paths.js +1 -0
  11. package/dist/core/addon/addon-registry.service.js +25 -33
  12. package/dist/core/addon/addon-settings-provider.js +57 -0
  13. package/dist/core/addon/boot-health-snapshot.js +0 -28
  14. package/dist/core/addon/{hub-spawn-gate.js → hub-addon-support.js} +12 -35
  15. package/dist/core/moleculer/moleculer.service.js +2 -13
  16. package/dist/core/moleculer/runner-hosted-on-node.js +23 -0
  17. package/dist/core/updates/required-addon-update.js +1 -1
  18. package/package.json +20 -11
  19. package/system/dist/addon-runner.js +22 -0
  20. package/system/dist/addon-runner.mjs +22 -0
  21. package/system/dist/{agent-https-szf2FU49.mjs → agent-https-BmVaVskH.mjs} +1 -1
  22. package/system/dist/{agent-https-jJDe-XNl.js → agent-https-DOs15BCJ.js} +1 -1
  23. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  24. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  25. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  26. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  27. package/system/dist/builtins/alerts/alerts.addon.d.ts +8 -0
  28. package/system/dist/builtins/alerts/alerts.addon.js +72 -1
  29. package/system/dist/builtins/alerts/alerts.addon.mjs +72 -1
  30. package/system/dist/builtins/autotrack/autotrack.addon.d.ts +7 -7
  31. package/system/dist/builtins/autotrack/index.js +15 -8
  32. package/system/dist/builtins/autotrack/index.mjs +15 -8
  33. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  34. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  35. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  36. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  37. package/system/dist/builtins/camera-grid/index.js +1 -1
  38. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  39. package/system/dist/builtins/composer/composer.addon.js +3 -3
  40. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  41. package/system/dist/builtins/console-logging/index.js +1 -1
  42. package/system/dist/builtins/console-logging/index.mjs +1 -1
  43. package/system/dist/builtins/core-blocks/core-blocks.addon.js +11 -5
  44. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +11 -5
  45. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  46. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  47. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  48. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  49. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  50. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  51. package/system/dist/builtins/keychain/index.js +4 -4
  52. package/system/dist/builtins/keychain/index.mjs +4 -4
  53. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  54. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  55. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  56. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  57. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  58. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  59. package/system/dist/builtins/loki-logging/index.js +1 -1
  60. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  61. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  62. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  63. package/system/dist/builtins/platform-probe/index.js +1 -1
  64. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  65. package/system/dist/builtins/record-entries/index.js +1 -1
  66. package/system/dist/builtins/record-entries/index.mjs +1 -1
  67. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.d.ts +4 -10
  68. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +16 -9
  69. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +16 -9
  70. package/system/dist/builtins/snapshot/index.js +1 -1
  71. package/system/dist/builtins/snapshot/index.mjs +1 -1
  72. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  73. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  74. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  75. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  76. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  77. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  78. package/system/dist/builtins/storage-orchestrator/access-guards.d.ts +1 -1
  79. package/system/dist/builtins/storage-orchestrator/custom-actions.d.ts +11 -0
  80. package/system/dist/builtins/storage-orchestrator/index.d.ts +1 -0
  81. package/system/dist/builtins/storage-orchestrator/index.js +2 -0
  82. package/system/dist/builtins/storage-orchestrator/index.mjs +2 -2
  83. package/system/dist/builtins/storage-orchestrator/location-instances.d.ts +72 -0
  84. package/system/dist/builtins/storage-orchestrator/location-repoint-move.d.ts +1 -1
  85. package/system/dist/builtins/storage-orchestrator/location-secret-refs.d.ts +26 -0
  86. package/system/dist/builtins/storage-orchestrator/location-store.d.ts +28 -2
  87. package/system/dist/builtins/storage-orchestrator/migrations/index.d.ts +9 -2
  88. package/system/dist/builtins/storage-orchestrator/migrations/legacy-location-secret-refs.d.ts +13 -0
  89. package/system/dist/builtins/storage-orchestrator/migrations/location-secret-ports.d.ts +15 -0
  90. package/system/dist/builtins/storage-orchestrator/migrations/location-secrets-to-record.d.ts +57 -0
  91. package/system/dist/builtins/storage-orchestrator/provider-discovery.d.ts +10 -13
  92. package/system/dist/builtins/storage-orchestrator/record-kinds.d.ts +6 -0
  93. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +39 -8
  94. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +954 -131
  95. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +954 -132
  96. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts +8 -0
  97. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  98. package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
  99. package/system/dist/builtins/winston-logging/index.js +112 -3
  100. package/system/dist/builtins/winston-logging/index.mjs +112 -3
  101. package/system/dist/builtins/winston-logging/migrations/index.d.ts +8 -0
  102. package/system/dist/builtins/winston-logging/migrations/node-fields.d.ts +43 -0
  103. package/system/dist/builtins/winston-logging/winston-logging.addon.d.ts +10 -2
  104. package/system/dist/{capture-engine-DNHgjQot.js → capture-engine-BVpkq9Mv.js} +1 -1
  105. package/system/dist/{capture-engine-BsKY_3xa.mjs → capture-engine-D-oUDtX5.mjs} +1 -1
  106. package/system/dist/{composition-sources-BRdGsbVT.mjs → composition-sources-Br7JhpbD.mjs} +1 -1
  107. package/system/dist/{composition-sources-BgO0GQYW.js → composition-sources-DKCbVA67.js} +1 -1
  108. package/system/dist/{constants-CQeMrR4f.mjs → constants-Bl0Qxbek.mjs} +1 -1
  109. package/system/dist/{constants-C3jGKQSQ.js → constants-CJVY-mUq.js} +1 -1
  110. package/system/dist/{device-ca-ByVi5eUC.mjs → device-ca-BeDGy8NK.mjs} +1 -1
  111. package/system/dist/{device-ca-D3y6wGmn.js → device-ca-i8EbKp3q.js} +1 -1
  112. package/system/dist/{dist-BsQA6-0i.mjs → dist-CPUbgRkb.mjs} +395 -425
  113. package/system/dist/{dist-BRI-Mwx0.js → dist-Ddkk4Dqq.js} +412 -424
  114. package/system/dist/file-host-worker.js +1 -1
  115. package/system/dist/file-host-worker.mjs +1 -1
  116. package/system/dist/{hub-mdns-ciao-8dJTW2LI.mjs → hub-mdns-ciao-DgF4SifE.mjs} +2 -2
  117. package/system/dist/{hub-mdns-ciao-Ry_Jpljx.js → hub-mdns-ciao-lHRHbXqV.js} +2 -2
  118. package/system/dist/index.js +151 -53
  119. package/system/dist/index.mjs +151 -55
  120. package/system/dist/kernel/addon-health-monitor.d.ts +0 -21
  121. package/system/dist/kernel/index.d.ts +2 -0
  122. package/system/dist/kernel/transport/child-cap-protocol.d.ts +1 -1
  123. package/system/dist/kernel/transport/runner-of-addon.d.ts +2 -0
  124. package/system/dist/kernel/unsupported-addon-tracker.d.ts +74 -0
  125. package/system/dist/{legacy-integration-rows-door-CjXTbmvH.mjs → legacy-integration-rows-door-9JSt493H.mjs} +1 -1
  126. package/system/dist/{legacy-integration-rows-door-D5BdSNla.js → legacy-integration-rows-door-n9GIUxgq.js} +1 -1
  127. package/system/dist/{restore-archive-GoWJMdHy.js → restore-archive-BDvLSZtj.js} +1 -1
  128. package/system/dist/{restore-archive-vn4co_kf.mjs → restore-archive-Dh3XnCR1.mjs} +82 -82
  129. package/system/dist/{wal-maintenance-CadfiGWy.mjs → wal-maintenance-BQJAmAwS.mjs} +0 -0
  130. package/system/dist/{wal-maintenance-sSlXJm4k.js → wal-maintenance-CWlz_qRq.js} +0 -0
  131. package/system/package.json +4 -1
@@ -13,6 +13,7 @@ exports.LOCALIZED_SCHEMA_PATHS = void 0;
13
13
  */
14
14
  exports.LOCALIZED_SCHEMA_PATHS = new Set([
15
15
  'addonSettings.getGlobalSettings',
16
+ 'addonSettings.getScopedSettings',
16
17
  'addonSettings.getIntegrationSettings',
17
18
  'addonSettings.getIntegrationFormSchema',
18
19
  'addonSettings.getDeviceSettings',
@@ -45,7 +45,7 @@ const fs = __importStar(require("node:fs"));
45
45
  const os = __importStar(require("node:os"));
46
46
  const path = __importStar(require("node:path"));
47
47
  const boot_health_snapshot_js_1 = require("./boot-health-snapshot.js");
48
- const hub_spawn_gate_js_1 = require("./hub-spawn-gate.js");
48
+ const hub_addon_support_js_1 = require("./hub-addon-support.js");
49
49
  const system_1 = require("@camstack/server/system");
50
50
  const types_1 = require("@camstack/types");
51
51
  const types_2 = require("@camstack/types");
@@ -292,8 +292,6 @@ class AddonRegistryService {
292
292
  moleculer;
293
293
  streamProbe;
294
294
  addonEntries = new Map();
295
- /** Addons the hub spawn gate holds back (id -> reason): neither started nor failed. */
296
- heldBackAddons = new boot_health_snapshot_js_1.HeldBackAddons();
297
295
  capabilityRegistry;
298
296
  /** Single router for addon-level calls (routes / custom / settings). */
299
297
  addonCallGateway;
@@ -328,6 +326,8 @@ class AddonRegistryService {
328
326
  logger;
329
327
  addonLoader;
330
328
  healthMonitor;
329
+ /** Raises and clears the alert for an addon that runs below the server's minimum (D1017). */
330
+ unsupportedAddons;
331
331
  addonRouteRegistry = null;
332
332
  dataPlaneRegistry = null;
333
333
  // Broker-routed AddonApi proxy — every addon's `ctx.api` resolves
@@ -449,7 +449,11 @@ class AddonRegistryService {
449
449
  eventBus: this.eventBusService,
450
450
  logger: this.loggingService.createLogger('AddonHealthMonitor'),
451
451
  retryFn: (packageName) => this.tryReloadPackage(packageName),
452
- isHeldBack: (addonId) => this.heldBackAddons.has(addonId),
452
+ });
453
+ this.unsupportedAddons = new system_1.UnsupportedAddonTracker({
454
+ eventBus: this.eventBusService,
455
+ nodeId: 'hub',
456
+ log: (line) => this.logger.warn(line),
453
457
  });
454
458
  // Create capability registry with config reader for singleton preferences
455
459
  this.capabilityRegistry = new system_1.CapabilityRegistry(this.loggingService.createLogger('CapabilityRegistry'), this.eventBusService);
@@ -1027,7 +1031,6 @@ class AddonRegistryService {
1027
1031
  // recorded above from `addonLoader.listLoadFailures()`.
1028
1032
  (0, boot_health_snapshot_js_1.recordBootHealth)({
1029
1033
  entries: this.addonEntries.entries(),
1030
- heldBack: this.heldBackAddons.asMap(),
1031
1034
  monitor: this.healthMonitor,
1032
1035
  });
1033
1036
  // Start the kernel-level retry tick (30s). Fires immediately
@@ -1161,6 +1164,7 @@ class AddonRegistryService {
1161
1164
  async onModuleDestroy() {
1162
1165
  this.logger.info('Shutting down all addons…');
1163
1166
  this.healthMonitor.stop();
1167
+ this.unsupportedAddons.stop();
1164
1168
  await this.shutdownAll();
1165
1169
  this.logger.info('All addons shut down');
1166
1170
  }
@@ -1919,7 +1923,7 @@ class AddonRegistryService {
1919
1923
  const suppressed = new Set([addonId]);
1920
1924
  if (this.isForkedAddonEntry(entry)) {
1921
1925
  const runnerId = (0, types_2.resolveRunnerId)(entry.declaration, addonId);
1922
- for (const { addonId: siblingId } of this.buildSpawnPlan([...this.addonEntries.keys()], () => undefined).get(runnerId) ?? []) {
1926
+ for (const { addonId: siblingId } of this.buildSpawnPlan([...this.addonEntries.keys()]).get(runnerId) ?? []) {
1923
1927
  suppressed.add(siblingId);
1924
1928
  }
1925
1929
  }
@@ -3345,24 +3349,21 @@ class AddonRegistryService {
3345
3349
  * diagnostics that want to render the current topology.
3346
3350
  */
3347
3351
  /**
3348
- * The plan the hub actually SPAWNS: `buildAddonGroupPlan` over the ids whose
3349
- * package passes the stale gate (planning#447). An addon below the running
3350
- * server's `requires.addons`, or needing a newer server, stays unspawned and
3351
- * is logged with both versions; the post-swap required-addon update brings it
3352
- * current and a reload spawns it then.
3352
+ * The plan the hub SPAWNS: `buildAddonGroupPlan` over `addonIds`, after the
3353
+ * support judgement of each one. An addon below the running server's
3354
+ * `requires.addons`, or needing a newer server, is NOT left out: it runs, and
3355
+ * the tracker raises (once) or clears the operator alert with both versions
3356
+ * (D1017). The post-swap required-addon update brings the package current.
3353
3357
  */
3354
- buildSpawnPlan(addonIds, log = (line) => this.logger.warn(line)) {
3355
- return this.buildAddonGroupPlan(this.spawnableIds(addonIds, log));
3356
- }
3357
- spawnableIds(addonIds, log) {
3358
- return this.heldBackAddons.track(addonIds, (onDeferred) => (0, hub_spawn_gate_js_1.spawnableAddonIds)({
3358
+ buildSpawnPlan(addonIds) {
3359
+ (0, hub_addon_support_js_1.reportHubAddonSupport)({
3359
3360
  addonIds,
3360
3361
  candidateOf: (id) => this.staleCandidateOf(id),
3361
- context: (0, hub_spawn_gate_js_1.readHubStaleGateContext)(),
3362
- infraCapabilities: new Set(system_1.INFRA_CAPABILITIES.map((c) => c.name)),
3363
- log,
3364
- onDeferred,
3365
- }));
3362
+ context: (0, hub_addon_support_js_1.readHubStaleGateContext)(),
3363
+ tracker: this.unsupportedAddons,
3364
+ installedPackages: [...this.addonEntries.values()].map((e) => e.packageName),
3365
+ });
3366
+ return this.buildAddonGroupPlan(addonIds);
3366
3367
  }
3367
3368
  staleCandidateOf(addonId) {
3368
3369
  const entry = this.addonEntries.get(addonId);
@@ -3571,18 +3572,9 @@ class AddonRegistryService {
3571
3572
  throw new Error(`ensureForkedRunner("${addonId}") requires an on-disk forked addon`);
3572
3573
  }
3573
3574
  const runnerId = (0, types_2.resolveRunnerId)(entry.declaration, addonId);
3574
- // The same gate as the boot plan: a restart, a hot-install or a retry must not spawn an addon
3575
- // the running server cannot host, nor carry a held-back sibling into its runner.
3576
- const held = [];
3577
- if (this.spawnableIds([addonId], (line) => held.push(line)).length === 0) {
3578
- const reason = held.join('; ');
3579
- this.logger.warn('ensureForkedRunner: addon is held back by the stale gate, not spawned', {
3580
- tags: { addonId },
3581
- meta: { reason },
3582
- });
3583
- throw new Error(`addon "${addonId}" is held back until its package is reconciled: ${reason}`);
3584
- }
3585
- const roster = this.buildSpawnPlan([...this.addonEntries.keys()], () => undefined).get(runnerId) ?? [{ addonId, addonDir: entry.addonDir }];
3575
+ const roster = this.buildSpawnPlan([...this.addonEntries.keys()]).get(runnerId) ?? [
3576
+ { addonId, addonDir: entry.addonDir },
3577
+ ];
3586
3578
  // Claim before the queue so a member that arrives while this one is
3587
3579
  // waiting is visible to the fork that has not started yet. Solo runners
3588
3580
  // (roster of one) never claim — each of their restarts forks.
@@ -12,6 +12,7 @@ exports.createAddonSettingsProvider = createAddonSettingsProvider;
12
12
  * panels went empty after the UDS migration; that path is gone.
13
13
  */
14
14
  const zod_1 = require("zod");
15
+ const ScopedValuesAnswer = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
15
16
  const DeclaredKeysAnswer = zod_1.z.object({ keys: zod_1.z.array(zod_1.z.string()) });
16
17
  const UnsetKeysAnswer = zod_1.z.object({
17
18
  removed: zod_1.z.array(zod_1.z.string()),
@@ -104,6 +105,62 @@ function createAddonSettingsProvider(deps) {
104
105
  }
105
106
  return forkedUpdate(input.addonId, 'updateGlobalSettings', { patch: input.patch, ...(input.nodeId ? { nodeId: input.nodeId } : {}) }, input.nodeId);
106
107
  },
108
+ async getScopedSettings(input) {
109
+ if (gateway.isInProcess(input.addonId, input.nodeId)) {
110
+ const addon = getAddon(input.addonId);
111
+ if (!addon || typeof addon.getScopedSettings !== 'function')
112
+ return null;
113
+ const result = await addon.getScopedSettings(input.scope, input.cap, input.nodeId);
114
+ return result ? reshapeForOutput(result) : null;
115
+ }
116
+ return forkedGet(input.addonId, 'getScopedSettings', {
117
+ scope: input.scope,
118
+ cap: input.cap,
119
+ ...(input.nodeId ? { nodeId: input.nodeId } : {}),
120
+ }, input.nodeId);
121
+ },
122
+ async updateScopedSettings(input) {
123
+ if (gateway.isInProcess(input.addonId, input.nodeId)) {
124
+ const addon = getAddon(input.addonId);
125
+ if (!addon || typeof addon.updateScopedSettings !== 'function') {
126
+ throw new Error(`Addon "${input.addonId}" does not implement updateScopedSettings`);
127
+ }
128
+ await addon.updateScopedSettings(input.scope, input.cap, input.patch, input.nodeId);
129
+ return { success: true };
130
+ }
131
+ return forkedUpdate(input.addonId, 'updateScopedSettings', {
132
+ scope: input.scope,
133
+ cap: input.cap,
134
+ patch: input.patch,
135
+ ...(input.nodeId ? { nodeId: input.nodeId } : {}),
136
+ }, input.nodeId);
137
+ },
138
+ async readScopedValues(input) {
139
+ try {
140
+ if (gateway.isInProcess(input.addonId, input.nodeId)) {
141
+ const addon = getAddon(input.addonId);
142
+ if (!addon || typeof addon.readScopedValues !== 'function')
143
+ return null;
144
+ return (await addon.readScopedValues(input.scope, input.cap, input.nodeId)) ?? null;
145
+ }
146
+ const raw = await gateway.callForked(input.addonId, {
147
+ target: 'settings',
148
+ method: 'readScopedValues',
149
+ args: {
150
+ scope: input.scope,
151
+ cap: input.cap,
152
+ ...(input.nodeId ? { nodeId: input.nodeId } : {}),
153
+ },
154
+ }, input.nodeId);
155
+ const parsed = ScopedValuesAnswer.safeParse(raw);
156
+ return parsed.success ? parsed.data : null;
157
+ }
158
+ catch (err) {
159
+ if (isServiceNotFoundError(err))
160
+ return null;
161
+ throw err;
162
+ }
163
+ },
107
164
  async getIntegrationSettings(input) {
108
165
  if (gateway.isInProcess(input.addonId, input.nodeId)) {
109
166
  const addon = getAddon(input.addonId);
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HeldBackAddons = void 0;
4
3
  exports.recordBootHealth = recordBootHealth;
5
4
  function recordBootHealth(input) {
6
5
  for (const [id, entry] of input.entries) {
@@ -8,35 +7,8 @@ function recordBootHealth(input) {
8
7
  input.monitor.recordSuccess(entry.packageName, id);
9
8
  continue;
10
9
  }
11
- const reason = input.heldBack.get(id);
12
- if (reason !== undefined) {
13
- input.monitor.recordHeldBack(entry.packageName, reason, id);
14
- continue;
15
- }
16
10
  // The catch handlers of Phase 1/2 do not carry the error forward, so a generic one is
17
11
  // synthesized; the real error is in the addon log.
18
12
  input.monitor.recordFailure(entry.packageName, new Error(`Addon "${id}" failed to initialize — see addon logs for details`), id);
19
13
  }
20
14
  }
21
- /**
22
- * The ids the spawn gate currently holds back, with the gate's reason. Each gate
23
- * run over a set of ids replaces what was held for THOSE ids (an addon the gate
24
- * now lets through is released) and leaves every other id alone.
25
- */
26
- class HeldBackAddons {
27
- reasons = new Map();
28
- track(addonIds, run) {
29
- for (const id of addonIds)
30
- this.reasons.delete(id);
31
- return run((id, reason) => {
32
- this.reasons.set(id, reason);
33
- });
34
- }
35
- has(addonId) {
36
- return this.reasons.has(addonId);
37
- }
38
- asMap() {
39
- return this.reasons;
40
- }
41
- }
42
- exports.HeldBackAddons = HeldBackAddons;
@@ -33,54 +33,31 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.spawnableAddonIds = spawnableAddonIds;
36
+ exports.reportHubAddonSupport = reportHubAddonSupport;
37
37
  exports.readHubStaleGateContext = readHubStaleGateContext;
38
38
  /**
39
- * The hub's spawn gate for a stale addon package (planning#447, D989).
39
+ * The hub's support judgement for an addon package (planning#447, D989, D1017).
40
40
  *
41
- * An agent already holds an addon back when its package is below what the
42
- * running server requires (`agent/stale-addon-gate.ts`, #346). The hub planned
43
- * every addon it found on disk, so after a server swap an addon built for the
44
- * previous framework was spawned, crashed, and burned the D6 respawn budget
45
- * before the post-swap update reached it. The hub now asks the SAME gate before
46
- * it plans a runner: a held-back addon stays unspawned, is logged with both
47
- * versions, and is not part of the plan.
41
+ * An addon whose package is below what the running server requires is spawned
42
+ * like any other and reported to the operator (`UnsupportedAddonTracker`); the
43
+ * hub asks the SAME judgement an agent does (`agent/stale-addon-gate.ts`).
44
+ * `readHubStaleGateContext` reads its facts for THIS hub from disk.
48
45
  */
49
46
  const path = __importStar(require("node:path"));
50
47
  const stale_addon_gate_js_1 = require("../../agent/stale-addon-gate.js");
51
48
  const addon_requirements_js_1 = require("./addon-requirements.js");
52
49
  const installed_addon_versions_js_1 = require("./installed-addon-versions.js");
53
- /** The ids of `addonIds` that may be spawned; every held-back one is logged. */
54
- function spawnableAddonIds(input) {
50
+ /** Judge the addons of `addonIds` the registry holds and report the verdict; nothing is held back. */
51
+ function reportHubAddonSupport(input) {
55
52
  const candidates = [];
56
- const known = new Set();
57
53
  for (const id of input.addonIds) {
58
54
  const candidate = input.candidateOf(id);
59
- if (candidate === undefined)
60
- continue;
61
- known.add(id);
62
- candidates.push(candidate);
55
+ if (candidate !== undefined)
56
+ candidates.push(candidate);
63
57
  }
64
- const { ready, deferred, unjudged } = (0, stale_addon_gate_js_1.gateStaleCandidates)(candidates, input.context);
65
- for (const line of unjudged)
66
- input.log(line);
67
- const readyIds = new Set(ready.map((c) => c.addonId));
68
- for (const d of deferred) {
69
- const isInfra = d.candidate.capabilities.some((c) => input.infraCapabilities.has(typeof c === 'string' ? c : c.name));
70
- if (isInfra) {
71
- // Holding a data-store or storage provider leaves the node with no storage at all.
72
- readyIds.add(d.candidate.addonId);
73
- input.log(`${d.reason} — infrastructure provider, SPAWNED ANYWAY so the node keeps its storage`);
74
- }
75
- else {
76
- input.log(d.reason);
77
- input.onDeferred?.(d.candidate.addonId, d.reason);
78
- }
79
- }
80
- // An id the registry cannot describe is not this gate's to judge: keep it, the plan drops it as before.
81
- return input.addonIds.filter((id) => readyIds.has(id) || !known.has(id));
58
+ (0, stale_addon_gate_js_1.reportSupport)(candidates, input.context, input.tracker, input.installedPackages);
82
59
  }
83
- /** The gate's facts for THIS hub, read from disk: the running server and the addons dir. */
60
+ /** The judgement's facts for THIS hub, read from disk: the running server and the addons dir. */
84
61
  function readHubStaleGateContext() {
85
62
  const dataDir = path.resolve(process.env.CAMSTACK_DATA ?? 'camstack-data');
86
63
  const addonsDir = process.env.CAMSTACK_ADDONS_DIR ?? path.resolve(dataDir, 'addons');
@@ -14,6 +14,7 @@ const instance_links_service_js_1 = require("../addon/instance-links.service.js"
14
14
  const hub_mesh_guard_js_1 = require("./hub-mesh-guard.js");
15
15
  const hub_server_version_js_1 = require("./hub-server-version.js");
16
16
  const cap_call_fn_js_1 = require("./cap-call-fn.js");
17
+ const runner_hosted_on_node_js_1 = require("./runner-hosted-on-node.js");
17
18
  const cap_route_authority_js_1 = require("./cap-route-authority.js");
18
19
  class MoleculerService {
19
20
  eventBus;
@@ -138,19 +139,7 @@ class MoleculerService {
138
139
  * registered hosts nothing.
139
140
  */
140
141
  isRunnerOnNode(nodeId, runnerId) {
141
- const nodes = this.nodeRegistry
142
- .listNodeIds()
143
- .filter((id) => id === nodeId || id.startsWith(`${nodeId}/`));
144
- if (nodes.includes(`${nodeId}/${runnerId}`))
145
- return true;
146
- for (const id of nodes) {
147
- for (const entry of this.nodeRegistry.getNodeManifest(id) ?? []) {
148
- const runner = this.runnerIdResolver?.(entry.addonId) ?? entry.addonId;
149
- if (entry.addonId === runnerId || runner === runnerId)
150
- return true;
151
- }
152
- }
153
- return false;
142
+ return (0, runner_hosted_on_node_js_1.isRunnerHostedByNode)(this.nodeRegistry, (addonId) => this.runnerIdResolver?.(addonId) ?? addonId, nodeId, runnerId);
154
143
  }
155
144
  get childRegistry() {
156
145
  return this.localChildRegistry;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRunnerHostedByNode = isRunnerHostedByNode;
4
+ /**
5
+ * Does `nodeId` (an agent) host the runner `runnerId`? Read from what the node itself
6
+ * registered: its manifest names the addons it runs, and an addon's runner is its
7
+ * `execution.group` or itself. A node that never registered hosts nothing.
8
+ *
9
+ * A stamp names a runner id (any cap) or, for the caps keyed by the ADDON (`records`,
10
+ * `migrations`), the member addon of a grouped runner; both resolve through the manifest.
11
+ */
12
+ function isRunnerHostedByNode(registry, runnerOfAddon, nodeId, runnerId) {
13
+ const nodes = registry.listNodeIds().filter((id) => id === nodeId || id.startsWith(`${nodeId}/`));
14
+ if (nodes.includes(`${nodeId}/${runnerId}`))
15
+ return true;
16
+ for (const id of nodes) {
17
+ for (const entry of registry.getNodeManifest(id) ?? []) {
18
+ if (entry.addonId === runnerId || runnerOfAddon(entry.addonId) === runnerId)
19
+ return true;
20
+ }
21
+ }
22
+ return false;
23
+ }
@@ -67,7 +67,7 @@ async function runRequiredAddonUpdates(deps) {
67
67
  }
68
68
  const reason = outcome.error ?? 'the update did not succeed';
69
69
  failed.push({ name: item.name, reason });
70
- deps.logger.warn('Required addon update failed — the addon stays held back', {
70
+ deps.logger.warn('Required addon update failed — the addon keeps running below the minimum', {
71
71
  meta: {
72
72
  name: item.name,
73
73
  installed: item.installed,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.789",
3
+ "version": "1.2.791",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -65,7 +65,16 @@
65
65
  "@camstack/addon-agent-ui"
66
66
  ],
67
67
  "requires": {
68
- "addons": {},
68
+ "addons": {
69
+ "@camstack/addon-admin-ui": ">=1.2.603",
70
+ "@camstack/addon-agent-ui": ">=1.2.338",
71
+ "@camstack/addon-decoder-nodeav": ">=1.2.148",
72
+ "@camstack/addon-export-alexa": ">=1.2.188",
73
+ "@camstack/addon-export-hap": ">=1.2.197",
74
+ "@camstack/addon-pipeline": ">=1.2.645",
75
+ "@camstack/addon-post-analysis": ">=1.2.678",
76
+ "@camstack/addon-provider-homeassistant": ">=1.2.671"
77
+ },
69
78
  "wrapper": {
70
79
  "desktop": ">=0.0.1",
71
80
  "image": ">=0.0.1"
@@ -73,19 +82,19 @@
73
82
  }
74
83
  },
75
84
  "dependencies": {
76
- "@camstack/addon-admin-ui": "1.2.601",
77
- "@camstack/addon-agent-ui": "1.2.336",
78
- "@camstack/addon-auth": "1.2.177",
85
+ "@camstack/addon-admin-ui": "1.2.603",
86
+ "@camstack/addon-agent-ui": "1.2.338",
87
+ "@camstack/addon-auth": "1.2.178",
79
88
  "@camstack/addon-benchmark": "1.2.312",
80
- "@camstack/addon-decoder-nodeav": "1.2.147",
81
- "@camstack/addon-notifiers": "1.2.632",
82
- "@camstack/addon-pipeline": "1.2.644",
89
+ "@camstack/addon-decoder-nodeav": "1.2.148",
90
+ "@camstack/addon-notifiers": "1.2.633",
91
+ "@camstack/addon-pipeline": "1.2.645",
83
92
  "@camstack/addon-pipeline-orchestrator": "1.2.664",
84
- "@camstack/addon-post-analysis": "1.2.676",
93
+ "@camstack/addon-post-analysis": "1.2.678",
85
94
  "@camstack/develop": "0.1.48",
86
95
  "@camstack/sdk": "1.2.156",
87
- "@camstack/types": "1.2.514",
88
- "@camstack/ui-library": "1.2.394",
96
+ "@camstack/types": "1.2.516",
97
+ "@camstack/ui-library": "1.2.396",
89
98
  "@fastify/compress": "^9.0.0",
90
99
  "@fastify/cookie": "^11.0.2",
91
100
  "@fastify/cors": "^11.2.0",
@@ -11442,6 +11442,14 @@ function toSerializableRoute(route) {
11442
11442
  ...typeof rateLimit === "string" ? { rateLimit } : {}
11443
11443
  };
11444
11444
  }
11445
+ /** A scoped-settings call names its scope and capability; a call without them is a bug. */
11446
+ function requireScopedTarget(addonId, method, args) {
11447
+ if (args.scope === void 0 || args.cap === void 0) throw new Error(`child-addon-call: addon "${addonId}" ${method} needs scope and cap`);
11448
+ return {
11449
+ scope: args.scope,
11450
+ cap: args.cap
11451
+ };
11452
+ }
11445
11453
  /**
11446
11454
  * Dispatch a `target: 'settings'` addon-call to the loaded addon instance.
11447
11455
  * Mirrors the (removed) `<addonId>.settings.<method>` Moleculer action. The
@@ -11457,6 +11465,20 @@ async function dispatchSettings(addon, addonId, method, args) {
11457
11465
  if (typeof addon.updateGlobalSettingsAsOperator === "function") await addon.updateGlobalSettingsAsOperator(args.patch ?? {}, args.nodeId);
11458
11466
  else await addon.updateGlobalSettings(args.patch ?? {}, args.nodeId);
11459
11467
  return { success: true };
11468
+ case "getScopedSettings": {
11469
+ const { scope, cap } = requireScopedTarget(addonId, method, args);
11470
+ return typeof addon.getScopedSettings === "function" ? await addon.getScopedSettings(scope, cap, args.nodeId) ?? null : null;
11471
+ }
11472
+ case "updateScopedSettings": {
11473
+ const { scope, cap } = requireScopedTarget(addonId, method, args);
11474
+ if (typeof addon.updateScopedSettings !== "function") throw new Error(`child-addon-call: addon "${addonId}" does not implement updateScopedSettings`);
11475
+ await addon.updateScopedSettings(scope, cap, args.patch ?? {}, args.nodeId);
11476
+ return { success: true };
11477
+ }
11478
+ case "readScopedValues": {
11479
+ const { scope, cap } = requireScopedTarget(addonId, method, args);
11480
+ return typeof addon.readScopedValues === "function" ? await addon.readScopedValues(scope, cap, args.nodeId) ?? null : null;
11481
+ }
11460
11482
  case "getIntegrationSettings": return typeof addon.getIntegrationSettings === "function" ? await addon.getIntegrationSettings(args.nodeId) ?? null : null;
11461
11483
  case "getIntegrationFormSchema": return typeof addon.getIntegrationFormSchema === "function" && args.instance !== void 0 ? await addon.getIntegrationFormSchema(args.instance, args.nodeId) ?? null : typeof addon.getGlobalSettings === "function" ? await addon.getGlobalSettings(void 0, void 0, args.nodeId) ?? null : null;
11462
11484
  case "getDeviceSettings": return typeof addon.getDeviceSettings === "function" && typeof args.deviceId === "number" ? await addon.getDeviceSettings(args.deviceId) ?? null : null;
@@ -11387,6 +11387,14 @@ function toSerializableRoute(route) {
11387
11387
  ...typeof rateLimit === "string" ? { rateLimit } : {}
11388
11388
  };
11389
11389
  }
11390
+ /** A scoped-settings call names its scope and capability; a call without them is a bug. */
11391
+ function requireScopedTarget(addonId, method, args) {
11392
+ if (args.scope === void 0 || args.cap === void 0) throw new Error(`child-addon-call: addon "${addonId}" ${method} needs scope and cap`);
11393
+ return {
11394
+ scope: args.scope,
11395
+ cap: args.cap
11396
+ };
11397
+ }
11390
11398
  /**
11391
11399
  * Dispatch a `target: 'settings'` addon-call to the loaded addon instance.
11392
11400
  * Mirrors the (removed) `<addonId>.settings.<method>` Moleculer action. The
@@ -11402,6 +11410,20 @@ async function dispatchSettings(addon, addonId, method, args) {
11402
11410
  if (typeof addon.updateGlobalSettingsAsOperator === "function") await addon.updateGlobalSettingsAsOperator(args.patch ?? {}, args.nodeId);
11403
11411
  else await addon.updateGlobalSettings(args.patch ?? {}, args.nodeId);
11404
11412
  return { success: true };
11413
+ case "getScopedSettings": {
11414
+ const { scope, cap } = requireScopedTarget(addonId, method, args);
11415
+ return typeof addon.getScopedSettings === "function" ? await addon.getScopedSettings(scope, cap, args.nodeId) ?? null : null;
11416
+ }
11417
+ case "updateScopedSettings": {
11418
+ const { scope, cap } = requireScopedTarget(addonId, method, args);
11419
+ if (typeof addon.updateScopedSettings !== "function") throw new Error(`child-addon-call: addon "${addonId}" does not implement updateScopedSettings`);
11420
+ await addon.updateScopedSettings(scope, cap, args.patch ?? {}, args.nodeId);
11421
+ return { success: true };
11422
+ }
11423
+ case "readScopedValues": {
11424
+ const { scope, cap } = requireScopedTarget(addonId, method, args);
11425
+ return typeof addon.readScopedValues === "function" ? await addon.readScopedValues(scope, cap, args.nodeId) ?? null : null;
11426
+ }
11405
11427
  case "getIntegrationSettings": return typeof addon.getIntegrationSettings === "function" ? await addon.getIntegrationSettings(args.nodeId) ?? null : null;
11406
11428
  case "getIntegrationFormSchema": return typeof addon.getIntegrationFormSchema === "function" && args.instance !== void 0 ? await addon.getIntegrationFormSchema(args.instance, args.nodeId) ?? null : typeof addon.getGlobalSettings === "function" ? await addon.getGlobalSettings(void 0, void 0, args.nodeId) ?? null : null;
11407
11429
  case "getDeviceSettings": return typeof addon.getDeviceSettings === "function" && typeof args.deviceId === "number" ? await addon.getDeviceSettings(args.deviceId) ?? null : null;
@@ -1,4 +1,4 @@
1
- import { Ns as defineRecordKinds } from "./dist-BsQA6-0i.mjs";
1
+ import { Is as defineRecordKinds } from "./dist-CPUbgRkb.mjs";
2
2
  import { C as backdatedNotBefore, S as withUtcTimeEncoding, _ as NameConstraints, a as KeyUsageFlags, c as Pkcs10CertificateRequest, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, g as GeneralSubtrees, h as GeneralSubtree, i as Extension, l as Pkcs10CertificateRequestGenerator, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension, u as SubjectAlternativeNameExtension, v as GeneralName, x as AsnConvert } from "./x509.es-BRiJgOvu.mjs";
3
3
  import { z } from "zod";
4
4
  import { X509Certificate, createHash, createPrivateKey, randomBytes, webcrypto } from "node:crypto";
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-BRI-Mwx0.js");
2
+ const require_dist = require("./dist-Ddkk4Dqq.js");
3
3
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
4
4
  let zod = require("zod");
5
5
  let node_crypto = require("node:crypto");
@@ -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_dist = require("../../dist-BRI-Mwx0.js");
6
+ const require_dist = require("../../dist-Ddkk4Dqq.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_fs = require("node:fs");
@@ -1,4 +1,4 @@
1
- import { Ec as EventCategory, Lo as BaseAddon, Tc as errMsg, mn as addonPagesCapability } from "../../dist-BsQA6-0i.mjs";
1
+ import { Bo as BaseAddon, Oc as errMsg, hn as addonPagesCapability, kc as EventCategory } from "../../dist-CPUbgRkb.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as fs$1 from "node:fs";
@@ -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_dist = require("../../dist-BRI-Mwx0.js");
6
+ const require_dist = require("../../dist-Ddkk4Dqq.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_fs = require("node:fs");
@@ -1,4 +1,4 @@
1
- import { Ec as EventCategory, Lo as BaseAddon, Tc as errMsg, gn as addonWidgetsCapability } from "../../dist-BsQA6-0i.mjs";
1
+ import { Bo as BaseAddon, Oc as errMsg, _n as addonWidgetsCapability, kc as EventCategory } from "../../dist-CPUbgRkb.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as fs$1 from "node:fs";
@@ -90,6 +90,14 @@ export declare class AlertCenterAddon extends BaseAddon<AlertCenterConfig> {
90
90
  */
91
91
  private handleAddonLoadRecovered;
92
92
  /**
93
+ * AddonUnsupportedVersion — an addon RUNS although its installed package is
94
+ * below what the server requires (D1017). One card per node and package, keyed
95
+ * `addon-unsupported:<nodeId>:<packageName>` so the resolve edge dismisses it.
96
+ */
97
+ private handleAddonUnsupportedVersion;
98
+ /** The package reached a supported version — drop its unsupported-version card. */
99
+ private handleAddonUnsupportedResolved;
100
+ /**
93
101
  * SystemLivenessFailed — a liveness invariant of this node is false.
94
102
  *
95
103
  * `findingId` is already stable across ticks (`liveness:no-devices`,