@camstack/server 1.2.941 → 1.2.942

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 (154) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/api/trpc/generated-cap-mounts.js +19 -1
  3. package/dist/api/trpc/generated-cap-routers.js +676 -596
  4. package/package.json +27 -11
  5. package/system/dist/action-index-B1fgpQBt.mjs +9925 -0
  6. package/system/dist/action-index-B_cLRwXJ.js +9972 -0
  7. package/system/dist/alert-episode-Be--PngO.mjs +64 -0
  8. package/system/dist/alert-episode-Bqktmt-i.js +93 -0
  9. package/system/dist/{base-addon-Md14i7pe.mjs → base-addon-BcS6r1cT.mjs} +20 -7
  10. package/system/dist/{base-addon-DD5dIfcZ.js → base-addon-CRsXtYFG.js} +20 -7
  11. package/system/dist/{base-device-CH8rfD9j.js → base-device-DAdWzDOl.js} +138 -34
  12. package/system/dist/{base-device-BcGO6LTT.mjs → base-device-DJXF5eDN.mjs} +138 -34
  13. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  14. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  15. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  16. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  17. package/system/dist/builtins/alerts/alert-episode-policy.d.ts +9 -5
  18. package/system/dist/builtins/alerts/alerts.addon.js +30 -80
  19. package/system/dist/builtins/alerts/alerts.addon.mjs +18 -68
  20. package/system/dist/builtins/autotrack/index.js +2 -2
  21. package/system/dist/builtins/autotrack/index.mjs +2 -2
  22. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  23. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  24. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  25. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  26. package/system/dist/builtins/camera-grid/index.js +9 -9
  27. package/system/dist/builtins/camera-grid/index.mjs +6 -6
  28. package/system/dist/builtins/composer/composer.addon.js +99 -99
  29. package/system/dist/builtins/composer/composer.addon.mjs +11 -11
  30. package/system/dist/builtins/console-logging/index.js +1 -1
  31. package/system/dist/builtins/console-logging/index.mjs +1 -1
  32. package/system/dist/builtins/core-blocks/automation-template-instances.d.ts +14 -1
  33. package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +6 -0
  34. package/system/dist/builtins/core-blocks/core-blocks.addon.js +296 -193
  35. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +237 -134
  36. package/system/dist/builtins/core-blocks/link-contributions.d.ts +2 -0
  37. package/system/dist/builtins/core-notifier/core-notifier.addon.js +91 -18
  38. package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +91 -18
  39. package/system/dist/builtins/core-notifier/group-notification-output.d.ts +8 -16
  40. package/system/dist/builtins/device-history/device-history.addon.d.ts +8 -0
  41. package/system/dist/builtins/device-history/device-history.addon.js +580 -60
  42. package/system/dist/builtins/device-history/device-history.addon.mjs +569 -49
  43. package/system/dist/builtins/device-history/retention/device-raw-overrides.d.ts +16 -0
  44. package/system/dist/builtins/device-history/retention/retention-knobs.d.ts +14 -0
  45. package/system/dist/builtins/device-history/retention/retention.d.ts +21 -1
  46. package/system/dist/builtins/device-history/transitions/change-coalescing.d.ts +48 -0
  47. package/system/dist/builtins/device-history/transitions/derived-changes.d.ts +49 -0
  48. package/system/dist/builtins/device-history/transitions/history-change-port.d.ts +20 -0
  49. package/system/dist/builtins/device-history/transitions/transitions-service.d.ts +18 -3
  50. package/system/dist/builtins/device-manager/device-identity-index.d.ts +2 -2
  51. package/system/dist/builtins/device-manager/device-manager.addon.js +177 -479
  52. package/system/dist/builtins/device-manager/device-manager.addon.mjs +169 -471
  53. package/system/dist/builtins/device-manager/device-state-mirror.d.ts +0 -5
  54. package/system/dist/builtins/device-manager/identity-link-reconciler.d.ts +5 -0
  55. package/system/dist/builtins/device-manager/transitions/command-recorder.d.ts +38 -0
  56. package/system/dist/builtins/device-manager/transitions/transitions-wiring.d.ts +8 -9
  57. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  58. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  59. package/system/dist/builtins/keychain/index.js +2 -2
  60. package/system/dist/builtins/keychain/index.mjs +2 -2
  61. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +2 -2
  62. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +2 -2
  63. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  64. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  65. package/system/dist/builtins/local-network/address-book.d.ts +3 -1
  66. package/system/dist/builtins/local-network/local-network.addon.d.ts +26 -1
  67. package/system/dist/builtins/local-network/local-network.addon.js +66 -11
  68. package/system/dist/builtins/local-network/local-network.addon.mjs +66 -11
  69. package/system/dist/builtins/loki-logging/index.js +1 -1
  70. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  71. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  72. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  73. package/system/dist/builtins/platform-probe/index.js +1 -1
  74. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  75. package/system/dist/builtins/record-entries/index.js +1 -1
  76. package/system/dist/builtins/record-entries/index.mjs +1 -1
  77. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  78. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  79. package/system/dist/builtins/snapshot/index.js +4 -4
  80. package/system/dist/builtins/snapshot/index.mjs +4 -4
  81. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  82. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  83. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  84. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  85. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  86. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  87. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  88. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  89. package/system/dist/builtins/system-config/system-config.addon.js +1 -1
  90. package/system/dist/builtins/system-config/system-config.addon.mjs +1 -1
  91. package/system/dist/builtins/winston-logging/index.js +1 -1
  92. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  93. package/system/dist/{capture-engine-CUZ3W0oZ.mjs → capture-engine-B2MmoNND.mjs} +1 -1
  94. package/system/dist/{capture-engine-mtDXEBAq.js → capture-engine-D_1IJmMs.js} +1 -1
  95. package/system/dist/command-catalog-C29hVOOg.js +210 -0
  96. package/system/dist/command-catalog-xAeqxbZk.mjs +169 -0
  97. package/system/dist/{error.cap-DCwbIGEF.mjs → compile-OBMHlqD-.mjs} +97 -100
  98. package/system/dist/{error.cap-BxLEHP6z.js → compile-SpeAhaZ6.js} +107 -116
  99. package/system/dist/{composition-sources-B56CU8hi.mjs → composition-sources-C327LGFn.mjs} +2 -2
  100. package/system/dist/{composition-sources-D_Bfwji0.js → composition-sources-Do5qM6EB.js} +17 -17
  101. package/system/dist/{core-blocks.cap-xt5_fK5Z.js → core-blocks.cap-CdTGUKtr.js} +194 -10110
  102. package/system/dist/{core-blocks.cap-DDECcMeI.mjs → core-blocks.cap-DLkEfV5b.mjs} +54 -9910
  103. package/system/dist/{device-kind-BJ2pfsjw.mjs → device-kind-C37Ra2wd.mjs} +4 -2
  104. package/system/dist/{device-kind-CsSiv_YF.js → device-kind-FMhJg8uC.js} +4 -2
  105. package/system/dist/{device-manager.cap-DyHOIh5T.js → device-manager.cap-DJs8izI6.js} +13 -4
  106. package/system/dist/{device-manager.cap-DIBK62-r.mjs → device-manager.cap-eYrj1Ezp.mjs} +13 -4
  107. package/system/dist/{device-provider.cap-BKUGJSo0.js → device-provider.cap-CNlYBQ5D.js} +1 -1
  108. package/system/dist/{device-provider.cap-DU6HMUXH.mjs → device-provider.cap-D8mJllVM.mjs} +1 -1
  109. package/system/dist/{device-row-store-O4mNbp5q.js → device-row-store-C0P2H18h.js} +2 -2
  110. package/system/dist/{device-row-store-C-_R-h1Z.mjs → device-row-store-CTocYKqC.mjs} +2 -2
  111. package/system/dist/{device-type-CbQsnFdC.js → device-type-Cnc0NiSX.js} +13 -0
  112. package/system/dist/{device-type-DgEvK3ch.mjs → device-type-TUGqGmaI.mjs} +13 -0
  113. package/system/dist/error.cap-BuKbL3Ac.js +125 -0
  114. package/system/dist/error.cap-CU1FB6uE.mjs +102 -0
  115. package/system/dist/file-host-worker.js +1 -1
  116. package/system/dist/file-host-worker.mjs +1 -1
  117. package/system/dist/{history-catalog-BwTeQ4Mr.mjs → history-catalog-A_dzXNpv.mjs} +98 -3
  118. package/system/dist/{history-catalog-BKRarIL_.js → history-catalog-CiTMP3-E.js} +98 -3
  119. package/system/dist/index.js +28 -6
  120. package/system/dist/index.mjs +28 -6
  121. package/system/dist/kernel/addon-version-policy.d.ts +10 -0
  122. package/system/dist/{legacy-integration-rows-door-B1nzxxr5.js → legacy-integration-rows-door-CdqYAj-o.js} +1 -1
  123. package/system/dist/{legacy-integration-rows-door-nTvo_6jQ.mjs → legacy-integration-rows-door-LSgpClpX.mjs} +1 -1
  124. package/system/dist/{low-power-sleep.cap-B6mz6ojP.js → low-power-sleep.cap-BJWyAuUQ.js} +1 -1
  125. package/system/dist/{low-power-sleep.cap-C3Vi8Vxj.mjs → low-power-sleep.cap-D9Orx3LS.mjs} +1 -1
  126. package/system/dist/migrations/hub/2026-11-22-device-transitions-commands-only.d.ts +10 -0
  127. package/system/dist/{network-access.cap-BEN_uRVb.js → network-access.cap-CTQ2WQoi.js} +38 -12
  128. package/system/dist/{network-access.cap-Dy8FNNVs.mjs → network-access.cap-Dx5K0I5i.mjs} +33 -13
  129. package/system/dist/{notification-rules.cap-Drwz-A4n.js → notification-rules.cap-BJKUjizS.js} +45 -9
  130. package/system/dist/{notification-rules.cap-0vVvsxQ1.mjs → notification-rules.cap-BUIuYPlQ.mjs} +45 -9
  131. package/system/dist/{notification-targets-DR-D-vIt.mjs → notification-targets-4bGYH5J7.mjs} +2 -2
  132. package/system/dist/{notification-targets-Cc_3OBH9.js → notification-targets-DMW7xgR2.js} +2 -2
  133. package/system/dist/{prefix-walk-CCO_VZVo.js → prefix-walk-BFnw8NBu.js} +5 -5
  134. package/system/dist/{prefix-walk-BhT0ZoKl.mjs → prefix-walk-Mtij0NNT.mjs} +2 -2
  135. package/system/dist/{ptz-autotrack.cap-DOz0xL0O.js → ptz-autotrack.cap-B9eyZU8w.js} +1 -1
  136. package/system/dist/{ptz-autotrack.cap-CDF6FeTK.mjs → ptz-autotrack.cap-Dw2k-po9.mjs} +1 -1
  137. package/system/dist/{recording-archive.cap-RHAN45fa.mjs → recording-archive.cap-CTlm86R8.mjs} +1 -1
  138. package/system/dist/{recording-archive.cap-BPJ7kvnd.js → recording-archive.cap-Wo-hEZhz.js} +1 -1
  139. package/system/dist/{rename-composition-block-DWUkrazx.mjs → rename-composition-block-Cdh-dRmY.mjs} +395 -20
  140. package/system/dist/{rename-composition-block-CH2vRIW7.js → rename-composition-block-D9Uc1AF7.js} +406 -31
  141. package/system/dist/{retention-CUOVI1p7.mjs → retention-CQs8QR1B.mjs} +33 -3
  142. package/system/dist/{device-transitions.cap-DCXP3zwY.mjs → retention-source.cap-550kkyp5.mjs} +98 -21
  143. package/system/dist/{device-transitions.cap-zOGvAIHz.js → retention-source.cap-C6Hy0hlM.js} +103 -20
  144. package/system/dist/{retention-BcOSL6b9.js → retention-xcjk_k1w.js} +33 -3
  145. package/system/dist/{snapshot.cap-Cis6JRwn.js → snapshot.cap-CHm29hBs.js} +1 -1
  146. package/system/dist/{snapshot.cap-BkfHpJVO.mjs → snapshot.cap-CO68YvJU.mjs} +1 -1
  147. package/system/dist/{stream-catalog.cap-D8Y-uXcy.js → stream-catalog.cap-CjEQFknc.js} +2 -2
  148. package/system/dist/{stream-catalog.cap-D1Hy19Yc.mjs → stream-catalog.cap-DVniDdRD.mjs} +2 -2
  149. package/system/dist/{user-management.cap-Ctd4c_im.mjs → user-management.cap-4IEUCSdL.mjs} +2 -2
  150. package/system/dist/{user-management.cap-DyVb68rY.js → user-management.cap-DV9Jfsj3.js} +2 -2
  151. package/system/dist/{wal-maintenance-CjpslZUL.mjs → wal-maintenance-Bey5ChBb.mjs} +0 -0
  152. package/system/dist/{wal-maintenance-DKTXQ7UF.js → wal-maintenance-BgYiAy5b.js} +0 -0
  153. package/system/package.json +4 -1
  154. package/system/dist/builtins/device-manager/transitions/transition-correlator.d.ts +0 -81
@@ -0,0 +1,64 @@
1
+ import { n as DeviceFaultSchema } from "./error.cap-CU1FB6uE.mjs";
2
+ import { z } from "zod";
3
+ //#region ../types/dist/esm/notification/alert-episode.mjs
4
+ /** An episode is closed once its alert is completed or dismissed. */
5
+ function isAlertEpisodeOpen(status) {
6
+ return status !== "completed" && status !== "dismissed";
7
+ }
8
+ /** The category of the alert a device's `error` cap opens for its fault. */
9
+ var DEVICE_ERROR_ALERT_CATEGORY = "device.error";
10
+ /**
11
+ * How loud an episode is, `0` when it is not announced at all. A device FAULT
12
+ * is announced at every tier, its warning included: who is told about a fault
13
+ * is the operator's choice (a rule's severity filter, a notifier's minimum
14
+ * priority), never the system's. Any other alert is announced from `error` up.
15
+ */
16
+ function alertEpisodeRank(alert) {
17
+ if (alert.severity === "critical") return 3;
18
+ if (alert.severity === "error") return 2;
19
+ return alert.severity === "warning" && alert.category === "device.error" ? 1 : 0;
20
+ }
21
+ function alertEpisodeId(alert) {
22
+ const minted = alert.metadata?.["episodeId"];
23
+ return typeof minted === "string" && minted.length > 0 ? minted : `${alert.id}@${String(alert.createdAt)}`;
24
+ }
25
+ /** The node an alert is about, from the places emitters put it. */
26
+ function alertNodeId(alert) {
27
+ const direct = alert.metadata?.["nodeId"];
28
+ if (typeof direct === "string") return direct;
29
+ const runner = alert.metadata?.["runner"];
30
+ if (typeof runner === "object" && runner !== null && "nodeId" in runner) {
31
+ const id = runner.nodeId;
32
+ if (typeof id === "string") return id;
33
+ }
34
+ return alert.source?.type === "node" ? alert.source.id : void 0;
35
+ }
36
+ /** The faults a device-error alert carries in its metadata; none when absent or malformed. */
37
+ function alertFaults(alert) {
38
+ const parsed = z.array(DeviceFaultSchema).safeParse(alert.metadata?.["faults"]);
39
+ return parsed.success && parsed.data.length > 0 ? parsed.data : void 0;
40
+ }
41
+ function alertEpisodePayload(alert, phase, at) {
42
+ const nodeId = alertNodeId(alert);
43
+ const faults = alertFaults(alert);
44
+ return {
45
+ phase,
46
+ episodeId: alertEpisodeId(alert),
47
+ alertId: alert.id,
48
+ severity: alert.severity,
49
+ category: alert.category,
50
+ title: alert.title,
51
+ message: alert.message,
52
+ ...alert.source !== void 0 ? {
53
+ sourceType: alert.source.type,
54
+ sourceId: alert.source.id
55
+ } : {},
56
+ ...nodeId !== void 0 ? { nodeId } : {},
57
+ ...alert.action?.href !== void 0 ? { actionUrl: alert.action.href } : {},
58
+ ...phase === "raised" && alert.action !== void 0 ? { action: alert.action } : {},
59
+ ...faults !== void 0 ? { faults } : {},
60
+ at
61
+ };
62
+ }
63
+ //#endregion
64
+ export { isAlertEpisodeOpen as a, alertEpisodeRank as i, alertEpisodeId as n, alertEpisodePayload as r, DEVICE_ERROR_ALERT_CATEGORY as t };
@@ -0,0 +1,93 @@
1
+ const require_error_cap = require("./error.cap-BuKbL3Ac.js");
2
+ let zod = require("zod");
3
+ //#region ../types/dist/esm/notification/alert-episode.mjs
4
+ /** An episode is closed once its alert is completed or dismissed. */
5
+ function isAlertEpisodeOpen(status) {
6
+ return status !== "completed" && status !== "dismissed";
7
+ }
8
+ /** The category of the alert a device's `error` cap opens for its fault. */
9
+ var DEVICE_ERROR_ALERT_CATEGORY = "device.error";
10
+ /**
11
+ * How loud an episode is, `0` when it is not announced at all. A device FAULT
12
+ * is announced at every tier, its warning included: who is told about a fault
13
+ * is the operator's choice (a rule's severity filter, a notifier's minimum
14
+ * priority), never the system's. Any other alert is announced from `error` up.
15
+ */
16
+ function alertEpisodeRank(alert) {
17
+ if (alert.severity === "critical") return 3;
18
+ if (alert.severity === "error") return 2;
19
+ return alert.severity === "warning" && alert.category === "device.error" ? 1 : 0;
20
+ }
21
+ function alertEpisodeId(alert) {
22
+ const minted = alert.metadata?.["episodeId"];
23
+ return typeof minted === "string" && minted.length > 0 ? minted : `${alert.id}@${String(alert.createdAt)}`;
24
+ }
25
+ /** The node an alert is about, from the places emitters put it. */
26
+ function alertNodeId(alert) {
27
+ const direct = alert.metadata?.["nodeId"];
28
+ if (typeof direct === "string") return direct;
29
+ const runner = alert.metadata?.["runner"];
30
+ if (typeof runner === "object" && runner !== null && "nodeId" in runner) {
31
+ const id = runner.nodeId;
32
+ if (typeof id === "string") return id;
33
+ }
34
+ return alert.source?.type === "node" ? alert.source.id : void 0;
35
+ }
36
+ /** The faults a device-error alert carries in its metadata; none when absent or malformed. */
37
+ function alertFaults(alert) {
38
+ const parsed = zod.z.array(require_error_cap.DeviceFaultSchema).safeParse(alert.metadata?.["faults"]);
39
+ return parsed.success && parsed.data.length > 0 ? parsed.data : void 0;
40
+ }
41
+ function alertEpisodePayload(alert, phase, at) {
42
+ const nodeId = alertNodeId(alert);
43
+ const faults = alertFaults(alert);
44
+ return {
45
+ phase,
46
+ episodeId: alertEpisodeId(alert),
47
+ alertId: alert.id,
48
+ severity: alert.severity,
49
+ category: alert.category,
50
+ title: alert.title,
51
+ message: alert.message,
52
+ ...alert.source !== void 0 ? {
53
+ sourceType: alert.source.type,
54
+ sourceId: alert.source.id
55
+ } : {},
56
+ ...nodeId !== void 0 ? { nodeId } : {},
57
+ ...alert.action?.href !== void 0 ? { actionUrl: alert.action.href } : {},
58
+ ...phase === "raised" && alert.action !== void 0 ? { action: alert.action } : {},
59
+ ...faults !== void 0 ? { faults } : {},
60
+ at
61
+ };
62
+ }
63
+ //#endregion
64
+ Object.defineProperty(exports, "DEVICE_ERROR_ALERT_CATEGORY", {
65
+ enumerable: true,
66
+ get: function() {
67
+ return DEVICE_ERROR_ALERT_CATEGORY;
68
+ }
69
+ });
70
+ Object.defineProperty(exports, "alertEpisodeId", {
71
+ enumerable: true,
72
+ get: function() {
73
+ return alertEpisodeId;
74
+ }
75
+ });
76
+ Object.defineProperty(exports, "alertEpisodePayload", {
77
+ enumerable: true,
78
+ get: function() {
79
+ return alertEpisodePayload;
80
+ }
81
+ });
82
+ Object.defineProperty(exports, "alertEpisodeRank", {
83
+ enumerable: true,
84
+ get: function() {
85
+ return alertEpisodeRank;
86
+ }
87
+ });
88
+ Object.defineProperty(exports, "isAlertEpisodeOpen", {
89
+ enumerable: true,
90
+ get: function() {
91
+ return isAlertEpisodeOpen;
92
+ }
93
+ });
@@ -493,9 +493,9 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
493
493
  */
494
494
  EventCategory["DeviceStateChanged"] = "device.state-changed";
495
495
  /**
496
- * A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
497
- * transition audit (D1022): confirmed, already in place, unconfirmed or
498
- * failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
496
+ * A device COMMAND (a vocabulary action, D920/D983) completed, as the hub's
497
+ * command audit saw it (D1022, D1084): the call returned (`ok`) or threw
498
+ * (`failed`). Never a device's own change, and never proof the device obeyed. Payload: `DeviceCommandSettledEvent`
499
499
  * (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
500
500
  * the Notification Center `device-command` kind. Telemetry (D8): losing one
501
501
  * costs a notification, never state; the audit row is the record.
@@ -3297,6 +3297,15 @@ var BaseAddon = class {
3297
3297
  /** The instance kinds whose switch move this process already ran (or tried), by record kind name. */
3298
3298
  switchMoved = /* @__PURE__ */ new Set();
3299
3299
  lastDeclared = [];
3300
+ /**
3301
+ * Every switch migration this process added to a declaration so far, by id. The engine replaces
3302
+ * an owner's catalogue on each declare, so a later one (a late kind) carries them all: dropping
3303
+ * an earlier id would read its applied ledger row as a newer database.
3304
+ */
3305
+ switchDeclared = /* @__PURE__ */ new Map();
3306
+ /** The seq each kind's move got, fixed at its first declare so its id and seq never change. */
3307
+ switchSeqs = /* @__PURE__ */ new Map();
3308
+ moveInDeclared = false;
3300
3309
  registrySwitchBound() {
3301
3310
  const api = this.ctx.migrationApi;
3302
3311
  const spec = this.registrySwitchSpec;
@@ -3307,7 +3316,7 @@ var BaseAddon = class {
3307
3316
  return [];
3308
3317
  }
3309
3318
  const date = "2026-11-06";
3310
- const moveIn = spec === null ? [] : migrationSet([registrySwitchToBodyMigration({
3319
+ const moveIn = spec === null || this.moveInDeclared ? [] : migrationSet([registrySwitchToBodyMigration({
3311
3320
  addonId: this.ctx.id,
3312
3321
  date,
3313
3322
  seq: 1e3,
@@ -3317,12 +3326,15 @@ var BaseAddon = class {
3317
3326
  records: switchRecordsOverMigrationApi(a),
3318
3327
  kind: spec.kind
3319
3328
  })).bind(api);
3320
- const moveBack = kinds.flatMap(({ kind }, index) => {
3329
+ if (spec !== null) this.moveInDeclared = true;
3330
+ const moveBack = kinds.flatMap(({ kind }) => {
3321
3331
  this.switchMoved.add(kind.name);
3332
+ const seq = 1001 + this.switchSeqs.size;
3333
+ this.switchSeqs.set(kind.name, seq);
3322
3334
  return migrationSet([bodySwitchToRegistryMigration({
3323
3335
  addonId: this.ctx.id,
3324
3336
  date: "2026-11-19",
3325
- seq: 1001 + index,
3337
+ seq,
3326
3338
  kindName: kind.name,
3327
3339
  ...spec === null ? {} : { followsDate: date }
3328
3340
  })], (a) => bodySwitchPortsOver({
@@ -3360,7 +3372,8 @@ var BaseAddon = class {
3360
3372
  async runBound(declared, options) {
3361
3373
  this.lastDeclared = declared;
3362
3374
  const added = this.registrySwitchBound();
3363
- const migrations = [...declared, ...added];
3375
+ for (const m of added) this.switchDeclared.set(m.meta.id, m);
3376
+ const migrations = [...declared, ...[...this.switchDeclared.values()].filter((m) => !declared.some((d) => d.meta.id === m.meta.id))];
3364
3377
  const widened = options?.only === void 0 || added.length === 0 ? options : {
3365
3378
  ...options,
3366
3379
  only: [...new Set([...options.only, ...added.map((m) => m.meta.id)])]
@@ -493,9 +493,9 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
493
493
  */
494
494
  EventCategory["DeviceStateChanged"] = "device.state-changed";
495
495
  /**
496
- * A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
497
- * transition audit (D1022): confirmed, already in place, unconfirmed or
498
- * failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
496
+ * A device COMMAND (a vocabulary action, D920/D983) completed, as the hub's
497
+ * command audit saw it (D1022, D1084): the call returned (`ok`) or threw
498
+ * (`failed`). Never a device's own change, and never proof the device obeyed. Payload: `DeviceCommandSettledEvent`
499
499
  * (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
500
500
  * the Notification Center `device-command` kind. Telemetry (D8): losing one
501
501
  * costs a notification, never state; the audit row is the record.
@@ -3297,6 +3297,15 @@ var BaseAddon = class {
3297
3297
  /** The instance kinds whose switch move this process already ran (or tried), by record kind name. */
3298
3298
  switchMoved = /* @__PURE__ */ new Set();
3299
3299
  lastDeclared = [];
3300
+ /**
3301
+ * Every switch migration this process added to a declaration so far, by id. The engine replaces
3302
+ * an owner's catalogue on each declare, so a later one (a late kind) carries them all: dropping
3303
+ * an earlier id would read its applied ledger row as a newer database.
3304
+ */
3305
+ switchDeclared = /* @__PURE__ */ new Map();
3306
+ /** The seq each kind's move got, fixed at its first declare so its id and seq never change. */
3307
+ switchSeqs = /* @__PURE__ */ new Map();
3308
+ moveInDeclared = false;
3300
3309
  registrySwitchBound() {
3301
3310
  const api = this.ctx.migrationApi;
3302
3311
  const spec = this.registrySwitchSpec;
@@ -3307,7 +3316,7 @@ var BaseAddon = class {
3307
3316
  return [];
3308
3317
  }
3309
3318
  const date = "2026-11-06";
3310
- const moveIn = spec === null ? [] : migrationSet([registrySwitchToBodyMigration({
3319
+ const moveIn = spec === null || this.moveInDeclared ? [] : migrationSet([registrySwitchToBodyMigration({
3311
3320
  addonId: this.ctx.id,
3312
3321
  date,
3313
3322
  seq: 1e3,
@@ -3317,12 +3326,15 @@ var BaseAddon = class {
3317
3326
  records: switchRecordsOverMigrationApi(a),
3318
3327
  kind: spec.kind
3319
3328
  })).bind(api);
3320
- const moveBack = kinds.flatMap(({ kind }, index) => {
3329
+ if (spec !== null) this.moveInDeclared = true;
3330
+ const moveBack = kinds.flatMap(({ kind }) => {
3321
3331
  this.switchMoved.add(kind.name);
3332
+ const seq = 1001 + this.switchSeqs.size;
3333
+ this.switchSeqs.set(kind.name, seq);
3322
3334
  return migrationSet([bodySwitchToRegistryMigration({
3323
3335
  addonId: this.ctx.id,
3324
3336
  date: "2026-11-19",
3325
- seq: 1001 + index,
3337
+ seq,
3326
3338
  kindName: kind.name,
3327
3339
  ...spec === null ? {} : { followsDate: date }
3328
3340
  })], (a) => bodySwitchPortsOver({
@@ -3360,7 +3372,8 @@ var BaseAddon = class {
3360
3372
  async runBound(declared, options) {
3361
3373
  this.lastDeclared = declared;
3362
3374
  const added = this.registrySwitchBound();
3363
- const migrations = [...declared, ...added];
3375
+ for (const m of added) this.switchDeclared.set(m.meta.id, m);
3376
+ const migrations = [...declared, ...[...this.switchDeclared.values()].filter((m) => !declared.some((d) => d.meta.id === m.meta.id))];
3364
3377
  const widened = options?.only === void 0 || added.length === 0 ? options : {
3365
3378
  ...options,
3366
3379
  only: [...new Set([...options.only, ...added.map((m) => m.meta.id)])]
@@ -1,10 +1,11 @@
1
- const require_stream_catalog_cap = require("./stream-catalog.cap-D8Y-uXcy.js");
2
- const require_base_addon = require("./base-addon-DD5dIfcZ.js");
1
+ const require_stream_catalog_cap = require("./stream-catalog.cap-CjEQFknc.js");
2
+ const require_base_addon = require("./base-addon-CRsXtYFG.js");
3
3
  const require_scoped_settings = require("./scoped-settings-CylSSq_8.js");
4
4
  const require_zod_secret = require("./zod-secret-DS7mj1bk.js");
5
5
  const require_device_identifiers = require("./device-identifiers-BQg9EQi1.js");
6
- const require_error_cap = require("./error.cap-BxLEHP6z.js");
7
6
  const require_source_info = require("./source-info-DtWf4k2j.js");
7
+ const require_error_cap = require("./error.cap-BuKbL3Ac.js");
8
+ const require_alert_episode = require("./alert-episode-Bqktmt-i.js");
8
9
  //#region ../types/dist/esm/device/device-config.mjs
9
10
  var DeviceConfig = class DeviceConfig {
10
11
  schema;
@@ -320,6 +321,75 @@ function deviceErrorEdge(previous, next) {
320
321
  if (next.active === false && previous?.active === true) return "resolve";
321
322
  return null;
322
323
  }
324
+ /**
325
+ * The alert severity of a fault tier. `error` is the cap's top tier and asks
326
+ * for attention (`critical`); `warning` stays a warning.
327
+ */
328
+ function deviceErrorAlertSeverity(severity) {
329
+ return severity === "error" ? "critical" : "warning";
330
+ }
331
+ var DEVICE_ERROR_ALERT_IDLE = {
332
+ neverOpened: false,
333
+ pending: null,
334
+ attempts: 0
335
+ };
336
+ /**
337
+ * The alert write a reading asks for.
338
+ *
339
+ * - a START opens; a `warning` fault that becomes an `error` opens again (same
340
+ * alert id and episode, now critical). An error that eases to a warning
341
+ * writes nothing: its critical alert stays until the fault resolves;
342
+ * - a RESOLVE closes, except an alert this process knows was never accepted —
343
+ * that one has nothing to close, and its failed open is dropped;
344
+ * - with no edge, a failed write is tried again while the reading still asks
345
+ * for it. An unknown reading asks for nothing (D49).
346
+ */
347
+ function planDeviceErrorAlert(delivery, edge, previous, next) {
348
+ if (edge === "start") return {
349
+ write: "open",
350
+ delivery: {
351
+ neverOpened: true,
352
+ pending: "open",
353
+ attempts: 0
354
+ }
355
+ };
356
+ if (edge === "resolve") {
357
+ if (delivery.neverOpened) return {
358
+ write: null,
359
+ delivery: DEVICE_ERROR_ALERT_IDLE
360
+ };
361
+ return {
362
+ write: "close",
363
+ delivery: {
364
+ neverOpened: false,
365
+ pending: "close",
366
+ attempts: 0
367
+ }
368
+ };
369
+ }
370
+ if (next.active === true) {
371
+ if (previous?.active === true && previous.severity === "warning" && next.severity === "error") return {
372
+ write: "open",
373
+ delivery: {
374
+ ...delivery,
375
+ pending: "open",
376
+ attempts: 0
377
+ }
378
+ };
379
+ if (delivery.pending === "open") return {
380
+ write: "open",
381
+ delivery
382
+ };
383
+ }
384
+ if (next.active === false && delivery.pending === "close") return {
385
+ write: "close",
386
+ delivery
387
+ };
388
+ return {
389
+ write: null,
390
+ delivery
391
+ };
392
+ }
323
393
  function deviceErrorAlertId(deviceId) {
324
394
  return `device-error:${String(deviceId)}`;
325
395
  }
@@ -344,8 +414,8 @@ function buildDeviceErrorAlert(deviceId, deviceName, status, now) {
344
414
  const alertId = deviceErrorAlertId(deviceId);
345
415
  return {
346
416
  id: alertId,
347
- category: "device.error",
348
- severity: "critical",
417
+ category: require_alert_episode.DEVICE_ERROR_ALERT_CATEGORY,
418
+ severity: deviceErrorAlertSeverity(status.severity),
349
419
  title: `${deviceName}: ${label}`,
350
420
  message: `${deviceName} reports a fault: ${label}.`,
351
421
  action: {
@@ -422,6 +492,7 @@ var DEVICE_LOCAL_STATE_CAP_NAMES = {
422
492
  intercom: "intercom",
423
493
  irTransmitter: "ir-transmitter",
424
494
  lawnMowerControl: "lawn-mower-control",
495
+ location: "location",
425
496
  lockControl: "lock-control",
426
497
  lowPowerSleep: "low-power-sleep",
427
498
  mediaPlayer: "media-player",
@@ -460,6 +531,7 @@ var DEVICE_LOCAL_STATE_CAP_NAMES = {
460
531
  update: "update",
461
532
  vacuumControl: "vacuum-control",
462
533
  valve: "valve",
534
+ vehicle: "vehicle",
463
535
  vibration: "vibration",
464
536
  waterHeater: "water-heater",
465
537
  weather: "weather",
@@ -479,6 +551,8 @@ var BaseDevice = class {
479
551
  statusIsExternal;
480
552
  /** The fault catalog the integration declared; `[]` until it does. */
481
553
  faultTypes = [];
554
+ /** What the alerts cap accepted for this device's fault, and the write still owed to it. */
555
+ errorAlertDelivery = DEVICE_ERROR_ALERT_IDLE;
482
556
  name;
483
557
  parentDeviceId;
484
558
  role;
@@ -831,51 +905,81 @@ var BaseDevice = class {
831
905
  /**
832
906
  * Publish the device's fault. The slice is written; on an EDGE (a fault
833
907
  * starts, or one resolves) an attention episode opens or closes through the
834
- * alerts cap, which the notification center announces as
835
- * `device-attention-required` / `-resolved`. An unknown reading is never an
836
- * edge. No rule exists by default: it notifies when the operator makes one.
908
+ * alerts cap, at the severity of the fault's tier: an `error` fault is a
909
+ * critical alert, which the notification center announces as
910
+ * `device-attention-required` / `-resolved`; a `warning` fault is a warning
911
+ * alert and announces nothing until it becomes an error. An unknown reading
912
+ * is never an edge. No rule exists by default: it notifies when the operator
913
+ * makes one.
914
+ *
915
+ * An alert write that fails is tried again on the next reading that still
916
+ * asks for it, `DEVICE_ERROR_ALERT_MAX_ATTEMPTS` times at most.
837
917
  */
838
918
  async publishError(reading) {
839
919
  const previous = this.getCapSlice(require_error_cap.errorCapability);
840
920
  if (reading.active === null && previous !== null && previous.active !== null) return;
841
921
  const now = Date.now();
842
922
  const edge = deviceErrorEdge(previous, reading);
843
- const next = edge === "start" && reading.since === null ? {
923
+ const next = this.withErrorSince(previous, reading, edge === "start", now);
924
+ this.setCapSlice(require_error_cap.errorCapability, next);
925
+ const plan = planDeviceErrorAlert(this.errorAlertDelivery, edge, previous, next);
926
+ this.errorAlertDelivery = plan.delivery;
927
+ if (plan.write === null) return;
928
+ await this.writeErrorAlert(plan.write, next, now);
929
+ }
930
+ /** A fault keeps the start it was given: stamped on the start, carried while it lasts. */
931
+ withErrorSince(previous, reading, starts, now) {
932
+ if (reading.active !== true || reading.since !== null) return reading;
933
+ if (starts) return {
844
934
  ...reading,
845
935
  since: now
846
- } : reading;
847
- this.setCapSlice(require_error_cap.errorCapability, next);
848
- if (edge === null) return;
849
- const alerts = this.ctx.api.alerts;
850
- if (alerts === void 0) {
851
- this.ctx.logger.warn("device error: attention event skipped — alerts capability missing", {
852
- tags: { deviceId: this.id },
853
- meta: { edge }
854
- });
855
- return;
856
- }
936
+ };
937
+ return previous?.since == null ? reading : {
938
+ ...reading,
939
+ since: previous.since
940
+ };
941
+ }
942
+ /** One attempt at the alert write the plan asked for; a failure stays owed, under the bound. */
943
+ async writeErrorAlert(write, status, now) {
944
+ const attempt = this.errorAlertDelivery.attempts + 1;
857
945
  try {
858
- if (edge === "start") await alerts.emit.mutate(buildDeviceErrorAlert(this.id, this.name, next, now));
859
- else await alerts.update.mutate({
860
- alertId: deviceErrorAlertId(this.id),
861
- patch: {
862
- status: "completed",
863
- read: true,
864
- updatedAt: now
865
- }
866
- });
867
- this.ctx.logger.info(`device error: ${edge === "start" ? "raised" : "resolved"}`, {
946
+ const alerts = this.ctx.api.alerts;
947
+ if (alerts === void 0) throw new Error("alerts capability missing");
948
+ if (write === "open") {
949
+ await alerts.emit.mutate(buildDeviceErrorAlert(this.id, this.name, status, now));
950
+ this.errorAlertDelivery = DEVICE_ERROR_ALERT_IDLE;
951
+ } else {
952
+ await alerts.update.mutate({
953
+ alertId: deviceErrorAlertId(this.id),
954
+ patch: {
955
+ status: "completed",
956
+ read: true,
957
+ updatedAt: now
958
+ }
959
+ });
960
+ this.errorAlertDelivery = DEVICE_ERROR_ALERT_IDLE;
961
+ }
962
+ this.ctx.logger.info(`device error: ${write === "open" ? "raised" : "resolved"}`, {
868
963
  tags: { deviceId: this.id },
869
964
  meta: {
870
- code: next.code,
871
- label: next.label
965
+ code: status.code,
966
+ label: status.label,
967
+ severity: status.severity,
968
+ attempt
872
969
  }
873
970
  });
874
971
  } catch (err) {
875
- this.ctx.logger.warn("device error: attention event failed", {
972
+ const givenUp = attempt >= 5;
973
+ this.errorAlertDelivery = {
974
+ ...this.errorAlertDelivery,
975
+ pending: givenUp ? null : write,
976
+ attempts: givenUp ? 0 : attempt
977
+ };
978
+ this.ctx.logger.warn(givenUp ? "device error: attention event given up, the alert is not written" : "device error: attention event failed, retried on the next reading", {
876
979
  tags: { deviceId: this.id },
877
980
  meta: {
878
- edge,
981
+ write,
982
+ attempt,
879
983
  error: require_scoped_settings.errMsg(err)
880
984
  }
881
985
  });