@camstack/server 1.2.891 → 1.2.892

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/api/trpc/generated-cap-mounts.js +2 -1
  3. package/dist/api/trpc/generated-cap-routers.js +194 -39
  4. package/dist/core/addon/addon-registry.service.js +47 -0
  5. package/dist/core/addon/retire-undeclared-fixed-integrations.js +57 -0
  6. package/package.json +31 -15
  7. package/system/dist/addon-runner.js +25 -9
  8. package/system/dist/addon-runner.mjs +25 -9
  9. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  10. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  11. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  12. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  13. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  14. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  15. package/system/dist/builtins/autotrack/index.js +1 -1
  16. package/system/dist/builtins/autotrack/index.mjs +1 -1
  17. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  18. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  19. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  20. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  21. package/system/dist/builtins/camera-grid/addon.d.ts +65 -41
  22. package/system/dist/builtins/camera-grid/grid-blocks.d.ts +51 -0
  23. package/system/dist/builtins/camera-grid/grid-camera-device.d.ts +4 -3
  24. package/system/dist/builtins/camera-grid/grid-layout-native-provider.d.ts +3 -1
  25. package/system/dist/builtins/camera-grid/grid-plan.d.ts +3 -3
  26. package/system/dist/builtins/camera-grid/index.d.ts +2 -6
  27. package/system/dist/builtins/camera-grid/index.js +431 -727
  28. package/system/dist/builtins/camera-grid/index.mjs +428 -719
  29. package/system/dist/builtins/composer/composed-device.d.ts +12 -2
  30. package/system/dist/builtins/composer/composer.addon.js +28 -10
  31. package/system/dist/builtins/composer/composer.addon.mjs +28 -10
  32. package/system/dist/builtins/composer/composition-declarations.d.ts +3 -1
  33. package/system/dist/builtins/console-logging/index.js +1 -1
  34. package/system/dist/builtins/console-logging/index.mjs +1 -1
  35. package/system/dist/builtins/core-blocks/core-blocks.addon.js +174 -39
  36. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +175 -40
  37. package/system/dist/builtins/core-blocks/hero-layout-service.d.ts +19 -1
  38. package/system/dist/builtins/core-blocks/power-source-devices.d.ts +9 -0
  39. package/system/dist/builtins/core-blocks/power-source-service.d.ts +39 -2
  40. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  41. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  42. package/system/dist/builtins/device-manager/device-identifiers-action.d.ts +9 -0
  43. package/system/dist/builtins/device-manager/device-manager.addon.js +172 -5
  44. package/system/dist/builtins/device-manager/device-manager.addon.mjs +172 -5
  45. package/system/dist/builtins/device-manager/device-meta-types.d.ts +5 -1
  46. package/system/dist/builtins/device-manager/device-row-store.d.ts +3 -2
  47. package/system/dist/builtins/device-manager/device-state-mirror.d.ts +7 -0
  48. package/system/dist/builtins/device-manager/workload-transition.d.ts +23 -0
  49. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  50. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  51. package/system/dist/builtins/keychain/index.js +4 -4
  52. package/system/dist/builtins/keychain/index.mjs +4 -4
  53. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  54. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  55. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  56. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  57. package/system/dist/builtins/local-network/local-network.addon.js +3 -3
  58. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  59. package/system/dist/builtins/loki-logging/index.js +1 -1
  60. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  61. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  62. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  63. package/system/dist/builtins/platform-probe/index.js +1 -1
  64. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  65. package/system/dist/builtins/record-entries/index.js +1 -1
  66. package/system/dist/builtins/record-entries/index.mjs +1 -1
  67. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  68. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  69. package/system/dist/builtins/snapshot/index.js +1 -1
  70. package/system/dist/builtins/snapshot/index.mjs +1 -1
  71. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  72. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  73. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  74. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  75. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  76. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  77. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  78. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  79. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  80. package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
  81. package/system/dist/builtins/winston-logging/index.js +1 -1
  82. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  83. package/system/dist/{capture-engine-DXz37Mjg.js → capture-engine-DHmlkW_d.js} +1 -1
  84. package/system/dist/{capture-engine-nmelnj-Y.mjs → capture-engine-sl6e9f9S.mjs} +1 -1
  85. package/system/dist/{composition-sources-uphZtYtN.mjs → composition-sources-CznD85Ri.mjs} +1 -1
  86. package/system/dist/{composition-sources-BLn3cU74.js → composition-sources-PqcZfe3j.js} +1 -1
  87. package/system/dist/{constants-DWU46D02.mjs → constants-CHwj_mIM.mjs} +1 -1
  88. package/system/dist/{constants-BAaGwvKn.js → constants-_2SOk0By.js} +1 -1
  89. package/system/dist/{device-ca-CK6mLB2w.mjs → device-ca-D2H1EMUY.mjs} +1 -1
  90. package/system/dist/{device-ca-jbH_rqZh.js → device-ca-WIEO5ZcE.js} +1 -1
  91. package/system/dist/{dist-Dgq9nuvh.mjs → dist-DbAhCrHy.mjs} +2366 -444
  92. package/system/dist/{dist-m5beNMze.js → dist-yx2KHo3b.js} +2467 -443
  93. package/system/dist/file-host-worker.js +1 -1
  94. package/system/dist/file-host-worker.mjs +1 -1
  95. package/system/dist/{hub-identity-DlBBoHJC.mjs → hub-identity-BcvZqT0L.mjs} +1 -1
  96. package/system/dist/{hub-identity-CKCA89XP.js → hub-identity-Buegac-w.js} +1 -1
  97. package/system/dist/{hub-mdns-ciao-B8uFW-RG.mjs → hub-mdns-ciao-B6K_dO2s.mjs} +2 -2
  98. package/system/dist/{hub-mdns-ciao-CqcCGPdi.js → hub-mdns-ciao-DcNPj7WJ.js} +2 -2
  99. package/system/dist/index.js +33 -19
  100. package/system/dist/index.mjs +33 -19
  101. package/system/dist/kernel/moleculer/child-cap-dispatch.d.ts +3 -6
  102. package/system/dist/kernel/moleculer/switch-toggle.d.ts +7 -2
  103. package/system/dist/{legacy-integration-rows-door-Co0gj1Lm.js → legacy-integration-rows-door-BsZyVNiR.js} +1 -1
  104. package/system/dist/{legacy-integration-rows-door-HI4nmSe_.mjs → legacy-integration-rows-door-DHOJeDPG.mjs} +1 -1
  105. package/system/dist/{rename-composition-block-UeVUYCwx.js → rename-composition-block-BXMor7MR.js} +1 -1
  106. package/system/dist/{rename-composition-block-BthBMrXA.mjs → rename-composition-block-DcVS1LuC.mjs} +1 -1
  107. package/system/dist/{restore-archive-P-ICnU58.mjs → restore-archive-BG8VJ8Ar.mjs} +82 -82
  108. package/system/dist/{restore-archive-CJLsfBwK.js → restore-archive-BURufVQd.js} +1 -1
  109. package/system/dist/{wal-maintenance-qWjb7_f2.mjs → wal-maintenance-B4wGD6QR.mjs} +0 -0
  110. package/system/dist/{wal-maintenance-CUtwx-2Z.js → wal-maintenance-CeaJyKNT.js} +0 -0
  111. package/system/package.json +2 -5
  112. package/system/dist/builtins/camera-grid/grid-camera-declarations.d.ts +0 -59
  113. package/system/dist/builtins/camera-grid/grid-instances.d.ts +0 -40
  114. package/system/dist/builtins/camera-grid/grid-record-kinds.d.ts +0 -31
  115. package/system/dist/builtins/camera-grid/migrations/__fixtures__/seed.d.ts +0 -13
  116. package/system/dist/builtins/camera-grid/migrations/camera-grids-to-records.d.ts +0 -26
  117. package/system/dist/builtins/camera-grid/migrations/index.d.ts +0 -6
@@ -1,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,260 @@ 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
+ /** True when the declaration carries no key at all. */
71150
+ function isEmptyIdentifiers(identifiers) {
71151
+ return DEVICE_IDENTIFIER_KEYS.every((key) => identifiers[key] === void 0);
71152
+ }
71153
+ /** Values devices report when they do not know: never an identity. */
71154
+ var PLACEHOLDER_PATTERN = /^(?:unknown|none|n\/?a|null|undefined|default|0+|-+)$/i;
71155
+ var NULL_MACS = new Set(["00:00:00:00:00:00", "ff:ff:ff:ff:ff:ff"]);
71156
+ function rejected(reason) {
71157
+ return {
71158
+ ok: false,
71159
+ reason
71160
+ };
71161
+ }
71162
+ /** `AA-BB-CC-DD-EE-FF`, `aabb.ccdd.eeff`, `AABBCCDDEEFF` → `aa:bb:cc:dd:ee:ff`. */
71163
+ function normaliseMac(raw) {
71164
+ const hex = raw.trim().toLowerCase().replace(/[\s:.-]/g, "");
71165
+ if (!/^[0-9a-f]{12}$/.test(hex)) return rejected("not a 48-bit MAC");
71166
+ const mac = (hex.match(/../g) ?? []).join(":");
71167
+ if (NULL_MACS.has(mac)) return rejected("placeholder MAC");
71168
+ return {
71169
+ ok: true,
71170
+ value: mac
71171
+ };
71172
+ }
71173
+ function slug$2(raw) {
71174
+ return raw.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[-._]+|[-._]+$/g, "");
71175
+ }
71176
+ function normalisePrefixed(prefixRaw, valueRaw, what) {
71177
+ const prefix = slug$2(prefixRaw);
71178
+ if (prefix.length === 0) return rejected(`no ${what}`);
71179
+ const value = valueRaw.trim().toLowerCase().replace(/\s+/g, "");
71180
+ if (value.length === 0) return rejected("blank value");
71181
+ if (PLACEHOLDER_PATTERN.test(value)) return rejected("placeholder value");
71182
+ return {
71183
+ ok: true,
71184
+ value: `${prefix}:${value}`
71185
+ };
71186
+ }
71187
+ function normaliseMachineUuid(raw) {
71188
+ const value = raw.trim().toLowerCase().replace(/^\{|\}$/g, "");
71189
+ if (!MACHINE_UUID_PATTERN.test(value)) return rejected("not a uuid");
71190
+ if (/^[0-]+$/.test(value) || /^[f-]+$/.test(value)) return rejected("placeholder uuid");
71191
+ return {
71192
+ ok: true,
71193
+ value
71194
+ };
71195
+ }
71196
+ function isIp(value) {
71197
+ return zod.z.union([zod.z.ipv4(), zod.z.ipv6()]).safeParse(value).success;
71198
+ }
71199
+ function normaliseHostname(raw) {
71200
+ const full = raw.trim().toLowerCase().replace(/\.$/, "");
71201
+ if (full.length === 0) return rejected("blank hostname");
71202
+ if (isIp(full)) return rejected("an address, not a hostname");
71203
+ const label = full.split(".")[0] ?? "";
71204
+ if (!HOSTNAME_PATTERN.test(label)) return rejected("not a hostname");
71205
+ if (label === "localhost") return rejected("placeholder hostname");
71206
+ return {
71207
+ ok: true,
71208
+ value: label
71209
+ };
71210
+ }
71211
+ function normaliseIp(raw) {
71212
+ const value = raw.trim().toLowerCase().replace(/^\[|\]$/g, "");
71213
+ if (!isIp(value)) return rejected("not an IP address");
71214
+ if (value === "0.0.0.0" || value === "::" || value === "::1" || value.startsWith("127.")) return rejected("loopback or unspecified address");
71215
+ return {
71216
+ ok: true,
71217
+ value
71218
+ };
71219
+ }
71220
+ function isBlank(value) {
71221
+ return value === null || value === void 0 || value.trim().length === 0;
71222
+ }
71223
+ /**
71224
+ * Turn what a driver read into a valid {@link DeviceIdentifiers}: MACs lower-case
71225
+ * with colons and de-duplicated, a hostname without its domain, an IP validated,
71226
+ * a serial prefixed by its manufacturer, a vendor uid by its vendor. A value that
71227
+ * cannot be normalised is left out and listed in `rejected` — the caller logs it
71228
+ * (with `tags: { deviceId }`), it is never dropped in silence.
71229
+ */
71230
+ function normaliseIdentifiers(raw, options = {}) {
71231
+ const readAt = options.readAt ?? Date.now();
71232
+ const originOf = (key) => options.originByKey?.[key] ?? options.origin ?? "read";
71233
+ const entry = (key, value) => ({
71234
+ value,
71235
+ origin: originOf(key),
71236
+ readAt
71237
+ });
71238
+ const refused = [];
71239
+ const take = (key, input, result) => {
71240
+ if (result.ok) return entry(key, result.value);
71241
+ refused.push({
71242
+ key,
71243
+ value: input,
71244
+ reason: result.reason
71245
+ });
71246
+ };
71247
+ const macInputs = raw.mac === null || raw.mac === void 0 ? [] : [raw.mac].flat();
71248
+ const macs = [];
71249
+ for (const input of macInputs) {
71250
+ if (isBlank(input)) continue;
71251
+ const taken = take("mac", input, normaliseMac(input));
71252
+ if (taken !== void 0 && !macs.some((m) => m.value === taken.value)) macs.push(taken);
71253
+ }
71254
+ 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"));
71255
+ 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"));
71256
+ const machineUuid = isBlank(raw.machineUuid) ? void 0 : take("machine-uuid", raw.machineUuid, normaliseMachineUuid(raw.machineUuid));
71257
+ const host = isBlank(raw.host) ? null : raw.host.trim();
71258
+ const hostIsIp = host !== null && isIp(host.toLowerCase().replace(/^\[|\]$/g, ""));
71259
+ const hostnameInput = isBlank(raw.hostname) ? hostIsIp ? null : host : raw.hostname;
71260
+ const ipInput = isBlank(raw.ip) ? hostIsIp ? host : null : raw.ip;
71261
+ const hostname = hostnameInput === null ? void 0 : take("hostname", hostnameInput, normaliseHostname(hostnameInput));
71262
+ const ip = ipInput === null ? void 0 : take("ip", ipInput, normaliseIp(ipInput));
71263
+ return {
71264
+ identifiers: {
71265
+ ...macs.length > 0 ? { mac: macs } : {},
71266
+ ...serial !== void 0 ? { serial } : {},
71267
+ ...machineUuid !== void 0 ? { "machine-uuid": machineUuid } : {},
71268
+ ...vendorUid !== void 0 ? { "vendor-uid": vendorUid } : {},
71269
+ ...hostname !== void 0 ? { hostname } : {},
71270
+ ...ip !== void 0 ? { ip } : {}
71271
+ },
71272
+ rejected: refused
71273
+ };
71274
+ }
71275
+ function sameEntry(a, b) {
71276
+ return a.value === b.value && a.origin === b.origin;
71277
+ }
71278
+ /** `next`, but with the stored entry wherever value and origin are unchanged. */
71279
+ function keepStoredEntry(next, stored) {
71280
+ return stored !== void 0 && sameEntry(next, stored) ? stored : next;
71281
+ }
71282
+ /**
71283
+ * The declaration to store when the owning provider declares `next` over
71284
+ * `stored` (D1059).
71285
+ *
71286
+ * - A kind in `unread` — the provider TRIED to read it and the read failed —
71287
+ * keeps its stored entry: a failed read changes nothing (D49).
71288
+ * - Every other kind is what `next` says: a kind absent from `next` was read and
71289
+ * found absent, so it is removed.
71290
+ * - An entry whose value and origin are unchanged keeps its stored `readAt`:
71291
+ * `readAt` is when that value was FIRST read, so a provider re-declaring on every
71292
+ * boot writes nothing and emits nothing.
71293
+ *
71294
+ * Returns `null` when nothing is left.
71295
+ */
71296
+ function mergeIdentifiers(stored, next, unread = []) {
71297
+ const before = stored ?? {};
71298
+ const after = next ?? {};
71299
+ const failed = new Set(unread);
71300
+ const macs = failed.has("mac") ? before.mac : after.mac?.map((m) => keepStoredEntry(m, before.mac?.find((s) => sameEntry(s, m))));
71301
+ const single = (key) => {
71302
+ if (failed.has(key)) return before[key];
71303
+ const entry = after[key];
71304
+ return entry === void 0 ? void 0 : keepStoredEntry(entry, before[key]);
71305
+ };
71306
+ const serial = single("serial");
71307
+ const machineUuid = single("machine-uuid");
71308
+ const vendorUid = single("vendor-uid");
71309
+ const hostname = single("hostname");
71310
+ const ip = single("ip");
71311
+ const merged = {
71312
+ ...macs !== void 0 && macs.length > 0 ? { mac: macs } : {},
71313
+ ...serial !== void 0 ? { serial } : {},
71314
+ ...machineUuid !== void 0 ? { "machine-uuid": machineUuid } : {},
71315
+ ...vendorUid !== void 0 ? { "vendor-uid": vendorUid } : {},
71316
+ ...hostname !== void 0 ? { hostname } : {},
71317
+ ...ip !== void 0 ? { ip } : {}
71318
+ };
71319
+ return isEmptyIdentifiers(merged) ? null : merged;
71320
+ }
71321
+ /** True when two declarations hold the same entries, `readAt` included (key order ignored). */
71322
+ function sameIdentifiers(a, b) {
71323
+ 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) => [
71324
+ x.value,
71325
+ x.origin,
71326
+ x.readAt
71327
+ ])]));
71328
+ return canonical(a) === canonical(b);
71329
+ }
70357
71330
  var DeviceSearchRequiresSchema = zod.z.object({
70358
71331
  /** Capability names the field wants a value of. Absent when the field wants actions only. */
70359
71332
  caps: zod.z.array(zod.z.string()).readonly().optional(),
@@ -70916,6 +71889,10 @@ var DeviceInfoSchema = zod.z.object({
70916
71889
  /** Hardware + identity blob (manufacturer / model / firmware / sn /
70917
71890
  * uid / mac / …). Populated by drivers; editable via setMetadata. */
70918
71891
  metadata: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
71892
+ /** Provider-declared identifiers (D1059): typed, normalised, written only by
71893
+ * the owning provider via `setIdentifiers`; read-only for the operator.
71894
+ * Absent ⇒ the provider declared none. */
71895
+ identifiers: DeviceIdentifiersSchema.optional(),
70919
71896
  /** Optional upstream-system identity + rendering envelope. See
70920
71897
  * `SourceInfo` in `packages/types/src/device/source-info.ts`. */
70921
71898
  sourceInfo: SourceInfoSchema.optional(),
@@ -71082,6 +72059,8 @@ var DeviceMetaSchema = zod.z.object({
71082
72059
  disabled: zod.z.boolean(),
71083
72060
  parentDeviceId: zod.z.number().nullable(),
71084
72061
  metadata: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
72062
+ /** Provider-declared identifiers (D1059). See `DeviceMeta.identifiers`. */
72063
+ identifiers: DeviceIdentifiersSchema.optional(),
71085
72064
  /** Optional upstream-system identity + rendering envelope. See
71086
72065
  * `SourceInfo`. Present when the device has been persisted with a
71087
72066
  * non-synthetic source identifier (HA entities, vendor MAC, …);
@@ -71563,6 +72542,26 @@ var deviceManagerCapability = {
71563
72542
  kind: "mutation",
71564
72543
  auth: "admin"
71565
72544
  }),
72545
+ /** Declare the device's identifiers (D1059) — the typed, normalised keys
72546
+ * (`mac`, `serial`, `machine-uuid`, `vendor-uid`, `hostname`, `ip`) a later
72547
+ * step matches across integrations. Each kind is REPLACED by what this call
72548
+ * says (absent = read and found absent, removed) EXCEPT the kinds listed in
72549
+ * `unread` — the reads that FAILED this time — which keep their stored value.
72550
+ * An unchanged value keeps its first `readAt`; a call that changes nothing
72551
+ * writes and emits nothing. `null` clears every read kind. Accepted only from the provider that OWNS the device: the
72552
+ * caller stamp the transport sets (`callerAddonId`) must equal the row's
72553
+ * `addonId`, so an operator session — which carries no stamp — is refused.
72554
+ * Build the value with `normaliseIdentifiers` (`@camstack/types`); a device
72555
+ * calls it through `BaseDevice.declareIdentifiers`. */
72556
+ setIdentifiers: method(zod.z.object({
72557
+ deviceId: zod.z.number(),
72558
+ identifiers: DeviceIdentifiersSchema.nullable(),
72559
+ /** Kinds the provider tried to read and could not: their stored value is kept. */
72560
+ unread: zod.z.array(DeviceIdentifierKeySchema).optional()
72561
+ }), zod.z.void(), {
72562
+ kind: "mutation",
72563
+ auth: "admin"
72564
+ }),
71566
72565
  /** Operator-curated location registry. Returns the union of:
71567
72566
  * (1) labels persisted in the registry via `addLocation`, and
71568
72567
  * (2) labels currently in use on at least one device's
@@ -77895,6 +78894,7 @@ var HERO_SCENE_BY_TYPE = {
77895
78894
  [DeviceType.WaterHeater]: "heater",
77896
78895
  [DeviceType.HeatPump]: "heat-pump",
77897
78896
  [DeviceType.EnergySystem]: "generic",
78897
+ [DeviceType.Workload]: "generic",
77898
78898
  [DeviceType.Fan]: "fan",
77899
78899
  [DeviceType.MediaPlayer]: "tv",
77900
78900
  [DeviceType.AlarmPanel]: "alarm",
@@ -77937,6 +78937,7 @@ var HERO_SCENE_BY_ROLE = {
77937
78937
  [DeviceRole.SwitchHeater]: "heater",
77938
78938
  [DeviceRole.SwitchFan]: "fan",
77939
78939
  [DeviceRole.SwitchLight]: "light",
78940
+ [DeviceRole.PoePort]: "plug",
77940
78941
  [DeviceRole.ClimateAc]: "ac",
77941
78942
  [DeviceRole.ClimateThermostat]: "inherit",
77942
78943
  [DeviceRole.ClimateFloor]: "inherit",
@@ -77981,7 +78982,12 @@ var HERO_SCENE_BY_ROLE = {
77981
78982
  [DeviceRole.MessagingNotifier]: "inherit",
77982
78983
  [DeviceRole.EmailNotifier]: "inherit",
77983
78984
  [DeviceRole.GenericNotifier]: "inherit",
77984
- [DeviceRole.IrTransmitter]: "inherit"
78985
+ [DeviceRole.IrTransmitter]: "inherit",
78986
+ [DeviceRole.Vm]: "inherit",
78987
+ [DeviceRole.AppContainer]: "inherit",
78988
+ [DeviceRole.Lxc]: "inherit",
78989
+ [DeviceRole.App]: "inherit",
78990
+ [DeviceRole.Host]: "inherit"
77985
78991
  };
77986
78992
  function isDeviceType$3(type) {
77987
78993
  return Object.values(DeviceType).includes(type);
@@ -78239,8 +79245,12 @@ var HeroPowerSupplySlotSchema = zod.z.object({
78239
79245
  /** Off asks for a confirmation while the device runs. */
78240
79246
  confirmOffWhileRunning: zod.z.boolean(),
78241
79247
  running: zod.z.boolean().nullable(),
78242
- powerOn: HeroActionSchema,
78243
- powerOff: HeroActionSchema,
79248
+ /**
79249
+ * `null` when the linked switch ANSWERED it only reports (a PoE port seen through an
79250
+ * API key): power on / off would always be refused. The restart stays (D1058).
79251
+ */
79252
+ powerOn: HeroActionSchema.nullable(),
79253
+ powerOff: HeroActionSchema.nullable(),
78244
79254
  restart: HeroActionSchema
78245
79255
  });
78246
79256
  var HeroStateBackdropSchema = zod.z.object({
@@ -91741,6 +92751,19 @@ var NetworkLinkStatusSchema = zod.z.object({
91741
92751
  rssi: zod.z.number().optional().meta(readingMeta("signal-level")),
91742
92752
  /** Network name of a wireless link, when the firmware reports it. */
91743
92753
  ssid: zod.z.string().optional(),
92754
+ /**
92755
+ * Negotiated link speed of a wired port, the `bitrate` quantity in its base
92756
+ * unit, kbit/s (a gigabit port is 1 000 000); the display picks the unit.
92757
+ * `null` = the port is down or the speed is not known; absent = the provider
92758
+ * never reports one.
92759
+ */
92760
+ speedKbps: zod.z.number().nonnegative().nullable().optional().meta(readingMeta("bitrate")),
92761
+ /**
92762
+ * Whether the link is up. `type` names the medium, not its state, so a wired
92763
+ * port that lost its link is `ethernet` + `linkUp: false`. `null` = not known;
92764
+ * absent = the provider never reports it.
92765
+ */
92766
+ linkUp: zod.z.boolean().nullable().optional(),
91744
92767
  /** Ms epoch of the last observation. Lets consumers reason about freshness. */
91745
92768
  lastUpdated: zod.z.number().meta(readingMeta("none"))
91746
92769
  });
@@ -102073,7 +103096,18 @@ var videoclipsCapability = {
102073
103096
  * older than this field keeps working unchanged (D382 — an unstated
102074
103097
  * ask is zero).
102075
103098
  */
102076
- audio: ClipStreamAudioSchema.optional()
103099
+ audio: ClipStreamAudioSchema.optional(),
103100
+ /**
103101
+ * The operator's authorisation to wake a sleeping camera for this
103102
+ * dial — the same {@link ClipWakeSchema} the byte reads carry. Absent
103103
+ * — the default — means a sleeping standalone battery camera is
103104
+ * REFUSED by name before any URL is minted. A caller sets it only
103105
+ * when a viewer itself asked for the clip (the broker's `playClip`);
103106
+ * a prefetch, a reconcile or a retry never does. With it, the
103107
+ * provider wakes the camera and waits under a bound; a camera that
103108
+ * does not come up is refused `wake-timeout`, naming the wait.
103109
+ */
103110
+ wake: ClipWakeSchema.optional()
102077
103111
  }), ClipStreamDialSchema, {
102078
103112
  kind: "query",
102079
103113
  auth: "protected"
@@ -102363,7 +103397,8 @@ zod.z.enum([
102363
103397
  "camera-refused",
102364
103398
  "fetch-failed",
102365
103399
  "too-large-to-transfer",
102366
- "wake-expired"
103400
+ "wake-expired",
103401
+ "wake-timeout"
102367
103402
  ]);
102368
103403
  /** Candidate download URLs (LAN first, then operator extra hosts). */
102369
103404
  var ExportDownloadSchema = zod.z.object({
@@ -104999,6 +106034,16 @@ var SirenOptionsSchema = zod.z.object({
104999
106034
  rangeSeconds: SirenDurationRangeSchema.nullable(),
105000
106035
  /** The camera's default duration, seconds. */
105001
106036
  defaultSeconds: zod.z.number().positive(),
106037
+ /**
106038
+ * Discrete play counts the operator may pick; `null` when the camera gives a
106039
+ * range or does not count plays. Defaults to `null` so a provider that
106040
+ * predates plays (#589) reads as declaring none.
106041
+ */
106042
+ allowedPlays: zod.z.array(zod.z.number().int().positive()).nullable().default(null),
106043
+ /** Continuous range of play counts; `null` when listed or not counted. */
106044
+ rangePlays: SirenDurationRangeSchema.nullable().default(null),
106045
+ /** The camera's default play count; `null` when the camera does not count plays. */
106046
+ defaultPlays: zod.z.number().int().positive().nullable().default(null),
105002
106047
  /** What the camera counts natively. */
105003
106048
  unit: zod.z.enum([SirenDurationUnit.Seconds, SirenDurationUnit.Plays]),
105004
106049
  /** Seconds one play lasts, when `unit` is `plays`; `null` for a seconds camera. */
@@ -105015,9 +106060,28 @@ var SirenStatusSchema = zod.z.object({
105015
106060
  activeUntil: zod.z.number().nullable(),
105016
106061
  /** Duration of the current / last activation, seconds; `null` when none yet. */
105017
106062
  durationSeconds: zod.z.number().nullable(),
106063
+ /**
106064
+ * The play count of the current / last activation when it was asked in plays;
106065
+ * `null` when it was asked in seconds (or none yet). The unit that was asked.
106066
+ */
106067
+ plays: zod.z.number().int().positive().nullable().default(null),
106068
+ /**
106069
+ * True when `activeUntil` comes from a seconds-per-play factor the camera did
106070
+ * not report — the siren may fall silent somewhat earlier or later.
106071
+ */
106072
+ activeUntilEstimated: zod.z.boolean().default(false),
105018
106073
  /** Ms epoch of the last trigger (0 = never). */
105019
106074
  lastTriggeredAt: zod.z.number()
105020
106075
  });
106076
+ /** A trigger asks seconds OR plays (#589); neither means the camera default. */
106077
+ var SirenTriggerInputSchema = zod.z.object({
106078
+ deviceId: zod.z.number().int().nonnegative(),
106079
+ durationSeconds: zod.z.number().positive().optional(),
106080
+ plays: zod.z.number().int().positive().optional()
106081
+ }).refine((input) => input.durationSeconds === void 0 || input.plays === void 0, {
106082
+ message: "a siren trigger takes durationSeconds or plays, not both",
106083
+ path: ["plays"]
106084
+ });
105021
106085
  var SirenRuntimeStateSchema = SirenStatusSchema.extend({
105022
106086
  /** Ms epoch of the last successful camera read of the options (0 = never). */
105023
106087
  lastFetchedAt: zod.z.number() });
@@ -105034,13 +106098,20 @@ var sirenCapability = {
105034
106098
  auth: "protected"
105035
106099
  }),
105036
106100
  /**
105037
- * Sound the siren. Without `durationSeconds` the camera default applies.
105038
- * Answers the state at the moment of the trigger (`activeUntil` included).
106101
+ * The play counts a rule may pick: what `getOptions` declares as a list, or
106102
+ * its range spelled out. Empty for a siren that counts seconds.
105039
106103
  */
105040
- trigger: method(zod.z.object({
105041
- deviceId: zod.z.number().int().nonnegative(),
105042
- durationSeconds: zod.z.number().positive().optional()
105043
- }), SirenStatusSchema, {
106104
+ getPlayChoices: method(zod.z.object({ deviceId: zod.z.number().int().nonnegative() }), zod.z.array(zod.z.number().int().positive()), {
106105
+ kind: "query",
106106
+ auth: "protected"
106107
+ }),
106108
+ /**
106109
+ * Sound the siren for `durationSeconds` OR `plays` — never both. With
106110
+ * neither the camera default applies. A count on a siren that declares no
106111
+ * plays is refused. Answers the state at the moment of the trigger
106112
+ * (`activeUntil` included).
106113
+ */
106114
+ trigger: method(SirenTriggerInputSchema, SirenStatusSchema, {
105044
106115
  kind: "mutation",
105045
106116
  auth: "protected",
105046
106117
  actions: [{
@@ -105049,6 +106120,21 @@ var sirenCapability = {
105049
106120
  phrase: t("Sound {device}", "Fai suonare {device}"),
105050
106121
  icon: "siren",
105051
106122
  args: {}
106123
+ }, {
106124
+ id: "siren.triggerPlays",
106125
+ label: t("Sound the siren N times", "Fai suonare la sirena N volte"),
106126
+ phrase: t("Sound {device} {plays} times", "Fai suonare {device} {plays} volte"),
106127
+ icon: "siren",
106128
+ openArgs: [{
106129
+ key: "plays",
106130
+ label: t("Plays", "Riproduzioni"),
106131
+ offer: {
106132
+ kind: "dynamic",
106133
+ from: "method",
106134
+ method: "getPlayChoices",
106135
+ valueKind: "number"
106136
+ }
106137
+ }]
105052
106138
  }]
105053
106139
  }),
105054
106140
  /** Silence the siren now. */
@@ -106638,6 +107724,27 @@ var SwitchStatusSchema = zod.z.object({
106638
107724
  /** Ms epoch of the last state change. Useful for UI "X minutes ago". */
106639
107725
  lastChangedAt: zod.z.number()
106640
107726
  });
107727
+ /**
107728
+ * What a switch can do, from its provider (`getOptions`). A provider that writes no
107729
+ * `getOptions` is a plain on/off switch: the defaults are the old contract.
107730
+ *
107731
+ * - `supportsSetState: false` — the switch reports its state but cannot be set (a PoE port seen only
107732
+ * through an API key). Its provider refuses `setState`; these surfaces withdraw on/off once the
107733
+ * device ANSWERED this (`switchRefusesSetState`): the device hero, the automation action picker
107734
+ * (`offeredWhen` on `switch.on` / `switch.off` / `switch.toggle`), the default `toggle`, the
107735
+ * HomeKit, Alexa and Google exporters, and `power-source` on a device the switch powers
107736
+ * (`getStatus().switchSettable`, `offeredWhen` on `powerSource.on` / `.off`, `not-settable`). A
107737
+ * read that failed or is pending changes nothing (D315).
107738
+ * - `supportsPowerCycle: true` — the device behind the switch can cut and restore its own output in
107739
+ * one native call (a PoE port's power cycle). It has no control of its own: a linked
107740
+ * `power-source.forceRestart` uses it instead of off / wait / on.
107741
+ */
107742
+ var SwitchOptionsSchema = zod.z.object({
107743
+ supportsSetState: zod.z.boolean().default(true),
107744
+ supportsPowerCycle: zod.z.boolean().default(false)
107745
+ });
107746
+ /** The options of a provider that did not answer `getOptions`: a plain on/off switch. */
107747
+ var SWITCH_DEFAULT_OPTIONS = SwitchOptionsSchema.parse({});
106641
107748
  var switchCapability = {
106642
107749
  name: "switch",
106643
107750
  scope: "device",
@@ -106665,7 +107772,8 @@ var switchCapability = {
106665
107772
  field: "on",
106666
107773
  value: true
106667
107774
  },
106668
- args: { on: true }
107775
+ args: { on: true },
107776
+ offeredWhen: SWITCH_SETTABLE_GATE
106669
107777
  }, {
106670
107778
  id: "switch.off",
106671
107779
  label: t("Turn off", "Spegni"),
@@ -106675,9 +107783,16 @@ var switchCapability = {
106675
107783
  field: "on",
106676
107784
  value: false
106677
107785
  },
106678
- args: { on: false }
107786
+ args: { on: false },
107787
+ offeredWhen: SWITCH_SETTABLE_GATE
106679
107788
  }]
106680
107789
  }),
107790
+ getOptions: optionalMethod(zod.z.object({ deviceId: zod.z.number() }), SwitchOptionsSchema, { auth: "protected" }),
107791
+ powerCycle: optionalMethod(zod.z.object({ deviceId: zod.z.number() }), zod.z.void(), {
107792
+ kind: "mutation",
107793
+ auth: "protected",
107794
+ notOperatorFacing: "a power cycle is the forced restart of the device the switch powers (power-source), never a step of its own"
107795
+ }),
106681
107796
  toggle: optionalMethod(zod.z.object({ deviceId: zod.z.number() }), zod.z.void(), {
106682
107797
  kind: "mutation",
106683
107798
  auth: "protected",
@@ -106685,7 +107800,8 @@ var switchCapability = {
106685
107800
  id: "switch.toggle",
106686
107801
  label: t("Toggle", "Commuta"),
106687
107802
  phrase: t("Toggle {device}", "Commuta {device}"),
106688
- icon: "toggle-right"
107803
+ icon: "toggle-right",
107804
+ offeredWhen: SWITCH_SETTABLE_GATE
106689
107805
  }]
106690
107806
  })
106691
107807
  },
@@ -106707,6 +107823,16 @@ var switchCapability = {
106707
107823
  * not need to re-query the provider after a setState mutation.
106708
107824
  */
106709
107825
  runtimeState: SwitchStatusSchema,
107826
+ composedMethods: {
107827
+ getOptions: {
107828
+ kind: "answer",
107829
+ value: SWITCH_DEFAULT_OPTIONS
107830
+ },
107831
+ powerCycle: {
107832
+ kind: "refuse",
107833
+ reason: "a composed switch has no native power cycle"
107834
+ }
107835
+ },
106710
107836
  /**
106711
107837
  * Runtime-state durability: **restored** — device state an operator reads as authoritative; 55 devices, transition-driven.
106712
107838
  *
@@ -106880,6 +108006,26 @@ var switchCapability = {
106880
108006
  "switch.off": { icon: "plug" }
106881
108007
  },
106882
108008
  state: { on: { icon: "plug-zap" } }
108009
+ },
108010
+ [DeviceRole.PoePort]: {
108011
+ actions: {
108012
+ "switch.on": {
108013
+ label: t("Power on", "Alimenta"),
108014
+ phrase: t("Power on {device}", "Alimenta {device}"),
108015
+ icon: "plug-zap"
108016
+ },
108017
+ "switch.off": {
108018
+ label: t("Power off", "Togli alimentazione"),
108019
+ phrase: t("Power off {device}", "Togli alimentazione a {device}"),
108020
+ icon: "unplug"
108021
+ }
108022
+ },
108023
+ state: { on: {
108024
+ label: t("Powered", "Alimentata"),
108025
+ whenTrue: t("When {device} is powered", "Quando {device} viene alimentata"),
108026
+ whenFalse: t("When {device} loses power", "Quando {device} perde l’alimentazione"),
108027
+ icon: "plug-zap"
108028
+ } }
106883
108029
  }
106884
108030
  }
106885
108031
  }
@@ -108632,7 +109778,6 @@ var templateCapability = {
108632
109778
  };
108633
109779
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
108634
109780
  var ProfileSettingsSchemaBridge = zod.z.unknown().nullable();
108635
- var ProfileSettingsBagSchema = zod.z.record(zod.z.string(), zod.z.unknown());
108636
109781
  /**
108637
109782
  * A live terminal session hosted by the provider addon. Output and input do
108638
109783
  * NOT flow through the capability — they use the addon data plane
@@ -108675,39 +109820,6 @@ var TerminalProfileInfoSchema = zod.z.object({
108675
109820
  /** ConfigUISchema for instance knobs, or null when the profile has none. */
108676
109821
  settingsSchema: ProfileSettingsSchemaBridge.optional()
108677
109822
  });
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
109823
  var TerminalOutputEventSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
108712
109824
  seq: zod.z.number().int().positive(),
108713
109825
  kind: zod.z.literal("data"),
@@ -108739,8 +109851,8 @@ var TerminalOutputBatchSchema = zod.z.object({
108739
109851
  * terminal-session — singleton system capability for interactive TTY sessions.
108740
109852
  *
108741
109853
  * 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.
109854
+ * Profiles are allowlisted templates; a Terminal camera is a core block naming
109855
+ * one Terminal (planning#580).
108744
109856
  */
108745
109857
  var terminalSessionCapability = {
108746
109858
  name: "terminal-session",
@@ -108749,16 +109861,6 @@ var terminalSessionCapability = {
108749
109861
  methods: {
108750
109862
  /** Pre-declared profiles the operator may open. */
108751
109863
  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
109864
  /** Live sessions currently hosted by the provider. */
108763
109865
  listSessions: method(zod.z.void(), zod.z.array(TerminalSessionInfoSchema).readonly(), { auth: "admin" }),
108764
109866
  /**
@@ -111907,6 +113009,454 @@ var webrtcSessionCapability = {
111907
113009
  order: 3340
111908
113010
  }
111909
113011
  };
113012
+ var WorkloadStateSchema = zod.z.enum([
113013
+ "running",
113014
+ "paused",
113015
+ "stopped",
113016
+ "starting",
113017
+ "stopping",
113018
+ "crashed"
113019
+ ]);
113020
+ /** The five kinds of workload, as roles of the `workload` device type (D1033). */
113021
+ var WORKLOAD_ROLES = [
113022
+ DeviceRole.Vm,
113023
+ DeviceRole.AppContainer,
113024
+ DeviceRole.Lxc,
113025
+ DeviceRole.App,
113026
+ DeviceRole.Host
113027
+ ];
113028
+ /**
113029
+ * What the workload uses. Every value is `null` when not reported (D393). A host
113030
+ * fills `load1` and `temperature`; its uptime is `since` while it runs.
113031
+ */
113032
+ var WorkloadResourcesSchema = zod.z.object({
113033
+ /** CPU use, percent of the CPUs it may use (0–100). */
113034
+ cpuPercent: zod.z.number().nullable().meta(readingMeta("percentage", { precision: 1 })),
113035
+ memoryUsedBytes: zod.z.number().nullable().meta(readingMeta("information")),
113036
+ /**
113037
+ * Memory use, percent of `memoryLimitBytes`, for a source that reports a share
113038
+ * and not bytes (a Docker container's stats). Absent or `null` = not reported.
113039
+ */
113040
+ memoryPercent: zod.z.number().nullable().optional().meta(readingMeta("percentage", { precision: 1 })),
113041
+ /** The memory it may use: the limit of a container, the RAM of a VM or host. */
113042
+ memoryLimitBytes: zod.z.number().nullable().meta(readingMeta("information")),
113043
+ vcpus: zod.z.number().nullable().meta(readingMeta("count")),
113044
+ diskUsedBytes: zod.z.number().nullable().meta(readingMeta("information")),
113045
+ diskTotalBytes: zod.z.number().nullable().meta(readingMeta("information")),
113046
+ /** Network received, kbit/s. */
113047
+ netRxKbps: zod.z.number().nullable().meta(readingMeta("bitrate")),
113048
+ /** Network sent, kbit/s. */
113049
+ netTxKbps: zod.z.number().nullable().meta(readingMeta("bitrate")),
113050
+ /** One-minute load average (a host). */
113051
+ load1: zod.z.number().nullable().meta(readingMeta("index", { precision: 2 })),
113052
+ /** CPU / board temperature (a host). */
113053
+ temperature: zod.z.number().nullable().meta(readingMeta("temperature", { precision: 1 }))
113054
+ });
113055
+ var WorkloadPortProtocolSchema = zod.z.enum(["tcp", "udp"]);
113056
+ /** One published port: the workload's own port and where the host exposes it. */
113057
+ var WorkloadPortSchema = zod.z.object({
113058
+ port: zod.z.number().int().meta(readingMeta("none")),
113059
+ /** The host port it is published on; null = not published. */
113060
+ hostPort: zod.z.number().int().nullable().meta(readingMeta("none")),
113061
+ /** The host address it is bound to; null = every address. */
113062
+ hostIp: zod.z.string().nullable(),
113063
+ protocol: WorkloadPortProtocolSchema
113064
+ });
113065
+ var WorkloadStatusSchema = zod.z.object({
113066
+ /** null = unknown, never stopped (D393). */
113067
+ state: WorkloadStateSchema.nullable().meta({ label: "State" }),
113068
+ /** Epoch ms the current state began (uptime while running); null when unknown. */
113069
+ since: zod.z.number().nullable().meta(readingMeta("none")),
113070
+ /** The `host` device this runs on, when the provider has adopted it. */
113071
+ hostDeviceId: zod.z.number().int().nullable().meta(readingMeta("device")),
113072
+ /** The image a container runs (`nginx:1.27`). */
113073
+ image: zod.z.string().nullable(),
113074
+ /** The operating system (a VM, an LXC, a host). */
113075
+ os: zod.z.string().nullable(),
113076
+ /** The version or firmware it runs. */
113077
+ version: zod.z.string().nullable(),
113078
+ /** Starts with its host; null when the platform does not say. */
113079
+ autostart: zod.z.boolean().nullable(),
113080
+ resources: WorkloadResourcesSchema,
113081
+ ports: zod.z.array(WorkloadPortSchema),
113082
+ /** The addresses it is reachable on (IPs or host names). */
113083
+ addresses: zod.z.array(zod.z.string()),
113084
+ /** A newer image / version exists. Installing it stays the `update` cap. */
113085
+ updateAvailable: zod.z.boolean().nullable(),
113086
+ lastFetchedAt: zod.z.number()
113087
+ });
113088
+ /**
113089
+ * What this device can do, probed by its provider (D14 honesty): a flag is
113090
+ * `true` only when the platform really serves it for THIS device.
113091
+ */
113092
+ var WorkloadOptionsSchema = zod.z.object({
113093
+ supportsStart: zod.z.boolean(),
113094
+ supportsStop: zod.z.boolean(),
113095
+ supportsRestart: zod.z.boolean(),
113096
+ /** Pause AND resume. */
113097
+ supportsPause: zod.z.boolean(),
113098
+ supportsForceStop: zod.z.boolean(),
113099
+ hasResources: zod.z.boolean(),
113100
+ hasPorts: zod.z.boolean(),
113101
+ hasAddresses: zod.z.boolean(),
113102
+ hasAutostart: zod.z.boolean(),
113103
+ hasUpdateCheck: zod.z.boolean()
113104
+ });
113105
+ var WorkloadDeviceInputSchema = zod.z.object({ deviceId: zod.z.number().int().nonnegative() });
113106
+ var WorkloadTransitionEventDataSchema = zod.z.object({
113107
+ deviceId: zod.z.number(),
113108
+ state: WorkloadStateSchema,
113109
+ previous: WorkloadStateSchema,
113110
+ since: zod.z.number().nullable()
113111
+ });
113112
+ function isWorkloadSettled(state) {
113113
+ return state !== "starting" && state !== "stopping";
113114
+ }
113115
+ /**
113116
+ * The event a move from the last SETTLED state to `next` raises, or null.
113117
+ * A first sight (`previous` undefined) raises nothing: it is not a change.
113118
+ * Unknown (`next` null) raises nothing and is not remembered.
113119
+ */
113120
+ function workloadTransition(previous, next) {
113121
+ if (previous === void 0 || next === null || next === previous) return null;
113122
+ switch (next) {
113123
+ case "running":
113124
+ if (previous === "crashed") return "recovered";
113125
+ return previous === "stopped" ? "started" : null;
113126
+ case "stopped": return previous === "running" || previous === "paused" ? "stopped" : null;
113127
+ case "crashed": return "crashed";
113128
+ case "paused":
113129
+ case "starting":
113130
+ case "stopping": return null;
113131
+ }
113132
+ }
113133
+ /** The bus category of each transition. */
113134
+ var WORKLOAD_TRANSITION_CATEGORY = {
113135
+ started: EventCategory.WorkloadStarted,
113136
+ stopped: EventCategory.WorkloadStopped,
113137
+ crashed: EventCategory.WorkloadCrashed,
113138
+ recovered: EventCategory.WorkloadRecovered
113139
+ };
113140
+ var workloadCapability = {
113141
+ name: "workload",
113142
+ scope: "device",
113143
+ deviceNative: true,
113144
+ mode: "singleton",
113145
+ deviceTypes: [DeviceType.Workload],
113146
+ deviceRoles: { [DeviceType.Workload]: WORKLOAD_ROLES },
113147
+ /**
113148
+ * On / off is the state (#462): stopped or crashed is off, anything else on.
113149
+ * The owner registers `switch` through `registerPowerSwitch`; there is no
113150
+ * second on/off state. A device whose provider serves no start / stop gets no
113151
+ * switch.
113152
+ */
113153
+ power: {
113154
+ kind: "methods",
113155
+ field: "state",
113156
+ offValues: ["stopped", "crashed"],
113157
+ on: "start",
113158
+ off: "stop"
113159
+ },
113160
+ methods: {
113161
+ start: optionalMethod(WorkloadDeviceInputSchema, zod.z.void(), {
113162
+ kind: "mutation",
113163
+ auth: "protected",
113164
+ actions: [{
113165
+ id: "workload.start",
113166
+ label: t("Start", "Avvia"),
113167
+ phrase: t("Start {device}", "Avvia {device}"),
113168
+ icon: "play",
113169
+ effect: {
113170
+ field: "state",
113171
+ value: "running"
113172
+ }
113173
+ }]
113174
+ }),
113175
+ stop: optionalMethod(WorkloadDeviceInputSchema, zod.z.void(), {
113176
+ kind: "mutation",
113177
+ auth: "protected",
113178
+ actions: [{
113179
+ id: "workload.stop",
113180
+ label: t("Stop", "Arresta"),
113181
+ phrase: t("Stop {device}", "Arresta {device}"),
113182
+ icon: "square",
113183
+ effect: {
113184
+ field: "state",
113185
+ value: "stopped"
113186
+ }
113187
+ }]
113188
+ }),
113189
+ restart: optionalMethod(WorkloadDeviceInputSchema, zod.z.void(), {
113190
+ kind: "mutation",
113191
+ auth: "protected",
113192
+ actions: [{
113193
+ id: "workload.restart",
113194
+ label: t("Restart", "Riavvia"),
113195
+ phrase: t("Restart {device}", "Riavvia {device}"),
113196
+ icon: "rotate-ccw"
113197
+ }]
113198
+ }),
113199
+ pause: optionalMethod(WorkloadDeviceInputSchema, zod.z.void(), {
113200
+ kind: "mutation",
113201
+ auth: "protected",
113202
+ actions: [{
113203
+ id: "workload.pause",
113204
+ label: t("Pause", "Metti in pausa"),
113205
+ phrase: t("Pause {device}", "Metti in pausa {device}"),
113206
+ icon: "pause",
113207
+ effect: {
113208
+ field: "state",
113209
+ value: "paused"
113210
+ }
113211
+ }]
113212
+ }),
113213
+ resume: optionalMethod(WorkloadDeviceInputSchema, zod.z.void(), {
113214
+ kind: "mutation",
113215
+ auth: "protected",
113216
+ actions: [{
113217
+ id: "workload.resume",
113218
+ label: t("Resume", "Riprendi"),
113219
+ phrase: t("Resume {device}", "Riprendi {device}"),
113220
+ icon: "circle-play",
113221
+ effect: {
113222
+ field: "state",
113223
+ value: "running"
113224
+ }
113225
+ }]
113226
+ }),
113227
+ forceStop: optionalMethod(WorkloadDeviceInputSchema, zod.z.void(), {
113228
+ kind: "mutation",
113229
+ auth: "admin",
113230
+ actions: [{
113231
+ id: "workload.forceStop",
113232
+ label: t("Force stop", "Arresto forzato"),
113233
+ phrase: t("Force {device} to stop", "Forza l’arresto di {device}"),
113234
+ icon: "octagon-x",
113235
+ effect: {
113236
+ field: "state",
113237
+ value: "stopped"
113238
+ }
113239
+ }]
113240
+ }),
113241
+ /** What THIS device can do, probed — the UI is derived from it. */
113242
+ getOptions: method(WorkloadDeviceInputSchema, WorkloadOptionsSchema, { auth: "protected" })
113243
+ },
113244
+ events: {
113245
+ onStarted: {
113246
+ data: WorkloadTransitionEventDataSchema,
113247
+ trigger: {
113248
+ category: EventCategory.WorkloadStarted,
113249
+ label: t("Started", "Avviato"),
113250
+ phrase: t("When {device} starts", "Quando {device} si avvia"),
113251
+ icon: "play"
113252
+ }
113253
+ },
113254
+ onStopped: {
113255
+ data: WorkloadTransitionEventDataSchema,
113256
+ trigger: {
113257
+ category: EventCategory.WorkloadStopped,
113258
+ label: t("Stopped", "Arrestato"),
113259
+ phrase: t("When {device} stops", "Quando {device} si arresta"),
113260
+ icon: "square"
113261
+ }
113262
+ },
113263
+ onCrashed: {
113264
+ data: WorkloadTransitionEventDataSchema,
113265
+ trigger: {
113266
+ category: EventCategory.WorkloadCrashed,
113267
+ label: t("Crashed", "Arrestato in modo anomalo"),
113268
+ phrase: t("When {device} stops without being asked", "Quando {device} si arresta senza che sia stato richiesto"),
113269
+ icon: "triangle-alert"
113270
+ }
113271
+ },
113272
+ onRecovered: {
113273
+ data: WorkloadTransitionEventDataSchema,
113274
+ trigger: {
113275
+ category: EventCategory.WorkloadRecovered,
113276
+ label: t("Recovered", "Ripristinato"),
113277
+ phrase: t("When {device} runs again after a crash", "Quando {device} riparte dopo un arresto anomalo"),
113278
+ icon: "heart-pulse"
113279
+ }
113280
+ }
113281
+ },
113282
+ status: {
113283
+ schema: WorkloadStatusSchema,
113284
+ kind: "poll"
113285
+ },
113286
+ runtimeState: WorkloadStatusSchema,
113287
+ /**
113288
+ * Runtime-state durability: **session** — the provider answers on its next
113289
+ * poll; the series are recorded, so a restart that clears the slice loses
113290
+ * nothing a reader needs. The events are judged from the first state seen.
113291
+ */
113292
+ durability: "session",
113293
+ /**
113294
+ * History (D850): the state as an enum, CPU / memory / network as gauges, so
113295
+ * the charts need no per-metric child device.
113296
+ */
113297
+ history: {
113298
+ primary: "resources.cpuPercent",
113299
+ priority: 40,
113300
+ fields: {
113301
+ state: { kind: "enum" },
113302
+ "resources.cpuPercent": {
113303
+ kind: "gauge",
113304
+ unit: "%",
113305
+ deadband: 2,
113306
+ displayName: "CPU"
113307
+ },
113308
+ "resources.memoryUsedBytes": {
113309
+ kind: "gauge",
113310
+ unit: "bytes",
113311
+ displayName: "Memory used"
113312
+ },
113313
+ "resources.memoryPercent": {
113314
+ kind: "gauge",
113315
+ unit: "%",
113316
+ deadband: 2,
113317
+ displayName: "Memory"
113318
+ },
113319
+ "resources.netRxKbps": {
113320
+ group: "network",
113321
+ kind: "gauge",
113322
+ unit: "kbps",
113323
+ displayName: "Network received"
113324
+ },
113325
+ "resources.netTxKbps": {
113326
+ group: "network",
113327
+ kind: "gauge",
113328
+ unit: "kbps",
113329
+ displayName: "Network sent"
113330
+ }
113331
+ }
113332
+ },
113333
+ volatileStateFields: ["lastFetchedAt"],
113334
+ vocabulary: {
113335
+ noun: t("Workload", "Carico di lavoro"),
113336
+ order: 2400,
113337
+ state: [
113338
+ {
113339
+ kind: "enum",
113340
+ field: "state",
113341
+ label: t("State", "Stato"),
113342
+ values: [
113343
+ {
113344
+ value: "running",
113345
+ label: t("Running", "In esecuzione"),
113346
+ phrase: t("When {device} is running", "Quando {device} è in esecuzione")
113347
+ },
113348
+ {
113349
+ value: "paused",
113350
+ label: t("Paused", "In pausa")
113351
+ },
113352
+ {
113353
+ value: "stopped",
113354
+ label: t("Stopped", "Arrestato"),
113355
+ phrase: t("When {device} is stopped", "Quando {device} è arrestato")
113356
+ },
113357
+ {
113358
+ value: "starting",
113359
+ label: t("Starting", "In avvio")
113360
+ },
113361
+ {
113362
+ value: "stopping",
113363
+ label: t("Stopping", "In arresto")
113364
+ },
113365
+ {
113366
+ value: "crashed",
113367
+ label: t("Crashed", "Arrestato in modo anomalo"),
113368
+ phrase: t("When {device} has crashed", "Quando {device} è arrestato in modo anomalo")
113369
+ }
113370
+ ],
113371
+ icon: "activity"
113372
+ },
113373
+ {
113374
+ kind: "numeric",
113375
+ field: "resources.cpuPercent",
113376
+ quantity: t("the CPU use", "l'uso della CPU"),
113377
+ label: t("CPU", "CPU"),
113378
+ unit: "%",
113379
+ icon: "cpu"
113380
+ },
113381
+ {
113382
+ kind: "numeric",
113383
+ field: "resources.memoryPercent",
113384
+ quantity: t("the memory use", "l'uso della memoria"),
113385
+ label: t("Memory", "Memoria"),
113386
+ unit: "%",
113387
+ icon: "memory-stick"
113388
+ },
113389
+ {
113390
+ kind: "numeric",
113391
+ field: "resources.temperature",
113392
+ quantity: t("the temperature", "la temperatura"),
113393
+ label: t("Temperature", "Temperatura"),
113394
+ unit: "°C",
113395
+ icon: "thermometer"
113396
+ }
113397
+ ],
113398
+ overrides: { byRole: {
113399
+ [DeviceRole.Vm]: {
113400
+ actions: { "workload.start": { icon: "monitor" } },
113401
+ state: { state: { icon: "monitor" } }
113402
+ },
113403
+ [DeviceRole.AppContainer]: {
113404
+ actions: { "workload.start": { icon: "container" } },
113405
+ state: { state: { icon: "container" } }
113406
+ },
113407
+ [DeviceRole.Lxc]: {
113408
+ actions: { "workload.start": { icon: "box" } },
113409
+ state: { state: { icon: "box" } }
113410
+ },
113411
+ [DeviceRole.App]: {
113412
+ actions: { "workload.start": { icon: "app-window" } },
113413
+ state: { state: { icon: "app-window" } }
113414
+ },
113415
+ [DeviceRole.Host]: {
113416
+ actions: {
113417
+ "workload.start": {
113418
+ label: t("Power on", "Accendi"),
113419
+ phrase: t("Power on {device}", "Accendi {device}"),
113420
+ icon: "power"
113421
+ },
113422
+ "workload.stop": {
113423
+ label: t("Shut down", "Spegni"),
113424
+ phrase: t("Shut down {device}", "Spegni {device}"),
113425
+ icon: "power-off"
113426
+ },
113427
+ "workload.restart": {
113428
+ label: t("Reboot", "Riavvia"),
113429
+ phrase: t("Reboot {device}", "Riavvia {device}"),
113430
+ icon: "refresh-cw"
113431
+ }
113432
+ },
113433
+ state: { state: { icon: "server" } },
113434
+ events: {
113435
+ onStarted: {
113436
+ label: t("Came online", "Tornato in linea"),
113437
+ phrase: t("When {device} comes online", "Quando {device} torna in linea"),
113438
+ icon: "server"
113439
+ },
113440
+ onStopped: {
113441
+ label: t("Shut down", "Spento"),
113442
+ phrase: t("When {device} shuts down", "Quando {device} si spegne"),
113443
+ icon: "server-off"
113444
+ },
113445
+ onCrashed: {
113446
+ label: t("Went down", "Caduto"),
113447
+ phrase: t("When {device} goes down unexpectedly", "Quando {device} cade inaspettatamente"),
113448
+ icon: "server-crash"
113449
+ },
113450
+ onRecovered: {
113451
+ label: t("Came online", "Tornato in linea"),
113452
+ phrase: t("When {device} comes back online after going down", "Quando {device} torna in linea dopo essere caduto"),
113453
+ icon: "server"
113454
+ }
113455
+ }
113456
+ }
113457
+ } }
113458
+ }
113459
+ };
111910
113460
  /**
111911
113461
  * Per-zone occupancy aggregation produced by the analytics frame
111912
113462
  * processor on every inference result. Covers the full combinatorial
@@ -112572,6 +114122,7 @@ var ALL_CAPABILITY_DEFINITIONS = [
112572
114122
  weatherCapability,
112573
114123
  weatherStationCapability,
112574
114124
  webrtcSessionCapability,
114125
+ workloadCapability,
112575
114126
  zoneAnalyticsCapability,
112576
114127
  zoneRulesCapability,
112577
114128
  zonesCapability
@@ -114631,6 +116182,438 @@ function withDefaultRunning(composition, blockId) {
114631
116182
  features: [...composition.features, feature]
114632
116183
  };
114633
116184
  }
116185
+ /** Marker written to a declared integration's `info`. */
116186
+ var DECLARED_INTEGRATION_FIXED_KEY = "fixed";
116187
+ /**
116188
+ * Give a declared integration its instance record, ONCE. The record is read first and left
116189
+ * exactly as it is when it exists (an operator's rename, a field the addon later adds): a seed
116190
+ * never overwrites. A read that fails throws and writes nothing (D49) — the next pass retries.
116191
+ * True when the record was written by this call.
116192
+ */
116193
+ async function seedInstanceOnce(instances, seed) {
116194
+ const existing = await instances.getInstance({ id: seed.id });
116195
+ if (existing !== null && existing !== void 0) return false;
116196
+ await instances.createInstance({
116197
+ id: seed.id,
116198
+ name: seed.name
116199
+ });
116200
+ return true;
116201
+ }
116202
+ /**
116203
+ * Strip the `<node>/<addon>` suffix a forked child carries.
116204
+ *
116205
+ * Comparing `ctx.kernel.localNodeId` raw skipped EVERY node — including the one
116206
+ * that was supposed to act — because on the hub it reads `hub/<addon>`.
116207
+ */
116208
+ function declarationOwnerNodeId(localNodeId) {
116209
+ const raw = localNodeId ?? "hub";
116210
+ if (!raw.includes("/")) return raw;
116211
+ return raw.split("/")[0] ?? "hub";
116212
+ }
116213
+ /**
116214
+ * The one way an addon owns a device it declares.
116215
+ *
116216
+ * Construct once with the addon's ports, then call {@link reconcile} on boot and
116217
+ * on every convergence tick. There is no second get-or-create helper — a guard
116218
+ * in `scripts/` enforces that.
116219
+ */
116220
+ var DeclaredDevices = class {
116221
+ ports;
116222
+ constructor(ports) {
116223
+ const addonId = ports.addonId;
116224
+ 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\`.`);
116225
+ this.ports = ports;
116226
+ }
116227
+ /**
116228
+ * Converge the declared set. Idempotent, and safe to call repeatedly.
116229
+ *
116230
+ * Throws only what the ports throw on the FIRST index read; every other
116231
+ * failure is per-device and logged, so one bad declaration never takes the
116232
+ * others down.
116233
+ */
116234
+ async reconcile(spec) {
116235
+ if ((spec.placement ?? "hub") === "hub") {
116236
+ const nodeId = declarationOwnerNodeId(this.ports.localNodeId);
116237
+ if (nodeId !== "hub") {
116238
+ this.ports.logger.info("declared devices are hub-owned — skipping on this node", { meta: {
116239
+ nodeId,
116240
+ rawNodeId: this.ports.localNodeId ?? null
116241
+ } });
116242
+ return {
116243
+ integrationId: null,
116244
+ devices: [],
116245
+ removed: [],
116246
+ owned: false
116247
+ };
116248
+ }
116249
+ }
116250
+ let integrationId;
116251
+ if (spec.integrationId !== void 0) integrationId = spec.integrationId;
116252
+ else {
116253
+ const own = await this.ensureIntegration(spec.integrationName);
116254
+ integrationId = own.id;
116255
+ await this.seedInstance(own);
116256
+ }
116257
+ const index = await this.readIndex();
116258
+ const live = await this.readLiveByStableId();
116259
+ const outcomes = [];
116260
+ for (const declaration of spec.devices) {
116261
+ const outcome = await this.applyDeclaration(declaration, integrationId, index, live);
116262
+ if (outcome !== null) outcomes.push(outcome);
116263
+ }
116264
+ const removed = await this.sweepWithdrawn(spec.devices, integrationId, index);
116265
+ return {
116266
+ integrationId,
116267
+ devices: outcomes,
116268
+ removed,
116269
+ owned: true
116270
+ };
116271
+ }
116272
+ /**
116273
+ * Get-or-create the FIXED integration, and RE-ASSERT the flag every pass.
116274
+ *
116275
+ * The re-assertion is the fix for the defect the hand-rolled version shipped
116276
+ * with: writing `info.fixed` only on the create path left every pre-existing
116277
+ * install without it, and the kernel kept offering to delete an integration
116278
+ * the addon owns.
116279
+ */
116280
+ async ensureIntegration(integrationName) {
116281
+ const existing = await this.ports.getIntegration(this.ports.addonId);
116282
+ if (existing === null) {
116283
+ const created = await this.ports.createIntegration({
116284
+ addonId: this.ports.addonId,
116285
+ name: integrationName,
116286
+ info: { [DECLARED_INTEGRATION_FIXED_KEY]: true }
116287
+ });
116288
+ this.ports.logger.info("declared a fixed integration", { meta: {
116289
+ integrationId: created.id,
116290
+ name: integrationName
116291
+ } });
116292
+ return {
116293
+ id: created.id,
116294
+ name: integrationName
116295
+ };
116296
+ }
116297
+ if (existing.info?.["fixed"] !== true) {
116298
+ await this.ports.updateIntegration({
116299
+ id: existing.id,
116300
+ info: { [DECLARED_INTEGRATION_FIXED_KEY]: true }
116301
+ });
116302
+ this.ports.logger.info("re-asserted `fixed` on a declared integration", { meta: { integrationId: existing.id } });
116303
+ }
116304
+ return {
116305
+ id: existing.id,
116306
+ name: existing.name ?? integrationName
116307
+ };
116308
+ }
116309
+ /** Seed the instance record of an integration this declarer owns; best-effort, retried next pass. */
116310
+ async seedInstance(integration) {
116311
+ const { seedInstance } = this.ports;
116312
+ if (seedInstance === void 0) return;
116313
+ try {
116314
+ await seedInstance({
116315
+ id: integration.id,
116316
+ name: integration.name
116317
+ });
116318
+ } catch (err) {
116319
+ this.ports.logger.warn("could not seed the instance record of a declared integration", {
116320
+ tags: { integrationId: integration.id },
116321
+ meta: { error: errMsg(err) }
116322
+ });
116323
+ }
116324
+ }
116325
+ async readIndex() {
116326
+ const rows = await this.ports.listOwnDevices();
116327
+ return new Map(rows.map((row) => [row.stableId, row]));
116328
+ }
116329
+ /**
116330
+ * Devices this kernel already has CONSTRUCTED, by stableId.
116331
+ *
116332
+ * Distinct from {@link readIndex}, and the distinction is the bug: the index
116333
+ * is persisted rows, this is live objects. A row without an object must be
116334
+ * adopted; an object must be left exactly as it is.
116335
+ *
116336
+ * Failure is non-fatal and deliberately so — an empty map degrades to the
116337
+ * previous behaviour (attempt the adopt) rather than skipping a device that
116338
+ * genuinely needs bringing up.
116339
+ */
116340
+ async readLiveByStableId() {
116341
+ try {
116342
+ const devices = await this.ports.devices.getAll();
116343
+ return new Map(devices.map((device) => [device.stableId, device]));
116344
+ } catch (err) {
116345
+ this.ports.logger.warn("could not read live devices — falling back to adopt-by-row", { meta: { error: err instanceof Error ? err.message : String(err) } });
116346
+ return /* @__PURE__ */ new Map();
116347
+ }
116348
+ }
116349
+ /**
116350
+ * One declaration: adopt what exists, create what does not.
116351
+ *
116352
+ * The create branch is the destructive one — it seeds `initialMeta`, and
116353
+ * `initialMeta.name` lands as an unconditional `setName`. A transiently empty
116354
+ * index therefore looks exactly like a first boot and would silently re-stamp
116355
+ * the declared name over the operator's rename. D49: that branch needs a
116356
+ * second read to agree.
116357
+ */
116358
+ async applyDeclaration(declaration, integrationId, index, live) {
116359
+ try {
116360
+ const alreadyLive = live.get(declaration.stableId);
116361
+ if (alreadyLive !== void 0) return {
116362
+ stableId: declaration.stableId,
116363
+ deviceId: alreadyLive.id,
116364
+ device: alreadyLive,
116365
+ created: false
116366
+ };
116367
+ let existing = index.get(declaration.stableId);
116368
+ if (existing === void 0) {
116369
+ existing = (await this.readIndex()).get(declaration.stableId);
116370
+ if (existing !== void 0) this.ports.logger.warn("device index disagreed with itself — adopting instead of re-creating", {
116371
+ tags: { deviceId: existing.id },
116372
+ meta: {
116373
+ stableId: declaration.stableId,
116374
+ addonId: this.ports.addonId
116375
+ }
116376
+ });
116377
+ }
116378
+ if (existing !== void 0) {
116379
+ const device = await this.ports.devices.create(declaration.stableId, declaration.DeviceClass, {}, null, void 0);
116380
+ this.ports.logger.info("declared device adopted", {
116381
+ tags: { deviceId: device.id },
116382
+ meta: {
116383
+ stableId: declaration.stableId,
116384
+ integrationId
116385
+ }
116386
+ });
116387
+ return {
116388
+ stableId: declaration.stableId,
116389
+ deviceId: device.id,
116390
+ device,
116391
+ created: false
116392
+ };
116393
+ }
116394
+ const device = await this.ports.devices.create(declaration.stableId, declaration.DeviceClass, declaration.config ?? {}, null, {
116395
+ type: declaration.type,
116396
+ name: declaration.name,
116397
+ integrationId,
116398
+ ...declaration.role === void 0 ? {} : { role: declaration.role }
116399
+ });
116400
+ this.ports.logger.info("declared device created", {
116401
+ tags: { deviceId: device.id },
116402
+ meta: {
116403
+ stableId: declaration.stableId,
116404
+ integrationId
116405
+ }
116406
+ });
116407
+ return {
116408
+ stableId: declaration.stableId,
116409
+ deviceId: device.id,
116410
+ device,
116411
+ created: true
116412
+ };
116413
+ } catch (err) {
116414
+ this.ports.logger.warn("a declared device could not be brought up", { meta: {
116415
+ stableId: declaration.stableId,
116416
+ error: err instanceof Error ? err.message : String(err)
116417
+ } });
116418
+ return null;
116419
+ }
116420
+ }
116421
+ /**
116422
+ * Remove rows under the addon's FIXED integration whose declaration is gone.
116423
+ *
116424
+ * Bounded to that integration: a declared integration has no operator
116425
+ * add-flow, so every row under it got there by declaration. Devices this
116426
+ * addon owns OUTSIDE it (a provider's adopted devices) are never candidates.
116427
+ *
116428
+ * Bounded in count, and every deletion is logged with its `deviceId` — a
116429
+ * withdrawal that removes an operator-visible row silently is the failure
116430
+ * mode, not the removal itself.
116431
+ */
116432
+ async sweepWithdrawn(declarations, integrationId, index) {
116433
+ const declared = new Set(declarations.map((d) => d.stableId));
116434
+ const candidates = [...index.values()].filter((row) => row.integrationId === integrationId && !declared.has(row.stableId));
116435
+ if (candidates.length === 0) return [];
116436
+ if (candidates.length > 32) {
116437
+ this.ports.logger.warn("withdrawal sweep exceeded its bound — removing nothing", { meta: {
116438
+ integrationId,
116439
+ candidates: candidates.length,
116440
+ bound: 32
116441
+ } });
116442
+ return [];
116443
+ }
116444
+ const removed = [];
116445
+ for (const row of candidates) try {
116446
+ await this.ports.devices.remove(row.id);
116447
+ removed.push(row.id);
116448
+ this.ports.logger.info("declared device removed — its declaration was withdrawn", {
116449
+ tags: { deviceId: row.id },
116450
+ meta: {
116451
+ stableId: row.stableId,
116452
+ integrationId
116453
+ }
116454
+ });
116455
+ } catch (err) {
116456
+ this.ports.logger.warn("a withdrawn declared device could not be removed", {
116457
+ tags: { deviceId: row.id },
116458
+ meta: {
116459
+ stableId: row.stableId,
116460
+ error: err instanceof Error ? err.message : String(err)
116461
+ }
116462
+ });
116463
+ }
116464
+ return removed;
116465
+ }
116466
+ };
116467
+ function isSpecOfKind(spec, kind) {
116468
+ return spec !== void 0 && spec.kind === kind;
116469
+ }
116470
+ /**
116471
+ * The blocks of `kind` whose composer row exists. A block whose row the
116472
+ * composer has not declared yet is left out: nothing can be hosted on it until
116473
+ * its next apply, and the next pass picks it up.
116474
+ */
116475
+ function selectEngineHostedBlocks(kind, compositions, composerRows) {
116476
+ if (compositions.state === "not-loaded") return {
116477
+ kind: "untrusted",
116478
+ reason: compositions.reason
116479
+ };
116480
+ const rowByStableId = new Map(composerRows.map((row) => [row.stableId, row]));
116481
+ const blocks = [];
116482
+ for (const view of compositions.views) {
116483
+ const block = view.block;
116484
+ const composition = block.source?.kind === "composition" ? block.source.composition : null;
116485
+ if (composition === null) continue;
116486
+ const spec = composition.helper;
116487
+ if (!isSpecOfKind(spec, kind)) continue;
116488
+ const stableId = `${COMPOSED_DEVICE_STABLE_ID_PREFIX}${block.id}`;
116489
+ const row = rowByStableId.get(stableId);
116490
+ if (row === void 0) continue;
116491
+ blocks.push({
116492
+ blockId: block.id,
116493
+ deviceId: row.id,
116494
+ stableId,
116495
+ name: block.name,
116496
+ enabled: block.enabled,
116497
+ updatedAt: block.updatedAt,
116498
+ composition,
116499
+ spec
116500
+ });
116501
+ }
116502
+ return {
116503
+ kind: "trusted",
116504
+ blocks
116505
+ };
116506
+ }
116507
+ var WITHDRAWAL_CONFIRMATIONS = 2;
116508
+ /**
116509
+ * D49 for an engine's hosted set: a block missing from ONE trusted read is
116510
+ * kept; a second consecutive trusted read that agrees withdraws it. An
116511
+ * untrusted read is never fed here, so it neither counts nor resets.
116512
+ */
116513
+ var HostedWithdrawalGate = class {
116514
+ misses = /* @__PURE__ */ new Map();
116515
+ /**
116516
+ * `hosted`: what the engine serves now; `present`: what this trusted read
116517
+ * names. Returns the ids to withdraw now, and the ids kept on a first miss.
116518
+ */
116519
+ judge(hosted, present) {
116520
+ const withdraw = [];
116521
+ const held = [];
116522
+ const misses = /* @__PURE__ */ new Map();
116523
+ for (const id of hosted) {
116524
+ if (present.has(id)) continue;
116525
+ const count = (this.misses.get(id) ?? 0) + 1;
116526
+ if (count < WITHDRAWAL_CONFIRMATIONS) {
116527
+ held.push(id);
116528
+ misses.set(id, count);
116529
+ } else withdraw.push(id);
116530
+ }
116531
+ this.misses = misses;
116532
+ return {
116533
+ withdraw,
116534
+ held
116535
+ };
116536
+ }
116537
+ };
116538
+ /**
116539
+ * Build `DeviceClass` on the composer's row `(stableId, id)`. The context is
116540
+ * `loadContext` (D677: a caller that BUILDS a device hydrates its stored
116541
+ * runtime state first); a kernel without it is refused by name rather than
116542
+ * building on an empty state. The device is never `register`ed and its config
116543
+ * never persisted: the row, its name and its lifetime are the composer's.
116544
+ */
116545
+ async function hostEngineDevice(devices, row, config, DeviceClass) {
116546
+ 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`);
116547
+ const base = await devices.loadContext(row.stableId, row.id, null, config);
116548
+ const registered = [];
116549
+ const device = new DeviceClass({
116550
+ ...base,
116551
+ registerNativeCap: (cap, provider) => {
116552
+ base.registerNativeCap(cap, provider);
116553
+ registered.push(cap.name);
116554
+ }
116555
+ });
116556
+ return {
116557
+ device,
116558
+ withdraw: async () => {
116559
+ await device.removeDevice();
116560
+ for (const capName of registered) base.unregisterNativeCap?.(capName);
116561
+ }
116562
+ };
116563
+ }
116564
+ /**
116565
+ * Whether an engine may stop sweeping: only once a pass found no old row left.
116566
+ * `none` is not done — a registry that has not answered the integration yet
116567
+ * reads as null too, and the sweep is one indexed read per pass.
116568
+ */
116569
+ function legacySweepDone(sweep) {
116570
+ return sweep.kind === "swept" && sweep.drained;
116571
+ }
116572
+ /**
116573
+ * The legacy rows, one bounded batch at a time: only the rows under the old
116574
+ * integration, ordered by id, at most `DECLARED_DEVICE_SWEEP_LIMIT` — a large
116575
+ * leftover set drains over passes instead of being refused whole by the
116576
+ * sweep's own bound.
116577
+ */
116578
+ function legacyEngineRowsIndex(rows, integrationId) {
116579
+ return rows.filter((row) => row.integrationId === integrationId).toSorted((left, right) => left.id - right.id).slice(0, 32);
116580
+ }
116581
+ /**
116582
+ * Remove every camera row an engine declared itself before its cameras were
116583
+ * blocks, unconditionally, through the declared sweep (`removeDevice` →
116584
+ * tombstone, D865). No integration means nothing was ever declared, and
116585
+ * nothing is minted to find out. A failed read throws: the caller retries.
116586
+ */
116587
+ async function sweepLegacyEngineRows(ports, integrationName) {
116588
+ const integration = await ports.getIntegration(ports.addonId);
116589
+ if (integration === null) return { kind: "none" };
116590
+ let found = 0;
116591
+ return {
116592
+ kind: "swept",
116593
+ removed: (await new DeclaredDevices({
116594
+ logger: ports.logger,
116595
+ addonId: ports.addonId,
116596
+ devices: ports.devices,
116597
+ localNodeId: ports.localNodeId,
116598
+ getIntegration: async () => integration,
116599
+ createIntegration: async () => {
116600
+ throw new Error(`${ports.addonId}: the legacy sweep never mints an integration`);
116601
+ },
116602
+ updateIntegration: async () => void 0,
116603
+ listOwnDevices: async () => {
116604
+ const index = legacyEngineRowsIndex(await ports.listAddonRows(ports.addonId), integration.id);
116605
+ found = index.length;
116606
+ return index;
116607
+ }
116608
+ }).reconcile({
116609
+ integrationName,
116610
+ integrationId: integration.id,
116611
+ placement: "hub",
116612
+ devices: []
116613
+ })).removed,
116614
+ drained: found === 0
116615
+ };
116616
+ }
114634
116617
  /**
114635
116618
  * One composed field, evaluated from what its sources say NOW (D659).
114636
116619
  *
@@ -115234,11 +117217,65 @@ var DEVICE_LOCAL_STATE_CAPS = {
115234
117217
  waterHeater: waterHeaterCapability,
115235
117218
  weather: weatherCapability,
115236
117219
  weatherStation: weatherStationCapability,
117220
+ workload: workloadCapability,
115237
117221
  zoneAnalytics: zoneAnalyticsCapability,
115238
117222
  zoneRules: zoneRulesCapability,
115239
117223
  zones: zonesCapability
115240
117224
  };
115241
117225
  /**
117226
+ * Normalise `raw` and declare it: every kind it carries replaces the stored one,
117227
+ * every kind it lacks is removed, except the kinds in `options.unread` (a failed
117228
+ * read keeps what was stored) — pass everything the provider read in one call.
117229
+ */
117230
+ async function declareDeviceIdentifiers(deps, raw, options = {}) {
117231
+ const { deviceId, logger, writer } = deps;
117232
+ const { unread, ...normaliseOptions } = options;
117233
+ const { identifiers, rejected } = normaliseIdentifiers(raw, normaliseOptions);
117234
+ for (const r of rejected) logger.warn("identifier refused — not declared", {
117235
+ tags: { deviceId },
117236
+ meta: {
117237
+ key: r.key,
117238
+ value: r.value,
117239
+ reason: r.reason
117240
+ }
117241
+ });
117242
+ const unreadKinds = new Set(unread ?? []);
117243
+ if (isEmptyIdentifiers(identifiers) && DEVICE_IDENTIFIER_KEYS.every((key) => unreadKinds.has(key))) {
117244
+ logger.debug("no identifier read — nothing declared", { tags: { deviceId } });
117245
+ return {
117246
+ outcome: "nothing-to-declare",
117247
+ identifiers
117248
+ };
117249
+ }
117250
+ if (writer === void 0) {
117251
+ logger.warn("identifiers not declared — device-manager unreachable", { tags: { deviceId } });
117252
+ return {
117253
+ outcome: "unavailable",
117254
+ identifiers
117255
+ };
117256
+ }
117257
+ try {
117258
+ await writer.mutate({
117259
+ deviceId,
117260
+ identifiers,
117261
+ ...unread !== void 0 && unread.length > 0 ? { unread } : {}
117262
+ });
117263
+ return {
117264
+ outcome: "declared",
117265
+ identifiers
117266
+ };
117267
+ } catch (err) {
117268
+ logger.warn("identifiers not declared — setIdentifiers failed", {
117269
+ tags: { deviceId },
117270
+ meta: { error: errMsg(err) }
117271
+ });
117272
+ return {
117273
+ outcome: "failed",
117274
+ identifiers
117275
+ };
117276
+ }
117277
+ }
117278
+ /**
115242
117279
  * The edge between two readings, or `null` for no edge.
115243
117280
  *
115244
117281
  * - `null`/cold → `true` is a START (a fault already open at boot is one);
@@ -115290,6 +117327,8 @@ var BaseDevice = class {
115290
117327
  id;
115291
117328
  stableId;
115292
117329
  type;
117330
+ /** True when another process owns the base slices (`options.deviceStatus: 'external'`). */
117331
+ statusIsExternal;
115293
117332
  name;
115294
117333
  parentDeviceId;
115295
117334
  role;
@@ -115438,21 +117477,26 @@ var BaseDevice = class {
115438
117477
  };
115439
117478
  this.runtimeState = DeviceRuntimeState.fromInitial(initial, writer, onWriteFailed);
115440
117479
  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
- });
117480
+ this.statusIsExternal = options.deviceStatus === "external";
117481
+ if (!this.statusIsExternal) ctx.registerNativeCap?.(deviceStatusCapability, {});
117482
+ if (!this.statusIsExternal) {
117483
+ const seed = {
117484
+ online: true,
117485
+ lastChangedAt: Date.now()
117486
+ };
117487
+ this.runtimeState.setCapState("device-status", seed);
117488
+ }
117489
+ if (!this.statusIsExternal) {
117490
+ ctx.registerNativeCap?.(featureProbeCapability, {});
117491
+ this.runtimeState.setCapState("feature-probe", {
117492
+ flags: {},
117493
+ deviceType: null,
117494
+ model: null,
117495
+ channelCount: null,
117496
+ lastProbedAt: 0,
117497
+ lastFetchedAt: 0
117498
+ });
117499
+ }
115456
117500
  }
115457
117501
  deviceActions = /* @__PURE__ */ new Map();
115458
117502
  /** Declare a device custom action + its typed handler. Idempotent per name. */
@@ -115480,7 +117524,7 @@ var BaseDevice = class {
115480
117524
  * override to gate side effects on the transition.
115481
117525
  */
115482
117526
  markOnline(online) {
115483
- if (this.online === online) return;
117527
+ if (this.statusIsExternal || this.online === online) return;
115484
117528
  const next = {
115485
117529
  online,
115486
117530
  lastChangedAt: Date.now()
@@ -115550,6 +117594,24 @@ var BaseDevice = class {
115550
117594
  }));
115551
117595
  }
115552
117596
  /**
117597
+ * Declare this device's identifiers (D1059): MAC(s), serial, vendor uid,
117598
+ * machine uuid, hostname, IP — what a later step matches across integrations.
117599
+ * Normalises `raw` (`normaliseIdentifiers`), logs every refused value, and
117600
+ * writes the result through `device-manager.setIdentifiers`, which accepts it
117601
+ * only from the provider that owns this device. Each kind it carries replaces
117602
+ * the stored one and each kind it lacks is removed — except the kinds listed in
117603
+ * `options.unread` (reads that FAILED), which keep their stored value. Pass
117604
+ * everything read in one call; a call where every kind is unread writes
117605
+ * nothing. Best-effort: never throws.
117606
+ */
117607
+ async declareIdentifiers(raw, options) {
117608
+ return declareDeviceIdentifiers({
117609
+ deviceId: this.id,
117610
+ logger: this.ctx.logger,
117611
+ writer: this.ctx.api.deviceManager?.setIdentifiers
117612
+ }, raw, options);
117613
+ }
117614
+ /**
115553
117615
  * Re-publish the device's current `features` array to the persisted
115554
117616
  * meta blob. Drivers call this after a probe finishes when the live
115555
117617
  * `features` getter has gained new flags (e.g. `hasIntercom` flips
@@ -115754,6 +117816,7 @@ var BaseDevice = class {
115754
117816
  * `lastProbedAt`) once their probe actually succeeds.
115755
117817
  */
115756
117818
  async onProbe() {
117819
+ if (this.statusIsExternal) return;
115757
117820
  const base = this.runtimeState.getCapState("feature-probe") ?? {
115758
117821
  flags: {},
115759
117822
  deviceType: null,
@@ -116170,289 +118233,7 @@ function legacyAutoLinkIds(params) {
116170
118233
  ids.delete(selfId);
116171
118234
  return [...ids];
116172
118235
  }
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;
118236
+ 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
118237
  new Set(Object.values(DeviceType));
116457
118238
  /** True when a value is a navigable node: a plain object OR a tRPC v11 client
116458
118239
  * proxy node (a callable `Proxy(noop)` → `typeof === 'function'`, NOT an
@@ -118714,10 +120495,12 @@ function durationText(seconds) {
118714
120495
  const text = `${Math.floor(m / 60)} h ${String(m % 60).padStart(2, "0")}`;
118715
120496
  return t(text, text);
118716
120497
  }
118717
- var switchContribution = contribution("switch", SwitchStatusSchema, (slice) => {
120498
+ var switchContribution = contribution("switch", SwitchStatusSchema, (slice, ctx) => {
118718
120499
  const on = slice?.on ?? null;
120500
+ const state = reading("switch", on === null ? "unknown" : on ? "on" : "off");
120501
+ if (ctx.switchOptions?.supportsSetState === false) return { reading: state };
118719
120502
  return {
118720
- reading: reading("switch", on === null ? "unknown" : on ? "on" : "off"),
120503
+ reading: state,
118721
120504
  ownPower: {
118722
120505
  source: "switch",
118723
120506
  on,
@@ -118927,14 +120710,17 @@ var timedRunContribution = contribution("timed-run", TimedRunStatusSchema, (slic
118927
120710
  tiles: armed
118928
120711
  };
118929
120712
  });
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
- } }));
120713
+ var powerSourceContribution = contribution("power-source", PowerSourceStateSchema, (slice, ctx) => {
120714
+ const settable = ctx.powerSupplySettable !== false;
120715
+ return { powerSupply: {
120716
+ on: slice?.switchOn ?? null,
120717
+ confirmOffWhileRunning: ctx.running === true,
120718
+ running: ctx.running ?? null,
120719
+ powerOn: settable ? action("power-supply.on", t("Power on", "Alimenta"), "plug", "power-source", "powerOn") : null,
120720
+ powerOff: settable ? action("power-supply.off", t("Power off", "Togli alimentazione"), "plug-zap", "power-source", "powerOff", {}, "normal", "off-while-running") : null,
120721
+ restart: action("power-supply.restart", t("Restart", "Riavvia"), "rotate-cw", "power-source", "forceRestart")
120722
+ } };
120723
+ });
118938
120724
  /** The remote cap has no status: the model's input carries how many commands it holds. */
118939
120725
  var remoteContribution = {
118940
120726
  cap: "remote",
@@ -119351,6 +121137,7 @@ var HERO_LAYOUT_BY_TYPE = {
119351
121137
  [DeviceType.WaterHeater]: CLIMATE_LAYOUT,
119352
121138
  [DeviceType.HeatPump]: HEAT_PUMP_LAYOUT,
119353
121139
  [DeviceType.EnergySystem]: HERO_LAYOUT_DEFAULT,
121140
+ [DeviceType.Workload]: HERO_LAYOUT_DEFAULT,
119354
121141
  [DeviceType.Fan]: FAN_LAYOUT,
119355
121142
  [DeviceType.MediaPlayer]: MEDIA_PLAYER_LAYOUT,
119356
121143
  [DeviceType.AlarmPanel]: ALARM_LAYOUT,
@@ -120075,6 +121862,7 @@ var HERO_LOOK_BY_TYPE = {
120075
121862
  [DeviceType.WaterHeater]: WATER_HEATER_LOOK,
120076
121863
  [DeviceType.HeatPump]: HEAT_PUMP_LOOK,
120077
121864
  [DeviceType.EnergySystem]: HERO_LOOK_DEFAULT,
121865
+ [DeviceType.Workload]: HERO_LOOK_DEFAULT,
120078
121866
  [DeviceType.Fan]: FAN_LOOK,
120079
121867
  [DeviceType.MediaPlayer]: MEDIA_PLAYER_LOOK,
120080
121868
  [DeviceType.AlarmPanel]: ALARM_LOOK,
@@ -120117,6 +121905,7 @@ var HERO_LOOK_BY_ROLE = {
120117
121905
  [DeviceRole.SwitchHeater]: HEATER_LOOK,
120118
121906
  [DeviceRole.SwitchFan]: FAN_LOOK,
120119
121907
  [DeviceRole.SwitchLight]: LIGHT_LOOK,
121908
+ [DeviceRole.PoePort]: "inherit",
120120
121909
  [DeviceRole.ClimateAc]: "inherit",
120121
121910
  [DeviceRole.ClimateThermostat]: "inherit",
120122
121911
  [DeviceRole.ClimateFloor]: "inherit",
@@ -120161,7 +121950,12 @@ var HERO_LOOK_BY_ROLE = {
120161
121950
  [DeviceRole.MessagingNotifier]: "inherit",
120162
121951
  [DeviceRole.EmailNotifier]: "inherit",
120163
121952
  [DeviceRole.GenericNotifier]: "inherit",
120164
- [DeviceRole.IrTransmitter]: "inherit"
121953
+ [DeviceRole.IrTransmitter]: "inherit",
121954
+ [DeviceRole.Vm]: "inherit",
121955
+ [DeviceRole.AppContainer]: "inherit",
121956
+ [DeviceRole.Lxc]: "inherit",
121957
+ [DeviceRole.App]: "inherit",
121958
+ [DeviceRole.Host]: "inherit"
120165
121959
  };
120166
121960
  function isDeviceType$1(type) {
120167
121961
  return Object.values(DeviceType).includes(type);
@@ -120196,16 +121990,6 @@ function resolveOwnPower(offers) {
120196
121990
  }
120197
121991
  return null;
120198
121992
  }
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
121993
  /** The first source with a known answer wins. */
120210
121994
  var STATE_SOURCE_ORDER = [
120211
121995
  "media-player",
@@ -120371,7 +122155,9 @@ function buildHeroModel(input) {
120371
122155
  running: runningOf(input),
120372
122156
  remoteCommands: input.remoteCommands,
120373
122157
  caps: input.caps,
120374
- quantity: device.quantity ?? null
122158
+ quantity: device.quantity ?? null,
122159
+ ...input.switchOptions !== void 0 ? { switchOptions: input.switchOptions } : {},
122160
+ ...input.powerSupplySettable !== void 0 ? { powerSupplySettable: input.powerSupplySettable } : {}
120375
122161
  };
120376
122162
  const contributed = HERO_CAP_CONTRIBUTIONS.filter((c) => input.caps.includes(c.cap)).map((c) => ({
120377
122163
  cap: c.cap,
@@ -123120,6 +124906,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
123120
124906
  access: "create",
123121
124907
  role: "admin"
123122
124908
  },
124909
+ "deviceManager.setIdentifiers": {
124910
+ capName: "device-manager",
124911
+ capScope: "system",
124912
+ addonId: null,
124913
+ access: "create",
124914
+ role: "admin"
124915
+ },
123123
124916
  "deviceManager.setIntegrationId": {
123124
124917
  capName: "device-manager",
123125
124918
  capScope: "system",
@@ -129042,6 +130835,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
129042
130835
  access: "view",
129043
130836
  role: "viewer"
129044
130837
  },
130838
+ "siren.getPlayChoices": {
130839
+ capName: "siren",
130840
+ capScope: "device",
130841
+ addonId: null,
130842
+ access: "view",
130843
+ role: "viewer"
130844
+ },
129045
130845
  "siren.getStatus": {
129046
130846
  capName: "siren",
129047
130847
  capScope: "device",
@@ -129854,6 +131654,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
129854
131654
  access: "view",
129855
131655
  role: "viewer"
129856
131656
  },
131657
+ "switch.getOptions": {
131658
+ capName: "switch",
131659
+ capScope: "device",
131660
+ addonId: null,
131661
+ access: "view",
131662
+ role: "viewer"
131663
+ },
129857
131664
  "switch.getStatus": {
129858
131665
  capName: "switch",
129859
131666
  capScope: "device",
@@ -129861,6 +131668,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
129861
131668
  access: "view",
129862
131669
  role: "viewer"
129863
131670
  },
131671
+ "switch.powerCycle": {
131672
+ capName: "switch",
131673
+ capScope: "device",
131674
+ addonId: null,
131675
+ access: "create",
131676
+ role: "viewer"
131677
+ },
129864
131678
  "switch.setState": {
129865
131679
  capName: "switch",
129866
131680
  capScope: "device",
@@ -130064,13 +131878,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
130064
131878
  access: "create",
130065
131879
  role: "admin"
130066
131880
  },
130067
- "terminalSession.adoptLegacyMonitor": {
130068
- capName: "terminal-session",
130069
- capScope: "system",
130070
- addonId: null,
130071
- access: "create",
130072
- role: "admin"
130073
- },
130074
131881
  "terminalSession.close": {
130075
131882
  capName: "terminal-session",
130076
131883
  capScope: "system",
@@ -130078,13 +131885,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
130078
131885
  access: "create",
130079
131886
  role: "admin"
130080
131887
  },
130081
- "terminalSession.listLegacyCameras": {
130082
- capName: "terminal-session",
130083
- capScope: "system",
130084
- addonId: null,
130085
- access: "view",
130086
- role: "admin"
130087
- },
130088
131888
  "terminalSession.listProfiles": {
130089
131889
  capName: "terminal-session",
130090
131890
  capScope: "system",
@@ -130946,6 +132746,62 @@ var METHOD_ACCESS_MAP = Object.freeze({
130946
132746
  access: "view",
130947
132747
  role: "viewer"
130948
132748
  },
132749
+ "workload.forceStop": {
132750
+ capName: "workload",
132751
+ capScope: "device",
132752
+ addonId: null,
132753
+ access: "create",
132754
+ role: "admin"
132755
+ },
132756
+ "workload.getOptions": {
132757
+ capName: "workload",
132758
+ capScope: "device",
132759
+ addonId: null,
132760
+ access: "view",
132761
+ role: "viewer"
132762
+ },
132763
+ "workload.getStatus": {
132764
+ capName: "workload",
132765
+ capScope: "device",
132766
+ addonId: null,
132767
+ access: "view",
132768
+ role: "viewer"
132769
+ },
132770
+ "workload.pause": {
132771
+ capName: "workload",
132772
+ capScope: "device",
132773
+ addonId: null,
132774
+ access: "create",
132775
+ role: "viewer"
132776
+ },
132777
+ "workload.restart": {
132778
+ capName: "workload",
132779
+ capScope: "device",
132780
+ addonId: null,
132781
+ access: "create",
132782
+ role: "viewer"
132783
+ },
132784
+ "workload.resume": {
132785
+ capName: "workload",
132786
+ capScope: "device",
132787
+ addonId: null,
132788
+ access: "create",
132789
+ role: "viewer"
132790
+ },
132791
+ "workload.start": {
132792
+ capName: "workload",
132793
+ capScope: "device",
132794
+ addonId: null,
132795
+ access: "create",
132796
+ role: "viewer"
132797
+ },
132798
+ "workload.stop": {
132799
+ capName: "workload",
132800
+ capScope: "device",
132801
+ addonId: null,
132802
+ access: "create",
132803
+ role: "viewer"
132804
+ },
130949
132805
  "zoneAnalytics.getCameraHistory": {
130950
132806
  capName: "zone-analytics",
130951
132807
  capScope: "device",
@@ -131072,7 +132928,8 @@ function resolveAction(cap, action, wordings) {
131072
132928
  icon: w.icon ?? action.icon,
131073
132929
  args: action.args ?? {},
131074
132930
  openArgs: action.openArgs ?? [],
131075
- access
132931
+ access,
132932
+ offeredWhen: action.offeredWhen ?? null
131076
132933
  };
131077
132934
  }
131078
132935
  /**
@@ -131315,8 +133172,8 @@ function offered(received) {
131315
133172
  };
131316
133173
  }
131317
133174
  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;
133175
+ 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;
133176
+ 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
133177
  new Set(Object.values(DeviceType));
131321
133178
  new Set(Object.values(DeviceRole));
131322
133179
  /**
@@ -131411,7 +133268,8 @@ var CAP_NAMES_WITH_STATUS = [
131411
133268
  "vibration",
131412
133269
  "water-heater",
131413
133270
  "weather",
131414
- "weather-station"
133271
+ "weather-station",
133272
+ "workload"
131415
133273
  ];
131416
133274
  Object.freeze({
131417
133275
  "accessories.getStatus": [{
@@ -132112,6 +133970,11 @@ Object.freeze({
132112
133970
  form: "single",
132113
133971
  optional: false
132114
133972
  }],
133973
+ "deviceManager.setIdentifiers": [{
133974
+ name: "deviceId",
133975
+ form: "single",
133976
+ optional: false
133977
+ }],
132115
133978
  "deviceManager.setIntegrationId": [{
132116
133979
  name: "deviceId",
132117
133980
  form: "single",
@@ -134106,6 +135969,11 @@ Object.freeze({
134106
135969
  form: "single",
134107
135970
  optional: false
134108
135971
  }],
135972
+ "siren.getPlayChoices": [{
135973
+ name: "deviceId",
135974
+ form: "single",
135975
+ optional: false
135976
+ }],
134109
135977
  "siren.getStatus": [{
134110
135978
  name: "deviceId",
134111
135979
  form: "single",
@@ -134288,11 +136156,21 @@ Object.freeze({
134288
136156
  form: "single",
134289
136157
  optional: false
134290
136158
  }],
136159
+ "switch.getOptions": [{
136160
+ name: "deviceId",
136161
+ form: "single",
136162
+ optional: false
136163
+ }],
134291
136164
  "switch.getStatus": [{
134292
136165
  name: "deviceId",
134293
136166
  form: "single",
134294
136167
  optional: false
134295
136168
  }],
136169
+ "switch.powerCycle": [{
136170
+ name: "deviceId",
136171
+ form: "single",
136172
+ optional: false
136173
+ }],
134296
136174
  "switch.setState": [{
134297
136175
  name: "deviceId",
134298
136176
  form: "single",
@@ -134533,6 +136411,46 @@ Object.freeze({
134533
136411
  form: "single",
134534
136412
  optional: false
134535
136413
  }],
136414
+ "workload.forceStop": [{
136415
+ name: "deviceId",
136416
+ form: "single",
136417
+ optional: false
136418
+ }],
136419
+ "workload.getOptions": [{
136420
+ name: "deviceId",
136421
+ form: "single",
136422
+ optional: false
136423
+ }],
136424
+ "workload.getStatus": [{
136425
+ name: "deviceId",
136426
+ form: "single",
136427
+ optional: false
136428
+ }],
136429
+ "workload.pause": [{
136430
+ name: "deviceId",
136431
+ form: "single",
136432
+ optional: false
136433
+ }],
136434
+ "workload.restart": [{
136435
+ name: "deviceId",
136436
+ form: "single",
136437
+ optional: false
136438
+ }],
136439
+ "workload.resume": [{
136440
+ name: "deviceId",
136441
+ form: "single",
136442
+ optional: false
136443
+ }],
136444
+ "workload.start": [{
136445
+ name: "deviceId",
136446
+ form: "single",
136447
+ optional: false
136448
+ }],
136449
+ "workload.stop": [{
136450
+ name: "deviceId",
136451
+ form: "single",
136452
+ optional: false
136453
+ }],
134536
136454
  "zoneAnalytics.getCameraHistory": [{
134537
136455
  name: "deviceId",
134538
136456
  form: "single",
@@ -134601,7 +136519,7 @@ Object.freeze({
134601
136519
  });
134602
136520
  /**
134603
136521
  * Per-cap runtime-state policy, projected from every `*.cap.ts` that declares
134604
- * `runtimeState`. 86 caps: 43 `restored`, 43 `session`.
136522
+ * `runtimeState`. 87 caps: 43 `restored`, 44 `session`.
134605
136523
  *
134606
136524
  * A cap absent from this map has no runtime-state slice at all. A cap PRESENT
134607
136525
  * with `durability: 'session'` has one and has decided not to keep it.
@@ -134941,6 +136859,10 @@ var RUNTIME_STATE_POLICY = {
134941
136859
  durability: "session",
134942
136860
  volatileFields: ["lastFetchedAt"]
134943
136861
  },
136862
+ "workload": {
136863
+ durability: "session",
136864
+ volatileFields: ["lastFetchedAt"]
136865
+ },
134944
136866
  "zone-analytics": {
134945
136867
  durability: "session",
134946
136868
  volatileFields: []
@@ -137408,6 +139330,12 @@ Object.defineProperty(exports, "DeviceFeature", {
137408
139330
  return DeviceFeature;
137409
139331
  }
137410
139332
  });
139333
+ Object.defineProperty(exports, "DeviceIdentifiersSchema", {
139334
+ enumerable: true,
139335
+ get: function() {
139336
+ return DeviceIdentifiersSchema;
139337
+ }
139338
+ });
137411
139339
  Object.defineProperty(exports, "DeviceRole", {
137412
139340
  enumerable: true,
137413
139341
  get: function() {
@@ -137606,6 +139534,12 @@ Object.defineProperty(exports, "HelperMemberSchema", {
137606
139534
  return HelperMemberSchema;
137607
139535
  }
137608
139536
  });
139537
+ Object.defineProperty(exports, "HostedWithdrawalGate", {
139538
+ enumerable: true,
139539
+ get: function() {
139540
+ return HostedWithdrawalGate;
139541
+ }
139542
+ });
137609
139543
  Object.defineProperty(exports, "HvacModeSchema", {
137610
139544
  enumerable: true,
137611
139545
  get: function() {
@@ -137948,6 +139882,12 @@ Object.defineProperty(exports, "STREAM_PROFILE_META", {
137948
139882
  return STREAM_PROFILE_META;
137949
139883
  }
137950
139884
  });
139885
+ Object.defineProperty(exports, "SWITCH_DEFAULT_OPTIONS", {
139886
+ enumerable: true,
139887
+ get: function() {
139888
+ return SWITCH_DEFAULT_OPTIONS;
139889
+ }
139890
+ });
137951
139891
  Object.defineProperty(exports, "SchedulerError", {
137952
139892
  enumerable: true,
137953
139893
  get: function() {
@@ -138086,6 +140026,18 @@ Object.defineProperty(exports, "WELL_KNOWN_TAB_MAP", {
138086
140026
  return WELL_KNOWN_TAB_MAP;
138087
140027
  }
138088
140028
  });
140029
+ Object.defineProperty(exports, "WORKLOAD_TRANSITION_CATEGORY", {
140030
+ enumerable: true,
140031
+ get: function() {
140032
+ return WORKLOAD_TRANSITION_CATEGORY;
140033
+ }
140034
+ });
140035
+ Object.defineProperty(exports, "WorkloadStateSchema", {
140036
+ enumerable: true,
140037
+ get: function() {
140038
+ return WorkloadStateSchema;
140039
+ }
140040
+ });
138089
140041
  Object.defineProperty(exports, "actionEffect", {
138090
140042
  enumerable: true,
138091
140043
  get: function() {
@@ -138434,6 +140386,12 @@ Object.defineProperty(exports, "compareVersions", {
138434
140386
  return compareVersions;
138435
140387
  }
138436
140388
  });
140389
+ Object.defineProperty(exports, "compileHelper", {
140390
+ enumerable: true,
140391
+ get: function() {
140392
+ return compileHelper;
140393
+ }
140394
+ });
138437
140395
  Object.defineProperty(exports, "compileScalarOverride", {
138438
140396
  enumerable: true,
138439
140397
  get: function() {
@@ -138974,6 +140932,12 @@ Object.defineProperty(exports, "historyUnitFor", {
138974
140932
  return historyUnitFor;
138975
140933
  }
138976
140934
  });
140935
+ Object.defineProperty(exports, "hostEngineDevice", {
140936
+ enumerable: true,
140937
+ get: function() {
140938
+ return hostEngineDevice;
140939
+ }
140940
+ });
138977
140941
  Object.defineProperty(exports, "hydrateSchema", {
138978
140942
  enumerable: true,
138979
140943
  get: function() {
@@ -139088,6 +141052,18 @@ Object.defineProperty(exports, "isDeviceConfigCap", {
139088
141052
  return isDeviceConfigCap;
139089
141053
  }
139090
141054
  });
141055
+ Object.defineProperty(exports, "isEmptyIdentifiers", {
141056
+ enumerable: true,
141057
+ get: function() {
141058
+ return isEmptyIdentifiers;
141059
+ }
141060
+ });
141061
+ Object.defineProperty(exports, "isEngineHostedHelper", {
141062
+ enumerable: true,
141063
+ get: function() {
141064
+ return isEngineHostedHelper;
141065
+ }
141066
+ });
139091
141067
  Object.defineProperty(exports, "isEvent", {
139092
141068
  enumerable: true,
139093
141069
  get: function() {
@@ -139190,6 +141166,12 @@ Object.defineProperty(exports, "isVoidInput", {
139190
141166
  return isVoidInput;
139191
141167
  }
139192
141168
  });
141169
+ Object.defineProperty(exports, "isWorkloadSettled", {
141170
+ enumerable: true,
141171
+ get: function() {
141172
+ return isWorkloadSettled;
141173
+ }
141174
+ });
139193
141175
  Object.defineProperty(exports, "kebabToCamel", {
139194
141176
  enumerable: true,
139195
141177
  get: function() {
@@ -139220,6 +141202,12 @@ Object.defineProperty(exports, "legacyModeOf", {
139220
141202
  return legacyModeOf;
139221
141203
  }
139222
141204
  });
141205
+ Object.defineProperty(exports, "legacySweepDone", {
141206
+ enumerable: true,
141207
+ get: function() {
141208
+ return legacySweepDone;
141209
+ }
141210
+ });
139223
141211
  Object.defineProperty(exports, "lifecycleJobSchema", {
139224
141212
  enumerable: true,
139225
141213
  get: function() {
@@ -139316,6 +141304,12 @@ Object.defineProperty(exports, "memoizePinnedFfmpeg", {
139316
141304
  return memoizePinnedFfmpeg;
139317
141305
  }
139318
141306
  });
141307
+ Object.defineProperty(exports, "mergeIdentifiers", {
141308
+ enumerable: true,
141309
+ get: function() {
141310
+ return mergeIdentifiers;
141311
+ }
141312
+ });
139319
141313
  Object.defineProperty(exports, "methodRefusal", {
139320
141314
  enumerable: true,
139321
141315
  get: function() {
@@ -139826,6 +141820,12 @@ Object.defineProperty(exports, "runtimeStatePolicyFor", {
139826
141820
  return runtimeStatePolicyFor;
139827
141821
  }
139828
141822
  });
141823
+ Object.defineProperty(exports, "sameIdentifiers", {
141824
+ enumerable: true,
141825
+ get: function() {
141826
+ return sameIdentifiers;
141827
+ }
141828
+ });
139829
141829
  Object.defineProperty(exports, "schedulersCapability", {
139830
141830
  enumerable: true,
139831
141831
  get: function() {
@@ -139886,6 +141886,12 @@ Object.defineProperty(exports, "seedInstanceOnce", {
139886
141886
  return seedInstanceOnce;
139887
141887
  }
139888
141888
  });
141889
+ Object.defineProperty(exports, "selectEngineHostedBlocks", {
141890
+ enumerable: true,
141891
+ get: function() {
141892
+ return selectEngineHostedBlocks;
141893
+ }
141894
+ });
139889
141895
  Object.defineProperty(exports, "settingsStoreCapability", {
139890
141896
  enumerable: true,
139891
141897
  get: function() {
@@ -140012,6 +142018,12 @@ Object.defineProperty(exports, "supportedRuntimes", {
140012
142018
  return supportedRuntimes;
140013
142019
  }
140014
142020
  });
142021
+ Object.defineProperty(exports, "sweepLegacyEngineRows", {
142022
+ enumerable: true,
142023
+ get: function() {
142024
+ return sweepLegacyEngineRows;
142025
+ }
142026
+ });
140015
142027
  Object.defineProperty(exports, "switchCapability", {
140016
142028
  enumerable: true,
140017
142029
  get: function() {
@@ -140204,6 +142216,18 @@ Object.defineProperty(exports, "withoutCallerStamp", {
140204
142216
  return withoutCallerStamp;
140205
142217
  }
140206
142218
  });
142219
+ Object.defineProperty(exports, "workloadCapability", {
142220
+ enumerable: true,
142221
+ get: function() {
142222
+ return workloadCapability;
142223
+ }
142224
+ });
142225
+ Object.defineProperty(exports, "workloadTransition", {
142226
+ enumerable: true,
142227
+ get: function() {
142228
+ return workloadTransition;
142229
+ }
142230
+ });
140207
142231
  Object.defineProperty(exports, "zoneOnlySite", {
140208
142232
  enumerable: true,
140209
142233
  get: function() {