@camstack/server 1.2.927 → 1.2.929
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 +12 -0
- package/package.json +11 -14
- package/system/dist/addon-id-CVg1_r5E.mjs +39 -0
- package/system/dist/addon-id-Di0lNJ89.js +50 -0
- package/system/dist/addon-pages.cap-Df9FQwN1.js +49 -0
- package/system/dist/addon-pages.cap-DksUlE8j.mjs +44 -0
- package/system/dist/addon-settings.cap-3-TIIMq_.mjs +592 -0
- package/system/dist/addon-settings.cap-DAiE0Nb0.js +651 -0
- package/system/dist/addon-widgets.cap-C4jxflbF.js +200 -0
- package/system/dist/addon-widgets.cap-D9m48X78.mjs +183 -0
- package/system/dist/base-addon-DD5dIfcZ.js +4624 -0
- package/system/dist/base-addon-Md14i7pe.mjs +4505 -0
- package/system/dist/base-device-2sL1DMm1.js +1103 -0
- package/system/dist/base-device-IuM1AwXZ.mjs +1098 -0
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +3 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +3 -1
- package/system/dist/builtins/alerts/alerts.addon.js +113 -56
- package/system/dist/builtins/alerts/alerts.addon.mjs +58 -1
- package/system/dist/builtins/autotrack/index.js +21 -17
- package/system/dist/builtins/autotrack/index.mjs +5 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +14 -11
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -2
- package/system/dist/builtins/calendars/calendars.addon.js +8 -6
- package/system/dist/builtins/calendars/calendars.addon.mjs +3 -1
- package/system/dist/builtins/camera-grid/index.js +615 -58
- package/system/dist/builtins/camera-grid/index.mjs +558 -1
- package/system/dist/builtins/composer/composer.addon.js +788 -209
- package/system/dist/builtins/composer/composer.addon.mjs +583 -4
- package/system/dist/builtins/console-logging/index.js +4 -3
- package/system/dist/builtins/console-logging/index.mjs +2 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +7887 -381
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +7511 -5
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +731 -21
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +711 -1
- package/system/dist/builtins/device-history/device-history.addon.js +110 -31
- package/system/dist/builtins/device-history/device-history.addon.mjs +81 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +12806 -227
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +12583 -5
- package/system/dist/builtins/hub-forwarder/index.js +4 -3
- package/system/dist/builtins/hub-forwarder/index.mjs +2 -1
- package/system/dist/builtins/keychain/index.js +31 -28
- package/system/dist/builtins/keychain/index.mjs +7 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +15 -12
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +4 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +140 -39
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +103 -3
- package/system/dist/builtins/local-network/local-network.addon.js +43 -39
- package/system/dist/builtins/local-network/local-network.addon.mjs +7 -3
- package/system/dist/builtins/loki-logging/index.js +23 -17
- package/system/dist/builtins/loki-logging/index.mjs +7 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +156 -15
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +142 -1
- package/system/dist/builtins/platform-probe/index.js +25 -23
- package/system/dist/builtins/platform-probe/index.mjs +4 -2
- package/system/dist/builtins/record-entries/index.js +9 -7
- package/system/dist/builtins/record-entries/index.mjs +3 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +4 -4
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +97 -44
- package/system/dist/builtins/snapshot/index.mjs +54 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +5 -4
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +2 -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 +87 -61
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +29 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +81 -72
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +10 -1
- package/system/dist/builtins/system-config/system-config.addon.js +17 -14
- package/system/dist/builtins/system-config/system-config.addon.mjs +6 -3
- package/system/dist/builtins/winston-logging/index.js +7 -5
- package/system/dist/builtins/winston-logging/index.mjs +3 -1
- package/system/dist/calendars.cap-CaFlShS9.js +155 -0
- package/system/dist/calendars.cap-_C4eD4fi.mjs +138 -0
- package/system/dist/camstack-error-DJ-TUAi1.js +23 -0
- package/system/dist/camstack-error-viZYfcj9.mjs +18 -0
- package/system/dist/cap-call-context-Bd76CbOW.js +95 -0
- package/system/dist/cap-call-context-DNwdgGSQ.mjs +78 -0
- package/system/dist/capability-definition-C2rJdVeX.mjs +177 -0
- package/system/dist/capability-definition-HCmTem8c.js +242 -0
- package/system/dist/{capture-engine-BcuwOSXv.js → capture-engine-DZ0LIUqA.js} +5 -4
- package/system/dist/{capture-engine-Bz7eXFjT.mjs → capture-engine-DiwbjoWp.mjs} +2 -1
- package/system/dist/command-origin-claim-Cief660O.js +35 -0
- package/system/dist/command-origin-claim-D1Wy7Qld.mjs +24 -0
- package/system/dist/composition-sources-Caqv7O7z.mjs +391 -0
- package/system/dist/composition-sources-CgnHjm8Q.js +408 -0
- package/system/dist/{constants-D2etJ02O.js → constants-Ba3FTIHl.js} +1 -1
- package/system/dist/constants-C860Y6U4.js +26 -0
- package/system/dist/{constants-BcUTQd1M.mjs → constants-DB4piTD5.mjs} +1 -1
- package/system/dist/constants-DCLpoF4L.mjs +21 -0
- package/system/dist/coral-accelerators-7o8hqvcN.js +564 -0
- package/system/dist/coral-accelerators-BKcXP59c.mjs +521 -0
- package/system/dist/core-blocks.cap-C6iKAZ-x.mjs +17986 -0
- package/system/dist/core-blocks.cap-LEMqVwxO.js +18705 -0
- package/system/dist/custom-actions-BFUSalC9.mjs +25 -0
- package/system/dist/custom-actions-D92NRi2c.js +36 -0
- package/system/dist/database-snapshot.cap-DF38e-0P.js +162 -0
- package/system/dist/database-snapshot.cap-dhrc9xnY.mjs +133 -0
- package/system/dist/declared-device-BWphj9WE.js +303 -0
- package/system/dist/declared-device-CKERA1Hi.mjs +286 -0
- package/system/dist/{device-ca-ExMN3xW3.mjs → device-ca-BLM6fccc.mjs} +2 -1
- package/system/dist/{device-ca-CU8zh9Pi.js → device-ca-C5kJE6mL.js} +7 -6
- package/system/dist/device-certificate-Cddm4Idn.mjs +91 -0
- package/system/dist/device-certificate-CguVACQO.js +162 -0
- package/system/dist/device-identifiers-BQg9EQi1.js +600 -0
- package/system/dist/device-identifiers-iSuQCKmK.mjs +529 -0
- package/system/dist/device-kind-BJ2pfsjw.mjs +78 -0
- package/system/dist/device-kind-CsSiv_YF.js +101 -0
- package/system/dist/device-manager.cap-2abwVLCM.js +2874 -0
- package/system/dist/device-manager.cap-CFZSPfUh.mjs +2749 -0
- package/system/dist/device-provider.cap-3Uvk6f5-.mjs +331 -0
- package/system/dist/device-provider.cap-D7TV2kVH.js +366 -0
- package/system/dist/{device-row-store-CeW_GWh9.mjs → device-row-store-YF3jtmkk.mjs} +4 -1
- package/system/dist/{device-row-store-BMIR-n3m.js → device-row-store-doTfMOqn.js} +12 -9
- package/system/dist/device-transitions.cap-B5w5PYU_.js +860 -0
- package/system/dist/device-transitions.cap-DojcwEuX.mjs +819 -0
- package/system/dist/device-type-CbQsnFdC.js +477 -0
- package/system/dist/device-type-DgEvK3ch.mjs +454 -0
- package/system/dist/entry-kind-D9MuVJCK.mjs +44 -0
- package/system/dist/entry-kind-cq90c--V.js +55 -0
- package/system/dist/error.cap-CSM_SRfR.mjs +3423 -0
- package/system/dist/error.cap-DBhgPeWK.js +3848 -0
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/history-catalog-BKRarIL_.js +831 -0
- package/system/dist/history-catalog-BwTeQ4Mr.mjs +802 -0
- package/system/dist/{hub-identity-Csxx2Q8k.js → hub-identity-BMdR3Mw9.js} +2 -2
- package/system/dist/{hub-identity-BBXzP6Ve.mjs → hub-identity-DjMN9Ac2.mjs} +1 -1
- package/system/dist/{hub-mdns-ciao-By5577HM.js → hub-mdns-ciao--0v1TKME.js} +5 -5
- package/system/dist/{hub-mdns-ciao-DG17NbGU.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +2 -2
- package/system/dist/index.js +763 -151
- package/system/dist/index.mjs +624 -12
- package/system/dist/integration-instances.cap-Cl9O-k4h.mjs +538 -0
- package/system/dist/integration-instances.cap-dJIxg2_s.js +549 -0
- package/system/dist/keychain-admin.cap-Db_oFX4H.js +425 -0
- package/system/dist/keychain-admin.cap-GtM7gVGG.mjs +396 -0
- package/system/dist/l10n-Bu6aUvSY.mjs +10 -0
- package/system/dist/l10n-CGMvp7NF.js +15 -0
- package/system/dist/labels-DX5S8deC.js +81 -0
- package/system/dist/labels-DsBcU7md.mjs +64 -0
- package/system/dist/{legacy-integration-rows-door-CVwOo5aq.js → legacy-integration-rows-door-B1nzxxr5.js} +2 -2
- package/system/dist/{legacy-integration-rows-door-D9tQOUzh.mjs → legacy-integration-rows-door-nTvo_6jQ.mjs} +1 -1
- package/system/dist/log-destination.cap-CxZzAVaR.mjs +143 -0
- package/system/dist/log-destination.cap-DELPJkZ0.js +148 -0
- package/system/dist/low-power-sleep.cap-7lfVU41N.js +103 -0
- package/system/dist/low-power-sleep.cap-tGPmaZ_V.mjs +92 -0
- package/system/dist/mask-shape-Ci8Co9w0.mjs +57 -0
- package/system/dist/mask-shape-CmPA2fst.js +92 -0
- package/system/dist/metrics-provider.cap-BNmcHDkQ.mjs +405 -0
- package/system/dist/metrics-provider.cap-BcmQUt6l.js +410 -0
- package/system/dist/migration-BMjgkyG2.js +380 -0
- package/system/dist/migration-DRJAtdy7.mjs +321 -0
- package/system/dist/network-access.cap-B5TWLDCC.js +1099 -0
- package/system/dist/network-access.cap-BJnGbE6n.mjs +1004 -0
- package/system/dist/notification-rules.cap-B__YBgnG.js +3422 -0
- package/system/dist/notification-rules.cap-D9ArZlwx.mjs +3357 -0
- package/system/dist/ops-log-CB4pIdqi.mjs +64 -0
- package/system/dist/ops-log-pxt9176Z.js +81 -0
- package/system/dist/pinned-binary-BOhOSNff.js +28 -0
- package/system/dist/pinned-binary-CrIRAi4G.mjs +23 -0
- package/system/dist/platform-probe.cap-1WrMhWHx.js +250 -0
- package/system/dist/platform-probe.cap-BFeqFLtQ.mjs +233 -0
- package/system/dist/prefix-walk-B4b2-9aK.mjs +790 -0
- package/system/dist/prefix-walk-DC0ljmbB.js +843 -0
- package/system/dist/ptz-autotrack.cap-BW7w0zHD.js +229 -0
- package/system/dist/ptz-autotrack.cap-DT2GypXw.mjs +224 -0
- package/system/dist/quantity-D3g5SxsZ.mjs +114 -0
- package/system/dist/quantity-lY1KiTSZ.js +143 -0
- package/system/dist/raw-secret-migration-DxuBFtvi.js +50 -0
- package/system/dist/raw-secret-migration-iv88mLoc.mjs +39 -0
- package/system/dist/record-entries.cap-sMUhTvTU.mjs +75 -0
- package/system/dist/record-entries.cap-ti1C046R.js +80 -0
- package/system/dist/record-kind-DoBfYHCs.js +203 -0
- package/system/dist/record-kind-ub6NXqfh.mjs +162 -0
- package/system/dist/recording-archive.cap-7OrIn9e5.mjs +1299 -0
- package/system/dist/recording-archive.cap-D7bo-QSM.js +1328 -0
- package/system/dist/records.cap-ClcWV64i.js +329 -0
- package/system/dist/records.cap-CwLT2ByG.mjs +294 -0
- package/system/dist/relocate-CdVQAk-w.js +804 -0
- package/system/dist/relocate-CoZZTui1.mjs +661 -0
- package/system/dist/rename-composition-block-7WIICIDq.mjs +33525 -0
- package/system/dist/rename-composition-block-CcWLwVhG.js +34692 -0
- package/system/dist/{restore-archive-kwtBd00M.mjs → restore-archive-CjAyKpgX.mjs} +3 -1
- package/system/dist/{restore-archive-CIFvqOze.js → restore-archive-CkTkv3Ss.js} +6 -4
- package/system/dist/scoped-settings-CylSSq_8.js +955 -0
- package/system/dist/scoped-settings-DVWUIP7Z.mjs +650 -0
- package/system/dist/server-name-BIhLuHvX.mjs +35 -0
- package/system/dist/server-name-OALNvpqC.js +52 -0
- package/system/dist/settings-store.cap-Ci4F2zul.mjs +569 -0
- package/system/dist/settings-store.cap-wlJhCspr.js +640 -0
- package/system/dist/snapshot.cap-3suPdBHV.js +250 -0
- package/system/dist/snapshot.cap-Bs8Oyaqh.mjs +245 -0
- package/system/dist/source-info-DGB7SdB_.mjs +190 -0
- package/system/dist/source-info-DtWf4k2j.js +225 -0
- package/system/dist/storage-admin.cap-BSv1NjKJ.mjs +883 -0
- package/system/dist/storage-admin.cap-he0OqvVM.js +906 -0
- package/system/dist/storage-location-CBT8GCD6.mjs +163 -0
- package/system/dist/storage-location-CTweDMZf.js +198 -0
- package/system/dist/storage-location-mode-B21UVRRX.mjs +167 -0
- package/system/dist/storage-location-mode-CS4sMzo-.js +232 -0
- package/system/dist/storage-migration.cap-CyyATY_p.js +330 -0
- package/system/dist/storage-migration.cap-D7QqGobp.mjs +313 -0
- package/system/dist/storage-occupancy.cap-2rmnS58Z.js +622 -0
- package/system/dist/storage-occupancy.cap-CqBztTl9.mjs +611 -0
- package/system/dist/storage-provider.cap-Bw0CfxVc.js +213 -0
- package/system/dist/storage-provider.cap-CMeck2w4.mjs +202 -0
- package/system/dist/stream-catalog.cap-Bp7SkgIf.mjs +6560 -0
- package/system/dist/stream-catalog.cap-D3uwePiA.js +6763 -0
- package/system/dist/streaming-shared-B8cXatuU.mjs +431 -0
- package/system/dist/streaming-shared-DQwFZOSi.js +526 -0
- package/system/dist/system-reasons-Be_k1W8g.js +25 -0
- package/system/dist/system-reasons-CYj4qwyS.mjs +20 -0
- package/system/dist/tag-BxLazvVb.js +2138 -0
- package/system/dist/tag-uZBAq6ox.mjs +2073 -0
- package/system/dist/user-management.cap-B9QDu8NE.js +825 -0
- package/system/dist/user-management.cap-DBIi77sB.mjs +766 -0
- package/system/dist/vector-store.cap-DnyfrYDn.js +330 -0
- package/system/dist/vector-store.cap-h2GHWQ1t.mjs +319 -0
- package/system/dist/{wal-maintenance-CTrCPzds.mjs → wal-maintenance-BG01rOn9.mjs} +0 -0
- package/system/dist/{wal-maintenance-dq7T3quB.js → wal-maintenance-DyrebYKF.js} +0 -0
- package/system/dist/zod-secret-DS7mj1bk.js +78 -0
- package/system/dist/zod-secret-zY4nM61M.mjs +73 -0
- package/system/package.json +1 -1
- package/system/dist/composition-sources-BI614LJx.mjs +0 -141
- package/system/dist/composition-sources-v_kkb8A9.js +0 -152
- package/system/dist/coral-accelerators-BSVsBVzt.js +0 -250
- package/system/dist/coral-accelerators-DBlgWB8k.mjs +0 -231
- package/system/dist/dist-BCHMSqzc.mjs +0 -143467
- package/system/dist/dist-BZfvhfS1.js +0 -146970
- package/system/dist/prefix-walk-DAOBSyH1.mjs +0 -88
- package/system/dist/prefix-walk-Dv6MLZlM.js +0 -99
- package/system/dist/rename-composition-block-C9HuBrKS.js +0 -112
- package/system/dist/rename-composition-block-DtaYmYAR.mjs +0 -101
package/system/dist/index.mjs
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { i as __require } from "./chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { b as EventCategory$1, i as collectSecretMarkerRefs, p as createEvent$1 } from "./base-addon-Md14i7pe.mjs";
|
|
3
|
+
import { Z as errMsg$1 } from "./scoped-settings-DVWUIP7Z.mjs";
|
|
4
|
+
import { Un as lifecycleJobSchema, a as isCollectionArrayMethod, c as kebabToCamel$1, d as objectInputDeclaresRequiredDeviceId, dr as compareVersions, f as procedureAuthKey, fr as describeUnmet, i as isArrayOutputSchema, l as looseSchema, m as ALL_CAPABILITY_DEFINITIONS, o as isObjectInput, p as resolveMethodAuth, pr as unmetRequirements, r as extractNestedAddonId, s as isVoidInput, u as objectInputDeclaresAddonId, ur as PackageRequiresSchema } from "./rename-composition-block-7WIICIDq.mjs";
|
|
5
|
+
import { t as userError } from "./camstack-error-viZYfcj9.mjs";
|
|
6
|
+
import { a as expandCapMethods, n as DEVICE_STATUS_METHOD, t as DEVICE_SETTINGS_CONTRIBUTION_METHODS, u as resolveCapMount } from "./capability-definition-C2rJdVeX.mjs";
|
|
7
|
+
import { s as defineRecordKinds } from "./record-kind-ub6NXqfh.mjs";
|
|
8
|
+
import { D as RecordsEngine, J as asNumber, X as parseJsonObject, Y as asString$1, Z as parseJsonUnknown, l as SqliteSettingsBackend, q as asJsonObject$1 } from "./wal-maintenance-BG01rOn9.mjs";
|
|
9
|
+
import { f as AppPageLangSchema } from "./device-certificate-Cddm4Idn.mjs";
|
|
10
|
+
import { i as addonSettingsCapability } from "./addon-settings.cap-3-TIIMq_.mjs";
|
|
11
|
+
import { t as loadPrefixed } from "./prefix-walk-B4b2-9aK.mjs";
|
|
12
|
+
import { a as AGENT_MDNS_TXT_KEYS, i as AGENT_MDNS_SERVICE_TYPE } from "./network-access.cap-BJnGbE6n.mjs";
|
|
13
|
+
import { t as RUNTIME_DEFAULTS } from "./constants-DCLpoF4L.mjs";
|
|
14
|
+
import { t as bareAddonId } from "./addon-id-CVg1_r5E.mjs";
|
|
15
|
+
import { r as nodeCoralFs, s as supportedRuntimes, t as classifyCoralAccelerator } from "./coral-accelerators-BKcXP59c.mjs";
|
|
16
|
+
import { d as JWT_SIGNING_KEY_REF, f as JwtSigningKeyUnavailableError, g as processJwtSigningKey, i as generateDeviceCa, l as verifyDeviceLeaf, m as getProcessJwtSigningKeyState, n as DEVICE_CA_KEY_REF, o as issueDeviceLeaf, p as SYSTEM_SECRET_OWNER, s as loadDeviceCa, u as verifyDeviceSignature, v as staticJwtSigningKey } from "./device-ca-BLM6fccc.mjs";
|
|
4
17
|
import { t as require_read_all_rows } from "./read-all-rows-TaPqdWNF.mjs";
|
|
5
18
|
import { a as redactLogText, i as redactLogMeta, r as redactLogEntry, t as isCredentialKeyName } from "./log-redactor-XLDrPzOi.mjs";
|
|
6
19
|
import { AlertCenterAddon, n as lastCauseAfterChunk, r as readRunnerDisplayName, t as CRASH_BREAKER_ERROR_PREFIX } from "./builtins/alerts/alerts.addon.mjs";
|
|
@@ -11,41 +24,38 @@ import { ComposerAddon } from "./builtins/composer/composer.addon.mjs";
|
|
|
11
24
|
import "./builtins/composer/index.mjs";
|
|
12
25
|
import { t as formatLogLine } from "./formatter-DkYZ4LXp.mjs";
|
|
13
26
|
import { ConsoleDestination, ConsoleLoggingAddon } from "./builtins/console-logging/index.mjs";
|
|
14
|
-
import { t as loadPrefixed } from "./prefix-walk-DAOBSyH1.mjs";
|
|
15
27
|
import { n as readCurrentCommandOrigin, r as runWithCapCallContext, t as currentCapCallContext } from "./cap-call-scope-Bic6Ekfw.mjs";
|
|
16
28
|
import { CoreBlocksAddon, c as readUnscopedAddonSettings, o as clearNodeSettings, s as createAddonSettingsStore } from "./builtins/core-blocks/core-blocks.addon.mjs";
|
|
17
29
|
import "./builtins/core-blocks/index.mjs";
|
|
18
30
|
import { CoreNotifierAddon } from "./builtins/core-notifier/core-notifier.addon.mjs";
|
|
19
31
|
import "./builtins/core-notifier/index.mjs";
|
|
20
|
-
import { C as deviceIdOfArgs, D as createDeviceSettingsStore, DeviceManagerAddon, E as observable, O as readDeviceOrThrow, S as commandFollowUpTarget, T as withCommandFollowUp, _ as getCommandObserverRegistry, a as childRefreshSource, b as CommandFollowUpRegistry, c as IN_PROCESS_HOLD_SOURCE, d as getCommandHoldOverrideRegistry, f as CommandObserverRegistry, g as commandObserverLink, h as commandActorFromContext, i as __resetStateRefreshPolicyRegistryForTests, k as setWrapperActive, l as childCommandHoldEntries, m as addonCommandActor, o as childStateRefreshEntries, p as __resetCommandObserverRegistryForTests, r as StateRefreshPolicyRegistry, s as getStateRefreshPolicyRegistry, t as IN_PROCESS_REFRESH_SOURCE, u as childHoldSource, v as reportCommand, w as getCommandFollowUpRegistry, x as __resetCommandFollowUpRegistryForTests, y as runObservedCommand } from "./builtins/device-manager/device-manager.addon.mjs";
|
|
32
|
+
import { A as METHOD_ACCESS_MAP, C as deviceIdOfArgs, D as createDeviceSettingsStore, DeviceManagerAddon, E as observable, O as readDeviceOrThrow, S as commandFollowUpTarget, T as withCommandFollowUp, _ as getCommandObserverRegistry, a as childRefreshSource, b as CommandFollowUpRegistry, c as IN_PROCESS_HOLD_SOURCE, d as getCommandHoldOverrideRegistry, f as CommandObserverRegistry, g as commandObserverLink, h as commandActorFromContext, i as __resetStateRefreshPolicyRegistryForTests, k as setWrapperActive, l as childCommandHoldEntries, m as addonCommandActor, o as childStateRefreshEntries, p as __resetCommandObserverRegistryForTests, r as StateRefreshPolicyRegistry, s as getStateRefreshPolicyRegistry, t as IN_PROCESS_REFRESH_SOURCE, u as childHoldSource, v as reportCommand, w as getCommandFollowUpRegistry, x as __resetCommandFollowUpRegistryForTests, y as runObservedCommand } from "./builtins/device-manager/device-manager.addon.mjs";
|
|
21
33
|
import "./builtins/device-manager/index.mjs";
|
|
22
34
|
import { HubForwarderAddon, HubForwarderDestination } from "./builtins/hub-forwarder/index.mjs";
|
|
23
35
|
import { LivenessMonitorAddon } from "./builtins/liveness-monitor/liveness-monitor.addon.mjs";
|
|
24
36
|
import "./builtins/liveness-monitor/index.mjs";
|
|
25
|
-
import { LocalAuthAddon, _ as SettingsReadUnavailableError, a as attachUserManagementInternal, c as DeviceCaStore, d as onSessionsRevoked, f as DeviceCredentialManager, g as parseTokenExpiry, h as AuthManager, i as USER_MANAGEMENT_INTERNAL, l as LoginSessionManager, m as AuthAuditLog, n as FIRST_BOOT_ADMIN_USERNAME, o as getUserManagementInternal, p as PREVIOUS_LEAF_GRACE_MS, r as UserManager, s as preferencesLimitReasonOf, t as FIRST_BOOT_ADMIN_PASSWORD, u as REFRESH_TOKEN_PREFIX, v as isSettingsReadUnavailable } from "./builtins/local-auth/local-auth.addon.mjs";
|
|
37
|
+
import { LocalAuthAddon, _ as SettingsReadUnavailableError, a as attachUserManagementInternal, c as DeviceCaStore, d as onSessionsRevoked, f as DeviceCredentialManager, g as parseTokenExpiry, h as AuthManager, i as USER_MANAGEMENT_INTERNAL, l as LoginSessionManager, m as AuthAuditLog, n as FIRST_BOOT_ADMIN_USERNAME, o as getUserManagementInternal, p as PREVIOUS_LEAF_GRACE_MS, r as UserManager, s as preferencesLimitReasonOf, t as FIRST_BOOT_ADMIN_PASSWORD, u as REFRESH_TOKEN_PREFIX, v as isSettingsReadUnavailable, y as DATAPLANE_SECRET_HEADER$1 } from "./builtins/local-auth/local-auth.addon.mjs";
|
|
26
38
|
import "./builtins/local-auth/index.mjs";
|
|
27
39
|
import { a as lineContainsText, i as levelRank, n as compileLogFilter, o as lineMatches, r as filterIsEmpty, s as originNodeOf, t as bareAddonOf } from "./log-read-filter-D7Ev3zm-.mjs";
|
|
28
40
|
import { LokiDestination, LokiLoggingAddon } from "./builtins/loki-logging/index.mjs";
|
|
29
41
|
import NativeMetricsAddon, { a as NativeMetricsProvider, i as parseProcStatusRss, n as nodeProcReader, r as parseProcStat } from "./builtins/native-metrics/native-metrics.addon.mjs";
|
|
30
42
|
import { DeviceHistoryAddon } from "./builtins/device-history/device-history.addon.mjs";
|
|
31
43
|
import { FilesystemStorageAddon, t as FilesystemStorageProvider } from "./builtins/sqlite-storage/filesystem-storage.addon.mjs";
|
|
32
|
-
import {
|
|
33
|
-
import { n as clearLegacyIntegrationRows, o as readLegacyIntegrationRows } from "./legacy-integration-rows-door-D9tQOUzh.mjs";
|
|
44
|
+
import { n as clearLegacyIntegrationRows, o as readLegacyIntegrationRows } from "./legacy-integration-rows-door-nTvo_6jQ.mjs";
|
|
34
45
|
import { SqliteSettingsAddon } from "./builtins/sqlite-storage/sqlite-settings.addon.mjs";
|
|
35
46
|
import { ConfigStore, DeviceStore } from "./builtins/sqlite-storage/index.mjs";
|
|
36
47
|
import { StorageOrchestratorAddon, a as createHubCapForwardService, i as HUB_CAP_FWD_SERVICE, o as stripForwardedCaller, r as HUB_CAP_FWD_ACTION, s as buildStorageLocationRegistry, t as StorageOrchestratorService, u as storageOrchestratorRecordKinds } from "./builtins/storage-orchestrator/storage-orchestrator.addon.mjs";
|
|
37
48
|
import "./builtins/storage-orchestrator/index.mjs";
|
|
38
|
-
import { A as evaluateExistingCert, B as AGENT_HTTPS_NAMES_COLLECTION, C as localCaCommonName, D as LEAF_RENEWAL_WINDOW_DAYS, E as CA_VALIDITY_DAYS, F as isConstrainedCa, H as AgentHttpsNames, I as isLocalOnlyHostname, L as permitsIdentity, M as PERMITTED_DNS_SUFFIXES, N as PERMITTED_IP_RANGES, O as MAX_LEAF_VALIDITY_DAYS, P as buildNameConstraintSet, R as permitsName, T as systemHostFacts, U as getProcessAgentHttpsNames, V as AGENT_HTTPS_NAMES_COLUMNS, W as setProcessAgentHttpsNames, _ as pemDigest, a as AgentHttpsInstallError, c as certificateNames, d as describeHttpsLeaf, f as installAgentHttps, g as loadAgentHttps, h as issueAgentHttpsLeaf, i as loadOrCreateHubId, k as SERVER_AUTH_OID, l as collectAgentNames, m as isPrivateAddress, n as HUB_IDENTITY_RELATIVE, o as acceptAgentSans, p as isContainerBridgeAddress, r as isAnnouncedHubId, s as agentHttpsPaths, t as HUB_IDENTITY_FILE, u as createAgentHttpsRequest, v as pinnedHttpsCaFingerprint, w as collectCertIdentity, y as CA_COMMON_NAME, z as readNameConstraints } from "./hub-identity-
|
|
39
|
-
import { a as MESH_CA_KEY_REF, i as MESH_CA_FIELD, n as DEFAULT_HUB_TLS_TCP_PORT, o as MESH_CA_SETTINGS_KEY } from "./constants-
|
|
49
|
+
import { A as evaluateExistingCert, B as AGENT_HTTPS_NAMES_COLLECTION, C as localCaCommonName, D as LEAF_RENEWAL_WINDOW_DAYS, E as CA_VALIDITY_DAYS, F as isConstrainedCa, H as AgentHttpsNames, I as isLocalOnlyHostname, L as permitsIdentity, M as PERMITTED_DNS_SUFFIXES, N as PERMITTED_IP_RANGES, O as MAX_LEAF_VALIDITY_DAYS, P as buildNameConstraintSet, R as permitsName, T as systemHostFacts, U as getProcessAgentHttpsNames, V as AGENT_HTTPS_NAMES_COLUMNS, W as setProcessAgentHttpsNames, _ as pemDigest, a as AgentHttpsInstallError, c as certificateNames, d as describeHttpsLeaf, f as installAgentHttps, g as loadAgentHttps, h as issueAgentHttpsLeaf, i as loadOrCreateHubId, k as SERVER_AUTH_OID, l as collectAgentNames, m as isPrivateAddress, n as HUB_IDENTITY_RELATIVE, o as acceptAgentSans, p as isContainerBridgeAddress, r as isAnnouncedHubId, s as agentHttpsPaths, t as HUB_IDENTITY_FILE, u as createAgentHttpsRequest, v as pinnedHttpsCaFingerprint, w as collectCertIdentity, y as CA_COMMON_NAME, z as readNameConstraints } from "./hub-identity-DjMN9Ac2.mjs";
|
|
50
|
+
import { a as MESH_CA_KEY_REF, i as MESH_CA_FIELD, n as DEFAULT_HUB_TLS_TCP_PORT, o as MESH_CA_SETTINGS_KEY } from "./constants-DB4piTD5.mjs";
|
|
40
51
|
import { $ as getProcessMeshCaState, A as emitProcessNodeRegistered, At as readCidrSetting, B as getProcessMeshTlsListenerState, C as verifyMembershipAnswer, Ct as isInsecureOrigin, D as ServiceBroker, Dt as createCidrMatcher, E as Errors, Et as readOriginSetting, F as onProcessNodeRegistered, G as MeshCertificateRegistry, H as setProcessMeshTlsListenerState, I as setProcessMeshHandshakeReporter, J as getProcessMeshCertificateRegistry, K as RENEWAL_ABANDONED, L as setProcessMeshPeerTransportLookup, M as getProcessNodeMeshTransport, N as getProcessPeerLeaf, O as setProcessMeshTlsEnabler, Ot as normalizeIp, P as isProcessVerifiedMeshPeer, Q as MeshCaKeeper, R as renewMeshCertificate, S as signMembershipProof, St as OPAQUE_ORIGIN, SystemConfigAddon, T as TlsTcpTransporter, Tt as parseOriginList, U as MESH_NODE_CERTIFICATES_COLLECTION, V as openMeshTlsWhenRevocationsLoaded, W as MESH_NODE_CERTIFICATES_COLUMNS, X as MeshCrl, Y as setProcessMeshCertificateRegistry, Z as processMeshCrl, _ as keyFingerprintShort, _t as isAllowedAgentDashboardReturnTo, a as dialableHubHost, at as generateMeshCa, b as MEMBERSHIP_PATHS, bt as verifyAgentUiUnlockTicket, c as PAIRING_MAX_CODE_ATTEMPTS, ct as issueMeshLeafForNode, d as PAIRING_PIN_DIGITS, dt as AGENT_DASHBOARD_ORIGINS_FIELD, et as requireProcessMeshCa, f as PAIRING_PROTOCOL, ft as AGENT_UI_UNLOCK_TTL_MS, g as describeCsr, gt as UnlockTicketJtiStore, h as computePairingSas, ht as AGENT_UI_UNLOCK_VERSION, i as AgentPairing, it as exportMeshPrivateKeyPem, j as getProcessMeshHandshakeReporter, k as dropProcessPeer, kt as parseCidrList, l as PAIRING_MAX_SESSIONS, lt as issueMeshLeafFromCsr, m as computePairingCommitment, mt as AGENT_UI_UNLOCK_USE, n as HubPairing, nt as caFingerprintCompact, o as hubHostFromMeshAddress, ot as generateMeshKeyPair, p as PAIRING_TTL_MS, pt as AGENT_UI_UNLOCK_TYP, q as describeMeshLeaf, r as PairingHttpError, rt as createMeshCsrPem, s as PAIRING_CODE_DIGITS, st as isValidAgentNodeId, tt as caFingerprint, u as PAIRING_PATHS, ut as loadMeshCa, v as signPairingProof, vt as mintAgentUiUnlockTicket, w as MESH_TLS_PORT_HELLO_FIELD, wt as normalizeOrigin, x as MembershipResponder, xt as InvalidCorsOriginError, y as verifyPairingProof, yt as parseAgentDashboardOrigins, z as revokeMeshCertificate } from "./builtins/system-config/system-config.addon.mjs";
|
|
41
52
|
import "./builtins/system-config/index.mjs";
|
|
42
53
|
import { WinstonDestination, WinstonLoggingAddon } from "./builtins/winston-logging/index.mjs";
|
|
43
54
|
import { C as isModelDownloaded, E as setHuggingFaceReachabilityObserver, T as revisionWeightUrl, _ as downloadFile, a as startEventLoopStallMonitor, b as fetchJson, c as createAuthenticatedFileServer, d as resolveFilePath, f as ModelDownloadService, g as deleteModelFromDisk, h as collectModelFiles, i as attributeStall, l as parseRangeHeader, m as adoptModelRevisions, n as STALL_REPORT_MS, o as createFileDataPlaneHandler, r as STALL_TICK_MS, s as contentTypeFor, t as CustomActionRegistry, u as parseTokenizedUrl, v as downloadModel, w as resolveFormatRevision, x as getModelFilePath, y as ensureModel } from "./custom-action-registry-B9zFBNVa.mjs";
|
|
44
|
-
import { A as retirePreviousLocalCa, C as checkUploadedCa, D as loadTlsCert, E as ensureTlsCert, F as closeLanHttp, I as readLanHttpState, L as registerLanHttpHandler, M as allFamiliesListenHost, N as applyLanHttp, O as reissueTlsLeaf, P as bindPendingLanHttp, S as chainsToPublicRoot, T as caReplacementMarkerFile, _ as readTlsMode, a as storeUploadedCertificate, b as writeTlsEnabled, c as leafFingerprintOf, d as servedHttpsLeafFingerprint, f as prepareBootTls, g as readTlsEnabled, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as DEFAULT_LAN_HTTP_PORT, k as replaceUnconstrainedLocalCa, l as registerHttpsListener, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, p as UPLOADED_CA_FILE, r as regenerateCertificate, s as clearHttpsListener, t as createCiaoPublisher, u as reloadHttpsListener, v as splitPemCertificates, w as validateUploadedTls, x as writeTlsMode, y as writeExtraSans } from "./hub-mdns-ciao-
|
|
55
|
+
import { A as retirePreviousLocalCa, C as checkUploadedCa, D as loadTlsCert, E as ensureTlsCert, F as closeLanHttp, I as readLanHttpState, L as registerLanHttpHandler, M as allFamiliesListenHost, N as applyLanHttp, O as reissueTlsLeaf, P as bindPendingLanHttp, S as chainsToPublicRoot, T as caReplacementMarkerFile, _ as readTlsMode, a as storeUploadedCertificate, b as writeTlsEnabled, c as leafFingerprintOf, d as servedHttpsLeafFingerprint, f as prepareBootTls, g as readTlsEnabled, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as DEFAULT_LAN_HTTP_PORT, k as replaceUnconstrainedLocalCa, l as registerHttpsListener, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, p as UPLOADED_CA_FILE, r as regenerateCertificate, s as clearHttpsListener, t as createCiaoPublisher, u as reloadHttpsListener, v as splitPemCertificates, w as validateUploadedTls, x as writeTlsMode, y as writeExtraSans } from "./hub-mdns-ciao-DBrtHOcc.mjs";
|
|
45
56
|
import { n as getPlatformKeychainKey, r as setPlatformKeychainKey, t as clearPlatformKeychainKey } from "./platform-key-source-BWlq0jjn.mjs";
|
|
46
57
|
import { n as getSinglePidStats, t as getPidStats } from "./resource-monitor-Di9daRwI.mjs";
|
|
47
|
-
import { _ as backupRecordStoresOf, c as BackupDecryptError, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, h as readBackupEncryptionHeader, l as BackupKeyFormatError, r as prepareRestoreArchive, s as SystemBackupService, t as BackupKeyRequiredError, u as BackupKeyMismatchError } from "./restore-archive-
|
|
48
|
-
import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-DBlgWB8k.mjs";
|
|
58
|
+
import { _ as backupRecordStoresOf, c as BackupDecryptError, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, h as readBackupEncryptionHeader, l as BackupKeyFormatError, r as prepareRestoreArchive, s as SystemBackupService, t as BackupKeyRequiredError, u as BackupKeyMismatchError } from "./restore-archive-CjAyKpgX.mjs";
|
|
49
59
|
import { z } from "zod";
|
|
50
60
|
import * as crypto$1 from "node:crypto";
|
|
51
61
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
@@ -71,6 +81,608 @@ import { monitorEventLoopDelay } from "node:perf_hooks";
|
|
|
71
81
|
import * as vm from "node:vm";
|
|
72
82
|
import { TRPCClientError, createTRPCClient } from "@trpc/client";
|
|
73
83
|
import { noiseEventCategories } from "@camstack/types/enums";
|
|
84
|
+
//#region ../types/dist/esm/addon/addon-instance.mjs
|
|
85
|
+
/**
|
|
86
|
+
* The integration instance of an addon, as it appears in an address or on an
|
|
87
|
+
* OAuth link (planning#415, D1046).
|
|
88
|
+
*
|
|
89
|
+
* The DEFAULT instance has two spellings on the wire and one in the code: a
|
|
90
|
+
* path with no instance segment and a link with no instance both mean it, and
|
|
91
|
+
* its id is the addon id. {@link oauthLinkServesInstance} is the one
|
|
92
|
+
* comparison a per-instance route is meant to call, so nobody compares
|
|
93
|
+
* `undefined` with an id. The Alexa export's routes are its first caller.
|
|
94
|
+
*/
|
|
95
|
+
/** An instance id as it may appear in a path or a query: no separator, no escape, bounded. */
|
|
96
|
+
var ADDON_INSTANCE_ID_RE = /^[A-Za-z0-9._-]{1,64}$/;
|
|
97
|
+
function isAddonInstanceId(value) {
|
|
98
|
+
return ADDON_INSTANCE_ID_RE.test(value);
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region ../types/dist/esm/interfaces/logging.mjs
|
|
102
|
+
/**
|
|
103
|
+
* Severity ordering. Declared once here because it had already been re-declared
|
|
104
|
+
* three times independently (`kernel/transport/uds-logger.ts`,
|
|
105
|
+
* `builtins/loki-logging/loki-destination.ts`, and the log buffer) — four copies
|
|
106
|
+
* of the same four numbers is four chances for one of them to disagree.
|
|
107
|
+
*
|
|
108
|
+
* `uds-logger` keeps its own copy on purpose: it ranks a plain `string` coming off
|
|
109
|
+
* the wire and needs a tolerant fallback for an unknown value, which this typed
|
|
110
|
+
* map deliberately does not offer.
|
|
111
|
+
*/
|
|
112
|
+
var LOG_LEVEL_RANK = {
|
|
113
|
+
debug: 0,
|
|
114
|
+
info: 1,
|
|
115
|
+
warn: 2,
|
|
116
|
+
error: 3
|
|
117
|
+
};
|
|
118
|
+
/** True when `level` is no more severe than `threshold` — i.e. prunable/filterable. */
|
|
119
|
+
function logLevelAtMost(level, threshold) {
|
|
120
|
+
return LOG_LEVEL_RANK[level] <= LOG_LEVEL_RANK[threshold];
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region ../types/dist/esm/logging/debug-watch.mjs
|
|
124
|
+
/** Every debug channel's name starts with this; the ring denies it by default. */
|
|
125
|
+
var DEBUG_CHANNEL_PREFIX = "debug.";
|
|
126
|
+
function isDebugChannelName(name) {
|
|
127
|
+
return name.startsWith(DEBUG_CHANNEL_PREFIX);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Who is watching what, in THIS process. In-memory, moved off the log path.
|
|
131
|
+
*
|
|
132
|
+
* `active` is a plain boolean FIELD, read first: with no watch anywhere, a
|
|
133
|
+
* `ctx.debug` call is one load and one branch.
|
|
134
|
+
*/
|
|
135
|
+
var DebugInterest = class {
|
|
136
|
+
active = false;
|
|
137
|
+
windows = /* @__PURE__ */ new Map();
|
|
138
|
+
/**
|
|
139
|
+
* Replace the interest with the FULL set of windows. Non-debug windows are
|
|
140
|
+
* ignored and an absent one is dropped, so a lost disarm cannot leave a
|
|
141
|
+
* channel running.
|
|
142
|
+
*/
|
|
143
|
+
apply(windows, nowMs) {
|
|
144
|
+
this.windows.clear();
|
|
145
|
+
for (const window of windows) {
|
|
146
|
+
if (!isDebugChannelName(window.channel) || window.armedUntilMs <= nowMs) continue;
|
|
147
|
+
const ids = window.deviceIds;
|
|
148
|
+
this.windows.set(window.channel, {
|
|
149
|
+
untilMs: window.armedUntilMs,
|
|
150
|
+
devices: ids === null || ids.length === 0 ? null : new Set(ids)
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
this.active = this.windows.size > 0;
|
|
154
|
+
}
|
|
155
|
+
/** Drop what has lapsed. Called on a timer, never from a log path. */
|
|
156
|
+
tick(nowMs) {
|
|
157
|
+
const closed = [];
|
|
158
|
+
for (const [name, window] of this.windows) if (window.untilMs <= nowMs) {
|
|
159
|
+
this.windows.delete(name);
|
|
160
|
+
closed.push(name);
|
|
161
|
+
}
|
|
162
|
+
this.active = this.windows.size > 0;
|
|
163
|
+
return closed;
|
|
164
|
+
}
|
|
165
|
+
/** `channel` is the full name, `debug.<channel>`. */
|
|
166
|
+
wants(channel, deviceId) {
|
|
167
|
+
if (!this.active) return false;
|
|
168
|
+
const window = this.windows.get(channel);
|
|
169
|
+
if (window === void 0) return false;
|
|
170
|
+
return window.devices === null || window.devices.has(deviceId);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var interestInstance = null;
|
|
174
|
+
function getDebugInterest() {
|
|
175
|
+
interestInstance ??= new DebugInterest();
|
|
176
|
+
return interestInstance;
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region ../types/dist/esm/readiness/readiness-registry.mjs
|
|
180
|
+
var ReadinessTimeoutError = class extends Error {
|
|
181
|
+
capName;
|
|
182
|
+
scope;
|
|
183
|
+
waitedMs;
|
|
184
|
+
constructor(capName, scope, waitedMs) {
|
|
185
|
+
super(`Timed out waiting for ${capName} (${scopeKey(scope)}) to become ready after ${waitedMs}ms`);
|
|
186
|
+
this.name = "ReadinessTimeoutError";
|
|
187
|
+
this.capName = capName;
|
|
188
|
+
this.scope = scope;
|
|
189
|
+
this.waitedMs = waitedMs;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Build a canonical string key for a `(capName, scope)` pair. Used as
|
|
194
|
+
* the snapshot map key and for log/debug output.
|
|
195
|
+
*/
|
|
196
|
+
function readinessKey(capName, scope) {
|
|
197
|
+
return `${capName}|${scopeKey(scope)}`;
|
|
198
|
+
}
|
|
199
|
+
function scopeKey(scope) {
|
|
200
|
+
switch (scope.type) {
|
|
201
|
+
case "global": return "global";
|
|
202
|
+
case "node": return `node:${scope.nodeId}`;
|
|
203
|
+
case "device": return `device:${scope.deviceId}`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Producer transition order within ONE generation: `starting → ready →
|
|
208
|
+
* down`. Used by `hydrate` to accept only forward moves for
|
|
209
|
+
* same-generation snapshot records (a snapshot can be ahead of a lost
|
|
210
|
+
* delta, never behind it, within one producer generation).
|
|
211
|
+
*/
|
|
212
|
+
function stateRank(state) {
|
|
213
|
+
switch (state) {
|
|
214
|
+
case "starting": return 0;
|
|
215
|
+
case "ready": return 1;
|
|
216
|
+
case "down": return 2;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function scopesEqual(a, b) {
|
|
220
|
+
if (a.type !== b.type) return false;
|
|
221
|
+
if (a.type === "global" || b.type === "global") return true;
|
|
222
|
+
if (a.type === "node" && b.type === "node") return a.nodeId === b.nodeId;
|
|
223
|
+
if (a.type === "device" && b.type === "device") return a.deviceId === b.deviceId;
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
var ReadinessRegistry = class {
|
|
227
|
+
bus;
|
|
228
|
+
sourceNodeId;
|
|
229
|
+
logger;
|
|
230
|
+
now;
|
|
231
|
+
generation;
|
|
232
|
+
verboseDeviceScopeLogs;
|
|
233
|
+
snapshot = /* @__PURE__ */ new Map();
|
|
234
|
+
subscriptions = /* @__PURE__ */ new Set();
|
|
235
|
+
unsubscribeBus;
|
|
236
|
+
unsubscribeAgentOffline;
|
|
237
|
+
constructor(options) {
|
|
238
|
+
this.bus = options.eventBus;
|
|
239
|
+
this.sourceNodeId = options.sourceNodeId;
|
|
240
|
+
this.logger = options.logger;
|
|
241
|
+
this.now = options.now ?? (() => Date.now());
|
|
242
|
+
this.generation = options.generation ?? randomGeneration();
|
|
243
|
+
this.verboseDeviceScopeLogs = options.verboseDeviceScopeLogs ?? false;
|
|
244
|
+
this.unsubscribeBus = this.bus.subscribe({ category: "system.ready-state" }, (event) => this.ingest(event.data));
|
|
245
|
+
this.unsubscribeAgentOffline = this.bus.subscribe({ category: "agent.offline" }, (event) => this.synthesizeDownForNode(event.data.agentId));
|
|
246
|
+
if (typeof this.bus.getRecent === "function") try {
|
|
247
|
+
const recent = this.bus.getRecent({ category: "system.ready-state" });
|
|
248
|
+
for (const event of recent) this.ingest(event.data);
|
|
249
|
+
} catch {}
|
|
250
|
+
}
|
|
251
|
+
/** Release the event-bus subscription. Idempotent. */
|
|
252
|
+
close() {
|
|
253
|
+
this.unsubscribeBus();
|
|
254
|
+
this.unsubscribeAgentOffline();
|
|
255
|
+
this.subscriptions.clear();
|
|
256
|
+
}
|
|
257
|
+
/** Current snapshot for a `(capName, scope)` pair, or `null` if never seen. */
|
|
258
|
+
get(capName, scope) {
|
|
259
|
+
return this.snapshot.get(readinessKey(capName, scope)) ?? null;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Serializable snapshot for cross-process transport. Returns an array
|
|
263
|
+
* of `ReadinessRecord` plain objects — safe for MsgPack / JSON
|
|
264
|
+
* transport. Used by the hub's `$readiness.getSnapshot` Moleculer
|
|
265
|
+
* action; consumers hydrate their local registry from the result.
|
|
266
|
+
*/
|
|
267
|
+
getSnapshotForTransport() {
|
|
268
|
+
return Array.from(this.snapshot.values());
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Hydrate the snapshot from an authoritative source — a RECONCILE, not
|
|
272
|
+
* an add-only merge (D8: readiness events are telemetry and may be
|
|
273
|
+
* lost; the on-reconnect/periodic snapshot re-pull is the repair path,
|
|
274
|
+
* so it MUST be able to advance a stale record — the 2026-07-17
|
|
275
|
+
* "still awaiting platform-probe forever" wedge was this method
|
|
276
|
+
* skipping every already-seen key).
|
|
277
|
+
*
|
|
278
|
+
* - **Unseen keys** are added (epoch 1 — mirrors the value the
|
|
279
|
+
* consumer would have derived from the first observed `ready`).
|
|
280
|
+
* - **Existing keys** are UPDATED when the authoritative record
|
|
281
|
+
* carries a different generation (producer restart / synthetic-down
|
|
282
|
+
* superseded — epoch bumps on a new-generation `ready`, mirroring
|
|
283
|
+
* `ingest`), or a FORWARD state move within the same generation
|
|
284
|
+
* (`starting → ready → down`; within one producer generation a
|
|
285
|
+
* snapshot can only be ahead of a lost delta, never behind it).
|
|
286
|
+
* - **Never a same-generation regress** — a snapshot pulled just
|
|
287
|
+
* before a live delta landed must not un-ready a record (the next
|
|
288
|
+
* reconcile round converges it anyway).
|
|
289
|
+
* - **Never a record this process is authoritative for** — node-scoped
|
|
290
|
+
* records for our own nodeId, and device/global records we emitted,
|
|
291
|
+
* keep local truth (an authority's stale copy of OUR record must
|
|
292
|
+
* not regress us).
|
|
293
|
+
*
|
|
294
|
+
* Every applied entry dispatches a one-shot transition to matching
|
|
295
|
+
* subscriptions so pending `awaitReady` callers unblock without having
|
|
296
|
+
* to wait for a fresh event.
|
|
297
|
+
*
|
|
298
|
+
* Returns the number of records APPLIED (added or advanced). Callers
|
|
299
|
+
* doing periodic reconciles use this to stay silent when the snapshot
|
|
300
|
+
* changed nothing — the every-60s "hydrated 1446 record(s)" heartbeat
|
|
301
|
+
* from every child process was pure noise (≈2 800 lines/hour observed
|
|
302
|
+
* live on 2026-08-01).
|
|
303
|
+
*/
|
|
304
|
+
hydrate(records) {
|
|
305
|
+
const now = this.now();
|
|
306
|
+
let applied = 0;
|
|
307
|
+
for (const record of records) {
|
|
308
|
+
const key = readinessKey(record.capName, record.scope);
|
|
309
|
+
const prev = this.snapshot.get(key) ?? null;
|
|
310
|
+
let epoch;
|
|
311
|
+
let durationInPrevState;
|
|
312
|
+
if (prev !== null) {
|
|
313
|
+
if (this.isLocallyAuthoritative(prev)) continue;
|
|
314
|
+
const sameGeneration = prev.generation === record.generation;
|
|
315
|
+
if (sameGeneration && stateRank(record.state) <= stateRank(prev.state)) continue;
|
|
316
|
+
epoch = !sameGeneration && record.state === "ready" ? prev.epoch + 1 : prev.epoch;
|
|
317
|
+
durationInPrevState = Math.max(0, now - prev.lastChange);
|
|
318
|
+
} else {
|
|
319
|
+
epoch = 1;
|
|
320
|
+
durationInPrevState = 0;
|
|
321
|
+
}
|
|
322
|
+
const hydrated = {
|
|
323
|
+
capName: record.capName,
|
|
324
|
+
scope: record.scope,
|
|
325
|
+
state: record.state,
|
|
326
|
+
generation: record.generation,
|
|
327
|
+
epoch,
|
|
328
|
+
lastChange: now,
|
|
329
|
+
sourceNodeId: record.sourceNodeId
|
|
330
|
+
};
|
|
331
|
+
this.snapshot.set(key, hydrated);
|
|
332
|
+
applied++;
|
|
333
|
+
this.logPerRecord(record.scope, `readiness: ${record.capName} (${scopeKey(record.scope)}) → ${record.state} (hydrated${prev !== null ? " update" : ""}, gen=${record.generation.slice(0, 6)})`);
|
|
334
|
+
const transition = {
|
|
335
|
+
capName: record.capName,
|
|
336
|
+
scope: record.scope,
|
|
337
|
+
state: record.state,
|
|
338
|
+
epoch,
|
|
339
|
+
generation: record.generation,
|
|
340
|
+
sourceNodeId: "hydrated",
|
|
341
|
+
ts: now,
|
|
342
|
+
durationInPrevState
|
|
343
|
+
};
|
|
344
|
+
for (const sub of this.subscriptions) {
|
|
345
|
+
if (sub.capName !== record.capName) continue;
|
|
346
|
+
if (!scopesEqual(sub.scope, record.scope)) continue;
|
|
347
|
+
try {
|
|
348
|
+
sub.handler(transition);
|
|
349
|
+
} catch (err) {
|
|
350
|
+
this.logger?.warn(`readiness hydrate handler threw for ${record.capName}: ${err.message ?? String(err)}`);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return applied;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Per-record debug line, volume-gated: device-scoped records are logged
|
|
358
|
+
* only when `verboseDeviceScopeLogs` is set (see the option's doc for
|
|
359
|
+
* the 21 577-lines-per-boot-minute incident that forced the gate);
|
|
360
|
+
* node/global records always log. Device lines carry `tags.deviceId`
|
|
361
|
+
* so they group per-camera (CLAUDE.md logging rule).
|
|
362
|
+
*/
|
|
363
|
+
logPerRecord(scope, message) {
|
|
364
|
+
if (!this.logger) return;
|
|
365
|
+
if (scope.type === "device") {
|
|
366
|
+
if (!this.verboseDeviceScopeLogs) return;
|
|
367
|
+
this.logger.debug(message, { tags: { deviceId: scope.deviceId } });
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
this.logger.debug(message);
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* True when THIS process is the origin authority for `record` — a
|
|
374
|
+
* snapshot pulled from elsewhere must never overwrite it:
|
|
375
|
+
* - node-scoped records whose `scope.nodeId` is our own node id
|
|
376
|
+
* (this process — or a child bridged onto our bus — emits them);
|
|
377
|
+
* - device/global-scoped records whose latest transition WE emitted.
|
|
378
|
+
*/
|
|
379
|
+
isLocallyAuthoritative(record) {
|
|
380
|
+
if (record.scope.type === "node") return record.scope.nodeId === this.sourceNodeId;
|
|
381
|
+
return record.sourceNodeId === this.sourceNodeId;
|
|
382
|
+
}
|
|
383
|
+
/** Shallow copy of the full snapshot — mainly for diagnostics/tests. */
|
|
384
|
+
getAll() {
|
|
385
|
+
return new Map(this.snapshot);
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Emit a `ready` transition for a locally-owned capability. The
|
|
389
|
+
* payload carries this registry's `generation` so remote registries
|
|
390
|
+
* can derive their own `epoch`.
|
|
391
|
+
*/
|
|
392
|
+
emitReady(capName, scope) {
|
|
393
|
+
this.emitTransition(capName, scope, "ready");
|
|
394
|
+
}
|
|
395
|
+
emitStarting(capName, scope) {
|
|
396
|
+
this.emitTransition(capName, scope, "starting");
|
|
397
|
+
}
|
|
398
|
+
emitDown(capName, scope) {
|
|
399
|
+
this.emitTransition(capName, scope, "down");
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* One-shot: resolve once the cap is `ready`. Reads the snapshot
|
|
403
|
+
* first — if already ready, resolves synchronously on the next tick.
|
|
404
|
+
*
|
|
405
|
+
* Default behaviour is **wait indefinitely** (timeoutMs = `Infinity`):
|
|
406
|
+
* the orchestrator and other callers never want to attach a camera
|
|
407
|
+
* with empty steps just because a cap took longer than 30s to come
|
|
408
|
+
* up. Pass an explicit finite `timeoutMs` to bound the wait, or an
|
|
409
|
+
* `AbortSignal` to cancel externally. `Infinity` is honoured natively
|
|
410
|
+
* — no `setTimeout` is registered (Node's setTimeout silently clamps
|
|
411
|
+
* values above ~24.8d, so we must skip the timer entirely).
|
|
412
|
+
*/
|
|
413
|
+
awaitReady(capName, scope, opts = {}) {
|
|
414
|
+
const timeoutMs = opts.timeoutMs ?? Number.POSITIVE_INFINITY;
|
|
415
|
+
const start = this.now();
|
|
416
|
+
if (this.get(capName, scope)?.state === "ready") return Promise.resolve();
|
|
417
|
+
if (opts.signal?.aborted) return Promise.reject(opts.signal.reason ?? /* @__PURE__ */ new Error("aborted"));
|
|
418
|
+
return new Promise((resolve, reject) => {
|
|
419
|
+
let settled = false;
|
|
420
|
+
const unsubscribe = this.onReadyState(capName, scope, (t) => {
|
|
421
|
+
if (t.state !== "ready") return;
|
|
422
|
+
if (settled) return;
|
|
423
|
+
settled = true;
|
|
424
|
+
cleanup();
|
|
425
|
+
resolve();
|
|
426
|
+
});
|
|
427
|
+
const timer = !Number.isFinite(timeoutMs) ? null : setTimeout(() => {
|
|
428
|
+
if (settled) return;
|
|
429
|
+
settled = true;
|
|
430
|
+
cleanup();
|
|
431
|
+
reject(new ReadinessTimeoutError(capName, scope, this.now() - start));
|
|
432
|
+
}, timeoutMs);
|
|
433
|
+
const pendingLogTimer = setInterval(() => {
|
|
434
|
+
if (settled) return;
|
|
435
|
+
this.logger?.warn(`readiness: still awaiting ${capName} (${scopeKey(scope)}) after ${this.now() - start}ms`);
|
|
436
|
+
}, 3e4);
|
|
437
|
+
if (typeof pendingLogTimer.unref === "function") pendingLogTimer.unref();
|
|
438
|
+
const onAbort = () => {
|
|
439
|
+
if (settled) return;
|
|
440
|
+
settled = true;
|
|
441
|
+
cleanup();
|
|
442
|
+
reject(opts.signal?.reason ?? /* @__PURE__ */ new Error("aborted"));
|
|
443
|
+
};
|
|
444
|
+
opts.signal?.addEventListener("abort", onAbort, { once: true });
|
|
445
|
+
function cleanup() {
|
|
446
|
+
unsubscribe();
|
|
447
|
+
if (timer !== null) clearTimeout(timer);
|
|
448
|
+
clearInterval(pendingLogTimer);
|
|
449
|
+
opts.signal?.removeEventListener("abort", onAbort);
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Observable: every transition (starting/ready/down) dispatches to
|
|
455
|
+
* `handler`. On subscription, if the snapshot has a current state,
|
|
456
|
+
* the handler fires ONCE asynchronously with that state as the
|
|
457
|
+
* initial transition (duration = 0) so late subscribers can pick up
|
|
458
|
+
* current state without racing the next transition.
|
|
459
|
+
*
|
|
460
|
+
* Returns an unsubscribe function.
|
|
461
|
+
*/
|
|
462
|
+
onReadyState(capName, scope, handler) {
|
|
463
|
+
const sub = {
|
|
464
|
+
capName,
|
|
465
|
+
scope,
|
|
466
|
+
handler
|
|
467
|
+
};
|
|
468
|
+
this.subscriptions.add(sub);
|
|
469
|
+
const current = this.get(capName, scope);
|
|
470
|
+
if (current !== null) queueMicrotask(() => {
|
|
471
|
+
if (!this.subscriptions.has(sub)) return;
|
|
472
|
+
handler({
|
|
473
|
+
capName,
|
|
474
|
+
scope,
|
|
475
|
+
state: current.state,
|
|
476
|
+
epoch: current.epoch,
|
|
477
|
+
generation: current.generation,
|
|
478
|
+
sourceNodeId: this.sourceNodeId,
|
|
479
|
+
ts: current.lastChange,
|
|
480
|
+
durationInPrevState: 0
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
return () => {
|
|
484
|
+
this.subscriptions.delete(sub);
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
emitTransition(capName, scope, state) {
|
|
488
|
+
const ts = this.now();
|
|
489
|
+
this.bus.emit(createEvent$1("system.ready-state", {
|
|
490
|
+
type: "capability",
|
|
491
|
+
id: capName,
|
|
492
|
+
nodeId: this.sourceNodeId
|
|
493
|
+
}, {
|
|
494
|
+
capName,
|
|
495
|
+
scope,
|
|
496
|
+
state,
|
|
497
|
+
generation: this.generation,
|
|
498
|
+
sourceNodeId: this.sourceNodeId,
|
|
499
|
+
ts
|
|
500
|
+
}));
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Update snapshot + dispatch to subscribers. Idempotent: same
|
|
504
|
+
* `generation + state` replay is a no-op for both snapshot and
|
|
505
|
+
* subscribers.
|
|
506
|
+
*
|
|
507
|
+
* Defensive against malformed payloads (legal reason: a mock bus's
|
|
508
|
+
* `getRecent` may ignore the category filter and replay unrelated
|
|
509
|
+
* events when we hydrate at construction time).
|
|
510
|
+
*/
|
|
511
|
+
ingest(payload) {
|
|
512
|
+
if (typeof payload?.capName !== "string") return;
|
|
513
|
+
if (payload.state !== "ready" && payload.state !== "starting" && payload.state !== "down") return;
|
|
514
|
+
if (typeof payload.generation !== "string") return;
|
|
515
|
+
if (payload.scope?.type !== "global" && payload.scope?.type !== "node" && payload.scope?.type !== "device") return;
|
|
516
|
+
const key = readinessKey(payload.capName, payload.scope);
|
|
517
|
+
const prev = this.snapshot.get(key) ?? null;
|
|
518
|
+
const now = this.now();
|
|
519
|
+
let epoch;
|
|
520
|
+
if (prev === null) epoch = payload.state === "ready" ? 1 : 0;
|
|
521
|
+
else if (prev.generation !== payload.generation && payload.state === "ready") epoch = prev.epoch + 1;
|
|
522
|
+
else epoch = prev.epoch;
|
|
523
|
+
if (prev !== null && prev.generation === payload.generation && prev.state === payload.state) return;
|
|
524
|
+
const durationInPrevState = prev === null ? 0 : Math.max(0, now - prev.lastChange);
|
|
525
|
+
const next = {
|
|
526
|
+
capName: payload.capName,
|
|
527
|
+
scope: payload.scope,
|
|
528
|
+
state: payload.state,
|
|
529
|
+
generation: payload.generation,
|
|
530
|
+
epoch,
|
|
531
|
+
lastChange: now,
|
|
532
|
+
sourceNodeId: payload.sourceNodeId
|
|
533
|
+
};
|
|
534
|
+
this.snapshot.set(key, next);
|
|
535
|
+
const transition = {
|
|
536
|
+
capName: payload.capName,
|
|
537
|
+
scope: payload.scope,
|
|
538
|
+
state: payload.state,
|
|
539
|
+
epoch,
|
|
540
|
+
generation: payload.generation,
|
|
541
|
+
sourceNodeId: payload.sourceNodeId,
|
|
542
|
+
ts: payload.ts,
|
|
543
|
+
durationInPrevState
|
|
544
|
+
};
|
|
545
|
+
this.logPerRecord(payload.scope, `readiness: ${payload.capName} (${scopeKey(payload.scope)}) → ${payload.state} epoch=${epoch} gen=${payload.generation.slice(0, 6)} (prev ${durationInPrevState}ms)`);
|
|
546
|
+
for (const sub of this.subscriptions) {
|
|
547
|
+
if (sub.capName !== payload.capName) continue;
|
|
548
|
+
if (!scopesEqual(sub.scope, payload.scope)) continue;
|
|
549
|
+
try {
|
|
550
|
+
sub.handler(transition);
|
|
551
|
+
} catch (err) {
|
|
552
|
+
this.logger?.warn(`readiness handler threw for ${payload.capName}: ${err.message ?? String(err)}`);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* `agent.offline` demux. When an agent disconnects ungracefully,
|
|
558
|
+
* its BaseAddon's shutdown hook doesn't fire — consumers would
|
|
559
|
+
* otherwise keep waiting on a stale `ready`. Walk the snapshot and
|
|
560
|
+
* synthesize a `down` transition for every node-scoped record bound
|
|
561
|
+
* to the disconnected `nodeId`, skipping records already `down`.
|
|
562
|
+
*
|
|
563
|
+
* Synthesis is LOCAL: we don't re-emit on the bus. Every registry
|
|
564
|
+
* (one per process) receives the same `agent.offline` and reacts
|
|
565
|
+
* independently, which means no duplicated downs and no central
|
|
566
|
+
* supervisor required.
|
|
567
|
+
*/
|
|
568
|
+
synthesizeDownForNode(offlineNodeId) {
|
|
569
|
+
const now = this.now();
|
|
570
|
+
for (const [key, record] of this.snapshot) {
|
|
571
|
+
if (record.state === "down") continue;
|
|
572
|
+
if (!(record.scope.type === "node" && record.scope.nodeId === offlineNodeId || record.scope.type === "device" && record.sourceNodeId === offlineNodeId)) continue;
|
|
573
|
+
const durationInPrevState = Math.max(0, now - record.lastChange);
|
|
574
|
+
const next = {
|
|
575
|
+
...record,
|
|
576
|
+
state: "down",
|
|
577
|
+
lastChange: now
|
|
578
|
+
};
|
|
579
|
+
this.snapshot.set(key, next);
|
|
580
|
+
const transition = {
|
|
581
|
+
capName: record.capName,
|
|
582
|
+
scope: record.scope,
|
|
583
|
+
state: "down",
|
|
584
|
+
epoch: record.epoch,
|
|
585
|
+
generation: record.generation,
|
|
586
|
+
sourceNodeId: this.sourceNodeId,
|
|
587
|
+
ts: now,
|
|
588
|
+
durationInPrevState
|
|
589
|
+
};
|
|
590
|
+
this.logPerRecord(record.scope, `readiness: ${record.capName} (${scopeKey(record.scope)}) → down (synthesized from agent.offline ${offlineNodeId})`);
|
|
591
|
+
for (const sub of this.subscriptions) {
|
|
592
|
+
if (sub.capName !== record.capName) continue;
|
|
593
|
+
if (!scopesEqual(sub.scope, record.scope)) continue;
|
|
594
|
+
try {
|
|
595
|
+
sub.handler(transition);
|
|
596
|
+
} catch (err) {
|
|
597
|
+
this.logger?.warn(`readiness handler threw during agent.offline demux for ${record.capName}: ${err.message ?? String(err)}`);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
function randomGeneration() {
|
|
604
|
+
if (typeof crypto !== "undefined" && crypto.randomUUID) return crypto.randomUUID();
|
|
605
|
+
return Math.random().toString(36).slice(2, 14);
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Given a list of `(capName, scope)` pairs that a just-disconnected
|
|
609
|
+
* node owned, emit a `down` transition for each. Callers (kernel
|
|
610
|
+
* supervisor, hub `$node.disconnected` handler) wire this up once they
|
|
611
|
+
* know which caps the node held.
|
|
612
|
+
*/
|
|
613
|
+
function emitDownForOwnedCaps(registry, owned) {
|
|
614
|
+
for (const { capName, scope } of owned) registry.emitDown(capName, scope);
|
|
615
|
+
}
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region ../types/dist/esm/auth/principal-scope.mjs
|
|
618
|
+
/**
|
|
619
|
+
* True if the scope set grants `access` on device-scoped capabilities.
|
|
620
|
+
* A `category:device` grant covers every device cap (the broad grant).
|
|
621
|
+
*/
|
|
622
|
+
function scopesAllowDeviceCap(scopes, access) {
|
|
623
|
+
return scopes.some((s) => s.type === "category" && s.target === "device" && s.access.includes(access));
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* True if the scope set names this addon with at least `access`.
|
|
627
|
+
*
|
|
628
|
+
* Deliberately NOT satisfied by `category:device`: a grant over per-camera
|
|
629
|
+
* capabilities says nothing about an addon's own HTTP surface, and conflating
|
|
630
|
+
* the two is precisely the confusion that let an Alexa token drive Home
|
|
631
|
+
* Assistant's command route.
|
|
632
|
+
*/
|
|
633
|
+
function scopesAllowAddon(scopes, addonId, access) {
|
|
634
|
+
return scopes.some((s) => s.type === "addon" && s.target === addonId && s.access.includes(access));
|
|
635
|
+
}
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region ../types/dist/esm/capabilities/caller-stamp.mjs
|
|
638
|
+
/**
|
|
639
|
+
* Every cap whose provider reads a `callerAddonId` in its input (the keychain's
|
|
640
|
+
* owner check, device-history's `not-owner`, records' owner).
|
|
641
|
+
*
|
|
642
|
+
* The stamp is set ONLY by the transport (`stampCallerAddonId`, or stated by a
|
|
643
|
+
* hub in-process caller). HTTP/WS mounts parse input with `.loose()`, so a
|
|
644
|
+
* session could add the key itself and act as another addon — those procedures
|
|
645
|
+
* strip it when `ctx.req` is present. Mesh / `$core-caps` calls have no request;
|
|
646
|
+
* the transport stamp must survive to the provider.
|
|
647
|
+
*/
|
|
648
|
+
var CALLER_STAMPED_CAPABILITIES$1 = [
|
|
649
|
+
"keychain",
|
|
650
|
+
"device-history",
|
|
651
|
+
"records",
|
|
652
|
+
"integrations",
|
|
653
|
+
"device-manager",
|
|
654
|
+
"core-blocks",
|
|
655
|
+
"migrations",
|
|
656
|
+
"device-transitions",
|
|
657
|
+
"integration-instances"
|
|
658
|
+
];
|
|
659
|
+
/** A copy of `input` without the caller stamp. Anything that is not a plain object passes through. */
|
|
660
|
+
function withoutCallerStamp(input) {
|
|
661
|
+
if (input === null || typeof input !== "object" || Array.isArray(input)) return input;
|
|
662
|
+
if (!Object.prototype.hasOwnProperty.call(input, "callerAddonId")) return input;
|
|
663
|
+
return Object.fromEntries(Object.entries(input).filter(([key]) => key !== "callerAddonId"));
|
|
664
|
+
}
|
|
665
|
+
var CATALOG_LANGS = AppPageLangSchema.options;
|
|
666
|
+
/** One catalog file: flat key to text. A file of any other shape is rejected whole. */
|
|
667
|
+
var CatalogFileSchema = /* @__PURE__ */ z.record(/* @__PURE__ */ z.string().min(1), /* @__PURE__ */ z.string());
|
|
668
|
+
/** Fills `{name}` placeholders; an unknown placeholder is left as written. */
|
|
669
|
+
function interpolate(template, params) {
|
|
670
|
+
if (params === void 0) return template;
|
|
671
|
+
return template.replace(/\{(\w+)\}/g, (whole, name) => {
|
|
672
|
+
const value = params[name];
|
|
673
|
+
return value === void 0 ? whole : String(value);
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
/** Splits `"ns:key"`; `null` when the reference has no namespace. */
|
|
677
|
+
function splitTranslationRef(ref) {
|
|
678
|
+
const at = ref.indexOf(":");
|
|
679
|
+
if (at <= 0 || at === ref.length - 1) return null;
|
|
680
|
+
return {
|
|
681
|
+
ns: ref.slice(0, at),
|
|
682
|
+
key: ref.slice(at + 1)
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
//#endregion
|
|
74
686
|
//#region src/addon/addon-api-factory.ts
|
|
75
687
|
/**
|
|
76
688
|
* Wrap a raw tRPC caller (from `createCallerFactory`) in a proxy that
|