@camstack/addon-agent-ui 1.1.14 → 1.1.16
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
CHANGED
|
@@ -4629,7 +4629,7 @@ function _instanceof(cls, params = {}) {
|
|
|
4629
4629
|
return inst;
|
|
4630
4630
|
}
|
|
4631
4631
|
//#endregion
|
|
4632
|
-
//#region ../types/dist/sleep-
|
|
4632
|
+
//#region ../types/dist/sleep-BiDFW0E7.mjs
|
|
4633
4633
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4634
4634
|
EventCategory["SystemBoot"] = "system.boot";
|
|
4635
4635
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -5442,6 +5442,100 @@ function createDurableState(deps) {
|
|
|
5442
5442
|
};
|
|
5443
5443
|
}
|
|
5444
5444
|
/**
|
|
5445
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
5446
|
+
*
|
|
5447
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
5448
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
5449
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
5450
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
5451
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
5452
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
5453
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
5454
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
5455
|
+
*
|
|
5456
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
5457
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
5458
|
+
* schema and routes reads/writes through these helpers.
|
|
5459
|
+
*
|
|
5460
|
+
* ## No bare-key fallback — deliberate
|
|
5461
|
+
*
|
|
5462
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
5463
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
5464
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
5465
|
+
* the store is invisible to every node, hub included, so one node's
|
|
5466
|
+
* selection can never leak onto another. (This generalizes the
|
|
5467
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
5468
|
+
* arbitrary set of per-node field keys.)
|
|
5469
|
+
*
|
|
5470
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
5471
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
5472
|
+
*/
|
|
5473
|
+
/**
|
|
5474
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
5475
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
5476
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
5477
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
5478
|
+
*/
|
|
5479
|
+
function normalizeNodeId(raw) {
|
|
5480
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
5481
|
+
const slashIdx = raw.indexOf("/");
|
|
5482
|
+
if (slashIdx < 0) return raw;
|
|
5483
|
+
const bare = raw.slice(0, slashIdx);
|
|
5484
|
+
return bare === "" ? "hub" : bare;
|
|
5485
|
+
}
|
|
5486
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
5487
|
+
function nodeScopedKey(base, nodeId) {
|
|
5488
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
5489
|
+
}
|
|
5490
|
+
/**
|
|
5491
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
5492
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
5493
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
5494
|
+
* schema `default` win on `undefined`.
|
|
5495
|
+
*/
|
|
5496
|
+
function readNodeValue(store, base, nodeId) {
|
|
5497
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
5498
|
+
}
|
|
5499
|
+
/**
|
|
5500
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
5501
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
5502
|
+
* the write path so a save for one node never clobbers another node's value
|
|
5503
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
5504
|
+
* patch is not mutated.
|
|
5505
|
+
*/
|
|
5506
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
5507
|
+
const out = {};
|
|
5508
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
5509
|
+
return out;
|
|
5510
|
+
}
|
|
5511
|
+
/**
|
|
5512
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
5513
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
5514
|
+
* values:
|
|
5515
|
+
*
|
|
5516
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
5517
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
5518
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
5519
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
5520
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
5521
|
+
* left ABSENT so the field's schema `default` wins.
|
|
5522
|
+
*
|
|
5523
|
+
* Returns a new object — the input store is not mutated.
|
|
5524
|
+
*/
|
|
5525
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
5526
|
+
const out = {};
|
|
5527
|
+
for (const [key, value] of Object.entries(store)) {
|
|
5528
|
+
if (key.includes("@")) continue;
|
|
5529
|
+
if (perNodeKeys.has(key)) continue;
|
|
5530
|
+
out[key] = value;
|
|
5531
|
+
}
|
|
5532
|
+
for (const base of perNodeKeys) {
|
|
5533
|
+
const value = readNodeValue(store, base, nodeId);
|
|
5534
|
+
if (value !== void 0) out[base] = value;
|
|
5535
|
+
}
|
|
5536
|
+
return out;
|
|
5537
|
+
}
|
|
5538
|
+
/**
|
|
5445
5539
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5446
5540
|
*
|
|
5447
5541
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -5609,23 +5703,63 @@ var BaseAddon = class {
|
|
|
5609
5703
|
deviceSettingsSchema() {
|
|
5610
5704
|
return null;
|
|
5611
5705
|
}
|
|
5612
|
-
async getGlobalSettings(overlay, cap,
|
|
5706
|
+
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5613
5707
|
const schema = this.globalSettingsSchema(cap);
|
|
5614
5708
|
if (!schema) return { sections: [] };
|
|
5615
|
-
const
|
|
5709
|
+
const projected = await this.resolveGlobalStore(nodeId, cap);
|
|
5616
5710
|
return hydrateSchema(schema, overlay ? {
|
|
5617
|
-
...
|
|
5711
|
+
...projected,
|
|
5618
5712
|
...overlay
|
|
5619
|
-
} :
|
|
5713
|
+
} : projected);
|
|
5620
5714
|
}
|
|
5621
|
-
|
|
5622
|
-
|
|
5715
|
+
/**
|
|
5716
|
+
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5717
|
+
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5718
|
+
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
5719
|
+
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
5720
|
+
* A no-op passthrough when the schema declares no `perNode` field.
|
|
5721
|
+
*
|
|
5722
|
+
* This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
|
|
5723
|
+
* the store for custom option logic (option narrowing, value snapping) to
|
|
5724
|
+
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
5725
|
+
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
5726
|
+
*/
|
|
5727
|
+
async resolveGlobalStore(nodeId, cap) {
|
|
5728
|
+
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
5729
|
+
const keys = this.perNodeKeys(cap);
|
|
5730
|
+
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5731
|
+
return keys.size > 0 ? projectStore(raw, keys, node) : raw;
|
|
5732
|
+
}
|
|
5733
|
+
async updateGlobalSettings(patch, nodeId) {
|
|
5734
|
+
const keys = this.perNodeKeys();
|
|
5735
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5736
|
+
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5737
|
+
const barePatch = patch;
|
|
5738
|
+
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
5739
|
+
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
5740
|
+
if (target !== localNode) return;
|
|
5623
5741
|
await this.resolveConfig();
|
|
5624
5742
|
await this.onConfigChanged();
|
|
5625
5743
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
5626
5744
|
this.maybeAutoRestart(patch, this.globalSettingsSchema());
|
|
5627
5745
|
}
|
|
5628
5746
|
/**
|
|
5747
|
+
* The set of field keys the global settings schema declares `perNode: true`
|
|
5748
|
+
* — derived once per `cap` argument and memoized (schemas are static
|
|
5749
|
+
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
5750
|
+
* settings API behaves exactly like the legacy node-agnostic one.
|
|
5751
|
+
*/
|
|
5752
|
+
_perNodeKeysCache = /* @__PURE__ */ new Map();
|
|
5753
|
+
perNodeKeys(cap) {
|
|
5754
|
+
const cacheKey = cap ?? "";
|
|
5755
|
+
const cached = this._perNodeKeysCache.get(cacheKey);
|
|
5756
|
+
if (cached) return cached;
|
|
5757
|
+
const schema = this.globalSettingsSchema(cap);
|
|
5758
|
+
const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
5759
|
+
this._perNodeKeysCache.set(cacheKey, keys);
|
|
5760
|
+
return keys;
|
|
5761
|
+
}
|
|
5762
|
+
/**
|
|
5629
5763
|
* If any field in `patch` is marked `requiresRestart` in `schema`,
|
|
5630
5764
|
* schedule an addon restart for the next tick. Deferred via
|
|
5631
5765
|
* `setImmediate` so the tRPC mutation that triggered the write has
|
|
@@ -5778,12 +5912,19 @@ var BaseAddon = class {
|
|
|
5778
5912
|
* The merge is shallow: each key in `defaults` is checked against the store.
|
|
5779
5913
|
* Only keys present in defaults are read — the store can contain extra keys
|
|
5780
5914
|
* (e.g. from older versions) without polluting the typed config.
|
|
5915
|
+
*
|
|
5916
|
+
* Keys the global settings schema declares `perNode: true` resolve from
|
|
5917
|
+
* THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
|
|
5918
|
+
* from the bare key — so a per-node field resolves to this node's own
|
|
5919
|
+
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
5781
5920
|
*/
|
|
5782
5921
|
async resolveConfig() {
|
|
5783
5922
|
const stored = await this.readAddonStoreWithRetry();
|
|
5923
|
+
const perNode = this.perNodeKeys();
|
|
5924
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5784
5925
|
const resolved = { ...this.defaults };
|
|
5785
5926
|
for (const key of Object.keys(this.defaults)) {
|
|
5786
|
-
const storedValue = stored[key];
|
|
5927
|
+
const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
|
|
5787
5928
|
if (storedValue !== void 0 && storedValue !== null) {
|
|
5788
5929
|
const defaultType = typeof this.defaults[key];
|
|
5789
5930
|
if (typeof storedValue === defaultType) resolved[key] = storedValue;
|
|
@@ -5867,6 +6008,27 @@ var BaseAddon = class {
|
|
|
5867
6008
|
}
|
|
5868
6009
|
};
|
|
5869
6010
|
/**
|
|
6011
|
+
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
6012
|
+
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
6013
|
+
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6014
|
+
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6015
|
+
*/
|
|
6016
|
+
function collectPerNodeFieldKeys(fields) {
|
|
6017
|
+
const collected = [];
|
|
6018
|
+
for (const field of fields) {
|
|
6019
|
+
if (field.type === "group") {
|
|
6020
|
+
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
6021
|
+
continue;
|
|
6022
|
+
}
|
|
6023
|
+
if (field.type === "sub-tabs") {
|
|
6024
|
+
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
6025
|
+
continue;
|
|
6026
|
+
}
|
|
6027
|
+
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
6028
|
+
}
|
|
6029
|
+
return collected;
|
|
6030
|
+
}
|
|
6031
|
+
/**
|
|
5870
6032
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
5871
6033
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
5872
6034
|
* envelopes pass through; void stays void.
|
|
@@ -6274,6 +6436,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
6274
6436
|
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
6275
6437
|
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
6276
6438
|
DeviceType["Image"] = "image";
|
|
6439
|
+
/** Smart pet feeder — cloud-connected food dispenser with a bowl food
|
|
6440
|
+
* level, battery, desiccant life, feeding state and manual-feed /
|
|
6441
|
+
* call-pet / maintenance actions. Installed with the `pet-feeder` cap;
|
|
6442
|
+
* dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
|
|
6443
|
+
* native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
|
|
6444
|
+
* integrations sharing the same food/desiccant/hopper surface. */
|
|
6445
|
+
DeviceType["PetFeeder"] = "pet-feeder";
|
|
6277
6446
|
return DeviceType;
|
|
6278
6447
|
}({});
|
|
6279
6448
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -7431,6 +7600,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
|
|
|
7431
7600
|
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7432
7601
|
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7433
7602
|
/**
|
|
7603
|
+
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7604
|
+
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
7605
|
+
* failure — both are non-fatal to the host: read paths degrade to "skip link".
|
|
7606
|
+
*/
|
|
7607
|
+
/** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
|
|
7608
|
+
* the failure is anchored to a character (author-facing inline feedback). */
|
|
7609
|
+
var ExpressionParseError = class extends Error {
|
|
7610
|
+
position;
|
|
7611
|
+
constructor(message, position) {
|
|
7612
|
+
super(message);
|
|
7613
|
+
this.name = "ExpressionParseError";
|
|
7614
|
+
this.position = position;
|
|
7615
|
+
}
|
|
7616
|
+
};
|
|
7617
|
+
/** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
|
|
7618
|
+
* result, unknown builtin, step-budget exceeded). */
|
|
7619
|
+
var ExpressionEvalError = class extends Error {
|
|
7620
|
+
constructor(message) {
|
|
7621
|
+
super(message);
|
|
7622
|
+
this.name = "ExpressionEvalError";
|
|
7623
|
+
}
|
|
7624
|
+
};
|
|
7625
|
+
/**
|
|
7626
|
+
* Resource-bound constants for the safe expression engine.
|
|
7627
|
+
*
|
|
7628
|
+
* Every bound is defense-in-depth: the grammar is non-Turing-complete (no
|
|
7629
|
+
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
7630
|
+
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
7631
|
+
* work a single author-supplied expression can request, so a hostile or
|
|
7632
|
+
* accidental pathological string can never spend unbounded CPU/memory.
|
|
7633
|
+
*/
|
|
7634
|
+
/** Max source length (chars) — checked BEFORE tokenizing so a huge string is
|
|
7635
|
+
* rejected without allocation. */
|
|
7636
|
+
var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
|
|
7637
|
+
/** A legal binding / identifier name. */
|
|
7638
|
+
var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7639
|
+
/** Binding names an author may NOT use: `now` is auto-injected; the literal
|
|
7640
|
+
* keywords lex as values, not identifiers, so binding to them is meaningless. */
|
|
7641
|
+
var RESERVED_BINDING_NAMES = new Set([
|
|
7642
|
+
"now",
|
|
7643
|
+
"true",
|
|
7644
|
+
"false",
|
|
7645
|
+
"null"
|
|
7646
|
+
]);
|
|
7647
|
+
/**
|
|
7648
|
+
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
7649
|
+
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
7650
|
+
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
7651
|
+
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
7652
|
+
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
7653
|
+
* is a parse error with a source position, so member access / assignment /
|
|
7654
|
+
* template literals are lexically impossible.
|
|
7655
|
+
*/
|
|
7656
|
+
var KEYWORDS = new Set([
|
|
7657
|
+
"true",
|
|
7658
|
+
"false",
|
|
7659
|
+
"null"
|
|
7660
|
+
]);
|
|
7661
|
+
function isDigit(ch) {
|
|
7662
|
+
return ch >= "0" && ch <= "9";
|
|
7663
|
+
}
|
|
7664
|
+
function isIdentStart(ch) {
|
|
7665
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
7666
|
+
}
|
|
7667
|
+
function isIdentPart(ch) {
|
|
7668
|
+
return isIdentStart(ch) || isDigit(ch);
|
|
7669
|
+
}
|
|
7670
|
+
function isWhitespace(ch) {
|
|
7671
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
7672
|
+
}
|
|
7673
|
+
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
7674
|
+
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
7675
|
+
* string. */
|
|
7676
|
+
function tokenize(source) {
|
|
7677
|
+
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
7678
|
+
const tokens = [];
|
|
7679
|
+
let i = 0;
|
|
7680
|
+
const n = source.length;
|
|
7681
|
+
while (i < n) {
|
|
7682
|
+
const ch = source[i];
|
|
7683
|
+
if (isWhitespace(ch)) {
|
|
7684
|
+
i += 1;
|
|
7685
|
+
continue;
|
|
7686
|
+
}
|
|
7687
|
+
if (isDigit(ch)) {
|
|
7688
|
+
const start = i;
|
|
7689
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7690
|
+
if (i < n && source[i] === ".") {
|
|
7691
|
+
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
7692
|
+
i += 1;
|
|
7693
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7694
|
+
}
|
|
7695
|
+
const text = source.slice(start, i);
|
|
7696
|
+
const value = Number(text);
|
|
7697
|
+
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
7698
|
+
tokens.push({
|
|
7699
|
+
type: "number",
|
|
7700
|
+
value,
|
|
7701
|
+
pos: start
|
|
7702
|
+
});
|
|
7703
|
+
continue;
|
|
7704
|
+
}
|
|
7705
|
+
if (ch === "'" || ch === "\"") {
|
|
7706
|
+
const quote = ch;
|
|
7707
|
+
const start = i;
|
|
7708
|
+
i += 1;
|
|
7709
|
+
let out = "";
|
|
7710
|
+
let closed = false;
|
|
7711
|
+
while (i < n) {
|
|
7712
|
+
const c = source[i];
|
|
7713
|
+
if (c === "\\") {
|
|
7714
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
7715
|
+
if (next === "\\" || next === "'" || next === "\"") {
|
|
7716
|
+
out += next;
|
|
7717
|
+
i += 2;
|
|
7718
|
+
continue;
|
|
7719
|
+
}
|
|
7720
|
+
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
7721
|
+
}
|
|
7722
|
+
if (c === quote) {
|
|
7723
|
+
closed = true;
|
|
7724
|
+
i += 1;
|
|
7725
|
+
break;
|
|
7726
|
+
}
|
|
7727
|
+
out += c;
|
|
7728
|
+
i += 1;
|
|
7729
|
+
}
|
|
7730
|
+
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
7731
|
+
tokens.push({
|
|
7732
|
+
type: "string",
|
|
7733
|
+
value: out,
|
|
7734
|
+
pos: start
|
|
7735
|
+
});
|
|
7736
|
+
continue;
|
|
7737
|
+
}
|
|
7738
|
+
if (isIdentStart(ch)) {
|
|
7739
|
+
const start = i;
|
|
7740
|
+
while (i < n && isIdentPart(source[i])) i += 1;
|
|
7741
|
+
const text = source.slice(start, i);
|
|
7742
|
+
if (KEYWORDS.has(text)) tokens.push({
|
|
7743
|
+
type: "keyword",
|
|
7744
|
+
keyword: keywordOf(text),
|
|
7745
|
+
pos: start
|
|
7746
|
+
});
|
|
7747
|
+
else tokens.push({
|
|
7748
|
+
type: "identifier",
|
|
7749
|
+
name: text,
|
|
7750
|
+
pos: start
|
|
7751
|
+
});
|
|
7752
|
+
continue;
|
|
7753
|
+
}
|
|
7754
|
+
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
7755
|
+
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
7756
|
+
tokens.push({
|
|
7757
|
+
type: "punct",
|
|
7758
|
+
punct: two,
|
|
7759
|
+
pos: i
|
|
7760
|
+
});
|
|
7761
|
+
i += 2;
|
|
7762
|
+
continue;
|
|
7763
|
+
}
|
|
7764
|
+
if (isSinglePunct(ch)) {
|
|
7765
|
+
tokens.push({
|
|
7766
|
+
type: "punct",
|
|
7767
|
+
punct: ch,
|
|
7768
|
+
pos: i
|
|
7769
|
+
});
|
|
7770
|
+
i += 1;
|
|
7771
|
+
continue;
|
|
7772
|
+
}
|
|
7773
|
+
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
7774
|
+
}
|
|
7775
|
+
tokens.push({
|
|
7776
|
+
type: "eof",
|
|
7777
|
+
pos: n
|
|
7778
|
+
});
|
|
7779
|
+
return tokens;
|
|
7780
|
+
}
|
|
7781
|
+
function keywordOf(text) {
|
|
7782
|
+
if (text === "true") return "true";
|
|
7783
|
+
if (text === "false") return "false";
|
|
7784
|
+
return "null";
|
|
7785
|
+
}
|
|
7786
|
+
function isSinglePunct(ch) {
|
|
7787
|
+
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
7788
|
+
}
|
|
7789
|
+
/**
|
|
7790
|
+
* Frozen, null-prototype builtin function table for the expression engine
|
|
7791
|
+
* (spec §4 rule 4). The table is the SOLE surface of callable functions: the
|
|
7792
|
+
* parser rejects any callee not in it, and the evaluator gates each call on an
|
|
7793
|
+
* own-property check against it.
|
|
7794
|
+
*
|
|
7795
|
+
* Because the object has a NULL prototype AND is `Object.freeze`d:
|
|
7796
|
+
* - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
|
|
7797
|
+
* - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
|
|
7798
|
+
* (there is no `Object.prototype` in the chain), so those names are not
|
|
7799
|
+
* callable — they are simply "unknown function" at parse time.
|
|
7800
|
+
*
|
|
7801
|
+
* Every numeric argument is validated as a finite number and every numeric
|
|
7802
|
+
* RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
|
|
7803
|
+
* (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
|
|
7804
|
+
* closed rather than emitting a garbage value.
|
|
7805
|
+
*/
|
|
7806
|
+
function asFiniteNumber(value, name, index) {
|
|
7807
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
7808
|
+
return value;
|
|
7809
|
+
}
|
|
7810
|
+
function asString$1(value, name, index) {
|
|
7811
|
+
if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
|
|
7812
|
+
return value;
|
|
7813
|
+
}
|
|
7814
|
+
function finiteResult(value, name) {
|
|
7815
|
+
if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
|
|
7816
|
+
return value;
|
|
7817
|
+
}
|
|
7818
|
+
function allFiniteNumbers(args, name) {
|
|
7819
|
+
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
7820
|
+
}
|
|
7821
|
+
var INF = Number.POSITIVE_INFINITY;
|
|
7822
|
+
var table = {
|
|
7823
|
+
min: {
|
|
7824
|
+
minArgs: 1,
|
|
7825
|
+
maxArgs: INF,
|
|
7826
|
+
apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
|
|
7827
|
+
},
|
|
7828
|
+
max: {
|
|
7829
|
+
minArgs: 1,
|
|
7830
|
+
maxArgs: INF,
|
|
7831
|
+
apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
|
|
7832
|
+
},
|
|
7833
|
+
abs: {
|
|
7834
|
+
minArgs: 1,
|
|
7835
|
+
maxArgs: 1,
|
|
7836
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
7837
|
+
},
|
|
7838
|
+
floor: {
|
|
7839
|
+
minArgs: 1,
|
|
7840
|
+
maxArgs: 1,
|
|
7841
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
7842
|
+
},
|
|
7843
|
+
ceil: {
|
|
7844
|
+
minArgs: 1,
|
|
7845
|
+
maxArgs: 1,
|
|
7846
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
7847
|
+
},
|
|
7848
|
+
sqrt: {
|
|
7849
|
+
minArgs: 1,
|
|
7850
|
+
maxArgs: 1,
|
|
7851
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
7852
|
+
},
|
|
7853
|
+
round: {
|
|
7854
|
+
minArgs: 1,
|
|
7855
|
+
maxArgs: 2,
|
|
7856
|
+
apply: (args) => {
|
|
7857
|
+
const x = asFiniteNumber(args[0], "round", 0);
|
|
7858
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
7859
|
+
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
7860
|
+
const factor = 10 ** digits;
|
|
7861
|
+
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
7862
|
+
}
|
|
7863
|
+
},
|
|
7864
|
+
pow: {
|
|
7865
|
+
minArgs: 2,
|
|
7866
|
+
maxArgs: 2,
|
|
7867
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
7868
|
+
},
|
|
7869
|
+
clamp: {
|
|
7870
|
+
minArgs: 3,
|
|
7871
|
+
maxArgs: 3,
|
|
7872
|
+
apply: (args) => {
|
|
7873
|
+
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
7874
|
+
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
7875
|
+
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
7876
|
+
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
7877
|
+
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
7878
|
+
}
|
|
7879
|
+
},
|
|
7880
|
+
avg: {
|
|
7881
|
+
minArgs: 1,
|
|
7882
|
+
maxArgs: INF,
|
|
7883
|
+
apply: (args) => {
|
|
7884
|
+
const nums = allFiniteNumbers(args, "avg");
|
|
7885
|
+
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
7886
|
+
}
|
|
7887
|
+
},
|
|
7888
|
+
sum: {
|
|
7889
|
+
minArgs: 1,
|
|
7890
|
+
maxArgs: INF,
|
|
7891
|
+
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
7892
|
+
},
|
|
7893
|
+
coalesce: {
|
|
7894
|
+
minArgs: 1,
|
|
7895
|
+
maxArgs: INF,
|
|
7896
|
+
apply: (args) => {
|
|
7897
|
+
for (const a of args) if (a !== null) return a;
|
|
7898
|
+
return null;
|
|
7899
|
+
}
|
|
7900
|
+
},
|
|
7901
|
+
age: {
|
|
7902
|
+
minArgs: 2,
|
|
7903
|
+
maxArgs: 2,
|
|
7904
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
7905
|
+
},
|
|
7906
|
+
convert: {
|
|
7907
|
+
minArgs: 3,
|
|
7908
|
+
maxArgs: 3,
|
|
7909
|
+
apply: (args, hooks) => {
|
|
7910
|
+
const x = asFiniteNumber(args[0], "convert", 0);
|
|
7911
|
+
const from = asString$1(args[1], "convert", 1).trim();
|
|
7912
|
+
const to = asString$1(args[2], "convert", 2).trim();
|
|
7913
|
+
if (hooks.convert) {
|
|
7914
|
+
const out = hooks.convert(x, from, to);
|
|
7915
|
+
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
7916
|
+
return finiteResult(out, "convert");
|
|
7917
|
+
}
|
|
7918
|
+
if (from === to) return x;
|
|
7919
|
+
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
7920
|
+
}
|
|
7921
|
+
}
|
|
7922
|
+
};
|
|
7923
|
+
Object.freeze(Object.assign(Object.create(null), table));
|
|
7924
|
+
/** The set of valid builtin names — used by the parser to reject unknown
|
|
7925
|
+
* callees at parse time (immediate author feedback). */
|
|
7926
|
+
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
7927
|
+
/**
|
|
7928
|
+
* Pratt (precedence-climbing) parser for the safe expression mini-language.
|
|
7929
|
+
*
|
|
7930
|
+
* Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
|
|
7931
|
+
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
7932
|
+
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
7933
|
+
* string validated against the builtin table at parse time, so an unknown
|
|
7934
|
+
* function is rejected immediately (author feedback) and a persisted expression
|
|
7935
|
+
* that references a since-removed builtin degrades at read.
|
|
7936
|
+
*
|
|
7937
|
+
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
7938
|
+
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
7939
|
+
*/
|
|
7940
|
+
/** Binary/logical operator precedence (higher binds tighter). */
|
|
7941
|
+
var BINARY_PRECEDENCE = {
|
|
7942
|
+
"||": 1,
|
|
7943
|
+
"&&": 2,
|
|
7944
|
+
"==": 3,
|
|
7945
|
+
"!=": 3,
|
|
7946
|
+
"<": 4,
|
|
7947
|
+
"<=": 4,
|
|
7948
|
+
">": 4,
|
|
7949
|
+
">=": 4,
|
|
7950
|
+
"+": 5,
|
|
7951
|
+
"-": 5,
|
|
7952
|
+
"*": 6,
|
|
7953
|
+
"/": 6,
|
|
7954
|
+
"%": 6
|
|
7955
|
+
};
|
|
7956
|
+
function isLogicalOp(op) {
|
|
7957
|
+
return op === "&&" || op === "||";
|
|
7958
|
+
}
|
|
7959
|
+
function isBinaryOp(op) {
|
|
7960
|
+
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
7961
|
+
}
|
|
7962
|
+
var Parser = class {
|
|
7963
|
+
tokens;
|
|
7964
|
+
pos = 0;
|
|
7965
|
+
nodeCount = 0;
|
|
7966
|
+
identifiers = /* @__PURE__ */ new Set();
|
|
7967
|
+
callees = /* @__PURE__ */ new Set();
|
|
7968
|
+
constructor(tokens) {
|
|
7969
|
+
this.tokens = tokens;
|
|
7970
|
+
}
|
|
7971
|
+
parse() {
|
|
7972
|
+
const ast = this.parseTernary();
|
|
7973
|
+
const tok = this.peek();
|
|
7974
|
+
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
7975
|
+
return {
|
|
7976
|
+
ast,
|
|
7977
|
+
identifiers: this.identifiers,
|
|
7978
|
+
callees: this.callees,
|
|
7979
|
+
nodeCount: this.nodeCount
|
|
7980
|
+
};
|
|
7981
|
+
}
|
|
7982
|
+
peek() {
|
|
7983
|
+
return this.tokens[this.pos];
|
|
7984
|
+
}
|
|
7985
|
+
next() {
|
|
7986
|
+
return this.tokens[this.pos++];
|
|
7987
|
+
}
|
|
7988
|
+
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
7989
|
+
expectPunct(punct) {
|
|
7990
|
+
const tok = this.peek();
|
|
7991
|
+
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
7992
|
+
this.pos += 1;
|
|
7993
|
+
}
|
|
7994
|
+
matchPunct(punct) {
|
|
7995
|
+
const tok = this.peek();
|
|
7996
|
+
if (tok.type === "punct" && tok.punct === punct) {
|
|
7997
|
+
this.pos += 1;
|
|
7998
|
+
return true;
|
|
7999
|
+
}
|
|
8000
|
+
return false;
|
|
8001
|
+
}
|
|
8002
|
+
countNode() {
|
|
8003
|
+
this.nodeCount += 1;
|
|
8004
|
+
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
8005
|
+
}
|
|
8006
|
+
parseTernary() {
|
|
8007
|
+
const test = this.parseBinary(1);
|
|
8008
|
+
if (this.matchPunct("?")) {
|
|
8009
|
+
const consequent = this.parseTernary();
|
|
8010
|
+
this.expectPunct(":");
|
|
8011
|
+
const alternate = this.parseTernary();
|
|
8012
|
+
this.countNode();
|
|
8013
|
+
return {
|
|
8014
|
+
kind: "conditional",
|
|
8015
|
+
test,
|
|
8016
|
+
consequent,
|
|
8017
|
+
alternate
|
|
8018
|
+
};
|
|
8019
|
+
}
|
|
8020
|
+
return test;
|
|
8021
|
+
}
|
|
8022
|
+
parseBinary(minPrec) {
|
|
8023
|
+
let left = this.parseUnary();
|
|
8024
|
+
for (;;) {
|
|
8025
|
+
const tok = this.peek();
|
|
8026
|
+
if (tok.type !== "punct") break;
|
|
8027
|
+
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
8028
|
+
if (prec === void 0 || prec < minPrec) break;
|
|
8029
|
+
const op = tok.punct;
|
|
8030
|
+
this.pos += 1;
|
|
8031
|
+
const right = this.parseBinary(prec + 1);
|
|
8032
|
+
this.countNode();
|
|
8033
|
+
if (isLogicalOp(op)) left = {
|
|
8034
|
+
kind: "logical",
|
|
8035
|
+
op,
|
|
8036
|
+
left,
|
|
8037
|
+
right
|
|
8038
|
+
};
|
|
8039
|
+
else if (isBinaryOp(op)) left = {
|
|
8040
|
+
kind: "binary",
|
|
8041
|
+
op,
|
|
8042
|
+
left,
|
|
8043
|
+
right
|
|
8044
|
+
};
|
|
8045
|
+
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
8046
|
+
}
|
|
8047
|
+
return left;
|
|
8048
|
+
}
|
|
8049
|
+
parseUnary() {
|
|
8050
|
+
const tok = this.peek();
|
|
8051
|
+
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
8052
|
+
const op = tok.punct;
|
|
8053
|
+
this.pos += 1;
|
|
8054
|
+
const operand = this.parseUnary();
|
|
8055
|
+
this.countNode();
|
|
8056
|
+
return {
|
|
8057
|
+
kind: "unary",
|
|
8058
|
+
op,
|
|
8059
|
+
operand
|
|
8060
|
+
};
|
|
8061
|
+
}
|
|
8062
|
+
return this.parsePrimary();
|
|
8063
|
+
}
|
|
8064
|
+
parsePrimary() {
|
|
8065
|
+
const tok = this.next();
|
|
8066
|
+
switch (tok.type) {
|
|
8067
|
+
case "number":
|
|
8068
|
+
this.countNode();
|
|
8069
|
+
return {
|
|
8070
|
+
kind: "literal",
|
|
8071
|
+
value: tok.value
|
|
8072
|
+
};
|
|
8073
|
+
case "string":
|
|
8074
|
+
this.countNode();
|
|
8075
|
+
return {
|
|
8076
|
+
kind: "literal",
|
|
8077
|
+
value: tok.value
|
|
8078
|
+
};
|
|
8079
|
+
case "keyword":
|
|
8080
|
+
this.countNode();
|
|
8081
|
+
return {
|
|
8082
|
+
kind: "literal",
|
|
8083
|
+
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
8084
|
+
};
|
|
8085
|
+
case "identifier": {
|
|
8086
|
+
const nextTok = this.peek();
|
|
8087
|
+
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
8088
|
+
this.identifiers.add(tok.name);
|
|
8089
|
+
this.countNode();
|
|
8090
|
+
return {
|
|
8091
|
+
kind: "identifier",
|
|
8092
|
+
name: tok.name
|
|
8093
|
+
};
|
|
8094
|
+
}
|
|
8095
|
+
case "punct":
|
|
8096
|
+
if (tok.punct === "(") {
|
|
8097
|
+
const inner = this.parseTernary();
|
|
8098
|
+
this.expectPunct(")");
|
|
8099
|
+
return inner;
|
|
8100
|
+
}
|
|
8101
|
+
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
8102
|
+
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
8103
|
+
}
|
|
8104
|
+
}
|
|
8105
|
+
parseCall(callee, pos) {
|
|
8106
|
+
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
8107
|
+
this.expectPunct("(");
|
|
8108
|
+
const args = [];
|
|
8109
|
+
if (!this.matchPunct(")")) for (;;) {
|
|
8110
|
+
args.push(this.parseTernary());
|
|
8111
|
+
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
8112
|
+
if (this.matchPunct(",")) continue;
|
|
8113
|
+
this.expectPunct(")");
|
|
8114
|
+
break;
|
|
8115
|
+
}
|
|
8116
|
+
this.callees.add(callee);
|
|
8117
|
+
this.countNode();
|
|
8118
|
+
return {
|
|
8119
|
+
kind: "call",
|
|
8120
|
+
callee,
|
|
8121
|
+
args
|
|
8122
|
+
};
|
|
8123
|
+
}
|
|
8124
|
+
};
|
|
8125
|
+
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
8126
|
+
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
8127
|
+
function parseExpression(source) {
|
|
8128
|
+
return new Parser(tokenize(source)).parse();
|
|
8129
|
+
}
|
|
8130
|
+
Object.freeze({});
|
|
8131
|
+
/**
|
|
8132
|
+
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
8133
|
+
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
8134
|
+
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
8135
|
+
* one per read on a hot resolve path.
|
|
8136
|
+
*
|
|
8137
|
+
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
8138
|
+
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
8139
|
+
* callers is safe and maximises hit rate.
|
|
8140
|
+
*/
|
|
8141
|
+
var cache = /* @__PURE__ */ new Map();
|
|
8142
|
+
function getCached(source) {
|
|
8143
|
+
const hit = cache.get(source);
|
|
8144
|
+
if (hit !== void 0) {
|
|
8145
|
+
cache.delete(source);
|
|
8146
|
+
cache.set(source, hit);
|
|
8147
|
+
return hit;
|
|
8148
|
+
}
|
|
8149
|
+
let result;
|
|
8150
|
+
try {
|
|
8151
|
+
result = {
|
|
8152
|
+
ok: true,
|
|
8153
|
+
parsed: parseExpression(source)
|
|
8154
|
+
};
|
|
8155
|
+
} catch (err) {
|
|
8156
|
+
result = {
|
|
8157
|
+
ok: false,
|
|
8158
|
+
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
8159
|
+
};
|
|
8160
|
+
}
|
|
8161
|
+
cache.set(source, result);
|
|
8162
|
+
if (cache.size > 256) {
|
|
8163
|
+
const oldest = cache.keys().next().value;
|
|
8164
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
8165
|
+
}
|
|
8166
|
+
return result;
|
|
8167
|
+
}
|
|
8168
|
+
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
8169
|
+
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
8170
|
+
function compileExpressionSafe(source) {
|
|
8171
|
+
return getCached(source);
|
|
8172
|
+
}
|
|
8173
|
+
/**
|
|
8174
|
+
* Author-time validation. Returns `null` when the source is valid, else a
|
|
8175
|
+
* human-readable error message. Checks: the expression compiles; binding count
|
|
8176
|
+
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
8177
|
+
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
8178
|
+
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
8179
|
+
*/
|
|
8180
|
+
function validateExpressionSource(src) {
|
|
8181
|
+
const names = Object.keys(src.bindings);
|
|
8182
|
+
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
8183
|
+
for (const name of names) {
|
|
8184
|
+
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
8185
|
+
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
8186
|
+
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
8187
|
+
}
|
|
8188
|
+
const compiled = compileExpressionSafe(src.expr);
|
|
8189
|
+
if (!compiled.ok) return compiled.error;
|
|
8190
|
+
const bound = new Set(names);
|
|
8191
|
+
for (const id of compiled.parsed.identifiers) {
|
|
8192
|
+
if (id === "now") continue;
|
|
8193
|
+
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
8194
|
+
}
|
|
8195
|
+
return null;
|
|
8196
|
+
}
|
|
8197
|
+
/**
|
|
7434
8198
|
* Accessory device helpers — shared across drivers.
|
|
7435
8199
|
*
|
|
7436
8200
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -9333,7 +10097,8 @@ var MotionAnalysisResultSchema = object({
|
|
|
9333
10097
|
});
|
|
9334
10098
|
method(object({
|
|
9335
10099
|
deviceId: number(),
|
|
9336
|
-
frame: FrameInputSchema
|
|
10100
|
+
frame: FrameInputSchema.optional(),
|
|
10101
|
+
frameHandle: FrameHandleSchema.optional()
|
|
9337
10102
|
}), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
|
|
9338
10103
|
deviceId: number(),
|
|
9339
10104
|
detected: boolean(),
|
|
@@ -9580,6 +10345,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
9580
10345
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
9581
10346
|
steps: array(PipelineStepInputSchema).min(1),
|
|
9582
10347
|
frame: FrameInputSchema.optional(),
|
|
10348
|
+
/**
|
|
10349
|
+
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
10350
|
+
* the decoded pixels live in. One more member of the one-of
|
|
10351
|
+
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
10352
|
+
*/
|
|
10353
|
+
frameHandle: FrameHandleSchema.optional(),
|
|
9583
10354
|
imageBase64: string().optional(),
|
|
9584
10355
|
/**
|
|
9585
10356
|
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
@@ -10284,6 +11055,113 @@ object({
|
|
|
10284
11055
|
lastFetchedAt: number()
|
|
10285
11056
|
});
|
|
10286
11057
|
DeviceType.Sensor;
|
|
11058
|
+
/**
|
|
11059
|
+
* Feeder connectivity / power status — mirrors the HA petkit device-status
|
|
11060
|
+
* enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
|
|
11061
|
+
* `on_batteries` (running on battery backup). `null` until first reported.
|
|
11062
|
+
*/
|
|
11063
|
+
var PetFeederDeviceStatusSchema = _enum([
|
|
11064
|
+
"normal",
|
|
11065
|
+
"offline",
|
|
11066
|
+
"on_batteries"
|
|
11067
|
+
]);
|
|
11068
|
+
var gramsPortion = number().int().min(4).max(200);
|
|
11069
|
+
object({
|
|
11070
|
+
/** Food currently in the bowl (grams). Null when the device has not
|
|
11071
|
+
* reported a reading yet. On dual-hopper models this is the combined
|
|
11072
|
+
* bowl reading; per-hopper levels live in `food1`/`food2`. */
|
|
11073
|
+
foodLevel: number().nullable(),
|
|
11074
|
+
/** Hopper-1 food level (grams) on dual-hopper feeders; null on
|
|
11075
|
+
* single-hopper models. */
|
|
11076
|
+
food1: number().nullable(),
|
|
11077
|
+
/** Hopper-2 food level (grams) on dual-hopper feeders; null on
|
|
11078
|
+
* single-hopper models. */
|
|
11079
|
+
food2: number().nullable(),
|
|
11080
|
+
/** Derived low-food flag — mirrors the HA `food_level` binary_sensor
|
|
11081
|
+
* (`device_class: problem`, on = low). True when the bowl is empty /
|
|
11082
|
+
* below the feeder's low threshold. */
|
|
11083
|
+
lowFood: boolean(),
|
|
11084
|
+
/** Battery charge 0..100 (%). Null on mains-powered models or when the
|
|
11085
|
+
* device has no battery reading. */
|
|
11086
|
+
batteryPower: number().min(0).max(100).nullable(),
|
|
11087
|
+
/** Days of desiccant life remaining. Null when the model has no
|
|
11088
|
+
* desiccant sensor. */
|
|
11089
|
+
desiccantLeftDays: number().nullable(),
|
|
11090
|
+
/** True while a feed is in progress. */
|
|
11091
|
+
feeding: boolean(),
|
|
11092
|
+
/** Decoded connectivity / power status (HA petkit device-status enum).
|
|
11093
|
+
* Null until the device has reported a status. */
|
|
11094
|
+
status: PetFeederDeviceStatusSchema.nullable(),
|
|
11095
|
+
/** Decoded human-readable fault message. Null (or the device's `no_error`
|
|
11096
|
+
* sentinel) means healthy; a non-null string is an active fault. Pairs
|
|
11097
|
+
* with `errorCode` for consumers that want the raw integer. */
|
|
11098
|
+
error: string().nullable(),
|
|
11099
|
+
/** Raw device error code (0 / null = no error). */
|
|
11100
|
+
errorCode: number().nullable(),
|
|
11101
|
+
/** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
|
|
11102
|
+
isDualHopper: boolean(),
|
|
11103
|
+
/** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
|
|
11104
|
+
childLock: boolean(),
|
|
11105
|
+
/** Front indicator-light setting. */
|
|
11106
|
+
indicatorLight: boolean(),
|
|
11107
|
+
/** Play a chime when dispensing. */
|
|
11108
|
+
feedSound: boolean(),
|
|
11109
|
+
/** Speaker / prompt volume level (device-scaled integer). */
|
|
11110
|
+
volume: number(),
|
|
11111
|
+
/** Ms epoch when the slice was last refreshed from the cloud. */
|
|
11112
|
+
lastFetchedAt: number()
|
|
11113
|
+
});
|
|
11114
|
+
DeviceType.PetFeeder, method(object({
|
|
11115
|
+
deviceId: number().int().nonnegative(),
|
|
11116
|
+
grams: gramsPortion.optional(),
|
|
11117
|
+
hopper1: gramsPortion.optional(),
|
|
11118
|
+
hopper2: gramsPortion.optional()
|
|
11119
|
+
}), _void(), {
|
|
11120
|
+
kind: "mutation",
|
|
11121
|
+
auth: "admin"
|
|
11122
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11123
|
+
kind: "mutation",
|
|
11124
|
+
auth: "admin"
|
|
11125
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11126
|
+
kind: "mutation",
|
|
11127
|
+
auth: "admin"
|
|
11128
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11129
|
+
kind: "mutation",
|
|
11130
|
+
auth: "admin"
|
|
11131
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11132
|
+
kind: "mutation",
|
|
11133
|
+
auth: "admin"
|
|
11134
|
+
}), method(object({
|
|
11135
|
+
deviceId: number().int().nonnegative(),
|
|
11136
|
+
soundId: number().int().nonnegative()
|
|
11137
|
+
}), _void(), {
|
|
11138
|
+
kind: "mutation",
|
|
11139
|
+
auth: "admin"
|
|
11140
|
+
}), method(object({
|
|
11141
|
+
deviceId: number().int().nonnegative(),
|
|
11142
|
+
on: boolean()
|
|
11143
|
+
}), _void(), {
|
|
11144
|
+
kind: "mutation",
|
|
11145
|
+
auth: "admin"
|
|
11146
|
+
}), method(object({
|
|
11147
|
+
deviceId: number().int().nonnegative(),
|
|
11148
|
+
on: boolean()
|
|
11149
|
+
}), _void(), {
|
|
11150
|
+
kind: "mutation",
|
|
11151
|
+
auth: "admin"
|
|
11152
|
+
}), method(object({
|
|
11153
|
+
deviceId: number().int().nonnegative(),
|
|
11154
|
+
on: boolean()
|
|
11155
|
+
}), _void(), {
|
|
11156
|
+
kind: "mutation",
|
|
11157
|
+
auth: "admin"
|
|
11158
|
+
}), method(object({
|
|
11159
|
+
deviceId: number().int().nonnegative(),
|
|
11160
|
+
level: number().int().nonnegative()
|
|
11161
|
+
}), _void(), {
|
|
11162
|
+
kind: "mutation",
|
|
11163
|
+
auth: "admin"
|
|
11164
|
+
});
|
|
10287
11165
|
object({
|
|
10288
11166
|
/** Instantaneous power draw in watts. */
|
|
10289
11167
|
watts: number().optional(),
|
|
@@ -12111,10 +12989,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
|
|
|
12111
12989
|
url: string()
|
|
12112
12990
|
}), _void()), method(object({
|
|
12113
12991
|
sessionId: string(),
|
|
12114
|
-
maxCount: number().default(1)
|
|
12992
|
+
maxCount: number().default(1),
|
|
12993
|
+
waitMs: number().optional()
|
|
12115
12994
|
}), array(DecodedFrameSchema)), method(object({
|
|
12116
12995
|
sessionId: string(),
|
|
12117
|
-
maxCount: number().default(1)
|
|
12996
|
+
maxCount: number().default(1),
|
|
12997
|
+
waitMs: number().optional()
|
|
12118
12998
|
}), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
|
|
12119
12999
|
sessionId: string(),
|
|
12120
13000
|
config: DecoderSessionConfigSchema.partial()
|
|
@@ -12406,30 +13286,57 @@ var ChildLayoutEntrySchema = object({
|
|
|
12406
13286
|
* LITERAL source carries a per-device constant (no sibling is read); a
|
|
12407
13287
|
* GLOBAL source (P2e) copies ANY device's status field, addressed by the
|
|
12408
13288
|
* source device's full re-sync-stable `stableId`. */
|
|
13289
|
+
var DeviceLinkFieldSourceSchema = object({
|
|
13290
|
+
kind: literal("field").optional(),
|
|
13291
|
+
sourceKey: string(),
|
|
13292
|
+
cap: string(),
|
|
13293
|
+
fieldPath: string()
|
|
13294
|
+
});
|
|
13295
|
+
var DeviceLinkLiteralSourceSchema = object({
|
|
13296
|
+
kind: literal("literal"),
|
|
13297
|
+
value: union([
|
|
13298
|
+
string(),
|
|
13299
|
+
number(),
|
|
13300
|
+
boolean(),
|
|
13301
|
+
_null()
|
|
13302
|
+
])
|
|
13303
|
+
});
|
|
13304
|
+
var DeviceLinkGlobalSourceSchema = object({
|
|
13305
|
+
kind: literal("global"),
|
|
13306
|
+
sourceStableId: string(),
|
|
13307
|
+
cap: string(),
|
|
13308
|
+
fieldPath: string()
|
|
13309
|
+
});
|
|
13310
|
+
/** Expression source (Stage X): compute the target field from N named bindings
|
|
13311
|
+
* via the safe expression engine. Bindings are field | literal | global — never
|
|
13312
|
+
* another expression (no nesting). The `superRefine` runs the SAME author-time
|
|
13313
|
+
* validation as `validateExpressionSource` (compiles the expr, checks binding
|
|
13314
|
+
* names + identifier coverage) so every wire boundary that parses a DeviceLink
|
|
13315
|
+
* (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
|
|
13316
|
+
* Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
|
|
13317
|
+
var DeviceLinkExpressionSourceSchema = object({
|
|
13318
|
+
kind: literal("expression"),
|
|
13319
|
+
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
13320
|
+
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
|
|
13321
|
+
DeviceLinkFieldSourceSchema,
|
|
13322
|
+
DeviceLinkLiteralSourceSchema,
|
|
13323
|
+
DeviceLinkGlobalSourceSchema
|
|
13324
|
+
]))
|
|
13325
|
+
}).superRefine((src, ctx) => {
|
|
13326
|
+
const err = validateExpressionSource(src);
|
|
13327
|
+
if (err !== null) ctx.addIssue({
|
|
13328
|
+
code: "custom",
|
|
13329
|
+
message: err,
|
|
13330
|
+
path: ["expr"]
|
|
13331
|
+
});
|
|
13332
|
+
});
|
|
12409
13333
|
var DeviceLinkSchema = object({
|
|
12410
13334
|
id: string(),
|
|
12411
13335
|
source: union([
|
|
12412
|
-
|
|
12413
|
-
|
|
12414
|
-
|
|
12415
|
-
|
|
12416
|
-
fieldPath: string()
|
|
12417
|
-
}),
|
|
12418
|
-
object({
|
|
12419
|
-
kind: literal("literal"),
|
|
12420
|
-
value: union([
|
|
12421
|
-
string(),
|
|
12422
|
-
number(),
|
|
12423
|
-
boolean(),
|
|
12424
|
-
_null()
|
|
12425
|
-
])
|
|
12426
|
-
}),
|
|
12427
|
-
object({
|
|
12428
|
-
kind: literal("global"),
|
|
12429
|
-
sourceStableId: string(),
|
|
12430
|
-
cap: string(),
|
|
12431
|
-
fieldPath: string()
|
|
12432
|
-
})
|
|
13336
|
+
DeviceLinkFieldSourceSchema,
|
|
13337
|
+
DeviceLinkLiteralSourceSchema,
|
|
13338
|
+
DeviceLinkGlobalSourceSchema,
|
|
13339
|
+
DeviceLinkExpressionSourceSchema
|
|
12433
13340
|
]),
|
|
12434
13341
|
target: object({
|
|
12435
13342
|
cap: string(),
|
|
@@ -12459,6 +13366,31 @@ var DeviceLinkSchema = object({
|
|
|
12459
13366
|
})
|
|
12460
13367
|
]).optional()
|
|
12461
13368
|
});
|
|
13369
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
13370
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
13371
|
+
var DeviceCapDisplayOverrideSchema = object({
|
|
13372
|
+
unit: string().min(1).optional(),
|
|
13373
|
+
precision: number().int().min(0).max(10).optional()
|
|
13374
|
+
});
|
|
13375
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
13376
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
13377
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
13378
|
+
var DeviceDisplayOverrideSchema = object({
|
|
13379
|
+
icon: string().min(1).optional(),
|
|
13380
|
+
label: string().min(1).optional(),
|
|
13381
|
+
unit: string().min(1).optional(),
|
|
13382
|
+
precision: number().int().min(0).max(10).optional(),
|
|
13383
|
+
hidden: boolean().optional(),
|
|
13384
|
+
perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
|
|
13385
|
+
});
|
|
13386
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
13387
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
13388
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
13389
|
+
var RoleDisplayDefaultSchema = object({
|
|
13390
|
+
unit: string().min(1).optional(),
|
|
13391
|
+
precision: number().int().min(0).max(10).optional(),
|
|
13392
|
+
icon: string().min(1).optional()
|
|
13393
|
+
});
|
|
12462
13394
|
/**
|
|
12463
13395
|
* Serializable projection of a live IDevice.
|
|
12464
13396
|
* Returned by listAll, getDevice, getChildren.
|
|
@@ -12514,7 +13446,9 @@ var DeviceInfoSchema = object({
|
|
|
12514
13446
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
12515
13447
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
12516
13448
|
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
12517
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional()
|
|
13449
|
+
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
13450
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
13451
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
12518
13452
|
});
|
|
12519
13453
|
var ConfigEntrySchema = object({
|
|
12520
13454
|
key: string(),
|
|
@@ -12579,7 +13513,9 @@ var DeviceMetaSchema = object({
|
|
|
12579
13513
|
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
12580
13514
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
12581
13515
|
* Optional: only present for accessory children that carry a known role. */
|
|
12582
|
-
role: string().nullable().optional()
|
|
13516
|
+
role: string().nullable().optional(),
|
|
13517
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
13518
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
12583
13519
|
});
|
|
12584
13520
|
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
12585
13521
|
var ConfigUISchemaOutput = unknown().nullable();
|
|
@@ -12673,6 +13609,15 @@ method(object({
|
|
|
12673
13609
|
}), _void(), {
|
|
12674
13610
|
kind: "mutation",
|
|
12675
13611
|
auth: "admin"
|
|
13612
|
+
}), method(object({
|
|
13613
|
+
deviceId: number(),
|
|
13614
|
+
display: DeviceDisplayOverrideSchema.nullable()
|
|
13615
|
+
}), _void(), {
|
|
13616
|
+
kind: "mutation",
|
|
13617
|
+
auth: "admin"
|
|
13618
|
+
}), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
|
|
13619
|
+
kind: "mutation",
|
|
13620
|
+
auth: "admin"
|
|
12676
13621
|
}), method(object({
|
|
12677
13622
|
deviceId: number(),
|
|
12678
13623
|
includeSynthesizable: boolean().optional()
|
|
@@ -14021,7 +14966,10 @@ var AgentLoadSummarySchema = object({
|
|
|
14021
14966
|
online: boolean(),
|
|
14022
14967
|
load: RunnerLocalLoadSchema,
|
|
14023
14968
|
/** Computed score used by the L2 capacity balancer (lower = less loaded). */
|
|
14024
|
-
score: number()
|
|
14969
|
+
score: number(),
|
|
14970
|
+
/** This node's decode hwaccel backend (per-node `probedBestHwaccel`), or null
|
|
14971
|
+
* when not yet probed — for the cluster Pipeline table UI (P0.2). */
|
|
14972
|
+
decodeHwaccel: string().nullable()
|
|
14025
14973
|
});
|
|
14026
14974
|
/**
|
|
14027
14975
|
* Aggregate metrics across the whole detection cluster. Replaces the legacy
|
|
@@ -16539,7 +17487,10 @@ var HwAccelBackendInputSchema = _enum([
|
|
|
16539
17487
|
"webgpu",
|
|
16540
17488
|
"none"
|
|
16541
17489
|
]).nullable().optional();
|
|
16542
|
-
var HwAccelResolutionSchema = object({
|
|
17490
|
+
var HwAccelResolutionSchema = object({
|
|
17491
|
+
preferred: array(string()).readonly(),
|
|
17492
|
+
rationale: string()
|
|
17493
|
+
});
|
|
16543
17494
|
var HardwareEncoderIdSchema = _enum([
|
|
16544
17495
|
"h264_videotoolbox",
|
|
16545
17496
|
"hevc_videotoolbox",
|
|
@@ -16554,7 +17505,7 @@ var HardwareEncoderIdSchema = _enum([
|
|
|
16554
17505
|
"libx264",
|
|
16555
17506
|
"libx265"
|
|
16556
17507
|
]);
|
|
16557
|
-
|
|
17508
|
+
object({
|
|
16558
17509
|
encoders: array(object({
|
|
16559
17510
|
encoder: HardwareEncoderIdSchema,
|
|
16560
17511
|
codec: _enum(["H264", "H265"]),
|
|
@@ -16573,15 +17524,7 @@ var HardwareEncodersSchema = object({
|
|
|
16573
17524
|
defaultH265: HardwareEncoderIdSchema,
|
|
16574
17525
|
probedAt: number()
|
|
16575
17526
|
});
|
|
16576
|
-
|
|
16577
|
-
* Decode-side companion to {@link HardwareEncodersSchema}: the `-hwaccel`
|
|
16578
|
-
* methods the configured ffmpeg binary actually supports (parsed from
|
|
16579
|
-
* `ffmpeg -hwaccels`). Used to gate decode-hwaccel attempts so the transcode
|
|
16580
|
-
* egress never spends a spawn on a backend this build cannot offer. Per-stream
|
|
16581
|
-
* decode fragility (e.g. VideoToolbox HEVC) is still handled by the egress's
|
|
16582
|
-
* software fallback — this only filters out wholly-unsupported backends.
|
|
16583
|
-
*/
|
|
16584
|
-
var HardwareDecodeAccelsSchema = object({
|
|
17527
|
+
object({
|
|
16585
17528
|
methods: array(string()).readonly(),
|
|
16586
17529
|
probedAt: number()
|
|
16587
17530
|
});
|
|
@@ -16644,16 +17587,7 @@ var ResolvedInferenceConfigSchema = object({
|
|
|
16644
17587
|
format: ModelFormatSchema,
|
|
16645
17588
|
reason: string()
|
|
16646
17589
|
});
|
|
16647
|
-
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
|
|
16648
|
-
prefer: HwAccelBackendInputSchema,
|
|
16649
|
-
nodeId: string().optional()
|
|
16650
|
-
}), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
16651
|
-
kind: "mutation",
|
|
16652
|
-
auth: "admin"
|
|
16653
|
-
}), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
|
|
16654
|
-
kind: "mutation",
|
|
16655
|
-
auth: "admin"
|
|
16656
|
-
});
|
|
17590
|
+
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema);
|
|
16657
17591
|
var PtzPresetSchema = object({
|
|
16658
17592
|
id: string(),
|
|
16659
17593
|
name: string()
|
|
@@ -18352,6 +19286,12 @@ Object.freeze({
|
|
|
18352
19286
|
addonId: null,
|
|
18353
19287
|
access: "view"
|
|
18354
19288
|
},
|
|
19289
|
+
"deviceManager.getRoleDisplayDefaults": {
|
|
19290
|
+
capName: "device-manager",
|
|
19291
|
+
capScope: "system",
|
|
19292
|
+
addonId: null,
|
|
19293
|
+
access: "view"
|
|
19294
|
+
},
|
|
18355
19295
|
"deviceManager.getSettingsSchema": {
|
|
18356
19296
|
capName: "device-manager",
|
|
18357
19297
|
capScope: "system",
|
|
@@ -18502,6 +19442,12 @@ Object.freeze({
|
|
|
18502
19442
|
addonId: null,
|
|
18503
19443
|
access: "create"
|
|
18504
19444
|
},
|
|
19445
|
+
"deviceManager.setDisplay": {
|
|
19446
|
+
capName: "device-manager",
|
|
19447
|
+
capScope: "system",
|
|
19448
|
+
addonId: null,
|
|
19449
|
+
access: "create"
|
|
19450
|
+
},
|
|
18505
19451
|
"deviceManager.setIntegrationId": {
|
|
18506
19452
|
capName: "device-manager",
|
|
18507
19453
|
capScope: "system",
|
|
@@ -18544,6 +19490,12 @@ Object.freeze({
|
|
|
18544
19490
|
addonId: null,
|
|
18545
19491
|
access: "create"
|
|
18546
19492
|
},
|
|
19493
|
+
"deviceManager.setRoleDisplayDefaults": {
|
|
19494
|
+
capName: "device-manager",
|
|
19495
|
+
capScope: "system",
|
|
19496
|
+
addonId: null,
|
|
19497
|
+
access: "create"
|
|
19498
|
+
},
|
|
18547
19499
|
"deviceManager.setStreamProfileMap": {
|
|
18548
19500
|
capName: "device-manager",
|
|
18549
19501
|
capScope: "system",
|
|
@@ -19594,6 +20546,66 @@ Object.freeze({
|
|
|
19594
20546
|
addonId: null,
|
|
19595
20547
|
access: "create"
|
|
19596
20548
|
},
|
|
20549
|
+
"petFeeder.callPet": {
|
|
20550
|
+
capName: "pet-feeder",
|
|
20551
|
+
capScope: "device",
|
|
20552
|
+
addonId: null,
|
|
20553
|
+
access: "create"
|
|
20554
|
+
},
|
|
20555
|
+
"petFeeder.cancelFeed": {
|
|
20556
|
+
capName: "pet-feeder",
|
|
20557
|
+
capScope: "device",
|
|
20558
|
+
addonId: null,
|
|
20559
|
+
access: "create"
|
|
20560
|
+
},
|
|
20561
|
+
"petFeeder.feed": {
|
|
20562
|
+
capName: "pet-feeder",
|
|
20563
|
+
capScope: "device",
|
|
20564
|
+
addonId: null,
|
|
20565
|
+
access: "create"
|
|
20566
|
+
},
|
|
20567
|
+
"petFeeder.markFoodReplenished": {
|
|
20568
|
+
capName: "pet-feeder",
|
|
20569
|
+
capScope: "device",
|
|
20570
|
+
addonId: null,
|
|
20571
|
+
access: "create"
|
|
20572
|
+
},
|
|
20573
|
+
"petFeeder.playSound": {
|
|
20574
|
+
capName: "pet-feeder",
|
|
20575
|
+
capScope: "device",
|
|
20576
|
+
addonId: null,
|
|
20577
|
+
access: "create"
|
|
20578
|
+
},
|
|
20579
|
+
"petFeeder.resetDesiccant": {
|
|
20580
|
+
capName: "pet-feeder",
|
|
20581
|
+
capScope: "device",
|
|
20582
|
+
addonId: null,
|
|
20583
|
+
access: "delete"
|
|
20584
|
+
},
|
|
20585
|
+
"petFeeder.setChildLock": {
|
|
20586
|
+
capName: "pet-feeder",
|
|
20587
|
+
capScope: "device",
|
|
20588
|
+
addonId: null,
|
|
20589
|
+
access: "create"
|
|
20590
|
+
},
|
|
20591
|
+
"petFeeder.setFeedSound": {
|
|
20592
|
+
capName: "pet-feeder",
|
|
20593
|
+
capScope: "device",
|
|
20594
|
+
addonId: null,
|
|
20595
|
+
access: "create"
|
|
20596
|
+
},
|
|
20597
|
+
"petFeeder.setIndicatorLight": {
|
|
20598
|
+
capName: "pet-feeder",
|
|
20599
|
+
capScope: "device",
|
|
20600
|
+
addonId: null,
|
|
20601
|
+
access: "create"
|
|
20602
|
+
},
|
|
20603
|
+
"petFeeder.setVolume": {
|
|
20604
|
+
capName: "pet-feeder",
|
|
20605
|
+
capScope: "device",
|
|
20606
|
+
addonId: null,
|
|
20607
|
+
access: "create"
|
|
20608
|
+
},
|
|
19597
20609
|
"pipelineAnalytics.clearTracks": {
|
|
19598
20610
|
capName: "pipeline-analytics",
|
|
19599
20611
|
capScope: "device",
|
|
@@ -20200,30 +21212,6 @@ Object.freeze({
|
|
|
20200
21212
|
addonId: null,
|
|
20201
21213
|
access: "view"
|
|
20202
21214
|
},
|
|
20203
|
-
"platformProbe.getHardwareDecodeAccels": {
|
|
20204
|
-
capName: "platform-probe",
|
|
20205
|
-
capScope: "system",
|
|
20206
|
-
addonId: null,
|
|
20207
|
-
access: "view"
|
|
20208
|
-
},
|
|
20209
|
-
"platformProbe.getHardwareEncoders": {
|
|
20210
|
-
capName: "platform-probe",
|
|
20211
|
-
capScope: "system",
|
|
20212
|
-
addonId: null,
|
|
20213
|
-
access: "view"
|
|
20214
|
-
},
|
|
20215
|
-
"platformProbe.refreshHardwareDecodeAccels": {
|
|
20216
|
-
capName: "platform-probe",
|
|
20217
|
-
capScope: "system",
|
|
20218
|
-
addonId: null,
|
|
20219
|
-
access: "create"
|
|
20220
|
-
},
|
|
20221
|
-
"platformProbe.refreshHardwareEncoders": {
|
|
20222
|
-
capName: "platform-probe",
|
|
20223
|
-
capScope: "system",
|
|
20224
|
-
addonId: null,
|
|
20225
|
-
access: "create"
|
|
20226
|
-
},
|
|
20227
21215
|
"platformProbe.resolveHwAccel": {
|
|
20228
21216
|
capName: "platform-probe",
|
|
20229
21217
|
capScope: "system",
|
|
@@ -21570,7 +22558,7 @@ var AgentUIAddon = class extends BaseAddon {
|
|
|
21570
22558
|
capability: adminUiCapability,
|
|
21571
22559
|
provider: {
|
|
21572
22560
|
getStaticDir: async () => ({ staticDir: path.resolve(__dirname) }),
|
|
21573
|
-
getVersion: async () => ({ version: "1.1.
|
|
22561
|
+
getVersion: async () => ({ version: "1.1.16" })
|
|
21574
22562
|
}
|
|
21575
22563
|
}];
|
|
21576
22564
|
}
|