@camstack/addon-provider-unifi 0.2.32 → 0.2.34

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 (3) hide show
  1. package/dist/addon.js +409 -30
  2. package/dist/addon.mjs +409 -30
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -7468,6 +7468,111 @@ var CameraSwitchGroupSchema = object({
7468
7468
  fetchedAt: number()
7469
7469
  });
7470
7470
  /**
7471
+ * Per-component log CHANNELS — the gate a hot path consults, and the registry
7472
+ * an addon declares its channels in.
7473
+ *
7474
+ * ## Two axes, deliberately separated
7475
+ *
7476
+ * - **DECLARATION** — which channels exist. Only the addon knows:
7477
+ * `stream-broker` knows webrtc/ICE/RTP, `provider-reolink` knows
7478
+ * baichuan/handshake. A hand-wired central list rots at the first addition,
7479
+ * and rots silently. So a channel is declared where it is consulted, and the
7480
+ * `log-channels` capability enumerates the declarations.
7481
+ * - **VALUE** — at which level, for which scope, until when. That stays ONE
7482
+ * thing: the logging settings document on the `system` cap. Two authorities
7483
+ * over the values is the exact defect
7484
+ * `docs/design/plans/2026-08-26-logging-per-componente.md` was written to
7485
+ * remove; re-introducing it from the cure side would be grotesque.
7486
+ *
7487
+ * Nothing in this file reads a clock, an env var or a store. The registry is
7488
+ * a MIRROR: it is moved only by {@link LogChannelRegistry.apply}, called off
7489
+ * the hot path with a value somebody actually read, and by
7490
+ * {@link LogChannelRegistry.tick}, called on a timer. A store read that fails
7491
+ * never reaches here, so it can neither disarm an armed channel nor arm a
7492
+ * disarmed one (D49).
7493
+ *
7494
+ * ## The canonical call shape
7495
+ *
7496
+ * ```ts
7497
+ * if (CH_RTP.on && CH_RTP.wants(deviceId)) {
7498
+ * CH_RTP.log(logger, 'rtp subscriber added', { tags: { deviceId }, meta: { ssrc } })
7499
+ * }
7500
+ * ```
7501
+ *
7502
+ * `on` is a plain boolean FIELD — never a getter — and it is the FIRST thing
7503
+ * read. Disarmed, a call site costs one load and one branch, and the `extras`
7504
+ * object literal is never constructed because it lives inside the branch. It
7505
+ * is the same shape already proven in production at `stream-broker.ts:1650`,
7506
+ * and the same discipline `LoggingGate.allowsDestination` uses for the
7507
+ * destination floor (measured at 1.93 ns/call when off).
7508
+ *
7509
+ * ## Why a channel emits at `info`
7510
+ *
7511
+ * `loki-logging.addon.ts` pins the destination default at `info` and
7512
+ * `loki-destination.ts` drops everything below it, so a line emitted at
7513
+ * `debug` never reaches Loki and the hub's in-memory ring only holds ~35
7514
+ * minutes. A diagnostic that cannot be read an hour later is worse than no
7515
+ * diagnostic, because it looks done. {@link LogChannelGate.log} therefore
7516
+ * emits at the channel's declared level, whose schema floor is `info`.
7517
+ */
7518
+ /**
7519
+ * The level a channel writes at once armed.
7520
+ *
7521
+ * `debug` is absent ON PURPOSE and not by omission: below `info` the line does
7522
+ * not leave the process for Loki, and the whole point of arming a channel is
7523
+ * to read it later.
7524
+ */
7525
+ var LogChannelLevelSchema = _enum([
7526
+ "info",
7527
+ "warn",
7528
+ "error"
7529
+ ]);
7530
+ /**
7531
+ * What an addon declares about one channel. No value, no state — a
7532
+ * declaration is inert.
7533
+ */
7534
+ var LogChannelDescriptorSchema = object({
7535
+ /**
7536
+ * Dotted `area.thing`, unique across the workspace. `area` is conventionally
7537
+ * the addon's short name so an operator reading a channel list can tell who
7538
+ * owns it without a second lookup.
7539
+ */
7540
+ name: string().min(3).regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/, "a channel name is dotted lower-kebab, e.g. area.thing"),
7541
+ /** One sentence: what the operator will SEE after arming it. */
7542
+ description: string().min(1),
7543
+ /** The level its lines are emitted at. Never below `info`. */
7544
+ defaultLevel: LogChannelLevelSchema,
7545
+ /**
7546
+ * Whether this channel can be narrowed to a camera.
7547
+ *
7548
+ * `true` is a PROMISE with two halves, and both must hold: the gate is
7549
+ * consulted with the numeric device id, AND every line the channel admits
7550
+ * carries `tags: { deviceId }` with that same numeric id. The second half is
7551
+ * what makes `| json | deviceId="617"` work in Loki — `loki-payload.ts`
7552
+ * keeps `deviceId` out of the stream labels for cardinality, so the tag in
7553
+ * the body is the only way to filter.
7554
+ *
7555
+ * A channel whose lines carry the device only in `meta` (or not at all) is
7556
+ * declared `false`. Declaring it `true` anyway would be a lie the UI repeats:
7557
+ * the operator narrows to one camera, sees nothing, and concludes the code
7558
+ * path was never taken.
7559
+ */
7560
+ perDevice: boolean()
7561
+ });
7562
+ /**
7563
+ * An armed window over one channel, as the document hands it to a mirror.
7564
+ *
7565
+ * A window is a DEADLINE, never a flag (ADR-0244): a channel somebody forgot
7566
+ * expires by itself, which is the one failure a boolean cannot avoid.
7567
+ */
7568
+ var LogChannelWindowSchema = object({
7569
+ channel: string().min(1),
7570
+ /** Epoch ms the window closes at. */
7571
+ armedUntilMs: number(),
7572
+ /** `null` = every camera. A non-empty list narrows to those numeric ids. */
7573
+ deviceIds: array(number().int()).readonly().nullable()
7574
+ });
7575
+ /**
7471
7576
  * Ops-log — the durable, append-only operations audit shared by the
7472
7577
  * recordings and events management surfaces.
7473
7578
  *
@@ -11088,6 +11193,35 @@ var MutationFilterSchema = object({
11088
11193
  whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11089
11194
  whereNot: record(string(), unknown()).optional()
11090
11195
  });
11196
+ /**
11197
+ * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
11198
+ *
11199
+ * `as` names the slot in the result, so the SAME column may be asked twice with
11200
+ * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
11201
+ * a `Record<column, op>` shape could not express.
11202
+ */
11203
+ var AggregateFieldSchema = object({
11204
+ /** Result key. */
11205
+ as: string().min(1),
11206
+ /** Column to aggregate. Must be a real column of a declared collection. */
11207
+ field: string().min(1),
11208
+ op: _enum([
11209
+ "sum",
11210
+ "min",
11211
+ "max"
11212
+ ])
11213
+ });
11214
+ /**
11215
+ * `COUNT(*)` plus one number per requested field.
11216
+ *
11217
+ * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
11218
+ * that really is 0 are different facts, and an accounting caller that renders
11219
+ * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
11220
+ */
11221
+ var AggregateResultSchema = object({
11222
+ count: number().int(),
11223
+ values: record(string(), number().nullable())
11224
+ });
11091
11225
  /** A single stored record: `{ id, data }`. */
11092
11226
  var SettingsRecordSchema = object({
11093
11227
  id: string(),
@@ -11172,6 +11306,11 @@ method(object({
11172
11306
  collection: string(),
11173
11307
  filter: QueryFilterSchema.optional()
11174
11308
  }), number()), method(object({
11309
+ namespace: string().optional(),
11310
+ collection: string(),
11311
+ fields: array(AggregateFieldSchema).readonly(),
11312
+ filter: QueryFilterSchema.optional()
11313
+ }), AggregateResultSchema), method(object({
11175
11314
  namespace: string().optional(),
11176
11315
  collection: string(),
11177
11316
  field: string(),
@@ -11288,6 +11427,11 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11288
11427
  collection: string(),
11289
11428
  filter: QueryFilterSchema.optional()
11290
11429
  }), number(), { auth: "admin" }), method(object({
11430
+ namespace: string().optional(),
11431
+ collection: string(),
11432
+ fields: array(AggregateFieldSchema).readonly(),
11433
+ filter: QueryFilterSchema.optional()
11434
+ }), AggregateResultSchema, { auth: "admin" }), method(object({
11291
11435
  namespace: string().optional(),
11292
11436
  collection: string(),
11293
11437
  field: string(),
@@ -12011,24 +12155,6 @@ var deviceProviderCapability = {
12011
12155
  })
12012
12156
  }
12013
12157
  };
12014
- /**
12015
- * Device Manager capability — hub-side singleton that unifies device persistence,
12016
- * live registry access, and all management operations into a single tRPC surface.
12017
- *
12018
- * Replaces:
12019
- * - `device-persistence` capability (persistence methods absorbed here)
12020
- * - `device-management.router.ts` (deleted in Phase 2)
12021
- * - `device-ops.router.ts` (compat layer — deleted; device-provider ops absorbed here)
12022
- *
12023
- * All device provider addons (rtsp, onvif, frigate, …) are hub-local: they may
12024
- * fork into separate processes but never run on remote cluster agents. Therefore:
12025
- * - No nodeId routing needed — this is a pure hub singleton.
12026
- * - The hub's DeviceRegistry is the single source of truth for all live devices.
12027
- * - No shadow registry or cross-node aggregation required.
12028
- *
12029
- * Forked workers register devices back to the hub via `ctx.devices`
12030
- * (DeviceManagerApi → ctx.api.deviceManager.registerDevice), same as today.
12031
- */
12032
12158
  /** One child-placement directive on a container's `childLayout`. Structurally
12033
12159
  * identical to `ChildLayoutEntry` in `device-management.ts` — the cap wire
12034
12160
  * shape for the same field. The child is identified by its re-sync-stable
@@ -12397,7 +12523,7 @@ method(object({
12397
12523
  * it answers today and the caller filters as it already does.
12398
12524
  */
12399
12525
  deviceIds: array(number()).optional()
12400
- }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), object({
12526
+ }), 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({
12401
12527
  mode: LinkedDevicesModeSchema,
12402
12528
  devices: array(LinkedDeviceSchema)
12403
12529
  })), 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({
@@ -13121,6 +13247,59 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
13121
13247
  kind: "mutation",
13122
13248
  auth: "admin"
13123
13249
  });
13250
+ /**
13251
+ * `log-channels` — the capability an addon DECLARES its diagnostic channels
13252
+ * through. It stores nothing.
13253
+ *
13254
+ * ## Why a capability at all, and why this shape
13255
+ *
13256
+ * Which channels exist is knowledge only the addon has: `stream-broker` knows
13257
+ * webrtc/ICE/RTP, `provider-reolink` knows baichuan/handshake. A central list
13258
+ * maintained by hand rots at the first addition and rots INVISIBLY — nothing
13259
+ * fails, an operator just never sees the channel somebody added. So the list
13260
+ * is assembled from declarations at runtime.
13261
+ *
13262
+ * The shape is copied from `log-destination.cap.ts`, which already does
13263
+ * exactly this job: `mode: 'collection'`, `internal: true`,
13264
+ * `mount: { kind: 'skip' }` — no tRPC route, no generated hooks — while
13265
+ * `addons.listCapabilityProviders` still enumerates it, and the hub's
13266
+ * `CapabilityRegistry` still holds an RPC proxy per provider so a forked
13267
+ * runner's declarations reach hub-main over the transport that already exists.
13268
+ * No new UDS message, no second registry.
13269
+ *
13270
+ * ## What it deliberately does NOT own
13271
+ *
13272
+ * The VALUES — which channel is armed, for which cameras, until when — live in
13273
+ * ONE place: the logging settings document on the `system` cap
13274
+ * (`getLoggingSettings` / `setLoggingSettings`). Two authorities over the same
13275
+ * value is the defect the plan behind this work exists to remove, and
13276
+ * `setRequestCensus` was retired (D245) rather than allowed to be a second
13277
+ * one. {@link logChannelsCapability} therefore has no getter for a level, no
13278
+ * setter for a window and no persistence of any kind.
13279
+ *
13280
+ * ## Why `apply` is here even so
13281
+ *
13282
+ * The gate lives in the addon's PROCESS; the document lives in hub-main. Some
13283
+ * seam has to carry the value from the authority to the mirror, and a channel
13284
+ * that cannot be reached is precisely the dead knob this whole slice exists to
13285
+ * make impossible (D62 — `audioThresholdDbfs`, the HA entities with no source).
13286
+ * `apply` is that seam and nothing more: it writes an in-memory mirror, it
13287
+ * persists nothing, it is never the source of a value, and it is called only
13288
+ * with a set the hub actually read (D49 — a read that fails does not call it
13289
+ * at all, so no channel is silently disarmed by a bad read).
13290
+ */
13291
+ /** What `apply` reports back — enough to log, not enough to be a second state. */
13292
+ var LogChannelApplyResultSchema = object({
13293
+ /** How many declared channels are armed in this process after the call. */
13294
+ armed: number().int().min(0),
13295
+ /**
13296
+ * Names the document armed that this process does not declare. Reported
13297
+ * rather than swallowed: a name here is either a typo or an addon that has
13298
+ * not booted, and both deserve a line instead of silence.
13299
+ */
13300
+ unknown: array(string()).readonly()
13301
+ });
13302
+ method(_void(), array(LogChannelDescriptorSchema).readonly()), method(object({ windows: array(LogChannelWindowSchema).readonly() }), LogChannelApplyResultSchema, { kind: "mutation" });
13124
13303
  var LogLevelSchema = _enum([
13125
13304
  "debug",
13126
13305
  "info",
@@ -28420,17 +28599,60 @@ var SetSiteLocationInputSchema = object({
28420
28599
  longitude: number().min(-180).max(180)
28421
28600
  }).nullable();
28422
28601
  /**
28423
- * One `(procedure, user-agent, ip, principal)` tuple of the HTTP request
28602
+ * The TRANSPORT a call arrived on.
28603
+ *
28604
+ * Every counted call carries exactly one of these, and `unknown` is a PLANE
28605
+ * rather than a gap: a plane that cannot attribute a call declares it here, so
28606
+ * the call lands in a named bucket instead of vanishing. `planes` summing to
28607
+ * `procedureCalls` is what makes "the sum of the planes explains the total"
28608
+ * checkable rather than asserted.
28609
+ *
28610
+ * - `http` — the Fastify tRPC plugin (`/trpc/*`), one context per request.
28611
+ * - `ws` — `applyWSSHandler`, counted per OPERATION rather than per
28612
+ * connection; the viewer talks to the hub over `wsLink`
28613
+ * exclusively, so this is the plane the HTTP census could not see.
28614
+ * - `mesh` — the in-process `$core-caps` bridge (`createCaller`), which
28615
+ * never touches a socket and therefore never touched a census.
28616
+ * - `unknown` — counted, plane undecidable. No hook produces it today, and
28617
+ * that is exactly what its `0` asserts: every plane the hub has can name
28618
+ * itself. It is an output bucket, never a knob — a call that arrives on a
28619
+ * plane nobody instrumented lands here instead of vanishing from the total.
28620
+ */
28621
+ var TransportPlaneSchema = _enum([
28622
+ "http",
28623
+ "ws",
28624
+ "mesh",
28625
+ "unknown"
28626
+ ]);
28627
+ /**
28628
+ * Calls per plane. Every key is always present, `0` included — an absent plane
28629
+ * reads as "not instrumented", which is the one thing this census must never
28630
+ * make an operator wonder about.
28631
+ */
28632
+ var TransportPlaneCountsSchema = object({
28633
+ http: number(),
28634
+ ws: number(),
28635
+ mesh: number(),
28636
+ unknown: number()
28637
+ });
28638
+ /**
28639
+ * One `(plane, procedure, user-agent, ip, principal)` tuple of the transport
28424
28640
  * census. `principal` is the DERIVED identity (`apocaliss92 (admin)`,
28425
28641
  * `scoped:1a2b3c4d (scoped-token)`, `anonymous`) that the tRPC error log
28426
28642
  * already prints - never a token, never an `Authorization` header.
28643
+ *
28644
+ * `subscriptions` is counted APART from `calls`: a subscription is opened once
28645
+ * and lives for hours, so folding it into a call count makes one long-lived
28646
+ * stream look like a storm.
28427
28647
  */
28428
28648
  var RequestCensusGroupSchema = object({
28649
+ plane: TransportPlaneSchema,
28429
28650
  procedure: string(),
28430
28651
  userAgent: string(),
28431
28652
  ip: string(),
28432
28653
  principal: string(),
28433
28654
  calls: number(),
28655
+ subscriptions: number(),
28434
28656
  perMin: number()
28435
28657
  });
28436
28658
  /**
@@ -28443,6 +28665,14 @@ var RequestCensusGroupSchema = object({
28443
28665
  var RequestCensusProcedureSchema = object({
28444
28666
  procedure: string(),
28445
28667
  calls: number(),
28668
+ /**
28669
+ * The same total, split by transport. THIS is the row that answers the
28670
+ * question the census exists for: one look at `deviceManager.listAll` says
28671
+ * which plane carried the 4 960, without joining two log lines by eye.
28672
+ */
28673
+ planes: TransportPlaneCountsSchema,
28674
+ /** Subscription STARTS on this procedure. Never folded into `calls`. */
28675
+ subscriptions: number(),
28446
28676
  perMin: number()
28447
28677
  });
28448
28678
  /**
@@ -28470,14 +28700,45 @@ var RequestCensusStatusSchema = object({
28470
28700
  */
28471
28701
  procedureCalls: number(),
28472
28702
  /**
28703
+ * `procedureCalls` split by transport. The four keys sum to
28704
+ * `procedureCalls` by construction - {@link RequestCensusSnapshotSchema}'s
28705
+ * `planesExplainTotal` is that identity, checked rather than assumed.
28706
+ */
28707
+ planes: TransportPlaneCountsSchema,
28708
+ /**
28709
+ * True iff `planes` sums to `procedureCalls`. False means a call was counted
28710
+ * on no plane at all - which is a RESULT (a plane is missing from the
28711
+ * instrument), not a failure, and it has to be visible to be read as one.
28712
+ */
28713
+ planesExplainTotal: boolean(),
28714
+ /**
28473
28715
  * tRPC WebSocket connections opened during the window. NOT calls - the WS
28474
- * transport resolves one context per connection - but the number that says
28475
- * whether a plane this census cannot see was busy while HTTP was quiet.
28716
+ * adapter resolves one context per connection - kept because a plane's call
28717
+ * count of zero against 37 open connections says something different from a
28718
+ * plane with no connections at all.
28476
28719
  */
28477
28720
  wsConnections: number(),
28721
+ /**
28722
+ * Client frames the WS plane looked at. `wsMessages` far above
28723
+ * `planes.ws + subscriptions` means most traffic is not operations
28724
+ * (keepalives, connection params) - which is itself an answer.
28725
+ */
28726
+ wsMessages: number(),
28727
+ /**
28728
+ * Subscription STARTS across every plane, excluded from `procedureCalls` on
28729
+ * purpose: one live-events stream opened at boot and held for six hours is
28730
+ * one subscription, and counting it as a call would let a quiet plane
28731
+ * masquerade as the storm.
28732
+ */
28733
+ subscriptions: number(),
28734
+ /** `subscription.stop` frames. Starts minus stops is what is still open. */
28735
+ subscriptionStops: number(),
28478
28736
  distinctGroups: number(),
28479
- /** Calls counted in the totals whose group attribution was shed at the
28480
- * cardinality bound. */
28737
+ /**
28738
+ * Operations counted in the totals whose CALLER attribution was shed at the
28739
+ * cardinality bound. Unrelated to the `unknown` PLANE: these calls know
28740
+ * which transport they arrived on, they just lost their group row.
28741
+ */
28481
28742
  unattributedCalls: number(),
28482
28743
  procedures: array(RequestCensusProcedureSchema).readonly(),
28483
28744
  groups: array(RequestCensusGroupSchema).readonly()
@@ -28500,10 +28761,11 @@ var DiagnosticIdSchema = _enum(["request-census"]);
28500
28761
  * The layers of the level hierarchy, general → specific. The most specific
28501
28762
  * layer that carries an explicit value wins.
28502
28763
  *
28503
- * `component` is DECLARED and not yet resolvable: the per-component channels
28504
- * are a later slice of the same plan, and a `levelSource` enum that has to
28505
- * grow later would force every consumer of this document to change with it.
28506
- * Nothing returns `component` today.
28764
+ * `component` became RESOLVABLE on 2026-08-27: a component is a declared log
28765
+ * CHANNEL (`stream-broker.webrtc`, `provider-reolink.baichuan`), named by
28766
+ * `scopeComponent`. It was declared-but-dark in the first slice precisely so
28767
+ * that turning it on would not force every consumer of this document to widen
28768
+ * a `levelSource` enum — which is what has now not happened.
28507
28769
  */
28508
28770
  var LoggingScopeKindSchema = _enum([
28509
28771
  "cluster",
@@ -28530,6 +28792,14 @@ var LoggingLevelLayerSchema = object({
28530
28792
  scope: LoggingScopeKindSchema,
28531
28793
  /** The node this layer speaks for; `null` on the cluster layer. */
28532
28794
  nodeId: string().nullable(),
28795
+ /**
28796
+ * The declared channel this layer speaks for; `null` on every layer but
28797
+ * `component`. Never folded into `nodeId`: a component level is CLUSTER-WIDE
28798
+ * by design — the convention this repo settled on is one orchestrator-wide
28799
+ * setting, never per node (D52) — so a component layer that carried a node
28800
+ * would invite a per-node copy of a value that has no per-node meaning.
28801
+ */
28802
+ component: string().nullable(),
28533
28803
  /** Explicitly set here, or `null` when this layer inherits. */
28534
28804
  level: LogLevelSchema$1.nullable()
28535
28805
  });
@@ -28571,6 +28841,49 @@ var DiagnosticWindowPatchSchema = object({
28571
28841
  reportEveryMs: number().int().positive().optional()
28572
28842
  });
28573
28843
  /**
28844
+ * A channel ARMED, as the document reports it.
28845
+ *
28846
+ * `armMs` is not echoed back: what an operator needs to see is the deadline
28847
+ * and the time left, because a diagnostic left running is itself an incident
28848
+ * and "armed for 10 minutes" said an hour ago is not an answer.
28849
+ */
28850
+ var LogChannelWindowStateSchema = object({
28851
+ channel: string(),
28852
+ armed: boolean(),
28853
+ /** Epoch ms the window closes at. 0 when disarmed. */
28854
+ armedUntilMs: number(),
28855
+ /** Ms left before it expires on its own. 0 when disarmed. */
28856
+ remainingMs: number(),
28857
+ /**
28858
+ * The cameras it is narrowed to, or `null` for every camera.
28859
+ *
28860
+ * A channel declared `perDevice: false` can only ever report `null` here:
28861
+ * its lines do not carry `tags: { deviceId }`, so narrowing them would
28862
+ * produce a filter that silently matches nothing. The server REFUSES such a
28863
+ * patch rather than quietly widening it — ignoring the request would teach
28864
+ * the operator that per-camera filtering works on that channel when it does
28865
+ * not.
28866
+ */
28867
+ deviceIds: array(number().int()).readonly().nullable()
28868
+ });
28869
+ /**
28870
+ * `armMs: 0` DISARMS. Same grammar as {@link DiagnosticWindowPatchSchema}, and
28871
+ * for the same reason: a channel is a window with a deadline, never a switch.
28872
+ */
28873
+ var LogChannelWindowPatchSchema = object({
28874
+ channel: string().min(1),
28875
+ armMs: number().int().min(0),
28876
+ /**
28877
+ * Narrow to these numeric device ids. Absent or `null` = every camera.
28878
+ *
28879
+ * Numeric because the repo's own rule makes it possible: every log line
28880
+ * about a device carries `tags: { deviceId }` with the numeric id. That rule
28881
+ * was paid for with a 22% thumbnail gap and a 3-hour media blackout both
28882
+ * diagnosed by hand, and this is the first thing that collects on it.
28883
+ */
28884
+ deviceIds: array(number().int()).readonly().nullable().optional()
28885
+ });
28886
+ /**
28574
28887
  * A PATCH, and patches MERGE.
28575
28888
  *
28576
28889
  * A field absent from the patch is left exactly as it was — arming a
@@ -28589,7 +28902,14 @@ var LoggingSettingsPatchSchema = object({
28589
28902
  * Only the diagnostics NAMED here change. An armed window that is not listed
28590
28903
  * keeps running — a patch is never a full replacement.
28591
28904
  */
28592
- diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional()
28905
+ diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional(),
28906
+ /**
28907
+ * Only the channels NAMED here change. An armed channel that is not listed
28908
+ * keeps running — same rule as `diagnostics`, because a patch that silently
28909
+ * disarmed the channels it did not mention would make the Levels page and
28910
+ * the Diagnostics page fight over the same value.
28911
+ */
28912
+ channels: array(LogChannelWindowPatchSchema).readonly().optional()
28593
28913
  });
28594
28914
  /**
28595
28915
  * Which LAYER of the hierarchy is addressed. Absent = the cluster layer.
@@ -28602,9 +28922,22 @@ var LoggingSettingsPatchSchema = object({
28602
28922
  * authority over the whole hierarchy and answers for every layer, so the
28603
28923
  * layer selector needs a name the transport does not already own.
28604
28924
  */
28605
- var GetLoggingSettingsInputSchema = object({ scopeNodeId: string().optional() });
28925
+ var GetLoggingSettingsInputSchema = object({
28926
+ scopeNodeId: string().optional(),
28927
+ /**
28928
+ * The declared CHANNEL this document is addressed at, when the caller wants
28929
+ * the `component` layer. Absent = the node/cluster hierarchy only.
28930
+ *
28931
+ * Naming it separately rather than overloading `scopeNodeId` keeps the two
28932
+ * axes from collapsing: a component level is cluster-wide, a node level is
28933
+ * not, and one selector for both would make "which of these two did I just
28934
+ * set" unanswerable — the exact ambiguity `explicit` exists to remove.
28935
+ */
28936
+ scopeComponent: string().optional()
28937
+ });
28606
28938
  var SetLoggingSettingsInputSchema = object({
28607
28939
  scopeNodeId: string().optional(),
28940
+ scopeComponent: string().optional(),
28608
28941
  patch: LoggingSettingsPatchSchema
28609
28942
  });
28610
28943
  /**
@@ -28619,9 +28952,20 @@ var SetLoggingSettingsInputSchema = object({
28619
28952
  var LoggingSettingsStateSchema = object({
28620
28953
  /** The layer this document was read at. `null` = the cluster layer. */
28621
28954
  scopeNodeId: string().nullable(),
28955
+ /** The channel this document was read at. `null` = no component layer. */
28956
+ scopeComponent: string().nullable(),
28622
28957
  effective: LoggingEffectiveSchema,
28623
28958
  explicit: LoggingExplicitSchema,
28624
28959
  activeWindows: array(DiagnosticWindowSchema).readonly(),
28960
+ /**
28961
+ * Every channel the cluster's addons DECLARE, gathered from the
28962
+ * `log-channels` providers. Not stored anywhere: assembled per read, so a
28963
+ * channel added by a redeployed addon appears without anybody editing a
28964
+ * list, and a channel whose addon is gone stops being offered.
28965
+ */
28966
+ channels: array(LogChannelDescriptorSchema).readonly(),
28967
+ /** The channels ARMED right now, each with its deadline. */
28968
+ activeChannels: array(LogChannelWindowStateSchema).readonly(),
28625
28969
  persisted: boolean()
28626
28970
  });
28627
28971
  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(), {
@@ -31606,6 +31950,12 @@ Object.freeze({
31606
31950
  addonId: null,
31607
31951
  access: "view"
31608
31952
  },
31953
+ "dataStoreProvider.aggregate": {
31954
+ capName: "data-store-provider",
31955
+ capScope: "system",
31956
+ addonId: null,
31957
+ access: "view"
31958
+ },
31609
31959
  "dataStoreProvider.count": {
31610
31960
  capName: "data-store-provider",
31611
31961
  capScope: "system",
@@ -32020,6 +32370,12 @@ Object.freeze({
32020
32370
  addonId: null,
32021
32371
  access: "view"
32022
32372
  },
32373
+ "deviceManager.getChildrenBatch": {
32374
+ capName: "device-manager",
32375
+ capScope: "system",
32376
+ addonId: null,
32377
+ access: "view"
32378
+ },
32023
32379
  "deviceManager.getConfigSchema": {
32024
32380
  capName: "device-manager",
32025
32381
  capScope: "system",
@@ -33070,6 +33426,18 @@ Object.freeze({
33070
33426
  addonId: null,
33071
33427
  access: "create"
33072
33428
  },
33429
+ "logChannels.apply": {
33430
+ capName: "log-channels",
33431
+ capScope: "system",
33432
+ addonId: null,
33433
+ access: "create"
33434
+ },
33435
+ "logChannels.list": {
33436
+ capName: "log-channels",
33437
+ capScope: "system",
33438
+ addonId: null,
33439
+ access: "view"
33440
+ },
33073
33441
  "logDestination.query": {
33074
33442
  capName: "log-destination",
33075
33443
  capScope: "system",
@@ -35224,6 +35592,12 @@ Object.freeze({
35224
35592
  addonId: null,
35225
35593
  access: "create"
35226
35594
  },
35595
+ "settingsStore.aggregate": {
35596
+ capName: "settings-store",
35597
+ capScope: "system",
35598
+ addonId: null,
35599
+ access: "view"
35600
+ },
35227
35601
  "settingsStore.count": {
35228
35602
  capName: "settings-store",
35229
35603
  capScope: "system",
@@ -36803,6 +37177,11 @@ Object.freeze({
36803
37177
  form: "single",
36804
37178
  optional: false
36805
37179
  }],
37180
+ "deviceManager.getChildrenBatch": [{
37181
+ name: "parentDeviceIds",
37182
+ form: "array",
37183
+ optional: false
37184
+ }],
36806
37185
  "deviceManager.getConfigSchema": [{
36807
37186
  name: "deviceId",
36808
37187
  form: "single",
package/dist/addon.mjs CHANGED
@@ -7467,6 +7467,111 @@ var CameraSwitchGroupSchema = object({
7467
7467
  fetchedAt: number()
7468
7468
  });
7469
7469
  /**
7470
+ * Per-component log CHANNELS — the gate a hot path consults, and the registry
7471
+ * an addon declares its channels in.
7472
+ *
7473
+ * ## Two axes, deliberately separated
7474
+ *
7475
+ * - **DECLARATION** — which channels exist. Only the addon knows:
7476
+ * `stream-broker` knows webrtc/ICE/RTP, `provider-reolink` knows
7477
+ * baichuan/handshake. A hand-wired central list rots at the first addition,
7478
+ * and rots silently. So a channel is declared where it is consulted, and the
7479
+ * `log-channels` capability enumerates the declarations.
7480
+ * - **VALUE** — at which level, for which scope, until when. That stays ONE
7481
+ * thing: the logging settings document on the `system` cap. Two authorities
7482
+ * over the values is the exact defect
7483
+ * `docs/design/plans/2026-08-26-logging-per-componente.md` was written to
7484
+ * remove; re-introducing it from the cure side would be grotesque.
7485
+ *
7486
+ * Nothing in this file reads a clock, an env var or a store. The registry is
7487
+ * a MIRROR: it is moved only by {@link LogChannelRegistry.apply}, called off
7488
+ * the hot path with a value somebody actually read, and by
7489
+ * {@link LogChannelRegistry.tick}, called on a timer. A store read that fails
7490
+ * never reaches here, so it can neither disarm an armed channel nor arm a
7491
+ * disarmed one (D49).
7492
+ *
7493
+ * ## The canonical call shape
7494
+ *
7495
+ * ```ts
7496
+ * if (CH_RTP.on && CH_RTP.wants(deviceId)) {
7497
+ * CH_RTP.log(logger, 'rtp subscriber added', { tags: { deviceId }, meta: { ssrc } })
7498
+ * }
7499
+ * ```
7500
+ *
7501
+ * `on` is a plain boolean FIELD — never a getter — and it is the FIRST thing
7502
+ * read. Disarmed, a call site costs one load and one branch, and the `extras`
7503
+ * object literal is never constructed because it lives inside the branch. It
7504
+ * is the same shape already proven in production at `stream-broker.ts:1650`,
7505
+ * and the same discipline `LoggingGate.allowsDestination` uses for the
7506
+ * destination floor (measured at 1.93 ns/call when off).
7507
+ *
7508
+ * ## Why a channel emits at `info`
7509
+ *
7510
+ * `loki-logging.addon.ts` pins the destination default at `info` and
7511
+ * `loki-destination.ts` drops everything below it, so a line emitted at
7512
+ * `debug` never reaches Loki and the hub's in-memory ring only holds ~35
7513
+ * minutes. A diagnostic that cannot be read an hour later is worse than no
7514
+ * diagnostic, because it looks done. {@link LogChannelGate.log} therefore
7515
+ * emits at the channel's declared level, whose schema floor is `info`.
7516
+ */
7517
+ /**
7518
+ * The level a channel writes at once armed.
7519
+ *
7520
+ * `debug` is absent ON PURPOSE and not by omission: below `info` the line does
7521
+ * not leave the process for Loki, and the whole point of arming a channel is
7522
+ * to read it later.
7523
+ */
7524
+ var LogChannelLevelSchema = _enum([
7525
+ "info",
7526
+ "warn",
7527
+ "error"
7528
+ ]);
7529
+ /**
7530
+ * What an addon declares about one channel. No value, no state — a
7531
+ * declaration is inert.
7532
+ */
7533
+ var LogChannelDescriptorSchema = object({
7534
+ /**
7535
+ * Dotted `area.thing`, unique across the workspace. `area` is conventionally
7536
+ * the addon's short name so an operator reading a channel list can tell who
7537
+ * owns it without a second lookup.
7538
+ */
7539
+ name: string().min(3).regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/, "a channel name is dotted lower-kebab, e.g. area.thing"),
7540
+ /** One sentence: what the operator will SEE after arming it. */
7541
+ description: string().min(1),
7542
+ /** The level its lines are emitted at. Never below `info`. */
7543
+ defaultLevel: LogChannelLevelSchema,
7544
+ /**
7545
+ * Whether this channel can be narrowed to a camera.
7546
+ *
7547
+ * `true` is a PROMISE with two halves, and both must hold: the gate is
7548
+ * consulted with the numeric device id, AND every line the channel admits
7549
+ * carries `tags: { deviceId }` with that same numeric id. The second half is
7550
+ * what makes `| json | deviceId="617"` work in Loki — `loki-payload.ts`
7551
+ * keeps `deviceId` out of the stream labels for cardinality, so the tag in
7552
+ * the body is the only way to filter.
7553
+ *
7554
+ * A channel whose lines carry the device only in `meta` (or not at all) is
7555
+ * declared `false`. Declaring it `true` anyway would be a lie the UI repeats:
7556
+ * the operator narrows to one camera, sees nothing, and concludes the code
7557
+ * path was never taken.
7558
+ */
7559
+ perDevice: boolean()
7560
+ });
7561
+ /**
7562
+ * An armed window over one channel, as the document hands it to a mirror.
7563
+ *
7564
+ * A window is a DEADLINE, never a flag (ADR-0244): a channel somebody forgot
7565
+ * expires by itself, which is the one failure a boolean cannot avoid.
7566
+ */
7567
+ var LogChannelWindowSchema = object({
7568
+ channel: string().min(1),
7569
+ /** Epoch ms the window closes at. */
7570
+ armedUntilMs: number(),
7571
+ /** `null` = every camera. A non-empty list narrows to those numeric ids. */
7572
+ deviceIds: array(number().int()).readonly().nullable()
7573
+ });
7574
+ /**
7470
7575
  * Ops-log — the durable, append-only operations audit shared by the
7471
7576
  * recordings and events management surfaces.
7472
7577
  *
@@ -11087,6 +11192,35 @@ var MutationFilterSchema = object({
11087
11192
  whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11088
11193
  whereNot: record(string(), unknown()).optional()
11089
11194
  });
11195
+ /**
11196
+ * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
11197
+ *
11198
+ * `as` names the slot in the result, so the SAME column may be asked twice with
11199
+ * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
11200
+ * a `Record<column, op>` shape could not express.
11201
+ */
11202
+ var AggregateFieldSchema = object({
11203
+ /** Result key. */
11204
+ as: string().min(1),
11205
+ /** Column to aggregate. Must be a real column of a declared collection. */
11206
+ field: string().min(1),
11207
+ op: _enum([
11208
+ "sum",
11209
+ "min",
11210
+ "max"
11211
+ ])
11212
+ });
11213
+ /**
11214
+ * `COUNT(*)` plus one number per requested field.
11215
+ *
11216
+ * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
11217
+ * that really is 0 are different facts, and an accounting caller that renders
11218
+ * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
11219
+ */
11220
+ var AggregateResultSchema = object({
11221
+ count: number().int(),
11222
+ values: record(string(), number().nullable())
11223
+ });
11090
11224
  /** A single stored record: `{ id, data }`. */
11091
11225
  var SettingsRecordSchema = object({
11092
11226
  id: string(),
@@ -11171,6 +11305,11 @@ method(object({
11171
11305
  collection: string(),
11172
11306
  filter: QueryFilterSchema.optional()
11173
11307
  }), number()), method(object({
11308
+ namespace: string().optional(),
11309
+ collection: string(),
11310
+ fields: array(AggregateFieldSchema).readonly(),
11311
+ filter: QueryFilterSchema.optional()
11312
+ }), AggregateResultSchema), method(object({
11174
11313
  namespace: string().optional(),
11175
11314
  collection: string(),
11176
11315
  field: string(),
@@ -11287,6 +11426,11 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11287
11426
  collection: string(),
11288
11427
  filter: QueryFilterSchema.optional()
11289
11428
  }), number(), { auth: "admin" }), method(object({
11429
+ namespace: string().optional(),
11430
+ collection: string(),
11431
+ fields: array(AggregateFieldSchema).readonly(),
11432
+ filter: QueryFilterSchema.optional()
11433
+ }), AggregateResultSchema, { auth: "admin" }), method(object({
11290
11434
  namespace: string().optional(),
11291
11435
  collection: string(),
11292
11436
  field: string(),
@@ -12010,24 +12154,6 @@ var deviceProviderCapability = {
12010
12154
  })
12011
12155
  }
12012
12156
  };
12013
- /**
12014
- * Device Manager capability — hub-side singleton that unifies device persistence,
12015
- * live registry access, and all management operations into a single tRPC surface.
12016
- *
12017
- * Replaces:
12018
- * - `device-persistence` capability (persistence methods absorbed here)
12019
- * - `device-management.router.ts` (deleted in Phase 2)
12020
- * - `device-ops.router.ts` (compat layer — deleted; device-provider ops absorbed here)
12021
- *
12022
- * All device provider addons (rtsp, onvif, frigate, …) are hub-local: they may
12023
- * fork into separate processes but never run on remote cluster agents. Therefore:
12024
- * - No nodeId routing needed — this is a pure hub singleton.
12025
- * - The hub's DeviceRegistry is the single source of truth for all live devices.
12026
- * - No shadow registry or cross-node aggregation required.
12027
- *
12028
- * Forked workers register devices back to the hub via `ctx.devices`
12029
- * (DeviceManagerApi → ctx.api.deviceManager.registerDevice), same as today.
12030
- */
12031
12157
  /** One child-placement directive on a container's `childLayout`. Structurally
12032
12158
  * identical to `ChildLayoutEntry` in `device-management.ts` — the cap wire
12033
12159
  * shape for the same field. The child is identified by its re-sync-stable
@@ -12396,7 +12522,7 @@ method(object({
12396
12522
  * it answers today and the caller filters as it already does.
12397
12523
  */
12398
12524
  deviceIds: array(number()).optional()
12399
- }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), object({
12525
+ }), 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({
12400
12526
  mode: LinkedDevicesModeSchema,
12401
12527
  devices: array(LinkedDeviceSchema)
12402
12528
  })), 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({
@@ -13120,6 +13246,59 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
13120
13246
  kind: "mutation",
13121
13247
  auth: "admin"
13122
13248
  });
13249
+ /**
13250
+ * `log-channels` — the capability an addon DECLARES its diagnostic channels
13251
+ * through. It stores nothing.
13252
+ *
13253
+ * ## Why a capability at all, and why this shape
13254
+ *
13255
+ * Which channels exist is knowledge only the addon has: `stream-broker` knows
13256
+ * webrtc/ICE/RTP, `provider-reolink` knows baichuan/handshake. A central list
13257
+ * maintained by hand rots at the first addition and rots INVISIBLY — nothing
13258
+ * fails, an operator just never sees the channel somebody added. So the list
13259
+ * is assembled from declarations at runtime.
13260
+ *
13261
+ * The shape is copied from `log-destination.cap.ts`, which already does
13262
+ * exactly this job: `mode: 'collection'`, `internal: true`,
13263
+ * `mount: { kind: 'skip' }` — no tRPC route, no generated hooks — while
13264
+ * `addons.listCapabilityProviders` still enumerates it, and the hub's
13265
+ * `CapabilityRegistry` still holds an RPC proxy per provider so a forked
13266
+ * runner's declarations reach hub-main over the transport that already exists.
13267
+ * No new UDS message, no second registry.
13268
+ *
13269
+ * ## What it deliberately does NOT own
13270
+ *
13271
+ * The VALUES — which channel is armed, for which cameras, until when — live in
13272
+ * ONE place: the logging settings document on the `system` cap
13273
+ * (`getLoggingSettings` / `setLoggingSettings`). Two authorities over the same
13274
+ * value is the defect the plan behind this work exists to remove, and
13275
+ * `setRequestCensus` was retired (D245) rather than allowed to be a second
13276
+ * one. {@link logChannelsCapability} therefore has no getter for a level, no
13277
+ * setter for a window and no persistence of any kind.
13278
+ *
13279
+ * ## Why `apply` is here even so
13280
+ *
13281
+ * The gate lives in the addon's PROCESS; the document lives in hub-main. Some
13282
+ * seam has to carry the value from the authority to the mirror, and a channel
13283
+ * that cannot be reached is precisely the dead knob this whole slice exists to
13284
+ * make impossible (D62 — `audioThresholdDbfs`, the HA entities with no source).
13285
+ * `apply` is that seam and nothing more: it writes an in-memory mirror, it
13286
+ * persists nothing, it is never the source of a value, and it is called only
13287
+ * with a set the hub actually read (D49 — a read that fails does not call it
13288
+ * at all, so no channel is silently disarmed by a bad read).
13289
+ */
13290
+ /** What `apply` reports back — enough to log, not enough to be a second state. */
13291
+ var LogChannelApplyResultSchema = object({
13292
+ /** How many declared channels are armed in this process after the call. */
13293
+ armed: number().int().min(0),
13294
+ /**
13295
+ * Names the document armed that this process does not declare. Reported
13296
+ * rather than swallowed: a name here is either a typo or an addon that has
13297
+ * not booted, and both deserve a line instead of silence.
13298
+ */
13299
+ unknown: array(string()).readonly()
13300
+ });
13301
+ method(_void(), array(LogChannelDescriptorSchema).readonly()), method(object({ windows: array(LogChannelWindowSchema).readonly() }), LogChannelApplyResultSchema, { kind: "mutation" });
13123
13302
  var LogLevelSchema = _enum([
13124
13303
  "debug",
13125
13304
  "info",
@@ -28419,17 +28598,60 @@ var SetSiteLocationInputSchema = object({
28419
28598
  longitude: number().min(-180).max(180)
28420
28599
  }).nullable();
28421
28600
  /**
28422
- * One `(procedure, user-agent, ip, principal)` tuple of the HTTP request
28601
+ * The TRANSPORT a call arrived on.
28602
+ *
28603
+ * Every counted call carries exactly one of these, and `unknown` is a PLANE
28604
+ * rather than a gap: a plane that cannot attribute a call declares it here, so
28605
+ * the call lands in a named bucket instead of vanishing. `planes` summing to
28606
+ * `procedureCalls` is what makes "the sum of the planes explains the total"
28607
+ * checkable rather than asserted.
28608
+ *
28609
+ * - `http` — the Fastify tRPC plugin (`/trpc/*`), one context per request.
28610
+ * - `ws` — `applyWSSHandler`, counted per OPERATION rather than per
28611
+ * connection; the viewer talks to the hub over `wsLink`
28612
+ * exclusively, so this is the plane the HTTP census could not see.
28613
+ * - `mesh` — the in-process `$core-caps` bridge (`createCaller`), which
28614
+ * never touches a socket and therefore never touched a census.
28615
+ * - `unknown` — counted, plane undecidable. No hook produces it today, and
28616
+ * that is exactly what its `0` asserts: every plane the hub has can name
28617
+ * itself. It is an output bucket, never a knob — a call that arrives on a
28618
+ * plane nobody instrumented lands here instead of vanishing from the total.
28619
+ */
28620
+ var TransportPlaneSchema = _enum([
28621
+ "http",
28622
+ "ws",
28623
+ "mesh",
28624
+ "unknown"
28625
+ ]);
28626
+ /**
28627
+ * Calls per plane. Every key is always present, `0` included — an absent plane
28628
+ * reads as "not instrumented", which is the one thing this census must never
28629
+ * make an operator wonder about.
28630
+ */
28631
+ var TransportPlaneCountsSchema = object({
28632
+ http: number(),
28633
+ ws: number(),
28634
+ mesh: number(),
28635
+ unknown: number()
28636
+ });
28637
+ /**
28638
+ * One `(plane, procedure, user-agent, ip, principal)` tuple of the transport
28423
28639
  * census. `principal` is the DERIVED identity (`apocaliss92 (admin)`,
28424
28640
  * `scoped:1a2b3c4d (scoped-token)`, `anonymous`) that the tRPC error log
28425
28641
  * already prints - never a token, never an `Authorization` header.
28642
+ *
28643
+ * `subscriptions` is counted APART from `calls`: a subscription is opened once
28644
+ * and lives for hours, so folding it into a call count makes one long-lived
28645
+ * stream look like a storm.
28426
28646
  */
28427
28647
  var RequestCensusGroupSchema = object({
28648
+ plane: TransportPlaneSchema,
28428
28649
  procedure: string(),
28429
28650
  userAgent: string(),
28430
28651
  ip: string(),
28431
28652
  principal: string(),
28432
28653
  calls: number(),
28654
+ subscriptions: number(),
28433
28655
  perMin: number()
28434
28656
  });
28435
28657
  /**
@@ -28442,6 +28664,14 @@ var RequestCensusGroupSchema = object({
28442
28664
  var RequestCensusProcedureSchema = object({
28443
28665
  procedure: string(),
28444
28666
  calls: number(),
28667
+ /**
28668
+ * The same total, split by transport. THIS is the row that answers the
28669
+ * question the census exists for: one look at `deviceManager.listAll` says
28670
+ * which plane carried the 4 960, without joining two log lines by eye.
28671
+ */
28672
+ planes: TransportPlaneCountsSchema,
28673
+ /** Subscription STARTS on this procedure. Never folded into `calls`. */
28674
+ subscriptions: number(),
28445
28675
  perMin: number()
28446
28676
  });
28447
28677
  /**
@@ -28469,14 +28699,45 @@ var RequestCensusStatusSchema = object({
28469
28699
  */
28470
28700
  procedureCalls: number(),
28471
28701
  /**
28702
+ * `procedureCalls` split by transport. The four keys sum to
28703
+ * `procedureCalls` by construction - {@link RequestCensusSnapshotSchema}'s
28704
+ * `planesExplainTotal` is that identity, checked rather than assumed.
28705
+ */
28706
+ planes: TransportPlaneCountsSchema,
28707
+ /**
28708
+ * True iff `planes` sums to `procedureCalls`. False means a call was counted
28709
+ * on no plane at all - which is a RESULT (a plane is missing from the
28710
+ * instrument), not a failure, and it has to be visible to be read as one.
28711
+ */
28712
+ planesExplainTotal: boolean(),
28713
+ /**
28472
28714
  * tRPC WebSocket connections opened during the window. NOT calls - the WS
28473
- * transport resolves one context per connection - but the number that says
28474
- * whether a plane this census cannot see was busy while HTTP was quiet.
28715
+ * adapter resolves one context per connection - kept because a plane's call
28716
+ * count of zero against 37 open connections says something different from a
28717
+ * plane with no connections at all.
28475
28718
  */
28476
28719
  wsConnections: number(),
28720
+ /**
28721
+ * Client frames the WS plane looked at. `wsMessages` far above
28722
+ * `planes.ws + subscriptions` means most traffic is not operations
28723
+ * (keepalives, connection params) - which is itself an answer.
28724
+ */
28725
+ wsMessages: number(),
28726
+ /**
28727
+ * Subscription STARTS across every plane, excluded from `procedureCalls` on
28728
+ * purpose: one live-events stream opened at boot and held for six hours is
28729
+ * one subscription, and counting it as a call would let a quiet plane
28730
+ * masquerade as the storm.
28731
+ */
28732
+ subscriptions: number(),
28733
+ /** `subscription.stop` frames. Starts minus stops is what is still open. */
28734
+ subscriptionStops: number(),
28477
28735
  distinctGroups: number(),
28478
- /** Calls counted in the totals whose group attribution was shed at the
28479
- * cardinality bound. */
28736
+ /**
28737
+ * Operations counted in the totals whose CALLER attribution was shed at the
28738
+ * cardinality bound. Unrelated to the `unknown` PLANE: these calls know
28739
+ * which transport they arrived on, they just lost their group row.
28740
+ */
28480
28741
  unattributedCalls: number(),
28481
28742
  procedures: array(RequestCensusProcedureSchema).readonly(),
28482
28743
  groups: array(RequestCensusGroupSchema).readonly()
@@ -28499,10 +28760,11 @@ var DiagnosticIdSchema = _enum(["request-census"]);
28499
28760
  * The layers of the level hierarchy, general → specific. The most specific
28500
28761
  * layer that carries an explicit value wins.
28501
28762
  *
28502
- * `component` is DECLARED and not yet resolvable: the per-component channels
28503
- * are a later slice of the same plan, and a `levelSource` enum that has to
28504
- * grow later would force every consumer of this document to change with it.
28505
- * Nothing returns `component` today.
28763
+ * `component` became RESOLVABLE on 2026-08-27: a component is a declared log
28764
+ * CHANNEL (`stream-broker.webrtc`, `provider-reolink.baichuan`), named by
28765
+ * `scopeComponent`. It was declared-but-dark in the first slice precisely so
28766
+ * that turning it on would not force every consumer of this document to widen
28767
+ * a `levelSource` enum — which is what has now not happened.
28506
28768
  */
28507
28769
  var LoggingScopeKindSchema = _enum([
28508
28770
  "cluster",
@@ -28529,6 +28791,14 @@ var LoggingLevelLayerSchema = object({
28529
28791
  scope: LoggingScopeKindSchema,
28530
28792
  /** The node this layer speaks for; `null` on the cluster layer. */
28531
28793
  nodeId: string().nullable(),
28794
+ /**
28795
+ * The declared channel this layer speaks for; `null` on every layer but
28796
+ * `component`. Never folded into `nodeId`: a component level is CLUSTER-WIDE
28797
+ * by design — the convention this repo settled on is one orchestrator-wide
28798
+ * setting, never per node (D52) — so a component layer that carried a node
28799
+ * would invite a per-node copy of a value that has no per-node meaning.
28800
+ */
28801
+ component: string().nullable(),
28532
28802
  /** Explicitly set here, or `null` when this layer inherits. */
28533
28803
  level: LogLevelSchema$1.nullable()
28534
28804
  });
@@ -28570,6 +28840,49 @@ var DiagnosticWindowPatchSchema = object({
28570
28840
  reportEveryMs: number().int().positive().optional()
28571
28841
  });
28572
28842
  /**
28843
+ * A channel ARMED, as the document reports it.
28844
+ *
28845
+ * `armMs` is not echoed back: what an operator needs to see is the deadline
28846
+ * and the time left, because a diagnostic left running is itself an incident
28847
+ * and "armed for 10 minutes" said an hour ago is not an answer.
28848
+ */
28849
+ var LogChannelWindowStateSchema = object({
28850
+ channel: string(),
28851
+ armed: boolean(),
28852
+ /** Epoch ms the window closes at. 0 when disarmed. */
28853
+ armedUntilMs: number(),
28854
+ /** Ms left before it expires on its own. 0 when disarmed. */
28855
+ remainingMs: number(),
28856
+ /**
28857
+ * The cameras it is narrowed to, or `null` for every camera.
28858
+ *
28859
+ * A channel declared `perDevice: false` can only ever report `null` here:
28860
+ * its lines do not carry `tags: { deviceId }`, so narrowing them would
28861
+ * produce a filter that silently matches nothing. The server REFUSES such a
28862
+ * patch rather than quietly widening it — ignoring the request would teach
28863
+ * the operator that per-camera filtering works on that channel when it does
28864
+ * not.
28865
+ */
28866
+ deviceIds: array(number().int()).readonly().nullable()
28867
+ });
28868
+ /**
28869
+ * `armMs: 0` DISARMS. Same grammar as {@link DiagnosticWindowPatchSchema}, and
28870
+ * for the same reason: a channel is a window with a deadline, never a switch.
28871
+ */
28872
+ var LogChannelWindowPatchSchema = object({
28873
+ channel: string().min(1),
28874
+ armMs: number().int().min(0),
28875
+ /**
28876
+ * Narrow to these numeric device ids. Absent or `null` = every camera.
28877
+ *
28878
+ * Numeric because the repo's own rule makes it possible: every log line
28879
+ * about a device carries `tags: { deviceId }` with the numeric id. That rule
28880
+ * was paid for with a 22% thumbnail gap and a 3-hour media blackout both
28881
+ * diagnosed by hand, and this is the first thing that collects on it.
28882
+ */
28883
+ deviceIds: array(number().int()).readonly().nullable().optional()
28884
+ });
28885
+ /**
28573
28886
  * A PATCH, and patches MERGE.
28574
28887
  *
28575
28888
  * A field absent from the patch is left exactly as it was — arming a
@@ -28588,7 +28901,14 @@ var LoggingSettingsPatchSchema = object({
28588
28901
  * Only the diagnostics NAMED here change. An armed window that is not listed
28589
28902
  * keeps running — a patch is never a full replacement.
28590
28903
  */
28591
- diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional()
28904
+ diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional(),
28905
+ /**
28906
+ * Only the channels NAMED here change. An armed channel that is not listed
28907
+ * keeps running — same rule as `diagnostics`, because a patch that silently
28908
+ * disarmed the channels it did not mention would make the Levels page and
28909
+ * the Diagnostics page fight over the same value.
28910
+ */
28911
+ channels: array(LogChannelWindowPatchSchema).readonly().optional()
28592
28912
  });
28593
28913
  /**
28594
28914
  * Which LAYER of the hierarchy is addressed. Absent = the cluster layer.
@@ -28601,9 +28921,22 @@ var LoggingSettingsPatchSchema = object({
28601
28921
  * authority over the whole hierarchy and answers for every layer, so the
28602
28922
  * layer selector needs a name the transport does not already own.
28603
28923
  */
28604
- var GetLoggingSettingsInputSchema = object({ scopeNodeId: string().optional() });
28924
+ var GetLoggingSettingsInputSchema = object({
28925
+ scopeNodeId: string().optional(),
28926
+ /**
28927
+ * The declared CHANNEL this document is addressed at, when the caller wants
28928
+ * the `component` layer. Absent = the node/cluster hierarchy only.
28929
+ *
28930
+ * Naming it separately rather than overloading `scopeNodeId` keeps the two
28931
+ * axes from collapsing: a component level is cluster-wide, a node level is
28932
+ * not, and one selector for both would make "which of these two did I just
28933
+ * set" unanswerable — the exact ambiguity `explicit` exists to remove.
28934
+ */
28935
+ scopeComponent: string().optional()
28936
+ });
28605
28937
  var SetLoggingSettingsInputSchema = object({
28606
28938
  scopeNodeId: string().optional(),
28939
+ scopeComponent: string().optional(),
28607
28940
  patch: LoggingSettingsPatchSchema
28608
28941
  });
28609
28942
  /**
@@ -28618,9 +28951,20 @@ var SetLoggingSettingsInputSchema = object({
28618
28951
  var LoggingSettingsStateSchema = object({
28619
28952
  /** The layer this document was read at. `null` = the cluster layer. */
28620
28953
  scopeNodeId: string().nullable(),
28954
+ /** The channel this document was read at. `null` = no component layer. */
28955
+ scopeComponent: string().nullable(),
28621
28956
  effective: LoggingEffectiveSchema,
28622
28957
  explicit: LoggingExplicitSchema,
28623
28958
  activeWindows: array(DiagnosticWindowSchema).readonly(),
28959
+ /**
28960
+ * Every channel the cluster's addons DECLARE, gathered from the
28961
+ * `log-channels` providers. Not stored anywhere: assembled per read, so a
28962
+ * channel added by a redeployed addon appears without anybody editing a
28963
+ * list, and a channel whose addon is gone stops being offered.
28964
+ */
28965
+ channels: array(LogChannelDescriptorSchema).readonly(),
28966
+ /** The channels ARMED right now, each with its deadline. */
28967
+ activeChannels: array(LogChannelWindowStateSchema).readonly(),
28624
28968
  persisted: boolean()
28625
28969
  });
28626
28970
  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(), {
@@ -31605,6 +31949,12 @@ Object.freeze({
31605
31949
  addonId: null,
31606
31950
  access: "view"
31607
31951
  },
31952
+ "dataStoreProvider.aggregate": {
31953
+ capName: "data-store-provider",
31954
+ capScope: "system",
31955
+ addonId: null,
31956
+ access: "view"
31957
+ },
31608
31958
  "dataStoreProvider.count": {
31609
31959
  capName: "data-store-provider",
31610
31960
  capScope: "system",
@@ -32019,6 +32369,12 @@ Object.freeze({
32019
32369
  addonId: null,
32020
32370
  access: "view"
32021
32371
  },
32372
+ "deviceManager.getChildrenBatch": {
32373
+ capName: "device-manager",
32374
+ capScope: "system",
32375
+ addonId: null,
32376
+ access: "view"
32377
+ },
32022
32378
  "deviceManager.getConfigSchema": {
32023
32379
  capName: "device-manager",
32024
32380
  capScope: "system",
@@ -33069,6 +33425,18 @@ Object.freeze({
33069
33425
  addonId: null,
33070
33426
  access: "create"
33071
33427
  },
33428
+ "logChannels.apply": {
33429
+ capName: "log-channels",
33430
+ capScope: "system",
33431
+ addonId: null,
33432
+ access: "create"
33433
+ },
33434
+ "logChannels.list": {
33435
+ capName: "log-channels",
33436
+ capScope: "system",
33437
+ addonId: null,
33438
+ access: "view"
33439
+ },
33072
33440
  "logDestination.query": {
33073
33441
  capName: "log-destination",
33074
33442
  capScope: "system",
@@ -35223,6 +35591,12 @@ Object.freeze({
35223
35591
  addonId: null,
35224
35592
  access: "create"
35225
35593
  },
35594
+ "settingsStore.aggregate": {
35595
+ capName: "settings-store",
35596
+ capScope: "system",
35597
+ addonId: null,
35598
+ access: "view"
35599
+ },
35226
35600
  "settingsStore.count": {
35227
35601
  capName: "settings-store",
35228
35602
  capScope: "system",
@@ -36802,6 +37176,11 @@ Object.freeze({
36802
37176
  form: "single",
36803
37177
  optional: false
36804
37178
  }],
37179
+ "deviceManager.getChildrenBatch": [{
37180
+ name: "parentDeviceIds",
37181
+ form: "array",
37182
+ optional: false
37183
+ }],
36805
37184
  "deviceManager.getConfigSchema": [{
36806
37185
  name: "deviceId",
36807
37186
  form: "single",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-unifi",
3
- "version": "0.2.32",
3
+ "version": "0.2.34",
4
4
  "description": "UniFi Network controller device-provider addon for CamStack — local-controller infra switches/APs (as containers) + network-client presence. NO cameras/Protect.",
5
5
  "keywords": [
6
6
  "camstack",