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