@camstack/server 1.2.941 → 1.2.943
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.
- package/CHANGELOG.md +20 -0
- package/dist/api/trpc/generated-cap-mounts.js +19 -1
- package/dist/api/trpc/generated-cap-routers.js +676 -596
- package/package.json +13 -11
- package/system/dist/action-index-B1fgpQBt.mjs +9925 -0
- package/system/dist/action-index-B_cLRwXJ.js +9972 -0
- package/system/dist/alert-episode-Be--PngO.mjs +64 -0
- package/system/dist/alert-episode-Bqktmt-i.js +93 -0
- package/system/dist/{base-addon-Md14i7pe.mjs → base-addon-BcS6r1cT.mjs} +20 -7
- package/system/dist/{base-addon-DD5dIfcZ.js → base-addon-CRsXtYFG.js} +20 -7
- package/system/dist/{base-device-CH8rfD9j.js → base-device-DAdWzDOl.js} +138 -34
- package/system/dist/{base-device-BcGO6LTT.mjs → base-device-DJXF5eDN.mjs} +138 -34
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alert-episode-policy.d.ts +9 -5
- package/system/dist/builtins/alerts/alerts.addon.js +30 -80
- package/system/dist/builtins/alerts/alerts.addon.mjs +18 -68
- package/system/dist/builtins/autotrack/index.js +2 -2
- package/system/dist/builtins/autotrack/index.mjs +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +9 -9
- package/system/dist/builtins/camera-grid/index.mjs +6 -6
- package/system/dist/builtins/composer/composer.addon.js +99 -99
- package/system/dist/builtins/composer/composer.addon.mjs +11 -11
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/automation-template-instances.d.ts +14 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +6 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +296 -193
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +237 -134
- package/system/dist/builtins/core-blocks/link-contributions.d.ts +2 -0
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +91 -18
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +91 -18
- package/system/dist/builtins/core-notifier/group-notification-output.d.ts +8 -16
- package/system/dist/builtins/device-history/device-history.addon.d.ts +8 -0
- package/system/dist/builtins/device-history/device-history.addon.js +580 -60
- package/system/dist/builtins/device-history/device-history.addon.mjs +569 -49
- package/system/dist/builtins/device-history/retention/device-raw-overrides.d.ts +16 -0
- package/system/dist/builtins/device-history/retention/retention-knobs.d.ts +14 -0
- package/system/dist/builtins/device-history/retention/retention.d.ts +21 -1
- package/system/dist/builtins/device-history/transitions/change-coalescing.d.ts +48 -0
- package/system/dist/builtins/device-history/transitions/derived-changes.d.ts +49 -0
- package/system/dist/builtins/device-history/transitions/history-change-port.d.ts +20 -0
- package/system/dist/builtins/device-history/transitions/transitions-service.d.ts +18 -3
- package/system/dist/builtins/device-manager/device-config-secrets.d.ts +14 -0
- package/system/dist/builtins/device-manager/device-identity-index.d.ts +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +226 -479
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +218 -471
- package/system/dist/builtins/device-manager/device-state-mirror.d.ts +0 -5
- package/system/dist/builtins/device-manager/identity-link-reconciler.d.ts +5 -0
- package/system/dist/builtins/device-manager/transitions/command-recorder.d.ts +38 -0
- package/system/dist/builtins/device-manager/transitions/transitions-wiring.d.ts +8 -9
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +2 -2
- package/system/dist/builtins/keychain/index.mjs +2 -2
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +2 -2
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/address-book.d.ts +3 -1
- package/system/dist/builtins/local-network/local-network.addon.d.ts +26 -1
- package/system/dist/builtins/local-network/local-network.addon.js +66 -11
- package/system/dist/builtins/local-network/local-network.addon.mjs +66 -11
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +4 -4
- package/system/dist/builtins/snapshot/index.mjs +4 -4
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +1 -1
- package/system/dist/builtins/system-config/system-config.addon.mjs +1 -1
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-CUZ3W0oZ.mjs → capture-engine-B2MmoNND.mjs} +1 -1
- package/system/dist/{capture-engine-mtDXEBAq.js → capture-engine-D_1IJmMs.js} +1 -1
- package/system/dist/command-catalog-C29hVOOg.js +210 -0
- package/system/dist/command-catalog-xAeqxbZk.mjs +169 -0
- package/system/dist/{error.cap-DCwbIGEF.mjs → compile-OBMHlqD-.mjs} +97 -100
- package/system/dist/{error.cap-BxLEHP6z.js → compile-SpeAhaZ6.js} +107 -116
- package/system/dist/{composition-sources-B56CU8hi.mjs → composition-sources-C327LGFn.mjs} +2 -2
- package/system/dist/{composition-sources-D_Bfwji0.js → composition-sources-Do5qM6EB.js} +17 -17
- package/system/dist/{core-blocks.cap-xt5_fK5Z.js → core-blocks.cap-CdTGUKtr.js} +194 -10110
- package/system/dist/{core-blocks.cap-DDECcMeI.mjs → core-blocks.cap-DLkEfV5b.mjs} +54 -9910
- package/system/dist/{device-kind-BJ2pfsjw.mjs → device-kind-C37Ra2wd.mjs} +4 -2
- package/system/dist/{device-kind-CsSiv_YF.js → device-kind-FMhJg8uC.js} +4 -2
- package/system/dist/{device-manager.cap-DyHOIh5T.js → device-manager.cap-DJs8izI6.js} +13 -4
- package/system/dist/{device-manager.cap-DIBK62-r.mjs → device-manager.cap-eYrj1Ezp.mjs} +13 -4
- package/system/dist/{device-provider.cap-BKUGJSo0.js → device-provider.cap-CNlYBQ5D.js} +1 -1
- package/system/dist/{device-provider.cap-DU6HMUXH.mjs → device-provider.cap-D8mJllVM.mjs} +1 -1
- package/system/dist/{device-row-store-O4mNbp5q.js → device-row-store-C0P2H18h.js} +2 -2
- package/system/dist/{device-row-store-C-_R-h1Z.mjs → device-row-store-CTocYKqC.mjs} +2 -2
- package/system/dist/{device-type-CbQsnFdC.js → device-type-Cnc0NiSX.js} +13 -0
- package/system/dist/{device-type-DgEvK3ch.mjs → device-type-TUGqGmaI.mjs} +13 -0
- package/system/dist/error.cap-BuKbL3Ac.js +125 -0
- package/system/dist/error.cap-CU1FB6uE.mjs +102 -0
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{history-catalog-BwTeQ4Mr.mjs → history-catalog-A_dzXNpv.mjs} +98 -3
- package/system/dist/{history-catalog-BKRarIL_.js → history-catalog-CiTMP3-E.js} +98 -3
- package/system/dist/index.js +28 -6
- package/system/dist/index.mjs +28 -6
- package/system/dist/kernel/addon-version-policy.d.ts +10 -0
- package/system/dist/{legacy-integration-rows-door-B1nzxxr5.js → legacy-integration-rows-door-CdqYAj-o.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-nTvo_6jQ.mjs → legacy-integration-rows-door-LSgpClpX.mjs} +1 -1
- package/system/dist/{low-power-sleep.cap-B6mz6ojP.js → low-power-sleep.cap-BJWyAuUQ.js} +1 -1
- package/system/dist/{low-power-sleep.cap-C3Vi8Vxj.mjs → low-power-sleep.cap-D9Orx3LS.mjs} +1 -1
- package/system/dist/migrations/hub/2026-11-22-device-transitions-commands-only.d.ts +10 -0
- package/system/dist/{network-access.cap-BEN_uRVb.js → network-access.cap-CTQ2WQoi.js} +38 -12
- package/system/dist/{network-access.cap-Dy8FNNVs.mjs → network-access.cap-Dx5K0I5i.mjs} +33 -13
- package/system/dist/{notification-rules.cap-Drwz-A4n.js → notification-rules.cap-BJKUjizS.js} +45 -9
- package/system/dist/{notification-rules.cap-0vVvsxQ1.mjs → notification-rules.cap-BUIuYPlQ.mjs} +45 -9
- package/system/dist/{notification-targets-DR-D-vIt.mjs → notification-targets-4bGYH5J7.mjs} +2 -2
- package/system/dist/{notification-targets-Cc_3OBH9.js → notification-targets-DMW7xgR2.js} +2 -2
- package/system/dist/{prefix-walk-CCO_VZVo.js → prefix-walk-BFnw8NBu.js} +5 -5
- package/system/dist/{prefix-walk-BhT0ZoKl.mjs → prefix-walk-Mtij0NNT.mjs} +2 -2
- package/system/dist/{ptz-autotrack.cap-DOz0xL0O.js → ptz-autotrack.cap-B9eyZU8w.js} +1 -1
- package/system/dist/{ptz-autotrack.cap-CDF6FeTK.mjs → ptz-autotrack.cap-Dw2k-po9.mjs} +1 -1
- package/system/dist/{recording-archive.cap-RHAN45fa.mjs → recording-archive.cap-CTlm86R8.mjs} +1 -1
- package/system/dist/{recording-archive.cap-BPJ7kvnd.js → recording-archive.cap-Wo-hEZhz.js} +1 -1
- package/system/dist/{rename-composition-block-DWUkrazx.mjs → rename-composition-block-Cdh-dRmY.mjs} +395 -20
- package/system/dist/{rename-composition-block-CH2vRIW7.js → rename-composition-block-D9Uc1AF7.js} +406 -31
- package/system/dist/{retention-CUOVI1p7.mjs → retention-CQs8QR1B.mjs} +33 -3
- package/system/dist/{device-transitions.cap-DCXP3zwY.mjs → retention-source.cap-550kkyp5.mjs} +98 -21
- package/system/dist/{device-transitions.cap-zOGvAIHz.js → retention-source.cap-C6Hy0hlM.js} +103 -20
- package/system/dist/{retention-BcOSL6b9.js → retention-xcjk_k1w.js} +33 -3
- package/system/dist/{snapshot.cap-Cis6JRwn.js → snapshot.cap-CHm29hBs.js} +1 -1
- package/system/dist/{snapshot.cap-BkfHpJVO.mjs → snapshot.cap-CO68YvJU.mjs} +1 -1
- package/system/dist/{stream-catalog.cap-D8Y-uXcy.js → stream-catalog.cap-CjEQFknc.js} +2 -2
- package/system/dist/{stream-catalog.cap-D1Hy19Yc.mjs → stream-catalog.cap-DVniDdRD.mjs} +2 -2
- package/system/dist/{user-management.cap-Ctd4c_im.mjs → user-management.cap-4IEUCSdL.mjs} +2 -2
- package/system/dist/{user-management.cap-DyVb68rY.js → user-management.cap-DV9Jfsj3.js} +2 -2
- package/system/dist/{wal-maintenance-CjpslZUL.mjs → wal-maintenance-Bey5ChBb.mjs} +0 -0
- package/system/dist/{wal-maintenance-DKTXQ7UF.js → wal-maintenance-BgYiAy5b.js} +0 -0
- package/system/package.json +4 -1
- 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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
12
|
-
import { n as capAppliesToDeviceKind } from "../../device-kind-
|
|
13
|
-
import {
|
|
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 "../../
|
|
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-
|
|
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-
|
|
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`.
|
|
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"]
|
|
@@ -18706,6 +18604,34 @@ async function loadDeviceConfigWithSecrets(ctx, input) {
|
|
|
18706
18604
|
});
|
|
18707
18605
|
return value;
|
|
18708
18606
|
}
|
|
18607
|
+
/**
|
|
18608
|
+
* The CREATE write reaches the door before the device class exists, so the
|
|
18609
|
+
* paths its schema declares secret are not known yet and the blob lands raw.
|
|
18610
|
+
* The first registration brings those paths: move every declared TOP-LEVEL
|
|
18611
|
+
* secret still raw (a non-empty string, not a marker) into the keychain.
|
|
18612
|
+
* Only the first registration of a row — this completes the create write; a
|
|
18613
|
+
* re-registration of an older row converts nothing (no silent migration).
|
|
18614
|
+
* Returns the converted path names (never values).
|
|
18615
|
+
*/
|
|
18616
|
+
async function secureRawDeclaredSecrets(deps, input) {
|
|
18617
|
+
if (ownerSecrets(deps.ctx, input.ownerAddonId) === null) return [];
|
|
18618
|
+
const stored = await deps.readStored();
|
|
18619
|
+
const rawKeys = input.secretPaths.filter((path) => {
|
|
18620
|
+
if (path.includes(".") || path.includes("[")) return false;
|
|
18621
|
+
const value = stored[path];
|
|
18622
|
+
return typeof value === "string" && value.length > 0;
|
|
18623
|
+
});
|
|
18624
|
+
if (rawKeys.length === 0) return [];
|
|
18625
|
+
const patch = Object.fromEntries(rawKeys.map((key) => [key, stored[key]]));
|
|
18626
|
+
await persistDeviceConfigWithSecrets(deps, {
|
|
18627
|
+
deviceId: input.deviceId,
|
|
18628
|
+
ownerAddonId: input.ownerAddonId,
|
|
18629
|
+
data: patch,
|
|
18630
|
+
secretPaths: rawKeys,
|
|
18631
|
+
operatorWrite: true
|
|
18632
|
+
});
|
|
18633
|
+
return rawKeys;
|
|
18634
|
+
}
|
|
18709
18635
|
//#endregion
|
|
18710
18636
|
//#region src/builtins/device-manager/device-removal-hooks.ts
|
|
18711
18637
|
/**
|
|
@@ -19940,6 +19866,27 @@ async function registerDevice(pctx, input) {
|
|
|
19940
19866
|
}
|
|
19941
19867
|
});
|
|
19942
19868
|
}
|
|
19869
|
+
const declaredSecretPaths = input.secretConfigPaths ?? [];
|
|
19870
|
+
if (isFirstRegistration && declaredSecretPaths.length > 0) try {
|
|
19871
|
+
const converted = await secureRawDeclaredSecrets({
|
|
19872
|
+
ctx: pctx.host.ctx,
|
|
19873
|
+
readStored: () => pctx.settings.readDeviceStore(id),
|
|
19874
|
+
write: (patch) => pctx.settings.writeDeviceStore(id, patch)
|
|
19875
|
+
}, {
|
|
19876
|
+
deviceId: id,
|
|
19877
|
+
ownerAddonId: addonId,
|
|
19878
|
+
secretPaths: declaredSecretPaths
|
|
19879
|
+
});
|
|
19880
|
+
if (converted.length > 0) pctx.host.ctx.logger.info("registerDevice: secured raw secret fields from the create write", {
|
|
19881
|
+
tags: { deviceId: id },
|
|
19882
|
+
meta: { paths: [...converted] }
|
|
19883
|
+
});
|
|
19884
|
+
} catch (err) {
|
|
19885
|
+
pctx.host.ctx.logger.warn("registerDevice: could not secure raw secret fields from the create write", {
|
|
19886
|
+
tags: { deviceId: id },
|
|
19887
|
+
meta: { error: err instanceof Error ? err.message : String(err) }
|
|
19888
|
+
});
|
|
19889
|
+
}
|
|
19943
19890
|
if (isFirstRegistration) pctx.host.ctx.eventBus.emit({
|
|
19944
19891
|
id: randomUUID(),
|
|
19945
19892
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -21519,6 +21466,7 @@ async function writeDeclaredIdentity(pctx, input, column) {
|
|
|
21519
21466
|
* | `proposal` candidate, no row | `proposed`, no event |
|
|
21520
21467
|
* | `proposed` row, candidate now `auto` | `linked` / `auto`, created |
|
|
21521
21468
|
* | `dismissed` row | stays dismissed: nothing re-proposes it |
|
|
21469
|
+
* | `dismissed` row, operator Relink | `linked` / `operator`, created (evidence must still hold) |
|
|
21522
21470
|
* | `linked`/`auto` row, evidence gone | row deleted, `identity-link.lost` evidence-gone |
|
|
21523
21471
|
* | `linked`/`operator` row, evidence gone | kept, flagged `evidenceGone`, `lost` evidence-gone |
|
|
21524
21472
|
* | `linked`/`operator` flagged, evidence back | flag cleared, `identity-link.created` |
|
|
@@ -21619,6 +21567,33 @@ var IdentityLinkReconciler = class {
|
|
|
21619
21567
|
return next;
|
|
21620
21568
|
});
|
|
21621
21569
|
}
|
|
21570
|
+
/** Undo a dismissal: a `dismissed` link acts again, as the operator's decision.
|
|
21571
|
+
* Refused `evidence-gone` when the current candidates no longer declare the pair
|
|
21572
|
+
* (a relink of a pair nothing declares would only be flagged at the next pass). */
|
|
21573
|
+
relink(linkId) {
|
|
21574
|
+
return this.decide(linkId, "dismissed", async (link) => {
|
|
21575
|
+
const answer = this.deps.candidates();
|
|
21576
|
+
if (!(answer.status === "answered" && answer.candidates.some((c) => identityLinkId(c.kind, c.a, c.b) === link.id))) return {
|
|
21577
|
+
ok: false,
|
|
21578
|
+
reason: "evidence-gone",
|
|
21579
|
+
message: `identity link ${linkId} cannot be relinked: its devices no longer declare the identifiers that matched them`
|
|
21580
|
+
};
|
|
21581
|
+
const { evidenceGone: _dropped, ...rest } = link;
|
|
21582
|
+
const next = {
|
|
21583
|
+
...rest,
|
|
21584
|
+
state: "linked",
|
|
21585
|
+
origin: "operator",
|
|
21586
|
+
decidedAt: this.now()
|
|
21587
|
+
};
|
|
21588
|
+
await this.deps.store.put(next);
|
|
21589
|
+
this.log("identity link relinked by the operator", next);
|
|
21590
|
+
this.deps.emit(EventCategory$1.IdentityLinkCreated, payloadOf(next));
|
|
21591
|
+
return {
|
|
21592
|
+
ok: true,
|
|
21593
|
+
link: next
|
|
21594
|
+
};
|
|
21595
|
+
});
|
|
21596
|
+
}
|
|
21622
21597
|
/** The `identity-links` removal step (D864): every link naming the device goes. */
|
|
21623
21598
|
removeDevice(deviceId) {
|
|
21624
21599
|
return this.serialized(async () => {
|
|
@@ -21762,9 +21737,10 @@ var IdentityLinkReconciler = class {
|
|
|
21762
21737
|
reason: "wrong-state",
|
|
21763
21738
|
message: `identity link ${linkId} is ${link.state}, not ${from}`
|
|
21764
21739
|
};
|
|
21765
|
-
|
|
21740
|
+
const applied = await apply(link);
|
|
21741
|
+
return "ok" in applied ? applied : {
|
|
21766
21742
|
ok: true,
|
|
21767
|
-
link:
|
|
21743
|
+
link: applied
|
|
21768
21744
|
};
|
|
21769
21745
|
});
|
|
21770
21746
|
}
|
|
@@ -22030,8 +22006,8 @@ var DeviceIdentityIndex = class {
|
|
|
22030
22006
|
* {@link candidates}, plus each device's attached identifiers paired with
|
|
22031
22007
|
* another integration's device identifiers (`poe-power`).
|
|
22032
22008
|
*
|
|
22033
|
-
*
|
|
22034
|
-
* device
|
|
22009
|
+
* A port reaching several devices (a PoE splitter) links every one of them. A
|
|
22010
|
+
* device reached by several ports is ambiguous: each of those attached pairs is
|
|
22035
22011
|
* graded a `proposal` at most — the operator picks.
|
|
22036
22012
|
*
|
|
22037
22013
|
* Freshness first: a pair whose shared keys the port only RETAINS (declared
|
|
@@ -22075,8 +22051,9 @@ var DeviceIdentityIndex = class {
|
|
|
22075
22051
|
const target = this.devices.get(id);
|
|
22076
22052
|
if (target === void 0 || id === port.deviceId || sameIntegration(port, target)) continue;
|
|
22077
22053
|
const keys = sharedKeys(port.attachedIdentifiers, target.identifiers);
|
|
22078
|
-
const
|
|
22079
|
-
if (
|
|
22054
|
+
const graded = classifyIdentityMatch(keys);
|
|
22055
|
+
if (graded === null) continue;
|
|
22056
|
+
const confidence = (port.attachedIdentifiers.mac?.length ?? 0) > 1 && port.attachedIdentifiers.ip === void 0 && keys.some((k) => k.key === "mac") ? "auto" : graded;
|
|
22080
22057
|
const retained = new Set(port.attachedRetained);
|
|
22081
22058
|
all.push({
|
|
22082
22059
|
pair: {
|
|
@@ -22093,13 +22070,9 @@ var DeviceIdentityIndex = class {
|
|
|
22093
22070
|
}
|
|
22094
22071
|
const freshlyReached = new Set(all.filter((p) => p.fresh).map((p) => p.pair.b.deviceId));
|
|
22095
22072
|
const pairs = all.filter((p) => p.fresh || !freshlyReached.has(p.pair.b.deviceId)).map((p) => p.pair);
|
|
22096
|
-
const perPort = /* @__PURE__ */ new Map();
|
|
22097
22073
|
const perTarget = /* @__PURE__ */ new Map();
|
|
22098
|
-
for (const p of pairs)
|
|
22099
|
-
|
|
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 ? {
|
|
22074
|
+
for (const p of pairs) perTarget.set(p.b.deviceId, (perTarget.get(p.b.deviceId) ?? 0) + 1);
|
|
22075
|
+
return pairs.map((p) => (perTarget.get(p.b.deviceId) ?? 0) > 1 ? {
|
|
22103
22076
|
...p,
|
|
22104
22077
|
confidence: "proposal"
|
|
22105
22078
|
} : p);
|
|
@@ -24360,7 +24333,6 @@ function errorMessage$2(err) {
|
|
|
24360
24333
|
var DeviceStateMirror = class {
|
|
24361
24334
|
ctx;
|
|
24362
24335
|
policyFor;
|
|
24363
|
-
transitionTap = null;
|
|
24364
24336
|
reportTap = null;
|
|
24365
24337
|
/**
|
|
24366
24338
|
* Hub-side mirror of every device's cap-keyed NATIVE runtime state — what the
|
|
@@ -24418,10 +24390,6 @@ var DeviceStateMirror = class {
|
|
|
24418
24390
|
readRowFirst: (deviceId, settings) => this.ensureRowRead(deviceId, settings)
|
|
24419
24391
|
});
|
|
24420
24392
|
}
|
|
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
24393
|
/** Set once by the device-manager: told of every native slice reported, before the no-change check (D1062). */
|
|
24426
24394
|
setReportTap(tap) {
|
|
24427
24395
|
this.reportTap = tap;
|
|
@@ -24481,7 +24449,6 @@ var DeviceStateMirror = class {
|
|
|
24481
24449
|
if (prior && shallowEqual(prior, written)) return false;
|
|
24482
24450
|
slice = written;
|
|
24483
24451
|
perCap.set(capName, { ...slice });
|
|
24484
|
-
this.transitionTap?.(deviceId, capName, prior, slice);
|
|
24485
24452
|
const claim = this.claims.claim(deviceId, capName);
|
|
24486
24453
|
if (claim) {
|
|
24487
24454
|
if (claim.mode === "replace") this.emitNativeShadow(deviceId, capName, { ...slice });
|
|
@@ -26251,31 +26218,22 @@ function createCommandArgsPreparer(inputFor) {
|
|
|
26251
26218
|
};
|
|
26252
26219
|
}
|
|
26253
26220
|
//#endregion
|
|
26254
|
-
//#region src/builtins/device-manager/transitions/
|
|
26221
|
+
//#region src/builtins/device-manager/transitions/command-recorder.ts
|
|
26255
26222
|
/**
|
|
26256
|
-
* The
|
|
26223
|
+
* The command recorder of the device audit (D1022, D1084).
|
|
26257
26224
|
*
|
|
26258
|
-
* A command
|
|
26259
|
-
*
|
|
26260
|
-
*
|
|
26261
|
-
*
|
|
26262
|
-
*
|
|
26263
|
-
* `already`; one that produced nothing inside its window is `unconfirmed`; one
|
|
26264
|
-
* the caller saw throw is `failed`.
|
|
26225
|
+
* A command is what the kernel saw leave its caller. It is written as ONE row,
|
|
26226
|
+
* when the call completes: `ok` when it returned, `failed` when the caller saw it
|
|
26227
|
+
* throw. Nothing waits for the device to obey and nothing is matched to a slice
|
|
26228
|
+
* change: the change, when the device reports one, is read back from device-history
|
|
26229
|
+
* on the Interactions read, beside the command row.
|
|
26265
26230
|
*
|
|
26266
|
-
* Pure and clock-injected
|
|
26267
|
-
*
|
|
26268
|
-
*
|
|
26231
|
+
* Pure and clock-injected; it reads memory only (D49): the mirror's current slice,
|
|
26232
|
+
* for the `from` value of a command that names an effect. What it produces is
|
|
26233
|
+
* handed to `emit`, whose queue is bounded.
|
|
26269
26234
|
*/
|
|
26270
|
-
/** How long a command waits for the change it should cause. */
|
|
26271
|
-
var COMMAND_MATCH_WINDOW_MS = 3e4;
|
|
26272
26235
|
/** Longest error text a row keeps. */
|
|
26273
26236
|
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
26237
|
/** A status value in the shape a transition stores: unknown is `null` (D393), an array is wrapped. */
|
|
26280
26238
|
function toTransitionValue(value) {
|
|
26281
26239
|
if (value === void 0 || value === null) return null;
|
|
@@ -26284,245 +26242,49 @@ function toTransitionValue(value) {
|
|
|
26284
26242
|
if (typeof value === "object") return Object.fromEntries(Object.entries(value));
|
|
26285
26243
|
return String(value);
|
|
26286
26244
|
}
|
|
26287
|
-
var
|
|
26245
|
+
var CommandRecorder = class {
|
|
26288
26246
|
deps;
|
|
26289
|
-
pending = /* @__PURE__ */ new Map();
|
|
26290
26247
|
seq = 0;
|
|
26291
|
-
held = /* @__PURE__ */ new Map();
|
|
26292
26248
|
constructor(deps) {
|
|
26293
26249
|
this.deps = deps;
|
|
26294
26250
|
}
|
|
26295
|
-
/**
|
|
26251
|
+
/**
|
|
26252
|
+
* A command left its caller. Where the seam can see the call settle (`obs.outcome`), the row is
|
|
26253
|
+
* written when it does; where it cannot (the UDS parent and in-process clients report only the
|
|
26254
|
+
* departure) the call is recorded as `ok` at once, since a throw there is not observable.
|
|
26255
|
+
*/
|
|
26296
26256
|
recordCommand(obs) {
|
|
26297
26257
|
const effect = commandEffect(obs.capName, obs.method, obs.args);
|
|
26298
|
-
const
|
|
26299
|
-
const
|
|
26300
|
-
const
|
|
26301
|
-
|
|
26302
|
-
|
|
26303
|
-
|
|
26304
|
-
|
|
26305
|
-
|
|
26306
|
-
|
|
26307
|
-
|
|
26308
|
-
|
|
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({
|
|
26258
|
+
const field = effect?.field ?? "*";
|
|
26259
|
+
const from = effect === null ? null : toTransitionValue(this.deps.currentSlice(obs.deviceId, obs.capName)?.[effect.field]);
|
|
26260
|
+
const to = effect === null ? null : toTransitionValue(effect.value);
|
|
26261
|
+
const write = (outcome, error) => {
|
|
26262
|
+
this.seq += 1;
|
|
26263
|
+
const commandId = `${obs.deviceId}:${obs.at}:c${this.seq}`;
|
|
26264
|
+
this.deps.emit({
|
|
26265
|
+
id: commandId,
|
|
26266
|
+
deviceId: obs.deviceId,
|
|
26267
|
+
at: obs.at,
|
|
26268
|
+
capName: obs.capName,
|
|
26337
26269
|
field,
|
|
26338
|
-
|
|
26339
|
-
|
|
26340
|
-
|
|
26270
|
+
from,
|
|
26271
|
+
to,
|
|
26272
|
+
outcome,
|
|
26273
|
+
actor: obs.actor,
|
|
26274
|
+
command: {
|
|
26275
|
+
commandId,
|
|
26276
|
+
method: obs.method,
|
|
26277
|
+
args: this.deps.prepareArgs(obs.capName, obs.method, obs.args),
|
|
26278
|
+
requestedAt: obs.at,
|
|
26279
|
+
...error !== void 0 ? { error: redactLogText(error).slice(0, ERROR_MAX_CHARS) } : {}
|
|
26280
|
+
}
|
|
26341
26281
|
});
|
|
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
26282
|
};
|
|
26352
|
-
|
|
26353
|
-
|
|
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);
|
|
26283
|
+
if (obs.outcome === void 0) {
|
|
26284
|
+
write("ok");
|
|
26460
26285
|
return;
|
|
26461
26286
|
}
|
|
26462
|
-
|
|
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}`;
|
|
26287
|
+
obs.outcome.then(() => write("ok"), (err) => write("failed", err instanceof Error ? err.message : String(err)));
|
|
26526
26288
|
}
|
|
26527
26289
|
};
|
|
26528
26290
|
var DROP_LOG_DEVICES_MAX = 10;
|
|
@@ -26585,10 +26347,10 @@ var TransitionSender = class {
|
|
|
26585
26347
|
//#endregion
|
|
26586
26348
|
//#region src/builtins/device-manager/transitions/transitions-wiring.ts
|
|
26587
26349
|
/**
|
|
26588
|
-
* Starts the hub's device
|
|
26589
|
-
*
|
|
26590
|
-
*
|
|
26591
|
-
*
|
|
26350
|
+
* Starts the hub's device command audit (D1022, D1084): command observations meet
|
|
26351
|
+
* the recorder, its rows ride a bounded queue to device-history. Everything here is
|
|
26352
|
+
* best-effort telemetry (D8): a failure costs rows, never a command or a mirror
|
|
26353
|
+
* write.
|
|
26592
26354
|
*/
|
|
26593
26355
|
var TRANSITIONS_FLUSH_INTERVAL_MS = 2e3;
|
|
26594
26356
|
var realTicker = (fn, ms) => {
|
|
@@ -26600,7 +26362,6 @@ function inputFor(capName, method) {
|
|
|
26600
26362
|
return def === void 0 ? void 0 : expandCapMethods$1(def)[method]?.input;
|
|
26601
26363
|
}
|
|
26602
26364
|
function startDeviceTransitions(deps) {
|
|
26603
|
-
const now = deps.now ?? Date.now;
|
|
26604
26365
|
const ticker = deps.ticker ?? realTicker;
|
|
26605
26366
|
const sender = new TransitionSender({
|
|
26606
26367
|
send: (batch) => deps.record(batch),
|
|
@@ -26623,11 +26384,10 @@ function startDeviceTransitions(deps) {
|
|
|
26623
26384
|
at: row.at
|
|
26624
26385
|
});
|
|
26625
26386
|
} catch (err) {
|
|
26626
|
-
deps.logger.warn(`device-transitions: announcing a
|
|
26387
|
+
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
26388
|
}
|
|
26628
26389
|
};
|
|
26629
|
-
const
|
|
26630
|
-
now,
|
|
26390
|
+
const recorder = new CommandRecorder({
|
|
26631
26391
|
logger: deps.logger,
|
|
26632
26392
|
currentSlice: (deviceId, capName) => deps.mirror.currentSlice(deviceId, capName),
|
|
26633
26393
|
emit: (row) => {
|
|
@@ -26636,36 +26396,23 @@ function startDeviceTransitions(deps) {
|
|
|
26636
26396
|
},
|
|
26637
26397
|
prepareArgs: createCommandArgsPreparer(inputFor)
|
|
26638
26398
|
});
|
|
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
26399
|
const unsubscribe = getCommandObserverRegistry().subscribe((obs) => {
|
|
26647
26400
|
if (!isCommand$1(obs.capName, obs.method)) return;
|
|
26648
26401
|
try {
|
|
26649
|
-
|
|
26402
|
+
recorder.recordCommand(obs);
|
|
26650
26403
|
} catch (err) {
|
|
26651
26404
|
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
26405
|
}
|
|
26653
26406
|
});
|
|
26654
26407
|
const stopTicker = ticker(() => {
|
|
26655
|
-
correlator.sweep();
|
|
26656
26408
|
sender.flush();
|
|
26657
26409
|
}, TRANSITIONS_FLUSH_INTERVAL_MS);
|
|
26658
|
-
return {
|
|
26659
|
-
|
|
26660
|
-
|
|
26661
|
-
|
|
26662
|
-
|
|
26663
|
-
|
|
26664
|
-
correlator.flush();
|
|
26665
|
-
await sender.flush();
|
|
26666
|
-
sender.abandon();
|
|
26667
|
-
}
|
|
26668
|
-
};
|
|
26410
|
+
return { stop: async () => {
|
|
26411
|
+
unsubscribe();
|
|
26412
|
+
stopTicker();
|
|
26413
|
+
await sender.flush();
|
|
26414
|
+
sender.abandon();
|
|
26415
|
+
} };
|
|
26669
26416
|
}
|
|
26670
26417
|
//#endregion
|
|
26671
26418
|
//#region src/builtins/device-manager/field-claims-index.ts
|
|
@@ -27243,7 +26990,6 @@ var DeviceManagerAddon = class extends BaseAddon {
|
|
|
27243
26990
|
holdMirrorWrites: (deviceIds, settings) => this.stateMirror.holdDiskWrites(deviceIds, settings),
|
|
27244
26991
|
mirrorOwnedCaps: (deviceId) => this.stateMirror.ownedCaps(deviceId),
|
|
27245
26992
|
forgetMirrorDevice: (deviceId) => {
|
|
27246
|
-
this.transitions?.forgetDevice(deviceId);
|
|
27247
26993
|
return this.stateMirror.forgetDevice(deviceId);
|
|
27248
26994
|
},
|
|
27249
26995
|
resolveDeviceOnline: (deviceId, fallbackOnline) => this.stateMirror.resolveDeviceOnline(deviceId, fallbackOnline),
|
|
@@ -27672,6 +27418,7 @@ var DeviceManagerAddon = class extends BaseAddon {
|
|
|
27672
27418
|
confirmIdentityLink: ({ linkId }) => identityLinks.confirm(linkId),
|
|
27673
27419
|
dismissIdentityLink: ({ linkId }) => identityLinks.dismiss(linkId),
|
|
27674
27420
|
unlinkIdentity: ({ linkId }) => identityLinks.unlink(linkId),
|
|
27421
|
+
relinkIdentity: ({ linkId }) => identityLinks.relink(linkId),
|
|
27675
27422
|
getRoleDisplayDefaults: (input) => getRoleDisplayDefaults(pctx, input),
|
|
27676
27423
|
setRoleDisplayDefaults: (input) => setRoleDisplayDefaults(pctx, input),
|
|
27677
27424
|
applyInitialMeta: (input) => applyInitialMeta(pctx, input),
|