@camstack/server 1.2.803 → 1.2.805

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 (113) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/agent/main.js +1 -1
  3. package/dist/api/core/addon-settings.router.js +2 -2
  4. package/dist/api/trpc/device-config-secret-redaction.js +3 -5
  5. package/dist/api/trpc/generated-cap-routers.js +10 -24
  6. package/dist/api/trpc/localized-schema-paths.js +0 -2
  7. package/dist/core/addon/addon-registry.service.js +4 -4
  8. package/dist/core/addon/addon-settings-provider.js +2 -49
  9. package/package.json +34 -15
  10. package/system/dist/addon-runner.js +2 -9
  11. package/system/dist/addon-runner.mjs +2 -9
  12. package/system/dist/{agent-https-DtYiXPGm.js → agent-https-CuChFRA2.js} +1 -1
  13. package/system/dist/{agent-https-BRfJO9ZR.mjs → agent-https-DS4b0ucn.mjs} +1 -1
  14. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  15. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  16. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  17. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  18. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  19. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  20. package/system/dist/builtins/autotrack/index.js +1 -1
  21. package/system/dist/builtins/autotrack/index.mjs +1 -1
  22. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  23. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  24. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  25. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  26. package/system/dist/builtins/camera-grid/index.js +1 -1
  27. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  28. package/system/dist/builtins/composer/composed-device.d.ts +5 -0
  29. package/system/dist/builtins/composer/composer.addon.js +39 -4
  30. package/system/dist/builtins/composer/composer.addon.mjs +39 -4
  31. package/system/dist/builtins/composer/composer.d.ts +13 -0
  32. package/system/dist/builtins/console-logging/index.js +1 -1
  33. package/system/dist/builtins/console-logging/index.mjs +1 -1
  34. package/system/dist/builtins/core-blocks/core-blocks.addon.js +4 -5
  35. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +4 -5
  36. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  37. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  38. package/system/dist/builtins/device-manager/device-alias-actions.d.ts +45 -0
  39. package/system/dist/builtins/device-manager/device-manager.addon.js +958 -768
  40. package/system/dist/builtins/device-manager/device-manager.addon.mjs +958 -768
  41. package/system/dist/builtins/device-manager/device-meta-types.d.ts +3 -0
  42. package/system/dist/builtins/device-manager/device-row-store.d.ts +8 -0
  43. package/system/dist/builtins/device-manager/device-template/mirror-resolver.d.ts +19 -0
  44. package/system/dist/builtins/device-manager/device-template/nunjucks-internals.d.ts +53 -0
  45. package/system/dist/builtins/device-manager/device-template/template-filters.d.ts +28 -0
  46. package/system/dist/builtins/device-manager/device-template/template-grammar.d.ts +43 -0
  47. package/system/dist/builtins/device-manager/device-template/template-protocol.d.ts +33 -0
  48. package/system/dist/builtins/device-manager/device-template/template-renderer.d.ts +54 -0
  49. package/system/dist/builtins/device-manager/device-template/template-worker.d.ts +1 -0
  50. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  51. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  52. package/system/dist/builtins/keychain/index.js +4 -4
  53. package/system/dist/builtins/keychain/index.mjs +4 -4
  54. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  55. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  56. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  57. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  58. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  59. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  60. package/system/dist/builtins/loki-logging/index.js +1 -1
  61. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  62. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  63. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  64. package/system/dist/builtins/platform-probe/index.js +1 -1
  65. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  66. package/system/dist/builtins/record-entries/index.js +1 -1
  67. package/system/dist/builtins/record-entries/index.mjs +1 -1
  68. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  69. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  70. package/system/dist/builtins/snapshot/index.js +2 -2
  71. package/system/dist/builtins/snapshot/index.mjs +2 -2
  72. package/system/dist/builtins/snapshot/snapshot.addon.d.ts +1 -1
  73. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  74. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  75. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  76. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  77. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  78. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  79. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  80. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  81. package/system/dist/builtins/system-config/bootstrap-form-actions.d.ts +4 -4
  82. package/system/dist/builtins/system-config/system-config.addon.js +7 -7
  83. package/system/dist/builtins/system-config/system-config.addon.mjs +7 -7
  84. package/system/dist/builtins/winston-logging/index.js +1 -1
  85. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  86. package/system/dist/{capture-engine-BQ08XTnZ.js → capture-engine-Byc5Fkp0.js} +1 -1
  87. package/system/dist/{capture-engine-BFgeAHa9.mjs → capture-engine-CnVIcnyN.mjs} +1 -1
  88. package/system/dist/{composition-sources-DkOfzgpS.mjs → composition-sources-BhM6G9QT.mjs} +1 -1
  89. package/system/dist/{composition-sources-DNHNUvTr.js → composition-sources-BxK6ttP9.js} +1 -1
  90. package/system/dist/{constants-D5CG3Gvc.js → constants--xo6Q-KA.js} +1 -1
  91. package/system/dist/{constants-GCrIKhD_.mjs → constants-Bf1PEHRU.mjs} +1 -1
  92. package/system/dist/{device-ca-Dk2sx_18.mjs → device-ca-Do0-HV_h.mjs} +1 -1
  93. package/system/dist/{device-ca-DgZeLVC1.js → device-ca-Uq5KGFSq.js} +1 -1
  94. package/system/dist/device-template-worker.js +7289 -0
  95. package/system/dist/device-template-worker.mjs +7287 -0
  96. package/system/dist/{dist-D5nGm8Sd.js → dist-2SHQaxaS.js} +631 -618
  97. package/system/dist/{dist-ze-qVU7x.mjs → dist-CogtCQxu.mjs} +608 -619
  98. package/system/dist/file-host-worker.js +1 -1
  99. package/system/dist/file-host-worker.mjs +1 -1
  100. package/system/dist/{hub-mdns-ciao-D4g9qsNL.js → hub-mdns-ciao-DqPrLiYH.js} +2 -2
  101. package/system/dist/{hub-mdns-ciao-DD2QP3w5.mjs → hub-mdns-ciao-aFHCKrif.mjs} +2 -2
  102. package/system/dist/index.js +28 -48
  103. package/system/dist/index.mjs +28 -48
  104. package/system/dist/kernel/moleculer/addon-service-factory.d.ts +2 -3
  105. package/system/dist/kernel/transport/child-cap-protocol.d.ts +2 -2
  106. package/system/dist/kernel/transport/parent-unowned-call.d.ts +1 -1
  107. package/system/dist/{legacy-integration-rows-door-MRr8Ncb_.js → legacy-integration-rows-door-Bz8rivxI.js} +1 -1
  108. package/system/dist/{legacy-integration-rows-door-BvEFQrAa.mjs → legacy-integration-rows-door-CiuxDLoc.mjs} +1 -1
  109. package/system/dist/{restore-archive-aG7OlQNo.js → restore-archive-D-3wmHDq.js} +1 -1
  110. package/system/dist/{restore-archive-DBc5sNQS.mjs → restore-archive-PlBC2NwT.mjs} +1 -1
  111. package/system/dist/{wal-maintenance-C-ddHy-q.js → wal-maintenance-BTR55y--.js} +0 -0
  112. package/system/dist/{wal-maintenance-vQHsOLGg.mjs → wal-maintenance-jrhYTCn2.mjs} +0 -0
  113. package/system/package.json +1 -1
@@ -3,9 +3,9 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D5nGm8Sd.js");
7
- const require_composition_sources = require("../../composition-sources-DNHNUvTr.js");
8
- const require_capture_engine = require("../../capture-engine-BQ08XTnZ.js");
6
+ const require_dist = require("../../dist-2SHQaxaS.js");
7
+ const require_composition_sources = require("../../composition-sources-BxK6ttP9.js");
8
+ const require_capture_engine = require("../../capture-engine-Byc5Fkp0.js");
9
9
  const require_retention = require("../../retention-BNONb5X_.js");
10
10
  let zod = require("zod");
11
11
  //#region src/builtins/composer/actuator-invoke.ts
@@ -159,13 +159,20 @@ function sliceBoolean(slice, field) {
159
159
  }
160
160
  var ComposedDevice = class extends require_dist.BaseDevice {
161
161
  sharedFeatures = [];
162
+ /** Features of caps bound on the device by others (a wrapper): derived from its bindings, never listed here. */
163
+ boundFeatures = [];
162
164
  extraCaps = /* @__PURE__ */ new Set();
163
165
  /** Whether this device's tank is also a `water` consumable (derived, never bound). */
164
166
  derivesWater;
165
167
  /** The `consumables` items the composition last wrote — the derived water item is added to these. */
166
168
  composedItems = [];
167
169
  get features() {
168
- return this.sharedFeatures;
170
+ return [...new Set([...this.sharedFeatures, ...this.boundFeatures])];
171
+ }
172
+ syncBoundFeatures(features) {
173
+ if (features.length === this.boundFeatures.length && features.every((feature) => this.boundFeatures.includes(feature))) return;
174
+ this.boundFeatures = [...features];
175
+ this.refreshFeatures();
169
176
  }
170
177
  constructor(ctx, type, caps) {
171
178
  super(ctx, COMPOSED_DEVICE_CONFIG_SCHEMA, { type });
@@ -4482,6 +4489,22 @@ var Composer = class {
4482
4489
  this.grafts.onBindingsChanged(data);
4483
4490
  this.dispatch(await this.deps.tracker.onBindingsChanged(data.deviceId, data.capName, data.reason));
4484
4491
  await this.chained(() => this.actuators?.onMemberBindings(data.deviceId));
4492
+ await this.syncBoundFeatures([...this.live.keys()].filter((blockId) => this.composed.idOf(require_dist.composedDeviceStableId(blockId)) === data.deviceId));
4493
+ }
4494
+ /**
4495
+ * A composed device carries the features its BOUND caps stand for — the same
4496
+ * flags a driver sets on a regular device. A cap bound later by a wrapper
4497
+ * (`timed-run`) reaches it here; a read that fails changes nothing (D49).
4498
+ */
4499
+ async syncBoundFeatures(blockIds) {
4500
+ const read = this.deps.boundCapNames;
4501
+ if (read === void 0) return;
4502
+ for (const blockId of blockIds) {
4503
+ const device = this.composed.get(require_dist.composedDeviceStableId(blockId));
4504
+ if (device === null || device.syncBoundFeatures === void 0) continue;
4505
+ const caps = await read(device.id);
4506
+ if (caps !== null) device.syncBoundFeatures(require_dist.featuresOfBoundCaps(caps));
4507
+ }
4485
4508
  }
4486
4509
  shutdown() {
4487
4510
  for (const entry of this.live.values()) entry.runtime?.stop();
@@ -4619,6 +4642,7 @@ var Composer = class {
4619
4642
  await this.syncSources(rebuilt);
4620
4643
  this.forwards?.sync(forwardBlocksOf(input.blocks));
4621
4644
  await this.syncExtensionFeatures(forwardBlocksOf(input.blocks));
4645
+ await this.syncBoundFeatures(input.blocks.map((block) => block.id));
4622
4646
  await this.actuators?.sync(input.blocks.flatMap((block) => {
4623
4647
  const helper = block.composition.helper;
4624
4648
  if (helper !== void 0 && helper.kind !== "group") return [];
@@ -6156,6 +6180,17 @@ var ComposerAddon = class extends require_dist.BaseAddon {
6156
6180
  ...args
6157
6181
  });
6158
6182
  },
6183
+ boundCapNames: async (deviceId) => {
6184
+ try {
6185
+ return (await api.deviceManager.getBindings.query({ deviceId })).entries.map((entry) => entry.capName);
6186
+ } catch (err) {
6187
+ this.ctx.logger.warn("composer: the bindings of a composed device could not be read", {
6188
+ tags: { deviceId },
6189
+ meta: { error: require_dist.errMsg(err) }
6190
+ });
6191
+ return null;
6192
+ }
6193
+ },
6159
6194
  extensionFeatures: async (deviceId) => {
6160
6195
  try {
6161
6196
  return require_dist.mediaPlayerFeaturesOfRoles((await api.remote.listCommands.query({ deviceId })).commands.map((c) => c.role));
@@ -1,6 +1,6 @@
1
- import { $s as isReadingQuantity, Ac as DeviceType, Ar as fanControlCapability, Bi as petFountainCapability, Bn as climateControlCapability, Bo as statisticCadenceMs, Br as groupTemplate, Co as compositionItemFieldPath, Da as sharedColorModes, Dn as brightnessCapability, Do as disarmRoseMemory, Ea as sharedActuatorMethods, Ei as motionCapability, Eo as createStatefulExpressionMemory, Fo as nextLocalMidnight, Gn as composerCapability, Hn as colorCapability, Io as openReset, J as DeclaredDevices, Jn as consumablesCapability, Kn as compositionFieldKey, Lo as openStatistic, Mc as EventCategory, Mo as integrateReading, No as isForwardInputRef, Nr as featureForwards, Oo as evaluateDerivative, Or as expressionContainsBuiltinCall, Po as isHistoryHelper, Ps as createEvent, Pt as PetFountainStatusSchema, Ri as parseColorInput, Ro as planResetTier, So as compositionFeatureEnabled, Ta as sharedActuatorFeatures, To as compositionSourceKey, Ui as planComposition, Uo as BaseAddon, Va as switchCapability, Vi as petFountainWaterItem, Vo as toExpressionValue, Xi as processTimeZoneOr, _a as runFanOut, _o as MINUTE_MS, at as FanDirectionSchema, bo as composedDeviceRef, di as lockControlCapability, eo as valveCapability, er as coverCapability, fo as DEFAULT_HISTORY_RETENTION, h as BaseDevice, ho as HOUR_MS, i as ACTUATOR_TEMPLATE_IDS, jc as errMsg, jo as historyRetentionFromSettings, jr as fanOutTargets, k as ConsumableItemSchema, kn as buildCapabilityLookup, ko as evaluateStatistic, lo as COMPOSER_ADDON_ID, lt as GroupCommandResultSchema, mo as HISTORY_SLOW_MS, mt as HvacModeSchema, ni as kebabToCamel, oo as withDefaultRunning, pa as resolveMutate, po as HISTORY_FAST_MS, r as ACTUATOR_METHODS, s as ALL_CAPABILITY_DEFINITIONS, sr as declaredSeriesKind, vi as mediaPlayerCapability, wo as compositionSliceKey, wr as evaluateCompositionField, x as COMPOSED_ITEM_FIXED_FIELDS, xi as methodRefusal, xo as composedDeviceStableId, yi as mediaPlayerFeaturesOfRoles, yo as cloneStatefulExpressionMemory, zo as planStatisticTier, zr as groupCommandsCapability } from "../../dist-ze-qVU7x.mjs";
2
- import { i as parseDeviceStateChanged, n as normalizedNativeOwner, r as isRecord$4 } from "../../composition-sources-DkOfzgpS.mjs";
3
- import { i as capSeriesKey } from "../../capture-engine-BFgeAHa9.mjs";
1
+ import { Ao as disarmRoseMemory, Bi as parseColorInput, Bo as openStatistic, Ci as methodRefusal, Co as composedDeviceRef, Da as sharedActuatorFeatures, Dn as brightnessCapability, Do as compositionSliceKey, Eo as compositionItemFieldPath, Fc as featuresOfBoundCaps, Fo as integrateReading, Gi as planComposition, Hi as petFountainCapability, Ho as planStatisticTier, Hr as groupTemplate, Ic as EventCategory, Io as isForwardInputRef, J as DeclaredDevices, Kn as composerCapability, Ko as BaseAddon, Lo as isHistoryHelper, Ls as createEvent, Mo as evaluateStatistic, Mr as fanOutTargets, Nc as DeviceType, Oa as sharedActuatorMethods, Oi as motionCapability, Oo as compositionSourceKey, Pc as errMsg, Po as historyRetentionFromSettings, Pr as featureForwards, Pt as PetFountainStatusSchema, Qi as processTimeZoneOr, Ro as nextLocalMidnight, So as cloneStatefulExpressionMemory, To as compositionFeatureEnabled, Tr as evaluateCompositionField, Ui as petFountainWaterItem, Un as colorCapability, Uo as statisticCadenceMs, Vn as climateControlCapability, Vo as planResetTier, Vr as groupCommandsCapability, Wa as switchCapability, Wo as toExpressionValue, Yn as consumablesCapability, _o as HISTORY_SLOW_MS, at as FanDirectionSchema, bi as mediaPlayerCapability, bo as MINUTE_MS, cr as declaredSeriesKind, fo as COMPOSER_ADDON_ID, go as HISTORY_FAST_MS, h as BaseDevice, ha as resolveMutate, ho as DEFAULT_HISTORY_RETENTION, i as ACTUATOR_TEMPLATE_IDS, ii as kebabToCamel, jo as evaluateDerivative, jr as fanControlCapability, k as ConsumableItemSchema, ka as sharedColorModes, kn as buildCapabilityLookup, ko as createStatefulExpressionMemory, kr as expressionContainsBuiltinCall, lo as withDefaultRunning, lt as GroupCommandResultSchema, mt as HvacModeSchema, nc as isReadingQuantity, pi as lockControlCapability, qn as compositionFieldKey, r as ACTUATOR_METHODS, ro as valveCapability, s as ALL_CAPABILITY_DEFINITIONS, tr as coverCapability, vo as HOUR_MS, wo as composedDeviceStableId, x as COMPOSED_ITEM_FIXED_FIELDS, xi as mediaPlayerFeaturesOfRoles, ya as runFanOut, zo as openReset } from "../../dist-CogtCQxu.mjs";
2
+ import { i as parseDeviceStateChanged, n as normalizedNativeOwner, r as isRecord$4 } from "../../composition-sources-BhM6G9QT.mjs";
3
+ import { i as capSeriesKey } from "../../capture-engine-CnVIcnyN.mjs";
4
4
  import { i as DAY_MS, t as DEFAULT_RETENTION } from "../../retention-B9l9TnGE.mjs";
5
5
  import { z } from "zod";
6
6
  //#region src/builtins/composer/actuator-invoke.ts
@@ -154,13 +154,20 @@ function sliceBoolean(slice, field) {
154
154
  }
155
155
  var ComposedDevice = class extends BaseDevice {
156
156
  sharedFeatures = [];
157
+ /** Features of caps bound on the device by others (a wrapper): derived from its bindings, never listed here. */
158
+ boundFeatures = [];
157
159
  extraCaps = /* @__PURE__ */ new Set();
158
160
  /** Whether this device's tank is also a `water` consumable (derived, never bound). */
159
161
  derivesWater;
160
162
  /** The `consumables` items the composition last wrote — the derived water item is added to these. */
161
163
  composedItems = [];
162
164
  get features() {
163
- return this.sharedFeatures;
165
+ return [...new Set([...this.sharedFeatures, ...this.boundFeatures])];
166
+ }
167
+ syncBoundFeatures(features) {
168
+ if (features.length === this.boundFeatures.length && features.every((feature) => this.boundFeatures.includes(feature))) return;
169
+ this.boundFeatures = [...features];
170
+ this.refreshFeatures();
164
171
  }
165
172
  constructor(ctx, type, caps) {
166
173
  super(ctx, COMPOSED_DEVICE_CONFIG_SCHEMA, { type });
@@ -4477,6 +4484,22 @@ var Composer = class {
4477
4484
  this.grafts.onBindingsChanged(data);
4478
4485
  this.dispatch(await this.deps.tracker.onBindingsChanged(data.deviceId, data.capName, data.reason));
4479
4486
  await this.chained(() => this.actuators?.onMemberBindings(data.deviceId));
4487
+ await this.syncBoundFeatures([...this.live.keys()].filter((blockId) => this.composed.idOf(composedDeviceStableId(blockId)) === data.deviceId));
4488
+ }
4489
+ /**
4490
+ * A composed device carries the features its BOUND caps stand for — the same
4491
+ * flags a driver sets on a regular device. A cap bound later by a wrapper
4492
+ * (`timed-run`) reaches it here; a read that fails changes nothing (D49).
4493
+ */
4494
+ async syncBoundFeatures(blockIds) {
4495
+ const read = this.deps.boundCapNames;
4496
+ if (read === void 0) return;
4497
+ for (const blockId of blockIds) {
4498
+ const device = this.composed.get(composedDeviceStableId(blockId));
4499
+ if (device === null || device.syncBoundFeatures === void 0) continue;
4500
+ const caps = await read(device.id);
4501
+ if (caps !== null) device.syncBoundFeatures(featuresOfBoundCaps(caps));
4502
+ }
4480
4503
  }
4481
4504
  shutdown() {
4482
4505
  for (const entry of this.live.values()) entry.runtime?.stop();
@@ -4614,6 +4637,7 @@ var Composer = class {
4614
4637
  await this.syncSources(rebuilt);
4615
4638
  this.forwards?.sync(forwardBlocksOf(input.blocks));
4616
4639
  await this.syncExtensionFeatures(forwardBlocksOf(input.blocks));
4640
+ await this.syncBoundFeatures(input.blocks.map((block) => block.id));
4617
4641
  await this.actuators?.sync(input.blocks.flatMap((block) => {
4618
4642
  const helper = block.composition.helper;
4619
4643
  if (helper !== void 0 && helper.kind !== "group") return [];
@@ -6151,6 +6175,17 @@ var ComposerAddon = class extends BaseAddon {
6151
6175
  ...args
6152
6176
  });
6153
6177
  },
6178
+ boundCapNames: async (deviceId) => {
6179
+ try {
6180
+ return (await api.deviceManager.getBindings.query({ deviceId })).entries.map((entry) => entry.capName);
6181
+ } catch (err) {
6182
+ this.ctx.logger.warn("composer: the bindings of a composed device could not be read", {
6183
+ tags: { deviceId },
6184
+ meta: { error: errMsg(err) }
6185
+ });
6186
+ return null;
6187
+ }
6188
+ },
6154
6189
  extensionFeatures: async (deviceId) => {
6155
6190
  try {
6156
6191
  return mediaPlayerFeaturesOfRoles((await api.remote.listCommands.query({ deviceId })).commands.map((c) => c.role));
@@ -128,6 +128,13 @@ export interface ComposerDeps {
128
128
  * Absent in tests that predate the `extension` command.
129
129
  */
130
130
  readonly extensionFeatures?: (deviceId: number) => Promise<readonly DeviceFeature[] | null>;
131
+ /**
132
+ * Every cap bound on a device, whoever serves it (a wrapper included), or null
133
+ * when it could not be read (the device keeps its features, D49). A composed
134
+ * device's features are the ones these caps stand for (`featuresOfBoundCaps`).
135
+ * Absent in tests that predate it.
136
+ */
137
+ readonly boundCapNames?: (deviceId: number) => Promise<readonly string[] | null>;
131
138
  }
132
139
  /** The configured zone, else the process zone when usable, else `UTC` (an empty `TZ` reads `Etc/Unknown`). */
133
140
  export declare function resolveComposerTimeZone(configured: string | undefined, logger: IScopedLogger): string;
@@ -171,6 +178,12 @@ export declare class Composer {
171
178
  onNativeChanged(data: NativeShadowChangedData): Promise<void>;
172
179
  onDeviceUnregistered(deviceId: number): Promise<void>;
173
180
  onBindingsChanged(data: DeviceBindingsChangedData): Promise<void>;
181
+ /**
182
+ * A composed device carries the features its BOUND caps stand for — the same
183
+ * flags a driver sets on a regular device. A cap bound later by a wrapper
184
+ * (`timed-run`) reaches it here; a read that fails changes nothing (D49).
185
+ */
186
+ private syncBoundFeatures;
174
187
  shutdown(): void;
175
188
  /**
176
189
  * A media player served by the `remote` extension reports nothing, so its
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D5nGm8Sd.js");
6
+ const require_dist = require("../../dist-2SHQaxaS.js");
7
7
  const require_formatter = require("../../formatter-xbxeV4GD.js");
8
8
  //#region src/builtins/console-logging/console-destination.ts
9
9
  var LEVEL_RANK = {
@@ -1,4 +1,4 @@
1
- import { Uo as BaseAddon, pi as logDestinationCapability } from "../../dist-ze-qVU7x.mjs";
1
+ import { Ko as BaseAddon, hi as logDestinationCapability } from "../../dist-CogtCQxu.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
3
3
  //#region src/builtins/console-logging/console-destination.ts
4
4
  var LEVEL_RANK = {
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-D5nGm8Sd.js");
3
+ const require_dist = require("../../dist-2SHQaxaS.js");
4
4
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
5
- const require_composition_sources = require("../../composition-sources-DNHNUvTr.js");
6
- const require_capture_engine = require("../../capture-engine-BQ08XTnZ.js");
5
+ const require_composition_sources = require("../../composition-sources-BxK6ttP9.js");
6
+ const require_capture_engine = require("../../capture-engine-Byc5Fkp0.js");
7
7
  const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
8
8
  const require_prefix_walk = require("../../prefix-walk-Dv6MLZlM.js");
9
9
  let zod = require("zod");
@@ -5354,8 +5354,7 @@ function hostOver(api) {
5354
5354
  capName: cap
5355
5355
  }),
5356
5356
  fetchStableIds: async () => {
5357
- const all = await need().deviceManager.listAll.query({ projection: "slim" });
5358
- return new Map(all.flatMap((d) => d.stableId === void 0 ? [] : [[d.stableId, d.id]]));
5357
+ return require_dist.stableIdMapOf(await need().deviceManager.listAll.query({ projection: "slim" }));
5359
5358
  },
5360
5359
  invokeCap: invokeCapOver(api)
5361
5360
  };
@@ -1,7 +1,7 @@
1
- import { $ as EMPTY_AUTOMATION_STATE, $a as validateSchedulerInput, $n as coreBlocksCapability, A as ControlStatusSchema, Ac as DeviceType$1, Ai as normalizeCoreBlockWrite, Ao as helperMembers, C as CORE_BLOCKS_ADDON_ID, Di as nextOccurrence, Et as MediaPlayerStatusSchema, Fi as occurrenceOn, Ft as PowerSourceInfoSchema, Ga as timedRunLimitOf, Gi as powerSourceCapability, Gt as RemoteConfigSchema, Hr as internalActionId, In as capUnitResolver, Is as defineAddonMigrations, J as DeclaredDevices, Ja as timedRunSeconds, Ji as problemsBlockSave, Ka as timedRunMaxIn, Ki as powerSourceLinkOfComposition, Kt as RunningStateStatusSchema, Mc as EventCategory$1, Mr as fanPresetsCapability, Ms as collectSecretMarkerRefs, O as ConditionMirror, Oi as normalizeActionUnits, On as buildActionSteps, Qn as coreBlockSourceKind, R as DEFAULT_HOLD_OVERRIDE, S as COMPOSER_RUNNER_ID, Tc as transformSecretWrite, To as compositionSourceKey, Tr as evaluateWhenTree, Ua as templateCapability, Ui as planComposition, Uo as BaseAddon, Vn as collectWhenMirrorSources, Vt as REMOTE_MEDIA_COMMANDS, Wa as timedRunCapability, Wn as compileScalarOverride, Wt as RemoteAssumedStateSchema, Xn as coreBlockComposition, Xt as SchedulerError, Yn as coreBlockAddonId, Za as validateComposition, Zi as proposeRunningThreshold, Zn as coreBlockIdFromAddonId, Zr as isInternalActionId, Zt as SchedulerSchema, _c as resolveSecretMarkers, aa as resolveActionVariables, an as SwitchStatusSchema, ao as weekdayOfLocalDate, ba as schedulersCapability, bc as secretTreeFromSchema, bo as composedDeviceRef, c as ActionError, ca as resolveCoreBlockEntry, ci as localDateOf, co as zoneOnlySite, d as ActionVariableSchema, dn as actionSourceCapability, do as DAY_MS, dr as describeComposableCaps, et as EMPTY_REMOTE_ASSUMED_STATE, fi as lockDoorLinkOfComposition, fn as actionWaitTotalMs, ga as resolveStepArgs, go as HelperMemberSchema, gt as INTERNAL_ACTION_PREFIX, ht as IDLE_ACTION_STATUS, ia as replacedFieldKeys, ic as isSecretRefOwnedBy, io as vocabActionIdFor, it as FanControlStatusSchema, j as CoreBlockSchema, jc as errMsg$1, ji as normalizeStepTargets, jo as historyRetentionFromSettings, ka as siteFor, ki as normalizeCapStep, kn as buildCapabilityLookup, l as ActionStepSchema, la as resolveCoreBlockFiles, m as BUILTIN_REMOTE_COMPONENTS, mn as addonIdOfActionId, n as ACTION_TARGET_INVALIDATION_EVENTS, na as remoteCapability, nc as isSecretMarker, ni as kebabToCamel, nr as customKeyOfRole, nt as FAN_CAPTURE_FIELDS, on as TemplateKindSchema, ot as FanPresetSchema, p as AutomationStateDocSchema, pn as actionsCapability, qa as timedRunQuickRun, qn as compositionSourceRefs, qs as hydrateSchema, ra as remoteLayoutComponentsCapability, rr as customRole, s as ALL_CAPABILITY_DEFINITIONS, tt as EMPTY_REMOTE_CONFIG, u as ActionTargetResolver, un as actionEffect, uo as CompositionSchema, va as runSteps, w as CORE_BLOCK_ADDON_PREFIX, xn as appendTrace, zn as checkTemplatePayload, zs as defineRecordKinds, zt as QuantityUnitError } from "../../dist-ze-qVU7x.mjs";
1
+ import { $ as EMPTY_AUTOMATION_STATE, $i as proposeRunningThreshold, $n as coreBlockSourceKind, $r as isInternalActionId, A as ControlStatusSchema, Ai as normalizeActionUnits, Bn as checkTemplatePayload, C as CORE_BLOCKS_ADDON_ID, Cc as secretTreeFromSchema, Co as composedDeviceRef, Er as evaluateWhenTree, Et as MediaPlayerStatusSchema, Fa as stableIdMapOf, Fs as collectSecretMarkerRefs, Ft as PowerSourceInfoSchema, Gi as planComposition, Gn as compileScalarOverride, Gt as RemoteConfigSchema, Hn as collectWhenMirrorSources, Hs as defineRecordKinds, Ic as EventCategory$1, In as capUnitResolver, J as DeclaredDevices, Ja as timedRunLimitOf, Ji as powerSourceLinkOfComposition, Jn as compositionSourceRefs, Ka as templateCapability, Ko as BaseAddon, Kt as RunningStateStatusSchema, Li as occurrenceOn, Mi as normalizeCoreBlockWrite, Nc as DeviceType$1, Ni as normalizeStepTargets, No as helperMembers, Nr as fanPresetsCapability, O as ConditionMirror, Oc as transformSecretWrite, On as buildActionSteps, Oo as compositionSourceKey, Pc as errMsg$1, Po as historyRetentionFromSettings, Qn as coreBlockIdFromAddonId, R as DEFAULT_HOLD_OVERRIDE, S as COMPOSER_RUNNER_ID, Sa as schedulersCapability, Vt as REMOTE_MEDIA_COMMANDS, Wr as internalActionId, Wt as RemoteAssumedStateSchema, Xa as timedRunQuickRun, Xi as problemsBlockSave, Xn as coreBlockAddonId, Xs as hydrateSchema, Xt as SchedulerError, Ya as timedRunMaxIn, Za as timedRunSeconds, Zn as coreBlockComposition, Zt as SchedulerSchema, aa as remoteLayoutComponentsCapability, ac as isSecretMarker, an as SwitchStatusSchema, ba as runSteps, bc as resolveSecretMarkers, c as ActionError, co as weekdayOfLocalDate, d as ActionVariableSchema, da as resolveCoreBlockFiles, dn as actionSourceCapability, do as zoneOnlySite, eo as validateComposition, er as coreBlocksCapability, et as EMPTY_REMOTE_ASSUMED_STATE, fn as actionWaitTotalMs, fr as describeComposableCaps, gt as INTERNAL_ACTION_PREFIX, ht as IDLE_ACTION_STATUS, ia as remoteCapability, ii as kebabToCamel, ir as customRole, it as FanControlStatusSchema, j as CoreBlockSchema, ja as siteFor, ji as normalizeCapStep, ki as nextOccurrence, kn as buildCapabilityLookup, l as ActionStepSchema, m as BUILTIN_REMOTE_COMPONENTS, mi as lockDoorLinkOfComposition, mn as addonIdOfActionId, mo as DAY_MS, n as ACTION_TARGET_INVALIDATION_EVENTS, no as validateSchedulerInput, nt as FAN_CAPTURE_FIELDS, oa as replacedFieldKeys, on as TemplateKindSchema, ot as FanPresetSchema, p as AutomationStateDocSchema, pn as actionsCapability, po as CompositionSchema, qa as timedRunCapability, qi as powerSourceCapability, rr as customKeyOfRole, s as ALL_CAPABILITY_DEFINITIONS, sa as resolveActionVariables, sc as isSecretRefOwnedBy, so as vocabActionIdFor, tt as EMPTY_REMOTE_CONFIG, u as ActionTargetResolver, ua as resolveCoreBlockEntry, ui as localDateOf, un as actionEffect, va as resolveStepArgs, w as CORE_BLOCK_ADDON_PREFIX, xn as appendTrace, yo as HelperMemberSchema, zs as defineAddonMigrations, zt as QuantityUnitError } from "../../dist-CogtCQxu.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
- import { i as parseDeviceStateChanged, t as describeCompositionSources } from "../../composition-sources-DkOfzgpS.mjs";
4
- import { i as capSeriesKey } from "../../capture-engine-BFgeAHa9.mjs";
3
+ import { i as parseDeviceStateChanged, t as describeCompositionSources } from "../../composition-sources-BhM6G9QT.mjs";
4
+ import { i as capSeriesKey } from "../../capture-engine-CnVIcnyN.mjs";
5
5
  import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
6
6
  import { n as unwrapStoredValue, t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
7
7
  import { createRequire } from "node:module";
@@ -5348,8 +5348,7 @@ function hostOver(api) {
5348
5348
  capName: cap
5349
5349
  }),
5350
5350
  fetchStableIds: async () => {
5351
- const all = await need().deviceManager.listAll.query({ projection: "slim" });
5352
- return new Map(all.flatMap((d) => d.stableId === void 0 ? [] : [[d.stableId, d.id]]));
5351
+ return stableIdMapOf(await need().deviceManager.listAll.query({ projection: "slim" }));
5353
5352
  },
5354
5353
  invokeCap: invokeCapOver(api)
5355
5354
  };
@@ -3,8 +3,8 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D5nGm8Sd.js");
7
- const require_capture_engine = require("../../capture-engine-BQ08XTnZ.js");
6
+ const require_dist = require("../../dist-2SHQaxaS.js");
7
+ const require_capture_engine = require("../../capture-engine-Byc5Fkp0.js");
8
8
  const require_retention = require("../../retention-BNONb5X_.js");
9
9
  let node_crypto = require("node:crypto");
10
10
  //#region src/builtins/device-history/capture/point-writer.ts
@@ -1,5 +1,5 @@
1
- import { $s as isReadingQuantity, Ac as DeviceType, Ho as wattMillisecondsToKwh, Ks as historyUnitFor, Mc as EventCategory, Sn as armRemovalReconcile, Uo as BaseAddon, V as DEVICE_HISTORY_ENERGY_KEY, Vs as emitReadiness, Y as DeviceRunSchema, _r as deviceRemovalHookCapability, dt as HISTORY_ITEM_CATALOG, hr as deviceHistoryCapability, ut as HISTORY_CATALOG, vr as deviceRunsCapability, zs as defineRecordKinds } from "../../dist-ze-qVU7x.mjs";
2
- import { a as catalogMetrics, c as DeviceDirectory, d as identityOf, f as subjectIdOf, i as capSeriesKey, l as isRealDeviceType, n as CaptureEngine, o as readPath, r as capItemSeriesKey, s as readUnit, t as CAP_KEY_PREFIX, u as SeriesRegistry } from "../../capture-engine-BFgeAHa9.mjs";
1
+ import { Go as wattMillisecondsToKwh, Hs as defineRecordKinds, Ic as EventCategory, Ko as BaseAddon, Nc as DeviceType, Sn as armRemovalReconcile, V as DEVICE_HISTORY_ENERGY_KEY, Ws as emitReadiness, Y as DeviceRunSchema, Ys as historyUnitFor, dt as HISTORY_ITEM_CATALOG, gr as deviceHistoryCapability, nc as isReadingQuantity, ut as HISTORY_CATALOG, vr as deviceRemovalHookCapability, yr as deviceRunsCapability } from "../../dist-CogtCQxu.mjs";
2
+ import { a as catalogMetrics, c as DeviceDirectory, d as identityOf, f as subjectIdOf, i as capSeriesKey, l as isRealDeviceType, n as CaptureEngine, o as readPath, r as capItemSeriesKey, s as readUnit, t as CAP_KEY_PREFIX, u as SeriesRegistry } from "../../capture-engine-CnVIcnyN.mjs";
3
3
  import { a as FIVE_MINUTES_MS, c as bucketEndOf, i as DAY_MS, l as bucketStartOf, n as RetentionJob, o as HOUR_MS, r as DepartureTracker, s as ROLLUP_GRACE_MS, t as DEFAULT_RETENTION, u as floorTo } from "../../retention-B9l9TnGE.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  //#region src/builtins/device-history/capture/point-writer.ts
@@ -0,0 +1,45 @@
1
+ import { deviceManagerCapability, type InferProvider } from "@camstack/types";
2
+ import type { ProviderContext } from "./device-provider-context.js";
3
+ import type { DeviceRowStore } from "./device-row-store.js";
4
+ type IDeviceManagerProvider = InferProvider<typeof deviceManagerCapability>;
5
+ export declare const DEVICE_ALIAS_BACKFILL_MARKER_KEY = "_deviceAliasBackfillVersion";
6
+ export declare const DEVICE_ALIAS_BACKFILL_VERSION = 1;
7
+ /**
8
+ * Addon-store key holding `{ [alias]: deviceId }` of REMOVED devices. A removed
9
+ * device's alias stays reserved so a template that still names it never silently
10
+ * starts reading a different device; only an explicit `setAlias` reclaims it.
11
+ */
12
+ export declare const RESERVED_ALIASES_KEY = "_reservedAliases";
13
+ export type ReservedAliases = Readonly<Record<string, number>>;
14
+ export declare function readReservedAliases(pctx: ProviderContext): Promise<ReservedAliases>;
15
+ /** Keep the alias of a device that is being removed. Caller holds the meta write lock. */
16
+ export declare function reserveAliasOfRemovedDevice(pctx: ProviderContext, alias: string, deviceId: number): Promise<void>;
17
+ /**
18
+ * The first free alias for `name`, against the persisted fleet. Caller holds the
19
+ * meta write lock. `selfId` is the device the alias is for: finding itself is not
20
+ * a collision.
21
+ */
22
+ export declare function freeAliasFor(rows: DeviceRowStore, name: string, selfId: number, reserved: ReservedAliases): Promise<string>;
23
+ export declare function setAlias(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["setAlias"]>[0]): ReturnType<IDeviceManagerProvider["setAlias"]>;
24
+ export interface AliasBackfillRow {
25
+ readonly id: number;
26
+ readonly name: string;
27
+ readonly alias?: string;
28
+ }
29
+ export interface AliasBackfillAssignment {
30
+ readonly id: number;
31
+ readonly alias: string;
32
+ }
33
+ /**
34
+ * Who gets which alias. Rows are taken in id order, so the same fleet always
35
+ * yields the same names; an alias a row already carries is kept and reserved.
36
+ */
37
+ export declare function planAliasBackfill(rows: readonly AliasBackfillRow[], reserved?: ReservedAliases): readonly AliasBackfillAssignment[];
38
+ /**
39
+ * One-shot, under a version marker in the addon store (same posture as the
40
+ * location and linked-devices backfills it sits beside): every device that has
41
+ * no alias gets the slug of its current name, deduped. Registration also stamps
42
+ * an alias-less row, so a device the boot missed heals the first time it registers.
43
+ */
44
+ export declare function runDeviceAliasBackfillAtBoot(pctx: ProviderContext): Promise<void>;
45
+ export {};