@camstack/addon-provider-gree 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 +1482 -62
  2. package/dist/addon.mjs +1482 -62
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -4644,7 +4644,7 @@ function preprocess(fn, schema) {
4644
4644
  });
4645
4645
  }
4646
4646
  //#endregion
4647
- //#region ../types/dist/sleep-C2M2zF7x.mjs
4647
+ //#region ../types/dist/sleep-BiDFW0E7.mjs
4648
4648
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4649
4649
  EventCategory["SystemBoot"] = "system.boot";
4650
4650
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5457,6 +5457,100 @@ function createDurableState(deps) {
5457
5457
  };
5458
5458
  }
5459
5459
  /**
5460
+ * Per-node scoping for the shared addon-settings blob.
5461
+ *
5462
+ * An addon's settings store is hub-central (the `addon-settings` cap is
5463
+ * hub-routed — the hub instance answers for every node), so fields whose
5464
+ * value is a NODE fact (decoder backend, engine pick, probed hardware
5465
+ * capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
5466
+ * the single shared blob. The SCHEMA field key stays bare: the write path
5467
+ * ({@link scopePatch}) maps the bare field onto the target node's scoped
5468
+ * key; the read/hydrate path ({@link projectStore}) maps THIS node's value
5469
+ * back, so UI forms and `resolveConfig` only ever see the bare key.
5470
+ *
5471
+ * Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
5472
+ * (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
5473
+ * schema and routes reads/writes through these helpers.
5474
+ *
5475
+ * ## No bare-key fallback — deliberate
5476
+ *
5477
+ * {@link readNodeValue} reads the node-scoped key ONLY. A node with no
5478
+ * scoped key resolves to `undefined` so the field's schema `default` wins —
5479
+ * NEVER `store[base]` and never another node's value. A bare legacy key in
5480
+ * the store is invisible to every node, hub included, so one node's
5481
+ * selection can never leak onto another. (This generalizes the
5482
+ * `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
5483
+ * arbitrary set of per-node field keys.)
5484
+ *
5485
+ * Pure functions only — no I/O, no imports beyond the language. This is a
5486
+ * LEAF module: import it via its deep path, never from the root barrel.
5487
+ */
5488
+ /**
5489
+ * Normalize a raw kernel node id to the bare node id used for scoping.
5490
+ * `localNodeId` can carry a `<node>/<addon>` suffix on forked child
5491
+ * processes; per-node settings are per-NODE, so strip the addon segment.
5492
+ * `undefined` / `null` / empty falls back to `'hub'`.
5493
+ */
5494
+ function normalizeNodeId(raw) {
5495
+ if (raw === void 0 || raw === null || raw === "") return "hub";
5496
+ const slashIdx = raw.indexOf("/");
5497
+ if (slashIdx < 0) return raw;
5498
+ const bare = raw.slice(0, slashIdx);
5499
+ return bare === "" ? "hub" : bare;
5500
+ }
5501
+ /** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
5502
+ function nodeScopedKey(base, nodeId) {
5503
+ return `${base}@${normalizeNodeId(nodeId)}`;
5504
+ }
5505
+ /**
5506
+ * Read a node's value for a per-node field from the raw shared store:
5507
+ * the node-scoped key when present, otherwise `undefined`.
5508
+ * Deliberately NO bare-key fallback (see module doc) — the caller lets the
5509
+ * schema `default` win on `undefined`.
5510
+ */
5511
+ function readNodeValue(store, base, nodeId) {
5512
+ return store[nodeScopedKey(base, nodeId)];
5513
+ }
5514
+ /**
5515
+ * Re-map a UI/settings patch so every bare perNode field persists under the
5516
+ * TARGET node's scoped key; all other keys pass through unchanged. Used on
5517
+ * the write path so a save for one node never clobbers another node's value
5518
+ * (and the bare key is never written). Returns a new object — the input
5519
+ * patch is not mutated.
5520
+ */
5521
+ function scopePatch(patch, perNodeKeys, nodeId) {
5522
+ const out = {};
5523
+ for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
5524
+ return out;
5525
+ }
5526
+ /**
5527
+ * Project the raw shared store onto the bare schema keys for ONE node so a
5528
+ * UI schema (whose field keys are bare) hydrates from that node's own
5529
+ * values:
5530
+ *
5531
+ * - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
5532
+ * - Every bare perNode key is dropped from the pass-through (a stray bare
5533
+ * legacy key must never hydrate any node — no bare fallback).
5534
+ * - THIS node's effective value ({@link readNodeValue}) is then laid onto
5535
+ * each bare perNode key; when the node has no scoped key the bare key is
5536
+ * left ABSENT so the field's schema `default` wins.
5537
+ *
5538
+ * Returns a new object — the input store is not mutated.
5539
+ */
5540
+ function projectStore(store, perNodeKeys, nodeId) {
5541
+ const out = {};
5542
+ for (const [key, value] of Object.entries(store)) {
5543
+ if (key.includes("@")) continue;
5544
+ if (perNodeKeys.has(key)) continue;
5545
+ out[key] = value;
5546
+ }
5547
+ for (const base of perNodeKeys) {
5548
+ const value = readNodeValue(store, base, nodeId);
5549
+ if (value !== void 0) out[base] = value;
5550
+ }
5551
+ return out;
5552
+ }
5553
+ /**
5460
5554
  * Base class for CamStack addons. Eliminates settings boilerplate:
5461
5555
  *
5462
5556
  * - Typed `config` property with automatic resolution from store + defaults
@@ -5624,23 +5718,63 @@ var BaseAddon = class {
5624
5718
  deviceSettingsSchema() {
5625
5719
  return null;
5626
5720
  }
5627
- async getGlobalSettings(overlay, cap, _nodeId) {
5721
+ async getGlobalSettings(overlay, cap, nodeId) {
5628
5722
  const schema = this.globalSettingsSchema(cap);
5629
5723
  if (!schema) return { sections: [] };
5630
- const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5724
+ const projected = await this.resolveGlobalStore(nodeId, cap);
5631
5725
  return hydrateSchema(schema, overlay ? {
5632
- ...raw,
5726
+ ...projected,
5633
5727
  ...overlay
5634
- } : raw);
5728
+ } : projected);
5635
5729
  }
5636
- async updateGlobalSettings(patch, _nodeId) {
5637
- await this._ctx?.settings?.writeAddonStore(patch);
5730
+ /**
5731
+ * The raw addon store PROJECTED onto the target node's bare per-node keys:
5732
+ * every `perNode: true` field carries THAT node's scoped value on its bare
5733
+ * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
5734
+ * bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
5735
+ * A no-op passthrough when the schema declares no `perNode` field.
5736
+ *
5737
+ * This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
5738
+ * the store for custom option logic (option narrowing, value snapping) to
5739
+ * read it per-node — never `ctx.settings.readAddonStore()` directly.
5740
+ * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
5741
+ */
5742
+ async resolveGlobalStore(nodeId, cap) {
5743
+ const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5744
+ const keys = this.perNodeKeys(cap);
5745
+ const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5746
+ return keys.size > 0 ? projectStore(raw, keys, node) : raw;
5747
+ }
5748
+ async updateGlobalSettings(patch, nodeId) {
5749
+ const keys = this.perNodeKeys();
5750
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5751
+ const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5752
+ const barePatch = patch;
5753
+ const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
5754
+ await this._ctx?.settings?.writeAddonStore(scoped);
5755
+ if (target !== localNode) return;
5638
5756
  await this.resolveConfig();
5639
5757
  await this.onConfigChanged();
5640
5758
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
5641
5759
  this.maybeAutoRestart(patch, this.globalSettingsSchema());
5642
5760
  }
5643
5761
  /**
5762
+ * The set of field keys the global settings schema declares `perNode: true`
5763
+ * — derived once per `cap` argument and memoized (schemas are static
5764
+ * declarations). Empty set ⇒ every per-node code path is bypassed and the
5765
+ * settings API behaves exactly like the legacy node-agnostic one.
5766
+ */
5767
+ _perNodeKeysCache = /* @__PURE__ */ new Map();
5768
+ perNodeKeys(cap) {
5769
+ const cacheKey = cap ?? "";
5770
+ const cached = this._perNodeKeysCache.get(cacheKey);
5771
+ if (cached) return cached;
5772
+ const schema = this.globalSettingsSchema(cap);
5773
+ const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
5774
+ this._perNodeKeysCache.set(cacheKey, keys);
5775
+ return keys;
5776
+ }
5777
+ /**
5644
5778
  * If any field in `patch` is marked `requiresRestart` in `schema`,
5645
5779
  * schedule an addon restart for the next tick. Deferred via
5646
5780
  * `setImmediate` so the tRPC mutation that triggered the write has
@@ -5793,12 +5927,19 @@ var BaseAddon = class {
5793
5927
  * The merge is shallow: each key in `defaults` is checked against the store.
5794
5928
  * Only keys present in defaults are read — the store can contain extra keys
5795
5929
  * (e.g. from older versions) without polluting the typed config.
5930
+ *
5931
+ * Keys the global settings schema declares `perNode: true` resolve from
5932
+ * THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
5933
+ * from the bare key — so a per-node field resolves to this node's own
5934
+ * selection at boot (absent scoped key ⇒ the constructor default wins).
5796
5935
  */
5797
5936
  async resolveConfig() {
5798
5937
  const stored = await this.readAddonStoreWithRetry();
5938
+ const perNode = this.perNodeKeys();
5939
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5799
5940
  const resolved = { ...this.defaults };
5800
5941
  for (const key of Object.keys(this.defaults)) {
5801
- const storedValue = stored[key];
5942
+ const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
5802
5943
  if (storedValue !== void 0 && storedValue !== null) {
5803
5944
  const defaultType = typeof this.defaults[key];
5804
5945
  if (typeof storedValue === defaultType) resolved[key] = storedValue;
@@ -5882,6 +6023,27 @@ var BaseAddon = class {
5882
6023
  }
5883
6024
  };
5884
6025
  /**
6026
+ * Collect the keys of every field marked `perNode: true`, recursing into
6027
+ * layout containers (`group` fields and `sub-tabs` tabs) the same way
6028
+ * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6029
+ * don't declare `perNode` and are excluded by the `in` narrowing.
6030
+ */
6031
+ function collectPerNodeFieldKeys(fields) {
6032
+ const collected = [];
6033
+ for (const field of fields) {
6034
+ if (field.type === "group") {
6035
+ collected.push(...collectPerNodeFieldKeys(field.fields));
6036
+ continue;
6037
+ }
6038
+ if (field.type === "sub-tabs") {
6039
+ for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
6040
+ continue;
6041
+ }
6042
+ if ("perNode" in field && field.perNode === true) collected.push(field.key);
6043
+ }
6044
+ return collected;
6045
+ }
6046
+ /**
5885
6047
  * Normalize an `ICamstackAddon.initialize()` return value into the
5886
6048
  * `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
5887
6049
  * envelopes pass through; void stays void.
@@ -5906,6 +6068,7 @@ var CamStreamKindSchema = _enum([
5906
6068
  "pull-rtsp",
5907
6069
  "pull-rtmp",
5908
6070
  "pull-http",
6071
+ "pull-flv",
5909
6072
  "pull-rfc4571",
5910
6073
  "push-annexb",
5911
6074
  "derived"
@@ -6288,6 +6451,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
6288
6451
  /** Single still-image entity (HA `image.*`). Read-only display of an
6289
6452
  * `entity_picture` signed URL the browser loads directly. `image` cap. */
6290
6453
  DeviceType["Image"] = "image";
6454
+ /** Smart pet feeder — cloud-connected food dispenser with a bowl food
6455
+ * level, battery, desiccant life, feeding state and manual-feed /
6456
+ * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
6457
+ * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
6458
+ * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
6459
+ * integrations sharing the same food/desiccant/hopper surface. */
6460
+ DeviceType["PetFeeder"] = "pet-feeder";
6291
6461
  return DeviceType;
6292
6462
  }({});
6293
6463
  var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
@@ -7065,7 +7235,21 @@ var StorageLocationDeclarationSchema = object({
7065
7235
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
7066
7236
  * configure the primary location.
7067
7237
  */
7068
- defaultsTo: string().optional()
7238
+ defaultsTo: string().optional(),
7239
+ /**
7240
+ * Which node root the seeded `<id>:default` instance is placed under on a
7241
+ * FRESH install:
7242
+ * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7243
+ * the appData volume. Right for small/durable data (backups, logs, models).
7244
+ * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7245
+ * env is set, else falls back to the data root. Right for bulky, hot media
7246
+ * (recordings, event media) that should stay off the appData disk.
7247
+ *
7248
+ * Only affects the seeded default's `basePath`; operators can repoint any
7249
+ * location afterwards, and a `defaultsTo` slot inherits its parent's root
7250
+ * regardless of this field. Absent (the common case) is treated as `'data'`.
7251
+ */
7252
+ defaultRoot: _enum(["data", "media"]).optional()
7069
7253
  });
7070
7254
  var DecoderStatsSchema = object({
7071
7255
  inputFps: number(),
@@ -7438,6 +7622,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
7438
7622
  for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7439
7623
  for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7440
7624
  /**
7625
+ * Error types for the safe expression engine. Two distinct classes so callers
7626
+ * can tell a compile-time (grammar) failure from a runtime (evaluation)
7627
+ * failure — both are non-fatal to the host: read paths degrade to "skip link".
7628
+ */
7629
+ /** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
7630
+ * the failure is anchored to a character (author-facing inline feedback). */
7631
+ var ExpressionParseError = class extends Error {
7632
+ position;
7633
+ constructor(message, position) {
7634
+ super(message);
7635
+ this.name = "ExpressionParseError";
7636
+ this.position = position;
7637
+ }
7638
+ };
7639
+ /** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
7640
+ * result, unknown builtin, step-budget exceeded). */
7641
+ var ExpressionEvalError = class extends Error {
7642
+ constructor(message) {
7643
+ super(message);
7644
+ this.name = "ExpressionEvalError";
7645
+ }
7646
+ };
7647
+ /**
7648
+ * Resource-bound constants for the safe expression engine.
7649
+ *
7650
+ * Every bound is defense-in-depth: the grammar is non-Turing-complete (no
7651
+ * loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
7652
+ * O(nodeCount) by construction. These caps merely put a hard ceiling on the
7653
+ * work a single author-supplied expression can request, so a hostile or
7654
+ * accidental pathological string can never spend unbounded CPU/memory.
7655
+ */
7656
+ /** Max source length (chars) — checked BEFORE tokenizing so a huge string is
7657
+ * rejected without allocation. */
7658
+ var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
7659
+ /** A legal binding / identifier name. */
7660
+ var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
7661
+ /** Binding names an author may NOT use: `now` is auto-injected; the literal
7662
+ * keywords lex as values, not identifiers, so binding to them is meaningless. */
7663
+ var RESERVED_BINDING_NAMES = new Set([
7664
+ "now",
7665
+ "true",
7666
+ "false",
7667
+ "null"
7668
+ ]);
7669
+ /**
7670
+ * Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
7671
+ * zero-dependency. The grammar is deliberately boring: decimal numbers,
7672
+ * single/double-quoted strings with a tiny escape set, identifiers, the three
7673
+ * value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
7674
+ * outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
7675
+ * is a parse error with a source position, so member access / assignment /
7676
+ * template literals are lexically impossible.
7677
+ */
7678
+ var KEYWORDS = new Set([
7679
+ "true",
7680
+ "false",
7681
+ "null"
7682
+ ]);
7683
+ function isDigit(ch) {
7684
+ return ch >= "0" && ch <= "9";
7685
+ }
7686
+ function isIdentStart(ch) {
7687
+ return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
7688
+ }
7689
+ function isIdentPart(ch) {
7690
+ return isIdentStart(ch) || isDigit(ch);
7691
+ }
7692
+ function isWhitespace(ch) {
7693
+ return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
7694
+ }
7695
+ /** Tokenize `source` into a flat token list ending with a single `eof` token.
7696
+ * Throws `ExpressionParseError` on any illegal character or unterminated
7697
+ * string. */
7698
+ function tokenize(source) {
7699
+ if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
7700
+ const tokens = [];
7701
+ let i = 0;
7702
+ const n = source.length;
7703
+ while (i < n) {
7704
+ const ch = source[i];
7705
+ if (isWhitespace(ch)) {
7706
+ i += 1;
7707
+ continue;
7708
+ }
7709
+ if (isDigit(ch)) {
7710
+ const start = i;
7711
+ while (i < n && isDigit(source[i])) i += 1;
7712
+ if (i < n && source[i] === ".") {
7713
+ if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
7714
+ i += 1;
7715
+ while (i < n && isDigit(source[i])) i += 1;
7716
+ }
7717
+ const text = source.slice(start, i);
7718
+ const value = Number(text);
7719
+ if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
7720
+ tokens.push({
7721
+ type: "number",
7722
+ value,
7723
+ pos: start
7724
+ });
7725
+ continue;
7726
+ }
7727
+ if (ch === "'" || ch === "\"") {
7728
+ const quote = ch;
7729
+ const start = i;
7730
+ i += 1;
7731
+ let out = "";
7732
+ let closed = false;
7733
+ while (i < n) {
7734
+ const c = source[i];
7735
+ if (c === "\\") {
7736
+ const next = i + 1 < n ? source[i + 1] : "";
7737
+ if (next === "\\" || next === "'" || next === "\"") {
7738
+ out += next;
7739
+ i += 2;
7740
+ continue;
7741
+ }
7742
+ throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
7743
+ }
7744
+ if (c === quote) {
7745
+ closed = true;
7746
+ i += 1;
7747
+ break;
7748
+ }
7749
+ out += c;
7750
+ i += 1;
7751
+ }
7752
+ if (!closed) throw new ExpressionParseError("unterminated string literal", start);
7753
+ tokens.push({
7754
+ type: "string",
7755
+ value: out,
7756
+ pos: start
7757
+ });
7758
+ continue;
7759
+ }
7760
+ if (isIdentStart(ch)) {
7761
+ const start = i;
7762
+ while (i < n && isIdentPart(source[i])) i += 1;
7763
+ const text = source.slice(start, i);
7764
+ if (KEYWORDS.has(text)) tokens.push({
7765
+ type: "keyword",
7766
+ keyword: keywordOf(text),
7767
+ pos: start
7768
+ });
7769
+ else tokens.push({
7770
+ type: "identifier",
7771
+ name: text,
7772
+ pos: start
7773
+ });
7774
+ continue;
7775
+ }
7776
+ const two = i + 1 < n ? source.slice(i, i + 2) : "";
7777
+ if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
7778
+ tokens.push({
7779
+ type: "punct",
7780
+ punct: two,
7781
+ pos: i
7782
+ });
7783
+ i += 2;
7784
+ continue;
7785
+ }
7786
+ if (isSinglePunct(ch)) {
7787
+ tokens.push({
7788
+ type: "punct",
7789
+ punct: ch,
7790
+ pos: i
7791
+ });
7792
+ i += 1;
7793
+ continue;
7794
+ }
7795
+ throw new ExpressionParseError(`unexpected character '${ch}'`, i);
7796
+ }
7797
+ tokens.push({
7798
+ type: "eof",
7799
+ pos: n
7800
+ });
7801
+ return tokens;
7802
+ }
7803
+ function keywordOf(text) {
7804
+ if (text === "true") return "true";
7805
+ if (text === "false") return "false";
7806
+ return "null";
7807
+ }
7808
+ function isSinglePunct(ch) {
7809
+ return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
7810
+ }
7811
+ /**
7812
+ * Frozen, null-prototype builtin function table for the expression engine
7813
+ * (spec §4 rule 4). The table is the SOLE surface of callable functions: the
7814
+ * parser rejects any callee not in it, and the evaluator gates each call on an
7815
+ * own-property check against it.
7816
+ *
7817
+ * Because the object has a NULL prototype AND is `Object.freeze`d:
7818
+ * - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
7819
+ * - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
7820
+ * (there is no `Object.prototype` in the chain), so those names are not
7821
+ * callable — they are simply "unknown function" at parse time.
7822
+ *
7823
+ * Every numeric argument is validated as a finite number and every numeric
7824
+ * RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
7825
+ * (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
7826
+ * closed rather than emitting a garbage value.
7827
+ */
7828
+ function asFiniteNumber(value, name, index) {
7829
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
7830
+ return value;
7831
+ }
7832
+ function asString$1(value, name, index) {
7833
+ if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
7834
+ return value;
7835
+ }
7836
+ function finiteResult(value, name) {
7837
+ if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
7838
+ return value;
7839
+ }
7840
+ function allFiniteNumbers(args, name) {
7841
+ return args.map((a, idx) => asFiniteNumber(a, name, idx));
7842
+ }
7843
+ var INF = Number.POSITIVE_INFINITY;
7844
+ var table = {
7845
+ min: {
7846
+ minArgs: 1,
7847
+ maxArgs: INF,
7848
+ apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
7849
+ },
7850
+ max: {
7851
+ minArgs: 1,
7852
+ maxArgs: INF,
7853
+ apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
7854
+ },
7855
+ abs: {
7856
+ minArgs: 1,
7857
+ maxArgs: 1,
7858
+ apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
7859
+ },
7860
+ floor: {
7861
+ minArgs: 1,
7862
+ maxArgs: 1,
7863
+ apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
7864
+ },
7865
+ ceil: {
7866
+ minArgs: 1,
7867
+ maxArgs: 1,
7868
+ apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
7869
+ },
7870
+ sqrt: {
7871
+ minArgs: 1,
7872
+ maxArgs: 1,
7873
+ apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
7874
+ },
7875
+ round: {
7876
+ minArgs: 1,
7877
+ maxArgs: 2,
7878
+ apply: (args) => {
7879
+ const x = asFiniteNumber(args[0], "round", 0);
7880
+ const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
7881
+ if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
7882
+ const factor = 10 ** digits;
7883
+ return finiteResult(Math.round(x * factor) / factor, "round");
7884
+ }
7885
+ },
7886
+ pow: {
7887
+ minArgs: 2,
7888
+ maxArgs: 2,
7889
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
7890
+ },
7891
+ clamp: {
7892
+ minArgs: 3,
7893
+ maxArgs: 3,
7894
+ apply: (args) => {
7895
+ const x = asFiniteNumber(args[0], "clamp", 0);
7896
+ const lo = asFiniteNumber(args[1], "clamp", 1);
7897
+ const hi = asFiniteNumber(args[2], "clamp", 2);
7898
+ if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
7899
+ return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
7900
+ }
7901
+ },
7902
+ avg: {
7903
+ minArgs: 1,
7904
+ maxArgs: INF,
7905
+ apply: (args) => {
7906
+ const nums = allFiniteNumbers(args, "avg");
7907
+ return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
7908
+ }
7909
+ },
7910
+ sum: {
7911
+ minArgs: 1,
7912
+ maxArgs: INF,
7913
+ apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
7914
+ },
7915
+ coalesce: {
7916
+ minArgs: 1,
7917
+ maxArgs: INF,
7918
+ apply: (args) => {
7919
+ for (const a of args) if (a !== null) return a;
7920
+ return null;
7921
+ }
7922
+ },
7923
+ age: {
7924
+ minArgs: 2,
7925
+ maxArgs: 2,
7926
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
7927
+ },
7928
+ convert: {
7929
+ minArgs: 3,
7930
+ maxArgs: 3,
7931
+ apply: (args, hooks) => {
7932
+ const x = asFiniteNumber(args[0], "convert", 0);
7933
+ const from = asString$1(args[1], "convert", 1).trim();
7934
+ const to = asString$1(args[2], "convert", 2).trim();
7935
+ if (hooks.convert) {
7936
+ const out = hooks.convert(x, from, to);
7937
+ if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
7938
+ return finiteResult(out, "convert");
7939
+ }
7940
+ if (from === to) return x;
7941
+ throw new ExpressionEvalError("convert: unit conversion table not installed");
7942
+ }
7943
+ }
7944
+ };
7945
+ Object.freeze(Object.assign(Object.create(null), table));
7946
+ /** The set of valid builtin names — used by the parser to reject unknown
7947
+ * callees at parse time (immediate author feedback). */
7948
+ var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
7949
+ /**
7950
+ * Pratt (precedence-climbing) parser for the safe expression mini-language.
7951
+ *
7952
+ * Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
7953
+ * → relational → additive → multiplicative → unary `! -` → call / primary.
7954
+ * Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
7955
+ * string validated against the builtin table at parse time, so an unknown
7956
+ * function is rejected immediately (author feedback) and a persisted expression
7957
+ * that references a since-removed builtin degrades at read.
7958
+ *
7959
+ * A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
7960
+ * arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
7961
+ */
7962
+ /** Binary/logical operator precedence (higher binds tighter). */
7963
+ var BINARY_PRECEDENCE = {
7964
+ "||": 1,
7965
+ "&&": 2,
7966
+ "==": 3,
7967
+ "!=": 3,
7968
+ "<": 4,
7969
+ "<=": 4,
7970
+ ">": 4,
7971
+ ">=": 4,
7972
+ "+": 5,
7973
+ "-": 5,
7974
+ "*": 6,
7975
+ "/": 6,
7976
+ "%": 6
7977
+ };
7978
+ function isLogicalOp(op) {
7979
+ return op === "&&" || op === "||";
7980
+ }
7981
+ function isBinaryOp(op) {
7982
+ return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
7983
+ }
7984
+ var Parser = class {
7985
+ tokens;
7986
+ pos = 0;
7987
+ nodeCount = 0;
7988
+ identifiers = /* @__PURE__ */ new Set();
7989
+ callees = /* @__PURE__ */ new Set();
7990
+ constructor(tokens) {
7991
+ this.tokens = tokens;
7992
+ }
7993
+ parse() {
7994
+ const ast = this.parseTernary();
7995
+ const tok = this.peek();
7996
+ if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
7997
+ return {
7998
+ ast,
7999
+ identifiers: this.identifiers,
8000
+ callees: this.callees,
8001
+ nodeCount: this.nodeCount
8002
+ };
8003
+ }
8004
+ peek() {
8005
+ return this.tokens[this.pos];
8006
+ }
8007
+ next() {
8008
+ return this.tokens[this.pos++];
8009
+ }
8010
+ /** Consume a punctuator token, erroring if the next token isn't it. */
8011
+ expectPunct(punct) {
8012
+ const tok = this.peek();
8013
+ if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
8014
+ this.pos += 1;
8015
+ }
8016
+ matchPunct(punct) {
8017
+ const tok = this.peek();
8018
+ if (tok.type === "punct" && tok.punct === punct) {
8019
+ this.pos += 1;
8020
+ return true;
8021
+ }
8022
+ return false;
8023
+ }
8024
+ countNode() {
8025
+ this.nodeCount += 1;
8026
+ if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
8027
+ }
8028
+ parseTernary() {
8029
+ const test = this.parseBinary(1);
8030
+ if (this.matchPunct("?")) {
8031
+ const consequent = this.parseTernary();
8032
+ this.expectPunct(":");
8033
+ const alternate = this.parseTernary();
8034
+ this.countNode();
8035
+ return {
8036
+ kind: "conditional",
8037
+ test,
8038
+ consequent,
8039
+ alternate
8040
+ };
8041
+ }
8042
+ return test;
8043
+ }
8044
+ parseBinary(minPrec) {
8045
+ let left = this.parseUnary();
8046
+ for (;;) {
8047
+ const tok = this.peek();
8048
+ if (tok.type !== "punct") break;
8049
+ const prec = BINARY_PRECEDENCE[tok.punct];
8050
+ if (prec === void 0 || prec < minPrec) break;
8051
+ const op = tok.punct;
8052
+ this.pos += 1;
8053
+ const right = this.parseBinary(prec + 1);
8054
+ this.countNode();
8055
+ if (isLogicalOp(op)) left = {
8056
+ kind: "logical",
8057
+ op,
8058
+ left,
8059
+ right
8060
+ };
8061
+ else if (isBinaryOp(op)) left = {
8062
+ kind: "binary",
8063
+ op,
8064
+ left,
8065
+ right
8066
+ };
8067
+ else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
8068
+ }
8069
+ return left;
8070
+ }
8071
+ parseUnary() {
8072
+ const tok = this.peek();
8073
+ if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
8074
+ const op = tok.punct;
8075
+ this.pos += 1;
8076
+ const operand = this.parseUnary();
8077
+ this.countNode();
8078
+ return {
8079
+ kind: "unary",
8080
+ op,
8081
+ operand
8082
+ };
8083
+ }
8084
+ return this.parsePrimary();
8085
+ }
8086
+ parsePrimary() {
8087
+ const tok = this.next();
8088
+ switch (tok.type) {
8089
+ case "number":
8090
+ this.countNode();
8091
+ return {
8092
+ kind: "literal",
8093
+ value: tok.value
8094
+ };
8095
+ case "string":
8096
+ this.countNode();
8097
+ return {
8098
+ kind: "literal",
8099
+ value: tok.value
8100
+ };
8101
+ case "keyword":
8102
+ this.countNode();
8103
+ return {
8104
+ kind: "literal",
8105
+ value: tok.keyword === "null" ? null : tok.keyword === "true"
8106
+ };
8107
+ case "identifier": {
8108
+ const nextTok = this.peek();
8109
+ if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
8110
+ this.identifiers.add(tok.name);
8111
+ this.countNode();
8112
+ return {
8113
+ kind: "identifier",
8114
+ name: tok.name
8115
+ };
8116
+ }
8117
+ case "punct":
8118
+ if (tok.punct === "(") {
8119
+ const inner = this.parseTernary();
8120
+ this.expectPunct(")");
8121
+ return inner;
8122
+ }
8123
+ throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
8124
+ case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
8125
+ }
8126
+ }
8127
+ parseCall(callee, pos) {
8128
+ if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
8129
+ this.expectPunct("(");
8130
+ const args = [];
8131
+ if (!this.matchPunct(")")) for (;;) {
8132
+ args.push(this.parseTernary());
8133
+ if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
8134
+ if (this.matchPunct(",")) continue;
8135
+ this.expectPunct(")");
8136
+ break;
8137
+ }
8138
+ this.callees.add(callee);
8139
+ this.countNode();
8140
+ return {
8141
+ kind: "call",
8142
+ callee,
8143
+ args
8144
+ };
8145
+ }
8146
+ };
8147
+ /** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
8148
+ * `ExpressionParseError` on any lexical or grammatical failure. */
8149
+ function parseExpression(source) {
8150
+ return new Parser(tokenize(source)).parse();
8151
+ }
8152
+ Object.freeze({});
8153
+ /**
8154
+ * LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
8155
+ * by expr"). The cache stores BOTH successes and failures (negative caching),
8156
+ * so a corrupt persisted string costs exactly one tokenize+parse total — not
8157
+ * one per read on a hot resolve path.
8158
+ *
8159
+ * The cache is a module-level singleton: entries are pure, content-addressed
8160
+ * ASTs keyed by the raw source string, so sharing one instance across all
8161
+ * callers is safe and maximises hit rate.
8162
+ */
8163
+ var cache = /* @__PURE__ */ new Map();
8164
+ function getCached(source) {
8165
+ const hit = cache.get(source);
8166
+ if (hit !== void 0) {
8167
+ cache.delete(source);
8168
+ cache.set(source, hit);
8169
+ return hit;
8170
+ }
8171
+ let result;
8172
+ try {
8173
+ result = {
8174
+ ok: true,
8175
+ parsed: parseExpression(source)
8176
+ };
8177
+ } catch (err) {
8178
+ result = {
8179
+ ok: false,
8180
+ error: err instanceof ExpressionParseError ? err.message : String(err)
8181
+ };
8182
+ }
8183
+ cache.set(source, result);
8184
+ if (cache.size > 256) {
8185
+ const oldest = cache.keys().next().value;
8186
+ if (oldest !== void 0) cache.delete(oldest);
8187
+ }
8188
+ return result;
8189
+ }
8190
+ /** Compile `source`, returning a discriminated result instead of throwing.
8191
+ * Used by read paths that must degrade rather than raise. LRU/negative-cached. */
8192
+ function compileExpressionSafe(source) {
8193
+ return getCached(source);
8194
+ }
8195
+ /**
8196
+ * Author-time validation. Returns `null` when the source is valid, else a
8197
+ * human-readable error message. Checks: the expression compiles; binding count
8198
+ * is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
8199
+ * is not reserved (`now`/keywords) and does not shadow a builtin; and every
8200
+ * FREE identifier of the AST is covered by a binding or the injected `now`.
8201
+ */
8202
+ function validateExpressionSource(src) {
8203
+ const names = Object.keys(src.bindings);
8204
+ if (names.length > 32) return `too many bindings (${names.length} > 32)`;
8205
+ for (const name of names) {
8206
+ if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
8207
+ if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
8208
+ if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
8209
+ }
8210
+ const compiled = compileExpressionSafe(src.expr);
8211
+ if (!compiled.ok) return compiled.error;
8212
+ const bound = new Set(names);
8213
+ for (const id of compiled.parsed.identifiers) {
8214
+ if (id === "now") continue;
8215
+ if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
8216
+ }
8217
+ return null;
8218
+ }
8219
+ /**
7441
8220
  * Accessory device helpers — shared across drivers.
7442
8221
  *
7443
8222
  * Many vendor-specific drivers register accessory child devices on
@@ -8282,7 +9061,13 @@ onStatusChanged: { data: object({
8282
9061
  }) } },
8283
9062
  status: {
8284
9063
  schema: BatteryStatusSchema,
8285
- kind: "push"
9064
+ kind: "push",
9065
+ empty: {
9066
+ percentage: 0,
9067
+ charging: "none",
9068
+ sleeping: false,
9069
+ lastUpdated: 0
9070
+ }
8286
9071
  },
8287
9072
  /**
8288
9073
  * Runtime-state slice — every provider that registers this cap
@@ -8421,6 +9206,10 @@ var RtspRestreamEntrySchema = object({
8421
9206
  var BrokerRtspClientSchema = object({
8422
9207
  sessionId: string(),
8423
9208
  remoteAddr: string(),
9209
+ /** Client `User-Agent` (e.g. `recorder` for the recorder's RTSP pull), or
9210
+ * null/absent when the client sent none. Lets the UI label a consumer by
9211
+ * purpose. Optional so a client built against an older schema stays valid. */
9212
+ userAgent: string().nullish(),
8424
9213
  playing: boolean(),
8425
9214
  muted: boolean(),
8426
9215
  connectedAt: number(),
@@ -9221,21 +10010,38 @@ var connectivityCapability = {
9221
10010
  },
9222
10011
  runtimeState: ConnectivityStatusSchema
9223
10012
  };
10013
+ /**
10014
+ * Generic device-consumables capability — surfaces a device's
10015
+ * maintenance items (vacuum filters/brushes, replaceable cartridges,
10016
+ * descaling cycles, …) with their remaining life and an optional
10017
+ * "Replaced" reset action. Device-agnostic: any provider that knows its
10018
+ * device tracks consumables can register it; the cap declares no
10019
+ * vocabulary of its own — the provider names each item verbatim.
10020
+ *
10021
+ * Like `childLayout`, the cap is INERT until a provider sets items: no
10022
+ * provider populates it by guessing (no HA inference). The UI renders a
10023
+ * "No consumables reported" placeholder when `items` is empty.
10024
+ */
10025
+ /** A single consumable item. Either a continuous `level` (remaining
10026
+ * life %) or a discrete `status` may be known — both may be null when a
10027
+ * provider only knows the item exists. `level` and `status` are not
10028
+ * mutually exclusive; a provider may report both. */
10029
+ var ConsumableItemSchema = object({
10030
+ /** Stable id, e.g. 'main-brush'. */
10031
+ key: string().min(1),
10032
+ /** Display name. */
10033
+ label: string().min(1),
10034
+ /** Remaining life % when known (0..100). */
10035
+ level: number().min(0).max(100).nullable(),
10036
+ /** Discrete state when known (binary mode). */
10037
+ status: _enum(["ok", "replace"]).nullable(),
10038
+ /** Ms epoch of the last replace, when known. */
10039
+ lastResetAt: number().nullable(),
10040
+ /** Whether `reset()` is meaningful for this item. */
10041
+ resettable: boolean()
10042
+ });
9224
10043
  var ConsumablesStatusSchema = object({
9225
- items: array(object({
9226
- /** Stable id, e.g. 'main-brush'. */
9227
- key: string().min(1),
9228
- /** Display name. */
9229
- label: string().min(1),
9230
- /** Remaining life % when known (0..100). */
9231
- level: number().min(0).max(100).nullable(),
9232
- /** Discrete state when known (binary mode). */
9233
- status: _enum(["ok", "replace"]).nullable(),
9234
- /** Ms epoch of the last replace, when known. */
9235
- lastResetAt: number().nullable(),
9236
- /** Whether `reset()` is meaningful for this item. */
9237
- resettable: boolean()
9238
- })),
10044
+ items: array(ConsumableItemSchema),
9239
10045
  lastChangedAt: number()
9240
10046
  });
9241
10047
  var consumablesCapability = {
@@ -9294,7 +10100,25 @@ reset: method(object({
9294
10100
  }) },
9295
10101
  status: {
9296
10102
  schema: ConsumablesStatusSchema,
9297
- kind: "push"
10103
+ kind: "push",
10104
+ empty: {
10105
+ items: [],
10106
+ lastChangedAt: 0
10107
+ },
10108
+ itemArray: {
10109
+ path: "items",
10110
+ keyField: "key",
10111
+ labelField: "label",
10112
+ itemSchema: ConsumableItemSchema,
10113
+ emptyItem: {
10114
+ key: "",
10115
+ label: "",
10116
+ level: null,
10117
+ status: null,
10118
+ lastResetAt: null,
10119
+ resettable: false
10120
+ }
10121
+ }
9298
10122
  },
9299
10123
  runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() })
9300
10124
  };
@@ -10536,7 +11360,8 @@ var MotionAnalysisResultSchema = object({
10536
11360
  });
10537
11361
  method(object({
10538
11362
  deviceId: number(),
10539
- frame: FrameInputSchema
11363
+ frame: FrameInputSchema.optional(),
11364
+ frameHandle: FrameHandleSchema.optional()
10540
11365
  }), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
10541
11366
  deviceId: number(),
10542
11367
  detected: boolean(),
@@ -10783,6 +11608,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
10783
11608
  engine: PipelineEngineChoiceSchema.optional(),
10784
11609
  steps: array(PipelineStepInputSchema).min(1),
10785
11610
  frame: FrameInputSchema.optional(),
11611
+ /**
11612
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
11613
+ * the decoded pixels live in. One more member of the one-of
11614
+ * frame/frameHandle/image/imageBase64/referenceImage group.
11615
+ */
11616
+ frameHandle: FrameHandleSchema.optional(),
10786
11617
  imageBase64: string().optional(),
10787
11618
  /**
10788
11619
  * Binary JPEG bytes — preferred over `imageBase64` on internal
@@ -11025,6 +11856,31 @@ var ReportMotionInputSchema = object({
11025
11856
  regions: array(MotionRegionSchema).readonly().optional()
11026
11857
  });
11027
11858
  /**
11859
+ * Where a runner gets a camera's decoded frames (cross-node Phase 2,
11860
+ * restream-owner model — P2c).
11861
+ *
11862
+ * - `local-broker` (DEFAULT): today's path — subscribe to the co-located
11863
+ * stream-broker's shm frame plane. Every pre-P2c attach payload (no
11864
+ * `frameSource` key) parses to this, so the field is additive with zero
11865
+ * behavior change.
11866
+ * - `remote-restream`: the detect node is NOT the camera's source-owner.
11867
+ * The runner acquires the owner's COMPRESSED passthrough restream
11868
+ * (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
11869
+ * double-pull guard) and decodes LOCALLY via a satellite frame plane +
11870
+ * pull-mode decoder session pinned to its own node. The shm ring stays
11871
+ * node-local; only H.264/H.265 packets cross the wire.
11872
+ * `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
11873
+ * when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
11874
+ * dials for the owner's restream.
11875
+ */
11876
+ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
11877
+ kind: literal("remote-restream"),
11878
+ /** The camera's source-owner node (slice 1: always the hub). */
11879
+ ownerNodeId: string(),
11880
+ /** Operator override for the owner host the runner dials. */
11881
+ hubHostnameOverride: string().optional()
11882
+ })]).describe("Per-camera frame-source mode for the runner (P2c)");
11883
+ /**
11028
11884
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
11029
11885
  * specific runner instance via `attachCamera`. Carries everything the
11030
11886
  * runner needs to subscribe to the local broker and execute inference.
@@ -11122,7 +11978,15 @@ var RunnerCameraConfigSchema = object({
11122
11978
  */
11123
11979
  onboardMotionDrivesAnalyzer: boolean().default(true),
11124
11980
  occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
11125
- occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
11981
+ occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
11982
+ /**
11983
+ * Where this runner gets the camera's decoded frames (P2c). Defaulted so
11984
+ * every existing payload behaves as `local-broker` — the pre-Phase-2 path.
11985
+ * Populated with `remote-restream` by the orchestrator ONLY when the
11986
+ * camera's detect node differs from its source-owner (P2d, gated by the
11987
+ * `remoteSourcingNodes` rollout setting).
11988
+ */
11989
+ frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
11126
11990
  });
11127
11991
  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;
11128
11992
  /**
@@ -11686,6 +12550,157 @@ var numericSensorCapability = {
11686
12550
  runtimeState: NumericSensorStatusSchema
11687
12551
  };
11688
12552
  /**
12553
+ * Feeder connectivity / power status — mirrors the HA petkit device-status
12554
+ * enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
12555
+ * `on_batteries` (running on battery backup). `null` until first reported.
12556
+ */
12557
+ var PetFeederDeviceStatusSchema = _enum([
12558
+ "normal",
12559
+ "offline",
12560
+ "on_batteries"
12561
+ ]);
12562
+ var gramsPortion = number().int().min(4).max(200);
12563
+ var PetFeederStatusSchema = object({
12564
+ /** Food currently in the bowl (grams). Null when the device has not
12565
+ * reported a reading yet. On dual-hopper models this is the combined
12566
+ * bowl reading; per-hopper levels live in `food1`/`food2`. */
12567
+ foodLevel: number().nullable(),
12568
+ /** Hopper-1 food level (grams) on dual-hopper feeders; null on
12569
+ * single-hopper models. */
12570
+ food1: number().nullable(),
12571
+ /** Hopper-2 food level (grams) on dual-hopper feeders; null on
12572
+ * single-hopper models. */
12573
+ food2: number().nullable(),
12574
+ /** Derived low-food flag — mirrors the HA `food_level` binary_sensor
12575
+ * (`device_class: problem`, on = low). True when the bowl is empty /
12576
+ * below the feeder's low threshold. */
12577
+ lowFood: boolean(),
12578
+ /** Battery charge 0..100 (%). Null on mains-powered models or when the
12579
+ * device has no battery reading. */
12580
+ batteryPower: number().min(0).max(100).nullable(),
12581
+ /** Days of desiccant life remaining. Null when the model has no
12582
+ * desiccant sensor. */
12583
+ desiccantLeftDays: number().nullable(),
12584
+ /** True while a feed is in progress. */
12585
+ feeding: boolean(),
12586
+ /** Decoded connectivity / power status (HA petkit device-status enum).
12587
+ * Null until the device has reported a status. */
12588
+ status: PetFeederDeviceStatusSchema.nullable(),
12589
+ /** Decoded human-readable fault message. Null (or the device's `no_error`
12590
+ * sentinel) means healthy; a non-null string is an active fault. Pairs
12591
+ * with `errorCode` for consumers that want the raw integer. */
12592
+ error: string().nullable(),
12593
+ /** Raw device error code (0 / null = no error). */
12594
+ errorCode: number().nullable(),
12595
+ /** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
12596
+ isDualHopper: boolean(),
12597
+ /** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
12598
+ childLock: boolean(),
12599
+ /** Front indicator-light setting. */
12600
+ indicatorLight: boolean(),
12601
+ /** Play a chime when dispensing. */
12602
+ feedSound: boolean(),
12603
+ /** Speaker / prompt volume level (device-scaled integer). */
12604
+ volume: number(),
12605
+ /** Ms epoch when the slice was last refreshed from the cloud. */
12606
+ lastFetchedAt: number()
12607
+ });
12608
+ var petFeederCapability = {
12609
+ name: "pet-feeder",
12610
+ scope: "device",
12611
+ deviceNative: true,
12612
+ mode: "singleton",
12613
+ deviceTypes: [DeviceType.PetFeeder],
12614
+ methods: {
12615
+ /**
12616
+ * Dispense food now. Single-hopper feeders take `grams`; dual-hopper
12617
+ * feeders (D4S/D4SH) accept `hopper1`/`hopper2` to target one or both
12618
+ * hoppers. All portions honour the 4–200 g hardware range. At least
12619
+ * one of the three must be present — the provider rejects an empty
12620
+ * request.
12621
+ */
12622
+ feed: method(object({
12623
+ deviceId: number().int().nonnegative(),
12624
+ grams: gramsPortion.optional(),
12625
+ hopper1: gramsPortion.optional(),
12626
+ hopper2: gramsPortion.optional()
12627
+ }), _void(), {
12628
+ kind: "mutation",
12629
+ auth: "admin"
12630
+ }),
12631
+ /** Cancel an in-progress manual feed. */
12632
+ cancelFeed: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12633
+ kind: "mutation",
12634
+ auth: "admin"
12635
+ }),
12636
+ /** Reset the desiccant "days remaining" counter after replacing it. */
12637
+ resetDesiccant: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12638
+ kind: "mutation",
12639
+ auth: "admin"
12640
+ }),
12641
+ /** Mark a hopper as refilled (D4H/D4S/D4SH). */
12642
+ markFoodReplenished: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12643
+ kind: "mutation",
12644
+ auth: "admin"
12645
+ }),
12646
+ /** Call the pet with the recorded prompt (D3). */
12647
+ callPet: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12648
+ kind: "mutation",
12649
+ auth: "admin"
12650
+ }),
12651
+ /** Play a stored sound by id (D3 / D4H / D4SH). */
12652
+ playSound: method(object({
12653
+ deviceId: number().int().nonnegative(),
12654
+ soundId: number().int().nonnegative()
12655
+ }), _void(), {
12656
+ kind: "mutation",
12657
+ auth: "admin"
12658
+ }),
12659
+ /** Toggle the child-lock (manual-lock) setting. */
12660
+ setChildLock: method(object({
12661
+ deviceId: number().int().nonnegative(),
12662
+ on: boolean()
12663
+ }), _void(), {
12664
+ kind: "mutation",
12665
+ auth: "admin"
12666
+ }),
12667
+ /** Toggle the front indicator light. */
12668
+ setIndicatorLight: method(object({
12669
+ deviceId: number().int().nonnegative(),
12670
+ on: boolean()
12671
+ }), _void(), {
12672
+ kind: "mutation",
12673
+ auth: "admin"
12674
+ }),
12675
+ /** Toggle the dispense chime. */
12676
+ setFeedSound: method(object({
12677
+ deviceId: number().int().nonnegative(),
12678
+ on: boolean()
12679
+ }), _void(), {
12680
+ kind: "mutation",
12681
+ auth: "admin"
12682
+ }),
12683
+ /** Set the speaker / prompt volume level. */
12684
+ setVolume: method(object({
12685
+ deviceId: number().int().nonnegative(),
12686
+ level: number().int().nonnegative()
12687
+ }), _void(), {
12688
+ kind: "mutation",
12689
+ auth: "admin"
12690
+ })
12691
+ },
12692
+ status: {
12693
+ schema: PetFeederStatusSchema,
12694
+ kind: "poll"
12695
+ },
12696
+ /**
12697
+ * Runtime-state slice — mirrored by the kernel. UI feeder cards read
12698
+ * the full slice via `device.state.petFeeder.value` and refresh on
12699
+ * every poll without re-querying the provider.
12700
+ */
12701
+ runtimeState: PetFeederStatusSchema
12702
+ };
12703
+ /**
11689
12704
  * Multi-metric electrical meter. One slice can carry any combination
11690
12705
  * of instantaneous power (W), cumulative energy (kWh), voltage (V),
11691
12706
  * and current (A) — all fields optional so a single-metric source
@@ -12988,6 +14003,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
12988
14003
  nativeObjectDetection: nativeObjectDetectionCapability,
12989
14004
  notifier: notifierCapability,
12990
14005
  numericSensor: numericSensorCapability,
14006
+ petFeeder: petFeederCapability,
12991
14007
  powerMeter: powerMeterCapability,
12992
14008
  presence: presenceCapability,
12993
14009
  pressureSensor: pressureSensorCapability,
@@ -14904,10 +15920,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
14904
15920
  url: string()
14905
15921
  }), _void()), method(object({
14906
15922
  sessionId: string(),
14907
- maxCount: number().default(1)
15923
+ maxCount: number().default(1),
15924
+ waitMs: number().optional()
14908
15925
  }), array(DecodedFrameSchema)), method(object({
14909
15926
  sessionId: string(),
14910
- maxCount: number().default(1)
15927
+ maxCount: number().default(1),
15928
+ waitMs: number().optional()
14911
15929
  }), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
14912
15930
  sessionId: string(),
14913
15931
  config: DecoderSessionConfigSchema.partial()
@@ -15194,14 +16212,63 @@ var ChildLayoutEntrySchema = object({
15194
16212
  collapsed: boolean().optional()
15195
16213
  });
15196
16214
  /** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
15197
- * `device-management.ts`. */
16215
+ * `device-management.ts`. Source is a union: a FIELD source copies a sibling
16216
+ * accessory's status field (`kind` optional/absent for wire compat); a
16217
+ * LITERAL source carries a per-device constant (no sibling is read); a
16218
+ * GLOBAL source (P2e) copies ANY device's status field, addressed by the
16219
+ * source device's full re-sync-stable `stableId`. */
16220
+ var DeviceLinkFieldSourceSchema = object({
16221
+ kind: literal("field").optional(),
16222
+ sourceKey: string(),
16223
+ cap: string(),
16224
+ fieldPath: string()
16225
+ });
16226
+ var DeviceLinkLiteralSourceSchema = object({
16227
+ kind: literal("literal"),
16228
+ value: union([
16229
+ string(),
16230
+ number(),
16231
+ boolean(),
16232
+ _null()
16233
+ ])
16234
+ });
16235
+ var DeviceLinkGlobalSourceSchema = object({
16236
+ kind: literal("global"),
16237
+ sourceStableId: string(),
16238
+ cap: string(),
16239
+ fieldPath: string()
16240
+ });
16241
+ /** Expression source (Stage X): compute the target field from N named bindings
16242
+ * via the safe expression engine. Bindings are field | literal | global — never
16243
+ * another expression (no nesting). The `superRefine` runs the SAME author-time
16244
+ * validation as `validateExpressionSource` (compiles the expr, checks binding
16245
+ * names + identifier coverage) so every wire boundary that parses a DeviceLink
16246
+ * (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
16247
+ * Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
16248
+ var DeviceLinkExpressionSourceSchema = object({
16249
+ kind: literal("expression"),
16250
+ expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
16251
+ bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
16252
+ DeviceLinkFieldSourceSchema,
16253
+ DeviceLinkLiteralSourceSchema,
16254
+ DeviceLinkGlobalSourceSchema
16255
+ ]))
16256
+ }).superRefine((src, ctx) => {
16257
+ const err = validateExpressionSource(src);
16258
+ if (err !== null) ctx.addIssue({
16259
+ code: "custom",
16260
+ message: err,
16261
+ path: ["expr"]
16262
+ });
16263
+ });
15198
16264
  var DeviceLinkSchema = object({
15199
16265
  id: string(),
15200
- source: object({
15201
- sourceKey: string(),
15202
- cap: string(),
15203
- fieldPath: string()
15204
- }),
16266
+ source: union([
16267
+ DeviceLinkFieldSourceSchema,
16268
+ DeviceLinkLiteralSourceSchema,
16269
+ DeviceLinkGlobalSourceSchema,
16270
+ DeviceLinkExpressionSourceSchema
16271
+ ]),
15205
16272
  target: object({
15206
16273
  cap: string(),
15207
16274
  fieldPath: string(),
@@ -15230,6 +16297,31 @@ var DeviceLinkSchema = object({
15230
16297
  })
15231
16298
  ]).optional()
15232
16299
  });
16300
+ /** Cap-wire shape of a per-cap display refinement — mirrors
16301
+ * `DeviceCapDisplayOverride` in `device-management.ts`. */
16302
+ var DeviceCapDisplayOverrideSchema = object({
16303
+ unit: string().min(1).optional(),
16304
+ precision: number().int().min(0).max(10).optional()
16305
+ });
16306
+ /** Cap-wire shape of an operator-authored per-device display override —
16307
+ * mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
16308
+ * bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
16309
+ var DeviceDisplayOverrideSchema = object({
16310
+ icon: string().min(1).optional(),
16311
+ label: string().min(1).optional(),
16312
+ unit: string().min(1).optional(),
16313
+ precision: number().int().min(0).max(10).optional(),
16314
+ hidden: boolean().optional(),
16315
+ perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
16316
+ });
16317
+ /** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
16318
+ * in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
16319
+ * the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
16320
+ var RoleDisplayDefaultSchema = object({
16321
+ unit: string().min(1).optional(),
16322
+ precision: number().int().min(0).max(10).optional(),
16323
+ icon: string().min(1).optional()
16324
+ });
15233
16325
  /**
15234
16326
  * Serializable projection of a live IDevice.
15235
16327
  * Returned by listAll, getDevice, getChildren.
@@ -15285,7 +16377,9 @@ var DeviceInfoSchema = object({
15285
16377
  * `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
15286
16378
  childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
15287
16379
  /** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
15288
- deviceLinks: array(DeviceLinkSchema).readonly().optional()
16380
+ deviceLinks: array(DeviceLinkSchema).readonly().optional(),
16381
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
16382
+ display: DeviceDisplayOverrideSchema.optional()
15289
16383
  });
15290
16384
  var ConfigEntrySchema = object({
15291
16385
  key: string(),
@@ -15350,7 +16444,9 @@ var DeviceMetaSchema = object({
15350
16444
  deviceLinks: array(DeviceLinkSchema).readonly().optional(),
15351
16445
  /** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
15352
16446
  * Optional: only present for accessory children that carry a known role. */
15353
- role: string().nullable().optional()
16447
+ role: string().nullable().optional(),
16448
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
16449
+ display: DeviceDisplayOverrideSchema.optional()
15354
16450
  });
15355
16451
  /** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
15356
16452
  var ConfigUISchemaOutput = unknown().nullable();
@@ -15444,7 +16540,19 @@ method(object({
15444
16540
  }), _void(), {
15445
16541
  kind: "mutation",
15446
16542
  auth: "admin"
15447
- }), method(object({ deviceId: number() }), object({ caps: array(object({
16543
+ }), method(object({
16544
+ deviceId: number(),
16545
+ display: DeviceDisplayOverrideSchema.nullable()
16546
+ }), _void(), {
16547
+ kind: "mutation",
16548
+ auth: "admin"
16549
+ }), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
16550
+ kind: "mutation",
16551
+ auth: "admin"
16552
+ }), method(object({
16553
+ deviceId: number(),
16554
+ includeSynthesizable: boolean().optional()
16555
+ }), object({ caps: array(object({
15448
16556
  cap: string(),
15449
16557
  fields: array(object({
15450
16558
  path: string(),
@@ -15454,8 +16562,13 @@ method(object({
15454
16562
  "boolean",
15455
16563
  "enum"
15456
16564
  ]),
15457
- enumValues: array(string()).optional()
15458
- })).readonly()
16565
+ enumValues: array(string()).optional(),
16566
+ item: boolean().optional()
16567
+ })).readonly(),
16568
+ itemArray: object({
16569
+ path: string(),
16570
+ keyField: string()
16571
+ }).optional()
15459
16572
  })).readonly() }), { kind: "query" }), method(object({
15460
16573
  deviceId: number(),
15461
16574
  role: string().nullable()
@@ -15525,7 +16638,11 @@ method(object({
15525
16638
  deviceId: number(),
15526
16639
  entries: array(object({
15527
16640
  capName: string(),
15528
- kind: _enum(["native", "wrapped"]),
16641
+ kind: _enum([
16642
+ "native",
16643
+ "wrapped",
16644
+ "linked"
16645
+ ]),
15529
16646
  providerAddonId: string(),
15530
16647
  providerNodeId: string(),
15531
16648
  nativeAddonId: string()
@@ -15534,7 +16651,11 @@ method(object({
15534
16651
  deviceId: number(),
15535
16652
  entries: array(object({
15536
16653
  capName: string(),
15537
- kind: _enum(["native", "wrapped"]),
16654
+ kind: _enum([
16655
+ "native",
16656
+ "wrapped",
16657
+ "linked"
16658
+ ]),
15538
16659
  providerAddonId: string(),
15539
16660
  providerNodeId: string(),
15540
16661
  nativeAddonId: string()
@@ -16024,7 +17145,7 @@ var AddBrokerInputSchema = object({
16024
17145
  });
16025
17146
  var AddBrokerResultSchema = object({ id: string() });
16026
17147
  var IdInputSchema = object({ id: string() });
16027
- var TestResultSchema = discriminatedUnion("ok", [object({
17148
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
16028
17149
  ok: literal(true),
16029
17150
  latencyMs: number()
16030
17151
  }), object({
@@ -16047,7 +17168,7 @@ var StatusSchema = object({
16047
17168
  brokerCount: number(),
16048
17169
  embeddedRunning: boolean()
16049
17170
  });
16050
- 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);
17171
+ 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);
16051
17172
  var NetworkEndpointSchema = object({
16052
17173
  url: string(),
16053
17174
  hostname: string(),
@@ -16081,23 +17202,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16081
17202
  sourcePort: number().optional()
16082
17203
  });
16083
17204
  method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16084
- method(object({
16085
- title: string(),
17205
+ /**
17206
+ * notification-output — canonical, capability-gated notification delivery.
17207
+ *
17208
+ * Apprise-derived model (see
17209
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
17210
+ * callers emit ONE canonical `Notification`; each provider declares a
17211
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
17212
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
17213
+ * message to what the kind supports — callers never special-case a service.
17214
+ *
17215
+ * DESIGN DECISIONS (locked):
17216
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
17217
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
17218
+ * cap. Rationale: the admin UI needs one uniform surface across the
17219
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
17220
+ * alternative would fork the UI per addon and cannot host the
17221
+ * discovery→adopt flow.
17222
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
17223
+ * the generated cap-mount auto-`concatCollection`-fans them across every
17224
+ * registered provider (notifiers addon + HA addon) so one catalog is
17225
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
17226
+ * `addonId` the generated collection router extracts from the call input.
17227
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
17228
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
17229
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
17230
+ * base64 fallback needed.
17231
+ *
17232
+ * TODO (deferred, closed-set change — separate decision): add
17233
+ * `providerKind: 'notify'` so notification providers surface on the unified
17234
+ * admin "Integrations" page.
17235
+ */
17236
+ /**
17237
+ * Zentik-derived typed-media enum — the superset across every kind. Each
17238
+ * adapter picks what it supports and the degrade engine filters the rest.
17239
+ */
17240
+ var AttachmentMediaTypeSchema = _enum([
17241
+ "image",
17242
+ "video",
17243
+ "gif",
17244
+ "audio",
17245
+ "icon"
17246
+ ]);
17247
+ /**
17248
+ * A single attachment. Exactly one of `url` (remote source, most adapters
17249
+ * prefer this) or `bytes` (inline source; required for Pushover-style
17250
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
17251
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
17252
+ */
17253
+ var AttachmentSchema = object({
17254
+ mediaType: AttachmentMediaTypeSchema,
17255
+ url: string().optional(),
17256
+ bytes: _instanceof(Uint8Array).optional(),
17257
+ mime: string().optional(),
17258
+ name: string().optional()
17259
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
17260
+ var NotificationFormatSchema = _enum([
17261
+ "text",
17262
+ "markdown",
17263
+ "html"
17264
+ ]);
17265
+ /** A single tap-through action button. */
17266
+ var NotificationActionSchema = object({
17267
+ id: string(),
17268
+ label: string(),
17269
+ url: string().optional()
17270
+ });
17271
+ /**
17272
+ * The canonical notification. `body` is the only hard field (Apprise model).
17273
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
17274
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
17275
+ * the adapter maps this ordinal onto its native level. `level?` is an
17276
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
17277
+ * `priority` for that one target.
17278
+ */
17279
+ var NotificationSchema = object({
16086
17280
  body: string(),
16087
- imageUrl: string().optional(),
17281
+ title: string().optional(),
17282
+ format: NotificationFormatSchema.default("text"),
17283
+ priority: number().int().min(1).max(5).default(3),
17284
+ level: string().optional(),
17285
+ attachments: array(AttachmentSchema).optional(),
17286
+ clickUrl: string().optional(),
17287
+ actions: array(NotificationActionSchema).optional(),
17288
+ sound: string().optional(),
17289
+ ttl: number().optional(),
17290
+ tag: string().optional(),
16088
17291
  deviceId: number().optional(),
16089
17292
  eventId: string().optional(),
16090
- priority: _enum([
16091
- "low",
16092
- "normal",
16093
- "high",
16094
- "critical"
16095
- ]).default("normal"),
16096
17293
  metadata: record(string(), unknown()).optional()
16097
- }), _void(), { kind: "mutation" }), method(_void(), object({
17294
+ });
17295
+ /** One declared native severity/priority level for a kind. */
17296
+ var TargetKindLevelSchema = object({
17297
+ id: string(),
17298
+ label: string(),
17299
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
17300
+ ordinal: number().int().min(1).max(5).nullable(),
17301
+ flags: object({
17302
+ critical: boolean().optional(),
17303
+ silent: boolean().optional(),
17304
+ noPush: boolean().optional()
17305
+ }).optional(),
17306
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
17307
+ requires: array(string()).optional(),
17308
+ description: string().optional()
17309
+ });
17310
+ /** The full capability block consulted before dispatch. */
17311
+ var TargetKindCapsSchema = object({
17312
+ attachments: object({
17313
+ mediaTypes: array(AttachmentMediaTypeSchema),
17314
+ mode: _enum([
17315
+ "url",
17316
+ "bytes",
17317
+ "both"
17318
+ ]),
17319
+ max: number().int().nonnegative(),
17320
+ maxBytes: number().int().positive().optional()
17321
+ }),
17322
+ /** Max action buttons (0 = none). */
17323
+ actions: number().int().nonnegative(),
17324
+ levels: array(TargetKindLevelSchema),
17325
+ format: array(NotificationFormatSchema),
17326
+ clickUrl: boolean(),
17327
+ sound: boolean(),
17328
+ ttl: boolean(),
17329
+ bodyMaxLen: number().int().positive()
17330
+ });
17331
+ /**
17332
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
17333
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
17334
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
17335
+ * the union is large and not meant for runtime validation here; the exported
17336
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
17337
+ */
17338
+ var ConfigSchemaPassthrough = unknown();
17339
+ var TargetKindSchema = object({
17340
+ kind: string(),
17341
+ label: string(),
17342
+ icon: string(),
17343
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
17344
+ addonId: string(),
17345
+ configSchema: ConfigSchemaPassthrough,
17346
+ supportsDiscovery: boolean(),
17347
+ caps: TargetKindCapsSchema
17348
+ });
17349
+ /**
17350
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
17351
+ * (return a presence marker only) when serving `listTargets` — never
17352
+ * round-trip a stored secret to the UI.
17353
+ */
17354
+ var TargetSchema = object({
17355
+ id: string(),
17356
+ name: string(),
17357
+ kind: string(),
17358
+ addonId: string(),
17359
+ enabled: boolean(),
17360
+ config: record(string(), unknown())
17361
+ });
17362
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
17363
+ var DiscoveredTargetSchema = object({
17364
+ kind: string(),
17365
+ suggestedName: string(),
17366
+ config: record(string(), unknown())
17367
+ });
17368
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
17369
+ var RenderedAsSchema = object({
17370
+ level: string(),
17371
+ format: NotificationFormatSchema,
17372
+ attachmentsSent: number().int().nonnegative(),
17373
+ actionsSent: number().int().nonnegative(),
17374
+ truncated: boolean(),
17375
+ dropped: array(string())
17376
+ });
17377
+ var SendResultSchema = object({
16098
17378
  success: boolean(),
16099
- error: string().optional()
16100
- }), { kind: "mutation" });
17379
+ error: string().optional(),
17380
+ renderedAs: RenderedAsSchema.optional()
17381
+ });
17382
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
17383
+ var TestResultSchema = SendResultSchema;
17384
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
17385
+ kind: string(),
17386
+ config: record(string(), unknown()).optional()
17387
+ }), array(DiscoveredTargetSchema)), method(object({
17388
+ targetId: string(),
17389
+ notification: NotificationSchema
17390
+ }), SendResultSchema, { kind: "mutation" }), method(object({
17391
+ targetId: string(),
17392
+ sample: NotificationSchema.optional()
17393
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
17394
+ targetId: string(),
17395
+ enabled: boolean()
17396
+ }), _void(), { kind: "mutation" });
16101
17397
  /**
16102
17398
  * Zod schemas for persisted record types.
16103
17399
  *
@@ -19119,7 +20415,10 @@ var HwAccelBackendInputSchema = _enum([
19119
20415
  "webgpu",
19120
20416
  "none"
19121
20417
  ]).nullable().optional();
19122
- var HwAccelResolutionSchema = object({ preferred: array(string()).readonly() });
20418
+ var HwAccelResolutionSchema = object({
20419
+ preferred: array(string()).readonly(),
20420
+ rationale: string()
20421
+ });
19123
20422
  var HardwareEncoderIdSchema = _enum([
19124
20423
  "h264_videotoolbox",
19125
20424
  "hevc_videotoolbox",
@@ -19224,10 +20523,7 @@ var ResolvedInferenceConfigSchema = object({
19224
20523
  format: ModelFormatSchema,
19225
20524
  reason: string()
19226
20525
  });
19227
- method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
19228
- prefer: HwAccelBackendInputSchema,
19229
- nodeId: string().optional()
19230
- }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
20526
+ method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
19231
20527
  kind: "mutation",
19232
20528
  auth: "admin"
19233
20529
  }), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
@@ -19286,6 +20582,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
19286
20582
  kind: "mutation",
19287
20583
  auth: "admin"
19288
20584
  });
20585
+ /**
20586
+ * `recording` cap — footage availability + HLS playback manifests + per-device
20587
+ * recording config. NOTE on events (source of truth, R5/C3): this cap carries
20588
+ * NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
20589
+ * events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
20590
+ * rows); the recorder's internal EventMap markers are ephemeral in-RAM
20591
+ * annotations that are not exposed here and must not be treated as an event
20592
+ * feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
20593
+ * (`interfaces/recording-config.ts`).
20594
+ */
19289
20595
  var RecordingStatusSchema = object({
19290
20596
  deviceId: number(),
19291
20597
  enabled: boolean(),
@@ -20922,6 +22228,12 @@ Object.freeze({
20922
22228
  addonId: null,
20923
22229
  access: "view"
20924
22230
  },
22231
+ "deviceManager.getRoleDisplayDefaults": {
22232
+ capName: "device-manager",
22233
+ capScope: "system",
22234
+ addonId: null,
22235
+ access: "view"
22236
+ },
20925
22237
  "deviceManager.getSettingsSchema": {
20926
22238
  capName: "device-manager",
20927
22239
  capScope: "system",
@@ -21072,6 +22384,12 @@ Object.freeze({
21072
22384
  addonId: null,
21073
22385
  access: "create"
21074
22386
  },
22387
+ "deviceManager.setDisplay": {
22388
+ capName: "device-manager",
22389
+ capScope: "system",
22390
+ addonId: null,
22391
+ access: "create"
22392
+ },
21075
22393
  "deviceManager.setIntegrationId": {
21076
22394
  capName: "device-manager",
21077
22395
  capScope: "system",
@@ -21114,6 +22432,12 @@ Object.freeze({
21114
22432
  addonId: null,
21115
22433
  access: "create"
21116
22434
  },
22435
+ "deviceManager.setRoleDisplayDefaults": {
22436
+ capName: "device-manager",
22437
+ capScope: "system",
22438
+ addonId: null,
22439
+ access: "create"
22440
+ },
21117
22441
  "deviceManager.setStreamProfileMap": {
21118
22442
  capName: "device-manager",
21119
22443
  capScope: "system",
@@ -22092,13 +23416,49 @@ Object.freeze({
22092
23416
  addonId: null,
22093
23417
  access: "create"
22094
23418
  },
23419
+ "notificationOutput.deleteTarget": {
23420
+ capName: "notification-output",
23421
+ capScope: "system",
23422
+ addonId: null,
23423
+ access: "delete"
23424
+ },
23425
+ "notificationOutput.discoverTargets": {
23426
+ capName: "notification-output",
23427
+ capScope: "system",
23428
+ addonId: null,
23429
+ access: "view"
23430
+ },
23431
+ "notificationOutput.listTargetKinds": {
23432
+ capName: "notification-output",
23433
+ capScope: "system",
23434
+ addonId: null,
23435
+ access: "view"
23436
+ },
23437
+ "notificationOutput.listTargets": {
23438
+ capName: "notification-output",
23439
+ capScope: "system",
23440
+ addonId: null,
23441
+ access: "view"
23442
+ },
22095
23443
  "notificationOutput.send": {
22096
23444
  capName: "notification-output",
22097
23445
  capScope: "system",
22098
23446
  addonId: null,
22099
23447
  access: "create"
22100
23448
  },
22101
- "notificationOutput.sendTest": {
23449
+ "notificationOutput.setTargetEnabled": {
23450
+ capName: "notification-output",
23451
+ capScope: "system",
23452
+ addonId: null,
23453
+ access: "create"
23454
+ },
23455
+ "notificationOutput.testTarget": {
23456
+ capName: "notification-output",
23457
+ capScope: "system",
23458
+ addonId: null,
23459
+ access: "create"
23460
+ },
23461
+ "notificationOutput.upsertTarget": {
22102
23462
  capName: "notification-output",
22103
23463
  capScope: "system",
22104
23464
  addonId: null,
@@ -22128,6 +23488,66 @@ Object.freeze({
22128
23488
  addonId: null,
22129
23489
  access: "create"
22130
23490
  },
23491
+ "petFeeder.callPet": {
23492
+ capName: "pet-feeder",
23493
+ capScope: "device",
23494
+ addonId: null,
23495
+ access: "create"
23496
+ },
23497
+ "petFeeder.cancelFeed": {
23498
+ capName: "pet-feeder",
23499
+ capScope: "device",
23500
+ addonId: null,
23501
+ access: "create"
23502
+ },
23503
+ "petFeeder.feed": {
23504
+ capName: "pet-feeder",
23505
+ capScope: "device",
23506
+ addonId: null,
23507
+ access: "create"
23508
+ },
23509
+ "petFeeder.markFoodReplenished": {
23510
+ capName: "pet-feeder",
23511
+ capScope: "device",
23512
+ addonId: null,
23513
+ access: "create"
23514
+ },
23515
+ "petFeeder.playSound": {
23516
+ capName: "pet-feeder",
23517
+ capScope: "device",
23518
+ addonId: null,
23519
+ access: "create"
23520
+ },
23521
+ "petFeeder.resetDesiccant": {
23522
+ capName: "pet-feeder",
23523
+ capScope: "device",
23524
+ addonId: null,
23525
+ access: "delete"
23526
+ },
23527
+ "petFeeder.setChildLock": {
23528
+ capName: "pet-feeder",
23529
+ capScope: "device",
23530
+ addonId: null,
23531
+ access: "create"
23532
+ },
23533
+ "petFeeder.setFeedSound": {
23534
+ capName: "pet-feeder",
23535
+ capScope: "device",
23536
+ addonId: null,
23537
+ access: "create"
23538
+ },
23539
+ "petFeeder.setIndicatorLight": {
23540
+ capName: "pet-feeder",
23541
+ capScope: "device",
23542
+ addonId: null,
23543
+ access: "create"
23544
+ },
23545
+ "petFeeder.setVolume": {
23546
+ capName: "pet-feeder",
23547
+ capScope: "device",
23548
+ addonId: null,
23549
+ access: "create"
23550
+ },
22131
23551
  "pipelineAnalytics.clearTracks": {
22132
23552
  capName: "pipeline-analytics",
22133
23553
  capScope: "device",