@camstack/server 1.2.940 → 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 +20 -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 -12
  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
@@ -3,28 +3,30 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_stream_catalog_cap = require("../../stream-catalog.cap-D8Y-uXcy.js");
7
- const require_base_addon = require("../../base-addon-DD5dIfcZ.js");
6
+ const require_stream_catalog_cap = require("../../stream-catalog.cap-CjEQFknc.js");
7
+ const require_base_addon = require("../../base-addon-CRsXtYFG.js");
8
8
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
9
- const require_rename_composition_block = require("../../rename-composition-block-CH2vRIW7.js");
9
+ const require_rename_composition_block = require("../../rename-composition-block-D9Uc1AF7.js");
10
10
  const require_camstack_error = require("../../camstack-error-DJ-TUAi1.js");
11
11
  const require_capability_definition = require("../../capability-definition-BEVd01Xj.js");
12
12
  const require_zod_secret = require("../../zod-secret-DS7mj1bk.js");
13
- const require_device_manager_cap = require("../../device-manager.cap-DyHOIh5T.js");
13
+ const require_device_manager_cap = require("../../device-manager.cap-DJs8izI6.js");
14
14
  const require_device_identifiers = require("../../device-identifiers-BQg9EQi1.js");
15
15
  const require_tag = require("../../tag-BxLazvVb.js");
16
- const require_device_type = require("../../device-type-CbQsnFdC.js");
17
- const require_device_kind = require("../../device-kind-CsSiv_YF.js");
18
- const require_core_blocks_cap = require("../../core-blocks.cap-xt5_fK5Z.js");
16
+ const require_device_type = require("../../device-type-Cnc0NiSX.js");
17
+ const require_device_kind = require("../../device-kind-FMhJg8uC.js");
18
+ const require_action_index = require("../../action-index-B_cLRwXJ.js");
19
19
  const require_addon_settings_cap = require("../../addon-settings.cap-DrLdMFIe.js");
20
- require("../../error.cap-BxLEHP6z.js");
20
+ const require_core_blocks_cap = require("../../core-blocks.cap-CdTGUKtr.js");
21
+ require("../../compile-SpeAhaZ6.js");
21
22
  const require_source_info = require("../../source-info-DtWf4k2j.js");
22
- const require_prefix_walk = require("../../prefix-walk-CCO_VZVo.js");
23
+ const require_prefix_walk = require("../../prefix-walk-BFnw8NBu.js");
24
+ const require_command_catalog = require("../../command-catalog-C29hVOOg.js");
23
25
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
24
26
  const require_log_redactor = require("../../log-redactor-BhIEMaG9.js");
25
27
  const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
26
28
  const require_retired_settings_keys = require("../../retired-settings-keys-C8nOOr5H.js");
27
- const require_device_row_store = require("../../device-row-store-O4mNbp5q.js");
29
+ const require_device_row_store = require("../../device-row-store-C0P2H18h.js");
28
30
  const require_template_protocol = require("../../template-protocol-D5ogm1rj.js");
29
31
  const require_dns_wire = require("../../dns-wire-B1BvF9Ao.js");
30
32
  let zod = require("zod");
@@ -443,6 +445,9 @@ function createDeviceExtensionProvider(options) {
443
445
  var CONTAINER_PRIMARY_CHILD_RULES = [{
444
446
  deviceType: require_device_type.DeviceType.HeatPump,
445
447
  primary: "self"
448
+ }, {
449
+ deviceType: require_device_type.DeviceType.Vehicle,
450
+ primary: "self"
446
451
  }];
447
452
  /** The declaration of a container read from its meta, or undefined when it declared none. */
448
453
  function primaryChildPreferenceOf(container) {
@@ -2151,6 +2156,13 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
2151
2156
  access: "view",
2152
2157
  role: "admin"
2153
2158
  },
2159
+ "coreBlocks.listTemplateInstances": {
2160
+ capName: "core-blocks",
2161
+ capScope: "system",
2162
+ addonId: null,
2163
+ access: "view",
2164
+ role: "admin"
2165
+ },
2154
2166
  "coreBlocks.migrateCapLinks": {
2155
2167
  capName: "core-blocks",
2156
2168
  capScope: "system",
@@ -3292,6 +3304,13 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
3292
3304
  access: "create",
3293
3305
  role: "admin"
3294
3306
  },
3307
+ "deviceManager.relinkIdentity": {
3308
+ capName: "device-manager",
3309
+ capScope: "system",
3310
+ addonId: null,
3311
+ access: "create",
3312
+ role: "admin"
3313
+ },
3295
3314
  "deviceManager.remove": {
3296
3315
  capName: "device-manager",
3297
3316
  capScope: "system",
@@ -5280,6 +5299,13 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
5280
5299
  access: "create",
5281
5300
  role: "admin"
5282
5301
  },
5302
+ "location.getStatus": {
5303
+ capName: "location",
5304
+ capScope: "device",
5305
+ addonId: null,
5306
+ access: "view",
5307
+ role: "viewer"
5308
+ },
5283
5309
  "lockControl.getStatus": {
5284
5310
  capName: "lock-control",
5285
5311
  capScope: "device",
@@ -9088,6 +9114,13 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
9088
9114
  access: "create",
9089
9115
  role: "admin"
9090
9116
  },
9117
+ "retentionSource.listRetentionKnobs": {
9118
+ capName: "retention-source",
9119
+ capScope: "system",
9120
+ addonId: null,
9121
+ access: "view",
9122
+ role: "admin"
9123
+ },
9091
9124
  "runningState.getStatus": {
9092
9125
  capName: "running-state",
9093
9126
  capScope: "device",
@@ -11167,6 +11200,20 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
11167
11200
  access: "create",
11168
11201
  role: "admin"
11169
11202
  },
11203
+ "vehicle.getStatus": {
11204
+ capName: "vehicle",
11205
+ capScope: "device",
11206
+ addonId: null,
11207
+ access: "view",
11208
+ role: "viewer"
11209
+ },
11210
+ "vehicle.requestRefresh": {
11211
+ capName: "vehicle",
11212
+ capScope: "device",
11213
+ addonId: null,
11214
+ access: "create",
11215
+ role: "admin"
11216
+ },
11170
11217
  "vibration.getStatus": {
11171
11218
  capName: "vibration",
11172
11219
  capScope: "device",
@@ -11507,7 +11554,7 @@ function capNamesOf(bindings) {
11507
11554
  /** The device-scoped entries the device binds, in the map's order. */
11508
11555
  function boundEntries(bindings) {
11509
11556
  const bound = new Set(capNamesOf(bindings));
11510
- return Object.entries(require_core_blocks_cap.CAP_VOCABULARY_BY_NAME).filter(([cap, entry]) => bound.has(cap) && entry.scope === "device");
11557
+ return Object.entries(require_action_index.CAP_VOCABULARY_BY_NAME).filter(([cap, entry]) => bound.has(cap) && entry.scope === "device");
11511
11558
  }
11512
11559
  /** The wordings that apply: the type's first, then the role's (a role wins). */
11513
11560
  function wordingsFor(entry, deviceType, role) {
@@ -11571,173 +11618,6 @@ function deviceOffersActions(bindings, actionIds, mode = "any", deviceType) {
11571
11618
  return mode === "all" ? actionIds.every((id) => offered.has(id)) : actionIds.some((id) => offered.has(id));
11572
11619
  }
11573
11620
  //#endregion
11574
- //#region ../types/dist/esm/device/cap-vocabulary/command-catalog.mjs
11575
- /**
11576
- * The command catalogue (D1022): which cap methods are COMMANDS - the
11577
- * vocabulary actions (D920/D983) of a device-scope cap - and which status
11578
- * fields a command's effect or a boolean/enum state trigger names.
11579
- *
11580
- * Derived from the vocabulary, never kept as a second list: a method that
11581
- * becomes an action is a command with no other edit, and the spec beside this
11582
- * file fails when a device mutation is neither one nor excused. The audit in
11583
- * the hub mirror reads `auditedFields` so a slice write on a cap without any
11584
- * costs one map miss.
11585
- */
11586
- var commandKeys;
11587
- var fieldsByCap;
11588
- var NO_FIELDS = /* @__PURE__ */ new Set();
11589
- function commands() {
11590
- commandKeys ??= new Set(require_core_blocks_cap.allVocabActions().map(({ cap, action }) => `${cap}.${action.method}`));
11591
- return commandKeys;
11592
- }
11593
- function buildAuditedFields() {
11594
- const byCap = /* @__PURE__ */ new Map();
11595
- const add = (cap, field) => {
11596
- const set = byCap.get(cap) ?? /* @__PURE__ */ new Set();
11597
- set.add(field);
11598
- byCap.set(cap, set);
11599
- };
11600
- for (const { cap, action } of require_core_blocks_cap.allVocabActions()) {
11601
- if (action.effect !== void 0) add(cap, action.effect.field);
11602
- for (const side of action.sideEffects ?? []) add(cap, side.field);
11603
- }
11604
- for (const [cap, entry] of Object.entries(require_core_blocks_cap.CAP_VOCABULARY_BY_NAME)) {
11605
- if (entry.scope !== "device") continue;
11606
- for (const trigger of entry.state ?? []) if (trigger.kind === "boolean" || trigger.kind === "enum") add(cap, trigger.field);
11607
- }
11608
- return byCap;
11609
- }
11610
- /** Is `cap.method` a vocabulary action of a device-scope cap? */
11611
- function isCommand$2(cap, method) {
11612
- return commands().has(`${cap}.${method}`);
11613
- }
11614
- /**
11615
- * The state the command `cap.method(args)` leads to, or `null` when it leads
11616
- * to none (toggle, press, stop), is not a command, or the argument carrying
11617
- * the value is missing.
11618
- */
11619
- function commandEffect(cap, method, args) {
11620
- const actionId = require_core_blocks_cap.vocabActionIdFor(cap, method, args);
11621
- if (actionId === void 0) return null;
11622
- const effect = require_core_blocks_cap.actionEffect(actionId, args);
11623
- return effect === null ? null : {
11624
- field: effect.field,
11625
- value: effect.value
11626
- };
11627
- }
11628
- /** The status fields of `cap` whose changes are recorded as transitions. */
11629
- function auditedFields(cap) {
11630
- fieldsByCap ??= buildAuditedFields();
11631
- return fieldsByCap.get(cap) ?? NO_FIELDS;
11632
- }
11633
- /** Does `slice` meet `when`? A field the slice lacks is in no list. */
11634
- function effectConditionHolds(when, slice) {
11635
- if (when === void 0) return true;
11636
- const raw = slice?.[when.field];
11637
- const value = typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean" ? raw : void 0;
11638
- if ("in" in when) return value !== void 0 && when.in.includes(value);
11639
- return value === void 0 || !when.notIn.includes(value);
11640
- }
11641
- /** The step of the number open arg `key`, when the action offers one. */
11642
- function stepOf(openArgs, key) {
11643
- const offer = openArgs?.find((a) => a.key === key)?.offer;
11644
- return offer?.kind === "number" && offer.step !== void 0 && offer.step > 0 ? offer.step : void 0;
11645
- }
11646
- /**
11647
- * One side effect resolved against the args and the slice the command acts
11648
- * on: `null` when the arg carrying its value is missing, or a `negate` names a
11649
- * field the slice holds no boolean in. `openArgs` lends a copied number its
11650
- * step as the tolerance.
11651
- */
11652
- function resolveSideEffect(side, args, shown, openArgs) {
11653
- if ("value" in side) return {
11654
- field: side.field,
11655
- value: side.value
11656
- };
11657
- if ("negate" in side) {
11658
- const raw = shown?.[side.field];
11659
- return typeof raw === "boolean" ? {
11660
- field: side.field,
11661
- value: !raw
11662
- } : null;
11663
- }
11664
- const raw = args?.[side.fromArg];
11665
- if (typeof raw === "string" || typeof raw === "boolean") return {
11666
- field: side.field,
11667
- value: raw
11668
- };
11669
- if (typeof raw === "number") {
11670
- const scale = side.scale ?? 1;
11671
- const step = stepOf(openArgs, side.fromArg);
11672
- return step === void 0 ? {
11673
- field: side.field,
11674
- value: raw * scale
11675
- } : {
11676
- field: side.field,
11677
- value: raw * scale,
11678
- tolerance: step * scale
11679
- };
11680
- }
11681
- return null;
11682
- }
11683
- /**
11684
- * The hold limit the vocabulary declares for `cap.method(args)` (its action's
11685
- * `hold.holdMs`), or `undefined` for the default.
11686
- */
11687
- function commandHoldMs(cap, method, args) {
11688
- return holdFor(cap, method, args)?.holdMs;
11689
- }
11690
- /**
11691
- * The hold the vocabulary declares for `cap.method(args)`: the matched
11692
- * action's, or — when several actions share the method and the args cannot
11693
- * tell them apart (`petFeeder.feed` / `feedHoppers`) — the one they all
11694
- * declare alike. Different holds on such actions resolve to none.
11695
- */
11696
- function holdFor(cap, method, args) {
11697
- const actionId = require_core_blocks_cap.vocabActionIdFor(cap, method, args);
11698
- if (actionId !== void 0) return require_core_blocks_cap.findVocabAction(actionId)?.action.hold;
11699
- const holds = require_core_blocks_cap.allVocabActions().filter(({ cap: c, action }) => c === cap && action.method === method).map(({ action }) => action.hold);
11700
- const first = holds[0];
11701
- if (first === void 0) return void 0;
11702
- const key = JSON.stringify(first);
11703
- return holds.every((h) => JSON.stringify(h) === key) ? first : void 0;
11704
- }
11705
- /**
11706
- * EVERY state the command `cap.method(args)` leads to (D1061): its `effect`
11707
- * first, then each side effect whose condition holds on `current` (the cap's
11708
- * slice the device reported when the command arrived). Empty when it leads to
11709
- * none. One field is named once — the first entry for it wins. A `negate`
11710
- * side effect flips what `shown` (the slice the person saw, held values
11711
- * included) holds, so a second toggle before the first is confirmed undoes it.
11712
- * An action that declares `hold.effects` is held as THOSE instead (a lock
11713
- * holds `locking`, not `locked`).
11714
- */
11715
- function commandEffects(cap, method, args, current, shown = current) {
11716
- const out = [];
11717
- const hold = holdFor(cap, method, args);
11718
- if (hold?.effects !== void 0) {
11719
- for (const entry of hold.effects) {
11720
- if (!effectConditionHolds(entry.when, current)) continue;
11721
- const resolved = resolveSideEffect(entry, args, shown);
11722
- if (resolved !== null && !out.some((e) => e.field === resolved.field)) out.push(resolved);
11723
- }
11724
- return out;
11725
- }
11726
- const actionId = require_core_blocks_cap.vocabActionIdFor(cap, method, args);
11727
- if (actionId === void 0) return [];
11728
- const action = require_core_blocks_cap.findVocabAction(actionId)?.action;
11729
- if (action?.effect !== void 0) {
11730
- const primary = resolveSideEffect(action.effect, args, shown, action.openArgs);
11731
- if (primary !== null) out.push(primary);
11732
- }
11733
- for (const side of action?.sideEffects ?? []) {
11734
- if (!effectConditionHolds(side.when, current)) continue;
11735
- const resolved = resolveSideEffect(side, args, shown, action?.openArgs);
11736
- if (resolved !== null && !out.some((e) => e.field === resolved.field)) out.push(resolved);
11737
- }
11738
- return out;
11739
- }
11740
- //#endregion
11741
11621
  //#region ../types/dist/esm/device/device-feature-requirements.mjs
11742
11622
  function bound(cap, methods = [], authority = "reported") {
11743
11623
  return {
@@ -11971,6 +11851,7 @@ var CAP_NAMES_WITH_STATUS = [
11971
11851
  "image-settings",
11972
11852
  "intercom",
11973
11853
  "lawn-mower-control",
11854
+ "location",
11974
11855
  "lock-control",
11975
11856
  "low-power-sleep",
11976
11857
  "media-player",
@@ -12011,6 +11892,7 @@ var CAP_NAMES_WITH_STATUS = [
12011
11892
  "update",
12012
11893
  "vacuum-control",
12013
11894
  "valve",
11895
+ "vehicle",
12014
11896
  "vibration",
12015
11897
  "water-heater",
12016
11898
  "weather",
@@ -12021,7 +11903,7 @@ var CAP_NAMES_WITH_STATUS = [
12021
11903
  //#region ../types/dist/esm/generated/runtime-state-durability.mjs
12022
11904
  /**
12023
11905
  * Per-cap runtime-state policy, projected from every `*.cap.ts` that declares
12024
- * `runtimeState`. 88 caps: 44 `restored`, 44 `session`.
11906
+ * `runtimeState`. 90 caps: 46 `restored`, 44 `session`.
12025
11907
  *
12026
11908
  * A cap absent from this map has no runtime-state slice at all. A cap PRESENT
12027
11909
  * with `durability: 'session'` has one and has decided not to keep it.
@@ -12197,6 +12079,14 @@ var RUNTIME_STATE_POLICY = {
12197
12079
  durability: "session",
12198
12080
  volatileFields: []
12199
12081
  },
12082
+ "location": {
12083
+ durability: "restored",
12084
+ volatileFields: [
12085
+ "fixAt",
12086
+ "lastChangedAt",
12087
+ "lastFetchedAt"
12088
+ ]
12089
+ },
12200
12090
  "lock-control": {
12201
12091
  durability: "restored",
12202
12092
  volatileFields: ["lastChangedAt"]
@@ -12349,6 +12239,14 @@ var RUNTIME_STATE_POLICY = {
12349
12239
  durability: "session",
12350
12240
  volatileFields: []
12351
12241
  },
12242
+ "vehicle": {
12243
+ durability: "restored",
12244
+ volatileFields: [
12245
+ "reportedAt",
12246
+ "lastChangedAt",
12247
+ "lastFetchedAt"
12248
+ ]
12249
+ },
12352
12250
  "vibration": {
12353
12251
  durability: "restored",
12354
12252
  volatileFields: ["lastChangedAt"]
@@ -12597,8 +12495,8 @@ function clampHoldMs(ms) {
12597
12495
  }
12598
12496
  function resolveList(list, args, current, shown, into) {
12599
12497
  for (const entry of list) {
12600
- if (!effectConditionHolds(entry.when, current)) continue;
12601
- const resolved = resolveSideEffect(entry, args, shown);
12498
+ if (!require_command_catalog.effectConditionHolds(entry.when, current)) continue;
12499
+ const resolved = require_command_catalog.resolveSideEffect(entry, args, shown);
12602
12500
  if (resolved !== null && !into.some((e) => e.field === resolved.field)) into.push(resolved);
12603
12501
  }
12604
12502
  }
@@ -12612,12 +12510,12 @@ function resolveCommandHold(cap, method, args, current, option, shown = current)
12612
12510
  if (option?.hold === "never") return null;
12613
12511
  const effects = [];
12614
12512
  if (option?.effects !== void 0) resolveList(option.effects, args, current, shown, effects);
12615
- else effects.push(...commandEffects(cap, method, args, current, shown));
12513
+ else effects.push(...require_command_catalog.commandEffects(cap, method, args, current, shown));
12616
12514
  if (option?.extraEffects !== void 0) resolveList(option.extraEffects, args, current, shown, effects);
12617
12515
  if (effects.length === 0) return null;
12618
12516
  return {
12619
12517
  effects,
12620
- holdMs: clampHoldMs(option?.holdMs ?? commandHoldMs(cap, method, args))
12518
+ holdMs: clampHoldMs(option?.holdMs ?? require_command_catalog.commandHoldMs(cap, method, args))
12621
12519
  };
12622
12520
  }
12623
12521
  //#endregion
@@ -21525,6 +21423,7 @@ async function writeDeclaredIdentity(pctx, input, column) {
21525
21423
  * | `proposal` candidate, no row | `proposed`, no event |
21526
21424
  * | `proposed` row, candidate now `auto` | `linked` / `auto`, created |
21527
21425
  * | `dismissed` row | stays dismissed: nothing re-proposes it |
21426
+ * | `dismissed` row, operator Relink | `linked` / `operator`, created (evidence must still hold) |
21528
21427
  * | `linked`/`auto` row, evidence gone | row deleted, `identity-link.lost` evidence-gone |
21529
21428
  * | `linked`/`operator` row, evidence gone | kept, flagged `evidenceGone`, `lost` evidence-gone |
21530
21429
  * | `linked`/`operator` flagged, evidence back | flag cleared, `identity-link.created` |
@@ -21625,6 +21524,33 @@ var IdentityLinkReconciler = class {
21625
21524
  return next;
21626
21525
  });
21627
21526
  }
21527
+ /** Undo a dismissal: a `dismissed` link acts again, as the operator's decision.
21528
+ * Refused `evidence-gone` when the current candidates no longer declare the pair
21529
+ * (a relink of a pair nothing declares would only be flagged at the next pass). */
21530
+ relink(linkId) {
21531
+ return this.decide(linkId, "dismissed", async (link) => {
21532
+ const answer = this.deps.candidates();
21533
+ if (!(answer.status === "answered" && answer.candidates.some((c) => require_device_manager_cap.identityLinkId(c.kind, c.a, c.b) === link.id))) return {
21534
+ ok: false,
21535
+ reason: "evidence-gone",
21536
+ message: `identity link ${linkId} cannot be relinked: its devices no longer declare the identifiers that matched them`
21537
+ };
21538
+ const { evidenceGone: _dropped, ...rest } = link;
21539
+ const next = {
21540
+ ...rest,
21541
+ state: "linked",
21542
+ origin: "operator",
21543
+ decidedAt: this.now()
21544
+ };
21545
+ await this.deps.store.put(next);
21546
+ this.log("identity link relinked by the operator", next);
21547
+ this.deps.emit(require_base_addon.EventCategory.IdentityLinkCreated, payloadOf(next));
21548
+ return {
21549
+ ok: true,
21550
+ link: next
21551
+ };
21552
+ });
21553
+ }
21628
21554
  /** The `identity-links` removal step (D864): every link naming the device goes. */
21629
21555
  removeDevice(deviceId) {
21630
21556
  return this.serialized(async () => {
@@ -21768,9 +21694,10 @@ var IdentityLinkReconciler = class {
21768
21694
  reason: "wrong-state",
21769
21695
  message: `identity link ${linkId} is ${link.state}, not ${from}`
21770
21696
  };
21771
- return {
21697
+ const applied = await apply(link);
21698
+ return "ok" in applied ? applied : {
21772
21699
  ok: true,
21773
- link: await apply(link)
21700
+ link: applied
21774
21701
  };
21775
21702
  });
21776
21703
  }
@@ -22036,8 +21963,8 @@ var DeviceIdentityIndex = class {
22036
21963
  * {@link candidates}, plus each device's attached identifiers paired with
22037
21964
  * another integration's device identifiers (`poe-power`).
22038
21965
  *
22039
- * One link per port: when a port's attached keys reach several devices, or a
22040
- * device is reached by several ports, every one of those attached pairs is
21966
+ * A port reaching several devices (a PoE splitter) links every one of them. A
21967
+ * device reached by several ports is ambiguous: each of those attached pairs is
22041
21968
  * graded a `proposal` at most — the operator picks.
22042
21969
  *
22043
21970
  * Freshness first: a pair whose shared keys the port only RETAINS (declared
@@ -22081,8 +22008,9 @@ var DeviceIdentityIndex = class {
22081
22008
  const target = this.devices.get(id);
22082
22009
  if (target === void 0 || id === port.deviceId || sameIntegration(port, target)) continue;
22083
22010
  const keys = sharedKeys(port.attachedIdentifiers, target.identifiers);
22084
- const confidence = classifyIdentityMatch(keys);
22085
- if (confidence === null) continue;
22011
+ const graded = classifyIdentityMatch(keys);
22012
+ if (graded === null) continue;
22013
+ const confidence = (port.attachedIdentifiers.mac?.length ?? 0) > 1 && port.attachedIdentifiers.ip === void 0 && keys.some((k) => k.key === "mac") ? "auto" : graded;
22086
22014
  const retained = new Set(port.attachedRetained);
22087
22015
  all.push({
22088
22016
  pair: {
@@ -22099,13 +22027,9 @@ var DeviceIdentityIndex = class {
22099
22027
  }
22100
22028
  const freshlyReached = new Set(all.filter((p) => p.fresh).map((p) => p.pair.b.deviceId));
22101
22029
  const pairs = all.filter((p) => p.fresh || !freshlyReached.has(p.pair.b.deviceId)).map((p) => p.pair);
22102
- const perPort = /* @__PURE__ */ new Map();
22103
22030
  const perTarget = /* @__PURE__ */ new Map();
22104
- for (const p of pairs) {
22105
- perPort.set(p.a.deviceId, (perPort.get(p.a.deviceId) ?? 0) + 1);
22106
- perTarget.set(p.b.deviceId, (perTarget.get(p.b.deviceId) ?? 0) + 1);
22107
- }
22108
- return pairs.map((p) => (perPort.get(p.a.deviceId) ?? 0) > 1 || (perTarget.get(p.b.deviceId) ?? 0) > 1 ? {
22031
+ for (const p of pairs) perTarget.set(p.b.deviceId, (perTarget.get(p.b.deviceId) ?? 0) + 1);
22032
+ return pairs.map((p) => (perTarget.get(p.b.deviceId) ?? 0) > 1 ? {
22109
22033
  ...p,
22110
22034
  confidence: "proposal"
22111
22035
  } : p);
@@ -24366,7 +24290,6 @@ function errorMessage$2(err) {
24366
24290
  var DeviceStateMirror = class {
24367
24291
  ctx;
24368
24292
  policyFor;
24369
- transitionTap = null;
24370
24293
  reportTap = null;
24371
24294
  /**
24372
24295
  * Hub-side mirror of every device's cap-keyed NATIVE runtime state — what the
@@ -24424,10 +24347,6 @@ var DeviceStateMirror = class {
24424
24347
  readRowFirst: (deviceId, settings) => this.ensureRowRead(deviceId, settings)
24425
24348
  });
24426
24349
  }
24427
- /** Set once by the device-manager: told, after the mirror stored it, of every native slice that actually changed (D1022). */
24428
- setTransitionTap(tap) {
24429
- this.transitionTap = tap;
24430
- }
24431
24350
  /** Set once by the device-manager: told of every native slice reported, before the no-change check (D1062). */
24432
24351
  setReportTap(tap) {
24433
24352
  this.reportTap = tap;
@@ -24487,7 +24406,6 @@ var DeviceStateMirror = class {
24487
24406
  if (prior && shallowEqual(prior, written)) return false;
24488
24407
  slice = written;
24489
24408
  perCap.set(capName, { ...slice });
24490
- this.transitionTap?.(deviceId, capName, prior, slice);
24491
24409
  const claim = this.claims.claim(deviceId, capName);
24492
24410
  if (claim) {
24493
24411
  if (claim.mode === "replace") this.emitNativeShadow(deviceId, capName, { ...slice });
@@ -26257,31 +26175,22 @@ function createCommandArgsPreparer(inputFor) {
26257
26175
  };
26258
26176
  }
26259
26177
  //#endregion
26260
- //#region src/builtins/device-manager/transitions/transition-correlator.ts
26178
+ //#region src/builtins/device-manager/transitions/command-recorder.ts
26261
26179
  /**
26262
- * The correlator of the device transition audit (D1022).
26180
+ * The command recorder of the device audit (D1022, D1084).
26263
26181
  *
26264
- * A command (what the kernel saw leave its caller) and a slice change (what the
26265
- * hub mirror saw land) are two facts about one event. This module pairs them:
26266
- * a change of an audited field is attributed to the newest pending command whose
26267
- * effect names that field and value, else to a command with no effect (toggle,
26268
- * press), else to the device itself. A command whose target already held is
26269
- * `already`; one that produced nothing inside its window is `unconfirmed`; one
26270
- * the caller saw throw is `failed`.
26182
+ * A command is what the kernel saw leave its caller. It is written as ONE row,
26183
+ * when the call completes: `ok` when it returned, `failed` when the caller saw it
26184
+ * throw. Nothing waits for the device to obey and nothing is matched to a slice
26185
+ * change: the change, when the device reports one, is read back from device-history
26186
+ * on the Interactions read, beside the command row.
26271
26187
  *
26272
- * Pure and clock-injected. It reads memory only (D49): the pending ring and the
26273
- * mirror's current slice. Nothing here does I/O, so a state write never waits on
26274
- * the audit; what it produces is handed to `emit`, whose queue is bounded.
26188
+ * Pure and clock-injected; it reads memory only (D49): the mirror's current slice,
26189
+ * for the `from` value of a command that names an effect. What it produces is
26190
+ * handed to `emit`, whose queue is bounded.
26275
26191
  */
26276
- /** How long a command waits for the change it should cause. */
26277
- var COMMAND_MATCH_WINDOW_MS = 3e4;
26278
26192
  /** Longest error text a row keeps. */
26279
26193
  var ERROR_MAX_CHARS = 300;
26280
- function sameValue(a, b) {
26281
- if (Object.is(a, b)) return true;
26282
- if (a === null || b === null || typeof a !== "object" || typeof b !== "object") return false;
26283
- return JSON.stringify(a) === JSON.stringify(b);
26284
- }
26285
26194
  /** A status value in the shape a transition stores: unknown is `null` (D393), an array is wrapped. */
26286
26195
  function toTransitionValue(value) {
26287
26196
  if (value === void 0 || value === null) return null;
@@ -26290,245 +26199,49 @@ function toTransitionValue(value) {
26290
26199
  if (typeof value === "object") return Object.fromEntries(Object.entries(value));
26291
26200
  return String(value);
26292
26201
  }
26293
- var TransitionCorrelator = class {
26202
+ var CommandRecorder = class {
26294
26203
  deps;
26295
- pending = /* @__PURE__ */ new Map();
26296
26204
  seq = 0;
26297
- held = /* @__PURE__ */ new Map();
26298
26205
  constructor(deps) {
26299
26206
  this.deps = deps;
26300
26207
  }
26301
- /** A command left its caller. */
26208
+ /**
26209
+ * A command left its caller. Where the seam can see the call settle (`obs.outcome`), the row is
26210
+ * written when it does; where it cannot (the UDS parent and in-process clients report only the
26211
+ * departure) the call is recorded as `ok` at once, since a throw there is not observable.
26212
+ */
26302
26213
  recordCommand(obs) {
26303
- const effect = commandEffect(obs.capName, obs.method, obs.args);
26304
- const current = this.deps.currentSlice(obs.deviceId, obs.capName);
26305
- const fromAtCommand = effect === null ? null : toTransitionValue(current?.[effect.field]);
26306
- const entry = {
26307
- commandId: this.nextCommandId(obs),
26308
- obs,
26309
- effect,
26310
- expiresAt: obs.at + COMMAND_MATCH_WINDOW_MS,
26311
- fromAtCommand,
26312
- settled: false
26313
- };
26314
- if (effect !== null && current !== void 0 && Object.hasOwn(current, effect.field) && sameValue(current[effect.field], effect.value)) {
26315
- entry.settled = true;
26316
- this.emit(entry, "already", effect.field, fromAtCommand, toTransitionValue(effect.value), null);
26317
- return;
26318
- }
26319
- const key = this.keyOf(obs.deviceId, obs.capName);
26320
- const ring = this.pending.get(key) ?? [];
26321
- ring.push(entry);
26322
- while (ring.length > 8) {
26323
- const oldest = ring.shift();
26324
- if (oldest !== void 0) this.expire(oldest);
26325
- }
26326
- this.pending.set(key, ring);
26327
- obs.outcome?.catch((err) => this.fail(entry, err));
26328
- }
26329
- /** The mirror stored a new native slice for `capName` (the previous one, if any, is `prior`). */
26330
- onSliceChange(deviceId, capName, prior, slice) {
26331
- const fields = auditedFields(capName);
26332
- if (fields.size === 0) return;
26333
- const now = this.deps.now();
26334
- const changes = [];
26335
- for (const field of fields) {
26336
- const hadBefore = prior !== void 0 && Object.hasOwn(prior, field);
26337
- const has = Object.hasOwn(slice, field);
26338
- if (!hadBefore && !has) continue;
26339
- const before = hadBefore ? prior[field] : void 0;
26340
- const after = has ? slice[field] : void 0;
26341
- if (sameValue(before, after)) continue;
26342
- changes.push({
26214
+ const effect = require_command_catalog.commandEffect(obs.capName, obs.method, obs.args);
26215
+ const field = effect?.field ?? "*";
26216
+ const from = effect === null ? null : toTransitionValue(this.deps.currentSlice(obs.deviceId, obs.capName)?.[effect.field]);
26217
+ const to = effect === null ? null : toTransitionValue(effect.value);
26218
+ const write = (outcome, error) => {
26219
+ this.seq += 1;
26220
+ const commandId = `${obs.deviceId}:${obs.at}:c${this.seq}`;
26221
+ this.deps.emit({
26222
+ id: commandId,
26223
+ deviceId: obs.deviceId,
26224
+ at: obs.at,
26225
+ capName: obs.capName,
26343
26226
  field,
26344
- before,
26345
- after,
26346
- neverHeld: !hadBefore
26227
+ from,
26228
+ to,
26229
+ outcome,
26230
+ actor: obs.actor,
26231
+ command: {
26232
+ commandId,
26233
+ method: obs.method,
26234
+ args: this.deps.prepareArgs(obs.capName, obs.method, obs.args),
26235
+ requestedAt: obs.at,
26236
+ ...error !== void 0 ? { error: require_log_redactor.redactLogText(error).slice(0, ERROR_MAX_CHARS) } : {}
26237
+ }
26347
26238
  });
26348
- }
26349
- if (changes.length === 0) return;
26350
- const key = this.keyOf(deviceId, capName);
26351
- const burst = this.held.get(key) ?? {
26352
- deviceId,
26353
- capName,
26354
- fields: /* @__PURE__ */ new Map(),
26355
- firstAt: now,
26356
- lastAt: now
26357
26239
  };
26358
- burst.lastAt = now;
26359
- const claimable = this.hasLiveCommand(deviceId, capName, now);
26360
- for (const change of changes) {
26361
- const earlier = burst.fields.get(change.field);
26362
- if (change.neverHeld && earlier === void 0 && !claimable) continue;
26363
- burst.fields.set(change.field, {
26364
- before: earlier !== void 0 ? earlier.before : change.before,
26365
- after: change.after,
26366
- neverHeld: earlier !== void 0 ? earlier.neverHeld : change.neverHeld
26367
- });
26368
- }
26369
- if (burst.fields.size === 0) return;
26370
- this.held.set(key, burst);
26371
- if (this.commandMatchedBy(deviceId, capName, changes, now) !== void 0) this.flushBurst(key, burst);
26372
- }
26373
- hasLiveCommand(deviceId, capName, now) {
26374
- return (this.pending.get(this.keyOf(deviceId, capName)) ?? []).some((e) => !e.settled && e.expiresAt > now);
26375
- }
26376
- /** Write every held burst now (shutdown): a held change must not be lost (D49). */
26377
- flush() {
26378
- for (const [key, burst] of [...this.held]) this.flushBurst(key, burst);
26379
- }
26380
- /** The fields of a burst that ended somewhere other than where they started. */
26381
- netChanges(burst) {
26382
- return [...burst.fields].filter(([, f]) => !sameValue(f.before, f.after)).map(([field, f]) => ({
26383
- field,
26384
- ...f
26385
- }));
26386
- }
26387
- flushBurst(key, burst) {
26388
- this.held.delete(key);
26389
- const net = this.netChanges(burst);
26390
- const { deviceId, capName } = burst;
26391
- for (const field of burst.fields.keys()) {
26392
- if (net.some((c) => c.field === field)) continue;
26393
- this.deps.logger?.debug(`device-transitions: ${capName}.${field} went and came back inside one burst; no row`, { tags: { deviceId } });
26394
- }
26395
- const touched = [...burst.fields].map(([field, f]) => ({
26396
- field,
26397
- ...f
26398
- }));
26399
- let claimed = this.commandMatchedBy(deviceId, capName, touched, burst.lastAt);
26400
- for (const change of net) claimed = this.attribute(deviceId, capName, change.field, toTransitionValue(change.before), toTransitionValue(change.after), burst.lastAt, claimed, change.neverHeld);
26401
- const effect = claimed?.effect;
26402
- if (claimed !== void 0 && effect !== null && effect !== void 0) {
26403
- if (!net.some((c) => c.field === effect.field)) {
26404
- const before = burst.fields.get(effect.field)?.before;
26405
- this.confirmWithoutNet(key, claimed, effect.field, toTransitionValue(before), toTransitionValue(effect.value), burst.lastAt);
26406
- }
26407
- }
26408
- }
26409
- confirmWithoutNet(key, entry, field, from, to, at) {
26410
- entry.settled = true;
26411
- this.emit(entry, "confirmed", field, from, to, at - entry.obs.at, void 0, at);
26412
- this.pruneSettled(key);
26413
- }
26414
- pruneSettled(key) {
26415
- const ring = this.pending.get(key);
26416
- if (ring === void 0) return;
26417
- const rest = ring.filter((e) => !e.settled);
26418
- if (rest.length === 0) this.pending.delete(key);
26419
- else this.pending.set(key, rest);
26420
- }
26421
- flushDue(now) {
26422
- for (const [key, burst] of [...this.held]) if (now - burst.lastAt >= 5e3 || now - burst.firstAt >= 6e4) this.flushBurst(key, burst);
26423
- }
26424
- /** The newest live command whose effect one of `changes` fulfils, if any. */
26425
- commandMatchedBy(deviceId, capName, changes, now) {
26426
- return [...(this.pending.get(this.keyOf(deviceId, capName)) ?? []).filter((e) => !e.settled && e.expiresAt > now)].reverse().find((e) => e.effect !== null && changes.some((c) => e.effect !== null && e.effect.field === c.field && sameValue(e.effect.value, toTransitionValue(c.after))));
26427
- }
26428
- /** Expire every pending command past its window. Driven by the sender's tick. */
26429
- sweep() {
26430
- const now = this.deps.now();
26431
- this.flushDue(now);
26432
- for (const [key, ring] of this.pending) {
26433
- const live = [];
26434
- for (const entry of ring) {
26435
- if (entry.settled) continue;
26436
- if (entry.expiresAt <= now) this.expire(entry);
26437
- else live.push(entry);
26438
- }
26439
- if (live.length === 0) this.pending.delete(key);
26440
- else this.pending.set(key, live);
26441
- }
26442
- }
26443
- /** Commands still waiting, for a status read. */
26444
- pendingCount() {
26445
- let n = 0;
26446
- for (const ring of this.pending.values()) n += ring.filter((e) => !e.settled).length;
26447
- return n;
26448
- }
26449
- /** Forget a removed device's pending commands. */
26450
- forgetDevice(deviceId) {
26451
- const prefix = `${deviceId}|`;
26452
- for (const key of [...this.held.keys()]) {
26453
- if (!key.startsWith(prefix)) continue;
26454
- this.deps.logger?.debug(`device-transitions: device removed with a held ${key.slice(prefix.length)} burst; dropped`, { tags: { deviceId } });
26455
- this.held.delete(key);
26456
- }
26457
- for (const key of [...this.pending.keys()]) if (key.startsWith(prefix)) this.pending.delete(key);
26458
- }
26459
- attribute(deviceId, capName, field, from, to, now, claimedByThisWrite, neverHeld) {
26460
- const key = this.keyOf(deviceId, capName);
26461
- const live = (this.pending.get(key) ?? []).filter((e) => !e.settled && e.expiresAt > now);
26462
- const matched = [...live].reverse().find((e) => e.effect !== null && e.effect.field === field && sameValue(e.effect.value, to)) ?? claimedByThisWrite ?? [...live].reverse().find((e) => e.effect === null);
26463
- if (matched === void 0) {
26464
- if (neverHeld) return void 0;
26465
- this.writeDevice(deviceId, capName, field, from, to, now);
26240
+ if (obs.outcome === void 0) {
26241
+ write("ok");
26466
26242
  return;
26467
26243
  }
26468
- matched.settled = true;
26469
- this.emit(matched, "confirmed", field, from, to, now - matched.obs.at, void 0, now);
26470
- this.pruneSettled(key);
26471
- return matched;
26472
- }
26473
- expire(entry) {
26474
- if (entry.settled) return;
26475
- entry.settled = true;
26476
- const field = entry.effect?.field ?? "*";
26477
- this.emit(entry, "unconfirmed", field, entry.fromAtCommand, entry.fromAtCommand, null);
26478
- }
26479
- fail(entry, err) {
26480
- if (entry.settled) return;
26481
- entry.settled = true;
26482
- const message = err instanceof Error ? err.message : String(err);
26483
- const field = entry.effect?.field ?? "*";
26484
- this.emit(entry, "failed", field, entry.fromAtCommand, entry.fromAtCommand, null, message);
26485
- }
26486
- emit(entry, outcome, field, from, to, matchedAfterMs, error, at = this.deps.now()) {
26487
- const { obs } = entry;
26488
- this.deps.emit({
26489
- id: this.nextId(obs.deviceId, at),
26490
- deviceId: obs.deviceId,
26491
- at,
26492
- capName: obs.capName,
26493
- field,
26494
- from,
26495
- to,
26496
- outcome,
26497
- actor: obs.actor,
26498
- command: {
26499
- commandId: entry.commandId,
26500
- method: obs.method,
26501
- args: this.deps.prepareArgs(obs.capName, obs.method, obs.args),
26502
- requestedAt: obs.at,
26503
- matchedAfterMs,
26504
- ...error !== void 0 ? { error: require_log_redactor.redactLogText(error).slice(0, ERROR_MAX_CHARS) } : {}
26505
- }
26506
- });
26507
- }
26508
- /** A change nobody asked for. */
26509
- writeDevice(deviceId, capName, field, from, to, at) {
26510
- this.deps.emit({
26511
- id: this.nextId(deviceId, at),
26512
- deviceId,
26513
- at,
26514
- capName,
26515
- field,
26516
- from,
26517
- to,
26518
- outcome: "device",
26519
- actor: { kind: "device" }
26520
- });
26521
- }
26522
- keyOf(deviceId, capName) {
26523
- return `${deviceId}|${capName}`;
26524
- }
26525
- nextId(deviceId, at) {
26526
- this.seq += 1;
26527
- return `${deviceId}:${at}:${this.seq}`;
26528
- }
26529
- nextCommandId(obs) {
26530
- this.seq += 1;
26531
- return `${obs.deviceId}:${obs.at}:c${this.seq}`;
26244
+ obs.outcome.then(() => write("ok"), (err) => write("failed", err instanceof Error ? err.message : String(err)));
26532
26245
  }
26533
26246
  };
26534
26247
  var DROP_LOG_DEVICES_MAX = 10;
@@ -26591,10 +26304,10 @@ var TransitionSender = class {
26591
26304
  //#endregion
26592
26305
  //#region src/builtins/device-manager/transitions/transitions-wiring.ts
26593
26306
  /**
26594
- * Starts the hub's device-transition audit (D1022): command observations and
26595
- * mirror slice changes meet in the correlator, its rows ride a bounded queue to
26596
- * device-history. Everything here is best-effort telemetry (D8): a failure
26597
- * costs rows, never a command or a mirror write.
26307
+ * Starts the hub's device command audit (D1022, D1084): command observations meet
26308
+ * the recorder, its rows ride a bounded queue to device-history. Everything here is
26309
+ * best-effort telemetry (D8): a failure costs rows, never a command or a mirror
26310
+ * write.
26598
26311
  */
26599
26312
  var TRANSITIONS_FLUSH_INTERVAL_MS = 2e3;
26600
26313
  var realTicker = (fn, ms) => {
@@ -26606,7 +26319,6 @@ function inputFor(capName, method) {
26606
26319
  return def === void 0 ? void 0 : require_capability_definition.expandCapMethods(def)[method]?.input;
26607
26320
  }
26608
26321
  function startDeviceTransitions(deps) {
26609
- const now = deps.now ?? Date.now;
26610
26322
  const ticker = deps.ticker ?? realTicker;
26611
26323
  const sender = new TransitionSender({
26612
26324
  send: (batch) => deps.record(batch),
@@ -26615,7 +26327,7 @@ function startDeviceTransitions(deps) {
26615
26327
  const announce = (row) => {
26616
26328
  if (deps.onCommandSettled === void 0 || row.command === void 0) return;
26617
26329
  if (row.outcome === "device") return;
26618
- const action = require_core_blocks_cap.vocabActionIdFor(row.capName, row.command.method, row.command.args);
26330
+ const action = require_action_index.vocabActionIdFor(row.capName, row.command.method, row.command.args);
26619
26331
  if (action === void 0) {
26620
26332
  deps.logger.debug(`device-transitions: ${row.capName}.${row.command.method} names no single vocabulary action; not announced`, { tags: { deviceId: row.deviceId } });
26621
26333
  return;
@@ -26629,11 +26341,10 @@ function startDeviceTransitions(deps) {
26629
26341
  at: row.at
26630
26342
  });
26631
26343
  } catch (err) {
26632
- deps.logger.warn(`device-transitions: announcing a settled ${row.capName}.${row.command.method} failed: ${err instanceof Error ? err.message : String(err)}`, { tags: { deviceId: row.deviceId } });
26344
+ deps.logger.warn(`device-transitions: announcing a completed ${row.capName}.${row.command.method} failed: ${err instanceof Error ? err.message : String(err)}`, { tags: { deviceId: row.deviceId } });
26633
26345
  }
26634
26346
  };
26635
- const correlator = new TransitionCorrelator({
26636
- now,
26347
+ const recorder = new CommandRecorder({
26637
26348
  logger: deps.logger,
26638
26349
  currentSlice: (deviceId, capName) => deps.mirror.currentSlice(deviceId, capName),
26639
26350
  emit: (row) => {
@@ -26642,36 +26353,23 @@ function startDeviceTransitions(deps) {
26642
26353
  },
26643
26354
  prepareArgs: createCommandArgsPreparer(inputFor)
26644
26355
  });
26645
- deps.mirror.setTransitionTap((deviceId, capName, prior, slice) => {
26646
- try {
26647
- correlator.onSliceChange(deviceId, capName, prior, slice);
26648
- } catch (err) {
26649
- deps.logger.error(`device-transitions: correlating a ${capName} change failed: ${err instanceof Error ? err.message : String(err)}`, { tags: { deviceId } });
26650
- }
26651
- });
26652
26356
  const unsubscribe = getCommandObserverRegistry().subscribe((obs) => {
26653
- if (!isCommand$2(obs.capName, obs.method)) return;
26357
+ if (!require_command_catalog.isCommand(obs.capName, obs.method)) return;
26654
26358
  try {
26655
- correlator.recordCommand(obs);
26359
+ recorder.recordCommand(obs);
26656
26360
  } catch (err) {
26657
26361
  deps.logger.error(`device-transitions: recording a ${obs.capName}.${obs.method} command failed: ${err instanceof Error ? err.message : String(err)}`, { tags: { deviceId: obs.deviceId } });
26658
26362
  }
26659
26363
  });
26660
26364
  const stopTicker = ticker(() => {
26661
- correlator.sweep();
26662
26365
  sender.flush();
26663
26366
  }, TRANSITIONS_FLUSH_INTERVAL_MS);
26664
- return {
26665
- forgetDevice: (deviceId) => correlator.forgetDevice(deviceId),
26666
- stop: async () => {
26667
- unsubscribe();
26668
- deps.mirror.setTransitionTap(null);
26669
- stopTicker();
26670
- correlator.flush();
26671
- await sender.flush();
26672
- sender.abandon();
26673
- }
26674
- };
26367
+ return { stop: async () => {
26368
+ unsubscribe();
26369
+ stopTicker();
26370
+ await sender.flush();
26371
+ sender.abandon();
26372
+ } };
26675
26373
  }
26676
26374
  //#endregion
26677
26375
  //#region src/builtins/device-manager/field-claims-index.ts
@@ -27249,7 +26947,6 @@ var DeviceManagerAddon = class extends require_base_addon.BaseAddon {
27249
26947
  holdMirrorWrites: (deviceIds, settings) => this.stateMirror.holdDiskWrites(deviceIds, settings),
27250
26948
  mirrorOwnedCaps: (deviceId) => this.stateMirror.ownedCaps(deviceId),
27251
26949
  forgetMirrorDevice: (deviceId) => {
27252
- this.transitions?.forgetDevice(deviceId);
27253
26950
  return this.stateMirror.forgetDevice(deviceId);
27254
26951
  },
27255
26952
  resolveDeviceOnline: (deviceId, fallbackOnline) => this.stateMirror.resolveDeviceOnline(deviceId, fallbackOnline),
@@ -27678,6 +27375,7 @@ var DeviceManagerAddon = class extends require_base_addon.BaseAddon {
27678
27375
  confirmIdentityLink: ({ linkId }) => identityLinks.confirm(linkId),
27679
27376
  dismissIdentityLink: ({ linkId }) => identityLinks.dismiss(linkId),
27680
27377
  unlinkIdentity: ({ linkId }) => identityLinks.unlink(linkId),
27378
+ relinkIdentity: ({ linkId }) => identityLinks.relink(linkId),
27681
27379
  getRoleDisplayDefaults: (input) => getRoleDisplayDefaults(pctx, input),
27682
27380
  setRoleDisplayDefaults: (input) => setRoleDisplayDefaults(pctx, input),
27683
27381
  applyInitialMeta: (input) => applyInitialMeta(pctx, input),