@camstack/system 1.2.58 → 1.2.60
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 +2 -2
- package/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
- package/dist/builtins/doorbell/binding-mirror.d.ts +65 -0
- package/dist/builtins/doorbell/virtual-doorbell.addon.d.ts +56 -11
- package/dist/builtins/doorbell/virtual-doorbell.addon.js +248 -26
- package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +248 -26
- 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 +2 -2
- package/dist/builtins/snapshot/index.mjs +2 -2
- 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/retired-settings-keys.d.ts +94 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +142 -2
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +142 -2
- 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-UrXyJ9Zm.mjs → dist-C5XpOjbI.mjs} +841 -38
- package/dist/{dist-Chl2MvMd.js → dist-Cis_iV-u.js} +852 -37
- package/dist/index.js +187 -39
- package/dist/index.mjs +187 -39
- package/dist/kernel/addon-installer.d.ts +55 -7
- package/dist/kernel/addon-manifest.d.ts +36 -16
- package/package.json +1 -1
|
@@ -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-Cis_iV-u.js");
|
|
7
7
|
const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
|
|
8
8
|
let node_crypto = require("node:crypto");
|
|
9
9
|
let node_fs = require("node:fs");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ft as errMsg, m as addonPagesCapability, pt as BaseAddon, zt as EventCategory } from "../../dist-C5XpOjbI.mjs";
|
|
2
2
|
import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import * as fs from "node:fs";
|
|
@@ -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-Cis_iV-u.js");
|
|
7
7
|
const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
|
|
8
8
|
let node_crypto = require("node:crypto");
|
|
9
9
|
let node_fs = require("node:fs");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ft as errMsg, g as addonWidgetsCapability, pt as BaseAddon, zt as EventCategory } from "../../dist-C5XpOjbI.mjs";
|
|
2
2
|
import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import * as fs from "node:fs";
|
|
@@ -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-Cis_iV-u.js");
|
|
7
7
|
//#region src/builtins/alerts/prune-policy.ts
|
|
8
8
|
/**
|
|
9
9
|
* Ids older than `cutoffMs`, oldest first.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Et as createEvent, _ as alertsCapability, ft as errMsg, n as AlertSchema, pt as BaseAddon, zt as EventCategory } from "../../dist-C5XpOjbI.mjs";
|
|
2
2
|
//#region src/builtins/alerts/prune-policy.ts
|
|
3
3
|
/**
|
|
4
4
|
* Ids older than `cutoffMs`, oldest first.
|
|
@@ -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-Cis_iV-u.js");
|
|
7
7
|
let node_crypto = require("node:crypto");
|
|
8
8
|
let node_fs = require("node:fs");
|
|
9
9
|
let node_fs$1 = require_chunk.__toESM(node_fs, 1);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as backupCapability, pt as BaseAddon, zt as EventCategory } from "../../dist-C5XpOjbI.mjs";
|
|
2
2
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import Kt from "node:fs";
|
|
@@ -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-Cis_iV-u.js");
|
|
7
7
|
const require_formatter = require("../../formatter-DqAKDlvN.js");
|
|
8
8
|
//#region src/builtins/console-logging/console-destination.ts
|
|
9
9
|
var LEVEL_RANK = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as logDestinationCapability, pt as BaseAddon } from "../../dist-C5XpOjbI.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
|
|
3
3
|
//#region src/builtins/console-logging/console-destination.ts
|
|
4
4
|
var LEVEL_RANK = {
|
|
@@ -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-Cis_iV-u.js");
|
|
4
4
|
let node_crypto = require("node:crypto");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
node_path = require_chunk.__toESM(node_path);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as __toESM } from "../../chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { C as coreBlocksCapability, o as CoreBlockSchema, pt as BaseAddon } from "../../dist-C5XpOjbI.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import * as path$1 from "node:path";
|
|
5
5
|
import * as fs from "node:fs/promises";
|
|
@@ -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-Cis_iV-u.js");
|
|
7
7
|
let _camstack_types_node = require("@camstack/types/node");
|
|
8
8
|
let zod = require("zod");
|
|
9
9
|
let node_crypto = require("node:crypto");
|
|
@@ -1644,7 +1644,7 @@ async function getBindings(deps, input) {
|
|
|
1644
1644
|
entries.push({
|
|
1645
1645
|
capName,
|
|
1646
1646
|
kind: "linked",
|
|
1647
|
-
providerAddonId: deps.ctx.id,
|
|
1647
|
+
providerAddonId: require_dist.bareAddonId(deps.ctx.id),
|
|
1648
1648
|
providerNodeId: deps.ctx.kernel.localNodeId ?? "hub",
|
|
1649
1649
|
nativeAddonId: ""
|
|
1650
1650
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as deviceStateCapability, E as deviceManagerCapability, I as getByPath, M as enumerateSchemaFields, N as evaluateLinkExpression, O as deviceStatusCapability, Rt as sleep, S as buildStreamParamsConfigSchema, St as WELL_KNOWN_TAB_MAP, Y as normalizeUnit, Z as parseStreamParamsFormPatch, _t as DeviceFeature, a as CAP_NAMES_WITH_STATUS, ft as errMsg, j as enumerateItemArrayFields, jt as isDeviceConfigCap, lt as validateExpressionSource, pt as BaseAddon, s as DeviceStatusSchema, st as toExpressionValue, t as ALL_CAPABILITY_DEFINITIONS, tt as setByPath, u as STREAM_PROFILE_META, v as applyTransform, vt as DeviceRole, x as bareAddonId, yt as DeviceType, zt as EventCategory } from "../../dist-C5XpOjbI.mjs";
|
|
2
2
|
import { canonicalDeviceFingerprint } from "@camstack/types/node";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
@@ -1639,7 +1639,7 @@ async function getBindings(deps, input) {
|
|
|
1639
1639
|
entries.push({
|
|
1640
1640
|
capName,
|
|
1641
1641
|
kind: "linked",
|
|
1642
|
-
providerAddonId: deps.ctx.id,
|
|
1642
|
+
providerAddonId: bareAddonId(deps.ctx.id),
|
|
1643
1643
|
providerNodeId: deps.ctx.kernel.localNodeId ?? "hub",
|
|
1644
1644
|
nativeAddonId: ""
|
|
1645
1645
|
});
|
|
@@ -31,6 +31,31 @@
|
|
|
31
31
|
* evidence the wrapper was bound. The cost of erring open is a spurious
|
|
32
32
|
* ring on a camera the operator unbound but left configured, for at most
|
|
33
33
|
* two reload cycles. The cost of erring closed is the press.
|
|
34
|
+
*
|
|
35
|
+
* ─────────────────────────────────────────────────────────────────────
|
|
36
|
+
* 2026-08-07 (D72). The corroboration above was DEFEATED, and the reason
|
|
37
|
+
* matters more than the fix. `refreshBindingMirror` matched the binding with
|
|
38
|
+
* `entry.providerAddonId === this.ctx.id`. The two addon-context factories do
|
|
39
|
+
* not spell `ctx.id` the same way: a forked addon gets `virtual-doorbell`, a
|
|
40
|
+
* hub-main BUILTIN gets `addon:virtual-doorbell`. Every entry on the wire
|
|
41
|
+
* carries the bare form. So for this builtin the comparison was false for
|
|
42
|
+
* every entry, forever — not a blip. Corroboration only defends against a
|
|
43
|
+
* TRANSIENT bad read; two systematically-wrong reads agree with each other,
|
|
44
|
+
* and the mirror latched `unbound` with no way back except an operator
|
|
45
|
+
* opening the settings page. A real press on camera 615 was dropped.
|
|
46
|
+
*
|
|
47
|
+
* Two things follow, and both are now load-bearing here:
|
|
48
|
+
*
|
|
49
|
+
* 1. The comparison goes through `isSameAddonId` ({@link entriesBindWrapper}),
|
|
50
|
+
* never a raw `===`.
|
|
51
|
+
* 2. The DERIVED view (`deviceManager.getBindings`) is no longer the sole
|
|
52
|
+
* input. Before a negative is believed — and again on the ring path
|
|
53
|
+
* before a press is destroyed — the DURABLE authority is consulted
|
|
54
|
+
* directly ({@link readDurableWrapperBinding} over the `device-manager`
|
|
55
|
+
* addon store's `deviceBindings` map). That read carries a discriminator
|
|
56
|
+
* the derived view genuinely cannot offer: a store answering from an
|
|
57
|
+
* empty snapshot (D44) has no `deviceBindings` key at all, while a
|
|
58
|
+
* genuine unbind leaves the key present and merely omits the row.
|
|
34
59
|
*/
|
|
35
60
|
/**
|
|
36
61
|
* `bound` — a read saw the wrapper's activation.
|
|
@@ -48,3 +73,43 @@ export declare function nextBindingState(previous: DoorbellBindingState | undefi
|
|
|
48
73
|
export declare function allowsRing(state: DoorbellBindingState | undefined): boolean;
|
|
49
74
|
/** True only when a read has positively confirmed the binding. */
|
|
50
75
|
export declare function hasConfirmedBinding(state: DoorbellBindingState | undefined): boolean;
|
|
76
|
+
/** The fields of a `DeviceBindingEntry` this module reasons about. */
|
|
77
|
+
export interface BindingEntryView {
|
|
78
|
+
readonly capName: string;
|
|
79
|
+
readonly kind: string;
|
|
80
|
+
readonly providerAddonId: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Does this list of binding entries name `ownAddonId` as the ACTIVE WRAPPER
|
|
84
|
+
* of `capName`?
|
|
85
|
+
*
|
|
86
|
+
* `isSameAddonId` is the whole point: `ownAddonId` is an `AddonContext.id`,
|
|
87
|
+
* which is prefixed (`addon:…`) in hub-main and bare in a forked runner,
|
|
88
|
+
* while `providerAddonId` is always bare. A raw `===` here is the D72 bug.
|
|
89
|
+
*/
|
|
90
|
+
export declare function entriesBindWrapper(entries: ReadonlyArray<BindingEntryView>, capName: string, ownAddonId: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Render binding entries for a log line. A systematic wrong answer and a
|
|
93
|
+
* one-off blip produce the same VERDICT; only the entries themselves tell
|
|
94
|
+
* them apart, so a negative read never gets to report just its conclusion.
|
|
95
|
+
*/
|
|
96
|
+
export declare function summariseEntries(entries: ReadonlyArray<BindingEntryView>): string[];
|
|
97
|
+
/**
|
|
98
|
+
* `bound` / `unbound` — the durable store answered, and this is its answer.
|
|
99
|
+
* `unreadable` — the store could not be read, or answered from an empty
|
|
100
|
+
* snapshot (D44). It carries NO information and must never destroy work.
|
|
101
|
+
*/
|
|
102
|
+
export type DurableBindingVerdict = 'bound' | 'unbound' | 'unreadable';
|
|
103
|
+
/**
|
|
104
|
+
* Read the DURABLE authority — the `device-manager` addon store's
|
|
105
|
+
* `deviceBindings` map — for "is `ownAddonId` the active wrapper of
|
|
106
|
+
* `capName` on `deviceId`".
|
|
107
|
+
*
|
|
108
|
+
* This is the input the derived `getBindings` view is not: it is the row the
|
|
109
|
+
* operator's toggle actually writes, with no registry resolution, no
|
|
110
|
+
* `defaultActive` auto-binding and no cross-node cap folding in between. It
|
|
111
|
+
* also grades its own trustworthiness, which `getBindings` cannot: the
|
|
112
|
+
* absence of the `deviceBindings` KEY is the signature of a store answering
|
|
113
|
+
* from an empty snapshot, whereas a genuine unbind leaves the key present.
|
|
114
|
+
*/
|
|
115
|
+
export declare function readDurableWrapperBinding(record: unknown, deviceId: number, capName: string, ownAddonId: string): DurableBindingVerdict;
|
|
@@ -67,23 +67,68 @@ export declare class VirtualDoorbellAddon extends BaseAddon<VirtualDoorbellAddon
|
|
|
67
67
|
* byte-shaped like a native firmware ring so every downstream consumer
|
|
68
68
|
* (UI toast, notifier rules, exporters) is agnostic to the origin.
|
|
69
69
|
*
|
|
70
|
-
* The binding gate here is a pure in-memory read
|
|
71
|
-
*
|
|
72
|
-
*
|
|
70
|
+
* The binding gate here is a pure in-memory read on the path that RINGS:
|
|
71
|
+
* an open mirror performs NO I/O and cannot fail. The mirror can only
|
|
72
|
+
* DESTROY a press through the one branch below, and that branch is not
|
|
73
|
+
* allowed to be the last word — see `ringsDespiteUnboundMirror`.
|
|
73
74
|
*/
|
|
74
75
|
private fireDoorbell;
|
|
75
76
|
/**
|
|
76
|
-
*
|
|
77
|
-
* assignment-reload cadence, never while firing.
|
|
77
|
+
* The addon id as the REGISTRY and the bindings store spell it.
|
|
78
78
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
* `ctx.id` does NOT: hub-main prefixes it (`addon:virtual-doorbell`) while
|
|
80
|
+
* a forked runner does not, and this builtin runs in hub-main. Comparing
|
|
81
|
+
* the raw `ctx.id` to a `providerAddonId` was false for every entry for
|
|
82
|
+
* twelve hours on 2026-08-07 (D72).
|
|
83
|
+
*/
|
|
84
|
+
private get ownAddonId();
|
|
85
|
+
/**
|
|
86
|
+
* One read of the DERIVED binding view. `null` when the read could not be
|
|
87
|
+
* answered at all — which carries no information and must leave the mirror
|
|
88
|
+
* untouched.
|
|
89
|
+
*/
|
|
90
|
+
private readDerivedBinding;
|
|
91
|
+
/**
|
|
92
|
+
* One read of the DURABLE authority: the `device-manager` addon store's
|
|
93
|
+
* `deviceBindings` map, straight from the settings DB.
|
|
94
|
+
*
|
|
95
|
+
* This is deliberately NOT `getBindings`. The derived view folds the store
|
|
96
|
+
* together with the capability registry, `defaultActive` auto-binding and
|
|
97
|
+
* the cluster native-cap feeds — any of which can make it disagree with
|
|
98
|
+
* what the operator actually persisted, and one of which (an addon-id
|
|
99
|
+
* spelling mismatch) made it disagree *systematically* while looking
|
|
100
|
+
* exactly like a genuine unbind. The raw row cannot: it is what the
|
|
101
|
+
* bindings toggle wrote, and it grades its own trustworthiness (D44).
|
|
102
|
+
*/
|
|
103
|
+
private readDurableAuthority;
|
|
104
|
+
/**
|
|
105
|
+
* Reconcile `cameraId`'s mirror against the authority. Runs on the
|
|
106
|
+
* assignment-reload cadence, never while firing — and it runs on EVERY
|
|
107
|
+
* cycle regardless of the current verdict, so a camera sitting in
|
|
108
|
+
* `unbound` returns to `bound` on its own the moment the authority says
|
|
109
|
+
* so. There is no latch here that an operator has to clear.
|
|
110
|
+
*
|
|
111
|
+
* A positive derived read is believed immediately. A NEGATIVE one never
|
|
112
|
+
* is: the durable authority is asked, and it outranks the derived view in
|
|
113
|
+
* the direction that destroys work. Only when the authority agrees does
|
|
114
|
+
* the negative get folded, and even then `nextBindingState` still wants a
|
|
115
|
+
* second consecutive one (D49).
|
|
85
116
|
*/
|
|
86
117
|
private refreshBindingMirror;
|
|
118
|
+
/**
|
|
119
|
+
* The mirror says `unbound` and a real press just arrived. Decide, with
|
|
120
|
+
* ONE read of the durable authority, whether to destroy it.
|
|
121
|
+
*
|
|
122
|
+
* D49 forbade I/O on the ring path because the read it would have made was
|
|
123
|
+
* the same fallible derived read that caused the problem. This read is
|
|
124
|
+
* different in both directions: it is the authority rather than a view of
|
|
125
|
+
* it, and it is paid ONLY on the branch that would otherwise drop a press —
|
|
126
|
+
* a ring is rare, one query is cheap, and a dropped ring has no retry, no
|
|
127
|
+
* reconcile and nothing downstream that notices.
|
|
128
|
+
*
|
|
129
|
+
* Returns `true` when the ring must proceed.
|
|
130
|
+
*/
|
|
131
|
+
private ringsDespiteUnboundMirror;
|
|
87
132
|
/**
|
|
88
133
|
* Record a binding we observed FIRST-HAND. Both callers are cap methods
|
|
89
134
|
* the router only reaches by resolving this wrapper for this device —
|
|
@@ -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-Cis_iV-u.js");
|
|
7
7
|
//#region src/builtins/doorbell/trigger-engine.ts
|
|
8
8
|
/**
|
|
9
9
|
* Pure trigger logic for the virtual-doorbell builtin — edge detection over
|
|
@@ -221,6 +221,65 @@ var DoorbellTriggerEngine = class {
|
|
|
221
221
|
//#endregion
|
|
222
222
|
//#region src/builtins/doorbell/binding-mirror.ts
|
|
223
223
|
/**
|
|
224
|
+
* The virtual-doorbell wrapper's in-memory mirror of ONE durable fact per
|
|
225
|
+
* camera: is this wrapper still the active `doorbell` binding for it?
|
|
226
|
+
*
|
|
227
|
+
* WHY A MIRROR AND NOT A READ. A doorbell press is a one-shot event: there
|
|
228
|
+
* is no retry, no reconcile, nothing downstream that can notice it went
|
|
229
|
+
* missing. The wrapper used to re-derive the binding on the ring path via
|
|
230
|
+
* `deviceManager.getBindings` and treat ANY answer that omitted its own
|
|
231
|
+
* activation as "the operator unbound this". On 2026-08-04/05 camera 615
|
|
232
|
+
* rang zero times out of three real presses: the binding was persisted (a
|
|
233
|
+
* same-day backup taken before the presses proves it, and the same process
|
|
234
|
+
* later returned it correctly to a tRPC query), but the store answered
|
|
235
|
+
* transiently without it — `getBindings` reads the device-manager addon
|
|
236
|
+
* store, which is exactly the surface that can silently answer `{}` (D44,
|
|
237
|
+
* `addon-registry.service.ts`). Three presses, three drops, at `debug`.
|
|
238
|
+
*
|
|
239
|
+
* WHY CORROBORATION AND NOT A BETTER DISCRIMINATOR. There isn't one. A
|
|
240
|
+
* genuinely unbound pure-wrapper cap and a store answering from an empty
|
|
241
|
+
* snapshot produce the SAME `getBindings` response — no `doorbell` entry,
|
|
242
|
+
* with the camera's native entries (snapshot, motion, …) still present in
|
|
243
|
+
* both cases because those come from the capability registry, not the
|
|
244
|
+
* store. The response cannot be graded. What CAN be graded is repetition: a
|
|
245
|
+
* real unbind is permanent and every later read agrees, a store blip does
|
|
246
|
+
* not survive the next read. So a negative read ARMS the revocation and a
|
|
247
|
+
* second consecutive negative applies it.
|
|
248
|
+
*
|
|
249
|
+
* ERRING. `undefined` (never read) and `unbind-pending` both ring. Reaching
|
|
250
|
+
* the ring path at all means the camera has a configured trigger source,
|
|
251
|
+
* and a source can only be configured through this wrapper's own
|
|
252
|
+
* binding-gated settings surface — so a configured source is itself
|
|
253
|
+
* evidence the wrapper was bound. The cost of erring open is a spurious
|
|
254
|
+
* ring on a camera the operator unbound but left configured, for at most
|
|
255
|
+
* two reload cycles. The cost of erring closed is the press.
|
|
256
|
+
*
|
|
257
|
+
* ─────────────────────────────────────────────────────────────────────
|
|
258
|
+
* 2026-08-07 (D72). The corroboration above was DEFEATED, and the reason
|
|
259
|
+
* matters more than the fix. `refreshBindingMirror` matched the binding with
|
|
260
|
+
* `entry.providerAddonId === this.ctx.id`. The two addon-context factories do
|
|
261
|
+
* not spell `ctx.id` the same way: a forked addon gets `virtual-doorbell`, a
|
|
262
|
+
* hub-main BUILTIN gets `addon:virtual-doorbell`. Every entry on the wire
|
|
263
|
+
* carries the bare form. So for this builtin the comparison was false for
|
|
264
|
+
* every entry, forever — not a blip. Corroboration only defends against a
|
|
265
|
+
* TRANSIENT bad read; two systematically-wrong reads agree with each other,
|
|
266
|
+
* and the mirror latched `unbound` with no way back except an operator
|
|
267
|
+
* opening the settings page. A real press on camera 615 was dropped.
|
|
268
|
+
*
|
|
269
|
+
* Two things follow, and both are now load-bearing here:
|
|
270
|
+
*
|
|
271
|
+
* 1. The comparison goes through `isSameAddonId` ({@link entriesBindWrapper}),
|
|
272
|
+
* never a raw `===`.
|
|
273
|
+
* 2. The DERIVED view (`deviceManager.getBindings`) is no longer the sole
|
|
274
|
+
* input. Before a negative is believed — and again on the ring path
|
|
275
|
+
* before a press is destroyed — the DURABLE authority is consulted
|
|
276
|
+
* directly ({@link readDurableWrapperBinding} over the `device-manager`
|
|
277
|
+
* addon store's `deviceBindings` map). That read carries a discriminator
|
|
278
|
+
* the derived view genuinely cannot offer: a store answering from an
|
|
279
|
+
* empty snapshot (D44) has no `deviceBindings` key at all, while a
|
|
280
|
+
* genuine unbind leaves the key present and merely omits the row.
|
|
281
|
+
*/
|
|
282
|
+
/**
|
|
224
283
|
* Fold one SUCCESSFUL bindings read into the mirror. A read that failed must
|
|
225
284
|
* never reach this function — an unanswerable store carries no information
|
|
226
285
|
* and must leave the mirror exactly as it was.
|
|
@@ -237,6 +296,52 @@ function allowsRing(state) {
|
|
|
237
296
|
function hasConfirmedBinding(state) {
|
|
238
297
|
return state === "bound";
|
|
239
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Does this list of binding entries name `ownAddonId` as the ACTIVE WRAPPER
|
|
301
|
+
* of `capName`?
|
|
302
|
+
*
|
|
303
|
+
* `isSameAddonId` is the whole point: `ownAddonId` is an `AddonContext.id`,
|
|
304
|
+
* which is prefixed (`addon:…`) in hub-main and bare in a forked runner,
|
|
305
|
+
* while `providerAddonId` is always bare. A raw `===` here is the D72 bug.
|
|
306
|
+
*/
|
|
307
|
+
function entriesBindWrapper(entries, capName, ownAddonId) {
|
|
308
|
+
return entries.some((entry) => entry.capName === capName && entry.kind === "wrapped" && require_dist.isSameAddonId(entry.providerAddonId, ownAddonId));
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Render binding entries for a log line. A systematic wrong answer and a
|
|
312
|
+
* one-off blip produce the same VERDICT; only the entries themselves tell
|
|
313
|
+
* them apart, so a negative read never gets to report just its conclusion.
|
|
314
|
+
*/
|
|
315
|
+
function summariseEntries(entries) {
|
|
316
|
+
return entries.map((entry) => `${entry.capName}:${entry.kind}:${entry.providerAddonId}`);
|
|
317
|
+
}
|
|
318
|
+
function isRecord$2(value) {
|
|
319
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Read the DURABLE authority — the `device-manager` addon store's
|
|
323
|
+
* `deviceBindings` map — for "is `ownAddonId` the active wrapper of
|
|
324
|
+
* `capName` on `deviceId`".
|
|
325
|
+
*
|
|
326
|
+
* This is the input the derived `getBindings` view is not: it is the row the
|
|
327
|
+
* operator's toggle actually writes, with no registry resolution, no
|
|
328
|
+
* `defaultActive` auto-binding and no cross-node cap folding in between. It
|
|
329
|
+
* also grades its own trustworthiness, which `getBindings` cannot: the
|
|
330
|
+
* absence of the `deviceBindings` KEY is the signature of a store answering
|
|
331
|
+
* from an empty snapshot, whereas a genuine unbind leaves the key present.
|
|
332
|
+
*/
|
|
333
|
+
function readDurableWrapperBinding(record, deviceId, capName, ownAddonId) {
|
|
334
|
+
if (!isRecord$2(record)) return "unreadable";
|
|
335
|
+
const deviceBindings = record["deviceBindings"];
|
|
336
|
+
if (!isRecord$2(deviceBindings)) return "unreadable";
|
|
337
|
+
const perDevice = deviceBindings[String(deviceId)];
|
|
338
|
+
if (!isRecord$2(perDevice)) return "unbound";
|
|
339
|
+
const activation = perDevice[capName];
|
|
340
|
+
if (!isRecord$2(activation)) return "unbound";
|
|
341
|
+
const wrapperAddonId = activation["wrapperAddonId"];
|
|
342
|
+
if (typeof wrapperAddonId !== "string") return "unbound";
|
|
343
|
+
return require_dist.isSameAddonId(wrapperAddonId, ownAddonId) ? "bound" : "unbound";
|
|
344
|
+
}
|
|
240
345
|
//#endregion
|
|
241
346
|
//#region src/builtins/doorbell/doorbell-settings.ts
|
|
242
347
|
/**
|
|
@@ -330,6 +435,13 @@ function applyDoorbellSourcesPatch(current, patchValue) {
|
|
|
330
435
|
}
|
|
331
436
|
//#endregion
|
|
332
437
|
//#region src/builtins/doorbell/virtual-doorbell.addon.ts
|
|
438
|
+
/**
|
|
439
|
+
* The addon whose store IS the durable authority on wrapper activations.
|
|
440
|
+
* `deviceBindings[<deviceId>][<capName>].wrapperAddonId` is the row the
|
|
441
|
+
* operator's bindings toggle writes; `deviceManager.getBindings` is a VIEW
|
|
442
|
+
* derived from it plus the capability registry.
|
|
443
|
+
*/
|
|
444
|
+
var DEVICE_MANAGER_ADDON_ID = "device-manager";
|
|
333
445
|
/** Structural narrowing helper for untrusted bus payloads. */
|
|
334
446
|
function isRecord(value) {
|
|
335
447
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -469,19 +581,14 @@ var VirtualDoorbellAddon = class extends require_dist.BaseAddon {
|
|
|
469
581
|
* byte-shaped like a native firmware ring so every downstream consumer
|
|
470
582
|
* (UI toast, notifier rules, exporters) is agnostic to the origin.
|
|
471
583
|
*
|
|
472
|
-
* The binding gate here is a pure in-memory read
|
|
473
|
-
*
|
|
474
|
-
*
|
|
584
|
+
* The binding gate here is a pure in-memory read on the path that RINGS:
|
|
585
|
+
* an open mirror performs NO I/O and cannot fail. The mirror can only
|
|
586
|
+
* DESTROY a press through the one branch below, and that branch is not
|
|
587
|
+
* allowed to be the last word — see `ringsDespiteUnboundMirror`.
|
|
475
588
|
*/
|
|
476
589
|
async fireDoorbell(cameraId, timestamp) {
|
|
477
590
|
const binding = this.bindingMirror.get(cameraId);
|
|
478
|
-
if (!allowsRing(binding))
|
|
479
|
-
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", {
|
|
480
|
-
tags: { deviceId: cameraId },
|
|
481
|
-
meta: { bindingState: binding }
|
|
482
|
-
});
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
591
|
+
if (!allowsRing(binding) && !await this.ringsDespiteUnboundMirror(cameraId, binding)) return;
|
|
485
592
|
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", {
|
|
486
593
|
tags: { deviceId: cameraId },
|
|
487
594
|
meta: { bindingState: binding ?? "never-read" }
|
|
@@ -520,20 +627,28 @@ var VirtualDoorbellAddon = class extends require_dist.BaseAddon {
|
|
|
520
627
|
});
|
|
521
628
|
}
|
|
522
629
|
/**
|
|
523
|
-
*
|
|
524
|
-
* assignment-reload cadence, never while firing.
|
|
630
|
+
* The addon id as the REGISTRY and the bindings store spell it.
|
|
525
631
|
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
* because a genuine unbind and a store answering from an empty snapshot
|
|
531
|
-
* (D44) are indistinguishable in a single response.
|
|
632
|
+
* `ctx.id` does NOT: hub-main prefixes it (`addon:virtual-doorbell`) while
|
|
633
|
+
* a forked runner does not, and this builtin runs in hub-main. Comparing
|
|
634
|
+
* the raw `ctx.id` to a `providerAddonId` was false for every entry for
|
|
635
|
+
* twelve hours on 2026-08-07 (D72).
|
|
532
636
|
*/
|
|
533
|
-
|
|
534
|
-
|
|
637
|
+
get ownAddonId() {
|
|
638
|
+
return require_dist.bareAddonId(this.ctx.id);
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* One read of the DERIVED binding view. `null` when the read could not be
|
|
642
|
+
* answered at all — which carries no information and must leave the mirror
|
|
643
|
+
* untouched.
|
|
644
|
+
*/
|
|
645
|
+
async readDerivedBinding(cameraId) {
|
|
535
646
|
try {
|
|
536
|
-
|
|
647
|
+
const bindings = await this.ctx.api.deviceManager.getBindings.query({ deviceId: cameraId });
|
|
648
|
+
return {
|
|
649
|
+
bound: entriesBindWrapper(bindings.entries, require_dist.doorbellCapability.name, this.ownAddonId),
|
|
650
|
+
entries: bindings.entries
|
|
651
|
+
};
|
|
537
652
|
} catch (err) {
|
|
538
653
|
this.ctx.logger.warn("virtual-doorbell: binding check failed — keeping the last known verdict, NOT treating this as an unbind", {
|
|
539
654
|
tags: { deviceId: cameraId },
|
|
@@ -542,19 +657,126 @@ var VirtualDoorbellAddon = class extends require_dist.BaseAddon {
|
|
|
542
657
|
bindingState: this.bindingMirror.get(cameraId)
|
|
543
658
|
}
|
|
544
659
|
});
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* One read of the DURABLE authority: the `device-manager` addon store's
|
|
665
|
+
* `deviceBindings` map, straight from the settings DB.
|
|
666
|
+
*
|
|
667
|
+
* This is deliberately NOT `getBindings`. The derived view folds the store
|
|
668
|
+
* together with the capability registry, `defaultActive` auto-binding and
|
|
669
|
+
* the cluster native-cap feeds — any of which can make it disagree with
|
|
670
|
+
* what the operator actually persisted, and one of which (an addon-id
|
|
671
|
+
* spelling mismatch) made it disagree *systematically* while looking
|
|
672
|
+
* exactly like a genuine unbind. The raw row cannot: it is what the
|
|
673
|
+
* bindings toggle wrote, and it grades its own trustworthiness (D44).
|
|
674
|
+
*/
|
|
675
|
+
async readDurableAuthority(cameraId) {
|
|
676
|
+
try {
|
|
677
|
+
return readDurableWrapperBinding(await this.ctx.api.addonSettingsRaw.getGlobal.query({ addonId: DEVICE_MANAGER_ADDON_ID }), cameraId, require_dist.doorbellCapability.name, this.ownAddonId);
|
|
678
|
+
} catch (err) {
|
|
679
|
+
this.ctx.logger.warn("virtual-doorbell: the durable bindings store could not be read — it carries no information and revokes nothing", {
|
|
680
|
+
tags: { deviceId: cameraId },
|
|
681
|
+
meta: { error: require_dist.errMsg(err) }
|
|
682
|
+
});
|
|
683
|
+
return "unreadable";
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Reconcile `cameraId`'s mirror against the authority. Runs on the
|
|
688
|
+
* assignment-reload cadence, never while firing — and it runs on EVERY
|
|
689
|
+
* cycle regardless of the current verdict, so a camera sitting in
|
|
690
|
+
* `unbound` returns to `bound` on its own the moment the authority says
|
|
691
|
+
* so. There is no latch here that an operator has to clear.
|
|
692
|
+
*
|
|
693
|
+
* A positive derived read is believed immediately. A NEGATIVE one never
|
|
694
|
+
* is: the durable authority is asked, and it outranks the derived view in
|
|
695
|
+
* the direction that destroys work. Only when the authority agrees does
|
|
696
|
+
* the negative get folded, and even then `nextBindingState` still wants a
|
|
697
|
+
* second consecutive one (D49).
|
|
698
|
+
*/
|
|
699
|
+
async refreshBindingMirror(cameraId) {
|
|
700
|
+
const derived = await this.readDerivedBinding(cameraId);
|
|
701
|
+
if (derived === null) return;
|
|
702
|
+
if (derived.bound) {
|
|
703
|
+
this.bindingMirror.set(cameraId, nextBindingState(this.bindingMirror.get(cameraId), true));
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
const authority = await this.readDurableAuthority(cameraId);
|
|
707
|
+
const entries = summariseEntries(derived.entries);
|
|
708
|
+
if (authority === "bound") {
|
|
709
|
+
this.ctx.logger.warn("virtual-doorbell: the derived binding list omits this wrapper but the durable bindings store still names this wrapper — trusting the store", {
|
|
710
|
+
tags: { deviceId: cameraId },
|
|
711
|
+
meta: {
|
|
712
|
+
ownAddonId: this.ownAddonId,
|
|
713
|
+
entries
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
this.bindingMirror.set(cameraId, nextBindingState(this.bindingMirror.get(cameraId), true));
|
|
545
717
|
return;
|
|
546
718
|
}
|
|
547
|
-
const boundNow = entries.some((entry) => entry.capName === require_dist.doorbellCapability.name && entry.kind === "wrapped" && entry.providerAddonId === this.ctx.id);
|
|
548
719
|
const previous = this.bindingMirror.get(cameraId);
|
|
549
|
-
const next = nextBindingState(previous,
|
|
720
|
+
const next = nextBindingState(previous, false);
|
|
550
721
|
this.bindingMirror.set(cameraId, next);
|
|
551
|
-
|
|
722
|
+
this.ctx.logger.warn("virtual-doorbell: bindings read did not see this wrapper", {
|
|
552
723
|
tags: { deviceId: cameraId },
|
|
553
724
|
meta: {
|
|
554
725
|
from: previous ?? "never-read",
|
|
555
|
-
to: next
|
|
726
|
+
to: next,
|
|
727
|
+
ownAddonId: this.ownAddonId,
|
|
728
|
+
durableAuthority: authority,
|
|
729
|
+
entries
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* The mirror says `unbound` and a real press just arrived. Decide, with
|
|
735
|
+
* ONE read of the durable authority, whether to destroy it.
|
|
736
|
+
*
|
|
737
|
+
* D49 forbade I/O on the ring path because the read it would have made was
|
|
738
|
+
* the same fallible derived read that caused the problem. This read is
|
|
739
|
+
* different in both directions: it is the authority rather than a view of
|
|
740
|
+
* it, and it is paid ONLY on the branch that would otherwise drop a press —
|
|
741
|
+
* a ring is rare, one query is cheap, and a dropped ring has no retry, no
|
|
742
|
+
* reconcile and nothing downstream that notices.
|
|
743
|
+
*
|
|
744
|
+
* Returns `true` when the ring must proceed.
|
|
745
|
+
*/
|
|
746
|
+
async ringsDespiteUnboundMirror(cameraId, binding) {
|
|
747
|
+
const authority = await this.readDurableAuthority(cameraId);
|
|
748
|
+
if (authority === "bound") {
|
|
749
|
+
this.bindingMirror.set(cameraId, "bound");
|
|
750
|
+
this.ctx.logger.warn("virtual-doorbell: ring RESCUED — the mirror said unbound but the durable bindings store still names this wrapper; the mirror has been repaired", {
|
|
751
|
+
tags: { deviceId: cameraId },
|
|
752
|
+
meta: {
|
|
753
|
+
bindingState: binding,
|
|
754
|
+
ownAddonId: this.ownAddonId
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
return true;
|
|
758
|
+
}
|
|
759
|
+
if (authority === "unreadable") {
|
|
760
|
+
this.ctx.logger.warn("virtual-doorbell: ringing on an unbound mirror — the durable bindings store could not answer, and an unanswerable store never destroys a one-shot press", {
|
|
761
|
+
tags: { deviceId: cameraId },
|
|
762
|
+
meta: {
|
|
763
|
+
bindingState: binding,
|
|
764
|
+
ownAddonId: this.ownAddonId
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
return true;
|
|
768
|
+
}
|
|
769
|
+
const derived = await this.readDerivedBinding(cameraId);
|
|
770
|
+
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", {
|
|
771
|
+
tags: { deviceId: cameraId },
|
|
772
|
+
meta: {
|
|
773
|
+
bindingState: binding,
|
|
774
|
+
ownAddonId: this.ownAddonId,
|
|
775
|
+
durableAuthority: authority,
|
|
776
|
+
entries: derived === null ? "unreadable" : summariseEntries(derived.entries)
|
|
556
777
|
}
|
|
557
778
|
});
|
|
779
|
+
return false;
|
|
558
780
|
}
|
|
559
781
|
/**
|
|
560
782
|
* Record a binding we observed FIRST-HAND. Both callers are cap methods
|