@camstack/addon-import-alexa 0.1.11 → 0.1.13

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.js CHANGED
@@ -4681,7 +4681,7 @@ function preprocess(fn, schema) {
4681
4681
  });
4682
4682
  }
4683
4683
  //#endregion
4684
- //#region ../types/dist/sleep-C2M2zF7x.mjs
4684
+ //#region ../types/dist/sleep-BiDFW0E7.mjs
4685
4685
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4686
4686
  EventCategory["SystemBoot"] = "system.boot";
4687
4687
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5494,6 +5494,100 @@ function createDurableState(deps) {
5494
5494
  };
5495
5495
  }
5496
5496
  /**
5497
+ * Per-node scoping for the shared addon-settings blob.
5498
+ *
5499
+ * An addon's settings store is hub-central (the `addon-settings` cap is
5500
+ * hub-routed — the hub instance answers for every node), so fields whose
5501
+ * value is a NODE fact (decoder backend, engine pick, probed hardware
5502
+ * capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
5503
+ * the single shared blob. The SCHEMA field key stays bare: the write path
5504
+ * ({@link scopePatch}) maps the bare field onto the target node's scoped
5505
+ * key; the read/hydrate path ({@link projectStore}) maps THIS node's value
5506
+ * back, so UI forms and `resolveConfig` only ever see the bare key.
5507
+ *
5508
+ * Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
5509
+ * (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
5510
+ * schema and routes reads/writes through these helpers.
5511
+ *
5512
+ * ## No bare-key fallback — deliberate
5513
+ *
5514
+ * {@link readNodeValue} reads the node-scoped key ONLY. A node with no
5515
+ * scoped key resolves to `undefined` so the field's schema `default` wins —
5516
+ * NEVER `store[base]` and never another node's value. A bare legacy key in
5517
+ * the store is invisible to every node, hub included, so one node's
5518
+ * selection can never leak onto another. (This generalizes the
5519
+ * `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
5520
+ * arbitrary set of per-node field keys.)
5521
+ *
5522
+ * Pure functions only — no I/O, no imports beyond the language. This is a
5523
+ * LEAF module: import it via its deep path, never from the root barrel.
5524
+ */
5525
+ /**
5526
+ * Normalize a raw kernel node id to the bare node id used for scoping.
5527
+ * `localNodeId` can carry a `<node>/<addon>` suffix on forked child
5528
+ * processes; per-node settings are per-NODE, so strip the addon segment.
5529
+ * `undefined` / `null` / empty falls back to `'hub'`.
5530
+ */
5531
+ function normalizeNodeId(raw) {
5532
+ if (raw === void 0 || raw === null || raw === "") return "hub";
5533
+ const slashIdx = raw.indexOf("/");
5534
+ if (slashIdx < 0) return raw;
5535
+ const bare = raw.slice(0, slashIdx);
5536
+ return bare === "" ? "hub" : bare;
5537
+ }
5538
+ /** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
5539
+ function nodeScopedKey(base, nodeId) {
5540
+ return `${base}@${normalizeNodeId(nodeId)}`;
5541
+ }
5542
+ /**
5543
+ * Read a node's value for a per-node field from the raw shared store:
5544
+ * the node-scoped key when present, otherwise `undefined`.
5545
+ * Deliberately NO bare-key fallback (see module doc) — the caller lets the
5546
+ * schema `default` win on `undefined`.
5547
+ */
5548
+ function readNodeValue(store, base, nodeId) {
5549
+ return store[nodeScopedKey(base, nodeId)];
5550
+ }
5551
+ /**
5552
+ * Re-map a UI/settings patch so every bare perNode field persists under the
5553
+ * TARGET node's scoped key; all other keys pass through unchanged. Used on
5554
+ * the write path so a save for one node never clobbers another node's value
5555
+ * (and the bare key is never written). Returns a new object — the input
5556
+ * patch is not mutated.
5557
+ */
5558
+ function scopePatch(patch, perNodeKeys, nodeId) {
5559
+ const out = {};
5560
+ for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
5561
+ return out;
5562
+ }
5563
+ /**
5564
+ * Project the raw shared store onto the bare schema keys for ONE node so a
5565
+ * UI schema (whose field keys are bare) hydrates from that node's own
5566
+ * values:
5567
+ *
5568
+ * - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
5569
+ * - Every bare perNode key is dropped from the pass-through (a stray bare
5570
+ * legacy key must never hydrate any node — no bare fallback).
5571
+ * - THIS node's effective value ({@link readNodeValue}) is then laid onto
5572
+ * each bare perNode key; when the node has no scoped key the bare key is
5573
+ * left ABSENT so the field's schema `default` wins.
5574
+ *
5575
+ * Returns a new object — the input store is not mutated.
5576
+ */
5577
+ function projectStore(store, perNodeKeys, nodeId) {
5578
+ const out = {};
5579
+ for (const [key, value] of Object.entries(store)) {
5580
+ if (key.includes("@")) continue;
5581
+ if (perNodeKeys.has(key)) continue;
5582
+ out[key] = value;
5583
+ }
5584
+ for (const base of perNodeKeys) {
5585
+ const value = readNodeValue(store, base, nodeId);
5586
+ if (value !== void 0) out[base] = value;
5587
+ }
5588
+ return out;
5589
+ }
5590
+ /**
5497
5591
  * Base class for CamStack addons. Eliminates settings boilerplate:
5498
5592
  *
5499
5593
  * - Typed `config` property with automatic resolution from store + defaults
@@ -5661,23 +5755,63 @@ var BaseAddon = class {
5661
5755
  deviceSettingsSchema() {
5662
5756
  return null;
5663
5757
  }
5664
- async getGlobalSettings(overlay, cap, _nodeId) {
5758
+ async getGlobalSettings(overlay, cap, nodeId) {
5665
5759
  const schema = this.globalSettingsSchema(cap);
5666
5760
  if (!schema) return { sections: [] };
5667
- const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5761
+ const projected = await this.resolveGlobalStore(nodeId, cap);
5668
5762
  return hydrateSchema(schema, overlay ? {
5669
- ...raw,
5763
+ ...projected,
5670
5764
  ...overlay
5671
- } : raw);
5765
+ } : projected);
5672
5766
  }
5673
- async updateGlobalSettings(patch, _nodeId) {
5674
- await this._ctx?.settings?.writeAddonStore(patch);
5767
+ /**
5768
+ * The raw addon store PROJECTED onto the target node's bare per-node keys:
5769
+ * every `perNode: true` field carries THAT node's scoped value on its bare
5770
+ * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
5771
+ * bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
5772
+ * A no-op passthrough when the schema declares no `perNode` field.
5773
+ *
5774
+ * This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
5775
+ * the store for custom option logic (option narrowing, value snapping) to
5776
+ * read it per-node — never `ctx.settings.readAddonStore()` directly.
5777
+ * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
5778
+ */
5779
+ async resolveGlobalStore(nodeId, cap) {
5780
+ const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5781
+ const keys = this.perNodeKeys(cap);
5782
+ const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5783
+ return keys.size > 0 ? projectStore(raw, keys, node) : raw;
5784
+ }
5785
+ async updateGlobalSettings(patch, nodeId) {
5786
+ const keys = this.perNodeKeys();
5787
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5788
+ const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5789
+ const barePatch = patch;
5790
+ const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
5791
+ await this._ctx?.settings?.writeAddonStore(scoped);
5792
+ if (target !== localNode) return;
5675
5793
  await this.resolveConfig();
5676
5794
  await this.onConfigChanged();
5677
5795
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
5678
5796
  this.maybeAutoRestart(patch, this.globalSettingsSchema());
5679
5797
  }
5680
5798
  /**
5799
+ * The set of field keys the global settings schema declares `perNode: true`
5800
+ * — derived once per `cap` argument and memoized (schemas are static
5801
+ * declarations). Empty set ⇒ every per-node code path is bypassed and the
5802
+ * settings API behaves exactly like the legacy node-agnostic one.
5803
+ */
5804
+ _perNodeKeysCache = /* @__PURE__ */ new Map();
5805
+ perNodeKeys(cap) {
5806
+ const cacheKey = cap ?? "";
5807
+ const cached = this._perNodeKeysCache.get(cacheKey);
5808
+ if (cached) return cached;
5809
+ const schema = this.globalSettingsSchema(cap);
5810
+ const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
5811
+ this._perNodeKeysCache.set(cacheKey, keys);
5812
+ return keys;
5813
+ }
5814
+ /**
5681
5815
  * If any field in `patch` is marked `requiresRestart` in `schema`,
5682
5816
  * schedule an addon restart for the next tick. Deferred via
5683
5817
  * `setImmediate` so the tRPC mutation that triggered the write has
@@ -5830,12 +5964,19 @@ var BaseAddon = class {
5830
5964
  * The merge is shallow: each key in `defaults` is checked against the store.
5831
5965
  * Only keys present in defaults are read — the store can contain extra keys
5832
5966
  * (e.g. from older versions) without polluting the typed config.
5967
+ *
5968
+ * Keys the global settings schema declares `perNode: true` resolve from
5969
+ * THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
5970
+ * from the bare key — so a per-node field resolves to this node's own
5971
+ * selection at boot (absent scoped key ⇒ the constructor default wins).
5833
5972
  */
5834
5973
  async resolveConfig() {
5835
5974
  const stored = await this.readAddonStoreWithRetry();
5975
+ const perNode = this.perNodeKeys();
5976
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5836
5977
  const resolved = { ...this.defaults };
5837
5978
  for (const key of Object.keys(this.defaults)) {
5838
- const storedValue = stored[key];
5979
+ const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
5839
5980
  if (storedValue !== void 0 && storedValue !== null) {
5840
5981
  const defaultType = typeof this.defaults[key];
5841
5982
  if (typeof storedValue === defaultType) resolved[key] = storedValue;
@@ -5919,6 +6060,27 @@ var BaseAddon = class {
5919
6060
  }
5920
6061
  };
5921
6062
  /**
6063
+ * Collect the keys of every field marked `perNode: true`, recursing into
6064
+ * layout containers (`group` fields and `sub-tabs` tabs) the same way
6065
+ * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6066
+ * don't declare `perNode` and are excluded by the `in` narrowing.
6067
+ */
6068
+ function collectPerNodeFieldKeys(fields) {
6069
+ const collected = [];
6070
+ for (const field of fields) {
6071
+ if (field.type === "group") {
6072
+ collected.push(...collectPerNodeFieldKeys(field.fields));
6073
+ continue;
6074
+ }
6075
+ if (field.type === "sub-tabs") {
6076
+ for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
6077
+ continue;
6078
+ }
6079
+ if ("perNode" in field && field.perNode === true) collected.push(field.key);
6080
+ }
6081
+ return collected;
6082
+ }
6083
+ /**
5922
6084
  * Normalize an `ICamstackAddon.initialize()` return value into the
5923
6085
  * `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
5924
6086
  * envelopes pass through; void stays void.
@@ -5943,6 +6105,7 @@ var CamStreamKindSchema = _enum([
5943
6105
  "pull-rtsp",
5944
6106
  "pull-rtmp",
5945
6107
  "pull-http",
6108
+ "pull-flv",
5946
6109
  "pull-rfc4571",
5947
6110
  "push-annexb",
5948
6111
  "derived"
@@ -6325,6 +6488,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
6325
6488
  /** Single still-image entity (HA `image.*`). Read-only display of an
6326
6489
  * `entity_picture` signed URL the browser loads directly. `image` cap. */
6327
6490
  DeviceType["Image"] = "image";
6491
+ /** Smart pet feeder — cloud-connected food dispenser with a bowl food
6492
+ * level, battery, desiccant life, feeding state and manual-feed /
6493
+ * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
6494
+ * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
6495
+ * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
6496
+ * integrations sharing the same food/desiccant/hopper surface. */
6497
+ DeviceType["PetFeeder"] = "pet-feeder";
6328
6498
  return DeviceType;
6329
6499
  }({});
6330
6500
  var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
@@ -7606,6 +7776,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
7606
7776
  for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7607
7777
  for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7608
7778
  /**
7779
+ * Error types for the safe expression engine. Two distinct classes so callers
7780
+ * can tell a compile-time (grammar) failure from a runtime (evaluation)
7781
+ * failure — both are non-fatal to the host: read paths degrade to "skip link".
7782
+ */
7783
+ /** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
7784
+ * the failure is anchored to a character (author-facing inline feedback). */
7785
+ var ExpressionParseError = class extends Error {
7786
+ position;
7787
+ constructor(message, position) {
7788
+ super(message);
7789
+ this.name = "ExpressionParseError";
7790
+ this.position = position;
7791
+ }
7792
+ };
7793
+ /** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
7794
+ * result, unknown builtin, step-budget exceeded). */
7795
+ var ExpressionEvalError = class extends Error {
7796
+ constructor(message) {
7797
+ super(message);
7798
+ this.name = "ExpressionEvalError";
7799
+ }
7800
+ };
7801
+ /**
7802
+ * Resource-bound constants for the safe expression engine.
7803
+ *
7804
+ * Every bound is defense-in-depth: the grammar is non-Turing-complete (no
7805
+ * loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
7806
+ * O(nodeCount) by construction. These caps merely put a hard ceiling on the
7807
+ * work a single author-supplied expression can request, so a hostile or
7808
+ * accidental pathological string can never spend unbounded CPU/memory.
7809
+ */
7810
+ /** Max source length (chars) — checked BEFORE tokenizing so a huge string is
7811
+ * rejected without allocation. */
7812
+ var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
7813
+ /** A legal binding / identifier name. */
7814
+ var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
7815
+ /** Binding names an author may NOT use: `now` is auto-injected; the literal
7816
+ * keywords lex as values, not identifiers, so binding to them is meaningless. */
7817
+ var RESERVED_BINDING_NAMES = new Set([
7818
+ "now",
7819
+ "true",
7820
+ "false",
7821
+ "null"
7822
+ ]);
7823
+ /**
7824
+ * Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
7825
+ * zero-dependency. The grammar is deliberately boring: decimal numbers,
7826
+ * single/double-quoted strings with a tiny escape set, identifiers, the three
7827
+ * value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
7828
+ * outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
7829
+ * is a parse error with a source position, so member access / assignment /
7830
+ * template literals are lexically impossible.
7831
+ */
7832
+ var KEYWORDS = new Set([
7833
+ "true",
7834
+ "false",
7835
+ "null"
7836
+ ]);
7837
+ function isDigit(ch) {
7838
+ return ch >= "0" && ch <= "9";
7839
+ }
7840
+ function isIdentStart(ch) {
7841
+ return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
7842
+ }
7843
+ function isIdentPart(ch) {
7844
+ return isIdentStart(ch) || isDigit(ch);
7845
+ }
7846
+ function isWhitespace(ch) {
7847
+ return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
7848
+ }
7849
+ /** Tokenize `source` into a flat token list ending with a single `eof` token.
7850
+ * Throws `ExpressionParseError` on any illegal character or unterminated
7851
+ * string. */
7852
+ function tokenize(source) {
7853
+ if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
7854
+ const tokens = [];
7855
+ let i = 0;
7856
+ const n = source.length;
7857
+ while (i < n) {
7858
+ const ch = source[i];
7859
+ if (isWhitespace(ch)) {
7860
+ i += 1;
7861
+ continue;
7862
+ }
7863
+ if (isDigit(ch)) {
7864
+ const start = i;
7865
+ while (i < n && isDigit(source[i])) i += 1;
7866
+ if (i < n && source[i] === ".") {
7867
+ if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
7868
+ i += 1;
7869
+ while (i < n && isDigit(source[i])) i += 1;
7870
+ }
7871
+ const text = source.slice(start, i);
7872
+ const value = Number(text);
7873
+ if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
7874
+ tokens.push({
7875
+ type: "number",
7876
+ value,
7877
+ pos: start
7878
+ });
7879
+ continue;
7880
+ }
7881
+ if (ch === "'" || ch === "\"") {
7882
+ const quote = ch;
7883
+ const start = i;
7884
+ i += 1;
7885
+ let out = "";
7886
+ let closed = false;
7887
+ while (i < n) {
7888
+ const c = source[i];
7889
+ if (c === "\\") {
7890
+ const next = i + 1 < n ? source[i + 1] : "";
7891
+ if (next === "\\" || next === "'" || next === "\"") {
7892
+ out += next;
7893
+ i += 2;
7894
+ continue;
7895
+ }
7896
+ throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
7897
+ }
7898
+ if (c === quote) {
7899
+ closed = true;
7900
+ i += 1;
7901
+ break;
7902
+ }
7903
+ out += c;
7904
+ i += 1;
7905
+ }
7906
+ if (!closed) throw new ExpressionParseError("unterminated string literal", start);
7907
+ tokens.push({
7908
+ type: "string",
7909
+ value: out,
7910
+ pos: start
7911
+ });
7912
+ continue;
7913
+ }
7914
+ if (isIdentStart(ch)) {
7915
+ const start = i;
7916
+ while (i < n && isIdentPart(source[i])) i += 1;
7917
+ const text = source.slice(start, i);
7918
+ if (KEYWORDS.has(text)) tokens.push({
7919
+ type: "keyword",
7920
+ keyword: keywordOf(text),
7921
+ pos: start
7922
+ });
7923
+ else tokens.push({
7924
+ type: "identifier",
7925
+ name: text,
7926
+ pos: start
7927
+ });
7928
+ continue;
7929
+ }
7930
+ const two = i + 1 < n ? source.slice(i, i + 2) : "";
7931
+ if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
7932
+ tokens.push({
7933
+ type: "punct",
7934
+ punct: two,
7935
+ pos: i
7936
+ });
7937
+ i += 2;
7938
+ continue;
7939
+ }
7940
+ if (isSinglePunct(ch)) {
7941
+ tokens.push({
7942
+ type: "punct",
7943
+ punct: ch,
7944
+ pos: i
7945
+ });
7946
+ i += 1;
7947
+ continue;
7948
+ }
7949
+ throw new ExpressionParseError(`unexpected character '${ch}'`, i);
7950
+ }
7951
+ tokens.push({
7952
+ type: "eof",
7953
+ pos: n
7954
+ });
7955
+ return tokens;
7956
+ }
7957
+ function keywordOf(text) {
7958
+ if (text === "true") return "true";
7959
+ if (text === "false") return "false";
7960
+ return "null";
7961
+ }
7962
+ function isSinglePunct(ch) {
7963
+ return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
7964
+ }
7965
+ /**
7966
+ * Frozen, null-prototype builtin function table for the expression engine
7967
+ * (spec §4 rule 4). The table is the SOLE surface of callable functions: the
7968
+ * parser rejects any callee not in it, and the evaluator gates each call on an
7969
+ * own-property check against it.
7970
+ *
7971
+ * Because the object has a NULL prototype AND is `Object.freeze`d:
7972
+ * - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
7973
+ * - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
7974
+ * (there is no `Object.prototype` in the chain), so those names are not
7975
+ * callable — they are simply "unknown function" at parse time.
7976
+ *
7977
+ * Every numeric argument is validated as a finite number and every numeric
7978
+ * RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
7979
+ * (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
7980
+ * closed rather than emitting a garbage value.
7981
+ */
7982
+ function asFiniteNumber(value, name, index) {
7983
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
7984
+ return value;
7985
+ }
7986
+ function asString$1(value, name, index) {
7987
+ if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
7988
+ return value;
7989
+ }
7990
+ function finiteResult(value, name) {
7991
+ if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
7992
+ return value;
7993
+ }
7994
+ function allFiniteNumbers(args, name) {
7995
+ return args.map((a, idx) => asFiniteNumber(a, name, idx));
7996
+ }
7997
+ var INF = Number.POSITIVE_INFINITY;
7998
+ var table = {
7999
+ min: {
8000
+ minArgs: 1,
8001
+ maxArgs: INF,
8002
+ apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
8003
+ },
8004
+ max: {
8005
+ minArgs: 1,
8006
+ maxArgs: INF,
8007
+ apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
8008
+ },
8009
+ abs: {
8010
+ minArgs: 1,
8011
+ maxArgs: 1,
8012
+ apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
8013
+ },
8014
+ floor: {
8015
+ minArgs: 1,
8016
+ maxArgs: 1,
8017
+ apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
8018
+ },
8019
+ ceil: {
8020
+ minArgs: 1,
8021
+ maxArgs: 1,
8022
+ apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
8023
+ },
8024
+ sqrt: {
8025
+ minArgs: 1,
8026
+ maxArgs: 1,
8027
+ apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
8028
+ },
8029
+ round: {
8030
+ minArgs: 1,
8031
+ maxArgs: 2,
8032
+ apply: (args) => {
8033
+ const x = asFiniteNumber(args[0], "round", 0);
8034
+ const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
8035
+ if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
8036
+ const factor = 10 ** digits;
8037
+ return finiteResult(Math.round(x * factor) / factor, "round");
8038
+ }
8039
+ },
8040
+ pow: {
8041
+ minArgs: 2,
8042
+ maxArgs: 2,
8043
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
8044
+ },
8045
+ clamp: {
8046
+ minArgs: 3,
8047
+ maxArgs: 3,
8048
+ apply: (args) => {
8049
+ const x = asFiniteNumber(args[0], "clamp", 0);
8050
+ const lo = asFiniteNumber(args[1], "clamp", 1);
8051
+ const hi = asFiniteNumber(args[2], "clamp", 2);
8052
+ if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
8053
+ return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
8054
+ }
8055
+ },
8056
+ avg: {
8057
+ minArgs: 1,
8058
+ maxArgs: INF,
8059
+ apply: (args) => {
8060
+ const nums = allFiniteNumbers(args, "avg");
8061
+ return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
8062
+ }
8063
+ },
8064
+ sum: {
8065
+ minArgs: 1,
8066
+ maxArgs: INF,
8067
+ apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
8068
+ },
8069
+ coalesce: {
8070
+ minArgs: 1,
8071
+ maxArgs: INF,
8072
+ apply: (args) => {
8073
+ for (const a of args) if (a !== null) return a;
8074
+ return null;
8075
+ }
8076
+ },
8077
+ age: {
8078
+ minArgs: 2,
8079
+ maxArgs: 2,
8080
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
8081
+ },
8082
+ convert: {
8083
+ minArgs: 3,
8084
+ maxArgs: 3,
8085
+ apply: (args, hooks) => {
8086
+ const x = asFiniteNumber(args[0], "convert", 0);
8087
+ const from = asString$1(args[1], "convert", 1).trim();
8088
+ const to = asString$1(args[2], "convert", 2).trim();
8089
+ if (hooks.convert) {
8090
+ const out = hooks.convert(x, from, to);
8091
+ if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
8092
+ return finiteResult(out, "convert");
8093
+ }
8094
+ if (from === to) return x;
8095
+ throw new ExpressionEvalError("convert: unit conversion table not installed");
8096
+ }
8097
+ }
8098
+ };
8099
+ Object.freeze(Object.assign(Object.create(null), table));
8100
+ /** The set of valid builtin names — used by the parser to reject unknown
8101
+ * callees at parse time (immediate author feedback). */
8102
+ var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
8103
+ /**
8104
+ * Pratt (precedence-climbing) parser for the safe expression mini-language.
8105
+ *
8106
+ * Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
8107
+ * → relational → additive → multiplicative → unary `! -` → call / primary.
8108
+ * Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
8109
+ * string validated against the builtin table at parse time, so an unknown
8110
+ * function is rejected immediately (author feedback) and a persisted expression
8111
+ * that references a since-removed builtin degrades at read.
8112
+ *
8113
+ * A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
8114
+ * arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
8115
+ */
8116
+ /** Binary/logical operator precedence (higher binds tighter). */
8117
+ var BINARY_PRECEDENCE = {
8118
+ "||": 1,
8119
+ "&&": 2,
8120
+ "==": 3,
8121
+ "!=": 3,
8122
+ "<": 4,
8123
+ "<=": 4,
8124
+ ">": 4,
8125
+ ">=": 4,
8126
+ "+": 5,
8127
+ "-": 5,
8128
+ "*": 6,
8129
+ "/": 6,
8130
+ "%": 6
8131
+ };
8132
+ function isLogicalOp(op) {
8133
+ return op === "&&" || op === "||";
8134
+ }
8135
+ function isBinaryOp(op) {
8136
+ return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
8137
+ }
8138
+ var Parser = class {
8139
+ tokens;
8140
+ pos = 0;
8141
+ nodeCount = 0;
8142
+ identifiers = /* @__PURE__ */ new Set();
8143
+ callees = /* @__PURE__ */ new Set();
8144
+ constructor(tokens) {
8145
+ this.tokens = tokens;
8146
+ }
8147
+ parse() {
8148
+ const ast = this.parseTernary();
8149
+ const tok = this.peek();
8150
+ if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
8151
+ return {
8152
+ ast,
8153
+ identifiers: this.identifiers,
8154
+ callees: this.callees,
8155
+ nodeCount: this.nodeCount
8156
+ };
8157
+ }
8158
+ peek() {
8159
+ return this.tokens[this.pos];
8160
+ }
8161
+ next() {
8162
+ return this.tokens[this.pos++];
8163
+ }
8164
+ /** Consume a punctuator token, erroring if the next token isn't it. */
8165
+ expectPunct(punct) {
8166
+ const tok = this.peek();
8167
+ if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
8168
+ this.pos += 1;
8169
+ }
8170
+ matchPunct(punct) {
8171
+ const tok = this.peek();
8172
+ if (tok.type === "punct" && tok.punct === punct) {
8173
+ this.pos += 1;
8174
+ return true;
8175
+ }
8176
+ return false;
8177
+ }
8178
+ countNode() {
8179
+ this.nodeCount += 1;
8180
+ if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
8181
+ }
8182
+ parseTernary() {
8183
+ const test = this.parseBinary(1);
8184
+ if (this.matchPunct("?")) {
8185
+ const consequent = this.parseTernary();
8186
+ this.expectPunct(":");
8187
+ const alternate = this.parseTernary();
8188
+ this.countNode();
8189
+ return {
8190
+ kind: "conditional",
8191
+ test,
8192
+ consequent,
8193
+ alternate
8194
+ };
8195
+ }
8196
+ return test;
8197
+ }
8198
+ parseBinary(minPrec) {
8199
+ let left = this.parseUnary();
8200
+ for (;;) {
8201
+ const tok = this.peek();
8202
+ if (tok.type !== "punct") break;
8203
+ const prec = BINARY_PRECEDENCE[tok.punct];
8204
+ if (prec === void 0 || prec < minPrec) break;
8205
+ const op = tok.punct;
8206
+ this.pos += 1;
8207
+ const right = this.parseBinary(prec + 1);
8208
+ this.countNode();
8209
+ if (isLogicalOp(op)) left = {
8210
+ kind: "logical",
8211
+ op,
8212
+ left,
8213
+ right
8214
+ };
8215
+ else if (isBinaryOp(op)) left = {
8216
+ kind: "binary",
8217
+ op,
8218
+ left,
8219
+ right
8220
+ };
8221
+ else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
8222
+ }
8223
+ return left;
8224
+ }
8225
+ parseUnary() {
8226
+ const tok = this.peek();
8227
+ if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
8228
+ const op = tok.punct;
8229
+ this.pos += 1;
8230
+ const operand = this.parseUnary();
8231
+ this.countNode();
8232
+ return {
8233
+ kind: "unary",
8234
+ op,
8235
+ operand
8236
+ };
8237
+ }
8238
+ return this.parsePrimary();
8239
+ }
8240
+ parsePrimary() {
8241
+ const tok = this.next();
8242
+ switch (tok.type) {
8243
+ case "number":
8244
+ this.countNode();
8245
+ return {
8246
+ kind: "literal",
8247
+ value: tok.value
8248
+ };
8249
+ case "string":
8250
+ this.countNode();
8251
+ return {
8252
+ kind: "literal",
8253
+ value: tok.value
8254
+ };
8255
+ case "keyword":
8256
+ this.countNode();
8257
+ return {
8258
+ kind: "literal",
8259
+ value: tok.keyword === "null" ? null : tok.keyword === "true"
8260
+ };
8261
+ case "identifier": {
8262
+ const nextTok = this.peek();
8263
+ if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
8264
+ this.identifiers.add(tok.name);
8265
+ this.countNode();
8266
+ return {
8267
+ kind: "identifier",
8268
+ name: tok.name
8269
+ };
8270
+ }
8271
+ case "punct":
8272
+ if (tok.punct === "(") {
8273
+ const inner = this.parseTernary();
8274
+ this.expectPunct(")");
8275
+ return inner;
8276
+ }
8277
+ throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
8278
+ case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
8279
+ }
8280
+ }
8281
+ parseCall(callee, pos) {
8282
+ if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
8283
+ this.expectPunct("(");
8284
+ const args = [];
8285
+ if (!this.matchPunct(")")) for (;;) {
8286
+ args.push(this.parseTernary());
8287
+ if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
8288
+ if (this.matchPunct(",")) continue;
8289
+ this.expectPunct(")");
8290
+ break;
8291
+ }
8292
+ this.callees.add(callee);
8293
+ this.countNode();
8294
+ return {
8295
+ kind: "call",
8296
+ callee,
8297
+ args
8298
+ };
8299
+ }
8300
+ };
8301
+ /** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
8302
+ * `ExpressionParseError` on any lexical or grammatical failure. */
8303
+ function parseExpression(source) {
8304
+ return new Parser(tokenize(source)).parse();
8305
+ }
8306
+ Object.freeze({});
8307
+ /**
8308
+ * LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
8309
+ * by expr"). The cache stores BOTH successes and failures (negative caching),
8310
+ * so a corrupt persisted string costs exactly one tokenize+parse total — not
8311
+ * one per read on a hot resolve path.
8312
+ *
8313
+ * The cache is a module-level singleton: entries are pure, content-addressed
8314
+ * ASTs keyed by the raw source string, so sharing one instance across all
8315
+ * callers is safe and maximises hit rate.
8316
+ */
8317
+ var cache = /* @__PURE__ */ new Map();
8318
+ function getCached(source) {
8319
+ const hit = cache.get(source);
8320
+ if (hit !== void 0) {
8321
+ cache.delete(source);
8322
+ cache.set(source, hit);
8323
+ return hit;
8324
+ }
8325
+ let result;
8326
+ try {
8327
+ result = {
8328
+ ok: true,
8329
+ parsed: parseExpression(source)
8330
+ };
8331
+ } catch (err) {
8332
+ result = {
8333
+ ok: false,
8334
+ error: err instanceof ExpressionParseError ? err.message : String(err)
8335
+ };
8336
+ }
8337
+ cache.set(source, result);
8338
+ if (cache.size > 256) {
8339
+ const oldest = cache.keys().next().value;
8340
+ if (oldest !== void 0) cache.delete(oldest);
8341
+ }
8342
+ return result;
8343
+ }
8344
+ /** Compile `source`, returning a discriminated result instead of throwing.
8345
+ * Used by read paths that must degrade rather than raise. LRU/negative-cached. */
8346
+ function compileExpressionSafe(source) {
8347
+ return getCached(source);
8348
+ }
8349
+ /**
8350
+ * Author-time validation. Returns `null` when the source is valid, else a
8351
+ * human-readable error message. Checks: the expression compiles; binding count
8352
+ * is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
8353
+ * is not reserved (`now`/keywords) and does not shadow a builtin; and every
8354
+ * FREE identifier of the AST is covered by a binding or the injected `now`.
8355
+ */
8356
+ function validateExpressionSource(src) {
8357
+ const names = Object.keys(src.bindings);
8358
+ if (names.length > 32) return `too many bindings (${names.length} > 32)`;
8359
+ for (const name of names) {
8360
+ if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
8361
+ if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
8362
+ if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
8363
+ }
8364
+ const compiled = compileExpressionSafe(src.expr);
8365
+ if (!compiled.ok) return compiled.error;
8366
+ const bound = new Set(names);
8367
+ for (const id of compiled.parsed.identifiers) {
8368
+ if (id === "now") continue;
8369
+ if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
8370
+ }
8371
+ return null;
8372
+ }
8373
+ /**
7609
8374
  * Accessory device helpers — shared across drivers.
7610
8375
  *
7611
8376
  * Many vendor-specific drivers register accessory child devices on
@@ -8450,7 +9215,13 @@ onStatusChanged: { data: object({
8450
9215
  }) } },
8451
9216
  status: {
8452
9217
  schema: BatteryStatusSchema,
8453
- kind: "push"
9218
+ kind: "push",
9219
+ empty: {
9220
+ percentage: 0,
9221
+ charging: "none",
9222
+ sleeping: false,
9223
+ lastUpdated: 0
9224
+ }
8454
9225
  },
8455
9226
  /**
8456
9227
  * Runtime-state slice — every provider that registers this cap
@@ -9393,21 +10164,38 @@ var connectivityCapability = {
9393
10164
  },
9394
10165
  runtimeState: ConnectivityStatusSchema
9395
10166
  };
10167
+ /**
10168
+ * Generic device-consumables capability — surfaces a device's
10169
+ * maintenance items (vacuum filters/brushes, replaceable cartridges,
10170
+ * descaling cycles, …) with their remaining life and an optional
10171
+ * "Replaced" reset action. Device-agnostic: any provider that knows its
10172
+ * device tracks consumables can register it; the cap declares no
10173
+ * vocabulary of its own — the provider names each item verbatim.
10174
+ *
10175
+ * Like `childLayout`, the cap is INERT until a provider sets items: no
10176
+ * provider populates it by guessing (no HA inference). The UI renders a
10177
+ * "No consumables reported" placeholder when `items` is empty.
10178
+ */
10179
+ /** A single consumable item. Either a continuous `level` (remaining
10180
+ * life %) or a discrete `status` may be known — both may be null when a
10181
+ * provider only knows the item exists. `level` and `status` are not
10182
+ * mutually exclusive; a provider may report both. */
10183
+ var ConsumableItemSchema = object({
10184
+ /** Stable id, e.g. 'main-brush'. */
10185
+ key: string().min(1),
10186
+ /** Display name. */
10187
+ label: string().min(1),
10188
+ /** Remaining life % when known (0..100). */
10189
+ level: number().min(0).max(100).nullable(),
10190
+ /** Discrete state when known (binary mode). */
10191
+ status: _enum(["ok", "replace"]).nullable(),
10192
+ /** Ms epoch of the last replace, when known. */
10193
+ lastResetAt: number().nullable(),
10194
+ /** Whether `reset()` is meaningful for this item. */
10195
+ resettable: boolean()
10196
+ });
9396
10197
  var ConsumablesStatusSchema = object({
9397
- items: array(object({
9398
- /** Stable id, e.g. 'main-brush'. */
9399
- key: string().min(1),
9400
- /** Display name. */
9401
- label: string().min(1),
9402
- /** Remaining life % when known (0..100). */
9403
- level: number().min(0).max(100).nullable(),
9404
- /** Discrete state when known (binary mode). */
9405
- status: _enum(["ok", "replace"]).nullable(),
9406
- /** Ms epoch of the last replace, when known. */
9407
- lastResetAt: number().nullable(),
9408
- /** Whether `reset()` is meaningful for this item. */
9409
- resettable: boolean()
9410
- })),
10198
+ items: array(ConsumableItemSchema),
9411
10199
  lastChangedAt: number()
9412
10200
  });
9413
10201
  var consumablesCapability = {
@@ -9466,7 +10254,25 @@ reset: method(object({
9466
10254
  }) },
9467
10255
  status: {
9468
10256
  schema: ConsumablesStatusSchema,
9469
- kind: "push"
10257
+ kind: "push",
10258
+ empty: {
10259
+ items: [],
10260
+ lastChangedAt: 0
10261
+ },
10262
+ itemArray: {
10263
+ path: "items",
10264
+ keyField: "key",
10265
+ labelField: "label",
10266
+ itemSchema: ConsumableItemSchema,
10267
+ emptyItem: {
10268
+ key: "",
10269
+ label: "",
10270
+ level: null,
10271
+ status: null,
10272
+ lastResetAt: null,
10273
+ resettable: false
10274
+ }
10275
+ }
9470
10276
  },
9471
10277
  runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() })
9472
10278
  };
@@ -10708,7 +11514,8 @@ var MotionAnalysisResultSchema = object({
10708
11514
  });
10709
11515
  method(object({
10710
11516
  deviceId: number(),
10711
- frame: FrameInputSchema
11517
+ frame: FrameInputSchema.optional(),
11518
+ frameHandle: FrameHandleSchema.optional()
10712
11519
  }), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
10713
11520
  deviceId: number(),
10714
11521
  detected: boolean(),
@@ -10955,6 +11762,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
10955
11762
  engine: PipelineEngineChoiceSchema.optional(),
10956
11763
  steps: array(PipelineStepInputSchema).min(1),
10957
11764
  frame: FrameInputSchema.optional(),
11765
+ /**
11766
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
11767
+ * the decoded pixels live in. One more member of the one-of
11768
+ * frame/frameHandle/image/imageBase64/referenceImage group.
11769
+ */
11770
+ frameHandle: FrameHandleSchema.optional(),
10958
11771
  imageBase64: string().optional(),
10959
11772
  /**
10960
11773
  * Binary JPEG bytes — preferred over `imageBase64` on internal
@@ -11197,6 +12010,31 @@ var ReportMotionInputSchema = object({
11197
12010
  regions: array(MotionRegionSchema).readonly().optional()
11198
12011
  });
11199
12012
  /**
12013
+ * Where a runner gets a camera's decoded frames (cross-node Phase 2,
12014
+ * restream-owner model — P2c).
12015
+ *
12016
+ * - `local-broker` (DEFAULT): today's path — subscribe to the co-located
12017
+ * stream-broker's shm frame plane. Every pre-P2c attach payload (no
12018
+ * `frameSource` key) parses to this, so the field is additive with zero
12019
+ * behavior change.
12020
+ * - `remote-restream`: the detect node is NOT the camera's source-owner.
12021
+ * The runner acquires the owner's COMPRESSED passthrough restream
12022
+ * (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
12023
+ * double-pull guard) and decodes LOCALLY via a satellite frame plane +
12024
+ * pull-mode decoder session pinned to its own node. The shm ring stays
12025
+ * node-local; only H.264/H.265 packets cross the wire.
12026
+ * `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
12027
+ * when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
12028
+ * dials for the owner's restream.
12029
+ */
12030
+ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
12031
+ kind: literal("remote-restream"),
12032
+ /** The camera's source-owner node (slice 1: always the hub). */
12033
+ ownerNodeId: string(),
12034
+ /** Operator override for the owner host the runner dials. */
12035
+ hubHostnameOverride: string().optional()
12036
+ })]).describe("Per-camera frame-source mode for the runner (P2c)");
12037
+ /**
11200
12038
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
11201
12039
  * specific runner instance via `attachCamera`. Carries everything the
11202
12040
  * runner needs to subscribe to the local broker and execute inference.
@@ -11294,7 +12132,15 @@ var RunnerCameraConfigSchema = object({
11294
12132
  */
11295
12133
  onboardMotionDrivesAnalyzer: boolean().default(true),
11296
12134
  occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
11297
- occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
12135
+ occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
12136
+ /**
12137
+ * Where this runner gets the camera's decoded frames (P2c). Defaulted so
12138
+ * every existing payload behaves as `local-broker` — the pre-Phase-2 path.
12139
+ * Populated with `remote-restream` by the orchestrator ONLY when the
12140
+ * camera's detect node differs from its source-owner (P2d, gated by the
12141
+ * `remoteSourcingNodes` rollout setting).
12142
+ */
12143
+ frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
11298
12144
  });
11299
12145
  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;
11300
12146
  /**
@@ -11858,6 +12704,157 @@ var numericSensorCapability = {
11858
12704
  runtimeState: NumericSensorStatusSchema
11859
12705
  };
11860
12706
  /**
12707
+ * Feeder connectivity / power status — mirrors the HA petkit device-status
12708
+ * enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
12709
+ * `on_batteries` (running on battery backup). `null` until first reported.
12710
+ */
12711
+ var PetFeederDeviceStatusSchema = _enum([
12712
+ "normal",
12713
+ "offline",
12714
+ "on_batteries"
12715
+ ]);
12716
+ var gramsPortion = number().int().min(4).max(200);
12717
+ var PetFeederStatusSchema = object({
12718
+ /** Food currently in the bowl (grams). Null when the device has not
12719
+ * reported a reading yet. On dual-hopper models this is the combined
12720
+ * bowl reading; per-hopper levels live in `food1`/`food2`. */
12721
+ foodLevel: number().nullable(),
12722
+ /** Hopper-1 food level (grams) on dual-hopper feeders; null on
12723
+ * single-hopper models. */
12724
+ food1: number().nullable(),
12725
+ /** Hopper-2 food level (grams) on dual-hopper feeders; null on
12726
+ * single-hopper models. */
12727
+ food2: number().nullable(),
12728
+ /** Derived low-food flag — mirrors the HA `food_level` binary_sensor
12729
+ * (`device_class: problem`, on = low). True when the bowl is empty /
12730
+ * below the feeder's low threshold. */
12731
+ lowFood: boolean(),
12732
+ /** Battery charge 0..100 (%). Null on mains-powered models or when the
12733
+ * device has no battery reading. */
12734
+ batteryPower: number().min(0).max(100).nullable(),
12735
+ /** Days of desiccant life remaining. Null when the model has no
12736
+ * desiccant sensor. */
12737
+ desiccantLeftDays: number().nullable(),
12738
+ /** True while a feed is in progress. */
12739
+ feeding: boolean(),
12740
+ /** Decoded connectivity / power status (HA petkit device-status enum).
12741
+ * Null until the device has reported a status. */
12742
+ status: PetFeederDeviceStatusSchema.nullable(),
12743
+ /** Decoded human-readable fault message. Null (or the device's `no_error`
12744
+ * sentinel) means healthy; a non-null string is an active fault. Pairs
12745
+ * with `errorCode` for consumers that want the raw integer. */
12746
+ error: string().nullable(),
12747
+ /** Raw device error code (0 / null = no error). */
12748
+ errorCode: number().nullable(),
12749
+ /** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
12750
+ isDualHopper: boolean(),
12751
+ /** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
12752
+ childLock: boolean(),
12753
+ /** Front indicator-light setting. */
12754
+ indicatorLight: boolean(),
12755
+ /** Play a chime when dispensing. */
12756
+ feedSound: boolean(),
12757
+ /** Speaker / prompt volume level (device-scaled integer). */
12758
+ volume: number(),
12759
+ /** Ms epoch when the slice was last refreshed from the cloud. */
12760
+ lastFetchedAt: number()
12761
+ });
12762
+ var petFeederCapability = {
12763
+ name: "pet-feeder",
12764
+ scope: "device",
12765
+ deviceNative: true,
12766
+ mode: "singleton",
12767
+ deviceTypes: [DeviceType.PetFeeder],
12768
+ methods: {
12769
+ /**
12770
+ * Dispense food now. Single-hopper feeders take `grams`; dual-hopper
12771
+ * feeders (D4S/D4SH) accept `hopper1`/`hopper2` to target one or both
12772
+ * hoppers. All portions honour the 4–200 g hardware range. At least
12773
+ * one of the three must be present — the provider rejects an empty
12774
+ * request.
12775
+ */
12776
+ feed: method(object({
12777
+ deviceId: number().int().nonnegative(),
12778
+ grams: gramsPortion.optional(),
12779
+ hopper1: gramsPortion.optional(),
12780
+ hopper2: gramsPortion.optional()
12781
+ }), _void(), {
12782
+ kind: "mutation",
12783
+ auth: "admin"
12784
+ }),
12785
+ /** Cancel an in-progress manual feed. */
12786
+ cancelFeed: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12787
+ kind: "mutation",
12788
+ auth: "admin"
12789
+ }),
12790
+ /** Reset the desiccant "days remaining" counter after replacing it. */
12791
+ resetDesiccant: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12792
+ kind: "mutation",
12793
+ auth: "admin"
12794
+ }),
12795
+ /** Mark a hopper as refilled (D4H/D4S/D4SH). */
12796
+ markFoodReplenished: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12797
+ kind: "mutation",
12798
+ auth: "admin"
12799
+ }),
12800
+ /** Call the pet with the recorded prompt (D3). */
12801
+ callPet: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12802
+ kind: "mutation",
12803
+ auth: "admin"
12804
+ }),
12805
+ /** Play a stored sound by id (D3 / D4H / D4SH). */
12806
+ playSound: method(object({
12807
+ deviceId: number().int().nonnegative(),
12808
+ soundId: number().int().nonnegative()
12809
+ }), _void(), {
12810
+ kind: "mutation",
12811
+ auth: "admin"
12812
+ }),
12813
+ /** Toggle the child-lock (manual-lock) setting. */
12814
+ setChildLock: method(object({
12815
+ deviceId: number().int().nonnegative(),
12816
+ on: boolean()
12817
+ }), _void(), {
12818
+ kind: "mutation",
12819
+ auth: "admin"
12820
+ }),
12821
+ /** Toggle the front indicator light. */
12822
+ setIndicatorLight: method(object({
12823
+ deviceId: number().int().nonnegative(),
12824
+ on: boolean()
12825
+ }), _void(), {
12826
+ kind: "mutation",
12827
+ auth: "admin"
12828
+ }),
12829
+ /** Toggle the dispense chime. */
12830
+ setFeedSound: method(object({
12831
+ deviceId: number().int().nonnegative(),
12832
+ on: boolean()
12833
+ }), _void(), {
12834
+ kind: "mutation",
12835
+ auth: "admin"
12836
+ }),
12837
+ /** Set the speaker / prompt volume level. */
12838
+ setVolume: method(object({
12839
+ deviceId: number().int().nonnegative(),
12840
+ level: number().int().nonnegative()
12841
+ }), _void(), {
12842
+ kind: "mutation",
12843
+ auth: "admin"
12844
+ })
12845
+ },
12846
+ status: {
12847
+ schema: PetFeederStatusSchema,
12848
+ kind: "poll"
12849
+ },
12850
+ /**
12851
+ * Runtime-state slice — mirrored by the kernel. UI feeder cards read
12852
+ * the full slice via `device.state.petFeeder.value` and refresh on
12853
+ * every poll without re-querying the provider.
12854
+ */
12855
+ runtimeState: PetFeederStatusSchema
12856
+ };
12857
+ /**
11861
12858
  * Multi-metric electrical meter. One slice can carry any combination
11862
12859
  * of instantaneous power (W), cumulative energy (kWh), voltage (V),
11863
12860
  * and current (A) — all fields optional so a single-metric source
@@ -13160,6 +14157,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
13160
14157
  nativeObjectDetection: nativeObjectDetectionCapability,
13161
14158
  notifier: notifierCapability,
13162
14159
  numericSensor: numericSensorCapability,
14160
+ petFeeder: petFeederCapability,
13163
14161
  powerMeter: powerMeterCapability,
13164
14162
  presence: presenceCapability,
13165
14163
  pressureSensor: pressureSensorCapability,
@@ -15144,10 +16142,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
15144
16142
  url: string()
15145
16143
  }), _void()), method(object({
15146
16144
  sessionId: string(),
15147
- maxCount: number().default(1)
16145
+ maxCount: number().default(1),
16146
+ waitMs: number().optional()
15148
16147
  }), array(DecodedFrameSchema)), method(object({
15149
16148
  sessionId: string(),
15150
- maxCount: number().default(1)
16149
+ maxCount: number().default(1),
16150
+ waitMs: number().optional()
15151
16151
  }), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
15152
16152
  sessionId: string(),
15153
16153
  config: DecoderSessionConfigSchema.partial()
@@ -15451,14 +16451,63 @@ var ChildLayoutEntrySchema = object({
15451
16451
  collapsed: boolean().optional()
15452
16452
  });
15453
16453
  /** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
15454
- * `device-management.ts`. */
16454
+ * `device-management.ts`. Source is a union: a FIELD source copies a sibling
16455
+ * accessory's status field (`kind` optional/absent for wire compat); a
16456
+ * LITERAL source carries a per-device constant (no sibling is read); a
16457
+ * GLOBAL source (P2e) copies ANY device's status field, addressed by the
16458
+ * source device's full re-sync-stable `stableId`. */
16459
+ var DeviceLinkFieldSourceSchema = object({
16460
+ kind: literal("field").optional(),
16461
+ sourceKey: string(),
16462
+ cap: string(),
16463
+ fieldPath: string()
16464
+ });
16465
+ var DeviceLinkLiteralSourceSchema = object({
16466
+ kind: literal("literal"),
16467
+ value: union([
16468
+ string(),
16469
+ number(),
16470
+ boolean(),
16471
+ _null()
16472
+ ])
16473
+ });
16474
+ var DeviceLinkGlobalSourceSchema = object({
16475
+ kind: literal("global"),
16476
+ sourceStableId: string(),
16477
+ cap: string(),
16478
+ fieldPath: string()
16479
+ });
16480
+ /** Expression source (Stage X): compute the target field from N named bindings
16481
+ * via the safe expression engine. Bindings are field | literal | global — never
16482
+ * another expression (no nesting). The `superRefine` runs the SAME author-time
16483
+ * validation as `validateExpressionSource` (compiles the expr, checks binding
16484
+ * names + identifier coverage) so every wire boundary that parses a DeviceLink
16485
+ * (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
16486
+ * Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
16487
+ var DeviceLinkExpressionSourceSchema = object({
16488
+ kind: literal("expression"),
16489
+ expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
16490
+ bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
16491
+ DeviceLinkFieldSourceSchema,
16492
+ DeviceLinkLiteralSourceSchema,
16493
+ DeviceLinkGlobalSourceSchema
16494
+ ]))
16495
+ }).superRefine((src, ctx) => {
16496
+ const err = validateExpressionSource(src);
16497
+ if (err !== null) ctx.addIssue({
16498
+ code: "custom",
16499
+ message: err,
16500
+ path: ["expr"]
16501
+ });
16502
+ });
15455
16503
  var DeviceLinkSchema = object({
15456
16504
  id: string(),
15457
- source: object({
15458
- sourceKey: string(),
15459
- cap: string(),
15460
- fieldPath: string()
15461
- }),
16505
+ source: union([
16506
+ DeviceLinkFieldSourceSchema,
16507
+ DeviceLinkLiteralSourceSchema,
16508
+ DeviceLinkGlobalSourceSchema,
16509
+ DeviceLinkExpressionSourceSchema
16510
+ ]),
15462
16511
  target: object({
15463
16512
  cap: string(),
15464
16513
  fieldPath: string(),
@@ -15487,6 +16536,31 @@ var DeviceLinkSchema = object({
15487
16536
  })
15488
16537
  ]).optional()
15489
16538
  });
16539
+ /** Cap-wire shape of a per-cap display refinement — mirrors
16540
+ * `DeviceCapDisplayOverride` in `device-management.ts`. */
16541
+ var DeviceCapDisplayOverrideSchema = object({
16542
+ unit: string().min(1).optional(),
16543
+ precision: number().int().min(0).max(10).optional()
16544
+ });
16545
+ /** Cap-wire shape of an operator-authored per-device display override —
16546
+ * mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
16547
+ * bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
16548
+ var DeviceDisplayOverrideSchema = object({
16549
+ icon: string().min(1).optional(),
16550
+ label: string().min(1).optional(),
16551
+ unit: string().min(1).optional(),
16552
+ precision: number().int().min(0).max(10).optional(),
16553
+ hidden: boolean().optional(),
16554
+ perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
16555
+ });
16556
+ /** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
16557
+ * in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
16558
+ * the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
16559
+ var RoleDisplayDefaultSchema = object({
16560
+ unit: string().min(1).optional(),
16561
+ precision: number().int().min(0).max(10).optional(),
16562
+ icon: string().min(1).optional()
16563
+ });
15490
16564
  /**
15491
16565
  * Serializable projection of a live IDevice.
15492
16566
  * Returned by listAll, getDevice, getChildren.
@@ -15542,7 +16616,9 @@ var DeviceInfoSchema = object({
15542
16616
  * `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
15543
16617
  childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
15544
16618
  /** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
15545
- deviceLinks: array(DeviceLinkSchema).readonly().optional()
16619
+ deviceLinks: array(DeviceLinkSchema).readonly().optional(),
16620
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
16621
+ display: DeviceDisplayOverrideSchema.optional()
15546
16622
  });
15547
16623
  var ConfigEntrySchema = object({
15548
16624
  key: string(),
@@ -15607,7 +16683,9 @@ var DeviceMetaSchema = object({
15607
16683
  deviceLinks: array(DeviceLinkSchema).readonly().optional(),
15608
16684
  /** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
15609
16685
  * Optional: only present for accessory children that carry a known role. */
15610
- role: string().nullable().optional()
16686
+ role: string().nullable().optional(),
16687
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
16688
+ display: DeviceDisplayOverrideSchema.optional()
15611
16689
  });
15612
16690
  /** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
15613
16691
  var ConfigUISchemaOutput = unknown().nullable();
@@ -15701,7 +16779,19 @@ method(object({
15701
16779
  }), _void(), {
15702
16780
  kind: "mutation",
15703
16781
  auth: "admin"
15704
- }), method(object({ deviceId: number() }), object({ caps: array(object({
16782
+ }), method(object({
16783
+ deviceId: number(),
16784
+ display: DeviceDisplayOverrideSchema.nullable()
16785
+ }), _void(), {
16786
+ kind: "mutation",
16787
+ auth: "admin"
16788
+ }), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
16789
+ kind: "mutation",
16790
+ auth: "admin"
16791
+ }), method(object({
16792
+ deviceId: number(),
16793
+ includeSynthesizable: boolean().optional()
16794
+ }), object({ caps: array(object({
15705
16795
  cap: string(),
15706
16796
  fields: array(object({
15707
16797
  path: string(),
@@ -15711,8 +16801,13 @@ method(object({
15711
16801
  "boolean",
15712
16802
  "enum"
15713
16803
  ]),
15714
- enumValues: array(string()).optional()
15715
- })).readonly()
16804
+ enumValues: array(string()).optional(),
16805
+ item: boolean().optional()
16806
+ })).readonly(),
16807
+ itemArray: object({
16808
+ path: string(),
16809
+ keyField: string()
16810
+ }).optional()
15716
16811
  })).readonly() }), { kind: "query" }), method(object({
15717
16812
  deviceId: number(),
15718
16813
  role: string().nullable()
@@ -15782,7 +16877,11 @@ method(object({
15782
16877
  deviceId: number(),
15783
16878
  entries: array(object({
15784
16879
  capName: string(),
15785
- kind: _enum(["native", "wrapped"]),
16880
+ kind: _enum([
16881
+ "native",
16882
+ "wrapped",
16883
+ "linked"
16884
+ ]),
15786
16885
  providerAddonId: string(),
15787
16886
  providerNodeId: string(),
15788
16887
  nativeAddonId: string()
@@ -15791,7 +16890,11 @@ method(object({
15791
16890
  deviceId: number(),
15792
16891
  entries: array(object({
15793
16892
  capName: string(),
15794
- kind: _enum(["native", "wrapped"]),
16893
+ kind: _enum([
16894
+ "native",
16895
+ "wrapped",
16896
+ "linked"
16897
+ ]),
15795
16898
  providerAddonId: string(),
15796
16899
  providerNodeId: string(),
15797
16900
  nativeAddonId: string()
@@ -16281,7 +17384,7 @@ var AddBrokerInputSchema = object({
16281
17384
  });
16282
17385
  var AddBrokerResultSchema = object({ id: string() });
16283
17386
  var IdInputSchema = object({ id: string() });
16284
- var TestResultSchema = discriminatedUnion("ok", [object({
17387
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
16285
17388
  ok: literal(true),
16286
17389
  latencyMs: number()
16287
17390
  }), object({
@@ -16304,7 +17407,7 @@ var StatusSchema = object({
16304
17407
  brokerCount: number(),
16305
17408
  embeddedRunning: boolean()
16306
17409
  });
16307
- 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);
17410
+ 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);
16308
17411
  var NetworkEndpointSchema = object({
16309
17412
  url: string(),
16310
17413
  hostname: string(),
@@ -16338,23 +17441,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16338
17441
  sourcePort: number().optional()
16339
17442
  });
16340
17443
  method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16341
- method(object({
16342
- title: string(),
17444
+ /**
17445
+ * notification-output — canonical, capability-gated notification delivery.
17446
+ *
17447
+ * Apprise-derived model (see
17448
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
17449
+ * callers emit ONE canonical `Notification`; each provider declares a
17450
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
17451
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
17452
+ * message to what the kind supports — callers never special-case a service.
17453
+ *
17454
+ * DESIGN DECISIONS (locked):
17455
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
17456
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
17457
+ * cap. Rationale: the admin UI needs one uniform surface across the
17458
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
17459
+ * alternative would fork the UI per addon and cannot host the
17460
+ * discovery→adopt flow.
17461
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
17462
+ * the generated cap-mount auto-`concatCollection`-fans them across every
17463
+ * registered provider (notifiers addon + HA addon) so one catalog is
17464
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
17465
+ * `addonId` the generated collection router extracts from the call input.
17466
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
17467
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
17468
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
17469
+ * base64 fallback needed.
17470
+ *
17471
+ * TODO (deferred, closed-set change — separate decision): add
17472
+ * `providerKind: 'notify'` so notification providers surface on the unified
17473
+ * admin "Integrations" page.
17474
+ */
17475
+ /**
17476
+ * Zentik-derived typed-media enum — the superset across every kind. Each
17477
+ * adapter picks what it supports and the degrade engine filters the rest.
17478
+ */
17479
+ var AttachmentMediaTypeSchema = _enum([
17480
+ "image",
17481
+ "video",
17482
+ "gif",
17483
+ "audio",
17484
+ "icon"
17485
+ ]);
17486
+ /**
17487
+ * A single attachment. Exactly one of `url` (remote source, most adapters
17488
+ * prefer this) or `bytes` (inline source; required for Pushover-style
17489
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
17490
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
17491
+ */
17492
+ var AttachmentSchema = object({
17493
+ mediaType: AttachmentMediaTypeSchema,
17494
+ url: string().optional(),
17495
+ bytes: _instanceof(Uint8Array).optional(),
17496
+ mime: string().optional(),
17497
+ name: string().optional()
17498
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
17499
+ var NotificationFormatSchema = _enum([
17500
+ "text",
17501
+ "markdown",
17502
+ "html"
17503
+ ]);
17504
+ /** A single tap-through action button. */
17505
+ var NotificationActionSchema = object({
17506
+ id: string(),
17507
+ label: string(),
17508
+ url: string().optional()
17509
+ });
17510
+ /**
17511
+ * The canonical notification. `body` is the only hard field (Apprise model).
17512
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
17513
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
17514
+ * the adapter maps this ordinal onto its native level. `level?` is an
17515
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
17516
+ * `priority` for that one target.
17517
+ */
17518
+ var NotificationSchema = object({
16343
17519
  body: string(),
16344
- imageUrl: string().optional(),
17520
+ title: string().optional(),
17521
+ format: NotificationFormatSchema.default("text"),
17522
+ priority: number().int().min(1).max(5).default(3),
17523
+ level: string().optional(),
17524
+ attachments: array(AttachmentSchema).optional(),
17525
+ clickUrl: string().optional(),
17526
+ actions: array(NotificationActionSchema).optional(),
17527
+ sound: string().optional(),
17528
+ ttl: number().optional(),
17529
+ tag: string().optional(),
16345
17530
  deviceId: number().optional(),
16346
17531
  eventId: string().optional(),
16347
- priority: _enum([
16348
- "low",
16349
- "normal",
16350
- "high",
16351
- "critical"
16352
- ]).default("normal"),
16353
17532
  metadata: record(string(), unknown()).optional()
16354
- }), _void(), { kind: "mutation" }), method(_void(), object({
17533
+ });
17534
+ /** One declared native severity/priority level for a kind. */
17535
+ var TargetKindLevelSchema = object({
17536
+ id: string(),
17537
+ label: string(),
17538
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
17539
+ ordinal: number().int().min(1).max(5).nullable(),
17540
+ flags: object({
17541
+ critical: boolean().optional(),
17542
+ silent: boolean().optional(),
17543
+ noPush: boolean().optional()
17544
+ }).optional(),
17545
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
17546
+ requires: array(string()).optional(),
17547
+ description: string().optional()
17548
+ });
17549
+ /** The full capability block consulted before dispatch. */
17550
+ var TargetKindCapsSchema = object({
17551
+ attachments: object({
17552
+ mediaTypes: array(AttachmentMediaTypeSchema),
17553
+ mode: _enum([
17554
+ "url",
17555
+ "bytes",
17556
+ "both"
17557
+ ]),
17558
+ max: number().int().nonnegative(),
17559
+ maxBytes: number().int().positive().optional()
17560
+ }),
17561
+ /** Max action buttons (0 = none). */
17562
+ actions: number().int().nonnegative(),
17563
+ levels: array(TargetKindLevelSchema),
17564
+ format: array(NotificationFormatSchema),
17565
+ clickUrl: boolean(),
17566
+ sound: boolean(),
17567
+ ttl: boolean(),
17568
+ bodyMaxLen: number().int().positive()
17569
+ });
17570
+ /**
17571
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
17572
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
17573
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
17574
+ * the union is large and not meant for runtime validation here; the exported
17575
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
17576
+ */
17577
+ var ConfigSchemaPassthrough = unknown();
17578
+ var TargetKindSchema = object({
17579
+ kind: string(),
17580
+ label: string(),
17581
+ icon: string(),
17582
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
17583
+ addonId: string(),
17584
+ configSchema: ConfigSchemaPassthrough,
17585
+ supportsDiscovery: boolean(),
17586
+ caps: TargetKindCapsSchema
17587
+ });
17588
+ /**
17589
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
17590
+ * (return a presence marker only) when serving `listTargets` — never
17591
+ * round-trip a stored secret to the UI.
17592
+ */
17593
+ var TargetSchema = object({
17594
+ id: string(),
17595
+ name: string(),
17596
+ kind: string(),
17597
+ addonId: string(),
17598
+ enabled: boolean(),
17599
+ config: record(string(), unknown())
17600
+ });
17601
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
17602
+ var DiscoveredTargetSchema = object({
17603
+ kind: string(),
17604
+ suggestedName: string(),
17605
+ config: record(string(), unknown())
17606
+ });
17607
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
17608
+ var RenderedAsSchema = object({
17609
+ level: string(),
17610
+ format: NotificationFormatSchema,
17611
+ attachmentsSent: number().int().nonnegative(),
17612
+ actionsSent: number().int().nonnegative(),
17613
+ truncated: boolean(),
17614
+ dropped: array(string())
17615
+ });
17616
+ var SendResultSchema = object({
16355
17617
  success: boolean(),
16356
- error: string().optional()
16357
- }), { kind: "mutation" });
17618
+ error: string().optional(),
17619
+ renderedAs: RenderedAsSchema.optional()
17620
+ });
17621
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
17622
+ var TestResultSchema = SendResultSchema;
17623
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
17624
+ kind: string(),
17625
+ config: record(string(), unknown()).optional()
17626
+ }), array(DiscoveredTargetSchema)), method(object({
17627
+ targetId: string(),
17628
+ notification: NotificationSchema
17629
+ }), SendResultSchema, { kind: "mutation" }), method(object({
17630
+ targetId: string(),
17631
+ sample: NotificationSchema.optional()
17632
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
17633
+ targetId: string(),
17634
+ enabled: boolean()
17635
+ }), _void(), { kind: "mutation" });
16358
17636
  /**
16359
17637
  * Zod schemas for persisted record types.
16360
17638
  *
@@ -16858,7 +18136,10 @@ var AgentLoadSummarySchema = object({
16858
18136
  online: boolean(),
16859
18137
  load: RunnerLocalLoadSchema,
16860
18138
  /** Computed score used by the L2 capacity balancer (lower = less loaded). */
16861
- score: number()
18139
+ score: number(),
18140
+ /** This node's decode hwaccel backend (per-node `probedBestHwaccel`), or null
18141
+ * when not yet probed — for the cluster Pipeline table UI (P0.2). */
18142
+ decodeHwaccel: string().nullable()
16862
18143
  });
16863
18144
  /**
16864
18145
  * Aggregate metrics across the whole detection cluster. Replaces the legacy
@@ -19393,7 +20674,10 @@ var HwAccelBackendInputSchema = _enum([
19393
20674
  "webgpu",
19394
20675
  "none"
19395
20676
  ]).nullable().optional();
19396
- var HwAccelResolutionSchema = object({ preferred: array(string()).readonly() });
20677
+ var HwAccelResolutionSchema = object({
20678
+ preferred: array(string()).readonly(),
20679
+ rationale: string()
20680
+ });
19397
20681
  var HardwareEncoderIdSchema = _enum([
19398
20682
  "h264_videotoolbox",
19399
20683
  "hevc_videotoolbox",
@@ -19408,7 +20692,7 @@ var HardwareEncoderIdSchema = _enum([
19408
20692
  "libx264",
19409
20693
  "libx265"
19410
20694
  ]);
19411
- var HardwareEncodersSchema = object({
20695
+ object({
19412
20696
  encoders: array(object({
19413
20697
  encoder: HardwareEncoderIdSchema,
19414
20698
  codec: _enum(["H264", "H265"]),
@@ -19427,15 +20711,7 @@ var HardwareEncodersSchema = object({
19427
20711
  defaultH265: HardwareEncoderIdSchema,
19428
20712
  probedAt: number()
19429
20713
  });
19430
- /**
19431
- * Decode-side companion to {@link HardwareEncodersSchema}: the `-hwaccel`
19432
- * methods the configured ffmpeg binary actually supports (parsed from
19433
- * `ffmpeg -hwaccels`). Used to gate decode-hwaccel attempts so the transcode
19434
- * egress never spends a spawn on a backend this build cannot offer. Per-stream
19435
- * decode fragility (e.g. VideoToolbox HEVC) is still handled by the egress's
19436
- * software fallback — this only filters out wholly-unsupported backends.
19437
- */
19438
- var HardwareDecodeAccelsSchema = object({
20714
+ object({
19439
20715
  methods: array(string()).readonly(),
19440
20716
  probedAt: number()
19441
20717
  });
@@ -19498,16 +20774,7 @@ var ResolvedInferenceConfigSchema = object({
19498
20774
  format: ModelFormatSchema,
19499
20775
  reason: string()
19500
20776
  });
19501
- method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
19502
- prefer: HwAccelBackendInputSchema,
19503
- nodeId: string().optional()
19504
- }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
19505
- kind: "mutation",
19506
- auth: "admin"
19507
- }), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
19508
- kind: "mutation",
19509
- auth: "admin"
19510
- });
20777
+ method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema);
19511
20778
  var PtzPresetSchema = object({
19512
20779
  id: string(),
19513
20780
  name: string()
@@ -19560,6 +20827,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
19560
20827
  kind: "mutation",
19561
20828
  auth: "admin"
19562
20829
  });
20830
+ /**
20831
+ * `recording` cap — footage availability + HLS playback manifests + per-device
20832
+ * recording config. NOTE on events (source of truth, R5/C3): this cap carries
20833
+ * NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
20834
+ * events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
20835
+ * rows); the recorder's internal EventMap markers are ephemeral in-RAM
20836
+ * annotations that are not exposed here and must not be treated as an event
20837
+ * feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
20838
+ * (`interfaces/recording-config.ts`).
20839
+ */
19563
20840
  var RecordingStatusSchema = object({
19564
20841
  deviceId: number(),
19565
20842
  enabled: boolean(),
@@ -21196,6 +22473,12 @@ Object.freeze({
21196
22473
  addonId: null,
21197
22474
  access: "view"
21198
22475
  },
22476
+ "deviceManager.getRoleDisplayDefaults": {
22477
+ capName: "device-manager",
22478
+ capScope: "system",
22479
+ addonId: null,
22480
+ access: "view"
22481
+ },
21199
22482
  "deviceManager.getSettingsSchema": {
21200
22483
  capName: "device-manager",
21201
22484
  capScope: "system",
@@ -21346,6 +22629,12 @@ Object.freeze({
21346
22629
  addonId: null,
21347
22630
  access: "create"
21348
22631
  },
22632
+ "deviceManager.setDisplay": {
22633
+ capName: "device-manager",
22634
+ capScope: "system",
22635
+ addonId: null,
22636
+ access: "create"
22637
+ },
21349
22638
  "deviceManager.setIntegrationId": {
21350
22639
  capName: "device-manager",
21351
22640
  capScope: "system",
@@ -21388,6 +22677,12 @@ Object.freeze({
21388
22677
  addonId: null,
21389
22678
  access: "create"
21390
22679
  },
22680
+ "deviceManager.setRoleDisplayDefaults": {
22681
+ capName: "device-manager",
22682
+ capScope: "system",
22683
+ addonId: null,
22684
+ access: "create"
22685
+ },
21391
22686
  "deviceManager.setStreamProfileMap": {
21392
22687
  capName: "device-manager",
21393
22688
  capScope: "system",
@@ -22366,13 +23661,49 @@ Object.freeze({
22366
23661
  addonId: null,
22367
23662
  access: "create"
22368
23663
  },
23664
+ "notificationOutput.deleteTarget": {
23665
+ capName: "notification-output",
23666
+ capScope: "system",
23667
+ addonId: null,
23668
+ access: "delete"
23669
+ },
23670
+ "notificationOutput.discoverTargets": {
23671
+ capName: "notification-output",
23672
+ capScope: "system",
23673
+ addonId: null,
23674
+ access: "view"
23675
+ },
23676
+ "notificationOutput.listTargetKinds": {
23677
+ capName: "notification-output",
23678
+ capScope: "system",
23679
+ addonId: null,
23680
+ access: "view"
23681
+ },
23682
+ "notificationOutput.listTargets": {
23683
+ capName: "notification-output",
23684
+ capScope: "system",
23685
+ addonId: null,
23686
+ access: "view"
23687
+ },
22369
23688
  "notificationOutput.send": {
22370
23689
  capName: "notification-output",
22371
23690
  capScope: "system",
22372
23691
  addonId: null,
22373
23692
  access: "create"
22374
23693
  },
22375
- "notificationOutput.sendTest": {
23694
+ "notificationOutput.setTargetEnabled": {
23695
+ capName: "notification-output",
23696
+ capScope: "system",
23697
+ addonId: null,
23698
+ access: "create"
23699
+ },
23700
+ "notificationOutput.testTarget": {
23701
+ capName: "notification-output",
23702
+ capScope: "system",
23703
+ addonId: null,
23704
+ access: "create"
23705
+ },
23706
+ "notificationOutput.upsertTarget": {
22376
23707
  capName: "notification-output",
22377
23708
  capScope: "system",
22378
23709
  addonId: null,
@@ -22402,6 +23733,66 @@ Object.freeze({
22402
23733
  addonId: null,
22403
23734
  access: "create"
22404
23735
  },
23736
+ "petFeeder.callPet": {
23737
+ capName: "pet-feeder",
23738
+ capScope: "device",
23739
+ addonId: null,
23740
+ access: "create"
23741
+ },
23742
+ "petFeeder.cancelFeed": {
23743
+ capName: "pet-feeder",
23744
+ capScope: "device",
23745
+ addonId: null,
23746
+ access: "create"
23747
+ },
23748
+ "petFeeder.feed": {
23749
+ capName: "pet-feeder",
23750
+ capScope: "device",
23751
+ addonId: null,
23752
+ access: "create"
23753
+ },
23754
+ "petFeeder.markFoodReplenished": {
23755
+ capName: "pet-feeder",
23756
+ capScope: "device",
23757
+ addonId: null,
23758
+ access: "create"
23759
+ },
23760
+ "petFeeder.playSound": {
23761
+ capName: "pet-feeder",
23762
+ capScope: "device",
23763
+ addonId: null,
23764
+ access: "create"
23765
+ },
23766
+ "petFeeder.resetDesiccant": {
23767
+ capName: "pet-feeder",
23768
+ capScope: "device",
23769
+ addonId: null,
23770
+ access: "delete"
23771
+ },
23772
+ "petFeeder.setChildLock": {
23773
+ capName: "pet-feeder",
23774
+ capScope: "device",
23775
+ addonId: null,
23776
+ access: "create"
23777
+ },
23778
+ "petFeeder.setFeedSound": {
23779
+ capName: "pet-feeder",
23780
+ capScope: "device",
23781
+ addonId: null,
23782
+ access: "create"
23783
+ },
23784
+ "petFeeder.setIndicatorLight": {
23785
+ capName: "pet-feeder",
23786
+ capScope: "device",
23787
+ addonId: null,
23788
+ access: "create"
23789
+ },
23790
+ "petFeeder.setVolume": {
23791
+ capName: "pet-feeder",
23792
+ capScope: "device",
23793
+ addonId: null,
23794
+ access: "create"
23795
+ },
22405
23796
  "pipelineAnalytics.clearTracks": {
22406
23797
  capName: "pipeline-analytics",
22407
23798
  capScope: "device",
@@ -23008,30 +24399,6 @@ Object.freeze({
23008
24399
  addonId: null,
23009
24400
  access: "view"
23010
24401
  },
23011
- "platformProbe.getHardwareDecodeAccels": {
23012
- capName: "platform-probe",
23013
- capScope: "system",
23014
- addonId: null,
23015
- access: "view"
23016
- },
23017
- "platformProbe.getHardwareEncoders": {
23018
- capName: "platform-probe",
23019
- capScope: "system",
23020
- addonId: null,
23021
- access: "view"
23022
- },
23023
- "platformProbe.refreshHardwareDecodeAccels": {
23024
- capName: "platform-probe",
23025
- capScope: "system",
23026
- addonId: null,
23027
- access: "create"
23028
- },
23029
- "platformProbe.refreshHardwareEncoders": {
23030
- capName: "platform-probe",
23031
- capScope: "system",
23032
- addonId: null,
23033
- access: "create"
23034
- },
23035
24402
  "platformProbe.resolveHwAccel": {
23036
24403
  capName: "platform-probe",
23037
24404
  capScope: "system",