@camstack/addon-provider-reolink 1.1.15 → 1.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +1257 -53
  2. package/dist/addon.mjs +1257 -53
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -4655,7 +4655,7 @@ function _instanceof(cls, params = {}) {
4655
4655
  return inst;
4656
4656
  }
4657
4657
  //#endregion
4658
- //#region ../types/dist/sleep-MHm--th-.mjs
4658
+ //#region ../types/dist/sleep-BiDFW0E7.mjs
4659
4659
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4660
4660
  EventCategory["SystemBoot"] = "system.boot";
4661
4661
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5468,6 +5468,100 @@ function createDurableState(deps) {
5468
5468
  };
5469
5469
  }
5470
5470
  /**
5471
+ * Per-node scoping for the shared addon-settings blob.
5472
+ *
5473
+ * An addon's settings store is hub-central (the `addon-settings` cap is
5474
+ * hub-routed — the hub instance answers for every node), so fields whose
5475
+ * value is a NODE fact (decoder backend, engine pick, probed hardware
5476
+ * capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
5477
+ * the single shared blob. The SCHEMA field key stays bare: the write path
5478
+ * ({@link scopePatch}) maps the bare field onto the target node's scoped
5479
+ * key; the read/hydrate path ({@link projectStore}) maps THIS node's value
5480
+ * back, so UI forms and `resolveConfig` only ever see the bare key.
5481
+ *
5482
+ * Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
5483
+ * (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
5484
+ * schema and routes reads/writes through these helpers.
5485
+ *
5486
+ * ## No bare-key fallback — deliberate
5487
+ *
5488
+ * {@link readNodeValue} reads the node-scoped key ONLY. A node with no
5489
+ * scoped key resolves to `undefined` so the field's schema `default` wins —
5490
+ * NEVER `store[base]` and never another node's value. A bare legacy key in
5491
+ * the store is invisible to every node, hub included, so one node's
5492
+ * selection can never leak onto another. (This generalizes the
5493
+ * `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
5494
+ * arbitrary set of per-node field keys.)
5495
+ *
5496
+ * Pure functions only — no I/O, no imports beyond the language. This is a
5497
+ * LEAF module: import it via its deep path, never from the root barrel.
5498
+ */
5499
+ /**
5500
+ * Normalize a raw kernel node id to the bare node id used for scoping.
5501
+ * `localNodeId` can carry a `<node>/<addon>` suffix on forked child
5502
+ * processes; per-node settings are per-NODE, so strip the addon segment.
5503
+ * `undefined` / `null` / empty falls back to `'hub'`.
5504
+ */
5505
+ function normalizeNodeId(raw) {
5506
+ if (raw === void 0 || raw === null || raw === "") return "hub";
5507
+ const slashIdx = raw.indexOf("/");
5508
+ if (slashIdx < 0) return raw;
5509
+ const bare = raw.slice(0, slashIdx);
5510
+ return bare === "" ? "hub" : bare;
5511
+ }
5512
+ /** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
5513
+ function nodeScopedKey(base, nodeId) {
5514
+ return `${base}@${normalizeNodeId(nodeId)}`;
5515
+ }
5516
+ /**
5517
+ * Read a node's value for a per-node field from the raw shared store:
5518
+ * the node-scoped key when present, otherwise `undefined`.
5519
+ * Deliberately NO bare-key fallback (see module doc) — the caller lets the
5520
+ * schema `default` win on `undefined`.
5521
+ */
5522
+ function readNodeValue(store, base, nodeId) {
5523
+ return store[nodeScopedKey(base, nodeId)];
5524
+ }
5525
+ /**
5526
+ * Re-map a UI/settings patch so every bare perNode field persists under the
5527
+ * TARGET node's scoped key; all other keys pass through unchanged. Used on
5528
+ * the write path so a save for one node never clobbers another node's value
5529
+ * (and the bare key is never written). Returns a new object — the input
5530
+ * patch is not mutated.
5531
+ */
5532
+ function scopePatch(patch, perNodeKeys, nodeId) {
5533
+ const out = {};
5534
+ for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
5535
+ return out;
5536
+ }
5537
+ /**
5538
+ * Project the raw shared store onto the bare schema keys for ONE node so a
5539
+ * UI schema (whose field keys are bare) hydrates from that node's own
5540
+ * values:
5541
+ *
5542
+ * - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
5543
+ * - Every bare perNode key is dropped from the pass-through (a stray bare
5544
+ * legacy key must never hydrate any node — no bare fallback).
5545
+ * - THIS node's effective value ({@link readNodeValue}) is then laid onto
5546
+ * each bare perNode key; when the node has no scoped key the bare key is
5547
+ * left ABSENT so the field's schema `default` wins.
5548
+ *
5549
+ * Returns a new object — the input store is not mutated.
5550
+ */
5551
+ function projectStore(store, perNodeKeys, nodeId) {
5552
+ const out = {};
5553
+ for (const [key, value] of Object.entries(store)) {
5554
+ if (key.includes("@")) continue;
5555
+ if (perNodeKeys.has(key)) continue;
5556
+ out[key] = value;
5557
+ }
5558
+ for (const base of perNodeKeys) {
5559
+ const value = readNodeValue(store, base, nodeId);
5560
+ if (value !== void 0) out[base] = value;
5561
+ }
5562
+ return out;
5563
+ }
5564
+ /**
5471
5565
  * Base class for CamStack addons. Eliminates settings boilerplate:
5472
5566
  *
5473
5567
  * - Typed `config` property with automatic resolution from store + defaults
@@ -5635,23 +5729,63 @@ var BaseAddon = class {
5635
5729
  deviceSettingsSchema() {
5636
5730
  return null;
5637
5731
  }
5638
- async getGlobalSettings(overlay, cap, _nodeId) {
5732
+ async getGlobalSettings(overlay, cap, nodeId) {
5639
5733
  const schema = this.globalSettingsSchema(cap);
5640
5734
  if (!schema) return { sections: [] };
5641
- const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5735
+ const projected = await this.resolveGlobalStore(nodeId, cap);
5642
5736
  return hydrateSchema(schema, overlay ? {
5643
- ...raw,
5737
+ ...projected,
5644
5738
  ...overlay
5645
- } : raw);
5739
+ } : projected);
5646
5740
  }
5647
- async updateGlobalSettings(patch, _nodeId) {
5648
- await this._ctx?.settings?.writeAddonStore(patch);
5741
+ /**
5742
+ * The raw addon store PROJECTED onto the target node's bare per-node keys:
5743
+ * every `perNode: true` field carries THAT node's scoped value on its bare
5744
+ * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
5745
+ * bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
5746
+ * A no-op passthrough when the schema declares no `perNode` field.
5747
+ *
5748
+ * This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
5749
+ * the store for custom option logic (option narrowing, value snapping) to
5750
+ * read it per-node — never `ctx.settings.readAddonStore()` directly.
5751
+ * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
5752
+ */
5753
+ async resolveGlobalStore(nodeId, cap) {
5754
+ const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5755
+ const keys = this.perNodeKeys(cap);
5756
+ const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5757
+ return keys.size > 0 ? projectStore(raw, keys, node) : raw;
5758
+ }
5759
+ async updateGlobalSettings(patch, nodeId) {
5760
+ const keys = this.perNodeKeys();
5761
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5762
+ const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5763
+ const barePatch = patch;
5764
+ const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
5765
+ await this._ctx?.settings?.writeAddonStore(scoped);
5766
+ if (target !== localNode) return;
5649
5767
  await this.resolveConfig();
5650
5768
  await this.onConfigChanged();
5651
5769
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
5652
5770
  this.maybeAutoRestart(patch, this.globalSettingsSchema());
5653
5771
  }
5654
5772
  /**
5773
+ * The set of field keys the global settings schema declares `perNode: true`
5774
+ * — derived once per `cap` argument and memoized (schemas are static
5775
+ * declarations). Empty set ⇒ every per-node code path is bypassed and the
5776
+ * settings API behaves exactly like the legacy node-agnostic one.
5777
+ */
5778
+ _perNodeKeysCache = /* @__PURE__ */ new Map();
5779
+ perNodeKeys(cap) {
5780
+ const cacheKey = cap ?? "";
5781
+ const cached = this._perNodeKeysCache.get(cacheKey);
5782
+ if (cached) return cached;
5783
+ const schema = this.globalSettingsSchema(cap);
5784
+ const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
5785
+ this._perNodeKeysCache.set(cacheKey, keys);
5786
+ return keys;
5787
+ }
5788
+ /**
5655
5789
  * If any field in `patch` is marked `requiresRestart` in `schema`,
5656
5790
  * schedule an addon restart for the next tick. Deferred via
5657
5791
  * `setImmediate` so the tRPC mutation that triggered the write has
@@ -5804,12 +5938,19 @@ var BaseAddon = class {
5804
5938
  * The merge is shallow: each key in `defaults` is checked against the store.
5805
5939
  * Only keys present in defaults are read — the store can contain extra keys
5806
5940
  * (e.g. from older versions) without polluting the typed config.
5941
+ *
5942
+ * Keys the global settings schema declares `perNode: true` resolve from
5943
+ * THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
5944
+ * from the bare key — so a per-node field resolves to this node's own
5945
+ * selection at boot (absent scoped key ⇒ the constructor default wins).
5807
5946
  */
5808
5947
  async resolveConfig() {
5809
5948
  const stored = await this.readAddonStoreWithRetry();
5949
+ const perNode = this.perNodeKeys();
5950
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5810
5951
  const resolved = { ...this.defaults };
5811
5952
  for (const key of Object.keys(this.defaults)) {
5812
- const storedValue = stored[key];
5953
+ const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
5813
5954
  if (storedValue !== void 0 && storedValue !== null) {
5814
5955
  const defaultType = typeof this.defaults[key];
5815
5956
  if (typeof storedValue === defaultType) resolved[key] = storedValue;
@@ -5893,6 +6034,27 @@ var BaseAddon = class {
5893
6034
  }
5894
6035
  };
5895
6036
  /**
6037
+ * Collect the keys of every field marked `perNode: true`, recursing into
6038
+ * layout containers (`group` fields and `sub-tabs` tabs) the same way
6039
+ * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6040
+ * don't declare `perNode` and are excluded by the `in` narrowing.
6041
+ */
6042
+ function collectPerNodeFieldKeys(fields) {
6043
+ const collected = [];
6044
+ for (const field of fields) {
6045
+ if (field.type === "group") {
6046
+ collected.push(...collectPerNodeFieldKeys(field.fields));
6047
+ continue;
6048
+ }
6049
+ if (field.type === "sub-tabs") {
6050
+ for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
6051
+ continue;
6052
+ }
6053
+ if ("perNode" in field && field.perNode === true) collected.push(field.key);
6054
+ }
6055
+ return collected;
6056
+ }
6057
+ /**
5896
6058
  * Normalize an `ICamstackAddon.initialize()` return value into the
5897
6059
  * `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
5898
6060
  * envelopes pass through; void stays void.
@@ -6300,6 +6462,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
6300
6462
  /** Single still-image entity (HA `image.*`). Read-only display of an
6301
6463
  * `entity_picture` signed URL the browser loads directly. `image` cap. */
6302
6464
  DeviceType["Image"] = "image";
6465
+ /** Smart pet feeder — cloud-connected food dispenser with a bowl food
6466
+ * level, battery, desiccant life, feeding state and manual-feed /
6467
+ * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
6468
+ * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
6469
+ * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
6470
+ * integrations sharing the same food/desiccant/hopper surface. */
6471
+ DeviceType["PetFeeder"] = "pet-feeder";
6303
6472
  return DeviceType;
6304
6473
  }({});
6305
6474
  var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
@@ -7651,6 +7820,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
7651
7820
  for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7652
7821
  for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7653
7822
  /**
7823
+ * Error types for the safe expression engine. Two distinct classes so callers
7824
+ * can tell a compile-time (grammar) failure from a runtime (evaluation)
7825
+ * failure — both are non-fatal to the host: read paths degrade to "skip link".
7826
+ */
7827
+ /** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
7828
+ * the failure is anchored to a character (author-facing inline feedback). */
7829
+ var ExpressionParseError = class extends Error {
7830
+ position;
7831
+ constructor(message, position) {
7832
+ super(message);
7833
+ this.name = "ExpressionParseError";
7834
+ this.position = position;
7835
+ }
7836
+ };
7837
+ /** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
7838
+ * result, unknown builtin, step-budget exceeded). */
7839
+ var ExpressionEvalError = class extends Error {
7840
+ constructor(message) {
7841
+ super(message);
7842
+ this.name = "ExpressionEvalError";
7843
+ }
7844
+ };
7845
+ /**
7846
+ * Resource-bound constants for the safe expression engine.
7847
+ *
7848
+ * Every bound is defense-in-depth: the grammar is non-Turing-complete (no
7849
+ * loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
7850
+ * O(nodeCount) by construction. These caps merely put a hard ceiling on the
7851
+ * work a single author-supplied expression can request, so a hostile or
7852
+ * accidental pathological string can never spend unbounded CPU/memory.
7853
+ */
7854
+ /** Max source length (chars) — checked BEFORE tokenizing so a huge string is
7855
+ * rejected without allocation. */
7856
+ var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
7857
+ /** A legal binding / identifier name. */
7858
+ var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
7859
+ /** Binding names an author may NOT use: `now` is auto-injected; the literal
7860
+ * keywords lex as values, not identifiers, so binding to them is meaningless. */
7861
+ var RESERVED_BINDING_NAMES = new Set([
7862
+ "now",
7863
+ "true",
7864
+ "false",
7865
+ "null"
7866
+ ]);
7867
+ /**
7868
+ * Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
7869
+ * zero-dependency. The grammar is deliberately boring: decimal numbers,
7870
+ * single/double-quoted strings with a tiny escape set, identifiers, the three
7871
+ * value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
7872
+ * outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
7873
+ * is a parse error with a source position, so member access / assignment /
7874
+ * template literals are lexically impossible.
7875
+ */
7876
+ var KEYWORDS = new Set([
7877
+ "true",
7878
+ "false",
7879
+ "null"
7880
+ ]);
7881
+ function isDigit(ch) {
7882
+ return ch >= "0" && ch <= "9";
7883
+ }
7884
+ function isIdentStart(ch) {
7885
+ return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
7886
+ }
7887
+ function isIdentPart(ch) {
7888
+ return isIdentStart(ch) || isDigit(ch);
7889
+ }
7890
+ function isWhitespace(ch) {
7891
+ return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
7892
+ }
7893
+ /** Tokenize `source` into a flat token list ending with a single `eof` token.
7894
+ * Throws `ExpressionParseError` on any illegal character or unterminated
7895
+ * string. */
7896
+ function tokenize(source) {
7897
+ if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
7898
+ const tokens = [];
7899
+ let i = 0;
7900
+ const n = source.length;
7901
+ while (i < n) {
7902
+ const ch = source[i];
7903
+ if (isWhitespace(ch)) {
7904
+ i += 1;
7905
+ continue;
7906
+ }
7907
+ if (isDigit(ch)) {
7908
+ const start = i;
7909
+ while (i < n && isDigit(source[i])) i += 1;
7910
+ if (i < n && source[i] === ".") {
7911
+ if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
7912
+ i += 1;
7913
+ while (i < n && isDigit(source[i])) i += 1;
7914
+ }
7915
+ const text = source.slice(start, i);
7916
+ const value = Number(text);
7917
+ if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
7918
+ tokens.push({
7919
+ type: "number",
7920
+ value,
7921
+ pos: start
7922
+ });
7923
+ continue;
7924
+ }
7925
+ if (ch === "'" || ch === "\"") {
7926
+ const quote = ch;
7927
+ const start = i;
7928
+ i += 1;
7929
+ let out = "";
7930
+ let closed = false;
7931
+ while (i < n) {
7932
+ const c = source[i];
7933
+ if (c === "\\") {
7934
+ const next = i + 1 < n ? source[i + 1] : "";
7935
+ if (next === "\\" || next === "'" || next === "\"") {
7936
+ out += next;
7937
+ i += 2;
7938
+ continue;
7939
+ }
7940
+ throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
7941
+ }
7942
+ if (c === quote) {
7943
+ closed = true;
7944
+ i += 1;
7945
+ break;
7946
+ }
7947
+ out += c;
7948
+ i += 1;
7949
+ }
7950
+ if (!closed) throw new ExpressionParseError("unterminated string literal", start);
7951
+ tokens.push({
7952
+ type: "string",
7953
+ value: out,
7954
+ pos: start
7955
+ });
7956
+ continue;
7957
+ }
7958
+ if (isIdentStart(ch)) {
7959
+ const start = i;
7960
+ while (i < n && isIdentPart(source[i])) i += 1;
7961
+ const text = source.slice(start, i);
7962
+ if (KEYWORDS.has(text)) tokens.push({
7963
+ type: "keyword",
7964
+ keyword: keywordOf(text),
7965
+ pos: start
7966
+ });
7967
+ else tokens.push({
7968
+ type: "identifier",
7969
+ name: text,
7970
+ pos: start
7971
+ });
7972
+ continue;
7973
+ }
7974
+ const two = i + 1 < n ? source.slice(i, i + 2) : "";
7975
+ if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
7976
+ tokens.push({
7977
+ type: "punct",
7978
+ punct: two,
7979
+ pos: i
7980
+ });
7981
+ i += 2;
7982
+ continue;
7983
+ }
7984
+ if (isSinglePunct(ch)) {
7985
+ tokens.push({
7986
+ type: "punct",
7987
+ punct: ch,
7988
+ pos: i
7989
+ });
7990
+ i += 1;
7991
+ continue;
7992
+ }
7993
+ throw new ExpressionParseError(`unexpected character '${ch}'`, i);
7994
+ }
7995
+ tokens.push({
7996
+ type: "eof",
7997
+ pos: n
7998
+ });
7999
+ return tokens;
8000
+ }
8001
+ function keywordOf(text) {
8002
+ if (text === "true") return "true";
8003
+ if (text === "false") return "false";
8004
+ return "null";
8005
+ }
8006
+ function isSinglePunct(ch) {
8007
+ return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
8008
+ }
8009
+ /**
8010
+ * Frozen, null-prototype builtin function table for the expression engine
8011
+ * (spec §4 rule 4). The table is the SOLE surface of callable functions: the
8012
+ * parser rejects any callee not in it, and the evaluator gates each call on an
8013
+ * own-property check against it.
8014
+ *
8015
+ * Because the object has a NULL prototype AND is `Object.freeze`d:
8016
+ * - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
8017
+ * - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
8018
+ * (there is no `Object.prototype` in the chain), so those names are not
8019
+ * callable — they are simply "unknown function" at parse time.
8020
+ *
8021
+ * Every numeric argument is validated as a finite number and every numeric
8022
+ * RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
8023
+ * (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
8024
+ * closed rather than emitting a garbage value.
8025
+ */
8026
+ function asFiniteNumber(value, name, index) {
8027
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
8028
+ return value;
8029
+ }
8030
+ function asString$1(value, name, index) {
8031
+ if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
8032
+ return value;
8033
+ }
8034
+ function finiteResult(value, name) {
8035
+ if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
8036
+ return value;
8037
+ }
8038
+ function allFiniteNumbers(args, name) {
8039
+ return args.map((a, idx) => asFiniteNumber(a, name, idx));
8040
+ }
8041
+ var INF = Number.POSITIVE_INFINITY;
8042
+ var table$1 = {
8043
+ min: {
8044
+ minArgs: 1,
8045
+ maxArgs: INF,
8046
+ apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
8047
+ },
8048
+ max: {
8049
+ minArgs: 1,
8050
+ maxArgs: INF,
8051
+ apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
8052
+ },
8053
+ abs: {
8054
+ minArgs: 1,
8055
+ maxArgs: 1,
8056
+ apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
8057
+ },
8058
+ floor: {
8059
+ minArgs: 1,
8060
+ maxArgs: 1,
8061
+ apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
8062
+ },
8063
+ ceil: {
8064
+ minArgs: 1,
8065
+ maxArgs: 1,
8066
+ apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
8067
+ },
8068
+ sqrt: {
8069
+ minArgs: 1,
8070
+ maxArgs: 1,
8071
+ apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
8072
+ },
8073
+ round: {
8074
+ minArgs: 1,
8075
+ maxArgs: 2,
8076
+ apply: (args) => {
8077
+ const x = asFiniteNumber(args[0], "round", 0);
8078
+ const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
8079
+ if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
8080
+ const factor = 10 ** digits;
8081
+ return finiteResult(Math.round(x * factor) / factor, "round");
8082
+ }
8083
+ },
8084
+ pow: {
8085
+ minArgs: 2,
8086
+ maxArgs: 2,
8087
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
8088
+ },
8089
+ clamp: {
8090
+ minArgs: 3,
8091
+ maxArgs: 3,
8092
+ apply: (args) => {
8093
+ const x = asFiniteNumber(args[0], "clamp", 0);
8094
+ const lo = asFiniteNumber(args[1], "clamp", 1);
8095
+ const hi = asFiniteNumber(args[2], "clamp", 2);
8096
+ if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
8097
+ return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
8098
+ }
8099
+ },
8100
+ avg: {
8101
+ minArgs: 1,
8102
+ maxArgs: INF,
8103
+ apply: (args) => {
8104
+ const nums = allFiniteNumbers(args, "avg");
8105
+ return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
8106
+ }
8107
+ },
8108
+ sum: {
8109
+ minArgs: 1,
8110
+ maxArgs: INF,
8111
+ apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
8112
+ },
8113
+ coalesce: {
8114
+ minArgs: 1,
8115
+ maxArgs: INF,
8116
+ apply: (args) => {
8117
+ for (const a of args) if (a !== null) return a;
8118
+ return null;
8119
+ }
8120
+ },
8121
+ age: {
8122
+ minArgs: 2,
8123
+ maxArgs: 2,
8124
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
8125
+ },
8126
+ convert: {
8127
+ minArgs: 3,
8128
+ maxArgs: 3,
8129
+ apply: (args, hooks) => {
8130
+ const x = asFiniteNumber(args[0], "convert", 0);
8131
+ const from = asString$1(args[1], "convert", 1).trim();
8132
+ const to = asString$1(args[2], "convert", 2).trim();
8133
+ if (hooks.convert) {
8134
+ const out = hooks.convert(x, from, to);
8135
+ if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
8136
+ return finiteResult(out, "convert");
8137
+ }
8138
+ if (from === to) return x;
8139
+ throw new ExpressionEvalError("convert: unit conversion table not installed");
8140
+ }
8141
+ }
8142
+ };
8143
+ Object.freeze(Object.assign(Object.create(null), table$1));
8144
+ /** The set of valid builtin names — used by the parser to reject unknown
8145
+ * callees at parse time (immediate author feedback). */
8146
+ var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table$1));
8147
+ /**
8148
+ * Pratt (precedence-climbing) parser for the safe expression mini-language.
8149
+ *
8150
+ * Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
8151
+ * → relational → additive → multiplicative → unary `! -` → call / primary.
8152
+ * Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
8153
+ * string validated against the builtin table at parse time, so an unknown
8154
+ * function is rejected immediately (author feedback) and a persisted expression
8155
+ * that references a since-removed builtin degrades at read.
8156
+ *
8157
+ * A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
8158
+ * arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
8159
+ */
8160
+ /** Binary/logical operator precedence (higher binds tighter). */
8161
+ var BINARY_PRECEDENCE = {
8162
+ "||": 1,
8163
+ "&&": 2,
8164
+ "==": 3,
8165
+ "!=": 3,
8166
+ "<": 4,
8167
+ "<=": 4,
8168
+ ">": 4,
8169
+ ">=": 4,
8170
+ "+": 5,
8171
+ "-": 5,
8172
+ "*": 6,
8173
+ "/": 6,
8174
+ "%": 6
8175
+ };
8176
+ function isLogicalOp(op) {
8177
+ return op === "&&" || op === "||";
8178
+ }
8179
+ function isBinaryOp(op) {
8180
+ return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
8181
+ }
8182
+ var Parser = class {
8183
+ tokens;
8184
+ pos = 0;
8185
+ nodeCount = 0;
8186
+ identifiers = /* @__PURE__ */ new Set();
8187
+ callees = /* @__PURE__ */ new Set();
8188
+ constructor(tokens) {
8189
+ this.tokens = tokens;
8190
+ }
8191
+ parse() {
8192
+ const ast = this.parseTernary();
8193
+ const tok = this.peek();
8194
+ if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
8195
+ return {
8196
+ ast,
8197
+ identifiers: this.identifiers,
8198
+ callees: this.callees,
8199
+ nodeCount: this.nodeCount
8200
+ };
8201
+ }
8202
+ peek() {
8203
+ return this.tokens[this.pos];
8204
+ }
8205
+ next() {
8206
+ return this.tokens[this.pos++];
8207
+ }
8208
+ /** Consume a punctuator token, erroring if the next token isn't it. */
8209
+ expectPunct(punct) {
8210
+ const tok = this.peek();
8211
+ if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
8212
+ this.pos += 1;
8213
+ }
8214
+ matchPunct(punct) {
8215
+ const tok = this.peek();
8216
+ if (tok.type === "punct" && tok.punct === punct) {
8217
+ this.pos += 1;
8218
+ return true;
8219
+ }
8220
+ return false;
8221
+ }
8222
+ countNode() {
8223
+ this.nodeCount += 1;
8224
+ if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
8225
+ }
8226
+ parseTernary() {
8227
+ const test = this.parseBinary(1);
8228
+ if (this.matchPunct("?")) {
8229
+ const consequent = this.parseTernary();
8230
+ this.expectPunct(":");
8231
+ const alternate = this.parseTernary();
8232
+ this.countNode();
8233
+ return {
8234
+ kind: "conditional",
8235
+ test,
8236
+ consequent,
8237
+ alternate
8238
+ };
8239
+ }
8240
+ return test;
8241
+ }
8242
+ parseBinary(minPrec) {
8243
+ let left = this.parseUnary();
8244
+ for (;;) {
8245
+ const tok = this.peek();
8246
+ if (tok.type !== "punct") break;
8247
+ const prec = BINARY_PRECEDENCE[tok.punct];
8248
+ if (prec === void 0 || prec < minPrec) break;
8249
+ const op = tok.punct;
8250
+ this.pos += 1;
8251
+ const right = this.parseBinary(prec + 1);
8252
+ this.countNode();
8253
+ if (isLogicalOp(op)) left = {
8254
+ kind: "logical",
8255
+ op,
8256
+ left,
8257
+ right
8258
+ };
8259
+ else if (isBinaryOp(op)) left = {
8260
+ kind: "binary",
8261
+ op,
8262
+ left,
8263
+ right
8264
+ };
8265
+ else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
8266
+ }
8267
+ return left;
8268
+ }
8269
+ parseUnary() {
8270
+ const tok = this.peek();
8271
+ if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
8272
+ const op = tok.punct;
8273
+ this.pos += 1;
8274
+ const operand = this.parseUnary();
8275
+ this.countNode();
8276
+ return {
8277
+ kind: "unary",
8278
+ op,
8279
+ operand
8280
+ };
8281
+ }
8282
+ return this.parsePrimary();
8283
+ }
8284
+ parsePrimary() {
8285
+ const tok = this.next();
8286
+ switch (tok.type) {
8287
+ case "number":
8288
+ this.countNode();
8289
+ return {
8290
+ kind: "literal",
8291
+ value: tok.value
8292
+ };
8293
+ case "string":
8294
+ this.countNode();
8295
+ return {
8296
+ kind: "literal",
8297
+ value: tok.value
8298
+ };
8299
+ case "keyword":
8300
+ this.countNode();
8301
+ return {
8302
+ kind: "literal",
8303
+ value: tok.keyword === "null" ? null : tok.keyword === "true"
8304
+ };
8305
+ case "identifier": {
8306
+ const nextTok = this.peek();
8307
+ if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
8308
+ this.identifiers.add(tok.name);
8309
+ this.countNode();
8310
+ return {
8311
+ kind: "identifier",
8312
+ name: tok.name
8313
+ };
8314
+ }
8315
+ case "punct":
8316
+ if (tok.punct === "(") {
8317
+ const inner = this.parseTernary();
8318
+ this.expectPunct(")");
8319
+ return inner;
8320
+ }
8321
+ throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
8322
+ case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
8323
+ }
8324
+ }
8325
+ parseCall(callee, pos) {
8326
+ if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
8327
+ this.expectPunct("(");
8328
+ const args = [];
8329
+ if (!this.matchPunct(")")) for (;;) {
8330
+ args.push(this.parseTernary());
8331
+ if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
8332
+ if (this.matchPunct(",")) continue;
8333
+ this.expectPunct(")");
8334
+ break;
8335
+ }
8336
+ this.callees.add(callee);
8337
+ this.countNode();
8338
+ return {
8339
+ kind: "call",
8340
+ callee,
8341
+ args
8342
+ };
8343
+ }
8344
+ };
8345
+ /** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
8346
+ * `ExpressionParseError` on any lexical or grammatical failure. */
8347
+ function parseExpression(source) {
8348
+ return new Parser(tokenize(source)).parse();
8349
+ }
8350
+ Object.freeze({});
8351
+ /**
8352
+ * LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
8353
+ * by expr"). The cache stores BOTH successes and failures (negative caching),
8354
+ * so a corrupt persisted string costs exactly one tokenize+parse total — not
8355
+ * one per read on a hot resolve path.
8356
+ *
8357
+ * The cache is a module-level singleton: entries are pure, content-addressed
8358
+ * ASTs keyed by the raw source string, so sharing one instance across all
8359
+ * callers is safe and maximises hit rate.
8360
+ */
8361
+ var cache$1 = /* @__PURE__ */ new Map();
8362
+ function getCached(source) {
8363
+ const hit = cache$1.get(source);
8364
+ if (hit !== void 0) {
8365
+ cache$1.delete(source);
8366
+ cache$1.set(source, hit);
8367
+ return hit;
8368
+ }
8369
+ let result;
8370
+ try {
8371
+ result = {
8372
+ ok: true,
8373
+ parsed: parseExpression(source)
8374
+ };
8375
+ } catch (err) {
8376
+ result = {
8377
+ ok: false,
8378
+ error: err instanceof ExpressionParseError ? err.message : String(err)
8379
+ };
8380
+ }
8381
+ cache$1.set(source, result);
8382
+ if (cache$1.size > 256) {
8383
+ const oldest = cache$1.keys().next().value;
8384
+ if (oldest !== void 0) cache$1.delete(oldest);
8385
+ }
8386
+ return result;
8387
+ }
8388
+ /** Compile `source`, returning a discriminated result instead of throwing.
8389
+ * Used by read paths that must degrade rather than raise. LRU/negative-cached. */
8390
+ function compileExpressionSafe(source) {
8391
+ return getCached(source);
8392
+ }
8393
+ /**
8394
+ * Author-time validation. Returns `null` when the source is valid, else a
8395
+ * human-readable error message. Checks: the expression compiles; binding count
8396
+ * is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
8397
+ * is not reserved (`now`/keywords) and does not shadow a builtin; and every
8398
+ * FREE identifier of the AST is covered by a binding or the injected `now`.
8399
+ */
8400
+ function validateExpressionSource(src) {
8401
+ const names = Object.keys(src.bindings);
8402
+ if (names.length > 32) return `too many bindings (${names.length} > 32)`;
8403
+ for (const name of names) {
8404
+ if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
8405
+ if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
8406
+ if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
8407
+ }
8408
+ const compiled = compileExpressionSafe(src.expr);
8409
+ if (!compiled.ok) return compiled.error;
8410
+ const bound = new Set(names);
8411
+ for (const id of compiled.parsed.identifiers) {
8412
+ if (id === "now") continue;
8413
+ if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
8414
+ }
8415
+ return null;
8416
+ }
8417
+ /**
7654
8418
  * Accessory device helpers — shared across drivers.
7655
8419
  *
7656
8420
  * Many vendor-specific drivers register accessory child devices on
@@ -8534,7 +9298,13 @@ onStatusChanged: { data: object({
8534
9298
  }) } },
8535
9299
  status: {
8536
9300
  schema: BatteryStatusSchema,
8537
- kind: "push"
9301
+ kind: "push",
9302
+ empty: {
9303
+ percentage: 0,
9304
+ charging: "none",
9305
+ sleeping: false,
9306
+ lastUpdated: 0
9307
+ }
8538
9308
  },
8539
9309
  /**
8540
9310
  * Runtime-state slice — every provider that registers this cap
@@ -9477,21 +10247,38 @@ var connectivityCapability = {
9477
10247
  },
9478
10248
  runtimeState: ConnectivityStatusSchema
9479
10249
  };
10250
+ /**
10251
+ * Generic device-consumables capability — surfaces a device's
10252
+ * maintenance items (vacuum filters/brushes, replaceable cartridges,
10253
+ * descaling cycles, …) with their remaining life and an optional
10254
+ * "Replaced" reset action. Device-agnostic: any provider that knows its
10255
+ * device tracks consumables can register it; the cap declares no
10256
+ * vocabulary of its own — the provider names each item verbatim.
10257
+ *
10258
+ * Like `childLayout`, the cap is INERT until a provider sets items: no
10259
+ * provider populates it by guessing (no HA inference). The UI renders a
10260
+ * "No consumables reported" placeholder when `items` is empty.
10261
+ */
10262
+ /** A single consumable item. Either a continuous `level` (remaining
10263
+ * life %) or a discrete `status` may be known — both may be null when a
10264
+ * provider only knows the item exists. `level` and `status` are not
10265
+ * mutually exclusive; a provider may report both. */
10266
+ var ConsumableItemSchema = object({
10267
+ /** Stable id, e.g. 'main-brush'. */
10268
+ key: string().min(1),
10269
+ /** Display name. */
10270
+ label: string().min(1),
10271
+ /** Remaining life % when known (0..100). */
10272
+ level: number().min(0).max(100).nullable(),
10273
+ /** Discrete state when known (binary mode). */
10274
+ status: _enum(["ok", "replace"]).nullable(),
10275
+ /** Ms epoch of the last replace, when known. */
10276
+ lastResetAt: number().nullable(),
10277
+ /** Whether `reset()` is meaningful for this item. */
10278
+ resettable: boolean()
10279
+ });
9480
10280
  var ConsumablesStatusSchema = object({
9481
- items: array(object({
9482
- /** Stable id, e.g. 'main-brush'. */
9483
- key: string().min(1),
9484
- /** Display name. */
9485
- label: string().min(1),
9486
- /** Remaining life % when known (0..100). */
9487
- level: number().min(0).max(100).nullable(),
9488
- /** Discrete state when known (binary mode). */
9489
- status: _enum(["ok", "replace"]).nullable(),
9490
- /** Ms epoch of the last replace, when known. */
9491
- lastResetAt: number().nullable(),
9492
- /** Whether `reset()` is meaningful for this item. */
9493
- resettable: boolean()
9494
- })),
10281
+ items: array(ConsumableItemSchema),
9495
10282
  lastChangedAt: number()
9496
10283
  });
9497
10284
  var consumablesCapability = {
@@ -9550,7 +10337,25 @@ reset: method(object({
9550
10337
  }) },
9551
10338
  status: {
9552
10339
  schema: ConsumablesStatusSchema,
9553
- kind: "push"
10340
+ kind: "push",
10341
+ empty: {
10342
+ items: [],
10343
+ lastChangedAt: 0
10344
+ },
10345
+ itemArray: {
10346
+ path: "items",
10347
+ keyField: "key",
10348
+ labelField: "label",
10349
+ itemSchema: ConsumableItemSchema,
10350
+ emptyItem: {
10351
+ key: "",
10352
+ label: "",
10353
+ level: null,
10354
+ status: null,
10355
+ lastResetAt: null,
10356
+ resettable: false
10357
+ }
10358
+ }
9554
10359
  },
9555
10360
  runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() })
9556
10361
  };
@@ -10792,7 +11597,8 @@ var MotionAnalysisResultSchema = object({
10792
11597
  });
10793
11598
  method(object({
10794
11599
  deviceId: number(),
10795
- frame: FrameInputSchema
11600
+ frame: FrameInputSchema.optional(),
11601
+ frameHandle: FrameHandleSchema.optional()
10796
11602
  }), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
10797
11603
  deviceId: number(),
10798
11604
  detected: boolean(),
@@ -11039,6 +11845,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11039
11845
  engine: PipelineEngineChoiceSchema.optional(),
11040
11846
  steps: array(PipelineStepInputSchema).min(1),
11041
11847
  frame: FrameInputSchema.optional(),
11848
+ /**
11849
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
11850
+ * the decoded pixels live in. One more member of the one-of
11851
+ * frame/frameHandle/image/imageBase64/referenceImage group.
11852
+ */
11853
+ frameHandle: FrameHandleSchema.optional(),
11042
11854
  imageBase64: string().optional(),
11043
11855
  /**
11044
11856
  * Binary JPEG bytes — preferred over `imageBase64` on internal
@@ -11281,6 +12093,31 @@ var ReportMotionInputSchema = object({
11281
12093
  regions: array(MotionRegionSchema).readonly().optional()
11282
12094
  });
11283
12095
  /**
12096
+ * Where a runner gets a camera's decoded frames (cross-node Phase 2,
12097
+ * restream-owner model — P2c).
12098
+ *
12099
+ * - `local-broker` (DEFAULT): today's path — subscribe to the co-located
12100
+ * stream-broker's shm frame plane. Every pre-P2c attach payload (no
12101
+ * `frameSource` key) parses to this, so the field is additive with zero
12102
+ * behavior change.
12103
+ * - `remote-restream`: the detect node is NOT the camera's source-owner.
12104
+ * The runner acquires the owner's COMPRESSED passthrough restream
12105
+ * (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
12106
+ * double-pull guard) and decodes LOCALLY via a satellite frame plane +
12107
+ * pull-mode decoder session pinned to its own node. The shm ring stays
12108
+ * node-local; only H.264/H.265 packets cross the wire.
12109
+ * `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
12110
+ * when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
12111
+ * dials for the owner's restream.
12112
+ */
12113
+ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
12114
+ kind: literal("remote-restream"),
12115
+ /** The camera's source-owner node (slice 1: always the hub). */
12116
+ ownerNodeId: string(),
12117
+ /** Operator override for the owner host the runner dials. */
12118
+ hubHostnameOverride: string().optional()
12119
+ })]).describe("Per-camera frame-source mode for the runner (P2c)");
12120
+ /**
11284
12121
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
11285
12122
  * specific runner instance via `attachCamera`. Carries everything the
11286
12123
  * runner needs to subscribe to the local broker and execute inference.
@@ -11378,7 +12215,15 @@ var RunnerCameraConfigSchema = object({
11378
12215
  */
11379
12216
  onboardMotionDrivesAnalyzer: boolean().default(true),
11380
12217
  occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
11381
- occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
12218
+ occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
12219
+ /**
12220
+ * Where this runner gets the camera's decoded frames (P2c). Defaulted so
12221
+ * every existing payload behaves as `local-broker` — the pre-Phase-2 path.
12222
+ * Populated with `remote-restream` by the orchestrator ONLY when the
12223
+ * camera's detect node differs from its source-owner (P2d, gated by the
12224
+ * `remoteSourcingNodes` rollout setting).
12225
+ */
12226
+ frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
11382
12227
  });
11383
12228
  motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
11384
12229
  /**
@@ -11942,6 +12787,157 @@ var numericSensorCapability = {
11942
12787
  runtimeState: NumericSensorStatusSchema
11943
12788
  };
11944
12789
  /**
12790
+ * Feeder connectivity / power status — mirrors the HA petkit device-status
12791
+ * enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
12792
+ * `on_batteries` (running on battery backup). `null` until first reported.
12793
+ */
12794
+ var PetFeederDeviceStatusSchema = _enum([
12795
+ "normal",
12796
+ "offline",
12797
+ "on_batteries"
12798
+ ]);
12799
+ var gramsPortion = number().int().min(4).max(200);
12800
+ var PetFeederStatusSchema = object({
12801
+ /** Food currently in the bowl (grams). Null when the device has not
12802
+ * reported a reading yet. On dual-hopper models this is the combined
12803
+ * bowl reading; per-hopper levels live in `food1`/`food2`. */
12804
+ foodLevel: number().nullable(),
12805
+ /** Hopper-1 food level (grams) on dual-hopper feeders; null on
12806
+ * single-hopper models. */
12807
+ food1: number().nullable(),
12808
+ /** Hopper-2 food level (grams) on dual-hopper feeders; null on
12809
+ * single-hopper models. */
12810
+ food2: number().nullable(),
12811
+ /** Derived low-food flag — mirrors the HA `food_level` binary_sensor
12812
+ * (`device_class: problem`, on = low). True when the bowl is empty /
12813
+ * below the feeder's low threshold. */
12814
+ lowFood: boolean(),
12815
+ /** Battery charge 0..100 (%). Null on mains-powered models or when the
12816
+ * device has no battery reading. */
12817
+ batteryPower: number().min(0).max(100).nullable(),
12818
+ /** Days of desiccant life remaining. Null when the model has no
12819
+ * desiccant sensor. */
12820
+ desiccantLeftDays: number().nullable(),
12821
+ /** True while a feed is in progress. */
12822
+ feeding: boolean(),
12823
+ /** Decoded connectivity / power status (HA petkit device-status enum).
12824
+ * Null until the device has reported a status. */
12825
+ status: PetFeederDeviceStatusSchema.nullable(),
12826
+ /** Decoded human-readable fault message. Null (or the device's `no_error`
12827
+ * sentinel) means healthy; a non-null string is an active fault. Pairs
12828
+ * with `errorCode` for consumers that want the raw integer. */
12829
+ error: string().nullable(),
12830
+ /** Raw device error code (0 / null = no error). */
12831
+ errorCode: number().nullable(),
12832
+ /** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
12833
+ isDualHopper: boolean(),
12834
+ /** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
12835
+ childLock: boolean(),
12836
+ /** Front indicator-light setting. */
12837
+ indicatorLight: boolean(),
12838
+ /** Play a chime when dispensing. */
12839
+ feedSound: boolean(),
12840
+ /** Speaker / prompt volume level (device-scaled integer). */
12841
+ volume: number(),
12842
+ /** Ms epoch when the slice was last refreshed from the cloud. */
12843
+ lastFetchedAt: number()
12844
+ });
12845
+ var petFeederCapability = {
12846
+ name: "pet-feeder",
12847
+ scope: "device",
12848
+ deviceNative: true,
12849
+ mode: "singleton",
12850
+ deviceTypes: [DeviceType.PetFeeder],
12851
+ methods: {
12852
+ /**
12853
+ * Dispense food now. Single-hopper feeders take `grams`; dual-hopper
12854
+ * feeders (D4S/D4SH) accept `hopper1`/`hopper2` to target one or both
12855
+ * hoppers. All portions honour the 4–200 g hardware range. At least
12856
+ * one of the three must be present — the provider rejects an empty
12857
+ * request.
12858
+ */
12859
+ feed: method(object({
12860
+ deviceId: number().int().nonnegative(),
12861
+ grams: gramsPortion.optional(),
12862
+ hopper1: gramsPortion.optional(),
12863
+ hopper2: gramsPortion.optional()
12864
+ }), _void(), {
12865
+ kind: "mutation",
12866
+ auth: "admin"
12867
+ }),
12868
+ /** Cancel an in-progress manual feed. */
12869
+ cancelFeed: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12870
+ kind: "mutation",
12871
+ auth: "admin"
12872
+ }),
12873
+ /** Reset the desiccant "days remaining" counter after replacing it. */
12874
+ resetDesiccant: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12875
+ kind: "mutation",
12876
+ auth: "admin"
12877
+ }),
12878
+ /** Mark a hopper as refilled (D4H/D4S/D4SH). */
12879
+ markFoodReplenished: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12880
+ kind: "mutation",
12881
+ auth: "admin"
12882
+ }),
12883
+ /** Call the pet with the recorded prompt (D3). */
12884
+ callPet: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12885
+ kind: "mutation",
12886
+ auth: "admin"
12887
+ }),
12888
+ /** Play a stored sound by id (D3 / D4H / D4SH). */
12889
+ playSound: method(object({
12890
+ deviceId: number().int().nonnegative(),
12891
+ soundId: number().int().nonnegative()
12892
+ }), _void(), {
12893
+ kind: "mutation",
12894
+ auth: "admin"
12895
+ }),
12896
+ /** Toggle the child-lock (manual-lock) setting. */
12897
+ setChildLock: method(object({
12898
+ deviceId: number().int().nonnegative(),
12899
+ on: boolean()
12900
+ }), _void(), {
12901
+ kind: "mutation",
12902
+ auth: "admin"
12903
+ }),
12904
+ /** Toggle the front indicator light. */
12905
+ setIndicatorLight: method(object({
12906
+ deviceId: number().int().nonnegative(),
12907
+ on: boolean()
12908
+ }), _void(), {
12909
+ kind: "mutation",
12910
+ auth: "admin"
12911
+ }),
12912
+ /** Toggle the dispense chime. */
12913
+ setFeedSound: method(object({
12914
+ deviceId: number().int().nonnegative(),
12915
+ on: boolean()
12916
+ }), _void(), {
12917
+ kind: "mutation",
12918
+ auth: "admin"
12919
+ }),
12920
+ /** Set the speaker / prompt volume level. */
12921
+ setVolume: method(object({
12922
+ deviceId: number().int().nonnegative(),
12923
+ level: number().int().nonnegative()
12924
+ }), _void(), {
12925
+ kind: "mutation",
12926
+ auth: "admin"
12927
+ })
12928
+ },
12929
+ status: {
12930
+ schema: PetFeederStatusSchema,
12931
+ kind: "poll"
12932
+ },
12933
+ /**
12934
+ * Runtime-state slice — mirrored by the kernel. UI feeder cards read
12935
+ * the full slice via `device.state.petFeeder.value` and refresh on
12936
+ * every poll without re-querying the provider.
12937
+ */
12938
+ runtimeState: PetFeederStatusSchema
12939
+ };
12940
+ /**
11945
12941
  * Multi-metric electrical meter. One slice can carry any combination
11946
12942
  * of instantaneous power (W), cumulative energy (kWh), voltage (V),
11947
12943
  * and current (A) — all fields optional so a single-metric source
@@ -13244,6 +14240,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
13244
14240
  nativeObjectDetection: nativeObjectDetectionCapability,
13245
14241
  notifier: notifierCapability,
13246
14242
  numericSensor: numericSensorCapability,
14243
+ petFeeder: petFeederCapability,
13247
14244
  powerMeter: powerMeterCapability,
13248
14245
  presence: presenceCapability,
13249
14246
  pressureSensor: pressureSensorCapability,
@@ -15172,10 +16169,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
15172
16169
  url: string()
15173
16170
  }), _void()), method(object({
15174
16171
  sessionId: string(),
15175
- maxCount: number().default(1)
16172
+ maxCount: number().default(1),
16173
+ waitMs: number().optional()
15176
16174
  }), array(DecodedFrameSchema)), method(object({
15177
16175
  sessionId: string(),
15178
- maxCount: number().default(1)
16176
+ maxCount: number().default(1),
16177
+ waitMs: number().optional()
15179
16178
  }), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
15180
16179
  sessionId: string(),
15181
16180
  config: DecoderSessionConfigSchema.partial()
@@ -15462,14 +16461,63 @@ var ChildLayoutEntrySchema = object({
15462
16461
  collapsed: boolean().optional()
15463
16462
  });
15464
16463
  /** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
15465
- * `device-management.ts`. */
16464
+ * `device-management.ts`. Source is a union: a FIELD source copies a sibling
16465
+ * accessory's status field (`kind` optional/absent for wire compat); a
16466
+ * LITERAL source carries a per-device constant (no sibling is read); a
16467
+ * GLOBAL source (P2e) copies ANY device's status field, addressed by the
16468
+ * source device's full re-sync-stable `stableId`. */
16469
+ var DeviceLinkFieldSourceSchema = object({
16470
+ kind: literal("field").optional(),
16471
+ sourceKey: string(),
16472
+ cap: string(),
16473
+ fieldPath: string()
16474
+ });
16475
+ var DeviceLinkLiteralSourceSchema = object({
16476
+ kind: literal("literal"),
16477
+ value: union([
16478
+ string(),
16479
+ number(),
16480
+ boolean(),
16481
+ _null()
16482
+ ])
16483
+ });
16484
+ var DeviceLinkGlobalSourceSchema = object({
16485
+ kind: literal("global"),
16486
+ sourceStableId: string(),
16487
+ cap: string(),
16488
+ fieldPath: string()
16489
+ });
16490
+ /** Expression source (Stage X): compute the target field from N named bindings
16491
+ * via the safe expression engine. Bindings are field | literal | global — never
16492
+ * another expression (no nesting). The `superRefine` runs the SAME author-time
16493
+ * validation as `validateExpressionSource` (compiles the expr, checks binding
16494
+ * names + identifier coverage) so every wire boundary that parses a DeviceLink
16495
+ * (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
16496
+ * Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
16497
+ var DeviceLinkExpressionSourceSchema = object({
16498
+ kind: literal("expression"),
16499
+ expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
16500
+ bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
16501
+ DeviceLinkFieldSourceSchema,
16502
+ DeviceLinkLiteralSourceSchema,
16503
+ DeviceLinkGlobalSourceSchema
16504
+ ]))
16505
+ }).superRefine((src, ctx) => {
16506
+ const err = validateExpressionSource(src);
16507
+ if (err !== null) ctx.addIssue({
16508
+ code: "custom",
16509
+ message: err,
16510
+ path: ["expr"]
16511
+ });
16512
+ });
15466
16513
  var DeviceLinkSchema = object({
15467
16514
  id: string(),
15468
- source: object({
15469
- sourceKey: string(),
15470
- cap: string(),
15471
- fieldPath: string()
15472
- }),
16515
+ source: union([
16516
+ DeviceLinkFieldSourceSchema,
16517
+ DeviceLinkLiteralSourceSchema,
16518
+ DeviceLinkGlobalSourceSchema,
16519
+ DeviceLinkExpressionSourceSchema
16520
+ ]),
15473
16521
  target: object({
15474
16522
  cap: string(),
15475
16523
  fieldPath: string(),
@@ -15498,6 +16546,31 @@ var DeviceLinkSchema = object({
15498
16546
  })
15499
16547
  ]).optional()
15500
16548
  });
16549
+ /** Cap-wire shape of a per-cap display refinement — mirrors
16550
+ * `DeviceCapDisplayOverride` in `device-management.ts`. */
16551
+ var DeviceCapDisplayOverrideSchema = object({
16552
+ unit: string().min(1).optional(),
16553
+ precision: number().int().min(0).max(10).optional()
16554
+ });
16555
+ /** Cap-wire shape of an operator-authored per-device display override —
16556
+ * mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
16557
+ * bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
16558
+ var DeviceDisplayOverrideSchema = object({
16559
+ icon: string().min(1).optional(),
16560
+ label: string().min(1).optional(),
16561
+ unit: string().min(1).optional(),
16562
+ precision: number().int().min(0).max(10).optional(),
16563
+ hidden: boolean().optional(),
16564
+ perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
16565
+ });
16566
+ /** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
16567
+ * in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
16568
+ * the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
16569
+ var RoleDisplayDefaultSchema = object({
16570
+ unit: string().min(1).optional(),
16571
+ precision: number().int().min(0).max(10).optional(),
16572
+ icon: string().min(1).optional()
16573
+ });
15501
16574
  /**
15502
16575
  * Serializable projection of a live IDevice.
15503
16576
  * Returned by listAll, getDevice, getChildren.
@@ -15553,7 +16626,9 @@ var DeviceInfoSchema = object({
15553
16626
  * `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
15554
16627
  childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
15555
16628
  /** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
15556
- deviceLinks: array(DeviceLinkSchema).readonly().optional()
16629
+ deviceLinks: array(DeviceLinkSchema).readonly().optional(),
16630
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
16631
+ display: DeviceDisplayOverrideSchema.optional()
15557
16632
  });
15558
16633
  var ConfigEntrySchema = object({
15559
16634
  key: string(),
@@ -15618,7 +16693,9 @@ var DeviceMetaSchema = object({
15618
16693
  deviceLinks: array(DeviceLinkSchema).readonly().optional(),
15619
16694
  /** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
15620
16695
  * Optional: only present for accessory children that carry a known role. */
15621
- role: string().nullable().optional()
16696
+ role: string().nullable().optional(),
16697
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
16698
+ display: DeviceDisplayOverrideSchema.optional()
15622
16699
  });
15623
16700
  /** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
15624
16701
  var ConfigUISchemaOutput = unknown().nullable();
@@ -15712,7 +16789,19 @@ method(object({
15712
16789
  }), _void(), {
15713
16790
  kind: "mutation",
15714
16791
  auth: "admin"
15715
- }), method(object({ deviceId: number() }), object({ caps: array(object({
16792
+ }), method(object({
16793
+ deviceId: number(),
16794
+ display: DeviceDisplayOverrideSchema.nullable()
16795
+ }), _void(), {
16796
+ kind: "mutation",
16797
+ auth: "admin"
16798
+ }), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
16799
+ kind: "mutation",
16800
+ auth: "admin"
16801
+ }), method(object({
16802
+ deviceId: number(),
16803
+ includeSynthesizable: boolean().optional()
16804
+ }), object({ caps: array(object({
15716
16805
  cap: string(),
15717
16806
  fields: array(object({
15718
16807
  path: string(),
@@ -15722,8 +16811,13 @@ method(object({
15722
16811
  "boolean",
15723
16812
  "enum"
15724
16813
  ]),
15725
- enumValues: array(string()).optional()
15726
- })).readonly()
16814
+ enumValues: array(string()).optional(),
16815
+ item: boolean().optional()
16816
+ })).readonly(),
16817
+ itemArray: object({
16818
+ path: string(),
16819
+ keyField: string()
16820
+ }).optional()
15727
16821
  })).readonly() }), { kind: "query" }), method(object({
15728
16822
  deviceId: number(),
15729
16823
  role: string().nullable()
@@ -15793,7 +16887,11 @@ method(object({
15793
16887
  deviceId: number(),
15794
16888
  entries: array(object({
15795
16889
  capName: string(),
15796
- kind: _enum(["native", "wrapped"]),
16890
+ kind: _enum([
16891
+ "native",
16892
+ "wrapped",
16893
+ "linked"
16894
+ ]),
15797
16895
  providerAddonId: string(),
15798
16896
  providerNodeId: string(),
15799
16897
  nativeAddonId: string()
@@ -15802,7 +16900,11 @@ method(object({
15802
16900
  deviceId: number(),
15803
16901
  entries: array(object({
15804
16902
  capName: string(),
15805
- kind: _enum(["native", "wrapped"]),
16903
+ kind: _enum([
16904
+ "native",
16905
+ "wrapped",
16906
+ "linked"
16907
+ ]),
15806
16908
  providerAddonId: string(),
15807
16909
  providerNodeId: string(),
15808
16910
  nativeAddonId: string()
@@ -19656,7 +20758,10 @@ var HwAccelBackendInputSchema = _enum([
19656
20758
  "webgpu",
19657
20759
  "none"
19658
20760
  ]).nullable().optional();
19659
- var HwAccelResolutionSchema = object({ preferred: array(string()).readonly() });
20761
+ var HwAccelResolutionSchema = object({
20762
+ preferred: array(string()).readonly(),
20763
+ rationale: string()
20764
+ });
19660
20765
  var HardwareEncoderIdSchema = _enum([
19661
20766
  "h264_videotoolbox",
19662
20767
  "hevc_videotoolbox",
@@ -19761,10 +20866,7 @@ var ResolvedInferenceConfigSchema = object({
19761
20866
  format: ModelFormatSchema,
19762
20867
  reason: string()
19763
20868
  });
19764
- method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
19765
- prefer: HwAccelBackendInputSchema,
19766
- nodeId: string().optional()
19767
- }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
20869
+ method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
19768
20870
  kind: "mutation",
19769
20871
  auth: "admin"
19770
20872
  }), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
@@ -19890,6 +20992,16 @@ var rebootCapability = {
19890
20992
  auth: "admin"
19891
20993
  }) }
19892
20994
  };
20995
+ /**
20996
+ * `recording` cap — footage availability + HLS playback manifests + per-device
20997
+ * recording config. NOTE on events (source of truth, R5/C3): this cap carries
20998
+ * NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
20999
+ * events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
21000
+ * rows); the recorder's internal EventMap markers are ephemeral in-RAM
21001
+ * annotations that are not exposed here and must not be treated as an event
21002
+ * feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
21003
+ * (`interfaces/recording-config.ts`).
21004
+ */
19893
21005
  var RecordingStatusSchema = object({
19894
21006
  deviceId: number(),
19895
21007
  enabled: boolean(),
@@ -21737,6 +22849,12 @@ Object.freeze({
21737
22849
  addonId: null,
21738
22850
  access: "view"
21739
22851
  },
22852
+ "deviceManager.getRoleDisplayDefaults": {
22853
+ capName: "device-manager",
22854
+ capScope: "system",
22855
+ addonId: null,
22856
+ access: "view"
22857
+ },
21740
22858
  "deviceManager.getSettingsSchema": {
21741
22859
  capName: "device-manager",
21742
22860
  capScope: "system",
@@ -21887,6 +23005,12 @@ Object.freeze({
21887
23005
  addonId: null,
21888
23006
  access: "create"
21889
23007
  },
23008
+ "deviceManager.setDisplay": {
23009
+ capName: "device-manager",
23010
+ capScope: "system",
23011
+ addonId: null,
23012
+ access: "create"
23013
+ },
21890
23014
  "deviceManager.setIntegrationId": {
21891
23015
  capName: "device-manager",
21892
23016
  capScope: "system",
@@ -21929,6 +23053,12 @@ Object.freeze({
21929
23053
  addonId: null,
21930
23054
  access: "create"
21931
23055
  },
23056
+ "deviceManager.setRoleDisplayDefaults": {
23057
+ capName: "device-manager",
23058
+ capScope: "system",
23059
+ addonId: null,
23060
+ access: "create"
23061
+ },
21932
23062
  "deviceManager.setStreamProfileMap": {
21933
23063
  capName: "device-manager",
21934
23064
  capScope: "system",
@@ -22979,6 +24109,66 @@ Object.freeze({
22979
24109
  addonId: null,
22980
24110
  access: "create"
22981
24111
  },
24112
+ "petFeeder.callPet": {
24113
+ capName: "pet-feeder",
24114
+ capScope: "device",
24115
+ addonId: null,
24116
+ access: "create"
24117
+ },
24118
+ "petFeeder.cancelFeed": {
24119
+ capName: "pet-feeder",
24120
+ capScope: "device",
24121
+ addonId: null,
24122
+ access: "create"
24123
+ },
24124
+ "petFeeder.feed": {
24125
+ capName: "pet-feeder",
24126
+ capScope: "device",
24127
+ addonId: null,
24128
+ access: "create"
24129
+ },
24130
+ "petFeeder.markFoodReplenished": {
24131
+ capName: "pet-feeder",
24132
+ capScope: "device",
24133
+ addonId: null,
24134
+ access: "create"
24135
+ },
24136
+ "petFeeder.playSound": {
24137
+ capName: "pet-feeder",
24138
+ capScope: "device",
24139
+ addonId: null,
24140
+ access: "create"
24141
+ },
24142
+ "petFeeder.resetDesiccant": {
24143
+ capName: "pet-feeder",
24144
+ capScope: "device",
24145
+ addonId: null,
24146
+ access: "delete"
24147
+ },
24148
+ "petFeeder.setChildLock": {
24149
+ capName: "pet-feeder",
24150
+ capScope: "device",
24151
+ addonId: null,
24152
+ access: "create"
24153
+ },
24154
+ "petFeeder.setFeedSound": {
24155
+ capName: "pet-feeder",
24156
+ capScope: "device",
24157
+ addonId: null,
24158
+ access: "create"
24159
+ },
24160
+ "petFeeder.setIndicatorLight": {
24161
+ capName: "pet-feeder",
24162
+ capScope: "device",
24163
+ addonId: null,
24164
+ access: "create"
24165
+ },
24166
+ "petFeeder.setVolume": {
24167
+ capName: "pet-feeder",
24168
+ capScope: "device",
24169
+ addonId: null,
24170
+ access: "create"
24171
+ },
22982
24172
  "pipelineAnalytics.clearTracks": {
22983
24173
  capName: "pipeline-analytics",
22984
24174
  capScope: "device",
@@ -223887,14 +225077,32 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
223887
225077
  }
223888
225078
  return cameras;
223889
225079
  }
225080
+ /**
225081
+ * Bootstrapped SMTP AUTH credentials — Zod-validated durable handles
225082
+ * over the SAME two store keys the raw writer used. Built lazily
225083
+ * (needs `this.ctx`) and memoised.
225084
+ */
225085
+ _emailPushAuthUsernameState = null;
225086
+ _emailPushAuthPasswordState = null;
225087
+ get emailPushAuthUsernameState() {
225088
+ if (!this._emailPushAuthUsernameState) this._emailPushAuthUsernameState = this.state("emailPushAuthUsername", string(), "");
225089
+ return this._emailPushAuthUsernameState;
225090
+ }
225091
+ get emailPushAuthPasswordState() {
225092
+ if (!this._emailPushAuthPasswordState) this._emailPushAuthPasswordState = this.state("emailPushAuthPassword", string(), "");
225093
+ return this._emailPushAuthPasswordState;
225094
+ }
223890
225095
  /** Lazily build the email-push server, wiring its provider deps. */
223891
225096
  ensureEmailPushServer() {
223892
225097
  if (!this.emailPushServer) this.emailPushServer = new ReolinkEmailPushServer({
223893
225098
  logger: this.ctx.logger.child("email-push"),
223894
225099
  listCameras: () => this.listReolinkCameras(),
223895
- readStore: async () => await this.ctx.settings?.readAddonStore() ?? {},
225100
+ readStore: async () => await this.resolveGlobalStore(),
223896
225101
  writeStore: async (patch) => {
223897
- await this.ctx.settings?.writeAddonStore(patch);
225102
+ const username = patch["emailPushAuthUsername"];
225103
+ if (typeof username === "string") await this.emailPushAuthUsernameState.set(username);
225104
+ const password = patch["emailPushAuthPassword"];
225105
+ if (typeof password === "string") await this.emailPushAuthPasswordState.set(password);
223898
225106
  }
223899
225107
  });
223900
225108
  return this.emailPushServer;
@@ -223973,13 +225181,9 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
223973
225181
  });
223974
225182
  }
223975
225183
  async getGlobalSettings() {
223976
- const raw = await this.ctx.settings?.readAddonStore() ?? {};
225184
+ const raw = await this.resolveGlobalStore();
223977
225185
  return hydrateSchema(buildEmailPushSettingsSchema(listLanHosts()[0] ?? "127.0.0.1"), raw);
223978
225186
  }
223979
- async updateGlobalSettings(patch) {
223980
- await this.ctx.settings?.writeAddonStore(patch);
223981
- await this.onConfigChanged();
223982
- }
223983
225187
  async onInitialize() {
223984
225188
  const regs = await super.onInitialize();
223985
225189
  this.subscribe({ category: EventCategory.StreamBrokerOnRequestStreamSourceRefresh }, (event) => {