@camstack/addon-provider-homeassistant 1.2.45 → 1.2.47

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/dist/addon.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_dist = require("./dist-BXcwGSn_.js");
2
+ const require_dist = require("./dist-D_G71rhM.js");
3
3
  let node_crypto = require("node:crypto");
4
4
  let node_zlib = require("node:zlib");
5
5
  //#region src/ha-device-source.ts
package/dist/addon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as presenceCapability, A as controlCapability, At as EventCategory, B as humiditySensorCapability, C as buildAddonRouteProvider, Ct as number, D as colorCapability, Dt as union, E as climateControlCapability, Et as string, F as eventEmitterCapability, G as motionCapability, H as lawnMowerControlCapability, I as fanControlCapability, J as notifierCapability, K as normalizeUnit, L as floodCapability, M as deviceAdoptionCapability, O as connectivityCapability, Ot as unknown, P as enumSensorCapability, Q as prepareNotification, R as gasCapability, S as brokerCapability, St as literal, T as carbonMonoxideCapability, Tt as record, U as lockControlCapability, V as imageCapability, W as mediaPlayerCapability, Y as numericSensorCapability, Z as powerMeterCapability, _ as automationControlCapability, _t as createEvent, at as temperatureSensorCapability, b as binaryCapability, bt as array, ct as valveCapability, d as TargetSchema, dt as weatherCapability, et as pressureSensorCapability, f as accessoriesCapability, ft as errMsg, g as ambientLightSensorCapability, gt as DeviceType, h as alarmPanelCapability, ht as DeviceRole, it as tamperCapability, j as coverCapability, k as contactCapability, kt as url, lt as vibrationCapability, m as airQualitySensorCapability, mt as DeviceFeature, n as BaseDevice, nt as smokeCapability, ot as updateCapability, p as addonRoutesCapability, q as notificationOutputCapability, r as BaseDeviceProvider, rt as switchCapability, s as EnumSensorDateTimeFormatSchema, st as vacuumControlCapability, tt as scriptRunnerCapability, ut as waterHeaterCapability, v as batteryCapability, w as buttonCapability, wt as object, x as brightnessCapability, xt as discriminatedUnion, y as bestLocationMatch, yt as _enum, z as humidifierCapability } from "./dist-Dfp98hJL.mjs";
1
+ import { $ as presenceCapability, A as controlCapability, At as EventCategory, B as humiditySensorCapability, C as buildAddonRouteProvider, Ct as number, D as colorCapability, Dt as union, E as climateControlCapability, Et as string, F as eventEmitterCapability, G as motionCapability, H as lawnMowerControlCapability, I as fanControlCapability, J as notifierCapability, K as normalizeUnit, L as floodCapability, M as deviceAdoptionCapability, O as connectivityCapability, Ot as unknown, P as enumSensorCapability, Q as prepareNotification, R as gasCapability, S as brokerCapability, St as literal, T as carbonMonoxideCapability, Tt as record, U as lockControlCapability, V as imageCapability, W as mediaPlayerCapability, Y as numericSensorCapability, Z as powerMeterCapability, _ as automationControlCapability, _t as createEvent, at as temperatureSensorCapability, b as binaryCapability, bt as array, ct as valveCapability, d as TargetSchema, dt as weatherCapability, et as pressureSensorCapability, f as accessoriesCapability, ft as errMsg, g as ambientLightSensorCapability, gt as DeviceType, h as alarmPanelCapability, ht as DeviceRole, it as tamperCapability, j as coverCapability, k as contactCapability, kt as url, lt as vibrationCapability, m as airQualitySensorCapability, mt as DeviceFeature, n as BaseDevice, nt as smokeCapability, ot as updateCapability, p as addonRoutesCapability, q as notificationOutputCapability, r as BaseDeviceProvider, rt as switchCapability, s as EnumSensorDateTimeFormatSchema, st as vacuumControlCapability, tt as scriptRunnerCapability, ut as waterHeaterCapability, v as batteryCapability, w as buttonCapability, wt as object, x as brightnessCapability, xt as discriminatedUnion, y as bestLocationMatch, yt as _enum, z as humidifierCapability } from "./dist-DlrKePv3.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { brotliCompressSync, deflateSync, gzipSync } from "node:zlib";
4
4
  //#region src/ha-device-source.ts
@@ -7671,6 +7671,111 @@ var CameraSwitchGroupSchema = object({
7671
7671
  fetchedAt: number()
7672
7672
  });
7673
7673
  /**
7674
+ * Per-component log CHANNELS — the gate a hot path consults, and the registry
7675
+ * an addon declares its channels in.
7676
+ *
7677
+ * ## Two axes, deliberately separated
7678
+ *
7679
+ * - **DECLARATION** — which channels exist. Only the addon knows:
7680
+ * `stream-broker` knows webrtc/ICE/RTP, `provider-reolink` knows
7681
+ * baichuan/handshake. A hand-wired central list rots at the first addition,
7682
+ * and rots silently. So a channel is declared where it is consulted, and the
7683
+ * `log-channels` capability enumerates the declarations.
7684
+ * - **VALUE** — at which level, for which scope, until when. That stays ONE
7685
+ * thing: the logging settings document on the `system` cap. Two authorities
7686
+ * over the values is the exact defect
7687
+ * `docs/design/plans/2026-08-26-logging-per-componente.md` was written to
7688
+ * remove; re-introducing it from the cure side would be grotesque.
7689
+ *
7690
+ * Nothing in this file reads a clock, an env var or a store. The registry is
7691
+ * a MIRROR: it is moved only by {@link LogChannelRegistry.apply}, called off
7692
+ * the hot path with a value somebody actually read, and by
7693
+ * {@link LogChannelRegistry.tick}, called on a timer. A store read that fails
7694
+ * never reaches here, so it can neither disarm an armed channel nor arm a
7695
+ * disarmed one (D49).
7696
+ *
7697
+ * ## The canonical call shape
7698
+ *
7699
+ * ```ts
7700
+ * if (CH_RTP.on && CH_RTP.wants(deviceId)) {
7701
+ * CH_RTP.log(logger, 'rtp subscriber added', { tags: { deviceId }, meta: { ssrc } })
7702
+ * }
7703
+ * ```
7704
+ *
7705
+ * `on` is a plain boolean FIELD — never a getter — and it is the FIRST thing
7706
+ * read. Disarmed, a call site costs one load and one branch, and the `extras`
7707
+ * object literal is never constructed because it lives inside the branch. It
7708
+ * is the same shape already proven in production at `stream-broker.ts:1650`,
7709
+ * and the same discipline `LoggingGate.allowsDestination` uses for the
7710
+ * destination floor (measured at 1.93 ns/call when off).
7711
+ *
7712
+ * ## Why a channel emits at `info`
7713
+ *
7714
+ * `loki-logging.addon.ts` pins the destination default at `info` and
7715
+ * `loki-destination.ts` drops everything below it, so a line emitted at
7716
+ * `debug` never reaches Loki and the hub's in-memory ring only holds ~35
7717
+ * minutes. A diagnostic that cannot be read an hour later is worse than no
7718
+ * diagnostic, because it looks done. {@link LogChannelGate.log} therefore
7719
+ * emits at the channel's declared level, whose schema floor is `info`.
7720
+ */
7721
+ /**
7722
+ * The level a channel writes at once armed.
7723
+ *
7724
+ * `debug` is absent ON PURPOSE and not by omission: below `info` the line does
7725
+ * not leave the process for Loki, and the whole point of arming a channel is
7726
+ * to read it later.
7727
+ */
7728
+ var LogChannelLevelSchema = _enum([
7729
+ "info",
7730
+ "warn",
7731
+ "error"
7732
+ ]);
7733
+ /**
7734
+ * What an addon declares about one channel. No value, no state — a
7735
+ * declaration is inert.
7736
+ */
7737
+ var LogChannelDescriptorSchema = object({
7738
+ /**
7739
+ * Dotted `area.thing`, unique across the workspace. `area` is conventionally
7740
+ * the addon's short name so an operator reading a channel list can tell who
7741
+ * owns it without a second lookup.
7742
+ */
7743
+ name: string().min(3).regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/, "a channel name is dotted lower-kebab, e.g. area.thing"),
7744
+ /** One sentence: what the operator will SEE after arming it. */
7745
+ description: string().min(1),
7746
+ /** The level its lines are emitted at. Never below `info`. */
7747
+ defaultLevel: LogChannelLevelSchema,
7748
+ /**
7749
+ * Whether this channel can be narrowed to a camera.
7750
+ *
7751
+ * `true` is a PROMISE with two halves, and both must hold: the gate is
7752
+ * consulted with the numeric device id, AND every line the channel admits
7753
+ * carries `tags: { deviceId }` with that same numeric id. The second half is
7754
+ * what makes `| json | deviceId="617"` work in Loki — `loki-payload.ts`
7755
+ * keeps `deviceId` out of the stream labels for cardinality, so the tag in
7756
+ * the body is the only way to filter.
7757
+ *
7758
+ * A channel whose lines carry the device only in `meta` (or not at all) is
7759
+ * declared `false`. Declaring it `true` anyway would be a lie the UI repeats:
7760
+ * the operator narrows to one camera, sees nothing, and concludes the code
7761
+ * path was never taken.
7762
+ */
7763
+ perDevice: boolean()
7764
+ });
7765
+ /**
7766
+ * An armed window over one channel, as the document hands it to a mirror.
7767
+ *
7768
+ * A window is a DEADLINE, never a flag (ADR-0244): a channel somebody forgot
7769
+ * expires by itself, which is the one failure a boolean cannot avoid.
7770
+ */
7771
+ var LogChannelWindowSchema = object({
7772
+ channel: string().min(1),
7773
+ /** Epoch ms the window closes at. */
7774
+ armedUntilMs: number(),
7775
+ /** `null` = every camera. A non-empty list narrows to those numeric ids. */
7776
+ deviceIds: array(number().int()).readonly().nullable()
7777
+ });
7778
+ /**
7674
7779
  * Ops-log — the durable, append-only operations audit shared by the
7675
7780
  * recordings and events management surfaces.
7676
7781
  *
@@ -11359,6 +11464,35 @@ var MutationFilterSchema = object({
11359
11464
  whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11360
11465
  whereNot: record(string(), unknown()).optional()
11361
11466
  });
11467
+ /**
11468
+ * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
11469
+ *
11470
+ * `as` names the slot in the result, so the SAME column may be asked twice with
11471
+ * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
11472
+ * a `Record<column, op>` shape could not express.
11473
+ */
11474
+ var AggregateFieldSchema = object({
11475
+ /** Result key. */
11476
+ as: string().min(1),
11477
+ /** Column to aggregate. Must be a real column of a declared collection. */
11478
+ field: string().min(1),
11479
+ op: _enum([
11480
+ "sum",
11481
+ "min",
11482
+ "max"
11483
+ ])
11484
+ });
11485
+ /**
11486
+ * `COUNT(*)` plus one number per requested field.
11487
+ *
11488
+ * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
11489
+ * that really is 0 are different facts, and an accounting caller that renders
11490
+ * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
11491
+ */
11492
+ var AggregateResultSchema = object({
11493
+ count: number().int(),
11494
+ values: record(string(), number().nullable())
11495
+ });
11362
11496
  /** A single stored record: `{ id, data }`. */
11363
11497
  var SettingsRecordSchema = object({
11364
11498
  id: string(),
@@ -11443,6 +11577,11 @@ method(object({
11443
11577
  collection: string(),
11444
11578
  filter: QueryFilterSchema.optional()
11445
11579
  }), number()), method(object({
11580
+ namespace: string().optional(),
11581
+ collection: string(),
11582
+ fields: array(AggregateFieldSchema).readonly(),
11583
+ filter: QueryFilterSchema.optional()
11584
+ }), AggregateResultSchema), method(object({
11446
11585
  namespace: string().optional(),
11447
11586
  collection: string(),
11448
11587
  field: string(),
@@ -11559,6 +11698,11 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11559
11698
  collection: string(),
11560
11699
  filter: QueryFilterSchema.optional()
11561
11700
  }), number(), { auth: "admin" }), method(object({
11701
+ namespace: string().optional(),
11702
+ collection: string(),
11703
+ fields: array(AggregateFieldSchema).readonly(),
11704
+ filter: QueryFilterSchema.optional()
11705
+ }), AggregateResultSchema, { auth: "admin" }), method(object({
11562
11706
  namespace: string().optional(),
11563
11707
  collection: string(),
11564
11708
  field: string(),
@@ -12369,24 +12513,6 @@ var deviceProviderCapability = {
12369
12513
  })
12370
12514
  }
12371
12515
  };
12372
- /**
12373
- * Device Manager capability — hub-side singleton that unifies device persistence,
12374
- * live registry access, and all management operations into a single tRPC surface.
12375
- *
12376
- * Replaces:
12377
- * - `device-persistence` capability (persistence methods absorbed here)
12378
- * - `device-management.router.ts` (deleted in Phase 2)
12379
- * - `device-ops.router.ts` (compat layer — deleted; device-provider ops absorbed here)
12380
- *
12381
- * All device provider addons (rtsp, onvif, frigate, …) are hub-local: they may
12382
- * fork into separate processes but never run on remote cluster agents. Therefore:
12383
- * - No nodeId routing needed — this is a pure hub singleton.
12384
- * - The hub's DeviceRegistry is the single source of truth for all live devices.
12385
- * - No shadow registry or cross-node aggregation required.
12386
- *
12387
- * Forked workers register devices back to the hub via `ctx.devices`
12388
- * (DeviceManagerApi → ctx.api.deviceManager.registerDevice), same as today.
12389
- */
12390
12516
  /** One child-placement directive on a container's `childLayout`. Structurally
12391
12517
  * identical to `ChildLayoutEntry` in `device-management.ts` — the cap wire
12392
12518
  * shape for the same field. The child is identified by its re-sync-stable
@@ -12755,7 +12881,7 @@ method(object({
12755
12881
  * it answers today and the caller filters as it already does.
12756
12882
  */
12757
12883
  deviceIds: array(number()).optional()
12758
- }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), object({
12884
+ }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ parentDeviceIds: array(number()).max(256) }), record(string(), array(DeviceInfoSchema))), method(object({ deviceId: number() }), object({
12759
12885
  mode: LinkedDevicesModeSchema,
12760
12886
  devices: array(LinkedDeviceSchema)
12761
12887
  })), method(object({ deviceIds: array(number()) }), array(LinkedDevicesForDeviceSchema)), method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema)), method(object({ deviceId: number() }), ConfigUISchemaOutput), method(object({
@@ -13479,6 +13605,59 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
13479
13605
  kind: "mutation",
13480
13606
  auth: "admin"
13481
13607
  });
13608
+ /**
13609
+ * `log-channels` — the capability an addon DECLARES its diagnostic channels
13610
+ * through. It stores nothing.
13611
+ *
13612
+ * ## Why a capability at all, and why this shape
13613
+ *
13614
+ * Which channels exist is knowledge only the addon has: `stream-broker` knows
13615
+ * webrtc/ICE/RTP, `provider-reolink` knows baichuan/handshake. A central list
13616
+ * maintained by hand rots at the first addition and rots INVISIBLY — nothing
13617
+ * fails, an operator just never sees the channel somebody added. So the list
13618
+ * is assembled from declarations at runtime.
13619
+ *
13620
+ * The shape is copied from `log-destination.cap.ts`, which already does
13621
+ * exactly this job: `mode: 'collection'`, `internal: true`,
13622
+ * `mount: { kind: 'skip' }` — no tRPC route, no generated hooks — while
13623
+ * `addons.listCapabilityProviders` still enumerates it, and the hub's
13624
+ * `CapabilityRegistry` still holds an RPC proxy per provider so a forked
13625
+ * runner's declarations reach hub-main over the transport that already exists.
13626
+ * No new UDS message, no second registry.
13627
+ *
13628
+ * ## What it deliberately does NOT own
13629
+ *
13630
+ * The VALUES — which channel is armed, for which cameras, until when — live in
13631
+ * ONE place: the logging settings document on the `system` cap
13632
+ * (`getLoggingSettings` / `setLoggingSettings`). Two authorities over the same
13633
+ * value is the defect the plan behind this work exists to remove, and
13634
+ * `setRequestCensus` was retired (D245) rather than allowed to be a second
13635
+ * one. {@link logChannelsCapability} therefore has no getter for a level, no
13636
+ * setter for a window and no persistence of any kind.
13637
+ *
13638
+ * ## Why `apply` is here even so
13639
+ *
13640
+ * The gate lives in the addon's PROCESS; the document lives in hub-main. Some
13641
+ * seam has to carry the value from the authority to the mirror, and a channel
13642
+ * that cannot be reached is precisely the dead knob this whole slice exists to
13643
+ * make impossible (D62 — `audioThresholdDbfs`, the HA entities with no source).
13644
+ * `apply` is that seam and nothing more: it writes an in-memory mirror, it
13645
+ * persists nothing, it is never the source of a value, and it is called only
13646
+ * with a set the hub actually read (D49 — a read that fails does not call it
13647
+ * at all, so no channel is silently disarmed by a bad read).
13648
+ */
13649
+ /** What `apply` reports back — enough to log, not enough to be a second state. */
13650
+ var LogChannelApplyResultSchema = object({
13651
+ /** How many declared channels are armed in this process after the call. */
13652
+ armed: number().int().min(0),
13653
+ /**
13654
+ * Names the document armed that this process does not declare. Reported
13655
+ * rather than swallowed: a name here is either a typo or an addon that has
13656
+ * not booted, and both deserve a line instead of silence.
13657
+ */
13658
+ unknown: array(string()).readonly()
13659
+ });
13660
+ method(_void(), array(LogChannelDescriptorSchema).readonly()), method(object({ windows: array(LogChannelWindowSchema).readonly() }), LogChannelApplyResultSchema, { kind: "mutation" });
13482
13661
  var LogLevelSchema = _enum([
13483
13662
  "debug",
13484
13663
  "info",
@@ -28880,17 +29059,60 @@ var SetSiteLocationInputSchema = object({
28880
29059
  longitude: number().min(-180).max(180)
28881
29060
  }).nullable();
28882
29061
  /**
28883
- * One `(procedure, user-agent, ip, principal)` tuple of the HTTP request
29062
+ * The TRANSPORT a call arrived on.
29063
+ *
29064
+ * Every counted call carries exactly one of these, and `unknown` is a PLANE
29065
+ * rather than a gap: a plane that cannot attribute a call declares it here, so
29066
+ * the call lands in a named bucket instead of vanishing. `planes` summing to
29067
+ * `procedureCalls` is what makes "the sum of the planes explains the total"
29068
+ * checkable rather than asserted.
29069
+ *
29070
+ * - `http` — the Fastify tRPC plugin (`/trpc/*`), one context per request.
29071
+ * - `ws` — `applyWSSHandler`, counted per OPERATION rather than per
29072
+ * connection; the viewer talks to the hub over `wsLink`
29073
+ * exclusively, so this is the plane the HTTP census could not see.
29074
+ * - `mesh` — the in-process `$core-caps` bridge (`createCaller`), which
29075
+ * never touches a socket and therefore never touched a census.
29076
+ * - `unknown` — counted, plane undecidable. No hook produces it today, and
29077
+ * that is exactly what its `0` asserts: every plane the hub has can name
29078
+ * itself. It is an output bucket, never a knob — a call that arrives on a
29079
+ * plane nobody instrumented lands here instead of vanishing from the total.
29080
+ */
29081
+ var TransportPlaneSchema = _enum([
29082
+ "http",
29083
+ "ws",
29084
+ "mesh",
29085
+ "unknown"
29086
+ ]);
29087
+ /**
29088
+ * Calls per plane. Every key is always present, `0` included — an absent plane
29089
+ * reads as "not instrumented", which is the one thing this census must never
29090
+ * make an operator wonder about.
29091
+ */
29092
+ var TransportPlaneCountsSchema = object({
29093
+ http: number(),
29094
+ ws: number(),
29095
+ mesh: number(),
29096
+ unknown: number()
29097
+ });
29098
+ /**
29099
+ * One `(plane, procedure, user-agent, ip, principal)` tuple of the transport
28884
29100
  * census. `principal` is the DERIVED identity (`apocaliss92 (admin)`,
28885
29101
  * `scoped:1a2b3c4d (scoped-token)`, `anonymous`) that the tRPC error log
28886
29102
  * already prints - never a token, never an `Authorization` header.
29103
+ *
29104
+ * `subscriptions` is counted APART from `calls`: a subscription is opened once
29105
+ * and lives for hours, so folding it into a call count makes one long-lived
29106
+ * stream look like a storm.
28887
29107
  */
28888
29108
  var RequestCensusGroupSchema = object({
29109
+ plane: TransportPlaneSchema,
28889
29110
  procedure: string(),
28890
29111
  userAgent: string(),
28891
29112
  ip: string(),
28892
29113
  principal: string(),
28893
29114
  calls: number(),
29115
+ subscriptions: number(),
28894
29116
  perMin: number()
28895
29117
  });
28896
29118
  /**
@@ -28903,6 +29125,14 @@ var RequestCensusGroupSchema = object({
28903
29125
  var RequestCensusProcedureSchema = object({
28904
29126
  procedure: string(),
28905
29127
  calls: number(),
29128
+ /**
29129
+ * The same total, split by transport. THIS is the row that answers the
29130
+ * question the census exists for: one look at `deviceManager.listAll` says
29131
+ * which plane carried the 4 960, without joining two log lines by eye.
29132
+ */
29133
+ planes: TransportPlaneCountsSchema,
29134
+ /** Subscription STARTS on this procedure. Never folded into `calls`. */
29135
+ subscriptions: number(),
28906
29136
  perMin: number()
28907
29137
  });
28908
29138
  /**
@@ -28930,14 +29160,45 @@ var RequestCensusStatusSchema = object({
28930
29160
  */
28931
29161
  procedureCalls: number(),
28932
29162
  /**
29163
+ * `procedureCalls` split by transport. The four keys sum to
29164
+ * `procedureCalls` by construction - {@link RequestCensusSnapshotSchema}'s
29165
+ * `planesExplainTotal` is that identity, checked rather than assumed.
29166
+ */
29167
+ planes: TransportPlaneCountsSchema,
29168
+ /**
29169
+ * True iff `planes` sums to `procedureCalls`. False means a call was counted
29170
+ * on no plane at all - which is a RESULT (a plane is missing from the
29171
+ * instrument), not a failure, and it has to be visible to be read as one.
29172
+ */
29173
+ planesExplainTotal: boolean(),
29174
+ /**
28933
29175
  * tRPC WebSocket connections opened during the window. NOT calls - the WS
28934
- * transport resolves one context per connection - but the number that says
28935
- * whether a plane this census cannot see was busy while HTTP was quiet.
29176
+ * adapter resolves one context per connection - kept because a plane's call
29177
+ * count of zero against 37 open connections says something different from a
29178
+ * plane with no connections at all.
28936
29179
  */
28937
29180
  wsConnections: number(),
29181
+ /**
29182
+ * Client frames the WS plane looked at. `wsMessages` far above
29183
+ * `planes.ws + subscriptions` means most traffic is not operations
29184
+ * (keepalives, connection params) - which is itself an answer.
29185
+ */
29186
+ wsMessages: number(),
29187
+ /**
29188
+ * Subscription STARTS across every plane, excluded from `procedureCalls` on
29189
+ * purpose: one live-events stream opened at boot and held for six hours is
29190
+ * one subscription, and counting it as a call would let a quiet plane
29191
+ * masquerade as the storm.
29192
+ */
29193
+ subscriptions: number(),
29194
+ /** `subscription.stop` frames. Starts minus stops is what is still open. */
29195
+ subscriptionStops: number(),
28938
29196
  distinctGroups: number(),
28939
- /** Calls counted in the totals whose group attribution was shed at the
28940
- * cardinality bound. */
29197
+ /**
29198
+ * Operations counted in the totals whose CALLER attribution was shed at the
29199
+ * cardinality bound. Unrelated to the `unknown` PLANE: these calls know
29200
+ * which transport they arrived on, they just lost their group row.
29201
+ */
28941
29202
  unattributedCalls: number(),
28942
29203
  procedures: array(RequestCensusProcedureSchema).readonly(),
28943
29204
  groups: array(RequestCensusGroupSchema).readonly()
@@ -28960,10 +29221,11 @@ var DiagnosticIdSchema = _enum(["request-census"]);
28960
29221
  * The layers of the level hierarchy, general → specific. The most specific
28961
29222
  * layer that carries an explicit value wins.
28962
29223
  *
28963
- * `component` is DECLARED and not yet resolvable: the per-component channels
28964
- * are a later slice of the same plan, and a `levelSource` enum that has to
28965
- * grow later would force every consumer of this document to change with it.
28966
- * Nothing returns `component` today.
29224
+ * `component` became RESOLVABLE on 2026-08-27: a component is a declared log
29225
+ * CHANNEL (`stream-broker.webrtc`, `provider-reolink.baichuan`), named by
29226
+ * `scopeComponent`. It was declared-but-dark in the first slice precisely so
29227
+ * that turning it on would not force every consumer of this document to widen
29228
+ * a `levelSource` enum — which is what has now not happened.
28967
29229
  */
28968
29230
  var LoggingScopeKindSchema = _enum([
28969
29231
  "cluster",
@@ -28990,6 +29252,14 @@ var LoggingLevelLayerSchema = object({
28990
29252
  scope: LoggingScopeKindSchema,
28991
29253
  /** The node this layer speaks for; `null` on the cluster layer. */
28992
29254
  nodeId: string().nullable(),
29255
+ /**
29256
+ * The declared channel this layer speaks for; `null` on every layer but
29257
+ * `component`. Never folded into `nodeId`: a component level is CLUSTER-WIDE
29258
+ * by design — the convention this repo settled on is one orchestrator-wide
29259
+ * setting, never per node (D52) — so a component layer that carried a node
29260
+ * would invite a per-node copy of a value that has no per-node meaning.
29261
+ */
29262
+ component: string().nullable(),
28993
29263
  /** Explicitly set here, or `null` when this layer inherits. */
28994
29264
  level: LogLevelSchema$1.nullable()
28995
29265
  });
@@ -29031,6 +29301,49 @@ var DiagnosticWindowPatchSchema = object({
29031
29301
  reportEveryMs: number().int().positive().optional()
29032
29302
  });
29033
29303
  /**
29304
+ * A channel ARMED, as the document reports it.
29305
+ *
29306
+ * `armMs` is not echoed back: what an operator needs to see is the deadline
29307
+ * and the time left, because a diagnostic left running is itself an incident
29308
+ * and "armed for 10 minutes" said an hour ago is not an answer.
29309
+ */
29310
+ var LogChannelWindowStateSchema = object({
29311
+ channel: string(),
29312
+ armed: boolean(),
29313
+ /** Epoch ms the window closes at. 0 when disarmed. */
29314
+ armedUntilMs: number(),
29315
+ /** Ms left before it expires on its own. 0 when disarmed. */
29316
+ remainingMs: number(),
29317
+ /**
29318
+ * The cameras it is narrowed to, or `null` for every camera.
29319
+ *
29320
+ * A channel declared `perDevice: false` can only ever report `null` here:
29321
+ * its lines do not carry `tags: { deviceId }`, so narrowing them would
29322
+ * produce a filter that silently matches nothing. The server REFUSES such a
29323
+ * patch rather than quietly widening it — ignoring the request would teach
29324
+ * the operator that per-camera filtering works on that channel when it does
29325
+ * not.
29326
+ */
29327
+ deviceIds: array(number().int()).readonly().nullable()
29328
+ });
29329
+ /**
29330
+ * `armMs: 0` DISARMS. Same grammar as {@link DiagnosticWindowPatchSchema}, and
29331
+ * for the same reason: a channel is a window with a deadline, never a switch.
29332
+ */
29333
+ var LogChannelWindowPatchSchema = object({
29334
+ channel: string().min(1),
29335
+ armMs: number().int().min(0),
29336
+ /**
29337
+ * Narrow to these numeric device ids. Absent or `null` = every camera.
29338
+ *
29339
+ * Numeric because the repo's own rule makes it possible: every log line
29340
+ * about a device carries `tags: { deviceId }` with the numeric id. That rule
29341
+ * was paid for with a 22% thumbnail gap and a 3-hour media blackout both
29342
+ * diagnosed by hand, and this is the first thing that collects on it.
29343
+ */
29344
+ deviceIds: array(number().int()).readonly().nullable().optional()
29345
+ });
29346
+ /**
29034
29347
  * A PATCH, and patches MERGE.
29035
29348
  *
29036
29349
  * A field absent from the patch is left exactly as it was — arming a
@@ -29049,7 +29362,14 @@ var LoggingSettingsPatchSchema = object({
29049
29362
  * Only the diagnostics NAMED here change. An armed window that is not listed
29050
29363
  * keeps running — a patch is never a full replacement.
29051
29364
  */
29052
- diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional()
29365
+ diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional(),
29366
+ /**
29367
+ * Only the channels NAMED here change. An armed channel that is not listed
29368
+ * keeps running — same rule as `diagnostics`, because a patch that silently
29369
+ * disarmed the channels it did not mention would make the Levels page and
29370
+ * the Diagnostics page fight over the same value.
29371
+ */
29372
+ channels: array(LogChannelWindowPatchSchema).readonly().optional()
29053
29373
  });
29054
29374
  /**
29055
29375
  * Which LAYER of the hierarchy is addressed. Absent = the cluster layer.
@@ -29062,9 +29382,22 @@ var LoggingSettingsPatchSchema = object({
29062
29382
  * authority over the whole hierarchy and answers for every layer, so the
29063
29383
  * layer selector needs a name the transport does not already own.
29064
29384
  */
29065
- var GetLoggingSettingsInputSchema = object({ scopeNodeId: string().optional() });
29385
+ var GetLoggingSettingsInputSchema = object({
29386
+ scopeNodeId: string().optional(),
29387
+ /**
29388
+ * The declared CHANNEL this document is addressed at, when the caller wants
29389
+ * the `component` layer. Absent = the node/cluster hierarchy only.
29390
+ *
29391
+ * Naming it separately rather than overloading `scopeNodeId` keeps the two
29392
+ * axes from collapsing: a component level is cluster-wide, a node level is
29393
+ * not, and one selector for both would make "which of these two did I just
29394
+ * set" unanswerable — the exact ambiguity `explicit` exists to remove.
29395
+ */
29396
+ scopeComponent: string().optional()
29397
+ });
29066
29398
  var SetLoggingSettingsInputSchema = object({
29067
29399
  scopeNodeId: string().optional(),
29400
+ scopeComponent: string().optional(),
29068
29401
  patch: LoggingSettingsPatchSchema
29069
29402
  });
29070
29403
  /**
@@ -29079,9 +29412,20 @@ var SetLoggingSettingsInputSchema = object({
29079
29412
  var LoggingSettingsStateSchema = object({
29080
29413
  /** The layer this document was read at. `null` = the cluster layer. */
29081
29414
  scopeNodeId: string().nullable(),
29415
+ /** The channel this document was read at. `null` = no component layer. */
29416
+ scopeComponent: string().nullable(),
29082
29417
  effective: LoggingEffectiveSchema,
29083
29418
  explicit: LoggingExplicitSchema,
29084
29419
  activeWindows: array(DiagnosticWindowSchema).readonly(),
29420
+ /**
29421
+ * Every channel the cluster's addons DECLARE, gathered from the
29422
+ * `log-channels` providers. Not stored anywhere: assembled per read, so a
29423
+ * channel added by a redeployed addon appears without anybody editing a
29424
+ * list, and a channel whose addon is gone stops being offered.
29425
+ */
29426
+ channels: array(LogChannelDescriptorSchema).readonly(),
29427
+ /** The channels ARMED right now, each with its deadline. */
29428
+ activeChannels: array(LogChannelWindowStateSchema).readonly(),
29085
29429
  persisted: boolean()
29086
29430
  });
29087
29431
  method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), method(_void(), FeatureManifestSchema), method(_void(), array(NetworkAddressSchema).readonly()), method(_void(), unknown().nullable(), { auth: "admin" }), method(record(string(), unknown()), _null(), {
@@ -32066,6 +32410,12 @@ Object.freeze({
32066
32410
  addonId: null,
32067
32411
  access: "view"
32068
32412
  },
32413
+ "dataStoreProvider.aggregate": {
32414
+ capName: "data-store-provider",
32415
+ capScope: "system",
32416
+ addonId: null,
32417
+ access: "view"
32418
+ },
32069
32419
  "dataStoreProvider.count": {
32070
32420
  capName: "data-store-provider",
32071
32421
  capScope: "system",
@@ -32480,6 +32830,12 @@ Object.freeze({
32480
32830
  addonId: null,
32481
32831
  access: "view"
32482
32832
  },
32833
+ "deviceManager.getChildrenBatch": {
32834
+ capName: "device-manager",
32835
+ capScope: "system",
32836
+ addonId: null,
32837
+ access: "view"
32838
+ },
32483
32839
  "deviceManager.getConfigSchema": {
32484
32840
  capName: "device-manager",
32485
32841
  capScope: "system",
@@ -33530,6 +33886,18 @@ Object.freeze({
33530
33886
  addonId: null,
33531
33887
  access: "create"
33532
33888
  },
33889
+ "logChannels.apply": {
33890
+ capName: "log-channels",
33891
+ capScope: "system",
33892
+ addonId: null,
33893
+ access: "create"
33894
+ },
33895
+ "logChannels.list": {
33896
+ capName: "log-channels",
33897
+ capScope: "system",
33898
+ addonId: null,
33899
+ access: "view"
33900
+ },
33533
33901
  "logDestination.query": {
33534
33902
  capName: "log-destination",
33535
33903
  capScope: "system",
@@ -35684,6 +36052,12 @@ Object.freeze({
35684
36052
  addonId: null,
35685
36053
  access: "create"
35686
36054
  },
36055
+ "settingsStore.aggregate": {
36056
+ capName: "settings-store",
36057
+ capScope: "system",
36058
+ addonId: null,
36059
+ access: "view"
36060
+ },
35687
36061
  "settingsStore.count": {
35688
36062
  capName: "settings-store",
35689
36063
  capScope: "system",
@@ -37263,6 +37637,11 @@ Object.freeze({
37263
37637
  form: "single",
37264
37638
  optional: false
37265
37639
  }],
37640
+ "deviceManager.getChildrenBatch": [{
37641
+ name: "parentDeviceIds",
37642
+ form: "array",
37643
+ optional: false
37644
+ }],
37266
37645
  "deviceManager.getConfigSchema": [{
37267
37646
  name: "deviceId",
37268
37647
  form: "single",
@@ -7671,6 +7671,111 @@ var CameraSwitchGroupSchema = object({
7671
7671
  fetchedAt: number()
7672
7672
  });
7673
7673
  /**
7674
+ * Per-component log CHANNELS — the gate a hot path consults, and the registry
7675
+ * an addon declares its channels in.
7676
+ *
7677
+ * ## Two axes, deliberately separated
7678
+ *
7679
+ * - **DECLARATION** — which channels exist. Only the addon knows:
7680
+ * `stream-broker` knows webrtc/ICE/RTP, `provider-reolink` knows
7681
+ * baichuan/handshake. A hand-wired central list rots at the first addition,
7682
+ * and rots silently. So a channel is declared where it is consulted, and the
7683
+ * `log-channels` capability enumerates the declarations.
7684
+ * - **VALUE** — at which level, for which scope, until when. That stays ONE
7685
+ * thing: the logging settings document on the `system` cap. Two authorities
7686
+ * over the values is the exact defect
7687
+ * `docs/design/plans/2026-08-26-logging-per-componente.md` was written to
7688
+ * remove; re-introducing it from the cure side would be grotesque.
7689
+ *
7690
+ * Nothing in this file reads a clock, an env var or a store. The registry is
7691
+ * a MIRROR: it is moved only by {@link LogChannelRegistry.apply}, called off
7692
+ * the hot path with a value somebody actually read, and by
7693
+ * {@link LogChannelRegistry.tick}, called on a timer. A store read that fails
7694
+ * never reaches here, so it can neither disarm an armed channel nor arm a
7695
+ * disarmed one (D49).
7696
+ *
7697
+ * ## The canonical call shape
7698
+ *
7699
+ * ```ts
7700
+ * if (CH_RTP.on && CH_RTP.wants(deviceId)) {
7701
+ * CH_RTP.log(logger, 'rtp subscriber added', { tags: { deviceId }, meta: { ssrc } })
7702
+ * }
7703
+ * ```
7704
+ *
7705
+ * `on` is a plain boolean FIELD — never a getter — and it is the FIRST thing
7706
+ * read. Disarmed, a call site costs one load and one branch, and the `extras`
7707
+ * object literal is never constructed because it lives inside the branch. It
7708
+ * is the same shape already proven in production at `stream-broker.ts:1650`,
7709
+ * and the same discipline `LoggingGate.allowsDestination` uses for the
7710
+ * destination floor (measured at 1.93 ns/call when off).
7711
+ *
7712
+ * ## Why a channel emits at `info`
7713
+ *
7714
+ * `loki-logging.addon.ts` pins the destination default at `info` and
7715
+ * `loki-destination.ts` drops everything below it, so a line emitted at
7716
+ * `debug` never reaches Loki and the hub's in-memory ring only holds ~35
7717
+ * minutes. A diagnostic that cannot be read an hour later is worse than no
7718
+ * diagnostic, because it looks done. {@link LogChannelGate.log} therefore
7719
+ * emits at the channel's declared level, whose schema floor is `info`.
7720
+ */
7721
+ /**
7722
+ * The level a channel writes at once armed.
7723
+ *
7724
+ * `debug` is absent ON PURPOSE and not by omission: below `info` the line does
7725
+ * not leave the process for Loki, and the whole point of arming a channel is
7726
+ * to read it later.
7727
+ */
7728
+ var LogChannelLevelSchema = _enum([
7729
+ "info",
7730
+ "warn",
7731
+ "error"
7732
+ ]);
7733
+ /**
7734
+ * What an addon declares about one channel. No value, no state — a
7735
+ * declaration is inert.
7736
+ */
7737
+ var LogChannelDescriptorSchema = object({
7738
+ /**
7739
+ * Dotted `area.thing`, unique across the workspace. `area` is conventionally
7740
+ * the addon's short name so an operator reading a channel list can tell who
7741
+ * owns it without a second lookup.
7742
+ */
7743
+ name: string().min(3).regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/, "a channel name is dotted lower-kebab, e.g. area.thing"),
7744
+ /** One sentence: what the operator will SEE after arming it. */
7745
+ description: string().min(1),
7746
+ /** The level its lines are emitted at. Never below `info`. */
7747
+ defaultLevel: LogChannelLevelSchema,
7748
+ /**
7749
+ * Whether this channel can be narrowed to a camera.
7750
+ *
7751
+ * `true` is a PROMISE with two halves, and both must hold: the gate is
7752
+ * consulted with the numeric device id, AND every line the channel admits
7753
+ * carries `tags: { deviceId }` with that same numeric id. The second half is
7754
+ * what makes `| json | deviceId="617"` work in Loki — `loki-payload.ts`
7755
+ * keeps `deviceId` out of the stream labels for cardinality, so the tag in
7756
+ * the body is the only way to filter.
7757
+ *
7758
+ * A channel whose lines carry the device only in `meta` (or not at all) is
7759
+ * declared `false`. Declaring it `true` anyway would be a lie the UI repeats:
7760
+ * the operator narrows to one camera, sees nothing, and concludes the code
7761
+ * path was never taken.
7762
+ */
7763
+ perDevice: boolean()
7764
+ });
7765
+ /**
7766
+ * An armed window over one channel, as the document hands it to a mirror.
7767
+ *
7768
+ * A window is a DEADLINE, never a flag (ADR-0244): a channel somebody forgot
7769
+ * expires by itself, which is the one failure a boolean cannot avoid.
7770
+ */
7771
+ var LogChannelWindowSchema = object({
7772
+ channel: string().min(1),
7773
+ /** Epoch ms the window closes at. */
7774
+ armedUntilMs: number(),
7775
+ /** `null` = every camera. A non-empty list narrows to those numeric ids. */
7776
+ deviceIds: array(number().int()).readonly().nullable()
7777
+ });
7778
+ /**
7674
7779
  * Ops-log — the durable, append-only operations audit shared by the
7675
7780
  * recordings and events management surfaces.
7676
7781
  *
@@ -11359,6 +11464,35 @@ var MutationFilterSchema = object({
11359
11464
  whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11360
11465
  whereNot: record(string(), unknown()).optional()
11361
11466
  });
11467
+ /**
11468
+ * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
11469
+ *
11470
+ * `as` names the slot in the result, so the SAME column may be asked twice with
11471
+ * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
11472
+ * a `Record<column, op>` shape could not express.
11473
+ */
11474
+ var AggregateFieldSchema = object({
11475
+ /** Result key. */
11476
+ as: string().min(1),
11477
+ /** Column to aggregate. Must be a real column of a declared collection. */
11478
+ field: string().min(1),
11479
+ op: _enum([
11480
+ "sum",
11481
+ "min",
11482
+ "max"
11483
+ ])
11484
+ });
11485
+ /**
11486
+ * `COUNT(*)` plus one number per requested field.
11487
+ *
11488
+ * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
11489
+ * that really is 0 are different facts, and an accounting caller that renders
11490
+ * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
11491
+ */
11492
+ var AggregateResultSchema = object({
11493
+ count: number().int(),
11494
+ values: record(string(), number().nullable())
11495
+ });
11362
11496
  /** A single stored record: `{ id, data }`. */
11363
11497
  var SettingsRecordSchema = object({
11364
11498
  id: string(),
@@ -11443,6 +11577,11 @@ method(object({
11443
11577
  collection: string(),
11444
11578
  filter: QueryFilterSchema.optional()
11445
11579
  }), number()), method(object({
11580
+ namespace: string().optional(),
11581
+ collection: string(),
11582
+ fields: array(AggregateFieldSchema).readonly(),
11583
+ filter: QueryFilterSchema.optional()
11584
+ }), AggregateResultSchema), method(object({
11446
11585
  namespace: string().optional(),
11447
11586
  collection: string(),
11448
11587
  field: string(),
@@ -11559,6 +11698,11 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11559
11698
  collection: string(),
11560
11699
  filter: QueryFilterSchema.optional()
11561
11700
  }), number(), { auth: "admin" }), method(object({
11701
+ namespace: string().optional(),
11702
+ collection: string(),
11703
+ fields: array(AggregateFieldSchema).readonly(),
11704
+ filter: QueryFilterSchema.optional()
11705
+ }), AggregateResultSchema, { auth: "admin" }), method(object({
11562
11706
  namespace: string().optional(),
11563
11707
  collection: string(),
11564
11708
  field: string(),
@@ -12369,24 +12513,6 @@ var deviceProviderCapability = {
12369
12513
  })
12370
12514
  }
12371
12515
  };
12372
- /**
12373
- * Device Manager capability — hub-side singleton that unifies device persistence,
12374
- * live registry access, and all management operations into a single tRPC surface.
12375
- *
12376
- * Replaces:
12377
- * - `device-persistence` capability (persistence methods absorbed here)
12378
- * - `device-management.router.ts` (deleted in Phase 2)
12379
- * - `device-ops.router.ts` (compat layer — deleted; device-provider ops absorbed here)
12380
- *
12381
- * All device provider addons (rtsp, onvif, frigate, …) are hub-local: they may
12382
- * fork into separate processes but never run on remote cluster agents. Therefore:
12383
- * - No nodeId routing needed — this is a pure hub singleton.
12384
- * - The hub's DeviceRegistry is the single source of truth for all live devices.
12385
- * - No shadow registry or cross-node aggregation required.
12386
- *
12387
- * Forked workers register devices back to the hub via `ctx.devices`
12388
- * (DeviceManagerApi → ctx.api.deviceManager.registerDevice), same as today.
12389
- */
12390
12516
  /** One child-placement directive on a container's `childLayout`. Structurally
12391
12517
  * identical to `ChildLayoutEntry` in `device-management.ts` — the cap wire
12392
12518
  * shape for the same field. The child is identified by its re-sync-stable
@@ -12755,7 +12881,7 @@ method(object({
12755
12881
  * it answers today and the caller filters as it already does.
12756
12882
  */
12757
12883
  deviceIds: array(number()).optional()
12758
- }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), object({
12884
+ }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ parentDeviceIds: array(number()).max(256) }), record(string(), array(DeviceInfoSchema))), method(object({ deviceId: number() }), object({
12759
12885
  mode: LinkedDevicesModeSchema,
12760
12886
  devices: array(LinkedDeviceSchema)
12761
12887
  })), method(object({ deviceIds: array(number()) }), array(LinkedDevicesForDeviceSchema)), method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema)), method(object({ deviceId: number() }), ConfigUISchemaOutput), method(object({
@@ -13479,6 +13605,59 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
13479
13605
  kind: "mutation",
13480
13606
  auth: "admin"
13481
13607
  });
13608
+ /**
13609
+ * `log-channels` — the capability an addon DECLARES its diagnostic channels
13610
+ * through. It stores nothing.
13611
+ *
13612
+ * ## Why a capability at all, and why this shape
13613
+ *
13614
+ * Which channels exist is knowledge only the addon has: `stream-broker` knows
13615
+ * webrtc/ICE/RTP, `provider-reolink` knows baichuan/handshake. A central list
13616
+ * maintained by hand rots at the first addition and rots INVISIBLY — nothing
13617
+ * fails, an operator just never sees the channel somebody added. So the list
13618
+ * is assembled from declarations at runtime.
13619
+ *
13620
+ * The shape is copied from `log-destination.cap.ts`, which already does
13621
+ * exactly this job: `mode: 'collection'`, `internal: true`,
13622
+ * `mount: { kind: 'skip' }` — no tRPC route, no generated hooks — while
13623
+ * `addons.listCapabilityProviders` still enumerates it, and the hub's
13624
+ * `CapabilityRegistry` still holds an RPC proxy per provider so a forked
13625
+ * runner's declarations reach hub-main over the transport that already exists.
13626
+ * No new UDS message, no second registry.
13627
+ *
13628
+ * ## What it deliberately does NOT own
13629
+ *
13630
+ * The VALUES — which channel is armed, for which cameras, until when — live in
13631
+ * ONE place: the logging settings document on the `system` cap
13632
+ * (`getLoggingSettings` / `setLoggingSettings`). Two authorities over the same
13633
+ * value is the defect the plan behind this work exists to remove, and
13634
+ * `setRequestCensus` was retired (D245) rather than allowed to be a second
13635
+ * one. {@link logChannelsCapability} therefore has no getter for a level, no
13636
+ * setter for a window and no persistence of any kind.
13637
+ *
13638
+ * ## Why `apply` is here even so
13639
+ *
13640
+ * The gate lives in the addon's PROCESS; the document lives in hub-main. Some
13641
+ * seam has to carry the value from the authority to the mirror, and a channel
13642
+ * that cannot be reached is precisely the dead knob this whole slice exists to
13643
+ * make impossible (D62 — `audioThresholdDbfs`, the HA entities with no source).
13644
+ * `apply` is that seam and nothing more: it writes an in-memory mirror, it
13645
+ * persists nothing, it is never the source of a value, and it is called only
13646
+ * with a set the hub actually read (D49 — a read that fails does not call it
13647
+ * at all, so no channel is silently disarmed by a bad read).
13648
+ */
13649
+ /** What `apply` reports back — enough to log, not enough to be a second state. */
13650
+ var LogChannelApplyResultSchema = object({
13651
+ /** How many declared channels are armed in this process after the call. */
13652
+ armed: number().int().min(0),
13653
+ /**
13654
+ * Names the document armed that this process does not declare. Reported
13655
+ * rather than swallowed: a name here is either a typo or an addon that has
13656
+ * not booted, and both deserve a line instead of silence.
13657
+ */
13658
+ unknown: array(string()).readonly()
13659
+ });
13660
+ method(_void(), array(LogChannelDescriptorSchema).readonly()), method(object({ windows: array(LogChannelWindowSchema).readonly() }), LogChannelApplyResultSchema, { kind: "mutation" });
13482
13661
  var LogLevelSchema = _enum([
13483
13662
  "debug",
13484
13663
  "info",
@@ -28880,17 +29059,60 @@ var SetSiteLocationInputSchema = object({
28880
29059
  longitude: number().min(-180).max(180)
28881
29060
  }).nullable();
28882
29061
  /**
28883
- * One `(procedure, user-agent, ip, principal)` tuple of the HTTP request
29062
+ * The TRANSPORT a call arrived on.
29063
+ *
29064
+ * Every counted call carries exactly one of these, and `unknown` is a PLANE
29065
+ * rather than a gap: a plane that cannot attribute a call declares it here, so
29066
+ * the call lands in a named bucket instead of vanishing. `planes` summing to
29067
+ * `procedureCalls` is what makes "the sum of the planes explains the total"
29068
+ * checkable rather than asserted.
29069
+ *
29070
+ * - `http` — the Fastify tRPC plugin (`/trpc/*`), one context per request.
29071
+ * - `ws` — `applyWSSHandler`, counted per OPERATION rather than per
29072
+ * connection; the viewer talks to the hub over `wsLink`
29073
+ * exclusively, so this is the plane the HTTP census could not see.
29074
+ * - `mesh` — the in-process `$core-caps` bridge (`createCaller`), which
29075
+ * never touches a socket and therefore never touched a census.
29076
+ * - `unknown` — counted, plane undecidable. No hook produces it today, and
29077
+ * that is exactly what its `0` asserts: every plane the hub has can name
29078
+ * itself. It is an output bucket, never a knob — a call that arrives on a
29079
+ * plane nobody instrumented lands here instead of vanishing from the total.
29080
+ */
29081
+ var TransportPlaneSchema = _enum([
29082
+ "http",
29083
+ "ws",
29084
+ "mesh",
29085
+ "unknown"
29086
+ ]);
29087
+ /**
29088
+ * Calls per plane. Every key is always present, `0` included — an absent plane
29089
+ * reads as "not instrumented", which is the one thing this census must never
29090
+ * make an operator wonder about.
29091
+ */
29092
+ var TransportPlaneCountsSchema = object({
29093
+ http: number(),
29094
+ ws: number(),
29095
+ mesh: number(),
29096
+ unknown: number()
29097
+ });
29098
+ /**
29099
+ * One `(plane, procedure, user-agent, ip, principal)` tuple of the transport
28884
29100
  * census. `principal` is the DERIVED identity (`apocaliss92 (admin)`,
28885
29101
  * `scoped:1a2b3c4d (scoped-token)`, `anonymous`) that the tRPC error log
28886
29102
  * already prints - never a token, never an `Authorization` header.
29103
+ *
29104
+ * `subscriptions` is counted APART from `calls`: a subscription is opened once
29105
+ * and lives for hours, so folding it into a call count makes one long-lived
29106
+ * stream look like a storm.
28887
29107
  */
28888
29108
  var RequestCensusGroupSchema = object({
29109
+ plane: TransportPlaneSchema,
28889
29110
  procedure: string(),
28890
29111
  userAgent: string(),
28891
29112
  ip: string(),
28892
29113
  principal: string(),
28893
29114
  calls: number(),
29115
+ subscriptions: number(),
28894
29116
  perMin: number()
28895
29117
  });
28896
29118
  /**
@@ -28903,6 +29125,14 @@ var RequestCensusGroupSchema = object({
28903
29125
  var RequestCensusProcedureSchema = object({
28904
29126
  procedure: string(),
28905
29127
  calls: number(),
29128
+ /**
29129
+ * The same total, split by transport. THIS is the row that answers the
29130
+ * question the census exists for: one look at `deviceManager.listAll` says
29131
+ * which plane carried the 4 960, without joining two log lines by eye.
29132
+ */
29133
+ planes: TransportPlaneCountsSchema,
29134
+ /** Subscription STARTS on this procedure. Never folded into `calls`. */
29135
+ subscriptions: number(),
28906
29136
  perMin: number()
28907
29137
  });
28908
29138
  /**
@@ -28930,14 +29160,45 @@ var RequestCensusStatusSchema = object({
28930
29160
  */
28931
29161
  procedureCalls: number(),
28932
29162
  /**
29163
+ * `procedureCalls` split by transport. The four keys sum to
29164
+ * `procedureCalls` by construction - {@link RequestCensusSnapshotSchema}'s
29165
+ * `planesExplainTotal` is that identity, checked rather than assumed.
29166
+ */
29167
+ planes: TransportPlaneCountsSchema,
29168
+ /**
29169
+ * True iff `planes` sums to `procedureCalls`. False means a call was counted
29170
+ * on no plane at all - which is a RESULT (a plane is missing from the
29171
+ * instrument), not a failure, and it has to be visible to be read as one.
29172
+ */
29173
+ planesExplainTotal: boolean(),
29174
+ /**
28933
29175
  * tRPC WebSocket connections opened during the window. NOT calls - the WS
28934
- * transport resolves one context per connection - but the number that says
28935
- * whether a plane this census cannot see was busy while HTTP was quiet.
29176
+ * adapter resolves one context per connection - kept because a plane's call
29177
+ * count of zero against 37 open connections says something different from a
29178
+ * plane with no connections at all.
28936
29179
  */
28937
29180
  wsConnections: number(),
29181
+ /**
29182
+ * Client frames the WS plane looked at. `wsMessages` far above
29183
+ * `planes.ws + subscriptions` means most traffic is not operations
29184
+ * (keepalives, connection params) - which is itself an answer.
29185
+ */
29186
+ wsMessages: number(),
29187
+ /**
29188
+ * Subscription STARTS across every plane, excluded from `procedureCalls` on
29189
+ * purpose: one live-events stream opened at boot and held for six hours is
29190
+ * one subscription, and counting it as a call would let a quiet plane
29191
+ * masquerade as the storm.
29192
+ */
29193
+ subscriptions: number(),
29194
+ /** `subscription.stop` frames. Starts minus stops is what is still open. */
29195
+ subscriptionStops: number(),
28938
29196
  distinctGroups: number(),
28939
- /** Calls counted in the totals whose group attribution was shed at the
28940
- * cardinality bound. */
29197
+ /**
29198
+ * Operations counted in the totals whose CALLER attribution was shed at the
29199
+ * cardinality bound. Unrelated to the `unknown` PLANE: these calls know
29200
+ * which transport they arrived on, they just lost their group row.
29201
+ */
28941
29202
  unattributedCalls: number(),
28942
29203
  procedures: array(RequestCensusProcedureSchema).readonly(),
28943
29204
  groups: array(RequestCensusGroupSchema).readonly()
@@ -28960,10 +29221,11 @@ var DiagnosticIdSchema = _enum(["request-census"]);
28960
29221
  * The layers of the level hierarchy, general → specific. The most specific
28961
29222
  * layer that carries an explicit value wins.
28962
29223
  *
28963
- * `component` is DECLARED and not yet resolvable: the per-component channels
28964
- * are a later slice of the same plan, and a `levelSource` enum that has to
28965
- * grow later would force every consumer of this document to change with it.
28966
- * Nothing returns `component` today.
29224
+ * `component` became RESOLVABLE on 2026-08-27: a component is a declared log
29225
+ * CHANNEL (`stream-broker.webrtc`, `provider-reolink.baichuan`), named by
29226
+ * `scopeComponent`. It was declared-but-dark in the first slice precisely so
29227
+ * that turning it on would not force every consumer of this document to widen
29228
+ * a `levelSource` enum — which is what has now not happened.
28967
29229
  */
28968
29230
  var LoggingScopeKindSchema = _enum([
28969
29231
  "cluster",
@@ -28990,6 +29252,14 @@ var LoggingLevelLayerSchema = object({
28990
29252
  scope: LoggingScopeKindSchema,
28991
29253
  /** The node this layer speaks for; `null` on the cluster layer. */
28992
29254
  nodeId: string().nullable(),
29255
+ /**
29256
+ * The declared channel this layer speaks for; `null` on every layer but
29257
+ * `component`. Never folded into `nodeId`: a component level is CLUSTER-WIDE
29258
+ * by design — the convention this repo settled on is one orchestrator-wide
29259
+ * setting, never per node (D52) — so a component layer that carried a node
29260
+ * would invite a per-node copy of a value that has no per-node meaning.
29261
+ */
29262
+ component: string().nullable(),
28993
29263
  /** Explicitly set here, or `null` when this layer inherits. */
28994
29264
  level: LogLevelSchema$1.nullable()
28995
29265
  });
@@ -29031,6 +29301,49 @@ var DiagnosticWindowPatchSchema = object({
29031
29301
  reportEveryMs: number().int().positive().optional()
29032
29302
  });
29033
29303
  /**
29304
+ * A channel ARMED, as the document reports it.
29305
+ *
29306
+ * `armMs` is not echoed back: what an operator needs to see is the deadline
29307
+ * and the time left, because a diagnostic left running is itself an incident
29308
+ * and "armed for 10 minutes" said an hour ago is not an answer.
29309
+ */
29310
+ var LogChannelWindowStateSchema = object({
29311
+ channel: string(),
29312
+ armed: boolean(),
29313
+ /** Epoch ms the window closes at. 0 when disarmed. */
29314
+ armedUntilMs: number(),
29315
+ /** Ms left before it expires on its own. 0 when disarmed. */
29316
+ remainingMs: number(),
29317
+ /**
29318
+ * The cameras it is narrowed to, or `null` for every camera.
29319
+ *
29320
+ * A channel declared `perDevice: false` can only ever report `null` here:
29321
+ * its lines do not carry `tags: { deviceId }`, so narrowing them would
29322
+ * produce a filter that silently matches nothing. The server REFUSES such a
29323
+ * patch rather than quietly widening it — ignoring the request would teach
29324
+ * the operator that per-camera filtering works on that channel when it does
29325
+ * not.
29326
+ */
29327
+ deviceIds: array(number().int()).readonly().nullable()
29328
+ });
29329
+ /**
29330
+ * `armMs: 0` DISARMS. Same grammar as {@link DiagnosticWindowPatchSchema}, and
29331
+ * for the same reason: a channel is a window with a deadline, never a switch.
29332
+ */
29333
+ var LogChannelWindowPatchSchema = object({
29334
+ channel: string().min(1),
29335
+ armMs: number().int().min(0),
29336
+ /**
29337
+ * Narrow to these numeric device ids. Absent or `null` = every camera.
29338
+ *
29339
+ * Numeric because the repo's own rule makes it possible: every log line
29340
+ * about a device carries `tags: { deviceId }` with the numeric id. That rule
29341
+ * was paid for with a 22% thumbnail gap and a 3-hour media blackout both
29342
+ * diagnosed by hand, and this is the first thing that collects on it.
29343
+ */
29344
+ deviceIds: array(number().int()).readonly().nullable().optional()
29345
+ });
29346
+ /**
29034
29347
  * A PATCH, and patches MERGE.
29035
29348
  *
29036
29349
  * A field absent from the patch is left exactly as it was — arming a
@@ -29049,7 +29362,14 @@ var LoggingSettingsPatchSchema = object({
29049
29362
  * Only the diagnostics NAMED here change. An armed window that is not listed
29050
29363
  * keeps running — a patch is never a full replacement.
29051
29364
  */
29052
- diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional()
29365
+ diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional(),
29366
+ /**
29367
+ * Only the channels NAMED here change. An armed channel that is not listed
29368
+ * keeps running — same rule as `diagnostics`, because a patch that silently
29369
+ * disarmed the channels it did not mention would make the Levels page and
29370
+ * the Diagnostics page fight over the same value.
29371
+ */
29372
+ channels: array(LogChannelWindowPatchSchema).readonly().optional()
29053
29373
  });
29054
29374
  /**
29055
29375
  * Which LAYER of the hierarchy is addressed. Absent = the cluster layer.
@@ -29062,9 +29382,22 @@ var LoggingSettingsPatchSchema = object({
29062
29382
  * authority over the whole hierarchy and answers for every layer, so the
29063
29383
  * layer selector needs a name the transport does not already own.
29064
29384
  */
29065
- var GetLoggingSettingsInputSchema = object({ scopeNodeId: string().optional() });
29385
+ var GetLoggingSettingsInputSchema = object({
29386
+ scopeNodeId: string().optional(),
29387
+ /**
29388
+ * The declared CHANNEL this document is addressed at, when the caller wants
29389
+ * the `component` layer. Absent = the node/cluster hierarchy only.
29390
+ *
29391
+ * Naming it separately rather than overloading `scopeNodeId` keeps the two
29392
+ * axes from collapsing: a component level is cluster-wide, a node level is
29393
+ * not, and one selector for both would make "which of these two did I just
29394
+ * set" unanswerable — the exact ambiguity `explicit` exists to remove.
29395
+ */
29396
+ scopeComponent: string().optional()
29397
+ });
29066
29398
  var SetLoggingSettingsInputSchema = object({
29067
29399
  scopeNodeId: string().optional(),
29400
+ scopeComponent: string().optional(),
29068
29401
  patch: LoggingSettingsPatchSchema
29069
29402
  });
29070
29403
  /**
@@ -29079,9 +29412,20 @@ var SetLoggingSettingsInputSchema = object({
29079
29412
  var LoggingSettingsStateSchema = object({
29080
29413
  /** The layer this document was read at. `null` = the cluster layer. */
29081
29414
  scopeNodeId: string().nullable(),
29415
+ /** The channel this document was read at. `null` = no component layer. */
29416
+ scopeComponent: string().nullable(),
29082
29417
  effective: LoggingEffectiveSchema,
29083
29418
  explicit: LoggingExplicitSchema,
29084
29419
  activeWindows: array(DiagnosticWindowSchema).readonly(),
29420
+ /**
29421
+ * Every channel the cluster's addons DECLARE, gathered from the
29422
+ * `log-channels` providers. Not stored anywhere: assembled per read, so a
29423
+ * channel added by a redeployed addon appears without anybody editing a
29424
+ * list, and a channel whose addon is gone stops being offered.
29425
+ */
29426
+ channels: array(LogChannelDescriptorSchema).readonly(),
29427
+ /** The channels ARMED right now, each with its deadline. */
29428
+ activeChannels: array(LogChannelWindowStateSchema).readonly(),
29085
29429
  persisted: boolean()
29086
29430
  });
29087
29431
  method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), method(_void(), FeatureManifestSchema), method(_void(), array(NetworkAddressSchema).readonly()), method(_void(), unknown().nullable(), { auth: "admin" }), method(record(string(), unknown()), _null(), {
@@ -32066,6 +32410,12 @@ Object.freeze({
32066
32410
  addonId: null,
32067
32411
  access: "view"
32068
32412
  },
32413
+ "dataStoreProvider.aggregate": {
32414
+ capName: "data-store-provider",
32415
+ capScope: "system",
32416
+ addonId: null,
32417
+ access: "view"
32418
+ },
32069
32419
  "dataStoreProvider.count": {
32070
32420
  capName: "data-store-provider",
32071
32421
  capScope: "system",
@@ -32480,6 +32830,12 @@ Object.freeze({
32480
32830
  addonId: null,
32481
32831
  access: "view"
32482
32832
  },
32833
+ "deviceManager.getChildrenBatch": {
32834
+ capName: "device-manager",
32835
+ capScope: "system",
32836
+ addonId: null,
32837
+ access: "view"
32838
+ },
32483
32839
  "deviceManager.getConfigSchema": {
32484
32840
  capName: "device-manager",
32485
32841
  capScope: "system",
@@ -33530,6 +33886,18 @@ Object.freeze({
33530
33886
  addonId: null,
33531
33887
  access: "create"
33532
33888
  },
33889
+ "logChannels.apply": {
33890
+ capName: "log-channels",
33891
+ capScope: "system",
33892
+ addonId: null,
33893
+ access: "create"
33894
+ },
33895
+ "logChannels.list": {
33896
+ capName: "log-channels",
33897
+ capScope: "system",
33898
+ addonId: null,
33899
+ access: "view"
33900
+ },
33533
33901
  "logDestination.query": {
33534
33902
  capName: "log-destination",
33535
33903
  capScope: "system",
@@ -35684,6 +36052,12 @@ Object.freeze({
35684
36052
  addonId: null,
35685
36053
  access: "create"
35686
36054
  },
36055
+ "settingsStore.aggregate": {
36056
+ capName: "settings-store",
36057
+ capScope: "system",
36058
+ addonId: null,
36059
+ access: "view"
36060
+ },
35687
36061
  "settingsStore.count": {
35688
36062
  capName: "settings-store",
35689
36063
  capScope: "system",
@@ -37263,6 +37637,11 @@ Object.freeze({
37263
37637
  form: "single",
37264
37638
  optional: false
37265
37639
  }],
37640
+ "deviceManager.getChildrenBatch": [{
37641
+ name: "parentDeviceIds",
37642
+ form: "array",
37643
+ optional: false
37644
+ }],
37266
37645
  "deviceManager.getConfigSchema": [{
37267
37646
  name: "deviceId",
37268
37647
  form: "single",
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  //#endregion
6
- const require_dist = require("../dist-BXcwGSn_.js");
6
+ const require_dist = require("../dist-D_G71rhM.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  //#region src/ha-export/topics.ts
9
9
  /**
@@ -1,4 +1,4 @@
1
- import { At as EventCategory, C as buildAddonRouteProvider, Et as string, N as deviceExportCapability, X as oauthIntegrationCapability, a as COCO_TO_MACRO, c as FanDirectionSchema, i as CAMERA_SWITCH_ORDER, l as HvacModeSchema, o as CameraSwitchIdSchema, p as addonRoutesCapability, pt as BaseAddon, t as AlarmArmModeSchema, u as MediaPlayerRepeatSchema, vt as nodePin } from "../dist-Dfp98hJL.mjs";
1
+ import { At as EventCategory, C as buildAddonRouteProvider, Et as string, N as deviceExportCapability, X as oauthIntegrationCapability, a as COCO_TO_MACRO, c as FanDirectionSchema, i as CAMERA_SWITCH_ORDER, l as HvacModeSchema, o as CameraSwitchIdSchema, p as addonRoutesCapability, pt as BaseAddon, t as AlarmArmModeSchema, u as MediaPlayerRepeatSchema, vt as nodePin } from "../dist-DlrKePv3.mjs";
2
2
  import { createHmac, timingSafeEqual } from "node:crypto";
3
3
  //#region src/ha-export/topics.ts
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-homeassistant",
3
- "version": "1.2.45",
3
+ "version": "1.2.47",
4
4
  "description": "Home Assistant device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",