@camstack/addon-matter-broker 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +1482 -62
- package/dist/addon.mjs +1482 -62
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -4656,7 +4656,7 @@ function preprocess(fn, schema) {
|
|
|
4656
4656
|
});
|
|
4657
4657
|
}
|
|
4658
4658
|
//#endregion
|
|
4659
|
-
//#region ../types/dist/sleep-
|
|
4659
|
+
//#region ../types/dist/sleep-BiDFW0E7.mjs
|
|
4660
4660
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4661
4661
|
EventCategory["SystemBoot"] = "system.boot";
|
|
4662
4662
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -5469,6 +5469,100 @@ function createDurableState(deps) {
|
|
|
5469
5469
|
};
|
|
5470
5470
|
}
|
|
5471
5471
|
/**
|
|
5472
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
5473
|
+
*
|
|
5474
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
5475
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
5476
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
5477
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
5478
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
5479
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
5480
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
5481
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
5482
|
+
*
|
|
5483
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
5484
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
5485
|
+
* schema and routes reads/writes through these helpers.
|
|
5486
|
+
*
|
|
5487
|
+
* ## No bare-key fallback — deliberate
|
|
5488
|
+
*
|
|
5489
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
5490
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
5491
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
5492
|
+
* the store is invisible to every node, hub included, so one node's
|
|
5493
|
+
* selection can never leak onto another. (This generalizes the
|
|
5494
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
5495
|
+
* arbitrary set of per-node field keys.)
|
|
5496
|
+
*
|
|
5497
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
5498
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
5499
|
+
*/
|
|
5500
|
+
/**
|
|
5501
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
5502
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
5503
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
5504
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
5505
|
+
*/
|
|
5506
|
+
function normalizeNodeId(raw) {
|
|
5507
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
5508
|
+
const slashIdx = raw.indexOf("/");
|
|
5509
|
+
if (slashIdx < 0) return raw;
|
|
5510
|
+
const bare = raw.slice(0, slashIdx);
|
|
5511
|
+
return bare === "" ? "hub" : bare;
|
|
5512
|
+
}
|
|
5513
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
5514
|
+
function nodeScopedKey(base, nodeId) {
|
|
5515
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
5516
|
+
}
|
|
5517
|
+
/**
|
|
5518
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
5519
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
5520
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
5521
|
+
* schema `default` win on `undefined`.
|
|
5522
|
+
*/
|
|
5523
|
+
function readNodeValue(store, base, nodeId) {
|
|
5524
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
5525
|
+
}
|
|
5526
|
+
/**
|
|
5527
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
5528
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
5529
|
+
* the write path so a save for one node never clobbers another node's value
|
|
5530
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
5531
|
+
* patch is not mutated.
|
|
5532
|
+
*/
|
|
5533
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
5534
|
+
const out = {};
|
|
5535
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
5536
|
+
return out;
|
|
5537
|
+
}
|
|
5538
|
+
/**
|
|
5539
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
5540
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
5541
|
+
* values:
|
|
5542
|
+
*
|
|
5543
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
5544
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
5545
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
5546
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
5547
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
5548
|
+
* left ABSENT so the field's schema `default` wins.
|
|
5549
|
+
*
|
|
5550
|
+
* Returns a new object — the input store is not mutated.
|
|
5551
|
+
*/
|
|
5552
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
5553
|
+
const out = {};
|
|
5554
|
+
for (const [key, value] of Object.entries(store)) {
|
|
5555
|
+
if (key.includes("@")) continue;
|
|
5556
|
+
if (perNodeKeys.has(key)) continue;
|
|
5557
|
+
out[key] = value;
|
|
5558
|
+
}
|
|
5559
|
+
for (const base of perNodeKeys) {
|
|
5560
|
+
const value = readNodeValue(store, base, nodeId);
|
|
5561
|
+
if (value !== void 0) out[base] = value;
|
|
5562
|
+
}
|
|
5563
|
+
return out;
|
|
5564
|
+
}
|
|
5565
|
+
/**
|
|
5472
5566
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5473
5567
|
*
|
|
5474
5568
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -5636,23 +5730,63 @@ var BaseAddon = class {
|
|
|
5636
5730
|
deviceSettingsSchema() {
|
|
5637
5731
|
return null;
|
|
5638
5732
|
}
|
|
5639
|
-
async getGlobalSettings(overlay, cap,
|
|
5733
|
+
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5640
5734
|
const schema = this.globalSettingsSchema(cap);
|
|
5641
5735
|
if (!schema) return { sections: [] };
|
|
5642
|
-
const
|
|
5736
|
+
const projected = await this.resolveGlobalStore(nodeId, cap);
|
|
5643
5737
|
return hydrateSchema(schema, overlay ? {
|
|
5644
|
-
...
|
|
5738
|
+
...projected,
|
|
5645
5739
|
...overlay
|
|
5646
|
-
} :
|
|
5740
|
+
} : projected);
|
|
5647
5741
|
}
|
|
5648
|
-
|
|
5649
|
-
|
|
5742
|
+
/**
|
|
5743
|
+
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5744
|
+
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5745
|
+
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
5746
|
+
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
5747
|
+
* A no-op passthrough when the schema declares no `perNode` field.
|
|
5748
|
+
*
|
|
5749
|
+
* This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
|
|
5750
|
+
* the store for custom option logic (option narrowing, value snapping) to
|
|
5751
|
+
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
5752
|
+
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
5753
|
+
*/
|
|
5754
|
+
async resolveGlobalStore(nodeId, cap) {
|
|
5755
|
+
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
5756
|
+
const keys = this.perNodeKeys(cap);
|
|
5757
|
+
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5758
|
+
return keys.size > 0 ? projectStore(raw, keys, node) : raw;
|
|
5759
|
+
}
|
|
5760
|
+
async updateGlobalSettings(patch, nodeId) {
|
|
5761
|
+
const keys = this.perNodeKeys();
|
|
5762
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5763
|
+
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5764
|
+
const barePatch = patch;
|
|
5765
|
+
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
5766
|
+
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
5767
|
+
if (target !== localNode) return;
|
|
5650
5768
|
await this.resolveConfig();
|
|
5651
5769
|
await this.onConfigChanged();
|
|
5652
5770
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
5653
5771
|
this.maybeAutoRestart(patch, this.globalSettingsSchema());
|
|
5654
5772
|
}
|
|
5655
5773
|
/**
|
|
5774
|
+
* The set of field keys the global settings schema declares `perNode: true`
|
|
5775
|
+
* — derived once per `cap` argument and memoized (schemas are static
|
|
5776
|
+
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
5777
|
+
* settings API behaves exactly like the legacy node-agnostic one.
|
|
5778
|
+
*/
|
|
5779
|
+
_perNodeKeysCache = /* @__PURE__ */ new Map();
|
|
5780
|
+
perNodeKeys(cap) {
|
|
5781
|
+
const cacheKey = cap ?? "";
|
|
5782
|
+
const cached = this._perNodeKeysCache.get(cacheKey);
|
|
5783
|
+
if (cached) return cached;
|
|
5784
|
+
const schema = this.globalSettingsSchema(cap);
|
|
5785
|
+
const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
5786
|
+
this._perNodeKeysCache.set(cacheKey, keys);
|
|
5787
|
+
return keys;
|
|
5788
|
+
}
|
|
5789
|
+
/**
|
|
5656
5790
|
* If any field in `patch` is marked `requiresRestart` in `schema`,
|
|
5657
5791
|
* schedule an addon restart for the next tick. Deferred via
|
|
5658
5792
|
* `setImmediate` so the tRPC mutation that triggered the write has
|
|
@@ -5805,12 +5939,19 @@ var BaseAddon = class {
|
|
|
5805
5939
|
* The merge is shallow: each key in `defaults` is checked against the store.
|
|
5806
5940
|
* Only keys present in defaults are read — the store can contain extra keys
|
|
5807
5941
|
* (e.g. from older versions) without polluting the typed config.
|
|
5942
|
+
*
|
|
5943
|
+
* Keys the global settings schema declares `perNode: true` resolve from
|
|
5944
|
+
* THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
|
|
5945
|
+
* from the bare key — so a per-node field resolves to this node's own
|
|
5946
|
+
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
5808
5947
|
*/
|
|
5809
5948
|
async resolveConfig() {
|
|
5810
5949
|
const stored = await this.readAddonStoreWithRetry();
|
|
5950
|
+
const perNode = this.perNodeKeys();
|
|
5951
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5811
5952
|
const resolved = { ...this.defaults };
|
|
5812
5953
|
for (const key of Object.keys(this.defaults)) {
|
|
5813
|
-
const storedValue = stored[key];
|
|
5954
|
+
const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
|
|
5814
5955
|
if (storedValue !== void 0 && storedValue !== null) {
|
|
5815
5956
|
const defaultType = typeof this.defaults[key];
|
|
5816
5957
|
if (typeof storedValue === defaultType) resolved[key] = storedValue;
|
|
@@ -5894,6 +6035,27 @@ var BaseAddon = class {
|
|
|
5894
6035
|
}
|
|
5895
6036
|
};
|
|
5896
6037
|
/**
|
|
6038
|
+
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
6039
|
+
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
6040
|
+
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6041
|
+
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6042
|
+
*/
|
|
6043
|
+
function collectPerNodeFieldKeys(fields) {
|
|
6044
|
+
const collected = [];
|
|
6045
|
+
for (const field of fields) {
|
|
6046
|
+
if (field.type === "group") {
|
|
6047
|
+
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
6048
|
+
continue;
|
|
6049
|
+
}
|
|
6050
|
+
if (field.type === "sub-tabs") {
|
|
6051
|
+
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
6052
|
+
continue;
|
|
6053
|
+
}
|
|
6054
|
+
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
6055
|
+
}
|
|
6056
|
+
return collected;
|
|
6057
|
+
}
|
|
6058
|
+
/**
|
|
5897
6059
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
5898
6060
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
5899
6061
|
* envelopes pass through; void stays void.
|
|
@@ -5918,6 +6080,7 @@ var CamStreamKindSchema = _enum([
|
|
|
5918
6080
|
"pull-rtsp",
|
|
5919
6081
|
"pull-rtmp",
|
|
5920
6082
|
"pull-http",
|
|
6083
|
+
"pull-flv",
|
|
5921
6084
|
"pull-rfc4571",
|
|
5922
6085
|
"push-annexb",
|
|
5923
6086
|
"derived"
|
|
@@ -6300,6 +6463,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
6300
6463
|
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
6301
6464
|
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
6302
6465
|
DeviceType["Image"] = "image";
|
|
6466
|
+
/** Smart pet feeder — cloud-connected food dispenser with a bowl food
|
|
6467
|
+
* level, battery, desiccant life, feeding state and manual-feed /
|
|
6468
|
+
* call-pet / maintenance actions. Installed with the `pet-feeder` cap;
|
|
6469
|
+
* dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
|
|
6470
|
+
* native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
|
|
6471
|
+
* integrations sharing the same food/desiccant/hopper surface. */
|
|
6472
|
+
DeviceType["PetFeeder"] = "pet-feeder";
|
|
6303
6473
|
return DeviceType;
|
|
6304
6474
|
}({});
|
|
6305
6475
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -7077,7 +7247,21 @@ var StorageLocationDeclarationSchema = object({
|
|
|
7077
7247
|
* slots (e.g. `recordingsLow` → `recordings`) so operators only need to
|
|
7078
7248
|
* configure the primary location.
|
|
7079
7249
|
*/
|
|
7080
|
-
defaultsTo: string$2().optional()
|
|
7250
|
+
defaultsTo: string$2().optional(),
|
|
7251
|
+
/**
|
|
7252
|
+
* Which node root the seeded `<id>:default` instance is placed under on a
|
|
7253
|
+
* FRESH install:
|
|
7254
|
+
* - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
|
|
7255
|
+
* the appData volume. Right for small/durable data (backups, logs, models).
|
|
7256
|
+
* - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
|
|
7257
|
+
* env is set, else falls back to the data root. Right for bulky, hot media
|
|
7258
|
+
* (recordings, event media) that should stay off the appData disk.
|
|
7259
|
+
*
|
|
7260
|
+
* Only affects the seeded default's `basePath`; operators can repoint any
|
|
7261
|
+
* location afterwards, and a `defaultsTo` slot inherits its parent's root
|
|
7262
|
+
* regardless of this field. Absent (the common case) is treated as `'data'`.
|
|
7263
|
+
*/
|
|
7264
|
+
defaultRoot: _enum(["data", "media"]).optional()
|
|
7081
7265
|
});
|
|
7082
7266
|
var DecoderStatsSchema = object({
|
|
7083
7267
|
inputFps: number(),
|
|
@@ -7450,6 +7634,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
|
|
|
7450
7634
|
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7451
7635
|
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7452
7636
|
/**
|
|
7637
|
+
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7638
|
+
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
7639
|
+
* failure — both are non-fatal to the host: read paths degrade to "skip link".
|
|
7640
|
+
*/
|
|
7641
|
+
/** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
|
|
7642
|
+
* the failure is anchored to a character (author-facing inline feedback). */
|
|
7643
|
+
var ExpressionParseError = class extends Error {
|
|
7644
|
+
position;
|
|
7645
|
+
constructor(message, position) {
|
|
7646
|
+
super(message);
|
|
7647
|
+
this.name = "ExpressionParseError";
|
|
7648
|
+
this.position = position;
|
|
7649
|
+
}
|
|
7650
|
+
};
|
|
7651
|
+
/** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
|
|
7652
|
+
* result, unknown builtin, step-budget exceeded). */
|
|
7653
|
+
var ExpressionEvalError = class extends Error {
|
|
7654
|
+
constructor(message) {
|
|
7655
|
+
super(message);
|
|
7656
|
+
this.name = "ExpressionEvalError";
|
|
7657
|
+
}
|
|
7658
|
+
};
|
|
7659
|
+
/**
|
|
7660
|
+
* Resource-bound constants for the safe expression engine.
|
|
7661
|
+
*
|
|
7662
|
+
* Every bound is defense-in-depth: the grammar is non-Turing-complete (no
|
|
7663
|
+
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
7664
|
+
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
7665
|
+
* work a single author-supplied expression can request, so a hostile or
|
|
7666
|
+
* accidental pathological string can never spend unbounded CPU/memory.
|
|
7667
|
+
*/
|
|
7668
|
+
/** Max source length (chars) — checked BEFORE tokenizing so a huge string is
|
|
7669
|
+
* rejected without allocation. */
|
|
7670
|
+
var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
|
|
7671
|
+
/** A legal binding / identifier name. */
|
|
7672
|
+
var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7673
|
+
/** Binding names an author may NOT use: `now` is auto-injected; the literal
|
|
7674
|
+
* keywords lex as values, not identifiers, so binding to them is meaningless. */
|
|
7675
|
+
var RESERVED_BINDING_NAMES = new Set([
|
|
7676
|
+
"now",
|
|
7677
|
+
"true",
|
|
7678
|
+
"false",
|
|
7679
|
+
"null"
|
|
7680
|
+
]);
|
|
7681
|
+
/**
|
|
7682
|
+
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
7683
|
+
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
7684
|
+
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
7685
|
+
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
7686
|
+
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
7687
|
+
* is a parse error with a source position, so member access / assignment /
|
|
7688
|
+
* template literals are lexically impossible.
|
|
7689
|
+
*/
|
|
7690
|
+
var KEYWORDS = new Set([
|
|
7691
|
+
"true",
|
|
7692
|
+
"false",
|
|
7693
|
+
"null"
|
|
7694
|
+
]);
|
|
7695
|
+
function isDigit(ch) {
|
|
7696
|
+
return ch >= "0" && ch <= "9";
|
|
7697
|
+
}
|
|
7698
|
+
function isIdentStart(ch) {
|
|
7699
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
7700
|
+
}
|
|
7701
|
+
function isIdentPart(ch) {
|
|
7702
|
+
return isIdentStart(ch) || isDigit(ch);
|
|
7703
|
+
}
|
|
7704
|
+
function isWhitespace(ch) {
|
|
7705
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
7706
|
+
}
|
|
7707
|
+
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
7708
|
+
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
7709
|
+
* string. */
|
|
7710
|
+
function tokenize(source) {
|
|
7711
|
+
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
7712
|
+
const tokens = [];
|
|
7713
|
+
let i = 0;
|
|
7714
|
+
const n = source.length;
|
|
7715
|
+
while (i < n) {
|
|
7716
|
+
const ch = source[i];
|
|
7717
|
+
if (isWhitespace(ch)) {
|
|
7718
|
+
i += 1;
|
|
7719
|
+
continue;
|
|
7720
|
+
}
|
|
7721
|
+
if (isDigit(ch)) {
|
|
7722
|
+
const start = i;
|
|
7723
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7724
|
+
if (i < n && source[i] === ".") {
|
|
7725
|
+
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
7726
|
+
i += 1;
|
|
7727
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7728
|
+
}
|
|
7729
|
+
const text = source.slice(start, i);
|
|
7730
|
+
const value = Number(text);
|
|
7731
|
+
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
7732
|
+
tokens.push({
|
|
7733
|
+
type: "number",
|
|
7734
|
+
value,
|
|
7735
|
+
pos: start
|
|
7736
|
+
});
|
|
7737
|
+
continue;
|
|
7738
|
+
}
|
|
7739
|
+
if (ch === "'" || ch === "\"") {
|
|
7740
|
+
const quote = ch;
|
|
7741
|
+
const start = i;
|
|
7742
|
+
i += 1;
|
|
7743
|
+
let out = "";
|
|
7744
|
+
let closed = false;
|
|
7745
|
+
while (i < n) {
|
|
7746
|
+
const c = source[i];
|
|
7747
|
+
if (c === "\\") {
|
|
7748
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
7749
|
+
if (next === "\\" || next === "'" || next === "\"") {
|
|
7750
|
+
out += next;
|
|
7751
|
+
i += 2;
|
|
7752
|
+
continue;
|
|
7753
|
+
}
|
|
7754
|
+
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
7755
|
+
}
|
|
7756
|
+
if (c === quote) {
|
|
7757
|
+
closed = true;
|
|
7758
|
+
i += 1;
|
|
7759
|
+
break;
|
|
7760
|
+
}
|
|
7761
|
+
out += c;
|
|
7762
|
+
i += 1;
|
|
7763
|
+
}
|
|
7764
|
+
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
7765
|
+
tokens.push({
|
|
7766
|
+
type: "string",
|
|
7767
|
+
value: out,
|
|
7768
|
+
pos: start
|
|
7769
|
+
});
|
|
7770
|
+
continue;
|
|
7771
|
+
}
|
|
7772
|
+
if (isIdentStart(ch)) {
|
|
7773
|
+
const start = i;
|
|
7774
|
+
while (i < n && isIdentPart(source[i])) i += 1;
|
|
7775
|
+
const text = source.slice(start, i);
|
|
7776
|
+
if (KEYWORDS.has(text)) tokens.push({
|
|
7777
|
+
type: "keyword",
|
|
7778
|
+
keyword: keywordOf(text),
|
|
7779
|
+
pos: start
|
|
7780
|
+
});
|
|
7781
|
+
else tokens.push({
|
|
7782
|
+
type: "identifier",
|
|
7783
|
+
name: text,
|
|
7784
|
+
pos: start
|
|
7785
|
+
});
|
|
7786
|
+
continue;
|
|
7787
|
+
}
|
|
7788
|
+
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
7789
|
+
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
7790
|
+
tokens.push({
|
|
7791
|
+
type: "punct",
|
|
7792
|
+
punct: two,
|
|
7793
|
+
pos: i
|
|
7794
|
+
});
|
|
7795
|
+
i += 2;
|
|
7796
|
+
continue;
|
|
7797
|
+
}
|
|
7798
|
+
if (isSinglePunct(ch)) {
|
|
7799
|
+
tokens.push({
|
|
7800
|
+
type: "punct",
|
|
7801
|
+
punct: ch,
|
|
7802
|
+
pos: i
|
|
7803
|
+
});
|
|
7804
|
+
i += 1;
|
|
7805
|
+
continue;
|
|
7806
|
+
}
|
|
7807
|
+
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
7808
|
+
}
|
|
7809
|
+
tokens.push({
|
|
7810
|
+
type: "eof",
|
|
7811
|
+
pos: n
|
|
7812
|
+
});
|
|
7813
|
+
return tokens;
|
|
7814
|
+
}
|
|
7815
|
+
function keywordOf(text) {
|
|
7816
|
+
if (text === "true") return "true";
|
|
7817
|
+
if (text === "false") return "false";
|
|
7818
|
+
return "null";
|
|
7819
|
+
}
|
|
7820
|
+
function isSinglePunct(ch) {
|
|
7821
|
+
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
7822
|
+
}
|
|
7823
|
+
/**
|
|
7824
|
+
* Frozen, null-prototype builtin function table for the expression engine
|
|
7825
|
+
* (spec §4 rule 4). The table is the SOLE surface of callable functions: the
|
|
7826
|
+
* parser rejects any callee not in it, and the evaluator gates each call on an
|
|
7827
|
+
* own-property check against it.
|
|
7828
|
+
*
|
|
7829
|
+
* Because the object has a NULL prototype AND is `Object.freeze`d:
|
|
7830
|
+
* - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
|
|
7831
|
+
* - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
|
|
7832
|
+
* (there is no `Object.prototype` in the chain), so those names are not
|
|
7833
|
+
* callable — they are simply "unknown function" at parse time.
|
|
7834
|
+
*
|
|
7835
|
+
* Every numeric argument is validated as a finite number and every numeric
|
|
7836
|
+
* RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
|
|
7837
|
+
* (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
|
|
7838
|
+
* closed rather than emitting a garbage value.
|
|
7839
|
+
*/
|
|
7840
|
+
function asFiniteNumber(value, name, index) {
|
|
7841
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
7842
|
+
return value;
|
|
7843
|
+
}
|
|
7844
|
+
function asString$1(value, name, index) {
|
|
7845
|
+
if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
|
|
7846
|
+
return value;
|
|
7847
|
+
}
|
|
7848
|
+
function finiteResult(value, name) {
|
|
7849
|
+
if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
|
|
7850
|
+
return value;
|
|
7851
|
+
}
|
|
7852
|
+
function allFiniteNumbers(args, name) {
|
|
7853
|
+
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
7854
|
+
}
|
|
7855
|
+
var INF = Number.POSITIVE_INFINITY;
|
|
7856
|
+
var table = {
|
|
7857
|
+
min: {
|
|
7858
|
+
minArgs: 1,
|
|
7859
|
+
maxArgs: INF,
|
|
7860
|
+
apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
|
|
7861
|
+
},
|
|
7862
|
+
max: {
|
|
7863
|
+
minArgs: 1,
|
|
7864
|
+
maxArgs: INF,
|
|
7865
|
+
apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
|
|
7866
|
+
},
|
|
7867
|
+
abs: {
|
|
7868
|
+
minArgs: 1,
|
|
7869
|
+
maxArgs: 1,
|
|
7870
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
7871
|
+
},
|
|
7872
|
+
floor: {
|
|
7873
|
+
minArgs: 1,
|
|
7874
|
+
maxArgs: 1,
|
|
7875
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
7876
|
+
},
|
|
7877
|
+
ceil: {
|
|
7878
|
+
minArgs: 1,
|
|
7879
|
+
maxArgs: 1,
|
|
7880
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
7881
|
+
},
|
|
7882
|
+
sqrt: {
|
|
7883
|
+
minArgs: 1,
|
|
7884
|
+
maxArgs: 1,
|
|
7885
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
7886
|
+
},
|
|
7887
|
+
round: {
|
|
7888
|
+
minArgs: 1,
|
|
7889
|
+
maxArgs: 2,
|
|
7890
|
+
apply: (args) => {
|
|
7891
|
+
const x = asFiniteNumber(args[0], "round", 0);
|
|
7892
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
7893
|
+
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
7894
|
+
const factor = 10 ** digits;
|
|
7895
|
+
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
7896
|
+
}
|
|
7897
|
+
},
|
|
7898
|
+
pow: {
|
|
7899
|
+
minArgs: 2,
|
|
7900
|
+
maxArgs: 2,
|
|
7901
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
7902
|
+
},
|
|
7903
|
+
clamp: {
|
|
7904
|
+
minArgs: 3,
|
|
7905
|
+
maxArgs: 3,
|
|
7906
|
+
apply: (args) => {
|
|
7907
|
+
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
7908
|
+
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
7909
|
+
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
7910
|
+
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
7911
|
+
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
7912
|
+
}
|
|
7913
|
+
},
|
|
7914
|
+
avg: {
|
|
7915
|
+
minArgs: 1,
|
|
7916
|
+
maxArgs: INF,
|
|
7917
|
+
apply: (args) => {
|
|
7918
|
+
const nums = allFiniteNumbers(args, "avg");
|
|
7919
|
+
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
7920
|
+
}
|
|
7921
|
+
},
|
|
7922
|
+
sum: {
|
|
7923
|
+
minArgs: 1,
|
|
7924
|
+
maxArgs: INF,
|
|
7925
|
+
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
7926
|
+
},
|
|
7927
|
+
coalesce: {
|
|
7928
|
+
minArgs: 1,
|
|
7929
|
+
maxArgs: INF,
|
|
7930
|
+
apply: (args) => {
|
|
7931
|
+
for (const a of args) if (a !== null) return a;
|
|
7932
|
+
return null;
|
|
7933
|
+
}
|
|
7934
|
+
},
|
|
7935
|
+
age: {
|
|
7936
|
+
minArgs: 2,
|
|
7937
|
+
maxArgs: 2,
|
|
7938
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
7939
|
+
},
|
|
7940
|
+
convert: {
|
|
7941
|
+
minArgs: 3,
|
|
7942
|
+
maxArgs: 3,
|
|
7943
|
+
apply: (args, hooks) => {
|
|
7944
|
+
const x = asFiniteNumber(args[0], "convert", 0);
|
|
7945
|
+
const from = asString$1(args[1], "convert", 1).trim();
|
|
7946
|
+
const to = asString$1(args[2], "convert", 2).trim();
|
|
7947
|
+
if (hooks.convert) {
|
|
7948
|
+
const out = hooks.convert(x, from, to);
|
|
7949
|
+
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
7950
|
+
return finiteResult(out, "convert");
|
|
7951
|
+
}
|
|
7952
|
+
if (from === to) return x;
|
|
7953
|
+
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
7954
|
+
}
|
|
7955
|
+
}
|
|
7956
|
+
};
|
|
7957
|
+
Object.freeze(Object.assign(Object.create(null), table));
|
|
7958
|
+
/** The set of valid builtin names — used by the parser to reject unknown
|
|
7959
|
+
* callees at parse time (immediate author feedback). */
|
|
7960
|
+
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
7961
|
+
/**
|
|
7962
|
+
* Pratt (precedence-climbing) parser for the safe expression mini-language.
|
|
7963
|
+
*
|
|
7964
|
+
* Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
|
|
7965
|
+
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
7966
|
+
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
7967
|
+
* string validated against the builtin table at parse time, so an unknown
|
|
7968
|
+
* function is rejected immediately (author feedback) and a persisted expression
|
|
7969
|
+
* that references a since-removed builtin degrades at read.
|
|
7970
|
+
*
|
|
7971
|
+
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
7972
|
+
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
7973
|
+
*/
|
|
7974
|
+
/** Binary/logical operator precedence (higher binds tighter). */
|
|
7975
|
+
var BINARY_PRECEDENCE = {
|
|
7976
|
+
"||": 1,
|
|
7977
|
+
"&&": 2,
|
|
7978
|
+
"==": 3,
|
|
7979
|
+
"!=": 3,
|
|
7980
|
+
"<": 4,
|
|
7981
|
+
"<=": 4,
|
|
7982
|
+
">": 4,
|
|
7983
|
+
">=": 4,
|
|
7984
|
+
"+": 5,
|
|
7985
|
+
"-": 5,
|
|
7986
|
+
"*": 6,
|
|
7987
|
+
"/": 6,
|
|
7988
|
+
"%": 6
|
|
7989
|
+
};
|
|
7990
|
+
function isLogicalOp(op) {
|
|
7991
|
+
return op === "&&" || op === "||";
|
|
7992
|
+
}
|
|
7993
|
+
function isBinaryOp(op) {
|
|
7994
|
+
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
7995
|
+
}
|
|
7996
|
+
var Parser$2 = class {
|
|
7997
|
+
tokens;
|
|
7998
|
+
pos = 0;
|
|
7999
|
+
nodeCount = 0;
|
|
8000
|
+
identifiers = /* @__PURE__ */ new Set();
|
|
8001
|
+
callees = /* @__PURE__ */ new Set();
|
|
8002
|
+
constructor(tokens) {
|
|
8003
|
+
this.tokens = tokens;
|
|
8004
|
+
}
|
|
8005
|
+
parse() {
|
|
8006
|
+
const ast = this.parseTernary();
|
|
8007
|
+
const tok = this.peek();
|
|
8008
|
+
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
8009
|
+
return {
|
|
8010
|
+
ast,
|
|
8011
|
+
identifiers: this.identifiers,
|
|
8012
|
+
callees: this.callees,
|
|
8013
|
+
nodeCount: this.nodeCount
|
|
8014
|
+
};
|
|
8015
|
+
}
|
|
8016
|
+
peek() {
|
|
8017
|
+
return this.tokens[this.pos];
|
|
8018
|
+
}
|
|
8019
|
+
next() {
|
|
8020
|
+
return this.tokens[this.pos++];
|
|
8021
|
+
}
|
|
8022
|
+
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
8023
|
+
expectPunct(punct) {
|
|
8024
|
+
const tok = this.peek();
|
|
8025
|
+
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
8026
|
+
this.pos += 1;
|
|
8027
|
+
}
|
|
8028
|
+
matchPunct(punct) {
|
|
8029
|
+
const tok = this.peek();
|
|
8030
|
+
if (tok.type === "punct" && tok.punct === punct) {
|
|
8031
|
+
this.pos += 1;
|
|
8032
|
+
return true;
|
|
8033
|
+
}
|
|
8034
|
+
return false;
|
|
8035
|
+
}
|
|
8036
|
+
countNode() {
|
|
8037
|
+
this.nodeCount += 1;
|
|
8038
|
+
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
8039
|
+
}
|
|
8040
|
+
parseTernary() {
|
|
8041
|
+
const test = this.parseBinary(1);
|
|
8042
|
+
if (this.matchPunct("?")) {
|
|
8043
|
+
const consequent = this.parseTernary();
|
|
8044
|
+
this.expectPunct(":");
|
|
8045
|
+
const alternate = this.parseTernary();
|
|
8046
|
+
this.countNode();
|
|
8047
|
+
return {
|
|
8048
|
+
kind: "conditional",
|
|
8049
|
+
test,
|
|
8050
|
+
consequent,
|
|
8051
|
+
alternate
|
|
8052
|
+
};
|
|
8053
|
+
}
|
|
8054
|
+
return test;
|
|
8055
|
+
}
|
|
8056
|
+
parseBinary(minPrec) {
|
|
8057
|
+
let left = this.parseUnary();
|
|
8058
|
+
for (;;) {
|
|
8059
|
+
const tok = this.peek();
|
|
8060
|
+
if (tok.type !== "punct") break;
|
|
8061
|
+
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
8062
|
+
if (prec === void 0 || prec < minPrec) break;
|
|
8063
|
+
const op = tok.punct;
|
|
8064
|
+
this.pos += 1;
|
|
8065
|
+
const right = this.parseBinary(prec + 1);
|
|
8066
|
+
this.countNode();
|
|
8067
|
+
if (isLogicalOp(op)) left = {
|
|
8068
|
+
kind: "logical",
|
|
8069
|
+
op,
|
|
8070
|
+
left,
|
|
8071
|
+
right
|
|
8072
|
+
};
|
|
8073
|
+
else if (isBinaryOp(op)) left = {
|
|
8074
|
+
kind: "binary",
|
|
8075
|
+
op,
|
|
8076
|
+
left,
|
|
8077
|
+
right
|
|
8078
|
+
};
|
|
8079
|
+
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
8080
|
+
}
|
|
8081
|
+
return left;
|
|
8082
|
+
}
|
|
8083
|
+
parseUnary() {
|
|
8084
|
+
const tok = this.peek();
|
|
8085
|
+
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
8086
|
+
const op = tok.punct;
|
|
8087
|
+
this.pos += 1;
|
|
8088
|
+
const operand = this.parseUnary();
|
|
8089
|
+
this.countNode();
|
|
8090
|
+
return {
|
|
8091
|
+
kind: "unary",
|
|
8092
|
+
op,
|
|
8093
|
+
operand
|
|
8094
|
+
};
|
|
8095
|
+
}
|
|
8096
|
+
return this.parsePrimary();
|
|
8097
|
+
}
|
|
8098
|
+
parsePrimary() {
|
|
8099
|
+
const tok = this.next();
|
|
8100
|
+
switch (tok.type) {
|
|
8101
|
+
case "number":
|
|
8102
|
+
this.countNode();
|
|
8103
|
+
return {
|
|
8104
|
+
kind: "literal",
|
|
8105
|
+
value: tok.value
|
|
8106
|
+
};
|
|
8107
|
+
case "string":
|
|
8108
|
+
this.countNode();
|
|
8109
|
+
return {
|
|
8110
|
+
kind: "literal",
|
|
8111
|
+
value: tok.value
|
|
8112
|
+
};
|
|
8113
|
+
case "keyword":
|
|
8114
|
+
this.countNode();
|
|
8115
|
+
return {
|
|
8116
|
+
kind: "literal",
|
|
8117
|
+
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
8118
|
+
};
|
|
8119
|
+
case "identifier": {
|
|
8120
|
+
const nextTok = this.peek();
|
|
8121
|
+
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
8122
|
+
this.identifiers.add(tok.name);
|
|
8123
|
+
this.countNode();
|
|
8124
|
+
return {
|
|
8125
|
+
kind: "identifier",
|
|
8126
|
+
name: tok.name
|
|
8127
|
+
};
|
|
8128
|
+
}
|
|
8129
|
+
case "punct":
|
|
8130
|
+
if (tok.punct === "(") {
|
|
8131
|
+
const inner = this.parseTernary();
|
|
8132
|
+
this.expectPunct(")");
|
|
8133
|
+
return inner;
|
|
8134
|
+
}
|
|
8135
|
+
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
8136
|
+
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
8137
|
+
}
|
|
8138
|
+
}
|
|
8139
|
+
parseCall(callee, pos) {
|
|
8140
|
+
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
8141
|
+
this.expectPunct("(");
|
|
8142
|
+
const args = [];
|
|
8143
|
+
if (!this.matchPunct(")")) for (;;) {
|
|
8144
|
+
args.push(this.parseTernary());
|
|
8145
|
+
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
8146
|
+
if (this.matchPunct(",")) continue;
|
|
8147
|
+
this.expectPunct(")");
|
|
8148
|
+
break;
|
|
8149
|
+
}
|
|
8150
|
+
this.callees.add(callee);
|
|
8151
|
+
this.countNode();
|
|
8152
|
+
return {
|
|
8153
|
+
kind: "call",
|
|
8154
|
+
callee,
|
|
8155
|
+
args
|
|
8156
|
+
};
|
|
8157
|
+
}
|
|
8158
|
+
};
|
|
8159
|
+
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
8160
|
+
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
8161
|
+
function parseExpression(source) {
|
|
8162
|
+
return new Parser$2(tokenize(source)).parse();
|
|
8163
|
+
}
|
|
8164
|
+
Object.freeze({});
|
|
8165
|
+
/**
|
|
8166
|
+
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
8167
|
+
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
8168
|
+
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
8169
|
+
* one per read on a hot resolve path.
|
|
8170
|
+
*
|
|
8171
|
+
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
8172
|
+
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
8173
|
+
* callers is safe and maximises hit rate.
|
|
8174
|
+
*/
|
|
8175
|
+
var cache$10 = /* @__PURE__ */ new Map();
|
|
8176
|
+
function getCached(source) {
|
|
8177
|
+
const hit = cache$10.get(source);
|
|
8178
|
+
if (hit !== void 0) {
|
|
8179
|
+
cache$10.delete(source);
|
|
8180
|
+
cache$10.set(source, hit);
|
|
8181
|
+
return hit;
|
|
8182
|
+
}
|
|
8183
|
+
let result;
|
|
8184
|
+
try {
|
|
8185
|
+
result = {
|
|
8186
|
+
ok: true,
|
|
8187
|
+
parsed: parseExpression(source)
|
|
8188
|
+
};
|
|
8189
|
+
} catch (err) {
|
|
8190
|
+
result = {
|
|
8191
|
+
ok: false,
|
|
8192
|
+
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
8193
|
+
};
|
|
8194
|
+
}
|
|
8195
|
+
cache$10.set(source, result);
|
|
8196
|
+
if (cache$10.size > 256) {
|
|
8197
|
+
const oldest = cache$10.keys().next().value;
|
|
8198
|
+
if (oldest !== void 0) cache$10.delete(oldest);
|
|
8199
|
+
}
|
|
8200
|
+
return result;
|
|
8201
|
+
}
|
|
8202
|
+
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
8203
|
+
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
8204
|
+
function compileExpressionSafe(source) {
|
|
8205
|
+
return getCached(source);
|
|
8206
|
+
}
|
|
8207
|
+
/**
|
|
8208
|
+
* Author-time validation. Returns `null` when the source is valid, else a
|
|
8209
|
+
* human-readable error message. Checks: the expression compiles; binding count
|
|
8210
|
+
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
8211
|
+
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
8212
|
+
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
8213
|
+
*/
|
|
8214
|
+
function validateExpressionSource(src) {
|
|
8215
|
+
const names = Object.keys(src.bindings);
|
|
8216
|
+
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
8217
|
+
for (const name of names) {
|
|
8218
|
+
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
8219
|
+
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
8220
|
+
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
8221
|
+
}
|
|
8222
|
+
const compiled = compileExpressionSafe(src.expr);
|
|
8223
|
+
if (!compiled.ok) return compiled.error;
|
|
8224
|
+
const bound = new Set(names);
|
|
8225
|
+
for (const id of compiled.parsed.identifiers) {
|
|
8226
|
+
if (id === "now") continue;
|
|
8227
|
+
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
8228
|
+
}
|
|
8229
|
+
return null;
|
|
8230
|
+
}
|
|
8231
|
+
/**
|
|
7453
8232
|
* Accessory device helpers — shared across drivers.
|
|
7454
8233
|
*
|
|
7455
8234
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -8294,7 +9073,13 @@ onStatusChanged: { data: object({
|
|
|
8294
9073
|
}) } },
|
|
8295
9074
|
status: {
|
|
8296
9075
|
schema: BatteryStatusSchema,
|
|
8297
|
-
kind: "push"
|
|
9076
|
+
kind: "push",
|
|
9077
|
+
empty: {
|
|
9078
|
+
percentage: 0,
|
|
9079
|
+
charging: "none",
|
|
9080
|
+
sleeping: false,
|
|
9081
|
+
lastUpdated: 0
|
|
9082
|
+
}
|
|
8298
9083
|
},
|
|
8299
9084
|
/**
|
|
8300
9085
|
* Runtime-state slice — every provider that registers this cap
|
|
@@ -8433,6 +9218,10 @@ var RtspRestreamEntrySchema = object({
|
|
|
8433
9218
|
var BrokerRtspClientSchema = object({
|
|
8434
9219
|
sessionId: string$2(),
|
|
8435
9220
|
remoteAddr: string$2(),
|
|
9221
|
+
/** Client `User-Agent` (e.g. `recorder` for the recorder's RTSP pull), or
|
|
9222
|
+
* null/absent when the client sent none. Lets the UI label a consumer by
|
|
9223
|
+
* purpose. Optional so a client built against an older schema stays valid. */
|
|
9224
|
+
userAgent: string$2().nullish(),
|
|
8436
9225
|
playing: boolean(),
|
|
8437
9226
|
muted: boolean(),
|
|
8438
9227
|
connectedAt: number(),
|
|
@@ -9233,21 +10022,38 @@ var connectivityCapability = {
|
|
|
9233
10022
|
},
|
|
9234
10023
|
runtimeState: ConnectivityStatusSchema
|
|
9235
10024
|
};
|
|
10025
|
+
/**
|
|
10026
|
+
* Generic device-consumables capability — surfaces a device's
|
|
10027
|
+
* maintenance items (vacuum filters/brushes, replaceable cartridges,
|
|
10028
|
+
* descaling cycles, …) with their remaining life and an optional
|
|
10029
|
+
* "Replaced" reset action. Device-agnostic: any provider that knows its
|
|
10030
|
+
* device tracks consumables can register it; the cap declares no
|
|
10031
|
+
* vocabulary of its own — the provider names each item verbatim.
|
|
10032
|
+
*
|
|
10033
|
+
* Like `childLayout`, the cap is INERT until a provider sets items: no
|
|
10034
|
+
* provider populates it by guessing (no HA inference). The UI renders a
|
|
10035
|
+
* "No consumables reported" placeholder when `items` is empty.
|
|
10036
|
+
*/
|
|
10037
|
+
/** A single consumable item. Either a continuous `level` (remaining
|
|
10038
|
+
* life %) or a discrete `status` may be known — both may be null when a
|
|
10039
|
+
* provider only knows the item exists. `level` and `status` are not
|
|
10040
|
+
* mutually exclusive; a provider may report both. */
|
|
10041
|
+
var ConsumableItemSchema = object({
|
|
10042
|
+
/** Stable id, e.g. 'main-brush'. */
|
|
10043
|
+
key: string$2().min(1),
|
|
10044
|
+
/** Display name. */
|
|
10045
|
+
label: string$2().min(1),
|
|
10046
|
+
/** Remaining life % when known (0..100). */
|
|
10047
|
+
level: number().min(0).max(100).nullable(),
|
|
10048
|
+
/** Discrete state when known (binary mode). */
|
|
10049
|
+
status: _enum(["ok", "replace"]).nullable(),
|
|
10050
|
+
/** Ms epoch of the last replace, when known. */
|
|
10051
|
+
lastResetAt: number().nullable(),
|
|
10052
|
+
/** Whether `reset()` is meaningful for this item. */
|
|
10053
|
+
resettable: boolean()
|
|
10054
|
+
});
|
|
9236
10055
|
var ConsumablesStatusSchema = object({
|
|
9237
|
-
items: array(
|
|
9238
|
-
/** Stable id, e.g. 'main-brush'. */
|
|
9239
|
-
key: string$2().min(1),
|
|
9240
|
-
/** Display name. */
|
|
9241
|
-
label: string$2().min(1),
|
|
9242
|
-
/** Remaining life % when known (0..100). */
|
|
9243
|
-
level: number().min(0).max(100).nullable(),
|
|
9244
|
-
/** Discrete state when known (binary mode). */
|
|
9245
|
-
status: _enum(["ok", "replace"]).nullable(),
|
|
9246
|
-
/** Ms epoch of the last replace, when known. */
|
|
9247
|
-
lastResetAt: number().nullable(),
|
|
9248
|
-
/** Whether `reset()` is meaningful for this item. */
|
|
9249
|
-
resettable: boolean()
|
|
9250
|
-
})),
|
|
10056
|
+
items: array(ConsumableItemSchema),
|
|
9251
10057
|
lastChangedAt: number()
|
|
9252
10058
|
});
|
|
9253
10059
|
var consumablesCapability = {
|
|
@@ -9306,7 +10112,25 @@ reset: method(object({
|
|
|
9306
10112
|
}) },
|
|
9307
10113
|
status: {
|
|
9308
10114
|
schema: ConsumablesStatusSchema,
|
|
9309
|
-
kind: "push"
|
|
10115
|
+
kind: "push",
|
|
10116
|
+
empty: {
|
|
10117
|
+
items: [],
|
|
10118
|
+
lastChangedAt: 0
|
|
10119
|
+
},
|
|
10120
|
+
itemArray: {
|
|
10121
|
+
path: "items",
|
|
10122
|
+
keyField: "key",
|
|
10123
|
+
labelField: "label",
|
|
10124
|
+
itemSchema: ConsumableItemSchema,
|
|
10125
|
+
emptyItem: {
|
|
10126
|
+
key: "",
|
|
10127
|
+
label: "",
|
|
10128
|
+
level: null,
|
|
10129
|
+
status: null,
|
|
10130
|
+
lastResetAt: null,
|
|
10131
|
+
resettable: false
|
|
10132
|
+
}
|
|
10133
|
+
}
|
|
9310
10134
|
},
|
|
9311
10135
|
runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() })
|
|
9312
10136
|
};
|
|
@@ -10548,7 +11372,8 @@ var MotionAnalysisResultSchema = object({
|
|
|
10548
11372
|
});
|
|
10549
11373
|
method(object({
|
|
10550
11374
|
deviceId: number(),
|
|
10551
|
-
frame: FrameInputSchema
|
|
11375
|
+
frame: FrameInputSchema.optional(),
|
|
11376
|
+
frameHandle: FrameHandleSchema.optional()
|
|
10552
11377
|
}), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
|
|
10553
11378
|
deviceId: number(),
|
|
10554
11379
|
detected: boolean(),
|
|
@@ -10795,6 +11620,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
10795
11620
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
10796
11621
|
steps: array(PipelineStepInputSchema).min(1),
|
|
10797
11622
|
frame: FrameInputSchema.optional(),
|
|
11623
|
+
/**
|
|
11624
|
+
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
11625
|
+
* the decoded pixels live in. One more member of the one-of
|
|
11626
|
+
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
11627
|
+
*/
|
|
11628
|
+
frameHandle: FrameHandleSchema.optional(),
|
|
10798
11629
|
imageBase64: string$2().optional(),
|
|
10799
11630
|
/**
|
|
10800
11631
|
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
@@ -11037,6 +11868,31 @@ var ReportMotionInputSchema = object({
|
|
|
11037
11868
|
regions: array(MotionRegionSchema).readonly().optional()
|
|
11038
11869
|
});
|
|
11039
11870
|
/**
|
|
11871
|
+
* Where a runner gets a camera's decoded frames (cross-node Phase 2,
|
|
11872
|
+
* restream-owner model — P2c).
|
|
11873
|
+
*
|
|
11874
|
+
* - `local-broker` (DEFAULT): today's path — subscribe to the co-located
|
|
11875
|
+
* stream-broker's shm frame plane. Every pre-P2c attach payload (no
|
|
11876
|
+
* `frameSource` key) parses to this, so the field is additive with zero
|
|
11877
|
+
* behavior change.
|
|
11878
|
+
* - `remote-restream`: the detect node is NOT the camera's source-owner.
|
|
11879
|
+
* The runner acquires the owner's COMPRESSED passthrough restream
|
|
11880
|
+
* (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
|
|
11881
|
+
* double-pull guard) and decodes LOCALLY via a satellite frame plane +
|
|
11882
|
+
* pull-mode decoder session pinned to its own node. The shm ring stays
|
|
11883
|
+
* node-local; only H.264/H.265 packets cross the wire.
|
|
11884
|
+
* `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
|
|
11885
|
+
* when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
|
|
11886
|
+
* dials for the owner's restream.
|
|
11887
|
+
*/
|
|
11888
|
+
var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
|
|
11889
|
+
kind: literal("remote-restream"),
|
|
11890
|
+
/** The camera's source-owner node (slice 1: always the hub). */
|
|
11891
|
+
ownerNodeId: string$2(),
|
|
11892
|
+
/** Operator override for the owner host the runner dials. */
|
|
11893
|
+
hubHostnameOverride: string$2().optional()
|
|
11894
|
+
})]).describe("Per-camera frame-source mode for the runner (P2c)");
|
|
11895
|
+
/**
|
|
11040
11896
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
11041
11897
|
* specific runner instance via `attachCamera`. Carries everything the
|
|
11042
11898
|
* runner needs to subscribe to the local broker and execute inference.
|
|
@@ -11134,7 +11990,15 @@ var RunnerCameraConfigSchema = object({
|
|
|
11134
11990
|
*/
|
|
11135
11991
|
onboardMotionDrivesAnalyzer: boolean().default(true),
|
|
11136
11992
|
occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
|
|
11137
|
-
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
|
|
11993
|
+
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
|
|
11994
|
+
/**
|
|
11995
|
+
* Where this runner gets the camera's decoded frames (P2c). Defaulted so
|
|
11996
|
+
* every existing payload behaves as `local-broker` — the pre-Phase-2 path.
|
|
11997
|
+
* Populated with `remote-restream` by the orchestrator ONLY when the
|
|
11998
|
+
* camera's detect node differs from its source-owner (P2d, gated by the
|
|
11999
|
+
* `remoteSourcingNodes` rollout setting).
|
|
12000
|
+
*/
|
|
12001
|
+
frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
|
|
11138
12002
|
});
|
|
11139
12003
|
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;
|
|
11140
12004
|
/**
|
|
@@ -11698,6 +12562,157 @@ var numericSensorCapability = {
|
|
|
11698
12562
|
runtimeState: NumericSensorStatusSchema
|
|
11699
12563
|
};
|
|
11700
12564
|
/**
|
|
12565
|
+
* Feeder connectivity / power status — mirrors the HA petkit device-status
|
|
12566
|
+
* enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
|
|
12567
|
+
* `on_batteries` (running on battery backup). `null` until first reported.
|
|
12568
|
+
*/
|
|
12569
|
+
var PetFeederDeviceStatusSchema = _enum([
|
|
12570
|
+
"normal",
|
|
12571
|
+
"offline",
|
|
12572
|
+
"on_batteries"
|
|
12573
|
+
]);
|
|
12574
|
+
var gramsPortion = number().int().min(4).max(200);
|
|
12575
|
+
var PetFeederStatusSchema = object({
|
|
12576
|
+
/** Food currently in the bowl (grams). Null when the device has not
|
|
12577
|
+
* reported a reading yet. On dual-hopper models this is the combined
|
|
12578
|
+
* bowl reading; per-hopper levels live in `food1`/`food2`. */
|
|
12579
|
+
foodLevel: number().nullable(),
|
|
12580
|
+
/** Hopper-1 food level (grams) on dual-hopper feeders; null on
|
|
12581
|
+
* single-hopper models. */
|
|
12582
|
+
food1: number().nullable(),
|
|
12583
|
+
/** Hopper-2 food level (grams) on dual-hopper feeders; null on
|
|
12584
|
+
* single-hopper models. */
|
|
12585
|
+
food2: number().nullable(),
|
|
12586
|
+
/** Derived low-food flag — mirrors the HA `food_level` binary_sensor
|
|
12587
|
+
* (`device_class: problem`, on = low). True when the bowl is empty /
|
|
12588
|
+
* below the feeder's low threshold. */
|
|
12589
|
+
lowFood: boolean(),
|
|
12590
|
+
/** Battery charge 0..100 (%). Null on mains-powered models or when the
|
|
12591
|
+
* device has no battery reading. */
|
|
12592
|
+
batteryPower: number().min(0).max(100).nullable(),
|
|
12593
|
+
/** Days of desiccant life remaining. Null when the model has no
|
|
12594
|
+
* desiccant sensor. */
|
|
12595
|
+
desiccantLeftDays: number().nullable(),
|
|
12596
|
+
/** True while a feed is in progress. */
|
|
12597
|
+
feeding: boolean(),
|
|
12598
|
+
/** Decoded connectivity / power status (HA petkit device-status enum).
|
|
12599
|
+
* Null until the device has reported a status. */
|
|
12600
|
+
status: PetFeederDeviceStatusSchema.nullable(),
|
|
12601
|
+
/** Decoded human-readable fault message. Null (or the device's `no_error`
|
|
12602
|
+
* sentinel) means healthy; a non-null string is an active fault. Pairs
|
|
12603
|
+
* with `errorCode` for consumers that want the raw integer. */
|
|
12604
|
+
error: string$2().nullable(),
|
|
12605
|
+
/** Raw device error code (0 / null = no error). */
|
|
12606
|
+
errorCode: number().nullable(),
|
|
12607
|
+
/** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
|
|
12608
|
+
isDualHopper: boolean(),
|
|
12609
|
+
/** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
|
|
12610
|
+
childLock: boolean(),
|
|
12611
|
+
/** Front indicator-light setting. */
|
|
12612
|
+
indicatorLight: boolean(),
|
|
12613
|
+
/** Play a chime when dispensing. */
|
|
12614
|
+
feedSound: boolean(),
|
|
12615
|
+
/** Speaker / prompt volume level (device-scaled integer). */
|
|
12616
|
+
volume: number(),
|
|
12617
|
+
/** Ms epoch when the slice was last refreshed from the cloud. */
|
|
12618
|
+
lastFetchedAt: number()
|
|
12619
|
+
});
|
|
12620
|
+
var petFeederCapability = {
|
|
12621
|
+
name: "pet-feeder",
|
|
12622
|
+
scope: "device",
|
|
12623
|
+
deviceNative: true,
|
|
12624
|
+
mode: "singleton",
|
|
12625
|
+
deviceTypes: [DeviceType.PetFeeder],
|
|
12626
|
+
methods: {
|
|
12627
|
+
/**
|
|
12628
|
+
* Dispense food now. Single-hopper feeders take `grams`; dual-hopper
|
|
12629
|
+
* feeders (D4S/D4SH) accept `hopper1`/`hopper2` to target one or both
|
|
12630
|
+
* hoppers. All portions honour the 4–200 g hardware range. At least
|
|
12631
|
+
* one of the three must be present — the provider rejects an empty
|
|
12632
|
+
* request.
|
|
12633
|
+
*/
|
|
12634
|
+
feed: method(object({
|
|
12635
|
+
deviceId: number().int().nonnegative(),
|
|
12636
|
+
grams: gramsPortion.optional(),
|
|
12637
|
+
hopper1: gramsPortion.optional(),
|
|
12638
|
+
hopper2: gramsPortion.optional()
|
|
12639
|
+
}), _void(), {
|
|
12640
|
+
kind: "mutation",
|
|
12641
|
+
auth: "admin"
|
|
12642
|
+
}),
|
|
12643
|
+
/** Cancel an in-progress manual feed. */
|
|
12644
|
+
cancelFeed: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12645
|
+
kind: "mutation",
|
|
12646
|
+
auth: "admin"
|
|
12647
|
+
}),
|
|
12648
|
+
/** Reset the desiccant "days remaining" counter after replacing it. */
|
|
12649
|
+
resetDesiccant: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12650
|
+
kind: "mutation",
|
|
12651
|
+
auth: "admin"
|
|
12652
|
+
}),
|
|
12653
|
+
/** Mark a hopper as refilled (D4H/D4S/D4SH). */
|
|
12654
|
+
markFoodReplenished: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12655
|
+
kind: "mutation",
|
|
12656
|
+
auth: "admin"
|
|
12657
|
+
}),
|
|
12658
|
+
/** Call the pet with the recorded prompt (D3). */
|
|
12659
|
+
callPet: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12660
|
+
kind: "mutation",
|
|
12661
|
+
auth: "admin"
|
|
12662
|
+
}),
|
|
12663
|
+
/** Play a stored sound by id (D3 / D4H / D4SH). */
|
|
12664
|
+
playSound: method(object({
|
|
12665
|
+
deviceId: number().int().nonnegative(),
|
|
12666
|
+
soundId: number().int().nonnegative()
|
|
12667
|
+
}), _void(), {
|
|
12668
|
+
kind: "mutation",
|
|
12669
|
+
auth: "admin"
|
|
12670
|
+
}),
|
|
12671
|
+
/** Toggle the child-lock (manual-lock) setting. */
|
|
12672
|
+
setChildLock: method(object({
|
|
12673
|
+
deviceId: number().int().nonnegative(),
|
|
12674
|
+
on: boolean()
|
|
12675
|
+
}), _void(), {
|
|
12676
|
+
kind: "mutation",
|
|
12677
|
+
auth: "admin"
|
|
12678
|
+
}),
|
|
12679
|
+
/** Toggle the front indicator light. */
|
|
12680
|
+
setIndicatorLight: method(object({
|
|
12681
|
+
deviceId: number().int().nonnegative(),
|
|
12682
|
+
on: boolean()
|
|
12683
|
+
}), _void(), {
|
|
12684
|
+
kind: "mutation",
|
|
12685
|
+
auth: "admin"
|
|
12686
|
+
}),
|
|
12687
|
+
/** Toggle the dispense chime. */
|
|
12688
|
+
setFeedSound: method(object({
|
|
12689
|
+
deviceId: number().int().nonnegative(),
|
|
12690
|
+
on: boolean()
|
|
12691
|
+
}), _void(), {
|
|
12692
|
+
kind: "mutation",
|
|
12693
|
+
auth: "admin"
|
|
12694
|
+
}),
|
|
12695
|
+
/** Set the speaker / prompt volume level. */
|
|
12696
|
+
setVolume: method(object({
|
|
12697
|
+
deviceId: number().int().nonnegative(),
|
|
12698
|
+
level: number().int().nonnegative()
|
|
12699
|
+
}), _void(), {
|
|
12700
|
+
kind: "mutation",
|
|
12701
|
+
auth: "admin"
|
|
12702
|
+
})
|
|
12703
|
+
},
|
|
12704
|
+
status: {
|
|
12705
|
+
schema: PetFeederStatusSchema,
|
|
12706
|
+
kind: "poll"
|
|
12707
|
+
},
|
|
12708
|
+
/**
|
|
12709
|
+
* Runtime-state slice — mirrored by the kernel. UI feeder cards read
|
|
12710
|
+
* the full slice via `device.state.petFeeder.value` and refresh on
|
|
12711
|
+
* every poll without re-querying the provider.
|
|
12712
|
+
*/
|
|
12713
|
+
runtimeState: PetFeederStatusSchema
|
|
12714
|
+
};
|
|
12715
|
+
/**
|
|
11701
12716
|
* Multi-metric electrical meter. One slice can carry any combination
|
|
11702
12717
|
* of instantaneous power (W), cumulative energy (kWh), voltage (V),
|
|
11703
12718
|
* and current (A) — all fields optional so a single-metric source
|
|
@@ -13000,6 +14015,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
|
|
|
13000
14015
|
nativeObjectDetection: nativeObjectDetectionCapability,
|
|
13001
14016
|
notifier: notifierCapability,
|
|
13002
14017
|
numericSensor: numericSensorCapability,
|
|
14018
|
+
petFeeder: petFeederCapability,
|
|
13003
14019
|
powerMeter: powerMeterCapability,
|
|
13004
14020
|
presence: presenceCapability,
|
|
13005
14021
|
pressureSensor: pressureSensorCapability,
|
|
@@ -14965,10 +15981,12 @@ method(object({ codec: string$2() }), boolean()), method(_void(), object({
|
|
|
14965
15981
|
url: string$2()
|
|
14966
15982
|
}), _void()), method(object({
|
|
14967
15983
|
sessionId: string$2(),
|
|
14968
|
-
maxCount: number().default(1)
|
|
15984
|
+
maxCount: number().default(1),
|
|
15985
|
+
waitMs: number().optional()
|
|
14969
15986
|
}), array(DecodedFrameSchema)), method(object({
|
|
14970
15987
|
sessionId: string$2(),
|
|
14971
|
-
maxCount: number().default(1)
|
|
15988
|
+
maxCount: number().default(1),
|
|
15989
|
+
waitMs: number().optional()
|
|
14972
15990
|
}), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string$2() }), ShmRingStatsSchema.nullable()), method(object({
|
|
14973
15991
|
sessionId: string$2(),
|
|
14974
15992
|
config: DecoderSessionConfigSchema.partial()
|
|
@@ -15272,14 +16290,63 @@ var ChildLayoutEntrySchema = object({
|
|
|
15272
16290
|
collapsed: boolean().optional()
|
|
15273
16291
|
});
|
|
15274
16292
|
/** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
|
|
15275
|
-
* `device-management.ts`.
|
|
16293
|
+
* `device-management.ts`. Source is a union: a FIELD source copies a sibling
|
|
16294
|
+
* accessory's status field (`kind` optional/absent for wire compat); a
|
|
16295
|
+
* LITERAL source carries a per-device constant (no sibling is read); a
|
|
16296
|
+
* GLOBAL source (P2e) copies ANY device's status field, addressed by the
|
|
16297
|
+
* source device's full re-sync-stable `stableId`. */
|
|
16298
|
+
var DeviceLinkFieldSourceSchema = object({
|
|
16299
|
+
kind: literal("field").optional(),
|
|
16300
|
+
sourceKey: string$2(),
|
|
16301
|
+
cap: string$2(),
|
|
16302
|
+
fieldPath: string$2()
|
|
16303
|
+
});
|
|
16304
|
+
var DeviceLinkLiteralSourceSchema = object({
|
|
16305
|
+
kind: literal("literal"),
|
|
16306
|
+
value: union([
|
|
16307
|
+
string$2(),
|
|
16308
|
+
number(),
|
|
16309
|
+
boolean(),
|
|
16310
|
+
_null()
|
|
16311
|
+
])
|
|
16312
|
+
});
|
|
16313
|
+
var DeviceLinkGlobalSourceSchema = object({
|
|
16314
|
+
kind: literal("global"),
|
|
16315
|
+
sourceStableId: string$2(),
|
|
16316
|
+
cap: string$2(),
|
|
16317
|
+
fieldPath: string$2()
|
|
16318
|
+
});
|
|
16319
|
+
/** Expression source (Stage X): compute the target field from N named bindings
|
|
16320
|
+
* via the safe expression engine. Bindings are field | literal | global — never
|
|
16321
|
+
* another expression (no nesting). The `superRefine` runs the SAME author-time
|
|
16322
|
+
* validation as `validateExpressionSource` (compiles the expr, checks binding
|
|
16323
|
+
* names + identifier coverage) so every wire boundary that parses a DeviceLink
|
|
16324
|
+
* (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
|
|
16325
|
+
* Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
|
|
16326
|
+
var DeviceLinkExpressionSourceSchema = object({
|
|
16327
|
+
kind: literal("expression"),
|
|
16328
|
+
expr: string$2().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
16329
|
+
bindings: record(string$2().regex(EXPRESSION_IDENTIFIER_RE), union([
|
|
16330
|
+
DeviceLinkFieldSourceSchema,
|
|
16331
|
+
DeviceLinkLiteralSourceSchema,
|
|
16332
|
+
DeviceLinkGlobalSourceSchema
|
|
16333
|
+
]))
|
|
16334
|
+
}).superRefine((src, ctx) => {
|
|
16335
|
+
const err = validateExpressionSource(src);
|
|
16336
|
+
if (err !== null) ctx.addIssue({
|
|
16337
|
+
code: "custom",
|
|
16338
|
+
message: err,
|
|
16339
|
+
path: ["expr"]
|
|
16340
|
+
});
|
|
16341
|
+
});
|
|
15276
16342
|
var DeviceLinkSchema = object({
|
|
15277
16343
|
id: string$2(),
|
|
15278
|
-
source:
|
|
15279
|
-
|
|
15280
|
-
|
|
15281
|
-
|
|
15282
|
-
|
|
16344
|
+
source: union([
|
|
16345
|
+
DeviceLinkFieldSourceSchema,
|
|
16346
|
+
DeviceLinkLiteralSourceSchema,
|
|
16347
|
+
DeviceLinkGlobalSourceSchema,
|
|
16348
|
+
DeviceLinkExpressionSourceSchema
|
|
16349
|
+
]),
|
|
15283
16350
|
target: object({
|
|
15284
16351
|
cap: string$2(),
|
|
15285
16352
|
fieldPath: string$2(),
|
|
@@ -15308,6 +16375,31 @@ var DeviceLinkSchema = object({
|
|
|
15308
16375
|
})
|
|
15309
16376
|
]).optional()
|
|
15310
16377
|
});
|
|
16378
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
16379
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
16380
|
+
var DeviceCapDisplayOverrideSchema = object({
|
|
16381
|
+
unit: string$2().min(1).optional(),
|
|
16382
|
+
precision: number().int().min(0).max(10).optional()
|
|
16383
|
+
});
|
|
16384
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
16385
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
16386
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
16387
|
+
var DeviceDisplayOverrideSchema = object({
|
|
16388
|
+
icon: string$2().min(1).optional(),
|
|
16389
|
+
label: string$2().min(1).optional(),
|
|
16390
|
+
unit: string$2().min(1).optional(),
|
|
16391
|
+
precision: number().int().min(0).max(10).optional(),
|
|
16392
|
+
hidden: boolean().optional(),
|
|
16393
|
+
perCap: record(string$2(), DeviceCapDisplayOverrideSchema).optional()
|
|
16394
|
+
});
|
|
16395
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
16396
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
16397
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
16398
|
+
var RoleDisplayDefaultSchema = object({
|
|
16399
|
+
unit: string$2().min(1).optional(),
|
|
16400
|
+
precision: number().int().min(0).max(10).optional(),
|
|
16401
|
+
icon: string$2().min(1).optional()
|
|
16402
|
+
});
|
|
15311
16403
|
/**
|
|
15312
16404
|
* Serializable projection of a live IDevice.
|
|
15313
16405
|
* Returned by listAll, getDevice, getChildren.
|
|
@@ -15363,7 +16455,9 @@ var DeviceInfoSchema = object({
|
|
|
15363
16455
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
15364
16456
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
15365
16457
|
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
15366
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional()
|
|
16458
|
+
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
16459
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
16460
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
15367
16461
|
});
|
|
15368
16462
|
var ConfigEntrySchema = object({
|
|
15369
16463
|
key: string$2(),
|
|
@@ -15428,7 +16522,9 @@ var DeviceMetaSchema = object({
|
|
|
15428
16522
|
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
15429
16523
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
15430
16524
|
* Optional: only present for accessory children that carry a known role. */
|
|
15431
|
-
role: string$2().nullable().optional()
|
|
16525
|
+
role: string$2().nullable().optional(),
|
|
16526
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
16527
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
15432
16528
|
});
|
|
15433
16529
|
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
15434
16530
|
var ConfigUISchemaOutput = unknown().nullable();
|
|
@@ -15522,7 +16618,19 @@ method(object({
|
|
|
15522
16618
|
}), _void(), {
|
|
15523
16619
|
kind: "mutation",
|
|
15524
16620
|
auth: "admin"
|
|
15525
|
-
}), method(object({
|
|
16621
|
+
}), method(object({
|
|
16622
|
+
deviceId: number(),
|
|
16623
|
+
display: DeviceDisplayOverrideSchema.nullable()
|
|
16624
|
+
}), _void(), {
|
|
16625
|
+
kind: "mutation",
|
|
16626
|
+
auth: "admin"
|
|
16627
|
+
}), method(object({}), object({ defaults: record(string$2(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string$2(), RoleDisplayDefaultSchema) }), _void(), {
|
|
16628
|
+
kind: "mutation",
|
|
16629
|
+
auth: "admin"
|
|
16630
|
+
}), method(object({
|
|
16631
|
+
deviceId: number(),
|
|
16632
|
+
includeSynthesizable: boolean().optional()
|
|
16633
|
+
}), object({ caps: array(object({
|
|
15526
16634
|
cap: string$2(),
|
|
15527
16635
|
fields: array(object({
|
|
15528
16636
|
path: string$2(),
|
|
@@ -15532,8 +16640,13 @@ method(object({
|
|
|
15532
16640
|
"boolean",
|
|
15533
16641
|
"enum"
|
|
15534
16642
|
]),
|
|
15535
|
-
enumValues: array(string$2()).optional()
|
|
15536
|
-
|
|
16643
|
+
enumValues: array(string$2()).optional(),
|
|
16644
|
+
item: boolean().optional()
|
|
16645
|
+
})).readonly(),
|
|
16646
|
+
itemArray: object({
|
|
16647
|
+
path: string$2(),
|
|
16648
|
+
keyField: string$2()
|
|
16649
|
+
}).optional()
|
|
15537
16650
|
})).readonly() }), { kind: "query" }), method(object({
|
|
15538
16651
|
deviceId: number(),
|
|
15539
16652
|
role: string$2().nullable()
|
|
@@ -15603,7 +16716,11 @@ method(object({
|
|
|
15603
16716
|
deviceId: number(),
|
|
15604
16717
|
entries: array(object({
|
|
15605
16718
|
capName: string$2(),
|
|
15606
|
-
kind: _enum([
|
|
16719
|
+
kind: _enum([
|
|
16720
|
+
"native",
|
|
16721
|
+
"wrapped",
|
|
16722
|
+
"linked"
|
|
16723
|
+
]),
|
|
15607
16724
|
providerAddonId: string$2(),
|
|
15608
16725
|
providerNodeId: string$2(),
|
|
15609
16726
|
nativeAddonId: string$2()
|
|
@@ -15612,7 +16729,11 @@ method(object({
|
|
|
15612
16729
|
deviceId: number(),
|
|
15613
16730
|
entries: array(object({
|
|
15614
16731
|
capName: string$2(),
|
|
15615
|
-
kind: _enum([
|
|
16732
|
+
kind: _enum([
|
|
16733
|
+
"native",
|
|
16734
|
+
"wrapped",
|
|
16735
|
+
"linked"
|
|
16736
|
+
]),
|
|
15616
16737
|
providerAddonId: string$2(),
|
|
15617
16738
|
providerNodeId: string$2(),
|
|
15618
16739
|
nativeAddonId: string$2()
|
|
@@ -16102,7 +17223,7 @@ var AddBrokerInputSchema = object({
|
|
|
16102
17223
|
});
|
|
16103
17224
|
var AddBrokerResultSchema = object({ id: string$2() });
|
|
16104
17225
|
var IdInputSchema = object({ id: string$2() });
|
|
16105
|
-
var TestResultSchema = discriminatedUnion("ok", [object({
|
|
17226
|
+
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
16106
17227
|
ok: literal(true),
|
|
16107
17228
|
latencyMs: number()
|
|
16108
17229
|
}), object({
|
|
@@ -16125,7 +17246,7 @@ var StatusSchema = object({
|
|
|
16125
17246
|
brokerCount: number(),
|
|
16126
17247
|
embeddedRunning: boolean()
|
|
16127
17248
|
});
|
|
16128
|
-
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);
|
|
17249
|
+
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);
|
|
16129
17250
|
var NetworkEndpointSchema = object({
|
|
16130
17251
|
url: string$2(),
|
|
16131
17252
|
hostname: string$2(),
|
|
@@ -16159,23 +17280,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
|
16159
17280
|
sourcePort: number().optional()
|
|
16160
17281
|
});
|
|
16161
17282
|
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
16162
|
-
|
|
16163
|
-
|
|
17283
|
+
/**
|
|
17284
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
17285
|
+
*
|
|
17286
|
+
* Apprise-derived model (see
|
|
17287
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
17288
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
17289
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
17290
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
17291
|
+
* message to what the kind supports — callers never special-case a service.
|
|
17292
|
+
*
|
|
17293
|
+
* DESIGN DECISIONS (locked):
|
|
17294
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
17295
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
17296
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
17297
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
17298
|
+
* alternative would fork the UI per addon and cannot host the
|
|
17299
|
+
* discovery→adopt flow.
|
|
17300
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
17301
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
17302
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
17303
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
17304
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
17305
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
17306
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
17307
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
17308
|
+
* base64 fallback needed.
|
|
17309
|
+
*
|
|
17310
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
17311
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
17312
|
+
* admin "Integrations" page.
|
|
17313
|
+
*/
|
|
17314
|
+
/**
|
|
17315
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
17316
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
17317
|
+
*/
|
|
17318
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
17319
|
+
"image",
|
|
17320
|
+
"video",
|
|
17321
|
+
"gif",
|
|
17322
|
+
"audio",
|
|
17323
|
+
"icon"
|
|
17324
|
+
]);
|
|
17325
|
+
/**
|
|
17326
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
17327
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
17328
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
17329
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
17330
|
+
*/
|
|
17331
|
+
var AttachmentSchema = object({
|
|
17332
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
17333
|
+
url: string$2().optional(),
|
|
17334
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
17335
|
+
mime: string$2().optional(),
|
|
17336
|
+
name: string$2().optional()
|
|
17337
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
17338
|
+
var NotificationFormatSchema = _enum([
|
|
17339
|
+
"text",
|
|
17340
|
+
"markdown",
|
|
17341
|
+
"html"
|
|
17342
|
+
]);
|
|
17343
|
+
/** A single tap-through action button. */
|
|
17344
|
+
var NotificationActionSchema = object({
|
|
17345
|
+
id: string$2(),
|
|
17346
|
+
label: string$2(),
|
|
17347
|
+
url: string$2().optional()
|
|
17348
|
+
});
|
|
17349
|
+
/**
|
|
17350
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
17351
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
17352
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
17353
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
17354
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
17355
|
+
* `priority` for that one target.
|
|
17356
|
+
*/
|
|
17357
|
+
var NotificationSchema = object({
|
|
16164
17358
|
body: string$2(),
|
|
16165
|
-
|
|
17359
|
+
title: string$2().optional(),
|
|
17360
|
+
format: NotificationFormatSchema.default("text"),
|
|
17361
|
+
priority: number().int().min(1).max(5).default(3),
|
|
17362
|
+
level: string$2().optional(),
|
|
17363
|
+
attachments: array(AttachmentSchema).optional(),
|
|
17364
|
+
clickUrl: string$2().optional(),
|
|
17365
|
+
actions: array(NotificationActionSchema).optional(),
|
|
17366
|
+
sound: string$2().optional(),
|
|
17367
|
+
ttl: number().optional(),
|
|
17368
|
+
tag: string$2().optional(),
|
|
16166
17369
|
deviceId: number().optional(),
|
|
16167
17370
|
eventId: string$2().optional(),
|
|
16168
|
-
priority: _enum([
|
|
16169
|
-
"low",
|
|
16170
|
-
"normal",
|
|
16171
|
-
"high",
|
|
16172
|
-
"critical"
|
|
16173
|
-
]).default("normal"),
|
|
16174
17371
|
metadata: record(string$2(), unknown()).optional()
|
|
16175
|
-
})
|
|
17372
|
+
});
|
|
17373
|
+
/** One declared native severity/priority level for a kind. */
|
|
17374
|
+
var TargetKindLevelSchema = object({
|
|
17375
|
+
id: string$2(),
|
|
17376
|
+
label: string$2(),
|
|
17377
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
17378
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
17379
|
+
flags: object({
|
|
17380
|
+
critical: boolean().optional(),
|
|
17381
|
+
silent: boolean().optional(),
|
|
17382
|
+
noPush: boolean().optional()
|
|
17383
|
+
}).optional(),
|
|
17384
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
17385
|
+
requires: array(string$2()).optional(),
|
|
17386
|
+
description: string$2().optional()
|
|
17387
|
+
});
|
|
17388
|
+
/** The full capability block consulted before dispatch. */
|
|
17389
|
+
var TargetKindCapsSchema = object({
|
|
17390
|
+
attachments: object({
|
|
17391
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
17392
|
+
mode: _enum([
|
|
17393
|
+
"url",
|
|
17394
|
+
"bytes",
|
|
17395
|
+
"both"
|
|
17396
|
+
]),
|
|
17397
|
+
max: number().int().nonnegative(),
|
|
17398
|
+
maxBytes: number().int().positive().optional()
|
|
17399
|
+
}),
|
|
17400
|
+
/** Max action buttons (0 = none). */
|
|
17401
|
+
actions: number().int().nonnegative(),
|
|
17402
|
+
levels: array(TargetKindLevelSchema),
|
|
17403
|
+
format: array(NotificationFormatSchema),
|
|
17404
|
+
clickUrl: boolean(),
|
|
17405
|
+
sound: boolean(),
|
|
17406
|
+
ttl: boolean(),
|
|
17407
|
+
bodyMaxLen: number().int().positive()
|
|
17408
|
+
});
|
|
17409
|
+
/**
|
|
17410
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
17411
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
17412
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
17413
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
17414
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
17415
|
+
*/
|
|
17416
|
+
var ConfigSchemaPassthrough = unknown();
|
|
17417
|
+
var TargetKindSchema = object({
|
|
17418
|
+
kind: string$2(),
|
|
17419
|
+
label: string$2(),
|
|
17420
|
+
icon: string$2(),
|
|
17421
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
17422
|
+
addonId: string$2(),
|
|
17423
|
+
configSchema: ConfigSchemaPassthrough,
|
|
17424
|
+
supportsDiscovery: boolean(),
|
|
17425
|
+
caps: TargetKindCapsSchema
|
|
17426
|
+
});
|
|
17427
|
+
/**
|
|
17428
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
17429
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
17430
|
+
* round-trip a stored secret to the UI.
|
|
17431
|
+
*/
|
|
17432
|
+
var TargetSchema = object({
|
|
17433
|
+
id: string$2(),
|
|
17434
|
+
name: string$2(),
|
|
17435
|
+
kind: string$2(),
|
|
17436
|
+
addonId: string$2(),
|
|
17437
|
+
enabled: boolean(),
|
|
17438
|
+
config: record(string$2(), unknown())
|
|
17439
|
+
});
|
|
17440
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
17441
|
+
var DiscoveredTargetSchema = object({
|
|
17442
|
+
kind: string$2(),
|
|
17443
|
+
suggestedName: string$2(),
|
|
17444
|
+
config: record(string$2(), unknown())
|
|
17445
|
+
});
|
|
17446
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
17447
|
+
var RenderedAsSchema = object({
|
|
17448
|
+
level: string$2(),
|
|
17449
|
+
format: NotificationFormatSchema,
|
|
17450
|
+
attachmentsSent: number().int().nonnegative(),
|
|
17451
|
+
actionsSent: number().int().nonnegative(),
|
|
17452
|
+
truncated: boolean(),
|
|
17453
|
+
dropped: array(string$2())
|
|
17454
|
+
});
|
|
17455
|
+
var SendResultSchema = object({
|
|
16176
17456
|
success: boolean(),
|
|
16177
|
-
error: string$2().optional()
|
|
16178
|
-
|
|
17457
|
+
error: string$2().optional(),
|
|
17458
|
+
renderedAs: RenderedAsSchema.optional()
|
|
17459
|
+
});
|
|
17460
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
17461
|
+
var TestResultSchema = SendResultSchema;
|
|
17462
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
|
|
17463
|
+
kind: string$2(),
|
|
17464
|
+
config: record(string$2(), unknown()).optional()
|
|
17465
|
+
}), array(DiscoveredTargetSchema)), method(object({
|
|
17466
|
+
targetId: string$2(),
|
|
17467
|
+
notification: NotificationSchema
|
|
17468
|
+
}), SendResultSchema, { kind: "mutation" }), method(object({
|
|
17469
|
+
targetId: string$2(),
|
|
17470
|
+
sample: NotificationSchema.optional()
|
|
17471
|
+
}), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string$2() }), _void(), { kind: "mutation" }), method(object({
|
|
17472
|
+
targetId: string$2(),
|
|
17473
|
+
enabled: boolean()
|
|
17474
|
+
}), _void(), { kind: "mutation" });
|
|
16179
17475
|
/**
|
|
16180
17476
|
* Zod schemas for persisted record types.
|
|
16181
17477
|
*
|
|
@@ -19214,7 +20510,10 @@ var HwAccelBackendInputSchema = _enum([
|
|
|
19214
20510
|
"webgpu",
|
|
19215
20511
|
"none"
|
|
19216
20512
|
]).nullable().optional();
|
|
19217
|
-
var HwAccelResolutionSchema = object({
|
|
20513
|
+
var HwAccelResolutionSchema = object({
|
|
20514
|
+
preferred: array(string$2()).readonly(),
|
|
20515
|
+
rationale: string$2()
|
|
20516
|
+
});
|
|
19218
20517
|
var HardwareEncoderIdSchema = _enum([
|
|
19219
20518
|
"h264_videotoolbox",
|
|
19220
20519
|
"hevc_videotoolbox",
|
|
@@ -19319,10 +20618,7 @@ var ResolvedInferenceConfigSchema = object({
|
|
|
19319
20618
|
format: ModelFormatSchema,
|
|
19320
20619
|
reason: string$2()
|
|
19321
20620
|
});
|
|
19322
|
-
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
|
|
19323
|
-
prefer: HwAccelBackendInputSchema,
|
|
19324
|
-
nodeId: string$2().optional()
|
|
19325
|
-
}), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
20621
|
+
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
19326
20622
|
kind: "mutation",
|
|
19327
20623
|
auth: "admin"
|
|
19328
20624
|
}), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
|
|
@@ -19381,6 +20677,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
|
|
|
19381
20677
|
kind: "mutation",
|
|
19382
20678
|
auth: "admin"
|
|
19383
20679
|
});
|
|
20680
|
+
/**
|
|
20681
|
+
* `recording` cap — footage availability + HLS playback manifests + per-device
|
|
20682
|
+
* recording config. NOTE on events (source of truth, R5/C3): this cap carries
|
|
20683
|
+
* NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
|
|
20684
|
+
* events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
|
|
20685
|
+
* rows); the recorder's internal EventMap markers are ephemeral in-RAM
|
|
20686
|
+
* annotations that are not exposed here and must not be treated as an event
|
|
20687
|
+
* feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
|
|
20688
|
+
* (`interfaces/recording-config.ts`).
|
|
20689
|
+
*/
|
|
19384
20690
|
var RecordingStatusSchema = object({
|
|
19385
20691
|
deviceId: number(),
|
|
19386
20692
|
enabled: boolean(),
|
|
@@ -21017,6 +22323,12 @@ Object.freeze({
|
|
|
21017
22323
|
addonId: null,
|
|
21018
22324
|
access: "view"
|
|
21019
22325
|
},
|
|
22326
|
+
"deviceManager.getRoleDisplayDefaults": {
|
|
22327
|
+
capName: "device-manager",
|
|
22328
|
+
capScope: "system",
|
|
22329
|
+
addonId: null,
|
|
22330
|
+
access: "view"
|
|
22331
|
+
},
|
|
21020
22332
|
"deviceManager.getSettingsSchema": {
|
|
21021
22333
|
capName: "device-manager",
|
|
21022
22334
|
capScope: "system",
|
|
@@ -21167,6 +22479,12 @@ Object.freeze({
|
|
|
21167
22479
|
addonId: null,
|
|
21168
22480
|
access: "create"
|
|
21169
22481
|
},
|
|
22482
|
+
"deviceManager.setDisplay": {
|
|
22483
|
+
capName: "device-manager",
|
|
22484
|
+
capScope: "system",
|
|
22485
|
+
addonId: null,
|
|
22486
|
+
access: "create"
|
|
22487
|
+
},
|
|
21170
22488
|
"deviceManager.setIntegrationId": {
|
|
21171
22489
|
capName: "device-manager",
|
|
21172
22490
|
capScope: "system",
|
|
@@ -21209,6 +22527,12 @@ Object.freeze({
|
|
|
21209
22527
|
addonId: null,
|
|
21210
22528
|
access: "create"
|
|
21211
22529
|
},
|
|
22530
|
+
"deviceManager.setRoleDisplayDefaults": {
|
|
22531
|
+
capName: "device-manager",
|
|
22532
|
+
capScope: "system",
|
|
22533
|
+
addonId: null,
|
|
22534
|
+
access: "create"
|
|
22535
|
+
},
|
|
21212
22536
|
"deviceManager.setStreamProfileMap": {
|
|
21213
22537
|
capName: "device-manager",
|
|
21214
22538
|
capScope: "system",
|
|
@@ -22187,13 +23511,49 @@ Object.freeze({
|
|
|
22187
23511
|
addonId: null,
|
|
22188
23512
|
access: "create"
|
|
22189
23513
|
},
|
|
23514
|
+
"notificationOutput.deleteTarget": {
|
|
23515
|
+
capName: "notification-output",
|
|
23516
|
+
capScope: "system",
|
|
23517
|
+
addonId: null,
|
|
23518
|
+
access: "delete"
|
|
23519
|
+
},
|
|
23520
|
+
"notificationOutput.discoverTargets": {
|
|
23521
|
+
capName: "notification-output",
|
|
23522
|
+
capScope: "system",
|
|
23523
|
+
addonId: null,
|
|
23524
|
+
access: "view"
|
|
23525
|
+
},
|
|
23526
|
+
"notificationOutput.listTargetKinds": {
|
|
23527
|
+
capName: "notification-output",
|
|
23528
|
+
capScope: "system",
|
|
23529
|
+
addonId: null,
|
|
23530
|
+
access: "view"
|
|
23531
|
+
},
|
|
23532
|
+
"notificationOutput.listTargets": {
|
|
23533
|
+
capName: "notification-output",
|
|
23534
|
+
capScope: "system",
|
|
23535
|
+
addonId: null,
|
|
23536
|
+
access: "view"
|
|
23537
|
+
},
|
|
22190
23538
|
"notificationOutput.send": {
|
|
22191
23539
|
capName: "notification-output",
|
|
22192
23540
|
capScope: "system",
|
|
22193
23541
|
addonId: null,
|
|
22194
23542
|
access: "create"
|
|
22195
23543
|
},
|
|
22196
|
-
"notificationOutput.
|
|
23544
|
+
"notificationOutput.setTargetEnabled": {
|
|
23545
|
+
capName: "notification-output",
|
|
23546
|
+
capScope: "system",
|
|
23547
|
+
addonId: null,
|
|
23548
|
+
access: "create"
|
|
23549
|
+
},
|
|
23550
|
+
"notificationOutput.testTarget": {
|
|
23551
|
+
capName: "notification-output",
|
|
23552
|
+
capScope: "system",
|
|
23553
|
+
addonId: null,
|
|
23554
|
+
access: "create"
|
|
23555
|
+
},
|
|
23556
|
+
"notificationOutput.upsertTarget": {
|
|
22197
23557
|
capName: "notification-output",
|
|
22198
23558
|
capScope: "system",
|
|
22199
23559
|
addonId: null,
|
|
@@ -22223,6 +23583,66 @@ Object.freeze({
|
|
|
22223
23583
|
addonId: null,
|
|
22224
23584
|
access: "create"
|
|
22225
23585
|
},
|
|
23586
|
+
"petFeeder.callPet": {
|
|
23587
|
+
capName: "pet-feeder",
|
|
23588
|
+
capScope: "device",
|
|
23589
|
+
addonId: null,
|
|
23590
|
+
access: "create"
|
|
23591
|
+
},
|
|
23592
|
+
"petFeeder.cancelFeed": {
|
|
23593
|
+
capName: "pet-feeder",
|
|
23594
|
+
capScope: "device",
|
|
23595
|
+
addonId: null,
|
|
23596
|
+
access: "create"
|
|
23597
|
+
},
|
|
23598
|
+
"petFeeder.feed": {
|
|
23599
|
+
capName: "pet-feeder",
|
|
23600
|
+
capScope: "device",
|
|
23601
|
+
addonId: null,
|
|
23602
|
+
access: "create"
|
|
23603
|
+
},
|
|
23604
|
+
"petFeeder.markFoodReplenished": {
|
|
23605
|
+
capName: "pet-feeder",
|
|
23606
|
+
capScope: "device",
|
|
23607
|
+
addonId: null,
|
|
23608
|
+
access: "create"
|
|
23609
|
+
},
|
|
23610
|
+
"petFeeder.playSound": {
|
|
23611
|
+
capName: "pet-feeder",
|
|
23612
|
+
capScope: "device",
|
|
23613
|
+
addonId: null,
|
|
23614
|
+
access: "create"
|
|
23615
|
+
},
|
|
23616
|
+
"petFeeder.resetDesiccant": {
|
|
23617
|
+
capName: "pet-feeder",
|
|
23618
|
+
capScope: "device",
|
|
23619
|
+
addonId: null,
|
|
23620
|
+
access: "delete"
|
|
23621
|
+
},
|
|
23622
|
+
"petFeeder.setChildLock": {
|
|
23623
|
+
capName: "pet-feeder",
|
|
23624
|
+
capScope: "device",
|
|
23625
|
+
addonId: null,
|
|
23626
|
+
access: "create"
|
|
23627
|
+
},
|
|
23628
|
+
"petFeeder.setFeedSound": {
|
|
23629
|
+
capName: "pet-feeder",
|
|
23630
|
+
capScope: "device",
|
|
23631
|
+
addonId: null,
|
|
23632
|
+
access: "create"
|
|
23633
|
+
},
|
|
23634
|
+
"petFeeder.setIndicatorLight": {
|
|
23635
|
+
capName: "pet-feeder",
|
|
23636
|
+
capScope: "device",
|
|
23637
|
+
addonId: null,
|
|
23638
|
+
access: "create"
|
|
23639
|
+
},
|
|
23640
|
+
"petFeeder.setVolume": {
|
|
23641
|
+
capName: "pet-feeder",
|
|
23642
|
+
capScope: "device",
|
|
23643
|
+
addonId: null,
|
|
23644
|
+
access: "create"
|
|
23645
|
+
},
|
|
22226
23646
|
"pipelineAnalytics.clearTracks": {
|
|
22227
23647
|
capName: "pipeline-analytics",
|
|
22228
23648
|
capScope: "device",
|