@camstack/server 1.2.822 → 1.2.824

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 (109) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/trpc/generated-cap-routers.js +0 -45
  3. package/package.json +11 -11
  4. package/system/dist/addon-runner.js +42 -15
  5. package/system/dist/addon-runner.mjs +43 -16
  6. package/system/dist/addon-utils.d.ts +1 -0
  7. package/system/dist/addon-utils.js +2 -0
  8. package/system/dist/addon-utils.mjs +2 -1
  9. package/system/dist/{agent-https-SGBI0xP8.js → agent-https-B2nqARmj.js} +1 -1
  10. package/system/dist/{agent-https-C4yxMErF.mjs → agent-https-BBO2OtNH.mjs} +1 -1
  11. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  12. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  13. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  14. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  15. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  16. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  17. package/system/dist/builtins/autotrack/index.js +1 -1
  18. package/system/dist/builtins/autotrack/index.mjs +1 -1
  19. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  20. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  21. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  22. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  23. package/system/dist/builtins/camera-grid/index.js +1 -1
  24. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  25. package/system/dist/builtins/composer/composed-device-set.d.ts +5 -1
  26. package/system/dist/builtins/composer/composed-device.d.ts +4 -0
  27. package/system/dist/builtins/composer/composed-name.d.ts +30 -0
  28. package/system/dist/builtins/composer/composer.addon.js +94 -6
  29. package/system/dist/builtins/composer/composer.addon.mjs +94 -6
  30. package/system/dist/builtins/composer/composer.d.ts +13 -0
  31. package/system/dist/builtins/console-logging/index.js +1 -1
  32. package/system/dist/builtins/console-logging/index.mjs +1 -1
  33. package/system/dist/builtins/core-blocks/actions-service.d.ts +8 -0
  34. package/system/dist/builtins/core-blocks/composition-api.d.ts +6 -0
  35. package/system/dist/builtins/core-blocks/core-blocks.addon.js +143 -23
  36. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +144 -24
  37. package/system/dist/builtins/core-blocks/record-kinds.d.ts +1 -0
  38. package/system/dist/builtins/core-blocks/rename-composition-block.d.ts +16 -0
  39. package/system/dist/builtins/core-blocks/sync-composed-device-name.d.ts +19 -0
  40. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  41. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  42. package/system/dist/builtins/device-manager/device-manager.addon.js +43 -4
  43. package/system/dist/builtins/device-manager/device-manager.addon.mjs +43 -4
  44. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  45. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  46. package/system/dist/builtins/keychain/index.js +4 -4
  47. package/system/dist/builtins/keychain/index.mjs +4 -4
  48. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  49. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  50. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  51. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  52. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  53. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  54. package/system/dist/builtins/loki-logging/index.js +1 -1
  55. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  56. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  57. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  58. package/system/dist/builtins/platform-probe/index.js +1 -1
  59. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  60. package/system/dist/builtins/record-entries/index.js +1 -1
  61. package/system/dist/builtins/record-entries/index.mjs +1 -1
  62. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  63. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  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 +3 -3
  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/cap-call-scope-8eiugfLl.js +46 -0
  79. package/system/dist/cap-call-scope-Bic6Ekfw.mjs +30 -0
  80. package/system/dist/{capture-engine-BSjE-CQA.mjs → capture-engine-C-rHYVFq.mjs} +1 -1
  81. package/system/dist/{capture-engine-6MVUyUry.js → capture-engine-DP4HbT3W.js} +1 -1
  82. package/system/dist/{composition-sources-C8T9DRbZ.mjs → composition-sources-CL9JFN4y.mjs} +1 -1
  83. package/system/dist/{composition-sources-BBAOXZdC.js → composition-sources-CM9c_jAj.js} +1 -1
  84. package/system/dist/{constants-CReG6K4k.mjs → constants-DzGFnCKZ.mjs} +1 -1
  85. package/system/dist/{constants-v0g9--wN.js → constants-jk7JccZ0.js} +1 -1
  86. package/system/dist/{device-ca-BFcBTfff.js → device-ca-B7_R5WJh.js} +1 -1
  87. package/system/dist/{device-ca-cX8qUs2s.mjs → device-ca-DZ_OQiCc.mjs} +1 -1
  88. package/system/dist/{dist-DjBZ1HhF.mjs → dist-BgRMQHuL.mjs} +171 -184
  89. package/system/dist/{dist-C2czR9xK.js → dist-BpTL3uNe.js} +188 -183
  90. package/system/dist/file-host-worker.js +1 -1
  91. package/system/dist/file-host-worker.mjs +1 -1
  92. package/system/dist/{hub-mdns-ciao-Cnr8xiSd.mjs → hub-mdns-ciao-DIcBingB.mjs} +2 -2
  93. package/system/dist/{hub-mdns-ciao-CpCleue0.js → hub-mdns-ciao-DPUaYAD3.js} +2 -2
  94. package/system/dist/index.d.ts +1 -0
  95. package/system/dist/index.js +65 -42
  96. package/system/dist/index.mjs +64 -44
  97. package/system/dist/kernel/cap-call-scope.d.ts +10 -0
  98. package/system/dist/kernel/transport/cap-route-resolver.d.ts +27 -1
  99. package/system/dist/kernel/transport/child-cap-protocol.d.ts +1 -1
  100. package/system/dist/kernel/transport/parent-unowned-call.d.ts +0 -11
  101. package/system/dist/{legacy-integration-rows-door-CGajkVPh.mjs → legacy-integration-rows-door-1GnkpMgH.mjs} +1 -1
  102. package/system/dist/{legacy-integration-rows-door-DhW6mPZj.js → legacy-integration-rows-door-DYNePgj4.js} +1 -1
  103. package/system/dist/rename-composition-block-Cp0_nwAI.mjs +101 -0
  104. package/system/dist/rename-composition-block-Dn2z4fnA.js +112 -0
  105. package/system/dist/{restore-archive-eA7L58KT.mjs → restore-archive-B3FEpUfz.mjs} +1 -1
  106. package/system/dist/{restore-archive-BLab80kx.js → restore-archive-BGa5pdp9.js} +1 -1
  107. package/system/dist/{wal-maintenance-DeBxoOFh.mjs → wal-maintenance-BLWLlVfF.mjs} +0 -0
  108. package/system/dist/{wal-maintenance-DhnSF7K-.js → wal-maintenance-GWFxnSnE.js} +0 -0
  109. package/system/package.json +1 -1
@@ -803,7 +803,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
803
803
  return EventCategory;
804
804
  }({});
805
805
  //#endregion
806
- //#region ../types/dist/device-type-DTTZKB2I.mjs
806
+ //#region ../types/dist/composed-stable-id-DLcPInGv.mjs
807
807
  /**
808
808
  import { errMsg } from '@camstack/types'
809
809
  * Extract a human-readable message from an unknown error value.
@@ -1214,8 +1214,14 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1214
1214
  DeviceRole["IrTransmitter"] = "ir-transmitter";
1215
1215
  return DeviceRole;
1216
1216
  }({});
1217
+ /**
1218
+ * A composed device's stableId is this prefix plus the block id. Its own module,
1219
+ * free of zod, so the addon runner can read it through `@camstack/types/addon`
1220
+ * without loading the schema barrel (D28).
1221
+ */
1222
+ var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
1217
1223
  //#endregion
1218
- //#region ../types/dist/sleep-DnVqHJc4.mjs
1224
+ //#region ../types/dist/sleep-VrfKAAGN.mjs
1219
1225
  /**
1220
1226
  * The audio chunk plane's byte format, and the ONE expansion from a coded
1221
1227
  * window to float samples (D455).
@@ -5561,15 +5567,58 @@ function assertTransactScope(members) {
5561
5567
  if (missing.length > 0) throw new TransactRefusedError(`no-family: ${missing.map((m) => m.kind).join(", ")} declare no transactFamily; kinds that must agree through transact share one`);
5562
5568
  if (new Set(kinds.map((m) => m.declaration.transactFamily)).size > 1) throw new TransactRefusedError(`cross-family: the ops span more than one transactFamily (${kinds.map((m) => `${m.kind}=${String(m.declaration.transactFamily)}`).join(", ")})`);
5563
5569
  }
5564
- zod.z.discriminatedUnion("kind", [zod.z.object({
5565
- kind: zod.z.literal("action"),
5566
- actionId: zod.z.string(),
5567
- runId: zod.z.string(),
5568
- automationId: zod.z.string().optional()
5569
- }), zod.z.object({
5570
- kind: zod.z.literal("scheduler"),
5571
- schedulerId: zod.z.string()
5572
- })]);
5570
+ /**
5571
+ * The match a notification rule fired on (D705). Carried as a command origin so an
5572
+ * Action the rule starts can press `alarm-panel.trigger` as that match, not as an
5573
+ * anonymous press (D735). The same fields a rule fire ref freezes.
5574
+ */
5575
+ var RuleFireOriginSchema = zod.z.object({
5576
+ ruleId: zod.z.string(),
5577
+ ruleName: zod.z.string(),
5578
+ deviceId: zod.z.number().int(),
5579
+ sourceDeviceId: zod.z.number().int().optional(),
5580
+ recordId: zod.z.string(),
5581
+ timestamp: zod.z.number(),
5582
+ trackId: zod.z.string().optional(),
5583
+ eventId: zod.z.string().optional(),
5584
+ className: zod.z.string().optional(),
5585
+ label: zod.z.string().optional(),
5586
+ zones: zod.z.array(zod.z.string()).optional(),
5587
+ confidence: zod.z.number().optional(),
5588
+ sensorChange: zod.z.object({
5589
+ name: zod.z.string(),
5590
+ kind: zod.z.string(),
5591
+ state: zod.z.string()
5592
+ }).optional(),
5593
+ extraStills: zod.z.array(zod.z.object({
5594
+ ownerId: zod.z.string(),
5595
+ cameraId: zod.z.number().int()
5596
+ })).optional()
5597
+ });
5598
+ zod.z.discriminatedUnion("kind", [
5599
+ zod.z.object({
5600
+ kind: zod.z.literal("action"),
5601
+ actionId: zod.z.string(),
5602
+ runId: zod.z.string(),
5603
+ automationId: zod.z.string().optional(),
5604
+ /** The rule fire that started this run, when one did (D705). */
5605
+ ruleFire: RuleFireOriginSchema.optional()
5606
+ }),
5607
+ zod.z.object({
5608
+ kind: zod.z.literal("scheduler"),
5609
+ schedulerId: zod.z.string()
5610
+ }),
5611
+ zod.z.object({
5612
+ kind: zod.z.literal("rule"),
5613
+ fire: RuleFireOriginSchema
5614
+ })
5615
+ ]);
5616
+ /** The rule fire a claim carries, if it carries one. */
5617
+ function ruleFireOfClaim(claim) {
5618
+ if (claim === void 0) return void 0;
5619
+ if (claim.kind === "rule") return claim.fire;
5620
+ if (claim.kind === "action") return claim.ruleFire;
5621
+ }
5573
5622
  /**
5574
5623
  * One recorded device transition (D1022): a status field of a device went from
5575
5624
  * one value to another, with who or what asked for it.
@@ -13805,7 +13854,7 @@ function sleep(ms) {
13805
13854
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
13806
13855
  }
13807
13856
  //#endregion
13808
- //#region ../types/dist/composition-C6TZGqUb.mjs
13857
+ //#region ../types/dist/composition-BFJq1Y88.mjs
13809
13858
  var AUDIO_ENCODER_BY_CODEC = {
13810
13859
  opus: "libopus",
13811
13860
  aac: "aac",
@@ -16200,8 +16249,6 @@ function helperMembers(spec) {
16200
16249
  */
16201
16250
  /** The owner of every composed device: the `composer` builtin. */
16202
16251
  var COMPOSER_ADDON_ID = "composer";
16203
- /** A composed device's stableId is this prefix plus the block id. */
16204
- var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
16205
16252
  /** Longest snippet a `code` source may carry (slice 4). */
16206
16253
  var MAX_COMPOSITION_CODE_LENGTH = 2e4;
16207
16254
  /** One field of one capability of one source device. */
@@ -43761,30 +43808,21 @@ function convertLegacyWhen(half) {
43761
43808
  * (instants) and state leaves (durations). It replaces the flat trigger list
43762
43809
  * plus the separate condition tree; the firing rule is in that file and in
43763
43810
  * ADR "one tree".
43764
- * - **Actions** — `NcRuleActionSchema`'s two steps, plus the `{kind:'code'}`
43765
- * fragment of §3.2.2. See {@link AutomationActionSchema} for the ONE place
43766
- * this had to diverge from "verbatim", and why.
43811
+ * - **Actions** — the `wait` and `cap` steps, plus the `{kind:'code'}`
43812
+ * fragment of §3.2.2. See {@link AutomationActionSchema}.
43767
43813
  *
43768
43814
  * A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
43769
43815
  * {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
43770
43816
  */
43771
43817
  /**
43772
- * One action step.
43818
+ * One action step: `wait`, or a `cap` call.
43773
43819
  *
43774
- * `wait` and `cap` are `NcRuleActionSchema`'s two members, kept structurally
43775
- * identical so `NcRuleActionRunner` runs them unchanged — its device-scope
43776
- * check, stop-at-first-failure and per-sequence throttle are the whole reason
43777
- * to reuse it, and none of them are re-implemented here.
43778
- *
43779
- * **The one divergence, and it is forced.** `NcRuleActionSchema.cap.deviceId` is
43780
- * a literal `z.number().int()`, and the NC runner's own `RunSequencesInput`
43781
- * documents its subject device as *"for the log tag, never for routing"*. So an
43782
- * NC action can never target the device that triggered it — which is fine for
43783
- * the NC (its rules already scope to a device) and fatal for an automation
43784
- * ("sound the siren of the camera that saw the person"). `deviceId` therefore
43785
- * also accepts `{ $var }`, resolved from the run's `vars` bag BEFORE the runner
43786
- * is called. The runner still receives a number and is untouched; the
43787
- * resolution is the recipe's job, not the runner's.
43820
+ * A cap step's target is who it acts on (D983: `devices`, a `domain`, or a
43821
+ * `{ $var }` resolved from the run's variables); the legacy `deviceId` is still
43822
+ * READ, never written. The step runner (`runSteps`) owns the device-scope
43823
+ * check, the stop-at-first-failure and the variable substitution, once, for
43824
+ * every caller — automations, Actions, and the notification centre, which runs
43825
+ * only Actions (planning#473).
43788
43826
  */
43789
43827
  var AutomationWaitStepSchema = zod.z.object({
43790
43828
  kind: zod.z.literal("wait"),
@@ -45114,6 +45152,8 @@ var IDLE_ACTION_STATUS = {
45114
45152
  lastRunAt: null,
45115
45153
  lastError: null
45116
45154
  };
45155
+ /** The throttle window of an action, in seconds; absent or 0 = no throttle. */
45156
+ var ActionMinDelaySecSchema = zod.z.number().int().min(0).max(86400);
45117
45157
  var ActionEntrySchema = zod.z.object({
45118
45158
  /** `internal:<uuid>` or `<addonId>:<localId>`. */
45119
45159
  id: zod.z.string().min(3),
@@ -45126,6 +45166,14 @@ var ActionEntrySchema = zod.z.object({
45126
45166
  /** Internal only: cap and wait steps. No action-in-action, so no cycles. */
45127
45167
  steps: zod.z.array(ActionStepSchema).min(1).max(50).optional(),
45128
45168
  variables: zod.z.array(ActionVariableSchema).max(20).optional(),
45169
+ /**
45170
+ * Internal only: the least time between two run STARTS. A run that begins
45171
+ * inside the window is skipped (`skipped-cooldown`), traced and logged. It
45172
+ * is an actuator's budget — "how often may this gate physically open" —
45173
+ * not a notification cooldown, and it is shared by every caller of the
45174
+ * action (two rules, a button, an automation).
45175
+ */
45176
+ minDelaySec: ActionMinDelaySecSchema.optional(),
45129
45177
  status: ActionStatusSchema
45130
45178
  }).superRefine((entry, ctx) => {
45131
45179
  if (entry.source === "internal") {
@@ -45156,7 +45204,8 @@ var ActionEntrySchema = zod.z.object({
45156
45204
  var ActionInputSchema = zod.z.object({
45157
45205
  name: zod.z.string().min(1).max(120),
45158
45206
  steps: zod.z.array(ActionStepSchema).min(1).max(50),
45159
- variables: zod.z.array(ActionVariableSchema).max(20).optional()
45207
+ variables: zod.z.array(ActionVariableSchema).max(20).optional(),
45208
+ minDelaySec: ActionMinDelaySecSchema.optional()
45160
45209
  });
45161
45210
  /** Who started a run. Absent = the operator pressed it. */
45162
45211
  var ActionRunOriginSchema = zod.z.object({
@@ -59290,7 +59339,13 @@ var deviceManagerCapability = {
59290
59339
  * row + emits `EventCategory.DeviceMetaChanged`. */
59291
59340
  setName: method(zod.z.object({
59292
59341
  deviceId: zod.z.number(),
59293
- name: zod.z.string()
59342
+ name: zod.z.string(),
59343
+ /**
59344
+ * Absent or true: an operator rename, which stamps `userNamed`.
59345
+ * False: the system copying a block name onto the device. That write
59346
+ * must not look like the operator's, or the next reconcile freezes it.
59347
+ */
59348
+ stampUserNamed: zod.z.boolean().optional()
59294
59349
  }), zod.z.void(), {
59295
59350
  kind: "mutation",
59296
59351
  auth: "admin"
@@ -78605,101 +78660,21 @@ var NcZoneConditionSchema = zod.z.object({
78605
78660
  * membership lists are OR within the list (spec §2.3).
78606
78661
  */
78607
78662
  /**
78608
- * What a rule may actuate.
78609
- *
78610
- * **No hand-maintained allowlist** (operator decision, and the right one — a
78611
- * written list of methods is a third parallel map to keep aligned, and this
78612
- * repo has paid for those). The boundary instead comes from a property the
78613
- * capabilities already carry: an action may target only a **device-scoped**
78614
- * capability method.
78615
- *
78616
- * That is not decoration. A rule can be authored by a NON-ADMIN — personal
78617
- * rules are a supported flow — and the executor runs with the addon's
78618
- * privileges, so an unbounded action is an arbitrary RPC channel with a
78619
- * privilege escalation attached. Restricting to device scope excludes the
78620
- * system caps (`device-manager.removeDevice` and friends) by construction,
78621
- * costs nothing to maintain, and cannot rot: a cap that stops being
78622
- * device-scoped stops being actuatable in the same change.
78663
+ * What a rule or a button runs: an **Action** of the `actions` surface
78664
+ * (`internal:<uuid>` or an addon's), by id, and nothing else (planning#473).
78623
78665
  *
78624
- * The executor enforces it; {@link NcRuleActionSchema} carries the intent.
78666
+ * The notification centre has no step vocabulary of its own. The steps, the
78667
+ * device-scope boundary, the stop-at-first-failure, the throttle
78668
+ * (`minDelaySec`), the variables and the runs ledger all belong to the Action;
78669
+ * an operator edits them in ONE place (the Actions page) and a rule points at
78670
+ * the result. A rule can be authored by a non-admin (personal rules), which is
78671
+ * safe for the same reason: it can only name an Action an admin already wrote.
78625
78672
  */
78673
+ var NcActionIdSchema = zod.z.string().min(1);
78674
+ /** Action ids one hook edge runs, in order. Capped so a slot never becomes a second editor. */
78675
+ var NcHookActionIdsSchema = zod.z.array(NcActionIdSchema).max(4);
78626
78676
  /**
78627
- * One step of a sequence.
78628
- *
78629
- * `wait` is a first-class step rather than a property of the next action: it is
78630
- * what makes a sequence a SEQUENCE and not a list — "unlock, wait 5s, open"
78631
- * cannot be expressed otherwise.
78632
- */
78633
- var NcRuleActionSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
78634
- kind: zod.z.literal("wait"),
78635
- seconds: zod.z.number().min(0).max(300)
78636
- }), zod.z.object({
78637
- kind: zod.z.literal("cap"),
78638
- /**
78639
- * WHO the step acts on (D983) — the only shape that is written. A sequence
78640
- * stored before D983 carries `deviceId`; the sequence store reads it as a
78641
- * `devices` target.
78642
- */
78643
- target: ActionTargetSchema.optional(),
78644
- /** The vocabulary action the step performs; required for a `domain` target. */
78645
- actionId: zod.z.string().min(1).optional(),
78646
- /** @deprecated The pre-D983 single device. Read, never written. */
78647
- deviceId: zod.z.number().int().optional(),
78648
- /** Capability name, e.g. `alarm-panel`. */
78649
- cap: zod.z.string().min(1),
78650
- /** Method on it. The executor refuses a non-device-scoped cap. */
78651
- method: zod.z.string().min(1),
78652
- /** Method arguments, minus `deviceId` (the executor injects it). */
78653
- args: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
78654
- }).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
78655
- message: "a cap step needs a target",
78656
- path: ["target"]
78657
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
78658
- message: "a domain target needs the vocabulary action it applies to (actionId)",
78659
- path: ["actionId"]
78660
- })]);
78661
- /**
78662
- * A named, ordered run of steps shared across rules, with its own throttle.
78663
- *
78664
- * Sequences live in the notification centre's sequence store — never inline on
78665
- * a rule. A rule binds to one by id ({@link NcActionBindingSchema}), and a
78666
- * button names one the same way. `minDelaySec` exists because a noisy rule
78667
- * otherwise hammers a physical actuator — the rule's own cooldown governs
78668
- * NOTIFICATIONS, which is a different budget from "how often may this gate
78669
- * actually open". The throttle key is the sequence id, so two rules sharing
78670
- * one sequence share its budget.
78671
- */
78672
- var NcSharedSequenceSchema = zod.z.object({
78673
- id: zod.z.string().min(1),
78674
- name: zod.z.string().min(1).max(120),
78675
- minDelaySec: zod.z.number().int().min(0).max(86400).optional(),
78676
- actions: zod.z.array(NcRuleActionSchema).min(1)
78677
- });
78678
- /** Create / update body — the id is minted by the provider. */
78679
- var NcSharedSequenceInputSchema = zod.z.object({
78680
- name: zod.z.string().min(1).max(120),
78681
- minDelaySec: zod.z.number().int().min(0).max(86400).optional(),
78682
- actions: zod.z.array(NcRuleActionSchema).min(1)
78683
- });
78684
- /**
78685
- * What one hook slot may run: a shared sequence, or a single step authored
78686
- * inline ("Do").
78687
- *
78688
- * A button may ONLY name a sequence — a one-shot Do on a public callback would
78689
- * be a parallel actuation vocabulary with no throttle and no shared authoring
78690
- * surface.
78691
- */
78692
- var NcActionBindingSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
78693
- kind: zod.z.literal("sequence"),
78694
- sequenceId: zod.z.string().min(1)
78695
- }), zod.z.object({
78696
- kind: zod.z.literal("do"),
78697
- action: NcRuleActionSchema
78698
- })]);
78699
- /** Bindings on one hook edge. Cap keeps a slot from becoming a second sequence editor. */
78700
- var NcHookBindingsSchema = zod.z.array(NcActionBindingSchema).max(4);
78701
- /**
78702
- * One button carried by the notification, running a shared sequence on tap.
78677
+ * One button carried by the notification, running an Action on tap.
78703
78678
  *
78704
78679
  * **Read this before adding a button that does something physical.** The tap
78705
78680
  * arrives over a link that travelled through third-party infrastructure — ntfy,
@@ -78714,9 +78689,9 @@ var NcRuleNotificationButtonSchema = zod.z.object({
78714
78689
  /** Stable id — travels in the callback and identifies the button in logs. */
78715
78690
  id: zod.z.string().min(1).max(64),
78716
78691
  label: zod.z.string().min(1).max(40),
78717
- /** Id of a shared sequence. The dispatcher drops a button whose sequence
78718
- * does not exist rather than minting a token for nothing. */
78719
- sequenceId: zod.z.string().min(1),
78692
+ /** The Action the tap runs. The dispatcher drops a button whose Action does
78693
+ * not exist rather than minting a token for nothing. */
78694
+ actionId: NcActionIdSchema,
78720
78695
  icon: NotificationActionIconSchema.optional(),
78721
78696
  destructive: zod.z.boolean().optional()
78722
78697
  });
@@ -78731,25 +78706,19 @@ var NcRuleNotificationButtonSchema = zod.z.object({
78731
78706
  * leave). A delivery with no clear edge never produces this hook.
78732
78707
  */
78733
78708
  var NcRuleActionsSchema = zod.z.object({
78734
- onActivation: NcHookBindingsSchema.optional(),
78735
- onDeactivation: NcHookBindingsSchema.optional(),
78709
+ onActivation: NcHookActionIdsSchema.optional(),
78710
+ onDeactivation: NcHookActionIdsSchema.optional(),
78736
78711
  /** Runs on a positive / raised match. */
78737
- onTrigger: NcHookBindingsSchema.optional(),
78712
+ onTrigger: NcHookActionIdsSchema.optional(),
78738
78713
  /** Runs on a clear / leave match, when the subject carries one. */
78739
- onTriggerOff: NcHookBindingsSchema.optional(),
78714
+ onTriggerOff: NcHookActionIdsSchema.optional(),
78740
78715
  /**
78741
- * Buttons the NOTIFICATION carries, each running one shared sequence when
78742
- * tapped. Deliberately a REFERENCE — a button that could define its own
78743
- * actions would be a parallel actuation vocabulary.
78716
+ * Buttons the NOTIFICATION carries, each running one Action when tapped.
78717
+ * Deliberately a REFERENCE — a button that could define its own steps would
78718
+ * be a parallel actuation vocabulary.
78744
78719
  */
78745
78720
  buttons: zod.z.array(NcRuleNotificationButtonSchema).max(8).optional()
78746
78721
  });
78747
- zod.z.object({
78748
- name: zod.z.string().min(1).max(120),
78749
- enabled: zod.z.boolean(),
78750
- minDelaySec: zod.z.number().int().min(0).max(86400).optional(),
78751
- actions: zod.z.array(NcRuleActionSchema).min(1)
78752
- });
78753
78722
  /**
78754
78723
  * "This rule applies only while `deviceId` is in one of `states`."
78755
78724
  *
@@ -80463,28 +80432,6 @@ var notificationRulesCapability = {
80463
80432
  auth: "admin"
80464
80433
  }),
80465
80434
  /**
80466
- * Shared action sequences — named step lists rules and buttons bind to by
80467
- * id. One store for the whole notification centre so two rules sharing a
80468
- * gate share its throttle too.
80469
- */
80470
- listSequences: method(zod.z.object({}), zod.z.object({ sequences: zod.z.array(NcSharedSequenceSchema) }), { auth: "admin" }),
80471
- getSequence: method(zod.z.object({ sequenceId: zod.z.string().min(1) }), zod.z.object({ sequence: NcSharedSequenceSchema.nullable() }), { auth: "admin" }),
80472
- createSequence: method(zod.z.object({ sequence: NcSharedSequenceInputSchema }), zod.z.object({ sequence: NcSharedSequenceSchema }), {
80473
- kind: "mutation",
80474
- auth: "admin"
80475
- }),
80476
- updateSequence: method(zod.z.object({
80477
- sequenceId: zod.z.string().min(1),
80478
- sequence: NcSharedSequenceInputSchema
80479
- }), zod.z.object({ sequence: NcSharedSequenceSchema }), {
80480
- kind: "mutation",
80481
- auth: "admin"
80482
- }),
80483
- deleteSequence: method(zod.z.object({ sequenceId: zod.z.string().min(1) }), zod.z.object({ success: zod.z.literal(true) }), {
80484
- kind: "mutation",
80485
- auth: "admin"
80486
- }),
80487
- /**
80488
80435
  * WHAT THE RULES ACTUALLY ASK the stream broker to retain, per camera.
80489
80436
  *
80490
80437
  * The notification centre owns the rules, so it is the only thing that can
@@ -98180,11 +98127,41 @@ function deriveBatteryPresence(input) {
98180
98127
  * priority-in-sync.ts` fails the build when either drifts — the comment that
98181
98128
  * used to ask for this could not.
98182
98129
  *
98183
- * The rule has two halves and the ORDER matters: an operator's explicit pick
98184
- * wins outright, and only in its absence does type priority decide. The pick is
98185
- * keyed on the child's re-sync-stable `entityId`, not its numeric id, so it
98186
- * survives a re-sync that reallocates ids.
98130
+ * The rule has three halves and the ORDER matters: an operator's explicit pick
98131
+ * wins outright; else a declaration on the device type
98132
+ * ({@link CONTAINER_PRIMARY_CHILD_RULES}); else role, namesake, then type
98133
+ * priority. The pick is keyed on the child's re-sync-stable `entityId`, not
98134
+ * its numeric id, so it survives a re-sync that reallocates ids.
98135
+ */
98136
+ /**
98137
+ * Device types that name their primary child. A heat pump stands for itself:
98138
+ * its hero is the system row, not the climate circuit that type-rank would
98139
+ * otherwise pick.
98140
+ */
98141
+ var CONTAINER_PRIMARY_CHILD_RULES = [{
98142
+ deviceType: DeviceType.HeatPump,
98143
+ primary: "self"
98144
+ }];
98145
+ /**
98146
+ * The type declaration, before the heuristic. `fall-through` means the
98147
+ * heuristic still decides: the type declared nothing, or it named a child
98148
+ * type that is not among the children.
98187
98149
  */
98150
+ function declaredChildType(primary) {
98151
+ if (primary === "self") return void 0;
98152
+ return primary.childType;
98153
+ }
98154
+ function applyPrimaryChildRule(rule, children) {
98155
+ if (rule === void 0) return { kind: "fall-through" };
98156
+ const childType = declaredChildType(rule.primary);
98157
+ if (childType === void 0) return { kind: "none" };
98158
+ const match = children.find((child) => child.type === childType);
98159
+ if (match === void 0) return { kind: "fall-through" };
98160
+ return {
98161
+ kind: "child",
98162
+ child: match
98163
+ };
98164
+ }
98188
98165
  /**
98189
98166
  * Type priority, most→least "primary". An actuator (climate / lock / cover / …)
98190
98167
  * outranks a bare `switch` so a container's defining child wins over its
@@ -98272,9 +98249,10 @@ function rank(type) {
98272
98249
  }
98273
98250
  /**
98274
98251
  * The child a container stands for: the operator's pick when it still exists,
98275
- * else the highest-priority type. `null` for a childless container — a caller
98276
- * must decide what an empty container means for it, rather than being handed a
98277
- * child that is not there.
98252
+ * else the device type's declaration, else the highest-priority type. `null`
98253
+ * for a childless container, and for a type that stands for itself — a caller
98254
+ * must decide what "no child" means for it, rather than being handed a child
98255
+ * that is not the device.
98278
98256
  */
98279
98257
  /**
98280
98258
  * Two names for the same thing, compared the way an integration writes them.
@@ -98303,11 +98281,14 @@ function sameName(childName, containerName) {
98303
98281
  const flatten = (v) => v.toLowerCase().replace(/[-_\s]+/g, " ").trim();
98304
98282
  return flatten(childName) === flatten(containerName);
98305
98283
  }
98306
- function resolveContainerPrimaryChild(children, overrideEntityId, containerName) {
98284
+ function resolveContainerPrimaryChild(children, overrideEntityId, containerName, containerType) {
98307
98285
  if (overrideEntityId !== void 0 && overrideEntityId !== null) {
98308
98286
  const picked = children.find((c) => c.stableId === overrideEntityId) ?? children.find((c) => c.entityId !== void 0 && c.entityId === overrideEntityId);
98309
98287
  if (picked !== void 0) return picked;
98310
98288
  }
98289
+ const declared = applyPrimaryChildRule(CONTAINER_PRIMARY_CHILD_RULES.find((entry) => entry.deviceType === containerType), children);
98290
+ if (declared.kind === "none") return null;
98291
+ if (declared.kind === "child") return declared.child;
98311
98292
  const namesake = (c) => containerName !== void 0 && containerName.length > 0 && c.name !== void 0 && sameName(c.name, containerName) ? 0 : 1;
98312
98293
  return [...children].toSorted((a, b) => roleRank(a.role) - roleRank(b.role) || namesake(a) - namesake(b) || rank(a.type) - rank(b.type))[0] ?? null;
98313
98294
  }
@@ -98355,7 +98336,7 @@ function expandContainer(id, byId, byParent, visited, out) {
98355
98336
  type: c.type,
98356
98337
  ...c.role !== void 0 && c.role !== null ? { role: c.role } : {},
98357
98338
  ...c.name !== void 0 ? { name: c.name } : {}
98358
- })), byId.get(id)?.primaryChildEntityId, byId.get(id)?.name);
98339
+ })), byId.get(id)?.primaryChildEntityId, byId.get(id)?.name, candidate.type);
98359
98340
  if (primary !== null) expandContainer(primary.id, byId, byParent, nextVisited, out);
98360
98341
  }
98361
98342
  /**
@@ -100445,7 +100426,7 @@ var CLIMATE_FAMILY_CONTRIBUTIONS = {
100445
100426
  /**
100446
100427
  * The heat pump's contribution to a hero (D1026): the compressor scene, every
100447
100428
  * circuit as a row with its own label and icon, the powers as pills (the
100448
- * instantaneous COP only when both powers are known) and a "System" group with
100429
+ * instantaneous COP is "—" when it cannot be computed) and a "System" group with
100449
100430
  * one selector per mode. Values and their limits come from the slice, which the
100450
100431
  * gateway filled: a selector with no allowed value is not drawn, a missing
100451
100432
  * reading is never a 0 (D393).
@@ -100517,9 +100498,22 @@ function circuitRow(circuit) {
100517
100498
  };
100518
100499
  }
100519
100500
  var kilowatts = (watts) => `${Number((watts / 1e3).toFixed(2))} kW`;
100501
+ /** A COP that cannot be computed is still the pill: "—", never an absent reading (D393). */
100502
+ function copPill(cop) {
100503
+ if (cop === null) return {
100504
+ icon: "gauge",
100505
+ text: t("Instantaneous COP —", "COP istantaneo —"),
100506
+ tone: "muted"
100507
+ };
100508
+ const text = String(Number(cop.toFixed(1)));
100509
+ return {
100510
+ icon: "gauge",
100511
+ text: t(`Instantaneous COP ${text}`, `COP istantaneo ${text}`),
100512
+ tone: "success"
100513
+ };
100514
+ }
100520
100515
  function powerPills(status) {
100521
100516
  const { thermalW, electricalW } = status.power;
100522
- const cop = heatPumpInstantCop(status.power);
100523
100517
  const pills = [];
100524
100518
  if (thermalW !== null) pills.push({
100525
100519
  icon: "flame",
@@ -100531,14 +100525,7 @@ function powerPills(status) {
100531
100525
  text: t(`Electrical ${kilowatts(electricalW)}`, `Elettrica ${kilowatts(electricalW)}`),
100532
100526
  tone: "muted"
100533
100527
  });
100534
- if (cop !== null) {
100535
- const text = String(Number(cop.toFixed(1)));
100536
- pills.push({
100537
- icon: "gauge",
100538
- text: t(`Instantaneous COP ${text}`, `COP istantaneo ${text}`),
100539
- tone: "success"
100540
- });
100541
- }
100528
+ pills.push(copPill(heatPumpInstantCop(status.power)));
100542
100529
  return pills;
100543
100530
  }
100544
100531
  /** The independent system modes, in the order the card draws them. */
@@ -118517,6 +118504,12 @@ Object.defineProperty(exports, "ActionError", {
118517
118504
  return ActionError;
118518
118505
  }
118519
118506
  });
118507
+ Object.defineProperty(exports, "ActionMinDelaySecSchema", {
118508
+ enumerable: true,
118509
+ get: function() {
118510
+ return ActionMinDelaySecSchema;
118511
+ }
118512
+ });
118520
118513
  Object.defineProperty(exports, "ActionStepSchema", {
118521
118514
  enumerable: true,
118522
118515
  get: function() {
@@ -118607,6 +118600,12 @@ Object.defineProperty(exports, "CATALOG_LANGS", {
118607
118600
  return CATALOG_LANGS;
118608
118601
  }
118609
118602
  });
118603
+ Object.defineProperty(exports, "COMPOSED_DEVICE_STABLE_ID_PREFIX", {
118604
+ enumerable: true,
118605
+ get: function() {
118606
+ return COMPOSED_DEVICE_STABLE_ID_PREFIX;
118607
+ }
118608
+ });
118610
118609
  Object.defineProperty(exports, "COMPOSED_ITEM_FIXED_FIELDS", {
118611
118610
  enumerable: true,
118612
118611
  get: function() {
@@ -121031,6 +121030,12 @@ Object.defineProperty(exports, "resolveTemplateRef", {
121031
121030
  return resolveTemplateRef;
121032
121031
  }
121033
121032
  });
121033
+ Object.defineProperty(exports, "ruleFireOfClaim", {
121034
+ enumerable: true,
121035
+ get: function() {
121036
+ return ruleFireOfClaim;
121037
+ }
121038
+ });
121034
121039
  Object.defineProperty(exports, "runFanOut", {
121035
121040
  enumerable: true,
121036
121041
  get: function() {
@@ -1,5 +1,5 @@
1
1
  require("./chunk-Cek0wNdY.js");
2
- const require_wal_maintenance = require("./wal-maintenance-DhnSF7K-.js");
2
+ const require_wal_maintenance = require("./wal-maintenance-GWFxnSnE.js");
3
3
  let node_worker_threads = require("node:worker_threads");
4
4
  //#region src/builtins/sqlite-storage/file-host-worker.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { A as callRecords, C as isFileHostWorkerData, D as RecordsEngine, M as controlTargetOf, O as callControl, S as isFileHostRequest, a as WalMaintenance, b as collectTransferables, d as callMigrate, f as migrateTargetOf, j as callVector, k as callData, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, u as HUB_MIGRATIONS, v as serializeError, w as trustInput } from "./wal-maintenance-DeBxoOFh.mjs";
1
+ import { A as callRecords, C as isFileHostWorkerData, D as RecordsEngine, M as controlTargetOf, O as callControl, S as isFileHostRequest, a as WalMaintenance, b as collectTransferables, d as callMigrate, f as migrateTargetOf, j as callVector, k as callData, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, u as HUB_MIGRATIONS, v as serializeError, w as trustInput } from "./wal-maintenance-BLWLlVfF.mjs";
2
2
  import { parentPort, threadId, workerData } from "node:worker_threads";
3
3
  //#region src/builtins/sqlite-storage/file-host-worker.ts
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  import { o as __toESM } from "./chunk-CNf5ZN-e.mjs";
2
- import { Xc as userError } from "./dist-DjBZ1HhF.mjs";
2
+ import { Qc as userError } from "./dist-BgRMQHuL.mjs";
3
3
  import { f as X509Certificate$1 } from "./x509.es-BRiJgOvu.mjs";
4
- import { D as reasonRequiresNewCa, E as evaluateExistingCert, F as readNameConstraints, N as permitsIdentity, _ as issueLeaf, b as collectCertIdentity, g as generateCa, j as isConstrainedCa, v as loadCa, y as localCaCommonName } from "./agent-https-C4yxMErF.mjs";
4
+ import { D as reasonRequiresNewCa, E as evaluateExistingCert, F as readNameConstraints, N as permitsIdentity, _ as issueLeaf, b as collectCertIdentity, g as generateCa, j as isConstrainedCa, v as loadCa, y as localCaCommonName } from "./agent-https-BBO2OtNH.mjs";
5
5
  import { X509Certificate, createPrivateKey } from "node:crypto";
6
6
  import { writeOwnerOnlyFileSync } from "@camstack/types/node";
7
7
  import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
@@ -1,7 +1,7 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-C2czR9xK.js");
2
+ const require_dist = require("./dist-BpTL3uNe.js");
3
3
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
4
- const require_agent_https = require("./agent-https-SGBI0xP8.js");
4
+ const require_agent_https = require("./agent-https-B2nqARmj.js");
5
5
  let node_crypto = require("node:crypto");
6
6
  let _camstack_types_node = require("@camstack/types/node");
7
7
  let node_fs = require("node:fs");
@@ -143,6 +143,7 @@ export { storageOrchestratorRecordKinds } from "./builtins/storage-orchestrator/
143
143
  export { backupOrchestratorRecordKinds, backupRecordStoresOf, type BackupRecordStores } from "./builtins/backup-orchestrator/record-kinds.js";
144
144
  export { readAllRows } from "./records/read-all-rows.js";
145
145
  export { clearNodeSettings } from "./kernel/addon-settings-store.js";
146
+ export { currentCapCallContext, readCurrentCommandOrigin, runWithCapCallContext } from "./kernel/cap-call-scope.js";
146
147
  export { RecordsEngine, type RecordsEngineOptions } from "./builtins/sqlite-storage/records/records-engine.js";
147
148
  export { type EnsureAddonNativePrebuildsOptions, ensureAddonNativePrebuilds, type NativeEnsureOutcome, type NativeEnsureResult } from "./kernel/deps/ensure-addon-natives.js";
148
149
  export { type EnsureNativePrebuildsOptions, ensureNativePrebuilds, hasDotNode, NATIVE_SCAN_DEPTH, type PrebuildFetchFn, type PrebuildTarget, TRADITIONAL_NATIVE_PACKAGES } from "./kernel/deps/ensure-native-prebuilds.js";