@camstack/addon-provider-reolink 1.2.55 → 1.2.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +687 -26
- package/dist/addon.mjs +687 -26
- package/package.json +4 -1
package/dist/addon.js
CHANGED
|
@@ -7507,6 +7507,362 @@ var CameraSwitchGroupSchema = object({
|
|
|
7507
7507
|
fetchedAt: number()
|
|
7508
7508
|
});
|
|
7509
7509
|
/**
|
|
7510
|
+
* Per-component log CHANNELS — the gate a hot path consults, and the registry
|
|
7511
|
+
* an addon declares its channels in.
|
|
7512
|
+
*
|
|
7513
|
+
* ## Two axes, deliberately separated
|
|
7514
|
+
*
|
|
7515
|
+
* - **DECLARATION** — which channels exist. Only the addon knows:
|
|
7516
|
+
* `stream-broker` knows webrtc/ICE/RTP, `provider-reolink` knows
|
|
7517
|
+
* baichuan/handshake. A hand-wired central list rots at the first addition,
|
|
7518
|
+
* and rots silently. So a channel is declared where it is consulted, and the
|
|
7519
|
+
* `log-channels` capability enumerates the declarations.
|
|
7520
|
+
* - **VALUE** — at which level, for which scope, until when. That stays ONE
|
|
7521
|
+
* thing: the logging settings document on the `system` cap. Two authorities
|
|
7522
|
+
* over the values is the exact defect
|
|
7523
|
+
* `docs/design/plans/2026-08-26-logging-per-componente.md` was written to
|
|
7524
|
+
* remove; re-introducing it from the cure side would be grotesque.
|
|
7525
|
+
*
|
|
7526
|
+
* Nothing in this file reads a clock, an env var or a store. The registry is
|
|
7527
|
+
* a MIRROR: it is moved only by {@link LogChannelRegistry.apply}, called off
|
|
7528
|
+
* the hot path with a value somebody actually read, and by
|
|
7529
|
+
* {@link LogChannelRegistry.tick}, called on a timer. A store read that fails
|
|
7530
|
+
* never reaches here, so it can neither disarm an armed channel nor arm a
|
|
7531
|
+
* disarmed one (D49).
|
|
7532
|
+
*
|
|
7533
|
+
* ## The canonical call shape
|
|
7534
|
+
*
|
|
7535
|
+
* ```ts
|
|
7536
|
+
* if (CH_RTP.on && CH_RTP.wants(deviceId)) {
|
|
7537
|
+
* CH_RTP.log(logger, 'rtp subscriber added', { tags: { deviceId }, meta: { ssrc } })
|
|
7538
|
+
* }
|
|
7539
|
+
* ```
|
|
7540
|
+
*
|
|
7541
|
+
* `on` is a plain boolean FIELD — never a getter — and it is the FIRST thing
|
|
7542
|
+
* read. Disarmed, a call site costs one load and one branch, and the `extras`
|
|
7543
|
+
* object literal is never constructed because it lives inside the branch. It
|
|
7544
|
+
* is the same shape already proven in production at `stream-broker.ts:1650`,
|
|
7545
|
+
* and the same discipline `LoggingGate.allowsDestination` uses for the
|
|
7546
|
+
* destination floor (measured at 1.93 ns/call when off).
|
|
7547
|
+
*
|
|
7548
|
+
* ## Why a channel emits at `info`
|
|
7549
|
+
*
|
|
7550
|
+
* `loki-logging.addon.ts` pins the destination default at `info` and
|
|
7551
|
+
* `loki-destination.ts` drops everything below it, so a line emitted at
|
|
7552
|
+
* `debug` never reaches Loki and the hub's in-memory ring only holds ~35
|
|
7553
|
+
* minutes. A diagnostic that cannot be read an hour later is worse than no
|
|
7554
|
+
* diagnostic, because it looks done. {@link LogChannelGate.log} therefore
|
|
7555
|
+
* emits at the channel's declared level, whose schema floor is `info`.
|
|
7556
|
+
*/
|
|
7557
|
+
/**
|
|
7558
|
+
* The level a channel writes at once armed.
|
|
7559
|
+
*
|
|
7560
|
+
* `debug` is absent ON PURPOSE and not by omission: below `info` the line does
|
|
7561
|
+
* not leave the process for Loki, and the whole point of arming a channel is
|
|
7562
|
+
* to read it later.
|
|
7563
|
+
*/
|
|
7564
|
+
var LogChannelLevelSchema = _enum([
|
|
7565
|
+
"info",
|
|
7566
|
+
"warn",
|
|
7567
|
+
"error"
|
|
7568
|
+
]);
|
|
7569
|
+
/**
|
|
7570
|
+
* What an addon declares about one channel. No value, no state — a
|
|
7571
|
+
* declaration is inert.
|
|
7572
|
+
*/
|
|
7573
|
+
var LogChannelDescriptorSchema = object({
|
|
7574
|
+
/**
|
|
7575
|
+
* Dotted `area.thing`, unique across the workspace. `area` is conventionally
|
|
7576
|
+
* the addon's short name so an operator reading a channel list can tell who
|
|
7577
|
+
* owns it without a second lookup.
|
|
7578
|
+
*/
|
|
7579
|
+
name: string().min(3).regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/, "a channel name is dotted lower-kebab, e.g. area.thing"),
|
|
7580
|
+
/** One sentence: what the operator will SEE after arming it. */
|
|
7581
|
+
description: string().min(1),
|
|
7582
|
+
/** The level its lines are emitted at. Never below `info`. */
|
|
7583
|
+
defaultLevel: LogChannelLevelSchema,
|
|
7584
|
+
/**
|
|
7585
|
+
* Whether this channel can be narrowed to a camera.
|
|
7586
|
+
*
|
|
7587
|
+
* `true` is a PROMISE with two halves, and both must hold: the gate is
|
|
7588
|
+
* consulted with the numeric device id, AND every line the channel admits
|
|
7589
|
+
* carries `tags: { deviceId }` with that same numeric id. The second half is
|
|
7590
|
+
* what makes `| json | deviceId="617"` work in Loki — `loki-payload.ts`
|
|
7591
|
+
* keeps `deviceId` out of the stream labels for cardinality, so the tag in
|
|
7592
|
+
* the body is the only way to filter.
|
|
7593
|
+
*
|
|
7594
|
+
* A channel whose lines carry the device only in `meta` (or not at all) is
|
|
7595
|
+
* declared `false`. Declaring it `true` anyway would be a lie the UI repeats:
|
|
7596
|
+
* the operator narrows to one camera, sees nothing, and concludes the code
|
|
7597
|
+
* path was never taken.
|
|
7598
|
+
*/
|
|
7599
|
+
perDevice: boolean()
|
|
7600
|
+
});
|
|
7601
|
+
/**
|
|
7602
|
+
* An armed window over one channel, as the document hands it to a mirror.
|
|
7603
|
+
*
|
|
7604
|
+
* A window is a DEADLINE, never a flag (ADR-0244): a channel somebody forgot
|
|
7605
|
+
* expires by itself, which is the one failure a boolean cannot avoid.
|
|
7606
|
+
*/
|
|
7607
|
+
var LogChannelWindowSchema = object({
|
|
7608
|
+
channel: string().min(1),
|
|
7609
|
+
/** Epoch ms the window closes at. */
|
|
7610
|
+
armedUntilMs: number(),
|
|
7611
|
+
/** `null` = every camera. A non-empty list narrows to those numeric ids. */
|
|
7612
|
+
deviceIds: array(number().int()).readonly().nullable()
|
|
7613
|
+
});
|
|
7614
|
+
/**
|
|
7615
|
+
* The gate a hot path holds.
|
|
7616
|
+
*
|
|
7617
|
+
* Obtain it ONCE — at module scope or in a constructor — and keep the
|
|
7618
|
+
* reference. Looking a channel up by name per line would put a Map lookup on
|
|
7619
|
+
* the path this class exists to keep free.
|
|
7620
|
+
*/
|
|
7621
|
+
var LogChannelGate = class {
|
|
7622
|
+
descriptor;
|
|
7623
|
+
/**
|
|
7624
|
+
* HOT PATH GUARD. A plain data FIELD, and it must stay one.
|
|
7625
|
+
*
|
|
7626
|
+
* `log-channel.spec.ts` asserts the property descriptor has no getter and
|
|
7627
|
+
* booby-traps the device set, so turning this into an accessor — or reading
|
|
7628
|
+
* anything before it — fails the spec instead of taxing every line the
|
|
7629
|
+
* process emits.
|
|
7630
|
+
*/
|
|
7631
|
+
on = false;
|
|
7632
|
+
/** `null` while armed for every camera. Never read while `on` is false. */
|
|
7633
|
+
devices = null;
|
|
7634
|
+
level;
|
|
7635
|
+
closesAtMs = 0;
|
|
7636
|
+
constructor(descriptor) {
|
|
7637
|
+
this.descriptor = descriptor;
|
|
7638
|
+
this.level = descriptor.defaultLevel;
|
|
7639
|
+
}
|
|
7640
|
+
/** Epoch ms this channel disarms itself at. 0 when disarmed. */
|
|
7641
|
+
get armedUntilMs() {
|
|
7642
|
+
return this.on ? this.closesAtMs : 0;
|
|
7643
|
+
}
|
|
7644
|
+
/**
|
|
7645
|
+
* Does this channel want a line about `deviceId`?
|
|
7646
|
+
*
|
|
7647
|
+
* Call it only behind `gate.on &&`. On its own it is still correct — the
|
|
7648
|
+
* guard is repeated inside — but the point of the prefix is that a disarmed
|
|
7649
|
+
* channel must not pay the call at all.
|
|
7650
|
+
*/
|
|
7651
|
+
wants(deviceId) {
|
|
7652
|
+
if (!this.on) return false;
|
|
7653
|
+
return this.devices === null || this.devices.has(deviceId);
|
|
7654
|
+
}
|
|
7655
|
+
/**
|
|
7656
|
+
* Emit one line on this channel, at the channel's declared level.
|
|
7657
|
+
*
|
|
7658
|
+
* The channel name is added as `tags.logChannel` so LogQL can select the
|
|
7659
|
+
* channel without matching on the message text, and whatever `tags` the
|
|
7660
|
+
* caller passed — `deviceId` above all — is preserved.
|
|
7661
|
+
*/
|
|
7662
|
+
log(logger, message, extras) {
|
|
7663
|
+
if (!this.on) return;
|
|
7664
|
+
const tags = {
|
|
7665
|
+
...extras.tags,
|
|
7666
|
+
logChannel: this.descriptor.name
|
|
7667
|
+
};
|
|
7668
|
+
const line = {
|
|
7669
|
+
...extras,
|
|
7670
|
+
tags
|
|
7671
|
+
};
|
|
7672
|
+
if (this.level === "error") logger.error(message, line);
|
|
7673
|
+
else if (this.level === "warn") logger.warn(message, line);
|
|
7674
|
+
else logger.info(message, line);
|
|
7675
|
+
}
|
|
7676
|
+
/**
|
|
7677
|
+
* Arm (or RE-arm, restarting) this channel. Off the hot path only.
|
|
7678
|
+
*
|
|
7679
|
+
* An empty `deviceIds` list is treated as "every camera" rather than "no
|
|
7680
|
+
* camera": a window that matches nothing is indistinguishable from a
|
|
7681
|
+
* disarmed one, and the operator who asked for it would wait for lines that
|
|
7682
|
+
* can never come.
|
|
7683
|
+
*/
|
|
7684
|
+
arm(window) {
|
|
7685
|
+
const ids = window.deviceIds;
|
|
7686
|
+
this.devices = ids === null || ids.length === 0 ? null : new Set(ids);
|
|
7687
|
+
this.closesAtMs = window.armedUntilMs;
|
|
7688
|
+
this.on = true;
|
|
7689
|
+
}
|
|
7690
|
+
/** Disarm. Off the hot path only. */
|
|
7691
|
+
disarm() {
|
|
7692
|
+
this.on = false;
|
|
7693
|
+
this.devices = null;
|
|
7694
|
+
this.closesAtMs = 0;
|
|
7695
|
+
}
|
|
7696
|
+
};
|
|
7697
|
+
/**
|
|
7698
|
+
* Every channel this PROCESS declares, and the mirror of what is armed on it.
|
|
7699
|
+
*
|
|
7700
|
+
* One per process. A forked runner has its own, and it is refreshed through
|
|
7701
|
+
* the `log-channels` capability by the hub that owns the document — the
|
|
7702
|
+
* registry never reaches for a value itself.
|
|
7703
|
+
*/
|
|
7704
|
+
var LogChannelRegistry = class {
|
|
7705
|
+
gates = /* @__PURE__ */ new Map();
|
|
7706
|
+
/**
|
|
7707
|
+
* Declare a channel and get its gate.
|
|
7708
|
+
*
|
|
7709
|
+
* A duplicate name throws. Two declarations of one name is a programming
|
|
7710
|
+
* error, not a merge: the operator would arm one and the other would stay
|
|
7711
|
+
* dark, which is the dead-knob shape (D62) with an extra step.
|
|
7712
|
+
*/
|
|
7713
|
+
declare(descriptor) {
|
|
7714
|
+
const parsed = LogChannelDescriptorSchema.parse(descriptor);
|
|
7715
|
+
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`);
|
|
7716
|
+
const gate = new LogChannelGate(parsed);
|
|
7717
|
+
this.gates.set(parsed.name, gate);
|
|
7718
|
+
return gate;
|
|
7719
|
+
}
|
|
7720
|
+
/** The declarations, sorted by name so a list is stable to read and diff. */
|
|
7721
|
+
list() {
|
|
7722
|
+
return [...this.gates.values()].map((gate) => gate.descriptor).sort((a, b) => a.name.localeCompare(b.name));
|
|
7723
|
+
}
|
|
7724
|
+
/** The gate for a declared channel, or `undefined`. */
|
|
7725
|
+
gate(name) {
|
|
7726
|
+
return this.gates.get(name);
|
|
7727
|
+
}
|
|
7728
|
+
/**
|
|
7729
|
+
* Apply the FULL set of armed windows. Off the hot path.
|
|
7730
|
+
*
|
|
7731
|
+
* Full, not incremental, and that is the whole design: the document is the
|
|
7732
|
+
* authority, so a channel the document does not name is disarmed here. An
|
|
7733
|
+
* incremental apply would let a disarm get lost in transit and leave a
|
|
7734
|
+
* channel running that nobody can see is running.
|
|
7735
|
+
*
|
|
7736
|
+
* A window already past its deadline is ignored rather than armed — a
|
|
7737
|
+
* restore that re-armed an expired window would make a forgotten diagnostic
|
|
7738
|
+
* immortal across restarts.
|
|
7739
|
+
*
|
|
7740
|
+
* Returns the names it could not place, so the caller can log them: a
|
|
7741
|
+
* channel named in the document that this process does not declare is
|
|
7742
|
+
* either a typo or an addon that has not booted yet, and both deserve a
|
|
7743
|
+
* line rather than silence.
|
|
7744
|
+
*/
|
|
7745
|
+
apply(windows, nowMs) {
|
|
7746
|
+
const wanted = /* @__PURE__ */ new Map();
|
|
7747
|
+
const unknown = [];
|
|
7748
|
+
for (const window of windows) {
|
|
7749
|
+
if (window.armedUntilMs <= nowMs) continue;
|
|
7750
|
+
if (!this.gates.has(window.channel)) {
|
|
7751
|
+
unknown.push(window.channel);
|
|
7752
|
+
continue;
|
|
7753
|
+
}
|
|
7754
|
+
wanted.set(window.channel, window);
|
|
7755
|
+
}
|
|
7756
|
+
for (const [name, gate] of this.gates) {
|
|
7757
|
+
const window = wanted.get(name);
|
|
7758
|
+
if (window === void 0) gate.disarm();
|
|
7759
|
+
else gate.arm(window);
|
|
7760
|
+
}
|
|
7761
|
+
return unknown;
|
|
7762
|
+
}
|
|
7763
|
+
/**
|
|
7764
|
+
* Disarm whatever has run out. Called on a timer, NEVER from a log path — a
|
|
7765
|
+
* diagnostic that adds a `Date.now()` to the path it is measuring measures
|
|
7766
|
+
* itself.
|
|
7767
|
+
*
|
|
7768
|
+
* Returns the names it closed, so the caller can write the one line that
|
|
7769
|
+
* says a window ended and stops "it went quiet" from reading as "the branch
|
|
7770
|
+
* was not taken".
|
|
7771
|
+
*/
|
|
7772
|
+
tick(nowMs) {
|
|
7773
|
+
const closed = [];
|
|
7774
|
+
for (const [name, gate] of this.gates) if (gate.on && gate.armedUntilMs <= nowMs) {
|
|
7775
|
+
gate.disarm();
|
|
7776
|
+
closed.push(name);
|
|
7777
|
+
}
|
|
7778
|
+
return closed;
|
|
7779
|
+
}
|
|
7780
|
+
/** The channels armed right now, as the document would describe them. */
|
|
7781
|
+
armed() {
|
|
7782
|
+
const out = [];
|
|
7783
|
+
for (const [name, gate] of this.gates) if (gate.on) out.push({
|
|
7784
|
+
channel: name,
|
|
7785
|
+
armedUntilMs: gate.armedUntilMs,
|
|
7786
|
+
deviceIds: null
|
|
7787
|
+
});
|
|
7788
|
+
return out;
|
|
7789
|
+
}
|
|
7790
|
+
};
|
|
7791
|
+
/**
|
|
7792
|
+
* Process-wide holder for the {@link LogChannelRegistry}.
|
|
7793
|
+
*
|
|
7794
|
+
* Three call sites that never meet need the SAME instance: the hot paths that
|
|
7795
|
+
* declare a gate at module scope, the `log-channels` provider that enumerates
|
|
7796
|
+
* the declarations for the hub, and the same provider applying the windows the
|
|
7797
|
+
* document hands down. A registry built inside any one of them would be
|
|
7798
|
+
* refreshed and collected — the shape of a knob that never does anything.
|
|
7799
|
+
*
|
|
7800
|
+
* Same idiom as `logging-gate.singleton.ts` and
|
|
7801
|
+
* `http-request-census.singleton.ts`.
|
|
7802
|
+
*/
|
|
7803
|
+
var instance = null;
|
|
7804
|
+
/** The process-wide log channel registry. Created empty on first use. */
|
|
7805
|
+
function getLogChannelRegistry() {
|
|
7806
|
+
instance ??= new LogChannelRegistry();
|
|
7807
|
+
return instance;
|
|
7808
|
+
}
|
|
7809
|
+
/**
|
|
7810
|
+
* Declare a channel on the process-wide registry and get its gate.
|
|
7811
|
+
*
|
|
7812
|
+
* The one call an addon makes. Keep the returned gate in a module-scope
|
|
7813
|
+
* `const`: looking a channel up by name per line would put a Map lookup on
|
|
7814
|
+
* exactly the path this mechanism exists to keep free.
|
|
7815
|
+
*
|
|
7816
|
+
* `scripts/check-log-channel-gated.ts` reads these call sites. It pairs the
|
|
7817
|
+
* declared name with the binding it is assigned to and refuses to let a
|
|
7818
|
+
* channel ship that no `<binding>.on` anywhere consults — a declared channel
|
|
7819
|
+
* nobody reads is a knob the operator turns with nothing happening, forever,
|
|
7820
|
+
* and without a line. That is D62, and this repo has now shipped it three
|
|
7821
|
+
* times (`audioThresholdDbfs`, the HA entities with no source, the second
|
|
7822
|
+
* per-camera switch that wrote a store nobody read).
|
|
7823
|
+
*/
|
|
7824
|
+
function declareLogChannel(descriptor) {
|
|
7825
|
+
return getLogChannelRegistry().declare(descriptor);
|
|
7826
|
+
}
|
|
7827
|
+
/**
|
|
7828
|
+
* Build the `log-channels` provider for this process.
|
|
7829
|
+
*
|
|
7830
|
+
* `logger` is used ONLY off the hot path — for the arm/expiry lines — so a
|
|
7831
|
+
* channel that is never armed costs this module nothing but a timer.
|
|
7832
|
+
*/
|
|
7833
|
+
function createLogChannelsProvider(logger, options = {}) {
|
|
7834
|
+
const registry = getLogChannelRegistry();
|
|
7835
|
+
const now = options.now ?? Date.now;
|
|
7836
|
+
const tickMs = options.tickMs ?? 5e3;
|
|
7837
|
+
const timer = setInterval(() => {
|
|
7838
|
+
const closed = registry.tick(now());
|
|
7839
|
+
for (const name of closed) logger.info("log channel window closed", {
|
|
7840
|
+
tags: { logChannel: name },
|
|
7841
|
+
meta: { channel: name }
|
|
7842
|
+
});
|
|
7843
|
+
}, tickMs);
|
|
7844
|
+
timer.unref?.();
|
|
7845
|
+
return {
|
|
7846
|
+
list: () => registry.list(),
|
|
7847
|
+
apply: (input) => {
|
|
7848
|
+
const unknown = registry.apply(input.windows, now());
|
|
7849
|
+
const armed = registry.armed();
|
|
7850
|
+
logger.info("log channels applied", { meta: {
|
|
7851
|
+
armed: armed.map((window) => window.channel),
|
|
7852
|
+
unknown,
|
|
7853
|
+
declared: registry.list().length
|
|
7854
|
+
} });
|
|
7855
|
+
return {
|
|
7856
|
+
armed: armed.length,
|
|
7857
|
+
unknown
|
|
7858
|
+
};
|
|
7859
|
+
},
|
|
7860
|
+
stop: () => {
|
|
7861
|
+
clearInterval(timer);
|
|
7862
|
+
}
|
|
7863
|
+
};
|
|
7864
|
+
}
|
|
7865
|
+
/**
|
|
7510
7866
|
* Ops-log — the durable, append-only operations audit shared by the
|
|
7511
7867
|
* recordings and events management surfaces.
|
|
7512
7868
|
*
|
|
@@ -11314,6 +11670,35 @@ var MutationFilterSchema = object({
|
|
|
11314
11670
|
whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
|
|
11315
11671
|
whereNot: record(string(), unknown()).optional()
|
|
11316
11672
|
});
|
|
11673
|
+
/**
|
|
11674
|
+
* One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
|
|
11675
|
+
*
|
|
11676
|
+
* `as` names the slot in the result, so the SAME column may be asked twice with
|
|
11677
|
+
* two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
|
|
11678
|
+
* a `Record<column, op>` shape could not express.
|
|
11679
|
+
*/
|
|
11680
|
+
var AggregateFieldSchema = object({
|
|
11681
|
+
/** Result key. */
|
|
11682
|
+
as: string().min(1),
|
|
11683
|
+
/** Column to aggregate. Must be a real column of a declared collection. */
|
|
11684
|
+
field: string().min(1),
|
|
11685
|
+
op: _enum([
|
|
11686
|
+
"sum",
|
|
11687
|
+
"min",
|
|
11688
|
+
"max"
|
|
11689
|
+
])
|
|
11690
|
+
});
|
|
11691
|
+
/**
|
|
11692
|
+
* `COUNT(*)` plus one number per requested field.
|
|
11693
|
+
*
|
|
11694
|
+
* `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
|
|
11695
|
+
* that really is 0 are different facts, and an accounting caller that renders
|
|
11696
|
+
* "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
|
|
11697
|
+
*/
|
|
11698
|
+
var AggregateResultSchema = object({
|
|
11699
|
+
count: number().int(),
|
|
11700
|
+
values: record(string(), number().nullable())
|
|
11701
|
+
});
|
|
11317
11702
|
/** A single stored record: `{ id, data }`. */
|
|
11318
11703
|
var SettingsRecordSchema = object({
|
|
11319
11704
|
id: string(),
|
|
@@ -11398,6 +11783,11 @@ method(object({
|
|
|
11398
11783
|
collection: string(),
|
|
11399
11784
|
filter: QueryFilterSchema.optional()
|
|
11400
11785
|
}), number()), method(object({
|
|
11786
|
+
namespace: string().optional(),
|
|
11787
|
+
collection: string(),
|
|
11788
|
+
fields: array(AggregateFieldSchema).readonly(),
|
|
11789
|
+
filter: QueryFilterSchema.optional()
|
|
11790
|
+
}), AggregateResultSchema), method(object({
|
|
11401
11791
|
namespace: string().optional(),
|
|
11402
11792
|
collection: string(),
|
|
11403
11793
|
field: string(),
|
|
@@ -11514,6 +11904,11 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
11514
11904
|
collection: string(),
|
|
11515
11905
|
filter: QueryFilterSchema.optional()
|
|
11516
11906
|
}), number(), { auth: "admin" }), method(object({
|
|
11907
|
+
namespace: string().optional(),
|
|
11908
|
+
collection: string(),
|
|
11909
|
+
fields: array(AggregateFieldSchema).readonly(),
|
|
11910
|
+
filter: QueryFilterSchema.optional()
|
|
11911
|
+
}), AggregateResultSchema, { auth: "admin" }), method(object({
|
|
11517
11912
|
namespace: string().optional(),
|
|
11518
11913
|
collection: string(),
|
|
11519
11914
|
field: string(),
|
|
@@ -12237,24 +12632,6 @@ var deviceProviderCapability = {
|
|
|
12237
12632
|
})
|
|
12238
12633
|
}
|
|
12239
12634
|
};
|
|
12240
|
-
/**
|
|
12241
|
-
* Device Manager capability — hub-side singleton that unifies device persistence,
|
|
12242
|
-
* live registry access, and all management operations into a single tRPC surface.
|
|
12243
|
-
*
|
|
12244
|
-
* Replaces:
|
|
12245
|
-
* - `device-persistence` capability (persistence methods absorbed here)
|
|
12246
|
-
* - `device-management.router.ts` (deleted in Phase 2)
|
|
12247
|
-
* - `device-ops.router.ts` (compat layer — deleted; device-provider ops absorbed here)
|
|
12248
|
-
*
|
|
12249
|
-
* All device provider addons (rtsp, onvif, frigate, …) are hub-local: they may
|
|
12250
|
-
* fork into separate processes but never run on remote cluster agents. Therefore:
|
|
12251
|
-
* - No nodeId routing needed — this is a pure hub singleton.
|
|
12252
|
-
* - The hub's DeviceRegistry is the single source of truth for all live devices.
|
|
12253
|
-
* - No shadow registry or cross-node aggregation required.
|
|
12254
|
-
*
|
|
12255
|
-
* Forked workers register devices back to the hub via `ctx.devices`
|
|
12256
|
-
* (DeviceManagerApi → ctx.api.deviceManager.registerDevice), same as today.
|
|
12257
|
-
*/
|
|
12258
12635
|
/** One child-placement directive on a container's `childLayout`. Structurally
|
|
12259
12636
|
* identical to `ChildLayoutEntry` in `device-management.ts` — the cap wire
|
|
12260
12637
|
* shape for the same field. The child is identified by its re-sync-stable
|
|
@@ -12623,7 +13000,7 @@ method(object({
|
|
|
12623
13000
|
* it answers today and the caller filters as it already does.
|
|
12624
13001
|
*/
|
|
12625
13002
|
deviceIds: array(number()).optional()
|
|
12626
|
-
}), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), object({
|
|
13003
|
+
}), 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({
|
|
12627
13004
|
mode: LinkedDevicesModeSchema,
|
|
12628
13005
|
devices: array(LinkedDeviceSchema)
|
|
12629
13006
|
})), 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({
|
|
@@ -13347,6 +13724,80 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
|
|
|
13347
13724
|
kind: "mutation",
|
|
13348
13725
|
auth: "admin"
|
|
13349
13726
|
});
|
|
13727
|
+
/**
|
|
13728
|
+
* `log-channels` — the capability an addon DECLARES its diagnostic channels
|
|
13729
|
+
* through. It stores nothing.
|
|
13730
|
+
*
|
|
13731
|
+
* ## Why a capability at all, and why this shape
|
|
13732
|
+
*
|
|
13733
|
+
* Which channels exist is knowledge only the addon has: `stream-broker` knows
|
|
13734
|
+
* webrtc/ICE/RTP, `provider-reolink` knows baichuan/handshake. A central list
|
|
13735
|
+
* maintained by hand rots at the first addition and rots INVISIBLY — nothing
|
|
13736
|
+
* fails, an operator just never sees the channel somebody added. So the list
|
|
13737
|
+
* is assembled from declarations at runtime.
|
|
13738
|
+
*
|
|
13739
|
+
* The shape is copied from `log-destination.cap.ts`, which already does
|
|
13740
|
+
* exactly this job: `mode: 'collection'`, `internal: true`,
|
|
13741
|
+
* `mount: { kind: 'skip' }` — no tRPC route, no generated hooks — while
|
|
13742
|
+
* `addons.listCapabilityProviders` still enumerates it, and the hub's
|
|
13743
|
+
* `CapabilityRegistry` still holds an RPC proxy per provider so a forked
|
|
13744
|
+
* runner's declarations reach hub-main over the transport that already exists.
|
|
13745
|
+
* No new UDS message, no second registry.
|
|
13746
|
+
*
|
|
13747
|
+
* ## What it deliberately does NOT own
|
|
13748
|
+
*
|
|
13749
|
+
* The VALUES — which channel is armed, for which cameras, until when — live in
|
|
13750
|
+
* ONE place: the logging settings document on the `system` cap
|
|
13751
|
+
* (`getLoggingSettings` / `setLoggingSettings`). Two authorities over the same
|
|
13752
|
+
* value is the defect the plan behind this work exists to remove, and
|
|
13753
|
+
* `setRequestCensus` was retired (D245) rather than allowed to be a second
|
|
13754
|
+
* one. {@link logChannelsCapability} therefore has no getter for a level, no
|
|
13755
|
+
* setter for a window and no persistence of any kind.
|
|
13756
|
+
*
|
|
13757
|
+
* ## Why `apply` is here even so
|
|
13758
|
+
*
|
|
13759
|
+
* The gate lives in the addon's PROCESS; the document lives in hub-main. Some
|
|
13760
|
+
* seam has to carry the value from the authority to the mirror, and a channel
|
|
13761
|
+
* that cannot be reached is precisely the dead knob this whole slice exists to
|
|
13762
|
+
* make impossible (D62 — `audioThresholdDbfs`, the HA entities with no source).
|
|
13763
|
+
* `apply` is that seam and nothing more: it writes an in-memory mirror, it
|
|
13764
|
+
* persists nothing, it is never the source of a value, and it is called only
|
|
13765
|
+
* with a set the hub actually read (D49 — a read that fails does not call it
|
|
13766
|
+
* at all, so no channel is silently disarmed by a bad read).
|
|
13767
|
+
*/
|
|
13768
|
+
/** What `apply` reports back — enough to log, not enough to be a second state. */
|
|
13769
|
+
var LogChannelApplyResultSchema = object({
|
|
13770
|
+
/** How many declared channels are armed in this process after the call. */
|
|
13771
|
+
armed: number().int().min(0),
|
|
13772
|
+
/**
|
|
13773
|
+
* Names the document armed that this process does not declare. Reported
|
|
13774
|
+
* rather than swallowed: a name here is either a typo or an addon that has
|
|
13775
|
+
* not booted, and both deserve a line instead of silence.
|
|
13776
|
+
*/
|
|
13777
|
+
unknown: array(string()).readonly()
|
|
13778
|
+
});
|
|
13779
|
+
var logChannelsCapability = {
|
|
13780
|
+
name: "log-channels",
|
|
13781
|
+
scope: "system",
|
|
13782
|
+
mode: "collection",
|
|
13783
|
+
internal: true,
|
|
13784
|
+
methods: {
|
|
13785
|
+
/** The channels this addon declares. Inert: no value, no state. */
|
|
13786
|
+
list: method(_void(), array(LogChannelDescriptorSchema).readonly()),
|
|
13787
|
+
/**
|
|
13788
|
+
* Refresh this process's mirror from the document's FULL set of armed
|
|
13789
|
+
* windows.
|
|
13790
|
+
*
|
|
13791
|
+
* Full and not incremental on purpose: the document is the authority, so a
|
|
13792
|
+
* channel it does not name is disarmed here. An incremental apply would
|
|
13793
|
+
* let a disarm get lost in transit and leave a channel running that
|
|
13794
|
+
* nobody can see is running.
|
|
13795
|
+
*/
|
|
13796
|
+
apply: method(object({ windows: array(LogChannelWindowSchema).readonly() }), LogChannelApplyResultSchema, { kind: "mutation" })
|
|
13797
|
+
},
|
|
13798
|
+
/** In-process only — enumerated through `addons.listCapabilityProviders`. */
|
|
13799
|
+
mount: { kind: "skip" }
|
|
13800
|
+
};
|
|
13350
13801
|
var LogLevelSchema = _enum([
|
|
13351
13802
|
"debug",
|
|
13352
13803
|
"info",
|
|
@@ -29180,10 +29631,11 @@ var DiagnosticIdSchema = _enum(["request-census"]);
|
|
|
29180
29631
|
* The layers of the level hierarchy, general → specific. The most specific
|
|
29181
29632
|
* layer that carries an explicit value wins.
|
|
29182
29633
|
*
|
|
29183
|
-
* `component`
|
|
29184
|
-
*
|
|
29185
|
-
*
|
|
29186
|
-
*
|
|
29634
|
+
* `component` became RESOLVABLE on 2026-08-27: a component is a declared log
|
|
29635
|
+
* CHANNEL (`stream-broker.webrtc`, `provider-reolink.baichuan`), named by
|
|
29636
|
+
* `scopeComponent`. It was declared-but-dark in the first slice precisely so
|
|
29637
|
+
* that turning it on would not force every consumer of this document to widen
|
|
29638
|
+
* a `levelSource` enum — which is what has now not happened.
|
|
29187
29639
|
*/
|
|
29188
29640
|
var LoggingScopeKindSchema = _enum([
|
|
29189
29641
|
"cluster",
|
|
@@ -29210,6 +29662,14 @@ var LoggingLevelLayerSchema = object({
|
|
|
29210
29662
|
scope: LoggingScopeKindSchema,
|
|
29211
29663
|
/** The node this layer speaks for; `null` on the cluster layer. */
|
|
29212
29664
|
nodeId: string().nullable(),
|
|
29665
|
+
/**
|
|
29666
|
+
* The declared channel this layer speaks for; `null` on every layer but
|
|
29667
|
+
* `component`. Never folded into `nodeId`: a component level is CLUSTER-WIDE
|
|
29668
|
+
* by design — the convention this repo settled on is one orchestrator-wide
|
|
29669
|
+
* setting, never per node (D52) — so a component layer that carried a node
|
|
29670
|
+
* would invite a per-node copy of a value that has no per-node meaning.
|
|
29671
|
+
*/
|
|
29672
|
+
component: string().nullable(),
|
|
29213
29673
|
/** Explicitly set here, or `null` when this layer inherits. */
|
|
29214
29674
|
level: LogLevelSchema$1.nullable()
|
|
29215
29675
|
});
|
|
@@ -29251,6 +29711,49 @@ var DiagnosticWindowPatchSchema = object({
|
|
|
29251
29711
|
reportEveryMs: number().int().positive().optional()
|
|
29252
29712
|
});
|
|
29253
29713
|
/**
|
|
29714
|
+
* A channel ARMED, as the document reports it.
|
|
29715
|
+
*
|
|
29716
|
+
* `armMs` is not echoed back: what an operator needs to see is the deadline
|
|
29717
|
+
* and the time left, because a diagnostic left running is itself an incident
|
|
29718
|
+
* and "armed for 10 minutes" said an hour ago is not an answer.
|
|
29719
|
+
*/
|
|
29720
|
+
var LogChannelWindowStateSchema = object({
|
|
29721
|
+
channel: string(),
|
|
29722
|
+
armed: boolean(),
|
|
29723
|
+
/** Epoch ms the window closes at. 0 when disarmed. */
|
|
29724
|
+
armedUntilMs: number(),
|
|
29725
|
+
/** Ms left before it expires on its own. 0 when disarmed. */
|
|
29726
|
+
remainingMs: number(),
|
|
29727
|
+
/**
|
|
29728
|
+
* The cameras it is narrowed to, or `null` for every camera.
|
|
29729
|
+
*
|
|
29730
|
+
* A channel declared `perDevice: false` can only ever report `null` here:
|
|
29731
|
+
* its lines do not carry `tags: { deviceId }`, so narrowing them would
|
|
29732
|
+
* produce a filter that silently matches nothing. The server REFUSES such a
|
|
29733
|
+
* patch rather than quietly widening it — ignoring the request would teach
|
|
29734
|
+
* the operator that per-camera filtering works on that channel when it does
|
|
29735
|
+
* not.
|
|
29736
|
+
*/
|
|
29737
|
+
deviceIds: array(number().int()).readonly().nullable()
|
|
29738
|
+
});
|
|
29739
|
+
/**
|
|
29740
|
+
* `armMs: 0` DISARMS. Same grammar as {@link DiagnosticWindowPatchSchema}, and
|
|
29741
|
+
* for the same reason: a channel is a window with a deadline, never a switch.
|
|
29742
|
+
*/
|
|
29743
|
+
var LogChannelWindowPatchSchema = object({
|
|
29744
|
+
channel: string().min(1),
|
|
29745
|
+
armMs: number().int().min(0),
|
|
29746
|
+
/**
|
|
29747
|
+
* Narrow to these numeric device ids. Absent or `null` = every camera.
|
|
29748
|
+
*
|
|
29749
|
+
* Numeric because the repo's own rule makes it possible: every log line
|
|
29750
|
+
* about a device carries `tags: { deviceId }` with the numeric id. That rule
|
|
29751
|
+
* was paid for with a 22% thumbnail gap and a 3-hour media blackout both
|
|
29752
|
+
* diagnosed by hand, and this is the first thing that collects on it.
|
|
29753
|
+
*/
|
|
29754
|
+
deviceIds: array(number().int()).readonly().nullable().optional()
|
|
29755
|
+
});
|
|
29756
|
+
/**
|
|
29254
29757
|
* A PATCH, and patches MERGE.
|
|
29255
29758
|
*
|
|
29256
29759
|
* A field absent from the patch is left exactly as it was — arming a
|
|
@@ -29269,7 +29772,14 @@ var LoggingSettingsPatchSchema = object({
|
|
|
29269
29772
|
* Only the diagnostics NAMED here change. An armed window that is not listed
|
|
29270
29773
|
* keeps running — a patch is never a full replacement.
|
|
29271
29774
|
*/
|
|
29272
|
-
diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional()
|
|
29775
|
+
diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional(),
|
|
29776
|
+
/**
|
|
29777
|
+
* Only the channels NAMED here change. An armed channel that is not listed
|
|
29778
|
+
* keeps running — same rule as `diagnostics`, because a patch that silently
|
|
29779
|
+
* disarmed the channels it did not mention would make the Levels page and
|
|
29780
|
+
* the Diagnostics page fight over the same value.
|
|
29781
|
+
*/
|
|
29782
|
+
channels: array(LogChannelWindowPatchSchema).readonly().optional()
|
|
29273
29783
|
});
|
|
29274
29784
|
/**
|
|
29275
29785
|
* Which LAYER of the hierarchy is addressed. Absent = the cluster layer.
|
|
@@ -29282,9 +29792,22 @@ var LoggingSettingsPatchSchema = object({
|
|
|
29282
29792
|
* authority over the whole hierarchy and answers for every layer, so the
|
|
29283
29793
|
* layer selector needs a name the transport does not already own.
|
|
29284
29794
|
*/
|
|
29285
|
-
var GetLoggingSettingsInputSchema = object({
|
|
29795
|
+
var GetLoggingSettingsInputSchema = object({
|
|
29796
|
+
scopeNodeId: string().optional(),
|
|
29797
|
+
/**
|
|
29798
|
+
* The declared CHANNEL this document is addressed at, when the caller wants
|
|
29799
|
+
* the `component` layer. Absent = the node/cluster hierarchy only.
|
|
29800
|
+
*
|
|
29801
|
+
* Naming it separately rather than overloading `scopeNodeId` keeps the two
|
|
29802
|
+
* axes from collapsing: a component level is cluster-wide, a node level is
|
|
29803
|
+
* not, and one selector for both would make "which of these two did I just
|
|
29804
|
+
* set" unanswerable — the exact ambiguity `explicit` exists to remove.
|
|
29805
|
+
*/
|
|
29806
|
+
scopeComponent: string().optional()
|
|
29807
|
+
});
|
|
29286
29808
|
var SetLoggingSettingsInputSchema = object({
|
|
29287
29809
|
scopeNodeId: string().optional(),
|
|
29810
|
+
scopeComponent: string().optional(),
|
|
29288
29811
|
patch: LoggingSettingsPatchSchema
|
|
29289
29812
|
});
|
|
29290
29813
|
/**
|
|
@@ -29299,9 +29822,20 @@ var SetLoggingSettingsInputSchema = object({
|
|
|
29299
29822
|
var LoggingSettingsStateSchema = object({
|
|
29300
29823
|
/** The layer this document was read at. `null` = the cluster layer. */
|
|
29301
29824
|
scopeNodeId: string().nullable(),
|
|
29825
|
+
/** The channel this document was read at. `null` = no component layer. */
|
|
29826
|
+
scopeComponent: string().nullable(),
|
|
29302
29827
|
effective: LoggingEffectiveSchema,
|
|
29303
29828
|
explicit: LoggingExplicitSchema,
|
|
29304
29829
|
activeWindows: array(DiagnosticWindowSchema).readonly(),
|
|
29830
|
+
/**
|
|
29831
|
+
* Every channel the cluster's addons DECLARE, gathered from the
|
|
29832
|
+
* `log-channels` providers. Not stored anywhere: assembled per read, so a
|
|
29833
|
+
* channel added by a redeployed addon appears without anybody editing a
|
|
29834
|
+
* list, and a channel whose addon is gone stops being offered.
|
|
29835
|
+
*/
|
|
29836
|
+
channels: array(LogChannelDescriptorSchema).readonly(),
|
|
29837
|
+
/** The channels ARMED right now, each with its deadline. */
|
|
29838
|
+
activeChannels: array(LogChannelWindowStateSchema).readonly(),
|
|
29305
29839
|
persisted: boolean()
|
|
29306
29840
|
});
|
|
29307
29841
|
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(), {
|
|
@@ -32453,6 +32987,12 @@ Object.freeze({
|
|
|
32453
32987
|
addonId: null,
|
|
32454
32988
|
access: "view"
|
|
32455
32989
|
},
|
|
32990
|
+
"dataStoreProvider.aggregate": {
|
|
32991
|
+
capName: "data-store-provider",
|
|
32992
|
+
capScope: "system",
|
|
32993
|
+
addonId: null,
|
|
32994
|
+
access: "view"
|
|
32995
|
+
},
|
|
32456
32996
|
"dataStoreProvider.count": {
|
|
32457
32997
|
capName: "data-store-provider",
|
|
32458
32998
|
capScope: "system",
|
|
@@ -32867,6 +33407,12 @@ Object.freeze({
|
|
|
32867
33407
|
addonId: null,
|
|
32868
33408
|
access: "view"
|
|
32869
33409
|
},
|
|
33410
|
+
"deviceManager.getChildrenBatch": {
|
|
33411
|
+
capName: "device-manager",
|
|
33412
|
+
capScope: "system",
|
|
33413
|
+
addonId: null,
|
|
33414
|
+
access: "view"
|
|
33415
|
+
},
|
|
32870
33416
|
"deviceManager.getConfigSchema": {
|
|
32871
33417
|
capName: "device-manager",
|
|
32872
33418
|
capScope: "system",
|
|
@@ -33917,6 +34463,18 @@ Object.freeze({
|
|
|
33917
34463
|
addonId: null,
|
|
33918
34464
|
access: "create"
|
|
33919
34465
|
},
|
|
34466
|
+
"logChannels.apply": {
|
|
34467
|
+
capName: "log-channels",
|
|
34468
|
+
capScope: "system",
|
|
34469
|
+
addonId: null,
|
|
34470
|
+
access: "create"
|
|
34471
|
+
},
|
|
34472
|
+
"logChannels.list": {
|
|
34473
|
+
capName: "log-channels",
|
|
34474
|
+
capScope: "system",
|
|
34475
|
+
addonId: null,
|
|
34476
|
+
access: "view"
|
|
34477
|
+
},
|
|
33920
34478
|
"logDestination.query": {
|
|
33921
34479
|
capName: "log-destination",
|
|
33922
34480
|
capScope: "system",
|
|
@@ -36071,6 +36629,12 @@ Object.freeze({
|
|
|
36071
36629
|
addonId: null,
|
|
36072
36630
|
access: "create"
|
|
36073
36631
|
},
|
|
36632
|
+
"settingsStore.aggregate": {
|
|
36633
|
+
capName: "settings-store",
|
|
36634
|
+
capScope: "system",
|
|
36635
|
+
addonId: null,
|
|
36636
|
+
access: "view"
|
|
36637
|
+
},
|
|
36074
36638
|
"settingsStore.count": {
|
|
36075
36639
|
capName: "settings-store",
|
|
36076
36640
|
capScope: "system",
|
|
@@ -37650,6 +38214,11 @@ Object.freeze({
|
|
|
37650
38214
|
form: "single",
|
|
37651
38215
|
optional: false
|
|
37652
38216
|
}],
|
|
38217
|
+
"deviceManager.getChildrenBatch": [{
|
|
38218
|
+
name: "parentDeviceIds",
|
|
38219
|
+
form: "array",
|
|
38220
|
+
optional: false
|
|
38221
|
+
}],
|
|
37653
38222
|
"deviceManager.getConfigSchema": [{
|
|
37654
38223
|
name: "deviceId",
|
|
37655
38224
|
form: "single",
|
|
@@ -227967,6 +228536,68 @@ function buildInitialStatus(config) {
|
|
|
227967
228536
|
};
|
|
227968
228537
|
}
|
|
227969
228538
|
//#endregion
|
|
228539
|
+
//#region src/log-channels.ts
|
|
228540
|
+
/**
|
|
228541
|
+
* The diagnostic log CHANNELS `provider-reolink` declares.
|
|
228542
|
+
*
|
|
228543
|
+
* Only this addon knows these exist. What "the Baichuan control channel" and
|
|
228544
|
+
* "the login handshake" mean is knowledge of the Reolink provider, and a
|
|
228545
|
+
* central list elsewhere would rot the first time a vendor quirk earns a third
|
|
228546
|
+
* channel — silently, because nothing fails when a list is merely incomplete.
|
|
228547
|
+
*
|
|
228548
|
+
* The VALUE — armed or not, for which cameras, until when — is not here. It
|
|
228549
|
+
* lives in the one logging settings document on the `system` cap. These are
|
|
228550
|
+
* declarations: inert, no state.
|
|
228551
|
+
*
|
|
228552
|
+
* ## Both are honestly per-camera, and here is why
|
|
228553
|
+
*
|
|
228554
|
+
* `ReolinkCamera` logs through `this.ctx.logger`, which the kernel builds as
|
|
228555
|
+
* `logger.child(stableId).withTags({ deviceId })` with the NUMERIC id
|
|
228556
|
+
* (`device-cap-proxy.ts`), and `ScopedLogger` merges its bound tags into every
|
|
228557
|
+
* line. So every line these channels admit carries `tags.deviceId`, and
|
|
228558
|
+
* `| json | deviceId="617"` selects exactly one camera. That is the repo rule
|
|
228559
|
+
* from `CLAUDE.md` — paid for with a 22% thumbnail gap and a 3-hour media
|
|
228560
|
+
* blackout diagnosed by hand — finally paying out.
|
|
228561
|
+
*
|
|
228562
|
+
* The hub's own dispatch lines are a different matter: `reolink-hub.ts` puts
|
|
228563
|
+
* the CHILD's id in `meta` and carries the HUB's id in `tags`, so those lines
|
|
228564
|
+
* are not per-camera filterable. Neither channel below claims them.
|
|
228565
|
+
*/
|
|
228566
|
+
/**
|
|
228567
|
+
* The Baichuan control channel itself: every protocol frame the lib sends and
|
|
228568
|
+
* receives, UDP keepalives, and the sleep-inference ticks on a battery camera.
|
|
228569
|
+
*
|
|
228570
|
+
* Consulted in `ReolinkCamera.getBaichuanDebugOptions`, the single place the
|
|
228571
|
+
* lib's `general` debug option is decided, so arming this channel turns on the
|
|
228572
|
+
* same protocol trace the per-camera `debugGeneral` switch does — through the
|
|
228573
|
+
* same funnel, with a deadline instead of forever.
|
|
228574
|
+
*
|
|
228575
|
+
* The lib is handed `libLoggerAdapter()`, which writes through
|
|
228576
|
+
* `this.ctx.logger.child('nodelink')` — `child()` preserves bound tags, so the
|
|
228577
|
+
* device tag survives and the per-camera promise holds.
|
|
228578
|
+
*/
|
|
228579
|
+
var CH_BAICHUAN = declareLogChannel({
|
|
228580
|
+
name: "provider-reolink.baichuan",
|
|
228581
|
+
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.",
|
|
228582
|
+
defaultLevel: "info",
|
|
228583
|
+
perDevice: true
|
|
228584
|
+
});
|
|
228585
|
+
/**
|
|
228586
|
+
* The login ceremony and the socket lifecycle around it: the pre-login dial,
|
|
228587
|
+
* the battery-camera wake that a login IS, login failures on a per-stream
|
|
228588
|
+
* RFC 4571 socket, and every reconnect that follows one.
|
|
228589
|
+
*
|
|
228590
|
+
* Consulted where the camera decides to dial and where it schedules a
|
|
228591
|
+
* reconnect — the two moments that explain a camera which is "there" in the
|
|
228592
|
+
* UI and answering nothing.
|
|
228593
|
+
*/
|
|
228594
|
+
var CH_HANDSHAKE = declareLogChannel({
|
|
228595
|
+
name: "provider-reolink.handshake",
|
|
228596
|
+
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.",
|
|
228597
|
+
defaultLevel: "info",
|
|
228598
|
+
perDevice: true
|
|
228599
|
+
});
|
|
228600
|
+
//#endregion
|
|
227970
228601
|
//#region src/day-night-mapping.ts
|
|
227971
228602
|
/**
|
|
227972
228603
|
* Maps between the vendor-neutral `day-night` cap's `DayNightMode` and
|
|
@@ -238000,6 +238631,18 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
238000
238631
|
}
|
|
238001
238632
|
});
|
|
238002
238633
|
const debugOptions = this.getBaichuanDebugOptions();
|
|
238634
|
+
if (CH_HANDSHAKE.on && CH_HANDSHAKE.wants(this.id)) CH_HANDSHAKE.log(this.ctx.logger, "baichuan dial", {
|
|
238635
|
+
tags: { deviceId: this.id },
|
|
238636
|
+
meta: {
|
|
238637
|
+
host: String(host),
|
|
238638
|
+
port,
|
|
238639
|
+
transport,
|
|
238640
|
+
hasUid: Boolean(uid),
|
|
238641
|
+
udpDiscoveryMethod: udpDiscoveryMethod ?? null,
|
|
238642
|
+
reconnectAttempts: this.reconnectAttempts,
|
|
238643
|
+
debugOptions: debugOptions === void 0 ? null : Object.keys(debugOptions)
|
|
238644
|
+
}
|
|
238645
|
+
});
|
|
238003
238646
|
this.loginPromise = (async () => {
|
|
238004
238647
|
const api = new ReolinkBaichuanApi({
|
|
238005
238648
|
host,
|
|
@@ -238105,7 +238748,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
238105
238748
|
* object override.
|
|
238106
238749
|
*/
|
|
238107
238750
|
getBaichuanDebugOptions() {
|
|
238108
|
-
const general = this.config.get("debugGeneral") === true;
|
|
238751
|
+
const general = this.config.get("debugGeneral") === true || CH_BAICHUAN.on && CH_BAICHUAN.wants(this.id);
|
|
238109
238752
|
const socketFlags = this.config.get("debugSocketLogs") ?? [];
|
|
238110
238753
|
const opts = {};
|
|
238111
238754
|
if (general) opts.general = true;
|
|
@@ -238387,6 +239030,15 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
238387
239030
|
backoffMs
|
|
238388
239031
|
}
|
|
238389
239032
|
});
|
|
239033
|
+
if (CH_HANDSHAKE.on && CH_HANDSHAKE.wants(this.id)) CH_HANDSHAKE.log(this.ctx.logger, "baichuan reconnect ladder", {
|
|
239034
|
+
tags: { deviceId: this.id },
|
|
239035
|
+
meta: {
|
|
239036
|
+
reason,
|
|
239037
|
+
attempt,
|
|
239038
|
+
backoffMs,
|
|
239039
|
+
hadApi: this.api !== null
|
|
239040
|
+
}
|
|
239041
|
+
});
|
|
238390
239042
|
this.api = null;
|
|
238391
239043
|
this.reconnectTimer = setTimeout(() => {
|
|
238392
239044
|
this.reconnectTimer = null;
|
|
@@ -240232,6 +240884,9 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
|
240232
240884
|
* lifecycle and restarted on settings change.
|
|
240233
240885
|
*/
|
|
240234
240886
|
emailPushServer;
|
|
240887
|
+
/** The `log-channels` provider for this process. Stopped on shutdown so a
|
|
240888
|
+
* diagnostic timer is never the reason a runner refuses to exit. */
|
|
240889
|
+
logChannels;
|
|
240235
240890
|
constructor() {
|
|
240236
240891
|
super({});
|
|
240237
240892
|
}
|
|
@@ -240341,6 +240996,7 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
|
240341
240996
|
throw new Error(`Reolink: ${reason}`);
|
|
240342
240997
|
}
|
|
240343
240998
|
async onShutdown() {
|
|
240999
|
+
this.logChannels?.stop();
|
|
240344
241000
|
await this.emailPushServer?.stop().catch(() => {});
|
|
240345
241001
|
await this.autodetectCache.dispose();
|
|
240346
241002
|
}
|
|
@@ -240360,6 +241016,11 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
|
240360
241016
|
}
|
|
240361
241017
|
async onInitialize() {
|
|
240362
241018
|
const regs = await super.onInitialize();
|
|
241019
|
+
this.logChannels = createLogChannelsProvider(this.ctx.logger.child("log-channels"));
|
|
241020
|
+
regs.push({
|
|
241021
|
+
capability: logChannelsCapability,
|
|
241022
|
+
provider: this.logChannels
|
|
241023
|
+
});
|
|
240363
241024
|
this.subscribe({ category: EventCategory.StreamBrokerOnRequestStreamSourceRefresh }, (event) => {
|
|
240364
241025
|
const data = event.data;
|
|
240365
241026
|
const deviceId = typeof data.deviceId === "number" ? data.deviceId : null;
|