@camstack/server 1.2.891 → 1.2.892

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 (117) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/api/trpc/generated-cap-mounts.js +2 -1
  3. package/dist/api/trpc/generated-cap-routers.js +194 -39
  4. package/dist/core/addon/addon-registry.service.js +47 -0
  5. package/dist/core/addon/retire-undeclared-fixed-integrations.js +57 -0
  6. package/package.json +31 -15
  7. package/system/dist/addon-runner.js +25 -9
  8. package/system/dist/addon-runner.mjs +25 -9
  9. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  10. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  11. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  12. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  13. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  14. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  15. package/system/dist/builtins/autotrack/index.js +1 -1
  16. package/system/dist/builtins/autotrack/index.mjs +1 -1
  17. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  18. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  19. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  20. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  21. package/system/dist/builtins/camera-grid/addon.d.ts +65 -41
  22. package/system/dist/builtins/camera-grid/grid-blocks.d.ts +51 -0
  23. package/system/dist/builtins/camera-grid/grid-camera-device.d.ts +4 -3
  24. package/system/dist/builtins/camera-grid/grid-layout-native-provider.d.ts +3 -1
  25. package/system/dist/builtins/camera-grid/grid-plan.d.ts +3 -3
  26. package/system/dist/builtins/camera-grid/index.d.ts +2 -6
  27. package/system/dist/builtins/camera-grid/index.js +431 -727
  28. package/system/dist/builtins/camera-grid/index.mjs +428 -719
  29. package/system/dist/builtins/composer/composed-device.d.ts +12 -2
  30. package/system/dist/builtins/composer/composer.addon.js +28 -10
  31. package/system/dist/builtins/composer/composer.addon.mjs +28 -10
  32. package/system/dist/builtins/composer/composition-declarations.d.ts +3 -1
  33. package/system/dist/builtins/console-logging/index.js +1 -1
  34. package/system/dist/builtins/console-logging/index.mjs +1 -1
  35. package/system/dist/builtins/core-blocks/core-blocks.addon.js +174 -39
  36. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +175 -40
  37. package/system/dist/builtins/core-blocks/hero-layout-service.d.ts +19 -1
  38. package/system/dist/builtins/core-blocks/power-source-devices.d.ts +9 -0
  39. package/system/dist/builtins/core-blocks/power-source-service.d.ts +39 -2
  40. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  41. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  42. package/system/dist/builtins/device-manager/device-identifiers-action.d.ts +9 -0
  43. package/system/dist/builtins/device-manager/device-manager.addon.js +172 -5
  44. package/system/dist/builtins/device-manager/device-manager.addon.mjs +172 -5
  45. package/system/dist/builtins/device-manager/device-meta-types.d.ts +5 -1
  46. package/system/dist/builtins/device-manager/device-row-store.d.ts +3 -2
  47. package/system/dist/builtins/device-manager/device-state-mirror.d.ts +7 -0
  48. package/system/dist/builtins/device-manager/workload-transition.d.ts +23 -0
  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 +3 -3
  58. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  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.js +1 -1
  68. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  69. package/system/dist/builtins/snapshot/index.js +1 -1
  70. package/system/dist/builtins/snapshot/index.mjs +1 -1
  71. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  72. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  73. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  74. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  75. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  76. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  77. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  78. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  79. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  80. package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
  81. package/system/dist/builtins/winston-logging/index.js +1 -1
  82. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  83. package/system/dist/{capture-engine-DXz37Mjg.js → capture-engine-DHmlkW_d.js} +1 -1
  84. package/system/dist/{capture-engine-nmelnj-Y.mjs → capture-engine-sl6e9f9S.mjs} +1 -1
  85. package/system/dist/{composition-sources-uphZtYtN.mjs → composition-sources-CznD85Ri.mjs} +1 -1
  86. package/system/dist/{composition-sources-BLn3cU74.js → composition-sources-PqcZfe3j.js} +1 -1
  87. package/system/dist/{constants-DWU46D02.mjs → constants-CHwj_mIM.mjs} +1 -1
  88. package/system/dist/{constants-BAaGwvKn.js → constants-_2SOk0By.js} +1 -1
  89. package/system/dist/{device-ca-CK6mLB2w.mjs → device-ca-D2H1EMUY.mjs} +1 -1
  90. package/system/dist/{device-ca-jbH_rqZh.js → device-ca-WIEO5ZcE.js} +1 -1
  91. package/system/dist/{dist-Dgq9nuvh.mjs → dist-DbAhCrHy.mjs} +2366 -444
  92. package/system/dist/{dist-m5beNMze.js → dist-yx2KHo3b.js} +2467 -443
  93. package/system/dist/file-host-worker.js +1 -1
  94. package/system/dist/file-host-worker.mjs +1 -1
  95. package/system/dist/{hub-identity-DlBBoHJC.mjs → hub-identity-BcvZqT0L.mjs} +1 -1
  96. package/system/dist/{hub-identity-CKCA89XP.js → hub-identity-Buegac-w.js} +1 -1
  97. package/system/dist/{hub-mdns-ciao-B8uFW-RG.mjs → hub-mdns-ciao-B6K_dO2s.mjs} +2 -2
  98. package/system/dist/{hub-mdns-ciao-CqcCGPdi.js → hub-mdns-ciao-DcNPj7WJ.js} +2 -2
  99. package/system/dist/index.js +33 -19
  100. package/system/dist/index.mjs +33 -19
  101. package/system/dist/kernel/moleculer/child-cap-dispatch.d.ts +3 -6
  102. package/system/dist/kernel/moleculer/switch-toggle.d.ts +7 -2
  103. package/system/dist/{legacy-integration-rows-door-Co0gj1Lm.js → legacy-integration-rows-door-BsZyVNiR.js} +1 -1
  104. package/system/dist/{legacy-integration-rows-door-HI4nmSe_.mjs → legacy-integration-rows-door-DHOJeDPG.mjs} +1 -1
  105. package/system/dist/{rename-composition-block-UeVUYCwx.js → rename-composition-block-BXMor7MR.js} +1 -1
  106. package/system/dist/{rename-composition-block-BthBMrXA.mjs → rename-composition-block-DcVS1LuC.mjs} +1 -1
  107. package/system/dist/{restore-archive-P-ICnU58.mjs → restore-archive-BG8VJ8Ar.mjs} +82 -82
  108. package/system/dist/{restore-archive-CJLsfBwK.js → restore-archive-BURufVQd.js} +1 -1
  109. package/system/dist/{wal-maintenance-qWjb7_f2.mjs → wal-maintenance-B4wGD6QR.mjs} +0 -0
  110. package/system/dist/{wal-maintenance-CUtwx-2Z.js → wal-maintenance-CeaJyKNT.js} +0 -0
  111. package/system/package.json +2 -5
  112. package/system/dist/builtins/camera-grid/grid-camera-declarations.d.ts +0 -59
  113. package/system/dist/builtins/camera-grid/grid-instances.d.ts +0 -40
  114. package/system/dist/builtins/camera-grid/grid-record-kinds.d.ts +0 -31
  115. package/system/dist/builtins/camera-grid/migrations/__fixtures__/seed.d.ts +0 -13
  116. package/system/dist/builtins/camera-grid/migrations/camera-grids-to-records.d.ts +0 -26
  117. package/system/dist/builtins/camera-grid/migrations/index.d.ts +0 -6
@@ -1,4 +1,4 @@
1
- import { BaseDevice, type CapabilityDefinition, type DeviceConstructor, type DeviceContext, type DeviceFeature, DeviceType, type GroupCommandResult, type IDevice, type ReadingQuantity } from "@camstack/types";
1
+ import { BaseDevice, type CapabilityDefinition, type DeviceConstructor, type DeviceContext, type DeviceStatusOwnership, type DeviceFeature, DeviceType, type GroupCommandResult, type IDevice, type ReadingQuantity } from "@camstack/types";
2
2
  import { z } from "zod";
3
3
  import type { ComposedWriteTarget, WriteOutcome } from "./composition-runtime.js";
4
4
  import type { SlicePatch } from "./slice-assembler.js";
@@ -25,7 +25,7 @@ export declare class ComposedDevice extends BaseDevice<typeof COMPOSED_DEVICE_CO
25
25
  get userNamed(): boolean;
26
26
  get features(): readonly DeviceFeature[];
27
27
  syncBoundFeatures(features: readonly DeviceFeature[]): void;
28
- constructor(ctx: DeviceContext, type: DeviceType, caps: readonly CapabilityDefinition[]);
28
+ constructor(ctx: DeviceContext, type: DeviceType, caps: readonly CapabilityDefinition[], deviceStatus?: DeviceStatusOwnership);
29
29
  /**
30
30
  * The methods of a BUILT cap are commands (D967): each one is dispatched under
31
31
  * its own name and the composer's forwards decide what it calls. A method the
@@ -75,6 +75,16 @@ export declare function composedDeviceClass(type: DeviceType, caps: readonly Cap
75
75
  * ROW's (`deviceMeta.type`) — only ever adopted from an existing row, where the
76
76
  * row is canonical — because there is no plan to take one from.
77
77
  */
78
+ /**
79
+ * The composer's device on an ENGINE-HOSTED row (Camera grid, Terminal camera —
80
+ * planning#580). The composer owns the row, its name and its lifetime; the
81
+ * engine serves every camera cap on it as a cross-addon native (D663) and is
82
+ * the only writer of its `device-status`. This device registers no cap and
83
+ * never writes availability.
84
+ */
85
+ export declare class EngineHostedComposedDevice extends ComposedDevice {
86
+ constructor(ctx: DeviceContext);
87
+ }
78
88
  export declare class ComposedPlaceholderDevice extends ComposedDevice {
79
89
  constructor(ctx: DeviceContext);
80
90
  }
@@ -3,11 +3,11 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-m5beNMze.js");
7
- const require_composition_sources = require("../../composition-sources-BLn3cU74.js");
8
- const require_capture_engine = require("../../capture-engine-DXz37Mjg.js");
6
+ const require_dist = require("../../dist-yx2KHo3b.js");
7
+ const require_composition_sources = require("../../composition-sources-PqcZfe3j.js");
8
+ const require_capture_engine = require("../../capture-engine-DHmlkW_d.js");
9
9
  const require_retention = require("../../retention-BcOSL6b9.js");
10
- const require_rename_composition_block = require("../../rename-composition-block-UeVUYCwx.js");
10
+ const require_rename_composition_block = require("../../rename-composition-block-BXMor7MR.js");
11
11
  let zod = require("zod");
12
12
  //#region src/builtins/composer/actuator-invoke.ts
13
13
  /**
@@ -178,8 +178,11 @@ var ComposedDevice = class extends require_dist.BaseDevice {
178
178
  this.boundFeatures = [...features];
179
179
  this.refreshFeatures();
180
180
  }
181
- constructor(ctx, type, caps) {
182
- super(ctx, COMPOSED_DEVICE_CONFIG_SCHEMA, { type });
181
+ constructor(ctx, type, caps, deviceStatus = "own") {
182
+ super(ctx, COMPOSED_DEVICE_CONFIG_SCHEMA, {
183
+ type,
184
+ deviceStatus
185
+ });
183
186
  this.derivesWater = type === require_dist.DeviceType.PetFountain;
184
187
  for (const cap of caps) {
185
188
  if (cap.name === require_dist.motionCapability.name) {
@@ -443,6 +446,18 @@ function composedDeviceClass(type, caps) {
443
446
  * ROW's (`deviceMeta.type`) — only ever adopted from an existing row, where the
444
447
  * row is canonical — because there is no plan to take one from.
445
448
  */
449
+ /**
450
+ * The composer's device on an ENGINE-HOSTED row (Camera grid, Terminal camera —
451
+ * planning#580). The composer owns the row, its name and its lifetime; the
452
+ * engine serves every camera cap on it as a cross-addon native (D663) and is
453
+ * the only writer of its `device-status`. This device registers no cap and
454
+ * never writes availability.
455
+ */
456
+ var EngineHostedComposedDevice = class extends ComposedDevice {
457
+ constructor(ctx) {
458
+ super(ctx, require_dist.DeviceType.Camera, [], "external");
459
+ }
460
+ };
446
461
  var ComposedPlaceholderDevice = class extends ComposedDevice {
447
462
  constructor(ctx) {
448
463
  super(ctx, ctx.deviceMeta.type, []);
@@ -1680,16 +1695,17 @@ function declarationFor(input) {
1680
1695
  stableId: require_dist.composedDeviceStableId(input.blockId),
1681
1696
  name: input.name,
1682
1697
  type: input.target.type,
1683
- DeviceClass: composedDeviceClass(input.target.type, input.caps),
1698
+ DeviceClass: input.hosted ? EngineHostedComposedDevice : composedDeviceClass(input.target.type, input.caps),
1684
1699
  ...input.target.role === void 0 ? {} : { role: input.target.role }
1685
1700
  };
1686
1701
  }
1687
- /** What forces a rebuild of the live device: type, role, cap set. Never the name. */
1702
+ /** What forces a rebuild of the live device: type, role, cap set, who hosts it. Never the name. */
1688
1703
  function shapeOf(input) {
1689
1704
  return JSON.stringify([
1690
1705
  input.target.type,
1691
1706
  input.target.role ?? null,
1692
- input.caps.map((c) => c.name).toSorted()
1707
+ input.caps.map((c) => c.name).toSorted(),
1708
+ ...input.hosted ? ["hosted"] : []
1693
1709
  ]);
1694
1710
  }
1695
1711
  /**
@@ -1843,11 +1859,13 @@ function planNew(block, target, lookupCap, rows) {
1843
1859
  const def = lookupCap(f.cap);
1844
1860
  return def === null ? [] : [def];
1845
1861
  });
1862
+ const hosted = composition.helper !== void 0 && require_dist.isEngineHostedHelper(composition.helper);
1846
1863
  const declarationInput = {
1847
1864
  blockId: block.id,
1848
1865
  name: block.name,
1849
1866
  target,
1850
- caps
1867
+ caps,
1868
+ hosted
1851
1869
  };
1852
1870
  return {
1853
1871
  block,
@@ -1,8 +1,8 @@
1
- import { As as disarmRoseMemory, Bn as brightnessCapability, Bs as openReset, Co as sharedActuatorMethods, Cs as composedDeviceRef, Ds as compositionSliceKey, Es as compositionItemFieldPath, Fi as kebabToCamel, Gr as evaluateCompositionField, Gs as toExpressionValue, Hn as buildCapabilityLookup, Hs as planResetTier, Is as integrateReading, Jl as featuresOfBoundCaps, Kl as DeviceType, Ls as isForwardInputRef, M as ConsumableItemSchema, Ms as evaluateStatistic, Os as compositionSourceKey, Ps as historyRetentionFromSettings, Qi as mediaPlayerFeaturesOfRoles, Rs as isHistoryHelper, Sa as planComposition, So as sharedActuatorFeatures, Ss as cloneStatefulExpressionMemory, Tr as declaredSeriesKind, Ts as compositionFeatureEnabled, Us as planStatisticTier, Vs as openStatistic, Wc as createEvent, Wi as lockControlCapability, Ws as statisticCadenceMs, Wt as PetFountainStatusSchema, Xr as expressionContainsBuiltinCall, Yl as EventCategory, Zi as mediaPlayerCapability, _a as parseColorInput, _s as MINUTE_MS, aa as motionCapability, ba as petFountainWaterItem, dl as isReadingQuantity, ea as methodRefusal, ei as fanControlCapability, fi as groupCommandsCapability, fs as DEFAULT_HISTORY_RETENTION, hs as HOUR_MS, ht as FanDirectionSchema, i as ACTUATOR_TEMPLATE_IDS, io as resolveMutate, ja as processTimeZoneOr, js as evaluateDerivative, ks as createStatefulExpressionMemory, lr as composerCapability, ls as COMPOSER_ADDON_ID, ms as HISTORY_SLOW_MS, or as colorCapability, os as withDefaultRunning, pi as groupTemplate, pr as consumablesCapability, ps as HISTORY_FAST_MS, ql as errMsg, qs as BaseAddon, r as ACTUATOR_METHODS, ri as featureForwards, rr as climateControlCapability, s as ALL_CAPABILITY_DEFINITIONS, ti as fanOutTargets, ts as valveCapability, tt as DeclaredDevices, uo as runFanOut, ur as compositionFieldKey, v as BaseDevice, w as COMPOSED_ITEM_FIXED_FIELDS, wo as sharedColorModes, ws as composedDeviceStableId, wt as HvacModeSchema, ya as petFountainCapability, yr as coverCapability, yt as GroupCommandResultSchema, zo as switchCapability, zs as nextLocalMidnight } from "../../dist-Dgq9nuvh.mjs";
2
- import { i as parseDeviceStateChanged, n as normalizedNativeOwner, r as isRecord$4 } from "../../composition-sources-uphZtYtN.mjs";
3
- import { i as capSeriesKey } from "../../capture-engine-nmelnj-Y.mjs";
1
+ import { $o as switchCapability, $s as isEngineHostedHelper, Aa as petFountainCapability, As as HISTORY_SLOW_MS, Bs as composedDeviceStableId, Et as HvacModeSchema, Fo as sharedActuatorFeatures, Gn as brightnessCapability, Gs as createStatefulExpressionMemory, Ha as processTimeZoneOr, Hs as compositionItemFieldPath, Io as sharedActuatorMethods, Js as evaluateStatistic, Ks as disarmRoseMemory, Kt as PetFountainStatusSchema, Lo as sharedColorModes, M as ConsumableItemSchema, Na as planComposition, Ns as MINUTE_MS, Oa as parseColorInput, Ol as isReadingQuantity, Os as DEFAULT_HISTORY_RETENTION, Qs as integrateReading, Rs as cloneStatefulExpressionMemory, Tr as coverCapability, Ts as COMPOSER_ADDON_ID, Us as compositionSliceKey, Vs as compositionFeatureEnabled, Wi as kebabToCamel, Ws as compositionSourceKey, Xs as historyRetentionFromSettings, Zr as evaluateCompositionField, ac as planResetTier, bs as withDefaultRunning, bt as GroupCommandResultSchema, ca as mediaPlayerFeaturesOfRoles, cc as toExpressionValue, cr as climateControlCapability, da as methodRefusal, dr as colorCapability, du as featuresOfBoundCaps, ea as lockControlCapability, ec as isForwardInputRef, fu as EventCategory, ga as motionCapability, gr as compositionFieldKey, gt as FanDirectionSchema, ho as resolveMutate, hr as composerCapability, hs as valveCapability, i as ACTUATOR_TEMPLATE_IDS, ic as openStatistic, ja as petFountainWaterItem, jr as declaredSeriesKind, js as HOUR_MS, ks as HISTORY_FAST_MS, li as featureForwards, lu as DeviceType, nc as nextLocalMidnight, ni as expressionContainsBuiltinCall, oc as planStatisticTier, oi as fanControlCapability, qn as buildCapabilityLookup, qs as evaluateDerivative, r as ACTUATOR_METHODS, rc as openReset, s as ALL_CAPABILITY_DEFINITIONS, sa as mediaPlayerCapability, sc as statisticCadenceMs, si as fanOutTargets, sl as createEvent, tc as isHistoryHelper, tt as DeclaredDevices, uc as BaseAddon, uu as errMsg, v as BaseDevice, vi as groupCommandsCapability, w as COMPOSED_ITEM_FIXED_FIELDS, xo as runFanOut, yi as groupTemplate, yr as consumablesCapability, zs as composedDeviceRef } from "../../dist-DbAhCrHy.mjs";
2
+ import { i as parseDeviceStateChanged, n as normalizedNativeOwner, r as isRecord$4 } from "../../composition-sources-CznD85Ri.mjs";
3
+ import { i as capSeriesKey } from "../../capture-engine-sl6e9f9S.mjs";
4
4
  import { i as DAY_MS, t as DEFAULT_RETENTION } from "../../retention-CUOVI1p7.mjs";
5
- import { n as renameCompositionBlock } from "../../rename-composition-block-BthBMrXA.mjs";
5
+ import { n as renameCompositionBlock } from "../../rename-composition-block-DcVS1LuC.mjs";
6
6
  import { z } from "zod";
7
7
  //#region src/builtins/composer/actuator-invoke.ts
8
8
  /**
@@ -173,8 +173,11 @@ var ComposedDevice = class extends BaseDevice {
173
173
  this.boundFeatures = [...features];
174
174
  this.refreshFeatures();
175
175
  }
176
- constructor(ctx, type, caps) {
177
- super(ctx, COMPOSED_DEVICE_CONFIG_SCHEMA, { type });
176
+ constructor(ctx, type, caps, deviceStatus = "own") {
177
+ super(ctx, COMPOSED_DEVICE_CONFIG_SCHEMA, {
178
+ type,
179
+ deviceStatus
180
+ });
178
181
  this.derivesWater = type === DeviceType.PetFountain;
179
182
  for (const cap of caps) {
180
183
  if (cap.name === motionCapability.name) {
@@ -438,6 +441,18 @@ function composedDeviceClass(type, caps) {
438
441
  * ROW's (`deviceMeta.type`) — only ever adopted from an existing row, where the
439
442
  * row is canonical — because there is no plan to take one from.
440
443
  */
444
+ /**
445
+ * The composer's device on an ENGINE-HOSTED row (Camera grid, Terminal camera —
446
+ * planning#580). The composer owns the row, its name and its lifetime; the
447
+ * engine serves every camera cap on it as a cross-addon native (D663) and is
448
+ * the only writer of its `device-status`. This device registers no cap and
449
+ * never writes availability.
450
+ */
451
+ var EngineHostedComposedDevice = class extends ComposedDevice {
452
+ constructor(ctx) {
453
+ super(ctx, DeviceType.Camera, [], "external");
454
+ }
455
+ };
441
456
  var ComposedPlaceholderDevice = class extends ComposedDevice {
442
457
  constructor(ctx) {
443
458
  super(ctx, ctx.deviceMeta.type, []);
@@ -1675,16 +1690,17 @@ function declarationFor(input) {
1675
1690
  stableId: composedDeviceStableId(input.blockId),
1676
1691
  name: input.name,
1677
1692
  type: input.target.type,
1678
- DeviceClass: composedDeviceClass(input.target.type, input.caps),
1693
+ DeviceClass: input.hosted ? EngineHostedComposedDevice : composedDeviceClass(input.target.type, input.caps),
1679
1694
  ...input.target.role === void 0 ? {} : { role: input.target.role }
1680
1695
  };
1681
1696
  }
1682
- /** What forces a rebuild of the live device: type, role, cap set. Never the name. */
1697
+ /** What forces a rebuild of the live device: type, role, cap set, who hosts it. Never the name. */
1683
1698
  function shapeOf(input) {
1684
1699
  return JSON.stringify([
1685
1700
  input.target.type,
1686
1701
  input.target.role ?? null,
1687
- input.caps.map((c) => c.name).toSorted()
1702
+ input.caps.map((c) => c.name).toSorted(),
1703
+ ...input.hosted ? ["hosted"] : []
1688
1704
  ]);
1689
1705
  }
1690
1706
  /**
@@ -1838,11 +1854,13 @@ function planNew(block, target, lookupCap, rows) {
1838
1854
  const def = lookupCap(f.cap);
1839
1855
  return def === null ? [] : [def];
1840
1856
  });
1857
+ const hosted = composition.helper !== void 0 && isEngineHostedHelper(composition.helper);
1841
1858
  const declarationInput = {
1842
1859
  blockId: block.id,
1843
1860
  name: block.name,
1844
1861
  target,
1845
- caps
1862
+ caps,
1863
+ hosted
1846
1864
  };
1847
1865
  return {
1848
1866
  block,
@@ -15,9 +15,11 @@ export interface ComposerDeclarationInput {
15
15
  readonly name: string;
16
16
  readonly target: CompositionNewTarget;
17
17
  readonly caps: readonly CapabilityDefinition[];
18
+ /** An engine serves this row's caps and status (a grid or terminal helper, planning#580). */
19
+ readonly hosted: boolean;
18
20
  }
19
21
  export declare function declarationFor(input: ComposerDeclarationInput): DeviceDeclaration;
20
- /** What forces a rebuild of the live device: type, role, cap set. Never the name. */
22
+ /** What forces a rebuild of the live device: type, role, cap set, who hosts it. Never the name. */
21
23
  export declare function shapeOf(input: ComposerDeclarationInput): string;
22
24
  /**
23
25
  * The numeric id of the live composed device behind a stableId, or null when
@@ -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-m5beNMze.js");
6
+ const require_dist = require("../../dist-yx2KHo3b.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 { Ki as logDestinationCapability, qs as BaseAddon } from "../../dist-Dgq9nuvh.mjs";
1
+ import { na as logDestinationCapability, uc as BaseAddon } from "../../dist-DbAhCrHy.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-m5beNMze.js");
3
+ const require_dist = require("../../dist-yx2KHo3b.js");
4
4
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
5
- const require_composition_sources = require("../../composition-sources-BLn3cU74.js");
6
- const require_capture_engine = require("../../capture-engine-DXz37Mjg.js");
5
+ const require_composition_sources = require("../../composition-sources-PqcZfe3j.js");
6
+ const require_capture_engine = require("../../capture-engine-DHmlkW_d.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
  const require_cap_call_scope = require("../../cap-call-scope-8eiugfLl.js");
@@ -4111,10 +4111,23 @@ function buildActionsRuntime(deps) {
4111
4111
  * The link and the off time are read from the STORED composition on each call
4112
4112
  * (D676), never cached as a second copy. A forced restart is switch off now,
4113
4113
  * switch on after `offSeconds`, through an injected scheduler so a spec drives
4114
- * the clock; the pending switch-on is cancelled on `stop()`.
4114
+ * the clock; the pending switch-on is cancelled on `stop()`. A switch that declares
4115
+ * a native power cycle (a PoE port) is cycled in one call instead, and never
4116
+ * switched off or on. A switch that ANSWERED it only reports (D1058) is never
4117
+ * switched on or off: power on / off are refused as `not-settable`, and `getStatus`
4118
+ * says so (`switchSettable`) for the surfaces that withdraw them.
4115
4119
  *
4116
4120
  * Every refusal is a typed result with its reason, logged with the device tag.
4117
4121
  */
4122
+ /** `switch.getOptions` FAILED (not absent): what the switch can do is unknown. */
4123
+ var SwitchOptionsUnreadableError = class extends Error {
4124
+ switchDeviceId;
4125
+ constructor(switchDeviceId, cause) {
4126
+ super(`switch ${switchDeviceId}: its options could not be read (${cause instanceof Error ? cause.message : String(cause)}); not power-cycling and not switching it off blind`);
4127
+ this.name = "SwitchOptionsUnreadableError";
4128
+ this.switchDeviceId = switchDeviceId;
4129
+ }
4130
+ };
4118
4131
  var timeoutScheduler = { schedule: (delayMs, fire) => {
4119
4132
  const handle = setTimeout(fire, delayMs);
4120
4133
  return { cancel: () => clearTimeout(handle) };
@@ -4124,28 +4137,40 @@ var PowerSourceService = class {
4124
4137
  deps;
4125
4138
  /** Restarts whose switch-on has not run yet, by device id. */
4126
4139
  restarting = /* @__PURE__ */ new Map();
4140
+ /**
4141
+ * Devices whose switch-options read is failing now: warned once per streak, cleared by a
4142
+ * success or when the device is no longer linked. A removed device leaves at most one bare id
4143
+ * behind (this service has no removal hook); the set dies with the process.
4144
+ */
4145
+ optionsReadFailing = /* @__PURE__ */ new Set();
4127
4146
  constructor(deps) {
4128
4147
  this.deps = deps;
4129
4148
  }
4130
4149
  getStatus = async ({ deviceId }) => {
4131
4150
  const link = await this.linkOf(deviceId);
4132
- if (link === null) return {
4133
- linked: false,
4134
- switchDeviceId: null,
4135
- switchName: null,
4136
- switchOn: null,
4137
- switchOnline: null,
4138
- restartInProgress: false,
4139
- offSeconds: 0
4140
- };
4151
+ if (link === null) {
4152
+ this.optionsReadFailing.delete(deviceId);
4153
+ return {
4154
+ linked: false,
4155
+ switchDeviceId: null,
4156
+ switchName: null,
4157
+ switchOn: null,
4158
+ switchOnline: null,
4159
+ switchSettable: null,
4160
+ restartInProgress: false,
4161
+ offSeconds: 0
4162
+ };
4163
+ }
4141
4164
  const switchDevice = await this.deps.devices.find(link.switch).catch(() => null);
4142
4165
  const switchOn = switchDevice === null ? null : await this.deps.devices.readOn(switchDevice.id).catch(() => null);
4166
+ const switchSettable = switchDevice === null ? null : await this.settableOf(deviceId, switchDevice.id);
4143
4167
  return {
4144
4168
  linked: true,
4145
4169
  switchDeviceId: switchDevice?.id ?? null,
4146
4170
  switchName: switchDevice?.name ?? link.switch.stableId,
4147
4171
  switchOn,
4148
4172
  switchOnline: switchDevice?.online ?? null,
4173
+ switchSettable,
4149
4174
  restartInProgress: this.restarting.has(deviceId),
4150
4175
  offSeconds: link.offSeconds
4151
4176
  };
@@ -4167,6 +4192,28 @@ var PowerSourceService = class {
4167
4192
  const { link, switchDevice } = lookup.resolved;
4168
4193
  const switchId = switchDevice.id;
4169
4194
  pending.switchId = switchId;
4195
+ const cycle = this.deps.devices.cycle;
4196
+ if (cycle !== void 0) {
4197
+ let cycled;
4198
+ try {
4199
+ cycled = await cycle(switchId);
4200
+ } catch (err) {
4201
+ this.restarting.delete(deviceId);
4202
+ const reason = err instanceof SwitchOptionsUnreadableError ? "switch-options-unreadable" : "switch-call-failed";
4203
+ return this.refuse(deviceId, reason, errorText$3(err), switchId);
4204
+ }
4205
+ if (cycled) {
4206
+ this.restarting.delete(deviceId);
4207
+ this.deps.logger.info("power-source: forced restart through the switch’s native power cycle", {
4208
+ tags: { deviceId },
4209
+ meta: {
4210
+ switchId,
4211
+ switchName: switchDevice.name
4212
+ }
4213
+ });
4214
+ return ACCEPTED;
4215
+ }
4216
+ }
4170
4217
  try {
4171
4218
  await this.deps.devices.setOn(switchId, false);
4172
4219
  } catch (err) {
@@ -4221,6 +4268,7 @@ var PowerSourceService = class {
4221
4268
  const lookup = await this.lookup(deviceId);
4222
4269
  if (lookup.kind === "refused") return this.refuse(deviceId, lookup.reason, lookup.message, null);
4223
4270
  const { switchDevice } = lookup.resolved;
4271
+ if (await this.settableOf(deviceId, switchDevice.id) === false) return this.refuse(deviceId, "not-settable", `the switch ${switchDevice.name} only reports its state; it cannot be switched ${on ? "on" : "off"}`, switchDevice.id);
4224
4272
  try {
4225
4273
  await this.deps.devices.setOn(switchDevice.id, on);
4226
4274
  } catch (err) {
@@ -4235,6 +4283,32 @@ var PowerSourceService = class {
4235
4283
  });
4236
4284
  return ACCEPTED;
4237
4285
  }
4286
+ /**
4287
+ * Whether the switch can be set: `true` for a plain switch (no options reader, or a provider
4288
+ * without `getOptions`), `null` when the read FAILED — never `false` for unknown. Every hero
4289
+ * build reads `getStatus`, so a failing read warns once per device per failure streak (tagged);
4290
+ * a successful read ends the streak.
4291
+ */
4292
+ async settableOf(deviceId, switchId) {
4293
+ const options = this.deps.devices.options;
4294
+ if (options === void 0) return true;
4295
+ try {
4296
+ const settable = (await options(switchId)).supportsSetState;
4297
+ this.optionsReadFailing.delete(deviceId);
4298
+ return settable;
4299
+ } catch (err) {
4300
+ if (this.optionsReadFailing.has(deviceId)) return null;
4301
+ this.optionsReadFailing.add(deviceId);
4302
+ this.deps.logger.warn("power-source: the switch options could not be read; settable unknown", {
4303
+ tags: { deviceId },
4304
+ meta: {
4305
+ switchId,
4306
+ error: errorText$3(err)
4307
+ }
4308
+ });
4309
+ return null;
4310
+ }
4311
+ }
4238
4312
  /** The link and the switch, or the reason there is nothing to act on. Reads the switch state: unknown is refused. */
4239
4313
  async lookup(deviceId) {
4240
4314
  const stored = await this.storedLinkOf(deviceId);
@@ -6207,6 +6281,8 @@ var RemoteComponentsService = class {
6207
6281
  * count comes from the remote cap and is `null` when it cannot be asked.
6208
6282
  */
6209
6283
  var REMOTE_CAP = "remote";
6284
+ var SWITCH_CAP = "switch";
6285
+ var POWER_SOURCE_CAP = "power-source";
6210
6286
  /** Models built at once for a list; the cap bounds the list, this bounds the fan-out on the registry. */
6211
6287
  var ROW_MODELS_CONCURRENCY = 16;
6212
6288
  var HeroLayoutService = class {
@@ -6241,6 +6317,8 @@ var HeroLayoutService = class {
6241
6317
  }
6242
6318
  }));
6243
6319
  const remoteCommands = await this.remoteCommands(deviceId);
6320
+ const switchOptions = bound.includes(SWITCH_CAP) ? await this.switchOptions(deviceId) : void 0;
6321
+ const powerSupplySettable = bound.includes(POWER_SOURCE_CAP) ? await this.powerSupplySettable(deviceId) : null;
6244
6322
  return require_dist.buildHeroModel({
6245
6323
  device: {
6246
6324
  id: deviceId,
@@ -6256,7 +6334,9 @@ var HeroLayoutService = class {
6256
6334
  slices,
6257
6335
  now: this.deps.now(),
6258
6336
  remoteCommands,
6259
- access: { canActuate: canActuate ?? true }
6337
+ access: { canActuate: canActuate ?? true },
6338
+ ...switchOptions !== void 0 ? { switchOptions } : {},
6339
+ powerSupplySettable
6260
6340
  });
6261
6341
  };
6262
6342
  /**
@@ -6289,6 +6369,34 @@ var HeroLayoutService = class {
6289
6369
  return null;
6290
6370
  }
6291
6371
  }
6372
+ /**
6373
+ * What the switch can do. A provider without `getOptions` answers the defaults through the
6374
+ * reader; a read that FAILED is unknown — the hero draws on/off, as before (D315) — and is
6375
+ * logged with the device.
6376
+ */
6377
+ async switchOptions(deviceId) {
6378
+ try {
6379
+ return await this.deps.reader.switchOptions(deviceId);
6380
+ } catch (error) {
6381
+ this.deps.logger.warn("hero model: the switch options could not be read; on/off drawn", {
6382
+ tags: { deviceId },
6383
+ meta: { error: error instanceof Error ? error.message : String(error) }
6384
+ });
6385
+ return;
6386
+ }
6387
+ }
6388
+ /** Whether the supply's switch can be set; a failed read is unknown (on/off drawn), logged. */
6389
+ async powerSupplySettable(deviceId) {
6390
+ try {
6391
+ return await this.deps.reader.powerSupplySettable(deviceId);
6392
+ } catch (error) {
6393
+ this.deps.logger.warn("hero model: the power supply status could not be read; power on/off drawn", {
6394
+ tags: { deviceId },
6395
+ meta: { error: error instanceof Error ? error.message : String(error) }
6396
+ });
6397
+ return null;
6398
+ }
6399
+ }
6292
6400
  async remoteCommands(deviceId) {
6293
6401
  try {
6294
6402
  return await this.deps.reader.remoteCommands(deviceId);
@@ -6413,6 +6521,54 @@ async function seedLockDoors(deps) {
6413
6521
  }
6414
6522
  }
6415
6523
  //#endregion
6524
+ //#region src/builtins/core-blocks/power-source-devices.ts
6525
+ /**
6526
+ * The devices `power-source` acts on, reached over `ctx.api`: the linked switch is read,
6527
+ * set, and — when its provider declares a native power cycle — cycled in one call.
6528
+ */
6529
+ /** The switch's options; the defaults when its provider has no `getOptions`; throws typed when the read failed. */
6530
+ async function switchOptionsOf(api, deviceId) {
6531
+ try {
6532
+ return await api.switch.getOptions.query({ deviceId });
6533
+ } catch (err) {
6534
+ if ((0, _camstack_types_addon.isCapMethodAbsent)(err)) return require_dist.SWITCH_DEFAULT_OPTIONS;
6535
+ throw new SwitchOptionsUnreadableError(deviceId, err);
6536
+ }
6537
+ }
6538
+ function powerSourceDevicesOver(requireApi) {
6539
+ return {
6540
+ find: async (ref) => {
6541
+ const row = (await requireApi().deviceManager.listAll.query({
6542
+ addonId: ref.addonId,
6543
+ projection: "slim"
6544
+ })).find((r) => r.stableId === ref.stableId);
6545
+ return row === void 0 ? null : {
6546
+ id: row.id,
6547
+ name: row.name,
6548
+ online: row.online
6549
+ };
6550
+ },
6551
+ readOn: async (deviceId) => {
6552
+ const status = await requireApi().switch.getStatus.query({ deviceId });
6553
+ const on = status !== null && typeof status === "object" ? Reflect.get(status, "on") : void 0;
6554
+ return typeof on === "boolean" ? on : null;
6555
+ },
6556
+ setOn: async (deviceId, on) => {
6557
+ await requireApi().switch.setState.mutate({
6558
+ deviceId,
6559
+ on
6560
+ });
6561
+ },
6562
+ options: (deviceId) => switchOptionsOf(requireApi(), deviceId),
6563
+ cycle: async (deviceId) => {
6564
+ const api = requireApi();
6565
+ if (!(await switchOptionsOf(api, deviceId)).supportsPowerCycle) return false;
6566
+ await api.switch.powerCycle.mutate({ deviceId });
6567
+ return true;
6568
+ }
6569
+ };
6570
+ }
6571
+ //#endregion
6416
6572
  //#region src/builtins/core-blocks/fan-link-forward.ts
6417
6573
  /**
6418
6574
  * A write to a fan-control field the operator linked in Customize goes to the
@@ -9906,7 +10062,9 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
9906
10062
  deviceId,
9907
10063
  capName
9908
10064
  }),
9909
- remoteCommands: async (deviceId) => (await requireApi().remote.listCommands.query({ deviceId })).commands.length
10065
+ remoteCommands: async (deviceId) => (await requireApi().remote.listCommands.query({ deviceId })).commands.length,
10066
+ switchOptions: (deviceId) => switchOptionsOf(requireApi(), deviceId),
10067
+ powerSupplySettable: async (deviceId) => (await requireApi().powerSource.getStatus.query({ deviceId })).switchSettable ?? null
9910
10068
  }
9911
10069
  });
9912
10070
  }
@@ -9926,30 +10084,7 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
9926
10084
  if (!api) throw new Error("core-blocks: no ctx.api on this node — power-source cannot reach devices");
9927
10085
  return api;
9928
10086
  };
9929
- return {
9930
- find: async (ref) => {
9931
- const row = (await requireApi().deviceManager.listAll.query({
9932
- addonId: ref.addonId,
9933
- projection: "slim"
9934
- })).find((r) => r.stableId === ref.stableId);
9935
- return row === void 0 ? null : {
9936
- id: row.id,
9937
- name: row.name,
9938
- online: row.online
9939
- };
9940
- },
9941
- readOn: async (deviceId) => {
9942
- const status = await requireApi().switch.getStatus.query({ deviceId });
9943
- const on = status !== null && typeof status === "object" ? Reflect.get(status, "on") : void 0;
9944
- return typeof on === "boolean" ? on : null;
9945
- },
9946
- setOn: async (deviceId, on) => {
9947
- await requireApi().switch.setState.mutate({
9948
- deviceId,
9949
- on
9950
- });
9951
- }
9952
- };
10087
+ return powerSourceDevicesOver(requireApi);
9953
10088
  }
9954
10089
  buildRemote(records) {
9955
10090
  const settings = this.ctx.settings;