@camstack/addon-provider-wyze 0.1.11 → 0.1.12
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.
- package/dist/addon.js +1463 -61
- package/dist/addon.mjs +1463 -61
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -4659,7 +4659,7 @@ function _instanceof(cls, params = {}) {
|
|
|
4659
4659
|
return inst;
|
|
4660
4660
|
}
|
|
4661
4661
|
//#endregion
|
|
4662
|
-
//#region ../types/dist/sleep-
|
|
4662
|
+
//#region ../types/dist/sleep-BiDFW0E7.mjs
|
|
4663
4663
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4664
4664
|
EventCategory["SystemBoot"] = "system.boot";
|
|
4665
4665
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -5472,6 +5472,100 @@ function createDurableState(deps) {
|
|
|
5472
5472
|
};
|
|
5473
5473
|
}
|
|
5474
5474
|
/**
|
|
5475
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
5476
|
+
*
|
|
5477
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
5478
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
5479
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
5480
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
5481
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
5482
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
5483
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
5484
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
5485
|
+
*
|
|
5486
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
5487
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
5488
|
+
* schema and routes reads/writes through these helpers.
|
|
5489
|
+
*
|
|
5490
|
+
* ## No bare-key fallback — deliberate
|
|
5491
|
+
*
|
|
5492
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
5493
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
5494
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
5495
|
+
* the store is invisible to every node, hub included, so one node's
|
|
5496
|
+
* selection can never leak onto another. (This generalizes the
|
|
5497
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
5498
|
+
* arbitrary set of per-node field keys.)
|
|
5499
|
+
*
|
|
5500
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
5501
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
5502
|
+
*/
|
|
5503
|
+
/**
|
|
5504
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
5505
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
5506
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
5507
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
5508
|
+
*/
|
|
5509
|
+
function normalizeNodeId(raw) {
|
|
5510
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
5511
|
+
const slashIdx = raw.indexOf("/");
|
|
5512
|
+
if (slashIdx < 0) return raw;
|
|
5513
|
+
const bare = raw.slice(0, slashIdx);
|
|
5514
|
+
return bare === "" ? "hub" : bare;
|
|
5515
|
+
}
|
|
5516
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
5517
|
+
function nodeScopedKey(base, nodeId) {
|
|
5518
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
5519
|
+
}
|
|
5520
|
+
/**
|
|
5521
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
5522
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
5523
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
5524
|
+
* schema `default` win on `undefined`.
|
|
5525
|
+
*/
|
|
5526
|
+
function readNodeValue(store, base, nodeId) {
|
|
5527
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
5528
|
+
}
|
|
5529
|
+
/**
|
|
5530
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
5531
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
5532
|
+
* the write path so a save for one node never clobbers another node's value
|
|
5533
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
5534
|
+
* patch is not mutated.
|
|
5535
|
+
*/
|
|
5536
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
5537
|
+
const out = {};
|
|
5538
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
5539
|
+
return out;
|
|
5540
|
+
}
|
|
5541
|
+
/**
|
|
5542
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
5543
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
5544
|
+
* values:
|
|
5545
|
+
*
|
|
5546
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
5547
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
5548
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
5549
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
5550
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
5551
|
+
* left ABSENT so the field's schema `default` wins.
|
|
5552
|
+
*
|
|
5553
|
+
* Returns a new object — the input store is not mutated.
|
|
5554
|
+
*/
|
|
5555
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
5556
|
+
const out = {};
|
|
5557
|
+
for (const [key, value] of Object.entries(store)) {
|
|
5558
|
+
if (key.includes("@")) continue;
|
|
5559
|
+
if (perNodeKeys.has(key)) continue;
|
|
5560
|
+
out[key] = value;
|
|
5561
|
+
}
|
|
5562
|
+
for (const base of perNodeKeys) {
|
|
5563
|
+
const value = readNodeValue(store, base, nodeId);
|
|
5564
|
+
if (value !== void 0) out[base] = value;
|
|
5565
|
+
}
|
|
5566
|
+
return out;
|
|
5567
|
+
}
|
|
5568
|
+
/**
|
|
5475
5569
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5476
5570
|
*
|
|
5477
5571
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -5639,23 +5733,63 @@ var BaseAddon = class {
|
|
|
5639
5733
|
deviceSettingsSchema() {
|
|
5640
5734
|
return null;
|
|
5641
5735
|
}
|
|
5642
|
-
async getGlobalSettings(overlay, cap,
|
|
5736
|
+
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5643
5737
|
const schema = this.globalSettingsSchema(cap);
|
|
5644
5738
|
if (!schema) return { sections: [] };
|
|
5645
|
-
const
|
|
5739
|
+
const projected = await this.resolveGlobalStore(nodeId, cap);
|
|
5646
5740
|
return hydrateSchema(schema, overlay ? {
|
|
5647
|
-
...
|
|
5741
|
+
...projected,
|
|
5648
5742
|
...overlay
|
|
5649
|
-
} :
|
|
5743
|
+
} : projected);
|
|
5650
5744
|
}
|
|
5651
|
-
|
|
5652
|
-
|
|
5745
|
+
/**
|
|
5746
|
+
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5747
|
+
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5748
|
+
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
5749
|
+
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
5750
|
+
* A no-op passthrough when the schema declares no `perNode` field.
|
|
5751
|
+
*
|
|
5752
|
+
* This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
|
|
5753
|
+
* the store for custom option logic (option narrowing, value snapping) to
|
|
5754
|
+
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
5755
|
+
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
5756
|
+
*/
|
|
5757
|
+
async resolveGlobalStore(nodeId, cap) {
|
|
5758
|
+
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
5759
|
+
const keys = this.perNodeKeys(cap);
|
|
5760
|
+
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5761
|
+
return keys.size > 0 ? projectStore(raw, keys, node) : raw;
|
|
5762
|
+
}
|
|
5763
|
+
async updateGlobalSettings(patch, nodeId) {
|
|
5764
|
+
const keys = this.perNodeKeys();
|
|
5765
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5766
|
+
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5767
|
+
const barePatch = patch;
|
|
5768
|
+
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
5769
|
+
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
5770
|
+
if (target !== localNode) return;
|
|
5653
5771
|
await this.resolveConfig();
|
|
5654
5772
|
await this.onConfigChanged();
|
|
5655
5773
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
5656
5774
|
this.maybeAutoRestart(patch, this.globalSettingsSchema());
|
|
5657
5775
|
}
|
|
5658
5776
|
/**
|
|
5777
|
+
* The set of field keys the global settings schema declares `perNode: true`
|
|
5778
|
+
* — derived once per `cap` argument and memoized (schemas are static
|
|
5779
|
+
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
5780
|
+
* settings API behaves exactly like the legacy node-agnostic one.
|
|
5781
|
+
*/
|
|
5782
|
+
_perNodeKeysCache = /* @__PURE__ */ new Map();
|
|
5783
|
+
perNodeKeys(cap) {
|
|
5784
|
+
const cacheKey = cap ?? "";
|
|
5785
|
+
const cached = this._perNodeKeysCache.get(cacheKey);
|
|
5786
|
+
if (cached) return cached;
|
|
5787
|
+
const schema = this.globalSettingsSchema(cap);
|
|
5788
|
+
const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
5789
|
+
this._perNodeKeysCache.set(cacheKey, keys);
|
|
5790
|
+
return keys;
|
|
5791
|
+
}
|
|
5792
|
+
/**
|
|
5659
5793
|
* If any field in `patch` is marked `requiresRestart` in `schema`,
|
|
5660
5794
|
* schedule an addon restart for the next tick. Deferred via
|
|
5661
5795
|
* `setImmediate` so the tRPC mutation that triggered the write has
|
|
@@ -5808,12 +5942,19 @@ var BaseAddon = class {
|
|
|
5808
5942
|
* The merge is shallow: each key in `defaults` is checked against the store.
|
|
5809
5943
|
* Only keys present in defaults are read — the store can contain extra keys
|
|
5810
5944
|
* (e.g. from older versions) without polluting the typed config.
|
|
5945
|
+
*
|
|
5946
|
+
* Keys the global settings schema declares `perNode: true` resolve from
|
|
5947
|
+
* THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
|
|
5948
|
+
* from the bare key — so a per-node field resolves to this node's own
|
|
5949
|
+
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
5811
5950
|
*/
|
|
5812
5951
|
async resolveConfig() {
|
|
5813
5952
|
const stored = await this.readAddonStoreWithRetry();
|
|
5953
|
+
const perNode = this.perNodeKeys();
|
|
5954
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5814
5955
|
const resolved = { ...this.defaults };
|
|
5815
5956
|
for (const key of Object.keys(this.defaults)) {
|
|
5816
|
-
const storedValue = stored[key];
|
|
5957
|
+
const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
|
|
5817
5958
|
if (storedValue !== void 0 && storedValue !== null) {
|
|
5818
5959
|
const defaultType = typeof this.defaults[key];
|
|
5819
5960
|
if (typeof storedValue === defaultType) resolved[key] = storedValue;
|
|
@@ -5897,6 +6038,27 @@ var BaseAddon = class {
|
|
|
5897
6038
|
}
|
|
5898
6039
|
};
|
|
5899
6040
|
/**
|
|
6041
|
+
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
6042
|
+
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
6043
|
+
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6044
|
+
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6045
|
+
*/
|
|
6046
|
+
function collectPerNodeFieldKeys(fields) {
|
|
6047
|
+
const collected = [];
|
|
6048
|
+
for (const field of fields) {
|
|
6049
|
+
if (field.type === "group") {
|
|
6050
|
+
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
6051
|
+
continue;
|
|
6052
|
+
}
|
|
6053
|
+
if (field.type === "sub-tabs") {
|
|
6054
|
+
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
6055
|
+
continue;
|
|
6056
|
+
}
|
|
6057
|
+
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
6058
|
+
}
|
|
6059
|
+
return collected;
|
|
6060
|
+
}
|
|
6061
|
+
/**
|
|
5900
6062
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
5901
6063
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
5902
6064
|
* envelopes pass through; void stays void.
|
|
@@ -5921,6 +6083,7 @@ var CamStreamKindSchema = _enum([
|
|
|
5921
6083
|
"pull-rtsp",
|
|
5922
6084
|
"pull-rtmp",
|
|
5923
6085
|
"pull-http",
|
|
6086
|
+
"pull-flv",
|
|
5924
6087
|
"pull-rfc4571",
|
|
5925
6088
|
"push-annexb",
|
|
5926
6089
|
"derived"
|
|
@@ -6303,6 +6466,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
6303
6466
|
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
6304
6467
|
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
6305
6468
|
DeviceType["Image"] = "image";
|
|
6469
|
+
/** Smart pet feeder — cloud-connected food dispenser with a bowl food
|
|
6470
|
+
* level, battery, desiccant life, feeding state and manual-feed /
|
|
6471
|
+
* call-pet / maintenance actions. Installed with the `pet-feeder` cap;
|
|
6472
|
+
* dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
|
|
6473
|
+
* native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
|
|
6474
|
+
* integrations sharing the same food/desiccant/hopper surface. */
|
|
6475
|
+
DeviceType["PetFeeder"] = "pet-feeder";
|
|
6306
6476
|
return DeviceType;
|
|
6307
6477
|
}({});
|
|
6308
6478
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -7467,6 +7637,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
|
|
|
7467
7637
|
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7468
7638
|
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7469
7639
|
/**
|
|
7640
|
+
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7641
|
+
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
7642
|
+
* failure — both are non-fatal to the host: read paths degrade to "skip link".
|
|
7643
|
+
*/
|
|
7644
|
+
/** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
|
|
7645
|
+
* the failure is anchored to a character (author-facing inline feedback). */
|
|
7646
|
+
var ExpressionParseError = class extends Error {
|
|
7647
|
+
position;
|
|
7648
|
+
constructor(message, position) {
|
|
7649
|
+
super(message);
|
|
7650
|
+
this.name = "ExpressionParseError";
|
|
7651
|
+
this.position = position;
|
|
7652
|
+
}
|
|
7653
|
+
};
|
|
7654
|
+
/** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
|
|
7655
|
+
* result, unknown builtin, step-budget exceeded). */
|
|
7656
|
+
var ExpressionEvalError = class extends Error {
|
|
7657
|
+
constructor(message) {
|
|
7658
|
+
super(message);
|
|
7659
|
+
this.name = "ExpressionEvalError";
|
|
7660
|
+
}
|
|
7661
|
+
};
|
|
7662
|
+
/**
|
|
7663
|
+
* Resource-bound constants for the safe expression engine.
|
|
7664
|
+
*
|
|
7665
|
+
* Every bound is defense-in-depth: the grammar is non-Turing-complete (no
|
|
7666
|
+
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
7667
|
+
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
7668
|
+
* work a single author-supplied expression can request, so a hostile or
|
|
7669
|
+
* accidental pathological string can never spend unbounded CPU/memory.
|
|
7670
|
+
*/
|
|
7671
|
+
/** Max source length (chars) — checked BEFORE tokenizing so a huge string is
|
|
7672
|
+
* rejected without allocation. */
|
|
7673
|
+
var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
|
|
7674
|
+
/** A legal binding / identifier name. */
|
|
7675
|
+
var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7676
|
+
/** Binding names an author may NOT use: `now` is auto-injected; the literal
|
|
7677
|
+
* keywords lex as values, not identifiers, so binding to them is meaningless. */
|
|
7678
|
+
var RESERVED_BINDING_NAMES = new Set([
|
|
7679
|
+
"now",
|
|
7680
|
+
"true",
|
|
7681
|
+
"false",
|
|
7682
|
+
"null"
|
|
7683
|
+
]);
|
|
7684
|
+
/**
|
|
7685
|
+
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
7686
|
+
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
7687
|
+
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
7688
|
+
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
7689
|
+
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
7690
|
+
* is a parse error with a source position, so member access / assignment /
|
|
7691
|
+
* template literals are lexically impossible.
|
|
7692
|
+
*/
|
|
7693
|
+
var KEYWORDS = new Set([
|
|
7694
|
+
"true",
|
|
7695
|
+
"false",
|
|
7696
|
+
"null"
|
|
7697
|
+
]);
|
|
7698
|
+
function isDigit(ch) {
|
|
7699
|
+
return ch >= "0" && ch <= "9";
|
|
7700
|
+
}
|
|
7701
|
+
function isIdentStart(ch) {
|
|
7702
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
7703
|
+
}
|
|
7704
|
+
function isIdentPart(ch) {
|
|
7705
|
+
return isIdentStart(ch) || isDigit(ch);
|
|
7706
|
+
}
|
|
7707
|
+
function isWhitespace(ch) {
|
|
7708
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
7709
|
+
}
|
|
7710
|
+
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
7711
|
+
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
7712
|
+
* string. */
|
|
7713
|
+
function tokenize(source) {
|
|
7714
|
+
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
7715
|
+
const tokens = [];
|
|
7716
|
+
let i = 0;
|
|
7717
|
+
const n = source.length;
|
|
7718
|
+
while (i < n) {
|
|
7719
|
+
const ch = source[i];
|
|
7720
|
+
if (isWhitespace(ch)) {
|
|
7721
|
+
i += 1;
|
|
7722
|
+
continue;
|
|
7723
|
+
}
|
|
7724
|
+
if (isDigit(ch)) {
|
|
7725
|
+
const start = i;
|
|
7726
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7727
|
+
if (i < n && source[i] === ".") {
|
|
7728
|
+
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
7729
|
+
i += 1;
|
|
7730
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7731
|
+
}
|
|
7732
|
+
const text = source.slice(start, i);
|
|
7733
|
+
const value = Number(text);
|
|
7734
|
+
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
7735
|
+
tokens.push({
|
|
7736
|
+
type: "number",
|
|
7737
|
+
value,
|
|
7738
|
+
pos: start
|
|
7739
|
+
});
|
|
7740
|
+
continue;
|
|
7741
|
+
}
|
|
7742
|
+
if (ch === "'" || ch === "\"") {
|
|
7743
|
+
const quote = ch;
|
|
7744
|
+
const start = i;
|
|
7745
|
+
i += 1;
|
|
7746
|
+
let out = "";
|
|
7747
|
+
let closed = false;
|
|
7748
|
+
while (i < n) {
|
|
7749
|
+
const c = source[i];
|
|
7750
|
+
if (c === "\\") {
|
|
7751
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
7752
|
+
if (next === "\\" || next === "'" || next === "\"") {
|
|
7753
|
+
out += next;
|
|
7754
|
+
i += 2;
|
|
7755
|
+
continue;
|
|
7756
|
+
}
|
|
7757
|
+
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
7758
|
+
}
|
|
7759
|
+
if (c === quote) {
|
|
7760
|
+
closed = true;
|
|
7761
|
+
i += 1;
|
|
7762
|
+
break;
|
|
7763
|
+
}
|
|
7764
|
+
out += c;
|
|
7765
|
+
i += 1;
|
|
7766
|
+
}
|
|
7767
|
+
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
7768
|
+
tokens.push({
|
|
7769
|
+
type: "string",
|
|
7770
|
+
value: out,
|
|
7771
|
+
pos: start
|
|
7772
|
+
});
|
|
7773
|
+
continue;
|
|
7774
|
+
}
|
|
7775
|
+
if (isIdentStart(ch)) {
|
|
7776
|
+
const start = i;
|
|
7777
|
+
while (i < n && isIdentPart(source[i])) i += 1;
|
|
7778
|
+
const text = source.slice(start, i);
|
|
7779
|
+
if (KEYWORDS.has(text)) tokens.push({
|
|
7780
|
+
type: "keyword",
|
|
7781
|
+
keyword: keywordOf(text),
|
|
7782
|
+
pos: start
|
|
7783
|
+
});
|
|
7784
|
+
else tokens.push({
|
|
7785
|
+
type: "identifier",
|
|
7786
|
+
name: text,
|
|
7787
|
+
pos: start
|
|
7788
|
+
});
|
|
7789
|
+
continue;
|
|
7790
|
+
}
|
|
7791
|
+
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
7792
|
+
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
7793
|
+
tokens.push({
|
|
7794
|
+
type: "punct",
|
|
7795
|
+
punct: two,
|
|
7796
|
+
pos: i
|
|
7797
|
+
});
|
|
7798
|
+
i += 2;
|
|
7799
|
+
continue;
|
|
7800
|
+
}
|
|
7801
|
+
if (isSinglePunct(ch)) {
|
|
7802
|
+
tokens.push({
|
|
7803
|
+
type: "punct",
|
|
7804
|
+
punct: ch,
|
|
7805
|
+
pos: i
|
|
7806
|
+
});
|
|
7807
|
+
i += 1;
|
|
7808
|
+
continue;
|
|
7809
|
+
}
|
|
7810
|
+
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
7811
|
+
}
|
|
7812
|
+
tokens.push({
|
|
7813
|
+
type: "eof",
|
|
7814
|
+
pos: n
|
|
7815
|
+
});
|
|
7816
|
+
return tokens;
|
|
7817
|
+
}
|
|
7818
|
+
function keywordOf(text) {
|
|
7819
|
+
if (text === "true") return "true";
|
|
7820
|
+
if (text === "false") return "false";
|
|
7821
|
+
return "null";
|
|
7822
|
+
}
|
|
7823
|
+
function isSinglePunct(ch) {
|
|
7824
|
+
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
7825
|
+
}
|
|
7826
|
+
/**
|
|
7827
|
+
* Frozen, null-prototype builtin function table for the expression engine
|
|
7828
|
+
* (spec §4 rule 4). The table is the SOLE surface of callable functions: the
|
|
7829
|
+
* parser rejects any callee not in it, and the evaluator gates each call on an
|
|
7830
|
+
* own-property check against it.
|
|
7831
|
+
*
|
|
7832
|
+
* Because the object has a NULL prototype AND is `Object.freeze`d:
|
|
7833
|
+
* - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
|
|
7834
|
+
* - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
|
|
7835
|
+
* (there is no `Object.prototype` in the chain), so those names are not
|
|
7836
|
+
* callable — they are simply "unknown function" at parse time.
|
|
7837
|
+
*
|
|
7838
|
+
* Every numeric argument is validated as a finite number and every numeric
|
|
7839
|
+
* RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
|
|
7840
|
+
* (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
|
|
7841
|
+
* closed rather than emitting a garbage value.
|
|
7842
|
+
*/
|
|
7843
|
+
function asFiniteNumber(value, name, index) {
|
|
7844
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
7845
|
+
return value;
|
|
7846
|
+
}
|
|
7847
|
+
function asString$1(value, name, index) {
|
|
7848
|
+
if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
|
|
7849
|
+
return value;
|
|
7850
|
+
}
|
|
7851
|
+
function finiteResult(value, name) {
|
|
7852
|
+
if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
|
|
7853
|
+
return value;
|
|
7854
|
+
}
|
|
7855
|
+
function allFiniteNumbers(args, name) {
|
|
7856
|
+
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
7857
|
+
}
|
|
7858
|
+
var INF = Number.POSITIVE_INFINITY;
|
|
7859
|
+
var table = {
|
|
7860
|
+
min: {
|
|
7861
|
+
minArgs: 1,
|
|
7862
|
+
maxArgs: INF,
|
|
7863
|
+
apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
|
|
7864
|
+
},
|
|
7865
|
+
max: {
|
|
7866
|
+
minArgs: 1,
|
|
7867
|
+
maxArgs: INF,
|
|
7868
|
+
apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
|
|
7869
|
+
},
|
|
7870
|
+
abs: {
|
|
7871
|
+
minArgs: 1,
|
|
7872
|
+
maxArgs: 1,
|
|
7873
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
7874
|
+
},
|
|
7875
|
+
floor: {
|
|
7876
|
+
minArgs: 1,
|
|
7877
|
+
maxArgs: 1,
|
|
7878
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
7879
|
+
},
|
|
7880
|
+
ceil: {
|
|
7881
|
+
minArgs: 1,
|
|
7882
|
+
maxArgs: 1,
|
|
7883
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
7884
|
+
},
|
|
7885
|
+
sqrt: {
|
|
7886
|
+
minArgs: 1,
|
|
7887
|
+
maxArgs: 1,
|
|
7888
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
7889
|
+
},
|
|
7890
|
+
round: {
|
|
7891
|
+
minArgs: 1,
|
|
7892
|
+
maxArgs: 2,
|
|
7893
|
+
apply: (args) => {
|
|
7894
|
+
const x = asFiniteNumber(args[0], "round", 0);
|
|
7895
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
7896
|
+
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
7897
|
+
const factor = 10 ** digits;
|
|
7898
|
+
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
7899
|
+
}
|
|
7900
|
+
},
|
|
7901
|
+
pow: {
|
|
7902
|
+
minArgs: 2,
|
|
7903
|
+
maxArgs: 2,
|
|
7904
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
7905
|
+
},
|
|
7906
|
+
clamp: {
|
|
7907
|
+
minArgs: 3,
|
|
7908
|
+
maxArgs: 3,
|
|
7909
|
+
apply: (args) => {
|
|
7910
|
+
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
7911
|
+
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
7912
|
+
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
7913
|
+
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
7914
|
+
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
7915
|
+
}
|
|
7916
|
+
},
|
|
7917
|
+
avg: {
|
|
7918
|
+
minArgs: 1,
|
|
7919
|
+
maxArgs: INF,
|
|
7920
|
+
apply: (args) => {
|
|
7921
|
+
const nums = allFiniteNumbers(args, "avg");
|
|
7922
|
+
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
7923
|
+
}
|
|
7924
|
+
},
|
|
7925
|
+
sum: {
|
|
7926
|
+
minArgs: 1,
|
|
7927
|
+
maxArgs: INF,
|
|
7928
|
+
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
7929
|
+
},
|
|
7930
|
+
coalesce: {
|
|
7931
|
+
minArgs: 1,
|
|
7932
|
+
maxArgs: INF,
|
|
7933
|
+
apply: (args) => {
|
|
7934
|
+
for (const a of args) if (a !== null) return a;
|
|
7935
|
+
return null;
|
|
7936
|
+
}
|
|
7937
|
+
},
|
|
7938
|
+
age: {
|
|
7939
|
+
minArgs: 2,
|
|
7940
|
+
maxArgs: 2,
|
|
7941
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
7942
|
+
},
|
|
7943
|
+
convert: {
|
|
7944
|
+
minArgs: 3,
|
|
7945
|
+
maxArgs: 3,
|
|
7946
|
+
apply: (args, hooks) => {
|
|
7947
|
+
const x = asFiniteNumber(args[0], "convert", 0);
|
|
7948
|
+
const from = asString$1(args[1], "convert", 1).trim();
|
|
7949
|
+
const to = asString$1(args[2], "convert", 2).trim();
|
|
7950
|
+
if (hooks.convert) {
|
|
7951
|
+
const out = hooks.convert(x, from, to);
|
|
7952
|
+
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
7953
|
+
return finiteResult(out, "convert");
|
|
7954
|
+
}
|
|
7955
|
+
if (from === to) return x;
|
|
7956
|
+
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
7957
|
+
}
|
|
7958
|
+
}
|
|
7959
|
+
};
|
|
7960
|
+
Object.freeze(Object.assign(Object.create(null), table));
|
|
7961
|
+
/** The set of valid builtin names — used by the parser to reject unknown
|
|
7962
|
+
* callees at parse time (immediate author feedback). */
|
|
7963
|
+
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
7964
|
+
/**
|
|
7965
|
+
* Pratt (precedence-climbing) parser for the safe expression mini-language.
|
|
7966
|
+
*
|
|
7967
|
+
* Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
|
|
7968
|
+
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
7969
|
+
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
7970
|
+
* string validated against the builtin table at parse time, so an unknown
|
|
7971
|
+
* function is rejected immediately (author feedback) and a persisted expression
|
|
7972
|
+
* that references a since-removed builtin degrades at read.
|
|
7973
|
+
*
|
|
7974
|
+
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
7975
|
+
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
7976
|
+
*/
|
|
7977
|
+
/** Binary/logical operator precedence (higher binds tighter). */
|
|
7978
|
+
var BINARY_PRECEDENCE = {
|
|
7979
|
+
"||": 1,
|
|
7980
|
+
"&&": 2,
|
|
7981
|
+
"==": 3,
|
|
7982
|
+
"!=": 3,
|
|
7983
|
+
"<": 4,
|
|
7984
|
+
"<=": 4,
|
|
7985
|
+
">": 4,
|
|
7986
|
+
">=": 4,
|
|
7987
|
+
"+": 5,
|
|
7988
|
+
"-": 5,
|
|
7989
|
+
"*": 6,
|
|
7990
|
+
"/": 6,
|
|
7991
|
+
"%": 6
|
|
7992
|
+
};
|
|
7993
|
+
function isLogicalOp(op) {
|
|
7994
|
+
return op === "&&" || op === "||";
|
|
7995
|
+
}
|
|
7996
|
+
function isBinaryOp(op) {
|
|
7997
|
+
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
7998
|
+
}
|
|
7999
|
+
var Parser = class {
|
|
8000
|
+
tokens;
|
|
8001
|
+
pos = 0;
|
|
8002
|
+
nodeCount = 0;
|
|
8003
|
+
identifiers = /* @__PURE__ */ new Set();
|
|
8004
|
+
callees = /* @__PURE__ */ new Set();
|
|
8005
|
+
constructor(tokens) {
|
|
8006
|
+
this.tokens = tokens;
|
|
8007
|
+
}
|
|
8008
|
+
parse() {
|
|
8009
|
+
const ast = this.parseTernary();
|
|
8010
|
+
const tok = this.peek();
|
|
8011
|
+
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
8012
|
+
return {
|
|
8013
|
+
ast,
|
|
8014
|
+
identifiers: this.identifiers,
|
|
8015
|
+
callees: this.callees,
|
|
8016
|
+
nodeCount: this.nodeCount
|
|
8017
|
+
};
|
|
8018
|
+
}
|
|
8019
|
+
peek() {
|
|
8020
|
+
return this.tokens[this.pos];
|
|
8021
|
+
}
|
|
8022
|
+
next() {
|
|
8023
|
+
return this.tokens[this.pos++];
|
|
8024
|
+
}
|
|
8025
|
+
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
8026
|
+
expectPunct(punct) {
|
|
8027
|
+
const tok = this.peek();
|
|
8028
|
+
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
8029
|
+
this.pos += 1;
|
|
8030
|
+
}
|
|
8031
|
+
matchPunct(punct) {
|
|
8032
|
+
const tok = this.peek();
|
|
8033
|
+
if (tok.type === "punct" && tok.punct === punct) {
|
|
8034
|
+
this.pos += 1;
|
|
8035
|
+
return true;
|
|
8036
|
+
}
|
|
8037
|
+
return false;
|
|
8038
|
+
}
|
|
8039
|
+
countNode() {
|
|
8040
|
+
this.nodeCount += 1;
|
|
8041
|
+
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
8042
|
+
}
|
|
8043
|
+
parseTernary() {
|
|
8044
|
+
const test = this.parseBinary(1);
|
|
8045
|
+
if (this.matchPunct("?")) {
|
|
8046
|
+
const consequent = this.parseTernary();
|
|
8047
|
+
this.expectPunct(":");
|
|
8048
|
+
const alternate = this.parseTernary();
|
|
8049
|
+
this.countNode();
|
|
8050
|
+
return {
|
|
8051
|
+
kind: "conditional",
|
|
8052
|
+
test,
|
|
8053
|
+
consequent,
|
|
8054
|
+
alternate
|
|
8055
|
+
};
|
|
8056
|
+
}
|
|
8057
|
+
return test;
|
|
8058
|
+
}
|
|
8059
|
+
parseBinary(minPrec) {
|
|
8060
|
+
let left = this.parseUnary();
|
|
8061
|
+
for (;;) {
|
|
8062
|
+
const tok = this.peek();
|
|
8063
|
+
if (tok.type !== "punct") break;
|
|
8064
|
+
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
8065
|
+
if (prec === void 0 || prec < minPrec) break;
|
|
8066
|
+
const op = tok.punct;
|
|
8067
|
+
this.pos += 1;
|
|
8068
|
+
const right = this.parseBinary(prec + 1);
|
|
8069
|
+
this.countNode();
|
|
8070
|
+
if (isLogicalOp(op)) left = {
|
|
8071
|
+
kind: "logical",
|
|
8072
|
+
op,
|
|
8073
|
+
left,
|
|
8074
|
+
right
|
|
8075
|
+
};
|
|
8076
|
+
else if (isBinaryOp(op)) left = {
|
|
8077
|
+
kind: "binary",
|
|
8078
|
+
op,
|
|
8079
|
+
left,
|
|
8080
|
+
right
|
|
8081
|
+
};
|
|
8082
|
+
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
8083
|
+
}
|
|
8084
|
+
return left;
|
|
8085
|
+
}
|
|
8086
|
+
parseUnary() {
|
|
8087
|
+
const tok = this.peek();
|
|
8088
|
+
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
8089
|
+
const op = tok.punct;
|
|
8090
|
+
this.pos += 1;
|
|
8091
|
+
const operand = this.parseUnary();
|
|
8092
|
+
this.countNode();
|
|
8093
|
+
return {
|
|
8094
|
+
kind: "unary",
|
|
8095
|
+
op,
|
|
8096
|
+
operand
|
|
8097
|
+
};
|
|
8098
|
+
}
|
|
8099
|
+
return this.parsePrimary();
|
|
8100
|
+
}
|
|
8101
|
+
parsePrimary() {
|
|
8102
|
+
const tok = this.next();
|
|
8103
|
+
switch (tok.type) {
|
|
8104
|
+
case "number":
|
|
8105
|
+
this.countNode();
|
|
8106
|
+
return {
|
|
8107
|
+
kind: "literal",
|
|
8108
|
+
value: tok.value
|
|
8109
|
+
};
|
|
8110
|
+
case "string":
|
|
8111
|
+
this.countNode();
|
|
8112
|
+
return {
|
|
8113
|
+
kind: "literal",
|
|
8114
|
+
value: tok.value
|
|
8115
|
+
};
|
|
8116
|
+
case "keyword":
|
|
8117
|
+
this.countNode();
|
|
8118
|
+
return {
|
|
8119
|
+
kind: "literal",
|
|
8120
|
+
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
8121
|
+
};
|
|
8122
|
+
case "identifier": {
|
|
8123
|
+
const nextTok = this.peek();
|
|
8124
|
+
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
8125
|
+
this.identifiers.add(tok.name);
|
|
8126
|
+
this.countNode();
|
|
8127
|
+
return {
|
|
8128
|
+
kind: "identifier",
|
|
8129
|
+
name: tok.name
|
|
8130
|
+
};
|
|
8131
|
+
}
|
|
8132
|
+
case "punct":
|
|
8133
|
+
if (tok.punct === "(") {
|
|
8134
|
+
const inner = this.parseTernary();
|
|
8135
|
+
this.expectPunct(")");
|
|
8136
|
+
return inner;
|
|
8137
|
+
}
|
|
8138
|
+
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
8139
|
+
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
8140
|
+
}
|
|
8141
|
+
}
|
|
8142
|
+
parseCall(callee, pos) {
|
|
8143
|
+
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
8144
|
+
this.expectPunct("(");
|
|
8145
|
+
const args = [];
|
|
8146
|
+
if (!this.matchPunct(")")) for (;;) {
|
|
8147
|
+
args.push(this.parseTernary());
|
|
8148
|
+
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
8149
|
+
if (this.matchPunct(",")) continue;
|
|
8150
|
+
this.expectPunct(")");
|
|
8151
|
+
break;
|
|
8152
|
+
}
|
|
8153
|
+
this.callees.add(callee);
|
|
8154
|
+
this.countNode();
|
|
8155
|
+
return {
|
|
8156
|
+
kind: "call",
|
|
8157
|
+
callee,
|
|
8158
|
+
args
|
|
8159
|
+
};
|
|
8160
|
+
}
|
|
8161
|
+
};
|
|
8162
|
+
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
8163
|
+
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
8164
|
+
function parseExpression(source) {
|
|
8165
|
+
return new Parser(tokenize(source)).parse();
|
|
8166
|
+
}
|
|
8167
|
+
Object.freeze({});
|
|
8168
|
+
/**
|
|
8169
|
+
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
8170
|
+
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
8171
|
+
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
8172
|
+
* one per read on a hot resolve path.
|
|
8173
|
+
*
|
|
8174
|
+
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
8175
|
+
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
8176
|
+
* callers is safe and maximises hit rate.
|
|
8177
|
+
*/
|
|
8178
|
+
var cache = /* @__PURE__ */ new Map();
|
|
8179
|
+
function getCached(source) {
|
|
8180
|
+
const hit = cache.get(source);
|
|
8181
|
+
if (hit !== void 0) {
|
|
8182
|
+
cache.delete(source);
|
|
8183
|
+
cache.set(source, hit);
|
|
8184
|
+
return hit;
|
|
8185
|
+
}
|
|
8186
|
+
let result;
|
|
8187
|
+
try {
|
|
8188
|
+
result = {
|
|
8189
|
+
ok: true,
|
|
8190
|
+
parsed: parseExpression(source)
|
|
8191
|
+
};
|
|
8192
|
+
} catch (err) {
|
|
8193
|
+
result = {
|
|
8194
|
+
ok: false,
|
|
8195
|
+
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
8196
|
+
};
|
|
8197
|
+
}
|
|
8198
|
+
cache.set(source, result);
|
|
8199
|
+
if (cache.size > 256) {
|
|
8200
|
+
const oldest = cache.keys().next().value;
|
|
8201
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
8202
|
+
}
|
|
8203
|
+
return result;
|
|
8204
|
+
}
|
|
8205
|
+
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
8206
|
+
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
8207
|
+
function compileExpressionSafe(source) {
|
|
8208
|
+
return getCached(source);
|
|
8209
|
+
}
|
|
8210
|
+
/**
|
|
8211
|
+
* Author-time validation. Returns `null` when the source is valid, else a
|
|
8212
|
+
* human-readable error message. Checks: the expression compiles; binding count
|
|
8213
|
+
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
8214
|
+
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
8215
|
+
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
8216
|
+
*/
|
|
8217
|
+
function validateExpressionSource(src) {
|
|
8218
|
+
const names = Object.keys(src.bindings);
|
|
8219
|
+
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
8220
|
+
for (const name of names) {
|
|
8221
|
+
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
8222
|
+
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
8223
|
+
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
8224
|
+
}
|
|
8225
|
+
const compiled = compileExpressionSafe(src.expr);
|
|
8226
|
+
if (!compiled.ok) return compiled.error;
|
|
8227
|
+
const bound = new Set(names);
|
|
8228
|
+
for (const id of compiled.parsed.identifiers) {
|
|
8229
|
+
if (id === "now") continue;
|
|
8230
|
+
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
8231
|
+
}
|
|
8232
|
+
return null;
|
|
8233
|
+
}
|
|
8234
|
+
/**
|
|
7470
8235
|
* Accessory device helpers — shared across drivers.
|
|
7471
8236
|
*
|
|
7472
8237
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -8311,7 +9076,13 @@ onStatusChanged: { data: object({
|
|
|
8311
9076
|
}) } },
|
|
8312
9077
|
status: {
|
|
8313
9078
|
schema: BatteryStatusSchema,
|
|
8314
|
-
kind: "push"
|
|
9079
|
+
kind: "push",
|
|
9080
|
+
empty: {
|
|
9081
|
+
percentage: 0,
|
|
9082
|
+
charging: "none",
|
|
9083
|
+
sleeping: false,
|
|
9084
|
+
lastUpdated: 0
|
|
9085
|
+
}
|
|
8315
9086
|
},
|
|
8316
9087
|
/**
|
|
8317
9088
|
* Runtime-state slice — every provider that registers this cap
|
|
@@ -9254,21 +10025,38 @@ var connectivityCapability = {
|
|
|
9254
10025
|
},
|
|
9255
10026
|
runtimeState: ConnectivityStatusSchema
|
|
9256
10027
|
};
|
|
10028
|
+
/**
|
|
10029
|
+
* Generic device-consumables capability — surfaces a device's
|
|
10030
|
+
* maintenance items (vacuum filters/brushes, replaceable cartridges,
|
|
10031
|
+
* descaling cycles, …) with their remaining life and an optional
|
|
10032
|
+
* "Replaced" reset action. Device-agnostic: any provider that knows its
|
|
10033
|
+
* device tracks consumables can register it; the cap declares no
|
|
10034
|
+
* vocabulary of its own — the provider names each item verbatim.
|
|
10035
|
+
*
|
|
10036
|
+
* Like `childLayout`, the cap is INERT until a provider sets items: no
|
|
10037
|
+
* provider populates it by guessing (no HA inference). The UI renders a
|
|
10038
|
+
* "No consumables reported" placeholder when `items` is empty.
|
|
10039
|
+
*/
|
|
10040
|
+
/** A single consumable item. Either a continuous `level` (remaining
|
|
10041
|
+
* life %) or a discrete `status` may be known — both may be null when a
|
|
10042
|
+
* provider only knows the item exists. `level` and `status` are not
|
|
10043
|
+
* mutually exclusive; a provider may report both. */
|
|
10044
|
+
var ConsumableItemSchema = object({
|
|
10045
|
+
/** Stable id, e.g. 'main-brush'. */
|
|
10046
|
+
key: string().min(1),
|
|
10047
|
+
/** Display name. */
|
|
10048
|
+
label: string().min(1),
|
|
10049
|
+
/** Remaining life % when known (0..100). */
|
|
10050
|
+
level: number().min(0).max(100).nullable(),
|
|
10051
|
+
/** Discrete state when known (binary mode). */
|
|
10052
|
+
status: _enum(["ok", "replace"]).nullable(),
|
|
10053
|
+
/** Ms epoch of the last replace, when known. */
|
|
10054
|
+
lastResetAt: number().nullable(),
|
|
10055
|
+
/** Whether `reset()` is meaningful for this item. */
|
|
10056
|
+
resettable: boolean()
|
|
10057
|
+
});
|
|
9257
10058
|
var ConsumablesStatusSchema = object({
|
|
9258
|
-
items: array(
|
|
9259
|
-
/** Stable id, e.g. 'main-brush'. */
|
|
9260
|
-
key: string().min(1),
|
|
9261
|
-
/** Display name. */
|
|
9262
|
-
label: string().min(1),
|
|
9263
|
-
/** Remaining life % when known (0..100). */
|
|
9264
|
-
level: number().min(0).max(100).nullable(),
|
|
9265
|
-
/** Discrete state when known (binary mode). */
|
|
9266
|
-
status: _enum(["ok", "replace"]).nullable(),
|
|
9267
|
-
/** Ms epoch of the last replace, when known. */
|
|
9268
|
-
lastResetAt: number().nullable(),
|
|
9269
|
-
/** Whether `reset()` is meaningful for this item. */
|
|
9270
|
-
resettable: boolean()
|
|
9271
|
-
})),
|
|
10059
|
+
items: array(ConsumableItemSchema),
|
|
9272
10060
|
lastChangedAt: number()
|
|
9273
10061
|
});
|
|
9274
10062
|
var consumablesCapability = {
|
|
@@ -9327,7 +10115,25 @@ reset: method(object({
|
|
|
9327
10115
|
}) },
|
|
9328
10116
|
status: {
|
|
9329
10117
|
schema: ConsumablesStatusSchema,
|
|
9330
|
-
kind: "push"
|
|
10118
|
+
kind: "push",
|
|
10119
|
+
empty: {
|
|
10120
|
+
items: [],
|
|
10121
|
+
lastChangedAt: 0
|
|
10122
|
+
},
|
|
10123
|
+
itemArray: {
|
|
10124
|
+
path: "items",
|
|
10125
|
+
keyField: "key",
|
|
10126
|
+
labelField: "label",
|
|
10127
|
+
itemSchema: ConsumableItemSchema,
|
|
10128
|
+
emptyItem: {
|
|
10129
|
+
key: "",
|
|
10130
|
+
label: "",
|
|
10131
|
+
level: null,
|
|
10132
|
+
status: null,
|
|
10133
|
+
lastResetAt: null,
|
|
10134
|
+
resettable: false
|
|
10135
|
+
}
|
|
10136
|
+
}
|
|
9331
10137
|
},
|
|
9332
10138
|
runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() })
|
|
9333
10139
|
};
|
|
@@ -10569,7 +11375,8 @@ var MotionAnalysisResultSchema = object({
|
|
|
10569
11375
|
});
|
|
10570
11376
|
method(object({
|
|
10571
11377
|
deviceId: number(),
|
|
10572
|
-
frame: FrameInputSchema
|
|
11378
|
+
frame: FrameInputSchema.optional(),
|
|
11379
|
+
frameHandle: FrameHandleSchema.optional()
|
|
10573
11380
|
}), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
|
|
10574
11381
|
deviceId: number(),
|
|
10575
11382
|
detected: boolean(),
|
|
@@ -10816,6 +11623,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
10816
11623
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
10817
11624
|
steps: array(PipelineStepInputSchema).min(1),
|
|
10818
11625
|
frame: FrameInputSchema.optional(),
|
|
11626
|
+
/**
|
|
11627
|
+
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
11628
|
+
* the decoded pixels live in. One more member of the one-of
|
|
11629
|
+
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
11630
|
+
*/
|
|
11631
|
+
frameHandle: FrameHandleSchema.optional(),
|
|
10819
11632
|
imageBase64: string().optional(),
|
|
10820
11633
|
/**
|
|
10821
11634
|
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
@@ -11058,6 +11871,31 @@ var ReportMotionInputSchema = object({
|
|
|
11058
11871
|
regions: array(MotionRegionSchema).readonly().optional()
|
|
11059
11872
|
});
|
|
11060
11873
|
/**
|
|
11874
|
+
* Where a runner gets a camera's decoded frames (cross-node Phase 2,
|
|
11875
|
+
* restream-owner model — P2c).
|
|
11876
|
+
*
|
|
11877
|
+
* - `local-broker` (DEFAULT): today's path — subscribe to the co-located
|
|
11878
|
+
* stream-broker's shm frame plane. Every pre-P2c attach payload (no
|
|
11879
|
+
* `frameSource` key) parses to this, so the field is additive with zero
|
|
11880
|
+
* behavior change.
|
|
11881
|
+
* - `remote-restream`: the detect node is NOT the camera's source-owner.
|
|
11882
|
+
* The runner acquires the owner's COMPRESSED passthrough restream
|
|
11883
|
+
* (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
|
|
11884
|
+
* double-pull guard) and decodes LOCALLY via a satellite frame plane +
|
|
11885
|
+
* pull-mode decoder session pinned to its own node. The shm ring stays
|
|
11886
|
+
* node-local; only H.264/H.265 packets cross the wire.
|
|
11887
|
+
* `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
|
|
11888
|
+
* when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
|
|
11889
|
+
* dials for the owner's restream.
|
|
11890
|
+
*/
|
|
11891
|
+
var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
|
|
11892
|
+
kind: literal("remote-restream"),
|
|
11893
|
+
/** The camera's source-owner node (slice 1: always the hub). */
|
|
11894
|
+
ownerNodeId: string(),
|
|
11895
|
+
/** Operator override for the owner host the runner dials. */
|
|
11896
|
+
hubHostnameOverride: string().optional()
|
|
11897
|
+
})]).describe("Per-camera frame-source mode for the runner (P2c)");
|
|
11898
|
+
/**
|
|
11061
11899
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
11062
11900
|
* specific runner instance via `attachCamera`. Carries everything the
|
|
11063
11901
|
* runner needs to subscribe to the local broker and execute inference.
|
|
@@ -11155,7 +11993,15 @@ var RunnerCameraConfigSchema = object({
|
|
|
11155
11993
|
*/
|
|
11156
11994
|
onboardMotionDrivesAnalyzer: boolean().default(true),
|
|
11157
11995
|
occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
|
|
11158
|
-
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
|
|
11996
|
+
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
|
|
11997
|
+
/**
|
|
11998
|
+
* Where this runner gets the camera's decoded frames (P2c). Defaulted so
|
|
11999
|
+
* every existing payload behaves as `local-broker` — the pre-Phase-2 path.
|
|
12000
|
+
* Populated with `remote-restream` by the orchestrator ONLY when the
|
|
12001
|
+
* camera's detect node differs from its source-owner (P2d, gated by the
|
|
12002
|
+
* `remoteSourcingNodes` rollout setting).
|
|
12003
|
+
*/
|
|
12004
|
+
frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
|
|
11159
12005
|
});
|
|
11160
12006
|
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;
|
|
11161
12007
|
/**
|
|
@@ -11719,6 +12565,157 @@ var numericSensorCapability = {
|
|
|
11719
12565
|
runtimeState: NumericSensorStatusSchema
|
|
11720
12566
|
};
|
|
11721
12567
|
/**
|
|
12568
|
+
* Feeder connectivity / power status — mirrors the HA petkit device-status
|
|
12569
|
+
* enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
|
|
12570
|
+
* `on_batteries` (running on battery backup). `null` until first reported.
|
|
12571
|
+
*/
|
|
12572
|
+
var PetFeederDeviceStatusSchema = _enum([
|
|
12573
|
+
"normal",
|
|
12574
|
+
"offline",
|
|
12575
|
+
"on_batteries"
|
|
12576
|
+
]);
|
|
12577
|
+
var gramsPortion = number().int().min(4).max(200);
|
|
12578
|
+
var PetFeederStatusSchema = object({
|
|
12579
|
+
/** Food currently in the bowl (grams). Null when the device has not
|
|
12580
|
+
* reported a reading yet. On dual-hopper models this is the combined
|
|
12581
|
+
* bowl reading; per-hopper levels live in `food1`/`food2`. */
|
|
12582
|
+
foodLevel: number().nullable(),
|
|
12583
|
+
/** Hopper-1 food level (grams) on dual-hopper feeders; null on
|
|
12584
|
+
* single-hopper models. */
|
|
12585
|
+
food1: number().nullable(),
|
|
12586
|
+
/** Hopper-2 food level (grams) on dual-hopper feeders; null on
|
|
12587
|
+
* single-hopper models. */
|
|
12588
|
+
food2: number().nullable(),
|
|
12589
|
+
/** Derived low-food flag — mirrors the HA `food_level` binary_sensor
|
|
12590
|
+
* (`device_class: problem`, on = low). True when the bowl is empty /
|
|
12591
|
+
* below the feeder's low threshold. */
|
|
12592
|
+
lowFood: boolean(),
|
|
12593
|
+
/** Battery charge 0..100 (%). Null on mains-powered models or when the
|
|
12594
|
+
* device has no battery reading. */
|
|
12595
|
+
batteryPower: number().min(0).max(100).nullable(),
|
|
12596
|
+
/** Days of desiccant life remaining. Null when the model has no
|
|
12597
|
+
* desiccant sensor. */
|
|
12598
|
+
desiccantLeftDays: number().nullable(),
|
|
12599
|
+
/** True while a feed is in progress. */
|
|
12600
|
+
feeding: boolean(),
|
|
12601
|
+
/** Decoded connectivity / power status (HA petkit device-status enum).
|
|
12602
|
+
* Null until the device has reported a status. */
|
|
12603
|
+
status: PetFeederDeviceStatusSchema.nullable(),
|
|
12604
|
+
/** Decoded human-readable fault message. Null (or the device's `no_error`
|
|
12605
|
+
* sentinel) means healthy; a non-null string is an active fault. Pairs
|
|
12606
|
+
* with `errorCode` for consumers that want the raw integer. */
|
|
12607
|
+
error: string().nullable(),
|
|
12608
|
+
/** Raw device error code (0 / null = no error). */
|
|
12609
|
+
errorCode: number().nullable(),
|
|
12610
|
+
/** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
|
|
12611
|
+
isDualHopper: boolean(),
|
|
12612
|
+
/** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
|
|
12613
|
+
childLock: boolean(),
|
|
12614
|
+
/** Front indicator-light setting. */
|
|
12615
|
+
indicatorLight: boolean(),
|
|
12616
|
+
/** Play a chime when dispensing. */
|
|
12617
|
+
feedSound: boolean(),
|
|
12618
|
+
/** Speaker / prompt volume level (device-scaled integer). */
|
|
12619
|
+
volume: number(),
|
|
12620
|
+
/** Ms epoch when the slice was last refreshed from the cloud. */
|
|
12621
|
+
lastFetchedAt: number()
|
|
12622
|
+
});
|
|
12623
|
+
var petFeederCapability = {
|
|
12624
|
+
name: "pet-feeder",
|
|
12625
|
+
scope: "device",
|
|
12626
|
+
deviceNative: true,
|
|
12627
|
+
mode: "singleton",
|
|
12628
|
+
deviceTypes: [DeviceType.PetFeeder],
|
|
12629
|
+
methods: {
|
|
12630
|
+
/**
|
|
12631
|
+
* Dispense food now. Single-hopper feeders take `grams`; dual-hopper
|
|
12632
|
+
* feeders (D4S/D4SH) accept `hopper1`/`hopper2` to target one or both
|
|
12633
|
+
* hoppers. All portions honour the 4–200 g hardware range. At least
|
|
12634
|
+
* one of the three must be present — the provider rejects an empty
|
|
12635
|
+
* request.
|
|
12636
|
+
*/
|
|
12637
|
+
feed: method(object({
|
|
12638
|
+
deviceId: number().int().nonnegative(),
|
|
12639
|
+
grams: gramsPortion.optional(),
|
|
12640
|
+
hopper1: gramsPortion.optional(),
|
|
12641
|
+
hopper2: gramsPortion.optional()
|
|
12642
|
+
}), _void(), {
|
|
12643
|
+
kind: "mutation",
|
|
12644
|
+
auth: "admin"
|
|
12645
|
+
}),
|
|
12646
|
+
/** Cancel an in-progress manual feed. */
|
|
12647
|
+
cancelFeed: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12648
|
+
kind: "mutation",
|
|
12649
|
+
auth: "admin"
|
|
12650
|
+
}),
|
|
12651
|
+
/** Reset the desiccant "days remaining" counter after replacing it. */
|
|
12652
|
+
resetDesiccant: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12653
|
+
kind: "mutation",
|
|
12654
|
+
auth: "admin"
|
|
12655
|
+
}),
|
|
12656
|
+
/** Mark a hopper as refilled (D4H/D4S/D4SH). */
|
|
12657
|
+
markFoodReplenished: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12658
|
+
kind: "mutation",
|
|
12659
|
+
auth: "admin"
|
|
12660
|
+
}),
|
|
12661
|
+
/** Call the pet with the recorded prompt (D3). */
|
|
12662
|
+
callPet: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12663
|
+
kind: "mutation",
|
|
12664
|
+
auth: "admin"
|
|
12665
|
+
}),
|
|
12666
|
+
/** Play a stored sound by id (D3 / D4H / D4SH). */
|
|
12667
|
+
playSound: method(object({
|
|
12668
|
+
deviceId: number().int().nonnegative(),
|
|
12669
|
+
soundId: number().int().nonnegative()
|
|
12670
|
+
}), _void(), {
|
|
12671
|
+
kind: "mutation",
|
|
12672
|
+
auth: "admin"
|
|
12673
|
+
}),
|
|
12674
|
+
/** Toggle the child-lock (manual-lock) setting. */
|
|
12675
|
+
setChildLock: method(object({
|
|
12676
|
+
deviceId: number().int().nonnegative(),
|
|
12677
|
+
on: boolean()
|
|
12678
|
+
}), _void(), {
|
|
12679
|
+
kind: "mutation",
|
|
12680
|
+
auth: "admin"
|
|
12681
|
+
}),
|
|
12682
|
+
/** Toggle the front indicator light. */
|
|
12683
|
+
setIndicatorLight: method(object({
|
|
12684
|
+
deviceId: number().int().nonnegative(),
|
|
12685
|
+
on: boolean()
|
|
12686
|
+
}), _void(), {
|
|
12687
|
+
kind: "mutation",
|
|
12688
|
+
auth: "admin"
|
|
12689
|
+
}),
|
|
12690
|
+
/** Toggle the dispense chime. */
|
|
12691
|
+
setFeedSound: method(object({
|
|
12692
|
+
deviceId: number().int().nonnegative(),
|
|
12693
|
+
on: boolean()
|
|
12694
|
+
}), _void(), {
|
|
12695
|
+
kind: "mutation",
|
|
12696
|
+
auth: "admin"
|
|
12697
|
+
}),
|
|
12698
|
+
/** Set the speaker / prompt volume level. */
|
|
12699
|
+
setVolume: method(object({
|
|
12700
|
+
deviceId: number().int().nonnegative(),
|
|
12701
|
+
level: number().int().nonnegative()
|
|
12702
|
+
}), _void(), {
|
|
12703
|
+
kind: "mutation",
|
|
12704
|
+
auth: "admin"
|
|
12705
|
+
})
|
|
12706
|
+
},
|
|
12707
|
+
status: {
|
|
12708
|
+
schema: PetFeederStatusSchema,
|
|
12709
|
+
kind: "poll"
|
|
12710
|
+
},
|
|
12711
|
+
/**
|
|
12712
|
+
* Runtime-state slice — mirrored by the kernel. UI feeder cards read
|
|
12713
|
+
* the full slice via `device.state.petFeeder.value` and refresh on
|
|
12714
|
+
* every poll without re-querying the provider.
|
|
12715
|
+
*/
|
|
12716
|
+
runtimeState: PetFeederStatusSchema
|
|
12717
|
+
};
|
|
12718
|
+
/**
|
|
11722
12719
|
* Multi-metric electrical meter. One slice can carry any combination
|
|
11723
12720
|
* of instantaneous power (W), cumulative energy (kWh), voltage (V),
|
|
11724
12721
|
* and current (A) — all fields optional so a single-metric source
|
|
@@ -13021,6 +14018,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
|
|
|
13021
14018
|
nativeObjectDetection: nativeObjectDetectionCapability,
|
|
13022
14019
|
notifier: notifierCapability,
|
|
13023
14020
|
numericSensor: numericSensorCapability,
|
|
14021
|
+
petFeeder: petFeederCapability,
|
|
13024
14022
|
powerMeter: powerMeterCapability,
|
|
13025
14023
|
presence: presenceCapability,
|
|
13026
14024
|
pressureSensor: pressureSensorCapability,
|
|
@@ -14937,10 +15935,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
|
|
|
14937
15935
|
url: string()
|
|
14938
15936
|
}), _void()), method(object({
|
|
14939
15937
|
sessionId: string(),
|
|
14940
|
-
maxCount: number().default(1)
|
|
15938
|
+
maxCount: number().default(1),
|
|
15939
|
+
waitMs: number().optional()
|
|
14941
15940
|
}), array(DecodedFrameSchema)), method(object({
|
|
14942
15941
|
sessionId: string(),
|
|
14943
|
-
maxCount: number().default(1)
|
|
15942
|
+
maxCount: number().default(1),
|
|
15943
|
+
waitMs: number().optional()
|
|
14944
15944
|
}), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
|
|
14945
15945
|
sessionId: string(),
|
|
14946
15946
|
config: DecoderSessionConfigSchema.partial()
|
|
@@ -15244,14 +16244,63 @@ var ChildLayoutEntrySchema = object({
|
|
|
15244
16244
|
collapsed: boolean().optional()
|
|
15245
16245
|
});
|
|
15246
16246
|
/** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
|
|
15247
|
-
* `device-management.ts`.
|
|
16247
|
+
* `device-management.ts`. Source is a union: a FIELD source copies a sibling
|
|
16248
|
+
* accessory's status field (`kind` optional/absent for wire compat); a
|
|
16249
|
+
* LITERAL source carries a per-device constant (no sibling is read); a
|
|
16250
|
+
* GLOBAL source (P2e) copies ANY device's status field, addressed by the
|
|
16251
|
+
* source device's full re-sync-stable `stableId`. */
|
|
16252
|
+
var DeviceLinkFieldSourceSchema = object({
|
|
16253
|
+
kind: literal("field").optional(),
|
|
16254
|
+
sourceKey: string(),
|
|
16255
|
+
cap: string(),
|
|
16256
|
+
fieldPath: string()
|
|
16257
|
+
});
|
|
16258
|
+
var DeviceLinkLiteralSourceSchema = object({
|
|
16259
|
+
kind: literal("literal"),
|
|
16260
|
+
value: union([
|
|
16261
|
+
string(),
|
|
16262
|
+
number(),
|
|
16263
|
+
boolean(),
|
|
16264
|
+
_null()
|
|
16265
|
+
])
|
|
16266
|
+
});
|
|
16267
|
+
var DeviceLinkGlobalSourceSchema = object({
|
|
16268
|
+
kind: literal("global"),
|
|
16269
|
+
sourceStableId: string(),
|
|
16270
|
+
cap: string(),
|
|
16271
|
+
fieldPath: string()
|
|
16272
|
+
});
|
|
16273
|
+
/** Expression source (Stage X): compute the target field from N named bindings
|
|
16274
|
+
* via the safe expression engine. Bindings are field | literal | global — never
|
|
16275
|
+
* another expression (no nesting). The `superRefine` runs the SAME author-time
|
|
16276
|
+
* validation as `validateExpressionSource` (compiles the expr, checks binding
|
|
16277
|
+
* names + identifier coverage) so every wire boundary that parses a DeviceLink
|
|
16278
|
+
* (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
|
|
16279
|
+
* Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
|
|
16280
|
+
var DeviceLinkExpressionSourceSchema = object({
|
|
16281
|
+
kind: literal("expression"),
|
|
16282
|
+
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
16283
|
+
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
|
|
16284
|
+
DeviceLinkFieldSourceSchema,
|
|
16285
|
+
DeviceLinkLiteralSourceSchema,
|
|
16286
|
+
DeviceLinkGlobalSourceSchema
|
|
16287
|
+
]))
|
|
16288
|
+
}).superRefine((src, ctx) => {
|
|
16289
|
+
const err = validateExpressionSource(src);
|
|
16290
|
+
if (err !== null) ctx.addIssue({
|
|
16291
|
+
code: "custom",
|
|
16292
|
+
message: err,
|
|
16293
|
+
path: ["expr"]
|
|
16294
|
+
});
|
|
16295
|
+
});
|
|
15248
16296
|
var DeviceLinkSchema = object({
|
|
15249
16297
|
id: string(),
|
|
15250
|
-
source:
|
|
15251
|
-
|
|
15252
|
-
|
|
15253
|
-
|
|
15254
|
-
|
|
16298
|
+
source: union([
|
|
16299
|
+
DeviceLinkFieldSourceSchema,
|
|
16300
|
+
DeviceLinkLiteralSourceSchema,
|
|
16301
|
+
DeviceLinkGlobalSourceSchema,
|
|
16302
|
+
DeviceLinkExpressionSourceSchema
|
|
16303
|
+
]),
|
|
15255
16304
|
target: object({
|
|
15256
16305
|
cap: string(),
|
|
15257
16306
|
fieldPath: string(),
|
|
@@ -15280,6 +16329,31 @@ var DeviceLinkSchema = object({
|
|
|
15280
16329
|
})
|
|
15281
16330
|
]).optional()
|
|
15282
16331
|
});
|
|
16332
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
16333
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
16334
|
+
var DeviceCapDisplayOverrideSchema = object({
|
|
16335
|
+
unit: string().min(1).optional(),
|
|
16336
|
+
precision: number().int().min(0).max(10).optional()
|
|
16337
|
+
});
|
|
16338
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
16339
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
16340
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
16341
|
+
var DeviceDisplayOverrideSchema = object({
|
|
16342
|
+
icon: string().min(1).optional(),
|
|
16343
|
+
label: string().min(1).optional(),
|
|
16344
|
+
unit: string().min(1).optional(),
|
|
16345
|
+
precision: number().int().min(0).max(10).optional(),
|
|
16346
|
+
hidden: boolean().optional(),
|
|
16347
|
+
perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
|
|
16348
|
+
});
|
|
16349
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
16350
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
16351
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
16352
|
+
var RoleDisplayDefaultSchema = object({
|
|
16353
|
+
unit: string().min(1).optional(),
|
|
16354
|
+
precision: number().int().min(0).max(10).optional(),
|
|
16355
|
+
icon: string().min(1).optional()
|
|
16356
|
+
});
|
|
15283
16357
|
/**
|
|
15284
16358
|
* Serializable projection of a live IDevice.
|
|
15285
16359
|
* Returned by listAll, getDevice, getChildren.
|
|
@@ -15335,7 +16409,9 @@ var DeviceInfoSchema = object({
|
|
|
15335
16409
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
15336
16410
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
15337
16411
|
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
15338
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional()
|
|
16412
|
+
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
16413
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
16414
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
15339
16415
|
});
|
|
15340
16416
|
var ConfigEntrySchema = object({
|
|
15341
16417
|
key: string(),
|
|
@@ -15400,7 +16476,9 @@ var DeviceMetaSchema = object({
|
|
|
15400
16476
|
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
15401
16477
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
15402
16478
|
* Optional: only present for accessory children that carry a known role. */
|
|
15403
|
-
role: string().nullable().optional()
|
|
16479
|
+
role: string().nullable().optional(),
|
|
16480
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
16481
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
15404
16482
|
});
|
|
15405
16483
|
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
15406
16484
|
var ConfigUISchemaOutput = unknown().nullable();
|
|
@@ -15494,7 +16572,19 @@ method(object({
|
|
|
15494
16572
|
}), _void(), {
|
|
15495
16573
|
kind: "mutation",
|
|
15496
16574
|
auth: "admin"
|
|
15497
|
-
}), method(object({
|
|
16575
|
+
}), method(object({
|
|
16576
|
+
deviceId: number(),
|
|
16577
|
+
display: DeviceDisplayOverrideSchema.nullable()
|
|
16578
|
+
}), _void(), {
|
|
16579
|
+
kind: "mutation",
|
|
16580
|
+
auth: "admin"
|
|
16581
|
+
}), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
|
|
16582
|
+
kind: "mutation",
|
|
16583
|
+
auth: "admin"
|
|
16584
|
+
}), method(object({
|
|
16585
|
+
deviceId: number(),
|
|
16586
|
+
includeSynthesizable: boolean().optional()
|
|
16587
|
+
}), object({ caps: array(object({
|
|
15498
16588
|
cap: string(),
|
|
15499
16589
|
fields: array(object({
|
|
15500
16590
|
path: string(),
|
|
@@ -15504,8 +16594,13 @@ method(object({
|
|
|
15504
16594
|
"boolean",
|
|
15505
16595
|
"enum"
|
|
15506
16596
|
]),
|
|
15507
|
-
enumValues: array(string()).optional()
|
|
15508
|
-
|
|
16597
|
+
enumValues: array(string()).optional(),
|
|
16598
|
+
item: boolean().optional()
|
|
16599
|
+
})).readonly(),
|
|
16600
|
+
itemArray: object({
|
|
16601
|
+
path: string(),
|
|
16602
|
+
keyField: string()
|
|
16603
|
+
}).optional()
|
|
15509
16604
|
})).readonly() }), { kind: "query" }), method(object({
|
|
15510
16605
|
deviceId: number(),
|
|
15511
16606
|
role: string().nullable()
|
|
@@ -15575,7 +16670,11 @@ method(object({
|
|
|
15575
16670
|
deviceId: number(),
|
|
15576
16671
|
entries: array(object({
|
|
15577
16672
|
capName: string(),
|
|
15578
|
-
kind: _enum([
|
|
16673
|
+
kind: _enum([
|
|
16674
|
+
"native",
|
|
16675
|
+
"wrapped",
|
|
16676
|
+
"linked"
|
|
16677
|
+
]),
|
|
15579
16678
|
providerAddonId: string(),
|
|
15580
16679
|
providerNodeId: string(),
|
|
15581
16680
|
nativeAddonId: string()
|
|
@@ -15584,7 +16683,11 @@ method(object({
|
|
|
15584
16683
|
deviceId: number(),
|
|
15585
16684
|
entries: array(object({
|
|
15586
16685
|
capName: string(),
|
|
15587
|
-
kind: _enum([
|
|
16686
|
+
kind: _enum([
|
|
16687
|
+
"native",
|
|
16688
|
+
"wrapped",
|
|
16689
|
+
"linked"
|
|
16690
|
+
]),
|
|
15588
16691
|
providerAddonId: string(),
|
|
15589
16692
|
providerNodeId: string(),
|
|
15590
16693
|
nativeAddonId: string()
|
|
@@ -16074,7 +17177,7 @@ var AddBrokerInputSchema = object({
|
|
|
16074
17177
|
});
|
|
16075
17178
|
var AddBrokerResultSchema = object({ id: string() });
|
|
16076
17179
|
var IdInputSchema = object({ id: string() });
|
|
16077
|
-
var TestResultSchema = discriminatedUnion("ok", [object({
|
|
17180
|
+
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
16078
17181
|
ok: literal(true),
|
|
16079
17182
|
latencyMs: number()
|
|
16080
17183
|
}), object({
|
|
@@ -16097,7 +17200,7 @@ var StatusSchema = object({
|
|
|
16097
17200
|
brokerCount: number(),
|
|
16098
17201
|
embeddedRunning: boolean()
|
|
16099
17202
|
});
|
|
16100
|
-
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);
|
|
17203
|
+
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);
|
|
16101
17204
|
var NetworkEndpointSchema = object({
|
|
16102
17205
|
url: string(),
|
|
16103
17206
|
hostname: string(),
|
|
@@ -16131,23 +17234,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
|
16131
17234
|
sourcePort: number().optional()
|
|
16132
17235
|
});
|
|
16133
17236
|
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
16134
|
-
|
|
16135
|
-
|
|
17237
|
+
/**
|
|
17238
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
17239
|
+
*
|
|
17240
|
+
* Apprise-derived model (see
|
|
17241
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
17242
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
17243
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
17244
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
17245
|
+
* message to what the kind supports — callers never special-case a service.
|
|
17246
|
+
*
|
|
17247
|
+
* DESIGN DECISIONS (locked):
|
|
17248
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
17249
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
17250
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
17251
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
17252
|
+
* alternative would fork the UI per addon and cannot host the
|
|
17253
|
+
* discovery→adopt flow.
|
|
17254
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
17255
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
17256
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
17257
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
17258
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
17259
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
17260
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
17261
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
17262
|
+
* base64 fallback needed.
|
|
17263
|
+
*
|
|
17264
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
17265
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
17266
|
+
* admin "Integrations" page.
|
|
17267
|
+
*/
|
|
17268
|
+
/**
|
|
17269
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
17270
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
17271
|
+
*/
|
|
17272
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
17273
|
+
"image",
|
|
17274
|
+
"video",
|
|
17275
|
+
"gif",
|
|
17276
|
+
"audio",
|
|
17277
|
+
"icon"
|
|
17278
|
+
]);
|
|
17279
|
+
/**
|
|
17280
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
17281
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
17282
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
17283
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
17284
|
+
*/
|
|
17285
|
+
var AttachmentSchema = object({
|
|
17286
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
17287
|
+
url: string().optional(),
|
|
17288
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
17289
|
+
mime: string().optional(),
|
|
17290
|
+
name: string().optional()
|
|
17291
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
17292
|
+
var NotificationFormatSchema = _enum([
|
|
17293
|
+
"text",
|
|
17294
|
+
"markdown",
|
|
17295
|
+
"html"
|
|
17296
|
+
]);
|
|
17297
|
+
/** A single tap-through action button. */
|
|
17298
|
+
var NotificationActionSchema = object({
|
|
17299
|
+
id: string(),
|
|
17300
|
+
label: string(),
|
|
17301
|
+
url: string().optional()
|
|
17302
|
+
});
|
|
17303
|
+
/**
|
|
17304
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
17305
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
17306
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
17307
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
17308
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
17309
|
+
* `priority` for that one target.
|
|
17310
|
+
*/
|
|
17311
|
+
var NotificationSchema = object({
|
|
16136
17312
|
body: string(),
|
|
16137
|
-
|
|
17313
|
+
title: string().optional(),
|
|
17314
|
+
format: NotificationFormatSchema.default("text"),
|
|
17315
|
+
priority: number().int().min(1).max(5).default(3),
|
|
17316
|
+
level: string().optional(),
|
|
17317
|
+
attachments: array(AttachmentSchema).optional(),
|
|
17318
|
+
clickUrl: string().optional(),
|
|
17319
|
+
actions: array(NotificationActionSchema).optional(),
|
|
17320
|
+
sound: string().optional(),
|
|
17321
|
+
ttl: number().optional(),
|
|
17322
|
+
tag: string().optional(),
|
|
16138
17323
|
deviceId: number().optional(),
|
|
16139
17324
|
eventId: string().optional(),
|
|
16140
|
-
priority: _enum([
|
|
16141
|
-
"low",
|
|
16142
|
-
"normal",
|
|
16143
|
-
"high",
|
|
16144
|
-
"critical"
|
|
16145
|
-
]).default("normal"),
|
|
16146
17325
|
metadata: record(string(), unknown()).optional()
|
|
16147
|
-
})
|
|
17326
|
+
});
|
|
17327
|
+
/** One declared native severity/priority level for a kind. */
|
|
17328
|
+
var TargetKindLevelSchema = object({
|
|
17329
|
+
id: string(),
|
|
17330
|
+
label: string(),
|
|
17331
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
17332
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
17333
|
+
flags: object({
|
|
17334
|
+
critical: boolean().optional(),
|
|
17335
|
+
silent: boolean().optional(),
|
|
17336
|
+
noPush: boolean().optional()
|
|
17337
|
+
}).optional(),
|
|
17338
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
17339
|
+
requires: array(string()).optional(),
|
|
17340
|
+
description: string().optional()
|
|
17341
|
+
});
|
|
17342
|
+
/** The full capability block consulted before dispatch. */
|
|
17343
|
+
var TargetKindCapsSchema = object({
|
|
17344
|
+
attachments: object({
|
|
17345
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
17346
|
+
mode: _enum([
|
|
17347
|
+
"url",
|
|
17348
|
+
"bytes",
|
|
17349
|
+
"both"
|
|
17350
|
+
]),
|
|
17351
|
+
max: number().int().nonnegative(),
|
|
17352
|
+
maxBytes: number().int().positive().optional()
|
|
17353
|
+
}),
|
|
17354
|
+
/** Max action buttons (0 = none). */
|
|
17355
|
+
actions: number().int().nonnegative(),
|
|
17356
|
+
levels: array(TargetKindLevelSchema),
|
|
17357
|
+
format: array(NotificationFormatSchema),
|
|
17358
|
+
clickUrl: boolean(),
|
|
17359
|
+
sound: boolean(),
|
|
17360
|
+
ttl: boolean(),
|
|
17361
|
+
bodyMaxLen: number().int().positive()
|
|
17362
|
+
});
|
|
17363
|
+
/**
|
|
17364
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
17365
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
17366
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
17367
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
17368
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
17369
|
+
*/
|
|
17370
|
+
var ConfigSchemaPassthrough = unknown();
|
|
17371
|
+
var TargetKindSchema = object({
|
|
17372
|
+
kind: string(),
|
|
17373
|
+
label: string(),
|
|
17374
|
+
icon: string(),
|
|
17375
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
17376
|
+
addonId: string(),
|
|
17377
|
+
configSchema: ConfigSchemaPassthrough,
|
|
17378
|
+
supportsDiscovery: boolean(),
|
|
17379
|
+
caps: TargetKindCapsSchema
|
|
17380
|
+
});
|
|
17381
|
+
/**
|
|
17382
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
17383
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
17384
|
+
* round-trip a stored secret to the UI.
|
|
17385
|
+
*/
|
|
17386
|
+
var TargetSchema = object({
|
|
17387
|
+
id: string(),
|
|
17388
|
+
name: string(),
|
|
17389
|
+
kind: string(),
|
|
17390
|
+
addonId: string(),
|
|
17391
|
+
enabled: boolean(),
|
|
17392
|
+
config: record(string(), unknown())
|
|
17393
|
+
});
|
|
17394
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
17395
|
+
var DiscoveredTargetSchema = object({
|
|
17396
|
+
kind: string(),
|
|
17397
|
+
suggestedName: string(),
|
|
17398
|
+
config: record(string(), unknown())
|
|
17399
|
+
});
|
|
17400
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
17401
|
+
var RenderedAsSchema = object({
|
|
17402
|
+
level: string(),
|
|
17403
|
+
format: NotificationFormatSchema,
|
|
17404
|
+
attachmentsSent: number().int().nonnegative(),
|
|
17405
|
+
actionsSent: number().int().nonnegative(),
|
|
17406
|
+
truncated: boolean(),
|
|
17407
|
+
dropped: array(string())
|
|
17408
|
+
});
|
|
17409
|
+
var SendResultSchema = object({
|
|
16148
17410
|
success: boolean(),
|
|
16149
|
-
error: string().optional()
|
|
16150
|
-
|
|
17411
|
+
error: string().optional(),
|
|
17412
|
+
renderedAs: RenderedAsSchema.optional()
|
|
17413
|
+
});
|
|
17414
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
17415
|
+
var TestResultSchema = SendResultSchema;
|
|
17416
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
|
|
17417
|
+
kind: string(),
|
|
17418
|
+
config: record(string(), unknown()).optional()
|
|
17419
|
+
}), array(DiscoveredTargetSchema)), method(object({
|
|
17420
|
+
targetId: string(),
|
|
17421
|
+
notification: NotificationSchema
|
|
17422
|
+
}), SendResultSchema, { kind: "mutation" }), method(object({
|
|
17423
|
+
targetId: string(),
|
|
17424
|
+
sample: NotificationSchema.optional()
|
|
17425
|
+
}), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
|
|
17426
|
+
targetId: string(),
|
|
17427
|
+
enabled: boolean()
|
|
17428
|
+
}), _void(), { kind: "mutation" });
|
|
16151
17429
|
/**
|
|
16152
17430
|
* Zod schemas for persisted record types.
|
|
16153
17431
|
*
|
|
@@ -19263,7 +20541,10 @@ var HwAccelBackendInputSchema = _enum([
|
|
|
19263
20541
|
"webgpu",
|
|
19264
20542
|
"none"
|
|
19265
20543
|
]).nullable().optional();
|
|
19266
|
-
var HwAccelResolutionSchema = object({
|
|
20544
|
+
var HwAccelResolutionSchema = object({
|
|
20545
|
+
preferred: array(string()).readonly(),
|
|
20546
|
+
rationale: string()
|
|
20547
|
+
});
|
|
19267
20548
|
var HardwareEncoderIdSchema = _enum([
|
|
19268
20549
|
"h264_videotoolbox",
|
|
19269
20550
|
"hevc_videotoolbox",
|
|
@@ -19368,10 +20649,7 @@ var ResolvedInferenceConfigSchema = object({
|
|
|
19368
20649
|
format: ModelFormatSchema,
|
|
19369
20650
|
reason: string()
|
|
19370
20651
|
});
|
|
19371
|
-
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
|
|
19372
|
-
prefer: HwAccelBackendInputSchema,
|
|
19373
|
-
nodeId: string().optional()
|
|
19374
|
-
}), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
20652
|
+
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
19375
20653
|
kind: "mutation",
|
|
19376
20654
|
auth: "admin"
|
|
19377
20655
|
}), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
|
|
@@ -19430,6 +20708,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
|
|
|
19430
20708
|
kind: "mutation",
|
|
19431
20709
|
auth: "admin"
|
|
19432
20710
|
});
|
|
20711
|
+
/**
|
|
20712
|
+
* `recording` cap — footage availability + HLS playback manifests + per-device
|
|
20713
|
+
* recording config. NOTE on events (source of truth, R5/C3): this cap carries
|
|
20714
|
+
* NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
|
|
20715
|
+
* events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
|
|
20716
|
+
* rows); the recorder's internal EventMap markers are ephemeral in-RAM
|
|
20717
|
+
* annotations that are not exposed here and must not be treated as an event
|
|
20718
|
+
* feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
|
|
20719
|
+
* (`interfaces/recording-config.ts`).
|
|
20720
|
+
*/
|
|
19433
20721
|
var RecordingStatusSchema = object({
|
|
19434
20722
|
deviceId: number(),
|
|
19435
20723
|
enabled: boolean(),
|
|
@@ -21079,6 +22367,12 @@ Object.freeze({
|
|
|
21079
22367
|
addonId: null,
|
|
21080
22368
|
access: "view"
|
|
21081
22369
|
},
|
|
22370
|
+
"deviceManager.getRoleDisplayDefaults": {
|
|
22371
|
+
capName: "device-manager",
|
|
22372
|
+
capScope: "system",
|
|
22373
|
+
addonId: null,
|
|
22374
|
+
access: "view"
|
|
22375
|
+
},
|
|
21082
22376
|
"deviceManager.getSettingsSchema": {
|
|
21083
22377
|
capName: "device-manager",
|
|
21084
22378
|
capScope: "system",
|
|
@@ -21229,6 +22523,12 @@ Object.freeze({
|
|
|
21229
22523
|
addonId: null,
|
|
21230
22524
|
access: "create"
|
|
21231
22525
|
},
|
|
22526
|
+
"deviceManager.setDisplay": {
|
|
22527
|
+
capName: "device-manager",
|
|
22528
|
+
capScope: "system",
|
|
22529
|
+
addonId: null,
|
|
22530
|
+
access: "create"
|
|
22531
|
+
},
|
|
21232
22532
|
"deviceManager.setIntegrationId": {
|
|
21233
22533
|
capName: "device-manager",
|
|
21234
22534
|
capScope: "system",
|
|
@@ -21271,6 +22571,12 @@ Object.freeze({
|
|
|
21271
22571
|
addonId: null,
|
|
21272
22572
|
access: "create"
|
|
21273
22573
|
},
|
|
22574
|
+
"deviceManager.setRoleDisplayDefaults": {
|
|
22575
|
+
capName: "device-manager",
|
|
22576
|
+
capScope: "system",
|
|
22577
|
+
addonId: null,
|
|
22578
|
+
access: "create"
|
|
22579
|
+
},
|
|
21274
22580
|
"deviceManager.setStreamProfileMap": {
|
|
21275
22581
|
capName: "device-manager",
|
|
21276
22582
|
capScope: "system",
|
|
@@ -22249,13 +23555,49 @@ Object.freeze({
|
|
|
22249
23555
|
addonId: null,
|
|
22250
23556
|
access: "create"
|
|
22251
23557
|
},
|
|
23558
|
+
"notificationOutput.deleteTarget": {
|
|
23559
|
+
capName: "notification-output",
|
|
23560
|
+
capScope: "system",
|
|
23561
|
+
addonId: null,
|
|
23562
|
+
access: "delete"
|
|
23563
|
+
},
|
|
23564
|
+
"notificationOutput.discoverTargets": {
|
|
23565
|
+
capName: "notification-output",
|
|
23566
|
+
capScope: "system",
|
|
23567
|
+
addonId: null,
|
|
23568
|
+
access: "view"
|
|
23569
|
+
},
|
|
23570
|
+
"notificationOutput.listTargetKinds": {
|
|
23571
|
+
capName: "notification-output",
|
|
23572
|
+
capScope: "system",
|
|
23573
|
+
addonId: null,
|
|
23574
|
+
access: "view"
|
|
23575
|
+
},
|
|
23576
|
+
"notificationOutput.listTargets": {
|
|
23577
|
+
capName: "notification-output",
|
|
23578
|
+
capScope: "system",
|
|
23579
|
+
addonId: null,
|
|
23580
|
+
access: "view"
|
|
23581
|
+
},
|
|
22252
23582
|
"notificationOutput.send": {
|
|
22253
23583
|
capName: "notification-output",
|
|
22254
23584
|
capScope: "system",
|
|
22255
23585
|
addonId: null,
|
|
22256
23586
|
access: "create"
|
|
22257
23587
|
},
|
|
22258
|
-
"notificationOutput.
|
|
23588
|
+
"notificationOutput.setTargetEnabled": {
|
|
23589
|
+
capName: "notification-output",
|
|
23590
|
+
capScope: "system",
|
|
23591
|
+
addonId: null,
|
|
23592
|
+
access: "create"
|
|
23593
|
+
},
|
|
23594
|
+
"notificationOutput.testTarget": {
|
|
23595
|
+
capName: "notification-output",
|
|
23596
|
+
capScope: "system",
|
|
23597
|
+
addonId: null,
|
|
23598
|
+
access: "create"
|
|
23599
|
+
},
|
|
23600
|
+
"notificationOutput.upsertTarget": {
|
|
22259
23601
|
capName: "notification-output",
|
|
22260
23602
|
capScope: "system",
|
|
22261
23603
|
addonId: null,
|
|
@@ -22285,6 +23627,66 @@ Object.freeze({
|
|
|
22285
23627
|
addonId: null,
|
|
22286
23628
|
access: "create"
|
|
22287
23629
|
},
|
|
23630
|
+
"petFeeder.callPet": {
|
|
23631
|
+
capName: "pet-feeder",
|
|
23632
|
+
capScope: "device",
|
|
23633
|
+
addonId: null,
|
|
23634
|
+
access: "create"
|
|
23635
|
+
},
|
|
23636
|
+
"petFeeder.cancelFeed": {
|
|
23637
|
+
capName: "pet-feeder",
|
|
23638
|
+
capScope: "device",
|
|
23639
|
+
addonId: null,
|
|
23640
|
+
access: "create"
|
|
23641
|
+
},
|
|
23642
|
+
"petFeeder.feed": {
|
|
23643
|
+
capName: "pet-feeder",
|
|
23644
|
+
capScope: "device",
|
|
23645
|
+
addonId: null,
|
|
23646
|
+
access: "create"
|
|
23647
|
+
},
|
|
23648
|
+
"petFeeder.markFoodReplenished": {
|
|
23649
|
+
capName: "pet-feeder",
|
|
23650
|
+
capScope: "device",
|
|
23651
|
+
addonId: null,
|
|
23652
|
+
access: "create"
|
|
23653
|
+
},
|
|
23654
|
+
"petFeeder.playSound": {
|
|
23655
|
+
capName: "pet-feeder",
|
|
23656
|
+
capScope: "device",
|
|
23657
|
+
addonId: null,
|
|
23658
|
+
access: "create"
|
|
23659
|
+
},
|
|
23660
|
+
"petFeeder.resetDesiccant": {
|
|
23661
|
+
capName: "pet-feeder",
|
|
23662
|
+
capScope: "device",
|
|
23663
|
+
addonId: null,
|
|
23664
|
+
access: "delete"
|
|
23665
|
+
},
|
|
23666
|
+
"petFeeder.setChildLock": {
|
|
23667
|
+
capName: "pet-feeder",
|
|
23668
|
+
capScope: "device",
|
|
23669
|
+
addonId: null,
|
|
23670
|
+
access: "create"
|
|
23671
|
+
},
|
|
23672
|
+
"petFeeder.setFeedSound": {
|
|
23673
|
+
capName: "pet-feeder",
|
|
23674
|
+
capScope: "device",
|
|
23675
|
+
addonId: null,
|
|
23676
|
+
access: "create"
|
|
23677
|
+
},
|
|
23678
|
+
"petFeeder.setIndicatorLight": {
|
|
23679
|
+
capName: "pet-feeder",
|
|
23680
|
+
capScope: "device",
|
|
23681
|
+
addonId: null,
|
|
23682
|
+
access: "create"
|
|
23683
|
+
},
|
|
23684
|
+
"petFeeder.setVolume": {
|
|
23685
|
+
capName: "pet-feeder",
|
|
23686
|
+
capScope: "device",
|
|
23687
|
+
addonId: null,
|
|
23688
|
+
access: "create"
|
|
23689
|
+
},
|
|
22288
23690
|
"pipelineAnalytics.clearTracks": {
|
|
22289
23691
|
capName: "pipeline-analytics",
|
|
22290
23692
|
capScope: "device",
|