@camstack/system 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/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/dist/builtins/alerts/alerts.addon.js +1 -1
- package/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/core-blocks.addon.js +1 -1
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +1 -1
- package/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/dist/builtins/doorbell/binding-mirror.d.ts +50 -0
- package/dist/builtins/doorbell/trigger-engine.d.ts +85 -8
- package/dist/builtins/doorbell/virtual-doorbell.addon.d.ts +53 -11
- package/dist/builtins/doorbell/virtual-doorbell.addon.js +243 -42
- package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +243 -42
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/local-auth.addon.js +1 -1
- package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
- package/dist/builtins/local-network/local-network.addon.js +1 -1
- package/dist/builtins/local-network/local-network.addon.mjs +1 -1
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/dist/builtins/platform-probe/index.js +1 -1
- package/dist/builtins/platform-probe/index.mjs +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +1 -1
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/dist/builtins/system-config/system-config.addon.js +1 -1
- package/dist/builtins/system-config/system-config.addon.mjs +1 -1
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{dist-CblJsHb-.js → dist-BupxnZOi.js} +66 -14
- package/dist/{dist-BOpRqInW.mjs → dist-DhL_zGRT.mjs} +66 -14
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Lt as EventCategory, O as doorbellCapability, _t as DeviceType, dt as BaseAddon, ut as errMsg, wt as createEvent } from "../../dist-
|
|
1
|
+
import { Lt as EventCategory, O as doorbellCapability, _t as DeviceType, dt as BaseAddon, ut as errMsg, wt as createEvent } from "../../dist-DhL_zGRT.mjs";
|
|
2
2
|
//#region src/builtins/doorbell/trigger-engine.ts
|
|
3
3
|
/**
|
|
4
4
|
* Pure trigger logic for the virtual-doorbell builtin — edge detection over
|
|
@@ -32,6 +32,30 @@ var SOURCE_CAP_ACTIVE_FIELD = {
|
|
|
32
32
|
vibration: "detected",
|
|
33
33
|
tamper: "tampered"
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* The same caps → the slice field carrying the ms-epoch timestamp of the
|
|
37
|
+
* last transition. Every source cap MUST appear here (guarded by a spec):
|
|
38
|
+
* without a transition timestamp the engine cannot tell a genuine press
|
|
39
|
+
* from a boot-time hydration when the FIRST slice it ever sees is already
|
|
40
|
+
* active, and errs towards silence — swallowing the press.
|
|
41
|
+
*
|
|
42
|
+
* These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
|
|
43
|
+
* provider derives them from `state.last_changed`, so they survive our own
|
|
44
|
+
* restarts and correctly read as "hours ago" for a state that has been
|
|
45
|
+
* active for hours. `motion` names its rise timestamp `lastDetectedAt`.
|
|
46
|
+
*/
|
|
47
|
+
var SOURCE_CAP_CHANGED_AT_FIELD = {
|
|
48
|
+
contact: "lastChangedAt",
|
|
49
|
+
binary: "lastChangedAt",
|
|
50
|
+
switch: "lastChangedAt",
|
|
51
|
+
motion: "lastDetectedAt",
|
|
52
|
+
flood: "lastChangedAt",
|
|
53
|
+
gas: "lastChangedAt",
|
|
54
|
+
smoke: "lastChangedAt",
|
|
55
|
+
"carbon-monoxide": "lastChangedAt",
|
|
56
|
+
vibration: "lastChangedAt",
|
|
57
|
+
tamper: "lastChangedAt"
|
|
58
|
+
};
|
|
35
59
|
/** Cap names whose presence in a device's bindings qualify it as a source. */
|
|
36
60
|
var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
|
|
37
61
|
/**
|
|
@@ -68,14 +92,46 @@ function sliceActiveValue(capName, slice) {
|
|
|
68
92
|
const raw = slice[field];
|
|
69
93
|
return typeof raw === "boolean" ? raw : null;
|
|
70
94
|
}
|
|
95
|
+
/** Ms-epoch transition timestamp a source cap's slice carries, or null when
|
|
96
|
+
* it is absent, non-numeric or the zero "never observed" sentinel. */
|
|
97
|
+
function sliceChangedAt(capName, slice) {
|
|
98
|
+
const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
|
|
99
|
+
if (field === void 0) return null;
|
|
100
|
+
const raw = slice[field];
|
|
101
|
+
if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
|
|
102
|
+
return raw;
|
|
103
|
+
}
|
|
104
|
+
function ignoredResult(reason) {
|
|
105
|
+
return {
|
|
106
|
+
fired: [],
|
|
107
|
+
debounced: [],
|
|
108
|
+
ignored: reason
|
|
109
|
+
};
|
|
110
|
+
}
|
|
71
111
|
/**
|
|
72
112
|
* Stateful (but side-effect-free towards the outside) trigger engine.
|
|
73
113
|
*
|
|
74
114
|
* Tracks the last observed binary value per (sourceDevice, cap) so a
|
|
75
115
|
* `DeviceStateChanged` re-emission (the slice's `lastChangedAt` moves while
|
|
76
|
-
* the binary value does not) never double-fires
|
|
77
|
-
*
|
|
78
|
-
*
|
|
116
|
+
* the binary value does not) never double-fires.
|
|
117
|
+
*
|
|
118
|
+
* FIRST SIGHTINGS. Seeding the baseline and never firing was wrong for the
|
|
119
|
+
* one case that matters: a momentary source (a button wired to a Home
|
|
120
|
+
* Assistant switch) is NOT re-pushed in its resting `off` state after a hub
|
|
121
|
+
* restart, so after every restart — several a day — the first slice the
|
|
122
|
+
* engine ever sees for it is the PRESS ITSELF, already active. That press
|
|
123
|
+
* was eaten whole; a real one on 2026-08-05 left no trace anywhere.
|
|
124
|
+
*
|
|
125
|
+
* The discriminator is the source's own transition timestamp. A first
|
|
126
|
+
* sighting that is already active rings only when its transition can be
|
|
127
|
+
* proved to have happened AFTER this engine started watching AND within
|
|
128
|
+
* `firstSightingFreshnessMs`. Both halves earn their keep: freshness alone
|
|
129
|
+
* would ring on a boot hydration of a state that flipped seconds before the
|
|
130
|
+
* restart, and "after we started" alone would ring, on a long-lived
|
|
131
|
+
* process, for a source adopted today whose state flipped yesterday. An
|
|
132
|
+
* undateable first sighting (no timestamp, or a zero sentinel) does NOT
|
|
133
|
+
* ring — the ambiguous case errs towards silence, but reports
|
|
134
|
+
* `baseline-seeded-stale-active` so the caller can say so out loud.
|
|
79
135
|
*/
|
|
80
136
|
var DoorbellTriggerEngine = class {
|
|
81
137
|
assignments = [];
|
|
@@ -85,9 +141,14 @@ var DoorbellTriggerEngine = class {
|
|
|
85
141
|
lastFiredAt = /* @__PURE__ */ new Map();
|
|
86
142
|
debounceMs;
|
|
87
143
|
now;
|
|
144
|
+
firstSightingFreshnessMs;
|
|
145
|
+
/** When this engine started watching — the floor for a first-sighting rise. */
|
|
146
|
+
startedAt;
|
|
88
147
|
constructor(options) {
|
|
89
148
|
this.debounceMs = options?.debounceMs ?? 2e3;
|
|
90
149
|
this.now = options?.now ?? Date.now;
|
|
150
|
+
this.firstSightingFreshnessMs = options?.firstSightingFreshnessMs ?? 3e4;
|
|
151
|
+
this.startedAt = this.now();
|
|
91
152
|
}
|
|
92
153
|
/** Replace the full assignment set (rebuilt whenever settings change). */
|
|
93
154
|
setAssignments(assignments) {
|
|
@@ -101,35 +162,77 @@ var DoorbellTriggerEngine = class {
|
|
|
101
162
|
return this.assignments.some((a) => a.sourceDeviceId === deviceId);
|
|
102
163
|
}
|
|
103
164
|
/**
|
|
104
|
-
* Feed one `DeviceStateChanged` slice.
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* the falling edge
|
|
165
|
+
* Feed one `DeviceStateChanged` slice. Reports which cameras should ring,
|
|
166
|
+
* which were suppressed by the debounce window, and — when nothing was
|
|
167
|
+
* matched at all — WHY. Only a rise to active on a recognised source cap
|
|
168
|
+
* can ring; re-emissions and the falling edge never do.
|
|
108
169
|
*/
|
|
109
170
|
onStateSlice(deviceId, capName, slice) {
|
|
110
171
|
const value = sliceActiveValue(capName, slice);
|
|
111
|
-
if (value === null) return
|
|
172
|
+
if (value === null) return ignoredResult(isSourceCap(capName) ? "non-boolean-value" : "unknown-cap");
|
|
112
173
|
const key = `${deviceId}:${capName}`;
|
|
113
174
|
const prior = this.lastValues.get(key);
|
|
114
175
|
this.lastValues.set(key, value);
|
|
115
|
-
if (prior === void 0
|
|
116
|
-
|
|
117
|
-
|
|
176
|
+
if (prior === void 0) {
|
|
177
|
+
if (!value) return ignoredResult("baseline-seeded-inactive");
|
|
178
|
+
if (!this.roseAfterWeStartedWatching(capName, slice)) return ignoredResult("baseline-seeded-stale-active");
|
|
179
|
+
return this.matchAndDebounce(deviceId);
|
|
180
|
+
}
|
|
181
|
+
if (prior === value) return ignoredResult("no-change");
|
|
182
|
+
if (!value) return ignoredResult("falling-edge");
|
|
183
|
+
return this.matchAndDebounce(deviceId);
|
|
118
184
|
}
|
|
119
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Can this slice PROVE its active state is a transition we would have
|
|
187
|
+
* witnessed had we been listening — i.e. recent, and after we started?
|
|
188
|
+
*/
|
|
189
|
+
roseAfterWeStartedWatching(capName, slice) {
|
|
190
|
+
const changedAt = sliceChangedAt(capName, slice);
|
|
191
|
+
if (changedAt === null) return false;
|
|
192
|
+
return changedAt >= Math.max(this.startedAt, this.now() - this.firstSightingFreshnessMs);
|
|
193
|
+
}
|
|
194
|
+
matchAndDebounce(sourceDeviceId) {
|
|
120
195
|
const now = this.now();
|
|
121
196
|
const fired = [];
|
|
197
|
+
const debounced = [];
|
|
122
198
|
for (const assignment of this.assignments) {
|
|
123
|
-
if (
|
|
199
|
+
if (assignment.sourceDeviceId !== sourceDeviceId) continue;
|
|
124
200
|
const last = this.lastFiredAt.get(assignment.cameraId);
|
|
125
|
-
if (last !== void 0 && now - last < this.debounceMs)
|
|
201
|
+
if (last !== void 0 && now - last < this.debounceMs) {
|
|
202
|
+
debounced.push(assignment.cameraId);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
126
205
|
this.lastFiredAt.set(assignment.cameraId, now);
|
|
127
206
|
fired.push(assignment.cameraId);
|
|
128
207
|
}
|
|
129
|
-
return
|
|
208
|
+
if (fired.length === 0 && debounced.length === 0) return ignoredResult("no-assignment");
|
|
209
|
+
return {
|
|
210
|
+
fired,
|
|
211
|
+
debounced,
|
|
212
|
+
ignored: null
|
|
213
|
+
};
|
|
130
214
|
}
|
|
131
215
|
};
|
|
132
216
|
//#endregion
|
|
217
|
+
//#region src/builtins/doorbell/binding-mirror.ts
|
|
218
|
+
/**
|
|
219
|
+
* Fold one SUCCESSFUL bindings read into the mirror. A read that failed must
|
|
220
|
+
* never reach this function — an unanswerable store carries no information
|
|
221
|
+
* and must leave the mirror exactly as it was.
|
|
222
|
+
*/
|
|
223
|
+
function nextBindingState(previous, boundNow) {
|
|
224
|
+
if (boundNow) return "bound";
|
|
225
|
+
return previous === "unbind-pending" || previous === "unbound" ? "unbound" : "unbind-pending";
|
|
226
|
+
}
|
|
227
|
+
/** May a ring proceed? Only a corroborated unbind stops one. */
|
|
228
|
+
function allowsRing(state) {
|
|
229
|
+
return state !== "unbound";
|
|
230
|
+
}
|
|
231
|
+
/** True only when a read has positively confirmed the binding. */
|
|
232
|
+
function hasConfirmedBinding(state) {
|
|
233
|
+
return state === "bound";
|
|
234
|
+
}
|
|
235
|
+
//#endregion
|
|
133
236
|
//#region src/builtins/doorbell/doorbell-settings.ts
|
|
134
237
|
/**
|
|
135
238
|
* Pure per-camera settings parsing/normalization for the virtual-doorbell
|
|
@@ -222,10 +325,6 @@ function applyDoorbellSourcesPatch(current, patchValue) {
|
|
|
222
325
|
}
|
|
223
326
|
//#endregion
|
|
224
327
|
//#region src/builtins/doorbell/virtual-doorbell.addon.ts
|
|
225
|
-
/** Reload the camera→source assignment map at most this often (lazily,
|
|
226
|
-
* on trigger traffic). Covers devices/settings appearing after boot
|
|
227
|
-
* without a settings save. */
|
|
228
|
-
var ASSIGNMENTS_TTL_MS = 6e4;
|
|
229
328
|
/** Structural narrowing helper for untrusted bus payloads. */
|
|
230
329
|
function isRecord(value) {
|
|
231
330
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -281,19 +380,32 @@ function parseDoorbellSlice(slice) {
|
|
|
281
380
|
* bumps the camera's `doorbell` runtime-state counters via the
|
|
282
381
|
* standard `deviceState.setCapSlice` plumbing.
|
|
283
382
|
*
|
|
284
|
-
* Fires ONLY for cameras
|
|
285
|
-
*
|
|
383
|
+
* Fires ONLY for cameras with at least one configured source device that
|
|
384
|
+
* this wrapper is BOUND to. The binding is NOT re-derived on the ring path:
|
|
385
|
+
* it is mirrored in memory (`binding-mirror.ts`) and refreshed on the
|
|
386
|
+
* assignment-reload cadence, because a fallible read must never be able to
|
|
387
|
+
* destroy a one-shot press.
|
|
286
388
|
*/
|
|
287
389
|
var VirtualDoorbellAddon = class extends BaseAddon {
|
|
288
390
|
engine;
|
|
289
391
|
/** Monotonic guard: assignments are reloaded lazily on trigger traffic. */
|
|
290
392
|
assignmentsLoadedAt = 0;
|
|
291
393
|
assignmentsLoading = null;
|
|
394
|
+
/**
|
|
395
|
+
* Per-camera mirror of "is this wrapper still the active doorbell
|
|
396
|
+
* binding". Written ONLY off the ring path; read on it. See
|
|
397
|
+
* `binding-mirror.ts` for why a single negative read is not believed.
|
|
398
|
+
*/
|
|
399
|
+
bindingMirror = /* @__PURE__ */ new Map();
|
|
292
400
|
constructor() {
|
|
293
|
-
super({
|
|
401
|
+
super({
|
|
402
|
+
debounceMs: 2e3,
|
|
403
|
+
assignmentsTtlMs: 6e4
|
|
404
|
+
});
|
|
294
405
|
this.engine = new DoorbellTriggerEngine({ debounceMs: 2e3 });
|
|
295
406
|
}
|
|
296
407
|
async onInitialize() {
|
|
408
|
+
this.engine = new DoorbellTriggerEngine({ debounceMs: this.config.debounceMs });
|
|
297
409
|
this.ctx.logger.info("Virtual doorbell wrapper initialized");
|
|
298
410
|
this.subscribe({ category: EventCategory.DeviceStateChanged }, (event) => {
|
|
299
411
|
const data = parseDeviceStateChanged(event.data);
|
|
@@ -313,22 +425,62 @@ var VirtualDoorbellAddon = class extends BaseAddon {
|
|
|
313
425
|
async handleStateChanged(data) {
|
|
314
426
|
if (!isSourceCap(data.capName)) return;
|
|
315
427
|
await this.ensureAssignments();
|
|
316
|
-
const
|
|
317
|
-
|
|
428
|
+
const result = this.engine.onStateSlice(data.deviceId, data.capName, data.slice);
|
|
429
|
+
this.logSuppressions(data, result);
|
|
430
|
+
for (const cameraId of result.fired) await this.fireDoorbell(cameraId, Date.now());
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Say out loud every case where a rise did NOT become a ring. Silence
|
|
434
|
+
* reads as "never happened": three real presses on camera 615 produced
|
|
435
|
+
* zero operator-visible lines because the drop logged at `debug`.
|
|
436
|
+
*/
|
|
437
|
+
logSuppressions(data, result) {
|
|
438
|
+
for (const cameraId of result.debounced) this.ctx.logger.info("virtual-doorbell: rise suppressed by the debounce window", {
|
|
439
|
+
tags: { deviceId: cameraId },
|
|
440
|
+
meta: {
|
|
441
|
+
sourceDeviceId: data.deviceId,
|
|
442
|
+
capName: data.capName
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
if (result.ignored === "baseline-seeded-stale-active") {
|
|
446
|
+
const message = "virtual-doorbell: first slice seen for this source is already ACTIVE but its transition could not be dated — seeded as baseline, a press may have been swallowed";
|
|
447
|
+
const options = {
|
|
448
|
+
tags: { deviceId: data.deviceId },
|
|
449
|
+
meta: { capName: data.capName }
|
|
450
|
+
};
|
|
451
|
+
if (this.engine.hasSource(data.deviceId)) this.ctx.logger.warn(message, options);
|
|
452
|
+
else this.ctx.logger.debug(message, options);
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (result.ignored === "no-assignment") this.ctx.logger.debug("virtual-doorbell: rise on a source no camera is wired to", {
|
|
456
|
+
tags: { deviceId: data.deviceId },
|
|
457
|
+
meta: { capName: data.capName }
|
|
458
|
+
});
|
|
318
459
|
}
|
|
319
460
|
/**
|
|
320
|
-
* Ring the camera's virtual doorbell:
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
461
|
+
* Ring the camera's virtual doorbell: bump the `doorbell` runtime-state
|
|
462
|
+
* counters through the canonical `deviceState.setCapSlice` write, and
|
|
463
|
+
* emit the typed `DoorbellOnPressed` event with the CAMERA as source —
|
|
464
|
+
* byte-shaped like a native firmware ring so every downstream consumer
|
|
465
|
+
* (UI toast, notifier rules, exporters) is agnostic to the origin.
|
|
466
|
+
*
|
|
467
|
+
* The binding gate here is a pure in-memory read. It performs NO I/O and
|
|
468
|
+
* cannot fail: the whole point of the mirror is that the ring path can no
|
|
469
|
+
* longer be talked out of ringing by a store that answered badly.
|
|
326
470
|
*/
|
|
327
471
|
async fireDoorbell(cameraId, timestamp) {
|
|
328
|
-
|
|
329
|
-
|
|
472
|
+
const binding = this.bindingMirror.get(cameraId);
|
|
473
|
+
if (!allowsRing(binding)) {
|
|
474
|
+
this.ctx.logger.warn("virtual-doorbell: ring DROPPED — the wrapper is not bound to this camera, but a trigger source is still configured for it", {
|
|
475
|
+
tags: { deviceId: cameraId },
|
|
476
|
+
meta: { bindingState: binding }
|
|
477
|
+
});
|
|
330
478
|
return;
|
|
331
479
|
}
|
|
480
|
+
if (!hasConfirmedBinding(binding)) this.ctx.logger.warn("virtual-doorbell: ringing on an unconfirmed binding — the bindings store has not corroborated an unbind, and a one-shot press is never dropped on an unproven read", {
|
|
481
|
+
tags: { deviceId: cameraId },
|
|
482
|
+
meta: { bindingState: binding ?? "never-read" }
|
|
483
|
+
});
|
|
332
484
|
try {
|
|
333
485
|
const next = {
|
|
334
486
|
lastPressedAt: timestamp,
|
|
@@ -362,17 +514,51 @@ var VirtualDoorbellAddon = class extends BaseAddon {
|
|
|
362
514
|
meta: { timestamp }
|
|
363
515
|
});
|
|
364
516
|
}
|
|
365
|
-
/**
|
|
366
|
-
|
|
517
|
+
/**
|
|
518
|
+
* Fold one bindings read for `cameraId` into the mirror. Runs on the
|
|
519
|
+
* assignment-reload cadence, never while firing.
|
|
520
|
+
*
|
|
521
|
+
* A read that THROWS carries no information and leaves the mirror exactly
|
|
522
|
+
* as it was — the previous verdict keeps standing. A read that succeeds
|
|
523
|
+
* but omits our activation only ARMS a revocation; `nextBindingState`
|
|
524
|
+
* requires a second consecutive negative before the camera goes silent,
|
|
525
|
+
* because a genuine unbind and a store answering from an empty snapshot
|
|
526
|
+
* (D44) are indistinguishable in a single response.
|
|
527
|
+
*/
|
|
528
|
+
async refreshBindingMirror(cameraId) {
|
|
529
|
+
let entries;
|
|
367
530
|
try {
|
|
368
|
-
|
|
531
|
+
entries = (await this.ctx.api.deviceManager.getBindings.query({ deviceId: cameraId })).entries;
|
|
369
532
|
} catch (err) {
|
|
370
|
-
this.ctx.logger.
|
|
533
|
+
this.ctx.logger.warn("virtual-doorbell: binding check failed — keeping the last known verdict, NOT treating this as an unbind", {
|
|
371
534
|
tags: { deviceId: cameraId },
|
|
372
|
-
meta: {
|
|
535
|
+
meta: {
|
|
536
|
+
error: errMsg(err),
|
|
537
|
+
bindingState: this.bindingMirror.get(cameraId)
|
|
538
|
+
}
|
|
373
539
|
});
|
|
374
|
-
return
|
|
540
|
+
return;
|
|
375
541
|
}
|
|
542
|
+
const boundNow = entries.some((entry) => entry.capName === doorbellCapability.name && entry.kind === "wrapped" && entry.providerAddonId === this.ctx.id);
|
|
543
|
+
const previous = this.bindingMirror.get(cameraId);
|
|
544
|
+
const next = nextBindingState(previous, boundNow);
|
|
545
|
+
this.bindingMirror.set(cameraId, next);
|
|
546
|
+
if (next !== previous && next !== "bound") this.ctx.logger.warn("virtual-doorbell: bindings read did not see this wrapper", {
|
|
547
|
+
tags: { deviceId: cameraId },
|
|
548
|
+
meta: {
|
|
549
|
+
from: previous ?? "never-read",
|
|
550
|
+
to: next
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Record a binding we observed FIRST-HAND. Both callers are cap methods
|
|
556
|
+
* the router only reaches by resolving this wrapper for this device —
|
|
557
|
+
* which it can only do through the binding — so a call is direct evidence
|
|
558
|
+
* and outranks anything the store says.
|
|
559
|
+
*/
|
|
560
|
+
confirmBindingFromCapCall(deviceId) {
|
|
561
|
+
this.bindingMirror.set(deviceId, nextBindingState(this.bindingMirror.get(deviceId), true));
|
|
376
562
|
}
|
|
377
563
|
/**
|
|
378
564
|
* Lazily (re)build the camera→source assignment set from every
|
|
@@ -381,7 +567,8 @@ var VirtualDoorbellAddon = class extends BaseAddon {
|
|
|
381
567
|
* eagerly by `applyDeviceSettingsPatch`.
|
|
382
568
|
*/
|
|
383
569
|
async ensureAssignments() {
|
|
384
|
-
|
|
570
|
+
const now = Date.now();
|
|
571
|
+
if (this.assignmentsLoadedAt > 0 && now - this.assignmentsLoadedAt < this.config.assignmentsTtlMs) return;
|
|
385
572
|
if (this.assignmentsLoading) return this.assignmentsLoading;
|
|
386
573
|
this.assignmentsLoading = this.loadAssignments().then(() => {
|
|
387
574
|
this.assignmentsLoadedAt = Date.now();
|
|
@@ -393,17 +580,29 @@ var VirtualDoorbellAddon = class extends BaseAddon {
|
|
|
393
580
|
return this.assignmentsLoading;
|
|
394
581
|
}
|
|
395
582
|
async loadAssignments() {
|
|
583
|
+
if (!this.ctx.settings) {
|
|
584
|
+
this.ctx.logger.warn("virtual-doorbell: no settings store — every camera reads ZERO trigger sources, no doorbell can ring");
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
396
587
|
const cameras = (await this.ctx.api.deviceManager.listAll.query({})).filter((d) => d.type === DeviceType.Camera);
|
|
397
588
|
const assignments = [];
|
|
589
|
+
const configuredCameras = [];
|
|
398
590
|
for (const camera of cameras) {
|
|
399
591
|
const sources = await this.readDeviceSources(camera.id);
|
|
592
|
+
if (sources.length > 0) configuredCameras.push(camera.id);
|
|
400
593
|
for (const source of sources) assignments.push({
|
|
401
594
|
cameraId: camera.id,
|
|
402
595
|
sourceDeviceId: source.deviceId
|
|
403
596
|
});
|
|
404
597
|
}
|
|
598
|
+
for (const cameraId of configuredCameras) await this.refreshBindingMirror(cameraId);
|
|
599
|
+
const hadAssignments = this.engine.getAssignments().length > 0;
|
|
405
600
|
this.engine.setAssignments(assignments);
|
|
406
|
-
this.ctx.logger.
|
|
601
|
+
if (hadAssignments && assignments.length === 0) this.ctx.logger.warn("virtual-doorbell: assignment reload went from configured to EMPTY — every camera just lost its trigger sources");
|
|
602
|
+
this.ctx.logger.debug("virtual-doorbell: assignments loaded", { meta: {
|
|
603
|
+
count: assignments.length,
|
|
604
|
+
configuredCameras: configuredCameras.length
|
|
605
|
+
} });
|
|
407
606
|
}
|
|
408
607
|
invalidateAssignments() {
|
|
409
608
|
this.assignmentsLoadedAt = 0;
|
|
@@ -420,7 +619,7 @@ var VirtualDoorbellAddon = class extends BaseAddon {
|
|
|
420
619
|
capName: doorbellCapability.name
|
|
421
620
|
}));
|
|
422
621
|
} catch (err) {
|
|
423
|
-
this.ctx.logger.
|
|
622
|
+
this.ctx.logger.warn("virtual-doorbell: getCapSlice failed during getStatus", {
|
|
424
623
|
tags: { deviceId },
|
|
425
624
|
meta: { error: errMsg(err) }
|
|
426
625
|
});
|
|
@@ -472,6 +671,7 @@ var VirtualDoorbellAddon = class extends BaseAddon {
|
|
|
472
671
|
async buildDeviceSettingsContribution(deviceId) {
|
|
473
672
|
const device = await this.lookupDevice(deviceId);
|
|
474
673
|
if (device && device.type !== DeviceType.Camera) return null;
|
|
674
|
+
this.confirmBindingFromCapCall(deviceId);
|
|
475
675
|
const sources = await this.readDeviceSources(deviceId);
|
|
476
676
|
return { sections: [{
|
|
477
677
|
id: "virtual-doorbell",
|
|
@@ -494,6 +694,7 @@ var VirtualDoorbellAddon = class extends BaseAddon {
|
|
|
494
694
|
}
|
|
495
695
|
async saveDeviceSettingsPatch(deviceId, patch) {
|
|
496
696
|
if (!this.ctx.settings) throw new Error("[virtual-doorbell] settings store unavailable — cannot persist per-device settings");
|
|
697
|
+
this.confirmBindingFromCapCall(deviceId);
|
|
497
698
|
if ("doorbellSources" in patch) {
|
|
498
699
|
const next = applyDoorbellSourcesPatch(await this.ctx.settings.readDeviceStore(deviceId), patch[KEY_SOURCES]);
|
|
499
700
|
await this.ctx.settings.writeDeviceStore(deviceId, next);
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-BupxnZOi.js");
|
|
7
7
|
const require_formatter = require("../../formatter-DqAKDlvN.js");
|
|
8
8
|
//#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
|
|
9
9
|
var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as logDestinationCapability, dt as BaseAddon } from "../../dist-
|
|
1
|
+
import { U as logDestinationCapability, dt as BaseAddon } from "../../dist-DhL_zGRT.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
|
|
3
3
|
//#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
|
|
4
4
|
var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("../../dist-
|
|
3
|
+
const require_dist = require("../../dist-BupxnZOi.js");
|
|
4
4
|
//#region src/builtins/liveness-monitor/liveness-checks.ts
|
|
5
5
|
var NO_DEVICES = "liveness:no-devices";
|
|
6
6
|
var ALL_OFFLINE = "liveness:all-devices-offline";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Lt as EventCategory, dt as BaseAddon, ut as errMsg, wt as createEvent } from "../../dist-
|
|
1
|
+
import { Lt as EventCategory, dt as BaseAddon, ut as errMsg, wt as createEvent } from "../../dist-DhL_zGRT.mjs";
|
|
2
2
|
//#region src/builtins/liveness-monitor/liveness-checks.ts
|
|
3
3
|
var NO_DEVICES = "liveness:no-devices";
|
|
4
4
|
var ALL_OFFLINE = "liveness:all-devices-offline";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-BupxnZOi.js");
|
|
7
7
|
let node_crypto = require("node:crypto");
|
|
8
8
|
node_crypto = require_chunk.__toESM(node_crypto);
|
|
9
9
|
let crypto$1 = require("crypto");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as __require, o as __toESM, t as __commonJSMin } from "../../chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import { d as ScopedTokenSchema, dt as BaseAddon, ot as userManagementCapability, p as UserRecordSchema, r as ApiKeyRecordSchema, y as authProviderCapability } from "../../dist-
|
|
2
|
+
import { d as ScopedTokenSchema, dt as BaseAddon, ot as userManagementCapability, p as UserRecordSchema, r as ApiKeyRecordSchema, y as authProviderCapability } from "../../dist-DhL_zGRT.mjs";
|
|
3
3
|
import * as crypto$1 from "node:crypto";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import nodeCrypto from "crypto";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("../../dist-
|
|
3
|
+
const require_dist = require("../../dist-BupxnZOi.js");
|
|
4
4
|
let node_os = require("node:os");
|
|
5
5
|
node_os = require_chunk.__toESM(node_os);
|
|
6
6
|
//#region src/builtins/local-network/local-network.addon.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as localNetworkCapability, Lt as EventCategory, dt as BaseAddon } from "../../dist-
|
|
1
|
+
import { H as localNetworkCapability, Lt as EventCategory, dt as BaseAddon } from "../../dist-DhL_zGRT.mjs";
|
|
2
2
|
import * as os from "node:os";
|
|
3
3
|
//#region src/builtins/local-network/local-network.addon.ts
|
|
4
4
|
/**
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-BupxnZOi.js");
|
|
7
7
|
//#region src/builtins/loki-logging/loki-payload.ts
|
|
8
8
|
/**
|
|
9
9
|
* Loki rejects a label name that is not a valid Prometheus label
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as logDestinationCapability, dt as BaseAddon } from "../../dist-
|
|
1
|
+
import { U as logDestinationCapability, dt as BaseAddon } from "../../dist-DhL_zGRT.mjs";
|
|
2
2
|
//#region src/builtins/loki-logging/loki-payload.ts
|
|
3
3
|
/**
|
|
4
4
|
* Loki rejects a label name that is not a valid Prometheus label
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-BupxnZOi.js");
|
|
7
7
|
let node_fs = require("node:fs");
|
|
8
8
|
node_fs = require_chunk.__toESM(node_fs);
|
|
9
9
|
let node_child_process = require("node:child_process");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as metricsProviderCapability, Lt as EventCategory, dt as BaseAddon, wt as createEvent } from "../../dist-
|
|
1
|
+
import { K as metricsProviderCapability, Lt as EventCategory, dt as BaseAddon, wt as createEvent } from "../../dist-DhL_zGRT.mjs";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import { execFile, execFileSync } from "node:child_process";
|
|
4
4
|
import { promisify } from "node:util";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-BupxnZOi.js");
|
|
7
7
|
let node_fs = require("node:fs");
|
|
8
8
|
node_fs = require_chunk.__toESM(node_fs);
|
|
9
9
|
let node_child_process = require("node:child_process");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as __toESM } from "../../chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import { Et as emitReadiness, Lt as EventCategory, Q as scoreRuntimes, X as platformProbeCapability, dt as BaseAddon, k as enumerateInferenceDevices, ut as errMsg } from "../../dist-
|
|
2
|
+
import { Et as emitReadiness, Lt as EventCategory, Q as scoreRuntimes, X as platformProbeCapability, dt as BaseAddon, k as enumerateInferenceDevices, ut as errMsg } from "../../dist-DhL_zGRT.mjs";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import { execFile } from "node:child_process";
|
|
5
5
|
import { promisify } from "node:util";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-BupxnZOi.js");
|
|
7
7
|
//#region src/builtins/remote-access-orchestrator/enabled-providers-reconcile.ts
|
|
8
8
|
/**
|
|
9
9
|
* Reconcile the durable `enabledProviders` set against authoritative
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Lt as EventCategory, dt as BaseAddon } from "../../dist-
|
|
1
|
+
import { Lt as EventCategory, dt as BaseAddon } from "../../dist-DhL_zGRT.mjs";
|
|
2
2
|
//#region src/builtins/remote-access-orchestrator/enabled-providers-reconcile.ts
|
|
3
3
|
/**
|
|
4
4
|
* Reconcile the durable `enabledProviders` set against authoritative
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-BupxnZOi.js");
|
|
7
7
|
let node_child_process = require("node:child_process");
|
|
8
8
|
//#region src/builtins/snapshot/snapshot-coalescing.ts
|
|
9
9
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { At as nodePin, _t as DeviceType, dt as BaseAddon, ht as DeviceFeature, i as BatteryStatusSchema, it as streamQualityLabel, tt as snapshotCapability, ut as errMsg } from "../../dist-
|
|
1
|
+
import { At as nodePin, _t as DeviceType, dt as BaseAddon, ht as DeviceFeature, i as BatteryStatusSchema, it as streamQualityLabel, tt as snapshotCapability, ut as errMsg } from "../../dist-DhL_zGRT.mjs";
|
|
2
2
|
import { execFile, spawn } from "node:child_process";
|
|
3
3
|
//#region src/builtins/snapshot/snapshot-coalescing.ts
|
|
4
4
|
/**
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-BupxnZOi.js");
|
|
7
7
|
let node_fs = require("node:fs");
|
|
8
8
|
node_fs = require_chunk.__toESM(node_fs);
|
|
9
9
|
let node_path = require("node:path");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as filesystemBrowseCapability, dt as BaseAddon, rt as storageProviderCapability } from "../../dist-
|
|
1
|
+
import { P as filesystemBrowseCapability, dt as BaseAddon, rt as storageProviderCapability } from "../../dist-DhL_zGRT.mjs";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as path$1 from "node:path";
|
|
4
4
|
import { basename, dirname, join, resolve, sep } from "node:path";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-BupxnZOi.js");
|
|
7
7
|
let node_crypto = require("node:crypto");
|
|
8
8
|
let node_module = require("node:module");
|
|
9
9
|
let better_sqlite3 = require("better-sqlite3");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as dataStoreProviderCapability, Mt as parseJsonUnknown, ct as vectorDimFromBase64, dt as BaseAddon, l as RUNTIME_DEFAULTS, lt as vectorStoreCapability, ut as errMsg, w as decodeVectorBase64, xt as asJsonObject } from "../../dist-
|
|
1
|
+
import { C as dataStoreProviderCapability, Mt as parseJsonUnknown, ct as vectorDimFromBase64, dt as BaseAddon, l as RUNTIME_DEFAULTS, lt as vectorStoreCapability, ut as errMsg, w as decodeVectorBase64, xt as asJsonObject } from "../../dist-DhL_zGRT.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import Database from "better-sqlite3";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-BupxnZOi.js");
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
node_path = require_chunk.__toESM(node_path);
|
|
9
9
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dt as BaseAddon, et as settingsStoreCapability, f as StorageLocationTypeSchema, jt as parseJsonObject, nt as storageCapability } from "../../dist-
|
|
1
|
+
import { dt as BaseAddon, et as settingsStoreCapability, f as StorageLocationTypeSchema, jt as parseJsonObject, nt as storageCapability } from "../../dist-DhL_zGRT.mjs";
|
|
2
2
|
import * as path$1 from "node:path";
|
|
3
3
|
import * as fs from "node:fs/promises";
|
|
4
4
|
import { buildStorageLocationRegistry } from "@camstack/system";
|