@camstack/addon-ai 0.4.25 → 0.4.27

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
@@ -7674,6 +7674,111 @@ var CameraSwitchGroupSchema = object({
7674
7674
  fetchedAt: number$1()
7675
7675
  });
7676
7676
  /**
7677
+ * Per-component log CHANNELS — the gate a hot path consults, and the registry
7678
+ * an addon declares its channels in.
7679
+ *
7680
+ * ## Two axes, deliberately separated
7681
+ *
7682
+ * - **DECLARATION** — which channels exist. Only the addon knows:
7683
+ * `stream-broker` knows webrtc/ICE/RTP, `provider-reolink` knows
7684
+ * baichuan/handshake. A hand-wired central list rots at the first addition,
7685
+ * and rots silently. So a channel is declared where it is consulted, and the
7686
+ * `log-channels` capability enumerates the declarations.
7687
+ * - **VALUE** — at which level, for which scope, until when. That stays ONE
7688
+ * thing: the logging settings document on the `system` cap. Two authorities
7689
+ * over the values is the exact defect
7690
+ * `docs/design/plans/2026-08-26-logging-per-componente.md` was written to
7691
+ * remove; re-introducing it from the cure side would be grotesque.
7692
+ *
7693
+ * Nothing in this file reads a clock, an env var or a store. The registry is
7694
+ * a MIRROR: it is moved only by {@link LogChannelRegistry.apply}, called off
7695
+ * the hot path with a value somebody actually read, and by
7696
+ * {@link LogChannelRegistry.tick}, called on a timer. A store read that fails
7697
+ * never reaches here, so it can neither disarm an armed channel nor arm a
7698
+ * disarmed one (D49).
7699
+ *
7700
+ * ## The canonical call shape
7701
+ *
7702
+ * ```ts
7703
+ * if (CH_RTP.on && CH_RTP.wants(deviceId)) {
7704
+ * CH_RTP.log(logger, 'rtp subscriber added', { tags: { deviceId }, meta: { ssrc } })
7705
+ * }
7706
+ * ```
7707
+ *
7708
+ * `on` is a plain boolean FIELD — never a getter — and it is the FIRST thing
7709
+ * read. Disarmed, a call site costs one load and one branch, and the `extras`
7710
+ * object literal is never constructed because it lives inside the branch. It
7711
+ * is the same shape already proven in production at `stream-broker.ts:1650`,
7712
+ * and the same discipline `LoggingGate.allowsDestination` uses for the
7713
+ * destination floor (measured at 1.93 ns/call when off).
7714
+ *
7715
+ * ## Why a channel emits at `info`
7716
+ *
7717
+ * `loki-logging.addon.ts` pins the destination default at `info` and
7718
+ * `loki-destination.ts` drops everything below it, so a line emitted at
7719
+ * `debug` never reaches Loki and the hub's in-memory ring only holds ~35
7720
+ * minutes. A diagnostic that cannot be read an hour later is worse than no
7721
+ * diagnostic, because it looks done. {@link LogChannelGate.log} therefore
7722
+ * emits at the channel's declared level, whose schema floor is `info`.
7723
+ */
7724
+ /**
7725
+ * The level a channel writes at once armed.
7726
+ *
7727
+ * `debug` is absent ON PURPOSE and not by omission: below `info` the line does
7728
+ * not leave the process for Loki, and the whole point of arming a channel is
7729
+ * to read it later.
7730
+ */
7731
+ var LogChannelLevelSchema = _enum([
7732
+ "info",
7733
+ "warn",
7734
+ "error"
7735
+ ]);
7736
+ /**
7737
+ * What an addon declares about one channel. No value, no state — a
7738
+ * declaration is inert.
7739
+ */
7740
+ var LogChannelDescriptorSchema = object({
7741
+ /**
7742
+ * Dotted `area.thing`, unique across the workspace. `area` is conventionally
7743
+ * the addon's short name so an operator reading a channel list can tell who
7744
+ * owns it without a second lookup.
7745
+ */
7746
+ name: string().min(3).regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/, "a channel name is dotted lower-kebab, e.g. area.thing"),
7747
+ /** One sentence: what the operator will SEE after arming it. */
7748
+ description: string().min(1),
7749
+ /** The level its lines are emitted at. Never below `info`. */
7750
+ defaultLevel: LogChannelLevelSchema,
7751
+ /**
7752
+ * Whether this channel can be narrowed to a camera.
7753
+ *
7754
+ * `true` is a PROMISE with two halves, and both must hold: the gate is
7755
+ * consulted with the numeric device id, AND every line the channel admits
7756
+ * carries `tags: { deviceId }` with that same numeric id. The second half is
7757
+ * what makes `| json | deviceId="617"` work in Loki — `loki-payload.ts`
7758
+ * keeps `deviceId` out of the stream labels for cardinality, so the tag in
7759
+ * the body is the only way to filter.
7760
+ *
7761
+ * A channel whose lines carry the device only in `meta` (or not at all) is
7762
+ * declared `false`. Declaring it `true` anyway would be a lie the UI repeats:
7763
+ * the operator narrows to one camera, sees nothing, and concludes the code
7764
+ * path was never taken.
7765
+ */
7766
+ perDevice: boolean()
7767
+ });
7768
+ /**
7769
+ * An armed window over one channel, as the document hands it to a mirror.
7770
+ *
7771
+ * A window is a DEADLINE, never a flag (ADR-0244): a channel somebody forgot
7772
+ * expires by itself, which is the one failure a boolean cannot avoid.
7773
+ */
7774
+ var LogChannelWindowSchema = object({
7775
+ channel: string().min(1),
7776
+ /** Epoch ms the window closes at. */
7777
+ armedUntilMs: number$1(),
7778
+ /** `null` = every camera. A non-empty list narrows to those numeric ids. */
7779
+ deviceIds: array(number$1().int()).readonly().nullable()
7780
+ });
7781
+ /**
7677
7782
  * Ops-log — the durable, append-only operations audit shared by the
7678
7783
  * recordings and events management surfaces.
7679
7784
  *
@@ -11192,6 +11297,35 @@ var MutationFilterSchema = object({
11192
11297
  whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11193
11298
  whereNot: record(string(), unknown()).optional()
11194
11299
  });
11300
+ /**
11301
+ * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
11302
+ *
11303
+ * `as` names the slot in the result, so the SAME column may be asked twice with
11304
+ * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
11305
+ * a `Record<column, op>` shape could not express.
11306
+ */
11307
+ var AggregateFieldSchema = object({
11308
+ /** Result key. */
11309
+ as: string().min(1),
11310
+ /** Column to aggregate. Must be a real column of a declared collection. */
11311
+ field: string().min(1),
11312
+ op: _enum([
11313
+ "sum",
11314
+ "min",
11315
+ "max"
11316
+ ])
11317
+ });
11318
+ /**
11319
+ * `COUNT(*)` plus one number per requested field.
11320
+ *
11321
+ * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
11322
+ * that really is 0 are different facts, and an accounting caller that renders
11323
+ * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
11324
+ */
11325
+ var AggregateResultSchema = object({
11326
+ count: number$1().int(),
11327
+ values: record(string(), number$1().nullable())
11328
+ });
11195
11329
  /** A single stored record: `{ id, data }`. */
11196
11330
  var SettingsRecordSchema = object({
11197
11331
  id: string(),
@@ -11276,6 +11410,11 @@ method(object({
11276
11410
  collection: string(),
11277
11411
  filter: QueryFilterSchema.optional()
11278
11412
  }), number$1()), method(object({
11413
+ namespace: string().optional(),
11414
+ collection: string(),
11415
+ fields: array(AggregateFieldSchema).readonly(),
11416
+ filter: QueryFilterSchema.optional()
11417
+ }), AggregateResultSchema), method(object({
11279
11418
  namespace: string().optional(),
11280
11419
  collection: string(),
11281
11420
  field: string(),
@@ -11392,6 +11531,11 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11392
11531
  collection: string(),
11393
11532
  filter: QueryFilterSchema.optional()
11394
11533
  }), number$1(), { auth: "admin" }), method(object({
11534
+ namespace: string().optional(),
11535
+ collection: string(),
11536
+ fields: array(AggregateFieldSchema).readonly(),
11537
+ filter: QueryFilterSchema.optional()
11538
+ }), AggregateResultSchema, { auth: "admin" }), method(object({
11395
11539
  namespace: string().optional(),
11396
11540
  collection: string(),
11397
11541
  field: string(),
@@ -11953,24 +12097,6 @@ method(_void(), _void(), { kind: "mutation" }), method(_void(), _void(), { kind:
11953
12097
  kind: "mutation",
11954
12098
  auth: "admin"
11955
12099
  });
11956
- /**
11957
- * Device Manager capability — hub-side singleton that unifies device persistence,
11958
- * live registry access, and all management operations into a single tRPC surface.
11959
- *
11960
- * Replaces:
11961
- * - `device-persistence` capability (persistence methods absorbed here)
11962
- * - `device-management.router.ts` (deleted in Phase 2)
11963
- * - `device-ops.router.ts` (compat layer — deleted; device-provider ops absorbed here)
11964
- *
11965
- * All device provider addons (rtsp, onvif, frigate, …) are hub-local: they may
11966
- * fork into separate processes but never run on remote cluster agents. Therefore:
11967
- * - No nodeId routing needed — this is a pure hub singleton.
11968
- * - The hub's DeviceRegistry is the single source of truth for all live devices.
11969
- * - No shadow registry or cross-node aggregation required.
11970
- *
11971
- * Forked workers register devices back to the hub via `ctx.devices`
11972
- * (DeviceManagerApi → ctx.api.deviceManager.registerDevice), same as today.
11973
- */
11974
12100
  /** One child-placement directive on a container's `childLayout`. Structurally
11975
12101
  * identical to `ChildLayoutEntry` in `device-management.ts` — the cap wire
11976
12102
  * shape for the same field. The child is identified by its re-sync-stable
@@ -12339,7 +12465,7 @@ method(object({
12339
12465
  * it answers today and the caller filters as it already does.
12340
12466
  */
12341
12467
  deviceIds: array(number$1()).optional()
12342
- }), array(DeviceInfoSchema)), method(object({ deviceId: number$1() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number$1() }), array(DeviceInfoSchema)), method(object({ deviceId: number$1() }), object({
12468
+ }), array(DeviceInfoSchema)), method(object({ deviceId: number$1() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number$1() }), array(DeviceInfoSchema)), method(object({ parentDeviceIds: array(number$1()).max(256) }), record(string(), array(DeviceInfoSchema))), method(object({ deviceId: number$1() }), object({
12343
12469
  mode: LinkedDevicesModeSchema,
12344
12470
  devices: array(LinkedDeviceSchema)
12345
12471
  })), method(object({ deviceIds: array(number$1()) }), array(LinkedDevicesForDeviceSchema)), method(object({ deviceId: number$1() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number$1() }), array(ConfigEntrySchema)), method(object({ deviceId: number$1() }), ConfigUISchemaOutput), method(object({
@@ -13157,6 +13283,59 @@ var llmCapability = {
13157
13283
  })
13158
13284
  }
13159
13285
  };
13286
+ /**
13287
+ * `log-channels` — the capability an addon DECLARES its diagnostic channels
13288
+ * through. It stores nothing.
13289
+ *
13290
+ * ## Why a capability at all, and why this shape
13291
+ *
13292
+ * Which channels exist is knowledge only the addon has: `stream-broker` knows
13293
+ * webrtc/ICE/RTP, `provider-reolink` knows baichuan/handshake. A central list
13294
+ * maintained by hand rots at the first addition and rots INVISIBLY — nothing
13295
+ * fails, an operator just never sees the channel somebody added. So the list
13296
+ * is assembled from declarations at runtime.
13297
+ *
13298
+ * The shape is copied from `log-destination.cap.ts`, which already does
13299
+ * exactly this job: `mode: 'collection'`, `internal: true`,
13300
+ * `mount: { kind: 'skip' }` — no tRPC route, no generated hooks — while
13301
+ * `addons.listCapabilityProviders` still enumerates it, and the hub's
13302
+ * `CapabilityRegistry` still holds an RPC proxy per provider so a forked
13303
+ * runner's declarations reach hub-main over the transport that already exists.
13304
+ * No new UDS message, no second registry.
13305
+ *
13306
+ * ## What it deliberately does NOT own
13307
+ *
13308
+ * The VALUES — which channel is armed, for which cameras, until when — live in
13309
+ * ONE place: the logging settings document on the `system` cap
13310
+ * (`getLoggingSettings` / `setLoggingSettings`). Two authorities over the same
13311
+ * value is the defect the plan behind this work exists to remove, and
13312
+ * `setRequestCensus` was retired (D245) rather than allowed to be a second
13313
+ * one. {@link logChannelsCapability} therefore has no getter for a level, no
13314
+ * setter for a window and no persistence of any kind.
13315
+ *
13316
+ * ## Why `apply` is here even so
13317
+ *
13318
+ * The gate lives in the addon's PROCESS; the document lives in hub-main. Some
13319
+ * seam has to carry the value from the authority to the mirror, and a channel
13320
+ * that cannot be reached is precisely the dead knob this whole slice exists to
13321
+ * make impossible (D62 — `audioThresholdDbfs`, the HA entities with no source).
13322
+ * `apply` is that seam and nothing more: it writes an in-memory mirror, it
13323
+ * persists nothing, it is never the source of a value, and it is called only
13324
+ * with a set the hub actually read (D49 — a read that fails does not call it
13325
+ * at all, so no channel is silently disarmed by a bad read).
13326
+ */
13327
+ /** What `apply` reports back — enough to log, not enough to be a second state. */
13328
+ var LogChannelApplyResultSchema = object({
13329
+ /** How many declared channels are armed in this process after the call. */
13330
+ armed: number$1().int().min(0),
13331
+ /**
13332
+ * Names the document armed that this process does not declare. Reported
13333
+ * rather than swallowed: a name here is either a typo or an addon that has
13334
+ * not booted, and both deserve a line instead of silence.
13335
+ */
13336
+ unknown: array(string()).readonly()
13337
+ });
13338
+ method(_void(), array(LogChannelDescriptorSchema).readonly()), method(object({ windows: array(LogChannelWindowSchema).readonly() }), LogChannelApplyResultSchema, { kind: "mutation" });
13160
13339
  var LogLevelSchema = _enum([
13161
13340
  "debug",
13162
13341
  "info",
@@ -26412,17 +26591,60 @@ var SetSiteLocationInputSchema = object({
26412
26591
  longitude: number$1().min(-180).max(180)
26413
26592
  }).nullable();
26414
26593
  /**
26415
- * One `(procedure, user-agent, ip, principal)` tuple of the HTTP request
26594
+ * The TRANSPORT a call arrived on.
26595
+ *
26596
+ * Every counted call carries exactly one of these, and `unknown` is a PLANE
26597
+ * rather than a gap: a plane that cannot attribute a call declares it here, so
26598
+ * the call lands in a named bucket instead of vanishing. `planes` summing to
26599
+ * `procedureCalls` is what makes "the sum of the planes explains the total"
26600
+ * checkable rather than asserted.
26601
+ *
26602
+ * - `http` — the Fastify tRPC plugin (`/trpc/*`), one context per request.
26603
+ * - `ws` — `applyWSSHandler`, counted per OPERATION rather than per
26604
+ * connection; the viewer talks to the hub over `wsLink`
26605
+ * exclusively, so this is the plane the HTTP census could not see.
26606
+ * - `mesh` — the in-process `$core-caps` bridge (`createCaller`), which
26607
+ * never touches a socket and therefore never touched a census.
26608
+ * - `unknown` — counted, plane undecidable. No hook produces it today, and
26609
+ * that is exactly what its `0` asserts: every plane the hub has can name
26610
+ * itself. It is an output bucket, never a knob — a call that arrives on a
26611
+ * plane nobody instrumented lands here instead of vanishing from the total.
26612
+ */
26613
+ var TransportPlaneSchema = _enum([
26614
+ "http",
26615
+ "ws",
26616
+ "mesh",
26617
+ "unknown"
26618
+ ]);
26619
+ /**
26620
+ * Calls per plane. Every key is always present, `0` included — an absent plane
26621
+ * reads as "not instrumented", which is the one thing this census must never
26622
+ * make an operator wonder about.
26623
+ */
26624
+ var TransportPlaneCountsSchema = object({
26625
+ http: number$1(),
26626
+ ws: number$1(),
26627
+ mesh: number$1(),
26628
+ unknown: number$1()
26629
+ });
26630
+ /**
26631
+ * One `(plane, procedure, user-agent, ip, principal)` tuple of the transport
26416
26632
  * census. `principal` is the DERIVED identity (`apocaliss92 (admin)`,
26417
26633
  * `scoped:1a2b3c4d (scoped-token)`, `anonymous`) that the tRPC error log
26418
26634
  * already prints - never a token, never an `Authorization` header.
26635
+ *
26636
+ * `subscriptions` is counted APART from `calls`: a subscription is opened once
26637
+ * and lives for hours, so folding it into a call count makes one long-lived
26638
+ * stream look like a storm.
26419
26639
  */
26420
26640
  var RequestCensusGroupSchema = object({
26641
+ plane: TransportPlaneSchema,
26421
26642
  procedure: string(),
26422
26643
  userAgent: string(),
26423
26644
  ip: string(),
26424
26645
  principal: string(),
26425
26646
  calls: number$1(),
26647
+ subscriptions: number$1(),
26426
26648
  perMin: number$1()
26427
26649
  });
26428
26650
  /**
@@ -26435,6 +26657,14 @@ var RequestCensusGroupSchema = object({
26435
26657
  var RequestCensusProcedureSchema = object({
26436
26658
  procedure: string(),
26437
26659
  calls: number$1(),
26660
+ /**
26661
+ * The same total, split by transport. THIS is the row that answers the
26662
+ * question the census exists for: one look at `deviceManager.listAll` says
26663
+ * which plane carried the 4 960, without joining two log lines by eye.
26664
+ */
26665
+ planes: TransportPlaneCountsSchema,
26666
+ /** Subscription STARTS on this procedure. Never folded into `calls`. */
26667
+ subscriptions: number$1(),
26438
26668
  perMin: number$1()
26439
26669
  });
26440
26670
  /**
@@ -26462,14 +26692,45 @@ var RequestCensusStatusSchema = object({
26462
26692
  */
26463
26693
  procedureCalls: number$1(),
26464
26694
  /**
26695
+ * `procedureCalls` split by transport. The four keys sum to
26696
+ * `procedureCalls` by construction - {@link RequestCensusSnapshotSchema}'s
26697
+ * `planesExplainTotal` is that identity, checked rather than assumed.
26698
+ */
26699
+ planes: TransportPlaneCountsSchema,
26700
+ /**
26701
+ * True iff `planes` sums to `procedureCalls`. False means a call was counted
26702
+ * on no plane at all - which is a RESULT (a plane is missing from the
26703
+ * instrument), not a failure, and it has to be visible to be read as one.
26704
+ */
26705
+ planesExplainTotal: boolean(),
26706
+ /**
26465
26707
  * tRPC WebSocket connections opened during the window. NOT calls - the WS
26466
- * transport resolves one context per connection - but the number that says
26467
- * whether a plane this census cannot see was busy while HTTP was quiet.
26708
+ * adapter resolves one context per connection - kept because a plane's call
26709
+ * count of zero against 37 open connections says something different from a
26710
+ * plane with no connections at all.
26468
26711
  */
26469
26712
  wsConnections: number$1(),
26713
+ /**
26714
+ * Client frames the WS plane looked at. `wsMessages` far above
26715
+ * `planes.ws + subscriptions` means most traffic is not operations
26716
+ * (keepalives, connection params) - which is itself an answer.
26717
+ */
26718
+ wsMessages: number$1(),
26719
+ /**
26720
+ * Subscription STARTS across every plane, excluded from `procedureCalls` on
26721
+ * purpose: one live-events stream opened at boot and held for six hours is
26722
+ * one subscription, and counting it as a call would let a quiet plane
26723
+ * masquerade as the storm.
26724
+ */
26725
+ subscriptions: number$1(),
26726
+ /** `subscription.stop` frames. Starts minus stops is what is still open. */
26727
+ subscriptionStops: number$1(),
26470
26728
  distinctGroups: number$1(),
26471
- /** Calls counted in the totals whose group attribution was shed at the
26472
- * cardinality bound. */
26729
+ /**
26730
+ * Operations counted in the totals whose CALLER attribution was shed at the
26731
+ * cardinality bound. Unrelated to the `unknown` PLANE: these calls know
26732
+ * which transport they arrived on, they just lost their group row.
26733
+ */
26473
26734
  unattributedCalls: number$1(),
26474
26735
  procedures: array(RequestCensusProcedureSchema).readonly(),
26475
26736
  groups: array(RequestCensusGroupSchema).readonly()
@@ -26492,10 +26753,11 @@ var DiagnosticIdSchema = _enum(["request-census"]);
26492
26753
  * The layers of the level hierarchy, general → specific. The most specific
26493
26754
  * layer that carries an explicit value wins.
26494
26755
  *
26495
- * `component` is DECLARED and not yet resolvable: the per-component channels
26496
- * are a later slice of the same plan, and a `levelSource` enum that has to
26497
- * grow later would force every consumer of this document to change with it.
26498
- * Nothing returns `component` today.
26756
+ * `component` became RESOLVABLE on 2026-08-27: a component is a declared log
26757
+ * CHANNEL (`stream-broker.webrtc`, `provider-reolink.baichuan`), named by
26758
+ * `scopeComponent`. It was declared-but-dark in the first slice precisely so
26759
+ * that turning it on would not force every consumer of this document to widen
26760
+ * a `levelSource` enum — which is what has now not happened.
26499
26761
  */
26500
26762
  var LoggingScopeKindSchema = _enum([
26501
26763
  "cluster",
@@ -26522,6 +26784,14 @@ var LoggingLevelLayerSchema = object({
26522
26784
  scope: LoggingScopeKindSchema,
26523
26785
  /** The node this layer speaks for; `null` on the cluster layer. */
26524
26786
  nodeId: string().nullable(),
26787
+ /**
26788
+ * The declared channel this layer speaks for; `null` on every layer but
26789
+ * `component`. Never folded into `nodeId`: a component level is CLUSTER-WIDE
26790
+ * by design — the convention this repo settled on is one orchestrator-wide
26791
+ * setting, never per node (D52) — so a component layer that carried a node
26792
+ * would invite a per-node copy of a value that has no per-node meaning.
26793
+ */
26794
+ component: string().nullable(),
26525
26795
  /** Explicitly set here, or `null` when this layer inherits. */
26526
26796
  level: LogLevelSchema$1.nullable()
26527
26797
  });
@@ -26563,6 +26833,49 @@ var DiagnosticWindowPatchSchema = object({
26563
26833
  reportEveryMs: number$1().int().positive().optional()
26564
26834
  });
26565
26835
  /**
26836
+ * A channel ARMED, as the document reports it.
26837
+ *
26838
+ * `armMs` is not echoed back: what an operator needs to see is the deadline
26839
+ * and the time left, because a diagnostic left running is itself an incident
26840
+ * and "armed for 10 minutes" said an hour ago is not an answer.
26841
+ */
26842
+ var LogChannelWindowStateSchema = object({
26843
+ channel: string(),
26844
+ armed: boolean(),
26845
+ /** Epoch ms the window closes at. 0 when disarmed. */
26846
+ armedUntilMs: number$1(),
26847
+ /** Ms left before it expires on its own. 0 when disarmed. */
26848
+ remainingMs: number$1(),
26849
+ /**
26850
+ * The cameras it is narrowed to, or `null` for every camera.
26851
+ *
26852
+ * A channel declared `perDevice: false` can only ever report `null` here:
26853
+ * its lines do not carry `tags: { deviceId }`, so narrowing them would
26854
+ * produce a filter that silently matches nothing. The server REFUSES such a
26855
+ * patch rather than quietly widening it — ignoring the request would teach
26856
+ * the operator that per-camera filtering works on that channel when it does
26857
+ * not.
26858
+ */
26859
+ deviceIds: array(number$1().int()).readonly().nullable()
26860
+ });
26861
+ /**
26862
+ * `armMs: 0` DISARMS. Same grammar as {@link DiagnosticWindowPatchSchema}, and
26863
+ * for the same reason: a channel is a window with a deadline, never a switch.
26864
+ */
26865
+ var LogChannelWindowPatchSchema = object({
26866
+ channel: string().min(1),
26867
+ armMs: number$1().int().min(0),
26868
+ /**
26869
+ * Narrow to these numeric device ids. Absent or `null` = every camera.
26870
+ *
26871
+ * Numeric because the repo's own rule makes it possible: every log line
26872
+ * about a device carries `tags: { deviceId }` with the numeric id. That rule
26873
+ * was paid for with a 22% thumbnail gap and a 3-hour media blackout both
26874
+ * diagnosed by hand, and this is the first thing that collects on it.
26875
+ */
26876
+ deviceIds: array(number$1().int()).readonly().nullable().optional()
26877
+ });
26878
+ /**
26566
26879
  * A PATCH, and patches MERGE.
26567
26880
  *
26568
26881
  * A field absent from the patch is left exactly as it was — arming a
@@ -26581,7 +26894,14 @@ var LoggingSettingsPatchSchema = object({
26581
26894
  * Only the diagnostics NAMED here change. An armed window that is not listed
26582
26895
  * keeps running — a patch is never a full replacement.
26583
26896
  */
26584
- diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional()
26897
+ diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional(),
26898
+ /**
26899
+ * Only the channels NAMED here change. An armed channel that is not listed
26900
+ * keeps running — same rule as `diagnostics`, because a patch that silently
26901
+ * disarmed the channels it did not mention would make the Levels page and
26902
+ * the Diagnostics page fight over the same value.
26903
+ */
26904
+ channels: array(LogChannelWindowPatchSchema).readonly().optional()
26585
26905
  });
26586
26906
  /**
26587
26907
  * Which LAYER of the hierarchy is addressed. Absent = the cluster layer.
@@ -26594,9 +26914,22 @@ var LoggingSettingsPatchSchema = object({
26594
26914
  * authority over the whole hierarchy and answers for every layer, so the
26595
26915
  * layer selector needs a name the transport does not already own.
26596
26916
  */
26597
- var GetLoggingSettingsInputSchema = object({ scopeNodeId: string().optional() });
26917
+ var GetLoggingSettingsInputSchema = object({
26918
+ scopeNodeId: string().optional(),
26919
+ /**
26920
+ * The declared CHANNEL this document is addressed at, when the caller wants
26921
+ * the `component` layer. Absent = the node/cluster hierarchy only.
26922
+ *
26923
+ * Naming it separately rather than overloading `scopeNodeId` keeps the two
26924
+ * axes from collapsing: a component level is cluster-wide, a node level is
26925
+ * not, and one selector for both would make "which of these two did I just
26926
+ * set" unanswerable — the exact ambiguity `explicit` exists to remove.
26927
+ */
26928
+ scopeComponent: string().optional()
26929
+ });
26598
26930
  var SetLoggingSettingsInputSchema = object({
26599
26931
  scopeNodeId: string().optional(),
26932
+ scopeComponent: string().optional(),
26600
26933
  patch: LoggingSettingsPatchSchema
26601
26934
  });
26602
26935
  /**
@@ -26611,9 +26944,20 @@ var SetLoggingSettingsInputSchema = object({
26611
26944
  var LoggingSettingsStateSchema = object({
26612
26945
  /** The layer this document was read at. `null` = the cluster layer. */
26613
26946
  scopeNodeId: string().nullable(),
26947
+ /** The channel this document was read at. `null` = no component layer. */
26948
+ scopeComponent: string().nullable(),
26614
26949
  effective: LoggingEffectiveSchema,
26615
26950
  explicit: LoggingExplicitSchema,
26616
26951
  activeWindows: array(DiagnosticWindowSchema).readonly(),
26952
+ /**
26953
+ * Every channel the cluster's addons DECLARE, gathered from the
26954
+ * `log-channels` providers. Not stored anywhere: assembled per read, so a
26955
+ * channel added by a redeployed addon appears without anybody editing a
26956
+ * list, and a channel whose addon is gone stops being offered.
26957
+ */
26958
+ channels: array(LogChannelDescriptorSchema).readonly(),
26959
+ /** The channels ARMED right now, each with its deadline. */
26960
+ activeChannels: array(LogChannelWindowStateSchema).readonly(),
26617
26961
  persisted: boolean()
26618
26962
  });
26619
26963
  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(), {
@@ -28190,6 +28534,12 @@ Object.freeze({
28190
28534
  addonId: null,
28191
28535
  access: "view"
28192
28536
  },
28537
+ "dataStoreProvider.aggregate": {
28538
+ capName: "data-store-provider",
28539
+ capScope: "system",
28540
+ addonId: null,
28541
+ access: "view"
28542
+ },
28193
28543
  "dataStoreProvider.count": {
28194
28544
  capName: "data-store-provider",
28195
28545
  capScope: "system",
@@ -28604,6 +28954,12 @@ Object.freeze({
28604
28954
  addonId: null,
28605
28955
  access: "view"
28606
28956
  },
28957
+ "deviceManager.getChildrenBatch": {
28958
+ capName: "device-manager",
28959
+ capScope: "system",
28960
+ addonId: null,
28961
+ access: "view"
28962
+ },
28607
28963
  "deviceManager.getConfigSchema": {
28608
28964
  capName: "device-manager",
28609
28965
  capScope: "system",
@@ -29654,6 +30010,18 @@ Object.freeze({
29654
30010
  addonId: null,
29655
30011
  access: "create"
29656
30012
  },
30013
+ "logChannels.apply": {
30014
+ capName: "log-channels",
30015
+ capScope: "system",
30016
+ addonId: null,
30017
+ access: "create"
30018
+ },
30019
+ "logChannels.list": {
30020
+ capName: "log-channels",
30021
+ capScope: "system",
30022
+ addonId: null,
30023
+ access: "view"
30024
+ },
29657
30025
  "logDestination.query": {
29658
30026
  capName: "log-destination",
29659
30027
  capScope: "system",
@@ -31808,6 +32176,12 @@ Object.freeze({
31808
32176
  addonId: null,
31809
32177
  access: "create"
31810
32178
  },
32179
+ "settingsStore.aggregate": {
32180
+ capName: "settings-store",
32181
+ capScope: "system",
32182
+ addonId: null,
32183
+ access: "view"
32184
+ },
31811
32185
  "settingsStore.count": {
31812
32186
  capName: "settings-store",
31813
32187
  capScope: "system",
@@ -33387,6 +33761,11 @@ Object.freeze({
33387
33761
  form: "single",
33388
33762
  optional: false
33389
33763
  }],
33764
+ "deviceManager.getChildrenBatch": [{
33765
+ name: "parentDeviceIds",
33766
+ form: "array",
33767
+ optional: false
33768
+ }],
33390
33769
  "deviceManager.getConfigSchema": [{
33391
33770
  name: "deviceId",
33392
33771
  form: "single",
package/dist/addon.mjs CHANGED
@@ -7700,6 +7700,111 @@ var CameraSwitchGroupSchema = object({
7700
7700
  fetchedAt: number$1()
7701
7701
  });
7702
7702
  /**
7703
+ * Per-component log CHANNELS — the gate a hot path consults, and the registry
7704
+ * an addon declares its channels in.
7705
+ *
7706
+ * ## Two axes, deliberately separated
7707
+ *
7708
+ * - **DECLARATION** — which channels exist. Only the addon knows:
7709
+ * `stream-broker` knows webrtc/ICE/RTP, `provider-reolink` knows
7710
+ * baichuan/handshake. A hand-wired central list rots at the first addition,
7711
+ * and rots silently. So a channel is declared where it is consulted, and the
7712
+ * `log-channels` capability enumerates the declarations.
7713
+ * - **VALUE** — at which level, for which scope, until when. That stays ONE
7714
+ * thing: the logging settings document on the `system` cap. Two authorities
7715
+ * over the values is the exact defect
7716
+ * `docs/design/plans/2026-08-26-logging-per-componente.md` was written to
7717
+ * remove; re-introducing it from the cure side would be grotesque.
7718
+ *
7719
+ * Nothing in this file reads a clock, an env var or a store. The registry is
7720
+ * a MIRROR: it is moved only by {@link LogChannelRegistry.apply}, called off
7721
+ * the hot path with a value somebody actually read, and by
7722
+ * {@link LogChannelRegistry.tick}, called on a timer. A store read that fails
7723
+ * never reaches here, so it can neither disarm an armed channel nor arm a
7724
+ * disarmed one (D49).
7725
+ *
7726
+ * ## The canonical call shape
7727
+ *
7728
+ * ```ts
7729
+ * if (CH_RTP.on && CH_RTP.wants(deviceId)) {
7730
+ * CH_RTP.log(logger, 'rtp subscriber added', { tags: { deviceId }, meta: { ssrc } })
7731
+ * }
7732
+ * ```
7733
+ *
7734
+ * `on` is a plain boolean FIELD — never a getter — and it is the FIRST thing
7735
+ * read. Disarmed, a call site costs one load and one branch, and the `extras`
7736
+ * object literal is never constructed because it lives inside the branch. It
7737
+ * is the same shape already proven in production at `stream-broker.ts:1650`,
7738
+ * and the same discipline `LoggingGate.allowsDestination` uses for the
7739
+ * destination floor (measured at 1.93 ns/call when off).
7740
+ *
7741
+ * ## Why a channel emits at `info`
7742
+ *
7743
+ * `loki-logging.addon.ts` pins the destination default at `info` and
7744
+ * `loki-destination.ts` drops everything below it, so a line emitted at
7745
+ * `debug` never reaches Loki and the hub's in-memory ring only holds ~35
7746
+ * minutes. A diagnostic that cannot be read an hour later is worse than no
7747
+ * diagnostic, because it looks done. {@link LogChannelGate.log} therefore
7748
+ * emits at the channel's declared level, whose schema floor is `info`.
7749
+ */
7750
+ /**
7751
+ * The level a channel writes at once armed.
7752
+ *
7753
+ * `debug` is absent ON PURPOSE and not by omission: below `info` the line does
7754
+ * not leave the process for Loki, and the whole point of arming a channel is
7755
+ * to read it later.
7756
+ */
7757
+ var LogChannelLevelSchema = _enum([
7758
+ "info",
7759
+ "warn",
7760
+ "error"
7761
+ ]);
7762
+ /**
7763
+ * What an addon declares about one channel. No value, no state — a
7764
+ * declaration is inert.
7765
+ */
7766
+ var LogChannelDescriptorSchema = object({
7767
+ /**
7768
+ * Dotted `area.thing`, unique across the workspace. `area` is conventionally
7769
+ * the addon's short name so an operator reading a channel list can tell who
7770
+ * owns it without a second lookup.
7771
+ */
7772
+ name: string().min(3).regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/, "a channel name is dotted lower-kebab, e.g. area.thing"),
7773
+ /** One sentence: what the operator will SEE after arming it. */
7774
+ description: string().min(1),
7775
+ /** The level its lines are emitted at. Never below `info`. */
7776
+ defaultLevel: LogChannelLevelSchema,
7777
+ /**
7778
+ * Whether this channel can be narrowed to a camera.
7779
+ *
7780
+ * `true` is a PROMISE with two halves, and both must hold: the gate is
7781
+ * consulted with the numeric device id, AND every line the channel admits
7782
+ * carries `tags: { deviceId }` with that same numeric id. The second half is
7783
+ * what makes `| json | deviceId="617"` work in Loki — `loki-payload.ts`
7784
+ * keeps `deviceId` out of the stream labels for cardinality, so the tag in
7785
+ * the body is the only way to filter.
7786
+ *
7787
+ * A channel whose lines carry the device only in `meta` (or not at all) is
7788
+ * declared `false`. Declaring it `true` anyway would be a lie the UI repeats:
7789
+ * the operator narrows to one camera, sees nothing, and concludes the code
7790
+ * path was never taken.
7791
+ */
7792
+ perDevice: boolean()
7793
+ });
7794
+ /**
7795
+ * An armed window over one channel, as the document hands it to a mirror.
7796
+ *
7797
+ * A window is a DEADLINE, never a flag (ADR-0244): a channel somebody forgot
7798
+ * expires by itself, which is the one failure a boolean cannot avoid.
7799
+ */
7800
+ var LogChannelWindowSchema = object({
7801
+ channel: string().min(1),
7802
+ /** Epoch ms the window closes at. */
7803
+ armedUntilMs: number$1(),
7804
+ /** `null` = every camera. A non-empty list narrows to those numeric ids. */
7805
+ deviceIds: array(number$1().int()).readonly().nullable()
7806
+ });
7807
+ /**
7703
7808
  * Ops-log — the durable, append-only operations audit shared by the
7704
7809
  * recordings and events management surfaces.
7705
7810
  *
@@ -11218,6 +11323,35 @@ var MutationFilterSchema = object({
11218
11323
  whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11219
11324
  whereNot: record(string(), unknown()).optional()
11220
11325
  });
11326
+ /**
11327
+ * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
11328
+ *
11329
+ * `as` names the slot in the result, so the SAME column may be asked twice with
11330
+ * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
11331
+ * a `Record<column, op>` shape could not express.
11332
+ */
11333
+ var AggregateFieldSchema = object({
11334
+ /** Result key. */
11335
+ as: string().min(1),
11336
+ /** Column to aggregate. Must be a real column of a declared collection. */
11337
+ field: string().min(1),
11338
+ op: _enum([
11339
+ "sum",
11340
+ "min",
11341
+ "max"
11342
+ ])
11343
+ });
11344
+ /**
11345
+ * `COUNT(*)` plus one number per requested field.
11346
+ *
11347
+ * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
11348
+ * that really is 0 are different facts, and an accounting caller that renders
11349
+ * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
11350
+ */
11351
+ var AggregateResultSchema = object({
11352
+ count: number$1().int(),
11353
+ values: record(string(), number$1().nullable())
11354
+ });
11221
11355
  /** A single stored record: `{ id, data }`. */
11222
11356
  var SettingsRecordSchema = object({
11223
11357
  id: string(),
@@ -11302,6 +11436,11 @@ method(object({
11302
11436
  collection: string(),
11303
11437
  filter: QueryFilterSchema.optional()
11304
11438
  }), number$1()), method(object({
11439
+ namespace: string().optional(),
11440
+ collection: string(),
11441
+ fields: array(AggregateFieldSchema).readonly(),
11442
+ filter: QueryFilterSchema.optional()
11443
+ }), AggregateResultSchema), method(object({
11305
11444
  namespace: string().optional(),
11306
11445
  collection: string(),
11307
11446
  field: string(),
@@ -11418,6 +11557,11 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11418
11557
  collection: string(),
11419
11558
  filter: QueryFilterSchema.optional()
11420
11559
  }), number$1(), { auth: "admin" }), method(object({
11560
+ namespace: string().optional(),
11561
+ collection: string(),
11562
+ fields: array(AggregateFieldSchema).readonly(),
11563
+ filter: QueryFilterSchema.optional()
11564
+ }), AggregateResultSchema, { auth: "admin" }), method(object({
11421
11565
  namespace: string().optional(),
11422
11566
  collection: string(),
11423
11567
  field: string(),
@@ -11979,24 +12123,6 @@ method(_void(), _void(), { kind: "mutation" }), method(_void(), _void(), { kind:
11979
12123
  kind: "mutation",
11980
12124
  auth: "admin"
11981
12125
  });
11982
- /**
11983
- * Device Manager capability — hub-side singleton that unifies device persistence,
11984
- * live registry access, and all management operations into a single tRPC surface.
11985
- *
11986
- * Replaces:
11987
- * - `device-persistence` capability (persistence methods absorbed here)
11988
- * - `device-management.router.ts` (deleted in Phase 2)
11989
- * - `device-ops.router.ts` (compat layer — deleted; device-provider ops absorbed here)
11990
- *
11991
- * All device provider addons (rtsp, onvif, frigate, …) are hub-local: they may
11992
- * fork into separate processes but never run on remote cluster agents. Therefore:
11993
- * - No nodeId routing needed — this is a pure hub singleton.
11994
- * - The hub's DeviceRegistry is the single source of truth for all live devices.
11995
- * - No shadow registry or cross-node aggregation required.
11996
- *
11997
- * Forked workers register devices back to the hub via `ctx.devices`
11998
- * (DeviceManagerApi → ctx.api.deviceManager.registerDevice), same as today.
11999
- */
12000
12126
  /** One child-placement directive on a container's `childLayout`. Structurally
12001
12127
  * identical to `ChildLayoutEntry` in `device-management.ts` — the cap wire
12002
12128
  * shape for the same field. The child is identified by its re-sync-stable
@@ -12365,7 +12491,7 @@ method(object({
12365
12491
  * it answers today and the caller filters as it already does.
12366
12492
  */
12367
12493
  deviceIds: array(number$1()).optional()
12368
- }), array(DeviceInfoSchema)), method(object({ deviceId: number$1() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number$1() }), array(DeviceInfoSchema)), method(object({ deviceId: number$1() }), object({
12494
+ }), array(DeviceInfoSchema)), method(object({ deviceId: number$1() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number$1() }), array(DeviceInfoSchema)), method(object({ parentDeviceIds: array(number$1()).max(256) }), record(string(), array(DeviceInfoSchema))), method(object({ deviceId: number$1() }), object({
12369
12495
  mode: LinkedDevicesModeSchema,
12370
12496
  devices: array(LinkedDeviceSchema)
12371
12497
  })), method(object({ deviceIds: array(number$1()) }), array(LinkedDevicesForDeviceSchema)), method(object({ deviceId: number$1() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number$1() }), array(ConfigEntrySchema)), method(object({ deviceId: number$1() }), ConfigUISchemaOutput), method(object({
@@ -13183,6 +13309,59 @@ var llmCapability = {
13183
13309
  })
13184
13310
  }
13185
13311
  };
13312
+ /**
13313
+ * `log-channels` — the capability an addon DECLARES its diagnostic channels
13314
+ * through. It stores nothing.
13315
+ *
13316
+ * ## Why a capability at all, and why this shape
13317
+ *
13318
+ * Which channels exist is knowledge only the addon has: `stream-broker` knows
13319
+ * webrtc/ICE/RTP, `provider-reolink` knows baichuan/handshake. A central list
13320
+ * maintained by hand rots at the first addition and rots INVISIBLY — nothing
13321
+ * fails, an operator just never sees the channel somebody added. So the list
13322
+ * is assembled from declarations at runtime.
13323
+ *
13324
+ * The shape is copied from `log-destination.cap.ts`, which already does
13325
+ * exactly this job: `mode: 'collection'`, `internal: true`,
13326
+ * `mount: { kind: 'skip' }` — no tRPC route, no generated hooks — while
13327
+ * `addons.listCapabilityProviders` still enumerates it, and the hub's
13328
+ * `CapabilityRegistry` still holds an RPC proxy per provider so a forked
13329
+ * runner's declarations reach hub-main over the transport that already exists.
13330
+ * No new UDS message, no second registry.
13331
+ *
13332
+ * ## What it deliberately does NOT own
13333
+ *
13334
+ * The VALUES — which channel is armed, for which cameras, until when — live in
13335
+ * ONE place: the logging settings document on the `system` cap
13336
+ * (`getLoggingSettings` / `setLoggingSettings`). Two authorities over the same
13337
+ * value is the defect the plan behind this work exists to remove, and
13338
+ * `setRequestCensus` was retired (D245) rather than allowed to be a second
13339
+ * one. {@link logChannelsCapability} therefore has no getter for a level, no
13340
+ * setter for a window and no persistence of any kind.
13341
+ *
13342
+ * ## Why `apply` is here even so
13343
+ *
13344
+ * The gate lives in the addon's PROCESS; the document lives in hub-main. Some
13345
+ * seam has to carry the value from the authority to the mirror, and a channel
13346
+ * that cannot be reached is precisely the dead knob this whole slice exists to
13347
+ * make impossible (D62 — `audioThresholdDbfs`, the HA entities with no source).
13348
+ * `apply` is that seam and nothing more: it writes an in-memory mirror, it
13349
+ * persists nothing, it is never the source of a value, and it is called only
13350
+ * with a set the hub actually read (D49 — a read that fails does not call it
13351
+ * at all, so no channel is silently disarmed by a bad read).
13352
+ */
13353
+ /** What `apply` reports back — enough to log, not enough to be a second state. */
13354
+ var LogChannelApplyResultSchema = object({
13355
+ /** How many declared channels are armed in this process after the call. */
13356
+ armed: number$1().int().min(0),
13357
+ /**
13358
+ * Names the document armed that this process does not declare. Reported
13359
+ * rather than swallowed: a name here is either a typo or an addon that has
13360
+ * not booted, and both deserve a line instead of silence.
13361
+ */
13362
+ unknown: array(string()).readonly()
13363
+ });
13364
+ method(_void(), array(LogChannelDescriptorSchema).readonly()), method(object({ windows: array(LogChannelWindowSchema).readonly() }), LogChannelApplyResultSchema, { kind: "mutation" });
13186
13365
  var LogLevelSchema = _enum([
13187
13366
  "debug",
13188
13367
  "info",
@@ -26438,17 +26617,60 @@ var SetSiteLocationInputSchema = object({
26438
26617
  longitude: number$1().min(-180).max(180)
26439
26618
  }).nullable();
26440
26619
  /**
26441
- * One `(procedure, user-agent, ip, principal)` tuple of the HTTP request
26620
+ * The TRANSPORT a call arrived on.
26621
+ *
26622
+ * Every counted call carries exactly one of these, and `unknown` is a PLANE
26623
+ * rather than a gap: a plane that cannot attribute a call declares it here, so
26624
+ * the call lands in a named bucket instead of vanishing. `planes` summing to
26625
+ * `procedureCalls` is what makes "the sum of the planes explains the total"
26626
+ * checkable rather than asserted.
26627
+ *
26628
+ * - `http` — the Fastify tRPC plugin (`/trpc/*`), one context per request.
26629
+ * - `ws` — `applyWSSHandler`, counted per OPERATION rather than per
26630
+ * connection; the viewer talks to the hub over `wsLink`
26631
+ * exclusively, so this is the plane the HTTP census could not see.
26632
+ * - `mesh` — the in-process `$core-caps` bridge (`createCaller`), which
26633
+ * never touches a socket and therefore never touched a census.
26634
+ * - `unknown` — counted, plane undecidable. No hook produces it today, and
26635
+ * that is exactly what its `0` asserts: every plane the hub has can name
26636
+ * itself. It is an output bucket, never a knob — a call that arrives on a
26637
+ * plane nobody instrumented lands here instead of vanishing from the total.
26638
+ */
26639
+ var TransportPlaneSchema = _enum([
26640
+ "http",
26641
+ "ws",
26642
+ "mesh",
26643
+ "unknown"
26644
+ ]);
26645
+ /**
26646
+ * Calls per plane. Every key is always present, `0` included — an absent plane
26647
+ * reads as "not instrumented", which is the one thing this census must never
26648
+ * make an operator wonder about.
26649
+ */
26650
+ var TransportPlaneCountsSchema = object({
26651
+ http: number$1(),
26652
+ ws: number$1(),
26653
+ mesh: number$1(),
26654
+ unknown: number$1()
26655
+ });
26656
+ /**
26657
+ * One `(plane, procedure, user-agent, ip, principal)` tuple of the transport
26442
26658
  * census. `principal` is the DERIVED identity (`apocaliss92 (admin)`,
26443
26659
  * `scoped:1a2b3c4d (scoped-token)`, `anonymous`) that the tRPC error log
26444
26660
  * already prints - never a token, never an `Authorization` header.
26661
+ *
26662
+ * `subscriptions` is counted APART from `calls`: a subscription is opened once
26663
+ * and lives for hours, so folding it into a call count makes one long-lived
26664
+ * stream look like a storm.
26445
26665
  */
26446
26666
  var RequestCensusGroupSchema = object({
26667
+ plane: TransportPlaneSchema,
26447
26668
  procedure: string(),
26448
26669
  userAgent: string(),
26449
26670
  ip: string(),
26450
26671
  principal: string(),
26451
26672
  calls: number$1(),
26673
+ subscriptions: number$1(),
26452
26674
  perMin: number$1()
26453
26675
  });
26454
26676
  /**
@@ -26461,6 +26683,14 @@ var RequestCensusGroupSchema = object({
26461
26683
  var RequestCensusProcedureSchema = object({
26462
26684
  procedure: string(),
26463
26685
  calls: number$1(),
26686
+ /**
26687
+ * The same total, split by transport. THIS is the row that answers the
26688
+ * question the census exists for: one look at `deviceManager.listAll` says
26689
+ * which plane carried the 4 960, without joining two log lines by eye.
26690
+ */
26691
+ planes: TransportPlaneCountsSchema,
26692
+ /** Subscription STARTS on this procedure. Never folded into `calls`. */
26693
+ subscriptions: number$1(),
26464
26694
  perMin: number$1()
26465
26695
  });
26466
26696
  /**
@@ -26488,14 +26718,45 @@ var RequestCensusStatusSchema = object({
26488
26718
  */
26489
26719
  procedureCalls: number$1(),
26490
26720
  /**
26721
+ * `procedureCalls` split by transport. The four keys sum to
26722
+ * `procedureCalls` by construction - {@link RequestCensusSnapshotSchema}'s
26723
+ * `planesExplainTotal` is that identity, checked rather than assumed.
26724
+ */
26725
+ planes: TransportPlaneCountsSchema,
26726
+ /**
26727
+ * True iff `planes` sums to `procedureCalls`. False means a call was counted
26728
+ * on no plane at all - which is a RESULT (a plane is missing from the
26729
+ * instrument), not a failure, and it has to be visible to be read as one.
26730
+ */
26731
+ planesExplainTotal: boolean(),
26732
+ /**
26491
26733
  * tRPC WebSocket connections opened during the window. NOT calls - the WS
26492
- * transport resolves one context per connection - but the number that says
26493
- * whether a plane this census cannot see was busy while HTTP was quiet.
26734
+ * adapter resolves one context per connection - kept because a plane's call
26735
+ * count of zero against 37 open connections says something different from a
26736
+ * plane with no connections at all.
26494
26737
  */
26495
26738
  wsConnections: number$1(),
26739
+ /**
26740
+ * Client frames the WS plane looked at. `wsMessages` far above
26741
+ * `planes.ws + subscriptions` means most traffic is not operations
26742
+ * (keepalives, connection params) - which is itself an answer.
26743
+ */
26744
+ wsMessages: number$1(),
26745
+ /**
26746
+ * Subscription STARTS across every plane, excluded from `procedureCalls` on
26747
+ * purpose: one live-events stream opened at boot and held for six hours is
26748
+ * one subscription, and counting it as a call would let a quiet plane
26749
+ * masquerade as the storm.
26750
+ */
26751
+ subscriptions: number$1(),
26752
+ /** `subscription.stop` frames. Starts minus stops is what is still open. */
26753
+ subscriptionStops: number$1(),
26496
26754
  distinctGroups: number$1(),
26497
- /** Calls counted in the totals whose group attribution was shed at the
26498
- * cardinality bound. */
26755
+ /**
26756
+ * Operations counted in the totals whose CALLER attribution was shed at the
26757
+ * cardinality bound. Unrelated to the `unknown` PLANE: these calls know
26758
+ * which transport they arrived on, they just lost their group row.
26759
+ */
26499
26760
  unattributedCalls: number$1(),
26500
26761
  procedures: array(RequestCensusProcedureSchema).readonly(),
26501
26762
  groups: array(RequestCensusGroupSchema).readonly()
@@ -26518,10 +26779,11 @@ var DiagnosticIdSchema = _enum(["request-census"]);
26518
26779
  * The layers of the level hierarchy, general → specific. The most specific
26519
26780
  * layer that carries an explicit value wins.
26520
26781
  *
26521
- * `component` is DECLARED and not yet resolvable: the per-component channels
26522
- * are a later slice of the same plan, and a `levelSource` enum that has to
26523
- * grow later would force every consumer of this document to change with it.
26524
- * Nothing returns `component` today.
26782
+ * `component` became RESOLVABLE on 2026-08-27: a component is a declared log
26783
+ * CHANNEL (`stream-broker.webrtc`, `provider-reolink.baichuan`), named by
26784
+ * `scopeComponent`. It was declared-but-dark in the first slice precisely so
26785
+ * that turning it on would not force every consumer of this document to widen
26786
+ * a `levelSource` enum — which is what has now not happened.
26525
26787
  */
26526
26788
  var LoggingScopeKindSchema = _enum([
26527
26789
  "cluster",
@@ -26548,6 +26810,14 @@ var LoggingLevelLayerSchema = object({
26548
26810
  scope: LoggingScopeKindSchema,
26549
26811
  /** The node this layer speaks for; `null` on the cluster layer. */
26550
26812
  nodeId: string().nullable(),
26813
+ /**
26814
+ * The declared channel this layer speaks for; `null` on every layer but
26815
+ * `component`. Never folded into `nodeId`: a component level is CLUSTER-WIDE
26816
+ * by design — the convention this repo settled on is one orchestrator-wide
26817
+ * setting, never per node (D52) — so a component layer that carried a node
26818
+ * would invite a per-node copy of a value that has no per-node meaning.
26819
+ */
26820
+ component: string().nullable(),
26551
26821
  /** Explicitly set here, or `null` when this layer inherits. */
26552
26822
  level: LogLevelSchema$1.nullable()
26553
26823
  });
@@ -26589,6 +26859,49 @@ var DiagnosticWindowPatchSchema = object({
26589
26859
  reportEveryMs: number$1().int().positive().optional()
26590
26860
  });
26591
26861
  /**
26862
+ * A channel ARMED, as the document reports it.
26863
+ *
26864
+ * `armMs` is not echoed back: what an operator needs to see is the deadline
26865
+ * and the time left, because a diagnostic left running is itself an incident
26866
+ * and "armed for 10 minutes" said an hour ago is not an answer.
26867
+ */
26868
+ var LogChannelWindowStateSchema = object({
26869
+ channel: string(),
26870
+ armed: boolean(),
26871
+ /** Epoch ms the window closes at. 0 when disarmed. */
26872
+ armedUntilMs: number$1(),
26873
+ /** Ms left before it expires on its own. 0 when disarmed. */
26874
+ remainingMs: number$1(),
26875
+ /**
26876
+ * The cameras it is narrowed to, or `null` for every camera.
26877
+ *
26878
+ * A channel declared `perDevice: false` can only ever report `null` here:
26879
+ * its lines do not carry `tags: { deviceId }`, so narrowing them would
26880
+ * produce a filter that silently matches nothing. The server REFUSES such a
26881
+ * patch rather than quietly widening it — ignoring the request would teach
26882
+ * the operator that per-camera filtering works on that channel when it does
26883
+ * not.
26884
+ */
26885
+ deviceIds: array(number$1().int()).readonly().nullable()
26886
+ });
26887
+ /**
26888
+ * `armMs: 0` DISARMS. Same grammar as {@link DiagnosticWindowPatchSchema}, and
26889
+ * for the same reason: a channel is a window with a deadline, never a switch.
26890
+ */
26891
+ var LogChannelWindowPatchSchema = object({
26892
+ channel: string().min(1),
26893
+ armMs: number$1().int().min(0),
26894
+ /**
26895
+ * Narrow to these numeric device ids. Absent or `null` = every camera.
26896
+ *
26897
+ * Numeric because the repo's own rule makes it possible: every log line
26898
+ * about a device carries `tags: { deviceId }` with the numeric id. That rule
26899
+ * was paid for with a 22% thumbnail gap and a 3-hour media blackout both
26900
+ * diagnosed by hand, and this is the first thing that collects on it.
26901
+ */
26902
+ deviceIds: array(number$1().int()).readonly().nullable().optional()
26903
+ });
26904
+ /**
26592
26905
  * A PATCH, and patches MERGE.
26593
26906
  *
26594
26907
  * A field absent from the patch is left exactly as it was — arming a
@@ -26607,7 +26920,14 @@ var LoggingSettingsPatchSchema = object({
26607
26920
  * Only the diagnostics NAMED here change. An armed window that is not listed
26608
26921
  * keeps running — a patch is never a full replacement.
26609
26922
  */
26610
- diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional()
26923
+ diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional(),
26924
+ /**
26925
+ * Only the channels NAMED here change. An armed channel that is not listed
26926
+ * keeps running — same rule as `diagnostics`, because a patch that silently
26927
+ * disarmed the channels it did not mention would make the Levels page and
26928
+ * the Diagnostics page fight over the same value.
26929
+ */
26930
+ channels: array(LogChannelWindowPatchSchema).readonly().optional()
26611
26931
  });
26612
26932
  /**
26613
26933
  * Which LAYER of the hierarchy is addressed. Absent = the cluster layer.
@@ -26620,9 +26940,22 @@ var LoggingSettingsPatchSchema = object({
26620
26940
  * authority over the whole hierarchy and answers for every layer, so the
26621
26941
  * layer selector needs a name the transport does not already own.
26622
26942
  */
26623
- var GetLoggingSettingsInputSchema = object({ scopeNodeId: string().optional() });
26943
+ var GetLoggingSettingsInputSchema = object({
26944
+ scopeNodeId: string().optional(),
26945
+ /**
26946
+ * The declared CHANNEL this document is addressed at, when the caller wants
26947
+ * the `component` layer. Absent = the node/cluster hierarchy only.
26948
+ *
26949
+ * Naming it separately rather than overloading `scopeNodeId` keeps the two
26950
+ * axes from collapsing: a component level is cluster-wide, a node level is
26951
+ * not, and one selector for both would make "which of these two did I just
26952
+ * set" unanswerable — the exact ambiguity `explicit` exists to remove.
26953
+ */
26954
+ scopeComponent: string().optional()
26955
+ });
26624
26956
  var SetLoggingSettingsInputSchema = object({
26625
26957
  scopeNodeId: string().optional(),
26958
+ scopeComponent: string().optional(),
26626
26959
  patch: LoggingSettingsPatchSchema
26627
26960
  });
26628
26961
  /**
@@ -26637,9 +26970,20 @@ var SetLoggingSettingsInputSchema = object({
26637
26970
  var LoggingSettingsStateSchema = object({
26638
26971
  /** The layer this document was read at. `null` = the cluster layer. */
26639
26972
  scopeNodeId: string().nullable(),
26973
+ /** The channel this document was read at. `null` = no component layer. */
26974
+ scopeComponent: string().nullable(),
26640
26975
  effective: LoggingEffectiveSchema,
26641
26976
  explicit: LoggingExplicitSchema,
26642
26977
  activeWindows: array(DiagnosticWindowSchema).readonly(),
26978
+ /**
26979
+ * Every channel the cluster's addons DECLARE, gathered from the
26980
+ * `log-channels` providers. Not stored anywhere: assembled per read, so a
26981
+ * channel added by a redeployed addon appears without anybody editing a
26982
+ * list, and a channel whose addon is gone stops being offered.
26983
+ */
26984
+ channels: array(LogChannelDescriptorSchema).readonly(),
26985
+ /** The channels ARMED right now, each with its deadline. */
26986
+ activeChannels: array(LogChannelWindowStateSchema).readonly(),
26643
26987
  persisted: boolean()
26644
26988
  });
26645
26989
  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(), {
@@ -28216,6 +28560,12 @@ Object.freeze({
28216
28560
  addonId: null,
28217
28561
  access: "view"
28218
28562
  },
28563
+ "dataStoreProvider.aggregate": {
28564
+ capName: "data-store-provider",
28565
+ capScope: "system",
28566
+ addonId: null,
28567
+ access: "view"
28568
+ },
28219
28569
  "dataStoreProvider.count": {
28220
28570
  capName: "data-store-provider",
28221
28571
  capScope: "system",
@@ -28630,6 +28980,12 @@ Object.freeze({
28630
28980
  addonId: null,
28631
28981
  access: "view"
28632
28982
  },
28983
+ "deviceManager.getChildrenBatch": {
28984
+ capName: "device-manager",
28985
+ capScope: "system",
28986
+ addonId: null,
28987
+ access: "view"
28988
+ },
28633
28989
  "deviceManager.getConfigSchema": {
28634
28990
  capName: "device-manager",
28635
28991
  capScope: "system",
@@ -29680,6 +30036,18 @@ Object.freeze({
29680
30036
  addonId: null,
29681
30037
  access: "create"
29682
30038
  },
30039
+ "logChannels.apply": {
30040
+ capName: "log-channels",
30041
+ capScope: "system",
30042
+ addonId: null,
30043
+ access: "create"
30044
+ },
30045
+ "logChannels.list": {
30046
+ capName: "log-channels",
30047
+ capScope: "system",
30048
+ addonId: null,
30049
+ access: "view"
30050
+ },
29683
30051
  "logDestination.query": {
29684
30052
  capName: "log-destination",
29685
30053
  capScope: "system",
@@ -31834,6 +32202,12 @@ Object.freeze({
31834
32202
  addonId: null,
31835
32203
  access: "create"
31836
32204
  },
32205
+ "settingsStore.aggregate": {
32206
+ capName: "settings-store",
32207
+ capScope: "system",
32208
+ addonId: null,
32209
+ access: "view"
32210
+ },
31837
32211
  "settingsStore.count": {
31838
32212
  capName: "settings-store",
31839
32213
  capScope: "system",
@@ -33413,6 +33787,11 @@ Object.freeze({
33413
33787
  form: "single",
33414
33788
  optional: false
33415
33789
  }],
33790
+ "deviceManager.getChildrenBatch": [{
33791
+ name: "parentDeviceIds",
33792
+ form: "array",
33793
+ optional: false
33794
+ }],
33416
33795
  "deviceManager.getConfigSchema": [{
33417
33796
  name: "deviceId",
33418
33797
  form: "single",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-ai",
3
- "version": "0.4.25",
3
+ "version": "0.4.27",
4
4
  "description": "AI addon for CamStack — the `llm` collection provider (cloud, LAN, and camstack-managed local llama.cpp profiles) plus the per-node `llm-runtime` managed executor.",
5
5
  "keywords": [
6
6
  "camstack",