@camstack/addon-matter-broker 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +1469 -102
- package/dist/addon.mjs +1469 -102
- package/package.json +1 -1
package/dist/addon.mjs
CHANGED
|
@@ -4654,7 +4654,7 @@ function preprocess(fn, schema) {
|
|
|
4654
4654
|
});
|
|
4655
4655
|
}
|
|
4656
4656
|
//#endregion
|
|
4657
|
-
//#region ../types/dist/sleep-
|
|
4657
|
+
//#region ../types/dist/sleep-BiDFW0E7.mjs
|
|
4658
4658
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4659
4659
|
EventCategory["SystemBoot"] = "system.boot";
|
|
4660
4660
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -5467,6 +5467,100 @@ function createDurableState(deps) {
|
|
|
5467
5467
|
};
|
|
5468
5468
|
}
|
|
5469
5469
|
/**
|
|
5470
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
5471
|
+
*
|
|
5472
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
5473
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
5474
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
5475
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
5476
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
5477
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
5478
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
5479
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
5480
|
+
*
|
|
5481
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
5482
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
5483
|
+
* schema and routes reads/writes through these helpers.
|
|
5484
|
+
*
|
|
5485
|
+
* ## No bare-key fallback — deliberate
|
|
5486
|
+
*
|
|
5487
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
5488
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
5489
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
5490
|
+
* the store is invisible to every node, hub included, so one node's
|
|
5491
|
+
* selection can never leak onto another. (This generalizes the
|
|
5492
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
5493
|
+
* arbitrary set of per-node field keys.)
|
|
5494
|
+
*
|
|
5495
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
5496
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
5497
|
+
*/
|
|
5498
|
+
/**
|
|
5499
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
5500
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
5501
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
5502
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
5503
|
+
*/
|
|
5504
|
+
function normalizeNodeId(raw) {
|
|
5505
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
5506
|
+
const slashIdx = raw.indexOf("/");
|
|
5507
|
+
if (slashIdx < 0) return raw;
|
|
5508
|
+
const bare = raw.slice(0, slashIdx);
|
|
5509
|
+
return bare === "" ? "hub" : bare;
|
|
5510
|
+
}
|
|
5511
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
5512
|
+
function nodeScopedKey(base, nodeId) {
|
|
5513
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
5514
|
+
}
|
|
5515
|
+
/**
|
|
5516
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
5517
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
5518
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
5519
|
+
* schema `default` win on `undefined`.
|
|
5520
|
+
*/
|
|
5521
|
+
function readNodeValue(store, base, nodeId) {
|
|
5522
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
5523
|
+
}
|
|
5524
|
+
/**
|
|
5525
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
5526
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
5527
|
+
* the write path so a save for one node never clobbers another node's value
|
|
5528
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
5529
|
+
* patch is not mutated.
|
|
5530
|
+
*/
|
|
5531
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
5532
|
+
const out = {};
|
|
5533
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
5534
|
+
return out;
|
|
5535
|
+
}
|
|
5536
|
+
/**
|
|
5537
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
5538
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
5539
|
+
* values:
|
|
5540
|
+
*
|
|
5541
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
5542
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
5543
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
5544
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
5545
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
5546
|
+
* left ABSENT so the field's schema `default` wins.
|
|
5547
|
+
*
|
|
5548
|
+
* Returns a new object — the input store is not mutated.
|
|
5549
|
+
*/
|
|
5550
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
5551
|
+
const out = {};
|
|
5552
|
+
for (const [key, value] of Object.entries(store)) {
|
|
5553
|
+
if (key.includes("@")) continue;
|
|
5554
|
+
if (perNodeKeys.has(key)) continue;
|
|
5555
|
+
out[key] = value;
|
|
5556
|
+
}
|
|
5557
|
+
for (const base of perNodeKeys) {
|
|
5558
|
+
const value = readNodeValue(store, base, nodeId);
|
|
5559
|
+
if (value !== void 0) out[base] = value;
|
|
5560
|
+
}
|
|
5561
|
+
return out;
|
|
5562
|
+
}
|
|
5563
|
+
/**
|
|
5470
5564
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5471
5565
|
*
|
|
5472
5566
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -5634,23 +5728,63 @@ var BaseAddon = class {
|
|
|
5634
5728
|
deviceSettingsSchema() {
|
|
5635
5729
|
return null;
|
|
5636
5730
|
}
|
|
5637
|
-
async getGlobalSettings(overlay, cap,
|
|
5731
|
+
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5638
5732
|
const schema = this.globalSettingsSchema(cap);
|
|
5639
5733
|
if (!schema) return { sections: [] };
|
|
5640
|
-
const
|
|
5734
|
+
const projected = await this.resolveGlobalStore(nodeId, cap);
|
|
5641
5735
|
return hydrateSchema(schema, overlay ? {
|
|
5642
|
-
...
|
|
5736
|
+
...projected,
|
|
5643
5737
|
...overlay
|
|
5644
|
-
} :
|
|
5738
|
+
} : projected);
|
|
5645
5739
|
}
|
|
5646
|
-
|
|
5647
|
-
|
|
5740
|
+
/**
|
|
5741
|
+
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5742
|
+
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5743
|
+
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
5744
|
+
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
5745
|
+
* A no-op passthrough when the schema declares no `perNode` field.
|
|
5746
|
+
*
|
|
5747
|
+
* This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
|
|
5748
|
+
* the store for custom option logic (option narrowing, value snapping) to
|
|
5749
|
+
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
5750
|
+
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
5751
|
+
*/
|
|
5752
|
+
async resolveGlobalStore(nodeId, cap) {
|
|
5753
|
+
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
5754
|
+
const keys = this.perNodeKeys(cap);
|
|
5755
|
+
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5756
|
+
return keys.size > 0 ? projectStore(raw, keys, node) : raw;
|
|
5757
|
+
}
|
|
5758
|
+
async updateGlobalSettings(patch, nodeId) {
|
|
5759
|
+
const keys = this.perNodeKeys();
|
|
5760
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5761
|
+
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5762
|
+
const barePatch = patch;
|
|
5763
|
+
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
5764
|
+
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
5765
|
+
if (target !== localNode) return;
|
|
5648
5766
|
await this.resolveConfig();
|
|
5649
5767
|
await this.onConfigChanged();
|
|
5650
5768
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
5651
5769
|
this.maybeAutoRestart(patch, this.globalSettingsSchema());
|
|
5652
5770
|
}
|
|
5653
5771
|
/**
|
|
5772
|
+
* The set of field keys the global settings schema declares `perNode: true`
|
|
5773
|
+
* — derived once per `cap` argument and memoized (schemas are static
|
|
5774
|
+
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
5775
|
+
* settings API behaves exactly like the legacy node-agnostic one.
|
|
5776
|
+
*/
|
|
5777
|
+
_perNodeKeysCache = /* @__PURE__ */ new Map();
|
|
5778
|
+
perNodeKeys(cap) {
|
|
5779
|
+
const cacheKey = cap ?? "";
|
|
5780
|
+
const cached = this._perNodeKeysCache.get(cacheKey);
|
|
5781
|
+
if (cached) return cached;
|
|
5782
|
+
const schema = this.globalSettingsSchema(cap);
|
|
5783
|
+
const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
5784
|
+
this._perNodeKeysCache.set(cacheKey, keys);
|
|
5785
|
+
return keys;
|
|
5786
|
+
}
|
|
5787
|
+
/**
|
|
5654
5788
|
* If any field in `patch` is marked `requiresRestart` in `schema`,
|
|
5655
5789
|
* schedule an addon restart for the next tick. Deferred via
|
|
5656
5790
|
* `setImmediate` so the tRPC mutation that triggered the write has
|
|
@@ -5803,12 +5937,19 @@ var BaseAddon = class {
|
|
|
5803
5937
|
* The merge is shallow: each key in `defaults` is checked against the store.
|
|
5804
5938
|
* Only keys present in defaults are read — the store can contain extra keys
|
|
5805
5939
|
* (e.g. from older versions) without polluting the typed config.
|
|
5940
|
+
*
|
|
5941
|
+
* Keys the global settings schema declares `perNode: true` resolve from
|
|
5942
|
+
* THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
|
|
5943
|
+
* from the bare key — so a per-node field resolves to this node's own
|
|
5944
|
+
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
5806
5945
|
*/
|
|
5807
5946
|
async resolveConfig() {
|
|
5808
5947
|
const stored = await this.readAddonStoreWithRetry();
|
|
5948
|
+
const perNode = this.perNodeKeys();
|
|
5949
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5809
5950
|
const resolved = { ...this.defaults };
|
|
5810
5951
|
for (const key of Object.keys(this.defaults)) {
|
|
5811
|
-
const storedValue = stored[key];
|
|
5952
|
+
const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
|
|
5812
5953
|
if (storedValue !== void 0 && storedValue !== null) {
|
|
5813
5954
|
const defaultType = typeof this.defaults[key];
|
|
5814
5955
|
if (typeof storedValue === defaultType) resolved[key] = storedValue;
|
|
@@ -5892,6 +6033,27 @@ var BaseAddon = class {
|
|
|
5892
6033
|
}
|
|
5893
6034
|
};
|
|
5894
6035
|
/**
|
|
6036
|
+
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
6037
|
+
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
6038
|
+
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6039
|
+
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6040
|
+
*/
|
|
6041
|
+
function collectPerNodeFieldKeys(fields) {
|
|
6042
|
+
const collected = [];
|
|
6043
|
+
for (const field of fields) {
|
|
6044
|
+
if (field.type === "group") {
|
|
6045
|
+
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
6046
|
+
continue;
|
|
6047
|
+
}
|
|
6048
|
+
if (field.type === "sub-tabs") {
|
|
6049
|
+
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
6050
|
+
continue;
|
|
6051
|
+
}
|
|
6052
|
+
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
6053
|
+
}
|
|
6054
|
+
return collected;
|
|
6055
|
+
}
|
|
6056
|
+
/**
|
|
5895
6057
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
5896
6058
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
5897
6059
|
* envelopes pass through; void stays void.
|
|
@@ -5916,6 +6078,7 @@ var CamStreamKindSchema = _enum([
|
|
|
5916
6078
|
"pull-rtsp",
|
|
5917
6079
|
"pull-rtmp",
|
|
5918
6080
|
"pull-http",
|
|
6081
|
+
"pull-flv",
|
|
5919
6082
|
"pull-rfc4571",
|
|
5920
6083
|
"push-annexb",
|
|
5921
6084
|
"derived"
|
|
@@ -6298,6 +6461,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
6298
6461
|
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
6299
6462
|
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
6300
6463
|
DeviceType["Image"] = "image";
|
|
6464
|
+
/** Smart pet feeder — cloud-connected food dispenser with a bowl food
|
|
6465
|
+
* level, battery, desiccant life, feeding state and manual-feed /
|
|
6466
|
+
* call-pet / maintenance actions. Installed with the `pet-feeder` cap;
|
|
6467
|
+
* dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
|
|
6468
|
+
* native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
|
|
6469
|
+
* integrations sharing the same food/desiccant/hopper surface. */
|
|
6470
|
+
DeviceType["PetFeeder"] = "pet-feeder";
|
|
6301
6471
|
return DeviceType;
|
|
6302
6472
|
}({});
|
|
6303
6473
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -7462,6 +7632,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
|
|
|
7462
7632
|
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7463
7633
|
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7464
7634
|
/**
|
|
7635
|
+
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7636
|
+
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
7637
|
+
* failure — both are non-fatal to the host: read paths degrade to "skip link".
|
|
7638
|
+
*/
|
|
7639
|
+
/** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
|
|
7640
|
+
* the failure is anchored to a character (author-facing inline feedback). */
|
|
7641
|
+
var ExpressionParseError = class extends Error {
|
|
7642
|
+
position;
|
|
7643
|
+
constructor(message, position) {
|
|
7644
|
+
super(message);
|
|
7645
|
+
this.name = "ExpressionParseError";
|
|
7646
|
+
this.position = position;
|
|
7647
|
+
}
|
|
7648
|
+
};
|
|
7649
|
+
/** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
|
|
7650
|
+
* result, unknown builtin, step-budget exceeded). */
|
|
7651
|
+
var ExpressionEvalError = class extends Error {
|
|
7652
|
+
constructor(message) {
|
|
7653
|
+
super(message);
|
|
7654
|
+
this.name = "ExpressionEvalError";
|
|
7655
|
+
}
|
|
7656
|
+
};
|
|
7657
|
+
/**
|
|
7658
|
+
* Resource-bound constants for the safe expression engine.
|
|
7659
|
+
*
|
|
7660
|
+
* Every bound is defense-in-depth: the grammar is non-Turing-complete (no
|
|
7661
|
+
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
7662
|
+
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
7663
|
+
* work a single author-supplied expression can request, so a hostile or
|
|
7664
|
+
* accidental pathological string can never spend unbounded CPU/memory.
|
|
7665
|
+
*/
|
|
7666
|
+
/** Max source length (chars) — checked BEFORE tokenizing so a huge string is
|
|
7667
|
+
* rejected without allocation. */
|
|
7668
|
+
var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
|
|
7669
|
+
/** A legal binding / identifier name. */
|
|
7670
|
+
var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7671
|
+
/** Binding names an author may NOT use: `now` is auto-injected; the literal
|
|
7672
|
+
* keywords lex as values, not identifiers, so binding to them is meaningless. */
|
|
7673
|
+
var RESERVED_BINDING_NAMES = new Set([
|
|
7674
|
+
"now",
|
|
7675
|
+
"true",
|
|
7676
|
+
"false",
|
|
7677
|
+
"null"
|
|
7678
|
+
]);
|
|
7679
|
+
/**
|
|
7680
|
+
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
7681
|
+
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
7682
|
+
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
7683
|
+
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
7684
|
+
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
7685
|
+
* is a parse error with a source position, so member access / assignment /
|
|
7686
|
+
* template literals are lexically impossible.
|
|
7687
|
+
*/
|
|
7688
|
+
var KEYWORDS = new Set([
|
|
7689
|
+
"true",
|
|
7690
|
+
"false",
|
|
7691
|
+
"null"
|
|
7692
|
+
]);
|
|
7693
|
+
function isDigit(ch) {
|
|
7694
|
+
return ch >= "0" && ch <= "9";
|
|
7695
|
+
}
|
|
7696
|
+
function isIdentStart(ch) {
|
|
7697
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
7698
|
+
}
|
|
7699
|
+
function isIdentPart(ch) {
|
|
7700
|
+
return isIdentStart(ch) || isDigit(ch);
|
|
7701
|
+
}
|
|
7702
|
+
function isWhitespace(ch) {
|
|
7703
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
7704
|
+
}
|
|
7705
|
+
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
7706
|
+
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
7707
|
+
* string. */
|
|
7708
|
+
function tokenize(source) {
|
|
7709
|
+
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
7710
|
+
const tokens = [];
|
|
7711
|
+
let i = 0;
|
|
7712
|
+
const n = source.length;
|
|
7713
|
+
while (i < n) {
|
|
7714
|
+
const ch = source[i];
|
|
7715
|
+
if (isWhitespace(ch)) {
|
|
7716
|
+
i += 1;
|
|
7717
|
+
continue;
|
|
7718
|
+
}
|
|
7719
|
+
if (isDigit(ch)) {
|
|
7720
|
+
const start = i;
|
|
7721
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7722
|
+
if (i < n && source[i] === ".") {
|
|
7723
|
+
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
7724
|
+
i += 1;
|
|
7725
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7726
|
+
}
|
|
7727
|
+
const text = source.slice(start, i);
|
|
7728
|
+
const value = Number(text);
|
|
7729
|
+
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
7730
|
+
tokens.push({
|
|
7731
|
+
type: "number",
|
|
7732
|
+
value,
|
|
7733
|
+
pos: start
|
|
7734
|
+
});
|
|
7735
|
+
continue;
|
|
7736
|
+
}
|
|
7737
|
+
if (ch === "'" || ch === "\"") {
|
|
7738
|
+
const quote = ch;
|
|
7739
|
+
const start = i;
|
|
7740
|
+
i += 1;
|
|
7741
|
+
let out = "";
|
|
7742
|
+
let closed = false;
|
|
7743
|
+
while (i < n) {
|
|
7744
|
+
const c = source[i];
|
|
7745
|
+
if (c === "\\") {
|
|
7746
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
7747
|
+
if (next === "\\" || next === "'" || next === "\"") {
|
|
7748
|
+
out += next;
|
|
7749
|
+
i += 2;
|
|
7750
|
+
continue;
|
|
7751
|
+
}
|
|
7752
|
+
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
7753
|
+
}
|
|
7754
|
+
if (c === quote) {
|
|
7755
|
+
closed = true;
|
|
7756
|
+
i += 1;
|
|
7757
|
+
break;
|
|
7758
|
+
}
|
|
7759
|
+
out += c;
|
|
7760
|
+
i += 1;
|
|
7761
|
+
}
|
|
7762
|
+
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
7763
|
+
tokens.push({
|
|
7764
|
+
type: "string",
|
|
7765
|
+
value: out,
|
|
7766
|
+
pos: start
|
|
7767
|
+
});
|
|
7768
|
+
continue;
|
|
7769
|
+
}
|
|
7770
|
+
if (isIdentStart(ch)) {
|
|
7771
|
+
const start = i;
|
|
7772
|
+
while (i < n && isIdentPart(source[i])) i += 1;
|
|
7773
|
+
const text = source.slice(start, i);
|
|
7774
|
+
if (KEYWORDS.has(text)) tokens.push({
|
|
7775
|
+
type: "keyword",
|
|
7776
|
+
keyword: keywordOf(text),
|
|
7777
|
+
pos: start
|
|
7778
|
+
});
|
|
7779
|
+
else tokens.push({
|
|
7780
|
+
type: "identifier",
|
|
7781
|
+
name: text,
|
|
7782
|
+
pos: start
|
|
7783
|
+
});
|
|
7784
|
+
continue;
|
|
7785
|
+
}
|
|
7786
|
+
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
7787
|
+
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
7788
|
+
tokens.push({
|
|
7789
|
+
type: "punct",
|
|
7790
|
+
punct: two,
|
|
7791
|
+
pos: i
|
|
7792
|
+
});
|
|
7793
|
+
i += 2;
|
|
7794
|
+
continue;
|
|
7795
|
+
}
|
|
7796
|
+
if (isSinglePunct(ch)) {
|
|
7797
|
+
tokens.push({
|
|
7798
|
+
type: "punct",
|
|
7799
|
+
punct: ch,
|
|
7800
|
+
pos: i
|
|
7801
|
+
});
|
|
7802
|
+
i += 1;
|
|
7803
|
+
continue;
|
|
7804
|
+
}
|
|
7805
|
+
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
7806
|
+
}
|
|
7807
|
+
tokens.push({
|
|
7808
|
+
type: "eof",
|
|
7809
|
+
pos: n
|
|
7810
|
+
});
|
|
7811
|
+
return tokens;
|
|
7812
|
+
}
|
|
7813
|
+
function keywordOf(text) {
|
|
7814
|
+
if (text === "true") return "true";
|
|
7815
|
+
if (text === "false") return "false";
|
|
7816
|
+
return "null";
|
|
7817
|
+
}
|
|
7818
|
+
function isSinglePunct(ch) {
|
|
7819
|
+
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
7820
|
+
}
|
|
7821
|
+
/**
|
|
7822
|
+
* Frozen, null-prototype builtin function table for the expression engine
|
|
7823
|
+
* (spec §4 rule 4). The table is the SOLE surface of callable functions: the
|
|
7824
|
+
* parser rejects any callee not in it, and the evaluator gates each call on an
|
|
7825
|
+
* own-property check against it.
|
|
7826
|
+
*
|
|
7827
|
+
* Because the object has a NULL prototype AND is `Object.freeze`d:
|
|
7828
|
+
* - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
|
|
7829
|
+
* - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
|
|
7830
|
+
* (there is no `Object.prototype` in the chain), so those names are not
|
|
7831
|
+
* callable — they are simply "unknown function" at parse time.
|
|
7832
|
+
*
|
|
7833
|
+
* Every numeric argument is validated as a finite number and every numeric
|
|
7834
|
+
* RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
|
|
7835
|
+
* (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
|
|
7836
|
+
* closed rather than emitting a garbage value.
|
|
7837
|
+
*/
|
|
7838
|
+
function asFiniteNumber(value, name, index) {
|
|
7839
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
7840
|
+
return value;
|
|
7841
|
+
}
|
|
7842
|
+
function asString$1(value, name, index) {
|
|
7843
|
+
if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
|
|
7844
|
+
return value;
|
|
7845
|
+
}
|
|
7846
|
+
function finiteResult(value, name) {
|
|
7847
|
+
if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
|
|
7848
|
+
return value;
|
|
7849
|
+
}
|
|
7850
|
+
function allFiniteNumbers(args, name) {
|
|
7851
|
+
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
7852
|
+
}
|
|
7853
|
+
var INF = Number.POSITIVE_INFINITY;
|
|
7854
|
+
var table = {
|
|
7855
|
+
min: {
|
|
7856
|
+
minArgs: 1,
|
|
7857
|
+
maxArgs: INF,
|
|
7858
|
+
apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
|
|
7859
|
+
},
|
|
7860
|
+
max: {
|
|
7861
|
+
minArgs: 1,
|
|
7862
|
+
maxArgs: INF,
|
|
7863
|
+
apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
|
|
7864
|
+
},
|
|
7865
|
+
abs: {
|
|
7866
|
+
minArgs: 1,
|
|
7867
|
+
maxArgs: 1,
|
|
7868
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
7869
|
+
},
|
|
7870
|
+
floor: {
|
|
7871
|
+
minArgs: 1,
|
|
7872
|
+
maxArgs: 1,
|
|
7873
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
7874
|
+
},
|
|
7875
|
+
ceil: {
|
|
7876
|
+
minArgs: 1,
|
|
7877
|
+
maxArgs: 1,
|
|
7878
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
7879
|
+
},
|
|
7880
|
+
sqrt: {
|
|
7881
|
+
minArgs: 1,
|
|
7882
|
+
maxArgs: 1,
|
|
7883
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
7884
|
+
},
|
|
7885
|
+
round: {
|
|
7886
|
+
minArgs: 1,
|
|
7887
|
+
maxArgs: 2,
|
|
7888
|
+
apply: (args) => {
|
|
7889
|
+
const x = asFiniteNumber(args[0], "round", 0);
|
|
7890
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
7891
|
+
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
7892
|
+
const factor = 10 ** digits;
|
|
7893
|
+
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
7894
|
+
}
|
|
7895
|
+
},
|
|
7896
|
+
pow: {
|
|
7897
|
+
minArgs: 2,
|
|
7898
|
+
maxArgs: 2,
|
|
7899
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
7900
|
+
},
|
|
7901
|
+
clamp: {
|
|
7902
|
+
minArgs: 3,
|
|
7903
|
+
maxArgs: 3,
|
|
7904
|
+
apply: (args) => {
|
|
7905
|
+
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
7906
|
+
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
7907
|
+
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
7908
|
+
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
7909
|
+
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
7910
|
+
}
|
|
7911
|
+
},
|
|
7912
|
+
avg: {
|
|
7913
|
+
minArgs: 1,
|
|
7914
|
+
maxArgs: INF,
|
|
7915
|
+
apply: (args) => {
|
|
7916
|
+
const nums = allFiniteNumbers(args, "avg");
|
|
7917
|
+
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
7918
|
+
}
|
|
7919
|
+
},
|
|
7920
|
+
sum: {
|
|
7921
|
+
minArgs: 1,
|
|
7922
|
+
maxArgs: INF,
|
|
7923
|
+
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
7924
|
+
},
|
|
7925
|
+
coalesce: {
|
|
7926
|
+
minArgs: 1,
|
|
7927
|
+
maxArgs: INF,
|
|
7928
|
+
apply: (args) => {
|
|
7929
|
+
for (const a of args) if (a !== null) return a;
|
|
7930
|
+
return null;
|
|
7931
|
+
}
|
|
7932
|
+
},
|
|
7933
|
+
age: {
|
|
7934
|
+
minArgs: 2,
|
|
7935
|
+
maxArgs: 2,
|
|
7936
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
7937
|
+
},
|
|
7938
|
+
convert: {
|
|
7939
|
+
minArgs: 3,
|
|
7940
|
+
maxArgs: 3,
|
|
7941
|
+
apply: (args, hooks) => {
|
|
7942
|
+
const x = asFiniteNumber(args[0], "convert", 0);
|
|
7943
|
+
const from = asString$1(args[1], "convert", 1).trim();
|
|
7944
|
+
const to = asString$1(args[2], "convert", 2).trim();
|
|
7945
|
+
if (hooks.convert) {
|
|
7946
|
+
const out = hooks.convert(x, from, to);
|
|
7947
|
+
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
7948
|
+
return finiteResult(out, "convert");
|
|
7949
|
+
}
|
|
7950
|
+
if (from === to) return x;
|
|
7951
|
+
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
7952
|
+
}
|
|
7953
|
+
}
|
|
7954
|
+
};
|
|
7955
|
+
Object.freeze(Object.assign(Object.create(null), table));
|
|
7956
|
+
/** The set of valid builtin names — used by the parser to reject unknown
|
|
7957
|
+
* callees at parse time (immediate author feedback). */
|
|
7958
|
+
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
7959
|
+
/**
|
|
7960
|
+
* Pratt (precedence-climbing) parser for the safe expression mini-language.
|
|
7961
|
+
*
|
|
7962
|
+
* Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
|
|
7963
|
+
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
7964
|
+
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
7965
|
+
* string validated against the builtin table at parse time, so an unknown
|
|
7966
|
+
* function is rejected immediately (author feedback) and a persisted expression
|
|
7967
|
+
* that references a since-removed builtin degrades at read.
|
|
7968
|
+
*
|
|
7969
|
+
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
7970
|
+
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
7971
|
+
*/
|
|
7972
|
+
/** Binary/logical operator precedence (higher binds tighter). */
|
|
7973
|
+
var BINARY_PRECEDENCE = {
|
|
7974
|
+
"||": 1,
|
|
7975
|
+
"&&": 2,
|
|
7976
|
+
"==": 3,
|
|
7977
|
+
"!=": 3,
|
|
7978
|
+
"<": 4,
|
|
7979
|
+
"<=": 4,
|
|
7980
|
+
">": 4,
|
|
7981
|
+
">=": 4,
|
|
7982
|
+
"+": 5,
|
|
7983
|
+
"-": 5,
|
|
7984
|
+
"*": 6,
|
|
7985
|
+
"/": 6,
|
|
7986
|
+
"%": 6
|
|
7987
|
+
};
|
|
7988
|
+
function isLogicalOp(op) {
|
|
7989
|
+
return op === "&&" || op === "||";
|
|
7990
|
+
}
|
|
7991
|
+
function isBinaryOp(op) {
|
|
7992
|
+
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
7993
|
+
}
|
|
7994
|
+
var Parser$2 = class {
|
|
7995
|
+
tokens;
|
|
7996
|
+
pos = 0;
|
|
7997
|
+
nodeCount = 0;
|
|
7998
|
+
identifiers = /* @__PURE__ */ new Set();
|
|
7999
|
+
callees = /* @__PURE__ */ new Set();
|
|
8000
|
+
constructor(tokens) {
|
|
8001
|
+
this.tokens = tokens;
|
|
8002
|
+
}
|
|
8003
|
+
parse() {
|
|
8004
|
+
const ast = this.parseTernary();
|
|
8005
|
+
const tok = this.peek();
|
|
8006
|
+
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
8007
|
+
return {
|
|
8008
|
+
ast,
|
|
8009
|
+
identifiers: this.identifiers,
|
|
8010
|
+
callees: this.callees,
|
|
8011
|
+
nodeCount: this.nodeCount
|
|
8012
|
+
};
|
|
8013
|
+
}
|
|
8014
|
+
peek() {
|
|
8015
|
+
return this.tokens[this.pos];
|
|
8016
|
+
}
|
|
8017
|
+
next() {
|
|
8018
|
+
return this.tokens[this.pos++];
|
|
8019
|
+
}
|
|
8020
|
+
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
8021
|
+
expectPunct(punct) {
|
|
8022
|
+
const tok = this.peek();
|
|
8023
|
+
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
8024
|
+
this.pos += 1;
|
|
8025
|
+
}
|
|
8026
|
+
matchPunct(punct) {
|
|
8027
|
+
const tok = this.peek();
|
|
8028
|
+
if (tok.type === "punct" && tok.punct === punct) {
|
|
8029
|
+
this.pos += 1;
|
|
8030
|
+
return true;
|
|
8031
|
+
}
|
|
8032
|
+
return false;
|
|
8033
|
+
}
|
|
8034
|
+
countNode() {
|
|
8035
|
+
this.nodeCount += 1;
|
|
8036
|
+
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
8037
|
+
}
|
|
8038
|
+
parseTernary() {
|
|
8039
|
+
const test = this.parseBinary(1);
|
|
8040
|
+
if (this.matchPunct("?")) {
|
|
8041
|
+
const consequent = this.parseTernary();
|
|
8042
|
+
this.expectPunct(":");
|
|
8043
|
+
const alternate = this.parseTernary();
|
|
8044
|
+
this.countNode();
|
|
8045
|
+
return {
|
|
8046
|
+
kind: "conditional",
|
|
8047
|
+
test,
|
|
8048
|
+
consequent,
|
|
8049
|
+
alternate
|
|
8050
|
+
};
|
|
8051
|
+
}
|
|
8052
|
+
return test;
|
|
8053
|
+
}
|
|
8054
|
+
parseBinary(minPrec) {
|
|
8055
|
+
let left = this.parseUnary();
|
|
8056
|
+
for (;;) {
|
|
8057
|
+
const tok = this.peek();
|
|
8058
|
+
if (tok.type !== "punct") break;
|
|
8059
|
+
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
8060
|
+
if (prec === void 0 || prec < minPrec) break;
|
|
8061
|
+
const op = tok.punct;
|
|
8062
|
+
this.pos += 1;
|
|
8063
|
+
const right = this.parseBinary(prec + 1);
|
|
8064
|
+
this.countNode();
|
|
8065
|
+
if (isLogicalOp(op)) left = {
|
|
8066
|
+
kind: "logical",
|
|
8067
|
+
op,
|
|
8068
|
+
left,
|
|
8069
|
+
right
|
|
8070
|
+
};
|
|
8071
|
+
else if (isBinaryOp(op)) left = {
|
|
8072
|
+
kind: "binary",
|
|
8073
|
+
op,
|
|
8074
|
+
left,
|
|
8075
|
+
right
|
|
8076
|
+
};
|
|
8077
|
+
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
8078
|
+
}
|
|
8079
|
+
return left;
|
|
8080
|
+
}
|
|
8081
|
+
parseUnary() {
|
|
8082
|
+
const tok = this.peek();
|
|
8083
|
+
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
8084
|
+
const op = tok.punct;
|
|
8085
|
+
this.pos += 1;
|
|
8086
|
+
const operand = this.parseUnary();
|
|
8087
|
+
this.countNode();
|
|
8088
|
+
return {
|
|
8089
|
+
kind: "unary",
|
|
8090
|
+
op,
|
|
8091
|
+
operand
|
|
8092
|
+
};
|
|
8093
|
+
}
|
|
8094
|
+
return this.parsePrimary();
|
|
8095
|
+
}
|
|
8096
|
+
parsePrimary() {
|
|
8097
|
+
const tok = this.next();
|
|
8098
|
+
switch (tok.type) {
|
|
8099
|
+
case "number":
|
|
8100
|
+
this.countNode();
|
|
8101
|
+
return {
|
|
8102
|
+
kind: "literal",
|
|
8103
|
+
value: tok.value
|
|
8104
|
+
};
|
|
8105
|
+
case "string":
|
|
8106
|
+
this.countNode();
|
|
8107
|
+
return {
|
|
8108
|
+
kind: "literal",
|
|
8109
|
+
value: tok.value
|
|
8110
|
+
};
|
|
8111
|
+
case "keyword":
|
|
8112
|
+
this.countNode();
|
|
8113
|
+
return {
|
|
8114
|
+
kind: "literal",
|
|
8115
|
+
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
8116
|
+
};
|
|
8117
|
+
case "identifier": {
|
|
8118
|
+
const nextTok = this.peek();
|
|
8119
|
+
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
8120
|
+
this.identifiers.add(tok.name);
|
|
8121
|
+
this.countNode();
|
|
8122
|
+
return {
|
|
8123
|
+
kind: "identifier",
|
|
8124
|
+
name: tok.name
|
|
8125
|
+
};
|
|
8126
|
+
}
|
|
8127
|
+
case "punct":
|
|
8128
|
+
if (tok.punct === "(") {
|
|
8129
|
+
const inner = this.parseTernary();
|
|
8130
|
+
this.expectPunct(")");
|
|
8131
|
+
return inner;
|
|
8132
|
+
}
|
|
8133
|
+
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
8134
|
+
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
8135
|
+
}
|
|
8136
|
+
}
|
|
8137
|
+
parseCall(callee, pos) {
|
|
8138
|
+
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
8139
|
+
this.expectPunct("(");
|
|
8140
|
+
const args = [];
|
|
8141
|
+
if (!this.matchPunct(")")) for (;;) {
|
|
8142
|
+
args.push(this.parseTernary());
|
|
8143
|
+
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
8144
|
+
if (this.matchPunct(",")) continue;
|
|
8145
|
+
this.expectPunct(")");
|
|
8146
|
+
break;
|
|
8147
|
+
}
|
|
8148
|
+
this.callees.add(callee);
|
|
8149
|
+
this.countNode();
|
|
8150
|
+
return {
|
|
8151
|
+
kind: "call",
|
|
8152
|
+
callee,
|
|
8153
|
+
args
|
|
8154
|
+
};
|
|
8155
|
+
}
|
|
8156
|
+
};
|
|
8157
|
+
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
8158
|
+
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
8159
|
+
function parseExpression(source) {
|
|
8160
|
+
return new Parser$2(tokenize(source)).parse();
|
|
8161
|
+
}
|
|
8162
|
+
Object.freeze({});
|
|
8163
|
+
/**
|
|
8164
|
+
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
8165
|
+
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
8166
|
+
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
8167
|
+
* one per read on a hot resolve path.
|
|
8168
|
+
*
|
|
8169
|
+
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
8170
|
+
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
8171
|
+
* callers is safe and maximises hit rate.
|
|
8172
|
+
*/
|
|
8173
|
+
var cache$10 = /* @__PURE__ */ new Map();
|
|
8174
|
+
function getCached(source) {
|
|
8175
|
+
const hit = cache$10.get(source);
|
|
8176
|
+
if (hit !== void 0) {
|
|
8177
|
+
cache$10.delete(source);
|
|
8178
|
+
cache$10.set(source, hit);
|
|
8179
|
+
return hit;
|
|
8180
|
+
}
|
|
8181
|
+
let result;
|
|
8182
|
+
try {
|
|
8183
|
+
result = {
|
|
8184
|
+
ok: true,
|
|
8185
|
+
parsed: parseExpression(source)
|
|
8186
|
+
};
|
|
8187
|
+
} catch (err) {
|
|
8188
|
+
result = {
|
|
8189
|
+
ok: false,
|
|
8190
|
+
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
8191
|
+
};
|
|
8192
|
+
}
|
|
8193
|
+
cache$10.set(source, result);
|
|
8194
|
+
if (cache$10.size > 256) {
|
|
8195
|
+
const oldest = cache$10.keys().next().value;
|
|
8196
|
+
if (oldest !== void 0) cache$10.delete(oldest);
|
|
8197
|
+
}
|
|
8198
|
+
return result;
|
|
8199
|
+
}
|
|
8200
|
+
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
8201
|
+
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
8202
|
+
function compileExpressionSafe(source) {
|
|
8203
|
+
return getCached(source);
|
|
8204
|
+
}
|
|
8205
|
+
/**
|
|
8206
|
+
* Author-time validation. Returns `null` when the source is valid, else a
|
|
8207
|
+
* human-readable error message. Checks: the expression compiles; binding count
|
|
8208
|
+
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
8209
|
+
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
8210
|
+
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
8211
|
+
*/
|
|
8212
|
+
function validateExpressionSource(src) {
|
|
8213
|
+
const names = Object.keys(src.bindings);
|
|
8214
|
+
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
8215
|
+
for (const name of names) {
|
|
8216
|
+
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
8217
|
+
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
8218
|
+
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
8219
|
+
}
|
|
8220
|
+
const compiled = compileExpressionSafe(src.expr);
|
|
8221
|
+
if (!compiled.ok) return compiled.error;
|
|
8222
|
+
const bound = new Set(names);
|
|
8223
|
+
for (const id of compiled.parsed.identifiers) {
|
|
8224
|
+
if (id === "now") continue;
|
|
8225
|
+
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
8226
|
+
}
|
|
8227
|
+
return null;
|
|
8228
|
+
}
|
|
8229
|
+
/**
|
|
7465
8230
|
* Accessory device helpers — shared across drivers.
|
|
7466
8231
|
*
|
|
7467
8232
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -8306,7 +9071,13 @@ onStatusChanged: { data: object({
|
|
|
8306
9071
|
}) } },
|
|
8307
9072
|
status: {
|
|
8308
9073
|
schema: BatteryStatusSchema,
|
|
8309
|
-
kind: "push"
|
|
9074
|
+
kind: "push",
|
|
9075
|
+
empty: {
|
|
9076
|
+
percentage: 0,
|
|
9077
|
+
charging: "none",
|
|
9078
|
+
sleeping: false,
|
|
9079
|
+
lastUpdated: 0
|
|
9080
|
+
}
|
|
8310
9081
|
},
|
|
8311
9082
|
/**
|
|
8312
9083
|
* Runtime-state slice — every provider that registers this cap
|
|
@@ -9249,21 +10020,38 @@ var connectivityCapability = {
|
|
|
9249
10020
|
},
|
|
9250
10021
|
runtimeState: ConnectivityStatusSchema
|
|
9251
10022
|
};
|
|
10023
|
+
/**
|
|
10024
|
+
* Generic device-consumables capability — surfaces a device's
|
|
10025
|
+
* maintenance items (vacuum filters/brushes, replaceable cartridges,
|
|
10026
|
+
* descaling cycles, …) with their remaining life and an optional
|
|
10027
|
+
* "Replaced" reset action. Device-agnostic: any provider that knows its
|
|
10028
|
+
* device tracks consumables can register it; the cap declares no
|
|
10029
|
+
* vocabulary of its own — the provider names each item verbatim.
|
|
10030
|
+
*
|
|
10031
|
+
* Like `childLayout`, the cap is INERT until a provider sets items: no
|
|
10032
|
+
* provider populates it by guessing (no HA inference). The UI renders a
|
|
10033
|
+
* "No consumables reported" placeholder when `items` is empty.
|
|
10034
|
+
*/
|
|
10035
|
+
/** A single consumable item. Either a continuous `level` (remaining
|
|
10036
|
+
* life %) or a discrete `status` may be known — both may be null when a
|
|
10037
|
+
* provider only knows the item exists. `level` and `status` are not
|
|
10038
|
+
* mutually exclusive; a provider may report both. */
|
|
10039
|
+
var ConsumableItemSchema = object({
|
|
10040
|
+
/** Stable id, e.g. 'main-brush'. */
|
|
10041
|
+
key: string$2().min(1),
|
|
10042
|
+
/** Display name. */
|
|
10043
|
+
label: string$2().min(1),
|
|
10044
|
+
/** Remaining life % when known (0..100). */
|
|
10045
|
+
level: number().min(0).max(100).nullable(),
|
|
10046
|
+
/** Discrete state when known (binary mode). */
|
|
10047
|
+
status: _enum(["ok", "replace"]).nullable(),
|
|
10048
|
+
/** Ms epoch of the last replace, when known. */
|
|
10049
|
+
lastResetAt: number().nullable(),
|
|
10050
|
+
/** Whether `reset()` is meaningful for this item. */
|
|
10051
|
+
resettable: boolean()
|
|
10052
|
+
});
|
|
9252
10053
|
var ConsumablesStatusSchema = object({
|
|
9253
|
-
items: array(
|
|
9254
|
-
/** Stable id, e.g. 'main-brush'. */
|
|
9255
|
-
key: string$2().min(1),
|
|
9256
|
-
/** Display name. */
|
|
9257
|
-
label: string$2().min(1),
|
|
9258
|
-
/** Remaining life % when known (0..100). */
|
|
9259
|
-
level: number().min(0).max(100).nullable(),
|
|
9260
|
-
/** Discrete state when known (binary mode). */
|
|
9261
|
-
status: _enum(["ok", "replace"]).nullable(),
|
|
9262
|
-
/** Ms epoch of the last replace, when known. */
|
|
9263
|
-
lastResetAt: number().nullable(),
|
|
9264
|
-
/** Whether `reset()` is meaningful for this item. */
|
|
9265
|
-
resettable: boolean()
|
|
9266
|
-
})),
|
|
10054
|
+
items: array(ConsumableItemSchema),
|
|
9267
10055
|
lastChangedAt: number()
|
|
9268
10056
|
});
|
|
9269
10057
|
var consumablesCapability = {
|
|
@@ -9322,7 +10110,25 @@ reset: method(object({
|
|
|
9322
10110
|
}) },
|
|
9323
10111
|
status: {
|
|
9324
10112
|
schema: ConsumablesStatusSchema,
|
|
9325
|
-
kind: "push"
|
|
10113
|
+
kind: "push",
|
|
10114
|
+
empty: {
|
|
10115
|
+
items: [],
|
|
10116
|
+
lastChangedAt: 0
|
|
10117
|
+
},
|
|
10118
|
+
itemArray: {
|
|
10119
|
+
path: "items",
|
|
10120
|
+
keyField: "key",
|
|
10121
|
+
labelField: "label",
|
|
10122
|
+
itemSchema: ConsumableItemSchema,
|
|
10123
|
+
emptyItem: {
|
|
10124
|
+
key: "",
|
|
10125
|
+
label: "",
|
|
10126
|
+
level: null,
|
|
10127
|
+
status: null,
|
|
10128
|
+
lastResetAt: null,
|
|
10129
|
+
resettable: false
|
|
10130
|
+
}
|
|
10131
|
+
}
|
|
9326
10132
|
},
|
|
9327
10133
|
runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() })
|
|
9328
10134
|
};
|
|
@@ -10564,7 +11370,8 @@ var MotionAnalysisResultSchema = object({
|
|
|
10564
11370
|
});
|
|
10565
11371
|
method(object({
|
|
10566
11372
|
deviceId: number(),
|
|
10567
|
-
frame: FrameInputSchema
|
|
11373
|
+
frame: FrameInputSchema.optional(),
|
|
11374
|
+
frameHandle: FrameHandleSchema.optional()
|
|
10568
11375
|
}), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
|
|
10569
11376
|
deviceId: number(),
|
|
10570
11377
|
detected: boolean(),
|
|
@@ -10811,6 +11618,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
10811
11618
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
10812
11619
|
steps: array(PipelineStepInputSchema).min(1),
|
|
10813
11620
|
frame: FrameInputSchema.optional(),
|
|
11621
|
+
/**
|
|
11622
|
+
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
11623
|
+
* the decoded pixels live in. One more member of the one-of
|
|
11624
|
+
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
11625
|
+
*/
|
|
11626
|
+
frameHandle: FrameHandleSchema.optional(),
|
|
10814
11627
|
imageBase64: string$2().optional(),
|
|
10815
11628
|
/**
|
|
10816
11629
|
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
@@ -11053,6 +11866,31 @@ var ReportMotionInputSchema = object({
|
|
|
11053
11866
|
regions: array(MotionRegionSchema).readonly().optional()
|
|
11054
11867
|
});
|
|
11055
11868
|
/**
|
|
11869
|
+
* Where a runner gets a camera's decoded frames (cross-node Phase 2,
|
|
11870
|
+
* restream-owner model — P2c).
|
|
11871
|
+
*
|
|
11872
|
+
* - `local-broker` (DEFAULT): today's path — subscribe to the co-located
|
|
11873
|
+
* stream-broker's shm frame plane. Every pre-P2c attach payload (no
|
|
11874
|
+
* `frameSource` key) parses to this, so the field is additive with zero
|
|
11875
|
+
* behavior change.
|
|
11876
|
+
* - `remote-restream`: the detect node is NOT the camera's source-owner.
|
|
11877
|
+
* The runner acquires the owner's COMPRESSED passthrough restream
|
|
11878
|
+
* (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
|
|
11879
|
+
* double-pull guard) and decodes LOCALLY via a satellite frame plane +
|
|
11880
|
+
* pull-mode decoder session pinned to its own node. The shm ring stays
|
|
11881
|
+
* node-local; only H.264/H.265 packets cross the wire.
|
|
11882
|
+
* `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
|
|
11883
|
+
* when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
|
|
11884
|
+
* dials for the owner's restream.
|
|
11885
|
+
*/
|
|
11886
|
+
var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
|
|
11887
|
+
kind: literal("remote-restream"),
|
|
11888
|
+
/** The camera's source-owner node (slice 1: always the hub). */
|
|
11889
|
+
ownerNodeId: string$2(),
|
|
11890
|
+
/** Operator override for the owner host the runner dials. */
|
|
11891
|
+
hubHostnameOverride: string$2().optional()
|
|
11892
|
+
})]).describe("Per-camera frame-source mode for the runner (P2c)");
|
|
11893
|
+
/**
|
|
11056
11894
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
11057
11895
|
* specific runner instance via `attachCamera`. Carries everything the
|
|
11058
11896
|
* runner needs to subscribe to the local broker and execute inference.
|
|
@@ -11150,7 +11988,15 @@ var RunnerCameraConfigSchema = object({
|
|
|
11150
11988
|
*/
|
|
11151
11989
|
onboardMotionDrivesAnalyzer: boolean().default(true),
|
|
11152
11990
|
occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
|
|
11153
|
-
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
|
|
11991
|
+
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
|
|
11992
|
+
/**
|
|
11993
|
+
* Where this runner gets the camera's decoded frames (P2c). Defaulted so
|
|
11994
|
+
* every existing payload behaves as `local-broker` — the pre-Phase-2 path.
|
|
11995
|
+
* Populated with `remote-restream` by the orchestrator ONLY when the
|
|
11996
|
+
* camera's detect node differs from its source-owner (P2d, gated by the
|
|
11997
|
+
* `remoteSourcingNodes` rollout setting).
|
|
11998
|
+
*/
|
|
11999
|
+
frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
|
|
11154
12000
|
});
|
|
11155
12001
|
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;
|
|
11156
12002
|
/**
|
|
@@ -11714,6 +12560,157 @@ var numericSensorCapability = {
|
|
|
11714
12560
|
runtimeState: NumericSensorStatusSchema
|
|
11715
12561
|
};
|
|
11716
12562
|
/**
|
|
12563
|
+
* Feeder connectivity / power status — mirrors the HA petkit device-status
|
|
12564
|
+
* enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
|
|
12565
|
+
* `on_batteries` (running on battery backup). `null` until first reported.
|
|
12566
|
+
*/
|
|
12567
|
+
var PetFeederDeviceStatusSchema = _enum([
|
|
12568
|
+
"normal",
|
|
12569
|
+
"offline",
|
|
12570
|
+
"on_batteries"
|
|
12571
|
+
]);
|
|
12572
|
+
var gramsPortion = number().int().min(4).max(200);
|
|
12573
|
+
var PetFeederStatusSchema = object({
|
|
12574
|
+
/** Food currently in the bowl (grams). Null when the device has not
|
|
12575
|
+
* reported a reading yet. On dual-hopper models this is the combined
|
|
12576
|
+
* bowl reading; per-hopper levels live in `food1`/`food2`. */
|
|
12577
|
+
foodLevel: number().nullable(),
|
|
12578
|
+
/** Hopper-1 food level (grams) on dual-hopper feeders; null on
|
|
12579
|
+
* single-hopper models. */
|
|
12580
|
+
food1: number().nullable(),
|
|
12581
|
+
/** Hopper-2 food level (grams) on dual-hopper feeders; null on
|
|
12582
|
+
* single-hopper models. */
|
|
12583
|
+
food2: number().nullable(),
|
|
12584
|
+
/** Derived low-food flag — mirrors the HA `food_level` binary_sensor
|
|
12585
|
+
* (`device_class: problem`, on = low). True when the bowl is empty /
|
|
12586
|
+
* below the feeder's low threshold. */
|
|
12587
|
+
lowFood: boolean(),
|
|
12588
|
+
/** Battery charge 0..100 (%). Null on mains-powered models or when the
|
|
12589
|
+
* device has no battery reading. */
|
|
12590
|
+
batteryPower: number().min(0).max(100).nullable(),
|
|
12591
|
+
/** Days of desiccant life remaining. Null when the model has no
|
|
12592
|
+
* desiccant sensor. */
|
|
12593
|
+
desiccantLeftDays: number().nullable(),
|
|
12594
|
+
/** True while a feed is in progress. */
|
|
12595
|
+
feeding: boolean(),
|
|
12596
|
+
/** Decoded connectivity / power status (HA petkit device-status enum).
|
|
12597
|
+
* Null until the device has reported a status. */
|
|
12598
|
+
status: PetFeederDeviceStatusSchema.nullable(),
|
|
12599
|
+
/** Decoded human-readable fault message. Null (or the device's `no_error`
|
|
12600
|
+
* sentinel) means healthy; a non-null string is an active fault. Pairs
|
|
12601
|
+
* with `errorCode` for consumers that want the raw integer. */
|
|
12602
|
+
error: string$2().nullable(),
|
|
12603
|
+
/** Raw device error code (0 / null = no error). */
|
|
12604
|
+
errorCode: number().nullable(),
|
|
12605
|
+
/** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
|
|
12606
|
+
isDualHopper: boolean(),
|
|
12607
|
+
/** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
|
|
12608
|
+
childLock: boolean(),
|
|
12609
|
+
/** Front indicator-light setting. */
|
|
12610
|
+
indicatorLight: boolean(),
|
|
12611
|
+
/** Play a chime when dispensing. */
|
|
12612
|
+
feedSound: boolean(),
|
|
12613
|
+
/** Speaker / prompt volume level (device-scaled integer). */
|
|
12614
|
+
volume: number(),
|
|
12615
|
+
/** Ms epoch when the slice was last refreshed from the cloud. */
|
|
12616
|
+
lastFetchedAt: number()
|
|
12617
|
+
});
|
|
12618
|
+
var petFeederCapability = {
|
|
12619
|
+
name: "pet-feeder",
|
|
12620
|
+
scope: "device",
|
|
12621
|
+
deviceNative: true,
|
|
12622
|
+
mode: "singleton",
|
|
12623
|
+
deviceTypes: [DeviceType.PetFeeder],
|
|
12624
|
+
methods: {
|
|
12625
|
+
/**
|
|
12626
|
+
* Dispense food now. Single-hopper feeders take `grams`; dual-hopper
|
|
12627
|
+
* feeders (D4S/D4SH) accept `hopper1`/`hopper2` to target one or both
|
|
12628
|
+
* hoppers. All portions honour the 4–200 g hardware range. At least
|
|
12629
|
+
* one of the three must be present — the provider rejects an empty
|
|
12630
|
+
* request.
|
|
12631
|
+
*/
|
|
12632
|
+
feed: method(object({
|
|
12633
|
+
deviceId: number().int().nonnegative(),
|
|
12634
|
+
grams: gramsPortion.optional(),
|
|
12635
|
+
hopper1: gramsPortion.optional(),
|
|
12636
|
+
hopper2: gramsPortion.optional()
|
|
12637
|
+
}), _void(), {
|
|
12638
|
+
kind: "mutation",
|
|
12639
|
+
auth: "admin"
|
|
12640
|
+
}),
|
|
12641
|
+
/** Cancel an in-progress manual feed. */
|
|
12642
|
+
cancelFeed: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12643
|
+
kind: "mutation",
|
|
12644
|
+
auth: "admin"
|
|
12645
|
+
}),
|
|
12646
|
+
/** Reset the desiccant "days remaining" counter after replacing it. */
|
|
12647
|
+
resetDesiccant: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12648
|
+
kind: "mutation",
|
|
12649
|
+
auth: "admin"
|
|
12650
|
+
}),
|
|
12651
|
+
/** Mark a hopper as refilled (D4H/D4S/D4SH). */
|
|
12652
|
+
markFoodReplenished: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12653
|
+
kind: "mutation",
|
|
12654
|
+
auth: "admin"
|
|
12655
|
+
}),
|
|
12656
|
+
/** Call the pet with the recorded prompt (D3). */
|
|
12657
|
+
callPet: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12658
|
+
kind: "mutation",
|
|
12659
|
+
auth: "admin"
|
|
12660
|
+
}),
|
|
12661
|
+
/** Play a stored sound by id (D3 / D4H / D4SH). */
|
|
12662
|
+
playSound: method(object({
|
|
12663
|
+
deviceId: number().int().nonnegative(),
|
|
12664
|
+
soundId: number().int().nonnegative()
|
|
12665
|
+
}), _void(), {
|
|
12666
|
+
kind: "mutation",
|
|
12667
|
+
auth: "admin"
|
|
12668
|
+
}),
|
|
12669
|
+
/** Toggle the child-lock (manual-lock) setting. */
|
|
12670
|
+
setChildLock: method(object({
|
|
12671
|
+
deviceId: number().int().nonnegative(),
|
|
12672
|
+
on: boolean()
|
|
12673
|
+
}), _void(), {
|
|
12674
|
+
kind: "mutation",
|
|
12675
|
+
auth: "admin"
|
|
12676
|
+
}),
|
|
12677
|
+
/** Toggle the front indicator light. */
|
|
12678
|
+
setIndicatorLight: method(object({
|
|
12679
|
+
deviceId: number().int().nonnegative(),
|
|
12680
|
+
on: boolean()
|
|
12681
|
+
}), _void(), {
|
|
12682
|
+
kind: "mutation",
|
|
12683
|
+
auth: "admin"
|
|
12684
|
+
}),
|
|
12685
|
+
/** Toggle the dispense chime. */
|
|
12686
|
+
setFeedSound: method(object({
|
|
12687
|
+
deviceId: number().int().nonnegative(),
|
|
12688
|
+
on: boolean()
|
|
12689
|
+
}), _void(), {
|
|
12690
|
+
kind: "mutation",
|
|
12691
|
+
auth: "admin"
|
|
12692
|
+
}),
|
|
12693
|
+
/** Set the speaker / prompt volume level. */
|
|
12694
|
+
setVolume: method(object({
|
|
12695
|
+
deviceId: number().int().nonnegative(),
|
|
12696
|
+
level: number().int().nonnegative()
|
|
12697
|
+
}), _void(), {
|
|
12698
|
+
kind: "mutation",
|
|
12699
|
+
auth: "admin"
|
|
12700
|
+
})
|
|
12701
|
+
},
|
|
12702
|
+
status: {
|
|
12703
|
+
schema: PetFeederStatusSchema,
|
|
12704
|
+
kind: "poll"
|
|
12705
|
+
},
|
|
12706
|
+
/**
|
|
12707
|
+
* Runtime-state slice — mirrored by the kernel. UI feeder cards read
|
|
12708
|
+
* the full slice via `device.state.petFeeder.value` and refresh on
|
|
12709
|
+
* every poll without re-querying the provider.
|
|
12710
|
+
*/
|
|
12711
|
+
runtimeState: PetFeederStatusSchema
|
|
12712
|
+
};
|
|
12713
|
+
/**
|
|
11717
12714
|
* Multi-metric electrical meter. One slice can carry any combination
|
|
11718
12715
|
* of instantaneous power (W), cumulative energy (kWh), voltage (V),
|
|
11719
12716
|
* and current (A) — all fields optional so a single-metric source
|
|
@@ -13016,6 +14013,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
|
|
|
13016
14013
|
nativeObjectDetection: nativeObjectDetectionCapability,
|
|
13017
14014
|
notifier: notifierCapability,
|
|
13018
14015
|
numericSensor: numericSensorCapability,
|
|
14016
|
+
petFeeder: petFeederCapability,
|
|
13019
14017
|
powerMeter: powerMeterCapability,
|
|
13020
14018
|
presence: presenceCapability,
|
|
13021
14019
|
pressureSensor: pressureSensorCapability,
|
|
@@ -14981,10 +15979,12 @@ method(object({ codec: string$2() }), boolean()), method(_void(), object({
|
|
|
14981
15979
|
url: string$2()
|
|
14982
15980
|
}), _void()), method(object({
|
|
14983
15981
|
sessionId: string$2(),
|
|
14984
|
-
maxCount: number().default(1)
|
|
15982
|
+
maxCount: number().default(1),
|
|
15983
|
+
waitMs: number().optional()
|
|
14985
15984
|
}), array(DecodedFrameSchema)), method(object({
|
|
14986
15985
|
sessionId: string$2(),
|
|
14987
|
-
maxCount: number().default(1)
|
|
15986
|
+
maxCount: number().default(1),
|
|
15987
|
+
waitMs: number().optional()
|
|
14988
15988
|
}), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string$2() }), ShmRingStatsSchema.nullable()), method(object({
|
|
14989
15989
|
sessionId: string$2(),
|
|
14990
15990
|
config: DecoderSessionConfigSchema.partial()
|
|
@@ -15288,14 +16288,63 @@ var ChildLayoutEntrySchema = object({
|
|
|
15288
16288
|
collapsed: boolean().optional()
|
|
15289
16289
|
});
|
|
15290
16290
|
/** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
|
|
15291
|
-
* `device-management.ts`.
|
|
16291
|
+
* `device-management.ts`. Source is a union: a FIELD source copies a sibling
|
|
16292
|
+
* accessory's status field (`kind` optional/absent for wire compat); a
|
|
16293
|
+
* LITERAL source carries a per-device constant (no sibling is read); a
|
|
16294
|
+
* GLOBAL source (P2e) copies ANY device's status field, addressed by the
|
|
16295
|
+
* source device's full re-sync-stable `stableId`. */
|
|
16296
|
+
var DeviceLinkFieldSourceSchema = object({
|
|
16297
|
+
kind: literal("field").optional(),
|
|
16298
|
+
sourceKey: string$2(),
|
|
16299
|
+
cap: string$2(),
|
|
16300
|
+
fieldPath: string$2()
|
|
16301
|
+
});
|
|
16302
|
+
var DeviceLinkLiteralSourceSchema = object({
|
|
16303
|
+
kind: literal("literal"),
|
|
16304
|
+
value: union([
|
|
16305
|
+
string$2(),
|
|
16306
|
+
number(),
|
|
16307
|
+
boolean(),
|
|
16308
|
+
_null()
|
|
16309
|
+
])
|
|
16310
|
+
});
|
|
16311
|
+
var DeviceLinkGlobalSourceSchema = object({
|
|
16312
|
+
kind: literal("global"),
|
|
16313
|
+
sourceStableId: string$2(),
|
|
16314
|
+
cap: string$2(),
|
|
16315
|
+
fieldPath: string$2()
|
|
16316
|
+
});
|
|
16317
|
+
/** Expression source (Stage X): compute the target field from N named bindings
|
|
16318
|
+
* via the safe expression engine. Bindings are field | literal | global — never
|
|
16319
|
+
* another expression (no nesting). The `superRefine` runs the SAME author-time
|
|
16320
|
+
* validation as `validateExpressionSource` (compiles the expr, checks binding
|
|
16321
|
+
* names + identifier coverage) so every wire boundary that parses a DeviceLink
|
|
16322
|
+
* (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
|
|
16323
|
+
* Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
|
|
16324
|
+
var DeviceLinkExpressionSourceSchema = object({
|
|
16325
|
+
kind: literal("expression"),
|
|
16326
|
+
expr: string$2().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
16327
|
+
bindings: record(string$2().regex(EXPRESSION_IDENTIFIER_RE), union([
|
|
16328
|
+
DeviceLinkFieldSourceSchema,
|
|
16329
|
+
DeviceLinkLiteralSourceSchema,
|
|
16330
|
+
DeviceLinkGlobalSourceSchema
|
|
16331
|
+
]))
|
|
16332
|
+
}).superRefine((src, ctx) => {
|
|
16333
|
+
const err = validateExpressionSource(src);
|
|
16334
|
+
if (err !== null) ctx.addIssue({
|
|
16335
|
+
code: "custom",
|
|
16336
|
+
message: err,
|
|
16337
|
+
path: ["expr"]
|
|
16338
|
+
});
|
|
16339
|
+
});
|
|
15292
16340
|
var DeviceLinkSchema = object({
|
|
15293
16341
|
id: string$2(),
|
|
15294
|
-
source:
|
|
15295
|
-
|
|
15296
|
-
|
|
15297
|
-
|
|
15298
|
-
|
|
16342
|
+
source: union([
|
|
16343
|
+
DeviceLinkFieldSourceSchema,
|
|
16344
|
+
DeviceLinkLiteralSourceSchema,
|
|
16345
|
+
DeviceLinkGlobalSourceSchema,
|
|
16346
|
+
DeviceLinkExpressionSourceSchema
|
|
16347
|
+
]),
|
|
15299
16348
|
target: object({
|
|
15300
16349
|
cap: string$2(),
|
|
15301
16350
|
fieldPath: string$2(),
|
|
@@ -15324,6 +16373,31 @@ var DeviceLinkSchema = object({
|
|
|
15324
16373
|
})
|
|
15325
16374
|
]).optional()
|
|
15326
16375
|
});
|
|
16376
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
16377
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
16378
|
+
var DeviceCapDisplayOverrideSchema = object({
|
|
16379
|
+
unit: string$2().min(1).optional(),
|
|
16380
|
+
precision: number().int().min(0).max(10).optional()
|
|
16381
|
+
});
|
|
16382
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
16383
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
16384
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
16385
|
+
var DeviceDisplayOverrideSchema = object({
|
|
16386
|
+
icon: string$2().min(1).optional(),
|
|
16387
|
+
label: string$2().min(1).optional(),
|
|
16388
|
+
unit: string$2().min(1).optional(),
|
|
16389
|
+
precision: number().int().min(0).max(10).optional(),
|
|
16390
|
+
hidden: boolean().optional(),
|
|
16391
|
+
perCap: record(string$2(), DeviceCapDisplayOverrideSchema).optional()
|
|
16392
|
+
});
|
|
16393
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
16394
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
16395
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
16396
|
+
var RoleDisplayDefaultSchema = object({
|
|
16397
|
+
unit: string$2().min(1).optional(),
|
|
16398
|
+
precision: number().int().min(0).max(10).optional(),
|
|
16399
|
+
icon: string$2().min(1).optional()
|
|
16400
|
+
});
|
|
15327
16401
|
/**
|
|
15328
16402
|
* Serializable projection of a live IDevice.
|
|
15329
16403
|
* Returned by listAll, getDevice, getChildren.
|
|
@@ -15379,7 +16453,9 @@ var DeviceInfoSchema = object({
|
|
|
15379
16453
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
15380
16454
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
15381
16455
|
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
15382
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional()
|
|
16456
|
+
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
16457
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
16458
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
15383
16459
|
});
|
|
15384
16460
|
var ConfigEntrySchema = object({
|
|
15385
16461
|
key: string$2(),
|
|
@@ -15444,7 +16520,9 @@ var DeviceMetaSchema = object({
|
|
|
15444
16520
|
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
15445
16521
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
15446
16522
|
* Optional: only present for accessory children that carry a known role. */
|
|
15447
|
-
role: string$2().nullable().optional()
|
|
16523
|
+
role: string$2().nullable().optional(),
|
|
16524
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
16525
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
15448
16526
|
});
|
|
15449
16527
|
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
15450
16528
|
var ConfigUISchemaOutput = unknown().nullable();
|
|
@@ -15538,7 +16616,19 @@ method(object({
|
|
|
15538
16616
|
}), _void(), {
|
|
15539
16617
|
kind: "mutation",
|
|
15540
16618
|
auth: "admin"
|
|
15541
|
-
}), method(object({
|
|
16619
|
+
}), method(object({
|
|
16620
|
+
deviceId: number(),
|
|
16621
|
+
display: DeviceDisplayOverrideSchema.nullable()
|
|
16622
|
+
}), _void(), {
|
|
16623
|
+
kind: "mutation",
|
|
16624
|
+
auth: "admin"
|
|
16625
|
+
}), method(object({}), object({ defaults: record(string$2(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string$2(), RoleDisplayDefaultSchema) }), _void(), {
|
|
16626
|
+
kind: "mutation",
|
|
16627
|
+
auth: "admin"
|
|
16628
|
+
}), method(object({
|
|
16629
|
+
deviceId: number(),
|
|
16630
|
+
includeSynthesizable: boolean().optional()
|
|
16631
|
+
}), object({ caps: array(object({
|
|
15542
16632
|
cap: string$2(),
|
|
15543
16633
|
fields: array(object({
|
|
15544
16634
|
path: string$2(),
|
|
@@ -15548,8 +16638,13 @@ method(object({
|
|
|
15548
16638
|
"boolean",
|
|
15549
16639
|
"enum"
|
|
15550
16640
|
]),
|
|
15551
|
-
enumValues: array(string$2()).optional()
|
|
15552
|
-
|
|
16641
|
+
enumValues: array(string$2()).optional(),
|
|
16642
|
+
item: boolean().optional()
|
|
16643
|
+
})).readonly(),
|
|
16644
|
+
itemArray: object({
|
|
16645
|
+
path: string$2(),
|
|
16646
|
+
keyField: string$2()
|
|
16647
|
+
}).optional()
|
|
15553
16648
|
})).readonly() }), { kind: "query" }), method(object({
|
|
15554
16649
|
deviceId: number(),
|
|
15555
16650
|
role: string$2().nullable()
|
|
@@ -15619,7 +16714,11 @@ method(object({
|
|
|
15619
16714
|
deviceId: number(),
|
|
15620
16715
|
entries: array(object({
|
|
15621
16716
|
capName: string$2(),
|
|
15622
|
-
kind: _enum([
|
|
16717
|
+
kind: _enum([
|
|
16718
|
+
"native",
|
|
16719
|
+
"wrapped",
|
|
16720
|
+
"linked"
|
|
16721
|
+
]),
|
|
15623
16722
|
providerAddonId: string$2(),
|
|
15624
16723
|
providerNodeId: string$2(),
|
|
15625
16724
|
nativeAddonId: string$2()
|
|
@@ -15628,7 +16727,11 @@ method(object({
|
|
|
15628
16727
|
deviceId: number(),
|
|
15629
16728
|
entries: array(object({
|
|
15630
16729
|
capName: string$2(),
|
|
15631
|
-
kind: _enum([
|
|
16730
|
+
kind: _enum([
|
|
16731
|
+
"native",
|
|
16732
|
+
"wrapped",
|
|
16733
|
+
"linked"
|
|
16734
|
+
]),
|
|
15632
16735
|
providerAddonId: string$2(),
|
|
15633
16736
|
providerNodeId: string$2(),
|
|
15634
16737
|
nativeAddonId: string$2()
|
|
@@ -16118,7 +17221,7 @@ var AddBrokerInputSchema = object({
|
|
|
16118
17221
|
});
|
|
16119
17222
|
var AddBrokerResultSchema = object({ id: string$2() });
|
|
16120
17223
|
var IdInputSchema = object({ id: string$2() });
|
|
16121
|
-
var TestResultSchema = discriminatedUnion("ok", [object({
|
|
17224
|
+
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
16122
17225
|
ok: literal(true),
|
|
16123
17226
|
latencyMs: number()
|
|
16124
17227
|
}), object({
|
|
@@ -16141,7 +17244,7 @@ var StatusSchema = object({
|
|
|
16141
17244
|
brokerCount: number(),
|
|
16142
17245
|
embeddedRunning: boolean()
|
|
16143
17246
|
});
|
|
16144
|
-
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);
|
|
17247
|
+
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);
|
|
16145
17248
|
var NetworkEndpointSchema = object({
|
|
16146
17249
|
url: string$2(),
|
|
16147
17250
|
hostname: string$2(),
|
|
@@ -16175,23 +17278,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
|
16175
17278
|
sourcePort: number().optional()
|
|
16176
17279
|
});
|
|
16177
17280
|
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
16178
|
-
|
|
16179
|
-
|
|
17281
|
+
/**
|
|
17282
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
17283
|
+
*
|
|
17284
|
+
* Apprise-derived model (see
|
|
17285
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
17286
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
17287
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
17288
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
17289
|
+
* message to what the kind supports — callers never special-case a service.
|
|
17290
|
+
*
|
|
17291
|
+
* DESIGN DECISIONS (locked):
|
|
17292
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
17293
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
17294
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
17295
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
17296
|
+
* alternative would fork the UI per addon and cannot host the
|
|
17297
|
+
* discovery→adopt flow.
|
|
17298
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
17299
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
17300
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
17301
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
17302
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
17303
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
17304
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
17305
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
17306
|
+
* base64 fallback needed.
|
|
17307
|
+
*
|
|
17308
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
17309
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
17310
|
+
* admin "Integrations" page.
|
|
17311
|
+
*/
|
|
17312
|
+
/**
|
|
17313
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
17314
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
17315
|
+
*/
|
|
17316
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
17317
|
+
"image",
|
|
17318
|
+
"video",
|
|
17319
|
+
"gif",
|
|
17320
|
+
"audio",
|
|
17321
|
+
"icon"
|
|
17322
|
+
]);
|
|
17323
|
+
/**
|
|
17324
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
17325
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
17326
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
17327
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
17328
|
+
*/
|
|
17329
|
+
var AttachmentSchema = object({
|
|
17330
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
17331
|
+
url: string$2().optional(),
|
|
17332
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
17333
|
+
mime: string$2().optional(),
|
|
17334
|
+
name: string$2().optional()
|
|
17335
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
17336
|
+
var NotificationFormatSchema = _enum([
|
|
17337
|
+
"text",
|
|
17338
|
+
"markdown",
|
|
17339
|
+
"html"
|
|
17340
|
+
]);
|
|
17341
|
+
/** A single tap-through action button. */
|
|
17342
|
+
var NotificationActionSchema = object({
|
|
17343
|
+
id: string$2(),
|
|
17344
|
+
label: string$2(),
|
|
17345
|
+
url: string$2().optional()
|
|
17346
|
+
});
|
|
17347
|
+
/**
|
|
17348
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
17349
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
17350
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
17351
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
17352
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
17353
|
+
* `priority` for that one target.
|
|
17354
|
+
*/
|
|
17355
|
+
var NotificationSchema = object({
|
|
16180
17356
|
body: string$2(),
|
|
16181
|
-
|
|
17357
|
+
title: string$2().optional(),
|
|
17358
|
+
format: NotificationFormatSchema.default("text"),
|
|
17359
|
+
priority: number().int().min(1).max(5).default(3),
|
|
17360
|
+
level: string$2().optional(),
|
|
17361
|
+
attachments: array(AttachmentSchema).optional(),
|
|
17362
|
+
clickUrl: string$2().optional(),
|
|
17363
|
+
actions: array(NotificationActionSchema).optional(),
|
|
17364
|
+
sound: string$2().optional(),
|
|
17365
|
+
ttl: number().optional(),
|
|
17366
|
+
tag: string$2().optional(),
|
|
16182
17367
|
deviceId: number().optional(),
|
|
16183
17368
|
eventId: string$2().optional(),
|
|
16184
|
-
priority: _enum([
|
|
16185
|
-
"low",
|
|
16186
|
-
"normal",
|
|
16187
|
-
"high",
|
|
16188
|
-
"critical"
|
|
16189
|
-
]).default("normal"),
|
|
16190
17369
|
metadata: record(string$2(), unknown()).optional()
|
|
16191
|
-
})
|
|
17370
|
+
});
|
|
17371
|
+
/** One declared native severity/priority level for a kind. */
|
|
17372
|
+
var TargetKindLevelSchema = object({
|
|
17373
|
+
id: string$2(),
|
|
17374
|
+
label: string$2(),
|
|
17375
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
17376
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
17377
|
+
flags: object({
|
|
17378
|
+
critical: boolean().optional(),
|
|
17379
|
+
silent: boolean().optional(),
|
|
17380
|
+
noPush: boolean().optional()
|
|
17381
|
+
}).optional(),
|
|
17382
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
17383
|
+
requires: array(string$2()).optional(),
|
|
17384
|
+
description: string$2().optional()
|
|
17385
|
+
});
|
|
17386
|
+
/** The full capability block consulted before dispatch. */
|
|
17387
|
+
var TargetKindCapsSchema = object({
|
|
17388
|
+
attachments: object({
|
|
17389
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
17390
|
+
mode: _enum([
|
|
17391
|
+
"url",
|
|
17392
|
+
"bytes",
|
|
17393
|
+
"both"
|
|
17394
|
+
]),
|
|
17395
|
+
max: number().int().nonnegative(),
|
|
17396
|
+
maxBytes: number().int().positive().optional()
|
|
17397
|
+
}),
|
|
17398
|
+
/** Max action buttons (0 = none). */
|
|
17399
|
+
actions: number().int().nonnegative(),
|
|
17400
|
+
levels: array(TargetKindLevelSchema),
|
|
17401
|
+
format: array(NotificationFormatSchema),
|
|
17402
|
+
clickUrl: boolean(),
|
|
17403
|
+
sound: boolean(),
|
|
17404
|
+
ttl: boolean(),
|
|
17405
|
+
bodyMaxLen: number().int().positive()
|
|
17406
|
+
});
|
|
17407
|
+
/**
|
|
17408
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
17409
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
17410
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
17411
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
17412
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
17413
|
+
*/
|
|
17414
|
+
var ConfigSchemaPassthrough = unknown();
|
|
17415
|
+
var TargetKindSchema = object({
|
|
17416
|
+
kind: string$2(),
|
|
17417
|
+
label: string$2(),
|
|
17418
|
+
icon: string$2(),
|
|
17419
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
17420
|
+
addonId: string$2(),
|
|
17421
|
+
configSchema: ConfigSchemaPassthrough,
|
|
17422
|
+
supportsDiscovery: boolean(),
|
|
17423
|
+
caps: TargetKindCapsSchema
|
|
17424
|
+
});
|
|
17425
|
+
/**
|
|
17426
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
17427
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
17428
|
+
* round-trip a stored secret to the UI.
|
|
17429
|
+
*/
|
|
17430
|
+
var TargetSchema = object({
|
|
17431
|
+
id: string$2(),
|
|
17432
|
+
name: string$2(),
|
|
17433
|
+
kind: string$2(),
|
|
17434
|
+
addonId: string$2(),
|
|
17435
|
+
enabled: boolean(),
|
|
17436
|
+
config: record(string$2(), unknown())
|
|
17437
|
+
});
|
|
17438
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
17439
|
+
var DiscoveredTargetSchema = object({
|
|
17440
|
+
kind: string$2(),
|
|
17441
|
+
suggestedName: string$2(),
|
|
17442
|
+
config: record(string$2(), unknown())
|
|
17443
|
+
});
|
|
17444
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
17445
|
+
var RenderedAsSchema = object({
|
|
17446
|
+
level: string$2(),
|
|
17447
|
+
format: NotificationFormatSchema,
|
|
17448
|
+
attachmentsSent: number().int().nonnegative(),
|
|
17449
|
+
actionsSent: number().int().nonnegative(),
|
|
17450
|
+
truncated: boolean(),
|
|
17451
|
+
dropped: array(string$2())
|
|
17452
|
+
});
|
|
17453
|
+
var SendResultSchema = object({
|
|
16192
17454
|
success: boolean(),
|
|
16193
|
-
error: string$2().optional()
|
|
16194
|
-
|
|
17455
|
+
error: string$2().optional(),
|
|
17456
|
+
renderedAs: RenderedAsSchema.optional()
|
|
17457
|
+
});
|
|
17458
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
17459
|
+
var TestResultSchema = SendResultSchema;
|
|
17460
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
|
|
17461
|
+
kind: string$2(),
|
|
17462
|
+
config: record(string$2(), unknown()).optional()
|
|
17463
|
+
}), array(DiscoveredTargetSchema)), method(object({
|
|
17464
|
+
targetId: string$2(),
|
|
17465
|
+
notification: NotificationSchema
|
|
17466
|
+
}), SendResultSchema, { kind: "mutation" }), method(object({
|
|
17467
|
+
targetId: string$2(),
|
|
17468
|
+
sample: NotificationSchema.optional()
|
|
17469
|
+
}), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string$2() }), _void(), { kind: "mutation" }), method(object({
|
|
17470
|
+
targetId: string$2(),
|
|
17471
|
+
enabled: boolean()
|
|
17472
|
+
}), _void(), { kind: "mutation" });
|
|
16195
17473
|
/**
|
|
16196
17474
|
* Zod schemas for persisted record types.
|
|
16197
17475
|
*
|
|
@@ -16695,7 +17973,10 @@ var AgentLoadSummarySchema = object({
|
|
|
16695
17973
|
online: boolean(),
|
|
16696
17974
|
load: RunnerLocalLoadSchema,
|
|
16697
17975
|
/** Computed score used by the L2 capacity balancer (lower = less loaded). */
|
|
16698
|
-
score: number()
|
|
17976
|
+
score: number(),
|
|
17977
|
+
/** This node's decode hwaccel backend (per-node `probedBestHwaccel`), or null
|
|
17978
|
+
* when not yet probed — for the cluster Pipeline table UI (P0.2). */
|
|
17979
|
+
decodeHwaccel: string$2().nullable()
|
|
16699
17980
|
});
|
|
16700
17981
|
/**
|
|
16701
17982
|
* Aggregate metrics across the whole detection cluster. Replaces the legacy
|
|
@@ -19230,7 +20511,10 @@ var HwAccelBackendInputSchema = _enum([
|
|
|
19230
20511
|
"webgpu",
|
|
19231
20512
|
"none"
|
|
19232
20513
|
]).nullable().optional();
|
|
19233
|
-
var HwAccelResolutionSchema = object({
|
|
20514
|
+
var HwAccelResolutionSchema = object({
|
|
20515
|
+
preferred: array(string$2()).readonly(),
|
|
20516
|
+
rationale: string$2()
|
|
20517
|
+
});
|
|
19234
20518
|
var HardwareEncoderIdSchema = _enum([
|
|
19235
20519
|
"h264_videotoolbox",
|
|
19236
20520
|
"hevc_videotoolbox",
|
|
@@ -19245,7 +20529,7 @@ var HardwareEncoderIdSchema = _enum([
|
|
|
19245
20529
|
"libx264",
|
|
19246
20530
|
"libx265"
|
|
19247
20531
|
]);
|
|
19248
|
-
|
|
20532
|
+
object({
|
|
19249
20533
|
encoders: array(object({
|
|
19250
20534
|
encoder: HardwareEncoderIdSchema,
|
|
19251
20535
|
codec: _enum(["H264", "H265"]),
|
|
@@ -19264,15 +20548,7 @@ var HardwareEncodersSchema = object({
|
|
|
19264
20548
|
defaultH265: HardwareEncoderIdSchema,
|
|
19265
20549
|
probedAt: number()
|
|
19266
20550
|
});
|
|
19267
|
-
|
|
19268
|
-
* Decode-side companion to {@link HardwareEncodersSchema}: the `-hwaccel`
|
|
19269
|
-
* methods the configured ffmpeg binary actually supports (parsed from
|
|
19270
|
-
* `ffmpeg -hwaccels`). Used to gate decode-hwaccel attempts so the transcode
|
|
19271
|
-
* egress never spends a spawn on a backend this build cannot offer. Per-stream
|
|
19272
|
-
* decode fragility (e.g. VideoToolbox HEVC) is still handled by the egress's
|
|
19273
|
-
* software fallback — this only filters out wholly-unsupported backends.
|
|
19274
|
-
*/
|
|
19275
|
-
var HardwareDecodeAccelsSchema = object({
|
|
20551
|
+
object({
|
|
19276
20552
|
methods: array(string$2()).readonly(),
|
|
19277
20553
|
probedAt: number()
|
|
19278
20554
|
});
|
|
@@ -19335,16 +20611,7 @@ var ResolvedInferenceConfigSchema = object({
|
|
|
19335
20611
|
format: ModelFormatSchema,
|
|
19336
20612
|
reason: string$2()
|
|
19337
20613
|
});
|
|
19338
|
-
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
|
|
19339
|
-
prefer: HwAccelBackendInputSchema,
|
|
19340
|
-
nodeId: string$2().optional()
|
|
19341
|
-
}), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
19342
|
-
kind: "mutation",
|
|
19343
|
-
auth: "admin"
|
|
19344
|
-
}), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
|
|
19345
|
-
kind: "mutation",
|
|
19346
|
-
auth: "admin"
|
|
19347
|
-
});
|
|
20614
|
+
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema);
|
|
19348
20615
|
var PtzPresetSchema = object({
|
|
19349
20616
|
id: string$2(),
|
|
19350
20617
|
name: string$2()
|
|
@@ -19397,6 +20664,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
|
|
|
19397
20664
|
kind: "mutation",
|
|
19398
20665
|
auth: "admin"
|
|
19399
20666
|
});
|
|
20667
|
+
/**
|
|
20668
|
+
* `recording` cap — footage availability + HLS playback manifests + per-device
|
|
20669
|
+
* recording config. NOTE on events (source of truth, R5/C3): this cap carries
|
|
20670
|
+
* NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
|
|
20671
|
+
* events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
|
|
20672
|
+
* rows); the recorder's internal EventMap markers are ephemeral in-RAM
|
|
20673
|
+
* annotations that are not exposed here and must not be treated as an event
|
|
20674
|
+
* feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
|
|
20675
|
+
* (`interfaces/recording-config.ts`).
|
|
20676
|
+
*/
|
|
19400
20677
|
var RecordingStatusSchema = object({
|
|
19401
20678
|
deviceId: number(),
|
|
19402
20679
|
enabled: boolean(),
|
|
@@ -21033,6 +22310,12 @@ Object.freeze({
|
|
|
21033
22310
|
addonId: null,
|
|
21034
22311
|
access: "view"
|
|
21035
22312
|
},
|
|
22313
|
+
"deviceManager.getRoleDisplayDefaults": {
|
|
22314
|
+
capName: "device-manager",
|
|
22315
|
+
capScope: "system",
|
|
22316
|
+
addonId: null,
|
|
22317
|
+
access: "view"
|
|
22318
|
+
},
|
|
21036
22319
|
"deviceManager.getSettingsSchema": {
|
|
21037
22320
|
capName: "device-manager",
|
|
21038
22321
|
capScope: "system",
|
|
@@ -21183,6 +22466,12 @@ Object.freeze({
|
|
|
21183
22466
|
addonId: null,
|
|
21184
22467
|
access: "create"
|
|
21185
22468
|
},
|
|
22469
|
+
"deviceManager.setDisplay": {
|
|
22470
|
+
capName: "device-manager",
|
|
22471
|
+
capScope: "system",
|
|
22472
|
+
addonId: null,
|
|
22473
|
+
access: "create"
|
|
22474
|
+
},
|
|
21186
22475
|
"deviceManager.setIntegrationId": {
|
|
21187
22476
|
capName: "device-manager",
|
|
21188
22477
|
capScope: "system",
|
|
@@ -21225,6 +22514,12 @@ Object.freeze({
|
|
|
21225
22514
|
addonId: null,
|
|
21226
22515
|
access: "create"
|
|
21227
22516
|
},
|
|
22517
|
+
"deviceManager.setRoleDisplayDefaults": {
|
|
22518
|
+
capName: "device-manager",
|
|
22519
|
+
capScope: "system",
|
|
22520
|
+
addonId: null,
|
|
22521
|
+
access: "create"
|
|
22522
|
+
},
|
|
21228
22523
|
"deviceManager.setStreamProfileMap": {
|
|
21229
22524
|
capName: "device-manager",
|
|
21230
22525
|
capScope: "system",
|
|
@@ -22203,13 +23498,49 @@ Object.freeze({
|
|
|
22203
23498
|
addonId: null,
|
|
22204
23499
|
access: "create"
|
|
22205
23500
|
},
|
|
23501
|
+
"notificationOutput.deleteTarget": {
|
|
23502
|
+
capName: "notification-output",
|
|
23503
|
+
capScope: "system",
|
|
23504
|
+
addonId: null,
|
|
23505
|
+
access: "delete"
|
|
23506
|
+
},
|
|
23507
|
+
"notificationOutput.discoverTargets": {
|
|
23508
|
+
capName: "notification-output",
|
|
23509
|
+
capScope: "system",
|
|
23510
|
+
addonId: null,
|
|
23511
|
+
access: "view"
|
|
23512
|
+
},
|
|
23513
|
+
"notificationOutput.listTargetKinds": {
|
|
23514
|
+
capName: "notification-output",
|
|
23515
|
+
capScope: "system",
|
|
23516
|
+
addonId: null,
|
|
23517
|
+
access: "view"
|
|
23518
|
+
},
|
|
23519
|
+
"notificationOutput.listTargets": {
|
|
23520
|
+
capName: "notification-output",
|
|
23521
|
+
capScope: "system",
|
|
23522
|
+
addonId: null,
|
|
23523
|
+
access: "view"
|
|
23524
|
+
},
|
|
22206
23525
|
"notificationOutput.send": {
|
|
22207
23526
|
capName: "notification-output",
|
|
22208
23527
|
capScope: "system",
|
|
22209
23528
|
addonId: null,
|
|
22210
23529
|
access: "create"
|
|
22211
23530
|
},
|
|
22212
|
-
"notificationOutput.
|
|
23531
|
+
"notificationOutput.setTargetEnabled": {
|
|
23532
|
+
capName: "notification-output",
|
|
23533
|
+
capScope: "system",
|
|
23534
|
+
addonId: null,
|
|
23535
|
+
access: "create"
|
|
23536
|
+
},
|
|
23537
|
+
"notificationOutput.testTarget": {
|
|
23538
|
+
capName: "notification-output",
|
|
23539
|
+
capScope: "system",
|
|
23540
|
+
addonId: null,
|
|
23541
|
+
access: "create"
|
|
23542
|
+
},
|
|
23543
|
+
"notificationOutput.upsertTarget": {
|
|
22213
23544
|
capName: "notification-output",
|
|
22214
23545
|
capScope: "system",
|
|
22215
23546
|
addonId: null,
|
|
@@ -22239,6 +23570,66 @@ Object.freeze({
|
|
|
22239
23570
|
addonId: null,
|
|
22240
23571
|
access: "create"
|
|
22241
23572
|
},
|
|
23573
|
+
"petFeeder.callPet": {
|
|
23574
|
+
capName: "pet-feeder",
|
|
23575
|
+
capScope: "device",
|
|
23576
|
+
addonId: null,
|
|
23577
|
+
access: "create"
|
|
23578
|
+
},
|
|
23579
|
+
"petFeeder.cancelFeed": {
|
|
23580
|
+
capName: "pet-feeder",
|
|
23581
|
+
capScope: "device",
|
|
23582
|
+
addonId: null,
|
|
23583
|
+
access: "create"
|
|
23584
|
+
},
|
|
23585
|
+
"petFeeder.feed": {
|
|
23586
|
+
capName: "pet-feeder",
|
|
23587
|
+
capScope: "device",
|
|
23588
|
+
addonId: null,
|
|
23589
|
+
access: "create"
|
|
23590
|
+
},
|
|
23591
|
+
"petFeeder.markFoodReplenished": {
|
|
23592
|
+
capName: "pet-feeder",
|
|
23593
|
+
capScope: "device",
|
|
23594
|
+
addonId: null,
|
|
23595
|
+
access: "create"
|
|
23596
|
+
},
|
|
23597
|
+
"petFeeder.playSound": {
|
|
23598
|
+
capName: "pet-feeder",
|
|
23599
|
+
capScope: "device",
|
|
23600
|
+
addonId: null,
|
|
23601
|
+
access: "create"
|
|
23602
|
+
},
|
|
23603
|
+
"petFeeder.resetDesiccant": {
|
|
23604
|
+
capName: "pet-feeder",
|
|
23605
|
+
capScope: "device",
|
|
23606
|
+
addonId: null,
|
|
23607
|
+
access: "delete"
|
|
23608
|
+
},
|
|
23609
|
+
"petFeeder.setChildLock": {
|
|
23610
|
+
capName: "pet-feeder",
|
|
23611
|
+
capScope: "device",
|
|
23612
|
+
addonId: null,
|
|
23613
|
+
access: "create"
|
|
23614
|
+
},
|
|
23615
|
+
"petFeeder.setFeedSound": {
|
|
23616
|
+
capName: "pet-feeder",
|
|
23617
|
+
capScope: "device",
|
|
23618
|
+
addonId: null,
|
|
23619
|
+
access: "create"
|
|
23620
|
+
},
|
|
23621
|
+
"petFeeder.setIndicatorLight": {
|
|
23622
|
+
capName: "pet-feeder",
|
|
23623
|
+
capScope: "device",
|
|
23624
|
+
addonId: null,
|
|
23625
|
+
access: "create"
|
|
23626
|
+
},
|
|
23627
|
+
"petFeeder.setVolume": {
|
|
23628
|
+
capName: "pet-feeder",
|
|
23629
|
+
capScope: "device",
|
|
23630
|
+
addonId: null,
|
|
23631
|
+
access: "create"
|
|
23632
|
+
},
|
|
22242
23633
|
"pipelineAnalytics.clearTracks": {
|
|
22243
23634
|
capName: "pipeline-analytics",
|
|
22244
23635
|
capScope: "device",
|
|
@@ -22845,30 +24236,6 @@ Object.freeze({
|
|
|
22845
24236
|
addonId: null,
|
|
22846
24237
|
access: "view"
|
|
22847
24238
|
},
|
|
22848
|
-
"platformProbe.getHardwareDecodeAccels": {
|
|
22849
|
-
capName: "platform-probe",
|
|
22850
|
-
capScope: "system",
|
|
22851
|
-
addonId: null,
|
|
22852
|
-
access: "view"
|
|
22853
|
-
},
|
|
22854
|
-
"platformProbe.getHardwareEncoders": {
|
|
22855
|
-
capName: "platform-probe",
|
|
22856
|
-
capScope: "system",
|
|
22857
|
-
addonId: null,
|
|
22858
|
-
access: "view"
|
|
22859
|
-
},
|
|
22860
|
-
"platformProbe.refreshHardwareDecodeAccels": {
|
|
22861
|
-
capName: "platform-probe",
|
|
22862
|
-
capScope: "system",
|
|
22863
|
-
addonId: null,
|
|
22864
|
-
access: "create"
|
|
22865
|
-
},
|
|
22866
|
-
"platformProbe.refreshHardwareEncoders": {
|
|
22867
|
-
capName: "platform-probe",
|
|
22868
|
-
capScope: "system",
|
|
22869
|
-
addonId: null,
|
|
22870
|
-
access: "create"
|
|
22871
|
-
},
|
|
22872
24239
|
"platformProbe.resolveHwAccel": {
|
|
22873
24240
|
capName: "platform-probe",
|
|
22874
24241
|
capScope: "system",
|