@camstack/server 1.2.897 → 1.2.899

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/trpc/cap-router-runtime.js +1 -0
  3. package/dist/api/trpc/generated-cap-mounts.js +2 -1
  4. package/dist/api/trpc/generated-cap-routers.js +1894 -1870
  5. package/dist/core/addon/hub-addon-api.js +1 -0
  6. package/dist/core/moleculer/moleculer.service.js +1 -0
  7. package/package.json +11 -10
  8. package/system/dist/addon-runner.js +207 -13
  9. package/system/dist/addon-runner.mjs +207 -13
  10. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  11. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  12. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  13. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  14. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  15. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  16. package/system/dist/builtins/autotrack/index.js +1 -1
  17. package/system/dist/builtins/autotrack/index.mjs +1 -1
  18. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  19. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  20. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  21. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  22. package/system/dist/builtins/camera-grid/index.js +1 -1
  23. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  24. package/system/dist/builtins/composer/composer.addon.js +14 -11
  25. package/system/dist/builtins/composer/composer.addon.mjs +11 -8
  26. package/system/dist/builtins/console-logging/index.js +1 -1
  27. package/system/dist/builtins/console-logging/index.mjs +1 -1
  28. package/system/dist/builtins/core-blocks/core-blocks.addon.js +170 -14
  29. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +169 -13
  30. package/system/dist/builtins/core-blocks/migrations/automation-confirmed-view.d.ts +23 -0
  31. package/system/dist/builtins/core-blocks/migrations/index.d.ts +1 -0
  32. package/system/dist/builtins/core-blocks/migrations/pump-cycle-split.d.ts +1 -0
  33. package/system/dist/builtins/device-history/device-history.addon.js +10 -9
  34. package/system/dist/builtins/device-history/device-history.addon.mjs +10 -9
  35. package/system/dist/builtins/device-manager/command-holds-wiring.d.ts +22 -0
  36. package/system/dist/builtins/device-manager/command-holds.d.ts +77 -0
  37. package/system/dist/builtins/device-manager/device-manager.addon.d.ts +3 -0
  38. package/system/dist/builtins/device-manager/device-manager.addon.js +1078 -41
  39. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1062 -42
  40. package/system/dist/builtins/device-manager/device-state-mirror.d.ts +42 -9
  41. package/system/dist/builtins/device-manager/state-refresh-scheduler.d.ts +92 -0
  42. package/system/dist/builtins/device-manager/state-refresh-wiring.d.ts +23 -0
  43. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  44. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  45. package/system/dist/builtins/keychain/index.js +4 -4
  46. package/system/dist/builtins/keychain/index.mjs +4 -4
  47. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  48. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  49. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  50. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  51. package/system/dist/builtins/local-network/local-network.addon.js +3 -3
  52. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  53. package/system/dist/builtins/loki-logging/index.js +1 -1
  54. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  55. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  56. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  57. package/system/dist/builtins/platform-probe/index.js +1 -1
  58. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  59. package/system/dist/builtins/record-entries/index.js +1 -1
  60. package/system/dist/builtins/record-entries/index.mjs +1 -1
  61. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  62. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  63. package/system/dist/builtins/shared/device-state-changed.d.ts +8 -0
  64. package/system/dist/builtins/snapshot/index.js +1 -1
  65. package/system/dist/builtins/snapshot/index.mjs +1 -1
  66. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  67. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  68. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  69. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  70. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  71. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  72. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  73. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  74. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  75. package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
  76. package/system/dist/builtins/winston-logging/index.js +1 -1
  77. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  78. package/system/dist/{capture-engine-Bjgs__i9.mjs → capture-engine-BcD6iCZM.mjs} +37 -2
  79. package/system/dist/{capture-engine-D1rjl2dW.js → capture-engine-LHKTf-nM.js} +48 -1
  80. package/system/dist/{composition-sources-B727nlA0.mjs → composition-sources-C3ARJk2g.mjs} +2 -21
  81. package/system/dist/{composition-sources-CF2-u58e.js → composition-sources-DNUDbuXy.js} +1 -32
  82. package/system/dist/{constants-DaR1SUh7.js → constants-dL8fl9aI.js} +1 -1
  83. package/system/dist/{constants-BF309c_I.mjs → constants-er38mZOb.mjs} +1 -1
  84. package/system/dist/{device-ca-DT1hYtdW.mjs → device-ca-Ccz5olgH.mjs} +1 -1
  85. package/system/dist/{device-ca-BqcX5_f2.js → device-ca-KWa6uJRU.js} +1 -1
  86. package/system/dist/{dist-DorY_sjS.mjs → dist-DBanWvHF.mjs} +819 -54
  87. package/system/dist/{dist-BoEy9sm9.js → dist-DEAjZE_-.js} +848 -53
  88. package/system/dist/file-host-worker.js +1 -1
  89. package/system/dist/file-host-worker.mjs +1 -1
  90. package/system/dist/{hub-identity-CZ0nE3GK.mjs → hub-identity-CVv79TVO.mjs} +1 -1
  91. package/system/dist/{hub-identity-DH1rxUMD.js → hub-identity-Dy8ZSUuq.js} +1 -1
  92. package/system/dist/{hub-mdns-ciao-N0nL34fx.js → hub-mdns-ciao-C_XjO7YI.js} +2 -2
  93. package/system/dist/{hub-mdns-ciao-7HK57Vtx.mjs → hub-mdns-ciao-DtmIyWDL.mjs} +2 -2
  94. package/system/dist/index.js +96 -17
  95. package/system/dist/index.mjs +92 -19
  96. package/system/dist/kernel/cap-router-builder.d.ts +7 -0
  97. package/system/dist/kernel/command-follow-up.d.ts +33 -0
  98. package/system/dist/kernel/command-hold-overrides.d.ts +42 -0
  99. package/system/dist/kernel/command-observation.d.ts +3 -0
  100. package/system/dist/kernel/index.d.ts +3 -0
  101. package/system/dist/kernel/moleculer/child-cap-descriptors.d.ts +5 -0
  102. package/system/dist/kernel/moleculer/device-cap-proxy.d.ts +3 -1
  103. package/system/dist/kernel/state-refresh-policies.d.ts +53 -0
  104. package/system/dist/kernel/transport/child-cap-protocol.d.ts +11 -1
  105. package/system/dist/kernel/transport/local-child-registry.d.ts +14 -0
  106. package/system/dist/{legacy-integration-rows-door-CdAQlIvv.mjs → legacy-integration-rows-door-BL8T4lya.mjs} +1 -1
  107. package/system/dist/{legacy-integration-rows-door-BTfeULYt.js → legacy-integration-rows-door-DPInWtE6.js} +1 -1
  108. package/system/dist/{rename-composition-block-B1x-yK5U.js → rename-composition-block-BxzETYOf.js} +1 -1
  109. package/system/dist/{rename-composition-block-CIQjxBUa.mjs → rename-composition-block-Dgo-9-Ts.mjs} +1 -1
  110. package/system/dist/{restore-archive-Bj_gYmE9.mjs → restore-archive-BUtuNTe1.mjs} +82 -82
  111. package/system/dist/{restore-archive-B086o8pL.js → restore-archive-Zvx9sHZP.js} +1 -1
  112. package/system/dist/{wal-maintenance-MVIyxmu7.js → wal-maintenance-DS2IKwtK.js} +0 -0
  113. package/system/dist/{wal-maintenance-Dgfmi-Ao.mjs → wal-maintenance-cASt_sYy.mjs} +0 -0
  114. package/system/package.json +1 -1
@@ -1,7 +1,7 @@
1
- import { $i as localDateOf, $l as secretTreeFromSchema, $r as evaluateStepCondition, $s as historyRetentionFromSettings, A as ConditionMirror, An as actionWaitTotalMs, As as DAY_MS, Ba as powerSourceLinkOfComposition, Ca as normalizeCoreBlockWrite, Cn as TemplateKindSchema, Cr as coreBlockSourceKind, Di as internalActionId, Dr as customKeyOfRole, Ds as zoneOnlySite, Dt as IDLE_ACTION_STATUS, E as CORE_BLOCK_ADDON_PREFIX, Ei as integrationInstancesCapability, Fs as HelperMemberSchema, Ha as prepareRecipeUnits, Ho as siteFor, Hs as composedDeviceRef, Ia as planComposition, Il as isSecretRefOwnedBy, Ir as describeComposableCaps, Jc as VocabActionError, Jt as PowerSourceInfoSchema, Ka as projectDeviceRow, Ki as kebabToCamel, Kn as buildActionSteps, Ko as stableIdMapOf, Lc as RecordIntegrationInstances, M as CoreBlockSchema, Mn as addonIdOfActionId, Nr as defaultTagColorId, Oa as occurrenceOn, Os as COMPOSER_ADDON_ID, Ot as INTERNAL_ACTION_PREFIX, Pi as isBuiltinTemplateId, Pl as isSecretMarker, Po as seedInstanceOnce, Qn as builtinAutomationTemplate, Qs as helperMembers, Qt as QuantityUnitError, Ra as powerSourceActuatorConflicts, Rs as canonicalStoredBlockTarget, Rt as MediaPlayerStatusSchema, Sa as normalizeActionUnits, Si as heroLayoutCapability, Sn as TagsFieldSchema, So as resolveStepArgs, Sr as coreBlockIdFromAddonId, Ss as weekdayOfLocalDate, T as CORE_BLOCKS_ADDON_ID, Ti as instanceCodeHash, To as runSteps, Ua as problemsBlockSave, Us as composedDeviceStableId, Vn as assertStepsOffered, Vt as NcTaggedRuleKindSchema, Ws as compositionFeatureEnabled, Xa as readStoredRemoteConfig, Xc as actionEffect, Xl as ruleFireOfClaim, Xn as buildHeroModel, Ya as readRecipeLiteral, Yl as resolveSecretMarkers, _ as BUILTIN_REMOTE_COMPONENTS, _i as generateAutomationBlock, _r as compositionSourceRefs, _s as validateSchedulerInput, _t as FanPresetSchema, an as RunningStateStatusSchema, ao as removeFromTags, as as tagsCapability, ba as nextOccurrence, bn as TagNameSchema, bo as resolveRemoteSource, br as coreBlockAddonId, c as ActionError, co as replacedFieldKeys, cs as timedRunLimitOf, ct as EMPTY_REMOTE_ASSUMED_STATE, d as ActionTargetResolver, dn as SchedulerSchema, ds as timedRunSeconds, dt as FAN_CAPTURE_FIELDS, du as DeviceRole, ei as evaluateWhenTree, en as REMOTE_MEDIA_COMMANDS, f as ActionVariableSchema, fi as findChannelSource, fl as defineAddonMigrations, fo as resolveCoreBlockEntry, fs as toTimings, ft as FAN_OSCILLATION_AXES, fu as DeviceType$1, g as BUILTIN_AUTOMATION_TEMPLATES, h as AutomationTemplatePayloadSchema, hl as defineRecordKinds, hs as validateComposition, ht as FanControlStatusSchema, hu as EventCategory$1, in as RemoteLayoutPayloadSchema, io as remoteSourceSteps, is as tagKey, iu as transformSecretWrite, jn as actionsCapability, kn as actionSourceCapability, ko as schedulersCapability, ks as CompositionSchema, l as ActionMinDelaySecSchema, li as fanPresetsCapability, ll as commandOrigin$1, ln as SWITCH_DEFAULT_OPTIONS, lo as resolveActionVariables, lr as collectDeviceTemplates, ls as timedRunMaxIn, lt as EMPTY_REMOTE_CONFIG, m as AutomationStateDocSchema, ml as defineEntryKind, mn as SetOscillationAxisInputSchema, mo as resolveHeroLayout, mr as compileScalarOverride, n as ACTION_TARGET_INVALIDATION_EVENTS, no as remoteCapability, nr as canonicalStoredStepTargets, oi as fanAxisPath, ol as collectSecretMarkerRefs, oo as renameInTags, os as templateCapability, ou as vocabActionIdFor, pc as BaseAddon, po as resolveCoreBlockFiles, pt as FAN_OSCILLATION_AXIS_SETTABLE, pu as errMsg$1, qa as proposeRunningThreshold, qn as buildCapabilityLookup, qs as compositionSourceKey, ra as lockDoorLinkOfComposition, rn as RemoteAssumedStateSchema, ro as remoteLayoutComponentsCapability, rr as capUnitResolver, s as ALL_CAPABILITY_DEFINITIONS, so as replaceRecipeLiteral, sr as checkTemplatePayload, ss as timedRunCapability, st as EMPTY_AUTOMATION_STATE, su as vocabCall, to as reexpandAutomationInstance, tt as DeclaredDevices, u as ActionStepSchema, un as SchedulerError, ur as collectWhenMirrorSources, us as timedRunQuickRun, vl as entryBody, vr as compositionUnionReads, w as COMPOSER_RUNNER_ID, wa as normalizeTags, wl as hydrateSchema, wr as coreBlocksCapability, xa as nextTimeBoundaryInMs, xi as hasTimeLeaves, xn as TagStyleSchema, xr as coreBlockComposition, z as DEFAULT_HOLD_OVERRIDE, za as powerSourceCapability, zi as isInternalActionId, zn as appendTrace } from "../../dist-DorY_sjS.mjs";
1
+ import { $a as readRecipeLiteral, $c as VocabActionError, $n as buildHeroModel, Ai as integrationInstancesCapability, Ao as runSteps, Ar as customKeyOfRole, B as DEFAULT_HOLD_OVERRIDE, Ba as planComposition, Bs as HelperMemberSchema, Cl as entryBody, Cn as TagNameSchema, Cr as coreBlockAddonId, D as CORE_BLOCK_ADDON_PREFIX, Da as normalizeCoreBlockWrite, Do as resolveStepArgs, Dr as coreBlocksCapability, Ds as weekdayOfLocalDate, E as CORE_BLOCKS_ADDON_ID, Ea as normalizeActionUnits, Ei as heroLayoutCapability, En as TemplateKindSchema, Er as coreBlockSourceKind, Fn as addonIdOfActionId, Fs as DAY_MS, Ha as powerSourceActuatorConflicts, Hc as RecordIntegrationInstances, Hn as appendTrace, Ht as NcTaggedRuleKindSchema, Ir as defaultTagColorId, Js as composedDeviceStableId, Ka as prepareRecipeUnits, Ma as occurrenceOn, Mn as actionSourceCapability, Ms as zoneOnlySite, N as CoreBlockSchema, Nn as actionWaitTotalMs, Ns as COMPOSER_ADDON_ID, Oa as normalizeTags, Ot as IDLE_ACTION_STATUS, Pn as actionsCapability, Po as schedulersCapability, Ps as CompositionSchema, Qs as compositionSourceKey, Ri as isBuiltinTemplateId, Ss as validateSchedulerInput, T as COMPOSER_RUNNER_ID, Ta as nextTimeBoundaryInMs, Ti as hasTimeLeaves, Tn as TagsFieldSchema, To as resolveRemoteSource, Tr as coreBlockIdFromAddonId, Ua as powerSourceCapability, Ui as isInternalActionId, Us as canonicalStoredBlockTarget, Vl as isSecretRefOwnedBy, Wa as powerSourceLinkOfComposition, Wn as assertStepsOffered, Xa as projectDeviceRow, Xi as kebabToCamel, Xn as buildCapabilityLookup, Yn as buildActionSteps, Ys as compositionFeatureEnabled, Za as proposeRunningThreshold, Zo as stableIdMapOf, Zt as PowerSourceInfoSchema, _ as BUILTIN_REMOTE_COMPONENTS, _l as defineAddonMigrations, _n as SetOscillationAxisInputSchema, _o as resolveCoreBlockEntry, _r as compileScalarOverride, _s as toTimings, _u as DeviceType$1, ao as reexpandAutomationInstance, ar as canonicalStoredStepTargets, bl as defineRecordKinds, br as compositionSourceRefs, bs as validateComposition, bu as EventCategory$1, c as ActionError, cn as RunningStateStatusSchema, co as remoteSourceSteps, ct as EMPTY_AUTOMATION_STATE, d as ActionTargetResolver, dl as collectSecretMarkerRefs, do as replaceRecipeLiteral, ds as templateCapability, du as vocabActionIdFor, eo as readStoredRemoteConfig, eu as resolveSecretMarkers, f as ActionVariableSchema, fn as SWITCH_DEFAULT_OPTIONS, fo as replacedFieldKeys, fr as collectDeviceTemplates, fs as timedRunCapability, ft as FAN_CAPTURE_FIELDS, fu as vocabCall, g as BUILTIN_AUTOMATION_TEMPLATES, gi as findChannelSource, gs as timedRunSeconds, gt as FanControlStatusSchema, gu as DeviceRole, h as AutomationTemplatePayloadSchema, hs as timedRunQuickRun, ic as historyRetentionFromSettings, ii as evaluateWhenTree, iu as secretTreeFromSchema, j as ConditionMirror, ji as internalActionId, ki as instanceCodeHash, kl as hydrateSchema, kt as INTERNAL_ACTION_PREFIX, l as ActionMinDelaySecSchema, lo as removeFromTags, ls as tagKey, lt as EMPTY_REMOTE_ASSUMED_STATE, lu as transformSecretWrite, m as AutomationStateDocSchema, ml as commandOrigin$1, mn as SchedulerSchema, ms as timedRunMaxIn, mt as FAN_OSCILLATION_AXIS_SETTABLE, n as ACTION_TARGET_INVALIDATION_EVENTS, nt as DeclaredDevices, on as RemoteAssumedStateSchema, oo as remoteCapability, or as capUnitResolver, pi as fanPresetsCapability, pn as SchedulerError, po as resolveActionVariables, pr as collectWhenMirrorSources, ps as timedRunLimitOf, pt as FAN_OSCILLATION_AXES, qa as problemsBlockSave, qo as siteFor, qs as composedDeviceRef, ra as localDateOf, rc as helperMembers, ri as evaluateStepCondition, rn as REMOTE_MEDIA_COMMANDS, s as ALL_CAPABILITY_DEFINITIONS, sa as lockDoorLinkOfComposition, sn as RemoteLayoutPayloadSchema, so as remoteLayoutComponentsCapability, tl as actionEffect, tn as QuantityUnitError, tr as builtinAutomationTemplate, tu as ruleFireOfClaim, u as ActionStepSchema, ui as fanAxisPath, uo as renameInTags, ur as checkTemplatePayload, us as tagsCapability, ut as EMPTY_REMOTE_CONFIG, vc as BaseAddon, vo as resolveCoreBlockFiles, vt as FanPresetSchema, vu as errMsg$1, wa as nextOccurrence, wn as TagStyleSchema, wr as coreBlockComposition, xi as generateAutomationBlock, xr as compositionUnionReads, yl as defineEntryKind, yo as resolveHeroLayout, zl as isSecretMarker, zo as seedInstanceOnce, zr as describeComposableCaps, zt as MediaPlayerStatusSchema } from "../../dist-DBanWvHF.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
- import { i as parseDeviceStateChanged, r as isRecord$1, t as describeCompositionSources } from "../../composition-sources-B727nlA0.mjs";
4
- import { i as capSeriesKey } from "../../capture-engine-Bjgs__i9.mjs";
3
+ import { i as capSeriesKey, m as parseConfirmedStateChanged, p as isRecord$1 } from "../../capture-engine-BcD6iCZM.mjs";
4
+ import { t as describeCompositionSources } from "../../composition-sources-C3ARJk2g.mjs";
5
5
  import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
6
6
  import { n as unwrapStoredValue, t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
7
7
  import { n as readCurrentCommandOrigin } from "../../cap-call-scope-Bic6Ekfw.mjs";
@@ -1899,6 +1899,137 @@ var CoreBlockStore = class CoreBlockStore {
1899
1899
  }
1900
1900
  };
1901
1901
  //#endregion
1902
+ //#region src/builtins/core-blocks/migrations/automation-confirmed-view.ts
1903
+ /**
1904
+ * Stored generated automations move to the CONFIRMED view (D1061).
1905
+ *
1906
+ * An automation generated before D1061 read a device's slice in the effective
1907
+ * view: a command the hub still holds read as already done, so a condition on
1908
+ * it could pass before the device acted. The generator now asks for the
1909
+ * device's word. This regenerates each stored automation from the recipe its
1910
+ * code embeds (`AUTOMATION_RECIPE`), exactly as saving it in the editor would.
1911
+ *
1912
+ * Only code that is still what the generator writes is regenerated: its body
1913
+ * (the recipe literal blanked, as `instanceCodeHash` reads it) must equal what
1914
+ * the generator wrote before D1061 for that same recipe. Code edited by hand,
1915
+ * or written by a generator older than the one before D1061, is left exactly
1916
+ * as it is and logged per automation: regenerating it would lose what it does
1917
+ * differently. A hand-written script (no recipe) is not an automation here.
1918
+ * A rerun finds every regenerated automation already current and edits nothing.
1919
+ */
1920
+ var AUTOMATION_CONFIRMED_VIEW_ID = "core-blocks/2026-11-17-automation-confirmed-view";
1921
+ /** What D1061 changed in the generated code: [before, after]. */
1922
+ var D1061_EDITS = [["ctx.api.deviceState.getCapSlice.query({ deviceId, capName: cap })", "ctx.api.deviceState.getCapSlice.query({ deviceId, capName: cap, confirmed: true })"], [" mirror.apply(deviceId, capName, data['slice'])\n guardMirror.apply(deviceId, capName, data['slice'])", " // what the device reported: a held command is never a condition (D1061)\n const slice = data['confirmed'] ?? data['slice']\n mirror.apply(deviceId, capName, slice)\n guardMirror.apply(deviceId, capName, slice)"]];
1923
+ /** The code the generator wrote for the same recipe before D1061. */
1924
+ function beforeConfirmedView(current) {
1925
+ return D1061_EDITS.reduce((code, [before, after]) => code.split(after).join(before), current);
1926
+ }
1927
+ function verdictOf(block) {
1928
+ const read = readRecipeLiteral(block.code);
1929
+ if (read.status === "none") return { kind: "skip" };
1930
+ if (read.status === "invalid") return {
1931
+ kind: "leave",
1932
+ reason: `its recipe does not read: ${read.detail}`
1933
+ };
1934
+ const fresh = generateAutomationBlock({
1935
+ name: block.name,
1936
+ recipe: read.recipe
1937
+ });
1938
+ const stored = instanceCodeHash(block.code);
1939
+ if (stored === instanceCodeHash(fresh)) return { kind: "skip" };
1940
+ if (stored !== instanceCodeHash(beforeConfirmedView(fresh))) return {
1941
+ kind: "leave",
1942
+ reason: "the code is not what its recipe generates (edited by hand, or written by an older version); saving it in the editor moves it"
1943
+ };
1944
+ return {
1945
+ kind: "regenerate",
1946
+ code: fresh
1947
+ };
1948
+ }
1949
+ /** The block with its code (and, multi-file, its entry file) replaced. */
1950
+ function withCode(block, code, updatedAt) {
1951
+ if (block.files === void 0) return {
1952
+ ...block,
1953
+ code,
1954
+ updatedAt
1955
+ };
1956
+ const entry = resolveCoreBlockEntry(block.entry);
1957
+ return {
1958
+ ...block,
1959
+ code,
1960
+ files: {
1961
+ ...block.files,
1962
+ [entry]: code
1963
+ },
1964
+ updatedAt
1965
+ };
1966
+ }
1967
+ function rewriteOf$3(row, ports) {
1968
+ const parsed = CoreBlockSchema.safeParse(row.data.block);
1969
+ if (!parsed.success) return null;
1970
+ const block = parsed.data;
1971
+ const verdict = verdictOf(block);
1972
+ if (verdict.kind === "skip") return null;
1973
+ if (verdict.kind === "leave") {
1974
+ ports.warn("automation left as it was: not moved to the confirmed view", {
1975
+ blockId: row.id,
1976
+ name: block.name,
1977
+ reason: verdict.reason
1978
+ });
1979
+ return null;
1980
+ }
1981
+ const updatedAt = Math.max(block.updatedAt + 1, ports.now());
1982
+ const next = CoreBlockSchema.safeParse(withCode(block, verdict.code, updatedAt));
1983
+ if (!next.success) {
1984
+ ports.warn("automation left as it was: the regenerated block does not validate", {
1985
+ blockId: row.id,
1986
+ name: block.name,
1987
+ reason: next.error.message
1988
+ });
1989
+ return null;
1990
+ }
1991
+ return {
1992
+ row,
1993
+ data: {
1994
+ ...row.data,
1995
+ updatedAt,
1996
+ block: next.data
1997
+ }
1998
+ };
1999
+ }
2000
+ async function regenerateAutomationsConfirmedView(ports) {
2001
+ const rewrites = (await ports.listBlockRows()).flatMap((row) => {
2002
+ const rewrite = rewriteOf$3(row, ports);
2003
+ return rewrite === null ? [] : [rewrite];
2004
+ });
2005
+ if (rewrites.length === 0) return {
2006
+ outcome: "already-done",
2007
+ summary: { automations: 0 }
2008
+ };
2009
+ let regenerated = 0;
2010
+ for (const { row, data } of rewrites) {
2011
+ try {
2012
+ await ports.replaceBlockRow(row.id, data, row.rev);
2013
+ } catch (error) {
2014
+ ports.warn("automation left as it was: the regenerated code could not be saved", {
2015
+ blockId: row.id,
2016
+ name: data.name,
2017
+ reason: error instanceof Error ? error.message : String(error)
2018
+ });
2019
+ continue;
2020
+ }
2021
+ regenerated += 1;
2022
+ ports.info("automation regenerated: it reads the confirmed view (D1061)", {
2023
+ blockId: row.id,
2024
+ name: data.name
2025
+ });
2026
+ }
2027
+ return {
2028
+ outcome: "done",
2029
+ summary: { automations: regenerated }
2030
+ };
2031
+ }
2032
+ //#endregion
1902
2033
  //#region src/builtins/core-blocks/migrations/fountain-drink-drop.ts
1903
2034
  /**
1904
2035
  * The drink counters leave the `pet-fountain` feature of a stored composition.
@@ -2346,6 +2477,9 @@ function coreBlocksMigrationPorts(blocks, logger, now) {
2346
2477
  }, { ifRev });
2347
2478
  },
2348
2479
  now,
2480
+ info: (message, meta) => {
2481
+ logger.info(message, { meta });
2482
+ },
2349
2483
  warn: (message, meta) => {
2350
2484
  logger.warn(message, { meta });
2351
2485
  }
@@ -2829,6 +2963,22 @@ var ADDON_MIGRATIONS = [
2829
2963
  fixtureMark: "the binding action of each lettered key and the label of each layout button"
2830
2964
  },
2831
2965
  procedure: renameRemoteColourRoles
2966
+ },
2967
+ {
2968
+ meta: {
2969
+ id: AUTOMATION_CONFIRMED_VIEW_ID,
2970
+ owner: "core-blocks",
2971
+ level: "addon-state",
2972
+ seq: 6,
2973
+ dependsOn: [],
2974
+ store: "settings",
2975
+ scope: "cluster",
2976
+ onFailure: "tolerate",
2977
+ bodyKind: "procedure",
2978
+ description: "Regenerate each stored generated automation from its embedded recipe so it reads what the device reported, never a command the hub still holds; code edited by hand is left as it is and logged",
2979
+ fixtureMark: "the block createdBy and name, which the migration does not know"
2980
+ },
2981
+ procedure: regenerateAutomationsConfirmedView
2832
2982
  }
2833
2983
  ];
2834
2984
  //#endregion
@@ -2900,7 +3050,8 @@ function conditionDoorOver(api) {
2900
3050
  return evaluateStepCondition(when, {
2901
3051
  fetchSlice: (deviceId, cap) => current.deviceState.getCapSlice.query({
2902
3052
  deviceId,
2903
- capName: cap
3053
+ capName: cap,
3054
+ confirmed: true
2904
3055
  }),
2905
3056
  fetchStableIds: async () => stableIdMapOf(await current.deviceManager.listAll.query({}))
2906
3057
  }, () => Date.now(), void 0, site);
@@ -6176,7 +6327,8 @@ function hostOver(api) {
6176
6327
  readSite: async () => need().system.getSiteLocation.query(),
6177
6328
  fetchSlice: (deviceId, cap) => need().deviceState.getCapSlice.query({
6178
6329
  deviceId,
6179
- capName: cap
6330
+ capName: cap,
6331
+ confirmed: true
6180
6332
  }),
6181
6333
  fetchStableIds: async () => {
6182
6334
  return stableIdMapOf(await need().deviceManager.listAll.query({ projection: "slim" }));
@@ -6215,7 +6367,7 @@ function buildSchedulersRuntime(deps) {
6215
6367
  logger: deps.logger.child("schedulers")
6216
6368
  });
6217
6369
  const unsubscribers = [...ACTION_TARGET_INVALIDATION_EVENTS.map((category) => deps.eventBus.subscribe({ category }, () => engine.invalidateTargets())), deps.eventBus.subscribe({ category: EventCategory$1.DeviceStateChanged }, (event) => {
6218
- const data = parseDeviceStateChanged(event.data);
6370
+ const data = parseConfirmedStateChanged(event.data);
6219
6371
  if (data !== null) engine.onDeviceState(data.deviceId, data.capName, data.slice);
6220
6372
  })];
6221
6373
  return {
@@ -7917,7 +8069,8 @@ function remoteSliceWriterOver(settings, api) {
7917
8069
  if (current === void 0) throw new Error("no ctx.api on this node");
7918
8070
  const kept = MediaPlayerStatusSchema.safeParse(await current.deviceState.getCapSlice.query({
7919
8071
  deviceId,
7920
- capName: MEDIA_PLAYER_CAP
8072
+ capName: MEDIA_PLAYER_CAP,
8073
+ confirmed: true
7921
8074
  }));
7922
8075
  if (kept.success && sameStatus(kept.data, status)) return;
7923
8076
  await current.deviceState.setCapSlice.mutate({
@@ -9939,7 +10092,7 @@ var CoreBlocksAddon = class extends BaseAddon {
9939
10092
  });
9940
10093
  this.timedRun = timedRun;
9941
10094
  this.subscribe({ category: EventCategory$1.DeviceStateChanged }, (event) => {
9942
- const data = parseDeviceStateChanged(event.data);
10095
+ const data = parseConfirmedStateChanged(event.data);
9943
10096
  if (data !== null) timedRun.onDeviceState(data);
9944
10097
  });
9945
10098
  armTimedRuns(timedRun, this.ctx.logger.child("timed-run"), { isDisposed: () => this.disposed });
@@ -10044,7 +10197,8 @@ var CoreBlocksAddon = class extends BaseAddon {
10044
10197
  caps: async (deviceId) => (await requireApi().deviceManager.getBindings.query({ deviceId })).entries.map((e) => e.capName),
10045
10198
  slice: (deviceId, capName) => requireApi().deviceState.getCapSlice.query({
10046
10199
  deviceId,
10047
- capName
10200
+ capName,
10201
+ confirmed: true
10048
10202
  }),
10049
10203
  remoteCommands: async (deviceId) => (await requireApi().remote.listCommands.query({ deviceId })).commands.length,
10050
10204
  switchOptions: (deviceId) => switchOptionsOf(requireApi(), deviceId),
@@ -10127,7 +10281,7 @@ var CoreBlocksAddon = class extends BaseAddon {
10127
10281
  logger: this.ctx.logger.child("lock-door")
10128
10282
  });
10129
10283
  this.subscribe({ category: EventCategory$1.DeviceStateChanged }, (event) => {
10130
- const data = parseDeviceStateChanged(event.data);
10284
+ const data = parseConfirmedStateChanged(event.data);
10131
10285
  if (data !== null) gate.onStateChanged(data);
10132
10286
  });
10133
10287
  this.seedLockDoorGate = () => this.seedGate(gate);
@@ -10156,7 +10310,8 @@ var CoreBlocksAddon = class extends BaseAddon {
10156
10310
  readControl: async (deviceId) => {
10157
10311
  const slice = await requireApi().deviceState.getCapSlice.query({
10158
10312
  deviceId,
10159
- capName: "control"
10313
+ capName: "control",
10314
+ confirmed: true
10160
10315
  });
10161
10316
  if (slice === null) return null;
10162
10317
  const kind = slice["kind"];
@@ -10201,7 +10356,7 @@ var CoreBlocksAddon = class extends BaseAddon {
10201
10356
  if (typeof deviceId === "number") remote.refreshSlice(deviceId);
10202
10357
  });
10203
10358
  this.subscribe({ category: EventCategory$1.DeviceStateChanged }, (event) => {
10204
- const data = parseDeviceStateChanged(event.data);
10359
+ const data = parseConfirmedStateChanged(event.data);
10205
10360
  if (data !== null && REMOTE_SLICE_INPUT_CAPS.has(data.capName)) remote.onInputChanged(data.deviceId);
10206
10361
  });
10207
10362
  }
@@ -10637,7 +10792,8 @@ var CoreBlocksAddon = class extends BaseAddon {
10637
10792
  readField: async (deviceId, cap, fieldPath) => {
10638
10793
  const slice = await requireApi().deviceState.getCapSlice.query({
10639
10794
  deviceId,
10640
- capName: cap
10795
+ capName: cap,
10796
+ confirmed: true
10641
10797
  });
10642
10798
  return slice === null ? void 0 : slice[fieldPath];
10643
10799
  }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Stored generated automations move to the CONFIRMED view (D1061).
3
+ *
4
+ * An automation generated before D1061 read a device's slice in the effective
5
+ * view: a command the hub still holds read as already done, so a condition on
6
+ * it could pass before the device acted. The generator now asks for the
7
+ * device's word. This regenerates each stored automation from the recipe its
8
+ * code embeds (`AUTOMATION_RECIPE`), exactly as saving it in the editor would.
9
+ *
10
+ * Only code that is still what the generator writes is regenerated: its body
11
+ * (the recipe literal blanked, as `instanceCodeHash` reads it) must equal what
12
+ * the generator wrote before D1061 for that same recipe. Code edited by hand,
13
+ * or written by a generator older than the one before D1061, is left exactly
14
+ * as it is and logged per automation: regenerating it would lose what it does
15
+ * differently. A hand-written script (no recipe) is not an automation here.
16
+ * A rerun finds every regenerated automation already current and edits nothing.
17
+ */
18
+ import { type MigrationProcedureResult } from "@camstack/types";
19
+ import type { CoreBlocksMigrationPorts } from "./pump-cycle-split.js";
20
+ export declare const AUTOMATION_CONFIRMED_VIEW_ID = "core-blocks/2026-11-17-automation-confirmed-view";
21
+ /** The code the generator wrote for the same recipe before D1061. */
22
+ export declare function beforeConfirmedView(current: string): string;
23
+ export declare function regenerateAutomationsConfirmedView(ports: CoreBlocksMigrationPorts): Promise<MigrationProcedureResult>;
@@ -1,6 +1,7 @@
1
1
  import type { AddonMigration } from "@camstack/types";
2
2
  import { type CoreBlocksMigrationPorts } from "./pump-cycle-split.js";
3
3
  import { type RemoteMigrationPorts } from "./remote-config-migrations.js";
4
+ export { AUTOMATION_CONFIRMED_VIEW_ID } from "./automation-confirmed-view.js";
4
5
  export { FOUNTAIN_DRINK_DROP_ID } from "./fountain-drink-drop.js";
5
6
  export { REMOTE_COLOUR_ROLES_ID, REMOTE_POWER_DROP_ID, remoteMigrationPortsOver, type RemoteMigrationPorts } from "./remote-config-migrations.js";
6
7
  /** Everything the core-blocks catalogue touches: the block rows, and the stored remotes and templates. */
@@ -36,6 +36,7 @@ export interface CoreBlocksMigrationPorts {
36
36
  /** Replace a row's body, refused when the row changed since it was read. */
37
37
  replaceBlockRow(id: string, data: CoreBlockRowBody, ifRev: number): Promise<void>;
38
38
  now(): number;
39
+ info(message: string, meta: Readonly<Record<string, unknown>>): void;
39
40
  warn(message: string, meta: Readonly<Record<string, unknown>>): void;
40
41
  }
41
42
  /** The ports over the real `core_blocks` kind. */
@@ -3,8 +3,8 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-BoEy9sm9.js");
7
- const require_capture_engine = require("../../capture-engine-D1rjl2dW.js");
6
+ const require_dist = require("../../dist-DEAjZE_-.js");
7
+ const require_capture_engine = require("../../capture-engine-LHKTf-nM.js");
8
8
  const require_retention = require("../../retention-BcOSL6b9.js");
9
9
  let node_crypto = require("node:crypto");
10
10
  //#region src/builtins/device-history/capture/point-writer.ts
@@ -3987,10 +3987,11 @@ var DeviceHistoryAddon = class extends require_dist.BaseAddon {
3987
3987
  };
3988
3988
  }
3989
3989
  },
3990
- readSnapshots: async () => api.deviceState.getAllSnapshots.query({}),
3990
+ readSnapshots: async () => api.deviceState.getAllSnapshots.query({ confirmed: true }),
3991
3991
  readCapSlice: (deviceId, capName) => api.deviceState.getCapSlice.query({
3992
3992
  deviceId,
3993
- capName
3993
+ capName,
3994
+ confirmed: true
3994
3995
  }),
3995
3996
  readDeviceQuantity: async (deviceId) => {
3996
3997
  const quantity = (await api.deviceManager.getDevice.query({ deviceId }))?.sourceInfo?.quantity;
@@ -4010,10 +4011,9 @@ var DeviceHistoryAddon = class extends require_dist.BaseAddon {
4010
4011
  this.transitions = transitions;
4011
4012
  runtime.retentionJob.attachTransitions(transitions);
4012
4013
  this.unsubscribe = this.ctx.eventBus.subscribe({ category: require_dist.EventCategory.DeviceStateChanged }, (event) => {
4013
- const data = event.data;
4014
- if (!isRecord(data)) return;
4014
+ const data = require_capture_engine.parseConfirmedStateChanged(event.data);
4015
+ if (data === null) return;
4015
4016
  const { deviceId, capName, slice } = data;
4016
- if (typeof deviceId !== "number" || typeof capName !== "string" || !isRecord(slice)) return;
4017
4017
  const at = event.timestamp instanceof Date ? event.timestamp.getTime() : Date.now();
4018
4018
  runtime.capture.handleState(deviceId, capName, slice, at);
4019
4019
  runs.handleState(deviceId, capName, slice, at);
@@ -4041,10 +4041,11 @@ var DeviceHistoryAddon = class extends require_dist.BaseAddon {
4041
4041
  if (records === void 0) throw new Error("device-history needs ctx.records on the hub for the run ledger");
4042
4042
  return new DeviceRunsService({
4043
4043
  records,
4044
- readSnapshots: async () => ctx.api.deviceState.getAllSnapshots.query({}),
4044
+ readSnapshots: async () => ctx.api.deviceState.getAllSnapshots.query({ confirmed: true }),
4045
4045
  readCapSlice: (deviceId, capName) => ctx.api.deviceState.getCapSlice.query({
4046
4046
  deviceId,
4047
- capName
4047
+ capName,
4048
+ confirmed: true
4048
4049
  }),
4049
4050
  deviceTypeOf: (deviceId) => runtime.directory.ensure(deviceId),
4050
4051
  energyFromHistory: (deviceId, from, to) => energyKwhFromHistory((query) => runtime.query.query(query), deviceId, from, to),
@@ -1,5 +1,5 @@
1
- import { Bc as RecordTooLargeError, Bn as armRemovalReconcile, Br as deviceHistoryCapability, Cl as historyUnitFor, H as DEVICE_HISTORY_ENERGY_KEY, Jr as deviceTransitionsCapability, St as HISTORY_ITEM_CATALOG, Ur as deviceRemovalHookCapability, Wr as deviceRunsCapability, _l as emitReadiness, bc as DeviceTransitionSchema, fc as wattMillisecondsToKwh, fu as DeviceType, hl as defineRecordKinds, hu as EventCategory, jl as isReadingQuantity, pc as BaseAddon, rt as DeviceRunSchema, wc as InvalidRecordError, xt as HISTORY_CATALOG } from "../../dist-DorY_sjS.mjs";
2
- import { a as catalogMetrics, c as DeviceDirectory, d as identityOf, f as subjectIdOf, i as capSeriesKey, l as isRealDeviceType, n as CaptureEngine, o as readPath, r as capItemSeriesKey, s as readUnit, t as CAP_KEY_PREFIX, u as SeriesRegistry } from "../../capture-engine-Bjgs__i9.mjs";
1
+ import { Ct as HISTORY_ITEM_CATALOG, Gc as RecordTooLargeError, Il as isReadingQuantity, Kr as deviceRemovalHookCapability, Ol as historyUnitFor, Sl as emitReadiness, St as HISTORY_CATALOG, Tc as DeviceTransitionSchema, U as DEVICE_HISTORY_ENERGY_KEY, Un as armRemovalReconcile, Ur as deviceHistoryCapability, Zr as deviceTransitionsCapability, _c as wattMillisecondsToKwh, _u as DeviceType, bl as defineRecordKinds, bu as EventCategory, it as DeviceRunSchema, kc as InvalidRecordError, qr as deviceRunsCapability, vc as BaseAddon } from "../../dist-DBanWvHF.mjs";
2
+ import { a as catalogMetrics, c as DeviceDirectory, d as identityOf, f as subjectIdOf, i as capSeriesKey, l as isRealDeviceType, m as parseConfirmedStateChanged, n as CaptureEngine, o as readPath, r as capItemSeriesKey, s as readUnit, t as CAP_KEY_PREFIX, u as SeriesRegistry } from "../../capture-engine-BcD6iCZM.mjs";
3
3
  import { a as FIVE_MINUTES_MS, c as bucketEndOf, i as DAY_MS, l as bucketStartOf, n as RetentionJob, o as HOUR_MS, r as DepartureTracker, s as ROLLUP_GRACE_MS, t as DEFAULT_RETENTION, u as floorTo } from "../../retention-CUOVI1p7.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  //#region src/builtins/device-history/capture/point-writer.ts
@@ -3982,10 +3982,11 @@ var DeviceHistoryAddon = class extends BaseAddon {
3982
3982
  };
3983
3983
  }
3984
3984
  },
3985
- readSnapshots: async () => api.deviceState.getAllSnapshots.query({}),
3985
+ readSnapshots: async () => api.deviceState.getAllSnapshots.query({ confirmed: true }),
3986
3986
  readCapSlice: (deviceId, capName) => api.deviceState.getCapSlice.query({
3987
3987
  deviceId,
3988
- capName
3988
+ capName,
3989
+ confirmed: true
3989
3990
  }),
3990
3991
  readDeviceQuantity: async (deviceId) => {
3991
3992
  const quantity = (await api.deviceManager.getDevice.query({ deviceId }))?.sourceInfo?.quantity;
@@ -4005,10 +4006,9 @@ var DeviceHistoryAddon = class extends BaseAddon {
4005
4006
  this.transitions = transitions;
4006
4007
  runtime.retentionJob.attachTransitions(transitions);
4007
4008
  this.unsubscribe = this.ctx.eventBus.subscribe({ category: EventCategory.DeviceStateChanged }, (event) => {
4008
- const data = event.data;
4009
- if (!isRecord(data)) return;
4009
+ const data = parseConfirmedStateChanged(event.data);
4010
+ if (data === null) return;
4010
4011
  const { deviceId, capName, slice } = data;
4011
- if (typeof deviceId !== "number" || typeof capName !== "string" || !isRecord(slice)) return;
4012
4012
  const at = event.timestamp instanceof Date ? event.timestamp.getTime() : Date.now();
4013
4013
  runtime.capture.handleState(deviceId, capName, slice, at);
4014
4014
  runs.handleState(deviceId, capName, slice, at);
@@ -4036,10 +4036,11 @@ var DeviceHistoryAddon = class extends BaseAddon {
4036
4036
  if (records === void 0) throw new Error("device-history needs ctx.records on the hub for the run ledger");
4037
4037
  return new DeviceRunsService({
4038
4038
  records,
4039
- readSnapshots: async () => ctx.api.deviceState.getAllSnapshots.query({}),
4039
+ readSnapshots: async () => ctx.api.deviceState.getAllSnapshots.query({ confirmed: true }),
4040
4040
  readCapSlice: (deviceId, capName) => ctx.api.deviceState.getCapSlice.query({
4041
4041
  deviceId,
4042
- capName
4042
+ capName,
4043
+ confirmed: true
4043
4044
  }),
4044
4045
  deviceTypeOf: (deviceId) => runtime.directory.ensure(deviceId),
4045
4046
  energyFromHistory: (deviceId, from, to) => energyKwhFromHistory((query) => runtime.query.query(query), deviceId, from, to),
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Arms the command hold (D1061) from the D1022 command seams.
3
+ *
4
+ * Every device command the hub sees — its tRPC mount, the UDS parent for a
5
+ * forked addon's `ctx.api`, an in-process addon's `ctx.api` — reaches the
6
+ * process-wide observer registry BEFORE the call runs. Here each one resolves
7
+ * what it leads to (the vocabulary's effects under the provider's option) on
8
+ * the slice the device last reported, and the mirror holds it; a refused call
9
+ * rolls the hold back at once.
10
+ *
11
+ * Telemetry in, never a gate (D8): a throw here costs the hold, never the call.
12
+ */
13
+ import { type CommandHoldOptions, type IScopedLogger } from "@camstack/types";
14
+ import type { DeviceStateMirror } from "./device-state-mirror.js";
15
+ export interface CommandHoldsWiringDeps {
16
+ readonly mirror: DeviceStateMirror;
17
+ readonly logger: IScopedLogger;
18
+ /** The provider's options for a device cap; defaults to the process-wide registry. */
19
+ readonly optionsFor?: (deviceId: number, capName: string) => CommandHoldOptions | undefined;
20
+ }
21
+ /** Subscribe the hold to the command observations; returns the unsubscribe. */
22
+ export declare function startCommandHolds(deps: CommandHoldsWiringDeps): () => void;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The command hold (D1061): what a device was just told to do, shown at once.
3
+ *
4
+ * A command arms a hold on each field its effects name; the mirror reads the
5
+ * device's slice through it (the EFFECTIVE slice) while the slice it stores,
6
+ * persists and records stays what the device reported. Each held field
7
+ * remembers what the device reported for it when the command arrived. A
8
+ * reading of a held field is
9
+ * - STALE when it equals that pre-command value (or a value an older,
10
+ * replaced command held): the device has not acted yet — keep holding;
11
+ * - the CONFIRMATION when it equals the held value, a number within the
12
+ * effect's tolerance (the step of the arg it came from) — release;
13
+ * - the DEVICE'S OWN ANSWER otherwise (locking, jammed, arming, a value
14
+ * rounded beyond the step) — release at once and serve it (logged at
15
+ * debug, `device-answered`).
16
+ * A held field also ends when the call is refused (rolled back at once), when
17
+ * the limit elapses with the device still stale (reverted, warned), or when a
18
+ * newer command names the same field (latest wins).
19
+ *
20
+ * Memory only: a restart drops every hold. Nothing here does I/O; the timers
21
+ * are unref'd so a hold never keeps a process alive.
22
+ */
23
+ import type { CommandEffect, IScopedLogger } from "@camstack/types";
24
+ type Slice = Readonly<Record<string, unknown>>;
25
+ /** Why a hold ended other than by confirmation. */
26
+ export type HoldRelease = "refused" | "unconfirmed";
27
+ export interface CommandHoldsDeps {
28
+ readonly logger: IScopedLogger;
29
+ /** The slice the hold sits on (native, or a claim's merge), `null` when the cap has none. */
30
+ readonly baseSlice: (deviceId: number, capName: string) => Slice | null;
31
+ /** Re-emit the cap: the held set changed while the slice under it did not. */
32
+ readonly reemit: (deviceId: number, capName: string) => void;
33
+ }
34
+ /** What one command armed. */
35
+ export interface ArmRequest {
36
+ readonly deviceId: number;
37
+ readonly capName: string;
38
+ readonly method: string;
39
+ readonly effects: readonly CommandEffect[];
40
+ readonly holdMs: number;
41
+ }
42
+ export declare class CommandHolds {
43
+ private readonly deps;
44
+ /** device → cap → field → held value. */
45
+ private readonly held;
46
+ private readonly armings;
47
+ private seq;
48
+ constructor(deps: CommandHoldsDeps);
49
+ /**
50
+ * Hold what a command leads to. A field the slice already holds is not held
51
+ * (and a standing hold on it is dropped: the newer command wins). Returns the
52
+ * token that `release` takes, or `null` when nothing is held.
53
+ */
54
+ arm(request: ArmRequest): number | null;
55
+ /** End what `token` still holds — refused at once, or unconfirmed at the limit. */
56
+ release(token: number, reason: HoldRelease): void;
57
+ /**
58
+ * The slice under the hold moved: keep each held field it still reports
59
+ * stale, drop the ones it confirms or answers otherwise.
60
+ */
61
+ settle(deviceId: number, capName: string, base: Slice): void;
62
+ /** `base` with the held values over it; `base` itself when nothing is held. */
63
+ overlay(deviceId: number, capName: string, base: Slice): Slice;
64
+ /** Is any field of the cap held? */
65
+ isHolding(deviceId: number, capName: string): boolean;
66
+ /** Is any field of any cap of the device still held? (D1062: the command burst stops when this is false.) */
67
+ isHoldingDevice(deviceId: number): boolean;
68
+ /** Forget a removed device's holds. */
69
+ clearDevice(deviceId: number): void;
70
+ /** Stop every timer (shutdown). */
71
+ dispose(): void;
72
+ private fieldsOf;
73
+ private dropEmpty;
74
+ /** An arming whose fields were all confirmed or replaced holds nothing: stop its timer. */
75
+ private forgetStaleArmings;
76
+ }
77
+ export {};
@@ -35,6 +35,9 @@ export declare class DeviceManagerAddon extends BaseAddon {
35
35
  private stateMirrorImpl;
36
36
  /** The transition audit (D1022): command + mirror correlation, shipped to device-history. */
37
37
  private transitions;
38
+ /** Unsubscribes the command hold (D1061). */
39
+ private stopCommandHolds;
40
+ private stopStateRefresh;
38
41
  /**
39
42
  * Removes the claimed-status overlay this addon installed on the capability
40
43
  * registry (D663, S3): `getStatus` of a claimed cap answers the mirror for