@camstack/server 1.2.941 → 1.2.943
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/api/trpc/generated-cap-mounts.js +19 -1
- package/dist/api/trpc/generated-cap-routers.js +676 -596
- package/package.json +13 -11
- package/system/dist/action-index-B1fgpQBt.mjs +9925 -0
- package/system/dist/action-index-B_cLRwXJ.js +9972 -0
- package/system/dist/alert-episode-Be--PngO.mjs +64 -0
- package/system/dist/alert-episode-Bqktmt-i.js +93 -0
- package/system/dist/{base-addon-Md14i7pe.mjs → base-addon-BcS6r1cT.mjs} +20 -7
- package/system/dist/{base-addon-DD5dIfcZ.js → base-addon-CRsXtYFG.js} +20 -7
- package/system/dist/{base-device-CH8rfD9j.js → base-device-DAdWzDOl.js} +138 -34
- package/system/dist/{base-device-BcGO6LTT.mjs → base-device-DJXF5eDN.mjs} +138 -34
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alert-episode-policy.d.ts +9 -5
- package/system/dist/builtins/alerts/alerts.addon.js +30 -80
- package/system/dist/builtins/alerts/alerts.addon.mjs +18 -68
- package/system/dist/builtins/autotrack/index.js +2 -2
- package/system/dist/builtins/autotrack/index.mjs +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +9 -9
- package/system/dist/builtins/camera-grid/index.mjs +6 -6
- package/system/dist/builtins/composer/composer.addon.js +99 -99
- package/system/dist/builtins/composer/composer.addon.mjs +11 -11
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/automation-template-instances.d.ts +14 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +6 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +296 -193
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +237 -134
- package/system/dist/builtins/core-blocks/link-contributions.d.ts +2 -0
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +91 -18
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +91 -18
- package/system/dist/builtins/core-notifier/group-notification-output.d.ts +8 -16
- package/system/dist/builtins/device-history/device-history.addon.d.ts +8 -0
- package/system/dist/builtins/device-history/device-history.addon.js +580 -60
- package/system/dist/builtins/device-history/device-history.addon.mjs +569 -49
- package/system/dist/builtins/device-history/retention/device-raw-overrides.d.ts +16 -0
- package/system/dist/builtins/device-history/retention/retention-knobs.d.ts +14 -0
- package/system/dist/builtins/device-history/retention/retention.d.ts +21 -1
- package/system/dist/builtins/device-history/transitions/change-coalescing.d.ts +48 -0
- package/system/dist/builtins/device-history/transitions/derived-changes.d.ts +49 -0
- package/system/dist/builtins/device-history/transitions/history-change-port.d.ts +20 -0
- package/system/dist/builtins/device-history/transitions/transitions-service.d.ts +18 -3
- package/system/dist/builtins/device-manager/device-config-secrets.d.ts +14 -0
- package/system/dist/builtins/device-manager/device-identity-index.d.ts +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +226 -479
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +218 -471
- package/system/dist/builtins/device-manager/device-state-mirror.d.ts +0 -5
- package/system/dist/builtins/device-manager/identity-link-reconciler.d.ts +5 -0
- package/system/dist/builtins/device-manager/transitions/command-recorder.d.ts +38 -0
- package/system/dist/builtins/device-manager/transitions/transitions-wiring.d.ts +8 -9
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +2 -2
- package/system/dist/builtins/keychain/index.mjs +2 -2
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +2 -2
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/address-book.d.ts +3 -1
- package/system/dist/builtins/local-network/local-network.addon.d.ts +26 -1
- package/system/dist/builtins/local-network/local-network.addon.js +66 -11
- package/system/dist/builtins/local-network/local-network.addon.mjs +66 -11
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +4 -4
- package/system/dist/builtins/snapshot/index.mjs +4 -4
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +1 -1
- package/system/dist/builtins/system-config/system-config.addon.mjs +1 -1
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-CUZ3W0oZ.mjs → capture-engine-B2MmoNND.mjs} +1 -1
- package/system/dist/{capture-engine-mtDXEBAq.js → capture-engine-D_1IJmMs.js} +1 -1
- package/system/dist/command-catalog-C29hVOOg.js +210 -0
- package/system/dist/command-catalog-xAeqxbZk.mjs +169 -0
- package/system/dist/{error.cap-DCwbIGEF.mjs → compile-OBMHlqD-.mjs} +97 -100
- package/system/dist/{error.cap-BxLEHP6z.js → compile-SpeAhaZ6.js} +107 -116
- package/system/dist/{composition-sources-B56CU8hi.mjs → composition-sources-C327LGFn.mjs} +2 -2
- package/system/dist/{composition-sources-D_Bfwji0.js → composition-sources-Do5qM6EB.js} +17 -17
- package/system/dist/{core-blocks.cap-xt5_fK5Z.js → core-blocks.cap-CdTGUKtr.js} +194 -10110
- package/system/dist/{core-blocks.cap-DDECcMeI.mjs → core-blocks.cap-DLkEfV5b.mjs} +54 -9910
- package/system/dist/{device-kind-BJ2pfsjw.mjs → device-kind-C37Ra2wd.mjs} +4 -2
- package/system/dist/{device-kind-CsSiv_YF.js → device-kind-FMhJg8uC.js} +4 -2
- package/system/dist/{device-manager.cap-DyHOIh5T.js → device-manager.cap-DJs8izI6.js} +13 -4
- package/system/dist/{device-manager.cap-DIBK62-r.mjs → device-manager.cap-eYrj1Ezp.mjs} +13 -4
- package/system/dist/{device-provider.cap-BKUGJSo0.js → device-provider.cap-CNlYBQ5D.js} +1 -1
- package/system/dist/{device-provider.cap-DU6HMUXH.mjs → device-provider.cap-D8mJllVM.mjs} +1 -1
- package/system/dist/{device-row-store-O4mNbp5q.js → device-row-store-C0P2H18h.js} +2 -2
- package/system/dist/{device-row-store-C-_R-h1Z.mjs → device-row-store-CTocYKqC.mjs} +2 -2
- package/system/dist/{device-type-CbQsnFdC.js → device-type-Cnc0NiSX.js} +13 -0
- package/system/dist/{device-type-DgEvK3ch.mjs → device-type-TUGqGmaI.mjs} +13 -0
- package/system/dist/error.cap-BuKbL3Ac.js +125 -0
- package/system/dist/error.cap-CU1FB6uE.mjs +102 -0
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{history-catalog-BwTeQ4Mr.mjs → history-catalog-A_dzXNpv.mjs} +98 -3
- package/system/dist/{history-catalog-BKRarIL_.js → history-catalog-CiTMP3-E.js} +98 -3
- package/system/dist/index.js +28 -6
- package/system/dist/index.mjs +28 -6
- package/system/dist/kernel/addon-version-policy.d.ts +10 -0
- package/system/dist/{legacy-integration-rows-door-B1nzxxr5.js → legacy-integration-rows-door-CdqYAj-o.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-nTvo_6jQ.mjs → legacy-integration-rows-door-LSgpClpX.mjs} +1 -1
- package/system/dist/{low-power-sleep.cap-B6mz6ojP.js → low-power-sleep.cap-BJWyAuUQ.js} +1 -1
- package/system/dist/{low-power-sleep.cap-C3Vi8Vxj.mjs → low-power-sleep.cap-D9Orx3LS.mjs} +1 -1
- package/system/dist/migrations/hub/2026-11-22-device-transitions-commands-only.d.ts +10 -0
- package/system/dist/{network-access.cap-BEN_uRVb.js → network-access.cap-CTQ2WQoi.js} +38 -12
- package/system/dist/{network-access.cap-Dy8FNNVs.mjs → network-access.cap-Dx5K0I5i.mjs} +33 -13
- package/system/dist/{notification-rules.cap-Drwz-A4n.js → notification-rules.cap-BJKUjizS.js} +45 -9
- package/system/dist/{notification-rules.cap-0vVvsxQ1.mjs → notification-rules.cap-BUIuYPlQ.mjs} +45 -9
- package/system/dist/{notification-targets-DR-D-vIt.mjs → notification-targets-4bGYH5J7.mjs} +2 -2
- package/system/dist/{notification-targets-Cc_3OBH9.js → notification-targets-DMW7xgR2.js} +2 -2
- package/system/dist/{prefix-walk-CCO_VZVo.js → prefix-walk-BFnw8NBu.js} +5 -5
- package/system/dist/{prefix-walk-BhT0ZoKl.mjs → prefix-walk-Mtij0NNT.mjs} +2 -2
- package/system/dist/{ptz-autotrack.cap-DOz0xL0O.js → ptz-autotrack.cap-B9eyZU8w.js} +1 -1
- package/system/dist/{ptz-autotrack.cap-CDF6FeTK.mjs → ptz-autotrack.cap-Dw2k-po9.mjs} +1 -1
- package/system/dist/{recording-archive.cap-RHAN45fa.mjs → recording-archive.cap-CTlm86R8.mjs} +1 -1
- package/system/dist/{recording-archive.cap-BPJ7kvnd.js → recording-archive.cap-Wo-hEZhz.js} +1 -1
- package/system/dist/{rename-composition-block-DWUkrazx.mjs → rename-composition-block-Cdh-dRmY.mjs} +395 -20
- package/system/dist/{rename-composition-block-CH2vRIW7.js → rename-composition-block-D9Uc1AF7.js} +406 -31
- package/system/dist/{retention-CUOVI1p7.mjs → retention-CQs8QR1B.mjs} +33 -3
- package/system/dist/{device-transitions.cap-DCXP3zwY.mjs → retention-source.cap-550kkyp5.mjs} +98 -21
- package/system/dist/{device-transitions.cap-zOGvAIHz.js → retention-source.cap-C6Hy0hlM.js} +103 -20
- package/system/dist/{retention-BcOSL6b9.js → retention-xcjk_k1w.js} +33 -3
- package/system/dist/{snapshot.cap-Cis6JRwn.js → snapshot.cap-CHm29hBs.js} +1 -1
- package/system/dist/{snapshot.cap-BkfHpJVO.mjs → snapshot.cap-CO68YvJU.mjs} +1 -1
- package/system/dist/{stream-catalog.cap-D8Y-uXcy.js → stream-catalog.cap-CjEQFknc.js} +2 -2
- package/system/dist/{stream-catalog.cap-D1Hy19Yc.mjs → stream-catalog.cap-DVniDdRD.mjs} +2 -2
- package/system/dist/{user-management.cap-Ctd4c_im.mjs → user-management.cap-4IEUCSdL.mjs} +2 -2
- package/system/dist/{user-management.cap-DyVb68rY.js → user-management.cap-DV9Jfsj3.js} +2 -2
- package/system/dist/{wal-maintenance-CjpslZUL.mjs → wal-maintenance-Bey5ChBb.mjs} +0 -0
- package/system/dist/{wal-maintenance-DKTXQ7UF.js → wal-maintenance-BgYiAy5b.js} +0 -0
- package/system/package.json +4 -1
- package/system/dist/builtins/device-manager/transitions/transition-correlator.d.ts +0 -81
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_stream_catalog_cap = require("../../stream-catalog.cap-
|
|
4
|
-
const require_base_addon = require("../../base-addon-
|
|
3
|
+
const require_stream_catalog_cap = require("../../stream-catalog.cap-CjEQFknc.js");
|
|
4
|
+
const require_base_addon = require("../../base-addon-CRsXtYFG.js");
|
|
5
5
|
const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
|
|
6
|
-
const require_rename_composition_block = require("../../rename-composition-block-
|
|
7
|
-
const require_notification_targets = require("../../notification-targets-
|
|
8
|
-
const require_notification_rules_cap = require("../../notification-rules.cap-
|
|
6
|
+
const require_rename_composition_block = require("../../rename-composition-block-D9Uc1AF7.js");
|
|
7
|
+
const require_notification_targets = require("../../notification-targets-DMW7xgR2.js");
|
|
8
|
+
const require_notification_rules_cap = require("../../notification-rules.cap-BJKUjizS.js");
|
|
9
9
|
const require_record_kind = require("../../record-kind-DoBfYHCs.js");
|
|
10
10
|
const require_entry_kind = require("../../entry-kind-cq90c--V.js");
|
|
11
|
-
const require_device_manager_cap = require("../../device-manager.cap-
|
|
11
|
+
const require_device_manager_cap = require("../../device-manager.cap-DJs8izI6.js");
|
|
12
12
|
const require_command_origin_claim = require("../../command-origin-claim-Cief660O.js");
|
|
13
13
|
const require_quantity = require("../../quantity-lY1KiTSZ.js");
|
|
14
14
|
const require_tag = require("../../tag-BxLazvVb.js");
|
|
15
|
-
const require_device_type = require("../../device-type-
|
|
16
|
-
const require_device_kind = require("../../device-kind-
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
15
|
+
const require_device_type = require("../../device-type-Cnc0NiSX.js");
|
|
16
|
+
const require_device_kind = require("../../device-kind-FMhJg8uC.js");
|
|
17
|
+
const require_action_index = require("../../action-index-B_cLRwXJ.js");
|
|
18
|
+
const require_core_blocks_cap = require("../../core-blocks.cap-CdTGUKtr.js");
|
|
19
|
+
const require_compile = require("../../compile-SpeAhaZ6.js");
|
|
20
|
+
const require_prefix_walk = require("../../prefix-walk-BFnw8NBu.js");
|
|
20
21
|
const require_l10n = require("../../l10n-CGMvp7NF.js");
|
|
21
22
|
const require_integration_instances_cap = require("../../integration-instances.cap-DSieF1w3.js");
|
|
22
23
|
const require_cap_call_context = require("../../cap-call-context-Bd76CbOW.js");
|
|
23
|
-
const require_composition_sources = require("../../composition-sources-
|
|
24
|
+
const require_composition_sources = require("../../composition-sources-Do5qM6EB.js");
|
|
24
25
|
const require_declared_device = require("../../declared-device-BWphj9WE.js");
|
|
25
26
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
26
|
-
const require_capture_engine = require("../../capture-engine-
|
|
27
|
+
const require_capture_engine = require("../../capture-engine-D_1IJmMs.js");
|
|
27
28
|
const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
|
|
28
29
|
const require_cap_call_scope = require("../../cap-call-scope-8eiugfLl.js");
|
|
29
30
|
let zod = require("zod");
|
|
@@ -666,7 +667,7 @@ async function resolveStepArgsWithTemplates(value, vars, onMissing, render) {
|
|
|
666
667
|
* building the run must not take the steps around it down with it.
|
|
667
668
|
*/
|
|
668
669
|
function commandStepMeta(target, actionId) {
|
|
669
|
-
const found =
|
|
670
|
+
const found = require_action_index.findVocabAction(actionId);
|
|
670
671
|
return {
|
|
671
672
|
kind: "command",
|
|
672
673
|
...found === void 0 ? {} : {
|
|
@@ -2272,8 +2273,8 @@ async function assertStepsOffered(steps, reader) {
|
|
|
2272
2273
|
const ids = [...new Set(commands.flatMap((command) => command.ids))];
|
|
2273
2274
|
const bound = ids.length === 0 ? /* @__PURE__ */ new Map() : await reader.boundCapsOf(ids);
|
|
2274
2275
|
for (const { actionId, ids: named } of commands) {
|
|
2275
|
-
|
|
2276
|
-
for (const id of named)
|
|
2276
|
+
require_action_index.vocabCall(actionId, void 0);
|
|
2277
|
+
for (const id of named) require_action_index.assertDeviceOffers(actionId, id, bound.get(id) ?? []);
|
|
2277
2278
|
}
|
|
2278
2279
|
}
|
|
2279
2280
|
//#endregion
|
|
@@ -2802,7 +2803,7 @@ function guardOf(step, ctx) {
|
|
|
2802
2803
|
/** A device command: resolve the target, substitute the args, dispatch one call per device. */
|
|
2803
2804
|
async function runCommand(step, scope, ctx) {
|
|
2804
2805
|
const { deps, bag } = ctx;
|
|
2805
|
-
|
|
2806
|
+
require_action_index.vocabCall(step.actionId, void 0);
|
|
2806
2807
|
const templated = await resolveStepArgsWithTemplates(step.args ?? {}, bag, (name) => deps.onMissingVar(name), deps.renderTemplates);
|
|
2807
2808
|
if (templated.notes.length > 0) scope.setTemplateNotes(templated.notes);
|
|
2808
2809
|
const args = isPlainRecord$2(templated.value) ? templated.value : {};
|
|
@@ -2814,7 +2815,7 @@ async function runCommand(step, scope, ctx) {
|
|
|
2814
2815
|
scope.markEmpty(target.emptyReason ?? "the target matched no device");
|
|
2815
2816
|
return;
|
|
2816
2817
|
}
|
|
2817
|
-
const call =
|
|
2818
|
+
const call = require_action_index.vocabCall(step.actionId, args);
|
|
2818
2819
|
scope.setArgs(args);
|
|
2819
2820
|
const [only] = target.deviceIds;
|
|
2820
2821
|
if (target.deviceIds.length === 1 && only !== void 0) {
|
|
@@ -3079,8 +3080,8 @@ function stampCondition(condition, resolver) {
|
|
|
3079
3080
|
}
|
|
3080
3081
|
function stampAction(action, resolver) {
|
|
3081
3082
|
if (action.kind !== "command" || action.args === void 0) return action;
|
|
3082
|
-
if (
|
|
3083
|
-
const { cap, method } =
|
|
3083
|
+
if (require_action_index.findVocabAction(action.actionId) === void 0) return action;
|
|
3084
|
+
const { cap, method } = require_action_index.vocabCall(action.actionId, void 0);
|
|
3084
3085
|
const argUnits = { ...action.argUnits };
|
|
3085
3086
|
for (const [arg, value] of Object.entries(action.args)) {
|
|
3086
3087
|
if (typeof value !== "number" || argUnits[arg] !== void 0) continue;
|
|
@@ -3474,6 +3475,24 @@ var BUILTIN_REMOTE_COMPONENTS = [
|
|
|
3474
3475
|
}
|
|
3475
3476
|
];
|
|
3476
3477
|
//#endregion
|
|
3478
|
+
//#region ../types/dist/esm/template/linked-trigger.mjs
|
|
3479
|
+
/**
|
|
3480
|
+
* The typed parameters of the `builtin:linked-trigger` automation template
|
|
3481
|
+
* (D1086): "this device is commanded when that device fires an event". An
|
|
3482
|
+
* instance is an ordinary automation made from the template, so the engine's
|
|
3483
|
+
* traces and run modes apply; the template only fixes the shape. The operator
|
|
3484
|
+
* reads and writes it from the COMMANDED device's Customize tab.
|
|
3485
|
+
*
|
|
3486
|
+
* Sources are events only: a device that fired (`device-fired`, optionally one
|
|
3487
|
+
* part, event, shared kind and payload predicates) or a device event of a
|
|
3488
|
+
* category. The action is a plain on, off or toggle of one capability of the
|
|
3489
|
+
* target. A linked trigger commands the target; it never claims the target's
|
|
3490
|
+
* state (that belongs to the target's own provider, D663).
|
|
3491
|
+
*/
|
|
3492
|
+
var LINKED_TRIGGER_TEMPLATE_ID = "builtin:linked-trigger";
|
|
3493
|
+
/** The input key whose value is the commanded device: the read keys on it. */
|
|
3494
|
+
var LINKED_TRIGGER_TARGET_INPUT = "target";
|
|
3495
|
+
//#endregion
|
|
3477
3496
|
//#region ../types/dist/esm/template/builtin-automation-templates.mjs
|
|
3478
3497
|
/**
|
|
3479
3498
|
* Automation templates shipped with CamStack (#527). They are read-only records
|
|
@@ -3483,102 +3502,9 @@ var BUILTIN_REMOTE_COMPONENTS = [
|
|
|
3483
3502
|
* migration and nothing an operator saved is ever overwritten.
|
|
3484
3503
|
*/
|
|
3485
3504
|
var BUILTIN_TEMPLATE_ID_PREFIX = "builtin:";
|
|
3486
|
-
/**
|
|
3487
|
-
var BUTTON_ROWS_MAX = 6;
|
|
3488
|
-
var ROW_ENTRIES_MAX = 10;
|
|
3489
|
-
/** The optional limit both built-ins end with: no value, no limit. */
|
|
3505
|
+
/** The optional limit a built-in ends with: no value, no limit. */
|
|
3490
3506
|
var ACTIVE_WINDOW_KEY = "active";
|
|
3491
|
-
var activeWindowInput = {
|
|
3492
|
-
kind: "time-window",
|
|
3493
|
-
key: ACTIVE_WINDOW_KEY,
|
|
3494
|
-
label: "Only when",
|
|
3495
|
-
description: "Limit the automation to a time of day, to some days, or both.",
|
|
3496
|
-
optional: true
|
|
3497
|
-
};
|
|
3498
|
-
/** Declared last: it moves the tree the other bindings write into one level down. */
|
|
3499
|
-
var activeWindowGate = {
|
|
3500
|
-
kind: "gate",
|
|
3501
|
-
input: ACTIVE_WINDOW_KEY,
|
|
3502
|
-
path: ["when"]
|
|
3503
|
-
};
|
|
3504
3507
|
var BUILTIN_AUTOMATION_TEMPLATES = [{
|
|
3505
|
-
id: `${BUILTIN_TEMPLATE_ID_PREFIX}buttons-to-devices`,
|
|
3506
|
-
name: "Buttons → devices",
|
|
3507
|
-
payload: {
|
|
3508
|
-
version: 1,
|
|
3509
|
-
description: "Each button: when it sends an event, run one or more actions.",
|
|
3510
|
-
body: {
|
|
3511
|
-
when: {
|
|
3512
|
-
kind: "any",
|
|
3513
|
-
children: []
|
|
3514
|
-
},
|
|
3515
|
-
actions: [{
|
|
3516
|
-
kind: "choose",
|
|
3517
|
-
branches: []
|
|
3518
|
-
}],
|
|
3519
|
-
runMode: {
|
|
3520
|
-
mode: "queued",
|
|
3521
|
-
max: 5
|
|
3522
|
-
}
|
|
3523
|
-
},
|
|
3524
|
-
inputs: [{
|
|
3525
|
-
kind: "group",
|
|
3526
|
-
key: "buttons",
|
|
3527
|
-
label: "Buttons",
|
|
3528
|
-
rowLabel: "button",
|
|
3529
|
-
maxRows: BUTTON_ROWS_MAX,
|
|
3530
|
-
inputs: [{
|
|
3531
|
-
kind: "entries",
|
|
3532
|
-
key: "when",
|
|
3533
|
-
label: "When",
|
|
3534
|
-
entry: "trigger",
|
|
3535
|
-
allow: ["device-fired"],
|
|
3536
|
-
maxItems: ROW_ENTRIES_MAX
|
|
3537
|
-
}, {
|
|
3538
|
-
kind: "entries",
|
|
3539
|
-
key: "do",
|
|
3540
|
-
label: "Actions",
|
|
3541
|
-
entry: "step",
|
|
3542
|
-
allow: ["command"],
|
|
3543
|
-
maxItems: ROW_ENTRIES_MAX
|
|
3544
|
-
}]
|
|
3545
|
-
}, activeWindowInput],
|
|
3546
|
-
bindings: [
|
|
3547
|
-
{
|
|
3548
|
-
kind: "entries",
|
|
3549
|
-
input: "when",
|
|
3550
|
-
in: "buttons",
|
|
3551
|
-
path: ["when", "children"]
|
|
3552
|
-
},
|
|
3553
|
-
{
|
|
3554
|
-
kind: "rows",
|
|
3555
|
-
input: "buttons",
|
|
3556
|
-
path: [
|
|
3557
|
-
"actions",
|
|
3558
|
-
0,
|
|
3559
|
-
"branches"
|
|
3560
|
-
],
|
|
3561
|
-
item: {
|
|
3562
|
-
if: {
|
|
3563
|
-
kind: "triggered-by",
|
|
3564
|
-
leafIds: []
|
|
3565
|
-
},
|
|
3566
|
-
steps: []
|
|
3567
|
-
},
|
|
3568
|
-
bindings: [{
|
|
3569
|
-
kind: "row-ids",
|
|
3570
|
-
input: "when",
|
|
3571
|
-
path: ["if", "leafIds"]
|
|
3572
|
-
}, {
|
|
3573
|
-
kind: "entries",
|
|
3574
|
-
input: "do",
|
|
3575
|
-
path: ["steps"]
|
|
3576
|
-
}]
|
|
3577
|
-
},
|
|
3578
|
-
activeWindowGate
|
|
3579
|
-
]
|
|
3580
|
-
}
|
|
3581
|
-
}, {
|
|
3582
3508
|
id: `${BUILTIN_TEMPLATE_ID_PREFIX}motion-light`,
|
|
3583
3509
|
name: "Motion → light, off after a delay",
|
|
3584
3510
|
payload: {
|
|
@@ -3629,7 +3555,13 @@ var BUILTIN_AUTOMATION_TEMPLATES = [{
|
|
|
3629
3555
|
max: 3600,
|
|
3630
3556
|
default: 300
|
|
3631
3557
|
},
|
|
3632
|
-
|
|
3558
|
+
{
|
|
3559
|
+
kind: "time-window",
|
|
3560
|
+
key: ACTIVE_WINDOW_KEY,
|
|
3561
|
+
label: "Only when",
|
|
3562
|
+
description: "Limit the automation to a time of day, to some days, or both.",
|
|
3563
|
+
optional: true
|
|
3564
|
+
}
|
|
3633
3565
|
],
|
|
3634
3566
|
bindings: [
|
|
3635
3567
|
{
|
|
@@ -3666,7 +3598,72 @@ var BUILTIN_AUTOMATION_TEMPLATES = [{
|
|
|
3666
3598
|
],
|
|
3667
3599
|
as: "target"
|
|
3668
3600
|
},
|
|
3669
|
-
|
|
3601
|
+
{
|
|
3602
|
+
kind: "gate",
|
|
3603
|
+
input: ACTIVE_WINDOW_KEY,
|
|
3604
|
+
path: ["when"]
|
|
3605
|
+
}
|
|
3606
|
+
]
|
|
3607
|
+
}
|
|
3608
|
+
}, {
|
|
3609
|
+
id: LINKED_TRIGGER_TEMPLATE_ID,
|
|
3610
|
+
name: "Linked trigger",
|
|
3611
|
+
payload: {
|
|
3612
|
+
version: 1,
|
|
3613
|
+
description: "Commands one device (on, off or toggle) when a device fires an event.",
|
|
3614
|
+
body: {
|
|
3615
|
+
when: {
|
|
3616
|
+
kind: "any",
|
|
3617
|
+
children: []
|
|
3618
|
+
},
|
|
3619
|
+
actions: [{ kind: "command" }],
|
|
3620
|
+
runMode: {
|
|
3621
|
+
mode: "queued",
|
|
3622
|
+
max: 5
|
|
3623
|
+
}
|
|
3624
|
+
},
|
|
3625
|
+
inputs: [
|
|
3626
|
+
{
|
|
3627
|
+
kind: "device",
|
|
3628
|
+
key: LINKED_TRIGGER_TARGET_INPUT,
|
|
3629
|
+
label: "Device to command"
|
|
3630
|
+
},
|
|
3631
|
+
{
|
|
3632
|
+
kind: "action",
|
|
3633
|
+
key: "action",
|
|
3634
|
+
label: "Action",
|
|
3635
|
+
deviceInput: LINKED_TRIGGER_TARGET_INPUT
|
|
3636
|
+
},
|
|
3637
|
+
{
|
|
3638
|
+
kind: "entries",
|
|
3639
|
+
key: "when",
|
|
3640
|
+
label: "When",
|
|
3641
|
+
entry: "trigger",
|
|
3642
|
+
allow: ["device-fired", "device-event"],
|
|
3643
|
+
maxItems: 10
|
|
3644
|
+
}
|
|
3645
|
+
],
|
|
3646
|
+
bindings: [
|
|
3647
|
+
{
|
|
3648
|
+
kind: "value",
|
|
3649
|
+
input: LINKED_TRIGGER_TARGET_INPUT,
|
|
3650
|
+
path: [
|
|
3651
|
+
"actions",
|
|
3652
|
+
0,
|
|
3653
|
+
"target"
|
|
3654
|
+
],
|
|
3655
|
+
as: "target"
|
|
3656
|
+
},
|
|
3657
|
+
{
|
|
3658
|
+
kind: "value",
|
|
3659
|
+
input: "action",
|
|
3660
|
+
path: ["actions", 0]
|
|
3661
|
+
},
|
|
3662
|
+
{
|
|
3663
|
+
kind: "entries",
|
|
3664
|
+
input: "when",
|
|
3665
|
+
path: ["when", "children"]
|
|
3666
|
+
}
|
|
3670
3667
|
]
|
|
3671
3668
|
}
|
|
3672
3669
|
}];
|
|
@@ -4001,7 +3998,7 @@ function runDwell(segments, to, threshold, startMs, stopMs) {
|
|
|
4001
3998
|
let openAt = null;
|
|
4002
3999
|
const evaluate = (active, at, timer) => {
|
|
4003
4000
|
deadline = null;
|
|
4004
|
-
const answer =
|
|
4001
|
+
const answer = require_compile.evaluateDwell(active, startMs, stopMs, 2, call, at, timer ? timerHooks : hooks);
|
|
4005
4002
|
if (answer === true && openAt === null) openAt = at;
|
|
4006
4003
|
if (answer !== true && openAt !== null) {
|
|
4007
4004
|
intervals.push({
|
|
@@ -7080,6 +7077,7 @@ var HERO_LAYOUT_BY_TYPE = {
|
|
|
7080
7077
|
[require_device_type.DeviceType.WaterHeater]: CLIMATE_LAYOUT,
|
|
7081
7078
|
[require_device_type.DeviceType.HeatPump]: HEAT_PUMP_LAYOUT,
|
|
7082
7079
|
[require_device_type.DeviceType.EnergySystem]: HERO_LAYOUT_DEFAULT,
|
|
7080
|
+
[require_device_type.DeviceType.Vehicle]: HERO_LAYOUT_DEFAULT,
|
|
7083
7081
|
[require_device_type.DeviceType.Workload]: HERO_LAYOUT_DEFAULT,
|
|
7084
7082
|
[require_device_type.DeviceType.Fan]: FAN_LAYOUT,
|
|
7085
7083
|
[require_device_type.DeviceType.MediaPlayer]: MEDIA_PLAYER_LAYOUT,
|
|
@@ -7807,6 +7805,7 @@ var HERO_LOOK_BY_TYPE = {
|
|
|
7807
7805
|
[require_device_type.DeviceType.WaterHeater]: WATER_HEATER_LOOK,
|
|
7808
7806
|
[require_device_type.DeviceType.HeatPump]: HEAT_PUMP_LOOK,
|
|
7809
7807
|
[require_device_type.DeviceType.EnergySystem]: HERO_LOOK_DEFAULT,
|
|
7808
|
+
[require_device_type.DeviceType.Vehicle]: HERO_LOOK_DEFAULT,
|
|
7810
7809
|
[require_device_type.DeviceType.Workload]: HERO_LOOK_DEFAULT,
|
|
7811
7810
|
[require_device_type.DeviceType.Fan]: FAN_LOOK,
|
|
7812
7811
|
[require_device_type.DeviceType.MediaPlayer]: MEDIA_PLAYER_LOOK,
|
|
@@ -7857,6 +7856,9 @@ var HERO_LOOK_BY_ROLE = {
|
|
|
7857
7856
|
[require_device_type.DeviceRole.ClimateRadiator]: "inherit",
|
|
7858
7857
|
[require_device_type.DeviceRole.ClimateHeater]: "inherit",
|
|
7859
7858
|
[require_device_type.DeviceRole.ClimateHeatPumpCircuit]: "inherit",
|
|
7859
|
+
[require_device_type.DeviceRole.ClimateVehicle]: "inherit",
|
|
7860
|
+
[require_device_type.DeviceRole.LockVehicle]: "inherit",
|
|
7861
|
+
[require_device_type.DeviceRole.MediaPlayerTv]: "inherit",
|
|
7860
7862
|
[require_device_type.DeviceRole.MotionSensor]: MOTION_LOOK,
|
|
7861
7863
|
[require_device_type.DeviceRole.ContactSensor]: "inherit",
|
|
7862
7864
|
[require_device_type.DeviceRole.LeakSensor]: LEAK_LOOK,
|
|
@@ -9854,7 +9856,7 @@ var CoreBlockStore = class CoreBlockStore {
|
|
|
9854
9856
|
const unreadable = [];
|
|
9855
9857
|
for (const row of rows) {
|
|
9856
9858
|
const raw = row.data.block;
|
|
9857
|
-
const parsed = require_core_blocks_cap.CoreBlockSchema.safeParse(
|
|
9859
|
+
const parsed = require_core_blocks_cap.CoreBlockSchema.safeParse(require_compile.canonicalStoredBlockTarget(raw));
|
|
9858
9860
|
if (!parsed.success) {
|
|
9859
9861
|
skipped += 1;
|
|
9860
9862
|
if (mayBeComposition(raw)) {
|
|
@@ -10363,13 +10365,13 @@ var LegacyApplianceSchema = zod.z.object({
|
|
|
10363
10365
|
thresholdWatts: zod.z.number(),
|
|
10364
10366
|
startDwellMs: zod.z.number(),
|
|
10365
10367
|
stopDwellMs: zod.z.number(),
|
|
10366
|
-
member:
|
|
10367
|
-
powerSwitch:
|
|
10368
|
+
member: require_compile.HelperMemberSchema,
|
|
10369
|
+
powerSwitch: require_compile.HelperMemberSchema.optional()
|
|
10368
10370
|
});
|
|
10369
10371
|
var LegacyHeaterSchema = zod.z.object({
|
|
10370
10372
|
kind: zod.z.literal("heater"),
|
|
10371
|
-
plug:
|
|
10372
|
-
meter:
|
|
10373
|
+
plug: require_compile.HelperMemberSchema,
|
|
10374
|
+
meter: require_compile.HelperMemberSchema.optional(),
|
|
10373
10375
|
thresholdWatts: zod.z.number(),
|
|
10374
10376
|
startDwellMs: zod.z.number(),
|
|
10375
10377
|
stopDwellMs: zod.z.number()
|
|
@@ -10478,7 +10480,7 @@ function powerSourceFeature(blockId, device, plug, original) {
|
|
|
10478
10480
|
};
|
|
10479
10481
|
}
|
|
10480
10482
|
function replacementsOf(blockId, composition, helper) {
|
|
10481
|
-
const device =
|
|
10483
|
+
const device = require_compile.composedDeviceRef(blockId);
|
|
10482
10484
|
if (helper.kind === "appliance") {
|
|
10483
10485
|
const base = {
|
|
10484
10486
|
"running-state": thresholdRunning({
|
|
@@ -10533,7 +10535,7 @@ function rewriteComposition(blockId, composition, helper) {
|
|
|
10533
10535
|
});
|
|
10534
10536
|
const missing = Object.keys(replacements).filter((cap) => !seen.has(cap));
|
|
10535
10537
|
if (missing.length > 0) return refuse$1(blockId, `no stored ${missing.join(", ")} feature to rewrite`);
|
|
10536
|
-
const parsed =
|
|
10538
|
+
const parsed = require_compile.CompositionSchema.safeParse({
|
|
10537
10539
|
...composition,
|
|
10538
10540
|
features
|
|
10539
10541
|
});
|
|
@@ -11998,7 +12000,7 @@ var ActionsService = class {
|
|
|
11998
12000
|
try {
|
|
11999
12001
|
await assertStepsOffered(steps, this.boundCaps);
|
|
12000
12002
|
} catch (err) {
|
|
12001
|
-
if (err instanceof
|
|
12003
|
+
if (err instanceof require_action_index.VocabActionError) {
|
|
12002
12004
|
this.logger.warn("action save refused — a device does not offer the action", {
|
|
12003
12005
|
...err.deviceId === void 0 ? {} : { tags: { deviceId: err.deviceId } },
|
|
12004
12006
|
meta: {
|
|
@@ -12821,7 +12823,7 @@ var PowerSourceService = class {
|
|
|
12821
12823
|
};
|
|
12822
12824
|
const current = read.links.find((l) => l.id === linkId);
|
|
12823
12825
|
const contribution = current ? require_device_manager_cap.IDENTITY_LINK_KINDS[current.kind].contributions.find((c) => c.cap === "power-source") : void 0;
|
|
12824
|
-
if (current !== void 0 && current.state === "linked" && current.evidenceGone !== true && contribution !== void 0 &&
|
|
12826
|
+
if (current !== void 0 && current.state === "linked" && current.evidenceGone !== true && contribution !== void 0 && require_compile.compositionSourceKey(current[contribution.source]) === require_compile.compositionSourceKey(link.switch)) return null;
|
|
12825
12827
|
this.deps.links.lost(deviceId);
|
|
12826
12828
|
return {
|
|
12827
12829
|
kind: "refused",
|
|
@@ -13506,9 +13508,9 @@ var HoldManager = class {
|
|
|
13506
13508
|
if (step.kind !== "command") continue;
|
|
13507
13509
|
const resolved = resolveStepArgs(step.args ?? {}, {}, () => void 0);
|
|
13508
13510
|
const args = isPlainRecord$1(resolved) ? resolved : {};
|
|
13509
|
-
const effect =
|
|
13511
|
+
const effect = require_action_index.actionEffect(step.actionId, args);
|
|
13510
13512
|
if (effect === null) continue;
|
|
13511
|
-
const call =
|
|
13513
|
+
const call = require_action_index.vocabCall(step.actionId, args);
|
|
13512
13514
|
let deviceIds;
|
|
13513
13515
|
try {
|
|
13514
13516
|
deviceIds = (await this.deps.targets.resolve(step.target, step.actionId, {}, {
|
|
@@ -13970,7 +13972,7 @@ var SchedulerEngine = class {
|
|
|
13970
13972
|
const out = [];
|
|
13971
13973
|
for (const step of point.steps) {
|
|
13972
13974
|
if (step.kind !== "command") continue;
|
|
13973
|
-
const effect =
|
|
13975
|
+
const effect = require_action_index.actionEffect(step.actionId, step.args);
|
|
13974
13976
|
if (effect === null) continue;
|
|
13975
13977
|
try {
|
|
13976
13978
|
const resolved = await this.deps.targets.resolve(step.target, step.actionId, {}, {
|
|
@@ -14231,9 +14233,9 @@ var SchedulerEngine = class {
|
|
|
14231
14233
|
}
|
|
14232
14234
|
/** A device call that a higher priority hold has, in a different state. */
|
|
14233
14235
|
edgeRefusal(scheduler, call) {
|
|
14234
|
-
const actionId =
|
|
14236
|
+
const actionId = require_action_index.vocabActionIdFor(call.cap, call.method, call.args);
|
|
14235
14237
|
if (actionId === void 0) return null;
|
|
14236
|
-
const effect =
|
|
14238
|
+
const effect = require_action_index.actionEffect(actionId, call.args);
|
|
14237
14239
|
if (effect === null) return null;
|
|
14238
14240
|
return this.holds.claimAgainst(scheduler, call.deviceId, effect.cap, effect.field, effect.value);
|
|
14239
14241
|
}
|
|
@@ -14323,7 +14325,7 @@ var SchedulersService = class {
|
|
|
14323
14325
|
try {
|
|
14324
14326
|
await assertStepsOffered(steps, this.deps.boundCaps);
|
|
14325
14327
|
} catch (err) {
|
|
14326
|
-
if (err instanceof
|
|
14328
|
+
if (err instanceof require_action_index.VocabActionError) {
|
|
14327
14329
|
this.deps.logger.warn("scheduler save refused — a device does not offer the action", {
|
|
14328
14330
|
...err.deviceId === void 0 ? {} : { tags: { deviceId: err.deviceId } },
|
|
14329
14331
|
meta: {
|
|
@@ -14480,7 +14482,7 @@ var SchedulersService = class {
|
|
|
14480
14482
|
for (const step of point.steps) {
|
|
14481
14483
|
if (step.kind !== "command") continue;
|
|
14482
14484
|
const resolved = resolveStepArgs(step.args ?? {}, {}, () => void 0);
|
|
14483
|
-
const effect =
|
|
14485
|
+
const effect = require_action_index.actionEffect(step.actionId, isPlainRecord(resolved) ? resolved : {});
|
|
14484
14486
|
if (effect === null) continue;
|
|
14485
14487
|
try {
|
|
14486
14488
|
const { deviceIds } = await this.deps.targets.resolve(step.target, step.actionId, {}, {
|
|
@@ -14764,10 +14766,10 @@ var RemoteComponentsService = class {
|
|
|
14764
14766
|
* D345).
|
|
14765
14767
|
*/
|
|
14766
14768
|
function hostBlock(blocks, host) {
|
|
14767
|
-
const key =
|
|
14769
|
+
const key = require_compile.compositionSourceKey(host);
|
|
14768
14770
|
return blocks.find((block) => {
|
|
14769
14771
|
const target = require_core_blocks_cap.coreBlockComposition(block)?.target;
|
|
14770
|
-
return target?.kind === "existing" &&
|
|
14772
|
+
return target?.kind === "existing" && require_compile.compositionSourceKey(target.device) === key;
|
|
14771
14773
|
}) ?? null;
|
|
14772
14774
|
}
|
|
14773
14775
|
function capLinkFeatures(composition) {
|
|
@@ -14796,7 +14798,7 @@ var CapLinksService = class {
|
|
|
14796
14798
|
if (declared === void 0) continue;
|
|
14797
14799
|
const sourceId = await this.ports.deviceIdOf(feature.source);
|
|
14798
14800
|
const gone = sourceId === null;
|
|
14799
|
-
const state = !
|
|
14801
|
+
const state = !require_compile.compositionFeatureEnabled(feature) ? "disabled" : gone ? "source-gone" : "linked";
|
|
14800
14802
|
if (state === "source-gone") this.logGone(deviceId, feature);
|
|
14801
14803
|
else this.goneLogged.delete(goneKey(deviceId, feature));
|
|
14802
14804
|
links.push({
|
|
@@ -14863,7 +14865,7 @@ var CapLinksService = class {
|
|
|
14863
14865
|
continue;
|
|
14864
14866
|
}
|
|
14865
14867
|
const plain = next.features.filter((f) => f.kind === "fields" && f.cap === cap);
|
|
14866
|
-
const candidates = plain.filter((f) => f.contributedBy === void 0 &&
|
|
14868
|
+
const candidates = plain.filter((f) => f.contributedBy === void 0 && require_compile.compositionFeatureEnabled(f));
|
|
14867
14869
|
report.skipped += plain.length - candidates.length;
|
|
14868
14870
|
if (candidates.length === 0) continue;
|
|
14869
14871
|
const verdict = identityGroup(candidates, link.sourceCap, link.map);
|
|
@@ -14931,7 +14933,7 @@ function widening(served, carried, next, candidates) {
|
|
|
14931
14933
|
if (missing.length > 0) reasons.push(`partial-set: would also take ${missing.join(", ")}`);
|
|
14932
14934
|
const taken = new Set(candidates);
|
|
14933
14935
|
for (const other of next.features) {
|
|
14934
|
-
if (other.kind !== "fields" || taken.has(other) || !
|
|
14936
|
+
if (other.kind !== "fields" || taken.has(other) || !require_compile.compositionFeatureEnabled(other)) continue;
|
|
14935
14937
|
const clash = Object.keys(other.fields).filter((path) => served.includes(path));
|
|
14936
14938
|
if (clash.length > 0) {
|
|
14937
14939
|
const by = other.contributedBy === void 0 ? "another feature" : `the device link ${other.contributedBy.linkId}`;
|
|
@@ -14966,7 +14968,7 @@ function identityGroup(features, sourceCap, map) {
|
|
|
14966
14968
|
}
|
|
14967
14969
|
if (value.cap !== sourceCap) reasons.push(`${path}: reads ${value.cap}, not ${sourceCap}`);
|
|
14968
14970
|
else if (value.fieldPath !== (map?.[path] ?? path)) reasons.push(`${path}: reads ${value.fieldPath}, not the same path`);
|
|
14969
|
-
sources.set(
|
|
14971
|
+
sources.set(require_compile.compositionSourceKey(value.source), value.source);
|
|
14970
14972
|
}
|
|
14971
14973
|
for (const extra of ["items", "commands"]) if (feature[extra] !== void 0) reasons.push(`the feature carries ${extra}`);
|
|
14972
14974
|
}
|
|
@@ -15315,7 +15317,7 @@ function linksOfBlock(block) {
|
|
|
15315
15317
|
if (composition === null || composition.target.kind !== "existing") return null;
|
|
15316
15318
|
const links = /* @__PURE__ */ new Map();
|
|
15317
15319
|
for (const feature of composition.features) {
|
|
15318
|
-
if (!
|
|
15320
|
+
if (!require_compile.compositionFeatureEnabled(feature) || feature.kind !== "fields") continue;
|
|
15319
15321
|
if (feature.cap !== FAN_CONTROL) continue;
|
|
15320
15322
|
for (const [path, source] of Object.entries(feature.fields)) {
|
|
15321
15323
|
if (source.kind !== "from") continue;
|
|
@@ -16412,6 +16414,7 @@ var TemplatesService = class {
|
|
|
16412
16414
|
async reexpandBuiltinInstances() {
|
|
16413
16415
|
if (this.deps.automations === void 0) return;
|
|
16414
16416
|
for (const template of BUILTIN_AUTOMATION_TEMPLATES) await this.deps.automations.reexpand(template.id, template.payload);
|
|
16417
|
+
await this.deps.automations.flagRetired(BUILTIN_AUTOMATION_TEMPLATES.map((template) => template.id));
|
|
16415
16418
|
}
|
|
16416
16419
|
/** A changed automation template reaches every automation made from it. */
|
|
16417
16420
|
async reexpandInstances(id, body) {
|
|
@@ -16720,6 +16723,7 @@ function buildRemoteRuntime(deps) {
|
|
|
16720
16723
|
* longer matches `template.codeHash`) is never regenerated over: only its
|
|
16721
16724
|
* literal is rewritten, to flag it `edited-by-hand`.
|
|
16722
16725
|
*/
|
|
16726
|
+
var RETIRED_DETAIL = "the built-in template this automation was made from is no longer shipped; it keeps running as it is, edit it as a free automation";
|
|
16723
16727
|
var EDITED_BY_HAND_DETAIL = "the code was edited by hand, so the template no longer updates it; convert it to a free automation or create it again from the template";
|
|
16724
16728
|
/** True when the block's code is still exactly what the generator wrote. */
|
|
16725
16729
|
function isGeneratedCode(code, recipe) {
|
|
@@ -16745,6 +16749,34 @@ function flaggedAsEdited(code, recipe) {
|
|
|
16745
16749
|
function errorText$1(error) {
|
|
16746
16750
|
return error instanceof Error ? error.message : String(error);
|
|
16747
16751
|
}
|
|
16752
|
+
/**
|
|
16753
|
+
* The automations made from `templateId`, optionally those about `deviceId`:
|
|
16754
|
+
* the device one of the template's own `device` inputs names (the commanded
|
|
16755
|
+
* device of a linked trigger, never an event source). A template this release
|
|
16756
|
+
* does not ship has no declared device inputs, so a device filter matches none.
|
|
16757
|
+
*/
|
|
16758
|
+
function listTemplateInstances(blocks, templateId, deviceId) {
|
|
16759
|
+
const deviceKeys = builtinAutomationTemplate(templateId)?.payload.inputs.flatMap((input) => input.kind === "device" ? [input.key] : []) ?? [];
|
|
16760
|
+
return blocks.flatMap((block) => {
|
|
16761
|
+
const read = readRecipeLiteral(block.code);
|
|
16762
|
+
const link = read.status === "recipe" ? read.recipe.template : void 0;
|
|
16763
|
+
if (link === void 0 || link.templateId !== templateId) return [];
|
|
16764
|
+
if (deviceId !== void 0) {
|
|
16765
|
+
if (!deviceKeys.some((key) => {
|
|
16766
|
+
const value = link.values[key];
|
|
16767
|
+
return value === deviceId || Array.isArray(value) && value.some((v) => v === deviceId);
|
|
16768
|
+
})) return [];
|
|
16769
|
+
}
|
|
16770
|
+
return [{
|
|
16771
|
+
blockId: block.id,
|
|
16772
|
+
name: block.name,
|
|
16773
|
+
enabled: block.enabled,
|
|
16774
|
+
templateId,
|
|
16775
|
+
values: link.values,
|
|
16776
|
+
...link.problems === void 0 ? {} : { problems: link.problems }
|
|
16777
|
+
}];
|
|
16778
|
+
});
|
|
16779
|
+
}
|
|
16748
16780
|
function automationTemplateInstancesOver(deps) {
|
|
16749
16781
|
const units = deps.units ?? require_rename_composition_block.capUnitResolver(require_rename_composition_block.ALL_CAPABILITY_DEFINITIONS);
|
|
16750
16782
|
const instancesOf = (templateId) => deps.blocks().flatMap((block) => {
|
|
@@ -16760,6 +16792,43 @@ function automationTemplateInstancesOver(deps) {
|
|
|
16760
16792
|
blockId: block.id,
|
|
16761
16793
|
name: block.name
|
|
16762
16794
|
})),
|
|
16795
|
+
flagRetired: async (shippedIds) => {
|
|
16796
|
+
let flagged = 0;
|
|
16797
|
+
for (const block of deps.blocks()) {
|
|
16798
|
+
const read = readRecipeLiteral(block.code);
|
|
16799
|
+
if (read.status !== "recipe") continue;
|
|
16800
|
+
const link = read.recipe.template;
|
|
16801
|
+
if (link === void 0 || !isBuiltinTemplateId(link.templateId)) continue;
|
|
16802
|
+
if (shippedIds.includes(link.templateId)) continue;
|
|
16803
|
+
if (link.problems?.some((p) => p.code === "missing-template") === true) continue;
|
|
16804
|
+
const code = replaceRecipeLiteral(block.code, {
|
|
16805
|
+
...read.recipe,
|
|
16806
|
+
template: {
|
|
16807
|
+
...link,
|
|
16808
|
+
problems: [{
|
|
16809
|
+
code: "missing-template",
|
|
16810
|
+
detail: RETIRED_DETAIL
|
|
16811
|
+
}]
|
|
16812
|
+
}
|
|
16813
|
+
});
|
|
16814
|
+
if (code === null) continue;
|
|
16815
|
+
try {
|
|
16816
|
+
await deps.saveCode(block.id, code);
|
|
16817
|
+
flagged += 1;
|
|
16818
|
+
deps.logger.warn("automation template: an instance of a retired built-in was flagged, it keeps running", { meta: {
|
|
16819
|
+
templateId: link.templateId,
|
|
16820
|
+
blockId: block.id
|
|
16821
|
+
} });
|
|
16822
|
+
} catch (error) {
|
|
16823
|
+
deps.logger.warn("automation template: a retired instance could not be flagged", { meta: {
|
|
16824
|
+
templateId: link.templateId,
|
|
16825
|
+
blockId: block.id,
|
|
16826
|
+
error: errorText$1(error)
|
|
16827
|
+
} });
|
|
16828
|
+
}
|
|
16829
|
+
}
|
|
16830
|
+
return flagged;
|
|
16831
|
+
},
|
|
16763
16832
|
reexpand: async (templateId, payload) => {
|
|
16764
16833
|
let updated = 0;
|
|
16765
16834
|
let flagged = 0;
|
|
@@ -17524,13 +17593,13 @@ function peerOf(stored, targets, lookupCap, candidateBlockId) {
|
|
|
17524
17593
|
if (composition.target.kind === "new") return {
|
|
17525
17594
|
peer: {
|
|
17526
17595
|
blockId,
|
|
17527
|
-
target:
|
|
17596
|
+
target: require_compile.composedDeviceRef(blockId),
|
|
17528
17597
|
composition
|
|
17529
17598
|
},
|
|
17530
17599
|
unread: null
|
|
17531
17600
|
};
|
|
17532
17601
|
const device = composition.target.device;
|
|
17533
|
-
const key =
|
|
17602
|
+
const key = require_compile.compositionSourceKey(device);
|
|
17534
17603
|
const replaced = replacedOf({
|
|
17535
17604
|
blockId,
|
|
17536
17605
|
composition
|
|
@@ -17573,7 +17642,7 @@ function storedPeers(blocks, targets, lookupCap, candidateBlockId) {
|
|
|
17573
17642
|
* (its `max` stands for the bucket), and the algorithm caps the confidence.
|
|
17574
17643
|
*/
|
|
17575
17644
|
/** The newest slices the proposal reads: a fortnight shows a weekly habit twice. */
|
|
17576
|
-
var LOOKBACK_MS = 14 *
|
|
17645
|
+
var LOOKBACK_MS = 14 * require_compile.DAY_MS;
|
|
17577
17646
|
var QUERY_MAX_POINTS = 5e3;
|
|
17578
17647
|
async function proposeForDevice(ports, request) {
|
|
17579
17648
|
const key = require_capture_engine.capSeriesKey(request.cap, request.fieldPath);
|
|
@@ -17622,8 +17691,8 @@ function emptySeries(now) {
|
|
|
17622
17691
|
/** Day slices ending at `to`, newest first, none reaching before `from`. */
|
|
17623
17692
|
function daySlices(from, to) {
|
|
17624
17693
|
const out = [];
|
|
17625
|
-
for (let end = to; end > from; end -=
|
|
17626
|
-
from: Math.max(from, end -
|
|
17694
|
+
for (let end = to; end > from; end -= require_compile.DAY_MS) out.push({
|
|
17695
|
+
from: Math.max(from, end - require_compile.DAY_MS),
|
|
17627
17696
|
to: end
|
|
17628
17697
|
});
|
|
17629
17698
|
return out;
|
|
@@ -17887,18 +17956,18 @@ function helperMemberDeviceIds(composition, sources) {
|
|
|
17887
17956
|
const helper = composition.helper;
|
|
17888
17957
|
if (helper === void 0) return [];
|
|
17889
17958
|
const ids = [];
|
|
17890
|
-
for (const member of
|
|
17891
|
-
const found = sources.get(
|
|
17959
|
+
for (const member of require_compile.helperMembers(helper)) {
|
|
17960
|
+
const found = sources.get(require_compile.compositionSourceKey(member.source));
|
|
17892
17961
|
if (found?.kind === "found") ids.push(found.deviceId);
|
|
17893
17962
|
}
|
|
17894
17963
|
return ids;
|
|
17895
17964
|
}
|
|
17896
17965
|
async function validateAgainstStore(deps, composition, blockId) {
|
|
17897
17966
|
if (!deps.store.isLoaded()) throw new Error(`${NOT_LOADED_REASON} — a composition cannot be judged against the stored ones until it has; retry shortly`);
|
|
17898
|
-
const self = blockId === null ? null :
|
|
17967
|
+
const self = blockId === null ? null : require_compile.composedDeviceRef(blockId);
|
|
17899
17968
|
const target = existingTarget(composition);
|
|
17900
|
-
const ownKeys = new Set([self, target].flatMap((ref) => ref === null ? [] : [
|
|
17901
|
-
const refs = require_core_blocks_cap.compositionSourceRefs(composition).filter((r) => !ownKeys.has(
|
|
17969
|
+
const ownKeys = new Set([self, target].flatMap((ref) => ref === null ? [] : [require_compile.compositionSourceKey(ref)]));
|
|
17970
|
+
const refs = require_core_blocks_cap.compositionSourceRefs(composition).filter((r) => !ownKeys.has(require_compile.compositionSourceKey(r)));
|
|
17902
17971
|
const blocks = deps.store.list();
|
|
17903
17972
|
const read = await deps.describe(refs, [...target === null ? [] : [target], ...storedCustomizationTargets(blocks)], require_core_blocks_cap.compositionUnionReads(composition, deps.lookupCap));
|
|
17904
17973
|
const stored = storedPeers(blocks, read.targets, deps.lookupCap, blockId);
|
|
@@ -17908,7 +17977,7 @@ async function validateAgainstStore(deps, composition, blockId) {
|
|
|
17908
17977
|
sources: read.sources,
|
|
17909
17978
|
self,
|
|
17910
17979
|
blockId,
|
|
17911
|
-
target: target === null ? null : read.targets.get(
|
|
17980
|
+
target: target === null ? null : read.targets.get(require_compile.compositionSourceKey(target)) ?? {
|
|
17912
17981
|
kind: "unreadable",
|
|
17913
17982
|
error: "it was not read"
|
|
17914
17983
|
},
|
|
@@ -17985,7 +18054,7 @@ var NEVER_BECOMES_CUSTOMIZATION = "a composed device cannot become the customiza
|
|
|
17985
18054
|
*/
|
|
17986
18055
|
async function resolveTarget(deps, target) {
|
|
17987
18056
|
try {
|
|
17988
|
-
const found = (await deps.describe([], [target])).targets.get(
|
|
18057
|
+
const found = (await deps.describe([], [target])).targets.get(require_compile.compositionSourceKey(target));
|
|
17989
18058
|
if (found?.kind === "found") return {
|
|
17990
18059
|
kind: "device",
|
|
17991
18060
|
deviceId: found.deviceId
|
|
@@ -18009,7 +18078,7 @@ async function refuseSave(deps, subject, target, reason) {
|
|
|
18009
18078
|
meta: {
|
|
18010
18079
|
name: subject.name,
|
|
18011
18080
|
blockId: subject.blockId,
|
|
18012
|
-
target: target === null ? null :
|
|
18081
|
+
target: target === null ? null : require_compile.compositionSourceKey(target),
|
|
18013
18082
|
...resolved?.kind === "unresolved" ? { targetUnresolved: resolved.why } : {},
|
|
18014
18083
|
reason
|
|
18015
18084
|
}
|
|
@@ -18055,7 +18124,7 @@ async function refuseRetarget(deps, blockId, patch) {
|
|
|
18055
18124
|
return;
|
|
18056
18125
|
}
|
|
18057
18126
|
if (patch.name !== void 0) return refuseSave(deps, subject, pinned, NO_NAME_OF_ITS_OWN);
|
|
18058
|
-
if (next === null ||
|
|
18127
|
+
if (next === null || require_compile.compositionSourceKey(next) !== require_compile.compositionSourceKey(pinned)) return refuseSave(deps, subject, pinned, DEVICE_IS_FIXED);
|
|
18059
18128
|
}
|
|
18060
18129
|
/**
|
|
18061
18130
|
* An editor rename of a composed device (not a customization, not a create)
|
|
@@ -18103,11 +18172,11 @@ async function withDeviceNames(deps, blocks) {
|
|
|
18103
18172
|
}
|
|
18104
18173
|
/** The block customizing `device`, found by TARGET — never by its derived name (rule 4). */
|
|
18105
18174
|
function customizationOf(blocks, device) {
|
|
18106
|
-
const key =
|
|
18175
|
+
const key = require_compile.compositionSourceKey(device);
|
|
18107
18176
|
return blocks.find((block) => {
|
|
18108
18177
|
const composition = require_core_blocks_cap.coreBlockComposition(block);
|
|
18109
18178
|
const target = composition === null ? null : existingTarget(composition);
|
|
18110
|
-
return target !== null &&
|
|
18179
|
+
return target !== null && require_compile.compositionSourceKey(target) === key;
|
|
18111
18180
|
}) ?? null;
|
|
18112
18181
|
}
|
|
18113
18182
|
/**
|
|
@@ -18309,7 +18378,7 @@ var LinkContributionReconciler = class {
|
|
|
18309
18378
|
for (const contribution of require_device_manager_cap.IDENTITY_LINK_KINDS[link.kind].contributions) {
|
|
18310
18379
|
const hostSide = link[contribution.host];
|
|
18311
18380
|
const host = refOf(hostSide);
|
|
18312
|
-
const key =
|
|
18381
|
+
const key = require_compile.compositionSourceKey(host);
|
|
18313
18382
|
const plan = plans.get(key) ?? {
|
|
18314
18383
|
host,
|
|
18315
18384
|
hostDeviceId: hostSide.deviceId,
|
|
@@ -18329,8 +18398,9 @@ var LinkContributionReconciler = class {
|
|
|
18329
18398
|
if (composition === null || composition.target.kind !== "existing") continue;
|
|
18330
18399
|
const stamped = composition.features.some((f) => fieldsFeature(f)?.contributedBy !== void 0);
|
|
18331
18400
|
const host = composition.target.device;
|
|
18332
|
-
const key =
|
|
18333
|
-
|
|
18401
|
+
const key = require_compile.compositionSourceKey(host);
|
|
18402
|
+
const leftEmpty = block.createdBy === "identity-links" && composition.features.length === 0;
|
|
18403
|
+
if ((stamped || leftEmpty) && !plans.has(key)) plans.set(key, {
|
|
18334
18404
|
host,
|
|
18335
18405
|
hostDeviceId: await this.hostIdOf(host, read.links),
|
|
18336
18406
|
owed: []
|
|
@@ -18343,16 +18413,16 @@ var LinkContributionReconciler = class {
|
|
|
18343
18413
|
* dismissed one), else from the device listing.
|
|
18344
18414
|
*/
|
|
18345
18415
|
async hostIdOf(host, links) {
|
|
18346
|
-
const key =
|
|
18416
|
+
const key = require_compile.compositionSourceKey(host);
|
|
18347
18417
|
for (const link of links) for (const contribution of require_device_manager_cap.IDENTITY_LINK_KINDS[link.kind].contributions) {
|
|
18348
18418
|
const side = link[contribution.host];
|
|
18349
|
-
if (
|
|
18419
|
+
if (require_compile.compositionSourceKey(refOf(side)) === key) return side.deviceId;
|
|
18350
18420
|
}
|
|
18351
18421
|
return this.ports.deviceIdOf(host).catch(() => null);
|
|
18352
18422
|
}
|
|
18353
18423
|
async reconcileWithRetry(plan, first) {
|
|
18354
18424
|
const tags = plan.hostDeviceId === null ? {} : { tags: { deviceId: plan.hostDeviceId } };
|
|
18355
|
-
const host =
|
|
18425
|
+
const host = require_compile.compositionSourceKey(plan.host);
|
|
18356
18426
|
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
18357
18427
|
const blocks = attempt === 1 ? first : this.ports.blocks();
|
|
18358
18428
|
if (blocks === null) return;
|
|
@@ -18381,10 +18451,10 @@ var LinkContributionReconciler = class {
|
|
|
18381
18451
|
});
|
|
18382
18452
|
}
|
|
18383
18453
|
async reconcileHost(plan, blocks) {
|
|
18384
|
-
const key =
|
|
18454
|
+
const key = require_compile.compositionSourceKey(plan.host);
|
|
18385
18455
|
const block = blocks.find((b) => {
|
|
18386
18456
|
const c = require_core_blocks_cap.coreBlockComposition(b);
|
|
18387
|
-
return c !== null && c.target.kind === "existing" &&
|
|
18457
|
+
return c !== null && c.target.kind === "existing" && require_compile.compositionSourceKey(c.target.device) === key;
|
|
18388
18458
|
}) ?? null;
|
|
18389
18459
|
const composition = block === null ? null : require_core_blocks_cap.coreBlockComposition(block);
|
|
18390
18460
|
const before = composition?.features ?? [];
|
|
@@ -18447,6 +18517,27 @@ var LinkContributionReconciler = class {
|
|
|
18447
18517
|
features = features.map((f, i) => i === index ? refreshed : f);
|
|
18448
18518
|
this.log("identity-link contribution refreshed", owed);
|
|
18449
18519
|
}
|
|
18520
|
+
if (block !== null && features.length === 0 && block.createdBy === "identity-links") {
|
|
18521
|
+
const current = this.ports.blocks()?.find((b) => b.id === block.id);
|
|
18522
|
+
const now = current === void 0 ? null : require_core_blocks_cap.coreBlockComposition(current);
|
|
18523
|
+
if (current === void 0 || now === null) return;
|
|
18524
|
+
if (JSON.stringify(now.features) !== JSON.stringify(before)) {
|
|
18525
|
+
this.ports.logger.info("identity-link customization kept — it gained content", { meta: {
|
|
18526
|
+
blockId: block.id,
|
|
18527
|
+
host: key
|
|
18528
|
+
} });
|
|
18529
|
+
return;
|
|
18530
|
+
}
|
|
18531
|
+
await this.ports.remove(current);
|
|
18532
|
+
this.ports.logger.info("identity-link customization removed — nothing is left in it", {
|
|
18533
|
+
...plan.hostDeviceId === null ? {} : { tags: { deviceId: plan.hostDeviceId } },
|
|
18534
|
+
meta: {
|
|
18535
|
+
blockId: block.id,
|
|
18536
|
+
host: key
|
|
18537
|
+
}
|
|
18538
|
+
});
|
|
18539
|
+
return;
|
|
18540
|
+
}
|
|
18450
18541
|
if (JSON.stringify(features) === JSON.stringify(before)) return;
|
|
18451
18542
|
if (block === null || composition === null) {
|
|
18452
18543
|
await this.ports.create(plan.host, features);
|
|
@@ -18499,10 +18590,10 @@ var LinkContributionReconciler = class {
|
|
|
18499
18590
|
* the composer's next apply retries the device write.
|
|
18500
18591
|
*/
|
|
18501
18592
|
async function writeComposedDeviceName(port, logger, blockId, name) {
|
|
18502
|
-
const stableId =
|
|
18593
|
+
const stableId = require_compile.composedDeviceStableId(blockId);
|
|
18503
18594
|
let deviceId = null;
|
|
18504
18595
|
try {
|
|
18505
|
-
const row = (await port.listPersistedByAddon(
|
|
18596
|
+
const row = (await port.listPersistedByAddon(require_compile.COMPOSER_ADDON_ID)).find((candidate) => candidate.stableId === stableId);
|
|
18506
18597
|
if (row === void 0) {
|
|
18507
18598
|
logger.warn("composed block was renamed but its device row was not found — retried on the next apply", { meta: {
|
|
18508
18599
|
blockId,
|
|
@@ -18525,9 +18616,9 @@ async function writeComposedDeviceName(port, logger, blockId, name) {
|
|
|
18525
18616
|
}
|
|
18526
18617
|
/** The device row's name for every composed block, by block id: the one name an operator sees. */
|
|
18527
18618
|
async function readComposedDeviceNames(port) {
|
|
18528
|
-
const rows = await port.listPersistedByAddon(
|
|
18619
|
+
const rows = await port.listPersistedByAddon(require_compile.COMPOSER_ADDON_ID);
|
|
18529
18620
|
return new Map(rows.flatMap((row) => {
|
|
18530
|
-
const blockId = require_rename_composition_block.composedBlockIdOf(
|
|
18621
|
+
const blockId = require_rename_composition_block.composedBlockIdOf(require_compile.COMPOSER_ADDON_ID, row.stableId);
|
|
18531
18622
|
return blockId === null ? [] : [[blockId, row.name]];
|
|
18532
18623
|
}));
|
|
18533
18624
|
}
|
|
@@ -19680,30 +19771,7 @@ var CoreBlocksAddon = class extends require_base_addon.BaseAddon {
|
|
|
19680
19771
|
});
|
|
19681
19772
|
throw new Error(linkRefusal);
|
|
19682
19773
|
}
|
|
19683
|
-
|
|
19684
|
-
await this.requireStore().delete(blockId);
|
|
19685
|
-
await this.requirePrefs().delete(blockId);
|
|
19686
|
-
await this.requireActions().ledger.delete(automationOwner(blockId));
|
|
19687
|
-
if (composition && this.supervisor === null) {
|
|
19688
|
-
this.ctx.logger.error("composition deleted but no supervisor can release its claims", { meta: { blockId } });
|
|
19689
|
-
throw new Error(`core-blocks: "${blockId}" was deleted but no supervisor runs here — its claims were not released`);
|
|
19690
|
-
}
|
|
19691
|
-
if (composition && this.supervisor !== null) {
|
|
19692
|
-
const unreleased = await this.supervisor.retireComposition(blockId);
|
|
19693
|
-
if (unreleased.length > 0) {
|
|
19694
|
-
for (const claim of unreleased) this.ctx.logger.error("composition deleted but its claim was not released", {
|
|
19695
|
-
tags: { deviceId: claim.deviceId },
|
|
19696
|
-
meta: {
|
|
19697
|
-
blockId,
|
|
19698
|
-
cap: claim.capName,
|
|
19699
|
-
owner: claim.owner,
|
|
19700
|
-
error: claim.error
|
|
19701
|
-
}
|
|
19702
|
-
});
|
|
19703
|
-
const detail = unreleased.map((claim) => `${claim.capName} on device ${claim.deviceId}: ${claim.error}`).join("; ");
|
|
19704
|
-
throw new Error(`core-blocks: "${blockId}" was deleted but its claims were not released — ${detail}`);
|
|
19705
|
-
}
|
|
19706
|
-
} else this.convergeSoon();
|
|
19774
|
+
await this.removeBlock(blockId, existing);
|
|
19707
19775
|
return { success: true };
|
|
19708
19776
|
},
|
|
19709
19777
|
setEnabled: async ({ blockId, enabled }) => {
|
|
@@ -19770,6 +19838,7 @@ var CoreBlocksAddon = class extends require_base_addon.BaseAddon {
|
|
|
19770
19838
|
},
|
|
19771
19839
|
...this.requireActions().runsApi,
|
|
19772
19840
|
...this.sharedCompositionApi(),
|
|
19841
|
+
listTemplateInstances: async ({ templateId, deviceId }) => ({ instances: [...listTemplateInstances(this.requireStore().list(), templateId, deviceId)] }),
|
|
19773
19842
|
getCapLinks: async ({ deviceId }) => this.sharedCapLinks().read(deviceId),
|
|
19774
19843
|
migrateCapLinks: async ({ dryRun }) => this.sharedCapLinks().migrate(dryRun)
|
|
19775
19844
|
};
|
|
@@ -19829,6 +19898,37 @@ var CoreBlocksAddon = class extends require_base_addon.BaseAddon {
|
|
|
19829
19898
|
})).find((r) => r.stableId === ref.stableId)?.id ?? null;
|
|
19830
19899
|
}
|
|
19831
19900
|
/**
|
|
19901
|
+
* Delete a block's records and release a composition's claims. The caller has already
|
|
19902
|
+
* judged whether the block may go (the operator's delete refuses a block that holds
|
|
19903
|
+
* link contributions; the link reconciler removes one it has just emptied).
|
|
19904
|
+
*/
|
|
19905
|
+
async removeBlock(blockId, existing) {
|
|
19906
|
+
const composition = existing !== null && require_core_blocks_cap.coreBlockComposition(existing) !== null;
|
|
19907
|
+
await this.requireStore().delete(blockId);
|
|
19908
|
+
await this.requirePrefs().delete(blockId);
|
|
19909
|
+
await this.requireActions().ledger.delete(automationOwner(blockId));
|
|
19910
|
+
if (composition && this.supervisor === null) {
|
|
19911
|
+
this.ctx.logger.error("composition deleted but no supervisor can release its claims", { meta: { blockId } });
|
|
19912
|
+
throw new Error(`core-blocks: "${blockId}" was deleted but no supervisor runs here — its claims were not released`);
|
|
19913
|
+
}
|
|
19914
|
+
if (composition && this.supervisor !== null) {
|
|
19915
|
+
const unreleased = await this.supervisor.retireComposition(blockId);
|
|
19916
|
+
if (unreleased.length > 0) {
|
|
19917
|
+
for (const claim of unreleased) this.ctx.logger.error("composition deleted but its claim was not released", {
|
|
19918
|
+
tags: { deviceId: claim.deviceId },
|
|
19919
|
+
meta: {
|
|
19920
|
+
blockId,
|
|
19921
|
+
cap: claim.capName,
|
|
19922
|
+
owner: claim.owner,
|
|
19923
|
+
error: claim.error
|
|
19924
|
+
}
|
|
19925
|
+
});
|
|
19926
|
+
const detail = unreleased.map((claim) => `${claim.capName} on device ${claim.deviceId}: ${claim.error}`).join("; ");
|
|
19927
|
+
throw new Error(`core-blocks: "${blockId}" was deleted but its claims were not released — ${detail}`);
|
|
19928
|
+
}
|
|
19929
|
+
} else this.convergeSoon();
|
|
19930
|
+
}
|
|
19931
|
+
/**
|
|
19832
19932
|
* The Customize features identity links contribute (D1063). A pass runs on
|
|
19833
19933
|
* every `identity-link.created` / `.lost`, once now, and — until a pass has
|
|
19834
19934
|
* read the links (device-manager answers only once it has booted) — on each
|
|
@@ -19871,6 +19971,9 @@ var CoreBlocksAddon = class extends require_base_addon.BaseAddon {
|
|
|
19871
19971
|
caller
|
|
19872
19972
|
});
|
|
19873
19973
|
},
|
|
19974
|
+
remove: async (block) => {
|
|
19975
|
+
await this.removeBlock(block.id, block);
|
|
19976
|
+
},
|
|
19874
19977
|
logger: this.ctx.logger.child("identity-links")
|
|
19875
19978
|
});
|
|
19876
19979
|
this.subscribe({ category: require_base_addon.EventCategory.IdentityLinkCreated }, () => links.requestPass());
|
|
@@ -19939,7 +20042,7 @@ var CoreBlocksAddon = class extends require_base_addon.BaseAddon {
|
|
|
19939
20042
|
resolution: input.resolution,
|
|
19940
20043
|
maxPoints: input.maxPoints
|
|
19941
20044
|
}),
|
|
19942
|
-
retention: async () =>
|
|
20045
|
+
retention: async () => require_compile.historyRetentionFromSettings(await requireApi().addonSettingsRaw.getGlobal.query({ addonId: "device-history" })),
|
|
19943
20046
|
now: () => Date.now(),
|
|
19944
20047
|
logger: this.ctx.logger.child("running-proposal")
|
|
19945
20048
|
},
|