@camstack/addon-provider-onvif 1.1.12 → 1.1.14

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 +1382 -55
  2. package/dist/addon.mjs +1382 -55
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -4631,7 +4631,7 @@ function _instanceof(cls, params = {}) {
4631
4631
  return inst;
4632
4632
  }
4633
4633
  //#endregion
4634
- //#region ../types/dist/sleep-C2M2zF7x.mjs
4634
+ //#region ../types/dist/sleep-BiDFW0E7.mjs
4635
4635
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4636
4636
  EventCategory["SystemBoot"] = "system.boot";
4637
4637
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5444,6 +5444,100 @@ function createDurableState(deps) {
5444
5444
  };
5445
5445
  }
5446
5446
  /**
5447
+ * Per-node scoping for the shared addon-settings blob.
5448
+ *
5449
+ * An addon's settings store is hub-central (the `addon-settings` cap is
5450
+ * hub-routed — the hub instance answers for every node), so fields whose
5451
+ * value is a NODE fact (decoder backend, engine pick, probed hardware
5452
+ * capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
5453
+ * the single shared blob. The SCHEMA field key stays bare: the write path
5454
+ * ({@link scopePatch}) maps the bare field onto the target node's scoped
5455
+ * key; the read/hydrate path ({@link projectStore}) maps THIS node's value
5456
+ * back, so UI forms and `resolveConfig` only ever see the bare key.
5457
+ *
5458
+ * Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
5459
+ * (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
5460
+ * schema and routes reads/writes through these helpers.
5461
+ *
5462
+ * ## No bare-key fallback — deliberate
5463
+ *
5464
+ * {@link readNodeValue} reads the node-scoped key ONLY. A node with no
5465
+ * scoped key resolves to `undefined` so the field's schema `default` wins —
5466
+ * NEVER `store[base]` and never another node's value. A bare legacy key in
5467
+ * the store is invisible to every node, hub included, so one node's
5468
+ * selection can never leak onto another. (This generalizes the
5469
+ * `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
5470
+ * arbitrary set of per-node field keys.)
5471
+ *
5472
+ * Pure functions only — no I/O, no imports beyond the language. This is a
5473
+ * LEAF module: import it via its deep path, never from the root barrel.
5474
+ */
5475
+ /**
5476
+ * Normalize a raw kernel node id to the bare node id used for scoping.
5477
+ * `localNodeId` can carry a `<node>/<addon>` suffix on forked child
5478
+ * processes; per-node settings are per-NODE, so strip the addon segment.
5479
+ * `undefined` / `null` / empty falls back to `'hub'`.
5480
+ */
5481
+ function normalizeNodeId(raw) {
5482
+ if (raw === void 0 || raw === null || raw === "") return "hub";
5483
+ const slashIdx = raw.indexOf("/");
5484
+ if (slashIdx < 0) return raw;
5485
+ const bare = raw.slice(0, slashIdx);
5486
+ return bare === "" ? "hub" : bare;
5487
+ }
5488
+ /** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
5489
+ function nodeScopedKey(base, nodeId) {
5490
+ return `${base}@${normalizeNodeId(nodeId)}`;
5491
+ }
5492
+ /**
5493
+ * Read a node's value for a per-node field from the raw shared store:
5494
+ * the node-scoped key when present, otherwise `undefined`.
5495
+ * Deliberately NO bare-key fallback (see module doc) — the caller lets the
5496
+ * schema `default` win on `undefined`.
5497
+ */
5498
+ function readNodeValue(store, base, nodeId) {
5499
+ return store[nodeScopedKey(base, nodeId)];
5500
+ }
5501
+ /**
5502
+ * Re-map a UI/settings patch so every bare perNode field persists under the
5503
+ * TARGET node's scoped key; all other keys pass through unchanged. Used on
5504
+ * the write path so a save for one node never clobbers another node's value
5505
+ * (and the bare key is never written). Returns a new object — the input
5506
+ * patch is not mutated.
5507
+ */
5508
+ function scopePatch(patch, perNodeKeys, nodeId) {
5509
+ const out = {};
5510
+ for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
5511
+ return out;
5512
+ }
5513
+ /**
5514
+ * Project the raw shared store onto the bare schema keys for ONE node so a
5515
+ * UI schema (whose field keys are bare) hydrates from that node's own
5516
+ * values:
5517
+ *
5518
+ * - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
5519
+ * - Every bare perNode key is dropped from the pass-through (a stray bare
5520
+ * legacy key must never hydrate any node — no bare fallback).
5521
+ * - THIS node's effective value ({@link readNodeValue}) is then laid onto
5522
+ * each bare perNode key; when the node has no scoped key the bare key is
5523
+ * left ABSENT so the field's schema `default` wins.
5524
+ *
5525
+ * Returns a new object — the input store is not mutated.
5526
+ */
5527
+ function projectStore(store, perNodeKeys, nodeId) {
5528
+ const out = {};
5529
+ for (const [key, value] of Object.entries(store)) {
5530
+ if (key.includes("@")) continue;
5531
+ if (perNodeKeys.has(key)) continue;
5532
+ out[key] = value;
5533
+ }
5534
+ for (const base of perNodeKeys) {
5535
+ const value = readNodeValue(store, base, nodeId);
5536
+ if (value !== void 0) out[base] = value;
5537
+ }
5538
+ return out;
5539
+ }
5540
+ /**
5447
5541
  * Base class for CamStack addons. Eliminates settings boilerplate:
5448
5542
  *
5449
5543
  * - Typed `config` property with automatic resolution from store + defaults
@@ -5611,23 +5705,63 @@ var BaseAddon = class {
5611
5705
  deviceSettingsSchema() {
5612
5706
  return null;
5613
5707
  }
5614
- async getGlobalSettings(overlay, cap, _nodeId) {
5708
+ async getGlobalSettings(overlay, cap, nodeId) {
5615
5709
  const schema = this.globalSettingsSchema(cap);
5616
5710
  if (!schema) return { sections: [] };
5617
- const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5711
+ const projected = await this.resolveGlobalStore(nodeId, cap);
5618
5712
  return hydrateSchema(schema, overlay ? {
5619
- ...raw,
5713
+ ...projected,
5620
5714
  ...overlay
5621
- } : raw);
5715
+ } : projected);
5622
5716
  }
5623
- async updateGlobalSettings(patch, _nodeId) {
5624
- await this._ctx?.settings?.writeAddonStore(patch);
5717
+ /**
5718
+ * The raw addon store PROJECTED onto the target node's bare per-node keys:
5719
+ * every `perNode: true` field carries THAT node's scoped value on its bare
5720
+ * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
5721
+ * bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
5722
+ * A no-op passthrough when the schema declares no `perNode` field.
5723
+ *
5724
+ * This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
5725
+ * the store for custom option logic (option narrowing, value snapping) to
5726
+ * read it per-node — never `ctx.settings.readAddonStore()` directly.
5727
+ * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
5728
+ */
5729
+ async resolveGlobalStore(nodeId, cap) {
5730
+ const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5731
+ const keys = this.perNodeKeys(cap);
5732
+ const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5733
+ return keys.size > 0 ? projectStore(raw, keys, node) : raw;
5734
+ }
5735
+ async updateGlobalSettings(patch, nodeId) {
5736
+ const keys = this.perNodeKeys();
5737
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5738
+ const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5739
+ const barePatch = patch;
5740
+ const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
5741
+ await this._ctx?.settings?.writeAddonStore(scoped);
5742
+ if (target !== localNode) return;
5625
5743
  await this.resolveConfig();
5626
5744
  await this.onConfigChanged();
5627
5745
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
5628
5746
  this.maybeAutoRestart(patch, this.globalSettingsSchema());
5629
5747
  }
5630
5748
  /**
5749
+ * The set of field keys the global settings schema declares `perNode: true`
5750
+ * — derived once per `cap` argument and memoized (schemas are static
5751
+ * declarations). Empty set ⇒ every per-node code path is bypassed and the
5752
+ * settings API behaves exactly like the legacy node-agnostic one.
5753
+ */
5754
+ _perNodeKeysCache = /* @__PURE__ */ new Map();
5755
+ perNodeKeys(cap) {
5756
+ const cacheKey = cap ?? "";
5757
+ const cached = this._perNodeKeysCache.get(cacheKey);
5758
+ if (cached) return cached;
5759
+ const schema = this.globalSettingsSchema(cap);
5760
+ const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
5761
+ this._perNodeKeysCache.set(cacheKey, keys);
5762
+ return keys;
5763
+ }
5764
+ /**
5631
5765
  * If any field in `patch` is marked `requiresRestart` in `schema`,
5632
5766
  * schedule an addon restart for the next tick. Deferred via
5633
5767
  * `setImmediate` so the tRPC mutation that triggered the write has
@@ -5780,12 +5914,19 @@ var BaseAddon = class {
5780
5914
  * The merge is shallow: each key in `defaults` is checked against the store.
5781
5915
  * Only keys present in defaults are read — the store can contain extra keys
5782
5916
  * (e.g. from older versions) without polluting the typed config.
5917
+ *
5918
+ * Keys the global settings schema declares `perNode: true` resolve from
5919
+ * THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
5920
+ * from the bare key — so a per-node field resolves to this node's own
5921
+ * selection at boot (absent scoped key ⇒ the constructor default wins).
5783
5922
  */
5784
5923
  async resolveConfig() {
5785
5924
  const stored = await this.readAddonStoreWithRetry();
5925
+ const perNode = this.perNodeKeys();
5926
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5786
5927
  const resolved = { ...this.defaults };
5787
5928
  for (const key of Object.keys(this.defaults)) {
5788
- const storedValue = stored[key];
5929
+ const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
5789
5930
  if (storedValue !== void 0 && storedValue !== null) {
5790
5931
  const defaultType = typeof this.defaults[key];
5791
5932
  if (typeof storedValue === defaultType) resolved[key] = storedValue;
@@ -5869,6 +6010,27 @@ var BaseAddon = class {
5869
6010
  }
5870
6011
  };
5871
6012
  /**
6013
+ * Collect the keys of every field marked `perNode: true`, recursing into
6014
+ * layout containers (`group` fields and `sub-tabs` tabs) the same way
6015
+ * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6016
+ * don't declare `perNode` and are excluded by the `in` narrowing.
6017
+ */
6018
+ function collectPerNodeFieldKeys(fields) {
6019
+ const collected = [];
6020
+ for (const field of fields) {
6021
+ if (field.type === "group") {
6022
+ collected.push(...collectPerNodeFieldKeys(field.fields));
6023
+ continue;
6024
+ }
6025
+ if (field.type === "sub-tabs") {
6026
+ for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
6027
+ continue;
6028
+ }
6029
+ if ("perNode" in field && field.perNode === true) collected.push(field.key);
6030
+ }
6031
+ return collected;
6032
+ }
6033
+ /**
5872
6034
  * Normalize an `ICamstackAddon.initialize()` return value into the
5873
6035
  * `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
5874
6036
  * envelopes pass through; void stays void.
@@ -5893,6 +6055,7 @@ var CamStreamKindSchema = _enum([
5893
6055
  "pull-rtsp",
5894
6056
  "pull-rtmp",
5895
6057
  "pull-http",
6058
+ "pull-flv",
5896
6059
  "pull-rfc4571",
5897
6060
  "push-annexb",
5898
6061
  "derived"
@@ -6275,6 +6438,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
6275
6438
  /** Single still-image entity (HA `image.*`). Read-only display of an
6276
6439
  * `entity_picture` signed URL the browser loads directly. `image` cap. */
6277
6440
  DeviceType["Image"] = "image";
6441
+ /** Smart pet feeder — cloud-connected food dispenser with a bowl food
6442
+ * level, battery, desiccant life, feeding state and manual-feed /
6443
+ * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
6444
+ * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
6445
+ * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
6446
+ * integrations sharing the same food/desiccant/hopper surface. */
6447
+ DeviceType["PetFeeder"] = "pet-feeder";
6278
6448
  return DeviceType;
6279
6449
  }({});
6280
6450
  var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
@@ -7048,7 +7218,21 @@ var StorageLocationDeclarationSchema = object({
7048
7218
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
7049
7219
  * configure the primary location.
7050
7220
  */
7051
- defaultsTo: string().optional()
7221
+ defaultsTo: string().optional(),
7222
+ /**
7223
+ * Which node root the seeded `<id>:default` instance is placed under on a
7224
+ * FRESH install:
7225
+ * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7226
+ * the appData volume. Right for small/durable data (backups, logs, models).
7227
+ * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7228
+ * env is set, else falls back to the data root. Right for bulky, hot media
7229
+ * (recordings, event media) that should stay off the appData disk.
7230
+ *
7231
+ * Only affects the seeded default's `basePath`; operators can repoint any
7232
+ * location afterwards, and a `defaultsTo` slot inherits its parent's root
7233
+ * regardless of this field. Absent (the common case) is treated as `'data'`.
7234
+ */
7235
+ defaultRoot: _enum(["data", "media"]).optional()
7052
7236
  });
7053
7237
  var DecoderStatsSchema = object({
7054
7238
  inputFps: number(),
@@ -7421,6 +7605,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
7421
7605
  for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7422
7606
  for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7423
7607
  /**
7608
+ * Error types for the safe expression engine. Two distinct classes so callers
7609
+ * can tell a compile-time (grammar) failure from a runtime (evaluation)
7610
+ * failure — both are non-fatal to the host: read paths degrade to "skip link".
7611
+ */
7612
+ /** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
7613
+ * the failure is anchored to a character (author-facing inline feedback). */
7614
+ var ExpressionParseError = class extends Error {
7615
+ position;
7616
+ constructor(message, position) {
7617
+ super(message);
7618
+ this.name = "ExpressionParseError";
7619
+ this.position = position;
7620
+ }
7621
+ };
7622
+ /** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
7623
+ * result, unknown builtin, step-budget exceeded). */
7624
+ var ExpressionEvalError = class extends Error {
7625
+ constructor(message) {
7626
+ super(message);
7627
+ this.name = "ExpressionEvalError";
7628
+ }
7629
+ };
7630
+ /**
7631
+ * Resource-bound constants for the safe expression engine.
7632
+ *
7633
+ * Every bound is defense-in-depth: the grammar is non-Turing-complete (no
7634
+ * loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
7635
+ * O(nodeCount) by construction. These caps merely put a hard ceiling on the
7636
+ * work a single author-supplied expression can request, so a hostile or
7637
+ * accidental pathological string can never spend unbounded CPU/memory.
7638
+ */
7639
+ /** Max source length (chars) — checked BEFORE tokenizing so a huge string is
7640
+ * rejected without allocation. */
7641
+ var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
7642
+ /** A legal binding / identifier name. */
7643
+ var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
7644
+ /** Binding names an author may NOT use: `now` is auto-injected; the literal
7645
+ * keywords lex as values, not identifiers, so binding to them is meaningless. */
7646
+ var RESERVED_BINDING_NAMES = new Set([
7647
+ "now",
7648
+ "true",
7649
+ "false",
7650
+ "null"
7651
+ ]);
7652
+ /**
7653
+ * Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
7654
+ * zero-dependency. The grammar is deliberately boring: decimal numbers,
7655
+ * single/double-quoted strings with a tiny escape set, identifiers, the three
7656
+ * value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
7657
+ * outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
7658
+ * is a parse error with a source position, so member access / assignment /
7659
+ * template literals are lexically impossible.
7660
+ */
7661
+ var KEYWORDS = new Set([
7662
+ "true",
7663
+ "false",
7664
+ "null"
7665
+ ]);
7666
+ function isDigit(ch) {
7667
+ return ch >= "0" && ch <= "9";
7668
+ }
7669
+ function isIdentStart(ch) {
7670
+ return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
7671
+ }
7672
+ function isIdentPart(ch) {
7673
+ return isIdentStart(ch) || isDigit(ch);
7674
+ }
7675
+ function isWhitespace(ch) {
7676
+ return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
7677
+ }
7678
+ /** Tokenize `source` into a flat token list ending with a single `eof` token.
7679
+ * Throws `ExpressionParseError` on any illegal character or unterminated
7680
+ * string. */
7681
+ function tokenize(source) {
7682
+ if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
7683
+ const tokens = [];
7684
+ let i = 0;
7685
+ const n = source.length;
7686
+ while (i < n) {
7687
+ const ch = source[i];
7688
+ if (isWhitespace(ch)) {
7689
+ i += 1;
7690
+ continue;
7691
+ }
7692
+ if (isDigit(ch)) {
7693
+ const start = i;
7694
+ while (i < n && isDigit(source[i])) i += 1;
7695
+ if (i < n && source[i] === ".") {
7696
+ if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
7697
+ i += 1;
7698
+ while (i < n && isDigit(source[i])) i += 1;
7699
+ }
7700
+ const text = source.slice(start, i);
7701
+ const value = Number(text);
7702
+ if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
7703
+ tokens.push({
7704
+ type: "number",
7705
+ value,
7706
+ pos: start
7707
+ });
7708
+ continue;
7709
+ }
7710
+ if (ch === "'" || ch === "\"") {
7711
+ const quote = ch;
7712
+ const start = i;
7713
+ i += 1;
7714
+ let out = "";
7715
+ let closed = false;
7716
+ while (i < n) {
7717
+ const c = source[i];
7718
+ if (c === "\\") {
7719
+ const next = i + 1 < n ? source[i + 1] : "";
7720
+ if (next === "\\" || next === "'" || next === "\"") {
7721
+ out += next;
7722
+ i += 2;
7723
+ continue;
7724
+ }
7725
+ throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
7726
+ }
7727
+ if (c === quote) {
7728
+ closed = true;
7729
+ i += 1;
7730
+ break;
7731
+ }
7732
+ out += c;
7733
+ i += 1;
7734
+ }
7735
+ if (!closed) throw new ExpressionParseError("unterminated string literal", start);
7736
+ tokens.push({
7737
+ type: "string",
7738
+ value: out,
7739
+ pos: start
7740
+ });
7741
+ continue;
7742
+ }
7743
+ if (isIdentStart(ch)) {
7744
+ const start = i;
7745
+ while (i < n && isIdentPart(source[i])) i += 1;
7746
+ const text = source.slice(start, i);
7747
+ if (KEYWORDS.has(text)) tokens.push({
7748
+ type: "keyword",
7749
+ keyword: keywordOf(text),
7750
+ pos: start
7751
+ });
7752
+ else tokens.push({
7753
+ type: "identifier",
7754
+ name: text,
7755
+ pos: start
7756
+ });
7757
+ continue;
7758
+ }
7759
+ const two = i + 1 < n ? source.slice(i, i + 2) : "";
7760
+ if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
7761
+ tokens.push({
7762
+ type: "punct",
7763
+ punct: two,
7764
+ pos: i
7765
+ });
7766
+ i += 2;
7767
+ continue;
7768
+ }
7769
+ if (isSinglePunct(ch)) {
7770
+ tokens.push({
7771
+ type: "punct",
7772
+ punct: ch,
7773
+ pos: i
7774
+ });
7775
+ i += 1;
7776
+ continue;
7777
+ }
7778
+ throw new ExpressionParseError(`unexpected character '${ch}'`, i);
7779
+ }
7780
+ tokens.push({
7781
+ type: "eof",
7782
+ pos: n
7783
+ });
7784
+ return tokens;
7785
+ }
7786
+ function keywordOf(text) {
7787
+ if (text === "true") return "true";
7788
+ if (text === "false") return "false";
7789
+ return "null";
7790
+ }
7791
+ function isSinglePunct(ch) {
7792
+ return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
7793
+ }
7794
+ /**
7795
+ * Frozen, null-prototype builtin function table for the expression engine
7796
+ * (spec §4 rule 4). The table is the SOLE surface of callable functions: the
7797
+ * parser rejects any callee not in it, and the evaluator gates each call on an
7798
+ * own-property check against it.
7799
+ *
7800
+ * Because the object has a NULL prototype AND is `Object.freeze`d:
7801
+ * - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
7802
+ * - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
7803
+ * (there is no `Object.prototype` in the chain), so those names are not
7804
+ * callable — they are simply "unknown function" at parse time.
7805
+ *
7806
+ * Every numeric argument is validated as a finite number and every numeric
7807
+ * RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
7808
+ * (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
7809
+ * closed rather than emitting a garbage value.
7810
+ */
7811
+ function asFiniteNumber(value, name, index) {
7812
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
7813
+ return value;
7814
+ }
7815
+ function asString$1(value, name, index) {
7816
+ if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
7817
+ return value;
7818
+ }
7819
+ function finiteResult(value, name) {
7820
+ if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
7821
+ return value;
7822
+ }
7823
+ function allFiniteNumbers(args, name) {
7824
+ return args.map((a, idx) => asFiniteNumber(a, name, idx));
7825
+ }
7826
+ var INF = Number.POSITIVE_INFINITY;
7827
+ var table = {
7828
+ min: {
7829
+ minArgs: 1,
7830
+ maxArgs: INF,
7831
+ apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
7832
+ },
7833
+ max: {
7834
+ minArgs: 1,
7835
+ maxArgs: INF,
7836
+ apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
7837
+ },
7838
+ abs: {
7839
+ minArgs: 1,
7840
+ maxArgs: 1,
7841
+ apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
7842
+ },
7843
+ floor: {
7844
+ minArgs: 1,
7845
+ maxArgs: 1,
7846
+ apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
7847
+ },
7848
+ ceil: {
7849
+ minArgs: 1,
7850
+ maxArgs: 1,
7851
+ apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
7852
+ },
7853
+ sqrt: {
7854
+ minArgs: 1,
7855
+ maxArgs: 1,
7856
+ apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
7857
+ },
7858
+ round: {
7859
+ minArgs: 1,
7860
+ maxArgs: 2,
7861
+ apply: (args) => {
7862
+ const x = asFiniteNumber(args[0], "round", 0);
7863
+ const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
7864
+ if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
7865
+ const factor = 10 ** digits;
7866
+ return finiteResult(Math.round(x * factor) / factor, "round");
7867
+ }
7868
+ },
7869
+ pow: {
7870
+ minArgs: 2,
7871
+ maxArgs: 2,
7872
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
7873
+ },
7874
+ clamp: {
7875
+ minArgs: 3,
7876
+ maxArgs: 3,
7877
+ apply: (args) => {
7878
+ const x = asFiniteNumber(args[0], "clamp", 0);
7879
+ const lo = asFiniteNumber(args[1], "clamp", 1);
7880
+ const hi = asFiniteNumber(args[2], "clamp", 2);
7881
+ if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
7882
+ return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
7883
+ }
7884
+ },
7885
+ avg: {
7886
+ minArgs: 1,
7887
+ maxArgs: INF,
7888
+ apply: (args) => {
7889
+ const nums = allFiniteNumbers(args, "avg");
7890
+ return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
7891
+ }
7892
+ },
7893
+ sum: {
7894
+ minArgs: 1,
7895
+ maxArgs: INF,
7896
+ apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
7897
+ },
7898
+ coalesce: {
7899
+ minArgs: 1,
7900
+ maxArgs: INF,
7901
+ apply: (args) => {
7902
+ for (const a of args) if (a !== null) return a;
7903
+ return null;
7904
+ }
7905
+ },
7906
+ age: {
7907
+ minArgs: 2,
7908
+ maxArgs: 2,
7909
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
7910
+ },
7911
+ convert: {
7912
+ minArgs: 3,
7913
+ maxArgs: 3,
7914
+ apply: (args, hooks) => {
7915
+ const x = asFiniteNumber(args[0], "convert", 0);
7916
+ const from = asString$1(args[1], "convert", 1).trim();
7917
+ const to = asString$1(args[2], "convert", 2).trim();
7918
+ if (hooks.convert) {
7919
+ const out = hooks.convert(x, from, to);
7920
+ if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
7921
+ return finiteResult(out, "convert");
7922
+ }
7923
+ if (from === to) return x;
7924
+ throw new ExpressionEvalError("convert: unit conversion table not installed");
7925
+ }
7926
+ }
7927
+ };
7928
+ Object.freeze(Object.assign(Object.create(null), table));
7929
+ /** The set of valid builtin names — used by the parser to reject unknown
7930
+ * callees at parse time (immediate author feedback). */
7931
+ var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
7932
+ /**
7933
+ * Pratt (precedence-climbing) parser for the safe expression mini-language.
7934
+ *
7935
+ * Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
7936
+ * → relational → additive → multiplicative → unary `! -` → call / primary.
7937
+ * Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
7938
+ * string validated against the builtin table at parse time, so an unknown
7939
+ * function is rejected immediately (author feedback) and a persisted expression
7940
+ * that references a since-removed builtin degrades at read.
7941
+ *
7942
+ * A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
7943
+ * arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
7944
+ */
7945
+ /** Binary/logical operator precedence (higher binds tighter). */
7946
+ var BINARY_PRECEDENCE = {
7947
+ "||": 1,
7948
+ "&&": 2,
7949
+ "==": 3,
7950
+ "!=": 3,
7951
+ "<": 4,
7952
+ "<=": 4,
7953
+ ">": 4,
7954
+ ">=": 4,
7955
+ "+": 5,
7956
+ "-": 5,
7957
+ "*": 6,
7958
+ "/": 6,
7959
+ "%": 6
7960
+ };
7961
+ function isLogicalOp(op) {
7962
+ return op === "&&" || op === "||";
7963
+ }
7964
+ function isBinaryOp(op) {
7965
+ return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
7966
+ }
7967
+ var Parser = class {
7968
+ tokens;
7969
+ pos = 0;
7970
+ nodeCount = 0;
7971
+ identifiers = /* @__PURE__ */ new Set();
7972
+ callees = /* @__PURE__ */ new Set();
7973
+ constructor(tokens) {
7974
+ this.tokens = tokens;
7975
+ }
7976
+ parse() {
7977
+ const ast = this.parseTernary();
7978
+ const tok = this.peek();
7979
+ if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
7980
+ return {
7981
+ ast,
7982
+ identifiers: this.identifiers,
7983
+ callees: this.callees,
7984
+ nodeCount: this.nodeCount
7985
+ };
7986
+ }
7987
+ peek() {
7988
+ return this.tokens[this.pos];
7989
+ }
7990
+ next() {
7991
+ return this.tokens[this.pos++];
7992
+ }
7993
+ /** Consume a punctuator token, erroring if the next token isn't it. */
7994
+ expectPunct(punct) {
7995
+ const tok = this.peek();
7996
+ if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
7997
+ this.pos += 1;
7998
+ }
7999
+ matchPunct(punct) {
8000
+ const tok = this.peek();
8001
+ if (tok.type === "punct" && tok.punct === punct) {
8002
+ this.pos += 1;
8003
+ return true;
8004
+ }
8005
+ return false;
8006
+ }
8007
+ countNode() {
8008
+ this.nodeCount += 1;
8009
+ if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
8010
+ }
8011
+ parseTernary() {
8012
+ const test = this.parseBinary(1);
8013
+ if (this.matchPunct("?")) {
8014
+ const consequent = this.parseTernary();
8015
+ this.expectPunct(":");
8016
+ const alternate = this.parseTernary();
8017
+ this.countNode();
8018
+ return {
8019
+ kind: "conditional",
8020
+ test,
8021
+ consequent,
8022
+ alternate
8023
+ };
8024
+ }
8025
+ return test;
8026
+ }
8027
+ parseBinary(minPrec) {
8028
+ let left = this.parseUnary();
8029
+ for (;;) {
8030
+ const tok = this.peek();
8031
+ if (tok.type !== "punct") break;
8032
+ const prec = BINARY_PRECEDENCE[tok.punct];
8033
+ if (prec === void 0 || prec < minPrec) break;
8034
+ const op = tok.punct;
8035
+ this.pos += 1;
8036
+ const right = this.parseBinary(prec + 1);
8037
+ this.countNode();
8038
+ if (isLogicalOp(op)) left = {
8039
+ kind: "logical",
8040
+ op,
8041
+ left,
8042
+ right
8043
+ };
8044
+ else if (isBinaryOp(op)) left = {
8045
+ kind: "binary",
8046
+ op,
8047
+ left,
8048
+ right
8049
+ };
8050
+ else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
8051
+ }
8052
+ return left;
8053
+ }
8054
+ parseUnary() {
8055
+ const tok = this.peek();
8056
+ if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
8057
+ const op = tok.punct;
8058
+ this.pos += 1;
8059
+ const operand = this.parseUnary();
8060
+ this.countNode();
8061
+ return {
8062
+ kind: "unary",
8063
+ op,
8064
+ operand
8065
+ };
8066
+ }
8067
+ return this.parsePrimary();
8068
+ }
8069
+ parsePrimary() {
8070
+ const tok = this.next();
8071
+ switch (tok.type) {
8072
+ case "number":
8073
+ this.countNode();
8074
+ return {
8075
+ kind: "literal",
8076
+ value: tok.value
8077
+ };
8078
+ case "string":
8079
+ this.countNode();
8080
+ return {
8081
+ kind: "literal",
8082
+ value: tok.value
8083
+ };
8084
+ case "keyword":
8085
+ this.countNode();
8086
+ return {
8087
+ kind: "literal",
8088
+ value: tok.keyword === "null" ? null : tok.keyword === "true"
8089
+ };
8090
+ case "identifier": {
8091
+ const nextTok = this.peek();
8092
+ if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
8093
+ this.identifiers.add(tok.name);
8094
+ this.countNode();
8095
+ return {
8096
+ kind: "identifier",
8097
+ name: tok.name
8098
+ };
8099
+ }
8100
+ case "punct":
8101
+ if (tok.punct === "(") {
8102
+ const inner = this.parseTernary();
8103
+ this.expectPunct(")");
8104
+ return inner;
8105
+ }
8106
+ throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
8107
+ case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
8108
+ }
8109
+ }
8110
+ parseCall(callee, pos) {
8111
+ if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
8112
+ this.expectPunct("(");
8113
+ const args = [];
8114
+ if (!this.matchPunct(")")) for (;;) {
8115
+ args.push(this.parseTernary());
8116
+ if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
8117
+ if (this.matchPunct(",")) continue;
8118
+ this.expectPunct(")");
8119
+ break;
8120
+ }
8121
+ this.callees.add(callee);
8122
+ this.countNode();
8123
+ return {
8124
+ kind: "call",
8125
+ callee,
8126
+ args
8127
+ };
8128
+ }
8129
+ };
8130
+ /** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
8131
+ * `ExpressionParseError` on any lexical or grammatical failure. */
8132
+ function parseExpression(source) {
8133
+ return new Parser(tokenize(source)).parse();
8134
+ }
8135
+ Object.freeze({});
8136
+ /**
8137
+ * LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
8138
+ * by expr"). The cache stores BOTH successes and failures (negative caching),
8139
+ * so a corrupt persisted string costs exactly one tokenize+parse total — not
8140
+ * one per read on a hot resolve path.
8141
+ *
8142
+ * The cache is a module-level singleton: entries are pure, content-addressed
8143
+ * ASTs keyed by the raw source string, so sharing one instance across all
8144
+ * callers is safe and maximises hit rate.
8145
+ */
8146
+ var cache = /* @__PURE__ */ new Map();
8147
+ function getCached(source) {
8148
+ const hit = cache.get(source);
8149
+ if (hit !== void 0) {
8150
+ cache.delete(source);
8151
+ cache.set(source, hit);
8152
+ return hit;
8153
+ }
8154
+ let result;
8155
+ try {
8156
+ result = {
8157
+ ok: true,
8158
+ parsed: parseExpression(source)
8159
+ };
8160
+ } catch (err) {
8161
+ result = {
8162
+ ok: false,
8163
+ error: err instanceof ExpressionParseError ? err.message : String(err)
8164
+ };
8165
+ }
8166
+ cache.set(source, result);
8167
+ if (cache.size > 256) {
8168
+ const oldest = cache.keys().next().value;
8169
+ if (oldest !== void 0) cache.delete(oldest);
8170
+ }
8171
+ return result;
8172
+ }
8173
+ /** Compile `source`, returning a discriminated result instead of throwing.
8174
+ * Used by read paths that must degrade rather than raise. LRU/negative-cached. */
8175
+ function compileExpressionSafe(source) {
8176
+ return getCached(source);
8177
+ }
8178
+ /**
8179
+ * Author-time validation. Returns `null` when the source is valid, else a
8180
+ * human-readable error message. Checks: the expression compiles; binding count
8181
+ * is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
8182
+ * is not reserved (`now`/keywords) and does not shadow a builtin; and every
8183
+ * FREE identifier of the AST is covered by a binding or the injected `now`.
8184
+ */
8185
+ function validateExpressionSource(src) {
8186
+ const names = Object.keys(src.bindings);
8187
+ if (names.length > 32) return `too many bindings (${names.length} > 32)`;
8188
+ for (const name of names) {
8189
+ if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
8190
+ if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
8191
+ if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
8192
+ }
8193
+ const compiled = compileExpressionSafe(src.expr);
8194
+ if (!compiled.ok) return compiled.error;
8195
+ const bound = new Set(names);
8196
+ for (const id of compiled.parsed.identifiers) {
8197
+ if (id === "now") continue;
8198
+ if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
8199
+ }
8200
+ return null;
8201
+ }
8202
+ /**
7424
8203
  * Accessory device helpers — shared across drivers.
7425
8204
  *
7426
8205
  * Many vendor-specific drivers register accessory child devices on
@@ -7999,6 +8778,10 @@ var RtspRestreamEntrySchema = object({
7999
8778
  var BrokerRtspClientSchema = object({
8000
8779
  sessionId: string(),
8001
8780
  remoteAddr: string(),
8781
+ /** Client `User-Agent` (e.g. `recorder` for the recorder's RTSP pull), or
8782
+ * null/absent when the client sent none. Lets the UI label a consumer by
8783
+ * purpose. Optional so a client built against an older schema stays valid. */
8784
+ userAgent: string().nullish(),
8002
8785
  playing: boolean(),
8003
8786
  muted: boolean(),
8004
8787
  connectedAt: number(),
@@ -9423,7 +10206,8 @@ var MotionAnalysisResultSchema = object({
9423
10206
  });
9424
10207
  method(object({
9425
10208
  deviceId: number(),
9426
- frame: FrameInputSchema
10209
+ frame: FrameInputSchema.optional(),
10210
+ frameHandle: FrameHandleSchema.optional()
9427
10211
  }), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
9428
10212
  deviceId: number(),
9429
10213
  detected: boolean(),
@@ -9670,6 +10454,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
9670
10454
  engine: PipelineEngineChoiceSchema.optional(),
9671
10455
  steps: array(PipelineStepInputSchema).min(1),
9672
10456
  frame: FrameInputSchema.optional(),
10457
+ /**
10458
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
10459
+ * the decoded pixels live in. One more member of the one-of
10460
+ * frame/frameHandle/image/imageBase64/referenceImage group.
10461
+ */
10462
+ frameHandle: FrameHandleSchema.optional(),
9673
10463
  imageBase64: string().optional(),
9674
10464
  /**
9675
10465
  * Binary JPEG bytes — preferred over `imageBase64` on internal
@@ -9879,6 +10669,31 @@ var ReportMotionInputSchema = object({
9879
10669
  regions: array(MotionRegionSchema).readonly().optional()
9880
10670
  });
9881
10671
  /**
10672
+ * Where a runner gets a camera's decoded frames (cross-node Phase 2,
10673
+ * restream-owner model — P2c).
10674
+ *
10675
+ * - `local-broker` (DEFAULT): today's path — subscribe to the co-located
10676
+ * stream-broker's shm frame plane. Every pre-P2c attach payload (no
10677
+ * `frameSource` key) parses to this, so the field is additive with zero
10678
+ * behavior change.
10679
+ * - `remote-restream`: the detect node is NOT the camera's source-owner.
10680
+ * The runner acquires the owner's COMPRESSED passthrough restream
10681
+ * (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
10682
+ * double-pull guard) and decodes LOCALLY via a satellite frame plane +
10683
+ * pull-mode decoder session pinned to its own node. The shm ring stays
10684
+ * node-local; only H.264/H.265 packets cross the wire.
10685
+ * `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
10686
+ * when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
10687
+ * dials for the owner's restream.
10688
+ */
10689
+ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
10690
+ kind: literal("remote-restream"),
10691
+ /** The camera's source-owner node (slice 1: always the hub). */
10692
+ ownerNodeId: string(),
10693
+ /** Operator override for the owner host the runner dials. */
10694
+ hubHostnameOverride: string().optional()
10695
+ })]).describe("Per-camera frame-source mode for the runner (P2c)");
10696
+ /**
9882
10697
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
9883
10698
  * specific runner instance via `attachCamera`. Carries everything the
9884
10699
  * runner needs to subscribe to the local broker and execute inference.
@@ -9976,7 +10791,15 @@ var RunnerCameraConfigSchema = object({
9976
10791
  */
9977
10792
  onboardMotionDrivesAnalyzer: boolean().default(true),
9978
10793
  occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
9979
- occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
10794
+ occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
10795
+ /**
10796
+ * Where this runner gets the camera's decoded frames (P2c). Defaulted so
10797
+ * every existing payload behaves as `local-broker` — the pre-Phase-2 path.
10798
+ * Populated with `remote-restream` by the orchestrator ONLY when the
10799
+ * camera's detect node differs from its source-owner (P2d, gated by the
10800
+ * `remoteSourcingNodes` rollout setting).
10801
+ */
10802
+ frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
9980
10803
  });
9981
10804
  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;
9982
10805
  /**
@@ -10341,6 +11164,113 @@ object({
10341
11164
  lastFetchedAt: number()
10342
11165
  });
10343
11166
  DeviceType.Sensor;
11167
+ /**
11168
+ * Feeder connectivity / power status — mirrors the HA petkit device-status
11169
+ * enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
11170
+ * `on_batteries` (running on battery backup). `null` until first reported.
11171
+ */
11172
+ var PetFeederDeviceStatusSchema = _enum([
11173
+ "normal",
11174
+ "offline",
11175
+ "on_batteries"
11176
+ ]);
11177
+ var gramsPortion = number().int().min(4).max(200);
11178
+ object({
11179
+ /** Food currently in the bowl (grams). Null when the device has not
11180
+ * reported a reading yet. On dual-hopper models this is the combined
11181
+ * bowl reading; per-hopper levels live in `food1`/`food2`. */
11182
+ foodLevel: number().nullable(),
11183
+ /** Hopper-1 food level (grams) on dual-hopper feeders; null on
11184
+ * single-hopper models. */
11185
+ food1: number().nullable(),
11186
+ /** Hopper-2 food level (grams) on dual-hopper feeders; null on
11187
+ * single-hopper models. */
11188
+ food2: number().nullable(),
11189
+ /** Derived low-food flag — mirrors the HA `food_level` binary_sensor
11190
+ * (`device_class: problem`, on = low). True when the bowl is empty /
11191
+ * below the feeder's low threshold. */
11192
+ lowFood: boolean(),
11193
+ /** Battery charge 0..100 (%). Null on mains-powered models or when the
11194
+ * device has no battery reading. */
11195
+ batteryPower: number().min(0).max(100).nullable(),
11196
+ /** Days of desiccant life remaining. Null when the model has no
11197
+ * desiccant sensor. */
11198
+ desiccantLeftDays: number().nullable(),
11199
+ /** True while a feed is in progress. */
11200
+ feeding: boolean(),
11201
+ /** Decoded connectivity / power status (HA petkit device-status enum).
11202
+ * Null until the device has reported a status. */
11203
+ status: PetFeederDeviceStatusSchema.nullable(),
11204
+ /** Decoded human-readable fault message. Null (or the device's `no_error`
11205
+ * sentinel) means healthy; a non-null string is an active fault. Pairs
11206
+ * with `errorCode` for consumers that want the raw integer. */
11207
+ error: string().nullable(),
11208
+ /** Raw device error code (0 / null = no error). */
11209
+ errorCode: number().nullable(),
11210
+ /** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
11211
+ isDualHopper: boolean(),
11212
+ /** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
11213
+ childLock: boolean(),
11214
+ /** Front indicator-light setting. */
11215
+ indicatorLight: boolean(),
11216
+ /** Play a chime when dispensing. */
11217
+ feedSound: boolean(),
11218
+ /** Speaker / prompt volume level (device-scaled integer). */
11219
+ volume: number(),
11220
+ /** Ms epoch when the slice was last refreshed from the cloud. */
11221
+ lastFetchedAt: number()
11222
+ });
11223
+ DeviceType.PetFeeder, method(object({
11224
+ deviceId: number().int().nonnegative(),
11225
+ grams: gramsPortion.optional(),
11226
+ hopper1: gramsPortion.optional(),
11227
+ hopper2: gramsPortion.optional()
11228
+ }), _void(), {
11229
+ kind: "mutation",
11230
+ auth: "admin"
11231
+ }), method(object({ deviceId: number().int().nonnegative() }), _void(), {
11232
+ kind: "mutation",
11233
+ auth: "admin"
11234
+ }), method(object({ deviceId: number().int().nonnegative() }), _void(), {
11235
+ kind: "mutation",
11236
+ auth: "admin"
11237
+ }), method(object({ deviceId: number().int().nonnegative() }), _void(), {
11238
+ kind: "mutation",
11239
+ auth: "admin"
11240
+ }), method(object({ deviceId: number().int().nonnegative() }), _void(), {
11241
+ kind: "mutation",
11242
+ auth: "admin"
11243
+ }), method(object({
11244
+ deviceId: number().int().nonnegative(),
11245
+ soundId: number().int().nonnegative()
11246
+ }), _void(), {
11247
+ kind: "mutation",
11248
+ auth: "admin"
11249
+ }), method(object({
11250
+ deviceId: number().int().nonnegative(),
11251
+ on: boolean()
11252
+ }), _void(), {
11253
+ kind: "mutation",
11254
+ auth: "admin"
11255
+ }), method(object({
11256
+ deviceId: number().int().nonnegative(),
11257
+ on: boolean()
11258
+ }), _void(), {
11259
+ kind: "mutation",
11260
+ auth: "admin"
11261
+ }), method(object({
11262
+ deviceId: number().int().nonnegative(),
11263
+ on: boolean()
11264
+ }), _void(), {
11265
+ kind: "mutation",
11266
+ auth: "admin"
11267
+ }), method(object({
11268
+ deviceId: number().int().nonnegative(),
11269
+ level: number().int().nonnegative()
11270
+ }), _void(), {
11271
+ kind: "mutation",
11272
+ auth: "admin"
11273
+ });
10344
11274
  object({
10345
11275
  /** Instantaneous power draw in watts. */
10346
11276
  watts: number().optional(),
@@ -12462,10 +13392,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
12462
13392
  url: string()
12463
13393
  }), _void()), method(object({
12464
13394
  sessionId: string(),
12465
- maxCount: number().default(1)
13395
+ maxCount: number().default(1),
13396
+ waitMs: number().optional()
12466
13397
  }), array(DecodedFrameSchema)), method(object({
12467
13398
  sessionId: string(),
12468
- maxCount: number().default(1)
13399
+ maxCount: number().default(1),
13400
+ waitMs: number().optional()
12469
13401
  }), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
12470
13402
  sessionId: string(),
12471
13403
  config: DecoderSessionConfigSchema.partial()
@@ -12752,14 +13684,63 @@ var ChildLayoutEntrySchema = object({
12752
13684
  collapsed: boolean().optional()
12753
13685
  });
12754
13686
  /** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
12755
- * `device-management.ts`. */
13687
+ * `device-management.ts`. Source is a union: a FIELD source copies a sibling
13688
+ * accessory's status field (`kind` optional/absent for wire compat); a
13689
+ * LITERAL source carries a per-device constant (no sibling is read); a
13690
+ * GLOBAL source (P2e) copies ANY device's status field, addressed by the
13691
+ * source device's full re-sync-stable `stableId`. */
13692
+ var DeviceLinkFieldSourceSchema = object({
13693
+ kind: literal("field").optional(),
13694
+ sourceKey: string(),
13695
+ cap: string(),
13696
+ fieldPath: string()
13697
+ });
13698
+ var DeviceLinkLiteralSourceSchema = object({
13699
+ kind: literal("literal"),
13700
+ value: union([
13701
+ string(),
13702
+ number(),
13703
+ boolean(),
13704
+ _null()
13705
+ ])
13706
+ });
13707
+ var DeviceLinkGlobalSourceSchema = object({
13708
+ kind: literal("global"),
13709
+ sourceStableId: string(),
13710
+ cap: string(),
13711
+ fieldPath: string()
13712
+ });
13713
+ /** Expression source (Stage X): compute the target field from N named bindings
13714
+ * via the safe expression engine. Bindings are field | literal | global — never
13715
+ * another expression (no nesting). The `superRefine` runs the SAME author-time
13716
+ * validation as `validateExpressionSource` (compiles the expr, checks binding
13717
+ * names + identifier coverage) so every wire boundary that parses a DeviceLink
13718
+ * (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
13719
+ * Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
13720
+ var DeviceLinkExpressionSourceSchema = object({
13721
+ kind: literal("expression"),
13722
+ expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
13723
+ bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
13724
+ DeviceLinkFieldSourceSchema,
13725
+ DeviceLinkLiteralSourceSchema,
13726
+ DeviceLinkGlobalSourceSchema
13727
+ ]))
13728
+ }).superRefine((src, ctx) => {
13729
+ const err = validateExpressionSource(src);
13730
+ if (err !== null) ctx.addIssue({
13731
+ code: "custom",
13732
+ message: err,
13733
+ path: ["expr"]
13734
+ });
13735
+ });
12756
13736
  var DeviceLinkSchema = object({
12757
13737
  id: string(),
12758
- source: object({
12759
- sourceKey: string(),
12760
- cap: string(),
12761
- fieldPath: string()
12762
- }),
13738
+ source: union([
13739
+ DeviceLinkFieldSourceSchema,
13740
+ DeviceLinkLiteralSourceSchema,
13741
+ DeviceLinkGlobalSourceSchema,
13742
+ DeviceLinkExpressionSourceSchema
13743
+ ]),
12763
13744
  target: object({
12764
13745
  cap: string(),
12765
13746
  fieldPath: string(),
@@ -12788,6 +13769,31 @@ var DeviceLinkSchema = object({
12788
13769
  })
12789
13770
  ]).optional()
12790
13771
  });
13772
+ /** Cap-wire shape of a per-cap display refinement — mirrors
13773
+ * `DeviceCapDisplayOverride` in `device-management.ts`. */
13774
+ var DeviceCapDisplayOverrideSchema = object({
13775
+ unit: string().min(1).optional(),
13776
+ precision: number().int().min(0).max(10).optional()
13777
+ });
13778
+ /** Cap-wire shape of an operator-authored per-device display override —
13779
+ * mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
13780
+ * bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
13781
+ var DeviceDisplayOverrideSchema = object({
13782
+ icon: string().min(1).optional(),
13783
+ label: string().min(1).optional(),
13784
+ unit: string().min(1).optional(),
13785
+ precision: number().int().min(0).max(10).optional(),
13786
+ hidden: boolean().optional(),
13787
+ perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
13788
+ });
13789
+ /** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
13790
+ * in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
13791
+ * the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
13792
+ var RoleDisplayDefaultSchema = object({
13793
+ unit: string().min(1).optional(),
13794
+ precision: number().int().min(0).max(10).optional(),
13795
+ icon: string().min(1).optional()
13796
+ });
12791
13797
  /**
12792
13798
  * Serializable projection of a live IDevice.
12793
13799
  * Returned by listAll, getDevice, getChildren.
@@ -12843,7 +13849,9 @@ var DeviceInfoSchema = object({
12843
13849
  * `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
12844
13850
  childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
12845
13851
  /** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
12846
- deviceLinks: array(DeviceLinkSchema).readonly().optional()
13852
+ deviceLinks: array(DeviceLinkSchema).readonly().optional(),
13853
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
13854
+ display: DeviceDisplayOverrideSchema.optional()
12847
13855
  });
12848
13856
  var ConfigEntrySchema = object({
12849
13857
  key: string(),
@@ -12908,7 +13916,9 @@ var DeviceMetaSchema = object({
12908
13916
  deviceLinks: array(DeviceLinkSchema).readonly().optional(),
12909
13917
  /** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
12910
13918
  * Optional: only present for accessory children that carry a known role. */
12911
- role: string().nullable().optional()
13919
+ role: string().nullable().optional(),
13920
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
13921
+ display: DeviceDisplayOverrideSchema.optional()
12912
13922
  });
12913
13923
  /** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
12914
13924
  var ConfigUISchemaOutput = unknown().nullable();
@@ -13002,7 +14012,19 @@ method(object({
13002
14012
  }), _void(), {
13003
14013
  kind: "mutation",
13004
14014
  auth: "admin"
13005
- }), method(object({ deviceId: number() }), object({ caps: array(object({
14015
+ }), method(object({
14016
+ deviceId: number(),
14017
+ display: DeviceDisplayOverrideSchema.nullable()
14018
+ }), _void(), {
14019
+ kind: "mutation",
14020
+ auth: "admin"
14021
+ }), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
14022
+ kind: "mutation",
14023
+ auth: "admin"
14024
+ }), method(object({
14025
+ deviceId: number(),
14026
+ includeSynthesizable: boolean().optional()
14027
+ }), object({ caps: array(object({
13006
14028
  cap: string(),
13007
14029
  fields: array(object({
13008
14030
  path: string(),
@@ -13012,8 +14034,13 @@ method(object({
13012
14034
  "boolean",
13013
14035
  "enum"
13014
14036
  ]),
13015
- enumValues: array(string()).optional()
13016
- })).readonly()
14037
+ enumValues: array(string()).optional(),
14038
+ item: boolean().optional()
14039
+ })).readonly(),
14040
+ itemArray: object({
14041
+ path: string(),
14042
+ keyField: string()
14043
+ }).optional()
13017
14044
  })).readonly() }), { kind: "query" }), method(object({
13018
14045
  deviceId: number(),
13019
14046
  role: string().nullable()
@@ -13083,7 +14110,11 @@ method(object({
13083
14110
  deviceId: number(),
13084
14111
  entries: array(object({
13085
14112
  capName: string(),
13086
- kind: _enum(["native", "wrapped"]),
14113
+ kind: _enum([
14114
+ "native",
14115
+ "wrapped",
14116
+ "linked"
14117
+ ]),
13087
14118
  providerAddonId: string(),
13088
14119
  providerNodeId: string(),
13089
14120
  nativeAddonId: string()
@@ -13092,7 +14123,11 @@ method(object({
13092
14123
  deviceId: number(),
13093
14124
  entries: array(object({
13094
14125
  capName: string(),
13095
- kind: _enum(["native", "wrapped"]),
14126
+ kind: _enum([
14127
+ "native",
14128
+ "wrapped",
14129
+ "linked"
14130
+ ]),
13096
14131
  providerAddonId: string(),
13097
14132
  providerNodeId: string(),
13098
14133
  nativeAddonId: string()
@@ -13582,7 +14617,7 @@ var AddBrokerInputSchema = object({
13582
14617
  });
13583
14618
  var AddBrokerResultSchema = object({ id: string() });
13584
14619
  var IdInputSchema = object({ id: string() });
13585
- var TestResultSchema = discriminatedUnion("ok", [object({
14620
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
13586
14621
  ok: literal(true),
13587
14622
  latencyMs: number()
13588
14623
  }), object({
@@ -13605,7 +14640,7 @@ var StatusSchema = object({
13605
14640
  brokerCount: number(),
13606
14641
  embeddedRunning: boolean()
13607
14642
  });
13608
- method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema), method(AddBrokerInputSchema, AddBrokerResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(IdInputSchema, TestResultSchema, { kind: "mutation" }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(_void(), StatusSchema);
14643
+ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema), method(AddBrokerInputSchema, AddBrokerResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(IdInputSchema, TestResultSchema$1, { kind: "mutation" }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(_void(), StatusSchema);
13609
14644
  var NetworkEndpointSchema = object({
13610
14645
  url: string(),
13611
14646
  hostname: string(),
@@ -13639,23 +14674,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
13639
14674
  sourcePort: number().optional()
13640
14675
  });
13641
14676
  method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
13642
- method(object({
13643
- title: string(),
14677
+ /**
14678
+ * notification-output — canonical, capability-gated notification delivery.
14679
+ *
14680
+ * Apprise-derived model (see
14681
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
14682
+ * callers emit ONE canonical `Notification`; each provider declares a
14683
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
14684
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
14685
+ * message to what the kind supports — callers never special-case a service.
14686
+ *
14687
+ * DESIGN DECISIONS (locked):
14688
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
14689
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
14690
+ * cap. Rationale: the admin UI needs one uniform surface across the
14691
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
14692
+ * alternative would fork the UI per addon and cannot host the
14693
+ * discovery→adopt flow.
14694
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
14695
+ * the generated cap-mount auto-`concatCollection`-fans them across every
14696
+ * registered provider (notifiers addon + HA addon) so one catalog is
14697
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
14698
+ * `addonId` the generated collection router extracts from the call input.
14699
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
14700
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
14701
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
14702
+ * base64 fallback needed.
14703
+ *
14704
+ * TODO (deferred, closed-set change — separate decision): add
14705
+ * `providerKind: 'notify'` so notification providers surface on the unified
14706
+ * admin "Integrations" page.
14707
+ */
14708
+ /**
14709
+ * Zentik-derived typed-media enum — the superset across every kind. Each
14710
+ * adapter picks what it supports and the degrade engine filters the rest.
14711
+ */
14712
+ var AttachmentMediaTypeSchema = _enum([
14713
+ "image",
14714
+ "video",
14715
+ "gif",
14716
+ "audio",
14717
+ "icon"
14718
+ ]);
14719
+ /**
14720
+ * A single attachment. Exactly one of `url` (remote source, most adapters
14721
+ * prefer this) or `bytes` (inline source; required for Pushover-style
14722
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
14723
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
14724
+ */
14725
+ var AttachmentSchema = object({
14726
+ mediaType: AttachmentMediaTypeSchema,
14727
+ url: string().optional(),
14728
+ bytes: _instanceof(Uint8Array).optional(),
14729
+ mime: string().optional(),
14730
+ name: string().optional()
14731
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
14732
+ var NotificationFormatSchema = _enum([
14733
+ "text",
14734
+ "markdown",
14735
+ "html"
14736
+ ]);
14737
+ /** A single tap-through action button. */
14738
+ var NotificationActionSchema = object({
14739
+ id: string(),
14740
+ label: string(),
14741
+ url: string().optional()
14742
+ });
14743
+ /**
14744
+ * The canonical notification. `body` is the only hard field (Apprise model).
14745
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
14746
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
14747
+ * the adapter maps this ordinal onto its native level. `level?` is an
14748
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
14749
+ * `priority` for that one target.
14750
+ */
14751
+ var NotificationSchema = object({
13644
14752
  body: string(),
13645
- imageUrl: string().optional(),
14753
+ title: string().optional(),
14754
+ format: NotificationFormatSchema.default("text"),
14755
+ priority: number().int().min(1).max(5).default(3),
14756
+ level: string().optional(),
14757
+ attachments: array(AttachmentSchema).optional(),
14758
+ clickUrl: string().optional(),
14759
+ actions: array(NotificationActionSchema).optional(),
14760
+ sound: string().optional(),
14761
+ ttl: number().optional(),
14762
+ tag: string().optional(),
13646
14763
  deviceId: number().optional(),
13647
14764
  eventId: string().optional(),
13648
- priority: _enum([
13649
- "low",
13650
- "normal",
13651
- "high",
13652
- "critical"
13653
- ]).default("normal"),
13654
14765
  metadata: record(string(), unknown()).optional()
13655
- }), _void(), { kind: "mutation" }), method(_void(), object({
14766
+ });
14767
+ /** One declared native severity/priority level for a kind. */
14768
+ var TargetKindLevelSchema = object({
14769
+ id: string(),
14770
+ label: string(),
14771
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
14772
+ ordinal: number().int().min(1).max(5).nullable(),
14773
+ flags: object({
14774
+ critical: boolean().optional(),
14775
+ silent: boolean().optional(),
14776
+ noPush: boolean().optional()
14777
+ }).optional(),
14778
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
14779
+ requires: array(string()).optional(),
14780
+ description: string().optional()
14781
+ });
14782
+ /** The full capability block consulted before dispatch. */
14783
+ var TargetKindCapsSchema = object({
14784
+ attachments: object({
14785
+ mediaTypes: array(AttachmentMediaTypeSchema),
14786
+ mode: _enum([
14787
+ "url",
14788
+ "bytes",
14789
+ "both"
14790
+ ]),
14791
+ max: number().int().nonnegative(),
14792
+ maxBytes: number().int().positive().optional()
14793
+ }),
14794
+ /** Max action buttons (0 = none). */
14795
+ actions: number().int().nonnegative(),
14796
+ levels: array(TargetKindLevelSchema),
14797
+ format: array(NotificationFormatSchema),
14798
+ clickUrl: boolean(),
14799
+ sound: boolean(),
14800
+ ttl: boolean(),
14801
+ bodyMaxLen: number().int().positive()
14802
+ });
14803
+ /**
14804
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
14805
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
14806
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
14807
+ * the union is large and not meant for runtime validation here; the exported
14808
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
14809
+ */
14810
+ var ConfigSchemaPassthrough = unknown();
14811
+ var TargetKindSchema = object({
14812
+ kind: string(),
14813
+ label: string(),
14814
+ icon: string(),
14815
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
14816
+ addonId: string(),
14817
+ configSchema: ConfigSchemaPassthrough,
14818
+ supportsDiscovery: boolean(),
14819
+ caps: TargetKindCapsSchema
14820
+ });
14821
+ /**
14822
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
14823
+ * (return a presence marker only) when serving `listTargets` — never
14824
+ * round-trip a stored secret to the UI.
14825
+ */
14826
+ var TargetSchema = object({
14827
+ id: string(),
14828
+ name: string(),
14829
+ kind: string(),
14830
+ addonId: string(),
14831
+ enabled: boolean(),
14832
+ config: record(string(), unknown())
14833
+ });
14834
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
14835
+ var DiscoveredTargetSchema = object({
14836
+ kind: string(),
14837
+ suggestedName: string(),
14838
+ config: record(string(), unknown())
14839
+ });
14840
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
14841
+ var RenderedAsSchema = object({
14842
+ level: string(),
14843
+ format: NotificationFormatSchema,
14844
+ attachmentsSent: number().int().nonnegative(),
14845
+ actionsSent: number().int().nonnegative(),
14846
+ truncated: boolean(),
14847
+ dropped: array(string())
14848
+ });
14849
+ var SendResultSchema = object({
13656
14850
  success: boolean(),
13657
- error: string().optional()
13658
- }), { kind: "mutation" });
14851
+ error: string().optional(),
14852
+ renderedAs: RenderedAsSchema.optional()
14853
+ });
14854
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
14855
+ var TestResultSchema = SendResultSchema;
14856
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
14857
+ kind: string(),
14858
+ config: record(string(), unknown()).optional()
14859
+ }), array(DiscoveredTargetSchema)), method(object({
14860
+ targetId: string(),
14861
+ notification: NotificationSchema
14862
+ }), SendResultSchema, { kind: "mutation" }), method(object({
14863
+ targetId: string(),
14864
+ sample: NotificationSchema.optional()
14865
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
14866
+ targetId: string(),
14867
+ enabled: boolean()
14868
+ }), _void(), { kind: "mutation" });
13659
14869
  /**
13660
14870
  * Zod schemas for persisted record types.
13661
14871
  *
@@ -16720,7 +17930,10 @@ var HwAccelBackendInputSchema = _enum([
16720
17930
  "webgpu",
16721
17931
  "none"
16722
17932
  ]).nullable().optional();
16723
- var HwAccelResolutionSchema = object({ preferred: array(string()).readonly() });
17933
+ var HwAccelResolutionSchema = object({
17934
+ preferred: array(string()).readonly(),
17935
+ rationale: string()
17936
+ });
16724
17937
  var HardwareEncoderIdSchema = _enum([
16725
17938
  "h264_videotoolbox",
16726
17939
  "hevc_videotoolbox",
@@ -16825,10 +18038,7 @@ var ResolvedInferenceConfigSchema = object({
16825
18038
  format: ModelFormatSchema,
16826
18039
  reason: string()
16827
18040
  });
16828
- method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
16829
- prefer: HwAccelBackendInputSchema,
16830
- nodeId: string().optional()
16831
- }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
18041
+ method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
16832
18042
  kind: "mutation",
16833
18043
  auth: "admin"
16834
18044
  }), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
@@ -16929,6 +18139,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
16929
18139
  kind: "mutation",
16930
18140
  auth: "admin"
16931
18141
  });
18142
+ /**
18143
+ * `recording` cap — footage availability + HLS playback manifests + per-device
18144
+ * recording config. NOTE on events (source of truth, R5/C3): this cap carries
18145
+ * NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
18146
+ * events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
18147
+ * rows); the recorder's internal EventMap markers are ephemeral in-RAM
18148
+ * annotations that are not exposed here and must not be treated as an event
18149
+ * feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
18150
+ * (`interfaces/recording-config.ts`).
18151
+ */
16932
18152
  var RecordingStatusSchema = object({
16933
18153
  deviceId: number(),
16934
18154
  enabled: boolean(),
@@ -18565,6 +19785,12 @@ Object.freeze({
18565
19785
  addonId: null,
18566
19786
  access: "view"
18567
19787
  },
19788
+ "deviceManager.getRoleDisplayDefaults": {
19789
+ capName: "device-manager",
19790
+ capScope: "system",
19791
+ addonId: null,
19792
+ access: "view"
19793
+ },
18568
19794
  "deviceManager.getSettingsSchema": {
18569
19795
  capName: "device-manager",
18570
19796
  capScope: "system",
@@ -18715,6 +19941,12 @@ Object.freeze({
18715
19941
  addonId: null,
18716
19942
  access: "create"
18717
19943
  },
19944
+ "deviceManager.setDisplay": {
19945
+ capName: "device-manager",
19946
+ capScope: "system",
19947
+ addonId: null,
19948
+ access: "create"
19949
+ },
18718
19950
  "deviceManager.setIntegrationId": {
18719
19951
  capName: "device-manager",
18720
19952
  capScope: "system",
@@ -18757,6 +19989,12 @@ Object.freeze({
18757
19989
  addonId: null,
18758
19990
  access: "create"
18759
19991
  },
19992
+ "deviceManager.setRoleDisplayDefaults": {
19993
+ capName: "device-manager",
19994
+ capScope: "system",
19995
+ addonId: null,
19996
+ access: "create"
19997
+ },
18760
19998
  "deviceManager.setStreamProfileMap": {
18761
19999
  capName: "device-manager",
18762
20000
  capScope: "system",
@@ -19735,13 +20973,49 @@ Object.freeze({
19735
20973
  addonId: null,
19736
20974
  access: "create"
19737
20975
  },
20976
+ "notificationOutput.deleteTarget": {
20977
+ capName: "notification-output",
20978
+ capScope: "system",
20979
+ addonId: null,
20980
+ access: "delete"
20981
+ },
20982
+ "notificationOutput.discoverTargets": {
20983
+ capName: "notification-output",
20984
+ capScope: "system",
20985
+ addonId: null,
20986
+ access: "view"
20987
+ },
20988
+ "notificationOutput.listTargetKinds": {
20989
+ capName: "notification-output",
20990
+ capScope: "system",
20991
+ addonId: null,
20992
+ access: "view"
20993
+ },
20994
+ "notificationOutput.listTargets": {
20995
+ capName: "notification-output",
20996
+ capScope: "system",
20997
+ addonId: null,
20998
+ access: "view"
20999
+ },
19738
21000
  "notificationOutput.send": {
19739
21001
  capName: "notification-output",
19740
21002
  capScope: "system",
19741
21003
  addonId: null,
19742
21004
  access: "create"
19743
21005
  },
19744
- "notificationOutput.sendTest": {
21006
+ "notificationOutput.setTargetEnabled": {
21007
+ capName: "notification-output",
21008
+ capScope: "system",
21009
+ addonId: null,
21010
+ access: "create"
21011
+ },
21012
+ "notificationOutput.testTarget": {
21013
+ capName: "notification-output",
21014
+ capScope: "system",
21015
+ addonId: null,
21016
+ access: "create"
21017
+ },
21018
+ "notificationOutput.upsertTarget": {
19745
21019
  capName: "notification-output",
19746
21020
  capScope: "system",
19747
21021
  addonId: null,
@@ -19771,6 +21045,66 @@ Object.freeze({
19771
21045
  addonId: null,
19772
21046
  access: "create"
19773
21047
  },
21048
+ "petFeeder.callPet": {
21049
+ capName: "pet-feeder",
21050
+ capScope: "device",
21051
+ addonId: null,
21052
+ access: "create"
21053
+ },
21054
+ "petFeeder.cancelFeed": {
21055
+ capName: "pet-feeder",
21056
+ capScope: "device",
21057
+ addonId: null,
21058
+ access: "create"
21059
+ },
21060
+ "petFeeder.feed": {
21061
+ capName: "pet-feeder",
21062
+ capScope: "device",
21063
+ addonId: null,
21064
+ access: "create"
21065
+ },
21066
+ "petFeeder.markFoodReplenished": {
21067
+ capName: "pet-feeder",
21068
+ capScope: "device",
21069
+ addonId: null,
21070
+ access: "create"
21071
+ },
21072
+ "petFeeder.playSound": {
21073
+ capName: "pet-feeder",
21074
+ capScope: "device",
21075
+ addonId: null,
21076
+ access: "create"
21077
+ },
21078
+ "petFeeder.resetDesiccant": {
21079
+ capName: "pet-feeder",
21080
+ capScope: "device",
21081
+ addonId: null,
21082
+ access: "delete"
21083
+ },
21084
+ "petFeeder.setChildLock": {
21085
+ capName: "pet-feeder",
21086
+ capScope: "device",
21087
+ addonId: null,
21088
+ access: "create"
21089
+ },
21090
+ "petFeeder.setFeedSound": {
21091
+ capName: "pet-feeder",
21092
+ capScope: "device",
21093
+ addonId: null,
21094
+ access: "create"
21095
+ },
21096
+ "petFeeder.setIndicatorLight": {
21097
+ capName: "pet-feeder",
21098
+ capScope: "device",
21099
+ addonId: null,
21100
+ access: "create"
21101
+ },
21102
+ "petFeeder.setVolume": {
21103
+ capName: "pet-feeder",
21104
+ capScope: "device",
21105
+ addonId: null,
21106
+ access: "create"
21107
+ },
19774
21108
  "pipelineAnalytics.clearTracks": {
19775
21109
  capName: "pipeline-analytics",
19776
21110
  capScope: "device",
@@ -31138,18 +32472,11 @@ var OnvifProviderAddon = class extends BaseDeviceProvider {
31138
32472
  }] };
31139
32473
  }
31140
32474
  async getGlobalSettings() {
31141
- const raw = await this.ctx.settings?.readAddonStore() ?? {};
32475
+ const raw = await this.resolveGlobalStore();
31142
32476
  return hydrateSchema(this.buildGlobalSchema(), raw);
31143
32477
  }
31144
- async updateGlobalSettings(patch) {
31145
- await this.ctx.settings?.writeAddonStore(patch);
31146
- }
31147
32478
  async _getAddonConfig() {
31148
- if (!this.ctx.settings) return {
31149
- id: "onvif-default",
31150
- name: "ONVIF Cameras"
31151
- };
31152
- const raw = await this.ctx.settings.readAddonStore();
32479
+ const raw = await this.resolveGlobalStore();
31153
32480
  return {
31154
32481
  id: typeof raw["id"] === "string" ? raw["id"] : "onvif-default",
31155
32482
  name: typeof raw["name"] === "string" ? raw["name"] : "ONVIF Cameras",