@camstack/server 1.2.891 → 1.2.893

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 (118) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/api/trpc/generated-cap-mounts.js +2 -1
  3. package/dist/api/trpc/generated-cap-routers.js +204 -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 +14 -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-identity-index.d.ts +73 -0
  44. package/system/dist/builtins/device-manager/device-manager.addon.js +401 -14
  45. package/system/dist/builtins/device-manager/device-manager.addon.mjs +401 -14
  46. package/system/dist/builtins/device-manager/device-meta-types.d.ts +5 -1
  47. package/system/dist/builtins/device-manager/device-row-store.d.ts +7 -3
  48. package/system/dist/builtins/device-manager/device-state-mirror.d.ts +7 -0
  49. package/system/dist/builtins/device-manager/workload-transition.d.ts +23 -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 +3 -3
  59. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  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 +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/storage-orchestrator.addon.js +1 -1
  79. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  80. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  81. package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
  82. package/system/dist/builtins/winston-logging/index.js +1 -1
  83. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  84. package/system/dist/{capture-engine-nmelnj-Y.mjs → capture-engine-CIVKm_jN.mjs} +1 -1
  85. package/system/dist/{capture-engine-DXz37Mjg.js → capture-engine-mZ2J-GD6.js} +1 -1
  86. package/system/dist/{composition-sources-BLn3cU74.js → composition-sources-CGP5ZUYo.js} +1 -1
  87. package/system/dist/{composition-sources-uphZtYtN.mjs → composition-sources-bJP8_Z2o.mjs} +1 -1
  88. package/system/dist/{constants-BAaGwvKn.js → constants-BD8oSQro.js} +1 -1
  89. package/system/dist/{constants-DWU46D02.mjs → constants-w-6vvTPp.mjs} +1 -1
  90. package/system/dist/{device-ca-jbH_rqZh.js → device-ca-CXxnQaff.js} +1 -1
  91. package/system/dist/{device-ca-CK6mLB2w.mjs → device-ca-DE_oetBE.mjs} +1 -1
  92. package/system/dist/{dist-m5beNMze.js → dist-B2-Uflhy.js} +2573 -443
  93. package/system/dist/{dist-Dgq9nuvh.mjs → dist-Be8yFd71.mjs} +2460 -444
  94. package/system/dist/file-host-worker.js +1 -1
  95. package/system/dist/file-host-worker.mjs +1 -1
  96. package/system/dist/{hub-identity-CKCA89XP.js → hub-identity-BjYvJU_v.js} +1 -1
  97. package/system/dist/{hub-identity-DlBBoHJC.mjs → hub-identity-C3g7b58L.mjs} +1 -1
  98. package/system/dist/{hub-mdns-ciao-CqcCGPdi.js → hub-mdns-ciao-BRfv9GfW.js} +2 -2
  99. package/system/dist/{hub-mdns-ciao-B8uFW-RG.mjs → hub-mdns-ciao-v6X_SbWl.mjs} +2 -2
  100. package/system/dist/index.js +33 -19
  101. package/system/dist/index.mjs +33 -19
  102. package/system/dist/kernel/moleculer/child-cap-dispatch.d.ts +3 -6
  103. package/system/dist/kernel/moleculer/switch-toggle.d.ts +7 -2
  104. package/system/dist/{legacy-integration-rows-door-Co0gj1Lm.js → legacy-integration-rows-door-B0q34gh3.js} +1 -1
  105. package/system/dist/{legacy-integration-rows-door-HI4nmSe_.mjs → legacy-integration-rows-door-DG35DG06.mjs} +1 -1
  106. package/system/dist/{rename-composition-block-UeVUYCwx.js → rename-composition-block-DNte3Cs9.js} +1 -1
  107. package/system/dist/{rename-composition-block-BthBMrXA.mjs → rename-composition-block-LEbZ4oZE.mjs} +1 -1
  108. package/system/dist/{restore-archive-P-ICnU58.mjs → restore-archive--4ENkU5f.mjs} +1 -1
  109. package/system/dist/{restore-archive-CJLsfBwK.js → restore-archive-DpFPheMK.js} +1 -1
  110. package/system/dist/{wal-maintenance-CUtwx-2Z.js → wal-maintenance-BWUJktqT.js} +0 -0
  111. package/system/dist/{wal-maintenance-qWjb7_f2.mjs → wal-maintenance-DQVDhuVJ.mjs} +0 -0
  112. package/system/package.json +2 -5
  113. package/system/dist/builtins/camera-grid/grid-camera-declarations.d.ts +0 -59
  114. package/system/dist/builtins/camera-grid/grid-instances.d.ts +0 -40
  115. package/system/dist/builtins/camera-grid/grid-record-kinds.d.ts +0 -31
  116. package/system/dist/builtins/camera-grid/migrations/__fixtures__/seed.d.ts +0 -13
  117. package/system/dist/builtins/camera-grid/migrations/camera-grids-to-records.d.ts +0 -26
  118. package/system/dist/builtins/camera-grid/migrations/index.d.ts +0 -6
@@ -1,6 +1,6 @@
1
1
  let zod = require("zod");
2
2
  require("node:crypto");
3
- //#region ../types/dist/event-category-Dhcd0TRH.mjs
3
+ //#region ../types/dist/event-category-Hwx_JSCU.mjs
4
4
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
5
5
  EventCategory["SystemBoot"] = "system.boot";
6
6
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -522,6 +522,14 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
522
522
  EventCategory["RunningStarted"] = "running.started";
523
523
  /** Mirrors `runningStateCapability.events.onFinished`. */
524
524
  EventCategory["RunningFinished"] = "running.finished";
525
+ /** Mirrors `workloadCapability.events.onStarted` — a workload reached running (#585). */
526
+ EventCategory["WorkloadStarted"] = "workload.started";
527
+ /** Mirrors `workloadCapability.events.onStopped` — a running workload stopped cleanly. */
528
+ EventCategory["WorkloadStopped"] = "workload.stopped";
529
+ /** Mirrors `workloadCapability.events.onCrashed` — a workload stopped without a request. */
530
+ EventCategory["WorkloadCrashed"] = "workload.crashed";
531
+ /** Mirrors `workloadCapability.events.onRecovered` — a crashed workload runs again. */
532
+ EventCategory["WorkloadRecovered"] = "workload.recovered";
525
533
  /** Mirrors `deviceRunsCapability.events.onRunOpened` - a durable run record opened. */
526
534
  EventCategory["DeviceRunOpened"] = "device-run.opened";
527
535
  /** Mirrors `deviceRunsCapability.events.onRunClosed` - a durable run record closed. */
@@ -824,7 +832,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
824
832
  return EventCategory;
825
833
  }({});
826
834
  //#endregion
827
- //#region ../types/dist/composed-stable-id-RvQIEpqg.mjs
835
+ //#region ../types/dist/composed-stable-id-BBL71oUQ.mjs
828
836
  /**
829
837
  import { errMsg } from '@camstack/types'
830
838
  * Extract a human-readable message from an unknown error value.
@@ -956,6 +964,10 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
956
964
  * and the storage as branches of one bus. One read-only `energy-system` cap carries
957
965
  * every value; the storage is a field of it, never the `battery` cap (#513, #522). */
958
966
  DeviceType["EnergySystem"] = "energy-system";
967
+ /** Something that RUNS on a machine, or the machine itself (#585): a VM, an app
968
+ * container, an LXC, an app, or a host. The kind is the ROLE (D1033, D1056), never
969
+ * a field; one `workload` cap carries the state, the controls and the resources. */
970
+ DeviceType["Workload"] = "workload";
959
971
  return DeviceType;
960
972
  }({});
961
973
  var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
@@ -1185,6 +1197,11 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1185
1197
  * `light` type: the provider owns the type, and a light implies brightness
1186
1198
  * or colour this relay lacks. */
1187
1199
  DeviceRole["SwitchLight"] = "switch-light";
1200
+ /** One port of a network switch that powers the device behind it (PoE): on /
1201
+ * off feeds or cuts that power. Its link is `network-link`, its draw
1202
+ * `power-meter`. Restarting the powered device through the port is that
1203
+ * device's `power-source` cap, never a reboot of the port. */
1204
+ DeviceRole["PoePort"] = "poe-port";
1188
1205
  /** Air conditioner / split unit: cooling, fan speed, louvres. */
1189
1206
  DeviceRole["ClimateAc"] = "climate-ac";
1190
1207
  /** Room thermostat: a setpoint and a room temperature. The default. */
@@ -1265,6 +1282,17 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1265
1282
  /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
1266
1283
  * cap. A `DeviceType.Generic` device. */
1267
1284
  DeviceRole["IrTransmitter"] = "ir-transmitter";
1285
+ /** A virtual machine on a hypervisor. */
1286
+ DeviceRole["Vm"] = "vm";
1287
+ /** An application container (Docker, Podman). */
1288
+ DeviceRole["AppContainer"] = "app-container";
1289
+ /** A system container (LXC). */
1290
+ DeviceRole["Lxc"] = "lxc";
1291
+ /** An application or service running on a host. */
1292
+ DeviceRole["App"] = "app";
1293
+ /** A machine that runs workloads or is an appliance with its own OS: a
1294
+ * server, a hypervisor, a gateway console, a CCU. */
1295
+ DeviceRole["Host"] = "host";
1268
1296
  return DeviceRole;
1269
1297
  }({});
1270
1298
  /**
@@ -1274,7 +1302,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1274
1302
  */
1275
1303
  var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
1276
1304
  //#endregion
1277
- //#region ../types/dist/sleep-Ch7Q7UtE.mjs
1305
+ //#region ../types/dist/sleep-D6Pih0Qt.mjs
1278
1306
  /**
1279
1307
  * The audio chunk plane's byte format, and the ONE expansion from a coded
1280
1308
  * window to float samples (D455).
@@ -6807,6 +6835,10 @@ var CAP_VOCABULARY_BY_NAME = {
6807
6835
  effect: {
6808
6836
  field: "on",
6809
6837
  value: true
6838
+ },
6839
+ offeredWhen: {
6840
+ method: "getOptions",
6841
+ field: "supportsSetState"
6810
6842
  }
6811
6843
  },
6812
6844
  {
@@ -6825,6 +6857,10 @@ var CAP_VOCABULARY_BY_NAME = {
6825
6857
  effect: {
6826
6858
  field: "on",
6827
6859
  value: false
6860
+ },
6861
+ offeredWhen: {
6862
+ method: "getOptions",
6863
+ field: "supportsSetState"
6828
6864
  }
6829
6865
  },
6830
6866
  {
@@ -6838,9 +6874,14 @@ var CAP_VOCABULARY_BY_NAME = {
6838
6874
  en: "Toggle {device}",
6839
6875
  it: "Commuta {device}"
6840
6876
  },
6841
- icon: "toggle-right"
6877
+ icon: "toggle-right",
6878
+ offeredWhen: {
6879
+ method: "getOptions",
6880
+ field: "supportsSetState"
6881
+ }
6842
6882
  }
6843
6883
  ],
6884
+ notOperatorFacing: { powerCycle: "a power cycle is the forced restart of the device the switch powers (power-source), never a step of its own" },
6844
6885
  state: [{
6845
6886
  kind: "boolean",
6846
6887
  field: "on",
@@ -7099,6 +7140,47 @@ var CAP_VOCABULARY_BY_NAME = {
7099
7140
  "switch.off": { icon: "plug" }
7100
7141
  },
7101
7142
  state: { on: { icon: "plug-zap" } }
7143
+ },
7144
+ [DeviceRole.PoePort]: {
7145
+ actions: {
7146
+ "switch.on": {
7147
+ label: {
7148
+ en: "Power on",
7149
+ it: "Alimenta"
7150
+ },
7151
+ phrase: {
7152
+ en: "Power on {device}",
7153
+ it: "Alimenta {device}"
7154
+ },
7155
+ icon: "plug-zap"
7156
+ },
7157
+ "switch.off": {
7158
+ label: {
7159
+ en: "Power off",
7160
+ it: "Togli alimentazione"
7161
+ },
7162
+ phrase: {
7163
+ en: "Power off {device}",
7164
+ it: "Togli alimentazione a {device}"
7165
+ },
7166
+ icon: "unplug"
7167
+ }
7168
+ },
7169
+ state: { on: {
7170
+ label: {
7171
+ en: "Powered",
7172
+ it: "Alimentata"
7173
+ },
7174
+ whenTrue: {
7175
+ en: "When {device} is powered",
7176
+ it: "Quando {device} viene alimentata"
7177
+ },
7178
+ whenFalse: {
7179
+ en: "When {device} loses power",
7180
+ it: "Quando {device} perde l’alimentazione"
7181
+ },
7182
+ icon: "plug-zap"
7183
+ } }
7102
7184
  }
7103
7185
  }
7104
7186
  }
@@ -7818,7 +7900,11 @@ var CAP_VOCABULARY_BY_NAME = {
7818
7900
  en: "Power on {device}",
7819
7901
  it: "Dai corrente a {device}"
7820
7902
  },
7821
- icon: "power"
7903
+ icon: "power",
7904
+ offeredWhen: {
7905
+ method: "getStatus",
7906
+ field: "switchSettable"
7907
+ }
7822
7908
  },
7823
7909
  {
7824
7910
  id: "powerSource.off",
@@ -7831,7 +7917,11 @@ var CAP_VOCABULARY_BY_NAME = {
7831
7917
  en: "Cut the power of {device}",
7832
7918
  it: "Togli la corrente a {device}"
7833
7919
  },
7834
- icon: "power-off"
7920
+ icon: "power-off",
7921
+ offeredWhen: {
7922
+ method: "getStatus",
7923
+ field: "switchSettable"
7924
+ }
7835
7925
  },
7836
7926
  {
7837
7927
  id: "powerSource.forceRestart",
@@ -9601,37 +9691,66 @@ var CAP_VOCABULARY_BY_NAME = {
9601
9691
  en: "Siren",
9602
9692
  it: "Sirena"
9603
9693
  },
9604
- actions: [{
9605
- id: "siren.trigger",
9606
- method: "trigger",
9607
- label: {
9608
- en: "Sound the siren",
9609
- it: "Fai suonare la sirena"
9610
- },
9611
- phrase: {
9612
- en: "Sound {device}",
9613
- it: "Fai suonare {device}"
9614
- },
9615
- icon: "siren",
9616
- args: {}
9617
- }, {
9618
- id: "siren.stop",
9619
- method: "stop",
9620
- label: {
9621
- en: "Silence the siren",
9622
- it: "Zittisci la sirena"
9694
+ actions: [
9695
+ {
9696
+ id: "siren.trigger",
9697
+ method: "trigger",
9698
+ label: {
9699
+ en: "Sound the siren",
9700
+ it: "Fai suonare la sirena"
9701
+ },
9702
+ phrase: {
9703
+ en: "Sound {device}",
9704
+ it: "Fai suonare {device}"
9705
+ },
9706
+ icon: "siren",
9707
+ args: {}
9623
9708
  },
9624
- phrase: {
9625
- en: "Silence {device}",
9626
- it: "Zittisci {device}"
9709
+ {
9710
+ id: "siren.triggerPlays",
9711
+ method: "trigger",
9712
+ label: {
9713
+ en: "Sound the siren N times",
9714
+ it: "Fai suonare la sirena N volte"
9715
+ },
9716
+ phrase: {
9717
+ en: "Sound {device} {plays} times",
9718
+ it: "Fai suonare {device} {plays} volte"
9719
+ },
9720
+ icon: "siren",
9721
+ openArgs: [{
9722
+ key: "plays",
9723
+ label: {
9724
+ en: "Plays",
9725
+ it: "Riproduzioni"
9726
+ },
9727
+ offer: {
9728
+ kind: "dynamic",
9729
+ from: "method",
9730
+ method: "getPlayChoices",
9731
+ valueKind: "number"
9732
+ }
9733
+ }]
9627
9734
  },
9628
- icon: "siren",
9629
- args: {},
9630
- effect: {
9631
- field: "active",
9632
- value: false
9735
+ {
9736
+ id: "siren.stop",
9737
+ method: "stop",
9738
+ label: {
9739
+ en: "Silence the siren",
9740
+ it: "Zittisci la sirena"
9741
+ },
9742
+ phrase: {
9743
+ en: "Silence {device}",
9744
+ it: "Zittisci {device}"
9745
+ },
9746
+ icon: "siren",
9747
+ args: {},
9748
+ effect: {
9749
+ field: "active",
9750
+ value: false
9751
+ }
9633
9752
  }
9634
- }],
9753
+ ],
9635
9754
  state: [{
9636
9755
  kind: "boolean",
9637
9756
  field: "active",
@@ -12226,6 +12345,374 @@ var CAP_VOCABULARY_BY_NAME = {
12226
12345
  icon: "loader"
12227
12346
  }]
12228
12347
  },
12348
+ "workload": {
12349
+ scope: "device",
12350
+ noun: {
12351
+ en: "Workload",
12352
+ it: "Carico di lavoro"
12353
+ },
12354
+ actions: [
12355
+ {
12356
+ id: "workload.start",
12357
+ method: "start",
12358
+ label: {
12359
+ en: "Start",
12360
+ it: "Avvia"
12361
+ },
12362
+ phrase: {
12363
+ en: "Start {device}",
12364
+ it: "Avvia {device}"
12365
+ },
12366
+ icon: "play",
12367
+ effect: {
12368
+ field: "state",
12369
+ value: "running"
12370
+ }
12371
+ },
12372
+ {
12373
+ id: "workload.stop",
12374
+ method: "stop",
12375
+ label: {
12376
+ en: "Stop",
12377
+ it: "Arresta"
12378
+ },
12379
+ phrase: {
12380
+ en: "Stop {device}",
12381
+ it: "Arresta {device}"
12382
+ },
12383
+ icon: "square",
12384
+ effect: {
12385
+ field: "state",
12386
+ value: "stopped"
12387
+ }
12388
+ },
12389
+ {
12390
+ id: "workload.restart",
12391
+ method: "restart",
12392
+ label: {
12393
+ en: "Restart",
12394
+ it: "Riavvia"
12395
+ },
12396
+ phrase: {
12397
+ en: "Restart {device}",
12398
+ it: "Riavvia {device}"
12399
+ },
12400
+ icon: "rotate-ccw"
12401
+ },
12402
+ {
12403
+ id: "workload.pause",
12404
+ method: "pause",
12405
+ label: {
12406
+ en: "Pause",
12407
+ it: "Metti in pausa"
12408
+ },
12409
+ phrase: {
12410
+ en: "Pause {device}",
12411
+ it: "Metti in pausa {device}"
12412
+ },
12413
+ icon: "pause",
12414
+ effect: {
12415
+ field: "state",
12416
+ value: "paused"
12417
+ }
12418
+ },
12419
+ {
12420
+ id: "workload.resume",
12421
+ method: "resume",
12422
+ label: {
12423
+ en: "Resume",
12424
+ it: "Riprendi"
12425
+ },
12426
+ phrase: {
12427
+ en: "Resume {device}",
12428
+ it: "Riprendi {device}"
12429
+ },
12430
+ icon: "circle-play",
12431
+ effect: {
12432
+ field: "state",
12433
+ value: "running"
12434
+ }
12435
+ },
12436
+ {
12437
+ id: "workload.forceStop",
12438
+ method: "forceStop",
12439
+ label: {
12440
+ en: "Force stop",
12441
+ it: "Arresto forzato"
12442
+ },
12443
+ phrase: {
12444
+ en: "Force {device} to stop",
12445
+ it: "Forza l’arresto di {device}"
12446
+ },
12447
+ icon: "octagon-x",
12448
+ effect: {
12449
+ field: "state",
12450
+ value: "stopped"
12451
+ }
12452
+ }
12453
+ ],
12454
+ state: [
12455
+ {
12456
+ kind: "enum",
12457
+ field: "state",
12458
+ label: {
12459
+ en: "State",
12460
+ it: "Stato"
12461
+ },
12462
+ values: [
12463
+ {
12464
+ value: "running",
12465
+ label: {
12466
+ en: "Running",
12467
+ it: "In esecuzione"
12468
+ },
12469
+ phrase: {
12470
+ en: "When {device} is running",
12471
+ it: "Quando {device} è in esecuzione"
12472
+ }
12473
+ },
12474
+ {
12475
+ value: "paused",
12476
+ label: {
12477
+ en: "Paused",
12478
+ it: "In pausa"
12479
+ }
12480
+ },
12481
+ {
12482
+ value: "stopped",
12483
+ label: {
12484
+ en: "Stopped",
12485
+ it: "Arrestato"
12486
+ },
12487
+ phrase: {
12488
+ en: "When {device} is stopped",
12489
+ it: "Quando {device} è arrestato"
12490
+ }
12491
+ },
12492
+ {
12493
+ value: "starting",
12494
+ label: {
12495
+ en: "Starting",
12496
+ it: "In avvio"
12497
+ }
12498
+ },
12499
+ {
12500
+ value: "stopping",
12501
+ label: {
12502
+ en: "Stopping",
12503
+ it: "In arresto"
12504
+ }
12505
+ },
12506
+ {
12507
+ value: "crashed",
12508
+ label: {
12509
+ en: "Crashed",
12510
+ it: "Arrestato in modo anomalo"
12511
+ },
12512
+ phrase: {
12513
+ en: "When {device} has crashed",
12514
+ it: "Quando {device} è arrestato in modo anomalo"
12515
+ }
12516
+ }
12517
+ ],
12518
+ icon: "activity"
12519
+ },
12520
+ {
12521
+ kind: "numeric",
12522
+ field: "resources.cpuPercent",
12523
+ quantity: {
12524
+ en: "the CPU use",
12525
+ it: "l'uso della CPU"
12526
+ },
12527
+ label: {
12528
+ en: "CPU",
12529
+ it: "CPU"
12530
+ },
12531
+ unit: "%",
12532
+ icon: "cpu"
12533
+ },
12534
+ {
12535
+ kind: "numeric",
12536
+ field: "resources.memoryPercent",
12537
+ quantity: {
12538
+ en: "the memory use",
12539
+ it: "l'uso della memoria"
12540
+ },
12541
+ label: {
12542
+ en: "Memory",
12543
+ it: "Memoria"
12544
+ },
12545
+ unit: "%",
12546
+ icon: "memory-stick"
12547
+ },
12548
+ {
12549
+ kind: "numeric",
12550
+ field: "resources.temperature",
12551
+ quantity: {
12552
+ en: "the temperature",
12553
+ it: "la temperatura"
12554
+ },
12555
+ label: {
12556
+ en: "Temperature",
12557
+ it: "Temperatura"
12558
+ },
12559
+ unit: "°C",
12560
+ icon: "thermometer"
12561
+ }
12562
+ ],
12563
+ events: {
12564
+ onStarted: {
12565
+ category: EventCategory.WorkloadStarted,
12566
+ label: {
12567
+ en: "Started",
12568
+ it: "Avviato"
12569
+ },
12570
+ phrase: {
12571
+ en: "When {device} starts",
12572
+ it: "Quando {device} si avvia"
12573
+ },
12574
+ icon: "play"
12575
+ },
12576
+ onStopped: {
12577
+ category: EventCategory.WorkloadStopped,
12578
+ label: {
12579
+ en: "Stopped",
12580
+ it: "Arrestato"
12581
+ },
12582
+ phrase: {
12583
+ en: "When {device} stops",
12584
+ it: "Quando {device} si arresta"
12585
+ },
12586
+ icon: "square"
12587
+ },
12588
+ onCrashed: {
12589
+ category: EventCategory.WorkloadCrashed,
12590
+ label: {
12591
+ en: "Crashed",
12592
+ it: "Arrestato in modo anomalo"
12593
+ },
12594
+ phrase: {
12595
+ en: "When {device} stops without being asked",
12596
+ it: "Quando {device} si arresta senza che sia stato richiesto"
12597
+ },
12598
+ icon: "triangle-alert"
12599
+ },
12600
+ onRecovered: {
12601
+ category: EventCategory.WorkloadRecovered,
12602
+ label: {
12603
+ en: "Recovered",
12604
+ it: "Ripristinato"
12605
+ },
12606
+ phrase: {
12607
+ en: "When {device} runs again after a crash",
12608
+ it: "Quando {device} riparte dopo un arresto anomalo"
12609
+ },
12610
+ icon: "heart-pulse"
12611
+ }
12612
+ },
12613
+ overrides: { byRole: {
12614
+ [DeviceRole.Vm]: {
12615
+ actions: { "workload.start": { icon: "monitor" } },
12616
+ state: { state: { icon: "monitor" } }
12617
+ },
12618
+ [DeviceRole.AppContainer]: {
12619
+ actions: { "workload.start": { icon: "container" } },
12620
+ state: { state: { icon: "container" } }
12621
+ },
12622
+ [DeviceRole.Lxc]: {
12623
+ actions: { "workload.start": { icon: "box" } },
12624
+ state: { state: { icon: "box" } }
12625
+ },
12626
+ [DeviceRole.App]: {
12627
+ actions: { "workload.start": { icon: "app-window" } },
12628
+ state: { state: { icon: "app-window" } }
12629
+ },
12630
+ [DeviceRole.Host]: {
12631
+ actions: {
12632
+ "workload.start": {
12633
+ label: {
12634
+ en: "Power on",
12635
+ it: "Accendi"
12636
+ },
12637
+ phrase: {
12638
+ en: "Power on {device}",
12639
+ it: "Accendi {device}"
12640
+ },
12641
+ icon: "power"
12642
+ },
12643
+ "workload.stop": {
12644
+ label: {
12645
+ en: "Shut down",
12646
+ it: "Spegni"
12647
+ },
12648
+ phrase: {
12649
+ en: "Shut down {device}",
12650
+ it: "Spegni {device}"
12651
+ },
12652
+ icon: "power-off"
12653
+ },
12654
+ "workload.restart": {
12655
+ label: {
12656
+ en: "Reboot",
12657
+ it: "Riavvia"
12658
+ },
12659
+ phrase: {
12660
+ en: "Reboot {device}",
12661
+ it: "Riavvia {device}"
12662
+ },
12663
+ icon: "refresh-cw"
12664
+ }
12665
+ },
12666
+ state: { state: { icon: "server" } },
12667
+ events: {
12668
+ onStarted: {
12669
+ label: {
12670
+ en: "Came online",
12671
+ it: "Tornato in linea"
12672
+ },
12673
+ phrase: {
12674
+ en: "When {device} comes online",
12675
+ it: "Quando {device} torna in linea"
12676
+ },
12677
+ icon: "server"
12678
+ },
12679
+ onStopped: {
12680
+ label: {
12681
+ en: "Shut down",
12682
+ it: "Spento"
12683
+ },
12684
+ phrase: {
12685
+ en: "When {device} shuts down",
12686
+ it: "Quando {device} si spegne"
12687
+ },
12688
+ icon: "server-off"
12689
+ },
12690
+ onCrashed: {
12691
+ label: {
12692
+ en: "Went down",
12693
+ it: "Caduto"
12694
+ },
12695
+ phrase: {
12696
+ en: "When {device} goes down unexpectedly",
12697
+ it: "Quando {device} cade inaspettatamente"
12698
+ },
12699
+ icon: "server-crash"
12700
+ },
12701
+ onRecovered: {
12702
+ label: {
12703
+ en: "Came online",
12704
+ it: "Tornato in linea"
12705
+ },
12706
+ phrase: {
12707
+ en: "When {device} comes back online after going down",
12708
+ it: "Quando {device} torna in linea dopo essere caduto"
12709
+ },
12710
+ icon: "server"
12711
+ }
12712
+ }
12713
+ }
12714
+ } }
12715
+ },
12229
12716
  "accessories": {
12230
12717
  scope: "device",
12231
12718
  noun: {
@@ -16062,6 +16549,15 @@ var PipelineStepInputSchema = zod.z.lazy(() => zod.z.object({
16062
16549
  }));
16063
16550
  /** Typed bridge to the recursive `FrameResult` graph; validation is structural. */
16064
16551
  var PipelineRunResultBridge = zod.z.custom();
16552
+ /**
16553
+ * Whether a switch can be set (D1058), schema-free so the addon runner can import it from
16554
+ * `@camstack/types/addon` without loading the capability schema graph (D28).
16555
+ */
16556
+ /** The read that decides whether a switch is offered on/off (`offeredWhen` of its actions). */
16557
+ var SWITCH_SETTABLE_GATE = {
16558
+ method: "getOptions",
16559
+ field: "supportsSetState"
16560
+ };
16065
16561
  var StaticDirOutputSchema = zod.z.object({ staticDir: zod.z.string() });
16066
16562
  var VersionOutputSchema = zod.z.object({ version: zod.z.string() });
16067
16563
  /**
@@ -16431,6 +16927,7 @@ var CAP_NAMES = Object.freeze([
16431
16927
  "weather",
16432
16928
  "weather-station",
16433
16929
  "webrtc-session",
16930
+ "workload",
16434
16931
  "zone-analytics",
16435
16932
  "zone-rules",
16436
16933
  "zones"
@@ -17733,6 +18230,14 @@ Object.freeze({
17733
18230
  "path": "ssid",
17734
18231
  "valueType": "string"
17735
18232
  },
18233
+ {
18234
+ "path": "speedKbps",
18235
+ "valueType": "number"
18236
+ },
18237
+ {
18238
+ "path": "linkUp",
18239
+ "valueType": "boolean"
18240
+ },
17736
18241
  {
17737
18242
  "path": "lastUpdated",
17738
18243
  "valueType": "number"
@@ -18129,6 +18634,14 @@ Object.freeze({
18129
18634
  "path": "durationSeconds",
18130
18635
  "valueType": "number"
18131
18636
  },
18637
+ {
18638
+ "path": "plays",
18639
+ "valueType": "number"
18640
+ },
18641
+ {
18642
+ "path": "activeUntilEstimated",
18643
+ "valueType": "boolean"
18644
+ },
18132
18645
  {
18133
18646
  "path": "lastTriggeredAt",
18134
18647
  "valueType": "number"
@@ -18531,6 +19044,92 @@ Object.freeze({
18531
19044
  "valueType": "number"
18532
19045
  }
18533
19046
  ],
19047
+ "workload": [
19048
+ {
19049
+ "path": "state",
19050
+ "valueType": "enum",
19051
+ "enumValues": [
19052
+ "running",
19053
+ "paused",
19054
+ "stopped",
19055
+ "starting",
19056
+ "stopping",
19057
+ "crashed"
19058
+ ]
19059
+ },
19060
+ {
19061
+ "path": "since",
19062
+ "valueType": "number"
19063
+ },
19064
+ {
19065
+ "path": "hostDeviceId",
19066
+ "valueType": "number"
19067
+ },
19068
+ {
19069
+ "path": "image",
19070
+ "valueType": "string"
19071
+ },
19072
+ {
19073
+ "path": "os",
19074
+ "valueType": "string"
19075
+ },
19076
+ {
19077
+ "path": "version",
19078
+ "valueType": "string"
19079
+ },
19080
+ {
19081
+ "path": "autostart",
19082
+ "valueType": "boolean"
19083
+ },
19084
+ {
19085
+ "path": "resources.cpuPercent",
19086
+ "valueType": "number"
19087
+ },
19088
+ {
19089
+ "path": "resources.memoryUsedBytes",
19090
+ "valueType": "number"
19091
+ },
19092
+ {
19093
+ "path": "resources.memoryPercent",
19094
+ "valueType": "number"
19095
+ },
19096
+ {
19097
+ "path": "resources.memoryLimitBytes",
19098
+ "valueType": "number"
19099
+ },
19100
+ {
19101
+ "path": "resources.vcpus",
19102
+ "valueType": "number"
19103
+ },
19104
+ {
19105
+ "path": "resources.diskUsedBytes",
19106
+ "valueType": "number"
19107
+ },
19108
+ {
19109
+ "path": "resources.diskTotalBytes",
19110
+ "valueType": "number"
19111
+ },
19112
+ {
19113
+ "path": "resources.netRxKbps",
19114
+ "valueType": "number"
19115
+ },
19116
+ {
19117
+ "path": "resources.netTxKbps",
19118
+ "valueType": "number"
19119
+ },
19120
+ {
19121
+ "path": "resources.load1",
19122
+ "valueType": "number"
19123
+ },
19124
+ {
19125
+ "path": "resources.temperature",
19126
+ "valueType": "number"
19127
+ },
19128
+ {
19129
+ "path": "updateAvailable",
19130
+ "valueType": "boolean"
19131
+ }
19132
+ ],
18534
19133
  "zone-analytics": [
18535
19134
  {
18536
19135
  "path": "ts",
@@ -18762,7 +19361,7 @@ function sleep(ms) {
18762
19361
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
18763
19362
  }
18764
19363
  //#endregion
18765
- //#region ../types/dist/implemented-methods-C5FMXLGP.mjs
19364
+ //#region ../types/dist/implemented-methods-u7ddjc-_.mjs
18766
19365
  var AUDIO_ENCODER_BY_CODEC = {
18767
19366
  opus: "libopus",
18768
19367
  aac: "aac",
@@ -21186,7 +21785,37 @@ var derivativeHelperObject = zod.z.object({
21186
21785
  ]),
21187
21786
  source: HelperMemberSchema
21188
21787
  });
21788
+ /** The stream profiles a camera grid can publish. */
21789
+ var GRID_PROFILES = [
21790
+ "high",
21791
+ "mid",
21792
+ "low"
21793
+ ];
21794
+ /** A rectangle in normalized [0,1] coordinates of whatever contains it. */
21795
+ var GridRectSchema = zod.z.object({
21796
+ x: zod.z.number().min(0).max(1),
21797
+ y: zod.z.number().min(0).max(1),
21798
+ width: zod.z.number().gt(0).max(1),
21799
+ height: zod.z.number().gt(0).max(1)
21800
+ });
21801
+ var GridCellSpecSchema = zod.z.object({
21802
+ source: CompositionSourceRefSchema,
21803
+ region: GridRectSchema,
21804
+ cell: GridRectSchema
21805
+ });
21806
+ var gridHelperObject = zod.z.object({
21807
+ kind: zod.z.literal("grid"),
21808
+ fps: zod.z.number().int().min(1).max(60),
21809
+ publishedProfiles: zod.z.array(zod.z.enum(GRID_PROFILES)).max(3),
21810
+ cells: zod.z.array(GridCellSpecSchema).max(16)
21811
+ });
21812
+ var terminalHelperObject = zod.z.object({
21813
+ kind: zod.z.literal("terminal"),
21814
+ terminalId: zod.z.string().uuid()
21815
+ });
21189
21816
  var HelperSpecSchema = zod.z.discriminatedUnion("kind", [
21817
+ gridHelperObject,
21818
+ terminalHelperObject,
21190
21819
  GroupHelperSpecSchema,
21191
21820
  statisticHelperObject,
21192
21821
  integralHelperObject,
@@ -21208,8 +21837,13 @@ function helperMembers(spec) {
21208
21837
  case "derivative": return [spec.source];
21209
21838
  case "arithmetic": return spec.inputs;
21210
21839
  case "expression": return spec.inputs.map((input) => input.member);
21840
+ case "grid":
21841
+ case "terminal": return [];
21211
21842
  }
21212
21843
  }
21844
+ function isEngineHostedHelper(spec) {
21845
+ return spec.kind === "grid" || spec.kind === "terminal";
21846
+ }
21213
21847
  /**
21214
21848
  * A COMPOSITION: a device assembled from other devices' state (D659).
21215
21849
  *
@@ -58940,9 +59574,10 @@ var GridProfileOfferSchema = zod.z.object({
58940
59574
  published: zod.z.boolean()
58941
59575
  });
58942
59576
  var GridLayoutViewSchema = zod.z.object({
58943
- /** The persisted grid row this camera was declared from. */
58944
- instanceId: zod.z.string(),
59577
+ /** The grid block (planning#580) whose camera this is. */
59578
+ blockId: zod.z.string(),
58945
59579
  deviceId: zod.z.number().int().nonnegative(),
59580
+ /** The device row's name — the only name a grid has; it is renamed on the block or the device. */
58946
59581
  name: zod.z.string(),
58947
59582
  /**
58948
59583
  * NO canvas size. A grid's resolution is not authored: each profile derives
@@ -58958,7 +59593,6 @@ var GridLayoutViewSchema = zod.z.object({
58958
59593
  });
58959
59594
  var GridLayoutPatchSchema = zod.z.object({
58960
59595
  deviceId: zod.z.number().int().nonnegative(),
58961
- name: zod.z.string().min(1).max(160).optional(),
58962
59596
  fps: zod.z.number().int().min(1).max(60).optional(),
58963
59597
  /** Which profiles to publish. See `GridProfileOffer.published`. */
58964
59598
  publishedProfiles: zod.z.array(zod.z.enum([
@@ -63411,7 +64045,8 @@ var CAP_CUSTOMIZE_CATALOG = {
63411
64045
  DeviceType.Dryer,
63412
64046
  DeviceType.Gateway,
63413
64047
  DeviceType.HeatPump,
63414
- DeviceType.EnergySystem
64048
+ DeviceType.EnergySystem,
64049
+ DeviceType.Workload
63415
64050
  ],
63416
64051
  apply: "add",
63417
64052
  vocabularyCap: "consumables",
@@ -65783,7 +66418,7 @@ function groupTemplate(id) {
65783
66418
  }
65784
66419
  /**
65785
66420
  * Cap history catalog, projected from every `*.cap.ts` `history` block.
65786
- * 46 caps with series (124 series), 39 caps answered `'none'`.
66421
+ * 47 caps with series (130 series), 39 caps answered `'none'`.
65787
66422
  * Field keys are `runtimeState` paths (`a.b` into fixed objects only).
65788
66423
  */
65789
66424
  var HISTORY_CATALOG = {
@@ -66416,6 +67051,48 @@ var HISTORY_CATALOG = {
66416
67051
  unit: "mm",
66417
67052
  deadband: .1
66418
67053
  }
67054
+ },
67055
+ "workload": {
67056
+ "state": {
67057
+ kind: "enum",
67058
+ values: [
67059
+ "running",
67060
+ "paused",
67061
+ "stopped",
67062
+ "starting",
67063
+ "stopping",
67064
+ "crashed"
67065
+ ]
67066
+ },
67067
+ "resources.cpuPercent": {
67068
+ kind: "gauge",
67069
+ unit: "%",
67070
+ deadband: 2,
67071
+ displayName: "CPU"
67072
+ },
67073
+ "resources.memoryUsedBytes": {
67074
+ kind: "gauge",
67075
+ unit: "bytes",
67076
+ displayName: "Memory used"
67077
+ },
67078
+ "resources.memoryPercent": {
67079
+ kind: "gauge",
67080
+ unit: "%",
67081
+ deadband: 2,
67082
+ displayName: "Memory"
67083
+ },
67084
+ "resources.netRxKbps": {
67085
+ group: "network",
67086
+ kind: "gauge",
67087
+ unit: "kbps",
67088
+ displayName: "Network received"
67089
+ },
67090
+ "resources.netTxKbps": {
67091
+ group: "network",
67092
+ kind: "gauge",
67093
+ unit: "kbps",
67094
+ displayName: "Network sent"
67095
+ }
66419
67096
  }
66420
67097
  };
66421
67098
  /**
@@ -66479,7 +67156,7 @@ var HISTORY_ITEM_CATALOG = {
66479
67156
  };
66480
67157
  /**
66481
67158
  * The series a device card trends, per cap (`history.primary` + `history.priority`):
66482
- * 6 caps. The card shows the primary of the enabled cap with the highest priority.
67159
+ * 7 caps. The card shows the primary of the enabled cap with the highest priority.
66483
67160
  */
66484
67161
  var HISTORY_PRIMARY = {
66485
67162
  "climate-control": {
@@ -66505,6 +67182,10 @@ var HISTORY_PRIMARY = {
66505
67182
  "weather-station": {
66506
67183
  field: "temperature",
66507
67184
  priority: 60
67185
+ },
67186
+ "workload": {
67187
+ field: "resources.cpuPercent",
67188
+ priority: 40
66508
67189
  }
66509
67190
  };
66510
67191
  /** The series specs of `capName`; empty for a `'none'` cap or an unknown one. */
@@ -66899,6 +67580,10 @@ function expressionDraft(spec) {
66899
67580
  draft: spec.output === "boolean" ? binarySensor(spec, source) : numericSensor(spec, source)
66900
67581
  };
66901
67582
  }
67583
+ /**
67584
+ * Project a helper spec onto the composition the composer already runs (D944).
67585
+ * Pure: it stores nothing. A group does not compile to `avg(...)` / `any(...)`.
67586
+ */
66902
67587
  function sameSource(a, b) {
66903
67588
  return a.addonId === b.addonId && a.stableId === b.stableId;
66904
67589
  }
@@ -67021,8 +67706,25 @@ function compileHelper(spec, retention = DEFAULT_HISTORY_RETENTION) {
67021
67706
  case "threshold": return compileMath(thresholdDraft(spec));
67022
67707
  case "arithmetic": return compileMath(arithmeticDraft(spec));
67023
67708
  case "expression": return compileMath(expressionDraft(spec));
67709
+ case "grid":
67710
+ case "terminal": return parseDraft(engineHostedDraft(spec));
67024
67711
  }
67025
67712
  }
67713
+ /**
67714
+ * A grid or a Terminal camera (planning#580): a bare `new` Camera. The composer
67715
+ * declares the row; the engine serves every cap on it, so there is nothing to
67716
+ * compose.
67717
+ */
67718
+ function engineHostedDraft(spec) {
67719
+ return {
67720
+ target: {
67721
+ kind: "new",
67722
+ type: DeviceType.Camera
67723
+ },
67724
+ helper: spec,
67725
+ features: []
67726
+ };
67727
+ }
67026
67728
  function compileMath(built) {
67027
67729
  if (built.problems.length > 0) return {
67028
67730
  ok: false,
@@ -67276,6 +67978,8 @@ var PowerSourceRefusalReasonSchema = zod.z.enum([
67276
67978
  "switch-unknown",
67277
67979
  "restart-in-progress",
67278
67980
  "switch-call-failed",
67981
+ "switch-options-unreadable",
67982
+ "not-settable",
67279
67983
  "switch-is-actuator"
67280
67984
  ]);
67281
67985
  var PowerSourceActionResultSchema = zod.z.discriminatedUnion("accepted", [zod.z.object({ accepted: zod.z.literal(true) }), zod.z.object({
@@ -67292,6 +67996,14 @@ var PowerSourceInfoSchema = zod.z.object({
67292
67996
  /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
67293
67997
  switchOn: zod.z.boolean().nullable(),
67294
67998
  switchOnline: zod.z.boolean().nullable(),
67999
+ /**
68000
+ * Whether the linked switch can be set (`switch.getOptions().supportsSetState`; a provider
68001
+ * without the method is a plain switch, `true`). `null` = not known: no link, the switch is
68002
+ * missing, or the read FAILED. Absent = a provider that predates the field. Only `false`
68003
+ * withdraws power on / off (`offeredWhen` of `powerSource.on` / `.off`, the device hero) —
68004
+ * unknown keeps them (D315, D1058).
68005
+ */
68006
+ switchSettable: zod.z.boolean().nullable().optional(),
67295
68007
  restartInProgress: zod.z.boolean(),
67296
68008
  offSeconds: zod.z.number().int()
67297
68009
  });
@@ -67349,6 +68061,11 @@ var powerSourceCustomize = {
67349
68061
  }]
67350
68062
  };
67351
68063
  var deviceInput$2 = zod.z.object({ deviceId: zod.z.number().int().nonnegative() });
68064
+ /** The read that decides whether power on / off are offered (`offeredWhen`, D1058). */
68065
+ var POWER_SOURCE_SETTABLE_GATE = {
68066
+ method: "getStatus",
68067
+ field: "switchSettable"
68068
+ };
67352
68069
  var powerSourceCapability = {
67353
68070
  name: "power-source",
67354
68071
  scope: "device",
@@ -67363,7 +68080,8 @@ var powerSourceCapability = {
67363
68080
  id: "powerSource.on",
67364
68081
  label: t("Power on", "Dai corrente"),
67365
68082
  phrase: t("Power on {device}", "Dai corrente a {device}"),
67366
- icon: "power"
68083
+ icon: "power",
68084
+ offeredWhen: POWER_SOURCE_SETTABLE_GATE
67367
68085
  }]
67368
68086
  }),
67369
68087
  powerOff: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
@@ -67373,7 +68091,8 @@ var powerSourceCapability = {
67373
68091
  id: "powerSource.off",
67374
68092
  label: t("Power off", "Togli corrente"),
67375
68093
  phrase: t("Cut the power of {device}", "Togli la corrente a {device}"),
67376
- icon: "power-off"
68094
+ icon: "power-off",
68095
+ offeredWhen: POWER_SOURCE_SETTABLE_GATE
67377
68096
  }]
67378
68097
  }),
67379
68098
  forceRestart: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
@@ -70354,6 +71073,335 @@ var SiteZoneSchema = zod.z.object({
70354
71073
  function siteZoneKey(label) {
70355
71074
  return label.trim().toLowerCase();
70356
71075
  }
71076
+ /**
71077
+ * Provider-declared device identifiers (D1059, planning#590).
71078
+ *
71079
+ * What a device IS, as its owning provider read it from the hardware: the keys a
71080
+ * later step matches across integrations to tell that two devices are the same
71081
+ * physical object. Separate from `DeviceMetadata` on purpose — metadata is a
71082
+ * free-form blob the operator can edit, identifiers are typed, normalised and
71083
+ * written ONLY by the provider that owns the device (`device-manager.
71084
+ * setIdentifiers`, owner-checked on the transport's caller stamp).
71085
+ *
71086
+ * | Key | Stored form | Strength |
71087
+ * | -------------- | ----------------------------------- | -------- |
71088
+ * | `mac` | `aa:bb:cc:dd:ee:ff`, several | strong |
71089
+ * | `serial` | `<manufacturer>:<serial>` | strong |
71090
+ * | `machine-uuid` | SMBIOS / VM / container uuid | strong |
71091
+ * | `vendor-uid` | `<vendor>:<id>` | strong |
71092
+ * | `hostname` | lower-case, no domain | weak |
71093
+ * | `ip` | IPv4 / IPv6 | weak |
71094
+ *
71095
+ * Strength is a property of the KEY, derived by {@link identifierStrength} —
71096
+ * never stored, so it cannot drift from the table above. A weak key never links
71097
+ * two devices on its own.
71098
+ *
71099
+ * The schema refuses a value that is not in its stored form, so whatever is
71100
+ * persisted is already normalised. Build a declaration with
71101
+ * {@link normaliseIdentifiers}, which turns the raw values a driver read into
71102
+ * that form and names every value it refused.
71103
+ */
71104
+ var DEVICE_IDENTIFIER_KEYS = [
71105
+ "mac",
71106
+ "serial",
71107
+ "machine-uuid",
71108
+ "vendor-uid",
71109
+ "hostname",
71110
+ "ip"
71111
+ ];
71112
+ var DeviceIdentifierKeySchema = zod.z.enum(DEVICE_IDENTIFIER_KEYS);
71113
+ /** `read` — the provider read it from the device; `derived` — computed from something else it read. */
71114
+ var DeviceIdentifierOriginSchema = zod.z.enum(["read", "derived"]);
71115
+ var MAC_PATTERN = /^[0-9a-f]{2}(?::[0-9a-f]{2}){5}$/;
71116
+ /** `<prefix>:<value>` — prefix a lower-case slug, value lower-case and non-blank. */
71117
+ var PREFIXED_PATTERN = /^[a-z0-9][a-z0-9._-]*:[^\sA-Z]+$/;
71118
+ var MACHINE_UUID_PATTERN = /^[0-9a-f][0-9a-f-]{7,}$/;
71119
+ var HOSTNAME_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
71120
+ function entrySchema(value) {
71121
+ return zod.z.object({
71122
+ value,
71123
+ origin: DeviceIdentifierOriginSchema,
71124
+ /** Epoch ms of the FIRST read that produced this value (and origin). A later
71125
+ * read of the same value does not move it — see {@link mergeIdentifiers}. */
71126
+ readAt: zod.z.number().int().nonnegative()
71127
+ }).strict();
71128
+ }
71129
+ var MacEntrySchema = entrySchema(zod.z.string().regex(MAC_PATTERN));
71130
+ var SerialEntrySchema = entrySchema(zod.z.string().regex(PREFIXED_PATTERN));
71131
+ var MachineUuidEntrySchema = entrySchema(zod.z.string().regex(MACHINE_UUID_PATTERN));
71132
+ var VendorUidEntrySchema = entrySchema(zod.z.string().regex(PREFIXED_PATTERN));
71133
+ var HostnameEntrySchema = entrySchema(zod.z.string().regex(HOSTNAME_PATTERN));
71134
+ var IpEntrySchema = entrySchema(zod.z.union([zod.z.ipv4(), zod.z.ipv6()]));
71135
+ zod.z.object({
71136
+ value: zod.z.string().min(1),
71137
+ origin: DeviceIdentifierOriginSchema,
71138
+ readAt: zod.z.number().int().nonnegative()
71139
+ }).strict();
71140
+ /** The typed declaration. Every key optional; `mac` the only one that holds several. */
71141
+ var DeviceIdentifiersSchema = zod.z.object({
71142
+ mac: zod.z.array(MacEntrySchema).min(1).readonly().optional(),
71143
+ serial: SerialEntrySchema.optional(),
71144
+ "machine-uuid": MachineUuidEntrySchema.optional(),
71145
+ "vendor-uid": VendorUidEntrySchema.optional(),
71146
+ hostname: HostnameEntrySchema.optional(),
71147
+ ip: IpEntrySchema.optional()
71148
+ }).strict();
71149
+ var STRENGTH = {
71150
+ mac: "strong",
71151
+ serial: "strong",
71152
+ "machine-uuid": "strong",
71153
+ "vendor-uid": "strong",
71154
+ hostname: "weak",
71155
+ ip: "weak"
71156
+ };
71157
+ /** How much a match on this key says about two devices being the same object. */
71158
+ function identifierStrength(key) {
71159
+ return STRENGTH[key];
71160
+ }
71161
+ /** True when the declaration carries no key at all. */
71162
+ function isEmptyIdentifiers(identifiers) {
71163
+ return DEVICE_IDENTIFIER_KEYS.every((key) => identifiers[key] === void 0);
71164
+ }
71165
+ /** Values devices report when they do not know: never an identity. */
71166
+ var PLACEHOLDER_PATTERN = /^(?:unknown|none|n\/?a|null|undefined|default|0+|-+)$/i;
71167
+ var NULL_MACS = new Set(["00:00:00:00:00:00", "ff:ff:ff:ff:ff:ff"]);
71168
+ function rejected(reason) {
71169
+ return {
71170
+ ok: false,
71171
+ reason
71172
+ };
71173
+ }
71174
+ /** `AA-BB-CC-DD-EE-FF`, `aabb.ccdd.eeff`, `AABBCCDDEEFF` → `aa:bb:cc:dd:ee:ff`. */
71175
+ function normaliseMac(raw) {
71176
+ const hex = raw.trim().toLowerCase().replace(/[\s:.-]/g, "");
71177
+ if (!/^[0-9a-f]{12}$/.test(hex)) return rejected("not a 48-bit MAC");
71178
+ const mac = (hex.match(/../g) ?? []).join(":");
71179
+ if (NULL_MACS.has(mac)) return rejected("placeholder MAC");
71180
+ return {
71181
+ ok: true,
71182
+ value: mac
71183
+ };
71184
+ }
71185
+ function slug$2(raw) {
71186
+ return raw.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[-._]+|[-._]+$/g, "");
71187
+ }
71188
+ function normalisePrefixed(prefixRaw, valueRaw, what) {
71189
+ const prefix = slug$2(prefixRaw);
71190
+ if (prefix.length === 0) return rejected(`no ${what}`);
71191
+ const value = valueRaw.trim().toLowerCase().replace(/\s+/g, "");
71192
+ if (value.length === 0) return rejected("blank value");
71193
+ if (PLACEHOLDER_PATTERN.test(value)) return rejected("placeholder value");
71194
+ return {
71195
+ ok: true,
71196
+ value: `${prefix}:${value}`
71197
+ };
71198
+ }
71199
+ function normaliseMachineUuid(raw) {
71200
+ const value = raw.trim().toLowerCase().replace(/^\{|\}$/g, "");
71201
+ if (!MACHINE_UUID_PATTERN.test(value)) return rejected("not a uuid");
71202
+ if (/^[0-]+$/.test(value) || /^[f-]+$/.test(value)) return rejected("placeholder uuid");
71203
+ return {
71204
+ ok: true,
71205
+ value
71206
+ };
71207
+ }
71208
+ function isIp(value) {
71209
+ return zod.z.union([zod.z.ipv4(), zod.z.ipv6()]).safeParse(value).success;
71210
+ }
71211
+ function normaliseHostname(raw) {
71212
+ const full = raw.trim().toLowerCase().replace(/\.$/, "");
71213
+ if (full.length === 0) return rejected("blank hostname");
71214
+ if (isIp(full)) return rejected("an address, not a hostname");
71215
+ const label = full.split(".")[0] ?? "";
71216
+ if (!HOSTNAME_PATTERN.test(label)) return rejected("not a hostname");
71217
+ if (label === "localhost") return rejected("placeholder hostname");
71218
+ return {
71219
+ ok: true,
71220
+ value: label
71221
+ };
71222
+ }
71223
+ function normaliseIp(raw) {
71224
+ const value = raw.trim().toLowerCase().replace(/^\[|\]$/g, "");
71225
+ if (!isIp(value)) return rejected("not an IP address");
71226
+ if (value === "0.0.0.0" || value === "::" || value === "::1" || value.startsWith("127.")) return rejected("loopback or unspecified address");
71227
+ return {
71228
+ ok: true,
71229
+ value
71230
+ };
71231
+ }
71232
+ function isBlank(value) {
71233
+ return value === null || value === void 0 || value.trim().length === 0;
71234
+ }
71235
+ /**
71236
+ * Turn what a driver read into a valid {@link DeviceIdentifiers}: MACs lower-case
71237
+ * with colons and de-duplicated, a hostname without its domain, an IP validated,
71238
+ * a serial prefixed by its manufacturer, a vendor uid by its vendor. A value that
71239
+ * cannot be normalised is left out and listed in `rejected` — the caller logs it
71240
+ * (with `tags: { deviceId }`), it is never dropped in silence.
71241
+ */
71242
+ function normaliseIdentifiers(raw, options = {}) {
71243
+ const readAt = options.readAt ?? Date.now();
71244
+ const originOf = (key) => options.originByKey?.[key] ?? options.origin ?? "read";
71245
+ const entry = (key, value) => ({
71246
+ value,
71247
+ origin: originOf(key),
71248
+ readAt
71249
+ });
71250
+ const refused = [];
71251
+ const take = (key, input, result) => {
71252
+ if (result.ok) return entry(key, result.value);
71253
+ refused.push({
71254
+ key,
71255
+ value: input,
71256
+ reason: result.reason
71257
+ });
71258
+ };
71259
+ const macInputs = raw.mac === null || raw.mac === void 0 ? [] : [raw.mac].flat();
71260
+ const macs = [];
71261
+ for (const input of macInputs) {
71262
+ if (isBlank(input)) continue;
71263
+ const taken = take("mac", input, normaliseMac(input));
71264
+ if (taken !== void 0 && !macs.some((m) => m.value === taken.value)) macs.push(taken);
71265
+ }
71266
+ const serial = raw.serial === null || raw.serial === void 0 || isBlank(raw.serial.serial) ? void 0 : take("serial", `${raw.serial.manufacturer}:${raw.serial.serial}`, normalisePrefixed(raw.serial.manufacturer, raw.serial.serial, "manufacturer"));
71267
+ const vendorUid = raw.vendorUid === null || raw.vendorUid === void 0 || isBlank(raw.vendorUid.id) ? void 0 : take("vendor-uid", `${raw.vendorUid.vendor}:${raw.vendorUid.id}`, normalisePrefixed(raw.vendorUid.vendor, raw.vendorUid.id, "vendor"));
71268
+ const machineUuid = isBlank(raw.machineUuid) ? void 0 : take("machine-uuid", raw.machineUuid, normaliseMachineUuid(raw.machineUuid));
71269
+ const host = isBlank(raw.host) ? null : raw.host.trim();
71270
+ const hostIsIp = host !== null && isIp(host.toLowerCase().replace(/^\[|\]$/g, ""));
71271
+ const hostnameInput = isBlank(raw.hostname) ? hostIsIp ? null : host : raw.hostname;
71272
+ const ipInput = isBlank(raw.ip) ? hostIsIp ? host : null : raw.ip;
71273
+ const hostname = hostnameInput === null ? void 0 : take("hostname", hostnameInput, normaliseHostname(hostnameInput));
71274
+ const ip = ipInput === null ? void 0 : take("ip", ipInput, normaliseIp(ipInput));
71275
+ return {
71276
+ identifiers: {
71277
+ ...macs.length > 0 ? { mac: macs } : {},
71278
+ ...serial !== void 0 ? { serial } : {},
71279
+ ...machineUuid !== void 0 ? { "machine-uuid": machineUuid } : {},
71280
+ ...vendorUid !== void 0 ? { "vendor-uid": vendorUid } : {},
71281
+ ...hostname !== void 0 ? { hostname } : {},
71282
+ ...ip !== void 0 ? { ip } : {}
71283
+ },
71284
+ rejected: refused
71285
+ };
71286
+ }
71287
+ function sameEntry(a, b) {
71288
+ return a.value === b.value && a.origin === b.origin;
71289
+ }
71290
+ /** `next`, but with the stored entry wherever value and origin are unchanged. */
71291
+ function keepStoredEntry(next, stored) {
71292
+ return stored !== void 0 && sameEntry(next, stored) ? stored : next;
71293
+ }
71294
+ /**
71295
+ * The declaration to store when the owning provider declares `next` over
71296
+ * `stored` (D1059).
71297
+ *
71298
+ * - A kind in `unread` — the provider TRIED to read it and the read failed —
71299
+ * keeps its stored entry: a failed read changes nothing (D49).
71300
+ * - Every other kind is what `next` says: a kind absent from `next` was read and
71301
+ * found absent, so it is removed.
71302
+ * - An entry whose value and origin are unchanged keeps its stored `readAt`:
71303
+ * `readAt` is when that value was FIRST read, so a provider re-declaring on every
71304
+ * boot writes nothing and emits nothing.
71305
+ *
71306
+ * Returns `null` when nothing is left.
71307
+ */
71308
+ function mergeIdentifiers(stored, next, unread = []) {
71309
+ const before = stored ?? {};
71310
+ const after = next ?? {};
71311
+ const failed = new Set(unread);
71312
+ const macs = failed.has("mac") ? before.mac : after.mac?.map((m) => keepStoredEntry(m, before.mac?.find((s) => sameEntry(s, m))));
71313
+ const single = (key) => {
71314
+ if (failed.has(key)) return before[key];
71315
+ const entry = after[key];
71316
+ return entry === void 0 ? void 0 : keepStoredEntry(entry, before[key]);
71317
+ };
71318
+ const serial = single("serial");
71319
+ const machineUuid = single("machine-uuid");
71320
+ const vendorUid = single("vendor-uid");
71321
+ const hostname = single("hostname");
71322
+ const ip = single("ip");
71323
+ const merged = {
71324
+ ...macs !== void 0 && macs.length > 0 ? { mac: macs } : {},
71325
+ ...serial !== void 0 ? { serial } : {},
71326
+ ...machineUuid !== void 0 ? { "machine-uuid": machineUuid } : {},
71327
+ ...vendorUid !== void 0 ? { "vendor-uid": vendorUid } : {},
71328
+ ...hostname !== void 0 ? { hostname } : {},
71329
+ ...ip !== void 0 ? { ip } : {}
71330
+ };
71331
+ return isEmptyIdentifiers(merged) ? null : merged;
71332
+ }
71333
+ /** True when two declarations hold the same entries, `readAt` included (key order ignored). */
71334
+ function sameIdentifiers(a, b) {
71335
+ const canonical = (v) => v === null || v === void 0 || isEmptyIdentifiers(v) ? "" : JSON.stringify(DEVICE_IDENTIFIER_KEYS.map((key) => [key, v[key] ?? null]).map(([key, e]) => [key, e === null ? null : [e].flat().map((x) => [
71336
+ x.value,
71337
+ x.origin,
71338
+ x.readAt
71339
+ ])]));
71340
+ return canonical(a) === canonical(b);
71341
+ }
71342
+ /**
71343
+ * Cross-integration identity candidates (planning#593, step 2 of D1059's epic).
71344
+ *
71345
+ * Two devices brought by DIFFERENT integrations that share provider-declared
71346
+ * identifiers ({@link DeviceIdentifiers}) are candidates for being the same
71347
+ * physical object. This module holds the answer's shape; the device-manager
71348
+ * keeps the index that finds the pairs and the ONE rule that grades a match
71349
+ * (`classifyIdentityMatch`, `device-identity-index.ts`).
71350
+ *
71351
+ * The rule (operator, planning#590):
71352
+ *
71353
+ * | Matched keys | Confidence |
71354
+ * | ---------------------------------------------- | ----------- |
71355
+ * | two strong KINDS (e.g. `mac` + `serial`) | `auto` |
71356
+ * | `mac` + `ip` | `auto` |
71357
+ * | exactly one strong kind | `proposal` |
71358
+ * | weak keys only (`hostname`, `ip`) | no candidate|
71359
+ *
71360
+ * Strength counts distinct KINDS, not values: two MACs of one device matching
71361
+ * the other's two MACs are still one kind of evidence, so a proposal. In doubt,
71362
+ * no match.
71363
+ *
71364
+ * Read-only: a candidate is NOT a link. Links are step 3.
71365
+ */
71366
+ var IdentityConfidenceSchema = zod.z.enum(["auto", "proposal"]);
71367
+ /** One identifier both devices declared, with the same normalised value. */
71368
+ var IdentityMatchedKeySchema = zod.z.object({
71369
+ key: DeviceIdentifierKeySchema,
71370
+ value: zod.z.string()
71371
+ });
71372
+ /** One side of a pair: the device and the integration that brought it. */
71373
+ var IdentityCandidateDeviceSchema = zod.z.object({
71374
+ deviceId: zod.z.number().int(),
71375
+ addonId: zod.z.string(),
71376
+ /** The integration instance (`int_NNNN`) that adopted it; `null` when none was stamped. */
71377
+ integrationId: zod.z.string().nullable()
71378
+ });
71379
+ /** Two devices of different integrations sharing at least one strong identifier. `a.deviceId < b.deviceId`. */
71380
+ var IdentityCandidatePairSchema = zod.z.object({
71381
+ a: IdentityCandidateDeviceSchema,
71382
+ b: IdentityCandidateDeviceSchema,
71383
+ /** Every identifier the two share, weak ones included, ordered by key then value. */
71384
+ keys: zod.z.array(IdentityMatchedKeySchema).readonly(),
71385
+ confidence: IdentityConfidenceSchema
71386
+ });
71387
+ /**
71388
+ * The answer of `device-manager.listIdentityCandidates`.
71389
+ *
71390
+ * - `unknown` — the index has not loaded yet: nothing can be said, and it is
71391
+ * NOT an empty list (D315).
71392
+ * - `answered` — `pairs` holds every candidate. `undeclaredDeviceIds` are the
71393
+ * devices with no identifiers on record: whether they match anything is
71394
+ * UNKNOWN, never "no match" (D393). A device absent from both lists declared
71395
+ * identifiers and matched nobody.
71396
+ */
71397
+ var IdentityCandidatesSchema = zod.z.discriminatedUnion("status", [zod.z.object({
71398
+ status: zod.z.literal("unknown"),
71399
+ reason: zod.z.string()
71400
+ }), zod.z.object({
71401
+ status: zod.z.literal("answered"),
71402
+ pairs: zod.z.array(IdentityCandidatePairSchema).readonly(),
71403
+ undeclaredDeviceIds: zod.z.array(zod.z.number().int()).readonly()
71404
+ })]);
70357
71405
  var DeviceSearchRequiresSchema = zod.z.object({
70358
71406
  /** Capability names the field wants a value of. Absent when the field wants actions only. */
70359
71407
  caps: zod.z.array(zod.z.string()).readonly().optional(),
@@ -70916,6 +71964,10 @@ var DeviceInfoSchema = zod.z.object({
70916
71964
  /** Hardware + identity blob (manufacturer / model / firmware / sn /
70917
71965
  * uid / mac / …). Populated by drivers; editable via setMetadata. */
70918
71966
  metadata: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
71967
+ /** Provider-declared identifiers (D1059): typed, normalised, written only by
71968
+ * the owning provider via `setIdentifiers`; read-only for the operator.
71969
+ * Absent ⇒ the provider declared none. */
71970
+ identifiers: DeviceIdentifiersSchema.optional(),
70919
71971
  /** Optional upstream-system identity + rendering envelope. See
70920
71972
  * `SourceInfo` in `packages/types/src/device/source-info.ts`. */
70921
71973
  sourceInfo: SourceInfoSchema.optional(),
@@ -71082,6 +72134,8 @@ var DeviceMetaSchema = zod.z.object({
71082
72134
  disabled: zod.z.boolean(),
71083
72135
  parentDeviceId: zod.z.number().nullable(),
71084
72136
  metadata: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
72137
+ /** Provider-declared identifiers (D1059). See `DeviceMeta.identifiers`. */
72138
+ identifiers: DeviceIdentifiersSchema.optional(),
71085
72139
  /** Optional upstream-system identity + rendering envelope. See
71086
72140
  * `SourceInfo`. Present when the device has been persisted with a
71087
72141
  * non-synthetic source identifier (HA entities, vendor MAC, …);
@@ -71563,6 +72617,38 @@ var deviceManagerCapability = {
71563
72617
  kind: "mutation",
71564
72618
  auth: "admin"
71565
72619
  }),
72620
+ /** Declare the device's identifiers (D1059) — the typed, normalised keys
72621
+ * (`mac`, `serial`, `machine-uuid`, `vendor-uid`, `hostname`, `ip`) a later
72622
+ * step matches across integrations. Each kind is REPLACED by what this call
72623
+ * says (absent = read and found absent, removed) EXCEPT the kinds listed in
72624
+ * `unread` — the reads that FAILED this time — which keep their stored value.
72625
+ * An unchanged value keeps its first `readAt`; a call that changes nothing
72626
+ * writes and emits nothing. `null` clears every read kind. Accepted only from the provider that OWNS the device: the
72627
+ * caller stamp the transport sets (`callerAddonId`) must equal the row's
72628
+ * `addonId`, so an operator session — which carries no stamp — is refused.
72629
+ * Build the value with `normaliseIdentifiers` (`@camstack/types`); a device
72630
+ * calls it through `BaseDevice.declareIdentifiers`. */
72631
+ setIdentifiers: method(zod.z.object({
72632
+ deviceId: zod.z.number(),
72633
+ identifiers: DeviceIdentifiersSchema.nullable(),
72634
+ /** Kinds the provider tried to read and could not: their stored value is kept. */
72635
+ unread: zod.z.array(DeviceIdentifierKeySchema).optional()
72636
+ }), zod.z.void(), {
72637
+ kind: "mutation",
72638
+ auth: "admin"
72639
+ }),
72640
+ /** Cross-integration identity candidates (planning#593) — READ-ONLY, links
72641
+ * nothing. Every pair of devices from DIFFERENT integrations that share a
72642
+ * strong identifier, with the keys they share and a confidence: `auto` (two
72643
+ * strong kinds, or `mac` + `ip`), `proposal` (one strong kind). Weak keys
72644
+ * alone never pair; a same-integration match is no candidate. Answered from
72645
+ * the device-manager's identifier index, never a fleet scan. `unknown`
72646
+ * until the index has loaded (never an empty list); `undeclaredDeviceIds`
72647
+ * are the devices whose identity is unknown, never "no match". */
72648
+ listIdentityCandidates: method(zod.z.object({}), IdentityCandidatesSchema, {
72649
+ kind: "query",
72650
+ auth: "admin"
72651
+ }),
71566
72652
  /** Operator-curated location registry. Returns the union of:
71567
72653
  * (1) labels persisted in the registry via `addLocation`, and
71568
72654
  * (2) labels currently in use on at least one device's
@@ -77895,6 +78981,7 @@ var HERO_SCENE_BY_TYPE = {
77895
78981
  [DeviceType.WaterHeater]: "heater",
77896
78982
  [DeviceType.HeatPump]: "heat-pump",
77897
78983
  [DeviceType.EnergySystem]: "generic",
78984
+ [DeviceType.Workload]: "generic",
77898
78985
  [DeviceType.Fan]: "fan",
77899
78986
  [DeviceType.MediaPlayer]: "tv",
77900
78987
  [DeviceType.AlarmPanel]: "alarm",
@@ -77937,6 +79024,7 @@ var HERO_SCENE_BY_ROLE = {
77937
79024
  [DeviceRole.SwitchHeater]: "heater",
77938
79025
  [DeviceRole.SwitchFan]: "fan",
77939
79026
  [DeviceRole.SwitchLight]: "light",
79027
+ [DeviceRole.PoePort]: "plug",
77940
79028
  [DeviceRole.ClimateAc]: "ac",
77941
79029
  [DeviceRole.ClimateThermostat]: "inherit",
77942
79030
  [DeviceRole.ClimateFloor]: "inherit",
@@ -77981,7 +79069,12 @@ var HERO_SCENE_BY_ROLE = {
77981
79069
  [DeviceRole.MessagingNotifier]: "inherit",
77982
79070
  [DeviceRole.EmailNotifier]: "inherit",
77983
79071
  [DeviceRole.GenericNotifier]: "inherit",
77984
- [DeviceRole.IrTransmitter]: "inherit"
79072
+ [DeviceRole.IrTransmitter]: "inherit",
79073
+ [DeviceRole.Vm]: "inherit",
79074
+ [DeviceRole.AppContainer]: "inherit",
79075
+ [DeviceRole.Lxc]: "inherit",
79076
+ [DeviceRole.App]: "inherit",
79077
+ [DeviceRole.Host]: "inherit"
77985
79078
  };
77986
79079
  function isDeviceType$3(type) {
77987
79080
  return Object.values(DeviceType).includes(type);
@@ -78239,8 +79332,12 @@ var HeroPowerSupplySlotSchema = zod.z.object({
78239
79332
  /** Off asks for a confirmation while the device runs. */
78240
79333
  confirmOffWhileRunning: zod.z.boolean(),
78241
79334
  running: zod.z.boolean().nullable(),
78242
- powerOn: HeroActionSchema,
78243
- powerOff: HeroActionSchema,
79335
+ /**
79336
+ * `null` when the linked switch ANSWERED it only reports (a PoE port seen through an
79337
+ * API key): power on / off would always be refused. The restart stays (D1058).
79338
+ */
79339
+ powerOn: HeroActionSchema.nullable(),
79340
+ powerOff: HeroActionSchema.nullable(),
78244
79341
  restart: HeroActionSchema
78245
79342
  });
78246
79343
  var HeroStateBackdropSchema = zod.z.object({
@@ -91741,6 +92838,19 @@ var NetworkLinkStatusSchema = zod.z.object({
91741
92838
  rssi: zod.z.number().optional().meta(readingMeta("signal-level")),
91742
92839
  /** Network name of a wireless link, when the firmware reports it. */
91743
92840
  ssid: zod.z.string().optional(),
92841
+ /**
92842
+ * Negotiated link speed of a wired port, the `bitrate` quantity in its base
92843
+ * unit, kbit/s (a gigabit port is 1 000 000); the display picks the unit.
92844
+ * `null` = the port is down or the speed is not known; absent = the provider
92845
+ * never reports one.
92846
+ */
92847
+ speedKbps: zod.z.number().nonnegative().nullable().optional().meta(readingMeta("bitrate")),
92848
+ /**
92849
+ * Whether the link is up. `type` names the medium, not its state, so a wired
92850
+ * port that lost its link is `ethernet` + `linkUp: false`. `null` = not known;
92851
+ * absent = the provider never reports it.
92852
+ */
92853
+ linkUp: zod.z.boolean().nullable().optional(),
91744
92854
  /** Ms epoch of the last observation. Lets consumers reason about freshness. */
91745
92855
  lastUpdated: zod.z.number().meta(readingMeta("none"))
91746
92856
  });
@@ -102073,7 +103183,18 @@ var videoclipsCapability = {
102073
103183
  * older than this field keeps working unchanged (D382 — an unstated
102074
103184
  * ask is zero).
102075
103185
  */
102076
- audio: ClipStreamAudioSchema.optional()
103186
+ audio: ClipStreamAudioSchema.optional(),
103187
+ /**
103188
+ * The operator's authorisation to wake a sleeping camera for this
103189
+ * dial — the same {@link ClipWakeSchema} the byte reads carry. Absent
103190
+ * — the default — means a sleeping standalone battery camera is
103191
+ * REFUSED by name before any URL is minted. A caller sets it only
103192
+ * when a viewer itself asked for the clip (the broker's `playClip`);
103193
+ * a prefetch, a reconcile or a retry never does. With it, the
103194
+ * provider wakes the camera and waits under a bound; a camera that
103195
+ * does not come up is refused `wake-timeout`, naming the wait.
103196
+ */
103197
+ wake: ClipWakeSchema.optional()
102077
103198
  }), ClipStreamDialSchema, {
102078
103199
  kind: "query",
102079
103200
  auth: "protected"
@@ -102363,7 +103484,8 @@ zod.z.enum([
102363
103484
  "camera-refused",
102364
103485
  "fetch-failed",
102365
103486
  "too-large-to-transfer",
102366
- "wake-expired"
103487
+ "wake-expired",
103488
+ "wake-timeout"
102367
103489
  ]);
102368
103490
  /** Candidate download URLs (LAN first, then operator extra hosts). */
102369
103491
  var ExportDownloadSchema = zod.z.object({
@@ -104999,6 +106121,16 @@ var SirenOptionsSchema = zod.z.object({
104999
106121
  rangeSeconds: SirenDurationRangeSchema.nullable(),
105000
106122
  /** The camera's default duration, seconds. */
105001
106123
  defaultSeconds: zod.z.number().positive(),
106124
+ /**
106125
+ * Discrete play counts the operator may pick; `null` when the camera gives a
106126
+ * range or does not count plays. Defaults to `null` so a provider that
106127
+ * predates plays (#589) reads as declaring none.
106128
+ */
106129
+ allowedPlays: zod.z.array(zod.z.number().int().positive()).nullable().default(null),
106130
+ /** Continuous range of play counts; `null` when listed or not counted. */
106131
+ rangePlays: SirenDurationRangeSchema.nullable().default(null),
106132
+ /** The camera's default play count; `null` when the camera does not count plays. */
106133
+ defaultPlays: zod.z.number().int().positive().nullable().default(null),
105002
106134
  /** What the camera counts natively. */
105003
106135
  unit: zod.z.enum([SirenDurationUnit.Seconds, SirenDurationUnit.Plays]),
105004
106136
  /** Seconds one play lasts, when `unit` is `plays`; `null` for a seconds camera. */
@@ -105015,9 +106147,28 @@ var SirenStatusSchema = zod.z.object({
105015
106147
  activeUntil: zod.z.number().nullable(),
105016
106148
  /** Duration of the current / last activation, seconds; `null` when none yet. */
105017
106149
  durationSeconds: zod.z.number().nullable(),
106150
+ /**
106151
+ * The play count of the current / last activation when it was asked in plays;
106152
+ * `null` when it was asked in seconds (or none yet). The unit that was asked.
106153
+ */
106154
+ plays: zod.z.number().int().positive().nullable().default(null),
106155
+ /**
106156
+ * True when `activeUntil` comes from a seconds-per-play factor the camera did
106157
+ * not report — the siren may fall silent somewhat earlier or later.
106158
+ */
106159
+ activeUntilEstimated: zod.z.boolean().default(false),
105018
106160
  /** Ms epoch of the last trigger (0 = never). */
105019
106161
  lastTriggeredAt: zod.z.number()
105020
106162
  });
106163
+ /** A trigger asks seconds OR plays (#589); neither means the camera default. */
106164
+ var SirenTriggerInputSchema = zod.z.object({
106165
+ deviceId: zod.z.number().int().nonnegative(),
106166
+ durationSeconds: zod.z.number().positive().optional(),
106167
+ plays: zod.z.number().int().positive().optional()
106168
+ }).refine((input) => input.durationSeconds === void 0 || input.plays === void 0, {
106169
+ message: "a siren trigger takes durationSeconds or plays, not both",
106170
+ path: ["plays"]
106171
+ });
105021
106172
  var SirenRuntimeStateSchema = SirenStatusSchema.extend({
105022
106173
  /** Ms epoch of the last successful camera read of the options (0 = never). */
105023
106174
  lastFetchedAt: zod.z.number() });
@@ -105034,13 +106185,20 @@ var sirenCapability = {
105034
106185
  auth: "protected"
105035
106186
  }),
105036
106187
  /**
105037
- * Sound the siren. Without `durationSeconds` the camera default applies.
105038
- * Answers the state at the moment of the trigger (`activeUntil` included).
106188
+ * The play counts a rule may pick: what `getOptions` declares as a list, or
106189
+ * its range spelled out. Empty for a siren that counts seconds.
105039
106190
  */
105040
- trigger: method(zod.z.object({
105041
- deviceId: zod.z.number().int().nonnegative(),
105042
- durationSeconds: zod.z.number().positive().optional()
105043
- }), SirenStatusSchema, {
106191
+ getPlayChoices: method(zod.z.object({ deviceId: zod.z.number().int().nonnegative() }), zod.z.array(zod.z.number().int().positive()), {
106192
+ kind: "query",
106193
+ auth: "protected"
106194
+ }),
106195
+ /**
106196
+ * Sound the siren for `durationSeconds` OR `plays` — never both. With
106197
+ * neither the camera default applies. A count on a siren that declares no
106198
+ * plays is refused. Answers the state at the moment of the trigger
106199
+ * (`activeUntil` included).
106200
+ */
106201
+ trigger: method(SirenTriggerInputSchema, SirenStatusSchema, {
105044
106202
  kind: "mutation",
105045
106203
  auth: "protected",
105046
106204
  actions: [{
@@ -105049,6 +106207,21 @@ var sirenCapability = {
105049
106207
  phrase: t("Sound {device}", "Fai suonare {device}"),
105050
106208
  icon: "siren",
105051
106209
  args: {}
106210
+ }, {
106211
+ id: "siren.triggerPlays",
106212
+ label: t("Sound the siren N times", "Fai suonare la sirena N volte"),
106213
+ phrase: t("Sound {device} {plays} times", "Fai suonare {device} {plays} volte"),
106214
+ icon: "siren",
106215
+ openArgs: [{
106216
+ key: "plays",
106217
+ label: t("Plays", "Riproduzioni"),
106218
+ offer: {
106219
+ kind: "dynamic",
106220
+ from: "method",
106221
+ method: "getPlayChoices",
106222
+ valueKind: "number"
106223
+ }
106224
+ }]
105052
106225
  }]
105053
106226
  }),
105054
106227
  /** Silence the siren now. */
@@ -106638,6 +107811,27 @@ var SwitchStatusSchema = zod.z.object({
106638
107811
  /** Ms epoch of the last state change. Useful for UI "X minutes ago". */
106639
107812
  lastChangedAt: zod.z.number()
106640
107813
  });
107814
+ /**
107815
+ * What a switch can do, from its provider (`getOptions`). A provider that writes no
107816
+ * `getOptions` is a plain on/off switch: the defaults are the old contract.
107817
+ *
107818
+ * - `supportsSetState: false` — the switch reports its state but cannot be set (a PoE port seen only
107819
+ * through an API key). Its provider refuses `setState`; these surfaces withdraw on/off once the
107820
+ * device ANSWERED this (`switchRefusesSetState`): the device hero, the automation action picker
107821
+ * (`offeredWhen` on `switch.on` / `switch.off` / `switch.toggle`), the default `toggle`, the
107822
+ * HomeKit, Alexa and Google exporters, and `power-source` on a device the switch powers
107823
+ * (`getStatus().switchSettable`, `offeredWhen` on `powerSource.on` / `.off`, `not-settable`). A
107824
+ * read that failed or is pending changes nothing (D315).
107825
+ * - `supportsPowerCycle: true` — the device behind the switch can cut and restore its own output in
107826
+ * one native call (a PoE port's power cycle). It has no control of its own: a linked
107827
+ * `power-source.forceRestart` uses it instead of off / wait / on.
107828
+ */
107829
+ var SwitchOptionsSchema = zod.z.object({
107830
+ supportsSetState: zod.z.boolean().default(true),
107831
+ supportsPowerCycle: zod.z.boolean().default(false)
107832
+ });
107833
+ /** The options of a provider that did not answer `getOptions`: a plain on/off switch. */
107834
+ var SWITCH_DEFAULT_OPTIONS = SwitchOptionsSchema.parse({});
106641
107835
  var switchCapability = {
106642
107836
  name: "switch",
106643
107837
  scope: "device",
@@ -106665,7 +107859,8 @@ var switchCapability = {
106665
107859
  field: "on",
106666
107860
  value: true
106667
107861
  },
106668
- args: { on: true }
107862
+ args: { on: true },
107863
+ offeredWhen: SWITCH_SETTABLE_GATE
106669
107864
  }, {
106670
107865
  id: "switch.off",
106671
107866
  label: t("Turn off", "Spegni"),
@@ -106675,9 +107870,16 @@ var switchCapability = {
106675
107870
  field: "on",
106676
107871
  value: false
106677
107872
  },
106678
- args: { on: false }
107873
+ args: { on: false },
107874
+ offeredWhen: SWITCH_SETTABLE_GATE
106679
107875
  }]
106680
107876
  }),
107877
+ getOptions: optionalMethod(zod.z.object({ deviceId: zod.z.number() }), SwitchOptionsSchema, { auth: "protected" }),
107878
+ powerCycle: optionalMethod(zod.z.object({ deviceId: zod.z.number() }), zod.z.void(), {
107879
+ kind: "mutation",
107880
+ auth: "protected",
107881
+ notOperatorFacing: "a power cycle is the forced restart of the device the switch powers (power-source), never a step of its own"
107882
+ }),
106681
107883
  toggle: optionalMethod(zod.z.object({ deviceId: zod.z.number() }), zod.z.void(), {
106682
107884
  kind: "mutation",
106683
107885
  auth: "protected",
@@ -106685,7 +107887,8 @@ var switchCapability = {
106685
107887
  id: "switch.toggle",
106686
107888
  label: t("Toggle", "Commuta"),
106687
107889
  phrase: t("Toggle {device}", "Commuta {device}"),
106688
- icon: "toggle-right"
107890
+ icon: "toggle-right",
107891
+ offeredWhen: SWITCH_SETTABLE_GATE
106689
107892
  }]
106690
107893
  })
106691
107894
  },
@@ -106707,6 +107910,16 @@ var switchCapability = {
106707
107910
  * not need to re-query the provider after a setState mutation.
106708
107911
  */
106709
107912
  runtimeState: SwitchStatusSchema,
107913
+ composedMethods: {
107914
+ getOptions: {
107915
+ kind: "answer",
107916
+ value: SWITCH_DEFAULT_OPTIONS
107917
+ },
107918
+ powerCycle: {
107919
+ kind: "refuse",
107920
+ reason: "a composed switch has no native power cycle"
107921
+ }
107922
+ },
106710
107923
  /**
106711
107924
  * Runtime-state durability: **restored** — device state an operator reads as authoritative; 55 devices, transition-driven.
106712
107925
  *
@@ -106880,6 +108093,26 @@ var switchCapability = {
106880
108093
  "switch.off": { icon: "plug" }
106881
108094
  },
106882
108095
  state: { on: { icon: "plug-zap" } }
108096
+ },
108097
+ [DeviceRole.PoePort]: {
108098
+ actions: {
108099
+ "switch.on": {
108100
+ label: t("Power on", "Alimenta"),
108101
+ phrase: t("Power on {device}", "Alimenta {device}"),
108102
+ icon: "plug-zap"
108103
+ },
108104
+ "switch.off": {
108105
+ label: t("Power off", "Togli alimentazione"),
108106
+ phrase: t("Power off {device}", "Togli alimentazione a {device}"),
108107
+ icon: "unplug"
108108
+ }
108109
+ },
108110
+ state: { on: {
108111
+ label: t("Powered", "Alimentata"),
108112
+ whenTrue: t("When {device} is powered", "Quando {device} viene alimentata"),
108113
+ whenFalse: t("When {device} loses power", "Quando {device} perde l’alimentazione"),
108114
+ icon: "plug-zap"
108115
+ } }
106883
108116
  }
106884
108117
  }
106885
108118
  }
@@ -108632,7 +109865,6 @@ var templateCapability = {
108632
109865
  };
108633
109866
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
108634
109867
  var ProfileSettingsSchemaBridge = zod.z.unknown().nullable();
108635
- var ProfileSettingsBagSchema = zod.z.record(zod.z.string(), zod.z.unknown());
108636
109868
  /**
108637
109869
  * A live terminal session hosted by the provider addon. Output and input do
108638
109870
  * NOT flow through the capability — they use the addon data plane
@@ -108675,39 +109907,6 @@ var TerminalProfileInfoSchema = zod.z.object({
108675
109907
  /** ConfigUISchema for instance knobs, or null when the profile has none. */
108676
109908
  settingsSchema: ProfileSettingsSchemaBridge.optional()
108677
109909
  });
108678
- /**
108679
- * A durable operator-created Terminal instance. Profiles are templates; only
108680
- * an instance declares a camera.
108681
- */
108682
- var TerminalInstanceInfoSchema = zod.z.object({
108683
- instanceId: zod.z.string(),
108684
- cameraStableId: zod.z.string(),
108685
- nodeId: zod.z.string(),
108686
- /**
108687
- * False while the node the instance is bound to is not in the cluster
108688
- * topology (forgotten, renamed, re-paired). The instance is kept; the
108689
- * operator re-points it on the Terminal page.
108690
- */
108691
- nodeInCluster: zod.z.boolean(),
108692
- profileId: zod.z.string(),
108693
- profileLabel: zod.z.string(),
108694
- name: zod.z.string(),
108695
- enabled: zod.z.boolean(),
108696
- executable: zod.z.string(),
108697
- args: zod.z.array(zod.z.string()).readonly(),
108698
- cwd: zod.z.string(),
108699
- environment: zod.z.array(zod.z.string()).readonly(),
108700
- profileSettings: ProfileSettingsBagSchema
108701
- });
108702
- var TerminalLegacyCameraSchema = zod.z.object({
108703
- stableId: zod.z.string(),
108704
- nodeId: zod.z.string(),
108705
- profileId: zod.z.string(),
108706
- profileLabel: zod.z.string(),
108707
- name: zod.z.string(),
108708
- /** Only legacy monitor cameras can retain their historic stable identity. */
108709
- adoptable: zod.z.boolean()
108710
- });
108711
109910
  var TerminalOutputEventSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
108712
109911
  seq: zod.z.number().int().positive(),
108713
109912
  kind: zod.z.literal("data"),
@@ -108739,8 +109938,8 @@ var TerminalOutputBatchSchema = zod.z.object({
108739
109938
  * terminal-session — singleton system capability for interactive TTY sessions.
108740
109939
  *
108741
109940
  * Owns both live PTY lifecycle and durable Terminal instance management.
108742
- * Profiles are allowlisted templates; an explicit instance is the only path
108743
- * that declares a camera.
109941
+ * Profiles are allowlisted templates; a Terminal camera is a core block naming
109942
+ * one Terminal (planning#580).
108744
109943
  */
108745
109944
  var terminalSessionCapability = {
108746
109945
  name: "terminal-session",
@@ -108749,16 +109948,6 @@ var terminalSessionCapability = {
108749
109948
  methods: {
108750
109949
  /** Pre-declared profiles the operator may open. */
108751
109950
  listProfiles: method(zod.z.void(), zod.z.array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }),
108752
- /** Existing automatic cameras are shown for explicit migration only. */
108753
- listLegacyCameras: method(zod.z.void(), zod.z.array(TerminalLegacyCameraSchema).readonly(), { auth: "admin" }),
108754
- /** Explicitly adopt one legacy monitor camera, retaining its stable id. */
108755
- adoptLegacyMonitor: method(zod.z.object({
108756
- stableId: zod.z.string().min(1),
108757
- name: zod.z.string().trim().min(1).max(160).optional()
108758
- }), TerminalInstanceInfoSchema, {
108759
- kind: "mutation",
108760
- auth: "admin"
108761
- }),
108762
109951
  /** Live sessions currently hosted by the provider. */
108763
109952
  listSessions: method(zod.z.void(), zod.z.array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }),
108764
109953
  /**
@@ -111907,6 +113096,454 @@ var webrtcSessionCapability = {
111907
113096
  order: 3340
111908
113097
  }
111909
113098
  };
113099
+ var WorkloadStateSchema = zod.z.enum([
113100
+ "running",
113101
+ "paused",
113102
+ "stopped",
113103
+ "starting",
113104
+ "stopping",
113105
+ "crashed"
113106
+ ]);
113107
+ /** The five kinds of workload, as roles of the `workload` device type (D1033). */
113108
+ var WORKLOAD_ROLES = [
113109
+ DeviceRole.Vm,
113110
+ DeviceRole.AppContainer,
113111
+ DeviceRole.Lxc,
113112
+ DeviceRole.App,
113113
+ DeviceRole.Host
113114
+ ];
113115
+ /**
113116
+ * What the workload uses. Every value is `null` when not reported (D393). A host
113117
+ * fills `load1` and `temperature`; its uptime is `since` while it runs.
113118
+ */
113119
+ var WorkloadResourcesSchema = zod.z.object({
113120
+ /** CPU use, percent of the CPUs it may use (0–100). */
113121
+ cpuPercent: zod.z.number().nullable().meta(readingMeta("percentage", { precision: 1 })),
113122
+ memoryUsedBytes: zod.z.number().nullable().meta(readingMeta("information")),
113123
+ /**
113124
+ * Memory use, percent of `memoryLimitBytes`, for a source that reports a share
113125
+ * and not bytes (a Docker container's stats). Absent or `null` = not reported.
113126
+ */
113127
+ memoryPercent: zod.z.number().nullable().optional().meta(readingMeta("percentage", { precision: 1 })),
113128
+ /** The memory it may use: the limit of a container, the RAM of a VM or host. */
113129
+ memoryLimitBytes: zod.z.number().nullable().meta(readingMeta("information")),
113130
+ vcpus: zod.z.number().nullable().meta(readingMeta("count")),
113131
+ diskUsedBytes: zod.z.number().nullable().meta(readingMeta("information")),
113132
+ diskTotalBytes: zod.z.number().nullable().meta(readingMeta("information")),
113133
+ /** Network received, kbit/s. */
113134
+ netRxKbps: zod.z.number().nullable().meta(readingMeta("bitrate")),
113135
+ /** Network sent, kbit/s. */
113136
+ netTxKbps: zod.z.number().nullable().meta(readingMeta("bitrate")),
113137
+ /** One-minute load average (a host). */
113138
+ load1: zod.z.number().nullable().meta(readingMeta("index", { precision: 2 })),
113139
+ /** CPU / board temperature (a host). */
113140
+ temperature: zod.z.number().nullable().meta(readingMeta("temperature", { precision: 1 }))
113141
+ });
113142
+ var WorkloadPortProtocolSchema = zod.z.enum(["tcp", "udp"]);
113143
+ /** One published port: the workload's own port and where the host exposes it. */
113144
+ var WorkloadPortSchema = zod.z.object({
113145
+ port: zod.z.number().int().meta(readingMeta("none")),
113146
+ /** The host port it is published on; null = not published. */
113147
+ hostPort: zod.z.number().int().nullable().meta(readingMeta("none")),
113148
+ /** The host address it is bound to; null = every address. */
113149
+ hostIp: zod.z.string().nullable(),
113150
+ protocol: WorkloadPortProtocolSchema
113151
+ });
113152
+ var WorkloadStatusSchema = zod.z.object({
113153
+ /** null = unknown, never stopped (D393). */
113154
+ state: WorkloadStateSchema.nullable().meta({ label: "State" }),
113155
+ /** Epoch ms the current state began (uptime while running); null when unknown. */
113156
+ since: zod.z.number().nullable().meta(readingMeta("none")),
113157
+ /** The `host` device this runs on, when the provider has adopted it. */
113158
+ hostDeviceId: zod.z.number().int().nullable().meta(readingMeta("device")),
113159
+ /** The image a container runs (`nginx:1.27`). */
113160
+ image: zod.z.string().nullable(),
113161
+ /** The operating system (a VM, an LXC, a host). */
113162
+ os: zod.z.string().nullable(),
113163
+ /** The version or firmware it runs. */
113164
+ version: zod.z.string().nullable(),
113165
+ /** Starts with its host; null when the platform does not say. */
113166
+ autostart: zod.z.boolean().nullable(),
113167
+ resources: WorkloadResourcesSchema,
113168
+ ports: zod.z.array(WorkloadPortSchema),
113169
+ /** The addresses it is reachable on (IPs or host names). */
113170
+ addresses: zod.z.array(zod.z.string()),
113171
+ /** A newer image / version exists. Installing it stays the `update` cap. */
113172
+ updateAvailable: zod.z.boolean().nullable(),
113173
+ lastFetchedAt: zod.z.number()
113174
+ });
113175
+ /**
113176
+ * What this device can do, probed by its provider (D14 honesty): a flag is
113177
+ * `true` only when the platform really serves it for THIS device.
113178
+ */
113179
+ var WorkloadOptionsSchema = zod.z.object({
113180
+ supportsStart: zod.z.boolean(),
113181
+ supportsStop: zod.z.boolean(),
113182
+ supportsRestart: zod.z.boolean(),
113183
+ /** Pause AND resume. */
113184
+ supportsPause: zod.z.boolean(),
113185
+ supportsForceStop: zod.z.boolean(),
113186
+ hasResources: zod.z.boolean(),
113187
+ hasPorts: zod.z.boolean(),
113188
+ hasAddresses: zod.z.boolean(),
113189
+ hasAutostart: zod.z.boolean(),
113190
+ hasUpdateCheck: zod.z.boolean()
113191
+ });
113192
+ var WorkloadDeviceInputSchema = zod.z.object({ deviceId: zod.z.number().int().nonnegative() });
113193
+ var WorkloadTransitionEventDataSchema = zod.z.object({
113194
+ deviceId: zod.z.number(),
113195
+ state: WorkloadStateSchema,
113196
+ previous: WorkloadStateSchema,
113197
+ since: zod.z.number().nullable()
113198
+ });
113199
+ function isWorkloadSettled(state) {
113200
+ return state !== "starting" && state !== "stopping";
113201
+ }
113202
+ /**
113203
+ * The event a move from the last SETTLED state to `next` raises, or null.
113204
+ * A first sight (`previous` undefined) raises nothing: it is not a change.
113205
+ * Unknown (`next` null) raises nothing and is not remembered.
113206
+ */
113207
+ function workloadTransition(previous, next) {
113208
+ if (previous === void 0 || next === null || next === previous) return null;
113209
+ switch (next) {
113210
+ case "running":
113211
+ if (previous === "crashed") return "recovered";
113212
+ return previous === "stopped" ? "started" : null;
113213
+ case "stopped": return previous === "running" || previous === "paused" ? "stopped" : null;
113214
+ case "crashed": return "crashed";
113215
+ case "paused":
113216
+ case "starting":
113217
+ case "stopping": return null;
113218
+ }
113219
+ }
113220
+ /** The bus category of each transition. */
113221
+ var WORKLOAD_TRANSITION_CATEGORY = {
113222
+ started: EventCategory.WorkloadStarted,
113223
+ stopped: EventCategory.WorkloadStopped,
113224
+ crashed: EventCategory.WorkloadCrashed,
113225
+ recovered: EventCategory.WorkloadRecovered
113226
+ };
113227
+ var workloadCapability = {
113228
+ name: "workload",
113229
+ scope: "device",
113230
+ deviceNative: true,
113231
+ mode: "singleton",
113232
+ deviceTypes: [DeviceType.Workload],
113233
+ deviceRoles: { [DeviceType.Workload]: WORKLOAD_ROLES },
113234
+ /**
113235
+ * On / off is the state (#462): stopped or crashed is off, anything else on.
113236
+ * The owner registers `switch` through `registerPowerSwitch`; there is no
113237
+ * second on/off state. A device whose provider serves no start / stop gets no
113238
+ * switch.
113239
+ */
113240
+ power: {
113241
+ kind: "methods",
113242
+ field: "state",
113243
+ offValues: ["stopped", "crashed"],
113244
+ on: "start",
113245
+ off: "stop"
113246
+ },
113247
+ methods: {
113248
+ start: optionalMethod(WorkloadDeviceInputSchema, zod.z.void(), {
113249
+ kind: "mutation",
113250
+ auth: "protected",
113251
+ actions: [{
113252
+ id: "workload.start",
113253
+ label: t("Start", "Avvia"),
113254
+ phrase: t("Start {device}", "Avvia {device}"),
113255
+ icon: "play",
113256
+ effect: {
113257
+ field: "state",
113258
+ value: "running"
113259
+ }
113260
+ }]
113261
+ }),
113262
+ stop: optionalMethod(WorkloadDeviceInputSchema, zod.z.void(), {
113263
+ kind: "mutation",
113264
+ auth: "protected",
113265
+ actions: [{
113266
+ id: "workload.stop",
113267
+ label: t("Stop", "Arresta"),
113268
+ phrase: t("Stop {device}", "Arresta {device}"),
113269
+ icon: "square",
113270
+ effect: {
113271
+ field: "state",
113272
+ value: "stopped"
113273
+ }
113274
+ }]
113275
+ }),
113276
+ restart: optionalMethod(WorkloadDeviceInputSchema, zod.z.void(), {
113277
+ kind: "mutation",
113278
+ auth: "protected",
113279
+ actions: [{
113280
+ id: "workload.restart",
113281
+ label: t("Restart", "Riavvia"),
113282
+ phrase: t("Restart {device}", "Riavvia {device}"),
113283
+ icon: "rotate-ccw"
113284
+ }]
113285
+ }),
113286
+ pause: optionalMethod(WorkloadDeviceInputSchema, zod.z.void(), {
113287
+ kind: "mutation",
113288
+ auth: "protected",
113289
+ actions: [{
113290
+ id: "workload.pause",
113291
+ label: t("Pause", "Metti in pausa"),
113292
+ phrase: t("Pause {device}", "Metti in pausa {device}"),
113293
+ icon: "pause",
113294
+ effect: {
113295
+ field: "state",
113296
+ value: "paused"
113297
+ }
113298
+ }]
113299
+ }),
113300
+ resume: optionalMethod(WorkloadDeviceInputSchema, zod.z.void(), {
113301
+ kind: "mutation",
113302
+ auth: "protected",
113303
+ actions: [{
113304
+ id: "workload.resume",
113305
+ label: t("Resume", "Riprendi"),
113306
+ phrase: t("Resume {device}", "Riprendi {device}"),
113307
+ icon: "circle-play",
113308
+ effect: {
113309
+ field: "state",
113310
+ value: "running"
113311
+ }
113312
+ }]
113313
+ }),
113314
+ forceStop: optionalMethod(WorkloadDeviceInputSchema, zod.z.void(), {
113315
+ kind: "mutation",
113316
+ auth: "admin",
113317
+ actions: [{
113318
+ id: "workload.forceStop",
113319
+ label: t("Force stop", "Arresto forzato"),
113320
+ phrase: t("Force {device} to stop", "Forza l’arresto di {device}"),
113321
+ icon: "octagon-x",
113322
+ effect: {
113323
+ field: "state",
113324
+ value: "stopped"
113325
+ }
113326
+ }]
113327
+ }),
113328
+ /** What THIS device can do, probed — the UI is derived from it. */
113329
+ getOptions: method(WorkloadDeviceInputSchema, WorkloadOptionsSchema, { auth: "protected" })
113330
+ },
113331
+ events: {
113332
+ onStarted: {
113333
+ data: WorkloadTransitionEventDataSchema,
113334
+ trigger: {
113335
+ category: EventCategory.WorkloadStarted,
113336
+ label: t("Started", "Avviato"),
113337
+ phrase: t("When {device} starts", "Quando {device} si avvia"),
113338
+ icon: "play"
113339
+ }
113340
+ },
113341
+ onStopped: {
113342
+ data: WorkloadTransitionEventDataSchema,
113343
+ trigger: {
113344
+ category: EventCategory.WorkloadStopped,
113345
+ label: t("Stopped", "Arrestato"),
113346
+ phrase: t("When {device} stops", "Quando {device} si arresta"),
113347
+ icon: "square"
113348
+ }
113349
+ },
113350
+ onCrashed: {
113351
+ data: WorkloadTransitionEventDataSchema,
113352
+ trigger: {
113353
+ category: EventCategory.WorkloadCrashed,
113354
+ label: t("Crashed", "Arrestato in modo anomalo"),
113355
+ phrase: t("When {device} stops without being asked", "Quando {device} si arresta senza che sia stato richiesto"),
113356
+ icon: "triangle-alert"
113357
+ }
113358
+ },
113359
+ onRecovered: {
113360
+ data: WorkloadTransitionEventDataSchema,
113361
+ trigger: {
113362
+ category: EventCategory.WorkloadRecovered,
113363
+ label: t("Recovered", "Ripristinato"),
113364
+ phrase: t("When {device} runs again after a crash", "Quando {device} riparte dopo un arresto anomalo"),
113365
+ icon: "heart-pulse"
113366
+ }
113367
+ }
113368
+ },
113369
+ status: {
113370
+ schema: WorkloadStatusSchema,
113371
+ kind: "poll"
113372
+ },
113373
+ runtimeState: WorkloadStatusSchema,
113374
+ /**
113375
+ * Runtime-state durability: **session** — the provider answers on its next
113376
+ * poll; the series are recorded, so a restart that clears the slice loses
113377
+ * nothing a reader needs. The events are judged from the first state seen.
113378
+ */
113379
+ durability: "session",
113380
+ /**
113381
+ * History (D850): the state as an enum, CPU / memory / network as gauges, so
113382
+ * the charts need no per-metric child device.
113383
+ */
113384
+ history: {
113385
+ primary: "resources.cpuPercent",
113386
+ priority: 40,
113387
+ fields: {
113388
+ state: { kind: "enum" },
113389
+ "resources.cpuPercent": {
113390
+ kind: "gauge",
113391
+ unit: "%",
113392
+ deadband: 2,
113393
+ displayName: "CPU"
113394
+ },
113395
+ "resources.memoryUsedBytes": {
113396
+ kind: "gauge",
113397
+ unit: "bytes",
113398
+ displayName: "Memory used"
113399
+ },
113400
+ "resources.memoryPercent": {
113401
+ kind: "gauge",
113402
+ unit: "%",
113403
+ deadband: 2,
113404
+ displayName: "Memory"
113405
+ },
113406
+ "resources.netRxKbps": {
113407
+ group: "network",
113408
+ kind: "gauge",
113409
+ unit: "kbps",
113410
+ displayName: "Network received"
113411
+ },
113412
+ "resources.netTxKbps": {
113413
+ group: "network",
113414
+ kind: "gauge",
113415
+ unit: "kbps",
113416
+ displayName: "Network sent"
113417
+ }
113418
+ }
113419
+ },
113420
+ volatileStateFields: ["lastFetchedAt"],
113421
+ vocabulary: {
113422
+ noun: t("Workload", "Carico di lavoro"),
113423
+ order: 2400,
113424
+ state: [
113425
+ {
113426
+ kind: "enum",
113427
+ field: "state",
113428
+ label: t("State", "Stato"),
113429
+ values: [
113430
+ {
113431
+ value: "running",
113432
+ label: t("Running", "In esecuzione"),
113433
+ phrase: t("When {device} is running", "Quando {device} è in esecuzione")
113434
+ },
113435
+ {
113436
+ value: "paused",
113437
+ label: t("Paused", "In pausa")
113438
+ },
113439
+ {
113440
+ value: "stopped",
113441
+ label: t("Stopped", "Arrestato"),
113442
+ phrase: t("When {device} is stopped", "Quando {device} è arrestato")
113443
+ },
113444
+ {
113445
+ value: "starting",
113446
+ label: t("Starting", "In avvio")
113447
+ },
113448
+ {
113449
+ value: "stopping",
113450
+ label: t("Stopping", "In arresto")
113451
+ },
113452
+ {
113453
+ value: "crashed",
113454
+ label: t("Crashed", "Arrestato in modo anomalo"),
113455
+ phrase: t("When {device} has crashed", "Quando {device} è arrestato in modo anomalo")
113456
+ }
113457
+ ],
113458
+ icon: "activity"
113459
+ },
113460
+ {
113461
+ kind: "numeric",
113462
+ field: "resources.cpuPercent",
113463
+ quantity: t("the CPU use", "l'uso della CPU"),
113464
+ label: t("CPU", "CPU"),
113465
+ unit: "%",
113466
+ icon: "cpu"
113467
+ },
113468
+ {
113469
+ kind: "numeric",
113470
+ field: "resources.memoryPercent",
113471
+ quantity: t("the memory use", "l'uso della memoria"),
113472
+ label: t("Memory", "Memoria"),
113473
+ unit: "%",
113474
+ icon: "memory-stick"
113475
+ },
113476
+ {
113477
+ kind: "numeric",
113478
+ field: "resources.temperature",
113479
+ quantity: t("the temperature", "la temperatura"),
113480
+ label: t("Temperature", "Temperatura"),
113481
+ unit: "°C",
113482
+ icon: "thermometer"
113483
+ }
113484
+ ],
113485
+ overrides: { byRole: {
113486
+ [DeviceRole.Vm]: {
113487
+ actions: { "workload.start": { icon: "monitor" } },
113488
+ state: { state: { icon: "monitor" } }
113489
+ },
113490
+ [DeviceRole.AppContainer]: {
113491
+ actions: { "workload.start": { icon: "container" } },
113492
+ state: { state: { icon: "container" } }
113493
+ },
113494
+ [DeviceRole.Lxc]: {
113495
+ actions: { "workload.start": { icon: "box" } },
113496
+ state: { state: { icon: "box" } }
113497
+ },
113498
+ [DeviceRole.App]: {
113499
+ actions: { "workload.start": { icon: "app-window" } },
113500
+ state: { state: { icon: "app-window" } }
113501
+ },
113502
+ [DeviceRole.Host]: {
113503
+ actions: {
113504
+ "workload.start": {
113505
+ label: t("Power on", "Accendi"),
113506
+ phrase: t("Power on {device}", "Accendi {device}"),
113507
+ icon: "power"
113508
+ },
113509
+ "workload.stop": {
113510
+ label: t("Shut down", "Spegni"),
113511
+ phrase: t("Shut down {device}", "Spegni {device}"),
113512
+ icon: "power-off"
113513
+ },
113514
+ "workload.restart": {
113515
+ label: t("Reboot", "Riavvia"),
113516
+ phrase: t("Reboot {device}", "Riavvia {device}"),
113517
+ icon: "refresh-cw"
113518
+ }
113519
+ },
113520
+ state: { state: { icon: "server" } },
113521
+ events: {
113522
+ onStarted: {
113523
+ label: t("Came online", "Tornato in linea"),
113524
+ phrase: t("When {device} comes online", "Quando {device} torna in linea"),
113525
+ icon: "server"
113526
+ },
113527
+ onStopped: {
113528
+ label: t("Shut down", "Spento"),
113529
+ phrase: t("When {device} shuts down", "Quando {device} si spegne"),
113530
+ icon: "server-off"
113531
+ },
113532
+ onCrashed: {
113533
+ label: t("Went down", "Caduto"),
113534
+ phrase: t("When {device} goes down unexpectedly", "Quando {device} cade inaspettatamente"),
113535
+ icon: "server-crash"
113536
+ },
113537
+ onRecovered: {
113538
+ label: t("Came online", "Tornato in linea"),
113539
+ phrase: t("When {device} comes back online after going down", "Quando {device} torna in linea dopo essere caduto"),
113540
+ icon: "server"
113541
+ }
113542
+ }
113543
+ }
113544
+ } }
113545
+ }
113546
+ };
111910
113547
  /**
111911
113548
  * Per-zone occupancy aggregation produced by the analytics frame
111912
113549
  * processor on every inference result. Covers the full combinatorial
@@ -112572,6 +114209,7 @@ var ALL_CAPABILITY_DEFINITIONS = [
112572
114209
  weatherCapability,
112573
114210
  weatherStationCapability,
112574
114211
  webrtcSessionCapability,
114212
+ workloadCapability,
112575
114213
  zoneAnalyticsCapability,
112576
114214
  zoneRulesCapability,
112577
114215
  zonesCapability
@@ -114631,6 +116269,438 @@ function withDefaultRunning(composition, blockId) {
114631
116269
  features: [...composition.features, feature]
114632
116270
  };
114633
116271
  }
116272
+ /** Marker written to a declared integration's `info`. */
116273
+ var DECLARED_INTEGRATION_FIXED_KEY = "fixed";
116274
+ /**
116275
+ * Give a declared integration its instance record, ONCE. The record is read first and left
116276
+ * exactly as it is when it exists (an operator's rename, a field the addon later adds): a seed
116277
+ * never overwrites. A read that fails throws and writes nothing (D49) — the next pass retries.
116278
+ * True when the record was written by this call.
116279
+ */
116280
+ async function seedInstanceOnce(instances, seed) {
116281
+ const existing = await instances.getInstance({ id: seed.id });
116282
+ if (existing !== null && existing !== void 0) return false;
116283
+ await instances.createInstance({
116284
+ id: seed.id,
116285
+ name: seed.name
116286
+ });
116287
+ return true;
116288
+ }
116289
+ /**
116290
+ * Strip the `<node>/<addon>` suffix a forked child carries.
116291
+ *
116292
+ * Comparing `ctx.kernel.localNodeId` raw skipped EVERY node — including the one
116293
+ * that was supposed to act — because on the hub it reads `hub/<addon>`.
116294
+ */
116295
+ function declarationOwnerNodeId(localNodeId) {
116296
+ const raw = localNodeId ?? "hub";
116297
+ if (!raw.includes("/")) return raw;
116298
+ return raw.split("/")[0] ?? "hub";
116299
+ }
116300
+ /**
116301
+ * The one way an addon owns a device it declares.
116302
+ *
116303
+ * Construct once with the addon's ports, then call {@link reconcile} on boot and
116304
+ * on every convergence tick. There is no second get-or-create helper — a guard
116305
+ * in `scripts/` enforces that.
116306
+ */
116307
+ var DeclaredDevices = class {
116308
+ ports;
116309
+ constructor(ports) {
116310
+ const addonId = ports.addonId;
116311
+ if (typeof addonId !== "string" || addonId.length === 0) throw new Error(`DeclaredDevices: addonId must be the declaring addon's id, got ${JSON.stringify(addonId)}. On an addon context it is \`ctx.id\` — there is no \`ctx.addonId\`.`);
116312
+ this.ports = ports;
116313
+ }
116314
+ /**
116315
+ * Converge the declared set. Idempotent, and safe to call repeatedly.
116316
+ *
116317
+ * Throws only what the ports throw on the FIRST index read; every other
116318
+ * failure is per-device and logged, so one bad declaration never takes the
116319
+ * others down.
116320
+ */
116321
+ async reconcile(spec) {
116322
+ if ((spec.placement ?? "hub") === "hub") {
116323
+ const nodeId = declarationOwnerNodeId(this.ports.localNodeId);
116324
+ if (nodeId !== "hub") {
116325
+ this.ports.logger.info("declared devices are hub-owned — skipping on this node", { meta: {
116326
+ nodeId,
116327
+ rawNodeId: this.ports.localNodeId ?? null
116328
+ } });
116329
+ return {
116330
+ integrationId: null,
116331
+ devices: [],
116332
+ removed: [],
116333
+ owned: false
116334
+ };
116335
+ }
116336
+ }
116337
+ let integrationId;
116338
+ if (spec.integrationId !== void 0) integrationId = spec.integrationId;
116339
+ else {
116340
+ const own = await this.ensureIntegration(spec.integrationName);
116341
+ integrationId = own.id;
116342
+ await this.seedInstance(own);
116343
+ }
116344
+ const index = await this.readIndex();
116345
+ const live = await this.readLiveByStableId();
116346
+ const outcomes = [];
116347
+ for (const declaration of spec.devices) {
116348
+ const outcome = await this.applyDeclaration(declaration, integrationId, index, live);
116349
+ if (outcome !== null) outcomes.push(outcome);
116350
+ }
116351
+ const removed = await this.sweepWithdrawn(spec.devices, integrationId, index);
116352
+ return {
116353
+ integrationId,
116354
+ devices: outcomes,
116355
+ removed,
116356
+ owned: true
116357
+ };
116358
+ }
116359
+ /**
116360
+ * Get-or-create the FIXED integration, and RE-ASSERT the flag every pass.
116361
+ *
116362
+ * The re-assertion is the fix for the defect the hand-rolled version shipped
116363
+ * with: writing `info.fixed` only on the create path left every pre-existing
116364
+ * install without it, and the kernel kept offering to delete an integration
116365
+ * the addon owns.
116366
+ */
116367
+ async ensureIntegration(integrationName) {
116368
+ const existing = await this.ports.getIntegration(this.ports.addonId);
116369
+ if (existing === null) {
116370
+ const created = await this.ports.createIntegration({
116371
+ addonId: this.ports.addonId,
116372
+ name: integrationName,
116373
+ info: { [DECLARED_INTEGRATION_FIXED_KEY]: true }
116374
+ });
116375
+ this.ports.logger.info("declared a fixed integration", { meta: {
116376
+ integrationId: created.id,
116377
+ name: integrationName
116378
+ } });
116379
+ return {
116380
+ id: created.id,
116381
+ name: integrationName
116382
+ };
116383
+ }
116384
+ if (existing.info?.["fixed"] !== true) {
116385
+ await this.ports.updateIntegration({
116386
+ id: existing.id,
116387
+ info: { [DECLARED_INTEGRATION_FIXED_KEY]: true }
116388
+ });
116389
+ this.ports.logger.info("re-asserted `fixed` on a declared integration", { meta: { integrationId: existing.id } });
116390
+ }
116391
+ return {
116392
+ id: existing.id,
116393
+ name: existing.name ?? integrationName
116394
+ };
116395
+ }
116396
+ /** Seed the instance record of an integration this declarer owns; best-effort, retried next pass. */
116397
+ async seedInstance(integration) {
116398
+ const { seedInstance } = this.ports;
116399
+ if (seedInstance === void 0) return;
116400
+ try {
116401
+ await seedInstance({
116402
+ id: integration.id,
116403
+ name: integration.name
116404
+ });
116405
+ } catch (err) {
116406
+ this.ports.logger.warn("could not seed the instance record of a declared integration", {
116407
+ tags: { integrationId: integration.id },
116408
+ meta: { error: errMsg(err) }
116409
+ });
116410
+ }
116411
+ }
116412
+ async readIndex() {
116413
+ const rows = await this.ports.listOwnDevices();
116414
+ return new Map(rows.map((row) => [row.stableId, row]));
116415
+ }
116416
+ /**
116417
+ * Devices this kernel already has CONSTRUCTED, by stableId.
116418
+ *
116419
+ * Distinct from {@link readIndex}, and the distinction is the bug: the index
116420
+ * is persisted rows, this is live objects. A row without an object must be
116421
+ * adopted; an object must be left exactly as it is.
116422
+ *
116423
+ * Failure is non-fatal and deliberately so — an empty map degrades to the
116424
+ * previous behaviour (attempt the adopt) rather than skipping a device that
116425
+ * genuinely needs bringing up.
116426
+ */
116427
+ async readLiveByStableId() {
116428
+ try {
116429
+ const devices = await this.ports.devices.getAll();
116430
+ return new Map(devices.map((device) => [device.stableId, device]));
116431
+ } catch (err) {
116432
+ this.ports.logger.warn("could not read live devices — falling back to adopt-by-row", { meta: { error: err instanceof Error ? err.message : String(err) } });
116433
+ return /* @__PURE__ */ new Map();
116434
+ }
116435
+ }
116436
+ /**
116437
+ * One declaration: adopt what exists, create what does not.
116438
+ *
116439
+ * The create branch is the destructive one — it seeds `initialMeta`, and
116440
+ * `initialMeta.name` lands as an unconditional `setName`. A transiently empty
116441
+ * index therefore looks exactly like a first boot and would silently re-stamp
116442
+ * the declared name over the operator's rename. D49: that branch needs a
116443
+ * second read to agree.
116444
+ */
116445
+ async applyDeclaration(declaration, integrationId, index, live) {
116446
+ try {
116447
+ const alreadyLive = live.get(declaration.stableId);
116448
+ if (alreadyLive !== void 0) return {
116449
+ stableId: declaration.stableId,
116450
+ deviceId: alreadyLive.id,
116451
+ device: alreadyLive,
116452
+ created: false
116453
+ };
116454
+ let existing = index.get(declaration.stableId);
116455
+ if (existing === void 0) {
116456
+ existing = (await this.readIndex()).get(declaration.stableId);
116457
+ if (existing !== void 0) this.ports.logger.warn("device index disagreed with itself — adopting instead of re-creating", {
116458
+ tags: { deviceId: existing.id },
116459
+ meta: {
116460
+ stableId: declaration.stableId,
116461
+ addonId: this.ports.addonId
116462
+ }
116463
+ });
116464
+ }
116465
+ if (existing !== void 0) {
116466
+ const device = await this.ports.devices.create(declaration.stableId, declaration.DeviceClass, {}, null, void 0);
116467
+ this.ports.logger.info("declared device adopted", {
116468
+ tags: { deviceId: device.id },
116469
+ meta: {
116470
+ stableId: declaration.stableId,
116471
+ integrationId
116472
+ }
116473
+ });
116474
+ return {
116475
+ stableId: declaration.stableId,
116476
+ deviceId: device.id,
116477
+ device,
116478
+ created: false
116479
+ };
116480
+ }
116481
+ const device = await this.ports.devices.create(declaration.stableId, declaration.DeviceClass, declaration.config ?? {}, null, {
116482
+ type: declaration.type,
116483
+ name: declaration.name,
116484
+ integrationId,
116485
+ ...declaration.role === void 0 ? {} : { role: declaration.role }
116486
+ });
116487
+ this.ports.logger.info("declared device created", {
116488
+ tags: { deviceId: device.id },
116489
+ meta: {
116490
+ stableId: declaration.stableId,
116491
+ integrationId
116492
+ }
116493
+ });
116494
+ return {
116495
+ stableId: declaration.stableId,
116496
+ deviceId: device.id,
116497
+ device,
116498
+ created: true
116499
+ };
116500
+ } catch (err) {
116501
+ this.ports.logger.warn("a declared device could not be brought up", { meta: {
116502
+ stableId: declaration.stableId,
116503
+ error: err instanceof Error ? err.message : String(err)
116504
+ } });
116505
+ return null;
116506
+ }
116507
+ }
116508
+ /**
116509
+ * Remove rows under the addon's FIXED integration whose declaration is gone.
116510
+ *
116511
+ * Bounded to that integration: a declared integration has no operator
116512
+ * add-flow, so every row under it got there by declaration. Devices this
116513
+ * addon owns OUTSIDE it (a provider's adopted devices) are never candidates.
116514
+ *
116515
+ * Bounded in count, and every deletion is logged with its `deviceId` — a
116516
+ * withdrawal that removes an operator-visible row silently is the failure
116517
+ * mode, not the removal itself.
116518
+ */
116519
+ async sweepWithdrawn(declarations, integrationId, index) {
116520
+ const declared = new Set(declarations.map((d) => d.stableId));
116521
+ const candidates = [...index.values()].filter((row) => row.integrationId === integrationId && !declared.has(row.stableId));
116522
+ if (candidates.length === 0) return [];
116523
+ if (candidates.length > 32) {
116524
+ this.ports.logger.warn("withdrawal sweep exceeded its bound — removing nothing", { meta: {
116525
+ integrationId,
116526
+ candidates: candidates.length,
116527
+ bound: 32
116528
+ } });
116529
+ return [];
116530
+ }
116531
+ const removed = [];
116532
+ for (const row of candidates) try {
116533
+ await this.ports.devices.remove(row.id);
116534
+ removed.push(row.id);
116535
+ this.ports.logger.info("declared device removed — its declaration was withdrawn", {
116536
+ tags: { deviceId: row.id },
116537
+ meta: {
116538
+ stableId: row.stableId,
116539
+ integrationId
116540
+ }
116541
+ });
116542
+ } catch (err) {
116543
+ this.ports.logger.warn("a withdrawn declared device could not be removed", {
116544
+ tags: { deviceId: row.id },
116545
+ meta: {
116546
+ stableId: row.stableId,
116547
+ error: err instanceof Error ? err.message : String(err)
116548
+ }
116549
+ });
116550
+ }
116551
+ return removed;
116552
+ }
116553
+ };
116554
+ function isSpecOfKind(spec, kind) {
116555
+ return spec !== void 0 && spec.kind === kind;
116556
+ }
116557
+ /**
116558
+ * The blocks of `kind` whose composer row exists. A block whose row the
116559
+ * composer has not declared yet is left out: nothing can be hosted on it until
116560
+ * its next apply, and the next pass picks it up.
116561
+ */
116562
+ function selectEngineHostedBlocks(kind, compositions, composerRows) {
116563
+ if (compositions.state === "not-loaded") return {
116564
+ kind: "untrusted",
116565
+ reason: compositions.reason
116566
+ };
116567
+ const rowByStableId = new Map(composerRows.map((row) => [row.stableId, row]));
116568
+ const blocks = [];
116569
+ for (const view of compositions.views) {
116570
+ const block = view.block;
116571
+ const composition = block.source?.kind === "composition" ? block.source.composition : null;
116572
+ if (composition === null) continue;
116573
+ const spec = composition.helper;
116574
+ if (!isSpecOfKind(spec, kind)) continue;
116575
+ const stableId = `${COMPOSED_DEVICE_STABLE_ID_PREFIX}${block.id}`;
116576
+ const row = rowByStableId.get(stableId);
116577
+ if (row === void 0) continue;
116578
+ blocks.push({
116579
+ blockId: block.id,
116580
+ deviceId: row.id,
116581
+ stableId,
116582
+ name: block.name,
116583
+ enabled: block.enabled,
116584
+ updatedAt: block.updatedAt,
116585
+ composition,
116586
+ spec
116587
+ });
116588
+ }
116589
+ return {
116590
+ kind: "trusted",
116591
+ blocks
116592
+ };
116593
+ }
116594
+ var WITHDRAWAL_CONFIRMATIONS = 2;
116595
+ /**
116596
+ * D49 for an engine's hosted set: a block missing from ONE trusted read is
116597
+ * kept; a second consecutive trusted read that agrees withdraws it. An
116598
+ * untrusted read is never fed here, so it neither counts nor resets.
116599
+ */
116600
+ var HostedWithdrawalGate = class {
116601
+ misses = /* @__PURE__ */ new Map();
116602
+ /**
116603
+ * `hosted`: what the engine serves now; `present`: what this trusted read
116604
+ * names. Returns the ids to withdraw now, and the ids kept on a first miss.
116605
+ */
116606
+ judge(hosted, present) {
116607
+ const withdraw = [];
116608
+ const held = [];
116609
+ const misses = /* @__PURE__ */ new Map();
116610
+ for (const id of hosted) {
116611
+ if (present.has(id)) continue;
116612
+ const count = (this.misses.get(id) ?? 0) + 1;
116613
+ if (count < WITHDRAWAL_CONFIRMATIONS) {
116614
+ held.push(id);
116615
+ misses.set(id, count);
116616
+ } else withdraw.push(id);
116617
+ }
116618
+ this.misses = misses;
116619
+ return {
116620
+ withdraw,
116621
+ held
116622
+ };
116623
+ }
116624
+ };
116625
+ /**
116626
+ * Build `DeviceClass` on the composer's row `(stableId, id)`. The context is
116627
+ * `loadContext` (D677: a caller that BUILDS a device hydrates its stored
116628
+ * runtime state first); a kernel without it is refused by name rather than
116629
+ * building on an empty state. The device is never `register`ed and its config
116630
+ * never persisted: the row, its name and its lifetime are the composer's.
116631
+ */
116632
+ async function hostEngineDevice(devices, row, config, DeviceClass) {
116633
+ if (devices.loadContext === void 0) throw new Error(`this kernel cannot build a device on a row it does not own (no loadContext) — device ${String(row.id)} is not hosted`);
116634
+ const base = await devices.loadContext(row.stableId, row.id, null, config);
116635
+ const registered = [];
116636
+ const device = new DeviceClass({
116637
+ ...base,
116638
+ registerNativeCap: (cap, provider) => {
116639
+ base.registerNativeCap(cap, provider);
116640
+ registered.push(cap.name);
116641
+ }
116642
+ });
116643
+ return {
116644
+ device,
116645
+ withdraw: async () => {
116646
+ await device.removeDevice();
116647
+ for (const capName of registered) base.unregisterNativeCap?.(capName);
116648
+ }
116649
+ };
116650
+ }
116651
+ /**
116652
+ * Whether an engine may stop sweeping: only once a pass found no old row left.
116653
+ * `none` is not done — a registry that has not answered the integration yet
116654
+ * reads as null too, and the sweep is one indexed read per pass.
116655
+ */
116656
+ function legacySweepDone(sweep) {
116657
+ return sweep.kind === "swept" && sweep.drained;
116658
+ }
116659
+ /**
116660
+ * The legacy rows, one bounded batch at a time: only the rows under the old
116661
+ * integration, ordered by id, at most `DECLARED_DEVICE_SWEEP_LIMIT` — a large
116662
+ * leftover set drains over passes instead of being refused whole by the
116663
+ * sweep's own bound.
116664
+ */
116665
+ function legacyEngineRowsIndex(rows, integrationId) {
116666
+ return rows.filter((row) => row.integrationId === integrationId).toSorted((left, right) => left.id - right.id).slice(0, 32);
116667
+ }
116668
+ /**
116669
+ * Remove every camera row an engine declared itself before its cameras were
116670
+ * blocks, unconditionally, through the declared sweep (`removeDevice` →
116671
+ * tombstone, D865). No integration means nothing was ever declared, and
116672
+ * nothing is minted to find out. A failed read throws: the caller retries.
116673
+ */
116674
+ async function sweepLegacyEngineRows(ports, integrationName) {
116675
+ const integration = await ports.getIntegration(ports.addonId);
116676
+ if (integration === null) return { kind: "none" };
116677
+ let found = 0;
116678
+ return {
116679
+ kind: "swept",
116680
+ removed: (await new DeclaredDevices({
116681
+ logger: ports.logger,
116682
+ addonId: ports.addonId,
116683
+ devices: ports.devices,
116684
+ localNodeId: ports.localNodeId,
116685
+ getIntegration: async () => integration,
116686
+ createIntegration: async () => {
116687
+ throw new Error(`${ports.addonId}: the legacy sweep never mints an integration`);
116688
+ },
116689
+ updateIntegration: async () => void 0,
116690
+ listOwnDevices: async () => {
116691
+ const index = legacyEngineRowsIndex(await ports.listAddonRows(ports.addonId), integration.id);
116692
+ found = index.length;
116693
+ return index;
116694
+ }
116695
+ }).reconcile({
116696
+ integrationName,
116697
+ integrationId: integration.id,
116698
+ placement: "hub",
116699
+ devices: []
116700
+ })).removed,
116701
+ drained: found === 0
116702
+ };
116703
+ }
114634
116704
  /**
114635
116705
  * One composed field, evaluated from what its sources say NOW (D659).
114636
116706
  *
@@ -115234,11 +117304,65 @@ var DEVICE_LOCAL_STATE_CAPS = {
115234
117304
  waterHeater: waterHeaterCapability,
115235
117305
  weather: weatherCapability,
115236
117306
  weatherStation: weatherStationCapability,
117307
+ workload: workloadCapability,
115237
117308
  zoneAnalytics: zoneAnalyticsCapability,
115238
117309
  zoneRules: zoneRulesCapability,
115239
117310
  zones: zonesCapability
115240
117311
  };
115241
117312
  /**
117313
+ * Normalise `raw` and declare it: every kind it carries replaces the stored one,
117314
+ * every kind it lacks is removed, except the kinds in `options.unread` (a failed
117315
+ * read keeps what was stored) — pass everything the provider read in one call.
117316
+ */
117317
+ async function declareDeviceIdentifiers(deps, raw, options = {}) {
117318
+ const { deviceId, logger, writer } = deps;
117319
+ const { unread, ...normaliseOptions } = options;
117320
+ const { identifiers, rejected } = normaliseIdentifiers(raw, normaliseOptions);
117321
+ for (const r of rejected) logger.warn("identifier refused — not declared", {
117322
+ tags: { deviceId },
117323
+ meta: {
117324
+ key: r.key,
117325
+ value: r.value,
117326
+ reason: r.reason
117327
+ }
117328
+ });
117329
+ const unreadKinds = new Set(unread ?? []);
117330
+ if (isEmptyIdentifiers(identifiers) && DEVICE_IDENTIFIER_KEYS.every((key) => unreadKinds.has(key))) {
117331
+ logger.debug("no identifier read — nothing declared", { tags: { deviceId } });
117332
+ return {
117333
+ outcome: "nothing-to-declare",
117334
+ identifiers
117335
+ };
117336
+ }
117337
+ if (writer === void 0) {
117338
+ logger.warn("identifiers not declared — device-manager unreachable", { tags: { deviceId } });
117339
+ return {
117340
+ outcome: "unavailable",
117341
+ identifiers
117342
+ };
117343
+ }
117344
+ try {
117345
+ await writer.mutate({
117346
+ deviceId,
117347
+ identifiers,
117348
+ ...unread !== void 0 && unread.length > 0 ? { unread } : {}
117349
+ });
117350
+ return {
117351
+ outcome: "declared",
117352
+ identifiers
117353
+ };
117354
+ } catch (err) {
117355
+ logger.warn("identifiers not declared — setIdentifiers failed", {
117356
+ tags: { deviceId },
117357
+ meta: { error: errMsg(err) }
117358
+ });
117359
+ return {
117360
+ outcome: "failed",
117361
+ identifiers
117362
+ };
117363
+ }
117364
+ }
117365
+ /**
115242
117366
  * The edge between two readings, or `null` for no edge.
115243
117367
  *
115244
117368
  * - `null`/cold → `true` is a START (a fault already open at boot is one);
@@ -115290,6 +117414,8 @@ var BaseDevice = class {
115290
117414
  id;
115291
117415
  stableId;
115292
117416
  type;
117417
+ /** True when another process owns the base slices (`options.deviceStatus: 'external'`). */
117418
+ statusIsExternal;
115293
117419
  name;
115294
117420
  parentDeviceId;
115295
117421
  role;
@@ -115438,21 +117564,26 @@ var BaseDevice = class {
115438
117564
  };
115439
117565
  this.runtimeState = DeviceRuntimeState.fromInitial(initial, writer, onWriteFailed);
115440
117566
  ctx.bindRuntimeState?.(this.runtimeState);
115441
- ctx.registerNativeCap?.(deviceStatusCapability, {});
115442
- const seed = {
115443
- online: true,
115444
- lastChangedAt: Date.now()
115445
- };
115446
- this.runtimeState.setCapState("device-status", seed);
115447
- ctx.registerNativeCap?.(featureProbeCapability, {});
115448
- this.runtimeState.setCapState("feature-probe", {
115449
- flags: {},
115450
- deviceType: null,
115451
- model: null,
115452
- channelCount: null,
115453
- lastProbedAt: 0,
115454
- lastFetchedAt: 0
115455
- });
117567
+ this.statusIsExternal = options.deviceStatus === "external";
117568
+ if (!this.statusIsExternal) ctx.registerNativeCap?.(deviceStatusCapability, {});
117569
+ if (!this.statusIsExternal) {
117570
+ const seed = {
117571
+ online: true,
117572
+ lastChangedAt: Date.now()
117573
+ };
117574
+ this.runtimeState.setCapState("device-status", seed);
117575
+ }
117576
+ if (!this.statusIsExternal) {
117577
+ ctx.registerNativeCap?.(featureProbeCapability, {});
117578
+ this.runtimeState.setCapState("feature-probe", {
117579
+ flags: {},
117580
+ deviceType: null,
117581
+ model: null,
117582
+ channelCount: null,
117583
+ lastProbedAt: 0,
117584
+ lastFetchedAt: 0
117585
+ });
117586
+ }
115456
117587
  }
115457
117588
  deviceActions = /* @__PURE__ */ new Map();
115458
117589
  /** Declare a device custom action + its typed handler. Idempotent per name. */
@@ -115480,7 +117611,7 @@ var BaseDevice = class {
115480
117611
  * override to gate side effects on the transition.
115481
117612
  */
115482
117613
  markOnline(online) {
115483
- if (this.online === online) return;
117614
+ if (this.statusIsExternal || this.online === online) return;
115484
117615
  const next = {
115485
117616
  online,
115486
117617
  lastChangedAt: Date.now()
@@ -115550,6 +117681,24 @@ var BaseDevice = class {
115550
117681
  }));
115551
117682
  }
115552
117683
  /**
117684
+ * Declare this device's identifiers (D1059): MAC(s), serial, vendor uid,
117685
+ * machine uuid, hostname, IP — what a later step matches across integrations.
117686
+ * Normalises `raw` (`normaliseIdentifiers`), logs every refused value, and
117687
+ * writes the result through `device-manager.setIdentifiers`, which accepts it
117688
+ * only from the provider that owns this device. Each kind it carries replaces
117689
+ * the stored one and each kind it lacks is removed — except the kinds listed in
117690
+ * `options.unread` (reads that FAILED), which keep their stored value. Pass
117691
+ * everything read in one call; a call where every kind is unread writes
117692
+ * nothing. Best-effort: never throws.
117693
+ */
117694
+ async declareIdentifiers(raw, options) {
117695
+ return declareDeviceIdentifiers({
117696
+ deviceId: this.id,
117697
+ logger: this.ctx.logger,
117698
+ writer: this.ctx.api.deviceManager?.setIdentifiers
117699
+ }, raw, options);
117700
+ }
117701
+ /**
115553
117702
  * Re-publish the device's current `features` array to the persisted
115554
117703
  * meta blob. Drivers call this after a probe finishes when the live
115555
117704
  * `features` getter has gained new flags (e.g. `hasIntercom` flips
@@ -115754,6 +117903,7 @@ var BaseDevice = class {
115754
117903
  * `lastProbedAt`) once their probe actually succeeds.
115755
117904
  */
115756
117905
  async onProbe() {
117906
+ if (this.statusIsExternal) return;
115757
117907
  const base = this.runtimeState.getCapState("feature-probe") ?? {
115758
117908
  flags: {},
115759
117909
  deviceType: null,
@@ -116170,289 +118320,7 @@ function legacyAutoLinkIds(params) {
116170
118320
  ids.delete(selfId);
116171
118321
  return [...ids];
116172
118322
  }
116173
- /** Marker written to a declared integration's `info`. */
116174
- var DECLARED_INTEGRATION_FIXED_KEY = "fixed";
116175
- /**
116176
- * Give a declared integration its instance record, ONCE. The record is read first and left
116177
- * exactly as it is when it exists (an operator's rename, a field the addon later adds): a seed
116178
- * never overwrites. A read that fails throws and writes nothing (D49) — the next pass retries.
116179
- * True when the record was written by this call.
116180
- */
116181
- async function seedInstanceOnce(instances, seed) {
116182
- const existing = await instances.getInstance({ id: seed.id });
116183
- if (existing !== null && existing !== void 0) return false;
116184
- await instances.createInstance({
116185
- id: seed.id,
116186
- name: seed.name
116187
- });
116188
- return true;
116189
- }
116190
- /**
116191
- * Strip the `<node>/<addon>` suffix a forked child carries.
116192
- *
116193
- * Comparing `ctx.kernel.localNodeId` raw skipped EVERY node — including the one
116194
- * that was supposed to act — because on the hub it reads `hub/<addon>`.
116195
- */
116196
- function declarationOwnerNodeId(localNodeId) {
116197
- const raw = localNodeId ?? "hub";
116198
- if (!raw.includes("/")) return raw;
116199
- return raw.split("/")[0] ?? "hub";
116200
- }
116201
- /**
116202
- * The one way an addon owns a device it declares.
116203
- *
116204
- * Construct once with the addon's ports, then call {@link reconcile} on boot and
116205
- * on every convergence tick. There is no second get-or-create helper — a guard
116206
- * in `scripts/` enforces that.
116207
- */
116208
- var DeclaredDevices = class {
116209
- ports;
116210
- constructor(ports) {
116211
- const addonId = ports.addonId;
116212
- if (typeof addonId !== "string" || addonId.length === 0) throw new Error(`DeclaredDevices: addonId must be the declaring addon's id, got ${JSON.stringify(addonId)}. On an addon context it is \`ctx.id\` — there is no \`ctx.addonId\`.`);
116213
- this.ports = ports;
116214
- }
116215
- /**
116216
- * Converge the declared set. Idempotent, and safe to call repeatedly.
116217
- *
116218
- * Throws only what the ports throw on the FIRST index read; every other
116219
- * failure is per-device and logged, so one bad declaration never takes the
116220
- * others down.
116221
- */
116222
- async reconcile(spec) {
116223
- if ((spec.placement ?? "hub") === "hub") {
116224
- const nodeId = declarationOwnerNodeId(this.ports.localNodeId);
116225
- if (nodeId !== "hub") {
116226
- this.ports.logger.info("declared devices are hub-owned — skipping on this node", { meta: {
116227
- nodeId,
116228
- rawNodeId: this.ports.localNodeId ?? null
116229
- } });
116230
- return {
116231
- integrationId: null,
116232
- devices: [],
116233
- removed: [],
116234
- owned: false
116235
- };
116236
- }
116237
- }
116238
- let integrationId;
116239
- if (spec.integrationId !== void 0) integrationId = spec.integrationId;
116240
- else {
116241
- const own = await this.ensureIntegration(spec.integrationName);
116242
- integrationId = own.id;
116243
- await this.seedInstance(own);
116244
- }
116245
- const index = await this.readIndex();
116246
- const live = await this.readLiveByStableId();
116247
- const outcomes = [];
116248
- for (const declaration of spec.devices) {
116249
- const outcome = await this.applyDeclaration(declaration, integrationId, index, live);
116250
- if (outcome !== null) outcomes.push(outcome);
116251
- }
116252
- const removed = await this.sweepWithdrawn(spec.devices, integrationId, index);
116253
- return {
116254
- integrationId,
116255
- devices: outcomes,
116256
- removed,
116257
- owned: true
116258
- };
116259
- }
116260
- /**
116261
- * Get-or-create the FIXED integration, and RE-ASSERT the flag every pass.
116262
- *
116263
- * The re-assertion is the fix for the defect the hand-rolled version shipped
116264
- * with: writing `info.fixed` only on the create path left every pre-existing
116265
- * install without it, and the kernel kept offering to delete an integration
116266
- * the addon owns.
116267
- */
116268
- async ensureIntegration(integrationName) {
116269
- const existing = await this.ports.getIntegration(this.ports.addonId);
116270
- if (existing === null) {
116271
- const created = await this.ports.createIntegration({
116272
- addonId: this.ports.addonId,
116273
- name: integrationName,
116274
- info: { [DECLARED_INTEGRATION_FIXED_KEY]: true }
116275
- });
116276
- this.ports.logger.info("declared a fixed integration", { meta: {
116277
- integrationId: created.id,
116278
- name: integrationName
116279
- } });
116280
- return {
116281
- id: created.id,
116282
- name: integrationName
116283
- };
116284
- }
116285
- if (existing.info?.["fixed"] !== true) {
116286
- await this.ports.updateIntegration({
116287
- id: existing.id,
116288
- info: { [DECLARED_INTEGRATION_FIXED_KEY]: true }
116289
- });
116290
- this.ports.logger.info("re-asserted `fixed` on a declared integration", { meta: { integrationId: existing.id } });
116291
- }
116292
- return {
116293
- id: existing.id,
116294
- name: existing.name ?? integrationName
116295
- };
116296
- }
116297
- /** Seed the instance record of an integration this declarer owns; best-effort, retried next pass. */
116298
- async seedInstance(integration) {
116299
- const { seedInstance } = this.ports;
116300
- if (seedInstance === void 0) return;
116301
- try {
116302
- await seedInstance({
116303
- id: integration.id,
116304
- name: integration.name
116305
- });
116306
- } catch (err) {
116307
- this.ports.logger.warn("could not seed the instance record of a declared integration", {
116308
- tags: { integrationId: integration.id },
116309
- meta: { error: errMsg(err) }
116310
- });
116311
- }
116312
- }
116313
- async readIndex() {
116314
- const rows = await this.ports.listOwnDevices();
116315
- return new Map(rows.map((row) => [row.stableId, row]));
116316
- }
116317
- /**
116318
- * Devices this kernel already has CONSTRUCTED, by stableId.
116319
- *
116320
- * Distinct from {@link readIndex}, and the distinction is the bug: the index
116321
- * is persisted rows, this is live objects. A row without an object must be
116322
- * adopted; an object must be left exactly as it is.
116323
- *
116324
- * Failure is non-fatal and deliberately so — an empty map degrades to the
116325
- * previous behaviour (attempt the adopt) rather than skipping a device that
116326
- * genuinely needs bringing up.
116327
- */
116328
- async readLiveByStableId() {
116329
- try {
116330
- const devices = await this.ports.devices.getAll();
116331
- return new Map(devices.map((device) => [device.stableId, device]));
116332
- } catch (err) {
116333
- this.ports.logger.warn("could not read live devices — falling back to adopt-by-row", { meta: { error: err instanceof Error ? err.message : String(err) } });
116334
- return /* @__PURE__ */ new Map();
116335
- }
116336
- }
116337
- /**
116338
- * One declaration: adopt what exists, create what does not.
116339
- *
116340
- * The create branch is the destructive one — it seeds `initialMeta`, and
116341
- * `initialMeta.name` lands as an unconditional `setName`. A transiently empty
116342
- * index therefore looks exactly like a first boot and would silently re-stamp
116343
- * the declared name over the operator's rename. D49: that branch needs a
116344
- * second read to agree.
116345
- */
116346
- async applyDeclaration(declaration, integrationId, index, live) {
116347
- try {
116348
- const alreadyLive = live.get(declaration.stableId);
116349
- if (alreadyLive !== void 0) return {
116350
- stableId: declaration.stableId,
116351
- deviceId: alreadyLive.id,
116352
- device: alreadyLive,
116353
- created: false
116354
- };
116355
- let existing = index.get(declaration.stableId);
116356
- if (existing === void 0) {
116357
- existing = (await this.readIndex()).get(declaration.stableId);
116358
- if (existing !== void 0) this.ports.logger.warn("device index disagreed with itself — adopting instead of re-creating", {
116359
- tags: { deviceId: existing.id },
116360
- meta: {
116361
- stableId: declaration.stableId,
116362
- addonId: this.ports.addonId
116363
- }
116364
- });
116365
- }
116366
- if (existing !== void 0) {
116367
- const device = await this.ports.devices.create(declaration.stableId, declaration.DeviceClass, {}, null, void 0);
116368
- this.ports.logger.info("declared device adopted", {
116369
- tags: { deviceId: device.id },
116370
- meta: {
116371
- stableId: declaration.stableId,
116372
- integrationId
116373
- }
116374
- });
116375
- return {
116376
- stableId: declaration.stableId,
116377
- deviceId: device.id,
116378
- device,
116379
- created: false
116380
- };
116381
- }
116382
- const device = await this.ports.devices.create(declaration.stableId, declaration.DeviceClass, declaration.config ?? {}, null, {
116383
- type: declaration.type,
116384
- name: declaration.name,
116385
- integrationId,
116386
- ...declaration.role === void 0 ? {} : { role: declaration.role }
116387
- });
116388
- this.ports.logger.info("declared device created", {
116389
- tags: { deviceId: device.id },
116390
- meta: {
116391
- stableId: declaration.stableId,
116392
- integrationId
116393
- }
116394
- });
116395
- return {
116396
- stableId: declaration.stableId,
116397
- deviceId: device.id,
116398
- device,
116399
- created: true
116400
- };
116401
- } catch (err) {
116402
- this.ports.logger.warn("a declared device could not be brought up", { meta: {
116403
- stableId: declaration.stableId,
116404
- error: err instanceof Error ? err.message : String(err)
116405
- } });
116406
- return null;
116407
- }
116408
- }
116409
- /**
116410
- * Remove rows under the addon's FIXED integration whose declaration is gone.
116411
- *
116412
- * Bounded to that integration: a declared integration has no operator
116413
- * add-flow, so every row under it got there by declaration. Devices this
116414
- * addon owns OUTSIDE it (a provider's adopted devices) are never candidates.
116415
- *
116416
- * Bounded in count, and every deletion is logged with its `deviceId` — a
116417
- * withdrawal that removes an operator-visible row silently is the failure
116418
- * mode, not the removal itself.
116419
- */
116420
- async sweepWithdrawn(declarations, integrationId, index) {
116421
- const declared = new Set(declarations.map((d) => d.stableId));
116422
- const candidates = [...index.values()].filter((row) => row.integrationId === integrationId && !declared.has(row.stableId));
116423
- if (candidates.length === 0) return [];
116424
- if (candidates.length > 32) {
116425
- this.ports.logger.warn("withdrawal sweep exceeded its bound — removing nothing", { meta: {
116426
- integrationId,
116427
- candidates: candidates.length,
116428
- bound: 32
116429
- } });
116430
- return [];
116431
- }
116432
- const removed = [];
116433
- for (const row of candidates) try {
116434
- await this.ports.devices.remove(row.id);
116435
- removed.push(row.id);
116436
- this.ports.logger.info("declared device removed — its declaration was withdrawn", {
116437
- tags: { deviceId: row.id },
116438
- meta: {
116439
- stableId: row.stableId,
116440
- integrationId
116441
- }
116442
- });
116443
- } catch (err) {
116444
- this.ports.logger.warn("a withdrawn declared device could not be removed", {
116445
- tags: { deviceId: row.id },
116446
- meta: {
116447
- stableId: row.stableId,
116448
- error: err instanceof Error ? err.message : String(err)
116449
- }
116450
- });
116451
- }
116452
- return removed;
116453
- }
116454
- };
116455
- DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Camera, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.WeatherStation, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
118323
+ DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Workload, DeviceType.Camera, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.WeatherStation, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
116456
118324
  new Set(Object.values(DeviceType));
116457
118325
  /** True when a value is a navigable node: a plain object OR a tRPC v11 client
116458
118326
  * proxy node (a callable `Proxy(noop)` → `typeof === 'function'`, NOT an
@@ -118714,10 +120582,12 @@ function durationText(seconds) {
118714
120582
  const text = `${Math.floor(m / 60)} h ${String(m % 60).padStart(2, "0")}`;
118715
120583
  return t(text, text);
118716
120584
  }
118717
- var switchContribution = contribution("switch", SwitchStatusSchema, (slice) => {
120585
+ var switchContribution = contribution("switch", SwitchStatusSchema, (slice, ctx) => {
118718
120586
  const on = slice?.on ?? null;
120587
+ const state = reading("switch", on === null ? "unknown" : on ? "on" : "off");
120588
+ if (ctx.switchOptions?.supportsSetState === false) return { reading: state };
118719
120589
  return {
118720
- reading: reading("switch", on === null ? "unknown" : on ? "on" : "off"),
120590
+ reading: state,
118721
120591
  ownPower: {
118722
120592
  source: "switch",
118723
120593
  on,
@@ -118927,14 +120797,17 @@ var timedRunContribution = contribution("timed-run", TimedRunStatusSchema, (slic
118927
120797
  tiles: armed
118928
120798
  };
118929
120799
  });
118930
- var powerSourceContribution = contribution("power-source", PowerSourceStateSchema, (slice, ctx) => ({ powerSupply: {
118931
- on: slice?.switchOn ?? null,
118932
- confirmOffWhileRunning: ctx.running === true,
118933
- running: ctx.running ?? null,
118934
- powerOn: action("power-supply.on", t("Power on", "Alimenta"), "plug", "power-source", "powerOn"),
118935
- powerOff: action("power-supply.off", t("Power off", "Togli alimentazione"), "plug-zap", "power-source", "powerOff", {}, "normal", "off-while-running"),
118936
- restart: action("power-supply.restart", t("Restart", "Riavvia"), "rotate-cw", "power-source", "forceRestart")
118937
- } }));
120800
+ var powerSourceContribution = contribution("power-source", PowerSourceStateSchema, (slice, ctx) => {
120801
+ const settable = ctx.powerSupplySettable !== false;
120802
+ return { powerSupply: {
120803
+ on: slice?.switchOn ?? null,
120804
+ confirmOffWhileRunning: ctx.running === true,
120805
+ running: ctx.running ?? null,
120806
+ powerOn: settable ? action("power-supply.on", t("Power on", "Alimenta"), "plug", "power-source", "powerOn") : null,
120807
+ powerOff: settable ? action("power-supply.off", t("Power off", "Togli alimentazione"), "plug-zap", "power-source", "powerOff", {}, "normal", "off-while-running") : null,
120808
+ restart: action("power-supply.restart", t("Restart", "Riavvia"), "rotate-cw", "power-source", "forceRestart")
120809
+ } };
120810
+ });
118938
120811
  /** The remote cap has no status: the model's input carries how many commands it holds. */
118939
120812
  var remoteContribution = {
118940
120813
  cap: "remote",
@@ -119351,6 +121224,7 @@ var HERO_LAYOUT_BY_TYPE = {
119351
121224
  [DeviceType.WaterHeater]: CLIMATE_LAYOUT,
119352
121225
  [DeviceType.HeatPump]: HEAT_PUMP_LAYOUT,
119353
121226
  [DeviceType.EnergySystem]: HERO_LAYOUT_DEFAULT,
121227
+ [DeviceType.Workload]: HERO_LAYOUT_DEFAULT,
119354
121228
  [DeviceType.Fan]: FAN_LAYOUT,
119355
121229
  [DeviceType.MediaPlayer]: MEDIA_PLAYER_LAYOUT,
119356
121230
  [DeviceType.AlarmPanel]: ALARM_LAYOUT,
@@ -120075,6 +121949,7 @@ var HERO_LOOK_BY_TYPE = {
120075
121949
  [DeviceType.WaterHeater]: WATER_HEATER_LOOK,
120076
121950
  [DeviceType.HeatPump]: HEAT_PUMP_LOOK,
120077
121951
  [DeviceType.EnergySystem]: HERO_LOOK_DEFAULT,
121952
+ [DeviceType.Workload]: HERO_LOOK_DEFAULT,
120078
121953
  [DeviceType.Fan]: FAN_LOOK,
120079
121954
  [DeviceType.MediaPlayer]: MEDIA_PLAYER_LOOK,
120080
121955
  [DeviceType.AlarmPanel]: ALARM_LOOK,
@@ -120117,6 +121992,7 @@ var HERO_LOOK_BY_ROLE = {
120117
121992
  [DeviceRole.SwitchHeater]: HEATER_LOOK,
120118
121993
  [DeviceRole.SwitchFan]: FAN_LOOK,
120119
121994
  [DeviceRole.SwitchLight]: LIGHT_LOOK,
121995
+ [DeviceRole.PoePort]: "inherit",
120120
121996
  [DeviceRole.ClimateAc]: "inherit",
120121
121997
  [DeviceRole.ClimateThermostat]: "inherit",
120122
121998
  [DeviceRole.ClimateFloor]: "inherit",
@@ -120161,7 +122037,12 @@ var HERO_LOOK_BY_ROLE = {
120161
122037
  [DeviceRole.MessagingNotifier]: "inherit",
120162
122038
  [DeviceRole.EmailNotifier]: "inherit",
120163
122039
  [DeviceRole.GenericNotifier]: "inherit",
120164
- [DeviceRole.IrTransmitter]: "inherit"
122040
+ [DeviceRole.IrTransmitter]: "inherit",
122041
+ [DeviceRole.Vm]: "inherit",
122042
+ [DeviceRole.AppContainer]: "inherit",
122043
+ [DeviceRole.Lxc]: "inherit",
122044
+ [DeviceRole.App]: "inherit",
122045
+ [DeviceRole.Host]: "inherit"
120165
122046
  };
120166
122047
  function isDeviceType$1(type) {
120167
122048
  return Object.values(DeviceType).includes(type);
@@ -120196,16 +122077,6 @@ function resolveOwnPower(offers) {
120196
122077
  }
120197
122078
  return null;
120198
122079
  }
120199
- /**
120200
- * `buildHeroModel` — the ONE pure function behind every device hero (D1023).
120201
- * The admin device page, the admin quick-detail dialog and the viewer's device
120202
- * screen all draw what it returns; none of them decides anything.
120203
- *
120204
- * Inputs are the device, the caps it is bound to (`getBindings`, per device —
120205
- * never the global cap list, D12), its features and one raw slice per cap. A
120206
- * slice that is missing or does not parse is "not answered": unknown is never
120207
- * off (D315/D393), a heater whose switch has not reported renders `unknown`.
120208
- */
120209
122080
  /** The first source with a known answer wins. */
120210
122081
  var STATE_SOURCE_ORDER = [
120211
122082
  "media-player",
@@ -120371,7 +122242,9 @@ function buildHeroModel(input) {
120371
122242
  running: runningOf(input),
120372
122243
  remoteCommands: input.remoteCommands,
120373
122244
  caps: input.caps,
120374
- quantity: device.quantity ?? null
122245
+ quantity: device.quantity ?? null,
122246
+ ...input.switchOptions !== void 0 ? { switchOptions: input.switchOptions } : {},
122247
+ ...input.powerSupplySettable !== void 0 ? { powerSupplySettable: input.powerSupplySettable } : {}
120375
122248
  };
120376
122249
  const contributed = HERO_CAP_CONTRIBUTIONS.filter((c) => input.caps.includes(c.cap)).map((c) => ({
120377
122250
  cap: c.cap,
@@ -122903,6 +124776,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
122903
124776
  access: "view",
122904
124777
  role: "admin"
122905
124778
  },
124779
+ "deviceManager.listIdentityCandidates": {
124780
+ capName: "device-manager",
124781
+ capScope: "system",
124782
+ addonId: null,
124783
+ access: "view",
124784
+ role: "admin"
124785
+ },
122906
124786
  "deviceManager.listLocationDescriptions": {
122907
124787
  capName: "device-manager",
122908
124788
  capScope: "system",
@@ -123120,6 +125000,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
123120
125000
  access: "create",
123121
125001
  role: "admin"
123122
125002
  },
125003
+ "deviceManager.setIdentifiers": {
125004
+ capName: "device-manager",
125005
+ capScope: "system",
125006
+ addonId: null,
125007
+ access: "create",
125008
+ role: "admin"
125009
+ },
123123
125010
  "deviceManager.setIntegrationId": {
123124
125011
  capName: "device-manager",
123125
125012
  capScope: "system",
@@ -129042,6 +130929,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
129042
130929
  access: "view",
129043
130930
  role: "viewer"
129044
130931
  },
130932
+ "siren.getPlayChoices": {
130933
+ capName: "siren",
130934
+ capScope: "device",
130935
+ addonId: null,
130936
+ access: "view",
130937
+ role: "viewer"
130938
+ },
129045
130939
  "siren.getStatus": {
129046
130940
  capName: "siren",
129047
130941
  capScope: "device",
@@ -129854,6 +131748,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
129854
131748
  access: "view",
129855
131749
  role: "viewer"
129856
131750
  },
131751
+ "switch.getOptions": {
131752
+ capName: "switch",
131753
+ capScope: "device",
131754
+ addonId: null,
131755
+ access: "view",
131756
+ role: "viewer"
131757
+ },
129857
131758
  "switch.getStatus": {
129858
131759
  capName: "switch",
129859
131760
  capScope: "device",
@@ -129861,6 +131762,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
129861
131762
  access: "view",
129862
131763
  role: "viewer"
129863
131764
  },
131765
+ "switch.powerCycle": {
131766
+ capName: "switch",
131767
+ capScope: "device",
131768
+ addonId: null,
131769
+ access: "create",
131770
+ role: "viewer"
131771
+ },
129864
131772
  "switch.setState": {
129865
131773
  capName: "switch",
129866
131774
  capScope: "device",
@@ -130064,13 +131972,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
130064
131972
  access: "create",
130065
131973
  role: "admin"
130066
131974
  },
130067
- "terminalSession.adoptLegacyMonitor": {
130068
- capName: "terminal-session",
130069
- capScope: "system",
130070
- addonId: null,
130071
- access: "create",
130072
- role: "admin"
130073
- },
130074
131975
  "terminalSession.close": {
130075
131976
  capName: "terminal-session",
130076
131977
  capScope: "system",
@@ -130078,13 +131979,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
130078
131979
  access: "create",
130079
131980
  role: "admin"
130080
131981
  },
130081
- "terminalSession.listLegacyCameras": {
130082
- capName: "terminal-session",
130083
- capScope: "system",
130084
- addonId: null,
130085
- access: "view",
130086
- role: "admin"
130087
- },
130088
131982
  "terminalSession.listProfiles": {
130089
131983
  capName: "terminal-session",
130090
131984
  capScope: "system",
@@ -130946,6 +132840,62 @@ var METHOD_ACCESS_MAP = Object.freeze({
130946
132840
  access: "view",
130947
132841
  role: "viewer"
130948
132842
  },
132843
+ "workload.forceStop": {
132844
+ capName: "workload",
132845
+ capScope: "device",
132846
+ addonId: null,
132847
+ access: "create",
132848
+ role: "admin"
132849
+ },
132850
+ "workload.getOptions": {
132851
+ capName: "workload",
132852
+ capScope: "device",
132853
+ addonId: null,
132854
+ access: "view",
132855
+ role: "viewer"
132856
+ },
132857
+ "workload.getStatus": {
132858
+ capName: "workload",
132859
+ capScope: "device",
132860
+ addonId: null,
132861
+ access: "view",
132862
+ role: "viewer"
132863
+ },
132864
+ "workload.pause": {
132865
+ capName: "workload",
132866
+ capScope: "device",
132867
+ addonId: null,
132868
+ access: "create",
132869
+ role: "viewer"
132870
+ },
132871
+ "workload.restart": {
132872
+ capName: "workload",
132873
+ capScope: "device",
132874
+ addonId: null,
132875
+ access: "create",
132876
+ role: "viewer"
132877
+ },
132878
+ "workload.resume": {
132879
+ capName: "workload",
132880
+ capScope: "device",
132881
+ addonId: null,
132882
+ access: "create",
132883
+ role: "viewer"
132884
+ },
132885
+ "workload.start": {
132886
+ capName: "workload",
132887
+ capScope: "device",
132888
+ addonId: null,
132889
+ access: "create",
132890
+ role: "viewer"
132891
+ },
132892
+ "workload.stop": {
132893
+ capName: "workload",
132894
+ capScope: "device",
132895
+ addonId: null,
132896
+ access: "create",
132897
+ role: "viewer"
132898
+ },
130949
132899
  "zoneAnalytics.getCameraHistory": {
130950
132900
  capName: "zone-analytics",
130951
132901
  capScope: "device",
@@ -131072,7 +133022,8 @@ function resolveAction(cap, action, wordings) {
131072
133022
  icon: w.icon ?? action.icon,
131073
133023
  args: action.args ?? {},
131074
133024
  openArgs: action.openArgs ?? [],
131075
- access
133025
+ access,
133026
+ offeredWhen: action.offeredWhen ?? null
131076
133027
  };
131077
133028
  }
131078
133029
  /**
@@ -131315,8 +133266,8 @@ function offered(received) {
131315
133266
  };
131316
133267
  }
131317
133268
  offered(HA_AS), withheld(HOMEKIT_REASON), withheld(ALEXA_REASON), withheld(GOOGLE_REASON), withheld(MATTER_REASON);
131318
- DeviceType.Camera, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.WeatherStation, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
131319
- DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.SwitchLight, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
133269
+ DeviceType.Camera, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Workload, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.WeatherStation, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
133270
+ DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.SwitchLight, DeviceRole.PoePort, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter, DeviceRole.Vm, DeviceRole.AppContainer, DeviceRole.Lxc, DeviceRole.App, DeviceRole.Host;
131320
133271
  new Set(Object.values(DeviceType));
131321
133272
  new Set(Object.values(DeviceRole));
131322
133273
  /**
@@ -131411,7 +133362,8 @@ var CAP_NAMES_WITH_STATUS = [
131411
133362
  "vibration",
131412
133363
  "water-heater",
131413
133364
  "weather",
131414
- "weather-station"
133365
+ "weather-station",
133366
+ "workload"
131415
133367
  ];
131416
133368
  Object.freeze({
131417
133369
  "accessories.getStatus": [{
@@ -132112,6 +134064,11 @@ Object.freeze({
132112
134064
  form: "single",
132113
134065
  optional: false
132114
134066
  }],
134067
+ "deviceManager.setIdentifiers": [{
134068
+ name: "deviceId",
134069
+ form: "single",
134070
+ optional: false
134071
+ }],
132115
134072
  "deviceManager.setIntegrationId": [{
132116
134073
  name: "deviceId",
132117
134074
  form: "single",
@@ -134106,6 +136063,11 @@ Object.freeze({
134106
136063
  form: "single",
134107
136064
  optional: false
134108
136065
  }],
136066
+ "siren.getPlayChoices": [{
136067
+ name: "deviceId",
136068
+ form: "single",
136069
+ optional: false
136070
+ }],
134109
136071
  "siren.getStatus": [{
134110
136072
  name: "deviceId",
134111
136073
  form: "single",
@@ -134288,11 +136250,21 @@ Object.freeze({
134288
136250
  form: "single",
134289
136251
  optional: false
134290
136252
  }],
136253
+ "switch.getOptions": [{
136254
+ name: "deviceId",
136255
+ form: "single",
136256
+ optional: false
136257
+ }],
134291
136258
  "switch.getStatus": [{
134292
136259
  name: "deviceId",
134293
136260
  form: "single",
134294
136261
  optional: false
134295
136262
  }],
136263
+ "switch.powerCycle": [{
136264
+ name: "deviceId",
136265
+ form: "single",
136266
+ optional: false
136267
+ }],
134296
136268
  "switch.setState": [{
134297
136269
  name: "deviceId",
134298
136270
  form: "single",
@@ -134533,6 +136505,46 @@ Object.freeze({
134533
136505
  form: "single",
134534
136506
  optional: false
134535
136507
  }],
136508
+ "workload.forceStop": [{
136509
+ name: "deviceId",
136510
+ form: "single",
136511
+ optional: false
136512
+ }],
136513
+ "workload.getOptions": [{
136514
+ name: "deviceId",
136515
+ form: "single",
136516
+ optional: false
136517
+ }],
136518
+ "workload.getStatus": [{
136519
+ name: "deviceId",
136520
+ form: "single",
136521
+ optional: false
136522
+ }],
136523
+ "workload.pause": [{
136524
+ name: "deviceId",
136525
+ form: "single",
136526
+ optional: false
136527
+ }],
136528
+ "workload.restart": [{
136529
+ name: "deviceId",
136530
+ form: "single",
136531
+ optional: false
136532
+ }],
136533
+ "workload.resume": [{
136534
+ name: "deviceId",
136535
+ form: "single",
136536
+ optional: false
136537
+ }],
136538
+ "workload.start": [{
136539
+ name: "deviceId",
136540
+ form: "single",
136541
+ optional: false
136542
+ }],
136543
+ "workload.stop": [{
136544
+ name: "deviceId",
136545
+ form: "single",
136546
+ optional: false
136547
+ }],
134536
136548
  "zoneAnalytics.getCameraHistory": [{
134537
136549
  name: "deviceId",
134538
136550
  form: "single",
@@ -134601,7 +136613,7 @@ Object.freeze({
134601
136613
  });
134602
136614
  /**
134603
136615
  * Per-cap runtime-state policy, projected from every `*.cap.ts` that declares
134604
- * `runtimeState`. 86 caps: 43 `restored`, 43 `session`.
136616
+ * `runtimeState`. 87 caps: 43 `restored`, 44 `session`.
134605
136617
  *
134606
136618
  * A cap absent from this map has no runtime-state slice at all. A cap PRESENT
134607
136619
  * with `durability: 'session'` has one and has decided not to keep it.
@@ -134941,6 +136953,10 @@ var RUNTIME_STATE_POLICY = {
134941
136953
  durability: "session",
134942
136954
  volatileFields: ["lastFetchedAt"]
134943
136955
  },
136956
+ "workload": {
136957
+ durability: "session",
136958
+ volatileFields: ["lastFetchedAt"]
136959
+ },
134944
136960
  "zone-analytics": {
134945
136961
  durability: "session",
134946
136962
  volatileFields: []
@@ -137312,6 +139328,12 @@ Object.defineProperty(exports, "DEVICE_HISTORY_ENERGY_KEY", {
137312
139328
  return DEVICE_HISTORY_ENERGY_KEY;
137313
139329
  }
137314
139330
  });
139331
+ Object.defineProperty(exports, "DEVICE_IDENTIFIER_KEYS", {
139332
+ enumerable: true,
139333
+ get: function() {
139334
+ return DEVICE_IDENTIFIER_KEYS;
139335
+ }
139336
+ });
137315
139337
  Object.defineProperty(exports, "DEVICE_ID_FIELD", {
137316
139338
  enumerable: true,
137317
139339
  get: function() {
@@ -137408,6 +139430,12 @@ Object.defineProperty(exports, "DeviceFeature", {
137408
139430
  return DeviceFeature;
137409
139431
  }
137410
139432
  });
139433
+ Object.defineProperty(exports, "DeviceIdentifiersSchema", {
139434
+ enumerable: true,
139435
+ get: function() {
139436
+ return DeviceIdentifiersSchema;
139437
+ }
139438
+ });
137411
139439
  Object.defineProperty(exports, "DeviceRole", {
137412
139440
  enumerable: true,
137413
139441
  get: function() {
@@ -137606,6 +139634,12 @@ Object.defineProperty(exports, "HelperMemberSchema", {
137606
139634
  return HelperMemberSchema;
137607
139635
  }
137608
139636
  });
139637
+ Object.defineProperty(exports, "HostedWithdrawalGate", {
139638
+ enumerable: true,
139639
+ get: function() {
139640
+ return HostedWithdrawalGate;
139641
+ }
139642
+ });
137609
139643
  Object.defineProperty(exports, "HvacModeSchema", {
137610
139644
  enumerable: true,
137611
139645
  get: function() {
@@ -137948,6 +139982,12 @@ Object.defineProperty(exports, "STREAM_PROFILE_META", {
137948
139982
  return STREAM_PROFILE_META;
137949
139983
  }
137950
139984
  });
139985
+ Object.defineProperty(exports, "SWITCH_DEFAULT_OPTIONS", {
139986
+ enumerable: true,
139987
+ get: function() {
139988
+ return SWITCH_DEFAULT_OPTIONS;
139989
+ }
139990
+ });
137951
139991
  Object.defineProperty(exports, "SchedulerError", {
137952
139992
  enumerable: true,
137953
139993
  get: function() {
@@ -138086,6 +140126,18 @@ Object.defineProperty(exports, "WELL_KNOWN_TAB_MAP", {
138086
140126
  return WELL_KNOWN_TAB_MAP;
138087
140127
  }
138088
140128
  });
140129
+ Object.defineProperty(exports, "WORKLOAD_TRANSITION_CATEGORY", {
140130
+ enumerable: true,
140131
+ get: function() {
140132
+ return WORKLOAD_TRANSITION_CATEGORY;
140133
+ }
140134
+ });
140135
+ Object.defineProperty(exports, "WorkloadStateSchema", {
140136
+ enumerable: true,
140137
+ get: function() {
140138
+ return WorkloadStateSchema;
140139
+ }
140140
+ });
138089
140141
  Object.defineProperty(exports, "actionEffect", {
138090
140142
  enumerable: true,
138091
140143
  get: function() {
@@ -138434,6 +140486,12 @@ Object.defineProperty(exports, "compareVersions", {
138434
140486
  return compareVersions;
138435
140487
  }
138436
140488
  });
140489
+ Object.defineProperty(exports, "compileHelper", {
140490
+ enumerable: true,
140491
+ get: function() {
140492
+ return compileHelper;
140493
+ }
140494
+ });
138437
140495
  Object.defineProperty(exports, "compileScalarOverride", {
138438
140496
  enumerable: true,
138439
140497
  get: function() {
@@ -138974,12 +141032,24 @@ Object.defineProperty(exports, "historyUnitFor", {
138974
141032
  return historyUnitFor;
138975
141033
  }
138976
141034
  });
141035
+ Object.defineProperty(exports, "hostEngineDevice", {
141036
+ enumerable: true,
141037
+ get: function() {
141038
+ return hostEngineDevice;
141039
+ }
141040
+ });
138977
141041
  Object.defineProperty(exports, "hydrateSchema", {
138978
141042
  enumerable: true,
138979
141043
  get: function() {
138980
141044
  return hydrateSchema;
138981
141045
  }
138982
141046
  });
141047
+ Object.defineProperty(exports, "identifierStrength", {
141048
+ enumerable: true,
141049
+ get: function() {
141050
+ return identifierStrength;
141051
+ }
141052
+ });
138983
141053
  Object.defineProperty(exports, "implementedMethodsOf", {
138984
141054
  enumerable: true,
138985
141055
  get: function() {
@@ -139088,6 +141158,18 @@ Object.defineProperty(exports, "isDeviceConfigCap", {
139088
141158
  return isDeviceConfigCap;
139089
141159
  }
139090
141160
  });
141161
+ Object.defineProperty(exports, "isEmptyIdentifiers", {
141162
+ enumerable: true,
141163
+ get: function() {
141164
+ return isEmptyIdentifiers;
141165
+ }
141166
+ });
141167
+ Object.defineProperty(exports, "isEngineHostedHelper", {
141168
+ enumerable: true,
141169
+ get: function() {
141170
+ return isEngineHostedHelper;
141171
+ }
141172
+ });
139091
141173
  Object.defineProperty(exports, "isEvent", {
139092
141174
  enumerable: true,
139093
141175
  get: function() {
@@ -139190,6 +141272,12 @@ Object.defineProperty(exports, "isVoidInput", {
139190
141272
  return isVoidInput;
139191
141273
  }
139192
141274
  });
141275
+ Object.defineProperty(exports, "isWorkloadSettled", {
141276
+ enumerable: true,
141277
+ get: function() {
141278
+ return isWorkloadSettled;
141279
+ }
141280
+ });
139193
141281
  Object.defineProperty(exports, "kebabToCamel", {
139194
141282
  enumerable: true,
139195
141283
  get: function() {
@@ -139220,6 +141308,12 @@ Object.defineProperty(exports, "legacyModeOf", {
139220
141308
  return legacyModeOf;
139221
141309
  }
139222
141310
  });
141311
+ Object.defineProperty(exports, "legacySweepDone", {
141312
+ enumerable: true,
141313
+ get: function() {
141314
+ return legacySweepDone;
141315
+ }
141316
+ });
139223
141317
  Object.defineProperty(exports, "lifecycleJobSchema", {
139224
141318
  enumerable: true,
139225
141319
  get: function() {
@@ -139316,6 +141410,12 @@ Object.defineProperty(exports, "memoizePinnedFfmpeg", {
139316
141410
  return memoizePinnedFfmpeg;
139317
141411
  }
139318
141412
  });
141413
+ Object.defineProperty(exports, "mergeIdentifiers", {
141414
+ enumerable: true,
141415
+ get: function() {
141416
+ return mergeIdentifiers;
141417
+ }
141418
+ });
139319
141419
  Object.defineProperty(exports, "methodRefusal", {
139320
141420
  enumerable: true,
139321
141421
  get: function() {
@@ -139826,6 +141926,12 @@ Object.defineProperty(exports, "runtimeStatePolicyFor", {
139826
141926
  return runtimeStatePolicyFor;
139827
141927
  }
139828
141928
  });
141929
+ Object.defineProperty(exports, "sameIdentifiers", {
141930
+ enumerable: true,
141931
+ get: function() {
141932
+ return sameIdentifiers;
141933
+ }
141934
+ });
139829
141935
  Object.defineProperty(exports, "schedulersCapability", {
139830
141936
  enumerable: true,
139831
141937
  get: function() {
@@ -139886,6 +141992,12 @@ Object.defineProperty(exports, "seedInstanceOnce", {
139886
141992
  return seedInstanceOnce;
139887
141993
  }
139888
141994
  });
141995
+ Object.defineProperty(exports, "selectEngineHostedBlocks", {
141996
+ enumerable: true,
141997
+ get: function() {
141998
+ return selectEngineHostedBlocks;
141999
+ }
142000
+ });
139889
142001
  Object.defineProperty(exports, "settingsStoreCapability", {
139890
142002
  enumerable: true,
139891
142003
  get: function() {
@@ -140012,6 +142124,12 @@ Object.defineProperty(exports, "supportedRuntimes", {
140012
142124
  return supportedRuntimes;
140013
142125
  }
140014
142126
  });
142127
+ Object.defineProperty(exports, "sweepLegacyEngineRows", {
142128
+ enumerable: true,
142129
+ get: function() {
142130
+ return sweepLegacyEngineRows;
142131
+ }
142132
+ });
140015
142133
  Object.defineProperty(exports, "switchCapability", {
140016
142134
  enumerable: true,
140017
142135
  get: function() {
@@ -140204,6 +142322,18 @@ Object.defineProperty(exports, "withoutCallerStamp", {
140204
142322
  return withoutCallerStamp;
140205
142323
  }
140206
142324
  });
142325
+ Object.defineProperty(exports, "workloadCapability", {
142326
+ enumerable: true,
142327
+ get: function() {
142328
+ return workloadCapability;
142329
+ }
142330
+ });
142331
+ Object.defineProperty(exports, "workloadTransition", {
142332
+ enumerable: true,
142333
+ get: function() {
142334
+ return workloadTransition;
142335
+ }
142336
+ });
140207
142337
  Object.defineProperty(exports, "zoneOnlySite", {
140208
142338
  enumerable: true,
140209
142339
  get: function() {