@camstack/addon-provider-reolink 1.2.54 → 1.2.56

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 +774 -31
  2. package/dist/addon.mjs +774 -31
  3. package/package.json +4 -1
package/dist/addon.mjs CHANGED
@@ -7502,6 +7502,362 @@ var CameraSwitchGroupSchema = object({
7502
7502
  fetchedAt: number()
7503
7503
  });
7504
7504
  /**
7505
+ * Per-component log CHANNELS — the gate a hot path consults, and the registry
7506
+ * an addon declares its channels in.
7507
+ *
7508
+ * ## Two axes, deliberately separated
7509
+ *
7510
+ * - **DECLARATION** — which channels exist. Only the addon knows:
7511
+ * `stream-broker` knows webrtc/ICE/RTP, `provider-reolink` knows
7512
+ * baichuan/handshake. A hand-wired central list rots at the first addition,
7513
+ * and rots silently. So a channel is declared where it is consulted, and the
7514
+ * `log-channels` capability enumerates the declarations.
7515
+ * - **VALUE** — at which level, for which scope, until when. That stays ONE
7516
+ * thing: the logging settings document on the `system` cap. Two authorities
7517
+ * over the values is the exact defect
7518
+ * `docs/design/plans/2026-08-26-logging-per-componente.md` was written to
7519
+ * remove; re-introducing it from the cure side would be grotesque.
7520
+ *
7521
+ * Nothing in this file reads a clock, an env var or a store. The registry is
7522
+ * a MIRROR: it is moved only by {@link LogChannelRegistry.apply}, called off
7523
+ * the hot path with a value somebody actually read, and by
7524
+ * {@link LogChannelRegistry.tick}, called on a timer. A store read that fails
7525
+ * never reaches here, so it can neither disarm an armed channel nor arm a
7526
+ * disarmed one (D49).
7527
+ *
7528
+ * ## The canonical call shape
7529
+ *
7530
+ * ```ts
7531
+ * if (CH_RTP.on && CH_RTP.wants(deviceId)) {
7532
+ * CH_RTP.log(logger, 'rtp subscriber added', { tags: { deviceId }, meta: { ssrc } })
7533
+ * }
7534
+ * ```
7535
+ *
7536
+ * `on` is a plain boolean FIELD — never a getter — and it is the FIRST thing
7537
+ * read. Disarmed, a call site costs one load and one branch, and the `extras`
7538
+ * object literal is never constructed because it lives inside the branch. It
7539
+ * is the same shape already proven in production at `stream-broker.ts:1650`,
7540
+ * and the same discipline `LoggingGate.allowsDestination` uses for the
7541
+ * destination floor (measured at 1.93 ns/call when off).
7542
+ *
7543
+ * ## Why a channel emits at `info`
7544
+ *
7545
+ * `loki-logging.addon.ts` pins the destination default at `info` and
7546
+ * `loki-destination.ts` drops everything below it, so a line emitted at
7547
+ * `debug` never reaches Loki and the hub's in-memory ring only holds ~35
7548
+ * minutes. A diagnostic that cannot be read an hour later is worse than no
7549
+ * diagnostic, because it looks done. {@link LogChannelGate.log} therefore
7550
+ * emits at the channel's declared level, whose schema floor is `info`.
7551
+ */
7552
+ /**
7553
+ * The level a channel writes at once armed.
7554
+ *
7555
+ * `debug` is absent ON PURPOSE and not by omission: below `info` the line does
7556
+ * not leave the process for Loki, and the whole point of arming a channel is
7557
+ * to read it later.
7558
+ */
7559
+ var LogChannelLevelSchema = _enum([
7560
+ "info",
7561
+ "warn",
7562
+ "error"
7563
+ ]);
7564
+ /**
7565
+ * What an addon declares about one channel. No value, no state — a
7566
+ * declaration is inert.
7567
+ */
7568
+ var LogChannelDescriptorSchema = object({
7569
+ /**
7570
+ * Dotted `area.thing`, unique across the workspace. `area` is conventionally
7571
+ * the addon's short name so an operator reading a channel list can tell who
7572
+ * owns it without a second lookup.
7573
+ */
7574
+ name: string().min(3).regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/, "a channel name is dotted lower-kebab, e.g. area.thing"),
7575
+ /** One sentence: what the operator will SEE after arming it. */
7576
+ description: string().min(1),
7577
+ /** The level its lines are emitted at. Never below `info`. */
7578
+ defaultLevel: LogChannelLevelSchema,
7579
+ /**
7580
+ * Whether this channel can be narrowed to a camera.
7581
+ *
7582
+ * `true` is a PROMISE with two halves, and both must hold: the gate is
7583
+ * consulted with the numeric device id, AND every line the channel admits
7584
+ * carries `tags: { deviceId }` with that same numeric id. The second half is
7585
+ * what makes `| json | deviceId="617"` work in Loki — `loki-payload.ts`
7586
+ * keeps `deviceId` out of the stream labels for cardinality, so the tag in
7587
+ * the body is the only way to filter.
7588
+ *
7589
+ * A channel whose lines carry the device only in `meta` (or not at all) is
7590
+ * declared `false`. Declaring it `true` anyway would be a lie the UI repeats:
7591
+ * the operator narrows to one camera, sees nothing, and concludes the code
7592
+ * path was never taken.
7593
+ */
7594
+ perDevice: boolean()
7595
+ });
7596
+ /**
7597
+ * An armed window over one channel, as the document hands it to a mirror.
7598
+ *
7599
+ * A window is a DEADLINE, never a flag (ADR-0244): a channel somebody forgot
7600
+ * expires by itself, which is the one failure a boolean cannot avoid.
7601
+ */
7602
+ var LogChannelWindowSchema = object({
7603
+ channel: string().min(1),
7604
+ /** Epoch ms the window closes at. */
7605
+ armedUntilMs: number(),
7606
+ /** `null` = every camera. A non-empty list narrows to those numeric ids. */
7607
+ deviceIds: array(number().int()).readonly().nullable()
7608
+ });
7609
+ /**
7610
+ * The gate a hot path holds.
7611
+ *
7612
+ * Obtain it ONCE — at module scope or in a constructor — and keep the
7613
+ * reference. Looking a channel up by name per line would put a Map lookup on
7614
+ * the path this class exists to keep free.
7615
+ */
7616
+ var LogChannelGate = class {
7617
+ descriptor;
7618
+ /**
7619
+ * HOT PATH GUARD. A plain data FIELD, and it must stay one.
7620
+ *
7621
+ * `log-channel.spec.ts` asserts the property descriptor has no getter and
7622
+ * booby-traps the device set, so turning this into an accessor — or reading
7623
+ * anything before it — fails the spec instead of taxing every line the
7624
+ * process emits.
7625
+ */
7626
+ on = false;
7627
+ /** `null` while armed for every camera. Never read while `on` is false. */
7628
+ devices = null;
7629
+ level;
7630
+ closesAtMs = 0;
7631
+ constructor(descriptor) {
7632
+ this.descriptor = descriptor;
7633
+ this.level = descriptor.defaultLevel;
7634
+ }
7635
+ /** Epoch ms this channel disarms itself at. 0 when disarmed. */
7636
+ get armedUntilMs() {
7637
+ return this.on ? this.closesAtMs : 0;
7638
+ }
7639
+ /**
7640
+ * Does this channel want a line about `deviceId`?
7641
+ *
7642
+ * Call it only behind `gate.on &&`. On its own it is still correct — the
7643
+ * guard is repeated inside — but the point of the prefix is that a disarmed
7644
+ * channel must not pay the call at all.
7645
+ */
7646
+ wants(deviceId) {
7647
+ if (!this.on) return false;
7648
+ return this.devices === null || this.devices.has(deviceId);
7649
+ }
7650
+ /**
7651
+ * Emit one line on this channel, at the channel's declared level.
7652
+ *
7653
+ * The channel name is added as `tags.logChannel` so LogQL can select the
7654
+ * channel without matching on the message text, and whatever `tags` the
7655
+ * caller passed — `deviceId` above all — is preserved.
7656
+ */
7657
+ log(logger, message, extras) {
7658
+ if (!this.on) return;
7659
+ const tags = {
7660
+ ...extras.tags,
7661
+ logChannel: this.descriptor.name
7662
+ };
7663
+ const line = {
7664
+ ...extras,
7665
+ tags
7666
+ };
7667
+ if (this.level === "error") logger.error(message, line);
7668
+ else if (this.level === "warn") logger.warn(message, line);
7669
+ else logger.info(message, line);
7670
+ }
7671
+ /**
7672
+ * Arm (or RE-arm, restarting) this channel. Off the hot path only.
7673
+ *
7674
+ * An empty `deviceIds` list is treated as "every camera" rather than "no
7675
+ * camera": a window that matches nothing is indistinguishable from a
7676
+ * disarmed one, and the operator who asked for it would wait for lines that
7677
+ * can never come.
7678
+ */
7679
+ arm(window) {
7680
+ const ids = window.deviceIds;
7681
+ this.devices = ids === null || ids.length === 0 ? null : new Set(ids);
7682
+ this.closesAtMs = window.armedUntilMs;
7683
+ this.on = true;
7684
+ }
7685
+ /** Disarm. Off the hot path only. */
7686
+ disarm() {
7687
+ this.on = false;
7688
+ this.devices = null;
7689
+ this.closesAtMs = 0;
7690
+ }
7691
+ };
7692
+ /**
7693
+ * Every channel this PROCESS declares, and the mirror of what is armed on it.
7694
+ *
7695
+ * One per process. A forked runner has its own, and it is refreshed through
7696
+ * the `log-channels` capability by the hub that owns the document — the
7697
+ * registry never reaches for a value itself.
7698
+ */
7699
+ var LogChannelRegistry = class {
7700
+ gates = /* @__PURE__ */ new Map();
7701
+ /**
7702
+ * Declare a channel and get its gate.
7703
+ *
7704
+ * A duplicate name throws. Two declarations of one name is a programming
7705
+ * error, not a merge: the operator would arm one and the other would stay
7706
+ * dark, which is the dead-knob shape (D62) with an extra step.
7707
+ */
7708
+ declare(descriptor) {
7709
+ const parsed = LogChannelDescriptorSchema.parse(descriptor);
7710
+ if (this.gates.get(parsed.name) !== void 0) throw new Error(`log channel "${parsed.name}" is already declared in this process — two declarations of one name is a programming error, not a merge`);
7711
+ const gate = new LogChannelGate(parsed);
7712
+ this.gates.set(parsed.name, gate);
7713
+ return gate;
7714
+ }
7715
+ /** The declarations, sorted by name so a list is stable to read and diff. */
7716
+ list() {
7717
+ return [...this.gates.values()].map((gate) => gate.descriptor).sort((a, b) => a.name.localeCompare(b.name));
7718
+ }
7719
+ /** The gate for a declared channel, or `undefined`. */
7720
+ gate(name) {
7721
+ return this.gates.get(name);
7722
+ }
7723
+ /**
7724
+ * Apply the FULL set of armed windows. Off the hot path.
7725
+ *
7726
+ * Full, not incremental, and that is the whole design: the document is the
7727
+ * authority, so a channel the document does not name is disarmed here. An
7728
+ * incremental apply would let a disarm get lost in transit and leave a
7729
+ * channel running that nobody can see is running.
7730
+ *
7731
+ * A window already past its deadline is ignored rather than armed — a
7732
+ * restore that re-armed an expired window would make a forgotten diagnostic
7733
+ * immortal across restarts.
7734
+ *
7735
+ * Returns the names it could not place, so the caller can log them: a
7736
+ * channel named in the document that this process does not declare is
7737
+ * either a typo or an addon that has not booted yet, and both deserve a
7738
+ * line rather than silence.
7739
+ */
7740
+ apply(windows, nowMs) {
7741
+ const wanted = /* @__PURE__ */ new Map();
7742
+ const unknown = [];
7743
+ for (const window of windows) {
7744
+ if (window.armedUntilMs <= nowMs) continue;
7745
+ if (!this.gates.has(window.channel)) {
7746
+ unknown.push(window.channel);
7747
+ continue;
7748
+ }
7749
+ wanted.set(window.channel, window);
7750
+ }
7751
+ for (const [name, gate] of this.gates) {
7752
+ const window = wanted.get(name);
7753
+ if (window === void 0) gate.disarm();
7754
+ else gate.arm(window);
7755
+ }
7756
+ return unknown;
7757
+ }
7758
+ /**
7759
+ * Disarm whatever has run out. Called on a timer, NEVER from a log path — a
7760
+ * diagnostic that adds a `Date.now()` to the path it is measuring measures
7761
+ * itself.
7762
+ *
7763
+ * Returns the names it closed, so the caller can write the one line that
7764
+ * says a window ended and stops "it went quiet" from reading as "the branch
7765
+ * was not taken".
7766
+ */
7767
+ tick(nowMs) {
7768
+ const closed = [];
7769
+ for (const [name, gate] of this.gates) if (gate.on && gate.armedUntilMs <= nowMs) {
7770
+ gate.disarm();
7771
+ closed.push(name);
7772
+ }
7773
+ return closed;
7774
+ }
7775
+ /** The channels armed right now, as the document would describe them. */
7776
+ armed() {
7777
+ const out = [];
7778
+ for (const [name, gate] of this.gates) if (gate.on) out.push({
7779
+ channel: name,
7780
+ armedUntilMs: gate.armedUntilMs,
7781
+ deviceIds: null
7782
+ });
7783
+ return out;
7784
+ }
7785
+ };
7786
+ /**
7787
+ * Process-wide holder for the {@link LogChannelRegistry}.
7788
+ *
7789
+ * Three call sites that never meet need the SAME instance: the hot paths that
7790
+ * declare a gate at module scope, the `log-channels` provider that enumerates
7791
+ * the declarations for the hub, and the same provider applying the windows the
7792
+ * document hands down. A registry built inside any one of them would be
7793
+ * refreshed and collected — the shape of a knob that never does anything.
7794
+ *
7795
+ * Same idiom as `logging-gate.singleton.ts` and
7796
+ * `http-request-census.singleton.ts`.
7797
+ */
7798
+ var instance = null;
7799
+ /** The process-wide log channel registry. Created empty on first use. */
7800
+ function getLogChannelRegistry() {
7801
+ instance ??= new LogChannelRegistry();
7802
+ return instance;
7803
+ }
7804
+ /**
7805
+ * Declare a channel on the process-wide registry and get its gate.
7806
+ *
7807
+ * The one call an addon makes. Keep the returned gate in a module-scope
7808
+ * `const`: looking a channel up by name per line would put a Map lookup on
7809
+ * exactly the path this mechanism exists to keep free.
7810
+ *
7811
+ * `scripts/check-log-channel-gated.ts` reads these call sites. It pairs the
7812
+ * declared name with the binding it is assigned to and refuses to let a
7813
+ * channel ship that no `<binding>.on` anywhere consults — a declared channel
7814
+ * nobody reads is a knob the operator turns with nothing happening, forever,
7815
+ * and without a line. That is D62, and this repo has now shipped it three
7816
+ * times (`audioThresholdDbfs`, the HA entities with no source, the second
7817
+ * per-camera switch that wrote a store nobody read).
7818
+ */
7819
+ function declareLogChannel(descriptor) {
7820
+ return getLogChannelRegistry().declare(descriptor);
7821
+ }
7822
+ /**
7823
+ * Build the `log-channels` provider for this process.
7824
+ *
7825
+ * `logger` is used ONLY off the hot path — for the arm/expiry lines — so a
7826
+ * channel that is never armed costs this module nothing but a timer.
7827
+ */
7828
+ function createLogChannelsProvider(logger, options = {}) {
7829
+ const registry = getLogChannelRegistry();
7830
+ const now = options.now ?? Date.now;
7831
+ const tickMs = options.tickMs ?? 5e3;
7832
+ const timer = setInterval(() => {
7833
+ const closed = registry.tick(now());
7834
+ for (const name of closed) logger.info("log channel window closed", {
7835
+ tags: { logChannel: name },
7836
+ meta: { channel: name }
7837
+ });
7838
+ }, tickMs);
7839
+ timer.unref?.();
7840
+ return {
7841
+ list: () => registry.list(),
7842
+ apply: (input) => {
7843
+ const unknown = registry.apply(input.windows, now());
7844
+ const armed = registry.armed();
7845
+ logger.info("log channels applied", { meta: {
7846
+ armed: armed.map((window) => window.channel),
7847
+ unknown,
7848
+ declared: registry.list().length
7849
+ } });
7850
+ return {
7851
+ armed: armed.length,
7852
+ unknown
7853
+ };
7854
+ },
7855
+ stop: () => {
7856
+ clearInterval(timer);
7857
+ }
7858
+ };
7859
+ }
7860
+ /**
7505
7861
  * Ops-log — the durable, append-only operations audit shared by the
7506
7862
  * recordings and events management surfaces.
7507
7863
  *
@@ -11309,6 +11665,35 @@ var MutationFilterSchema = object({
11309
11665
  whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11310
11666
  whereNot: record(string(), unknown()).optional()
11311
11667
  });
11668
+ /**
11669
+ * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
11670
+ *
11671
+ * `as` names the slot in the result, so the SAME column may be asked twice with
11672
+ * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
11673
+ * a `Record<column, op>` shape could not express.
11674
+ */
11675
+ var AggregateFieldSchema = object({
11676
+ /** Result key. */
11677
+ as: string().min(1),
11678
+ /** Column to aggregate. Must be a real column of a declared collection. */
11679
+ field: string().min(1),
11680
+ op: _enum([
11681
+ "sum",
11682
+ "min",
11683
+ "max"
11684
+ ])
11685
+ });
11686
+ /**
11687
+ * `COUNT(*)` plus one number per requested field.
11688
+ *
11689
+ * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
11690
+ * that really is 0 are different facts, and an accounting caller that renders
11691
+ * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
11692
+ */
11693
+ var AggregateResultSchema = object({
11694
+ count: number().int(),
11695
+ values: record(string(), number().nullable())
11696
+ });
11312
11697
  /** A single stored record: `{ id, data }`. */
11313
11698
  var SettingsRecordSchema = object({
11314
11699
  id: string(),
@@ -11393,6 +11778,11 @@ method(object({
11393
11778
  collection: string(),
11394
11779
  filter: QueryFilterSchema.optional()
11395
11780
  }), number()), method(object({
11781
+ namespace: string().optional(),
11782
+ collection: string(),
11783
+ fields: array(AggregateFieldSchema).readonly(),
11784
+ filter: QueryFilterSchema.optional()
11785
+ }), AggregateResultSchema), method(object({
11396
11786
  namespace: string().optional(),
11397
11787
  collection: string(),
11398
11788
  field: string(),
@@ -11509,6 +11899,11 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11509
11899
  collection: string(),
11510
11900
  filter: QueryFilterSchema.optional()
11511
11901
  }), number(), { auth: "admin" }), method(object({
11902
+ namespace: string().optional(),
11903
+ collection: string(),
11904
+ fields: array(AggregateFieldSchema).readonly(),
11905
+ filter: QueryFilterSchema.optional()
11906
+ }), AggregateResultSchema, { auth: "admin" }), method(object({
11512
11907
  namespace: string().optional(),
11513
11908
  collection: string(),
11514
11909
  field: string(),
@@ -12232,24 +12627,6 @@ var deviceProviderCapability = {
12232
12627
  })
12233
12628
  }
12234
12629
  };
12235
- /**
12236
- * Device Manager capability — hub-side singleton that unifies device persistence,
12237
- * live registry access, and all management operations into a single tRPC surface.
12238
- *
12239
- * Replaces:
12240
- * - `device-persistence` capability (persistence methods absorbed here)
12241
- * - `device-management.router.ts` (deleted in Phase 2)
12242
- * - `device-ops.router.ts` (compat layer — deleted; device-provider ops absorbed here)
12243
- *
12244
- * All device provider addons (rtsp, onvif, frigate, …) are hub-local: they may
12245
- * fork into separate processes but never run on remote cluster agents. Therefore:
12246
- * - No nodeId routing needed — this is a pure hub singleton.
12247
- * - The hub's DeviceRegistry is the single source of truth for all live devices.
12248
- * - No shadow registry or cross-node aggregation required.
12249
- *
12250
- * Forked workers register devices back to the hub via `ctx.devices`
12251
- * (DeviceManagerApi → ctx.api.deviceManager.registerDevice), same as today.
12252
- */
12253
12630
  /** One child-placement directive on a container's `childLayout`. Structurally
12254
12631
  * identical to `ChildLayoutEntry` in `device-management.ts` — the cap wire
12255
12632
  * shape for the same field. The child is identified by its re-sync-stable
@@ -12618,7 +12995,7 @@ method(object({
12618
12995
  * it answers today and the caller filters as it already does.
12619
12996
  */
12620
12997
  deviceIds: array(number()).optional()
12621
- }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), object({
12998
+ }), 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({
12622
12999
  mode: LinkedDevicesModeSchema,
12623
13000
  devices: array(LinkedDeviceSchema)
12624
13001
  })), 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({
@@ -13342,6 +13719,80 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
13342
13719
  kind: "mutation",
13343
13720
  auth: "admin"
13344
13721
  });
13722
+ /**
13723
+ * `log-channels` — the capability an addon DECLARES its diagnostic channels
13724
+ * through. It stores nothing.
13725
+ *
13726
+ * ## Why a capability at all, and why this shape
13727
+ *
13728
+ * Which channels exist is knowledge only the addon has: `stream-broker` knows
13729
+ * webrtc/ICE/RTP, `provider-reolink` knows baichuan/handshake. A central list
13730
+ * maintained by hand rots at the first addition and rots INVISIBLY — nothing
13731
+ * fails, an operator just never sees the channel somebody added. So the list
13732
+ * is assembled from declarations at runtime.
13733
+ *
13734
+ * The shape is copied from `log-destination.cap.ts`, which already does
13735
+ * exactly this job: `mode: 'collection'`, `internal: true`,
13736
+ * `mount: { kind: 'skip' }` — no tRPC route, no generated hooks — while
13737
+ * `addons.listCapabilityProviders` still enumerates it, and the hub's
13738
+ * `CapabilityRegistry` still holds an RPC proxy per provider so a forked
13739
+ * runner's declarations reach hub-main over the transport that already exists.
13740
+ * No new UDS message, no second registry.
13741
+ *
13742
+ * ## What it deliberately does NOT own
13743
+ *
13744
+ * The VALUES — which channel is armed, for which cameras, until when — live in
13745
+ * ONE place: the logging settings document on the `system` cap
13746
+ * (`getLoggingSettings` / `setLoggingSettings`). Two authorities over the same
13747
+ * value is the defect the plan behind this work exists to remove, and
13748
+ * `setRequestCensus` was retired (D245) rather than allowed to be a second
13749
+ * one. {@link logChannelsCapability} therefore has no getter for a level, no
13750
+ * setter for a window and no persistence of any kind.
13751
+ *
13752
+ * ## Why `apply` is here even so
13753
+ *
13754
+ * The gate lives in the addon's PROCESS; the document lives in hub-main. Some
13755
+ * seam has to carry the value from the authority to the mirror, and a channel
13756
+ * that cannot be reached is precisely the dead knob this whole slice exists to
13757
+ * make impossible (D62 — `audioThresholdDbfs`, the HA entities with no source).
13758
+ * `apply` is that seam and nothing more: it writes an in-memory mirror, it
13759
+ * persists nothing, it is never the source of a value, and it is called only
13760
+ * with a set the hub actually read (D49 — a read that fails does not call it
13761
+ * at all, so no channel is silently disarmed by a bad read).
13762
+ */
13763
+ /** What `apply` reports back — enough to log, not enough to be a second state. */
13764
+ var LogChannelApplyResultSchema = object({
13765
+ /** How many declared channels are armed in this process after the call. */
13766
+ armed: number().int().min(0),
13767
+ /**
13768
+ * Names the document armed that this process does not declare. Reported
13769
+ * rather than swallowed: a name here is either a typo or an addon that has
13770
+ * not booted, and both deserve a line instead of silence.
13771
+ */
13772
+ unknown: array(string()).readonly()
13773
+ });
13774
+ var logChannelsCapability = {
13775
+ name: "log-channels",
13776
+ scope: "system",
13777
+ mode: "collection",
13778
+ internal: true,
13779
+ methods: {
13780
+ /** The channels this addon declares. Inert: no value, no state. */
13781
+ list: method(_void(), array(LogChannelDescriptorSchema).readonly()),
13782
+ /**
13783
+ * Refresh this process's mirror from the document's FULL set of armed
13784
+ * windows.
13785
+ *
13786
+ * Full and not incremental on purpose: the document is the authority, so a
13787
+ * channel it does not name is disarmed here. An incremental apply would
13788
+ * let a disarm get lost in transit and leave a channel running that
13789
+ * nobody can see is running.
13790
+ */
13791
+ apply: method(object({ windows: array(LogChannelWindowSchema).readonly() }), LogChannelApplyResultSchema, { kind: "mutation" })
13792
+ },
13793
+ /** In-process only — enumerated through `addons.listCapabilityProviders`. */
13794
+ mount: { kind: "skip" }
13795
+ };
13345
13796
  var LogLevelSchema = _enum([
13346
13797
  "debug",
13347
13798
  "info",
@@ -29013,17 +29464,60 @@ var SetSiteLocationInputSchema = object({
29013
29464
  longitude: number().min(-180).max(180)
29014
29465
  }).nullable();
29015
29466
  /**
29016
- * One `(procedure, user-agent, ip, principal)` tuple of the HTTP request
29467
+ * The TRANSPORT a call arrived on.
29468
+ *
29469
+ * Every counted call carries exactly one of these, and `unknown` is a PLANE
29470
+ * rather than a gap: a plane that cannot attribute a call declares it here, so
29471
+ * the call lands in a named bucket instead of vanishing. `planes` summing to
29472
+ * `procedureCalls` is what makes "the sum of the planes explains the total"
29473
+ * checkable rather than asserted.
29474
+ *
29475
+ * - `http` — the Fastify tRPC plugin (`/trpc/*`), one context per request.
29476
+ * - `ws` — `applyWSSHandler`, counted per OPERATION rather than per
29477
+ * connection; the viewer talks to the hub over `wsLink`
29478
+ * exclusively, so this is the plane the HTTP census could not see.
29479
+ * - `mesh` — the in-process `$core-caps` bridge (`createCaller`), which
29480
+ * never touches a socket and therefore never touched a census.
29481
+ * - `unknown` — counted, plane undecidable. No hook produces it today, and
29482
+ * that is exactly what its `0` asserts: every plane the hub has can name
29483
+ * itself. It is an output bucket, never a knob — a call that arrives on a
29484
+ * plane nobody instrumented lands here instead of vanishing from the total.
29485
+ */
29486
+ var TransportPlaneSchema = _enum([
29487
+ "http",
29488
+ "ws",
29489
+ "mesh",
29490
+ "unknown"
29491
+ ]);
29492
+ /**
29493
+ * Calls per plane. Every key is always present, `0` included — an absent plane
29494
+ * reads as "not instrumented", which is the one thing this census must never
29495
+ * make an operator wonder about.
29496
+ */
29497
+ var TransportPlaneCountsSchema = object({
29498
+ http: number(),
29499
+ ws: number(),
29500
+ mesh: number(),
29501
+ unknown: number()
29502
+ });
29503
+ /**
29504
+ * One `(plane, procedure, user-agent, ip, principal)` tuple of the transport
29017
29505
  * census. `principal` is the DERIVED identity (`apocaliss92 (admin)`,
29018
29506
  * `scoped:1a2b3c4d (scoped-token)`, `anonymous`) that the tRPC error log
29019
29507
  * already prints - never a token, never an `Authorization` header.
29508
+ *
29509
+ * `subscriptions` is counted APART from `calls`: a subscription is opened once
29510
+ * and lives for hours, so folding it into a call count makes one long-lived
29511
+ * stream look like a storm.
29020
29512
  */
29021
29513
  var RequestCensusGroupSchema = object({
29514
+ plane: TransportPlaneSchema,
29022
29515
  procedure: string(),
29023
29516
  userAgent: string(),
29024
29517
  ip: string(),
29025
29518
  principal: string(),
29026
29519
  calls: number(),
29520
+ subscriptions: number(),
29027
29521
  perMin: number()
29028
29522
  });
29029
29523
  /**
@@ -29036,6 +29530,14 @@ var RequestCensusGroupSchema = object({
29036
29530
  var RequestCensusProcedureSchema = object({
29037
29531
  procedure: string(),
29038
29532
  calls: number(),
29533
+ /**
29534
+ * The same total, split by transport. THIS is the row that answers the
29535
+ * question the census exists for: one look at `deviceManager.listAll` says
29536
+ * which plane carried the 4 960, without joining two log lines by eye.
29537
+ */
29538
+ planes: TransportPlaneCountsSchema,
29539
+ /** Subscription STARTS on this procedure. Never folded into `calls`. */
29540
+ subscriptions: number(),
29039
29541
  perMin: number()
29040
29542
  });
29041
29543
  /**
@@ -29063,14 +29565,45 @@ var RequestCensusStatusSchema = object({
29063
29565
  */
29064
29566
  procedureCalls: number(),
29065
29567
  /**
29568
+ * `procedureCalls` split by transport. The four keys sum to
29569
+ * `procedureCalls` by construction - {@link RequestCensusSnapshotSchema}'s
29570
+ * `planesExplainTotal` is that identity, checked rather than assumed.
29571
+ */
29572
+ planes: TransportPlaneCountsSchema,
29573
+ /**
29574
+ * True iff `planes` sums to `procedureCalls`. False means a call was counted
29575
+ * on no plane at all - which is a RESULT (a plane is missing from the
29576
+ * instrument), not a failure, and it has to be visible to be read as one.
29577
+ */
29578
+ planesExplainTotal: boolean(),
29579
+ /**
29066
29580
  * tRPC WebSocket connections opened during the window. NOT calls - the WS
29067
- * transport resolves one context per connection - but the number that says
29068
- * whether a plane this census cannot see was busy while HTTP was quiet.
29581
+ * adapter resolves one context per connection - kept because a plane's call
29582
+ * count of zero against 37 open connections says something different from a
29583
+ * plane with no connections at all.
29069
29584
  */
29070
29585
  wsConnections: number(),
29586
+ /**
29587
+ * Client frames the WS plane looked at. `wsMessages` far above
29588
+ * `planes.ws + subscriptions` means most traffic is not operations
29589
+ * (keepalives, connection params) - which is itself an answer.
29590
+ */
29591
+ wsMessages: number(),
29592
+ /**
29593
+ * Subscription STARTS across every plane, excluded from `procedureCalls` on
29594
+ * purpose: one live-events stream opened at boot and held for six hours is
29595
+ * one subscription, and counting it as a call would let a quiet plane
29596
+ * masquerade as the storm.
29597
+ */
29598
+ subscriptions: number(),
29599
+ /** `subscription.stop` frames. Starts minus stops is what is still open. */
29600
+ subscriptionStops: number(),
29071
29601
  distinctGroups: number(),
29072
- /** Calls counted in the totals whose group attribution was shed at the
29073
- * cardinality bound. */
29602
+ /**
29603
+ * Operations counted in the totals whose CALLER attribution was shed at the
29604
+ * cardinality bound. Unrelated to the `unknown` PLANE: these calls know
29605
+ * which transport they arrived on, they just lost their group row.
29606
+ */
29074
29607
  unattributedCalls: number(),
29075
29608
  procedures: array(RequestCensusProcedureSchema).readonly(),
29076
29609
  groups: array(RequestCensusGroupSchema).readonly()
@@ -29093,10 +29626,11 @@ var DiagnosticIdSchema = _enum(["request-census"]);
29093
29626
  * The layers of the level hierarchy, general → specific. The most specific
29094
29627
  * layer that carries an explicit value wins.
29095
29628
  *
29096
- * `component` is DECLARED and not yet resolvable: the per-component channels
29097
- * are a later slice of the same plan, and a `levelSource` enum that has to
29098
- * grow later would force every consumer of this document to change with it.
29099
- * Nothing returns `component` today.
29629
+ * `component` became RESOLVABLE on 2026-08-27: a component is a declared log
29630
+ * CHANNEL (`stream-broker.webrtc`, `provider-reolink.baichuan`), named by
29631
+ * `scopeComponent`. It was declared-but-dark in the first slice precisely so
29632
+ * that turning it on would not force every consumer of this document to widen
29633
+ * a `levelSource` enum — which is what has now not happened.
29100
29634
  */
29101
29635
  var LoggingScopeKindSchema = _enum([
29102
29636
  "cluster",
@@ -29123,6 +29657,14 @@ var LoggingLevelLayerSchema = object({
29123
29657
  scope: LoggingScopeKindSchema,
29124
29658
  /** The node this layer speaks for; `null` on the cluster layer. */
29125
29659
  nodeId: string().nullable(),
29660
+ /**
29661
+ * The declared channel this layer speaks for; `null` on every layer but
29662
+ * `component`. Never folded into `nodeId`: a component level is CLUSTER-WIDE
29663
+ * by design — the convention this repo settled on is one orchestrator-wide
29664
+ * setting, never per node (D52) — so a component layer that carried a node
29665
+ * would invite a per-node copy of a value that has no per-node meaning.
29666
+ */
29667
+ component: string().nullable(),
29126
29668
  /** Explicitly set here, or `null` when this layer inherits. */
29127
29669
  level: LogLevelSchema$1.nullable()
29128
29670
  });
@@ -29164,6 +29706,49 @@ var DiagnosticWindowPatchSchema = object({
29164
29706
  reportEveryMs: number().int().positive().optional()
29165
29707
  });
29166
29708
  /**
29709
+ * A channel ARMED, as the document reports it.
29710
+ *
29711
+ * `armMs` is not echoed back: what an operator needs to see is the deadline
29712
+ * and the time left, because a diagnostic left running is itself an incident
29713
+ * and "armed for 10 minutes" said an hour ago is not an answer.
29714
+ */
29715
+ var LogChannelWindowStateSchema = object({
29716
+ channel: string(),
29717
+ armed: boolean(),
29718
+ /** Epoch ms the window closes at. 0 when disarmed. */
29719
+ armedUntilMs: number(),
29720
+ /** Ms left before it expires on its own. 0 when disarmed. */
29721
+ remainingMs: number(),
29722
+ /**
29723
+ * The cameras it is narrowed to, or `null` for every camera.
29724
+ *
29725
+ * A channel declared `perDevice: false` can only ever report `null` here:
29726
+ * its lines do not carry `tags: { deviceId }`, so narrowing them would
29727
+ * produce a filter that silently matches nothing. The server REFUSES such a
29728
+ * patch rather than quietly widening it — ignoring the request would teach
29729
+ * the operator that per-camera filtering works on that channel when it does
29730
+ * not.
29731
+ */
29732
+ deviceIds: array(number().int()).readonly().nullable()
29733
+ });
29734
+ /**
29735
+ * `armMs: 0` DISARMS. Same grammar as {@link DiagnosticWindowPatchSchema}, and
29736
+ * for the same reason: a channel is a window with a deadline, never a switch.
29737
+ */
29738
+ var LogChannelWindowPatchSchema = object({
29739
+ channel: string().min(1),
29740
+ armMs: number().int().min(0),
29741
+ /**
29742
+ * Narrow to these numeric device ids. Absent or `null` = every camera.
29743
+ *
29744
+ * Numeric because the repo's own rule makes it possible: every log line
29745
+ * about a device carries `tags: { deviceId }` with the numeric id. That rule
29746
+ * was paid for with a 22% thumbnail gap and a 3-hour media blackout both
29747
+ * diagnosed by hand, and this is the first thing that collects on it.
29748
+ */
29749
+ deviceIds: array(number().int()).readonly().nullable().optional()
29750
+ });
29751
+ /**
29167
29752
  * A PATCH, and patches MERGE.
29168
29753
  *
29169
29754
  * A field absent from the patch is left exactly as it was — arming a
@@ -29182,7 +29767,14 @@ var LoggingSettingsPatchSchema = object({
29182
29767
  * Only the diagnostics NAMED here change. An armed window that is not listed
29183
29768
  * keeps running — a patch is never a full replacement.
29184
29769
  */
29185
- diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional()
29770
+ diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional(),
29771
+ /**
29772
+ * Only the channels NAMED here change. An armed channel that is not listed
29773
+ * keeps running — same rule as `diagnostics`, because a patch that silently
29774
+ * disarmed the channels it did not mention would make the Levels page and
29775
+ * the Diagnostics page fight over the same value.
29776
+ */
29777
+ channels: array(LogChannelWindowPatchSchema).readonly().optional()
29186
29778
  });
29187
29779
  /**
29188
29780
  * Which LAYER of the hierarchy is addressed. Absent = the cluster layer.
@@ -29195,9 +29787,22 @@ var LoggingSettingsPatchSchema = object({
29195
29787
  * authority over the whole hierarchy and answers for every layer, so the
29196
29788
  * layer selector needs a name the transport does not already own.
29197
29789
  */
29198
- var GetLoggingSettingsInputSchema = object({ scopeNodeId: string().optional() });
29790
+ var GetLoggingSettingsInputSchema = object({
29791
+ scopeNodeId: string().optional(),
29792
+ /**
29793
+ * The declared CHANNEL this document is addressed at, when the caller wants
29794
+ * the `component` layer. Absent = the node/cluster hierarchy only.
29795
+ *
29796
+ * Naming it separately rather than overloading `scopeNodeId` keeps the two
29797
+ * axes from collapsing: a component level is cluster-wide, a node level is
29798
+ * not, and one selector for both would make "which of these two did I just
29799
+ * set" unanswerable — the exact ambiguity `explicit` exists to remove.
29800
+ */
29801
+ scopeComponent: string().optional()
29802
+ });
29199
29803
  var SetLoggingSettingsInputSchema = object({
29200
29804
  scopeNodeId: string().optional(),
29805
+ scopeComponent: string().optional(),
29201
29806
  patch: LoggingSettingsPatchSchema
29202
29807
  });
29203
29808
  /**
@@ -29212,9 +29817,20 @@ var SetLoggingSettingsInputSchema = object({
29212
29817
  var LoggingSettingsStateSchema = object({
29213
29818
  /** The layer this document was read at. `null` = the cluster layer. */
29214
29819
  scopeNodeId: string().nullable(),
29820
+ /** The channel this document was read at. `null` = no component layer. */
29821
+ scopeComponent: string().nullable(),
29215
29822
  effective: LoggingEffectiveSchema,
29216
29823
  explicit: LoggingExplicitSchema,
29217
29824
  activeWindows: array(DiagnosticWindowSchema).readonly(),
29825
+ /**
29826
+ * Every channel the cluster's addons DECLARE, gathered from the
29827
+ * `log-channels` providers. Not stored anywhere: assembled per read, so a
29828
+ * channel added by a redeployed addon appears without anybody editing a
29829
+ * list, and a channel whose addon is gone stops being offered.
29830
+ */
29831
+ channels: array(LogChannelDescriptorSchema).readonly(),
29832
+ /** The channels ARMED right now, each with its deadline. */
29833
+ activeChannels: array(LogChannelWindowStateSchema).readonly(),
29218
29834
  persisted: boolean()
29219
29835
  });
29220
29836
  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(), {
@@ -32366,6 +32982,12 @@ Object.freeze({
32366
32982
  addonId: null,
32367
32983
  access: "view"
32368
32984
  },
32985
+ "dataStoreProvider.aggregate": {
32986
+ capName: "data-store-provider",
32987
+ capScope: "system",
32988
+ addonId: null,
32989
+ access: "view"
32990
+ },
32369
32991
  "dataStoreProvider.count": {
32370
32992
  capName: "data-store-provider",
32371
32993
  capScope: "system",
@@ -32780,6 +33402,12 @@ Object.freeze({
32780
33402
  addonId: null,
32781
33403
  access: "view"
32782
33404
  },
33405
+ "deviceManager.getChildrenBatch": {
33406
+ capName: "device-manager",
33407
+ capScope: "system",
33408
+ addonId: null,
33409
+ access: "view"
33410
+ },
32783
33411
  "deviceManager.getConfigSchema": {
32784
33412
  capName: "device-manager",
32785
33413
  capScope: "system",
@@ -33830,6 +34458,18 @@ Object.freeze({
33830
34458
  addonId: null,
33831
34459
  access: "create"
33832
34460
  },
34461
+ "logChannels.apply": {
34462
+ capName: "log-channels",
34463
+ capScope: "system",
34464
+ addonId: null,
34465
+ access: "create"
34466
+ },
34467
+ "logChannels.list": {
34468
+ capName: "log-channels",
34469
+ capScope: "system",
34470
+ addonId: null,
34471
+ access: "view"
34472
+ },
33833
34473
  "logDestination.query": {
33834
34474
  capName: "log-destination",
33835
34475
  capScope: "system",
@@ -35984,6 +36624,12 @@ Object.freeze({
35984
36624
  addonId: null,
35985
36625
  access: "create"
35986
36626
  },
36627
+ "settingsStore.aggregate": {
36628
+ capName: "settings-store",
36629
+ capScope: "system",
36630
+ addonId: null,
36631
+ access: "view"
36632
+ },
35987
36633
  "settingsStore.count": {
35988
36634
  capName: "settings-store",
35989
36635
  capScope: "system",
@@ -37563,6 +38209,11 @@ Object.freeze({
37563
38209
  form: "single",
37564
38210
  optional: false
37565
38211
  }],
38212
+ "deviceManager.getChildrenBatch": [{
38213
+ name: "parentDeviceIds",
38214
+ form: "array",
38215
+ optional: false
38216
+ }],
37566
38217
  "deviceManager.getConfigSchema": [{
37567
38218
  name: "deviceId",
37568
38219
  form: "single",
@@ -227865,6 +228516,68 @@ function buildInitialStatus(config) {
227865
228516
  };
227866
228517
  }
227867
228518
  //#endregion
228519
+ //#region src/log-channels.ts
228520
+ /**
228521
+ * The diagnostic log CHANNELS `provider-reolink` declares.
228522
+ *
228523
+ * Only this addon knows these exist. What "the Baichuan control channel" and
228524
+ * "the login handshake" mean is knowledge of the Reolink provider, and a
228525
+ * central list elsewhere would rot the first time a vendor quirk earns a third
228526
+ * channel — silently, because nothing fails when a list is merely incomplete.
228527
+ *
228528
+ * The VALUE — armed or not, for which cameras, until when — is not here. It
228529
+ * lives in the one logging settings document on the `system` cap. These are
228530
+ * declarations: inert, no state.
228531
+ *
228532
+ * ## Both are honestly per-camera, and here is why
228533
+ *
228534
+ * `ReolinkCamera` logs through `this.ctx.logger`, which the kernel builds as
228535
+ * `logger.child(stableId).withTags({ deviceId })` with the NUMERIC id
228536
+ * (`device-cap-proxy.ts`), and `ScopedLogger` merges its bound tags into every
228537
+ * line. So every line these channels admit carries `tags.deviceId`, and
228538
+ * `| json | deviceId="617"` selects exactly one camera. That is the repo rule
228539
+ * from `CLAUDE.md` — paid for with a 22% thumbnail gap and a 3-hour media
228540
+ * blackout diagnosed by hand — finally paying out.
228541
+ *
228542
+ * The hub's own dispatch lines are a different matter: `reolink-hub.ts` puts
228543
+ * the CHILD's id in `meta` and carries the HUB's id in `tags`, so those lines
228544
+ * are not per-camera filterable. Neither channel below claims them.
228545
+ */
228546
+ /**
228547
+ * The Baichuan control channel itself: every protocol frame the lib sends and
228548
+ * receives, UDP keepalives, and the sleep-inference ticks on a battery camera.
228549
+ *
228550
+ * Consulted in `ReolinkCamera.getBaichuanDebugOptions`, the single place the
228551
+ * lib's `general` debug option is decided, so arming this channel turns on the
228552
+ * same protocol trace the per-camera `debugGeneral` switch does — through the
228553
+ * same funnel, with a deadline instead of forever.
228554
+ *
228555
+ * The lib is handed `libLoggerAdapter()`, which writes through
228556
+ * `this.ctx.logger.child('nodelink')` — `child()` preserves bound tags, so the
228557
+ * device tag survives and the per-camera promise holds.
228558
+ */
228559
+ var CH_BAICHUAN = declareLogChannel({
228560
+ name: "provider-reolink.baichuan",
228561
+ description: "Every Baichuan protocol frame this camera sends and receives, plus UDP keepalives and battery-camera sleep inference. Loud on an active camera — arm it for one camera and a short window.",
228562
+ defaultLevel: "info",
228563
+ perDevice: true
228564
+ });
228565
+ /**
228566
+ * The login ceremony and the socket lifecycle around it: the pre-login dial,
228567
+ * the battery-camera wake that a login IS, login failures on a per-stream
228568
+ * RFC 4571 socket, and every reconnect that follows one.
228569
+ *
228570
+ * Consulted where the camera decides to dial and where it schedules a
228571
+ * reconnect — the two moments that explain a camera which is "there" in the
228572
+ * UI and answering nothing.
228573
+ */
228574
+ var CH_HANDSHAKE = declareLogChannel({
228575
+ name: "provider-reolink.handshake",
228576
+ description: "Login and socket lifecycle for this camera: the pre-login dial, the battery-camera wake a login causes, login failures and the reconnects that follow. The channel to arm when a camera looks present but answers nothing.",
228577
+ defaultLevel: "info",
228578
+ perDevice: true
228579
+ });
228580
+ //#endregion
227868
228581
  //#region src/day-night-mapping.ts
227869
228582
  /**
227870
228583
  * Maps between the vendor-neutral `day-night` cap's `DayNightMode` and
@@ -237898,6 +238611,18 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
237898
238611
  }
237899
238612
  });
237900
238613
  const debugOptions = this.getBaichuanDebugOptions();
238614
+ if (CH_HANDSHAKE.on && CH_HANDSHAKE.wants(this.id)) CH_HANDSHAKE.log(this.ctx.logger, "baichuan dial", {
238615
+ tags: { deviceId: this.id },
238616
+ meta: {
238617
+ host: String(host),
238618
+ port,
238619
+ transport,
238620
+ hasUid: Boolean(uid),
238621
+ udpDiscoveryMethod: udpDiscoveryMethod ?? null,
238622
+ reconnectAttempts: this.reconnectAttempts,
238623
+ debugOptions: debugOptions === void 0 ? null : Object.keys(debugOptions)
238624
+ }
238625
+ });
237901
238626
  this.loginPromise = (async () => {
237902
238627
  const api = new ReolinkBaichuanApi({
237903
238628
  host,
@@ -238003,7 +238728,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
238003
238728
  * object override.
238004
238729
  */
238005
238730
  getBaichuanDebugOptions() {
238006
- const general = this.config.get("debugGeneral") === true;
238731
+ const general = this.config.get("debugGeneral") === true || CH_BAICHUAN.on && CH_BAICHUAN.wants(this.id);
238007
238732
  const socketFlags = this.config.get("debugSocketLogs") ?? [];
238008
238733
  const opts = {};
238009
238734
  if (general) opts.general = true;
@@ -238285,6 +239010,15 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
238285
239010
  backoffMs
238286
239011
  }
238287
239012
  });
239013
+ if (CH_HANDSHAKE.on && CH_HANDSHAKE.wants(this.id)) CH_HANDSHAKE.log(this.ctx.logger, "baichuan reconnect ladder", {
239014
+ tags: { deviceId: this.id },
239015
+ meta: {
239016
+ reason,
239017
+ attempt,
239018
+ backoffMs,
239019
+ hadApi: this.api !== null
239020
+ }
239021
+ });
238288
239022
  this.api = null;
238289
239023
  this.reconnectTimer = setTimeout(() => {
238290
239024
  this.reconnectTimer = null;
@@ -240130,6 +240864,9 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
240130
240864
  * lifecycle and restarted on settings change.
240131
240865
  */
240132
240866
  emailPushServer;
240867
+ /** The `log-channels` provider for this process. Stopped on shutdown so a
240868
+ * diagnostic timer is never the reason a runner refuses to exit. */
240869
+ logChannels;
240133
240870
  constructor() {
240134
240871
  super({});
240135
240872
  }
@@ -240239,6 +240976,7 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
240239
240976
  throw new Error(`Reolink: ${reason}`);
240240
240977
  }
240241
240978
  async onShutdown() {
240979
+ this.logChannels?.stop();
240242
240980
  await this.emailPushServer?.stop().catch(() => {});
240243
240981
  await this.autodetectCache.dispose();
240244
240982
  }
@@ -240258,6 +240996,11 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
240258
240996
  }
240259
240997
  async onInitialize() {
240260
240998
  const regs = await super.onInitialize();
240999
+ this.logChannels = createLogChannelsProvider(this.ctx.logger.child("log-channels"));
241000
+ regs.push({
241001
+ capability: logChannelsCapability,
241002
+ provider: this.logChannels
241003
+ });
240261
241004
  this.subscribe({ category: EventCategory.StreamBrokerOnRequestStreamSourceRefresh }, (event) => {
240262
241005
  const data = event.data;
240263
241006
  const deviceId = typeof data.deviceId === "number" ? data.deviceId : null;