@camstack/addon-provider-rtsp 1.1.13 → 1.1.15

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 +1469 -102
  2. package/dist/addon.mjs +1469 -102
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -4641,7 +4641,7 @@ function preprocess(fn, schema) {
4641
4641
  });
4642
4642
  }
4643
4643
  //#endregion
4644
- //#region ../types/dist/sleep-C2M2zF7x.mjs
4644
+ //#region ../types/dist/sleep-BiDFW0E7.mjs
4645
4645
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4646
4646
  EventCategory["SystemBoot"] = "system.boot";
4647
4647
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5454,6 +5454,100 @@ function createDurableState(deps) {
5454
5454
  };
5455
5455
  }
5456
5456
  /**
5457
+ * Per-node scoping for the shared addon-settings blob.
5458
+ *
5459
+ * An addon's settings store is hub-central (the `addon-settings` cap is
5460
+ * hub-routed — the hub instance answers for every node), so fields whose
5461
+ * value is a NODE fact (decoder backend, engine pick, probed hardware
5462
+ * capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
5463
+ * the single shared blob. The SCHEMA field key stays bare: the write path
5464
+ * ({@link scopePatch}) maps the bare field onto the target node's scoped
5465
+ * key; the read/hydrate path ({@link projectStore}) maps THIS node's value
5466
+ * back, so UI forms and `resolveConfig` only ever see the bare key.
5467
+ *
5468
+ * Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
5469
+ * (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
5470
+ * schema and routes reads/writes through these helpers.
5471
+ *
5472
+ * ## No bare-key fallback — deliberate
5473
+ *
5474
+ * {@link readNodeValue} reads the node-scoped key ONLY. A node with no
5475
+ * scoped key resolves to `undefined` so the field's schema `default` wins —
5476
+ * NEVER `store[base]` and never another node's value. A bare legacy key in
5477
+ * the store is invisible to every node, hub included, so one node's
5478
+ * selection can never leak onto another. (This generalizes the
5479
+ * `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
5480
+ * arbitrary set of per-node field keys.)
5481
+ *
5482
+ * Pure functions only — no I/O, no imports beyond the language. This is a
5483
+ * LEAF module: import it via its deep path, never from the root barrel.
5484
+ */
5485
+ /**
5486
+ * Normalize a raw kernel node id to the bare node id used for scoping.
5487
+ * `localNodeId` can carry a `<node>/<addon>` suffix on forked child
5488
+ * processes; per-node settings are per-NODE, so strip the addon segment.
5489
+ * `undefined` / `null` / empty falls back to `'hub'`.
5490
+ */
5491
+ function normalizeNodeId(raw) {
5492
+ if (raw === void 0 || raw === null || raw === "") return "hub";
5493
+ const slashIdx = raw.indexOf("/");
5494
+ if (slashIdx < 0) return raw;
5495
+ const bare = raw.slice(0, slashIdx);
5496
+ return bare === "" ? "hub" : bare;
5497
+ }
5498
+ /** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
5499
+ function nodeScopedKey(base, nodeId) {
5500
+ return `${base}@${normalizeNodeId(nodeId)}`;
5501
+ }
5502
+ /**
5503
+ * Read a node's value for a per-node field from the raw shared store:
5504
+ * the node-scoped key when present, otherwise `undefined`.
5505
+ * Deliberately NO bare-key fallback (see module doc) — the caller lets the
5506
+ * schema `default` win on `undefined`.
5507
+ */
5508
+ function readNodeValue(store, base, nodeId) {
5509
+ return store[nodeScopedKey(base, nodeId)];
5510
+ }
5511
+ /**
5512
+ * Re-map a UI/settings patch so every bare perNode field persists under the
5513
+ * TARGET node's scoped key; all other keys pass through unchanged. Used on
5514
+ * the write path so a save for one node never clobbers another node's value
5515
+ * (and the bare key is never written). Returns a new object — the input
5516
+ * patch is not mutated.
5517
+ */
5518
+ function scopePatch(patch, perNodeKeys, nodeId) {
5519
+ const out = {};
5520
+ for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
5521
+ return out;
5522
+ }
5523
+ /**
5524
+ * Project the raw shared store onto the bare schema keys for ONE node so a
5525
+ * UI schema (whose field keys are bare) hydrates from that node's own
5526
+ * values:
5527
+ *
5528
+ * - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
5529
+ * - Every bare perNode key is dropped from the pass-through (a stray bare
5530
+ * legacy key must never hydrate any node — no bare fallback).
5531
+ * - THIS node's effective value ({@link readNodeValue}) is then laid onto
5532
+ * each bare perNode key; when the node has no scoped key the bare key is
5533
+ * left ABSENT so the field's schema `default` wins.
5534
+ *
5535
+ * Returns a new object — the input store is not mutated.
5536
+ */
5537
+ function projectStore(store, perNodeKeys, nodeId) {
5538
+ const out = {};
5539
+ for (const [key, value] of Object.entries(store)) {
5540
+ if (key.includes("@")) continue;
5541
+ if (perNodeKeys.has(key)) continue;
5542
+ out[key] = value;
5543
+ }
5544
+ for (const base of perNodeKeys) {
5545
+ const value = readNodeValue(store, base, nodeId);
5546
+ if (value !== void 0) out[base] = value;
5547
+ }
5548
+ return out;
5549
+ }
5550
+ /**
5457
5551
  * Base class for CamStack addons. Eliminates settings boilerplate:
5458
5552
  *
5459
5553
  * - Typed `config` property with automatic resolution from store + defaults
@@ -5621,23 +5715,63 @@ var BaseAddon = class {
5621
5715
  deviceSettingsSchema() {
5622
5716
  return null;
5623
5717
  }
5624
- async getGlobalSettings(overlay, cap, _nodeId) {
5718
+ async getGlobalSettings(overlay, cap, nodeId) {
5625
5719
  const schema = this.globalSettingsSchema(cap);
5626
5720
  if (!schema) return { sections: [] };
5627
- const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5721
+ const projected = await this.resolveGlobalStore(nodeId, cap);
5628
5722
  return hydrateSchema(schema, overlay ? {
5629
- ...raw,
5723
+ ...projected,
5630
5724
  ...overlay
5631
- } : raw);
5725
+ } : projected);
5632
5726
  }
5633
- async updateGlobalSettings(patch, _nodeId) {
5634
- await this._ctx?.settings?.writeAddonStore(patch);
5727
+ /**
5728
+ * The raw addon store PROJECTED onto the target node's bare per-node keys:
5729
+ * every `perNode: true` field carries THAT node's scoped value on its bare
5730
+ * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
5731
+ * bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
5732
+ * A no-op passthrough when the schema declares no `perNode` field.
5733
+ *
5734
+ * This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
5735
+ * the store for custom option logic (option narrowing, value snapping) to
5736
+ * read it per-node — never `ctx.settings.readAddonStore()` directly.
5737
+ * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
5738
+ */
5739
+ async resolveGlobalStore(nodeId, cap) {
5740
+ const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5741
+ const keys = this.perNodeKeys(cap);
5742
+ const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5743
+ return keys.size > 0 ? projectStore(raw, keys, node) : raw;
5744
+ }
5745
+ async updateGlobalSettings(patch, nodeId) {
5746
+ const keys = this.perNodeKeys();
5747
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5748
+ const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5749
+ const barePatch = patch;
5750
+ const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
5751
+ await this._ctx?.settings?.writeAddonStore(scoped);
5752
+ if (target !== localNode) return;
5635
5753
  await this.resolveConfig();
5636
5754
  await this.onConfigChanged();
5637
5755
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
5638
5756
  this.maybeAutoRestart(patch, this.globalSettingsSchema());
5639
5757
  }
5640
5758
  /**
5759
+ * The set of field keys the global settings schema declares `perNode: true`
5760
+ * — derived once per `cap` argument and memoized (schemas are static
5761
+ * declarations). Empty set ⇒ every per-node code path is bypassed and the
5762
+ * settings API behaves exactly like the legacy node-agnostic one.
5763
+ */
5764
+ _perNodeKeysCache = /* @__PURE__ */ new Map();
5765
+ perNodeKeys(cap) {
5766
+ const cacheKey = cap ?? "";
5767
+ const cached = this._perNodeKeysCache.get(cacheKey);
5768
+ if (cached) return cached;
5769
+ const schema = this.globalSettingsSchema(cap);
5770
+ const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
5771
+ this._perNodeKeysCache.set(cacheKey, keys);
5772
+ return keys;
5773
+ }
5774
+ /**
5641
5775
  * If any field in `patch` is marked `requiresRestart` in `schema`,
5642
5776
  * schedule an addon restart for the next tick. Deferred via
5643
5777
  * `setImmediate` so the tRPC mutation that triggered the write has
@@ -5790,12 +5924,19 @@ var BaseAddon = class {
5790
5924
  * The merge is shallow: each key in `defaults` is checked against the store.
5791
5925
  * Only keys present in defaults are read — the store can contain extra keys
5792
5926
  * (e.g. from older versions) without polluting the typed config.
5927
+ *
5928
+ * Keys the global settings schema declares `perNode: true` resolve from
5929
+ * THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
5930
+ * from the bare key — so a per-node field resolves to this node's own
5931
+ * selection at boot (absent scoped key ⇒ the constructor default wins).
5793
5932
  */
5794
5933
  async resolveConfig() {
5795
5934
  const stored = await this.readAddonStoreWithRetry();
5935
+ const perNode = this.perNodeKeys();
5936
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5796
5937
  const resolved = { ...this.defaults };
5797
5938
  for (const key of Object.keys(this.defaults)) {
5798
- const storedValue = stored[key];
5939
+ const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
5799
5940
  if (storedValue !== void 0 && storedValue !== null) {
5800
5941
  const defaultType = typeof this.defaults[key];
5801
5942
  if (typeof storedValue === defaultType) resolved[key] = storedValue;
@@ -5879,6 +6020,27 @@ var BaseAddon = class {
5879
6020
  }
5880
6021
  };
5881
6022
  /**
6023
+ * Collect the keys of every field marked `perNode: true`, recursing into
6024
+ * layout containers (`group` fields and `sub-tabs` tabs) the same way
6025
+ * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6026
+ * don't declare `perNode` and are excluded by the `in` narrowing.
6027
+ */
6028
+ function collectPerNodeFieldKeys(fields) {
6029
+ const collected = [];
6030
+ for (const field of fields) {
6031
+ if (field.type === "group") {
6032
+ collected.push(...collectPerNodeFieldKeys(field.fields));
6033
+ continue;
6034
+ }
6035
+ if (field.type === "sub-tabs") {
6036
+ for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
6037
+ continue;
6038
+ }
6039
+ if ("perNode" in field && field.perNode === true) collected.push(field.key);
6040
+ }
6041
+ return collected;
6042
+ }
6043
+ /**
5882
6044
  * Normalize an `ICamstackAddon.initialize()` return value into the
5883
6045
  * `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
5884
6046
  * envelopes pass through; void stays void.
@@ -5903,6 +6065,7 @@ var CamStreamKindSchema = _enum([
5903
6065
  "pull-rtsp",
5904
6066
  "pull-rtmp",
5905
6067
  "pull-http",
6068
+ "pull-flv",
5906
6069
  "pull-rfc4571",
5907
6070
  "push-annexb",
5908
6071
  "derived"
@@ -6285,6 +6448,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
6285
6448
  /** Single still-image entity (HA `image.*`). Read-only display of an
6286
6449
  * `entity_picture` signed URL the browser loads directly. `image` cap. */
6287
6450
  DeviceType["Image"] = "image";
6451
+ /** Smart pet feeder — cloud-connected food dispenser with a bowl food
6452
+ * level, battery, desiccant life, feeding state and manual-feed /
6453
+ * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
6454
+ * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
6455
+ * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
6456
+ * integrations sharing the same food/desiccant/hopper surface. */
6457
+ DeviceType["PetFeeder"] = "pet-feeder";
6288
6458
  return DeviceType;
6289
6459
  }({});
6290
6460
  var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
@@ -7469,6 +7639,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
7469
7639
  for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7470
7640
  for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7471
7641
  /**
7642
+ * Error types for the safe expression engine. Two distinct classes so callers
7643
+ * can tell a compile-time (grammar) failure from a runtime (evaluation)
7644
+ * failure — both are non-fatal to the host: read paths degrade to "skip link".
7645
+ */
7646
+ /** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
7647
+ * the failure is anchored to a character (author-facing inline feedback). */
7648
+ var ExpressionParseError = class extends Error {
7649
+ position;
7650
+ constructor(message, position) {
7651
+ super(message);
7652
+ this.name = "ExpressionParseError";
7653
+ this.position = position;
7654
+ }
7655
+ };
7656
+ /** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
7657
+ * result, unknown builtin, step-budget exceeded). */
7658
+ var ExpressionEvalError = class extends Error {
7659
+ constructor(message) {
7660
+ super(message);
7661
+ this.name = "ExpressionEvalError";
7662
+ }
7663
+ };
7664
+ /**
7665
+ * Resource-bound constants for the safe expression engine.
7666
+ *
7667
+ * Every bound is defense-in-depth: the grammar is non-Turing-complete (no
7668
+ * loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
7669
+ * O(nodeCount) by construction. These caps merely put a hard ceiling on the
7670
+ * work a single author-supplied expression can request, so a hostile or
7671
+ * accidental pathological string can never spend unbounded CPU/memory.
7672
+ */
7673
+ /** Max source length (chars) — checked BEFORE tokenizing so a huge string is
7674
+ * rejected without allocation. */
7675
+ var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
7676
+ /** A legal binding / identifier name. */
7677
+ var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
7678
+ /** Binding names an author may NOT use: `now` is auto-injected; the literal
7679
+ * keywords lex as values, not identifiers, so binding to them is meaningless. */
7680
+ var RESERVED_BINDING_NAMES = new Set([
7681
+ "now",
7682
+ "true",
7683
+ "false",
7684
+ "null"
7685
+ ]);
7686
+ /**
7687
+ * Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
7688
+ * zero-dependency. The grammar is deliberately boring: decimal numbers,
7689
+ * single/double-quoted strings with a tiny escape set, identifiers, the three
7690
+ * value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
7691
+ * outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
7692
+ * is a parse error with a source position, so member access / assignment /
7693
+ * template literals are lexically impossible.
7694
+ */
7695
+ var KEYWORDS = new Set([
7696
+ "true",
7697
+ "false",
7698
+ "null"
7699
+ ]);
7700
+ function isDigit(ch) {
7701
+ return ch >= "0" && ch <= "9";
7702
+ }
7703
+ function isIdentStart(ch) {
7704
+ return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
7705
+ }
7706
+ function isIdentPart(ch) {
7707
+ return isIdentStart(ch) || isDigit(ch);
7708
+ }
7709
+ function isWhitespace(ch) {
7710
+ return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
7711
+ }
7712
+ /** Tokenize `source` into a flat token list ending with a single `eof` token.
7713
+ * Throws `ExpressionParseError` on any illegal character or unterminated
7714
+ * string. */
7715
+ function tokenize(source) {
7716
+ if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
7717
+ const tokens = [];
7718
+ let i = 0;
7719
+ const n = source.length;
7720
+ while (i < n) {
7721
+ const ch = source[i];
7722
+ if (isWhitespace(ch)) {
7723
+ i += 1;
7724
+ continue;
7725
+ }
7726
+ if (isDigit(ch)) {
7727
+ const start = i;
7728
+ while (i < n && isDigit(source[i])) i += 1;
7729
+ if (i < n && source[i] === ".") {
7730
+ if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
7731
+ i += 1;
7732
+ while (i < n && isDigit(source[i])) i += 1;
7733
+ }
7734
+ const text = source.slice(start, i);
7735
+ const value = Number(text);
7736
+ if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
7737
+ tokens.push({
7738
+ type: "number",
7739
+ value,
7740
+ pos: start
7741
+ });
7742
+ continue;
7743
+ }
7744
+ if (ch === "'" || ch === "\"") {
7745
+ const quote = ch;
7746
+ const start = i;
7747
+ i += 1;
7748
+ let out = "";
7749
+ let closed = false;
7750
+ while (i < n) {
7751
+ const c = source[i];
7752
+ if (c === "\\") {
7753
+ const next = i + 1 < n ? source[i + 1] : "";
7754
+ if (next === "\\" || next === "'" || next === "\"") {
7755
+ out += next;
7756
+ i += 2;
7757
+ continue;
7758
+ }
7759
+ throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
7760
+ }
7761
+ if (c === quote) {
7762
+ closed = true;
7763
+ i += 1;
7764
+ break;
7765
+ }
7766
+ out += c;
7767
+ i += 1;
7768
+ }
7769
+ if (!closed) throw new ExpressionParseError("unterminated string literal", start);
7770
+ tokens.push({
7771
+ type: "string",
7772
+ value: out,
7773
+ pos: start
7774
+ });
7775
+ continue;
7776
+ }
7777
+ if (isIdentStart(ch)) {
7778
+ const start = i;
7779
+ while (i < n && isIdentPart(source[i])) i += 1;
7780
+ const text = source.slice(start, i);
7781
+ if (KEYWORDS.has(text)) tokens.push({
7782
+ type: "keyword",
7783
+ keyword: keywordOf(text),
7784
+ pos: start
7785
+ });
7786
+ else tokens.push({
7787
+ type: "identifier",
7788
+ name: text,
7789
+ pos: start
7790
+ });
7791
+ continue;
7792
+ }
7793
+ const two = i + 1 < n ? source.slice(i, i + 2) : "";
7794
+ if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
7795
+ tokens.push({
7796
+ type: "punct",
7797
+ punct: two,
7798
+ pos: i
7799
+ });
7800
+ i += 2;
7801
+ continue;
7802
+ }
7803
+ if (isSinglePunct(ch)) {
7804
+ tokens.push({
7805
+ type: "punct",
7806
+ punct: ch,
7807
+ pos: i
7808
+ });
7809
+ i += 1;
7810
+ continue;
7811
+ }
7812
+ throw new ExpressionParseError(`unexpected character '${ch}'`, i);
7813
+ }
7814
+ tokens.push({
7815
+ type: "eof",
7816
+ pos: n
7817
+ });
7818
+ return tokens;
7819
+ }
7820
+ function keywordOf(text) {
7821
+ if (text === "true") return "true";
7822
+ if (text === "false") return "false";
7823
+ return "null";
7824
+ }
7825
+ function isSinglePunct(ch) {
7826
+ return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
7827
+ }
7828
+ /**
7829
+ * Frozen, null-prototype builtin function table for the expression engine
7830
+ * (spec §4 rule 4). The table is the SOLE surface of callable functions: the
7831
+ * parser rejects any callee not in it, and the evaluator gates each call on an
7832
+ * own-property check against it.
7833
+ *
7834
+ * Because the object has a NULL prototype AND is `Object.freeze`d:
7835
+ * - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
7836
+ * - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
7837
+ * (there is no `Object.prototype` in the chain), so those names are not
7838
+ * callable — they are simply "unknown function" at parse time.
7839
+ *
7840
+ * Every numeric argument is validated as a finite number and every numeric
7841
+ * RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
7842
+ * (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
7843
+ * closed rather than emitting a garbage value.
7844
+ */
7845
+ function asFiniteNumber(value, name, index) {
7846
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
7847
+ return value;
7848
+ }
7849
+ function asString$1(value, name, index) {
7850
+ if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
7851
+ return value;
7852
+ }
7853
+ function finiteResult(value, name) {
7854
+ if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
7855
+ return value;
7856
+ }
7857
+ function allFiniteNumbers(args, name) {
7858
+ return args.map((a, idx) => asFiniteNumber(a, name, idx));
7859
+ }
7860
+ var INF = Number.POSITIVE_INFINITY;
7861
+ var table = {
7862
+ min: {
7863
+ minArgs: 1,
7864
+ maxArgs: INF,
7865
+ apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
7866
+ },
7867
+ max: {
7868
+ minArgs: 1,
7869
+ maxArgs: INF,
7870
+ apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
7871
+ },
7872
+ abs: {
7873
+ minArgs: 1,
7874
+ maxArgs: 1,
7875
+ apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
7876
+ },
7877
+ floor: {
7878
+ minArgs: 1,
7879
+ maxArgs: 1,
7880
+ apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
7881
+ },
7882
+ ceil: {
7883
+ minArgs: 1,
7884
+ maxArgs: 1,
7885
+ apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
7886
+ },
7887
+ sqrt: {
7888
+ minArgs: 1,
7889
+ maxArgs: 1,
7890
+ apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
7891
+ },
7892
+ round: {
7893
+ minArgs: 1,
7894
+ maxArgs: 2,
7895
+ apply: (args) => {
7896
+ const x = asFiniteNumber(args[0], "round", 0);
7897
+ const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
7898
+ if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
7899
+ const factor = 10 ** digits;
7900
+ return finiteResult(Math.round(x * factor) / factor, "round");
7901
+ }
7902
+ },
7903
+ pow: {
7904
+ minArgs: 2,
7905
+ maxArgs: 2,
7906
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
7907
+ },
7908
+ clamp: {
7909
+ minArgs: 3,
7910
+ maxArgs: 3,
7911
+ apply: (args) => {
7912
+ const x = asFiniteNumber(args[0], "clamp", 0);
7913
+ const lo = asFiniteNumber(args[1], "clamp", 1);
7914
+ const hi = asFiniteNumber(args[2], "clamp", 2);
7915
+ if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
7916
+ return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
7917
+ }
7918
+ },
7919
+ avg: {
7920
+ minArgs: 1,
7921
+ maxArgs: INF,
7922
+ apply: (args) => {
7923
+ const nums = allFiniteNumbers(args, "avg");
7924
+ return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
7925
+ }
7926
+ },
7927
+ sum: {
7928
+ minArgs: 1,
7929
+ maxArgs: INF,
7930
+ apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
7931
+ },
7932
+ coalesce: {
7933
+ minArgs: 1,
7934
+ maxArgs: INF,
7935
+ apply: (args) => {
7936
+ for (const a of args) if (a !== null) return a;
7937
+ return null;
7938
+ }
7939
+ },
7940
+ age: {
7941
+ minArgs: 2,
7942
+ maxArgs: 2,
7943
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
7944
+ },
7945
+ convert: {
7946
+ minArgs: 3,
7947
+ maxArgs: 3,
7948
+ apply: (args, hooks) => {
7949
+ const x = asFiniteNumber(args[0], "convert", 0);
7950
+ const from = asString$1(args[1], "convert", 1).trim();
7951
+ const to = asString$1(args[2], "convert", 2).trim();
7952
+ if (hooks.convert) {
7953
+ const out = hooks.convert(x, from, to);
7954
+ if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
7955
+ return finiteResult(out, "convert");
7956
+ }
7957
+ if (from === to) return x;
7958
+ throw new ExpressionEvalError("convert: unit conversion table not installed");
7959
+ }
7960
+ }
7961
+ };
7962
+ Object.freeze(Object.assign(Object.create(null), table));
7963
+ /** The set of valid builtin names — used by the parser to reject unknown
7964
+ * callees at parse time (immediate author feedback). */
7965
+ var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
7966
+ /**
7967
+ * Pratt (precedence-climbing) parser for the safe expression mini-language.
7968
+ *
7969
+ * Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
7970
+ * → relational → additive → multiplicative → unary `! -` → call / primary.
7971
+ * Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
7972
+ * string validated against the builtin table at parse time, so an unknown
7973
+ * function is rejected immediately (author feedback) and a persisted expression
7974
+ * that references a since-removed builtin degrades at read.
7975
+ *
7976
+ * A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
7977
+ * arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
7978
+ */
7979
+ /** Binary/logical operator precedence (higher binds tighter). */
7980
+ var BINARY_PRECEDENCE = {
7981
+ "||": 1,
7982
+ "&&": 2,
7983
+ "==": 3,
7984
+ "!=": 3,
7985
+ "<": 4,
7986
+ "<=": 4,
7987
+ ">": 4,
7988
+ ">=": 4,
7989
+ "+": 5,
7990
+ "-": 5,
7991
+ "*": 6,
7992
+ "/": 6,
7993
+ "%": 6
7994
+ };
7995
+ function isLogicalOp(op) {
7996
+ return op === "&&" || op === "||";
7997
+ }
7998
+ function isBinaryOp(op) {
7999
+ return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
8000
+ }
8001
+ var Parser = class {
8002
+ tokens;
8003
+ pos = 0;
8004
+ nodeCount = 0;
8005
+ identifiers = /* @__PURE__ */ new Set();
8006
+ callees = /* @__PURE__ */ new Set();
8007
+ constructor(tokens) {
8008
+ this.tokens = tokens;
8009
+ }
8010
+ parse() {
8011
+ const ast = this.parseTernary();
8012
+ const tok = this.peek();
8013
+ if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
8014
+ return {
8015
+ ast,
8016
+ identifiers: this.identifiers,
8017
+ callees: this.callees,
8018
+ nodeCount: this.nodeCount
8019
+ };
8020
+ }
8021
+ peek() {
8022
+ return this.tokens[this.pos];
8023
+ }
8024
+ next() {
8025
+ return this.tokens[this.pos++];
8026
+ }
8027
+ /** Consume a punctuator token, erroring if the next token isn't it. */
8028
+ expectPunct(punct) {
8029
+ const tok = this.peek();
8030
+ if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
8031
+ this.pos += 1;
8032
+ }
8033
+ matchPunct(punct) {
8034
+ const tok = this.peek();
8035
+ if (tok.type === "punct" && tok.punct === punct) {
8036
+ this.pos += 1;
8037
+ return true;
8038
+ }
8039
+ return false;
8040
+ }
8041
+ countNode() {
8042
+ this.nodeCount += 1;
8043
+ if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
8044
+ }
8045
+ parseTernary() {
8046
+ const test = this.parseBinary(1);
8047
+ if (this.matchPunct("?")) {
8048
+ const consequent = this.parseTernary();
8049
+ this.expectPunct(":");
8050
+ const alternate = this.parseTernary();
8051
+ this.countNode();
8052
+ return {
8053
+ kind: "conditional",
8054
+ test,
8055
+ consequent,
8056
+ alternate
8057
+ };
8058
+ }
8059
+ return test;
8060
+ }
8061
+ parseBinary(minPrec) {
8062
+ let left = this.parseUnary();
8063
+ for (;;) {
8064
+ const tok = this.peek();
8065
+ if (tok.type !== "punct") break;
8066
+ const prec = BINARY_PRECEDENCE[tok.punct];
8067
+ if (prec === void 0 || prec < minPrec) break;
8068
+ const op = tok.punct;
8069
+ this.pos += 1;
8070
+ const right = this.parseBinary(prec + 1);
8071
+ this.countNode();
8072
+ if (isLogicalOp(op)) left = {
8073
+ kind: "logical",
8074
+ op,
8075
+ left,
8076
+ right
8077
+ };
8078
+ else if (isBinaryOp(op)) left = {
8079
+ kind: "binary",
8080
+ op,
8081
+ left,
8082
+ right
8083
+ };
8084
+ else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
8085
+ }
8086
+ return left;
8087
+ }
8088
+ parseUnary() {
8089
+ const tok = this.peek();
8090
+ if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
8091
+ const op = tok.punct;
8092
+ this.pos += 1;
8093
+ const operand = this.parseUnary();
8094
+ this.countNode();
8095
+ return {
8096
+ kind: "unary",
8097
+ op,
8098
+ operand
8099
+ };
8100
+ }
8101
+ return this.parsePrimary();
8102
+ }
8103
+ parsePrimary() {
8104
+ const tok = this.next();
8105
+ switch (tok.type) {
8106
+ case "number":
8107
+ this.countNode();
8108
+ return {
8109
+ kind: "literal",
8110
+ value: tok.value
8111
+ };
8112
+ case "string":
8113
+ this.countNode();
8114
+ return {
8115
+ kind: "literal",
8116
+ value: tok.value
8117
+ };
8118
+ case "keyword":
8119
+ this.countNode();
8120
+ return {
8121
+ kind: "literal",
8122
+ value: tok.keyword === "null" ? null : tok.keyword === "true"
8123
+ };
8124
+ case "identifier": {
8125
+ const nextTok = this.peek();
8126
+ if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
8127
+ this.identifiers.add(tok.name);
8128
+ this.countNode();
8129
+ return {
8130
+ kind: "identifier",
8131
+ name: tok.name
8132
+ };
8133
+ }
8134
+ case "punct":
8135
+ if (tok.punct === "(") {
8136
+ const inner = this.parseTernary();
8137
+ this.expectPunct(")");
8138
+ return inner;
8139
+ }
8140
+ throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
8141
+ case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
8142
+ }
8143
+ }
8144
+ parseCall(callee, pos) {
8145
+ if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
8146
+ this.expectPunct("(");
8147
+ const args = [];
8148
+ if (!this.matchPunct(")")) for (;;) {
8149
+ args.push(this.parseTernary());
8150
+ if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
8151
+ if (this.matchPunct(",")) continue;
8152
+ this.expectPunct(")");
8153
+ break;
8154
+ }
8155
+ this.callees.add(callee);
8156
+ this.countNode();
8157
+ return {
8158
+ kind: "call",
8159
+ callee,
8160
+ args
8161
+ };
8162
+ }
8163
+ };
8164
+ /** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
8165
+ * `ExpressionParseError` on any lexical or grammatical failure. */
8166
+ function parseExpression(source) {
8167
+ return new Parser(tokenize(source)).parse();
8168
+ }
8169
+ Object.freeze({});
8170
+ /**
8171
+ * LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
8172
+ * by expr"). The cache stores BOTH successes and failures (negative caching),
8173
+ * so a corrupt persisted string costs exactly one tokenize+parse total — not
8174
+ * one per read on a hot resolve path.
8175
+ *
8176
+ * The cache is a module-level singleton: entries are pure, content-addressed
8177
+ * ASTs keyed by the raw source string, so sharing one instance across all
8178
+ * callers is safe and maximises hit rate.
8179
+ */
8180
+ var cache = /* @__PURE__ */ new Map();
8181
+ function getCached(source) {
8182
+ const hit = cache.get(source);
8183
+ if (hit !== void 0) {
8184
+ cache.delete(source);
8185
+ cache.set(source, hit);
8186
+ return hit;
8187
+ }
8188
+ let result;
8189
+ try {
8190
+ result = {
8191
+ ok: true,
8192
+ parsed: parseExpression(source)
8193
+ };
8194
+ } catch (err) {
8195
+ result = {
8196
+ ok: false,
8197
+ error: err instanceof ExpressionParseError ? err.message : String(err)
8198
+ };
8199
+ }
8200
+ cache.set(source, result);
8201
+ if (cache.size > 256) {
8202
+ const oldest = cache.keys().next().value;
8203
+ if (oldest !== void 0) cache.delete(oldest);
8204
+ }
8205
+ return result;
8206
+ }
8207
+ /** Compile `source`, returning a discriminated result instead of throwing.
8208
+ * Used by read paths that must degrade rather than raise. LRU/negative-cached. */
8209
+ function compileExpressionSafe(source) {
8210
+ return getCached(source);
8211
+ }
8212
+ /**
8213
+ * Author-time validation. Returns `null` when the source is valid, else a
8214
+ * human-readable error message. Checks: the expression compiles; binding count
8215
+ * is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
8216
+ * is not reserved (`now`/keywords) and does not shadow a builtin; and every
8217
+ * FREE identifier of the AST is covered by a binding or the injected `now`.
8218
+ */
8219
+ function validateExpressionSource(src) {
8220
+ const names = Object.keys(src.bindings);
8221
+ if (names.length > 32) return `too many bindings (${names.length} > 32)`;
8222
+ for (const name of names) {
8223
+ if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
8224
+ if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
8225
+ if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
8226
+ }
8227
+ const compiled = compileExpressionSafe(src.expr);
8228
+ if (!compiled.ok) return compiled.error;
8229
+ const bound = new Set(names);
8230
+ for (const id of compiled.parsed.identifiers) {
8231
+ if (id === "now") continue;
8232
+ if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
8233
+ }
8234
+ return null;
8235
+ }
8236
+ /**
7472
8237
  * Accessory device helpers — shared across drivers.
7473
8238
  *
7474
8239
  * Many vendor-specific drivers register accessory child devices on
@@ -8313,7 +9078,13 @@ onStatusChanged: { data: object({
8313
9078
  }) } },
8314
9079
  status: {
8315
9080
  schema: BatteryStatusSchema,
8316
- kind: "push"
9081
+ kind: "push",
9082
+ empty: {
9083
+ percentage: 0,
9084
+ charging: "none",
9085
+ sleeping: false,
9086
+ lastUpdated: 0
9087
+ }
8317
9088
  },
8318
9089
  /**
8319
9090
  * Runtime-state slice — every provider that registers this cap
@@ -9256,21 +10027,38 @@ var connectivityCapability = {
9256
10027
  },
9257
10028
  runtimeState: ConnectivityStatusSchema
9258
10029
  };
10030
+ /**
10031
+ * Generic device-consumables capability — surfaces a device's
10032
+ * maintenance items (vacuum filters/brushes, replaceable cartridges,
10033
+ * descaling cycles, …) with their remaining life and an optional
10034
+ * "Replaced" reset action. Device-agnostic: any provider that knows its
10035
+ * device tracks consumables can register it; the cap declares no
10036
+ * vocabulary of its own — the provider names each item verbatim.
10037
+ *
10038
+ * Like `childLayout`, the cap is INERT until a provider sets items: no
10039
+ * provider populates it by guessing (no HA inference). The UI renders a
10040
+ * "No consumables reported" placeholder when `items` is empty.
10041
+ */
10042
+ /** A single consumable item. Either a continuous `level` (remaining
10043
+ * life %) or a discrete `status` may be known — both may be null when a
10044
+ * provider only knows the item exists. `level` and `status` are not
10045
+ * mutually exclusive; a provider may report both. */
10046
+ var ConsumableItemSchema = object({
10047
+ /** Stable id, e.g. 'main-brush'. */
10048
+ key: string().min(1),
10049
+ /** Display name. */
10050
+ label: string().min(1),
10051
+ /** Remaining life % when known (0..100). */
10052
+ level: number().min(0).max(100).nullable(),
10053
+ /** Discrete state when known (binary mode). */
10054
+ status: _enum(["ok", "replace"]).nullable(),
10055
+ /** Ms epoch of the last replace, when known. */
10056
+ lastResetAt: number().nullable(),
10057
+ /** Whether `reset()` is meaningful for this item. */
10058
+ resettable: boolean()
10059
+ });
9259
10060
  var ConsumablesStatusSchema = object({
9260
- items: array(object({
9261
- /** Stable id, e.g. 'main-brush'. */
9262
- key: string().min(1),
9263
- /** Display name. */
9264
- label: string().min(1),
9265
- /** Remaining life % when known (0..100). */
9266
- level: number().min(0).max(100).nullable(),
9267
- /** Discrete state when known (binary mode). */
9268
- status: _enum(["ok", "replace"]).nullable(),
9269
- /** Ms epoch of the last replace, when known. */
9270
- lastResetAt: number().nullable(),
9271
- /** Whether `reset()` is meaningful for this item. */
9272
- resettable: boolean()
9273
- })),
10061
+ items: array(ConsumableItemSchema),
9274
10062
  lastChangedAt: number()
9275
10063
  });
9276
10064
  var consumablesCapability = {
@@ -9329,7 +10117,25 @@ reset: method(object({
9329
10117
  }) },
9330
10118
  status: {
9331
10119
  schema: ConsumablesStatusSchema,
9332
- kind: "push"
10120
+ kind: "push",
10121
+ empty: {
10122
+ items: [],
10123
+ lastChangedAt: 0
10124
+ },
10125
+ itemArray: {
10126
+ path: "items",
10127
+ keyField: "key",
10128
+ labelField: "label",
10129
+ itemSchema: ConsumableItemSchema,
10130
+ emptyItem: {
10131
+ key: "",
10132
+ label: "",
10133
+ level: null,
10134
+ status: null,
10135
+ lastResetAt: null,
10136
+ resettable: false
10137
+ }
10138
+ }
9333
10139
  },
9334
10140
  runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() })
9335
10141
  };
@@ -10571,7 +11377,8 @@ var MotionAnalysisResultSchema = object({
10571
11377
  });
10572
11378
  method(object({
10573
11379
  deviceId: number(),
10574
- frame: FrameInputSchema
11380
+ frame: FrameInputSchema.optional(),
11381
+ frameHandle: FrameHandleSchema.optional()
10575
11382
  }), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
10576
11383
  deviceId: number(),
10577
11384
  detected: boolean(),
@@ -10818,6 +11625,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
10818
11625
  engine: PipelineEngineChoiceSchema.optional(),
10819
11626
  steps: array(PipelineStepInputSchema).min(1),
10820
11627
  frame: FrameInputSchema.optional(),
11628
+ /**
11629
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
11630
+ * the decoded pixels live in. One more member of the one-of
11631
+ * frame/frameHandle/image/imageBase64/referenceImage group.
11632
+ */
11633
+ frameHandle: FrameHandleSchema.optional(),
10821
11634
  imageBase64: string().optional(),
10822
11635
  /**
10823
11636
  * Binary JPEG bytes — preferred over `imageBase64` on internal
@@ -11060,6 +11873,31 @@ var ReportMotionInputSchema = object({
11060
11873
  regions: array(MotionRegionSchema).readonly().optional()
11061
11874
  });
11062
11875
  /**
11876
+ * Where a runner gets a camera's decoded frames (cross-node Phase 2,
11877
+ * restream-owner model — P2c).
11878
+ *
11879
+ * - `local-broker` (DEFAULT): today's path — subscribe to the co-located
11880
+ * stream-broker's shm frame plane. Every pre-P2c attach payload (no
11881
+ * `frameSource` key) parses to this, so the field is additive with zero
11882
+ * behavior change.
11883
+ * - `remote-restream`: the detect node is NOT the camera's source-owner.
11884
+ * The runner acquires the owner's COMPRESSED passthrough restream
11885
+ * (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
11886
+ * double-pull guard) and decodes LOCALLY via a satellite frame plane +
11887
+ * pull-mode decoder session pinned to its own node. The shm ring stays
11888
+ * node-local; only H.264/H.265 packets cross the wire.
11889
+ * `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
11890
+ * when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
11891
+ * dials for the owner's restream.
11892
+ */
11893
+ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
11894
+ kind: literal("remote-restream"),
11895
+ /** The camera's source-owner node (slice 1: always the hub). */
11896
+ ownerNodeId: string(),
11897
+ /** Operator override for the owner host the runner dials. */
11898
+ hubHostnameOverride: string().optional()
11899
+ })]).describe("Per-camera frame-source mode for the runner (P2c)");
11900
+ /**
11063
11901
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
11064
11902
  * specific runner instance via `attachCamera`. Carries everything the
11065
11903
  * runner needs to subscribe to the local broker and execute inference.
@@ -11157,7 +11995,15 @@ var RunnerCameraConfigSchema = object({
11157
11995
  */
11158
11996
  onboardMotionDrivesAnalyzer: boolean().default(true),
11159
11997
  occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
11160
- occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
11998
+ occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
11999
+ /**
12000
+ * Where this runner gets the camera's decoded frames (P2c). Defaulted so
12001
+ * every existing payload behaves as `local-broker` — the pre-Phase-2 path.
12002
+ * Populated with `remote-restream` by the orchestrator ONLY when the
12003
+ * camera's detect node differs from its source-owner (P2d, gated by the
12004
+ * `remoteSourcingNodes` rollout setting).
12005
+ */
12006
+ frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
11161
12007
  });
11162
12008
  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;
11163
12009
  /**
@@ -11721,6 +12567,157 @@ var numericSensorCapability = {
11721
12567
  runtimeState: NumericSensorStatusSchema
11722
12568
  };
11723
12569
  /**
12570
+ * Feeder connectivity / power status — mirrors the HA petkit device-status
12571
+ * enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
12572
+ * `on_batteries` (running on battery backup). `null` until first reported.
12573
+ */
12574
+ var PetFeederDeviceStatusSchema = _enum([
12575
+ "normal",
12576
+ "offline",
12577
+ "on_batteries"
12578
+ ]);
12579
+ var gramsPortion = number().int().min(4).max(200);
12580
+ var PetFeederStatusSchema = object({
12581
+ /** Food currently in the bowl (grams). Null when the device has not
12582
+ * reported a reading yet. On dual-hopper models this is the combined
12583
+ * bowl reading; per-hopper levels live in `food1`/`food2`. */
12584
+ foodLevel: number().nullable(),
12585
+ /** Hopper-1 food level (grams) on dual-hopper feeders; null on
12586
+ * single-hopper models. */
12587
+ food1: number().nullable(),
12588
+ /** Hopper-2 food level (grams) on dual-hopper feeders; null on
12589
+ * single-hopper models. */
12590
+ food2: number().nullable(),
12591
+ /** Derived low-food flag — mirrors the HA `food_level` binary_sensor
12592
+ * (`device_class: problem`, on = low). True when the bowl is empty /
12593
+ * below the feeder's low threshold. */
12594
+ lowFood: boolean(),
12595
+ /** Battery charge 0..100 (%). Null on mains-powered models or when the
12596
+ * device has no battery reading. */
12597
+ batteryPower: number().min(0).max(100).nullable(),
12598
+ /** Days of desiccant life remaining. Null when the model has no
12599
+ * desiccant sensor. */
12600
+ desiccantLeftDays: number().nullable(),
12601
+ /** True while a feed is in progress. */
12602
+ feeding: boolean(),
12603
+ /** Decoded connectivity / power status (HA petkit device-status enum).
12604
+ * Null until the device has reported a status. */
12605
+ status: PetFeederDeviceStatusSchema.nullable(),
12606
+ /** Decoded human-readable fault message. Null (or the device's `no_error`
12607
+ * sentinel) means healthy; a non-null string is an active fault. Pairs
12608
+ * with `errorCode` for consumers that want the raw integer. */
12609
+ error: string().nullable(),
12610
+ /** Raw device error code (0 / null = no error). */
12611
+ errorCode: number().nullable(),
12612
+ /** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
12613
+ isDualHopper: boolean(),
12614
+ /** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
12615
+ childLock: boolean(),
12616
+ /** Front indicator-light setting. */
12617
+ indicatorLight: boolean(),
12618
+ /** Play a chime when dispensing. */
12619
+ feedSound: boolean(),
12620
+ /** Speaker / prompt volume level (device-scaled integer). */
12621
+ volume: number(),
12622
+ /** Ms epoch when the slice was last refreshed from the cloud. */
12623
+ lastFetchedAt: number()
12624
+ });
12625
+ var petFeederCapability = {
12626
+ name: "pet-feeder",
12627
+ scope: "device",
12628
+ deviceNative: true,
12629
+ mode: "singleton",
12630
+ deviceTypes: [DeviceType.PetFeeder],
12631
+ methods: {
12632
+ /**
12633
+ * Dispense food now. Single-hopper feeders take `grams`; dual-hopper
12634
+ * feeders (D4S/D4SH) accept `hopper1`/`hopper2` to target one or both
12635
+ * hoppers. All portions honour the 4–200 g hardware range. At least
12636
+ * one of the three must be present — the provider rejects an empty
12637
+ * request.
12638
+ */
12639
+ feed: method(object({
12640
+ deviceId: number().int().nonnegative(),
12641
+ grams: gramsPortion.optional(),
12642
+ hopper1: gramsPortion.optional(),
12643
+ hopper2: gramsPortion.optional()
12644
+ }), _void(), {
12645
+ kind: "mutation",
12646
+ auth: "admin"
12647
+ }),
12648
+ /** Cancel an in-progress manual feed. */
12649
+ cancelFeed: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12650
+ kind: "mutation",
12651
+ auth: "admin"
12652
+ }),
12653
+ /** Reset the desiccant "days remaining" counter after replacing it. */
12654
+ resetDesiccant: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12655
+ kind: "mutation",
12656
+ auth: "admin"
12657
+ }),
12658
+ /** Mark a hopper as refilled (D4H/D4S/D4SH). */
12659
+ markFoodReplenished: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12660
+ kind: "mutation",
12661
+ auth: "admin"
12662
+ }),
12663
+ /** Call the pet with the recorded prompt (D3). */
12664
+ callPet: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12665
+ kind: "mutation",
12666
+ auth: "admin"
12667
+ }),
12668
+ /** Play a stored sound by id (D3 / D4H / D4SH). */
12669
+ playSound: method(object({
12670
+ deviceId: number().int().nonnegative(),
12671
+ soundId: number().int().nonnegative()
12672
+ }), _void(), {
12673
+ kind: "mutation",
12674
+ auth: "admin"
12675
+ }),
12676
+ /** Toggle the child-lock (manual-lock) setting. */
12677
+ setChildLock: method(object({
12678
+ deviceId: number().int().nonnegative(),
12679
+ on: boolean()
12680
+ }), _void(), {
12681
+ kind: "mutation",
12682
+ auth: "admin"
12683
+ }),
12684
+ /** Toggle the front indicator light. */
12685
+ setIndicatorLight: method(object({
12686
+ deviceId: number().int().nonnegative(),
12687
+ on: boolean()
12688
+ }), _void(), {
12689
+ kind: "mutation",
12690
+ auth: "admin"
12691
+ }),
12692
+ /** Toggle the dispense chime. */
12693
+ setFeedSound: method(object({
12694
+ deviceId: number().int().nonnegative(),
12695
+ on: boolean()
12696
+ }), _void(), {
12697
+ kind: "mutation",
12698
+ auth: "admin"
12699
+ }),
12700
+ /** Set the speaker / prompt volume level. */
12701
+ setVolume: method(object({
12702
+ deviceId: number().int().nonnegative(),
12703
+ level: number().int().nonnegative()
12704
+ }), _void(), {
12705
+ kind: "mutation",
12706
+ auth: "admin"
12707
+ })
12708
+ },
12709
+ status: {
12710
+ schema: PetFeederStatusSchema,
12711
+ kind: "poll"
12712
+ },
12713
+ /**
12714
+ * Runtime-state slice — mirrored by the kernel. UI feeder cards read
12715
+ * the full slice via `device.state.petFeeder.value` and refresh on
12716
+ * every poll without re-querying the provider.
12717
+ */
12718
+ runtimeState: PetFeederStatusSchema
12719
+ };
12720
+ /**
11724
12721
  * Multi-metric electrical meter. One slice can carry any combination
11725
12722
  * of instantaneous power (W), cumulative energy (kWh), voltage (V),
11726
12723
  * and current (A) — all fields optional so a single-metric source
@@ -13023,6 +14020,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
13023
14020
  nativeObjectDetection: nativeObjectDetectionCapability,
13024
14021
  notifier: notifierCapability,
13025
14022
  numericSensor: numericSensorCapability,
14023
+ petFeeder: petFeederCapability,
13026
14024
  powerMeter: powerMeterCapability,
13027
14025
  presence: presenceCapability,
13028
14026
  pressureSensor: pressureSensorCapability,
@@ -14939,10 +15937,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
14939
15937
  url: string()
14940
15938
  }), _void()), method(object({
14941
15939
  sessionId: string(),
14942
- maxCount: number().default(1)
15940
+ maxCount: number().default(1),
15941
+ waitMs: number().optional()
14943
15942
  }), array(DecodedFrameSchema)), method(object({
14944
15943
  sessionId: string(),
14945
- maxCount: number().default(1)
15944
+ maxCount: number().default(1),
15945
+ waitMs: number().optional()
14946
15946
  }), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
14947
15947
  sessionId: string(),
14948
15948
  config: DecoderSessionConfigSchema.partial()
@@ -15229,14 +16229,63 @@ var ChildLayoutEntrySchema = object({
15229
16229
  collapsed: boolean().optional()
15230
16230
  });
15231
16231
  /** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
15232
- * `device-management.ts`. */
16232
+ * `device-management.ts`. Source is a union: a FIELD source copies a sibling
16233
+ * accessory's status field (`kind` optional/absent for wire compat); a
16234
+ * LITERAL source carries a per-device constant (no sibling is read); a
16235
+ * GLOBAL source (P2e) copies ANY device's status field, addressed by the
16236
+ * source device's full re-sync-stable `stableId`. */
16237
+ var DeviceLinkFieldSourceSchema = object({
16238
+ kind: literal("field").optional(),
16239
+ sourceKey: string(),
16240
+ cap: string(),
16241
+ fieldPath: string()
16242
+ });
16243
+ var DeviceLinkLiteralSourceSchema = object({
16244
+ kind: literal("literal"),
16245
+ value: union([
16246
+ string(),
16247
+ number(),
16248
+ boolean(),
16249
+ _null()
16250
+ ])
16251
+ });
16252
+ var DeviceLinkGlobalSourceSchema = object({
16253
+ kind: literal("global"),
16254
+ sourceStableId: string(),
16255
+ cap: string(),
16256
+ fieldPath: string()
16257
+ });
16258
+ /** Expression source (Stage X): compute the target field from N named bindings
16259
+ * via the safe expression engine. Bindings are field | literal | global — never
16260
+ * another expression (no nesting). The `superRefine` runs the SAME author-time
16261
+ * validation as `validateExpressionSource` (compiles the expr, checks binding
16262
+ * names + identifier coverage) so every wire boundary that parses a DeviceLink
16263
+ * (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
16264
+ * Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
16265
+ var DeviceLinkExpressionSourceSchema = object({
16266
+ kind: literal("expression"),
16267
+ expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
16268
+ bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
16269
+ DeviceLinkFieldSourceSchema,
16270
+ DeviceLinkLiteralSourceSchema,
16271
+ DeviceLinkGlobalSourceSchema
16272
+ ]))
16273
+ }).superRefine((src, ctx) => {
16274
+ const err = validateExpressionSource(src);
16275
+ if (err !== null) ctx.addIssue({
16276
+ code: "custom",
16277
+ message: err,
16278
+ path: ["expr"]
16279
+ });
16280
+ });
15233
16281
  var DeviceLinkSchema = object({
15234
16282
  id: string(),
15235
- source: object({
15236
- sourceKey: string(),
15237
- cap: string(),
15238
- fieldPath: string()
15239
- }),
16283
+ source: union([
16284
+ DeviceLinkFieldSourceSchema,
16285
+ DeviceLinkLiteralSourceSchema,
16286
+ DeviceLinkGlobalSourceSchema,
16287
+ DeviceLinkExpressionSourceSchema
16288
+ ]),
15240
16289
  target: object({
15241
16290
  cap: string(),
15242
16291
  fieldPath: string(),
@@ -15265,6 +16314,31 @@ var DeviceLinkSchema = object({
15265
16314
  })
15266
16315
  ]).optional()
15267
16316
  });
16317
+ /** Cap-wire shape of a per-cap display refinement — mirrors
16318
+ * `DeviceCapDisplayOverride` in `device-management.ts`. */
16319
+ var DeviceCapDisplayOverrideSchema = object({
16320
+ unit: string().min(1).optional(),
16321
+ precision: number().int().min(0).max(10).optional()
16322
+ });
16323
+ /** Cap-wire shape of an operator-authored per-device display override —
16324
+ * mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
16325
+ * bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
16326
+ var DeviceDisplayOverrideSchema = object({
16327
+ icon: string().min(1).optional(),
16328
+ label: string().min(1).optional(),
16329
+ unit: string().min(1).optional(),
16330
+ precision: number().int().min(0).max(10).optional(),
16331
+ hidden: boolean().optional(),
16332
+ perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
16333
+ });
16334
+ /** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
16335
+ * in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
16336
+ * the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
16337
+ var RoleDisplayDefaultSchema = object({
16338
+ unit: string().min(1).optional(),
16339
+ precision: number().int().min(0).max(10).optional(),
16340
+ icon: string().min(1).optional()
16341
+ });
15268
16342
  /**
15269
16343
  * Serializable projection of a live IDevice.
15270
16344
  * Returned by listAll, getDevice, getChildren.
@@ -15320,7 +16394,9 @@ var DeviceInfoSchema = object({
15320
16394
  * `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
15321
16395
  childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
15322
16396
  /** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
15323
- deviceLinks: array(DeviceLinkSchema).readonly().optional()
16397
+ deviceLinks: array(DeviceLinkSchema).readonly().optional(),
16398
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
16399
+ display: DeviceDisplayOverrideSchema.optional()
15324
16400
  });
15325
16401
  var ConfigEntrySchema = object({
15326
16402
  key: string(),
@@ -15385,7 +16461,9 @@ var DeviceMetaSchema = object({
15385
16461
  deviceLinks: array(DeviceLinkSchema).readonly().optional(),
15386
16462
  /** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
15387
16463
  * Optional: only present for accessory children that carry a known role. */
15388
- role: string().nullable().optional()
16464
+ role: string().nullable().optional(),
16465
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
16466
+ display: DeviceDisplayOverrideSchema.optional()
15389
16467
  });
15390
16468
  /** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
15391
16469
  var ConfigUISchemaOutput = unknown().nullable();
@@ -15479,7 +16557,19 @@ method(object({
15479
16557
  }), _void(), {
15480
16558
  kind: "mutation",
15481
16559
  auth: "admin"
15482
- }), method(object({ deviceId: number() }), object({ caps: array(object({
16560
+ }), method(object({
16561
+ deviceId: number(),
16562
+ display: DeviceDisplayOverrideSchema.nullable()
16563
+ }), _void(), {
16564
+ kind: "mutation",
16565
+ auth: "admin"
16566
+ }), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
16567
+ kind: "mutation",
16568
+ auth: "admin"
16569
+ }), method(object({
16570
+ deviceId: number(),
16571
+ includeSynthesizable: boolean().optional()
16572
+ }), object({ caps: array(object({
15483
16573
  cap: string(),
15484
16574
  fields: array(object({
15485
16575
  path: string(),
@@ -15489,8 +16579,13 @@ method(object({
15489
16579
  "boolean",
15490
16580
  "enum"
15491
16581
  ]),
15492
- enumValues: array(string()).optional()
15493
- })).readonly()
16582
+ enumValues: array(string()).optional(),
16583
+ item: boolean().optional()
16584
+ })).readonly(),
16585
+ itemArray: object({
16586
+ path: string(),
16587
+ keyField: string()
16588
+ }).optional()
15494
16589
  })).readonly() }), { kind: "query" }), method(object({
15495
16590
  deviceId: number(),
15496
16591
  role: string().nullable()
@@ -15560,7 +16655,11 @@ method(object({
15560
16655
  deviceId: number(),
15561
16656
  entries: array(object({
15562
16657
  capName: string(),
15563
- kind: _enum(["native", "wrapped"]),
16658
+ kind: _enum([
16659
+ "native",
16660
+ "wrapped",
16661
+ "linked"
16662
+ ]),
15564
16663
  providerAddonId: string(),
15565
16664
  providerNodeId: string(),
15566
16665
  nativeAddonId: string()
@@ -15569,7 +16668,11 @@ method(object({
15569
16668
  deviceId: number(),
15570
16669
  entries: array(object({
15571
16670
  capName: string(),
15572
- kind: _enum(["native", "wrapped"]),
16671
+ kind: _enum([
16672
+ "native",
16673
+ "wrapped",
16674
+ "linked"
16675
+ ]),
15573
16676
  providerAddonId: string(),
15574
16677
  providerNodeId: string(),
15575
16678
  nativeAddonId: string()
@@ -16059,7 +17162,7 @@ var AddBrokerInputSchema = object({
16059
17162
  });
16060
17163
  var AddBrokerResultSchema = object({ id: string() });
16061
17164
  var IdInputSchema = object({ id: string() });
16062
- var TestResultSchema = discriminatedUnion("ok", [object({
17165
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
16063
17166
  ok: literal(true),
16064
17167
  latencyMs: number()
16065
17168
  }), object({
@@ -16082,7 +17185,7 @@ var StatusSchema = object({
16082
17185
  brokerCount: number(),
16083
17186
  embeddedRunning: boolean()
16084
17187
  });
16085
- 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);
17188
+ 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);
16086
17189
  var NetworkEndpointSchema = object({
16087
17190
  url: string(),
16088
17191
  hostname: string(),
@@ -16116,23 +17219,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16116
17219
  sourcePort: number().optional()
16117
17220
  });
16118
17221
  method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16119
- method(object({
16120
- title: string(),
17222
+ /**
17223
+ * notification-output — canonical, capability-gated notification delivery.
17224
+ *
17225
+ * Apprise-derived model (see
17226
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
17227
+ * callers emit ONE canonical `Notification`; each provider declares a
17228
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
17229
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
17230
+ * message to what the kind supports — callers never special-case a service.
17231
+ *
17232
+ * DESIGN DECISIONS (locked):
17233
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
17234
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
17235
+ * cap. Rationale: the admin UI needs one uniform surface across the
17236
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
17237
+ * alternative would fork the UI per addon and cannot host the
17238
+ * discovery→adopt flow.
17239
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
17240
+ * the generated cap-mount auto-`concatCollection`-fans them across every
17241
+ * registered provider (notifiers addon + HA addon) so one catalog is
17242
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
17243
+ * `addonId` the generated collection router extracts from the call input.
17244
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
17245
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
17246
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
17247
+ * base64 fallback needed.
17248
+ *
17249
+ * TODO (deferred, closed-set change — separate decision): add
17250
+ * `providerKind: 'notify'` so notification providers surface on the unified
17251
+ * admin "Integrations" page.
17252
+ */
17253
+ /**
17254
+ * Zentik-derived typed-media enum — the superset across every kind. Each
17255
+ * adapter picks what it supports and the degrade engine filters the rest.
17256
+ */
17257
+ var AttachmentMediaTypeSchema = _enum([
17258
+ "image",
17259
+ "video",
17260
+ "gif",
17261
+ "audio",
17262
+ "icon"
17263
+ ]);
17264
+ /**
17265
+ * A single attachment. Exactly one of `url` (remote source, most adapters
17266
+ * prefer this) or `bytes` (inline source; required for Pushover-style
17267
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
17268
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
17269
+ */
17270
+ var AttachmentSchema = object({
17271
+ mediaType: AttachmentMediaTypeSchema,
17272
+ url: string().optional(),
17273
+ bytes: _instanceof(Uint8Array).optional(),
17274
+ mime: string().optional(),
17275
+ name: string().optional()
17276
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
17277
+ var NotificationFormatSchema = _enum([
17278
+ "text",
17279
+ "markdown",
17280
+ "html"
17281
+ ]);
17282
+ /** A single tap-through action button. */
17283
+ var NotificationActionSchema = object({
17284
+ id: string(),
17285
+ label: string(),
17286
+ url: string().optional()
17287
+ });
17288
+ /**
17289
+ * The canonical notification. `body` is the only hard field (Apprise model).
17290
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
17291
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
17292
+ * the adapter maps this ordinal onto its native level. `level?` is an
17293
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
17294
+ * `priority` for that one target.
17295
+ */
17296
+ var NotificationSchema = object({
16121
17297
  body: string(),
16122
- imageUrl: string().optional(),
17298
+ title: string().optional(),
17299
+ format: NotificationFormatSchema.default("text"),
17300
+ priority: number().int().min(1).max(5).default(3),
17301
+ level: string().optional(),
17302
+ attachments: array(AttachmentSchema).optional(),
17303
+ clickUrl: string().optional(),
17304
+ actions: array(NotificationActionSchema).optional(),
17305
+ sound: string().optional(),
17306
+ ttl: number().optional(),
17307
+ tag: string().optional(),
16123
17308
  deviceId: number().optional(),
16124
17309
  eventId: string().optional(),
16125
- priority: _enum([
16126
- "low",
16127
- "normal",
16128
- "high",
16129
- "critical"
16130
- ]).default("normal"),
16131
17310
  metadata: record(string(), unknown()).optional()
16132
- }), _void(), { kind: "mutation" }), method(_void(), object({
17311
+ });
17312
+ /** One declared native severity/priority level for a kind. */
17313
+ var TargetKindLevelSchema = object({
17314
+ id: string(),
17315
+ label: string(),
17316
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
17317
+ ordinal: number().int().min(1).max(5).nullable(),
17318
+ flags: object({
17319
+ critical: boolean().optional(),
17320
+ silent: boolean().optional(),
17321
+ noPush: boolean().optional()
17322
+ }).optional(),
17323
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
17324
+ requires: array(string()).optional(),
17325
+ description: string().optional()
17326
+ });
17327
+ /** The full capability block consulted before dispatch. */
17328
+ var TargetKindCapsSchema = object({
17329
+ attachments: object({
17330
+ mediaTypes: array(AttachmentMediaTypeSchema),
17331
+ mode: _enum([
17332
+ "url",
17333
+ "bytes",
17334
+ "both"
17335
+ ]),
17336
+ max: number().int().nonnegative(),
17337
+ maxBytes: number().int().positive().optional()
17338
+ }),
17339
+ /** Max action buttons (0 = none). */
17340
+ actions: number().int().nonnegative(),
17341
+ levels: array(TargetKindLevelSchema),
17342
+ format: array(NotificationFormatSchema),
17343
+ clickUrl: boolean(),
17344
+ sound: boolean(),
17345
+ ttl: boolean(),
17346
+ bodyMaxLen: number().int().positive()
17347
+ });
17348
+ /**
17349
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
17350
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
17351
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
17352
+ * the union is large and not meant for runtime validation here; the exported
17353
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
17354
+ */
17355
+ var ConfigSchemaPassthrough = unknown();
17356
+ var TargetKindSchema = object({
17357
+ kind: string(),
17358
+ label: string(),
17359
+ icon: string(),
17360
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
17361
+ addonId: string(),
17362
+ configSchema: ConfigSchemaPassthrough,
17363
+ supportsDiscovery: boolean(),
17364
+ caps: TargetKindCapsSchema
17365
+ });
17366
+ /**
17367
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
17368
+ * (return a presence marker only) when serving `listTargets` — never
17369
+ * round-trip a stored secret to the UI.
17370
+ */
17371
+ var TargetSchema = object({
17372
+ id: string(),
17373
+ name: string(),
17374
+ kind: string(),
17375
+ addonId: string(),
17376
+ enabled: boolean(),
17377
+ config: record(string(), unknown())
17378
+ });
17379
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
17380
+ var DiscoveredTargetSchema = object({
17381
+ kind: string(),
17382
+ suggestedName: string(),
17383
+ config: record(string(), unknown())
17384
+ });
17385
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
17386
+ var RenderedAsSchema = object({
17387
+ level: string(),
17388
+ format: NotificationFormatSchema,
17389
+ attachmentsSent: number().int().nonnegative(),
17390
+ actionsSent: number().int().nonnegative(),
17391
+ truncated: boolean(),
17392
+ dropped: array(string())
17393
+ });
17394
+ var SendResultSchema = object({
16133
17395
  success: boolean(),
16134
- error: string().optional()
16135
- }), { kind: "mutation" });
17396
+ error: string().optional(),
17397
+ renderedAs: RenderedAsSchema.optional()
17398
+ });
17399
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
17400
+ var TestResultSchema = SendResultSchema;
17401
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
17402
+ kind: string(),
17403
+ config: record(string(), unknown()).optional()
17404
+ }), array(DiscoveredTargetSchema)), method(object({
17405
+ targetId: string(),
17406
+ notification: NotificationSchema
17407
+ }), SendResultSchema, { kind: "mutation" }), method(object({
17408
+ targetId: string(),
17409
+ sample: NotificationSchema.optional()
17410
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
17411
+ targetId: string(),
17412
+ enabled: boolean()
17413
+ }), _void(), { kind: "mutation" });
16136
17414
  /**
16137
17415
  * Zod schemas for persisted record types.
16138
17416
  *
@@ -16636,7 +17914,10 @@ var AgentLoadSummarySchema = object({
16636
17914
  online: boolean(),
16637
17915
  load: RunnerLocalLoadSchema,
16638
17916
  /** Computed score used by the L2 capacity balancer (lower = less loaded). */
16639
- score: number()
17917
+ score: number(),
17918
+ /** This node's decode hwaccel backend (per-node `probedBestHwaccel`), or null
17919
+ * when not yet probed — for the cluster Pipeline table UI (P0.2). */
17920
+ decodeHwaccel: string().nullable()
16640
17921
  });
16641
17922
  /**
16642
17923
  * Aggregate metrics across the whole detection cluster. Replaces the legacy
@@ -19197,7 +20478,10 @@ var HwAccelBackendInputSchema = _enum([
19197
20478
  "webgpu",
19198
20479
  "none"
19199
20480
  ]).nullable().optional();
19200
- var HwAccelResolutionSchema = object({ preferred: array(string()).readonly() });
20481
+ var HwAccelResolutionSchema = object({
20482
+ preferred: array(string()).readonly(),
20483
+ rationale: string()
20484
+ });
19201
20485
  var HardwareEncoderIdSchema = _enum([
19202
20486
  "h264_videotoolbox",
19203
20487
  "hevc_videotoolbox",
@@ -19212,7 +20496,7 @@ var HardwareEncoderIdSchema = _enum([
19212
20496
  "libx264",
19213
20497
  "libx265"
19214
20498
  ]);
19215
- var HardwareEncodersSchema = object({
20499
+ object({
19216
20500
  encoders: array(object({
19217
20501
  encoder: HardwareEncoderIdSchema,
19218
20502
  codec: _enum(["H264", "H265"]),
@@ -19231,15 +20515,7 @@ var HardwareEncodersSchema = object({
19231
20515
  defaultH265: HardwareEncoderIdSchema,
19232
20516
  probedAt: number()
19233
20517
  });
19234
- /**
19235
- * Decode-side companion to {@link HardwareEncodersSchema}: the `-hwaccel`
19236
- * methods the configured ffmpeg binary actually supports (parsed from
19237
- * `ffmpeg -hwaccels`). Used to gate decode-hwaccel attempts so the transcode
19238
- * egress never spends a spawn on a backend this build cannot offer. Per-stream
19239
- * decode fragility (e.g. VideoToolbox HEVC) is still handled by the egress's
19240
- * software fallback — this only filters out wholly-unsupported backends.
19241
- */
19242
- var HardwareDecodeAccelsSchema = object({
20518
+ object({
19243
20519
  methods: array(string()).readonly(),
19244
20520
  probedAt: number()
19245
20521
  });
@@ -19302,16 +20578,7 @@ var ResolvedInferenceConfigSchema = object({
19302
20578
  format: ModelFormatSchema,
19303
20579
  reason: string()
19304
20580
  });
19305
- method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
19306
- prefer: HwAccelBackendInputSchema,
19307
- nodeId: string().optional()
19308
- }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
19309
- kind: "mutation",
19310
- auth: "admin"
19311
- }), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
19312
- kind: "mutation",
19313
- auth: "admin"
19314
- });
20581
+ method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema);
19315
20582
  var PtzPresetSchema = object({
19316
20583
  id: string(),
19317
20584
  name: string()
@@ -19364,6 +20631,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
19364
20631
  kind: "mutation",
19365
20632
  auth: "admin"
19366
20633
  });
20634
+ /**
20635
+ * `recording` cap — footage availability + HLS playback manifests + per-device
20636
+ * recording config. NOTE on events (source of truth, R5/C3): this cap carries
20637
+ * NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
20638
+ * events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
20639
+ * rows); the recorder's internal EventMap markers are ephemeral in-RAM
20640
+ * annotations that are not exposed here and must not be treated as an event
20641
+ * feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
20642
+ * (`interfaces/recording-config.ts`).
20643
+ */
19367
20644
  var RecordingStatusSchema = object({
19368
20645
  deviceId: number(),
19369
20646
  enabled: boolean(),
@@ -21013,6 +22290,12 @@ Object.freeze({
21013
22290
  addonId: null,
21014
22291
  access: "view"
21015
22292
  },
22293
+ "deviceManager.getRoleDisplayDefaults": {
22294
+ capName: "device-manager",
22295
+ capScope: "system",
22296
+ addonId: null,
22297
+ access: "view"
22298
+ },
21016
22299
  "deviceManager.getSettingsSchema": {
21017
22300
  capName: "device-manager",
21018
22301
  capScope: "system",
@@ -21163,6 +22446,12 @@ Object.freeze({
21163
22446
  addonId: null,
21164
22447
  access: "create"
21165
22448
  },
22449
+ "deviceManager.setDisplay": {
22450
+ capName: "device-manager",
22451
+ capScope: "system",
22452
+ addonId: null,
22453
+ access: "create"
22454
+ },
21166
22455
  "deviceManager.setIntegrationId": {
21167
22456
  capName: "device-manager",
21168
22457
  capScope: "system",
@@ -21205,6 +22494,12 @@ Object.freeze({
21205
22494
  addonId: null,
21206
22495
  access: "create"
21207
22496
  },
22497
+ "deviceManager.setRoleDisplayDefaults": {
22498
+ capName: "device-manager",
22499
+ capScope: "system",
22500
+ addonId: null,
22501
+ access: "create"
22502
+ },
21208
22503
  "deviceManager.setStreamProfileMap": {
21209
22504
  capName: "device-manager",
21210
22505
  capScope: "system",
@@ -22183,13 +23478,49 @@ Object.freeze({
22183
23478
  addonId: null,
22184
23479
  access: "create"
22185
23480
  },
23481
+ "notificationOutput.deleteTarget": {
23482
+ capName: "notification-output",
23483
+ capScope: "system",
23484
+ addonId: null,
23485
+ access: "delete"
23486
+ },
23487
+ "notificationOutput.discoverTargets": {
23488
+ capName: "notification-output",
23489
+ capScope: "system",
23490
+ addonId: null,
23491
+ access: "view"
23492
+ },
23493
+ "notificationOutput.listTargetKinds": {
23494
+ capName: "notification-output",
23495
+ capScope: "system",
23496
+ addonId: null,
23497
+ access: "view"
23498
+ },
23499
+ "notificationOutput.listTargets": {
23500
+ capName: "notification-output",
23501
+ capScope: "system",
23502
+ addonId: null,
23503
+ access: "view"
23504
+ },
22186
23505
  "notificationOutput.send": {
22187
23506
  capName: "notification-output",
22188
23507
  capScope: "system",
22189
23508
  addonId: null,
22190
23509
  access: "create"
22191
23510
  },
22192
- "notificationOutput.sendTest": {
23511
+ "notificationOutput.setTargetEnabled": {
23512
+ capName: "notification-output",
23513
+ capScope: "system",
23514
+ addonId: null,
23515
+ access: "create"
23516
+ },
23517
+ "notificationOutput.testTarget": {
23518
+ capName: "notification-output",
23519
+ capScope: "system",
23520
+ addonId: null,
23521
+ access: "create"
23522
+ },
23523
+ "notificationOutput.upsertTarget": {
22193
23524
  capName: "notification-output",
22194
23525
  capScope: "system",
22195
23526
  addonId: null,
@@ -22219,6 +23550,66 @@ Object.freeze({
22219
23550
  addonId: null,
22220
23551
  access: "create"
22221
23552
  },
23553
+ "petFeeder.callPet": {
23554
+ capName: "pet-feeder",
23555
+ capScope: "device",
23556
+ addonId: null,
23557
+ access: "create"
23558
+ },
23559
+ "petFeeder.cancelFeed": {
23560
+ capName: "pet-feeder",
23561
+ capScope: "device",
23562
+ addonId: null,
23563
+ access: "create"
23564
+ },
23565
+ "petFeeder.feed": {
23566
+ capName: "pet-feeder",
23567
+ capScope: "device",
23568
+ addonId: null,
23569
+ access: "create"
23570
+ },
23571
+ "petFeeder.markFoodReplenished": {
23572
+ capName: "pet-feeder",
23573
+ capScope: "device",
23574
+ addonId: null,
23575
+ access: "create"
23576
+ },
23577
+ "petFeeder.playSound": {
23578
+ capName: "pet-feeder",
23579
+ capScope: "device",
23580
+ addonId: null,
23581
+ access: "create"
23582
+ },
23583
+ "petFeeder.resetDesiccant": {
23584
+ capName: "pet-feeder",
23585
+ capScope: "device",
23586
+ addonId: null,
23587
+ access: "delete"
23588
+ },
23589
+ "petFeeder.setChildLock": {
23590
+ capName: "pet-feeder",
23591
+ capScope: "device",
23592
+ addonId: null,
23593
+ access: "create"
23594
+ },
23595
+ "petFeeder.setFeedSound": {
23596
+ capName: "pet-feeder",
23597
+ capScope: "device",
23598
+ addonId: null,
23599
+ access: "create"
23600
+ },
23601
+ "petFeeder.setIndicatorLight": {
23602
+ capName: "pet-feeder",
23603
+ capScope: "device",
23604
+ addonId: null,
23605
+ access: "create"
23606
+ },
23607
+ "petFeeder.setVolume": {
23608
+ capName: "pet-feeder",
23609
+ capScope: "device",
23610
+ addonId: null,
23611
+ access: "create"
23612
+ },
22222
23613
  "pipelineAnalytics.clearTracks": {
22223
23614
  capName: "pipeline-analytics",
22224
23615
  capScope: "device",
@@ -22825,30 +24216,6 @@ Object.freeze({
22825
24216
  addonId: null,
22826
24217
  access: "view"
22827
24218
  },
22828
- "platformProbe.getHardwareDecodeAccels": {
22829
- capName: "platform-probe",
22830
- capScope: "system",
22831
- addonId: null,
22832
- access: "view"
22833
- },
22834
- "platformProbe.getHardwareEncoders": {
22835
- capName: "platform-probe",
22836
- capScope: "system",
22837
- addonId: null,
22838
- access: "view"
22839
- },
22840
- "platformProbe.refreshHardwareDecodeAccels": {
22841
- capName: "platform-probe",
22842
- capScope: "system",
22843
- addonId: null,
22844
- access: "create"
22845
- },
22846
- "platformProbe.refreshHardwareEncoders": {
22847
- capName: "platform-probe",
22848
- capScope: "system",
22849
- addonId: null,
22850
- access: "create"
22851
- },
22852
24219
  "platformProbe.resolveHwAccel": {
22853
24220
  capName: "platform-probe",
22854
24221
  capScope: "system",