@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
@@ -1,25 +1,27 @@
1
- import { E as deviceStatusCapability, T as DeviceStatusSchema } from "../../stream-catalog.cap-D1Hy19Yc.mjs";
2
- import { b as EventCategory$1, g as WELL_KNOWN_TAB_MAP, n as secretTreeFromPaths, o as resolveSecretMarkers, s as transformSecretWrite, t as BaseAddon } from "../../base-addon-Md14i7pe.mjs";
1
+ import { E as deviceStatusCapability, T as DeviceStatusSchema } from "../../stream-catalog.cap-DVniDdRD.mjs";
2
+ import { b as EventCategory$1, g as WELL_KNOWN_TAB_MAP, n as secretTreeFromPaths, o as resolveSecretMarkers, s as transformSecretWrite, t as BaseAddon } from "../../base-addon-BcS6r1cT.mjs";
3
3
  import { B as SECRET_CLEAR, G as isSecretMarkerLike, H as isSecretClear, W as isSecretMarker, X as isKeychainStoredField, Z as errMsg$1, q as toSecretFieldView } from "../../scoped-settings-DVWUIP7Z.mjs";
4
- import { Jn as ExportNameRefusedError, _n as deviceStateCapability, b as workloadTransition, c as kebabToCamel, fn as PUSH_CONFIRM_WINDOW_MS, g as WorkloadStateSchema, gn as FieldClaimSchema, h as WORKLOAD_TRANSITION_CATEGORY, hn as FieldClaimModeSchema, m as ALL_CAPABILITY_DEFINITIONS, mn as effectiveRefreshIntervalMs, n as renameCompositionBlock, pn as commandBurstOffsets, t as composedBlockIdOf, v as isWorkloadSettled, vn as deviceExtensionCapability, y as workloadCapability, yn as EXTENSION_SLOTS } from "../../rename-composition-block-DWUkrazx.mjs";
4
+ import { Jn as ExportNameRefusedError, _n as deviceStateCapability, b as workloadTransition, c as kebabToCamel, fn as PUSH_CONFIRM_WINDOW_MS, g as WorkloadStateSchema, gn as FieldClaimSchema, h as WORKLOAD_TRANSITION_CATEGORY, hn as FieldClaimModeSchema, m as ALL_CAPABILITY_DEFINITIONS, mn as effectiveRefreshIntervalMs, n as renameCompositionBlock, pn as commandBurstOffsets, t as composedBlockIdOf, v as isWorkloadSettled, vn as deviceExtensionCapability, y as workloadCapability, yn as EXTENSION_SLOTS } from "../../rename-composition-block-Cdh-dRmY.mjs";
5
5
  import { t as userError } from "../../camstack-error-viZYfcj9.mjs";
6
6
  import { a as expandCapMethods$1, s as isDeviceConfigCap } from "../../capability-definition-C1TLUVJR.mjs";
7
7
  import { t as collectZodSecretPaths$1 } from "../../zod-secret-zY4nM61M.mjs";
8
- import { _ as resolveTemplateRef, a as deviceManagerCapability, d as siteZoneKey, f as DEVICE_TEMPLATE_FILTERS, g as DEVICE_TEMPLATE_VALUES_CAP, l as identityLinkId, m as DEVICE_TEMPLATE_MAX_OUTPUT, p as DEVICE_TEMPLATE_MAX_LENGTH, u as identityLinkSidesRefusal, v as checkDeviceAlias, y as generateDeviceAlias } from "../../device-manager.cap-DIBK62-r.mjs";
8
+ import { _ as resolveTemplateRef, a as deviceManagerCapability, d as siteZoneKey, f as DEVICE_TEMPLATE_FILTERS, g as DEVICE_TEMPLATE_VALUES_CAP, l as identityLinkId, m as DEVICE_TEMPLATE_MAX_OUTPUT, p as DEVICE_TEMPLATE_MAX_LENGTH, u as identityLinkSidesRefusal, v as checkDeviceAlias, y as generateDeviceAlias } from "../../device-manager.cap-eYrj1Ezp.mjs";
9
9
  import { a as isEmptyIdentifiers, c as sameIdentifiers, i as identifierStrength, l as CAMERA_SWITCH_ORDER, o as mergeIdentifiers, r as DeviceIdentifiersSchema, t as DEVICE_IDENTIFIER_KEYS } from "../../device-identifiers-iSuQCKmK.mjs";
10
10
  import { d as canonicalIconKey, o as normalizeTags } from "../../tag-uZBAq6ox.mjs";
11
- import { n as DeviceRole, r as DeviceType$1, t as DeviceFeature } from "../../device-type-DgEvK3ch.mjs";
12
- import { n as capAppliesToDeviceKind } from "../../device-kind-BJ2pfsjw.mjs";
13
- import { $ as CAP_RUNTIME_FIELD_UNITS, Qt as enumerateSchemaFields, Zt as enumerateItemArrayFields, fn as actionEffect, gn as vocabActionIdFor, hn as findVocabAction, pn as allVocabActions, vn as CAP_VOCABULARY_BY_NAME } from "../../core-blocks.cap-DDECcMeI.mjs";
11
+ import { n as DeviceRole, r as DeviceType$1, t as DeviceFeature } from "../../device-type-TUGqGmaI.mjs";
12
+ import { n as capAppliesToDeviceKind } from "../../device-kind-C37Ra2wd.mjs";
13
+ import { c as CAP_VOCABULARY_BY_NAME, o as vocabActionIdFor } from "../../action-index-B1fgpQBt.mjs";
14
14
  import { u as locationIconKey } from "../../addon-settings.cap-CZ4MC7ha.mjs";
15
- import "../../error.cap-DCwbIGEF.mjs";
15
+ import { $ as CAP_RUNTIME_FIELD_UNITS, Xt as enumerateSchemaFields, Yt as enumerateItemArrayFields } from "../../core-blocks.cap-DLkEfV5b.mjs";
16
+ import "../../compile-OBMHlqD-.mjs";
16
17
  import { a as normalizeUnit, r as extractSourceInfoFromMetadata } from "../../source-info-DGB7SdB_.mjs";
17
- import { r as ConditionMirror, t as loadPrefixed } from "../../prefix-walk-BhT0ZoKl.mjs";
18
+ import { r as ConditionMirror, t as loadPrefixed } from "../../prefix-walk-Mtij0NNT.mjs";
19
+ import { a as effectConditionHolds, i as commandHoldMs, n as commandEffect, o as isCommand$1, r as commandEffects, s as resolveSideEffect } from "../../command-catalog-xAeqxbZk.mjs";
18
20
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
19
21
  import { a as redactLogText, i as redactLogMeta, n as isSecretArgumentKey } from "../../log-redactor-XLDrPzOi.mjs";
20
22
  import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
21
23
  import { n as purgeRetiredSettingsRows } from "../../retired-settings-keys-u6xQA6r7.mjs";
22
- import { a as MigrationRefusedError, i as deviceManagerRecordKinds, n as DeviceRowStore, r as deviceRowBackendOf } from "../../device-row-store-C-_R-h1Z.mjs";
24
+ import { a as MigrationRefusedError, i as deviceManagerRecordKinds, n as DeviceRowStore, r as deviceRowBackendOf } from "../../device-row-store-CTocYKqC.mjs";
23
25
  import { n as isRenderResponse, r as analyzeTemplate } from "../../template-protocol-SgPDx3Hw.mjs";
24
26
  import { s as normalizeServiceType } from "../../dns-wire-Dm3H_7ST.mjs";
25
27
  import { createRequire } from "node:module";
@@ -437,6 +439,9 @@ function createDeviceExtensionProvider(options) {
437
439
  var CONTAINER_PRIMARY_CHILD_RULES = [{
438
440
  deviceType: DeviceType$1.HeatPump,
439
441
  primary: "self"
442
+ }, {
443
+ deviceType: DeviceType$1.Vehicle,
444
+ primary: "self"
440
445
  }];
441
446
  /** The declaration of a container read from its meta, or undefined when it declared none. */
442
447
  function primaryChildPreferenceOf(container) {
@@ -2145,6 +2150,13 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
2145
2150
  access: "view",
2146
2151
  role: "admin"
2147
2152
  },
2153
+ "coreBlocks.listTemplateInstances": {
2154
+ capName: "core-blocks",
2155
+ capScope: "system",
2156
+ addonId: null,
2157
+ access: "view",
2158
+ role: "admin"
2159
+ },
2148
2160
  "coreBlocks.migrateCapLinks": {
2149
2161
  capName: "core-blocks",
2150
2162
  capScope: "system",
@@ -3286,6 +3298,13 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
3286
3298
  access: "create",
3287
3299
  role: "admin"
3288
3300
  },
3301
+ "deviceManager.relinkIdentity": {
3302
+ capName: "device-manager",
3303
+ capScope: "system",
3304
+ addonId: null,
3305
+ access: "create",
3306
+ role: "admin"
3307
+ },
3289
3308
  "deviceManager.remove": {
3290
3309
  capName: "device-manager",
3291
3310
  capScope: "system",
@@ -5274,6 +5293,13 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
5274
5293
  access: "create",
5275
5294
  role: "admin"
5276
5295
  },
5296
+ "location.getStatus": {
5297
+ capName: "location",
5298
+ capScope: "device",
5299
+ addonId: null,
5300
+ access: "view",
5301
+ role: "viewer"
5302
+ },
5277
5303
  "lockControl.getStatus": {
5278
5304
  capName: "lock-control",
5279
5305
  capScope: "device",
@@ -9082,6 +9108,13 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
9082
9108
  access: "create",
9083
9109
  role: "admin"
9084
9110
  },
9111
+ "retentionSource.listRetentionKnobs": {
9112
+ capName: "retention-source",
9113
+ capScope: "system",
9114
+ addonId: null,
9115
+ access: "view",
9116
+ role: "admin"
9117
+ },
9085
9118
  "runningState.getStatus": {
9086
9119
  capName: "running-state",
9087
9120
  capScope: "device",
@@ -11161,6 +11194,20 @@ var METHOD_ACCESS_MAP = /* @__PURE__ */ Object.freeze({
11161
11194
  access: "create",
11162
11195
  role: "admin"
11163
11196
  },
11197
+ "vehicle.getStatus": {
11198
+ capName: "vehicle",
11199
+ capScope: "device",
11200
+ addonId: null,
11201
+ access: "view",
11202
+ role: "viewer"
11203
+ },
11204
+ "vehicle.requestRefresh": {
11205
+ capName: "vehicle",
11206
+ capScope: "device",
11207
+ addonId: null,
11208
+ access: "create",
11209
+ role: "admin"
11210
+ },
11164
11211
  "vibration.getStatus": {
11165
11212
  capName: "vibration",
11166
11213
  capScope: "device",
@@ -11565,173 +11612,6 @@ function deviceOffersActions(bindings, actionIds, mode = "any", deviceType) {
11565
11612
  return mode === "all" ? actionIds.every((id) => offered.has(id)) : actionIds.some((id) => offered.has(id));
11566
11613
  }
11567
11614
  //#endregion
11568
- //#region ../types/dist/esm/device/cap-vocabulary/command-catalog.mjs
11569
- /**
11570
- * The command catalogue (D1022): which cap methods are COMMANDS - the
11571
- * vocabulary actions (D920/D983) of a device-scope cap - and which status
11572
- * fields a command's effect or a boolean/enum state trigger names.
11573
- *
11574
- * Derived from the vocabulary, never kept as a second list: a method that
11575
- * becomes an action is a command with no other edit, and the spec beside this
11576
- * file fails when a device mutation is neither one nor excused. The audit in
11577
- * the hub mirror reads `auditedFields` so a slice write on a cap without any
11578
- * costs one map miss.
11579
- */
11580
- var commandKeys;
11581
- var fieldsByCap;
11582
- var NO_FIELDS = /* @__PURE__ */ new Set();
11583
- function commands() {
11584
- commandKeys ??= new Set(allVocabActions().map(({ cap, action }) => `${cap}.${action.method}`));
11585
- return commandKeys;
11586
- }
11587
- function buildAuditedFields() {
11588
- const byCap = /* @__PURE__ */ new Map();
11589
- const add = (cap, field) => {
11590
- const set = byCap.get(cap) ?? /* @__PURE__ */ new Set();
11591
- set.add(field);
11592
- byCap.set(cap, set);
11593
- };
11594
- for (const { cap, action } of allVocabActions()) {
11595
- if (action.effect !== void 0) add(cap, action.effect.field);
11596
- for (const side of action.sideEffects ?? []) add(cap, side.field);
11597
- }
11598
- for (const [cap, entry] of Object.entries(CAP_VOCABULARY_BY_NAME)) {
11599
- if (entry.scope !== "device") continue;
11600
- for (const trigger of entry.state ?? []) if (trigger.kind === "boolean" || trigger.kind === "enum") add(cap, trigger.field);
11601
- }
11602
- return byCap;
11603
- }
11604
- /** Is `cap.method` a vocabulary action of a device-scope cap? */
11605
- function isCommand$1(cap, method) {
11606
- return commands().has(`${cap}.${method}`);
11607
- }
11608
- /**
11609
- * The state the command `cap.method(args)` leads to, or `null` when it leads
11610
- * to none (toggle, press, stop), is not a command, or the argument carrying
11611
- * the value is missing.
11612
- */
11613
- function commandEffect(cap, method, args) {
11614
- const actionId = vocabActionIdFor(cap, method, args);
11615
- if (actionId === void 0) return null;
11616
- const effect = actionEffect(actionId, args);
11617
- return effect === null ? null : {
11618
- field: effect.field,
11619
- value: effect.value
11620
- };
11621
- }
11622
- /** The status fields of `cap` whose changes are recorded as transitions. */
11623
- function auditedFields(cap) {
11624
- fieldsByCap ??= buildAuditedFields();
11625
- return fieldsByCap.get(cap) ?? NO_FIELDS;
11626
- }
11627
- /** Does `slice` meet `when`? A field the slice lacks is in no list. */
11628
- function effectConditionHolds(when, slice) {
11629
- if (when === void 0) return true;
11630
- const raw = slice?.[when.field];
11631
- const value = typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean" ? raw : void 0;
11632
- if ("in" in when) return value !== void 0 && when.in.includes(value);
11633
- return value === void 0 || !when.notIn.includes(value);
11634
- }
11635
- /** The step of the number open arg `key`, when the action offers one. */
11636
- function stepOf(openArgs, key) {
11637
- const offer = openArgs?.find((a) => a.key === key)?.offer;
11638
- return offer?.kind === "number" && offer.step !== void 0 && offer.step > 0 ? offer.step : void 0;
11639
- }
11640
- /**
11641
- * One side effect resolved against the args and the slice the command acts
11642
- * on: `null` when the arg carrying its value is missing, or a `negate` names a
11643
- * field the slice holds no boolean in. `openArgs` lends a copied number its
11644
- * step as the tolerance.
11645
- */
11646
- function resolveSideEffect(side, args, shown, openArgs) {
11647
- if ("value" in side) return {
11648
- field: side.field,
11649
- value: side.value
11650
- };
11651
- if ("negate" in side) {
11652
- const raw = shown?.[side.field];
11653
- return typeof raw === "boolean" ? {
11654
- field: side.field,
11655
- value: !raw
11656
- } : null;
11657
- }
11658
- const raw = args?.[side.fromArg];
11659
- if (typeof raw === "string" || typeof raw === "boolean") return {
11660
- field: side.field,
11661
- value: raw
11662
- };
11663
- if (typeof raw === "number") {
11664
- const scale = side.scale ?? 1;
11665
- const step = stepOf(openArgs, side.fromArg);
11666
- return step === void 0 ? {
11667
- field: side.field,
11668
- value: raw * scale
11669
- } : {
11670
- field: side.field,
11671
- value: raw * scale,
11672
- tolerance: step * scale
11673
- };
11674
- }
11675
- return null;
11676
- }
11677
- /**
11678
- * The hold limit the vocabulary declares for `cap.method(args)` (its action's
11679
- * `hold.holdMs`), or `undefined` for the default.
11680
- */
11681
- function commandHoldMs(cap, method, args) {
11682
- return holdFor(cap, method, args)?.holdMs;
11683
- }
11684
- /**
11685
- * The hold the vocabulary declares for `cap.method(args)`: the matched
11686
- * action's, or — when several actions share the method and the args cannot
11687
- * tell them apart (`petFeeder.feed` / `feedHoppers`) — the one they all
11688
- * declare alike. Different holds on such actions resolve to none.
11689
- */
11690
- function holdFor(cap, method, args) {
11691
- const actionId = vocabActionIdFor(cap, method, args);
11692
- if (actionId !== void 0) return findVocabAction(actionId)?.action.hold;
11693
- const holds = allVocabActions().filter(({ cap: c, action }) => c === cap && action.method === method).map(({ action }) => action.hold);
11694
- const first = holds[0];
11695
- if (first === void 0) return void 0;
11696
- const key = JSON.stringify(first);
11697
- return holds.every((h) => JSON.stringify(h) === key) ? first : void 0;
11698
- }
11699
- /**
11700
- * EVERY state the command `cap.method(args)` leads to (D1061): its `effect`
11701
- * first, then each side effect whose condition holds on `current` (the cap's
11702
- * slice the device reported when the command arrived). Empty when it leads to
11703
- * none. One field is named once — the first entry for it wins. A `negate`
11704
- * side effect flips what `shown` (the slice the person saw, held values
11705
- * included) holds, so a second toggle before the first is confirmed undoes it.
11706
- * An action that declares `hold.effects` is held as THOSE instead (a lock
11707
- * holds `locking`, not `locked`).
11708
- */
11709
- function commandEffects(cap, method, args, current, shown = current) {
11710
- const out = [];
11711
- const hold = holdFor(cap, method, args);
11712
- if (hold?.effects !== void 0) {
11713
- for (const entry of hold.effects) {
11714
- if (!effectConditionHolds(entry.when, current)) continue;
11715
- const resolved = resolveSideEffect(entry, args, shown);
11716
- if (resolved !== null && !out.some((e) => e.field === resolved.field)) out.push(resolved);
11717
- }
11718
- return out;
11719
- }
11720
- const actionId = vocabActionIdFor(cap, method, args);
11721
- if (actionId === void 0) return [];
11722
- const action = findVocabAction(actionId)?.action;
11723
- if (action?.effect !== void 0) {
11724
- const primary = resolveSideEffect(action.effect, args, shown, action.openArgs);
11725
- if (primary !== null) out.push(primary);
11726
- }
11727
- for (const side of action?.sideEffects ?? []) {
11728
- if (!effectConditionHolds(side.when, current)) continue;
11729
- const resolved = resolveSideEffect(side, args, shown, action?.openArgs);
11730
- if (resolved !== null && !out.some((e) => e.field === resolved.field)) out.push(resolved);
11731
- }
11732
- return out;
11733
- }
11734
- //#endregion
11735
11615
  //#region ../types/dist/esm/device/device-feature-requirements.mjs
11736
11616
  function bound(cap, methods = [], authority = "reported") {
11737
11617
  return {
@@ -11965,6 +11845,7 @@ var CAP_NAMES_WITH_STATUS = [
11965
11845
  "image-settings",
11966
11846
  "intercom",
11967
11847
  "lawn-mower-control",
11848
+ "location",
11968
11849
  "lock-control",
11969
11850
  "low-power-sleep",
11970
11851
  "media-player",
@@ -12005,6 +11886,7 @@ var CAP_NAMES_WITH_STATUS = [
12005
11886
  "update",
12006
11887
  "vacuum-control",
12007
11888
  "valve",
11889
+ "vehicle",
12008
11890
  "vibration",
12009
11891
  "water-heater",
12010
11892
  "weather",
@@ -12015,7 +11897,7 @@ var CAP_NAMES_WITH_STATUS = [
12015
11897
  //#region ../types/dist/esm/generated/runtime-state-durability.mjs
12016
11898
  /**
12017
11899
  * Per-cap runtime-state policy, projected from every `*.cap.ts` that declares
12018
- * `runtimeState`. 88 caps: 44 `restored`, 44 `session`.
11900
+ * `runtimeState`. 90 caps: 46 `restored`, 44 `session`.
12019
11901
  *
12020
11902
  * A cap absent from this map has no runtime-state slice at all. A cap PRESENT
12021
11903
  * with `durability: 'session'` has one and has decided not to keep it.
@@ -12191,6 +12073,14 @@ var RUNTIME_STATE_POLICY = {
12191
12073
  durability: "session",
12192
12074
  volatileFields: []
12193
12075
  },
12076
+ "location": {
12077
+ durability: "restored",
12078
+ volatileFields: [
12079
+ "fixAt",
12080
+ "lastChangedAt",
12081
+ "lastFetchedAt"
12082
+ ]
12083
+ },
12194
12084
  "lock-control": {
12195
12085
  durability: "restored",
12196
12086
  volatileFields: ["lastChangedAt"]
@@ -12343,6 +12233,14 @@ var RUNTIME_STATE_POLICY = {
12343
12233
  durability: "session",
12344
12234
  volatileFields: []
12345
12235
  },
12236
+ "vehicle": {
12237
+ durability: "restored",
12238
+ volatileFields: [
12239
+ "reportedAt",
12240
+ "lastChangedAt",
12241
+ "lastFetchedAt"
12242
+ ]
12243
+ },
12346
12244
  "vibration": {
12347
12245
  durability: "restored",
12348
12246
  volatileFields: ["lastChangedAt"]
@@ -21519,6 +21417,7 @@ async function writeDeclaredIdentity(pctx, input, column) {
21519
21417
  * | `proposal` candidate, no row | `proposed`, no event |
21520
21418
  * | `proposed` row, candidate now `auto` | `linked` / `auto`, created |
21521
21419
  * | `dismissed` row | stays dismissed: nothing re-proposes it |
21420
+ * | `dismissed` row, operator Relink | `linked` / `operator`, created (evidence must still hold) |
21522
21421
  * | `linked`/`auto` row, evidence gone | row deleted, `identity-link.lost` evidence-gone |
21523
21422
  * | `linked`/`operator` row, evidence gone | kept, flagged `evidenceGone`, `lost` evidence-gone |
21524
21423
  * | `linked`/`operator` flagged, evidence back | flag cleared, `identity-link.created` |
@@ -21619,6 +21518,33 @@ var IdentityLinkReconciler = class {
21619
21518
  return next;
21620
21519
  });
21621
21520
  }
21521
+ /** Undo a dismissal: a `dismissed` link acts again, as the operator's decision.
21522
+ * Refused `evidence-gone` when the current candidates no longer declare the pair
21523
+ * (a relink of a pair nothing declares would only be flagged at the next pass). */
21524
+ relink(linkId) {
21525
+ return this.decide(linkId, "dismissed", async (link) => {
21526
+ const answer = this.deps.candidates();
21527
+ if (!(answer.status === "answered" && answer.candidates.some((c) => identityLinkId(c.kind, c.a, c.b) === link.id))) return {
21528
+ ok: false,
21529
+ reason: "evidence-gone",
21530
+ message: `identity link ${linkId} cannot be relinked: its devices no longer declare the identifiers that matched them`
21531
+ };
21532
+ const { evidenceGone: _dropped, ...rest } = link;
21533
+ const next = {
21534
+ ...rest,
21535
+ state: "linked",
21536
+ origin: "operator",
21537
+ decidedAt: this.now()
21538
+ };
21539
+ await this.deps.store.put(next);
21540
+ this.log("identity link relinked by the operator", next);
21541
+ this.deps.emit(EventCategory$1.IdentityLinkCreated, payloadOf(next));
21542
+ return {
21543
+ ok: true,
21544
+ link: next
21545
+ };
21546
+ });
21547
+ }
21622
21548
  /** The `identity-links` removal step (D864): every link naming the device goes. */
21623
21549
  removeDevice(deviceId) {
21624
21550
  return this.serialized(async () => {
@@ -21762,9 +21688,10 @@ var IdentityLinkReconciler = class {
21762
21688
  reason: "wrong-state",
21763
21689
  message: `identity link ${linkId} is ${link.state}, not ${from}`
21764
21690
  };
21765
- return {
21691
+ const applied = await apply(link);
21692
+ return "ok" in applied ? applied : {
21766
21693
  ok: true,
21767
- link: await apply(link)
21694
+ link: applied
21768
21695
  };
21769
21696
  });
21770
21697
  }
@@ -22030,8 +21957,8 @@ var DeviceIdentityIndex = class {
22030
21957
  * {@link candidates}, plus each device's attached identifiers paired with
22031
21958
  * another integration's device identifiers (`poe-power`).
22032
21959
  *
22033
- * One link per port: when a port's attached keys reach several devices, or a
22034
- * device is reached by several ports, every one of those attached pairs is
21960
+ * A port reaching several devices (a PoE splitter) links every one of them. A
21961
+ * device reached by several ports is ambiguous: each of those attached pairs is
22035
21962
  * graded a `proposal` at most — the operator picks.
22036
21963
  *
22037
21964
  * Freshness first: a pair whose shared keys the port only RETAINS (declared
@@ -22075,8 +22002,9 @@ var DeviceIdentityIndex = class {
22075
22002
  const target = this.devices.get(id);
22076
22003
  if (target === void 0 || id === port.deviceId || sameIntegration(port, target)) continue;
22077
22004
  const keys = sharedKeys(port.attachedIdentifiers, target.identifiers);
22078
- const confidence = classifyIdentityMatch(keys);
22079
- if (confidence === null) continue;
22005
+ const graded = classifyIdentityMatch(keys);
22006
+ if (graded === null) continue;
22007
+ const confidence = (port.attachedIdentifiers.mac?.length ?? 0) > 1 && port.attachedIdentifiers.ip === void 0 && keys.some((k) => k.key === "mac") ? "auto" : graded;
22080
22008
  const retained = new Set(port.attachedRetained);
22081
22009
  all.push({
22082
22010
  pair: {
@@ -22093,13 +22021,9 @@ var DeviceIdentityIndex = class {
22093
22021
  }
22094
22022
  const freshlyReached = new Set(all.filter((p) => p.fresh).map((p) => p.pair.b.deviceId));
22095
22023
  const pairs = all.filter((p) => p.fresh || !freshlyReached.has(p.pair.b.deviceId)).map((p) => p.pair);
22096
- const perPort = /* @__PURE__ */ new Map();
22097
22024
  const perTarget = /* @__PURE__ */ new Map();
22098
- for (const p of pairs) {
22099
- perPort.set(p.a.deviceId, (perPort.get(p.a.deviceId) ?? 0) + 1);
22100
- perTarget.set(p.b.deviceId, (perTarget.get(p.b.deviceId) ?? 0) + 1);
22101
- }
22102
- return pairs.map((p) => (perPort.get(p.a.deviceId) ?? 0) > 1 || (perTarget.get(p.b.deviceId) ?? 0) > 1 ? {
22025
+ for (const p of pairs) perTarget.set(p.b.deviceId, (perTarget.get(p.b.deviceId) ?? 0) + 1);
22026
+ return pairs.map((p) => (perTarget.get(p.b.deviceId) ?? 0) > 1 ? {
22103
22027
  ...p,
22104
22028
  confidence: "proposal"
22105
22029
  } : p);
@@ -24360,7 +24284,6 @@ function errorMessage$2(err) {
24360
24284
  var DeviceStateMirror = class {
24361
24285
  ctx;
24362
24286
  policyFor;
24363
- transitionTap = null;
24364
24287
  reportTap = null;
24365
24288
  /**
24366
24289
  * Hub-side mirror of every device's cap-keyed NATIVE runtime state — what the
@@ -24418,10 +24341,6 @@ var DeviceStateMirror = class {
24418
24341
  readRowFirst: (deviceId, settings) => this.ensureRowRead(deviceId, settings)
24419
24342
  });
24420
24343
  }
24421
- /** Set once by the device-manager: told, after the mirror stored it, of every native slice that actually changed (D1022). */
24422
- setTransitionTap(tap) {
24423
- this.transitionTap = tap;
24424
- }
24425
24344
  /** Set once by the device-manager: told of every native slice reported, before the no-change check (D1062). */
24426
24345
  setReportTap(tap) {
24427
24346
  this.reportTap = tap;
@@ -24481,7 +24400,6 @@ var DeviceStateMirror = class {
24481
24400
  if (prior && shallowEqual(prior, written)) return false;
24482
24401
  slice = written;
24483
24402
  perCap.set(capName, { ...slice });
24484
- this.transitionTap?.(deviceId, capName, prior, slice);
24485
24403
  const claim = this.claims.claim(deviceId, capName);
24486
24404
  if (claim) {
24487
24405
  if (claim.mode === "replace") this.emitNativeShadow(deviceId, capName, { ...slice });
@@ -26251,31 +26169,22 @@ function createCommandArgsPreparer(inputFor) {
26251
26169
  };
26252
26170
  }
26253
26171
  //#endregion
26254
- //#region src/builtins/device-manager/transitions/transition-correlator.ts
26172
+ //#region src/builtins/device-manager/transitions/command-recorder.ts
26255
26173
  /**
26256
- * The correlator of the device transition audit (D1022).
26174
+ * The command recorder of the device audit (D1022, D1084).
26257
26175
  *
26258
- * A command (what the kernel saw leave its caller) and a slice change (what the
26259
- * hub mirror saw land) are two facts about one event. This module pairs them:
26260
- * a change of an audited field is attributed to the newest pending command whose
26261
- * effect names that field and value, else to a command with no effect (toggle,
26262
- * press), else to the device itself. A command whose target already held is
26263
- * `already`; one that produced nothing inside its window is `unconfirmed`; one
26264
- * the caller saw throw is `failed`.
26176
+ * A command is what the kernel saw leave its caller. It is written as ONE row,
26177
+ * when the call completes: `ok` when it returned, `failed` when the caller saw it
26178
+ * throw. Nothing waits for the device to obey and nothing is matched to a slice
26179
+ * change: the change, when the device reports one, is read back from device-history
26180
+ * on the Interactions read, beside the command row.
26265
26181
  *
26266
- * Pure and clock-injected. It reads memory only (D49): the pending ring and the
26267
- * mirror's current slice. Nothing here does I/O, so a state write never waits on
26268
- * the audit; what it produces is handed to `emit`, whose queue is bounded.
26182
+ * Pure and clock-injected; it reads memory only (D49): the mirror's current slice,
26183
+ * for the `from` value of a command that names an effect. What it produces is
26184
+ * handed to `emit`, whose queue is bounded.
26269
26185
  */
26270
- /** How long a command waits for the change it should cause. */
26271
- var COMMAND_MATCH_WINDOW_MS = 3e4;
26272
26186
  /** Longest error text a row keeps. */
26273
26187
  var ERROR_MAX_CHARS = 300;
26274
- function sameValue(a, b) {
26275
- if (Object.is(a, b)) return true;
26276
- if (a === null || b === null || typeof a !== "object" || typeof b !== "object") return false;
26277
- return JSON.stringify(a) === JSON.stringify(b);
26278
- }
26279
26188
  /** A status value in the shape a transition stores: unknown is `null` (D393), an array is wrapped. */
26280
26189
  function toTransitionValue(value) {
26281
26190
  if (value === void 0 || value === null) return null;
@@ -26284,245 +26193,49 @@ function toTransitionValue(value) {
26284
26193
  if (typeof value === "object") return Object.fromEntries(Object.entries(value));
26285
26194
  return String(value);
26286
26195
  }
26287
- var TransitionCorrelator = class {
26196
+ var CommandRecorder = class {
26288
26197
  deps;
26289
- pending = /* @__PURE__ */ new Map();
26290
26198
  seq = 0;
26291
- held = /* @__PURE__ */ new Map();
26292
26199
  constructor(deps) {
26293
26200
  this.deps = deps;
26294
26201
  }
26295
- /** A command left its caller. */
26202
+ /**
26203
+ * A command left its caller. Where the seam can see the call settle (`obs.outcome`), the row is
26204
+ * written when it does; where it cannot (the UDS parent and in-process clients report only the
26205
+ * departure) the call is recorded as `ok` at once, since a throw there is not observable.
26206
+ */
26296
26207
  recordCommand(obs) {
26297
26208
  const effect = commandEffect(obs.capName, obs.method, obs.args);
26298
- const current = this.deps.currentSlice(obs.deviceId, obs.capName);
26299
- const fromAtCommand = effect === null ? null : toTransitionValue(current?.[effect.field]);
26300
- const entry = {
26301
- commandId: this.nextCommandId(obs),
26302
- obs,
26303
- effect,
26304
- expiresAt: obs.at + COMMAND_MATCH_WINDOW_MS,
26305
- fromAtCommand,
26306
- settled: false
26307
- };
26308
- if (effect !== null && current !== void 0 && Object.hasOwn(current, effect.field) && sameValue(current[effect.field], effect.value)) {
26309
- entry.settled = true;
26310
- this.emit(entry, "already", effect.field, fromAtCommand, toTransitionValue(effect.value), null);
26311
- return;
26312
- }
26313
- const key = this.keyOf(obs.deviceId, obs.capName);
26314
- const ring = this.pending.get(key) ?? [];
26315
- ring.push(entry);
26316
- while (ring.length > 8) {
26317
- const oldest = ring.shift();
26318
- if (oldest !== void 0) this.expire(oldest);
26319
- }
26320
- this.pending.set(key, ring);
26321
- obs.outcome?.catch((err) => this.fail(entry, err));
26322
- }
26323
- /** The mirror stored a new native slice for `capName` (the previous one, if any, is `prior`). */
26324
- onSliceChange(deviceId, capName, prior, slice) {
26325
- const fields = auditedFields(capName);
26326
- if (fields.size === 0) return;
26327
- const now = this.deps.now();
26328
- const changes = [];
26329
- for (const field of fields) {
26330
- const hadBefore = prior !== void 0 && Object.hasOwn(prior, field);
26331
- const has = Object.hasOwn(slice, field);
26332
- if (!hadBefore && !has) continue;
26333
- const before = hadBefore ? prior[field] : void 0;
26334
- const after = has ? slice[field] : void 0;
26335
- if (sameValue(before, after)) continue;
26336
- changes.push({
26209
+ const field = effect?.field ?? "*";
26210
+ const from = effect === null ? null : toTransitionValue(this.deps.currentSlice(obs.deviceId, obs.capName)?.[effect.field]);
26211
+ const to = effect === null ? null : toTransitionValue(effect.value);
26212
+ const write = (outcome, error) => {
26213
+ this.seq += 1;
26214
+ const commandId = `${obs.deviceId}:${obs.at}:c${this.seq}`;
26215
+ this.deps.emit({
26216
+ id: commandId,
26217
+ deviceId: obs.deviceId,
26218
+ at: obs.at,
26219
+ capName: obs.capName,
26337
26220
  field,
26338
- before,
26339
- after,
26340
- neverHeld: !hadBefore
26221
+ from,
26222
+ to,
26223
+ outcome,
26224
+ actor: obs.actor,
26225
+ command: {
26226
+ commandId,
26227
+ method: obs.method,
26228
+ args: this.deps.prepareArgs(obs.capName, obs.method, obs.args),
26229
+ requestedAt: obs.at,
26230
+ ...error !== void 0 ? { error: redactLogText(error).slice(0, ERROR_MAX_CHARS) } : {}
26231
+ }
26341
26232
  });
26342
- }
26343
- if (changes.length === 0) return;
26344
- const key = this.keyOf(deviceId, capName);
26345
- const burst = this.held.get(key) ?? {
26346
- deviceId,
26347
- capName,
26348
- fields: /* @__PURE__ */ new Map(),
26349
- firstAt: now,
26350
- lastAt: now
26351
26233
  };
26352
- burst.lastAt = now;
26353
- const claimable = this.hasLiveCommand(deviceId, capName, now);
26354
- for (const change of changes) {
26355
- const earlier = burst.fields.get(change.field);
26356
- if (change.neverHeld && earlier === void 0 && !claimable) continue;
26357
- burst.fields.set(change.field, {
26358
- before: earlier !== void 0 ? earlier.before : change.before,
26359
- after: change.after,
26360
- neverHeld: earlier !== void 0 ? earlier.neverHeld : change.neverHeld
26361
- });
26362
- }
26363
- if (burst.fields.size === 0) return;
26364
- this.held.set(key, burst);
26365
- if (this.commandMatchedBy(deviceId, capName, changes, now) !== void 0) this.flushBurst(key, burst);
26366
- }
26367
- hasLiveCommand(deviceId, capName, now) {
26368
- return (this.pending.get(this.keyOf(deviceId, capName)) ?? []).some((e) => !e.settled && e.expiresAt > now);
26369
- }
26370
- /** Write every held burst now (shutdown): a held change must not be lost (D49). */
26371
- flush() {
26372
- for (const [key, burst] of [...this.held]) this.flushBurst(key, burst);
26373
- }
26374
- /** The fields of a burst that ended somewhere other than where they started. */
26375
- netChanges(burst) {
26376
- return [...burst.fields].filter(([, f]) => !sameValue(f.before, f.after)).map(([field, f]) => ({
26377
- field,
26378
- ...f
26379
- }));
26380
- }
26381
- flushBurst(key, burst) {
26382
- this.held.delete(key);
26383
- const net = this.netChanges(burst);
26384
- const { deviceId, capName } = burst;
26385
- for (const field of burst.fields.keys()) {
26386
- if (net.some((c) => c.field === field)) continue;
26387
- this.deps.logger?.debug(`device-transitions: ${capName}.${field} went and came back inside one burst; no row`, { tags: { deviceId } });
26388
- }
26389
- const touched = [...burst.fields].map(([field, f]) => ({
26390
- field,
26391
- ...f
26392
- }));
26393
- let claimed = this.commandMatchedBy(deviceId, capName, touched, burst.lastAt);
26394
- for (const change of net) claimed = this.attribute(deviceId, capName, change.field, toTransitionValue(change.before), toTransitionValue(change.after), burst.lastAt, claimed, change.neverHeld);
26395
- const effect = claimed?.effect;
26396
- if (claimed !== void 0 && effect !== null && effect !== void 0) {
26397
- if (!net.some((c) => c.field === effect.field)) {
26398
- const before = burst.fields.get(effect.field)?.before;
26399
- this.confirmWithoutNet(key, claimed, effect.field, toTransitionValue(before), toTransitionValue(effect.value), burst.lastAt);
26400
- }
26401
- }
26402
- }
26403
- confirmWithoutNet(key, entry, field, from, to, at) {
26404
- entry.settled = true;
26405
- this.emit(entry, "confirmed", field, from, to, at - entry.obs.at, void 0, at);
26406
- this.pruneSettled(key);
26407
- }
26408
- pruneSettled(key) {
26409
- const ring = this.pending.get(key);
26410
- if (ring === void 0) return;
26411
- const rest = ring.filter((e) => !e.settled);
26412
- if (rest.length === 0) this.pending.delete(key);
26413
- else this.pending.set(key, rest);
26414
- }
26415
- flushDue(now) {
26416
- for (const [key, burst] of [...this.held]) if (now - burst.lastAt >= 5e3 || now - burst.firstAt >= 6e4) this.flushBurst(key, burst);
26417
- }
26418
- /** The newest live command whose effect one of `changes` fulfils, if any. */
26419
- commandMatchedBy(deviceId, capName, changes, now) {
26420
- 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))));
26421
- }
26422
- /** Expire every pending command past its window. Driven by the sender's tick. */
26423
- sweep() {
26424
- const now = this.deps.now();
26425
- this.flushDue(now);
26426
- for (const [key, ring] of this.pending) {
26427
- const live = [];
26428
- for (const entry of ring) {
26429
- if (entry.settled) continue;
26430
- if (entry.expiresAt <= now) this.expire(entry);
26431
- else live.push(entry);
26432
- }
26433
- if (live.length === 0) this.pending.delete(key);
26434
- else this.pending.set(key, live);
26435
- }
26436
- }
26437
- /** Commands still waiting, for a status read. */
26438
- pendingCount() {
26439
- let n = 0;
26440
- for (const ring of this.pending.values()) n += ring.filter((e) => !e.settled).length;
26441
- return n;
26442
- }
26443
- /** Forget a removed device's pending commands. */
26444
- forgetDevice(deviceId) {
26445
- const prefix = `${deviceId}|`;
26446
- for (const key of [...this.held.keys()]) {
26447
- if (!key.startsWith(prefix)) continue;
26448
- this.deps.logger?.debug(`device-transitions: device removed with a held ${key.slice(prefix.length)} burst; dropped`, { tags: { deviceId } });
26449
- this.held.delete(key);
26450
- }
26451
- for (const key of [...this.pending.keys()]) if (key.startsWith(prefix)) this.pending.delete(key);
26452
- }
26453
- attribute(deviceId, capName, field, from, to, now, claimedByThisWrite, neverHeld) {
26454
- const key = this.keyOf(deviceId, capName);
26455
- const live = (this.pending.get(key) ?? []).filter((e) => !e.settled && e.expiresAt > now);
26456
- 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);
26457
- if (matched === void 0) {
26458
- if (neverHeld) return void 0;
26459
- this.writeDevice(deviceId, capName, field, from, to, now);
26234
+ if (obs.outcome === void 0) {
26235
+ write("ok");
26460
26236
  return;
26461
26237
  }
26462
- matched.settled = true;
26463
- this.emit(matched, "confirmed", field, from, to, now - matched.obs.at, void 0, now);
26464
- this.pruneSettled(key);
26465
- return matched;
26466
- }
26467
- expire(entry) {
26468
- if (entry.settled) return;
26469
- entry.settled = true;
26470
- const field = entry.effect?.field ?? "*";
26471
- this.emit(entry, "unconfirmed", field, entry.fromAtCommand, entry.fromAtCommand, null);
26472
- }
26473
- fail(entry, err) {
26474
- if (entry.settled) return;
26475
- entry.settled = true;
26476
- const message = err instanceof Error ? err.message : String(err);
26477
- const field = entry.effect?.field ?? "*";
26478
- this.emit(entry, "failed", field, entry.fromAtCommand, entry.fromAtCommand, null, message);
26479
- }
26480
- emit(entry, outcome, field, from, to, matchedAfterMs, error, at = this.deps.now()) {
26481
- const { obs } = entry;
26482
- this.deps.emit({
26483
- id: this.nextId(obs.deviceId, at),
26484
- deviceId: obs.deviceId,
26485
- at,
26486
- capName: obs.capName,
26487
- field,
26488
- from,
26489
- to,
26490
- outcome,
26491
- actor: obs.actor,
26492
- command: {
26493
- commandId: entry.commandId,
26494
- method: obs.method,
26495
- args: this.deps.prepareArgs(obs.capName, obs.method, obs.args),
26496
- requestedAt: obs.at,
26497
- matchedAfterMs,
26498
- ...error !== void 0 ? { error: redactLogText(error).slice(0, ERROR_MAX_CHARS) } : {}
26499
- }
26500
- });
26501
- }
26502
- /** A change nobody asked for. */
26503
- writeDevice(deviceId, capName, field, from, to, at) {
26504
- this.deps.emit({
26505
- id: this.nextId(deviceId, at),
26506
- deviceId,
26507
- at,
26508
- capName,
26509
- field,
26510
- from,
26511
- to,
26512
- outcome: "device",
26513
- actor: { kind: "device" }
26514
- });
26515
- }
26516
- keyOf(deviceId, capName) {
26517
- return `${deviceId}|${capName}`;
26518
- }
26519
- nextId(deviceId, at) {
26520
- this.seq += 1;
26521
- return `${deviceId}:${at}:${this.seq}`;
26522
- }
26523
- nextCommandId(obs) {
26524
- this.seq += 1;
26525
- return `${obs.deviceId}:${obs.at}:c${this.seq}`;
26238
+ obs.outcome.then(() => write("ok"), (err) => write("failed", err instanceof Error ? err.message : String(err)));
26526
26239
  }
26527
26240
  };
26528
26241
  var DROP_LOG_DEVICES_MAX = 10;
@@ -26585,10 +26298,10 @@ var TransitionSender = class {
26585
26298
  //#endregion
26586
26299
  //#region src/builtins/device-manager/transitions/transitions-wiring.ts
26587
26300
  /**
26588
- * Starts the hub's device-transition audit (D1022): command observations and
26589
- * mirror slice changes meet in the correlator, its rows ride a bounded queue to
26590
- * device-history. Everything here is best-effort telemetry (D8): a failure
26591
- * costs rows, never a command or a mirror write.
26301
+ * Starts the hub's device command audit (D1022, D1084): command observations meet
26302
+ * the recorder, its rows ride a bounded queue to device-history. Everything here is
26303
+ * best-effort telemetry (D8): a failure costs rows, never a command or a mirror
26304
+ * write.
26592
26305
  */
26593
26306
  var TRANSITIONS_FLUSH_INTERVAL_MS = 2e3;
26594
26307
  var realTicker = (fn, ms) => {
@@ -26600,7 +26313,6 @@ function inputFor(capName, method) {
26600
26313
  return def === void 0 ? void 0 : expandCapMethods$1(def)[method]?.input;
26601
26314
  }
26602
26315
  function startDeviceTransitions(deps) {
26603
- const now = deps.now ?? Date.now;
26604
26316
  const ticker = deps.ticker ?? realTicker;
26605
26317
  const sender = new TransitionSender({
26606
26318
  send: (batch) => deps.record(batch),
@@ -26623,11 +26335,10 @@ function startDeviceTransitions(deps) {
26623
26335
  at: row.at
26624
26336
  });
26625
26337
  } catch (err) {
26626
- 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 } });
26338
+ 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 } });
26627
26339
  }
26628
26340
  };
26629
- const correlator = new TransitionCorrelator({
26630
- now,
26341
+ const recorder = new CommandRecorder({
26631
26342
  logger: deps.logger,
26632
26343
  currentSlice: (deviceId, capName) => deps.mirror.currentSlice(deviceId, capName),
26633
26344
  emit: (row) => {
@@ -26636,36 +26347,23 @@ function startDeviceTransitions(deps) {
26636
26347
  },
26637
26348
  prepareArgs: createCommandArgsPreparer(inputFor)
26638
26349
  });
26639
- deps.mirror.setTransitionTap((deviceId, capName, prior, slice) => {
26640
- try {
26641
- correlator.onSliceChange(deviceId, capName, prior, slice);
26642
- } catch (err) {
26643
- deps.logger.error(`device-transitions: correlating a ${capName} change failed: ${err instanceof Error ? err.message : String(err)}`, { tags: { deviceId } });
26644
- }
26645
- });
26646
26350
  const unsubscribe = getCommandObserverRegistry().subscribe((obs) => {
26647
26351
  if (!isCommand$1(obs.capName, obs.method)) return;
26648
26352
  try {
26649
- correlator.recordCommand(obs);
26353
+ recorder.recordCommand(obs);
26650
26354
  } catch (err) {
26651
26355
  deps.logger.error(`device-transitions: recording a ${obs.capName}.${obs.method} command failed: ${err instanceof Error ? err.message : String(err)}`, { tags: { deviceId: obs.deviceId } });
26652
26356
  }
26653
26357
  });
26654
26358
  const stopTicker = ticker(() => {
26655
- correlator.sweep();
26656
26359
  sender.flush();
26657
26360
  }, TRANSITIONS_FLUSH_INTERVAL_MS);
26658
- return {
26659
- forgetDevice: (deviceId) => correlator.forgetDevice(deviceId),
26660
- stop: async () => {
26661
- unsubscribe();
26662
- deps.mirror.setTransitionTap(null);
26663
- stopTicker();
26664
- correlator.flush();
26665
- await sender.flush();
26666
- sender.abandon();
26667
- }
26668
- };
26361
+ return { stop: async () => {
26362
+ unsubscribe();
26363
+ stopTicker();
26364
+ await sender.flush();
26365
+ sender.abandon();
26366
+ } };
26669
26367
  }
26670
26368
  //#endregion
26671
26369
  //#region src/builtins/device-manager/field-claims-index.ts
@@ -27243,7 +26941,6 @@ var DeviceManagerAddon = class extends BaseAddon {
27243
26941
  holdMirrorWrites: (deviceIds, settings) => this.stateMirror.holdDiskWrites(deviceIds, settings),
27244
26942
  mirrorOwnedCaps: (deviceId) => this.stateMirror.ownedCaps(deviceId),
27245
26943
  forgetMirrorDevice: (deviceId) => {
27246
- this.transitions?.forgetDevice(deviceId);
27247
26944
  return this.stateMirror.forgetDevice(deviceId);
27248
26945
  },
27249
26946
  resolveDeviceOnline: (deviceId, fallbackOnline) => this.stateMirror.resolveDeviceOnline(deviceId, fallbackOnline),
@@ -27672,6 +27369,7 @@ var DeviceManagerAddon = class extends BaseAddon {
27672
27369
  confirmIdentityLink: ({ linkId }) => identityLinks.confirm(linkId),
27673
27370
  dismissIdentityLink: ({ linkId }) => identityLinks.dismiss(linkId),
27674
27371
  unlinkIdentity: ({ linkId }) => identityLinks.unlink(linkId),
27372
+ relinkIdentity: ({ linkId }) => identityLinks.relink(linkId),
27675
27373
  getRoleDisplayDefaults: (input) => getRoleDisplayDefaults(pctx, input),
27676
27374
  setRoleDisplayDefaults: (input) => setRoleDisplayDefaults(pctx, input),
27677
27375
  applyInitialMeta: (input) => applyInitialMeta(pctx, input),