@camstack/addon-provider-dreo 0.1.9 → 0.1.10

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 +1463 -61
  2. package/dist/addon.mjs +1463 -61
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -4665,7 +4665,7 @@ function _instanceof(cls, params = {}) {
4665
4665
  return inst;
4666
4666
  }
4667
4667
  //#endregion
4668
- //#region ../types/dist/sleep-C2M2zF7x.mjs
4668
+ //#region ../types/dist/sleep-BiDFW0E7.mjs
4669
4669
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4670
4670
  EventCategory["SystemBoot"] = "system.boot";
4671
4671
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5478,6 +5478,100 @@ function createDurableState(deps) {
5478
5478
  };
5479
5479
  }
5480
5480
  /**
5481
+ * Per-node scoping for the shared addon-settings blob.
5482
+ *
5483
+ * An addon's settings store is hub-central (the `addon-settings` cap is
5484
+ * hub-routed — the hub instance answers for every node), so fields whose
5485
+ * value is a NODE fact (decoder backend, engine pick, probed hardware
5486
+ * capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
5487
+ * the single shared blob. The SCHEMA field key stays bare: the write path
5488
+ * ({@link scopePatch}) maps the bare field onto the target node's scoped
5489
+ * key; the read/hydrate path ({@link projectStore}) maps THIS node's value
5490
+ * back, so UI forms and `resolveConfig` only ever see the bare key.
5491
+ *
5492
+ * Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
5493
+ * (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
5494
+ * schema and routes reads/writes through these helpers.
5495
+ *
5496
+ * ## No bare-key fallback — deliberate
5497
+ *
5498
+ * {@link readNodeValue} reads the node-scoped key ONLY. A node with no
5499
+ * scoped key resolves to `undefined` so the field's schema `default` wins —
5500
+ * NEVER `store[base]` and never another node's value. A bare legacy key in
5501
+ * the store is invisible to every node, hub included, so one node's
5502
+ * selection can never leak onto another. (This generalizes the
5503
+ * `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
5504
+ * arbitrary set of per-node field keys.)
5505
+ *
5506
+ * Pure functions only — no I/O, no imports beyond the language. This is a
5507
+ * LEAF module: import it via its deep path, never from the root barrel.
5508
+ */
5509
+ /**
5510
+ * Normalize a raw kernel node id to the bare node id used for scoping.
5511
+ * `localNodeId` can carry a `<node>/<addon>` suffix on forked child
5512
+ * processes; per-node settings are per-NODE, so strip the addon segment.
5513
+ * `undefined` / `null` / empty falls back to `'hub'`.
5514
+ */
5515
+ function normalizeNodeId(raw) {
5516
+ if (raw === void 0 || raw === null || raw === "") return "hub";
5517
+ const slashIdx = raw.indexOf("/");
5518
+ if (slashIdx < 0) return raw;
5519
+ const bare = raw.slice(0, slashIdx);
5520
+ return bare === "" ? "hub" : bare;
5521
+ }
5522
+ /** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
5523
+ function nodeScopedKey(base, nodeId) {
5524
+ return `${base}@${normalizeNodeId(nodeId)}`;
5525
+ }
5526
+ /**
5527
+ * Read a node's value for a per-node field from the raw shared store:
5528
+ * the node-scoped key when present, otherwise `undefined`.
5529
+ * Deliberately NO bare-key fallback (see module doc) — the caller lets the
5530
+ * schema `default` win on `undefined`.
5531
+ */
5532
+ function readNodeValue(store, base, nodeId) {
5533
+ return store[nodeScopedKey(base, nodeId)];
5534
+ }
5535
+ /**
5536
+ * Re-map a UI/settings patch so every bare perNode field persists under the
5537
+ * TARGET node's scoped key; all other keys pass through unchanged. Used on
5538
+ * the write path so a save for one node never clobbers another node's value
5539
+ * (and the bare key is never written). Returns a new object — the input
5540
+ * patch is not mutated.
5541
+ */
5542
+ function scopePatch(patch, perNodeKeys, nodeId) {
5543
+ const out = {};
5544
+ for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
5545
+ return out;
5546
+ }
5547
+ /**
5548
+ * Project the raw shared store onto the bare schema keys for ONE node so a
5549
+ * UI schema (whose field keys are bare) hydrates from that node's own
5550
+ * values:
5551
+ *
5552
+ * - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
5553
+ * - Every bare perNode key is dropped from the pass-through (a stray bare
5554
+ * legacy key must never hydrate any node — no bare fallback).
5555
+ * - THIS node's effective value ({@link readNodeValue}) is then laid onto
5556
+ * each bare perNode key; when the node has no scoped key the bare key is
5557
+ * left ABSENT so the field's schema `default` wins.
5558
+ *
5559
+ * Returns a new object — the input store is not mutated.
5560
+ */
5561
+ function projectStore(store, perNodeKeys, nodeId) {
5562
+ const out = {};
5563
+ for (const [key, value] of Object.entries(store)) {
5564
+ if (key.includes("@")) continue;
5565
+ if (perNodeKeys.has(key)) continue;
5566
+ out[key] = value;
5567
+ }
5568
+ for (const base of perNodeKeys) {
5569
+ const value = readNodeValue(store, base, nodeId);
5570
+ if (value !== void 0) out[base] = value;
5571
+ }
5572
+ return out;
5573
+ }
5574
+ /**
5481
5575
  * Base class for CamStack addons. Eliminates settings boilerplate:
5482
5576
  *
5483
5577
  * - Typed `config` property with automatic resolution from store + defaults
@@ -5645,23 +5739,63 @@ var BaseAddon = class {
5645
5739
  deviceSettingsSchema() {
5646
5740
  return null;
5647
5741
  }
5648
- async getGlobalSettings(overlay, cap, _nodeId) {
5742
+ async getGlobalSettings(overlay, cap, nodeId) {
5649
5743
  const schema = this.globalSettingsSchema(cap);
5650
5744
  if (!schema) return { sections: [] };
5651
- const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5745
+ const projected = await this.resolveGlobalStore(nodeId, cap);
5652
5746
  return hydrateSchema(schema, overlay ? {
5653
- ...raw,
5747
+ ...projected,
5654
5748
  ...overlay
5655
- } : raw);
5749
+ } : projected);
5656
5750
  }
5657
- async updateGlobalSettings(patch, _nodeId) {
5658
- await this._ctx?.settings?.writeAddonStore(patch);
5751
+ /**
5752
+ * The raw addon store PROJECTED onto the target node's bare per-node keys:
5753
+ * every `perNode: true` field carries THAT node's scoped value on its bare
5754
+ * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
5755
+ * bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
5756
+ * A no-op passthrough when the schema declares no `perNode` field.
5757
+ *
5758
+ * This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
5759
+ * the store for custom option logic (option narrowing, value snapping) to
5760
+ * read it per-node — never `ctx.settings.readAddonStore()` directly.
5761
+ * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
5762
+ */
5763
+ async resolveGlobalStore(nodeId, cap) {
5764
+ const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5765
+ const keys = this.perNodeKeys(cap);
5766
+ const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5767
+ return keys.size > 0 ? projectStore(raw, keys, node) : raw;
5768
+ }
5769
+ async updateGlobalSettings(patch, nodeId) {
5770
+ const keys = this.perNodeKeys();
5771
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5772
+ const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5773
+ const barePatch = patch;
5774
+ const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
5775
+ await this._ctx?.settings?.writeAddonStore(scoped);
5776
+ if (target !== localNode) return;
5659
5777
  await this.resolveConfig();
5660
5778
  await this.onConfigChanged();
5661
5779
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
5662
5780
  this.maybeAutoRestart(patch, this.globalSettingsSchema());
5663
5781
  }
5664
5782
  /**
5783
+ * The set of field keys the global settings schema declares `perNode: true`
5784
+ * — derived once per `cap` argument and memoized (schemas are static
5785
+ * declarations). Empty set ⇒ every per-node code path is bypassed and the
5786
+ * settings API behaves exactly like the legacy node-agnostic one.
5787
+ */
5788
+ _perNodeKeysCache = /* @__PURE__ */ new Map();
5789
+ perNodeKeys(cap) {
5790
+ const cacheKey = cap ?? "";
5791
+ const cached = this._perNodeKeysCache.get(cacheKey);
5792
+ if (cached) return cached;
5793
+ const schema = this.globalSettingsSchema(cap);
5794
+ const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
5795
+ this._perNodeKeysCache.set(cacheKey, keys);
5796
+ return keys;
5797
+ }
5798
+ /**
5665
5799
  * If any field in `patch` is marked `requiresRestart` in `schema`,
5666
5800
  * schedule an addon restart for the next tick. Deferred via
5667
5801
  * `setImmediate` so the tRPC mutation that triggered the write has
@@ -5814,12 +5948,19 @@ var BaseAddon = class {
5814
5948
  * The merge is shallow: each key in `defaults` is checked against the store.
5815
5949
  * Only keys present in defaults are read — the store can contain extra keys
5816
5950
  * (e.g. from older versions) without polluting the typed config.
5951
+ *
5952
+ * Keys the global settings schema declares `perNode: true` resolve from
5953
+ * THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
5954
+ * from the bare key — so a per-node field resolves to this node's own
5955
+ * selection at boot (absent scoped key ⇒ the constructor default wins).
5817
5956
  */
5818
5957
  async resolveConfig() {
5819
5958
  const stored = await this.readAddonStoreWithRetry();
5959
+ const perNode = this.perNodeKeys();
5960
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5820
5961
  const resolved = { ...this.defaults };
5821
5962
  for (const key of Object.keys(this.defaults)) {
5822
- const storedValue = stored[key];
5963
+ const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
5823
5964
  if (storedValue !== void 0 && storedValue !== null) {
5824
5965
  const defaultType = typeof this.defaults[key];
5825
5966
  if (typeof storedValue === defaultType) resolved[key] = storedValue;
@@ -5903,6 +6044,27 @@ var BaseAddon = class {
5903
6044
  }
5904
6045
  };
5905
6046
  /**
6047
+ * Collect the keys of every field marked `perNode: true`, recursing into
6048
+ * layout containers (`group` fields and `sub-tabs` tabs) the same way
6049
+ * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6050
+ * don't declare `perNode` and are excluded by the `in` narrowing.
6051
+ */
6052
+ function collectPerNodeFieldKeys(fields) {
6053
+ const collected = [];
6054
+ for (const field of fields) {
6055
+ if (field.type === "group") {
6056
+ collected.push(...collectPerNodeFieldKeys(field.fields));
6057
+ continue;
6058
+ }
6059
+ if (field.type === "sub-tabs") {
6060
+ for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
6061
+ continue;
6062
+ }
6063
+ if ("perNode" in field && field.perNode === true) collected.push(field.key);
6064
+ }
6065
+ return collected;
6066
+ }
6067
+ /**
5906
6068
  * Normalize an `ICamstackAddon.initialize()` return value into the
5907
6069
  * `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
5908
6070
  * envelopes pass through; void stays void.
@@ -5927,6 +6089,7 @@ var CamStreamKindSchema = _enum([
5927
6089
  "pull-rtsp",
5928
6090
  "pull-rtmp",
5929
6091
  "pull-http",
6092
+ "pull-flv",
5930
6093
  "pull-rfc4571",
5931
6094
  "push-annexb",
5932
6095
  "derived"
@@ -6309,6 +6472,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
6309
6472
  /** Single still-image entity (HA `image.*`). Read-only display of an
6310
6473
  * `entity_picture` signed URL the browser loads directly. `image` cap. */
6311
6474
  DeviceType["Image"] = "image";
6475
+ /** Smart pet feeder — cloud-connected food dispenser with a bowl food
6476
+ * level, battery, desiccant life, feeding state and manual-feed /
6477
+ * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
6478
+ * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
6479
+ * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
6480
+ * integrations sharing the same food/desiccant/hopper surface. */
6481
+ DeviceType["PetFeeder"] = "pet-feeder";
6312
6482
  return DeviceType;
6313
6483
  }({});
6314
6484
  var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
@@ -7473,6 +7643,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
7473
7643
  for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7474
7644
  for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7475
7645
  /**
7646
+ * Error types for the safe expression engine. Two distinct classes so callers
7647
+ * can tell a compile-time (grammar) failure from a runtime (evaluation)
7648
+ * failure — both are non-fatal to the host: read paths degrade to "skip link".
7649
+ */
7650
+ /** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
7651
+ * the failure is anchored to a character (author-facing inline feedback). */
7652
+ var ExpressionParseError = class extends Error {
7653
+ position;
7654
+ constructor(message, position) {
7655
+ super(message);
7656
+ this.name = "ExpressionParseError";
7657
+ this.position = position;
7658
+ }
7659
+ };
7660
+ /** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
7661
+ * result, unknown builtin, step-budget exceeded). */
7662
+ var ExpressionEvalError = class extends Error {
7663
+ constructor(message) {
7664
+ super(message);
7665
+ this.name = "ExpressionEvalError";
7666
+ }
7667
+ };
7668
+ /**
7669
+ * Resource-bound constants for the safe expression engine.
7670
+ *
7671
+ * Every bound is defense-in-depth: the grammar is non-Turing-complete (no
7672
+ * loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
7673
+ * O(nodeCount) by construction. These caps merely put a hard ceiling on the
7674
+ * work a single author-supplied expression can request, so a hostile or
7675
+ * accidental pathological string can never spend unbounded CPU/memory.
7676
+ */
7677
+ /** Max source length (chars) — checked BEFORE tokenizing so a huge string is
7678
+ * rejected without allocation. */
7679
+ var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
7680
+ /** A legal binding / identifier name. */
7681
+ var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
7682
+ /** Binding names an author may NOT use: `now` is auto-injected; the literal
7683
+ * keywords lex as values, not identifiers, so binding to them is meaningless. */
7684
+ var RESERVED_BINDING_NAMES = new Set([
7685
+ "now",
7686
+ "true",
7687
+ "false",
7688
+ "null"
7689
+ ]);
7690
+ /**
7691
+ * Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
7692
+ * zero-dependency. The grammar is deliberately boring: decimal numbers,
7693
+ * single/double-quoted strings with a tiny escape set, identifiers, the three
7694
+ * value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
7695
+ * outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
7696
+ * is a parse error with a source position, so member access / assignment /
7697
+ * template literals are lexically impossible.
7698
+ */
7699
+ var KEYWORDS = new Set([
7700
+ "true",
7701
+ "false",
7702
+ "null"
7703
+ ]);
7704
+ function isDigit(ch) {
7705
+ return ch >= "0" && ch <= "9";
7706
+ }
7707
+ function isIdentStart(ch) {
7708
+ return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
7709
+ }
7710
+ function isIdentPart(ch) {
7711
+ return isIdentStart(ch) || isDigit(ch);
7712
+ }
7713
+ function isWhitespace(ch) {
7714
+ return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
7715
+ }
7716
+ /** Tokenize `source` into a flat token list ending with a single `eof` token.
7717
+ * Throws `ExpressionParseError` on any illegal character or unterminated
7718
+ * string. */
7719
+ function tokenize(source) {
7720
+ if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
7721
+ const tokens = [];
7722
+ let i = 0;
7723
+ const n = source.length;
7724
+ while (i < n) {
7725
+ const ch = source[i];
7726
+ if (isWhitespace(ch)) {
7727
+ i += 1;
7728
+ continue;
7729
+ }
7730
+ if (isDigit(ch)) {
7731
+ const start = i;
7732
+ while (i < n && isDigit(source[i])) i += 1;
7733
+ if (i < n && source[i] === ".") {
7734
+ if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
7735
+ i += 1;
7736
+ while (i < n && isDigit(source[i])) i += 1;
7737
+ }
7738
+ const text = source.slice(start, i);
7739
+ const value = Number(text);
7740
+ if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
7741
+ tokens.push({
7742
+ type: "number",
7743
+ value,
7744
+ pos: start
7745
+ });
7746
+ continue;
7747
+ }
7748
+ if (ch === "'" || ch === "\"") {
7749
+ const quote = ch;
7750
+ const start = i;
7751
+ i += 1;
7752
+ let out = "";
7753
+ let closed = false;
7754
+ while (i < n) {
7755
+ const c = source[i];
7756
+ if (c === "\\") {
7757
+ const next = i + 1 < n ? source[i + 1] : "";
7758
+ if (next === "\\" || next === "'" || next === "\"") {
7759
+ out += next;
7760
+ i += 2;
7761
+ continue;
7762
+ }
7763
+ throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
7764
+ }
7765
+ if (c === quote) {
7766
+ closed = true;
7767
+ i += 1;
7768
+ break;
7769
+ }
7770
+ out += c;
7771
+ i += 1;
7772
+ }
7773
+ if (!closed) throw new ExpressionParseError("unterminated string literal", start);
7774
+ tokens.push({
7775
+ type: "string",
7776
+ value: out,
7777
+ pos: start
7778
+ });
7779
+ continue;
7780
+ }
7781
+ if (isIdentStart(ch)) {
7782
+ const start = i;
7783
+ while (i < n && isIdentPart(source[i])) i += 1;
7784
+ const text = source.slice(start, i);
7785
+ if (KEYWORDS.has(text)) tokens.push({
7786
+ type: "keyword",
7787
+ keyword: keywordOf(text),
7788
+ pos: start
7789
+ });
7790
+ else tokens.push({
7791
+ type: "identifier",
7792
+ name: text,
7793
+ pos: start
7794
+ });
7795
+ continue;
7796
+ }
7797
+ const two = i + 1 < n ? source.slice(i, i + 2) : "";
7798
+ if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
7799
+ tokens.push({
7800
+ type: "punct",
7801
+ punct: two,
7802
+ pos: i
7803
+ });
7804
+ i += 2;
7805
+ continue;
7806
+ }
7807
+ if (isSinglePunct(ch)) {
7808
+ tokens.push({
7809
+ type: "punct",
7810
+ punct: ch,
7811
+ pos: i
7812
+ });
7813
+ i += 1;
7814
+ continue;
7815
+ }
7816
+ throw new ExpressionParseError(`unexpected character '${ch}'`, i);
7817
+ }
7818
+ tokens.push({
7819
+ type: "eof",
7820
+ pos: n
7821
+ });
7822
+ return tokens;
7823
+ }
7824
+ function keywordOf(text) {
7825
+ if (text === "true") return "true";
7826
+ if (text === "false") return "false";
7827
+ return "null";
7828
+ }
7829
+ function isSinglePunct(ch) {
7830
+ return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
7831
+ }
7832
+ /**
7833
+ * Frozen, null-prototype builtin function table for the expression engine
7834
+ * (spec §4 rule 4). The table is the SOLE surface of callable functions: the
7835
+ * parser rejects any callee not in it, and the evaluator gates each call on an
7836
+ * own-property check against it.
7837
+ *
7838
+ * Because the object has a NULL prototype AND is `Object.freeze`d:
7839
+ * - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
7840
+ * - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
7841
+ * (there is no `Object.prototype` in the chain), so those names are not
7842
+ * callable — they are simply "unknown function" at parse time.
7843
+ *
7844
+ * Every numeric argument is validated as a finite number and every numeric
7845
+ * RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
7846
+ * (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
7847
+ * closed rather than emitting a garbage value.
7848
+ */
7849
+ function asFiniteNumber(value, name, index) {
7850
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
7851
+ return value;
7852
+ }
7853
+ function asString$1(value, name, index) {
7854
+ if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
7855
+ return value;
7856
+ }
7857
+ function finiteResult(value, name) {
7858
+ if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
7859
+ return value;
7860
+ }
7861
+ function allFiniteNumbers(args, name) {
7862
+ return args.map((a, idx) => asFiniteNumber(a, name, idx));
7863
+ }
7864
+ var INF = Number.POSITIVE_INFINITY;
7865
+ var table = {
7866
+ min: {
7867
+ minArgs: 1,
7868
+ maxArgs: INF,
7869
+ apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
7870
+ },
7871
+ max: {
7872
+ minArgs: 1,
7873
+ maxArgs: INF,
7874
+ apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
7875
+ },
7876
+ abs: {
7877
+ minArgs: 1,
7878
+ maxArgs: 1,
7879
+ apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
7880
+ },
7881
+ floor: {
7882
+ minArgs: 1,
7883
+ maxArgs: 1,
7884
+ apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
7885
+ },
7886
+ ceil: {
7887
+ minArgs: 1,
7888
+ maxArgs: 1,
7889
+ apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
7890
+ },
7891
+ sqrt: {
7892
+ minArgs: 1,
7893
+ maxArgs: 1,
7894
+ apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
7895
+ },
7896
+ round: {
7897
+ minArgs: 1,
7898
+ maxArgs: 2,
7899
+ apply: (args) => {
7900
+ const x = asFiniteNumber(args[0], "round", 0);
7901
+ const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
7902
+ if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
7903
+ const factor = 10 ** digits;
7904
+ return finiteResult(Math.round(x * factor) / factor, "round");
7905
+ }
7906
+ },
7907
+ pow: {
7908
+ minArgs: 2,
7909
+ maxArgs: 2,
7910
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
7911
+ },
7912
+ clamp: {
7913
+ minArgs: 3,
7914
+ maxArgs: 3,
7915
+ apply: (args) => {
7916
+ const x = asFiniteNumber(args[0], "clamp", 0);
7917
+ const lo = asFiniteNumber(args[1], "clamp", 1);
7918
+ const hi = asFiniteNumber(args[2], "clamp", 2);
7919
+ if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
7920
+ return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
7921
+ }
7922
+ },
7923
+ avg: {
7924
+ minArgs: 1,
7925
+ maxArgs: INF,
7926
+ apply: (args) => {
7927
+ const nums = allFiniteNumbers(args, "avg");
7928
+ return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
7929
+ }
7930
+ },
7931
+ sum: {
7932
+ minArgs: 1,
7933
+ maxArgs: INF,
7934
+ apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
7935
+ },
7936
+ coalesce: {
7937
+ minArgs: 1,
7938
+ maxArgs: INF,
7939
+ apply: (args) => {
7940
+ for (const a of args) if (a !== null) return a;
7941
+ return null;
7942
+ }
7943
+ },
7944
+ age: {
7945
+ minArgs: 2,
7946
+ maxArgs: 2,
7947
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
7948
+ },
7949
+ convert: {
7950
+ minArgs: 3,
7951
+ maxArgs: 3,
7952
+ apply: (args, hooks) => {
7953
+ const x = asFiniteNumber(args[0], "convert", 0);
7954
+ const from = asString$1(args[1], "convert", 1).trim();
7955
+ const to = asString$1(args[2], "convert", 2).trim();
7956
+ if (hooks.convert) {
7957
+ const out = hooks.convert(x, from, to);
7958
+ if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
7959
+ return finiteResult(out, "convert");
7960
+ }
7961
+ if (from === to) return x;
7962
+ throw new ExpressionEvalError("convert: unit conversion table not installed");
7963
+ }
7964
+ }
7965
+ };
7966
+ Object.freeze(Object.assign(Object.create(null), table));
7967
+ /** The set of valid builtin names — used by the parser to reject unknown
7968
+ * callees at parse time (immediate author feedback). */
7969
+ var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
7970
+ /**
7971
+ * Pratt (precedence-climbing) parser for the safe expression mini-language.
7972
+ *
7973
+ * Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
7974
+ * → relational → additive → multiplicative → unary `! -` → call / primary.
7975
+ * Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
7976
+ * string validated against the builtin table at parse time, so an unknown
7977
+ * function is rejected immediately (author feedback) and a persisted expression
7978
+ * that references a since-removed builtin degrades at read.
7979
+ *
7980
+ * A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
7981
+ * arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
7982
+ */
7983
+ /** Binary/logical operator precedence (higher binds tighter). */
7984
+ var BINARY_PRECEDENCE = {
7985
+ "||": 1,
7986
+ "&&": 2,
7987
+ "==": 3,
7988
+ "!=": 3,
7989
+ "<": 4,
7990
+ "<=": 4,
7991
+ ">": 4,
7992
+ ">=": 4,
7993
+ "+": 5,
7994
+ "-": 5,
7995
+ "*": 6,
7996
+ "/": 6,
7997
+ "%": 6
7998
+ };
7999
+ function isLogicalOp(op) {
8000
+ return op === "&&" || op === "||";
8001
+ }
8002
+ function isBinaryOp(op) {
8003
+ return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
8004
+ }
8005
+ var Parser = class {
8006
+ tokens;
8007
+ pos = 0;
8008
+ nodeCount = 0;
8009
+ identifiers = /* @__PURE__ */ new Set();
8010
+ callees = /* @__PURE__ */ new Set();
8011
+ constructor(tokens) {
8012
+ this.tokens = tokens;
8013
+ }
8014
+ parse() {
8015
+ const ast = this.parseTernary();
8016
+ const tok = this.peek();
8017
+ if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
8018
+ return {
8019
+ ast,
8020
+ identifiers: this.identifiers,
8021
+ callees: this.callees,
8022
+ nodeCount: this.nodeCount
8023
+ };
8024
+ }
8025
+ peek() {
8026
+ return this.tokens[this.pos];
8027
+ }
8028
+ next() {
8029
+ return this.tokens[this.pos++];
8030
+ }
8031
+ /** Consume a punctuator token, erroring if the next token isn't it. */
8032
+ expectPunct(punct) {
8033
+ const tok = this.peek();
8034
+ if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
8035
+ this.pos += 1;
8036
+ }
8037
+ matchPunct(punct) {
8038
+ const tok = this.peek();
8039
+ if (tok.type === "punct" && tok.punct === punct) {
8040
+ this.pos += 1;
8041
+ return true;
8042
+ }
8043
+ return false;
8044
+ }
8045
+ countNode() {
8046
+ this.nodeCount += 1;
8047
+ if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
8048
+ }
8049
+ parseTernary() {
8050
+ const test = this.parseBinary(1);
8051
+ if (this.matchPunct("?")) {
8052
+ const consequent = this.parseTernary();
8053
+ this.expectPunct(":");
8054
+ const alternate = this.parseTernary();
8055
+ this.countNode();
8056
+ return {
8057
+ kind: "conditional",
8058
+ test,
8059
+ consequent,
8060
+ alternate
8061
+ };
8062
+ }
8063
+ return test;
8064
+ }
8065
+ parseBinary(minPrec) {
8066
+ let left = this.parseUnary();
8067
+ for (;;) {
8068
+ const tok = this.peek();
8069
+ if (tok.type !== "punct") break;
8070
+ const prec = BINARY_PRECEDENCE[tok.punct];
8071
+ if (prec === void 0 || prec < minPrec) break;
8072
+ const op = tok.punct;
8073
+ this.pos += 1;
8074
+ const right = this.parseBinary(prec + 1);
8075
+ this.countNode();
8076
+ if (isLogicalOp(op)) left = {
8077
+ kind: "logical",
8078
+ op,
8079
+ left,
8080
+ right
8081
+ };
8082
+ else if (isBinaryOp(op)) left = {
8083
+ kind: "binary",
8084
+ op,
8085
+ left,
8086
+ right
8087
+ };
8088
+ else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
8089
+ }
8090
+ return left;
8091
+ }
8092
+ parseUnary() {
8093
+ const tok = this.peek();
8094
+ if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
8095
+ const op = tok.punct;
8096
+ this.pos += 1;
8097
+ const operand = this.parseUnary();
8098
+ this.countNode();
8099
+ return {
8100
+ kind: "unary",
8101
+ op,
8102
+ operand
8103
+ };
8104
+ }
8105
+ return this.parsePrimary();
8106
+ }
8107
+ parsePrimary() {
8108
+ const tok = this.next();
8109
+ switch (tok.type) {
8110
+ case "number":
8111
+ this.countNode();
8112
+ return {
8113
+ kind: "literal",
8114
+ value: tok.value
8115
+ };
8116
+ case "string":
8117
+ this.countNode();
8118
+ return {
8119
+ kind: "literal",
8120
+ value: tok.value
8121
+ };
8122
+ case "keyword":
8123
+ this.countNode();
8124
+ return {
8125
+ kind: "literal",
8126
+ value: tok.keyword === "null" ? null : tok.keyword === "true"
8127
+ };
8128
+ case "identifier": {
8129
+ const nextTok = this.peek();
8130
+ if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
8131
+ this.identifiers.add(tok.name);
8132
+ this.countNode();
8133
+ return {
8134
+ kind: "identifier",
8135
+ name: tok.name
8136
+ };
8137
+ }
8138
+ case "punct":
8139
+ if (tok.punct === "(") {
8140
+ const inner = this.parseTernary();
8141
+ this.expectPunct(")");
8142
+ return inner;
8143
+ }
8144
+ throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
8145
+ case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
8146
+ }
8147
+ }
8148
+ parseCall(callee, pos) {
8149
+ if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
8150
+ this.expectPunct("(");
8151
+ const args = [];
8152
+ if (!this.matchPunct(")")) for (;;) {
8153
+ args.push(this.parseTernary());
8154
+ if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
8155
+ if (this.matchPunct(",")) continue;
8156
+ this.expectPunct(")");
8157
+ break;
8158
+ }
8159
+ this.callees.add(callee);
8160
+ this.countNode();
8161
+ return {
8162
+ kind: "call",
8163
+ callee,
8164
+ args
8165
+ };
8166
+ }
8167
+ };
8168
+ /** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
8169
+ * `ExpressionParseError` on any lexical or grammatical failure. */
8170
+ function parseExpression(source) {
8171
+ return new Parser(tokenize(source)).parse();
8172
+ }
8173
+ Object.freeze({});
8174
+ /**
8175
+ * LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
8176
+ * by expr"). The cache stores BOTH successes and failures (negative caching),
8177
+ * so a corrupt persisted string costs exactly one tokenize+parse total — not
8178
+ * one per read on a hot resolve path.
8179
+ *
8180
+ * The cache is a module-level singleton: entries are pure, content-addressed
8181
+ * ASTs keyed by the raw source string, so sharing one instance across all
8182
+ * callers is safe and maximises hit rate.
8183
+ */
8184
+ var cache = /* @__PURE__ */ new Map();
8185
+ function getCached(source) {
8186
+ const hit = cache.get(source);
8187
+ if (hit !== void 0) {
8188
+ cache.delete(source);
8189
+ cache.set(source, hit);
8190
+ return hit;
8191
+ }
8192
+ let result;
8193
+ try {
8194
+ result = {
8195
+ ok: true,
8196
+ parsed: parseExpression(source)
8197
+ };
8198
+ } catch (err) {
8199
+ result = {
8200
+ ok: false,
8201
+ error: err instanceof ExpressionParseError ? err.message : String(err)
8202
+ };
8203
+ }
8204
+ cache.set(source, result);
8205
+ if (cache.size > 256) {
8206
+ const oldest = cache.keys().next().value;
8207
+ if (oldest !== void 0) cache.delete(oldest);
8208
+ }
8209
+ return result;
8210
+ }
8211
+ /** Compile `source`, returning a discriminated result instead of throwing.
8212
+ * Used by read paths that must degrade rather than raise. LRU/negative-cached. */
8213
+ function compileExpressionSafe(source) {
8214
+ return getCached(source);
8215
+ }
8216
+ /**
8217
+ * Author-time validation. Returns `null` when the source is valid, else a
8218
+ * human-readable error message. Checks: the expression compiles; binding count
8219
+ * is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
8220
+ * is not reserved (`now`/keywords) and does not shadow a builtin; and every
8221
+ * FREE identifier of the AST is covered by a binding or the injected `now`.
8222
+ */
8223
+ function validateExpressionSource(src) {
8224
+ const names = Object.keys(src.bindings);
8225
+ if (names.length > 32) return `too many bindings (${names.length} > 32)`;
8226
+ for (const name of names) {
8227
+ if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
8228
+ if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
8229
+ if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
8230
+ }
8231
+ const compiled = compileExpressionSafe(src.expr);
8232
+ if (!compiled.ok) return compiled.error;
8233
+ const bound = new Set(names);
8234
+ for (const id of compiled.parsed.identifiers) {
8235
+ if (id === "now") continue;
8236
+ if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
8237
+ }
8238
+ return null;
8239
+ }
8240
+ /**
7476
8241
  * Accessory device helpers — shared across drivers.
7477
8242
  *
7478
8243
  * Many vendor-specific drivers register accessory child devices on
@@ -8317,7 +9082,13 @@ onStatusChanged: { data: object({
8317
9082
  }) } },
8318
9083
  status: {
8319
9084
  schema: BatteryStatusSchema,
8320
- kind: "push"
9085
+ kind: "push",
9086
+ empty: {
9087
+ percentage: 0,
9088
+ charging: "none",
9089
+ sleeping: false,
9090
+ lastUpdated: 0
9091
+ }
8321
9092
  },
8322
9093
  /**
8323
9094
  * Runtime-state slice — every provider that registers this cap
@@ -9260,21 +10031,38 @@ var connectivityCapability = {
9260
10031
  },
9261
10032
  runtimeState: ConnectivityStatusSchema
9262
10033
  };
10034
+ /**
10035
+ * Generic device-consumables capability — surfaces a device's
10036
+ * maintenance items (vacuum filters/brushes, replaceable cartridges,
10037
+ * descaling cycles, …) with their remaining life and an optional
10038
+ * "Replaced" reset action. Device-agnostic: any provider that knows its
10039
+ * device tracks consumables can register it; the cap declares no
10040
+ * vocabulary of its own — the provider names each item verbatim.
10041
+ *
10042
+ * Like `childLayout`, the cap is INERT until a provider sets items: no
10043
+ * provider populates it by guessing (no HA inference). The UI renders a
10044
+ * "No consumables reported" placeholder when `items` is empty.
10045
+ */
10046
+ /** A single consumable item. Either a continuous `level` (remaining
10047
+ * life %) or a discrete `status` may be known — both may be null when a
10048
+ * provider only knows the item exists. `level` and `status` are not
10049
+ * mutually exclusive; a provider may report both. */
10050
+ var ConsumableItemSchema = object({
10051
+ /** Stable id, e.g. 'main-brush'. */
10052
+ key: string().min(1),
10053
+ /** Display name. */
10054
+ label: string().min(1),
10055
+ /** Remaining life % when known (0..100). */
10056
+ level: number().min(0).max(100).nullable(),
10057
+ /** Discrete state when known (binary mode). */
10058
+ status: _enum(["ok", "replace"]).nullable(),
10059
+ /** Ms epoch of the last replace, when known. */
10060
+ lastResetAt: number().nullable(),
10061
+ /** Whether `reset()` is meaningful for this item. */
10062
+ resettable: boolean()
10063
+ });
9263
10064
  var ConsumablesStatusSchema = object({
9264
- items: array(object({
9265
- /** Stable id, e.g. 'main-brush'. */
9266
- key: string().min(1),
9267
- /** Display name. */
9268
- label: string().min(1),
9269
- /** Remaining life % when known (0..100). */
9270
- level: number().min(0).max(100).nullable(),
9271
- /** Discrete state when known (binary mode). */
9272
- status: _enum(["ok", "replace"]).nullable(),
9273
- /** Ms epoch of the last replace, when known. */
9274
- lastResetAt: number().nullable(),
9275
- /** Whether `reset()` is meaningful for this item. */
9276
- resettable: boolean()
9277
- })),
10065
+ items: array(ConsumableItemSchema),
9278
10066
  lastChangedAt: number()
9279
10067
  });
9280
10068
  var consumablesCapability = {
@@ -9333,7 +10121,25 @@ reset: method(object({
9333
10121
  }) },
9334
10122
  status: {
9335
10123
  schema: ConsumablesStatusSchema,
9336
- kind: "push"
10124
+ kind: "push",
10125
+ empty: {
10126
+ items: [],
10127
+ lastChangedAt: 0
10128
+ },
10129
+ itemArray: {
10130
+ path: "items",
10131
+ keyField: "key",
10132
+ labelField: "label",
10133
+ itemSchema: ConsumableItemSchema,
10134
+ emptyItem: {
10135
+ key: "",
10136
+ label: "",
10137
+ level: null,
10138
+ status: null,
10139
+ lastResetAt: null,
10140
+ resettable: false
10141
+ }
10142
+ }
9337
10143
  },
9338
10144
  runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() })
9339
10145
  };
@@ -10575,7 +11381,8 @@ var MotionAnalysisResultSchema = object({
10575
11381
  });
10576
11382
  method(object({
10577
11383
  deviceId: number(),
10578
- frame: FrameInputSchema
11384
+ frame: FrameInputSchema.optional(),
11385
+ frameHandle: FrameHandleSchema.optional()
10579
11386
  }), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
10580
11387
  deviceId: number(),
10581
11388
  detected: boolean(),
@@ -10822,6 +11629,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
10822
11629
  engine: PipelineEngineChoiceSchema.optional(),
10823
11630
  steps: array(PipelineStepInputSchema).min(1),
10824
11631
  frame: FrameInputSchema.optional(),
11632
+ /**
11633
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
11634
+ * the decoded pixels live in. One more member of the one-of
11635
+ * frame/frameHandle/image/imageBase64/referenceImage group.
11636
+ */
11637
+ frameHandle: FrameHandleSchema.optional(),
10825
11638
  imageBase64: string().optional(),
10826
11639
  /**
10827
11640
  * Binary JPEG bytes — preferred over `imageBase64` on internal
@@ -11064,6 +11877,31 @@ var ReportMotionInputSchema = object({
11064
11877
  regions: array(MotionRegionSchema).readonly().optional()
11065
11878
  });
11066
11879
  /**
11880
+ * Where a runner gets a camera's decoded frames (cross-node Phase 2,
11881
+ * restream-owner model — P2c).
11882
+ *
11883
+ * - `local-broker` (DEFAULT): today's path — subscribe to the co-located
11884
+ * stream-broker's shm frame plane. Every pre-P2c attach payload (no
11885
+ * `frameSource` key) parses to this, so the field is additive with zero
11886
+ * behavior change.
11887
+ * - `remote-restream`: the detect node is NOT the camera's source-owner.
11888
+ * The runner acquires the owner's COMPRESSED passthrough restream
11889
+ * (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
11890
+ * double-pull guard) and decodes LOCALLY via a satellite frame plane +
11891
+ * pull-mode decoder session pinned to its own node. The shm ring stays
11892
+ * node-local; only H.264/H.265 packets cross the wire.
11893
+ * `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
11894
+ * when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
11895
+ * dials for the owner's restream.
11896
+ */
11897
+ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
11898
+ kind: literal("remote-restream"),
11899
+ /** The camera's source-owner node (slice 1: always the hub). */
11900
+ ownerNodeId: string(),
11901
+ /** Operator override for the owner host the runner dials. */
11902
+ hubHostnameOverride: string().optional()
11903
+ })]).describe("Per-camera frame-source mode for the runner (P2c)");
11904
+ /**
11067
11905
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
11068
11906
  * specific runner instance via `attachCamera`. Carries everything the
11069
11907
  * runner needs to subscribe to the local broker and execute inference.
@@ -11161,7 +11999,15 @@ var RunnerCameraConfigSchema = object({
11161
11999
  */
11162
12000
  onboardMotionDrivesAnalyzer: boolean().default(true),
11163
12001
  occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
11164
- occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
12002
+ occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
12003
+ /**
12004
+ * Where this runner gets the camera's decoded frames (P2c). Defaulted so
12005
+ * every existing payload behaves as `local-broker` — the pre-Phase-2 path.
12006
+ * Populated with `remote-restream` by the orchestrator ONLY when the
12007
+ * camera's detect node differs from its source-owner (P2d, gated by the
12008
+ * `remoteSourcingNodes` rollout setting).
12009
+ */
12010
+ frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
11165
12011
  });
11166
12012
  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;
11167
12013
  /**
@@ -11725,6 +12571,157 @@ var numericSensorCapability = {
11725
12571
  runtimeState: NumericSensorStatusSchema
11726
12572
  };
11727
12573
  /**
12574
+ * Feeder connectivity / power status — mirrors the HA petkit device-status
12575
+ * enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
12576
+ * `on_batteries` (running on battery backup). `null` until first reported.
12577
+ */
12578
+ var PetFeederDeviceStatusSchema = _enum([
12579
+ "normal",
12580
+ "offline",
12581
+ "on_batteries"
12582
+ ]);
12583
+ var gramsPortion = number().int().min(4).max(200);
12584
+ var PetFeederStatusSchema = object({
12585
+ /** Food currently in the bowl (grams). Null when the device has not
12586
+ * reported a reading yet. On dual-hopper models this is the combined
12587
+ * bowl reading; per-hopper levels live in `food1`/`food2`. */
12588
+ foodLevel: number().nullable(),
12589
+ /** Hopper-1 food level (grams) on dual-hopper feeders; null on
12590
+ * single-hopper models. */
12591
+ food1: number().nullable(),
12592
+ /** Hopper-2 food level (grams) on dual-hopper feeders; null on
12593
+ * single-hopper models. */
12594
+ food2: number().nullable(),
12595
+ /** Derived low-food flag — mirrors the HA `food_level` binary_sensor
12596
+ * (`device_class: problem`, on = low). True when the bowl is empty /
12597
+ * below the feeder's low threshold. */
12598
+ lowFood: boolean(),
12599
+ /** Battery charge 0..100 (%). Null on mains-powered models or when the
12600
+ * device has no battery reading. */
12601
+ batteryPower: number().min(0).max(100).nullable(),
12602
+ /** Days of desiccant life remaining. Null when the model has no
12603
+ * desiccant sensor. */
12604
+ desiccantLeftDays: number().nullable(),
12605
+ /** True while a feed is in progress. */
12606
+ feeding: boolean(),
12607
+ /** Decoded connectivity / power status (HA petkit device-status enum).
12608
+ * Null until the device has reported a status. */
12609
+ status: PetFeederDeviceStatusSchema.nullable(),
12610
+ /** Decoded human-readable fault message. Null (or the device's `no_error`
12611
+ * sentinel) means healthy; a non-null string is an active fault. Pairs
12612
+ * with `errorCode` for consumers that want the raw integer. */
12613
+ error: string().nullable(),
12614
+ /** Raw device error code (0 / null = no error). */
12615
+ errorCode: number().nullable(),
12616
+ /** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
12617
+ isDualHopper: boolean(),
12618
+ /** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
12619
+ childLock: boolean(),
12620
+ /** Front indicator-light setting. */
12621
+ indicatorLight: boolean(),
12622
+ /** Play a chime when dispensing. */
12623
+ feedSound: boolean(),
12624
+ /** Speaker / prompt volume level (device-scaled integer). */
12625
+ volume: number(),
12626
+ /** Ms epoch when the slice was last refreshed from the cloud. */
12627
+ lastFetchedAt: number()
12628
+ });
12629
+ var petFeederCapability = {
12630
+ name: "pet-feeder",
12631
+ scope: "device",
12632
+ deviceNative: true,
12633
+ mode: "singleton",
12634
+ deviceTypes: [DeviceType.PetFeeder],
12635
+ methods: {
12636
+ /**
12637
+ * Dispense food now. Single-hopper feeders take `grams`; dual-hopper
12638
+ * feeders (D4S/D4SH) accept `hopper1`/`hopper2` to target one or both
12639
+ * hoppers. All portions honour the 4–200 g hardware range. At least
12640
+ * one of the three must be present — the provider rejects an empty
12641
+ * request.
12642
+ */
12643
+ feed: method(object({
12644
+ deviceId: number().int().nonnegative(),
12645
+ grams: gramsPortion.optional(),
12646
+ hopper1: gramsPortion.optional(),
12647
+ hopper2: gramsPortion.optional()
12648
+ }), _void(), {
12649
+ kind: "mutation",
12650
+ auth: "admin"
12651
+ }),
12652
+ /** Cancel an in-progress manual feed. */
12653
+ cancelFeed: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12654
+ kind: "mutation",
12655
+ auth: "admin"
12656
+ }),
12657
+ /** Reset the desiccant "days remaining" counter after replacing it. */
12658
+ resetDesiccant: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12659
+ kind: "mutation",
12660
+ auth: "admin"
12661
+ }),
12662
+ /** Mark a hopper as refilled (D4H/D4S/D4SH). */
12663
+ markFoodReplenished: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12664
+ kind: "mutation",
12665
+ auth: "admin"
12666
+ }),
12667
+ /** Call the pet with the recorded prompt (D3). */
12668
+ callPet: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12669
+ kind: "mutation",
12670
+ auth: "admin"
12671
+ }),
12672
+ /** Play a stored sound by id (D3 / D4H / D4SH). */
12673
+ playSound: method(object({
12674
+ deviceId: number().int().nonnegative(),
12675
+ soundId: number().int().nonnegative()
12676
+ }), _void(), {
12677
+ kind: "mutation",
12678
+ auth: "admin"
12679
+ }),
12680
+ /** Toggle the child-lock (manual-lock) setting. */
12681
+ setChildLock: method(object({
12682
+ deviceId: number().int().nonnegative(),
12683
+ on: boolean()
12684
+ }), _void(), {
12685
+ kind: "mutation",
12686
+ auth: "admin"
12687
+ }),
12688
+ /** Toggle the front indicator light. */
12689
+ setIndicatorLight: method(object({
12690
+ deviceId: number().int().nonnegative(),
12691
+ on: boolean()
12692
+ }), _void(), {
12693
+ kind: "mutation",
12694
+ auth: "admin"
12695
+ }),
12696
+ /** Toggle the dispense chime. */
12697
+ setFeedSound: method(object({
12698
+ deviceId: number().int().nonnegative(),
12699
+ on: boolean()
12700
+ }), _void(), {
12701
+ kind: "mutation",
12702
+ auth: "admin"
12703
+ }),
12704
+ /** Set the speaker / prompt volume level. */
12705
+ setVolume: method(object({
12706
+ deviceId: number().int().nonnegative(),
12707
+ level: number().int().nonnegative()
12708
+ }), _void(), {
12709
+ kind: "mutation",
12710
+ auth: "admin"
12711
+ })
12712
+ },
12713
+ status: {
12714
+ schema: PetFeederStatusSchema,
12715
+ kind: "poll"
12716
+ },
12717
+ /**
12718
+ * Runtime-state slice — mirrored by the kernel. UI feeder cards read
12719
+ * the full slice via `device.state.petFeeder.value` and refresh on
12720
+ * every poll without re-querying the provider.
12721
+ */
12722
+ runtimeState: PetFeederStatusSchema
12723
+ };
12724
+ /**
11728
12725
  * Multi-metric electrical meter. One slice can carry any combination
11729
12726
  * of instantaneous power (W), cumulative energy (kWh), voltage (V),
11730
12727
  * and current (A) — all fields optional so a single-metric source
@@ -13027,6 +14024,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
13027
14024
  nativeObjectDetection: nativeObjectDetectionCapability,
13028
14025
  notifier: notifierCapability,
13029
14026
  numericSensor: numericSensorCapability,
14027
+ petFeeder: petFeederCapability,
13030
14028
  powerMeter: powerMeterCapability,
13031
14029
  presence: presenceCapability,
13032
14030
  pressureSensor: pressureSensorCapability,
@@ -14943,10 +15941,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
14943
15941
  url: string()
14944
15942
  }), _void()), method(object({
14945
15943
  sessionId: string(),
14946
- maxCount: number().default(1)
15944
+ maxCount: number().default(1),
15945
+ waitMs: number().optional()
14947
15946
  }), array(DecodedFrameSchema)), method(object({
14948
15947
  sessionId: string(),
14949
- maxCount: number().default(1)
15948
+ maxCount: number().default(1),
15949
+ waitMs: number().optional()
14950
15950
  }), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
14951
15951
  sessionId: string(),
14952
15952
  config: DecoderSessionConfigSchema.partial()
@@ -15250,14 +16250,63 @@ var ChildLayoutEntrySchema = object({
15250
16250
  collapsed: boolean().optional()
15251
16251
  });
15252
16252
  /** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
15253
- * `device-management.ts`. */
16253
+ * `device-management.ts`. Source is a union: a FIELD source copies a sibling
16254
+ * accessory's status field (`kind` optional/absent for wire compat); a
16255
+ * LITERAL source carries a per-device constant (no sibling is read); a
16256
+ * GLOBAL source (P2e) copies ANY device's status field, addressed by the
16257
+ * source device's full re-sync-stable `stableId`. */
16258
+ var DeviceLinkFieldSourceSchema = object({
16259
+ kind: literal("field").optional(),
16260
+ sourceKey: string(),
16261
+ cap: string(),
16262
+ fieldPath: string()
16263
+ });
16264
+ var DeviceLinkLiteralSourceSchema = object({
16265
+ kind: literal("literal"),
16266
+ value: union([
16267
+ string(),
16268
+ number(),
16269
+ boolean(),
16270
+ _null()
16271
+ ])
16272
+ });
16273
+ var DeviceLinkGlobalSourceSchema = object({
16274
+ kind: literal("global"),
16275
+ sourceStableId: string(),
16276
+ cap: string(),
16277
+ fieldPath: string()
16278
+ });
16279
+ /** Expression source (Stage X): compute the target field from N named bindings
16280
+ * via the safe expression engine. Bindings are field | literal | global — never
16281
+ * another expression (no nesting). The `superRefine` runs the SAME author-time
16282
+ * validation as `validateExpressionSource` (compiles the expr, checks binding
16283
+ * names + identifier coverage) so every wire boundary that parses a DeviceLink
16284
+ * (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
16285
+ * Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
16286
+ var DeviceLinkExpressionSourceSchema = object({
16287
+ kind: literal("expression"),
16288
+ expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
16289
+ bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
16290
+ DeviceLinkFieldSourceSchema,
16291
+ DeviceLinkLiteralSourceSchema,
16292
+ DeviceLinkGlobalSourceSchema
16293
+ ]))
16294
+ }).superRefine((src, ctx) => {
16295
+ const err = validateExpressionSource(src);
16296
+ if (err !== null) ctx.addIssue({
16297
+ code: "custom",
16298
+ message: err,
16299
+ path: ["expr"]
16300
+ });
16301
+ });
15254
16302
  var DeviceLinkSchema = object({
15255
16303
  id: string(),
15256
- source: object({
15257
- sourceKey: string(),
15258
- cap: string(),
15259
- fieldPath: string()
15260
- }),
16304
+ source: union([
16305
+ DeviceLinkFieldSourceSchema,
16306
+ DeviceLinkLiteralSourceSchema,
16307
+ DeviceLinkGlobalSourceSchema,
16308
+ DeviceLinkExpressionSourceSchema
16309
+ ]),
15261
16310
  target: object({
15262
16311
  cap: string(),
15263
16312
  fieldPath: string(),
@@ -15286,6 +16335,31 @@ var DeviceLinkSchema = object({
15286
16335
  })
15287
16336
  ]).optional()
15288
16337
  });
16338
+ /** Cap-wire shape of a per-cap display refinement — mirrors
16339
+ * `DeviceCapDisplayOverride` in `device-management.ts`. */
16340
+ var DeviceCapDisplayOverrideSchema = object({
16341
+ unit: string().min(1).optional(),
16342
+ precision: number().int().min(0).max(10).optional()
16343
+ });
16344
+ /** Cap-wire shape of an operator-authored per-device display override —
16345
+ * mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
16346
+ * bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
16347
+ var DeviceDisplayOverrideSchema = object({
16348
+ icon: string().min(1).optional(),
16349
+ label: string().min(1).optional(),
16350
+ unit: string().min(1).optional(),
16351
+ precision: number().int().min(0).max(10).optional(),
16352
+ hidden: boolean().optional(),
16353
+ perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
16354
+ });
16355
+ /** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
16356
+ * in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
16357
+ * the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
16358
+ var RoleDisplayDefaultSchema = object({
16359
+ unit: string().min(1).optional(),
16360
+ precision: number().int().min(0).max(10).optional(),
16361
+ icon: string().min(1).optional()
16362
+ });
15289
16363
  /**
15290
16364
  * Serializable projection of a live IDevice.
15291
16365
  * Returned by listAll, getDevice, getChildren.
@@ -15341,7 +16415,9 @@ var DeviceInfoSchema = object({
15341
16415
  * `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
15342
16416
  childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
15343
16417
  /** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
15344
- deviceLinks: array(DeviceLinkSchema).readonly().optional()
16418
+ deviceLinks: array(DeviceLinkSchema).readonly().optional(),
16419
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
16420
+ display: DeviceDisplayOverrideSchema.optional()
15345
16421
  });
15346
16422
  var ConfigEntrySchema = object({
15347
16423
  key: string(),
@@ -15406,7 +16482,9 @@ var DeviceMetaSchema = object({
15406
16482
  deviceLinks: array(DeviceLinkSchema).readonly().optional(),
15407
16483
  /** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
15408
16484
  * Optional: only present for accessory children that carry a known role. */
15409
- role: string().nullable().optional()
16485
+ role: string().nullable().optional(),
16486
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
16487
+ display: DeviceDisplayOverrideSchema.optional()
15410
16488
  });
15411
16489
  /** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
15412
16490
  var ConfigUISchemaOutput = unknown().nullable();
@@ -15500,7 +16578,19 @@ method(object({
15500
16578
  }), _void(), {
15501
16579
  kind: "mutation",
15502
16580
  auth: "admin"
15503
- }), method(object({ deviceId: number() }), object({ caps: array(object({
16581
+ }), method(object({
16582
+ deviceId: number(),
16583
+ display: DeviceDisplayOverrideSchema.nullable()
16584
+ }), _void(), {
16585
+ kind: "mutation",
16586
+ auth: "admin"
16587
+ }), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
16588
+ kind: "mutation",
16589
+ auth: "admin"
16590
+ }), method(object({
16591
+ deviceId: number(),
16592
+ includeSynthesizable: boolean().optional()
16593
+ }), object({ caps: array(object({
15504
16594
  cap: string(),
15505
16595
  fields: array(object({
15506
16596
  path: string(),
@@ -15510,8 +16600,13 @@ method(object({
15510
16600
  "boolean",
15511
16601
  "enum"
15512
16602
  ]),
15513
- enumValues: array(string()).optional()
15514
- })).readonly()
16603
+ enumValues: array(string()).optional(),
16604
+ item: boolean().optional()
16605
+ })).readonly(),
16606
+ itemArray: object({
16607
+ path: string(),
16608
+ keyField: string()
16609
+ }).optional()
15515
16610
  })).readonly() }), { kind: "query" }), method(object({
15516
16611
  deviceId: number(),
15517
16612
  role: string().nullable()
@@ -15581,7 +16676,11 @@ method(object({
15581
16676
  deviceId: number(),
15582
16677
  entries: array(object({
15583
16678
  capName: string(),
15584
- kind: _enum(["native", "wrapped"]),
16679
+ kind: _enum([
16680
+ "native",
16681
+ "wrapped",
16682
+ "linked"
16683
+ ]),
15585
16684
  providerAddonId: string(),
15586
16685
  providerNodeId: string(),
15587
16686
  nativeAddonId: string()
@@ -15590,7 +16689,11 @@ method(object({
15590
16689
  deviceId: number(),
15591
16690
  entries: array(object({
15592
16691
  capName: string(),
15593
- kind: _enum(["native", "wrapped"]),
16692
+ kind: _enum([
16693
+ "native",
16694
+ "wrapped",
16695
+ "linked"
16696
+ ]),
15594
16697
  providerAddonId: string(),
15595
16698
  providerNodeId: string(),
15596
16699
  nativeAddonId: string()
@@ -16080,7 +17183,7 @@ var AddBrokerInputSchema = object({
16080
17183
  });
16081
17184
  var AddBrokerResultSchema = object({ id: string() });
16082
17185
  var IdInputSchema = object({ id: string() });
16083
- var TestResultSchema = discriminatedUnion("ok", [object({
17186
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
16084
17187
  ok: literal(true),
16085
17188
  latencyMs: number()
16086
17189
  }), object({
@@ -16103,7 +17206,7 @@ var StatusSchema = object({
16103
17206
  brokerCount: number(),
16104
17207
  embeddedRunning: boolean()
16105
17208
  });
16106
- 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);
17209
+ 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);
16107
17210
  var NetworkEndpointSchema = object({
16108
17211
  url: string(),
16109
17212
  hostname: string(),
@@ -16137,23 +17240,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16137
17240
  sourcePort: number().optional()
16138
17241
  });
16139
17242
  method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16140
- method(object({
16141
- title: string(),
17243
+ /**
17244
+ * notification-output — canonical, capability-gated notification delivery.
17245
+ *
17246
+ * Apprise-derived model (see
17247
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
17248
+ * callers emit ONE canonical `Notification`; each provider declares a
17249
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
17250
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
17251
+ * message to what the kind supports — callers never special-case a service.
17252
+ *
17253
+ * DESIGN DECISIONS (locked):
17254
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
17255
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
17256
+ * cap. Rationale: the admin UI needs one uniform surface across the
17257
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
17258
+ * alternative would fork the UI per addon and cannot host the
17259
+ * discovery→adopt flow.
17260
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
17261
+ * the generated cap-mount auto-`concatCollection`-fans them across every
17262
+ * registered provider (notifiers addon + HA addon) so one catalog is
17263
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
17264
+ * `addonId` the generated collection router extracts from the call input.
17265
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
17266
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
17267
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
17268
+ * base64 fallback needed.
17269
+ *
17270
+ * TODO (deferred, closed-set change — separate decision): add
17271
+ * `providerKind: 'notify'` so notification providers surface on the unified
17272
+ * admin "Integrations" page.
17273
+ */
17274
+ /**
17275
+ * Zentik-derived typed-media enum — the superset across every kind. Each
17276
+ * adapter picks what it supports and the degrade engine filters the rest.
17277
+ */
17278
+ var AttachmentMediaTypeSchema = _enum([
17279
+ "image",
17280
+ "video",
17281
+ "gif",
17282
+ "audio",
17283
+ "icon"
17284
+ ]);
17285
+ /**
17286
+ * A single attachment. Exactly one of `url` (remote source, most adapters
17287
+ * prefer this) or `bytes` (inline source; required for Pushover-style
17288
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
17289
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
17290
+ */
17291
+ var AttachmentSchema = object({
17292
+ mediaType: AttachmentMediaTypeSchema,
17293
+ url: string().optional(),
17294
+ bytes: _instanceof(Uint8Array).optional(),
17295
+ mime: string().optional(),
17296
+ name: string().optional()
17297
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
17298
+ var NotificationFormatSchema = _enum([
17299
+ "text",
17300
+ "markdown",
17301
+ "html"
17302
+ ]);
17303
+ /** A single tap-through action button. */
17304
+ var NotificationActionSchema = object({
17305
+ id: string(),
17306
+ label: string(),
17307
+ url: string().optional()
17308
+ });
17309
+ /**
17310
+ * The canonical notification. `body` is the only hard field (Apprise model).
17311
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
17312
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
17313
+ * the adapter maps this ordinal onto its native level. `level?` is an
17314
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
17315
+ * `priority` for that one target.
17316
+ */
17317
+ var NotificationSchema = object({
16142
17318
  body: string(),
16143
- imageUrl: string().optional(),
17319
+ title: string().optional(),
17320
+ format: NotificationFormatSchema.default("text"),
17321
+ priority: number().int().min(1).max(5).default(3),
17322
+ level: string().optional(),
17323
+ attachments: array(AttachmentSchema).optional(),
17324
+ clickUrl: string().optional(),
17325
+ actions: array(NotificationActionSchema).optional(),
17326
+ sound: string().optional(),
17327
+ ttl: number().optional(),
17328
+ tag: string().optional(),
16144
17329
  deviceId: number().optional(),
16145
17330
  eventId: string().optional(),
16146
- priority: _enum([
16147
- "low",
16148
- "normal",
16149
- "high",
16150
- "critical"
16151
- ]).default("normal"),
16152
17331
  metadata: record(string(), unknown()).optional()
16153
- }), _void(), { kind: "mutation" }), method(_void(), object({
17332
+ });
17333
+ /** One declared native severity/priority level for a kind. */
17334
+ var TargetKindLevelSchema = object({
17335
+ id: string(),
17336
+ label: string(),
17337
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
17338
+ ordinal: number().int().min(1).max(5).nullable(),
17339
+ flags: object({
17340
+ critical: boolean().optional(),
17341
+ silent: boolean().optional(),
17342
+ noPush: boolean().optional()
17343
+ }).optional(),
17344
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
17345
+ requires: array(string()).optional(),
17346
+ description: string().optional()
17347
+ });
17348
+ /** The full capability block consulted before dispatch. */
17349
+ var TargetKindCapsSchema = object({
17350
+ attachments: object({
17351
+ mediaTypes: array(AttachmentMediaTypeSchema),
17352
+ mode: _enum([
17353
+ "url",
17354
+ "bytes",
17355
+ "both"
17356
+ ]),
17357
+ max: number().int().nonnegative(),
17358
+ maxBytes: number().int().positive().optional()
17359
+ }),
17360
+ /** Max action buttons (0 = none). */
17361
+ actions: number().int().nonnegative(),
17362
+ levels: array(TargetKindLevelSchema),
17363
+ format: array(NotificationFormatSchema),
17364
+ clickUrl: boolean(),
17365
+ sound: boolean(),
17366
+ ttl: boolean(),
17367
+ bodyMaxLen: number().int().positive()
17368
+ });
17369
+ /**
17370
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
17371
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
17372
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
17373
+ * the union is large and not meant for runtime validation here; the exported
17374
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
17375
+ */
17376
+ var ConfigSchemaPassthrough = unknown();
17377
+ var TargetKindSchema = object({
17378
+ kind: string(),
17379
+ label: string(),
17380
+ icon: string(),
17381
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
17382
+ addonId: string(),
17383
+ configSchema: ConfigSchemaPassthrough,
17384
+ supportsDiscovery: boolean(),
17385
+ caps: TargetKindCapsSchema
17386
+ });
17387
+ /**
17388
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
17389
+ * (return a presence marker only) when serving `listTargets` — never
17390
+ * round-trip a stored secret to the UI.
17391
+ */
17392
+ var TargetSchema = object({
17393
+ id: string(),
17394
+ name: string(),
17395
+ kind: string(),
17396
+ addonId: string(),
17397
+ enabled: boolean(),
17398
+ config: record(string(), unknown())
17399
+ });
17400
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
17401
+ var DiscoveredTargetSchema = object({
17402
+ kind: string(),
17403
+ suggestedName: string(),
17404
+ config: record(string(), unknown())
17405
+ });
17406
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
17407
+ var RenderedAsSchema = object({
17408
+ level: string(),
17409
+ format: NotificationFormatSchema,
17410
+ attachmentsSent: number().int().nonnegative(),
17411
+ actionsSent: number().int().nonnegative(),
17412
+ truncated: boolean(),
17413
+ dropped: array(string())
17414
+ });
17415
+ var SendResultSchema = object({
16154
17416
  success: boolean(),
16155
- error: string().optional()
16156
- }), { kind: "mutation" });
17417
+ error: string().optional(),
17418
+ renderedAs: RenderedAsSchema.optional()
17419
+ });
17420
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
17421
+ var TestResultSchema = SendResultSchema;
17422
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
17423
+ kind: string(),
17424
+ config: record(string(), unknown()).optional()
17425
+ }), array(DiscoveredTargetSchema)), method(object({
17426
+ targetId: string(),
17427
+ notification: NotificationSchema
17428
+ }), SendResultSchema, { kind: "mutation" }), method(object({
17429
+ targetId: string(),
17430
+ sample: NotificationSchema.optional()
17431
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
17432
+ targetId: string(),
17433
+ enabled: boolean()
17434
+ }), _void(), { kind: "mutation" });
16157
17435
  /**
16158
17436
  * Zod schemas for persisted record types.
16159
17437
  *
@@ -19175,7 +20453,10 @@ var HwAccelBackendInputSchema = _enum([
19175
20453
  "webgpu",
19176
20454
  "none"
19177
20455
  ]).nullable().optional();
19178
- var HwAccelResolutionSchema = object({ preferred: array(string()).readonly() });
20456
+ var HwAccelResolutionSchema = object({
20457
+ preferred: array(string()).readonly(),
20458
+ rationale: string()
20459
+ });
19179
20460
  var HardwareEncoderIdSchema = _enum([
19180
20461
  "h264_videotoolbox",
19181
20462
  "hevc_videotoolbox",
@@ -19280,10 +20561,7 @@ var ResolvedInferenceConfigSchema = object({
19280
20561
  format: ModelFormatSchema,
19281
20562
  reason: string()
19282
20563
  });
19283
- method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
19284
- prefer: HwAccelBackendInputSchema,
19285
- nodeId: string().optional()
19286
- }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
20564
+ method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
19287
20565
  kind: "mutation",
19288
20566
  auth: "admin"
19289
20567
  }), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
@@ -19342,6 +20620,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
19342
20620
  kind: "mutation",
19343
20621
  auth: "admin"
19344
20622
  });
20623
+ /**
20624
+ * `recording` cap — footage availability + HLS playback manifests + per-device
20625
+ * recording config. NOTE on events (source of truth, R5/C3): this cap carries
20626
+ * NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
20627
+ * events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
20628
+ * rows); the recorder's internal EventMap markers are ephemeral in-RAM
20629
+ * annotations that are not exposed here and must not be treated as an event
20630
+ * feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
20631
+ * (`interfaces/recording-config.ts`).
20632
+ */
19345
20633
  var RecordingStatusSchema = object({
19346
20634
  deviceId: number(),
19347
20635
  enabled: boolean(),
@@ -20978,6 +22266,12 @@ Object.freeze({
20978
22266
  addonId: null,
20979
22267
  access: "view"
20980
22268
  },
22269
+ "deviceManager.getRoleDisplayDefaults": {
22270
+ capName: "device-manager",
22271
+ capScope: "system",
22272
+ addonId: null,
22273
+ access: "view"
22274
+ },
20981
22275
  "deviceManager.getSettingsSchema": {
20982
22276
  capName: "device-manager",
20983
22277
  capScope: "system",
@@ -21128,6 +22422,12 @@ Object.freeze({
21128
22422
  addonId: null,
21129
22423
  access: "create"
21130
22424
  },
22425
+ "deviceManager.setDisplay": {
22426
+ capName: "device-manager",
22427
+ capScope: "system",
22428
+ addonId: null,
22429
+ access: "create"
22430
+ },
21131
22431
  "deviceManager.setIntegrationId": {
21132
22432
  capName: "device-manager",
21133
22433
  capScope: "system",
@@ -21170,6 +22470,12 @@ Object.freeze({
21170
22470
  addonId: null,
21171
22471
  access: "create"
21172
22472
  },
22473
+ "deviceManager.setRoleDisplayDefaults": {
22474
+ capName: "device-manager",
22475
+ capScope: "system",
22476
+ addonId: null,
22477
+ access: "create"
22478
+ },
21173
22479
  "deviceManager.setStreamProfileMap": {
21174
22480
  capName: "device-manager",
21175
22481
  capScope: "system",
@@ -22148,13 +23454,49 @@ Object.freeze({
22148
23454
  addonId: null,
22149
23455
  access: "create"
22150
23456
  },
23457
+ "notificationOutput.deleteTarget": {
23458
+ capName: "notification-output",
23459
+ capScope: "system",
23460
+ addonId: null,
23461
+ access: "delete"
23462
+ },
23463
+ "notificationOutput.discoverTargets": {
23464
+ capName: "notification-output",
23465
+ capScope: "system",
23466
+ addonId: null,
23467
+ access: "view"
23468
+ },
23469
+ "notificationOutput.listTargetKinds": {
23470
+ capName: "notification-output",
23471
+ capScope: "system",
23472
+ addonId: null,
23473
+ access: "view"
23474
+ },
23475
+ "notificationOutput.listTargets": {
23476
+ capName: "notification-output",
23477
+ capScope: "system",
23478
+ addonId: null,
23479
+ access: "view"
23480
+ },
22151
23481
  "notificationOutput.send": {
22152
23482
  capName: "notification-output",
22153
23483
  capScope: "system",
22154
23484
  addonId: null,
22155
23485
  access: "create"
22156
23486
  },
22157
- "notificationOutput.sendTest": {
23487
+ "notificationOutput.setTargetEnabled": {
23488
+ capName: "notification-output",
23489
+ capScope: "system",
23490
+ addonId: null,
23491
+ access: "create"
23492
+ },
23493
+ "notificationOutput.testTarget": {
23494
+ capName: "notification-output",
23495
+ capScope: "system",
23496
+ addonId: null,
23497
+ access: "create"
23498
+ },
23499
+ "notificationOutput.upsertTarget": {
22158
23500
  capName: "notification-output",
22159
23501
  capScope: "system",
22160
23502
  addonId: null,
@@ -22184,6 +23526,66 @@ Object.freeze({
22184
23526
  addonId: null,
22185
23527
  access: "create"
22186
23528
  },
23529
+ "petFeeder.callPet": {
23530
+ capName: "pet-feeder",
23531
+ capScope: "device",
23532
+ addonId: null,
23533
+ access: "create"
23534
+ },
23535
+ "petFeeder.cancelFeed": {
23536
+ capName: "pet-feeder",
23537
+ capScope: "device",
23538
+ addonId: null,
23539
+ access: "create"
23540
+ },
23541
+ "petFeeder.feed": {
23542
+ capName: "pet-feeder",
23543
+ capScope: "device",
23544
+ addonId: null,
23545
+ access: "create"
23546
+ },
23547
+ "petFeeder.markFoodReplenished": {
23548
+ capName: "pet-feeder",
23549
+ capScope: "device",
23550
+ addonId: null,
23551
+ access: "create"
23552
+ },
23553
+ "petFeeder.playSound": {
23554
+ capName: "pet-feeder",
23555
+ capScope: "device",
23556
+ addonId: null,
23557
+ access: "create"
23558
+ },
23559
+ "petFeeder.resetDesiccant": {
23560
+ capName: "pet-feeder",
23561
+ capScope: "device",
23562
+ addonId: null,
23563
+ access: "delete"
23564
+ },
23565
+ "petFeeder.setChildLock": {
23566
+ capName: "pet-feeder",
23567
+ capScope: "device",
23568
+ addonId: null,
23569
+ access: "create"
23570
+ },
23571
+ "petFeeder.setFeedSound": {
23572
+ capName: "pet-feeder",
23573
+ capScope: "device",
23574
+ addonId: null,
23575
+ access: "create"
23576
+ },
23577
+ "petFeeder.setIndicatorLight": {
23578
+ capName: "pet-feeder",
23579
+ capScope: "device",
23580
+ addonId: null,
23581
+ access: "create"
23582
+ },
23583
+ "petFeeder.setVolume": {
23584
+ capName: "pet-feeder",
23585
+ capScope: "device",
23586
+ addonId: null,
23587
+ access: "create"
23588
+ },
22187
23589
  "pipelineAnalytics.clearTracks": {
22188
23590
  capName: "pipeline-analytics",
22189
23591
  capScope: "device",