@camstack/addon-provider-reolink 1.2.101 → 1.2.103
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 +892 -759
- package/dist/addon.mjs +892 -759
- package/package.json +1 -1
package/dist/addon.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import * as net2 from "net";
|
|
|
20
20
|
import netImpl from "net";
|
|
21
21
|
import { mkdir } from "fs/promises";
|
|
22
22
|
import os from "node:os";
|
|
23
|
-
//#region ../types/dist/event-category-
|
|
23
|
+
//#region ../types/dist/event-category-CnLqLOKs.mjs
|
|
24
24
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
25
25
|
EventCategory["SystemBoot"] = "system.boot";
|
|
26
26
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -215,6 +215,19 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
215
215
|
EventCategory["ProcessCrashed"] = "process.crashed";
|
|
216
216
|
EventCategory["ProcessRestartScheduled"] = "process.restart_scheduled";
|
|
217
217
|
EventCategory["ProcessRestarted"] = "process.restarted";
|
|
218
|
+
/**
|
|
219
|
+
* The SET of storage locations changed — one was created, edited, enabled,
|
|
220
|
+
* disabled or deleted through `storage.upsertLocation` / `deleteLocation`.
|
|
221
|
+
*
|
|
222
|
+
* Telemetry, not a transaction (D8/D11): every consumer that re-resolves on
|
|
223
|
+
* it must also converge on its own periodic path, because a dropped event
|
|
224
|
+
* must not leave a node writing to yesterday's disk set forever. It exists
|
|
225
|
+
* because there was NO signal at all — an operator who added a second
|
|
226
|
+
* recordings disk in the admin UI got nothing, and the recorder kept its
|
|
227
|
+
* resolved locations until something else happened to re-resolve them
|
|
228
|
+
* (D387). Payload `StorageLocationsChangedPayload`.
|
|
229
|
+
*/
|
|
230
|
+
EventCategory["StorageLocationsChanged"] = "storage.locations-changed";
|
|
218
231
|
EventCategory["RecordingStarted"] = "recording.started";
|
|
219
232
|
EventCategory["RecordingStopped"] = "recording.stopped";
|
|
220
233
|
EventCategory["RecordingError"] = "recording.error";
|
|
@@ -7648,362 +7661,6 @@ var CameraSwitchGroupSchema = object({
|
|
|
7648
7661
|
fetchedAt: number()
|
|
7649
7662
|
});
|
|
7650
7663
|
/**
|
|
7651
|
-
* Per-component log CHANNELS — the gate a hot path consults, and the registry
|
|
7652
|
-
* an addon declares its channels in.
|
|
7653
|
-
*
|
|
7654
|
-
* ## Two axes, deliberately separated
|
|
7655
|
-
*
|
|
7656
|
-
* - **DECLARATION** — which channels exist. Only the addon knows:
|
|
7657
|
-
* `stream-broker` knows webrtc/ICE/RTP, `provider-reolink` knows
|
|
7658
|
-
* baichuan/handshake. A hand-wired central list rots at the first addition,
|
|
7659
|
-
* and rots silently. So a channel is declared where it is consulted, and the
|
|
7660
|
-
* `log-channels` capability enumerates the declarations.
|
|
7661
|
-
* - **VALUE** — at which level, for which scope, until when. That stays ONE
|
|
7662
|
-
* thing: the logging settings document on the `system` cap. Two authorities
|
|
7663
|
-
* over the values is the exact defect
|
|
7664
|
-
* `docs/design/plans/2026-08-26-logging-per-componente.md` was written to
|
|
7665
|
-
* remove; re-introducing it from the cure side would be grotesque.
|
|
7666
|
-
*
|
|
7667
|
-
* Nothing in this file reads a clock, an env var or a store. The registry is
|
|
7668
|
-
* a MIRROR: it is moved only by {@link LogChannelRegistry.apply}, called off
|
|
7669
|
-
* the hot path with a value somebody actually read, and by
|
|
7670
|
-
* {@link LogChannelRegistry.tick}, called on a timer. A store read that fails
|
|
7671
|
-
* never reaches here, so it can neither disarm an armed channel nor arm a
|
|
7672
|
-
* disarmed one (D49).
|
|
7673
|
-
*
|
|
7674
|
-
* ## The canonical call shape
|
|
7675
|
-
*
|
|
7676
|
-
* ```ts
|
|
7677
|
-
* if (CH_RTP.on && CH_RTP.wants(deviceId)) {
|
|
7678
|
-
* CH_RTP.log(logger, 'rtp subscriber added', { tags: { deviceId }, meta: { ssrc } })
|
|
7679
|
-
* }
|
|
7680
|
-
* ```
|
|
7681
|
-
*
|
|
7682
|
-
* `on` is a plain boolean FIELD — never a getter — and it is the FIRST thing
|
|
7683
|
-
* read. Disarmed, a call site costs one load and one branch, and the `extras`
|
|
7684
|
-
* object literal is never constructed because it lives inside the branch. It
|
|
7685
|
-
* is the same shape already proven in production at `stream-broker.ts:1650`,
|
|
7686
|
-
* and the same discipline `LoggingGate.allowsDestination` uses for the
|
|
7687
|
-
* destination floor (measured at 1.93 ns/call when off).
|
|
7688
|
-
*
|
|
7689
|
-
* ## Why a channel emits at `info`
|
|
7690
|
-
*
|
|
7691
|
-
* `loki-logging.addon.ts` pins the destination default at `info` and
|
|
7692
|
-
* `loki-destination.ts` drops everything below it, so a line emitted at
|
|
7693
|
-
* `debug` never reaches Loki and the hub's in-memory ring only holds ~35
|
|
7694
|
-
* minutes. A diagnostic that cannot be read an hour later is worse than no
|
|
7695
|
-
* diagnostic, because it looks done. {@link LogChannelGate.log} therefore
|
|
7696
|
-
* emits at the channel's declared level, whose schema floor is `info`.
|
|
7697
|
-
*/
|
|
7698
|
-
/**
|
|
7699
|
-
* The level a channel writes at once armed.
|
|
7700
|
-
*
|
|
7701
|
-
* `debug` is absent ON PURPOSE and not by omission: below `info` the line does
|
|
7702
|
-
* not leave the process for Loki, and the whole point of arming a channel is
|
|
7703
|
-
* to read it later.
|
|
7704
|
-
*/
|
|
7705
|
-
var LogChannelLevelSchema = _enum([
|
|
7706
|
-
"info",
|
|
7707
|
-
"warn",
|
|
7708
|
-
"error"
|
|
7709
|
-
]);
|
|
7710
|
-
/**
|
|
7711
|
-
* What an addon declares about one channel. No value, no state — a
|
|
7712
|
-
* declaration is inert.
|
|
7713
|
-
*/
|
|
7714
|
-
var LogChannelDescriptorSchema = object({
|
|
7715
|
-
/**
|
|
7716
|
-
* Dotted `area.thing`, unique across the workspace. `area` is conventionally
|
|
7717
|
-
* the addon's short name so an operator reading a channel list can tell who
|
|
7718
|
-
* owns it without a second lookup.
|
|
7719
|
-
*/
|
|
7720
|
-
name: string().min(3).regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/, "a channel name is dotted lower-kebab, e.g. area.thing"),
|
|
7721
|
-
/** One sentence: what the operator will SEE after arming it. */
|
|
7722
|
-
description: string().min(1),
|
|
7723
|
-
/** The level its lines are emitted at. Never below `info`. */
|
|
7724
|
-
defaultLevel: LogChannelLevelSchema,
|
|
7725
|
-
/**
|
|
7726
|
-
* Whether this channel can be narrowed to a camera.
|
|
7727
|
-
*
|
|
7728
|
-
* `true` is a PROMISE with two halves, and both must hold: the gate is
|
|
7729
|
-
* consulted with the numeric device id, AND every line the channel admits
|
|
7730
|
-
* carries `tags: { deviceId }` with that same numeric id. The second half is
|
|
7731
|
-
* what makes `| json | deviceId="617"` work in Loki — `loki-payload.ts`
|
|
7732
|
-
* keeps `deviceId` out of the stream labels for cardinality, so the tag in
|
|
7733
|
-
* the body is the only way to filter.
|
|
7734
|
-
*
|
|
7735
|
-
* A channel whose lines carry the device only in `meta` (or not at all) is
|
|
7736
|
-
* declared `false`. Declaring it `true` anyway would be a lie the UI repeats:
|
|
7737
|
-
* the operator narrows to one camera, sees nothing, and concludes the code
|
|
7738
|
-
* path was never taken.
|
|
7739
|
-
*/
|
|
7740
|
-
perDevice: boolean()
|
|
7741
|
-
});
|
|
7742
|
-
/**
|
|
7743
|
-
* An armed window over one channel, as the document hands it to a mirror.
|
|
7744
|
-
*
|
|
7745
|
-
* A window is a DEADLINE, never a flag (ADR-0244): a channel somebody forgot
|
|
7746
|
-
* expires by itself, which is the one failure a boolean cannot avoid.
|
|
7747
|
-
*/
|
|
7748
|
-
var LogChannelWindowSchema = object({
|
|
7749
|
-
channel: string().min(1),
|
|
7750
|
-
/** Epoch ms the window closes at. */
|
|
7751
|
-
armedUntilMs: number(),
|
|
7752
|
-
/** `null` = every camera. A non-empty list narrows to those numeric ids. */
|
|
7753
|
-
deviceIds: array(number().int()).readonly().nullable()
|
|
7754
|
-
});
|
|
7755
|
-
/**
|
|
7756
|
-
* The gate a hot path holds.
|
|
7757
|
-
*
|
|
7758
|
-
* Obtain it ONCE — at module scope or in a constructor — and keep the
|
|
7759
|
-
* reference. Looking a channel up by name per line would put a Map lookup on
|
|
7760
|
-
* the path this class exists to keep free.
|
|
7761
|
-
*/
|
|
7762
|
-
var LogChannelGate = class {
|
|
7763
|
-
descriptor;
|
|
7764
|
-
/**
|
|
7765
|
-
* HOT PATH GUARD. A plain data FIELD, and it must stay one.
|
|
7766
|
-
*
|
|
7767
|
-
* `log-channel.spec.ts` asserts the property descriptor has no getter and
|
|
7768
|
-
* booby-traps the device set, so turning this into an accessor — or reading
|
|
7769
|
-
* anything before it — fails the spec instead of taxing every line the
|
|
7770
|
-
* process emits.
|
|
7771
|
-
*/
|
|
7772
|
-
on = false;
|
|
7773
|
-
/** `null` while armed for every camera. Never read while `on` is false. */
|
|
7774
|
-
devices = null;
|
|
7775
|
-
level;
|
|
7776
|
-
closesAtMs = 0;
|
|
7777
|
-
constructor(descriptor) {
|
|
7778
|
-
this.descriptor = descriptor;
|
|
7779
|
-
this.level = descriptor.defaultLevel;
|
|
7780
|
-
}
|
|
7781
|
-
/** Epoch ms this channel disarms itself at. 0 when disarmed. */
|
|
7782
|
-
get armedUntilMs() {
|
|
7783
|
-
return this.on ? this.closesAtMs : 0;
|
|
7784
|
-
}
|
|
7785
|
-
/**
|
|
7786
|
-
* Does this channel want a line about `deviceId`?
|
|
7787
|
-
*
|
|
7788
|
-
* Call it only behind `gate.on &&`. On its own it is still correct — the
|
|
7789
|
-
* guard is repeated inside — but the point of the prefix is that a disarmed
|
|
7790
|
-
* channel must not pay the call at all.
|
|
7791
|
-
*/
|
|
7792
|
-
wants(deviceId) {
|
|
7793
|
-
if (!this.on) return false;
|
|
7794
|
-
return this.devices === null || this.devices.has(deviceId);
|
|
7795
|
-
}
|
|
7796
|
-
/**
|
|
7797
|
-
* Emit one line on this channel, at the channel's declared level.
|
|
7798
|
-
*
|
|
7799
|
-
* The channel name is added as `tags.logChannel` so LogQL can select the
|
|
7800
|
-
* channel without matching on the message text, and whatever `tags` the
|
|
7801
|
-
* caller passed — `deviceId` above all — is preserved.
|
|
7802
|
-
*/
|
|
7803
|
-
log(logger, message, extras) {
|
|
7804
|
-
if (!this.on) return;
|
|
7805
|
-
const tags = {
|
|
7806
|
-
...extras.tags,
|
|
7807
|
-
logChannel: this.descriptor.name
|
|
7808
|
-
};
|
|
7809
|
-
const line = {
|
|
7810
|
-
...extras,
|
|
7811
|
-
tags
|
|
7812
|
-
};
|
|
7813
|
-
if (this.level === "error") logger.error(message, line);
|
|
7814
|
-
else if (this.level === "warn") logger.warn(message, line);
|
|
7815
|
-
else logger.info(message, line);
|
|
7816
|
-
}
|
|
7817
|
-
/**
|
|
7818
|
-
* Arm (or RE-arm, restarting) this channel. Off the hot path only.
|
|
7819
|
-
*
|
|
7820
|
-
* An empty `deviceIds` list is treated as "every camera" rather than "no
|
|
7821
|
-
* camera": a window that matches nothing is indistinguishable from a
|
|
7822
|
-
* disarmed one, and the operator who asked for it would wait for lines that
|
|
7823
|
-
* can never come.
|
|
7824
|
-
*/
|
|
7825
|
-
arm(window) {
|
|
7826
|
-
const ids = window.deviceIds;
|
|
7827
|
-
this.devices = ids === null || ids.length === 0 ? null : new Set(ids);
|
|
7828
|
-
this.closesAtMs = window.armedUntilMs;
|
|
7829
|
-
this.on = true;
|
|
7830
|
-
}
|
|
7831
|
-
/** Disarm. Off the hot path only. */
|
|
7832
|
-
disarm() {
|
|
7833
|
-
this.on = false;
|
|
7834
|
-
this.devices = null;
|
|
7835
|
-
this.closesAtMs = 0;
|
|
7836
|
-
}
|
|
7837
|
-
};
|
|
7838
|
-
/**
|
|
7839
|
-
* Every channel this PROCESS declares, and the mirror of what is armed on it.
|
|
7840
|
-
*
|
|
7841
|
-
* One per process. A forked runner has its own, and it is refreshed through
|
|
7842
|
-
* the `log-channels` capability by the hub that owns the document — the
|
|
7843
|
-
* registry never reaches for a value itself.
|
|
7844
|
-
*/
|
|
7845
|
-
var LogChannelRegistry = class {
|
|
7846
|
-
gates = /* @__PURE__ */ new Map();
|
|
7847
|
-
/**
|
|
7848
|
-
* Declare a channel and get its gate.
|
|
7849
|
-
*
|
|
7850
|
-
* A duplicate name throws. Two declarations of one name is a programming
|
|
7851
|
-
* error, not a merge: the operator would arm one and the other would stay
|
|
7852
|
-
* dark, which is the dead-knob shape (D62) with an extra step.
|
|
7853
|
-
*/
|
|
7854
|
-
declare(descriptor) {
|
|
7855
|
-
const parsed = LogChannelDescriptorSchema.parse(descriptor);
|
|
7856
|
-
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`);
|
|
7857
|
-
const gate = new LogChannelGate(parsed);
|
|
7858
|
-
this.gates.set(parsed.name, gate);
|
|
7859
|
-
return gate;
|
|
7860
|
-
}
|
|
7861
|
-
/** The declarations, sorted by name so a list is stable to read and diff. */
|
|
7862
|
-
list() {
|
|
7863
|
-
return [...this.gates.values()].map((gate) => gate.descriptor).sort((a, b) => a.name.localeCompare(b.name));
|
|
7864
|
-
}
|
|
7865
|
-
/** The gate for a declared channel, or `undefined`. */
|
|
7866
|
-
gate(name) {
|
|
7867
|
-
return this.gates.get(name);
|
|
7868
|
-
}
|
|
7869
|
-
/**
|
|
7870
|
-
* Apply the FULL set of armed windows. Off the hot path.
|
|
7871
|
-
*
|
|
7872
|
-
* Full, not incremental, and that is the whole design: the document is the
|
|
7873
|
-
* authority, so a channel the document does not name is disarmed here. An
|
|
7874
|
-
* incremental apply would let a disarm get lost in transit and leave a
|
|
7875
|
-
* channel running that nobody can see is running.
|
|
7876
|
-
*
|
|
7877
|
-
* A window already past its deadline is ignored rather than armed — a
|
|
7878
|
-
* restore that re-armed an expired window would make a forgotten diagnostic
|
|
7879
|
-
* immortal across restarts.
|
|
7880
|
-
*
|
|
7881
|
-
* Returns the names it could not place, so the caller can log them: a
|
|
7882
|
-
* channel named in the document that this process does not declare is
|
|
7883
|
-
* either a typo or an addon that has not booted yet, and both deserve a
|
|
7884
|
-
* line rather than silence.
|
|
7885
|
-
*/
|
|
7886
|
-
apply(windows, nowMs) {
|
|
7887
|
-
const wanted = /* @__PURE__ */ new Map();
|
|
7888
|
-
const unknown = [];
|
|
7889
|
-
for (const window of windows) {
|
|
7890
|
-
if (window.armedUntilMs <= nowMs) continue;
|
|
7891
|
-
if (!this.gates.has(window.channel)) {
|
|
7892
|
-
unknown.push(window.channel);
|
|
7893
|
-
continue;
|
|
7894
|
-
}
|
|
7895
|
-
wanted.set(window.channel, window);
|
|
7896
|
-
}
|
|
7897
|
-
for (const [name, gate] of this.gates) {
|
|
7898
|
-
const window = wanted.get(name);
|
|
7899
|
-
if (window === void 0) gate.disarm();
|
|
7900
|
-
else gate.arm(window);
|
|
7901
|
-
}
|
|
7902
|
-
return unknown;
|
|
7903
|
-
}
|
|
7904
|
-
/**
|
|
7905
|
-
* Disarm whatever has run out. Called on a timer, NEVER from a log path — a
|
|
7906
|
-
* diagnostic that adds a `Date.now()` to the path it is measuring measures
|
|
7907
|
-
* itself.
|
|
7908
|
-
*
|
|
7909
|
-
* Returns the names it closed, so the caller can write the one line that
|
|
7910
|
-
* says a window ended and stops "it went quiet" from reading as "the branch
|
|
7911
|
-
* was not taken".
|
|
7912
|
-
*/
|
|
7913
|
-
tick(nowMs) {
|
|
7914
|
-
const closed = [];
|
|
7915
|
-
for (const [name, gate] of this.gates) if (gate.on && gate.armedUntilMs <= nowMs) {
|
|
7916
|
-
gate.disarm();
|
|
7917
|
-
closed.push(name);
|
|
7918
|
-
}
|
|
7919
|
-
return closed;
|
|
7920
|
-
}
|
|
7921
|
-
/** The channels armed right now, as the document would describe them. */
|
|
7922
|
-
armed() {
|
|
7923
|
-
const out = [];
|
|
7924
|
-
for (const [name, gate] of this.gates) if (gate.on) out.push({
|
|
7925
|
-
channel: name,
|
|
7926
|
-
armedUntilMs: gate.armedUntilMs,
|
|
7927
|
-
deviceIds: null
|
|
7928
|
-
});
|
|
7929
|
-
return out;
|
|
7930
|
-
}
|
|
7931
|
-
};
|
|
7932
|
-
/**
|
|
7933
|
-
* Process-wide holder for the {@link LogChannelRegistry}.
|
|
7934
|
-
*
|
|
7935
|
-
* Three call sites that never meet need the SAME instance: the hot paths that
|
|
7936
|
-
* declare a gate at module scope, the `log-channels` provider that enumerates
|
|
7937
|
-
* the declarations for the hub, and the same provider applying the windows the
|
|
7938
|
-
* document hands down. A registry built inside any one of them would be
|
|
7939
|
-
* refreshed and collected — the shape of a knob that never does anything.
|
|
7940
|
-
*
|
|
7941
|
-
* Same idiom as `logging-gate.singleton.ts` and
|
|
7942
|
-
* `http-request-census.singleton.ts`.
|
|
7943
|
-
*/
|
|
7944
|
-
var instance = null;
|
|
7945
|
-
/** The process-wide log channel registry. Created empty on first use. */
|
|
7946
|
-
function getLogChannelRegistry() {
|
|
7947
|
-
instance ??= new LogChannelRegistry();
|
|
7948
|
-
return instance;
|
|
7949
|
-
}
|
|
7950
|
-
/**
|
|
7951
|
-
* Declare a channel on the process-wide registry and get its gate.
|
|
7952
|
-
*
|
|
7953
|
-
* The one call an addon makes. Keep the returned gate in a module-scope
|
|
7954
|
-
* `const`: looking a channel up by name per line would put a Map lookup on
|
|
7955
|
-
* exactly the path this mechanism exists to keep free.
|
|
7956
|
-
*
|
|
7957
|
-
* `scripts/check-log-channel-gated.ts` reads these call sites. It pairs the
|
|
7958
|
-
* declared name with the binding it is assigned to and refuses to let a
|
|
7959
|
-
* channel ship that no `<binding>.on` anywhere consults — a declared channel
|
|
7960
|
-
* nobody reads is a knob the operator turns with nothing happening, forever,
|
|
7961
|
-
* and without a line. That is D62, and this repo has now shipped it three
|
|
7962
|
-
* times (`audioThresholdDbfs`, the HA entities with no source, the second
|
|
7963
|
-
* per-camera switch that wrote a store nobody read).
|
|
7964
|
-
*/
|
|
7965
|
-
function declareLogChannel(descriptor) {
|
|
7966
|
-
return getLogChannelRegistry().declare(descriptor);
|
|
7967
|
-
}
|
|
7968
|
-
/**
|
|
7969
|
-
* Build the `log-channels` provider for this process.
|
|
7970
|
-
*
|
|
7971
|
-
* `logger` is used ONLY off the hot path — for the arm/expiry lines — so a
|
|
7972
|
-
* channel that is never armed costs this module nothing but a timer.
|
|
7973
|
-
*/
|
|
7974
|
-
function createLogChannelsProvider(logger, options = {}) {
|
|
7975
|
-
const registry = getLogChannelRegistry();
|
|
7976
|
-
const now = options.now ?? Date.now;
|
|
7977
|
-
const tickMs = options.tickMs ?? 5e3;
|
|
7978
|
-
const timer = setInterval(() => {
|
|
7979
|
-
const closed = registry.tick(now());
|
|
7980
|
-
for (const name of closed) logger.info("log channel window closed", {
|
|
7981
|
-
tags: { logChannel: name },
|
|
7982
|
-
meta: { channel: name }
|
|
7983
|
-
});
|
|
7984
|
-
}, tickMs);
|
|
7985
|
-
timer.unref?.();
|
|
7986
|
-
return {
|
|
7987
|
-
list: () => registry.list(),
|
|
7988
|
-
apply: (input) => {
|
|
7989
|
-
const unknown = registry.apply(input.windows, now());
|
|
7990
|
-
const armed = registry.armed();
|
|
7991
|
-
logger.info("log channels applied", { meta: {
|
|
7992
|
-
armed: armed.map((window) => window.channel),
|
|
7993
|
-
unknown,
|
|
7994
|
-
declared: registry.list().length
|
|
7995
|
-
} });
|
|
7996
|
-
return {
|
|
7997
|
-
armed: armed.length,
|
|
7998
|
-
unknown
|
|
7999
|
-
};
|
|
8000
|
-
},
|
|
8001
|
-
stop: () => {
|
|
8002
|
-
clearInterval(timer);
|
|
8003
|
-
}
|
|
8004
|
-
};
|
|
8005
|
-
}
|
|
8006
|
-
/**
|
|
8007
7664
|
* Ops-log — the durable, append-only operations audit shared by the
|
|
8008
7665
|
* recordings and events management surfaces.
|
|
8009
7666
|
*
|
|
@@ -8925,6 +8582,21 @@ var StorageCleanupJobSchema = object({
|
|
|
8925
8582
|
});
|
|
8926
8583
|
var StorageCleanupStatusInputSchema = object({ jobId: string().optional() });
|
|
8927
8584
|
/**
|
|
8585
|
+
* The one typed state of a storage location. Authoritative Zod schema — the TS
|
|
8586
|
+
* alias below is `z.infer<>` of it, never a second spelling.
|
|
8587
|
+
*/
|
|
8588
|
+
var StorageLocationModeSchema = _enum([
|
|
8589
|
+
"active",
|
|
8590
|
+
"readonly",
|
|
8591
|
+
"drain",
|
|
8592
|
+
"disabled"
|
|
8593
|
+
]);
|
|
8594
|
+
_enum([
|
|
8595
|
+
"normal",
|
|
8596
|
+
"never",
|
|
8597
|
+
"drain"
|
|
8598
|
+
]);
|
|
8599
|
+
/**
|
|
8928
8600
|
* `StorageLocationType` — an addon-declared id that identifies the *kind* of
|
|
8929
8601
|
* storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
|
|
8930
8602
|
* so the persisted record schema and the consumer-facing cap can both consume it
|
|
@@ -8949,8 +8621,11 @@ var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
|
|
|
8949
8621
|
* `STORAGE_LOCATION_CARDINALITY` map has been removed.
|
|
8950
8622
|
*
|
|
8951
8623
|
* `id` is a stable namespaced string of the form `<type>:<slug>`.
|
|
8952
|
-
* The
|
|
8953
|
-
*
|
|
8624
|
+
* The seed names its first instance `<type>:default` — a NAME, not a flag.
|
|
8625
|
+
* There is no default location any more (D383): `enabled` is the whole write
|
|
8626
|
+
* model, and a bare type ref resolves to the sole location of the type, or —
|
|
8627
|
+
* transitionally, only while legacy NULL-stamped rows exist — to the row whose
|
|
8628
|
+
* slug is `default`.
|
|
8954
8629
|
*
|
|
8955
8630
|
* `isSystem` is a legacy persisted flag. Seed still creates the initial
|
|
8956
8631
|
* `<type>:default` locations; the flag is no longer a lock, a badge, or a
|
|
@@ -8971,23 +8646,37 @@ var StorageLocationSchema = object({
|
|
|
8971
8646
|
* flag at upsert time, not here (the schema is provider-agnostic).
|
|
8972
8647
|
*/
|
|
8973
8648
|
nodeId: string().optional(),
|
|
8974
|
-
isDefault: boolean().default(false),
|
|
8975
8649
|
isSystem: boolean().default(false),
|
|
8976
8650
|
/**
|
|
8977
|
-
*
|
|
8978
|
-
*
|
|
8979
|
-
*
|
|
8980
|
-
*
|
|
8981
|
-
*
|
|
8651
|
+
* THE write switch, and the only one (D383). `enabled: true` means every
|
|
8652
|
+
* consumer that chooses a write target for this type may write here, and all
|
|
8653
|
+
* enabled locations of a type are used TOGETHER; `false` means read-only —
|
|
8654
|
+
* still read, still played back, still age-swept, still drained, never
|
|
8655
|
+
* written.
|
|
8982
8656
|
*
|
|
8983
|
-
* OPTIONAL
|
|
8984
|
-
*
|
|
8985
|
-
*
|
|
8986
|
-
*
|
|
8987
|
-
*
|
|
8988
|
-
*
|
|
8657
|
+
* OPTIONAL only for the wire: an upsert that omits it means "leave what is
|
|
8658
|
+
* stored" on an update and "born inert unless it is the first location of its
|
|
8659
|
+
* type" on a create. On a PERSISTED row absence is legacy and it means
|
|
8660
|
+
* enabled — {@link isLocationEnabled} is the one place that says so, and the
|
|
8661
|
+
* orchestrator stamps every flagless row `true` once at hydrate so absence
|
|
8662
|
+
* stops existing rather than being re-derived on every read.
|
|
8989
8663
|
*/
|
|
8990
8664
|
enabled: boolean().optional(),
|
|
8665
|
+
/**
|
|
8666
|
+
* THE state of this location (D385), and the only authority on what may be
|
|
8667
|
+
* written, read or evicted here. Interpreted in exactly one place —
|
|
8668
|
+
* `storage-location-mode.ts` — which also folds the legacy
|
|
8669
|
+
* `enabled` / `config.readOnly` pair into a mode so an old row is never
|
|
8670
|
+
* ambiguous.
|
|
8671
|
+
*
|
|
8672
|
+
* OPTIONAL only for the wire and for rows written before D385: absence is
|
|
8673
|
+
* resolved by `resolveLocationMode`, and the orchestrator stamps every
|
|
8674
|
+
* unstamped row ONCE at hydrate so absence stops existing rather than being
|
|
8675
|
+
* re-derived on every read. `enabled` survives one release as a DERIVED
|
|
8676
|
+
* mirror (`mode === 'active'`); `withLocationMode` is the only writer of
|
|
8677
|
+
* either, so the two cannot disagree.
|
|
8678
|
+
*/
|
|
8679
|
+
mode: StorageLocationModeSchema.optional(),
|
|
8991
8680
|
/** COMPUTED at read time by the orchestrator (statfs of the backing volume
|
|
8992
8681
|
* for node-local locations it can reach) — never persisted, absent when the
|
|
8993
8682
|
* volume is remote/unreachable. The single capacity truth every UI reads. */
|
|
@@ -8995,13 +8684,50 @@ var StorageLocationSchema = object({
|
|
|
8995
8684
|
totalBytes: number(),
|
|
8996
8685
|
availableBytes: number()
|
|
8997
8686
|
}).nullable().optional(),
|
|
8687
|
+
/**
|
|
8688
|
+
* How much of that volume CamStack ITSELF holds on this location (D388) —
|
|
8689
|
+
* COMPUTED at read time from the `storage-occupancy` providers' own figures,
|
|
8690
|
+
* never persisted, never a filesystem walk.
|
|
8691
|
+
*
|
|
8692
|
+
* **ABSENT MEANS UNKNOWN, never zero.** No provider has reported for this
|
|
8693
|
+
* location yet — nobody stores here, the owning addon is down, or the first
|
|
8694
|
+
* refresh has not completed. A UI must omit the segment rather than draw it
|
|
8695
|
+
* at zero, which would claim we occupy nothing (D315). It is an OBJECT and
|
|
8696
|
+
* not a bare number precisely so that a `?? 0` on the consuming side has to
|
|
8697
|
+
* be spelled out loud instead of appearing by accident.
|
|
8698
|
+
*
|
|
8699
|
+
* `measuredAtMs` is the OLDEST contributing measurement, so it is honest
|
|
8700
|
+
* about the whole figure rather than about its freshest part.
|
|
8701
|
+
*/
|
|
8702
|
+
owned: object({
|
|
8703
|
+
bytes: number().int().nonnegative(),
|
|
8704
|
+
measuredAtMs: number().int().nonnegative()
|
|
8705
|
+
}).optional(),
|
|
8998
8706
|
createdAt: number(),
|
|
8999
8707
|
updatedAt: number()
|
|
9000
8708
|
});
|
|
8709
|
+
object({ isDefault: boolean().optional() });
|
|
8710
|
+
/**
|
|
8711
|
+
* How far a `drain` has got (D386) — the read a UI renders, and nothing more.
|
|
8712
|
+
*
|
|
8713
|
+
* `estimatedEmptyAtMs` is derived from the growth the ratchet has actually
|
|
8714
|
+
* OBSERVED and is `null` when it has observed none. Never a fabricated date: a
|
|
8715
|
+
* drain with no observed growth has no honest ETA, and inventing one is how an
|
|
8716
|
+
* operator learns not to believe the screen.
|
|
8717
|
+
*/
|
|
8718
|
+
var StorageDrainProgressSchema = object({
|
|
8719
|
+
locationId: string(),
|
|
8720
|
+
startedAtMs: number(),
|
|
8721
|
+
startBytes: number(),
|
|
8722
|
+
bytesRemaining: number(),
|
|
8723
|
+
drained: boolean(),
|
|
8724
|
+
estimatedEmptyAtMs: number().nullable()
|
|
8725
|
+
});
|
|
9001
8726
|
/**
|
|
9002
8727
|
* Reference accepted by consumer-facing `api.storage.*` calls.
|
|
9003
8728
|
* Either:
|
|
9004
|
-
* - a `StorageLocationType` (e.g. `'backups'`) →
|
|
8729
|
+
* - a `StorageLocationType` (e.g. `'backups'`) → the sole location of that type
|
|
8730
|
+
* (transitionally, the `<type>:default`-slugged row when several exist)
|
|
9005
8731
|
* - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
|
|
9006
8732
|
*
|
|
9007
8733
|
* The orchestrator's `resolveRef(ref)` handles both cases.
|
|
@@ -9353,6 +9079,362 @@ function findTimezone(id) {
|
|
|
9353
9079
|
return TIMEZONES.find((tz) => tz.id === id);
|
|
9354
9080
|
}
|
|
9355
9081
|
/**
|
|
9082
|
+
* Per-component log CHANNELS — the gate a hot path consults, and the registry
|
|
9083
|
+
* an addon declares its channels in.
|
|
9084
|
+
*
|
|
9085
|
+
* ## Two axes, deliberately separated
|
|
9086
|
+
*
|
|
9087
|
+
* - **DECLARATION** — which channels exist. Only the addon knows:
|
|
9088
|
+
* `stream-broker` knows webrtc/ICE/RTP, `provider-reolink` knows
|
|
9089
|
+
* baichuan/handshake. A hand-wired central list rots at the first addition,
|
|
9090
|
+
* and rots silently. So a channel is declared where it is consulted, and the
|
|
9091
|
+
* `log-channels` capability enumerates the declarations.
|
|
9092
|
+
* - **VALUE** — at which level, for which scope, until when. That stays ONE
|
|
9093
|
+
* thing: the logging settings document on the `system` cap. Two authorities
|
|
9094
|
+
* over the values is the exact defect
|
|
9095
|
+
* `docs/design/plans/2026-08-26-logging-per-componente.md` was written to
|
|
9096
|
+
* remove; re-introducing it from the cure side would be grotesque.
|
|
9097
|
+
*
|
|
9098
|
+
* Nothing in this file reads a clock, an env var or a store. The registry is
|
|
9099
|
+
* a MIRROR: it is moved only by {@link LogChannelRegistry.apply}, called off
|
|
9100
|
+
* the hot path with a value somebody actually read, and by
|
|
9101
|
+
* {@link LogChannelRegistry.tick}, called on a timer. A store read that fails
|
|
9102
|
+
* never reaches here, so it can neither disarm an armed channel nor arm a
|
|
9103
|
+
* disarmed one (D49).
|
|
9104
|
+
*
|
|
9105
|
+
* ## The canonical call shape
|
|
9106
|
+
*
|
|
9107
|
+
* ```ts
|
|
9108
|
+
* if (CH_RTP.on && CH_RTP.wants(deviceId)) {
|
|
9109
|
+
* CH_RTP.log(logger, 'rtp subscriber added', { tags: { deviceId }, meta: { ssrc } })
|
|
9110
|
+
* }
|
|
9111
|
+
* ```
|
|
9112
|
+
*
|
|
9113
|
+
* `on` is a plain boolean FIELD — never a getter — and it is the FIRST thing
|
|
9114
|
+
* read. Disarmed, a call site costs one load and one branch, and the `extras`
|
|
9115
|
+
* object literal is never constructed because it lives inside the branch. It
|
|
9116
|
+
* is the same shape already proven in production at `stream-broker.ts:1650`,
|
|
9117
|
+
* and the same discipline `LoggingGate.allowsDestination` uses for the
|
|
9118
|
+
* destination floor (measured at 1.93 ns/call when off).
|
|
9119
|
+
*
|
|
9120
|
+
* ## Why a channel emits at `info`
|
|
9121
|
+
*
|
|
9122
|
+
* `loki-logging.addon.ts` pins the destination default at `info` and
|
|
9123
|
+
* `loki-destination.ts` drops everything below it, so a line emitted at
|
|
9124
|
+
* `debug` never reaches Loki and the hub's in-memory ring only holds ~35
|
|
9125
|
+
* minutes. A diagnostic that cannot be read an hour later is worse than no
|
|
9126
|
+
* diagnostic, because it looks done. {@link LogChannelGate.log} therefore
|
|
9127
|
+
* emits at the channel's declared level, whose schema floor is `info`.
|
|
9128
|
+
*/
|
|
9129
|
+
/**
|
|
9130
|
+
* The level a channel writes at once armed.
|
|
9131
|
+
*
|
|
9132
|
+
* `debug` is absent ON PURPOSE and not by omission: below `info` the line does
|
|
9133
|
+
* not leave the process for Loki, and the whole point of arming a channel is
|
|
9134
|
+
* to read it later.
|
|
9135
|
+
*/
|
|
9136
|
+
var LogChannelLevelSchema = _enum([
|
|
9137
|
+
"info",
|
|
9138
|
+
"warn",
|
|
9139
|
+
"error"
|
|
9140
|
+
]);
|
|
9141
|
+
/**
|
|
9142
|
+
* What an addon declares about one channel. No value, no state — a
|
|
9143
|
+
* declaration is inert.
|
|
9144
|
+
*/
|
|
9145
|
+
var LogChannelDescriptorSchema = object({
|
|
9146
|
+
/**
|
|
9147
|
+
* Dotted `area.thing`, unique across the workspace. `area` is conventionally
|
|
9148
|
+
* the addon's short name so an operator reading a channel list can tell who
|
|
9149
|
+
* owns it without a second lookup.
|
|
9150
|
+
*/
|
|
9151
|
+
name: string().min(3).regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/, "a channel name is dotted lower-kebab, e.g. area.thing"),
|
|
9152
|
+
/** One sentence: what the operator will SEE after arming it. */
|
|
9153
|
+
description: string().min(1),
|
|
9154
|
+
/** The level its lines are emitted at. Never below `info`. */
|
|
9155
|
+
defaultLevel: LogChannelLevelSchema,
|
|
9156
|
+
/**
|
|
9157
|
+
* Whether this channel can be narrowed to a camera.
|
|
9158
|
+
*
|
|
9159
|
+
* `true` is a PROMISE with two halves, and both must hold: the gate is
|
|
9160
|
+
* consulted with the numeric device id, AND every line the channel admits
|
|
9161
|
+
* carries `tags: { deviceId }` with that same numeric id. The second half is
|
|
9162
|
+
* what makes `| json | deviceId="617"` work in Loki — `loki-payload.ts`
|
|
9163
|
+
* keeps `deviceId` out of the stream labels for cardinality, so the tag in
|
|
9164
|
+
* the body is the only way to filter.
|
|
9165
|
+
*
|
|
9166
|
+
* A channel whose lines carry the device only in `meta` (or not at all) is
|
|
9167
|
+
* declared `false`. Declaring it `true` anyway would be a lie the UI repeats:
|
|
9168
|
+
* the operator narrows to one camera, sees nothing, and concludes the code
|
|
9169
|
+
* path was never taken.
|
|
9170
|
+
*/
|
|
9171
|
+
perDevice: boolean()
|
|
9172
|
+
});
|
|
9173
|
+
/**
|
|
9174
|
+
* An armed window over one channel, as the document hands it to a mirror.
|
|
9175
|
+
*
|
|
9176
|
+
* A window is a DEADLINE, never a flag (ADR-0244): a channel somebody forgot
|
|
9177
|
+
* expires by itself, which is the one failure a boolean cannot avoid.
|
|
9178
|
+
*/
|
|
9179
|
+
var LogChannelWindowSchema = object({
|
|
9180
|
+
channel: string().min(1),
|
|
9181
|
+
/** Epoch ms the window closes at. */
|
|
9182
|
+
armedUntilMs: number(),
|
|
9183
|
+
/** `null` = every camera. A non-empty list narrows to those numeric ids. */
|
|
9184
|
+
deviceIds: array(number().int()).readonly().nullable()
|
|
9185
|
+
});
|
|
9186
|
+
/**
|
|
9187
|
+
* The gate a hot path holds.
|
|
9188
|
+
*
|
|
9189
|
+
* Obtain it ONCE — at module scope or in a constructor — and keep the
|
|
9190
|
+
* reference. Looking a channel up by name per line would put a Map lookup on
|
|
9191
|
+
* the path this class exists to keep free.
|
|
9192
|
+
*/
|
|
9193
|
+
var LogChannelGate = class {
|
|
9194
|
+
descriptor;
|
|
9195
|
+
/**
|
|
9196
|
+
* HOT PATH GUARD. A plain data FIELD, and it must stay one.
|
|
9197
|
+
*
|
|
9198
|
+
* `log-channel.spec.ts` asserts the property descriptor has no getter and
|
|
9199
|
+
* booby-traps the device set, so turning this into an accessor — or reading
|
|
9200
|
+
* anything before it — fails the spec instead of taxing every line the
|
|
9201
|
+
* process emits.
|
|
9202
|
+
*/
|
|
9203
|
+
on = false;
|
|
9204
|
+
/** `null` while armed for every camera. Never read while `on` is false. */
|
|
9205
|
+
devices = null;
|
|
9206
|
+
level;
|
|
9207
|
+
closesAtMs = 0;
|
|
9208
|
+
constructor(descriptor) {
|
|
9209
|
+
this.descriptor = descriptor;
|
|
9210
|
+
this.level = descriptor.defaultLevel;
|
|
9211
|
+
}
|
|
9212
|
+
/** Epoch ms this channel disarms itself at. 0 when disarmed. */
|
|
9213
|
+
get armedUntilMs() {
|
|
9214
|
+
return this.on ? this.closesAtMs : 0;
|
|
9215
|
+
}
|
|
9216
|
+
/**
|
|
9217
|
+
* Does this channel want a line about `deviceId`?
|
|
9218
|
+
*
|
|
9219
|
+
* Call it only behind `gate.on &&`. On its own it is still correct — the
|
|
9220
|
+
* guard is repeated inside — but the point of the prefix is that a disarmed
|
|
9221
|
+
* channel must not pay the call at all.
|
|
9222
|
+
*/
|
|
9223
|
+
wants(deviceId) {
|
|
9224
|
+
if (!this.on) return false;
|
|
9225
|
+
return this.devices === null || this.devices.has(deviceId);
|
|
9226
|
+
}
|
|
9227
|
+
/**
|
|
9228
|
+
* Emit one line on this channel, at the channel's declared level.
|
|
9229
|
+
*
|
|
9230
|
+
* The channel name is added as `tags.logChannel` so LogQL can select the
|
|
9231
|
+
* channel without matching on the message text, and whatever `tags` the
|
|
9232
|
+
* caller passed — `deviceId` above all — is preserved.
|
|
9233
|
+
*/
|
|
9234
|
+
log(logger, message, extras) {
|
|
9235
|
+
if (!this.on) return;
|
|
9236
|
+
const tags = {
|
|
9237
|
+
...extras.tags,
|
|
9238
|
+
logChannel: this.descriptor.name
|
|
9239
|
+
};
|
|
9240
|
+
const line = {
|
|
9241
|
+
...extras,
|
|
9242
|
+
tags
|
|
9243
|
+
};
|
|
9244
|
+
if (this.level === "error") logger.error(message, line);
|
|
9245
|
+
else if (this.level === "warn") logger.warn(message, line);
|
|
9246
|
+
else logger.info(message, line);
|
|
9247
|
+
}
|
|
9248
|
+
/**
|
|
9249
|
+
* Arm (or RE-arm, restarting) this channel. Off the hot path only.
|
|
9250
|
+
*
|
|
9251
|
+
* An empty `deviceIds` list is treated as "every camera" rather than "no
|
|
9252
|
+
* camera": a window that matches nothing is indistinguishable from a
|
|
9253
|
+
* disarmed one, and the operator who asked for it would wait for lines that
|
|
9254
|
+
* can never come.
|
|
9255
|
+
*/
|
|
9256
|
+
arm(window) {
|
|
9257
|
+
const ids = window.deviceIds;
|
|
9258
|
+
this.devices = ids === null || ids.length === 0 ? null : new Set(ids);
|
|
9259
|
+
this.closesAtMs = window.armedUntilMs;
|
|
9260
|
+
this.on = true;
|
|
9261
|
+
}
|
|
9262
|
+
/** Disarm. Off the hot path only. */
|
|
9263
|
+
disarm() {
|
|
9264
|
+
this.on = false;
|
|
9265
|
+
this.devices = null;
|
|
9266
|
+
this.closesAtMs = 0;
|
|
9267
|
+
}
|
|
9268
|
+
};
|
|
9269
|
+
/**
|
|
9270
|
+
* Every channel this PROCESS declares, and the mirror of what is armed on it.
|
|
9271
|
+
*
|
|
9272
|
+
* One per process. A forked runner has its own, and it is refreshed through
|
|
9273
|
+
* the `log-channels` capability by the hub that owns the document — the
|
|
9274
|
+
* registry never reaches for a value itself.
|
|
9275
|
+
*/
|
|
9276
|
+
var LogChannelRegistry = class {
|
|
9277
|
+
gates = /* @__PURE__ */ new Map();
|
|
9278
|
+
/**
|
|
9279
|
+
* Declare a channel and get its gate.
|
|
9280
|
+
*
|
|
9281
|
+
* A duplicate name throws. Two declarations of one name is a programming
|
|
9282
|
+
* error, not a merge: the operator would arm one and the other would stay
|
|
9283
|
+
* dark, which is the dead-knob shape (D62) with an extra step.
|
|
9284
|
+
*/
|
|
9285
|
+
declare(descriptor) {
|
|
9286
|
+
const parsed = LogChannelDescriptorSchema.parse(descriptor);
|
|
9287
|
+
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`);
|
|
9288
|
+
const gate = new LogChannelGate(parsed);
|
|
9289
|
+
this.gates.set(parsed.name, gate);
|
|
9290
|
+
return gate;
|
|
9291
|
+
}
|
|
9292
|
+
/** The declarations, sorted by name so a list is stable to read and diff. */
|
|
9293
|
+
list() {
|
|
9294
|
+
return [...this.gates.values()].map((gate) => gate.descriptor).sort((a, b) => a.name.localeCompare(b.name));
|
|
9295
|
+
}
|
|
9296
|
+
/** The gate for a declared channel, or `undefined`. */
|
|
9297
|
+
gate(name) {
|
|
9298
|
+
return this.gates.get(name);
|
|
9299
|
+
}
|
|
9300
|
+
/**
|
|
9301
|
+
* Apply the FULL set of armed windows. Off the hot path.
|
|
9302
|
+
*
|
|
9303
|
+
* Full, not incremental, and that is the whole design: the document is the
|
|
9304
|
+
* authority, so a channel the document does not name is disarmed here. An
|
|
9305
|
+
* incremental apply would let a disarm get lost in transit and leave a
|
|
9306
|
+
* channel running that nobody can see is running.
|
|
9307
|
+
*
|
|
9308
|
+
* A window already past its deadline is ignored rather than armed — a
|
|
9309
|
+
* restore that re-armed an expired window would make a forgotten diagnostic
|
|
9310
|
+
* immortal across restarts.
|
|
9311
|
+
*
|
|
9312
|
+
* Returns the names it could not place, so the caller can log them: a
|
|
9313
|
+
* channel named in the document that this process does not declare is
|
|
9314
|
+
* either a typo or an addon that has not booted yet, and both deserve a
|
|
9315
|
+
* line rather than silence.
|
|
9316
|
+
*/
|
|
9317
|
+
apply(windows, nowMs) {
|
|
9318
|
+
const wanted = /* @__PURE__ */ new Map();
|
|
9319
|
+
const unknown = [];
|
|
9320
|
+
for (const window of windows) {
|
|
9321
|
+
if (window.armedUntilMs <= nowMs) continue;
|
|
9322
|
+
if (!this.gates.has(window.channel)) {
|
|
9323
|
+
unknown.push(window.channel);
|
|
9324
|
+
continue;
|
|
9325
|
+
}
|
|
9326
|
+
wanted.set(window.channel, window);
|
|
9327
|
+
}
|
|
9328
|
+
for (const [name, gate] of this.gates) {
|
|
9329
|
+
const window = wanted.get(name);
|
|
9330
|
+
if (window === void 0) gate.disarm();
|
|
9331
|
+
else gate.arm(window);
|
|
9332
|
+
}
|
|
9333
|
+
return unknown;
|
|
9334
|
+
}
|
|
9335
|
+
/**
|
|
9336
|
+
* Disarm whatever has run out. Called on a timer, NEVER from a log path — a
|
|
9337
|
+
* diagnostic that adds a `Date.now()` to the path it is measuring measures
|
|
9338
|
+
* itself.
|
|
9339
|
+
*
|
|
9340
|
+
* Returns the names it closed, so the caller can write the one line that
|
|
9341
|
+
* says a window ended and stops "it went quiet" from reading as "the branch
|
|
9342
|
+
* was not taken".
|
|
9343
|
+
*/
|
|
9344
|
+
tick(nowMs) {
|
|
9345
|
+
const closed = [];
|
|
9346
|
+
for (const [name, gate] of this.gates) if (gate.on && gate.armedUntilMs <= nowMs) {
|
|
9347
|
+
gate.disarm();
|
|
9348
|
+
closed.push(name);
|
|
9349
|
+
}
|
|
9350
|
+
return closed;
|
|
9351
|
+
}
|
|
9352
|
+
/** The channels armed right now, as the document would describe them. */
|
|
9353
|
+
armed() {
|
|
9354
|
+
const out = [];
|
|
9355
|
+
for (const [name, gate] of this.gates) if (gate.on) out.push({
|
|
9356
|
+
channel: name,
|
|
9357
|
+
armedUntilMs: gate.armedUntilMs,
|
|
9358
|
+
deviceIds: null
|
|
9359
|
+
});
|
|
9360
|
+
return out;
|
|
9361
|
+
}
|
|
9362
|
+
};
|
|
9363
|
+
/**
|
|
9364
|
+
* Process-wide holder for the {@link LogChannelRegistry}.
|
|
9365
|
+
*
|
|
9366
|
+
* Three call sites that never meet need the SAME instance: the hot paths that
|
|
9367
|
+
* declare a gate at module scope, the `log-channels` provider that enumerates
|
|
9368
|
+
* the declarations for the hub, and the same provider applying the windows the
|
|
9369
|
+
* document hands down. A registry built inside any one of them would be
|
|
9370
|
+
* refreshed and collected — the shape of a knob that never does anything.
|
|
9371
|
+
*
|
|
9372
|
+
* Same idiom as `logging-gate.singleton.ts` and
|
|
9373
|
+
* `http-request-census.singleton.ts`.
|
|
9374
|
+
*/
|
|
9375
|
+
var instance = null;
|
|
9376
|
+
/** The process-wide log channel registry. Created empty on first use. */
|
|
9377
|
+
function getLogChannelRegistry() {
|
|
9378
|
+
instance ??= new LogChannelRegistry();
|
|
9379
|
+
return instance;
|
|
9380
|
+
}
|
|
9381
|
+
/**
|
|
9382
|
+
* Declare a channel on the process-wide registry and get its gate.
|
|
9383
|
+
*
|
|
9384
|
+
* The one call an addon makes. Keep the returned gate in a module-scope
|
|
9385
|
+
* `const`: looking a channel up by name per line would put a Map lookup on
|
|
9386
|
+
* exactly the path this mechanism exists to keep free.
|
|
9387
|
+
*
|
|
9388
|
+
* `scripts/check-log-channel-gated.ts` reads these call sites. It pairs the
|
|
9389
|
+
* declared name with the binding it is assigned to and refuses to let a
|
|
9390
|
+
* channel ship that no `<binding>.on` anywhere consults — a declared channel
|
|
9391
|
+
* nobody reads is a knob the operator turns with nothing happening, forever,
|
|
9392
|
+
* and without a line. That is D62, and this repo has now shipped it three
|
|
9393
|
+
* times (`audioThresholdDbfs`, the HA entities with no source, the second
|
|
9394
|
+
* per-camera switch that wrote a store nobody read).
|
|
9395
|
+
*/
|
|
9396
|
+
function declareLogChannel(descriptor) {
|
|
9397
|
+
return getLogChannelRegistry().declare(descriptor);
|
|
9398
|
+
}
|
|
9399
|
+
/**
|
|
9400
|
+
* Build the `log-channels` provider for this process.
|
|
9401
|
+
*
|
|
9402
|
+
* `logger` is used ONLY off the hot path — for the arm/expiry lines — so a
|
|
9403
|
+
* channel that is never armed costs this module nothing but a timer.
|
|
9404
|
+
*/
|
|
9405
|
+
function createLogChannelsProvider(logger, options = {}) {
|
|
9406
|
+
const registry = getLogChannelRegistry();
|
|
9407
|
+
const now = options.now ?? Date.now;
|
|
9408
|
+
const tickMs = options.tickMs ?? 5e3;
|
|
9409
|
+
const timer = setInterval(() => {
|
|
9410
|
+
const closed = registry.tick(now());
|
|
9411
|
+
for (const name of closed) logger.info("log channel window closed", {
|
|
9412
|
+
tags: { logChannel: name },
|
|
9413
|
+
meta: { channel: name }
|
|
9414
|
+
});
|
|
9415
|
+
}, tickMs);
|
|
9416
|
+
timer.unref?.();
|
|
9417
|
+
return {
|
|
9418
|
+
list: () => registry.list(),
|
|
9419
|
+
apply: (input) => {
|
|
9420
|
+
const unknown = registry.apply(input.windows, now());
|
|
9421
|
+
const armed = registry.armed();
|
|
9422
|
+
logger.info("log channels applied", { meta: {
|
|
9423
|
+
armed: armed.map((window) => window.channel),
|
|
9424
|
+
unknown,
|
|
9425
|
+
declared: registry.list().length
|
|
9426
|
+
} });
|
|
9427
|
+
return {
|
|
9428
|
+
armed: armed.length,
|
|
9429
|
+
unknown
|
|
9430
|
+
};
|
|
9431
|
+
},
|
|
9432
|
+
stop: () => {
|
|
9433
|
+
clearInterval(timer);
|
|
9434
|
+
}
|
|
9435
|
+
};
|
|
9436
|
+
}
|
|
9437
|
+
/**
|
|
9356
9438
|
* Distinct (device, family, variant) counters one instance will hold.
|
|
9357
9439
|
*
|
|
9358
9440
|
* A large fleet x the handful of families any single addon reports, with
|
|
@@ -22668,7 +22750,7 @@ method(object({
|
|
|
22668
22750
|
downloadId: string(),
|
|
22669
22751
|
offset: number(),
|
|
22670
22752
|
length: number()
|
|
22671
|
-
}), _instanceof(Uint8Array)), method(object({ downloadId: string() }), _void(), { kind: "mutation" }), method(object({ type: StorageLocationTypeSchema.optional() }), array(StorageLocationSchema).readonly()), method(
|
|
22753
|
+
}), _instanceof(Uint8Array)), method(object({ downloadId: string() }), _void(), { kind: "mutation" }), method(object({ type: StorageLocationTypeSchema.optional() }), array(StorageLocationSchema).readonly()), method(_void(), array(StorageLocationDeclarationSchema).readonly()), method(StorageLocationSchema.omit({
|
|
22672
22754
|
createdAt: true,
|
|
22673
22755
|
updatedAt: true
|
|
22674
22756
|
}), StorageLocationSchema, {
|
|
@@ -22680,7 +22762,7 @@ method(object({
|
|
|
22680
22762
|
}), _void(), {
|
|
22681
22763
|
kind: "mutation",
|
|
22682
22764
|
auth: "admin"
|
|
22683
|
-
}), method(object({ id: string() }), object({
|
|
22765
|
+
}), method(_void(), array(StorageDrainProgressSchema).readonly()), method(object({ id: string() }), object({
|
|
22684
22766
|
ok: boolean(),
|
|
22685
22767
|
error: string().optional()
|
|
22686
22768
|
}), { auth: "admin" }), method(_void(), array(ProviderListEntrySchema).readonly()), method(object({
|
|
@@ -22750,6 +22832,51 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
|
|
|
22750
22832
|
kind: "mutation",
|
|
22751
22833
|
auth: "admin"
|
|
22752
22834
|
}), method(object({}), array(StorageMigrationJobSchema).readonly(), { auth: "admin" });
|
|
22835
|
+
/**
|
|
22836
|
+
* `storage-occupancy` — how many bytes an addon actually HOLDS on a storage
|
|
22837
|
+
* location (D388).
|
|
22838
|
+
*
|
|
22839
|
+
* ## Why this is not `storage-evictable`
|
|
22840
|
+
*
|
|
22841
|
+
* `storage-evictable.getEvictableUsage` looks like the same question and is
|
|
22842
|
+
* not, in two ways that both matter and both bite hardest on the locations an
|
|
22843
|
+
* operator most wants a figure for:
|
|
22844
|
+
*
|
|
22845
|
+
* - it reports the whole eviction DOMAIN, not the location. `recordings:default`
|
|
22846
|
+
* and `recordingsLow:default` deliberately share one root and evict as one
|
|
22847
|
+
* oldest-first pool, so both answer with the SAME combined total. As an
|
|
22848
|
+
* occupancy figure that double-counts the disk.
|
|
22849
|
+
* - it reports ZERO for a location whose eviction policy is `never` (D385) —
|
|
22850
|
+
* a `readonly` or `disabled` disk. Those are exactly the disks an operator
|
|
22851
|
+
* is retiring and staring at.
|
|
22852
|
+
*
|
|
22853
|
+
* So this is its own contract with its own quantity, and the quantity is
|
|
22854
|
+
* OCCUPIED: every byte the addon holds on that location, whether or not it
|
|
22855
|
+
* would ever be willing to delete it. A provider that can only answer
|
|
22856
|
+
* "evictable" must not register here — a number that silently means different
|
|
22857
|
+
* things per class is worse than no number.
|
|
22858
|
+
*
|
|
22859
|
+
* ## Absence is an answer
|
|
22860
|
+
*
|
|
22861
|
+
* A location nobody reports for is UNKNOWN, never zero (D315). The orchestrator
|
|
22862
|
+
* stamps `StorageLocation.owned` only for locations it has a report for, and
|
|
22863
|
+
* the field is an OBJECT rather than a bare number so that a `?? 0` on the
|
|
22864
|
+
* consuming side has to be written out loud instead of appearing by accident.
|
|
22865
|
+
*
|
|
22866
|
+
* `internal: true` — consumed by the orchestrator's `listLocations` stamp, never
|
|
22867
|
+
* a public client surface. Clients read the stamped `StorageLocation.owned`.
|
|
22868
|
+
*/
|
|
22869
|
+
/** One provider's occupancy answer for one location. */
|
|
22870
|
+
var StorageOccupancyReportSchema = object({
|
|
22871
|
+
locationId: string(),
|
|
22872
|
+
/** Bytes this provider holds on THAT location — not its eviction domain, and
|
|
22873
|
+
* not net of what it is willing to delete. */
|
|
22874
|
+
ownedBytes: number().int().nonnegative(),
|
|
22875
|
+
/** When the provider last actually measured this. The orchestrator carries it
|
|
22876
|
+
* through so a UI can say how old the figure is instead of implying "now". */
|
|
22877
|
+
measuredAtMs: number().int().nonnegative()
|
|
22878
|
+
});
|
|
22879
|
+
method(object({ locationIds: array(string()).readonly() }), array(StorageOccupancyReportSchema).readonly(), { auth: "admin" });
|
|
22753
22880
|
var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
|
|
22754
22881
|
providerId: string().min(1),
|
|
22755
22882
|
displayName: string().min(1),
|
|
@@ -24585,108 +24712,6 @@ onStatusChanged: { data: object({
|
|
|
24585
24712
|
volatileStateFields: ["lastUpdated"]
|
|
24586
24713
|
};
|
|
24587
24714
|
/**
|
|
24588
|
-
* Network-link snapshot. Same shape for every provider (a Reolink wifi
|
|
24589
|
-
* camera, a Home Assistant device with a signal-strength sensor, a Tapo
|
|
24590
|
-
* plug): one slice under `device.runtimeState['network-link']`, one badge,
|
|
24591
|
-
* one Home Assistant projection.
|
|
24592
|
-
*/
|
|
24593
|
-
var NetworkLinkStatusSchema = object({
|
|
24594
|
-
/** The link the device is on. `'unknown'` = not read yet, not "no link". */
|
|
24595
|
-
type: _enum([
|
|
24596
|
-
"wifi",
|
|
24597
|
-
"ethernet",
|
|
24598
|
-
"cellular",
|
|
24599
|
-
"unknown"
|
|
24600
|
-
]),
|
|
24601
|
-
/**
|
|
24602
|
-
* Link quality, 0..100 inclusive, normalised by the provider from whatever
|
|
24603
|
-
* the firmware reports (bars, RSSI, a vendor scale). **`null` means NOT
|
|
24604
|
-
* KNOWN or NOT APPLICABLE** — a wired link has no signal, and a wireless
|
|
24605
|
-
* one whose reading has not landed must not be drawn at 0 %. Consumers
|
|
24606
|
-
* SKIP a null rather than coerce it.
|
|
24607
|
-
*/
|
|
24608
|
-
signalPercent: number().min(0).max(100).nullable(),
|
|
24609
|
-
/** Raw received signal strength in dBm, when the firmware reports one. */
|
|
24610
|
-
rssiDbm: number().optional(),
|
|
24611
|
-
/** Network name of a wireless link, when the firmware reports it. */
|
|
24612
|
-
ssid: string().optional(),
|
|
24613
|
-
/** Ms epoch of the last observation. Lets consumers reason about freshness. */
|
|
24614
|
-
lastUpdated: number()
|
|
24615
|
-
});
|
|
24616
|
-
/** The slice a provider seeds before its first read: nothing is known yet. */
|
|
24617
|
-
var NETWORK_LINK_UNKNOWN = {
|
|
24618
|
-
type: "unknown",
|
|
24619
|
-
signalPercent: null,
|
|
24620
|
-
lastUpdated: 0
|
|
24621
|
-
};
|
|
24622
|
-
/**
|
|
24623
|
-
* Normalise a signal the firmware reports as BARS (0..`maxBars`) to 0..100.
|
|
24624
|
-
* Out-of-range or non-finite input is not a reading: `null`.
|
|
24625
|
-
*/
|
|
24626
|
-
function signalPercentFromBars(bars, maxBars) {
|
|
24627
|
-
if (bars === void 0 || !Number.isFinite(bars) || maxBars <= 0) return null;
|
|
24628
|
-
if (bars < 0 || bars > maxBars) return null;
|
|
24629
|
-
return Math.round(bars / maxBars * 100);
|
|
24630
|
-
}
|
|
24631
|
-
/**
|
|
24632
|
-
* Normalise an RSSI in dBm to 0..100 on the usual wifi scale: -100 dBm and
|
|
24633
|
-
* below is 0 %, -50 dBm and above is 100 %, linear between. Non-finite or
|
|
24634
|
-
* positive input is not an RSSI: `null`.
|
|
24635
|
-
*/
|
|
24636
|
-
function signalPercentFromRssi(rssiDbm) {
|
|
24637
|
-
if (rssiDbm === void 0 || !Number.isFinite(rssiDbm) || rssiDbm > 0) return null;
|
|
24638
|
-
return Math.round((Math.min(-50, Math.max(-100, rssiDbm)) + 100) * 2);
|
|
24639
|
-
}
|
|
24640
|
-
var networkLinkCapability = {
|
|
24641
|
-
name: "network-link",
|
|
24642
|
-
scope: "device",
|
|
24643
|
-
deviceNative: true,
|
|
24644
|
-
mode: "singleton",
|
|
24645
|
-
deviceTypes: [
|
|
24646
|
-
DeviceType.Camera,
|
|
24647
|
-
DeviceType.Sensor,
|
|
24648
|
-
DeviceType.Button,
|
|
24649
|
-
DeviceType.Switch,
|
|
24650
|
-
DeviceType.Light,
|
|
24651
|
-
DeviceType.Lock,
|
|
24652
|
-
DeviceType.Siren
|
|
24653
|
-
],
|
|
24654
|
-
methods: {},
|
|
24655
|
-
events: {
|
|
24656
|
-
/**
|
|
24657
|
-
* Emitted whenever the cached status changes (a link switch, a signal
|
|
24658
|
-
* reading that moved). Mirrored on the parent chain by the
|
|
24659
|
-
* DeviceEventPropagator like `battery.onStatusChanged`.
|
|
24660
|
-
*/
|
|
24661
|
-
onStatusChanged: { data: object({
|
|
24662
|
-
deviceId: number(),
|
|
24663
|
-
status: NetworkLinkStatusSchema
|
|
24664
|
-
}) } },
|
|
24665
|
-
status: {
|
|
24666
|
-
schema: NetworkLinkStatusSchema,
|
|
24667
|
-
kind: "push",
|
|
24668
|
-
empty: NETWORK_LINK_UNKNOWN
|
|
24669
|
-
},
|
|
24670
|
-
/**
|
|
24671
|
-
* Runtime-state slice — every provider stores the same shape under
|
|
24672
|
-
* `device.runtimeState['network-link']`, read once by the badge and the
|
|
24673
|
-
* Home Assistant projector regardless of the driver.
|
|
24674
|
-
*/
|
|
24675
|
-
runtimeState: NetworkLinkStatusSchema,
|
|
24676
|
-
/**
|
|
24677
|
-
* Runtime-state durability: **restored** — a link reading is slow to
|
|
24678
|
-
* change and a sleeping battery camera may not report for hours; the
|
|
24679
|
-
* restored slice is what the badge shows until the next read.
|
|
24680
|
-
*
|
|
24681
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
24682
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
24683
|
-
*/
|
|
24684
|
-
durability: "restored",
|
|
24685
|
-
/** Clock fields: written, but excluded from the compare that decides
|
|
24686
|
-
* whether persisting is worth a SQLite commit. */
|
|
24687
|
-
volatileStateFields: ["lastUpdated"]
|
|
24688
|
-
};
|
|
24689
|
-
/**
|
|
24690
24715
|
* Generic boolean sensor — last-resort fallback when no domain-
|
|
24691
24716
|
* specific binary cap fits (Home Assistant `binary_sensor` without a
|
|
24692
24717
|
* known `device_class`, or a domain we haven't typed yet). Pure
|
|
@@ -28216,6 +28241,389 @@ var nativeObjectDetectionCapability = {
|
|
|
28216
28241
|
volatileStateFields: ["lastFetchedAt"]
|
|
28217
28242
|
};
|
|
28218
28243
|
/**
|
|
28244
|
+
* `navigation` — a device-scoped capability that natively expresses the FULL
|
|
28245
|
+
* navigation / action surface of a robot that DRIVES ITSELF and carries an
|
|
28246
|
+
* on-board camera (the Dreame robot-vacuum camera is the first provider).
|
|
28247
|
+
*
|
|
28248
|
+
* Why a NEW cap rather than overloading `ptz`:
|
|
28249
|
+
* - `ptz` moves a *gimbal* on a fixed camera (pan/tilt/zoom of the lens). A
|
|
28250
|
+
* robot vacuum has no gimbal — the whole chassis drives, turns and spins.
|
|
28251
|
+
* The two are different physical models: PTZ is absolute-position + presets,
|
|
28252
|
+
* navigation is momentary drive nudges + discrete robot ACTIONS
|
|
28253
|
+
* (dock / spot-clean / follow-pet / go-to-point / …).
|
|
28254
|
+
* - This cap is the SOURCE OF TRUTH. Two consumers adapt from it rather than
|
|
28255
|
+
* the reverse:
|
|
28256
|
+
* 1. a native CamStack navigation panel (data-driven from `listActions`
|
|
28257
|
+
* / `getOptions`), and
|
|
28258
|
+
* 2. the PTZ surface — a thin adapter mimics `ptz` from `navigation` so a
|
|
28259
|
+
* robot camera shows up in the existing PTZ control path without every
|
|
28260
|
+
* PTZ provider learning about robots. The mapping lives in the adapter,
|
|
28261
|
+
* not here (see the addon design note):
|
|
28262
|
+
* ptz.continuousMove({pan,tilt}) → navigation.move({pan,tilt})
|
|
28263
|
+
* ptz.stop() → navigation.stop()
|
|
28264
|
+
* ptz.goHome() → navigation.runAction('goHome')
|
|
28265
|
+
* ptz.getPresets() → navigation.listActions() (id→preset)
|
|
28266
|
+
* ptz.goToPreset(id) → navigation.runAction(id)
|
|
28267
|
+
*
|
|
28268
|
+
* ## Continuous drive
|
|
28269
|
+
*
|
|
28270
|
+
* `move` is MOMENTARY. Fluid navigation comes from the UI (or the PTZ adapter)
|
|
28271
|
+
* sending `move({pan,tilt})` REPEATEDLY at ~1 Hz while a direction is held, and
|
|
28272
|
+
* one `stop()` on release — exactly like the robot app's remote-drive joystick.
|
|
28273
|
+
* The provider forwards EACH `move` to one drive write; it must NOT debounce or
|
|
28274
|
+
* coalesce them. The UI owns the cadence.
|
|
28275
|
+
*
|
|
28276
|
+
* ## The action dictionary
|
|
28277
|
+
*
|
|
28278
|
+
* The discrete controls (dock / locate / spot-clean / follow / flash / sounds)
|
|
28279
|
+
* are a DATA-DRIVEN dictionary the cap exposes via `listActions()`. Each entry
|
|
28280
|
+
* carries `{ id, kind, label, icon }` (plus `soundId` for sound entries) so the
|
|
28281
|
+
* native panel AND the PTZ mimic render buttons WITHOUT hardcoding a
|
|
28282
|
+
* vendor-specific list. `kind: 'action'` entries are triggered with
|
|
28283
|
+
* `runAction({ actionId })`; `kind: 'sound'` entries with `playSound({ soundId })`
|
|
28284
|
+
* (the entry carries the `soundId` to pass). The general primitives — `move`,
|
|
28285
|
+
* `stop`, `goToPoint` — stay as first-class methods, not dictionary entries.
|
|
28286
|
+
*
|
|
28287
|
+
* NOTE (provider wiring): the first provider (Dreame) drives this with the RAW
|
|
28288
|
+
* `callAction(siid,aiid,in)` / `setProperty({siid,piid,value})` MIoT primitives
|
|
28289
|
+
* that the currently-published `@apocaliss92/nodedreame` already exposes on
|
|
28290
|
+
* every device handle. A future nodedreame publish adds a typed
|
|
28291
|
+
* `DreameCameraController` (drive / playPetSound / spotClean / findPet / …); the
|
|
28292
|
+
* provider can then swap the raw calls for the typed methods with no change to
|
|
28293
|
+
* THIS contract.
|
|
28294
|
+
*/
|
|
28295
|
+
/**
|
|
28296
|
+
* A momentary drive nudge. The robot MOVES (no gimbal) for as long as the caller
|
|
28297
|
+
* keeps sending nudges (~1 Hz); an explicit `stop` (or letting the nudges lapse)
|
|
28298
|
+
* halts it.
|
|
28299
|
+
*
|
|
28300
|
+
* - `pan` — turn: negative = left, positive = right, 0 = straight.
|
|
28301
|
+
* - `tilt` — throttle: positive = forward, negative = spin / turn-around.
|
|
28302
|
+
* - `speed` — optional intensity hint [0, 1]; the provider may scale the drive
|
|
28303
|
+
* vector by it (drivers without proportional drive ignore it).
|
|
28304
|
+
*
|
|
28305
|
+
* `pan` / `tilt` are normalized [-1, 1]. Both optional so a caller can nudge one
|
|
28306
|
+
* axis alone; an all-undefined nudge is a no-op.
|
|
28307
|
+
*/
|
|
28308
|
+
var NavigationMoveCommandSchema = object({
|
|
28309
|
+
pan: number().min(-1).max(1).optional(),
|
|
28310
|
+
tilt: number().min(-1).max(1).optional(),
|
|
28311
|
+
speed: number().min(0).max(1).optional()
|
|
28312
|
+
});
|
|
28313
|
+
/**
|
|
28314
|
+
* The enumerated discrete actions a navigation-capable robot can perform via
|
|
28315
|
+
* `runAction`. This is the CLOSED vocabulary; a given device advertises the
|
|
28316
|
+
* subset it supports through `listActions`. Sounds are NOT here — they go through
|
|
28317
|
+
* `playSound` (see the `sound` dictionary entries).
|
|
28318
|
+
*/
|
|
28319
|
+
var NavigationActionIdSchema = _enum([
|
|
28320
|
+
"goHome",
|
|
28321
|
+
"locate",
|
|
28322
|
+
"spotClean",
|
|
28323
|
+
"findPet",
|
|
28324
|
+
"personFollow",
|
|
28325
|
+
"stop",
|
|
28326
|
+
"startClean",
|
|
28327
|
+
"pauseClean",
|
|
28328
|
+
"dockWash",
|
|
28329
|
+
"autoEmpty",
|
|
28330
|
+
"flashOn",
|
|
28331
|
+
"flashOff"
|
|
28332
|
+
]);
|
|
28333
|
+
/** Whether a dictionary entry is a `runAction` action or a `playSound` sound. */
|
|
28334
|
+
var NavigationEntryKindSchema = _enum(["action", "sound"]);
|
|
28335
|
+
/**
|
|
28336
|
+
* One entry in the navigation action dictionary — the DATA-DRIVEN unit both the
|
|
28337
|
+
* native panel and the PTZ mimic render as a button.
|
|
28338
|
+
*
|
|
28339
|
+
* - `id` — stable id. For `kind:'action'` it is a {@link NavigationActionId}
|
|
28340
|
+
* (pass to `runAction`); for `kind:'sound'` it is a namespaced id
|
|
28341
|
+
* (`sound:meow`) whose `soundId` is passed to `playSound`.
|
|
28342
|
+
* - `icon` — icon HINT (lucide-style name; the UI maps it to its own set).
|
|
28343
|
+
* - `label` — operator-facing English label.
|
|
28344
|
+
* - `soundId` — wire sound id, present only on `kind:'sound'` entries.
|
|
28345
|
+
* - `enabled` — per-device FEATURE FLAG. `listActions` reports it so the UI /
|
|
28346
|
+
* PTZ render ONLY enabled entries. Data-driven: the provider
|
|
28347
|
+
* flips it from config, never by editing code.
|
|
28348
|
+
*/
|
|
28349
|
+
var NavigationActionEntrySchema = object({
|
|
28350
|
+
id: string(),
|
|
28351
|
+
kind: NavigationEntryKindSchema,
|
|
28352
|
+
label: string(),
|
|
28353
|
+
icon: string(),
|
|
28354
|
+
/** Present only on `kind:'sound'` entries — the id to pass to `playSound`. */
|
|
28355
|
+
soundId: number().int().optional(),
|
|
28356
|
+
/** Per-device feature flag — render this entry only when true. */
|
|
28357
|
+
enabled: boolean()
|
|
28358
|
+
});
|
|
28359
|
+
/** Coordinates for `goToPoint` — a point on the robot's live map. */
|
|
28360
|
+
var NavigationPointSchema = object({
|
|
28361
|
+
x: number(),
|
|
28362
|
+
y: number()
|
|
28363
|
+
});
|
|
28364
|
+
/**
|
|
28365
|
+
* Per-device FEATURE-FLAG report for the general (non-dictionary) primitives.
|
|
28366
|
+
* The cap reports which are enabled so the UI / PTZ render only the controls
|
|
28367
|
+
* that are turned on for THIS device. Data-driven: the provider derives these
|
|
28368
|
+
* from config + probe, never hardcoded in the UI. The per-DICTIONARY-entry flags
|
|
28369
|
+
* live on {@link NavigationActionEntrySchema.enabled}; these gate the primitives
|
|
28370
|
+
* that are not dictionary entries.
|
|
28371
|
+
*
|
|
28372
|
+
* - `move` / `stop` — the momentary drive joystick.
|
|
28373
|
+
* - `goToPoint` — send-to-map-coordinate. Ships OFF on Dreame until the
|
|
28374
|
+
* map-coordinate plumbing is wired.
|
|
28375
|
+
* - `runAction` — the discrete action buttons (dictionary `kind:'action'`).
|
|
28376
|
+
* - `playSound` — the sound buttons (dictionary `kind:'sound'`).
|
|
28377
|
+
* - `light` — the on/off fill-light toggle (works anytime).
|
|
28378
|
+
* - `lightMode` — the auto/manual selector + manual level slider (a
|
|
28379
|
+
* camera-service control; needs an active stream).
|
|
28380
|
+
*/
|
|
28381
|
+
var NavigationFeaturesSchema = object({
|
|
28382
|
+
move: boolean(),
|
|
28383
|
+
stop: boolean(),
|
|
28384
|
+
goToPoint: boolean(),
|
|
28385
|
+
runAction: boolean(),
|
|
28386
|
+
playSound: boolean(),
|
|
28387
|
+
light: boolean(),
|
|
28388
|
+
lightMode: boolean()
|
|
28389
|
+
});
|
|
28390
|
+
/** Light mode: `auto` lets the camera choose brightness; `manual` uses `level`. */
|
|
28391
|
+
var NavigationLightModeSchema = _enum(["auto", "manual"]);
|
|
28392
|
+
/**
|
|
28393
|
+
* Live navigation state so the UI can reflect what the robot is doing:
|
|
28394
|
+
* - `mode` — coarse activity (idle / cleaning / following / …).
|
|
28395
|
+
* - `following` — person/pet follow is currently armed.
|
|
28396
|
+
* - `flash` — the on-camera fill light is on.
|
|
28397
|
+
* - `lightMode` — auto vs manual fill-light mode.
|
|
28398
|
+
* - `lightLevel` — manual fill-light level (40..100); meaningful when
|
|
28399
|
+
* `lightMode === 'manual'`.
|
|
28400
|
+
*/
|
|
28401
|
+
var NavigationStatusSchema = object({
|
|
28402
|
+
mode: _enum([
|
|
28403
|
+
"idle",
|
|
28404
|
+
"cleaning",
|
|
28405
|
+
"spot",
|
|
28406
|
+
"following",
|
|
28407
|
+
"goto",
|
|
28408
|
+
"returning",
|
|
28409
|
+
"paused",
|
|
28410
|
+
"unknown"
|
|
28411
|
+
]),
|
|
28412
|
+
following: boolean(),
|
|
28413
|
+
flash: boolean(),
|
|
28414
|
+
lightMode: NavigationLightModeSchema,
|
|
28415
|
+
lightLevel: number().min(40).max(100),
|
|
28416
|
+
/** Ms epoch when the slice was last updated. */
|
|
28417
|
+
lastChangedAt: number()
|
|
28418
|
+
});
|
|
28419
|
+
/**
|
|
28420
|
+
* Runtime-state slice owned by this cap (kernel-managed: validated, mirrored,
|
|
28421
|
+
* observable). Adds `lastFetchedAt` on top of the status shape per the
|
|
28422
|
+
* convention.
|
|
28423
|
+
*/
|
|
28424
|
+
var NavigationRuntimeStateSchema = NavigationStatusSchema.extend({ lastFetchedAt: number() });
|
|
28425
|
+
var navigationCapability = {
|
|
28426
|
+
name: "navigation",
|
|
28427
|
+
scope: "device",
|
|
28428
|
+
deviceNative: true,
|
|
28429
|
+
mode: "singleton",
|
|
28430
|
+
deviceTypes: [DeviceType.Camera],
|
|
28431
|
+
deviceConfig: { ui: {
|
|
28432
|
+
kind: "widget",
|
|
28433
|
+
widgetId: "host/navigation-panel",
|
|
28434
|
+
tab: "navigation",
|
|
28435
|
+
topTab: true,
|
|
28436
|
+
label: "Navigation",
|
|
28437
|
+
order: 0
|
|
28438
|
+
} },
|
|
28439
|
+
methods: {
|
|
28440
|
+
/**
|
|
28441
|
+
* Momentary drive nudge (the robot moves). `protected` — mirrors
|
|
28442
|
+
* `ptz.continuousMove` so the Viewer navigation panel (and the PTZ-mimic
|
|
28443
|
+
* path) works for any authenticated user, not admin-only. The UI sends
|
|
28444
|
+
* these at ~1 Hz while a control is held; the provider forwards each one to
|
|
28445
|
+
* a single drive write WITHOUT debouncing.
|
|
28446
|
+
*/
|
|
28447
|
+
move: method(NavigationMoveCommandSchema.extend({ deviceId: number() }), _void(), { kind: "mutation" }),
|
|
28448
|
+
/** Halt all motion immediately (zero drive vector). */
|
|
28449
|
+
stop: method(object({ deviceId: number() }), _void(), { kind: "mutation" }),
|
|
28450
|
+
/** Send the robot to a point on its live map. */
|
|
28451
|
+
goToPoint: method(NavigationPointSchema.extend({ deviceId: number() }), _void(), { kind: "mutation" }),
|
|
28452
|
+
/**
|
|
28453
|
+
* Enumerate the discrete controls THIS device supports (data-driven UI +
|
|
28454
|
+
* PTZ mimic). Camera-probed subset of {@link NAVIGATION_ACTION_CATALOG}.
|
|
28455
|
+
*/
|
|
28456
|
+
listActions: method(object({ deviceId: number() }), array(NavigationActionEntrySchema)),
|
|
28457
|
+
/**
|
|
28458
|
+
* Run one discrete action (a `kind:'action'` dictionary entry). Invalid /
|
|
28459
|
+
* unsupported action ids are rejected by the provider.
|
|
28460
|
+
*/
|
|
28461
|
+
runAction: method(object({
|
|
28462
|
+
deviceId: number(),
|
|
28463
|
+
actionId: NavigationActionIdSchema
|
|
28464
|
+
}), _void(), { kind: "mutation" }),
|
|
28465
|
+
/** Play a sound by its wire id (the `soundId` of a `kind:'sound'` entry). */
|
|
28466
|
+
playSound: method(object({
|
|
28467
|
+
deviceId: number(),
|
|
28468
|
+
soundId: number().int()
|
|
28469
|
+
}), _void(), { kind: "mutation" }),
|
|
28470
|
+
/**
|
|
28471
|
+
* Turn the on-camera fill light on / off (the `OpenFullLight` control —
|
|
28472
|
+
* works anytime, no active stream required).
|
|
28473
|
+
*/
|
|
28474
|
+
setLightOn: method(object({
|
|
28475
|
+
deviceId: number(),
|
|
28476
|
+
on: boolean()
|
|
28477
|
+
}), _void(), { kind: "mutation" }),
|
|
28478
|
+
/**
|
|
28479
|
+
* Set the fill-light mode (auto vs manual). `manual` optionally carries the
|
|
28480
|
+
* initial `level`. The auto/manual + level control is a CAMERA-service
|
|
28481
|
+
* action that generally needs an active camera stream/monitor session — the
|
|
28482
|
+
* UI shows the manual level slider ONLY when `mode === 'manual'`.
|
|
28483
|
+
*/
|
|
28484
|
+
setLightMode: method(object({
|
|
28485
|
+
deviceId: number(),
|
|
28486
|
+
mode: NavigationLightModeSchema,
|
|
28487
|
+
level: number().min(40).max(100).optional()
|
|
28488
|
+
}), _void(), { kind: "mutation" }),
|
|
28489
|
+
/** Set the MANUAL fill-light level (40..100). Implies `manual` mode. */
|
|
28490
|
+
setLightLevel: method(object({
|
|
28491
|
+
deviceId: number(),
|
|
28492
|
+
level: number().min(40).max(100)
|
|
28493
|
+
}), _void(), { kind: "mutation" }),
|
|
28494
|
+
/**
|
|
28495
|
+
* Per-device FEATURE-FLAG report for the general primitives — drives which
|
|
28496
|
+
* controls the UI shows (the per-entry flags for the dictionary come back on
|
|
28497
|
+
* `listActions`).
|
|
28498
|
+
*/
|
|
28499
|
+
getFeatures: method(object({ deviceId: number() }), NavigationFeaturesSchema)
|
|
28500
|
+
},
|
|
28501
|
+
events: { onStatusChanged: { data: object({
|
|
28502
|
+
deviceId: number(),
|
|
28503
|
+
status: NavigationStatusSchema
|
|
28504
|
+
}) } },
|
|
28505
|
+
status: {
|
|
28506
|
+
schema: NavigationStatusSchema,
|
|
28507
|
+
kind: "push"
|
|
28508
|
+
},
|
|
28509
|
+
/**
|
|
28510
|
+
* Runtime-state slice mirrored by the kernel. The navigation panel watches it
|
|
28511
|
+
* for live mode / follow / flash changes.
|
|
28512
|
+
*/
|
|
28513
|
+
runtimeState: NavigationRuntimeStateSchema,
|
|
28514
|
+
/**
|
|
28515
|
+
* Runtime-state durability: **session** — like `vacuum-control`, a restored
|
|
28516
|
+
* `mode: cleaning` / `following: true` is a robot that is not actually doing
|
|
28517
|
+
* that. The live handle re-publishes on connect.
|
|
28518
|
+
*
|
|
28519
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
28520
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
28521
|
+
*/
|
|
28522
|
+
durability: "session"
|
|
28523
|
+
};
|
|
28524
|
+
/**
|
|
28525
|
+
* Network-link snapshot. Same shape for every provider (a Reolink wifi
|
|
28526
|
+
* camera, a Home Assistant device with a signal-strength sensor, a Tapo
|
|
28527
|
+
* plug): one slice under `device.runtimeState['network-link']`, one badge,
|
|
28528
|
+
* one Home Assistant projection.
|
|
28529
|
+
*/
|
|
28530
|
+
var NetworkLinkStatusSchema = object({
|
|
28531
|
+
/** The link the device is on. `'unknown'` = not read yet, not "no link". */
|
|
28532
|
+
type: _enum([
|
|
28533
|
+
"wifi",
|
|
28534
|
+
"ethernet",
|
|
28535
|
+
"cellular",
|
|
28536
|
+
"unknown"
|
|
28537
|
+
]),
|
|
28538
|
+
/**
|
|
28539
|
+
* Link quality, 0..100 inclusive, normalised by the provider from whatever
|
|
28540
|
+
* the firmware reports (bars, RSSI, a vendor scale). **`null` means NOT
|
|
28541
|
+
* KNOWN or NOT APPLICABLE** — a wired link has no signal, and a wireless
|
|
28542
|
+
* one whose reading has not landed must not be drawn at 0 %. Consumers
|
|
28543
|
+
* SKIP a null rather than coerce it.
|
|
28544
|
+
*/
|
|
28545
|
+
signalPercent: number().min(0).max(100).nullable(),
|
|
28546
|
+
/** Raw received signal strength in dBm, when the firmware reports one. */
|
|
28547
|
+
rssiDbm: number().optional(),
|
|
28548
|
+
/** Network name of a wireless link, when the firmware reports it. */
|
|
28549
|
+
ssid: string().optional(),
|
|
28550
|
+
/** Ms epoch of the last observation. Lets consumers reason about freshness. */
|
|
28551
|
+
lastUpdated: number()
|
|
28552
|
+
});
|
|
28553
|
+
/** The slice a provider seeds before its first read: nothing is known yet. */
|
|
28554
|
+
var NETWORK_LINK_UNKNOWN = {
|
|
28555
|
+
type: "unknown",
|
|
28556
|
+
signalPercent: null,
|
|
28557
|
+
lastUpdated: 0
|
|
28558
|
+
};
|
|
28559
|
+
/**
|
|
28560
|
+
* Normalise a signal the firmware reports as BARS (0..`maxBars`) to 0..100.
|
|
28561
|
+
* Out-of-range or non-finite input is not a reading: `null`.
|
|
28562
|
+
*/
|
|
28563
|
+
function signalPercentFromBars(bars, maxBars) {
|
|
28564
|
+
if (bars === void 0 || !Number.isFinite(bars) || maxBars <= 0) return null;
|
|
28565
|
+
if (bars < 0 || bars > maxBars) return null;
|
|
28566
|
+
return Math.round(bars / maxBars * 100);
|
|
28567
|
+
}
|
|
28568
|
+
/**
|
|
28569
|
+
* Normalise an RSSI in dBm to 0..100 on the usual wifi scale: -100 dBm and
|
|
28570
|
+
* below is 0 %, -50 dBm and above is 100 %, linear between. Non-finite or
|
|
28571
|
+
* positive input is not an RSSI: `null`.
|
|
28572
|
+
*/
|
|
28573
|
+
function signalPercentFromRssi(rssiDbm) {
|
|
28574
|
+
if (rssiDbm === void 0 || !Number.isFinite(rssiDbm) || rssiDbm > 0) return null;
|
|
28575
|
+
return Math.round((Math.min(-50, Math.max(-100, rssiDbm)) + 100) * 2);
|
|
28576
|
+
}
|
|
28577
|
+
var networkLinkCapability = {
|
|
28578
|
+
name: "network-link",
|
|
28579
|
+
scope: "device",
|
|
28580
|
+
deviceNative: true,
|
|
28581
|
+
mode: "singleton",
|
|
28582
|
+
deviceTypes: [
|
|
28583
|
+
DeviceType.Camera,
|
|
28584
|
+
DeviceType.Sensor,
|
|
28585
|
+
DeviceType.Button,
|
|
28586
|
+
DeviceType.Switch,
|
|
28587
|
+
DeviceType.Light,
|
|
28588
|
+
DeviceType.Lock,
|
|
28589
|
+
DeviceType.Siren
|
|
28590
|
+
],
|
|
28591
|
+
methods: {},
|
|
28592
|
+
events: {
|
|
28593
|
+
/**
|
|
28594
|
+
* Emitted whenever the cached status changes (a link switch, a signal
|
|
28595
|
+
* reading that moved). Mirrored on the parent chain by the
|
|
28596
|
+
* DeviceEventPropagator like `battery.onStatusChanged`.
|
|
28597
|
+
*/
|
|
28598
|
+
onStatusChanged: { data: object({
|
|
28599
|
+
deviceId: number(),
|
|
28600
|
+
status: NetworkLinkStatusSchema
|
|
28601
|
+
}) } },
|
|
28602
|
+
status: {
|
|
28603
|
+
schema: NetworkLinkStatusSchema,
|
|
28604
|
+
kind: "push",
|
|
28605
|
+
empty: NETWORK_LINK_UNKNOWN
|
|
28606
|
+
},
|
|
28607
|
+
/**
|
|
28608
|
+
* Runtime-state slice — every provider stores the same shape under
|
|
28609
|
+
* `device.runtimeState['network-link']`, read once by the badge and the
|
|
28610
|
+
* Home Assistant projector regardless of the driver.
|
|
28611
|
+
*/
|
|
28612
|
+
runtimeState: NetworkLinkStatusSchema,
|
|
28613
|
+
/**
|
|
28614
|
+
* Runtime-state durability: **restored** — a link reading is slow to
|
|
28615
|
+
* change and a sleeping battery camera may not report for hours; the
|
|
28616
|
+
* restored slice is what the badge shows until the next read.
|
|
28617
|
+
*
|
|
28618
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
28619
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
28620
|
+
*/
|
|
28621
|
+
durability: "restored",
|
|
28622
|
+
/** Clock fields: written, but excluded from the compare that decides
|
|
28623
|
+
* whether persisting is worth a SQLite commit. */
|
|
28624
|
+
volatileStateFields: ["lastUpdated"]
|
|
28625
|
+
};
|
|
28626
|
+
/**
|
|
28219
28627
|
* network-quality — system-scoped singleton capability tracking RTT,
|
|
28220
28628
|
* jitter, and observed/peak bandwidth per device + per client.
|
|
28221
28629
|
*
|
|
@@ -29859,287 +30267,6 @@ var ptzAutotrackCapability = {
|
|
|
29859
30267
|
durability: "session"
|
|
29860
30268
|
};
|
|
29861
30269
|
/**
|
|
29862
|
-
* `navigation` — a device-scoped capability that natively expresses the FULL
|
|
29863
|
-
* navigation / action surface of a robot that DRIVES ITSELF and carries an
|
|
29864
|
-
* on-board camera (the Dreame robot-vacuum camera is the first provider).
|
|
29865
|
-
*
|
|
29866
|
-
* Why a NEW cap rather than overloading `ptz`:
|
|
29867
|
-
* - `ptz` moves a *gimbal* on a fixed camera (pan/tilt/zoom of the lens). A
|
|
29868
|
-
* robot vacuum has no gimbal — the whole chassis drives, turns and spins.
|
|
29869
|
-
* The two are different physical models: PTZ is absolute-position + presets,
|
|
29870
|
-
* navigation is momentary drive nudges + discrete robot ACTIONS
|
|
29871
|
-
* (dock / spot-clean / follow-pet / go-to-point / …).
|
|
29872
|
-
* - This cap is the SOURCE OF TRUTH. Two consumers adapt from it rather than
|
|
29873
|
-
* the reverse:
|
|
29874
|
-
* 1. a native CamStack navigation panel (data-driven from `listActions`
|
|
29875
|
-
* / `getOptions`), and
|
|
29876
|
-
* 2. the PTZ surface — a thin adapter mimics `ptz` from `navigation` so a
|
|
29877
|
-
* robot camera shows up in the existing PTZ control path without every
|
|
29878
|
-
* PTZ provider learning about robots. The mapping lives in the adapter,
|
|
29879
|
-
* not here (see the addon design note):
|
|
29880
|
-
* ptz.continuousMove({pan,tilt}) → navigation.move({pan,tilt})
|
|
29881
|
-
* ptz.stop() → navigation.stop()
|
|
29882
|
-
* ptz.goHome() → navigation.runAction('goHome')
|
|
29883
|
-
* ptz.getPresets() → navigation.listActions() (id→preset)
|
|
29884
|
-
* ptz.goToPreset(id) → navigation.runAction(id)
|
|
29885
|
-
*
|
|
29886
|
-
* ## Continuous drive
|
|
29887
|
-
*
|
|
29888
|
-
* `move` is MOMENTARY. Fluid navigation comes from the UI (or the PTZ adapter)
|
|
29889
|
-
* sending `move({pan,tilt})` REPEATEDLY at ~1 Hz while a direction is held, and
|
|
29890
|
-
* one `stop()` on release — exactly like the robot app's remote-drive joystick.
|
|
29891
|
-
* The provider forwards EACH `move` to one drive write; it must NOT debounce or
|
|
29892
|
-
* coalesce them. The UI owns the cadence.
|
|
29893
|
-
*
|
|
29894
|
-
* ## The action dictionary
|
|
29895
|
-
*
|
|
29896
|
-
* The discrete controls (dock / locate / spot-clean / follow / flash / sounds)
|
|
29897
|
-
* are a DATA-DRIVEN dictionary the cap exposes via `listActions()`. Each entry
|
|
29898
|
-
* carries `{ id, kind, label, icon }` (plus `soundId` for sound entries) so the
|
|
29899
|
-
* native panel AND the PTZ mimic render buttons WITHOUT hardcoding a
|
|
29900
|
-
* vendor-specific list. `kind: 'action'` entries are triggered with
|
|
29901
|
-
* `runAction({ actionId })`; `kind: 'sound'` entries with `playSound({ soundId })`
|
|
29902
|
-
* (the entry carries the `soundId` to pass). The general primitives — `move`,
|
|
29903
|
-
* `stop`, `goToPoint` — stay as first-class methods, not dictionary entries.
|
|
29904
|
-
*
|
|
29905
|
-
* NOTE (provider wiring): the first provider (Dreame) drives this with the RAW
|
|
29906
|
-
* `callAction(siid,aiid,in)` / `setProperty({siid,piid,value})` MIoT primitives
|
|
29907
|
-
* that the currently-published `@apocaliss92/nodedreame` already exposes on
|
|
29908
|
-
* every device handle. A future nodedreame publish adds a typed
|
|
29909
|
-
* `DreameCameraController` (drive / playPetSound / spotClean / findPet / …); the
|
|
29910
|
-
* provider can then swap the raw calls for the typed methods with no change to
|
|
29911
|
-
* THIS contract.
|
|
29912
|
-
*/
|
|
29913
|
-
/**
|
|
29914
|
-
* A momentary drive nudge. The robot MOVES (no gimbal) for as long as the caller
|
|
29915
|
-
* keeps sending nudges (~1 Hz); an explicit `stop` (or letting the nudges lapse)
|
|
29916
|
-
* halts it.
|
|
29917
|
-
*
|
|
29918
|
-
* - `pan` — turn: negative = left, positive = right, 0 = straight.
|
|
29919
|
-
* - `tilt` — throttle: positive = forward, negative = spin / turn-around.
|
|
29920
|
-
* - `speed` — optional intensity hint [0, 1]; the provider may scale the drive
|
|
29921
|
-
* vector by it (drivers without proportional drive ignore it).
|
|
29922
|
-
*
|
|
29923
|
-
* `pan` / `tilt` are normalized [-1, 1]. Both optional so a caller can nudge one
|
|
29924
|
-
* axis alone; an all-undefined nudge is a no-op.
|
|
29925
|
-
*/
|
|
29926
|
-
var NavigationMoveCommandSchema = object({
|
|
29927
|
-
pan: number().min(-1).max(1).optional(),
|
|
29928
|
-
tilt: number().min(-1).max(1).optional(),
|
|
29929
|
-
speed: number().min(0).max(1).optional()
|
|
29930
|
-
});
|
|
29931
|
-
/**
|
|
29932
|
-
* The enumerated discrete actions a navigation-capable robot can perform via
|
|
29933
|
-
* `runAction`. This is the CLOSED vocabulary; a given device advertises the
|
|
29934
|
-
* subset it supports through `listActions`. Sounds are NOT here — they go through
|
|
29935
|
-
* `playSound` (see the `sound` dictionary entries).
|
|
29936
|
-
*/
|
|
29937
|
-
var NavigationActionIdSchema = _enum([
|
|
29938
|
-
"goHome",
|
|
29939
|
-
"locate",
|
|
29940
|
-
"spotClean",
|
|
29941
|
-
"findPet",
|
|
29942
|
-
"personFollow",
|
|
29943
|
-
"stop",
|
|
29944
|
-
"startClean",
|
|
29945
|
-
"pauseClean",
|
|
29946
|
-
"dockWash",
|
|
29947
|
-
"autoEmpty",
|
|
29948
|
-
"flashOn",
|
|
29949
|
-
"flashOff"
|
|
29950
|
-
]);
|
|
29951
|
-
/** Whether a dictionary entry is a `runAction` action or a `playSound` sound. */
|
|
29952
|
-
var NavigationEntryKindSchema = _enum(["action", "sound"]);
|
|
29953
|
-
/**
|
|
29954
|
-
* One entry in the navigation action dictionary — the DATA-DRIVEN unit both the
|
|
29955
|
-
* native panel and the PTZ mimic render as a button.
|
|
29956
|
-
*
|
|
29957
|
-
* - `id` — stable id. For `kind:'action'` it is a {@link NavigationActionId}
|
|
29958
|
-
* (pass to `runAction`); for `kind:'sound'` it is a namespaced id
|
|
29959
|
-
* (`sound:meow`) whose `soundId` is passed to `playSound`.
|
|
29960
|
-
* - `icon` — icon HINT (lucide-style name; the UI maps it to its own set).
|
|
29961
|
-
* - `label` — operator-facing English label.
|
|
29962
|
-
* - `soundId` — wire sound id, present only on `kind:'sound'` entries.
|
|
29963
|
-
* - `enabled` — per-device FEATURE FLAG. `listActions` reports it so the UI /
|
|
29964
|
-
* PTZ render ONLY enabled entries. Data-driven: the provider
|
|
29965
|
-
* flips it from config, never by editing code.
|
|
29966
|
-
*/
|
|
29967
|
-
var NavigationActionEntrySchema = object({
|
|
29968
|
-
id: string(),
|
|
29969
|
-
kind: NavigationEntryKindSchema,
|
|
29970
|
-
label: string(),
|
|
29971
|
-
icon: string(),
|
|
29972
|
-
/** Present only on `kind:'sound'` entries — the id to pass to `playSound`. */
|
|
29973
|
-
soundId: number().int().optional(),
|
|
29974
|
-
/** Per-device feature flag — render this entry only when true. */
|
|
29975
|
-
enabled: boolean()
|
|
29976
|
-
});
|
|
29977
|
-
/** Coordinates for `goToPoint` — a point on the robot's live map. */
|
|
29978
|
-
var NavigationPointSchema = object({
|
|
29979
|
-
x: number(),
|
|
29980
|
-
y: number()
|
|
29981
|
-
});
|
|
29982
|
-
/**
|
|
29983
|
-
* Per-device FEATURE-FLAG report for the general (non-dictionary) primitives.
|
|
29984
|
-
* The cap reports which are enabled so the UI / PTZ render only the controls
|
|
29985
|
-
* that are turned on for THIS device. Data-driven: the provider derives these
|
|
29986
|
-
* from config + probe, never hardcoded in the UI. The per-DICTIONARY-entry flags
|
|
29987
|
-
* live on {@link NavigationActionEntrySchema.enabled}; these gate the primitives
|
|
29988
|
-
* that are not dictionary entries.
|
|
29989
|
-
*
|
|
29990
|
-
* - `move` / `stop` — the momentary drive joystick.
|
|
29991
|
-
* - `goToPoint` — send-to-map-coordinate. Ships OFF on Dreame until the
|
|
29992
|
-
* map-coordinate plumbing is wired.
|
|
29993
|
-
* - `runAction` — the discrete action buttons (dictionary `kind:'action'`).
|
|
29994
|
-
* - `playSound` — the sound buttons (dictionary `kind:'sound'`).
|
|
29995
|
-
* - `light` — the on/off fill-light toggle (works anytime).
|
|
29996
|
-
* - `lightMode` — the auto/manual selector + manual level slider (a
|
|
29997
|
-
* camera-service control; needs an active stream).
|
|
29998
|
-
*/
|
|
29999
|
-
var NavigationFeaturesSchema = object({
|
|
30000
|
-
move: boolean(),
|
|
30001
|
-
stop: boolean(),
|
|
30002
|
-
goToPoint: boolean(),
|
|
30003
|
-
runAction: boolean(),
|
|
30004
|
-
playSound: boolean(),
|
|
30005
|
-
light: boolean(),
|
|
30006
|
-
lightMode: boolean()
|
|
30007
|
-
});
|
|
30008
|
-
/** Light mode: `auto` lets the camera choose brightness; `manual` uses `level`. */
|
|
30009
|
-
var NavigationLightModeSchema = _enum(["auto", "manual"]);
|
|
30010
|
-
/**
|
|
30011
|
-
* Live navigation state so the UI can reflect what the robot is doing:
|
|
30012
|
-
* - `mode` — coarse activity (idle / cleaning / following / …).
|
|
30013
|
-
* - `following` — person/pet follow is currently armed.
|
|
30014
|
-
* - `flash` — the on-camera fill light is on.
|
|
30015
|
-
* - `lightMode` — auto vs manual fill-light mode.
|
|
30016
|
-
* - `lightLevel` — manual fill-light level (40..100); meaningful when
|
|
30017
|
-
* `lightMode === 'manual'`.
|
|
30018
|
-
*/
|
|
30019
|
-
var NavigationStatusSchema = object({
|
|
30020
|
-
mode: _enum([
|
|
30021
|
-
"idle",
|
|
30022
|
-
"cleaning",
|
|
30023
|
-
"spot",
|
|
30024
|
-
"following",
|
|
30025
|
-
"goto",
|
|
30026
|
-
"returning",
|
|
30027
|
-
"paused",
|
|
30028
|
-
"unknown"
|
|
30029
|
-
]),
|
|
30030
|
-
following: boolean(),
|
|
30031
|
-
flash: boolean(),
|
|
30032
|
-
lightMode: NavigationLightModeSchema,
|
|
30033
|
-
lightLevel: number().min(40).max(100),
|
|
30034
|
-
/** Ms epoch when the slice was last updated. */
|
|
30035
|
-
lastChangedAt: number()
|
|
30036
|
-
});
|
|
30037
|
-
/**
|
|
30038
|
-
* Runtime-state slice owned by this cap (kernel-managed: validated, mirrored,
|
|
30039
|
-
* observable). Adds `lastFetchedAt` on top of the status shape per the
|
|
30040
|
-
* convention.
|
|
30041
|
-
*/
|
|
30042
|
-
var NavigationRuntimeStateSchema = NavigationStatusSchema.extend({ lastFetchedAt: number() });
|
|
30043
|
-
var navigationCapability = {
|
|
30044
|
-
name: "navigation",
|
|
30045
|
-
scope: "device",
|
|
30046
|
-
deviceNative: true,
|
|
30047
|
-
mode: "singleton",
|
|
30048
|
-
deviceTypes: [DeviceType.Camera],
|
|
30049
|
-
deviceConfig: { ui: {
|
|
30050
|
-
kind: "widget",
|
|
30051
|
-
widgetId: "host/navigation-panel",
|
|
30052
|
-
tab: "navigation",
|
|
30053
|
-
topTab: true,
|
|
30054
|
-
label: "Navigation",
|
|
30055
|
-
order: 0
|
|
30056
|
-
} },
|
|
30057
|
-
methods: {
|
|
30058
|
-
/**
|
|
30059
|
-
* Momentary drive nudge (the robot moves). `protected` — mirrors
|
|
30060
|
-
* `ptz.continuousMove` so the Viewer navigation panel (and the PTZ-mimic
|
|
30061
|
-
* path) works for any authenticated user, not admin-only. The UI sends
|
|
30062
|
-
* these at ~1 Hz while a control is held; the provider forwards each one to
|
|
30063
|
-
* a single drive write WITHOUT debouncing.
|
|
30064
|
-
*/
|
|
30065
|
-
move: method(NavigationMoveCommandSchema.extend({ deviceId: number() }), _void(), { kind: "mutation" }),
|
|
30066
|
-
/** Halt all motion immediately (zero drive vector). */
|
|
30067
|
-
stop: method(object({ deviceId: number() }), _void(), { kind: "mutation" }),
|
|
30068
|
-
/** Send the robot to a point on its live map. */
|
|
30069
|
-
goToPoint: method(NavigationPointSchema.extend({ deviceId: number() }), _void(), { kind: "mutation" }),
|
|
30070
|
-
/**
|
|
30071
|
-
* Enumerate the discrete controls THIS device supports (data-driven UI +
|
|
30072
|
-
* PTZ mimic). Camera-probed subset of {@link NAVIGATION_ACTION_CATALOG}.
|
|
30073
|
-
*/
|
|
30074
|
-
listActions: method(object({ deviceId: number() }), array(NavigationActionEntrySchema)),
|
|
30075
|
-
/**
|
|
30076
|
-
* Run one discrete action (a `kind:'action'` dictionary entry). Invalid /
|
|
30077
|
-
* unsupported action ids are rejected by the provider.
|
|
30078
|
-
*/
|
|
30079
|
-
runAction: method(object({
|
|
30080
|
-
deviceId: number(),
|
|
30081
|
-
actionId: NavigationActionIdSchema
|
|
30082
|
-
}), _void(), { kind: "mutation" }),
|
|
30083
|
-
/** Play a sound by its wire id (the `soundId` of a `kind:'sound'` entry). */
|
|
30084
|
-
playSound: method(object({
|
|
30085
|
-
deviceId: number(),
|
|
30086
|
-
soundId: number().int()
|
|
30087
|
-
}), _void(), { kind: "mutation" }),
|
|
30088
|
-
/**
|
|
30089
|
-
* Turn the on-camera fill light on / off (the `OpenFullLight` control —
|
|
30090
|
-
* works anytime, no active stream required).
|
|
30091
|
-
*/
|
|
30092
|
-
setLightOn: method(object({
|
|
30093
|
-
deviceId: number(),
|
|
30094
|
-
on: boolean()
|
|
30095
|
-
}), _void(), { kind: "mutation" }),
|
|
30096
|
-
/**
|
|
30097
|
-
* Set the fill-light mode (auto vs manual). `manual` optionally carries the
|
|
30098
|
-
* initial `level`. The auto/manual + level control is a CAMERA-service
|
|
30099
|
-
* action that generally needs an active camera stream/monitor session — the
|
|
30100
|
-
* UI shows the manual level slider ONLY when `mode === 'manual'`.
|
|
30101
|
-
*/
|
|
30102
|
-
setLightMode: method(object({
|
|
30103
|
-
deviceId: number(),
|
|
30104
|
-
mode: NavigationLightModeSchema,
|
|
30105
|
-
level: number().min(40).max(100).optional()
|
|
30106
|
-
}), _void(), { kind: "mutation" }),
|
|
30107
|
-
/** Set the MANUAL fill-light level (40..100). Implies `manual` mode. */
|
|
30108
|
-
setLightLevel: method(object({
|
|
30109
|
-
deviceId: number(),
|
|
30110
|
-
level: number().min(40).max(100)
|
|
30111
|
-
}), _void(), { kind: "mutation" }),
|
|
30112
|
-
/**
|
|
30113
|
-
* Per-device FEATURE-FLAG report for the general primitives — drives which
|
|
30114
|
-
* controls the UI shows (the per-entry flags for the dictionary come back on
|
|
30115
|
-
* `listActions`).
|
|
30116
|
-
*/
|
|
30117
|
-
getFeatures: method(object({ deviceId: number() }), NavigationFeaturesSchema)
|
|
30118
|
-
},
|
|
30119
|
-
events: { onStatusChanged: { data: object({
|
|
30120
|
-
deviceId: number(),
|
|
30121
|
-
status: NavigationStatusSchema
|
|
30122
|
-
}) } },
|
|
30123
|
-
status: {
|
|
30124
|
-
schema: NavigationStatusSchema,
|
|
30125
|
-
kind: "push"
|
|
30126
|
-
},
|
|
30127
|
-
/**
|
|
30128
|
-
* Runtime-state slice mirrored by the kernel. The navigation panel watches it
|
|
30129
|
-
* for live mode / follow / flash changes.
|
|
30130
|
-
*/
|
|
30131
|
-
runtimeState: NavigationRuntimeStateSchema,
|
|
30132
|
-
/**
|
|
30133
|
-
* Runtime-state durability: **session** — like `vacuum-control`, a restored
|
|
30134
|
-
* `mode: cleaning` / `following: true` is a robot that is not actually doing
|
|
30135
|
-
* that. The live handle re-publishes on connect.
|
|
30136
|
-
*
|
|
30137
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
30138
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
30139
|
-
*/
|
|
30140
|
-
durability: "session"
|
|
30141
|
-
};
|
|
30142
|
-
/**
|
|
30143
30270
|
* reboot — device-scoped capability for "soft" device reboots (firmware
|
|
30144
30271
|
* reboot via vendor protocol; cameras, NVRs, doorbells). Surfaces a
|
|
30145
30272
|
* single mutation so the UI can offer a confirm-and-reboot button for
|
|
@@ -39996,13 +40123,13 @@ Object.freeze({
|
|
|
39996
40123
|
addonId: null,
|
|
39997
40124
|
access: "view"
|
|
39998
40125
|
},
|
|
39999
|
-
"storage.
|
|
40126
|
+
"storage.list": {
|
|
40000
40127
|
capName: "storage",
|
|
40001
40128
|
capScope: "system",
|
|
40002
40129
|
addonId: null,
|
|
40003
40130
|
access: "view"
|
|
40004
40131
|
},
|
|
40005
|
-
"storage.
|
|
40132
|
+
"storage.listDrainProgress": {
|
|
40006
40133
|
capName: "storage",
|
|
40007
40134
|
capScope: "system",
|
|
40008
40135
|
addonId: null,
|
|
@@ -40152,6 +40279,12 @@ Object.freeze({
|
|
|
40152
40279
|
addonId: null,
|
|
40153
40280
|
access: "view"
|
|
40154
40281
|
},
|
|
40282
|
+
"storageOccupancy.getOccupancy": {
|
|
40283
|
+
capName: "storage-occupancy",
|
|
40284
|
+
capScope: "system",
|
|
40285
|
+
addonId: null,
|
|
40286
|
+
access: "view"
|
|
40287
|
+
},
|
|
40155
40288
|
"storageProvider.abortUpload": {
|
|
40156
40289
|
capName: "storage-provider",
|
|
40157
40290
|
capScope: "system",
|