@camstack/addon-provider-hikvision 1.1.12 → 1.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +1483 -63
  2. package/dist/addon.mjs +1483 -63
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -4636,7 +4636,7 @@ function _instanceof(cls, params = {}) {
4636
4636
  return inst;
4637
4637
  }
4638
4638
  //#endregion
4639
- //#region ../types/dist/sleep-C2M2zF7x.mjs
4639
+ //#region ../types/dist/sleep-BiDFW0E7.mjs
4640
4640
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4641
4641
  EventCategory["SystemBoot"] = "system.boot";
4642
4642
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5449,6 +5449,100 @@ function createDurableState(deps) {
5449
5449
  };
5450
5450
  }
5451
5451
  /**
5452
+ * Per-node scoping for the shared addon-settings blob.
5453
+ *
5454
+ * An addon's settings store is hub-central (the `addon-settings` cap is
5455
+ * hub-routed — the hub instance answers for every node), so fields whose
5456
+ * value is a NODE fact (decoder backend, engine pick, probed hardware
5457
+ * capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
5458
+ * the single shared blob. The SCHEMA field key stays bare: the write path
5459
+ * ({@link scopePatch}) maps the bare field onto the target node's scoped
5460
+ * key; the read/hydrate path ({@link projectStore}) maps THIS node's value
5461
+ * back, so UI forms and `resolveConfig` only ever see the bare key.
5462
+ *
5463
+ * Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
5464
+ * (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
5465
+ * schema and routes reads/writes through these helpers.
5466
+ *
5467
+ * ## No bare-key fallback — deliberate
5468
+ *
5469
+ * {@link readNodeValue} reads the node-scoped key ONLY. A node with no
5470
+ * scoped key resolves to `undefined` so the field's schema `default` wins —
5471
+ * NEVER `store[base]` and never another node's value. A bare legacy key in
5472
+ * the store is invisible to every node, hub included, so one node's
5473
+ * selection can never leak onto another. (This generalizes the
5474
+ * `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
5475
+ * arbitrary set of per-node field keys.)
5476
+ *
5477
+ * Pure functions only — no I/O, no imports beyond the language. This is a
5478
+ * LEAF module: import it via its deep path, never from the root barrel.
5479
+ */
5480
+ /**
5481
+ * Normalize a raw kernel node id to the bare node id used for scoping.
5482
+ * `localNodeId` can carry a `<node>/<addon>` suffix on forked child
5483
+ * processes; per-node settings are per-NODE, so strip the addon segment.
5484
+ * `undefined` / `null` / empty falls back to `'hub'`.
5485
+ */
5486
+ function normalizeNodeId(raw) {
5487
+ if (raw === void 0 || raw === null || raw === "") return "hub";
5488
+ const slashIdx = raw.indexOf("/");
5489
+ if (slashIdx < 0) return raw;
5490
+ const bare = raw.slice(0, slashIdx);
5491
+ return bare === "" ? "hub" : bare;
5492
+ }
5493
+ /** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
5494
+ function nodeScopedKey(base, nodeId) {
5495
+ return `${base}@${normalizeNodeId(nodeId)}`;
5496
+ }
5497
+ /**
5498
+ * Read a node's value for a per-node field from the raw shared store:
5499
+ * the node-scoped key when present, otherwise `undefined`.
5500
+ * Deliberately NO bare-key fallback (see module doc) — the caller lets the
5501
+ * schema `default` win on `undefined`.
5502
+ */
5503
+ function readNodeValue(store, base, nodeId) {
5504
+ return store[nodeScopedKey(base, nodeId)];
5505
+ }
5506
+ /**
5507
+ * Re-map a UI/settings patch so every bare perNode field persists under the
5508
+ * TARGET node's scoped key; all other keys pass through unchanged. Used on
5509
+ * the write path so a save for one node never clobbers another node's value
5510
+ * (and the bare key is never written). Returns a new object — the input
5511
+ * patch is not mutated.
5512
+ */
5513
+ function scopePatch(patch, perNodeKeys, nodeId) {
5514
+ const out = {};
5515
+ for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
5516
+ return out;
5517
+ }
5518
+ /**
5519
+ * Project the raw shared store onto the bare schema keys for ONE node so a
5520
+ * UI schema (whose field keys are bare) hydrates from that node's own
5521
+ * values:
5522
+ *
5523
+ * - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
5524
+ * - Every bare perNode key is dropped from the pass-through (a stray bare
5525
+ * legacy key must never hydrate any node — no bare fallback).
5526
+ * - THIS node's effective value ({@link readNodeValue}) is then laid onto
5527
+ * each bare perNode key; when the node has no scoped key the bare key is
5528
+ * left ABSENT so the field's schema `default` wins.
5529
+ *
5530
+ * Returns a new object — the input store is not mutated.
5531
+ */
5532
+ function projectStore(store, perNodeKeys, nodeId) {
5533
+ const out = {};
5534
+ for (const [key, value] of Object.entries(store)) {
5535
+ if (key.includes("@")) continue;
5536
+ if (perNodeKeys.has(key)) continue;
5537
+ out[key] = value;
5538
+ }
5539
+ for (const base of perNodeKeys) {
5540
+ const value = readNodeValue(store, base, nodeId);
5541
+ if (value !== void 0) out[base] = value;
5542
+ }
5543
+ return out;
5544
+ }
5545
+ /**
5452
5546
  * Base class for CamStack addons. Eliminates settings boilerplate:
5453
5547
  *
5454
5548
  * - Typed `config` property with automatic resolution from store + defaults
@@ -5616,23 +5710,63 @@ var BaseAddon = class {
5616
5710
  deviceSettingsSchema() {
5617
5711
  return null;
5618
5712
  }
5619
- async getGlobalSettings(overlay, cap, _nodeId) {
5713
+ async getGlobalSettings(overlay, cap, nodeId) {
5620
5714
  const schema = this.globalSettingsSchema(cap);
5621
5715
  if (!schema) return { sections: [] };
5622
- const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5716
+ const projected = await this.resolveGlobalStore(nodeId, cap);
5623
5717
  return hydrateSchema(schema, overlay ? {
5624
- ...raw,
5718
+ ...projected,
5625
5719
  ...overlay
5626
- } : raw);
5720
+ } : projected);
5627
5721
  }
5628
- async updateGlobalSettings(patch, _nodeId) {
5629
- await this._ctx?.settings?.writeAddonStore(patch);
5722
+ /**
5723
+ * The raw addon store PROJECTED onto the target node's bare per-node keys:
5724
+ * every `perNode: true` field carries THAT node's scoped value on its bare
5725
+ * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
5726
+ * bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
5727
+ * A no-op passthrough when the schema declares no `perNode` field.
5728
+ *
5729
+ * This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
5730
+ * the store for custom option logic (option narrowing, value snapping) to
5731
+ * read it per-node — never `ctx.settings.readAddonStore()` directly.
5732
+ * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
5733
+ */
5734
+ async resolveGlobalStore(nodeId, cap) {
5735
+ const raw = await this._ctx?.settings?.readAddonStore() ?? {};
5736
+ const keys = this.perNodeKeys(cap);
5737
+ const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5738
+ return keys.size > 0 ? projectStore(raw, keys, node) : raw;
5739
+ }
5740
+ async updateGlobalSettings(patch, nodeId) {
5741
+ const keys = this.perNodeKeys();
5742
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5743
+ const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
5744
+ const barePatch = patch;
5745
+ const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
5746
+ await this._ctx?.settings?.writeAddonStore(scoped);
5747
+ if (target !== localNode) return;
5630
5748
  await this.resolveConfig();
5631
5749
  await this.onConfigChanged();
5632
5750
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
5633
5751
  this.maybeAutoRestart(patch, this.globalSettingsSchema());
5634
5752
  }
5635
5753
  /**
5754
+ * The set of field keys the global settings schema declares `perNode: true`
5755
+ * — derived once per `cap` argument and memoized (schemas are static
5756
+ * declarations). Empty set ⇒ every per-node code path is bypassed and the
5757
+ * settings API behaves exactly like the legacy node-agnostic one.
5758
+ */
5759
+ _perNodeKeysCache = /* @__PURE__ */ new Map();
5760
+ perNodeKeys(cap) {
5761
+ const cacheKey = cap ?? "";
5762
+ const cached = this._perNodeKeysCache.get(cacheKey);
5763
+ if (cached) return cached;
5764
+ const schema = this.globalSettingsSchema(cap);
5765
+ const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
5766
+ this._perNodeKeysCache.set(cacheKey, keys);
5767
+ return keys;
5768
+ }
5769
+ /**
5636
5770
  * If any field in `patch` is marked `requiresRestart` in `schema`,
5637
5771
  * schedule an addon restart for the next tick. Deferred via
5638
5772
  * `setImmediate` so the tRPC mutation that triggered the write has
@@ -5785,12 +5919,19 @@ var BaseAddon = class {
5785
5919
  * The merge is shallow: each key in `defaults` is checked against the store.
5786
5920
  * Only keys present in defaults are read — the store can contain extra keys
5787
5921
  * (e.g. from older versions) without polluting the typed config.
5922
+ *
5923
+ * Keys the global settings schema declares `perNode: true` resolve from
5924
+ * THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
5925
+ * from the bare key — so a per-node field resolves to this node's own
5926
+ * selection at boot (absent scoped key ⇒ the constructor default wins).
5788
5927
  */
5789
5928
  async resolveConfig() {
5790
5929
  const stored = await this.readAddonStoreWithRetry();
5930
+ const perNode = this.perNodeKeys();
5931
+ const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
5791
5932
  const resolved = { ...this.defaults };
5792
5933
  for (const key of Object.keys(this.defaults)) {
5793
- const storedValue = stored[key];
5934
+ const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
5794
5935
  if (storedValue !== void 0 && storedValue !== null) {
5795
5936
  const defaultType = typeof this.defaults[key];
5796
5937
  if (typeof storedValue === defaultType) resolved[key] = storedValue;
@@ -5874,6 +6015,27 @@ var BaseAddon = class {
5874
6015
  }
5875
6016
  };
5876
6017
  /**
6018
+ * Collect the keys of every field marked `perNode: true`, recursing into
6019
+ * layout containers (`group` fields and `sub-tabs` tabs) the same way
6020
+ * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6021
+ * don't declare `perNode` and are excluded by the `in` narrowing.
6022
+ */
6023
+ function collectPerNodeFieldKeys(fields) {
6024
+ const collected = [];
6025
+ for (const field of fields) {
6026
+ if (field.type === "group") {
6027
+ collected.push(...collectPerNodeFieldKeys(field.fields));
6028
+ continue;
6029
+ }
6030
+ if (field.type === "sub-tabs") {
6031
+ for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
6032
+ continue;
6033
+ }
6034
+ if ("perNode" in field && field.perNode === true) collected.push(field.key);
6035
+ }
6036
+ return collected;
6037
+ }
6038
+ /**
5877
6039
  * Normalize an `ICamstackAddon.initialize()` return value into the
5878
6040
  * `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
5879
6041
  * envelopes pass through; void stays void.
@@ -5898,6 +6060,7 @@ var CamStreamKindSchema = _enum([
5898
6060
  "pull-rtsp",
5899
6061
  "pull-rtmp",
5900
6062
  "pull-http",
6063
+ "pull-flv",
5901
6064
  "pull-rfc4571",
5902
6065
  "push-annexb",
5903
6066
  "derived"
@@ -6280,6 +6443,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
6280
6443
  /** Single still-image entity (HA `image.*`). Read-only display of an
6281
6444
  * `entity_picture` signed URL the browser loads directly. `image` cap. */
6282
6445
  DeviceType["Image"] = "image";
6446
+ /** Smart pet feeder — cloud-connected food dispenser with a bowl food
6447
+ * level, battery, desiccant life, feeding state and manual-feed /
6448
+ * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
6449
+ * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
6450
+ * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
6451
+ * integrations sharing the same food/desiccant/hopper surface. */
6452
+ DeviceType["PetFeeder"] = "pet-feeder";
6283
6453
  return DeviceType;
6284
6454
  }({});
6285
6455
  var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
@@ -7220,7 +7390,21 @@ var StorageLocationDeclarationSchema = object({
7220
7390
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
7221
7391
  * configure the primary location.
7222
7392
  */
7223
- defaultsTo: string().optional()
7393
+ defaultsTo: string().optional(),
7394
+ /**
7395
+ * Which node root the seeded `<id>:default` instance is placed under on a
7396
+ * FRESH install:
7397
+ * - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
7398
+ * the appData volume. Right for small/durable data (backups, logs, models).
7399
+ * - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
7400
+ * env is set, else falls back to the data root. Right for bulky, hot media
7401
+ * (recordings, event media) that should stay off the appData disk.
7402
+ *
7403
+ * Only affects the seeded default's `basePath`; operators can repoint any
7404
+ * location afterwards, and a `defaultsTo` slot inherits its parent's root
7405
+ * regardless of this field. Absent (the common case) is treated as `'data'`.
7406
+ */
7407
+ defaultRoot: _enum(["data", "media"]).optional()
7224
7408
  });
7225
7409
  var DecoderStatsSchema = object({
7226
7410
  inputFps: number(),
@@ -7593,6 +7777,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
7593
7777
  for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7594
7778
  for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7595
7779
  /**
7780
+ * Error types for the safe expression engine. Two distinct classes so callers
7781
+ * can tell a compile-time (grammar) failure from a runtime (evaluation)
7782
+ * failure — both are non-fatal to the host: read paths degrade to "skip link".
7783
+ */
7784
+ /** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
7785
+ * the failure is anchored to a character (author-facing inline feedback). */
7786
+ var ExpressionParseError = class extends Error {
7787
+ position;
7788
+ constructor(message, position) {
7789
+ super(message);
7790
+ this.name = "ExpressionParseError";
7791
+ this.position = position;
7792
+ }
7793
+ };
7794
+ /** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
7795
+ * result, unknown builtin, step-budget exceeded). */
7796
+ var ExpressionEvalError = class extends Error {
7797
+ constructor(message) {
7798
+ super(message);
7799
+ this.name = "ExpressionEvalError";
7800
+ }
7801
+ };
7802
+ /**
7803
+ * Resource-bound constants for the safe expression engine.
7804
+ *
7805
+ * Every bound is defense-in-depth: the grammar is non-Turing-complete (no
7806
+ * loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
7807
+ * O(nodeCount) by construction. These caps merely put a hard ceiling on the
7808
+ * work a single author-supplied expression can request, so a hostile or
7809
+ * accidental pathological string can never spend unbounded CPU/memory.
7810
+ */
7811
+ /** Max source length (chars) — checked BEFORE tokenizing so a huge string is
7812
+ * rejected without allocation. */
7813
+ var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
7814
+ /** A legal binding / identifier name. */
7815
+ var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
7816
+ /** Binding names an author may NOT use: `now` is auto-injected; the literal
7817
+ * keywords lex as values, not identifiers, so binding to them is meaningless. */
7818
+ var RESERVED_BINDING_NAMES = new Set([
7819
+ "now",
7820
+ "true",
7821
+ "false",
7822
+ "null"
7823
+ ]);
7824
+ /**
7825
+ * Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
7826
+ * zero-dependency. The grammar is deliberately boring: decimal numbers,
7827
+ * single/double-quoted strings with a tiny escape set, identifiers, the three
7828
+ * value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
7829
+ * outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
7830
+ * is a parse error with a source position, so member access / assignment /
7831
+ * template literals are lexically impossible.
7832
+ */
7833
+ var KEYWORDS = new Set([
7834
+ "true",
7835
+ "false",
7836
+ "null"
7837
+ ]);
7838
+ function isDigit(ch) {
7839
+ return ch >= "0" && ch <= "9";
7840
+ }
7841
+ function isIdentStart(ch) {
7842
+ return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
7843
+ }
7844
+ function isIdentPart(ch) {
7845
+ return isIdentStart(ch) || isDigit(ch);
7846
+ }
7847
+ function isWhitespace(ch) {
7848
+ return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
7849
+ }
7850
+ /** Tokenize `source` into a flat token list ending with a single `eof` token.
7851
+ * Throws `ExpressionParseError` on any illegal character or unterminated
7852
+ * string. */
7853
+ function tokenize(source) {
7854
+ if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
7855
+ const tokens = [];
7856
+ let i = 0;
7857
+ const n = source.length;
7858
+ while (i < n) {
7859
+ const ch = source[i];
7860
+ if (isWhitespace(ch)) {
7861
+ i += 1;
7862
+ continue;
7863
+ }
7864
+ if (isDigit(ch)) {
7865
+ const start = i;
7866
+ while (i < n && isDigit(source[i])) i += 1;
7867
+ if (i < n && source[i] === ".") {
7868
+ if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
7869
+ i += 1;
7870
+ while (i < n && isDigit(source[i])) i += 1;
7871
+ }
7872
+ const text = source.slice(start, i);
7873
+ const value = Number(text);
7874
+ if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
7875
+ tokens.push({
7876
+ type: "number",
7877
+ value,
7878
+ pos: start
7879
+ });
7880
+ continue;
7881
+ }
7882
+ if (ch === "'" || ch === "\"") {
7883
+ const quote = ch;
7884
+ const start = i;
7885
+ i += 1;
7886
+ let out = "";
7887
+ let closed = false;
7888
+ while (i < n) {
7889
+ const c = source[i];
7890
+ if (c === "\\") {
7891
+ const next = i + 1 < n ? source[i + 1] : "";
7892
+ if (next === "\\" || next === "'" || next === "\"") {
7893
+ out += next;
7894
+ i += 2;
7895
+ continue;
7896
+ }
7897
+ throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
7898
+ }
7899
+ if (c === quote) {
7900
+ closed = true;
7901
+ i += 1;
7902
+ break;
7903
+ }
7904
+ out += c;
7905
+ i += 1;
7906
+ }
7907
+ if (!closed) throw new ExpressionParseError("unterminated string literal", start);
7908
+ tokens.push({
7909
+ type: "string",
7910
+ value: out,
7911
+ pos: start
7912
+ });
7913
+ continue;
7914
+ }
7915
+ if (isIdentStart(ch)) {
7916
+ const start = i;
7917
+ while (i < n && isIdentPart(source[i])) i += 1;
7918
+ const text = source.slice(start, i);
7919
+ if (KEYWORDS.has(text)) tokens.push({
7920
+ type: "keyword",
7921
+ keyword: keywordOf(text),
7922
+ pos: start
7923
+ });
7924
+ else tokens.push({
7925
+ type: "identifier",
7926
+ name: text,
7927
+ pos: start
7928
+ });
7929
+ continue;
7930
+ }
7931
+ const two = i + 1 < n ? source.slice(i, i + 2) : "";
7932
+ if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
7933
+ tokens.push({
7934
+ type: "punct",
7935
+ punct: two,
7936
+ pos: i
7937
+ });
7938
+ i += 2;
7939
+ continue;
7940
+ }
7941
+ if (isSinglePunct(ch)) {
7942
+ tokens.push({
7943
+ type: "punct",
7944
+ punct: ch,
7945
+ pos: i
7946
+ });
7947
+ i += 1;
7948
+ continue;
7949
+ }
7950
+ throw new ExpressionParseError(`unexpected character '${ch}'`, i);
7951
+ }
7952
+ tokens.push({
7953
+ type: "eof",
7954
+ pos: n
7955
+ });
7956
+ return tokens;
7957
+ }
7958
+ function keywordOf(text) {
7959
+ if (text === "true") return "true";
7960
+ if (text === "false") return "false";
7961
+ return "null";
7962
+ }
7963
+ function isSinglePunct(ch) {
7964
+ return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
7965
+ }
7966
+ /**
7967
+ * Frozen, null-prototype builtin function table for the expression engine
7968
+ * (spec §4 rule 4). The table is the SOLE surface of callable functions: the
7969
+ * parser rejects any callee not in it, and the evaluator gates each call on an
7970
+ * own-property check against it.
7971
+ *
7972
+ * Because the object has a NULL prototype AND is `Object.freeze`d:
7973
+ * - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
7974
+ * - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
7975
+ * (there is no `Object.prototype` in the chain), so those names are not
7976
+ * callable — they are simply "unknown function" at parse time.
7977
+ *
7978
+ * Every numeric argument is validated as a finite number and every numeric
7979
+ * RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
7980
+ * (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
7981
+ * closed rather than emitting a garbage value.
7982
+ */
7983
+ function asFiniteNumber(value, name, index) {
7984
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
7985
+ return value;
7986
+ }
7987
+ function asString$1(value, name, index) {
7988
+ if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
7989
+ return value;
7990
+ }
7991
+ function finiteResult(value, name) {
7992
+ if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
7993
+ return value;
7994
+ }
7995
+ function allFiniteNumbers(args, name) {
7996
+ return args.map((a, idx) => asFiniteNumber(a, name, idx));
7997
+ }
7998
+ var INF = Number.POSITIVE_INFINITY;
7999
+ var table = {
8000
+ min: {
8001
+ minArgs: 1,
8002
+ maxArgs: INF,
8003
+ apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
8004
+ },
8005
+ max: {
8006
+ minArgs: 1,
8007
+ maxArgs: INF,
8008
+ apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
8009
+ },
8010
+ abs: {
8011
+ minArgs: 1,
8012
+ maxArgs: 1,
8013
+ apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
8014
+ },
8015
+ floor: {
8016
+ minArgs: 1,
8017
+ maxArgs: 1,
8018
+ apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
8019
+ },
8020
+ ceil: {
8021
+ minArgs: 1,
8022
+ maxArgs: 1,
8023
+ apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
8024
+ },
8025
+ sqrt: {
8026
+ minArgs: 1,
8027
+ maxArgs: 1,
8028
+ apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
8029
+ },
8030
+ round: {
8031
+ minArgs: 1,
8032
+ maxArgs: 2,
8033
+ apply: (args) => {
8034
+ const x = asFiniteNumber(args[0], "round", 0);
8035
+ const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
8036
+ if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
8037
+ const factor = 10 ** digits;
8038
+ return finiteResult(Math.round(x * factor) / factor, "round");
8039
+ }
8040
+ },
8041
+ pow: {
8042
+ minArgs: 2,
8043
+ maxArgs: 2,
8044
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
8045
+ },
8046
+ clamp: {
8047
+ minArgs: 3,
8048
+ maxArgs: 3,
8049
+ apply: (args) => {
8050
+ const x = asFiniteNumber(args[0], "clamp", 0);
8051
+ const lo = asFiniteNumber(args[1], "clamp", 1);
8052
+ const hi = asFiniteNumber(args[2], "clamp", 2);
8053
+ if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
8054
+ return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
8055
+ }
8056
+ },
8057
+ avg: {
8058
+ minArgs: 1,
8059
+ maxArgs: INF,
8060
+ apply: (args) => {
8061
+ const nums = allFiniteNumbers(args, "avg");
8062
+ return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
8063
+ }
8064
+ },
8065
+ sum: {
8066
+ minArgs: 1,
8067
+ maxArgs: INF,
8068
+ apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
8069
+ },
8070
+ coalesce: {
8071
+ minArgs: 1,
8072
+ maxArgs: INF,
8073
+ apply: (args) => {
8074
+ for (const a of args) if (a !== null) return a;
8075
+ return null;
8076
+ }
8077
+ },
8078
+ age: {
8079
+ minArgs: 2,
8080
+ maxArgs: 2,
8081
+ apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
8082
+ },
8083
+ convert: {
8084
+ minArgs: 3,
8085
+ maxArgs: 3,
8086
+ apply: (args, hooks) => {
8087
+ const x = asFiniteNumber(args[0], "convert", 0);
8088
+ const from = asString$1(args[1], "convert", 1).trim();
8089
+ const to = asString$1(args[2], "convert", 2).trim();
8090
+ if (hooks.convert) {
8091
+ const out = hooks.convert(x, from, to);
8092
+ if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
8093
+ return finiteResult(out, "convert");
8094
+ }
8095
+ if (from === to) return x;
8096
+ throw new ExpressionEvalError("convert: unit conversion table not installed");
8097
+ }
8098
+ }
8099
+ };
8100
+ Object.freeze(Object.assign(Object.create(null), table));
8101
+ /** The set of valid builtin names — used by the parser to reject unknown
8102
+ * callees at parse time (immediate author feedback). */
8103
+ var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
8104
+ /**
8105
+ * Pratt (precedence-climbing) parser for the safe expression mini-language.
8106
+ *
8107
+ * Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
8108
+ * → relational → additive → multiplicative → unary `! -` → call / primary.
8109
+ * Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
8110
+ * string validated against the builtin table at parse time, so an unknown
8111
+ * function is rejected immediately (author feedback) and a persisted expression
8112
+ * that references a since-removed builtin degrades at read.
8113
+ *
8114
+ * A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
8115
+ * arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
8116
+ */
8117
+ /** Binary/logical operator precedence (higher binds tighter). */
8118
+ var BINARY_PRECEDENCE = {
8119
+ "||": 1,
8120
+ "&&": 2,
8121
+ "==": 3,
8122
+ "!=": 3,
8123
+ "<": 4,
8124
+ "<=": 4,
8125
+ ">": 4,
8126
+ ">=": 4,
8127
+ "+": 5,
8128
+ "-": 5,
8129
+ "*": 6,
8130
+ "/": 6,
8131
+ "%": 6
8132
+ };
8133
+ function isLogicalOp(op) {
8134
+ return op === "&&" || op === "||";
8135
+ }
8136
+ function isBinaryOp(op) {
8137
+ return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
8138
+ }
8139
+ var Parser = class {
8140
+ tokens;
8141
+ pos = 0;
8142
+ nodeCount = 0;
8143
+ identifiers = /* @__PURE__ */ new Set();
8144
+ callees = /* @__PURE__ */ new Set();
8145
+ constructor(tokens) {
8146
+ this.tokens = tokens;
8147
+ }
8148
+ parse() {
8149
+ const ast = this.parseTernary();
8150
+ const tok = this.peek();
8151
+ if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
8152
+ return {
8153
+ ast,
8154
+ identifiers: this.identifiers,
8155
+ callees: this.callees,
8156
+ nodeCount: this.nodeCount
8157
+ };
8158
+ }
8159
+ peek() {
8160
+ return this.tokens[this.pos];
8161
+ }
8162
+ next() {
8163
+ return this.tokens[this.pos++];
8164
+ }
8165
+ /** Consume a punctuator token, erroring if the next token isn't it. */
8166
+ expectPunct(punct) {
8167
+ const tok = this.peek();
8168
+ if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
8169
+ this.pos += 1;
8170
+ }
8171
+ matchPunct(punct) {
8172
+ const tok = this.peek();
8173
+ if (tok.type === "punct" && tok.punct === punct) {
8174
+ this.pos += 1;
8175
+ return true;
8176
+ }
8177
+ return false;
8178
+ }
8179
+ countNode() {
8180
+ this.nodeCount += 1;
8181
+ if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
8182
+ }
8183
+ parseTernary() {
8184
+ const test = this.parseBinary(1);
8185
+ if (this.matchPunct("?")) {
8186
+ const consequent = this.parseTernary();
8187
+ this.expectPunct(":");
8188
+ const alternate = this.parseTernary();
8189
+ this.countNode();
8190
+ return {
8191
+ kind: "conditional",
8192
+ test,
8193
+ consequent,
8194
+ alternate
8195
+ };
8196
+ }
8197
+ return test;
8198
+ }
8199
+ parseBinary(minPrec) {
8200
+ let left = this.parseUnary();
8201
+ for (;;) {
8202
+ const tok = this.peek();
8203
+ if (tok.type !== "punct") break;
8204
+ const prec = BINARY_PRECEDENCE[tok.punct];
8205
+ if (prec === void 0 || prec < minPrec) break;
8206
+ const op = tok.punct;
8207
+ this.pos += 1;
8208
+ const right = this.parseBinary(prec + 1);
8209
+ this.countNode();
8210
+ if (isLogicalOp(op)) left = {
8211
+ kind: "logical",
8212
+ op,
8213
+ left,
8214
+ right
8215
+ };
8216
+ else if (isBinaryOp(op)) left = {
8217
+ kind: "binary",
8218
+ op,
8219
+ left,
8220
+ right
8221
+ };
8222
+ else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
8223
+ }
8224
+ return left;
8225
+ }
8226
+ parseUnary() {
8227
+ const tok = this.peek();
8228
+ if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
8229
+ const op = tok.punct;
8230
+ this.pos += 1;
8231
+ const operand = this.parseUnary();
8232
+ this.countNode();
8233
+ return {
8234
+ kind: "unary",
8235
+ op,
8236
+ operand
8237
+ };
8238
+ }
8239
+ return this.parsePrimary();
8240
+ }
8241
+ parsePrimary() {
8242
+ const tok = this.next();
8243
+ switch (tok.type) {
8244
+ case "number":
8245
+ this.countNode();
8246
+ return {
8247
+ kind: "literal",
8248
+ value: tok.value
8249
+ };
8250
+ case "string":
8251
+ this.countNode();
8252
+ return {
8253
+ kind: "literal",
8254
+ value: tok.value
8255
+ };
8256
+ case "keyword":
8257
+ this.countNode();
8258
+ return {
8259
+ kind: "literal",
8260
+ value: tok.keyword === "null" ? null : tok.keyword === "true"
8261
+ };
8262
+ case "identifier": {
8263
+ const nextTok = this.peek();
8264
+ if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
8265
+ this.identifiers.add(tok.name);
8266
+ this.countNode();
8267
+ return {
8268
+ kind: "identifier",
8269
+ name: tok.name
8270
+ };
8271
+ }
8272
+ case "punct":
8273
+ if (tok.punct === "(") {
8274
+ const inner = this.parseTernary();
8275
+ this.expectPunct(")");
8276
+ return inner;
8277
+ }
8278
+ throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
8279
+ case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
8280
+ }
8281
+ }
8282
+ parseCall(callee, pos) {
8283
+ if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
8284
+ this.expectPunct("(");
8285
+ const args = [];
8286
+ if (!this.matchPunct(")")) for (;;) {
8287
+ args.push(this.parseTernary());
8288
+ if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
8289
+ if (this.matchPunct(",")) continue;
8290
+ this.expectPunct(")");
8291
+ break;
8292
+ }
8293
+ this.callees.add(callee);
8294
+ this.countNode();
8295
+ return {
8296
+ kind: "call",
8297
+ callee,
8298
+ args
8299
+ };
8300
+ }
8301
+ };
8302
+ /** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
8303
+ * `ExpressionParseError` on any lexical or grammatical failure. */
8304
+ function parseExpression(source) {
8305
+ return new Parser(tokenize(source)).parse();
8306
+ }
8307
+ Object.freeze({});
8308
+ /**
8309
+ * LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
8310
+ * by expr"). The cache stores BOTH successes and failures (negative caching),
8311
+ * so a corrupt persisted string costs exactly one tokenize+parse total — not
8312
+ * one per read on a hot resolve path.
8313
+ *
8314
+ * The cache is a module-level singleton: entries are pure, content-addressed
8315
+ * ASTs keyed by the raw source string, so sharing one instance across all
8316
+ * callers is safe and maximises hit rate.
8317
+ */
8318
+ var cache = /* @__PURE__ */ new Map();
8319
+ function getCached(source) {
8320
+ const hit = cache.get(source);
8321
+ if (hit !== void 0) {
8322
+ cache.delete(source);
8323
+ cache.set(source, hit);
8324
+ return hit;
8325
+ }
8326
+ let result;
8327
+ try {
8328
+ result = {
8329
+ ok: true,
8330
+ parsed: parseExpression(source)
8331
+ };
8332
+ } catch (err) {
8333
+ result = {
8334
+ ok: false,
8335
+ error: err instanceof ExpressionParseError ? err.message : String(err)
8336
+ };
8337
+ }
8338
+ cache.set(source, result);
8339
+ if (cache.size > 256) {
8340
+ const oldest = cache.keys().next().value;
8341
+ if (oldest !== void 0) cache.delete(oldest);
8342
+ }
8343
+ return result;
8344
+ }
8345
+ /** Compile `source`, returning a discriminated result instead of throwing.
8346
+ * Used by read paths that must degrade rather than raise. LRU/negative-cached. */
8347
+ function compileExpressionSafe(source) {
8348
+ return getCached(source);
8349
+ }
8350
+ /**
8351
+ * Author-time validation. Returns `null` when the source is valid, else a
8352
+ * human-readable error message. Checks: the expression compiles; binding count
8353
+ * is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
8354
+ * is not reserved (`now`/keywords) and does not shadow a builtin; and every
8355
+ * FREE identifier of the AST is covered by a binding or the injected `now`.
8356
+ */
8357
+ function validateExpressionSource(src) {
8358
+ const names = Object.keys(src.bindings);
8359
+ if (names.length > 32) return `too many bindings (${names.length} > 32)`;
8360
+ for (const name of names) {
8361
+ if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
8362
+ if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
8363
+ if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
8364
+ }
8365
+ const compiled = compileExpressionSafe(src.expr);
8366
+ if (!compiled.ok) return compiled.error;
8367
+ const bound = new Set(names);
8368
+ for (const id of compiled.parsed.identifiers) {
8369
+ if (id === "now") continue;
8370
+ if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
8371
+ }
8372
+ return null;
8373
+ }
8374
+ /**
7596
8375
  * Accessory device helpers — shared across drivers.
7597
8376
  *
7598
8377
  * Many vendor-specific drivers register accessory child devices on
@@ -8476,7 +9255,13 @@ onStatusChanged: { data: object({
8476
9255
  }) } },
8477
9256
  status: {
8478
9257
  schema: BatteryStatusSchema,
8479
- kind: "push"
9258
+ kind: "push",
9259
+ empty: {
9260
+ percentage: 0,
9261
+ charging: "none",
9262
+ sleeping: false,
9263
+ lastUpdated: 0
9264
+ }
8480
9265
  },
8481
9266
  /**
8482
9267
  * Runtime-state slice — every provider that registers this cap
@@ -8615,6 +9400,10 @@ var RtspRestreamEntrySchema = object({
8615
9400
  var BrokerRtspClientSchema = object({
8616
9401
  sessionId: string(),
8617
9402
  remoteAddr: string(),
9403
+ /** Client `User-Agent` (e.g. `recorder` for the recorder's RTSP pull), or
9404
+ * null/absent when the client sent none. Lets the UI label a consumer by
9405
+ * purpose. Optional so a client built against an older schema stays valid. */
9406
+ userAgent: string().nullish(),
8618
9407
  playing: boolean(),
8619
9408
  muted: boolean(),
8620
9409
  connectedAt: number(),
@@ -9415,21 +10204,38 @@ var connectivityCapability = {
9415
10204
  },
9416
10205
  runtimeState: ConnectivityStatusSchema
9417
10206
  };
10207
+ /**
10208
+ * Generic device-consumables capability — surfaces a device's
10209
+ * maintenance items (vacuum filters/brushes, replaceable cartridges,
10210
+ * descaling cycles, …) with their remaining life and an optional
10211
+ * "Replaced" reset action. Device-agnostic: any provider that knows its
10212
+ * device tracks consumables can register it; the cap declares no
10213
+ * vocabulary of its own — the provider names each item verbatim.
10214
+ *
10215
+ * Like `childLayout`, the cap is INERT until a provider sets items: no
10216
+ * provider populates it by guessing (no HA inference). The UI renders a
10217
+ * "No consumables reported" placeholder when `items` is empty.
10218
+ */
10219
+ /** A single consumable item. Either a continuous `level` (remaining
10220
+ * life %) or a discrete `status` may be known — both may be null when a
10221
+ * provider only knows the item exists. `level` and `status` are not
10222
+ * mutually exclusive; a provider may report both. */
10223
+ var ConsumableItemSchema = object({
10224
+ /** Stable id, e.g. 'main-brush'. */
10225
+ key: string().min(1),
10226
+ /** Display name. */
10227
+ label: string().min(1),
10228
+ /** Remaining life % when known (0..100). */
10229
+ level: number().min(0).max(100).nullable(),
10230
+ /** Discrete state when known (binary mode). */
10231
+ status: _enum(["ok", "replace"]).nullable(),
10232
+ /** Ms epoch of the last replace, when known. */
10233
+ lastResetAt: number().nullable(),
10234
+ /** Whether `reset()` is meaningful for this item. */
10235
+ resettable: boolean()
10236
+ });
9418
10237
  var ConsumablesStatusSchema = object({
9419
- items: array(object({
9420
- /** Stable id, e.g. 'main-brush'. */
9421
- key: string().min(1),
9422
- /** Display name. */
9423
- label: string().min(1),
9424
- /** Remaining life % when known (0..100). */
9425
- level: number().min(0).max(100).nullable(),
9426
- /** Discrete state when known (binary mode). */
9427
- status: _enum(["ok", "replace"]).nullable(),
9428
- /** Ms epoch of the last replace, when known. */
9429
- lastResetAt: number().nullable(),
9430
- /** Whether `reset()` is meaningful for this item. */
9431
- resettable: boolean()
9432
- })),
10238
+ items: array(ConsumableItemSchema),
9433
10239
  lastChangedAt: number()
9434
10240
  });
9435
10241
  var consumablesCapability = {
@@ -9488,7 +10294,25 @@ reset: method(object({
9488
10294
  }) },
9489
10295
  status: {
9490
10296
  schema: ConsumablesStatusSchema,
9491
- kind: "push"
10297
+ kind: "push",
10298
+ empty: {
10299
+ items: [],
10300
+ lastChangedAt: 0
10301
+ },
10302
+ itemArray: {
10303
+ path: "items",
10304
+ keyField: "key",
10305
+ labelField: "label",
10306
+ itemSchema: ConsumableItemSchema,
10307
+ emptyItem: {
10308
+ key: "",
10309
+ label: "",
10310
+ level: null,
10311
+ status: null,
10312
+ lastResetAt: null,
10313
+ resettable: false
10314
+ }
10315
+ }
9492
10316
  },
9493
10317
  runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() })
9494
10318
  };
@@ -10730,7 +11554,8 @@ var MotionAnalysisResultSchema = object({
10730
11554
  });
10731
11555
  method(object({
10732
11556
  deviceId: number(),
10733
- frame: FrameInputSchema
11557
+ frame: FrameInputSchema.optional(),
11558
+ frameHandle: FrameHandleSchema.optional()
10734
11559
  }), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
10735
11560
  deviceId: number(),
10736
11561
  detected: boolean(),
@@ -10977,6 +11802,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
10977
11802
  engine: PipelineEngineChoiceSchema.optional(),
10978
11803
  steps: array(PipelineStepInputSchema).min(1),
10979
11804
  frame: FrameInputSchema.optional(),
11805
+ /**
11806
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
11807
+ * the decoded pixels live in. One more member of the one-of
11808
+ * frame/frameHandle/image/imageBase64/referenceImage group.
11809
+ */
11810
+ frameHandle: FrameHandleSchema.optional(),
10980
11811
  imageBase64: string().optional(),
10981
11812
  /**
10982
11813
  * Binary JPEG bytes — preferred over `imageBase64` on internal
@@ -11219,6 +12050,31 @@ var ReportMotionInputSchema = object({
11219
12050
  regions: array(MotionRegionSchema).readonly().optional()
11220
12051
  });
11221
12052
  /**
12053
+ * Where a runner gets a camera's decoded frames (cross-node Phase 2,
12054
+ * restream-owner model — P2c).
12055
+ *
12056
+ * - `local-broker` (DEFAULT): today's path — subscribe to the co-located
12057
+ * stream-broker's shm frame plane. Every pre-P2c attach payload (no
12058
+ * `frameSource` key) parses to this, so the field is additive with zero
12059
+ * behavior change.
12060
+ * - `remote-restream`: the detect node is NOT the camera's source-owner.
12061
+ * The runner acquires the owner's COMPRESSED passthrough restream
12062
+ * (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
12063
+ * double-pull guard) and decodes LOCALLY via a satellite frame plane +
12064
+ * pull-mode decoder session pinned to its own node. The shm ring stays
12065
+ * node-local; only H.264/H.265 packets cross the wire.
12066
+ * `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
12067
+ * when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
12068
+ * dials for the owner's restream.
12069
+ */
12070
+ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
12071
+ kind: literal("remote-restream"),
12072
+ /** The camera's source-owner node (slice 1: always the hub). */
12073
+ ownerNodeId: string(),
12074
+ /** Operator override for the owner host the runner dials. */
12075
+ hubHostnameOverride: string().optional()
12076
+ })]).describe("Per-camera frame-source mode for the runner (P2c)");
12077
+ /**
11222
12078
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
11223
12079
  * specific runner instance via `attachCamera`. Carries everything the
11224
12080
  * runner needs to subscribe to the local broker and execute inference.
@@ -11316,7 +12172,15 @@ var RunnerCameraConfigSchema = object({
11316
12172
  */
11317
12173
  onboardMotionDrivesAnalyzer: boolean().default(true),
11318
12174
  occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
11319
- occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
12175
+ occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
12176
+ /**
12177
+ * Where this runner gets the camera's decoded frames (P2c). Defaulted so
12178
+ * every existing payload behaves as `local-broker` — the pre-Phase-2 path.
12179
+ * Populated with `remote-restream` by the orchestrator ONLY when the
12180
+ * camera's detect node differs from its source-owner (P2d, gated by the
12181
+ * `remoteSourcingNodes` rollout setting).
12182
+ */
12183
+ frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
11320
12184
  });
11321
12185
  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;
11322
12186
  /**
@@ -11880,6 +12744,157 @@ var numericSensorCapability = {
11880
12744
  runtimeState: NumericSensorStatusSchema
11881
12745
  };
11882
12746
  /**
12747
+ * Feeder connectivity / power status — mirrors the HA petkit device-status
12748
+ * enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
12749
+ * `on_batteries` (running on battery backup). `null` until first reported.
12750
+ */
12751
+ var PetFeederDeviceStatusSchema = _enum([
12752
+ "normal",
12753
+ "offline",
12754
+ "on_batteries"
12755
+ ]);
12756
+ var gramsPortion = number().int().min(4).max(200);
12757
+ var PetFeederStatusSchema = object({
12758
+ /** Food currently in the bowl (grams). Null when the device has not
12759
+ * reported a reading yet. On dual-hopper models this is the combined
12760
+ * bowl reading; per-hopper levels live in `food1`/`food2`. */
12761
+ foodLevel: number().nullable(),
12762
+ /** Hopper-1 food level (grams) on dual-hopper feeders; null on
12763
+ * single-hopper models. */
12764
+ food1: number().nullable(),
12765
+ /** Hopper-2 food level (grams) on dual-hopper feeders; null on
12766
+ * single-hopper models. */
12767
+ food2: number().nullable(),
12768
+ /** Derived low-food flag — mirrors the HA `food_level` binary_sensor
12769
+ * (`device_class: problem`, on = low). True when the bowl is empty /
12770
+ * below the feeder's low threshold. */
12771
+ lowFood: boolean(),
12772
+ /** Battery charge 0..100 (%). Null on mains-powered models or when the
12773
+ * device has no battery reading. */
12774
+ batteryPower: number().min(0).max(100).nullable(),
12775
+ /** Days of desiccant life remaining. Null when the model has no
12776
+ * desiccant sensor. */
12777
+ desiccantLeftDays: number().nullable(),
12778
+ /** True while a feed is in progress. */
12779
+ feeding: boolean(),
12780
+ /** Decoded connectivity / power status (HA petkit device-status enum).
12781
+ * Null until the device has reported a status. */
12782
+ status: PetFeederDeviceStatusSchema.nullable(),
12783
+ /** Decoded human-readable fault message. Null (or the device's `no_error`
12784
+ * sentinel) means healthy; a non-null string is an active fault. Pairs
12785
+ * with `errorCode` for consumers that want the raw integer. */
12786
+ error: string().nullable(),
12787
+ /** Raw device error code (0 / null = no error). */
12788
+ errorCode: number().nullable(),
12789
+ /** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
12790
+ isDualHopper: boolean(),
12791
+ /** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
12792
+ childLock: boolean(),
12793
+ /** Front indicator-light setting. */
12794
+ indicatorLight: boolean(),
12795
+ /** Play a chime when dispensing. */
12796
+ feedSound: boolean(),
12797
+ /** Speaker / prompt volume level (device-scaled integer). */
12798
+ volume: number(),
12799
+ /** Ms epoch when the slice was last refreshed from the cloud. */
12800
+ lastFetchedAt: number()
12801
+ });
12802
+ var petFeederCapability = {
12803
+ name: "pet-feeder",
12804
+ scope: "device",
12805
+ deviceNative: true,
12806
+ mode: "singleton",
12807
+ deviceTypes: [DeviceType.PetFeeder],
12808
+ methods: {
12809
+ /**
12810
+ * Dispense food now. Single-hopper feeders take `grams`; dual-hopper
12811
+ * feeders (D4S/D4SH) accept `hopper1`/`hopper2` to target one or both
12812
+ * hoppers. All portions honour the 4–200 g hardware range. At least
12813
+ * one of the three must be present — the provider rejects an empty
12814
+ * request.
12815
+ */
12816
+ feed: method(object({
12817
+ deviceId: number().int().nonnegative(),
12818
+ grams: gramsPortion.optional(),
12819
+ hopper1: gramsPortion.optional(),
12820
+ hopper2: gramsPortion.optional()
12821
+ }), _void(), {
12822
+ kind: "mutation",
12823
+ auth: "admin"
12824
+ }),
12825
+ /** Cancel an in-progress manual feed. */
12826
+ cancelFeed: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12827
+ kind: "mutation",
12828
+ auth: "admin"
12829
+ }),
12830
+ /** Reset the desiccant "days remaining" counter after replacing it. */
12831
+ resetDesiccant: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12832
+ kind: "mutation",
12833
+ auth: "admin"
12834
+ }),
12835
+ /** Mark a hopper as refilled (D4H/D4S/D4SH). */
12836
+ markFoodReplenished: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12837
+ kind: "mutation",
12838
+ auth: "admin"
12839
+ }),
12840
+ /** Call the pet with the recorded prompt (D3). */
12841
+ callPet: method(object({ deviceId: number().int().nonnegative() }), _void(), {
12842
+ kind: "mutation",
12843
+ auth: "admin"
12844
+ }),
12845
+ /** Play a stored sound by id (D3 / D4H / D4SH). */
12846
+ playSound: method(object({
12847
+ deviceId: number().int().nonnegative(),
12848
+ soundId: number().int().nonnegative()
12849
+ }), _void(), {
12850
+ kind: "mutation",
12851
+ auth: "admin"
12852
+ }),
12853
+ /** Toggle the child-lock (manual-lock) setting. */
12854
+ setChildLock: method(object({
12855
+ deviceId: number().int().nonnegative(),
12856
+ on: boolean()
12857
+ }), _void(), {
12858
+ kind: "mutation",
12859
+ auth: "admin"
12860
+ }),
12861
+ /** Toggle the front indicator light. */
12862
+ setIndicatorLight: method(object({
12863
+ deviceId: number().int().nonnegative(),
12864
+ on: boolean()
12865
+ }), _void(), {
12866
+ kind: "mutation",
12867
+ auth: "admin"
12868
+ }),
12869
+ /** Toggle the dispense chime. */
12870
+ setFeedSound: method(object({
12871
+ deviceId: number().int().nonnegative(),
12872
+ on: boolean()
12873
+ }), _void(), {
12874
+ kind: "mutation",
12875
+ auth: "admin"
12876
+ }),
12877
+ /** Set the speaker / prompt volume level. */
12878
+ setVolume: method(object({
12879
+ deviceId: number().int().nonnegative(),
12880
+ level: number().int().nonnegative()
12881
+ }), _void(), {
12882
+ kind: "mutation",
12883
+ auth: "admin"
12884
+ })
12885
+ },
12886
+ status: {
12887
+ schema: PetFeederStatusSchema,
12888
+ kind: "poll"
12889
+ },
12890
+ /**
12891
+ * Runtime-state slice — mirrored by the kernel. UI feeder cards read
12892
+ * the full slice via `device.state.petFeeder.value` and refresh on
12893
+ * every poll without re-querying the provider.
12894
+ */
12895
+ runtimeState: PetFeederStatusSchema
12896
+ };
12897
+ /**
11883
12898
  * Multi-metric electrical meter. One slice can carry any combination
11884
12899
  * of instantaneous power (W), cumulative energy (kWh), voltage (V),
11885
12900
  * and current (A) — all fields optional so a single-metric source
@@ -13182,6 +14197,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
13182
14197
  nativeObjectDetection: nativeObjectDetectionCapability,
13183
14198
  notifier: notifierCapability,
13184
14199
  numericSensor: numericSensorCapability,
14200
+ petFeeder: petFeederCapability,
13185
14201
  powerMeter: powerMeterCapability,
13186
14202
  presence: presenceCapability,
13187
14203
  pressureSensor: pressureSensorCapability,
@@ -15110,10 +16126,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
15110
16126
  url: string()
15111
16127
  }), _void()), method(object({
15112
16128
  sessionId: string(),
15113
- maxCount: number().default(1)
16129
+ maxCount: number().default(1),
16130
+ waitMs: number().optional()
15114
16131
  }), array(DecodedFrameSchema)), method(object({
15115
16132
  sessionId: string(),
15116
- maxCount: number().default(1)
16133
+ maxCount: number().default(1),
16134
+ waitMs: number().optional()
15117
16135
  }), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
15118
16136
  sessionId: string(),
15119
16137
  config: DecoderSessionConfigSchema.partial()
@@ -15400,14 +16418,63 @@ var ChildLayoutEntrySchema = object({
15400
16418
  collapsed: boolean().optional()
15401
16419
  });
15402
16420
  /** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
15403
- * `device-management.ts`. */
16421
+ * `device-management.ts`. Source is a union: a FIELD source copies a sibling
16422
+ * accessory's status field (`kind` optional/absent for wire compat); a
16423
+ * LITERAL source carries a per-device constant (no sibling is read); a
16424
+ * GLOBAL source (P2e) copies ANY device's status field, addressed by the
16425
+ * source device's full re-sync-stable `stableId`. */
16426
+ var DeviceLinkFieldSourceSchema = object({
16427
+ kind: literal("field").optional(),
16428
+ sourceKey: string(),
16429
+ cap: string(),
16430
+ fieldPath: string()
16431
+ });
16432
+ var DeviceLinkLiteralSourceSchema = object({
16433
+ kind: literal("literal"),
16434
+ value: union([
16435
+ string(),
16436
+ number(),
16437
+ boolean(),
16438
+ _null()
16439
+ ])
16440
+ });
16441
+ var DeviceLinkGlobalSourceSchema = object({
16442
+ kind: literal("global"),
16443
+ sourceStableId: string(),
16444
+ cap: string(),
16445
+ fieldPath: string()
16446
+ });
16447
+ /** Expression source (Stage X): compute the target field from N named bindings
16448
+ * via the safe expression engine. Bindings are field | literal | global — never
16449
+ * another expression (no nesting). The `superRefine` runs the SAME author-time
16450
+ * validation as `validateExpressionSource` (compiles the expr, checks binding
16451
+ * names + identifier coverage) so every wire boundary that parses a DeviceLink
16452
+ * (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
16453
+ * Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
16454
+ var DeviceLinkExpressionSourceSchema = object({
16455
+ kind: literal("expression"),
16456
+ expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
16457
+ bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
16458
+ DeviceLinkFieldSourceSchema,
16459
+ DeviceLinkLiteralSourceSchema,
16460
+ DeviceLinkGlobalSourceSchema
16461
+ ]))
16462
+ }).superRefine((src, ctx) => {
16463
+ const err = validateExpressionSource(src);
16464
+ if (err !== null) ctx.addIssue({
16465
+ code: "custom",
16466
+ message: err,
16467
+ path: ["expr"]
16468
+ });
16469
+ });
15404
16470
  var DeviceLinkSchema = object({
15405
16471
  id: string(),
15406
- source: object({
15407
- sourceKey: string(),
15408
- cap: string(),
15409
- fieldPath: string()
15410
- }),
16472
+ source: union([
16473
+ DeviceLinkFieldSourceSchema,
16474
+ DeviceLinkLiteralSourceSchema,
16475
+ DeviceLinkGlobalSourceSchema,
16476
+ DeviceLinkExpressionSourceSchema
16477
+ ]),
15411
16478
  target: object({
15412
16479
  cap: string(),
15413
16480
  fieldPath: string(),
@@ -15436,6 +16503,31 @@ var DeviceLinkSchema = object({
15436
16503
  })
15437
16504
  ]).optional()
15438
16505
  });
16506
+ /** Cap-wire shape of a per-cap display refinement — mirrors
16507
+ * `DeviceCapDisplayOverride` in `device-management.ts`. */
16508
+ var DeviceCapDisplayOverrideSchema = object({
16509
+ unit: string().min(1).optional(),
16510
+ precision: number().int().min(0).max(10).optional()
16511
+ });
16512
+ /** Cap-wire shape of an operator-authored per-device display override —
16513
+ * mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
16514
+ * bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
16515
+ var DeviceDisplayOverrideSchema = object({
16516
+ icon: string().min(1).optional(),
16517
+ label: string().min(1).optional(),
16518
+ unit: string().min(1).optional(),
16519
+ precision: number().int().min(0).max(10).optional(),
16520
+ hidden: boolean().optional(),
16521
+ perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
16522
+ });
16523
+ /** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
16524
+ * in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
16525
+ * the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
16526
+ var RoleDisplayDefaultSchema = object({
16527
+ unit: string().min(1).optional(),
16528
+ precision: number().int().min(0).max(10).optional(),
16529
+ icon: string().min(1).optional()
16530
+ });
15439
16531
  /**
15440
16532
  * Serializable projection of a live IDevice.
15441
16533
  * Returned by listAll, getDevice, getChildren.
@@ -15491,7 +16583,9 @@ var DeviceInfoSchema = object({
15491
16583
  * `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
15492
16584
  childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
15493
16585
  /** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
15494
- deviceLinks: array(DeviceLinkSchema).readonly().optional()
16586
+ deviceLinks: array(DeviceLinkSchema).readonly().optional(),
16587
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
16588
+ display: DeviceDisplayOverrideSchema.optional()
15495
16589
  });
15496
16590
  var ConfigEntrySchema = object({
15497
16591
  key: string(),
@@ -15556,7 +16650,9 @@ var DeviceMetaSchema = object({
15556
16650
  deviceLinks: array(DeviceLinkSchema).readonly().optional(),
15557
16651
  /** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
15558
16652
  * Optional: only present for accessory children that carry a known role. */
15559
- role: string().nullable().optional()
16653
+ role: string().nullable().optional(),
16654
+ /** Operator-authored per-device display override. See `DeviceMeta.display`. */
16655
+ display: DeviceDisplayOverrideSchema.optional()
15560
16656
  });
15561
16657
  /** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
15562
16658
  var ConfigUISchemaOutput = unknown().nullable();
@@ -15650,7 +16746,19 @@ method(object({
15650
16746
  }), _void(), {
15651
16747
  kind: "mutation",
15652
16748
  auth: "admin"
15653
- }), method(object({ deviceId: number() }), object({ caps: array(object({
16749
+ }), method(object({
16750
+ deviceId: number(),
16751
+ display: DeviceDisplayOverrideSchema.nullable()
16752
+ }), _void(), {
16753
+ kind: "mutation",
16754
+ auth: "admin"
16755
+ }), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
16756
+ kind: "mutation",
16757
+ auth: "admin"
16758
+ }), method(object({
16759
+ deviceId: number(),
16760
+ includeSynthesizable: boolean().optional()
16761
+ }), object({ caps: array(object({
15654
16762
  cap: string(),
15655
16763
  fields: array(object({
15656
16764
  path: string(),
@@ -15660,8 +16768,13 @@ method(object({
15660
16768
  "boolean",
15661
16769
  "enum"
15662
16770
  ]),
15663
- enumValues: array(string()).optional()
15664
- })).readonly()
16771
+ enumValues: array(string()).optional(),
16772
+ item: boolean().optional()
16773
+ })).readonly(),
16774
+ itemArray: object({
16775
+ path: string(),
16776
+ keyField: string()
16777
+ }).optional()
15665
16778
  })).readonly() }), { kind: "query" }), method(object({
15666
16779
  deviceId: number(),
15667
16780
  role: string().nullable()
@@ -15731,7 +16844,11 @@ method(object({
15731
16844
  deviceId: number(),
15732
16845
  entries: array(object({
15733
16846
  capName: string(),
15734
- kind: _enum(["native", "wrapped"]),
16847
+ kind: _enum([
16848
+ "native",
16849
+ "wrapped",
16850
+ "linked"
16851
+ ]),
15735
16852
  providerAddonId: string(),
15736
16853
  providerNodeId: string(),
15737
16854
  nativeAddonId: string()
@@ -15740,7 +16857,11 @@ method(object({
15740
16857
  deviceId: number(),
15741
16858
  entries: array(object({
15742
16859
  capName: string(),
15743
- kind: _enum(["native", "wrapped"]),
16860
+ kind: _enum([
16861
+ "native",
16862
+ "wrapped",
16863
+ "linked"
16864
+ ]),
15744
16865
  providerAddonId: string(),
15745
16866
  providerNodeId: string(),
15746
16867
  nativeAddonId: string()
@@ -16230,7 +17351,7 @@ var AddBrokerInputSchema = object({
16230
17351
  });
16231
17352
  var AddBrokerResultSchema = object({ id: string() });
16232
17353
  var IdInputSchema = object({ id: string() });
16233
- var TestResultSchema = discriminatedUnion("ok", [object({
17354
+ var TestResultSchema$1 = discriminatedUnion("ok", [object({
16234
17355
  ok: literal(true),
16235
17356
  latencyMs: number()
16236
17357
  }), object({
@@ -16253,7 +17374,7 @@ var StatusSchema = object({
16253
17374
  brokerCount: number(),
16254
17375
  embeddedRunning: boolean()
16255
17376
  });
16256
- 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);
17377
+ 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);
16257
17378
  var NetworkEndpointSchema = object({
16258
17379
  url: string(),
16259
17380
  hostname: string(),
@@ -16287,23 +17408,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
16287
17408
  sourcePort: number().optional()
16288
17409
  });
16289
17410
  method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
16290
- method(object({
16291
- title: string(),
17411
+ /**
17412
+ * notification-output — canonical, capability-gated notification delivery.
17413
+ *
17414
+ * Apprise-derived model (see
17415
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
17416
+ * callers emit ONE canonical `Notification`; each provider declares a
17417
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
17418
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
17419
+ * message to what the kind supports — callers never special-case a service.
17420
+ *
17421
+ * DESIGN DECISIONS (locked):
17422
+ * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
17423
+ * `setTargetEnabled`), each provider persisting via the `settings-store`
17424
+ * cap. Rationale: the admin UI needs one uniform surface across the
17425
+ * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
17426
+ * alternative would fork the UI per addon and cannot host the
17427
+ * discovery→adopt flow.
17428
+ * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
17429
+ * the generated cap-mount auto-`concatCollection`-fans them across every
17430
+ * registered provider (notifiers addon + HA addon) so one catalog is
17431
+ * routable. `send` / `testTarget` / CRUD route to ONE provider by the
17432
+ * `addonId` the generated collection router extracts from the call input.
17433
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
17434
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
17435
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
17436
+ * base64 fallback needed.
17437
+ *
17438
+ * TODO (deferred, closed-set change — separate decision): add
17439
+ * `providerKind: 'notify'` so notification providers surface on the unified
17440
+ * admin "Integrations" page.
17441
+ */
17442
+ /**
17443
+ * Zentik-derived typed-media enum — the superset across every kind. Each
17444
+ * adapter picks what it supports and the degrade engine filters the rest.
17445
+ */
17446
+ var AttachmentMediaTypeSchema = _enum([
17447
+ "image",
17448
+ "video",
17449
+ "gif",
17450
+ "audio",
17451
+ "icon"
17452
+ ]);
17453
+ /**
17454
+ * A single attachment. Exactly one of `url` (remote source, most adapters
17455
+ * prefer this) or `bytes` (inline source; required for Pushover-style
17456
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
17457
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
17458
+ */
17459
+ var AttachmentSchema = object({
17460
+ mediaType: AttachmentMediaTypeSchema,
17461
+ url: string().optional(),
17462
+ bytes: _instanceof(Uint8Array).optional(),
17463
+ mime: string().optional(),
17464
+ name: string().optional()
17465
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
17466
+ var NotificationFormatSchema = _enum([
17467
+ "text",
17468
+ "markdown",
17469
+ "html"
17470
+ ]);
17471
+ /** A single tap-through action button. */
17472
+ var NotificationActionSchema = object({
17473
+ id: string(),
17474
+ label: string(),
17475
+ url: string().optional()
17476
+ });
17477
+ /**
17478
+ * The canonical notification. `body` is the only hard field (Apprise model).
17479
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
17480
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
17481
+ * the adapter maps this ordinal onto its native level. `level?` is an
17482
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
17483
+ * `priority` for that one target.
17484
+ */
17485
+ var NotificationSchema = object({
16292
17486
  body: string(),
16293
- imageUrl: string().optional(),
17487
+ title: string().optional(),
17488
+ format: NotificationFormatSchema.default("text"),
17489
+ priority: number().int().min(1).max(5).default(3),
17490
+ level: string().optional(),
17491
+ attachments: array(AttachmentSchema).optional(),
17492
+ clickUrl: string().optional(),
17493
+ actions: array(NotificationActionSchema).optional(),
17494
+ sound: string().optional(),
17495
+ ttl: number().optional(),
17496
+ tag: string().optional(),
16294
17497
  deviceId: number().optional(),
16295
17498
  eventId: string().optional(),
16296
- priority: _enum([
16297
- "low",
16298
- "normal",
16299
- "high",
16300
- "critical"
16301
- ]).default("normal"),
16302
17499
  metadata: record(string(), unknown()).optional()
16303
- }), _void(), { kind: "mutation" }), method(_void(), object({
17500
+ });
17501
+ /** One declared native severity/priority level for a kind. */
17502
+ var TargetKindLevelSchema = object({
17503
+ id: string(),
17504
+ label: string(),
17505
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
17506
+ ordinal: number().int().min(1).max(5).nullable(),
17507
+ flags: object({
17508
+ critical: boolean().optional(),
17509
+ silent: boolean().optional(),
17510
+ noPush: boolean().optional()
17511
+ }).optional(),
17512
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
17513
+ requires: array(string()).optional(),
17514
+ description: string().optional()
17515
+ });
17516
+ /** The full capability block consulted before dispatch. */
17517
+ var TargetKindCapsSchema = object({
17518
+ attachments: object({
17519
+ mediaTypes: array(AttachmentMediaTypeSchema),
17520
+ mode: _enum([
17521
+ "url",
17522
+ "bytes",
17523
+ "both"
17524
+ ]),
17525
+ max: number().int().nonnegative(),
17526
+ maxBytes: number().int().positive().optional()
17527
+ }),
17528
+ /** Max action buttons (0 = none). */
17529
+ actions: number().int().nonnegative(),
17530
+ levels: array(TargetKindLevelSchema),
17531
+ format: array(NotificationFormatSchema),
17532
+ clickUrl: boolean(),
17533
+ sound: boolean(),
17534
+ ttl: boolean(),
17535
+ bodyMaxLen: number().int().positive()
17536
+ });
17537
+ /**
17538
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
17539
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
17540
+ * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
17541
+ * the union is large and not meant for runtime validation here; the exported
17542
+ * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
17543
+ */
17544
+ var ConfigSchemaPassthrough = unknown();
17545
+ var TargetKindSchema = object({
17546
+ kind: string(),
17547
+ label: string(),
17548
+ icon: string(),
17549
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
17550
+ addonId: string(),
17551
+ configSchema: ConfigSchemaPassthrough,
17552
+ supportsDiscovery: boolean(),
17553
+ caps: TargetKindCapsSchema
17554
+ });
17555
+ /**
17556
+ * A persisted target. `config` holds secrets; providers REDACT secret fields
17557
+ * (return a presence marker only) when serving `listTargets` — never
17558
+ * round-trip a stored secret to the UI.
17559
+ */
17560
+ var TargetSchema = object({
17561
+ id: string(),
17562
+ name: string(),
17563
+ kind: string(),
17564
+ addonId: string(),
17565
+ enabled: boolean(),
17566
+ config: record(string(), unknown())
17567
+ });
17568
+ /** A discovery-surfaced candidate (config is partial + non-secret). */
17569
+ var DiscoveredTargetSchema = object({
17570
+ kind: string(),
17571
+ suggestedName: string(),
17572
+ config: record(string(), unknown())
17573
+ });
17574
+ /** The degrade engine's report — what was resolved / dropped / degraded. */
17575
+ var RenderedAsSchema = object({
17576
+ level: string(),
17577
+ format: NotificationFormatSchema,
17578
+ attachmentsSent: number().int().nonnegative(),
17579
+ actionsSent: number().int().nonnegative(),
17580
+ truncated: boolean(),
17581
+ dropped: array(string())
17582
+ });
17583
+ var SendResultSchema = object({
16304
17584
  success: boolean(),
16305
- error: string().optional()
16306
- }), { kind: "mutation" });
17585
+ error: string().optional(),
17586
+ renderedAs: RenderedAsSchema.optional()
17587
+ });
17588
+ /** Same shape as SendResult — kept as a distinct name for the test panel. */
17589
+ var TestResultSchema = SendResultSchema;
17590
+ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
17591
+ kind: string(),
17592
+ config: record(string(), unknown()).optional()
17593
+ }), array(DiscoveredTargetSchema)), method(object({
17594
+ targetId: string(),
17595
+ notification: NotificationSchema
17596
+ }), SendResultSchema, { kind: "mutation" }), method(object({
17597
+ targetId: string(),
17598
+ sample: NotificationSchema.optional()
17599
+ }), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
17600
+ targetId: string(),
17601
+ enabled: boolean()
17602
+ }), _void(), { kind: "mutation" });
16307
17603
  /**
16308
17604
  * Zod schemas for persisted record types.
16309
17605
  *
@@ -19465,7 +20761,10 @@ var HwAccelBackendInputSchema = _enum([
19465
20761
  "webgpu",
19466
20762
  "none"
19467
20763
  ]).nullable().optional();
19468
- var HwAccelResolutionSchema = object({ preferred: array(string()).readonly() });
20764
+ var HwAccelResolutionSchema = object({
20765
+ preferred: array(string()).readonly(),
20766
+ rationale: string()
20767
+ });
19469
20768
  var HardwareEncoderIdSchema = _enum([
19470
20769
  "h264_videotoolbox",
19471
20770
  "hevc_videotoolbox",
@@ -19570,10 +20869,7 @@ var ResolvedInferenceConfigSchema = object({
19570
20869
  format: ModelFormatSchema,
19571
20870
  reason: string()
19572
20871
  });
19573
- method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
19574
- prefer: HwAccelBackendInputSchema,
19575
- nodeId: string().optional()
19576
- }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
20872
+ method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
19577
20873
  kind: "mutation",
19578
20874
  auth: "admin"
19579
20875
  }), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
@@ -19699,6 +20995,16 @@ var rebootCapability = {
19699
20995
  auth: "admin"
19700
20996
  }) }
19701
20997
  };
20998
+ /**
20999
+ * `recording` cap — footage availability + HLS playback manifests + per-device
21000
+ * recording config. NOTE on events (source of truth, R5/C3): this cap carries
21001
+ * NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
21002
+ * events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
21003
+ * rows); the recorder's internal EventMap markers are ephemeral in-RAM
21004
+ * annotations that are not exposed here and must not be treated as an event
21005
+ * feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
21006
+ * (`interfaces/recording-config.ts`).
21007
+ */
19702
21008
  var RecordingStatusSchema = object({
19703
21009
  deviceId: number(),
19704
21010
  enabled: boolean(),
@@ -21546,6 +22852,12 @@ Object.freeze({
21546
22852
  addonId: null,
21547
22853
  access: "view"
21548
22854
  },
22855
+ "deviceManager.getRoleDisplayDefaults": {
22856
+ capName: "device-manager",
22857
+ capScope: "system",
22858
+ addonId: null,
22859
+ access: "view"
22860
+ },
21549
22861
  "deviceManager.getSettingsSchema": {
21550
22862
  capName: "device-manager",
21551
22863
  capScope: "system",
@@ -21696,6 +23008,12 @@ Object.freeze({
21696
23008
  addonId: null,
21697
23009
  access: "create"
21698
23010
  },
23011
+ "deviceManager.setDisplay": {
23012
+ capName: "device-manager",
23013
+ capScope: "system",
23014
+ addonId: null,
23015
+ access: "create"
23016
+ },
21699
23017
  "deviceManager.setIntegrationId": {
21700
23018
  capName: "device-manager",
21701
23019
  capScope: "system",
@@ -21738,6 +23056,12 @@ Object.freeze({
21738
23056
  addonId: null,
21739
23057
  access: "create"
21740
23058
  },
23059
+ "deviceManager.setRoleDisplayDefaults": {
23060
+ capName: "device-manager",
23061
+ capScope: "system",
23062
+ addonId: null,
23063
+ access: "create"
23064
+ },
21741
23065
  "deviceManager.setStreamProfileMap": {
21742
23066
  capName: "device-manager",
21743
23067
  capScope: "system",
@@ -22716,13 +24040,49 @@ Object.freeze({
22716
24040
  addonId: null,
22717
24041
  access: "create"
22718
24042
  },
24043
+ "notificationOutput.deleteTarget": {
24044
+ capName: "notification-output",
24045
+ capScope: "system",
24046
+ addonId: null,
24047
+ access: "delete"
24048
+ },
24049
+ "notificationOutput.discoverTargets": {
24050
+ capName: "notification-output",
24051
+ capScope: "system",
24052
+ addonId: null,
24053
+ access: "view"
24054
+ },
24055
+ "notificationOutput.listTargetKinds": {
24056
+ capName: "notification-output",
24057
+ capScope: "system",
24058
+ addonId: null,
24059
+ access: "view"
24060
+ },
24061
+ "notificationOutput.listTargets": {
24062
+ capName: "notification-output",
24063
+ capScope: "system",
24064
+ addonId: null,
24065
+ access: "view"
24066
+ },
22719
24067
  "notificationOutput.send": {
22720
24068
  capName: "notification-output",
22721
24069
  capScope: "system",
22722
24070
  addonId: null,
22723
24071
  access: "create"
22724
24072
  },
22725
- "notificationOutput.sendTest": {
24073
+ "notificationOutput.setTargetEnabled": {
24074
+ capName: "notification-output",
24075
+ capScope: "system",
24076
+ addonId: null,
24077
+ access: "create"
24078
+ },
24079
+ "notificationOutput.testTarget": {
24080
+ capName: "notification-output",
24081
+ capScope: "system",
24082
+ addonId: null,
24083
+ access: "create"
24084
+ },
24085
+ "notificationOutput.upsertTarget": {
22726
24086
  capName: "notification-output",
22727
24087
  capScope: "system",
22728
24088
  addonId: null,
@@ -22752,6 +24112,66 @@ Object.freeze({
22752
24112
  addonId: null,
22753
24113
  access: "create"
22754
24114
  },
24115
+ "petFeeder.callPet": {
24116
+ capName: "pet-feeder",
24117
+ capScope: "device",
24118
+ addonId: null,
24119
+ access: "create"
24120
+ },
24121
+ "petFeeder.cancelFeed": {
24122
+ capName: "pet-feeder",
24123
+ capScope: "device",
24124
+ addonId: null,
24125
+ access: "create"
24126
+ },
24127
+ "petFeeder.feed": {
24128
+ capName: "pet-feeder",
24129
+ capScope: "device",
24130
+ addonId: null,
24131
+ access: "create"
24132
+ },
24133
+ "petFeeder.markFoodReplenished": {
24134
+ capName: "pet-feeder",
24135
+ capScope: "device",
24136
+ addonId: null,
24137
+ access: "create"
24138
+ },
24139
+ "petFeeder.playSound": {
24140
+ capName: "pet-feeder",
24141
+ capScope: "device",
24142
+ addonId: null,
24143
+ access: "create"
24144
+ },
24145
+ "petFeeder.resetDesiccant": {
24146
+ capName: "pet-feeder",
24147
+ capScope: "device",
24148
+ addonId: null,
24149
+ access: "delete"
24150
+ },
24151
+ "petFeeder.setChildLock": {
24152
+ capName: "pet-feeder",
24153
+ capScope: "device",
24154
+ addonId: null,
24155
+ access: "create"
24156
+ },
24157
+ "petFeeder.setFeedSound": {
24158
+ capName: "pet-feeder",
24159
+ capScope: "device",
24160
+ addonId: null,
24161
+ access: "create"
24162
+ },
24163
+ "petFeeder.setIndicatorLight": {
24164
+ capName: "pet-feeder",
24165
+ capScope: "device",
24166
+ addonId: null,
24167
+ access: "create"
24168
+ },
24169
+ "petFeeder.setVolume": {
24170
+ capName: "pet-feeder",
24171
+ capScope: "device",
24172
+ addonId: null,
24173
+ access: "create"
24174
+ },
22755
24175
  "pipelineAnalytics.clearTracks": {
22756
24176
  capName: "pipeline-analytics",
22757
24177
  capScope: "device",
@@ -28981,7 +30401,7 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
28981
30401
  */
28982
30402
  resolveAudioCodecApi() {
28983
30403
  const router = this.ctx.api.audioCodec;
28984
- if (!router) throw new Error("Hikvision intercom: `audio-codec` capability is not mounted. Install + enable the `addon-audio-codec-nodeav` addon (or any other addon that provides the `audio-codec` capability) before opening a talk session.");
30404
+ if (!router) throw new Error("Hikvision intercom: `audio-codec` capability is not mounted. Install + enable the `addon-audio-codec-ffmpeg` addon (or any other addon that provides the `audio-codec` capability) before opening a talk session.");
28985
30405
  return {
28986
30406
  createDecodeSession: (input) => router.createDecodeSession.mutate(input),
28987
30407
  pushEncodedFrame: (input) => router.pushEncodedFrame.mutate(input),