@camstack/addon-provider-wyze 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.mjs
CHANGED
|
@@ -4638,7 +4638,7 @@ function _instanceof(cls, params = {}) {
|
|
|
4638
4638
|
return inst;
|
|
4639
4639
|
}
|
|
4640
4640
|
//#endregion
|
|
4641
|
-
//#region ../types/dist/sleep-
|
|
4641
|
+
//#region ../types/dist/sleep-BiDFW0E7.mjs
|
|
4642
4642
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4643
4643
|
EventCategory["SystemBoot"] = "system.boot";
|
|
4644
4644
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -5451,6 +5451,100 @@ function createDurableState(deps) {
|
|
|
5451
5451
|
};
|
|
5452
5452
|
}
|
|
5453
5453
|
/**
|
|
5454
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
5455
|
+
*
|
|
5456
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
5457
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
5458
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
5459
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
5460
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
5461
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
5462
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
5463
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
5464
|
+
*
|
|
5465
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
5466
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
5467
|
+
* schema and routes reads/writes through these helpers.
|
|
5468
|
+
*
|
|
5469
|
+
* ## No bare-key fallback — deliberate
|
|
5470
|
+
*
|
|
5471
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
5472
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
5473
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
5474
|
+
* the store is invisible to every node, hub included, so one node's
|
|
5475
|
+
* selection can never leak onto another. (This generalizes the
|
|
5476
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
5477
|
+
* arbitrary set of per-node field keys.)
|
|
5478
|
+
*
|
|
5479
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
5480
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
5481
|
+
*/
|
|
5482
|
+
/**
|
|
5483
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
5484
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
5485
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
5486
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
5487
|
+
*/
|
|
5488
|
+
function normalizeNodeId(raw) {
|
|
5489
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
5490
|
+
const slashIdx = raw.indexOf("/");
|
|
5491
|
+
if (slashIdx < 0) return raw;
|
|
5492
|
+
const bare = raw.slice(0, slashIdx);
|
|
5493
|
+
return bare === "" ? "hub" : bare;
|
|
5494
|
+
}
|
|
5495
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
5496
|
+
function nodeScopedKey(base, nodeId) {
|
|
5497
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
5498
|
+
}
|
|
5499
|
+
/**
|
|
5500
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
5501
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
5502
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
5503
|
+
* schema `default` win on `undefined`.
|
|
5504
|
+
*/
|
|
5505
|
+
function readNodeValue(store, base, nodeId) {
|
|
5506
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
5507
|
+
}
|
|
5508
|
+
/**
|
|
5509
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
5510
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
5511
|
+
* the write path so a save for one node never clobbers another node's value
|
|
5512
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
5513
|
+
* patch is not mutated.
|
|
5514
|
+
*/
|
|
5515
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
5516
|
+
const out = {};
|
|
5517
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
5518
|
+
return out;
|
|
5519
|
+
}
|
|
5520
|
+
/**
|
|
5521
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
5522
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
5523
|
+
* values:
|
|
5524
|
+
*
|
|
5525
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
5526
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
5527
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
5528
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
5529
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
5530
|
+
* left ABSENT so the field's schema `default` wins.
|
|
5531
|
+
*
|
|
5532
|
+
* Returns a new object — the input store is not mutated.
|
|
5533
|
+
*/
|
|
5534
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
5535
|
+
const out = {};
|
|
5536
|
+
for (const [key, value] of Object.entries(store)) {
|
|
5537
|
+
if (key.includes("@")) continue;
|
|
5538
|
+
if (perNodeKeys.has(key)) continue;
|
|
5539
|
+
out[key] = value;
|
|
5540
|
+
}
|
|
5541
|
+
for (const base of perNodeKeys) {
|
|
5542
|
+
const value = readNodeValue(store, base, nodeId);
|
|
5543
|
+
if (value !== void 0) out[base] = value;
|
|
5544
|
+
}
|
|
5545
|
+
return out;
|
|
5546
|
+
}
|
|
5547
|
+
/**
|
|
5454
5548
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5455
5549
|
*
|
|
5456
5550
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -5618,23 +5712,63 @@ var BaseAddon = class {
|
|
|
5618
5712
|
deviceSettingsSchema() {
|
|
5619
5713
|
return null;
|
|
5620
5714
|
}
|
|
5621
|
-
async getGlobalSettings(overlay, cap,
|
|
5715
|
+
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5622
5716
|
const schema = this.globalSettingsSchema(cap);
|
|
5623
5717
|
if (!schema) return { sections: [] };
|
|
5624
|
-
const
|
|
5718
|
+
const projected = await this.resolveGlobalStore(nodeId, cap);
|
|
5625
5719
|
return hydrateSchema(schema, overlay ? {
|
|
5626
|
-
...
|
|
5720
|
+
...projected,
|
|
5627
5721
|
...overlay
|
|
5628
|
-
} :
|
|
5722
|
+
} : projected);
|
|
5629
5723
|
}
|
|
5630
|
-
|
|
5631
|
-
|
|
5724
|
+
/**
|
|
5725
|
+
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5726
|
+
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5727
|
+
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
5728
|
+
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
5729
|
+
* A no-op passthrough when the schema declares no `perNode` field.
|
|
5730
|
+
*
|
|
5731
|
+
* This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
|
|
5732
|
+
* the store for custom option logic (option narrowing, value snapping) to
|
|
5733
|
+
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
5734
|
+
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
5735
|
+
*/
|
|
5736
|
+
async resolveGlobalStore(nodeId, cap) {
|
|
5737
|
+
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
5738
|
+
const keys = this.perNodeKeys(cap);
|
|
5739
|
+
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5740
|
+
return keys.size > 0 ? projectStore(raw, keys, node) : raw;
|
|
5741
|
+
}
|
|
5742
|
+
async updateGlobalSettings(patch, nodeId) {
|
|
5743
|
+
const keys = this.perNodeKeys();
|
|
5744
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5745
|
+
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5746
|
+
const barePatch = patch;
|
|
5747
|
+
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
5748
|
+
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
5749
|
+
if (target !== localNode) return;
|
|
5632
5750
|
await this.resolveConfig();
|
|
5633
5751
|
await this.onConfigChanged();
|
|
5634
5752
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
5635
5753
|
this.maybeAutoRestart(patch, this.globalSettingsSchema());
|
|
5636
5754
|
}
|
|
5637
5755
|
/**
|
|
5756
|
+
* The set of field keys the global settings schema declares `perNode: true`
|
|
5757
|
+
* — derived once per `cap` argument and memoized (schemas are static
|
|
5758
|
+
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
5759
|
+
* settings API behaves exactly like the legacy node-agnostic one.
|
|
5760
|
+
*/
|
|
5761
|
+
_perNodeKeysCache = /* @__PURE__ */ new Map();
|
|
5762
|
+
perNodeKeys(cap) {
|
|
5763
|
+
const cacheKey = cap ?? "";
|
|
5764
|
+
const cached = this._perNodeKeysCache.get(cacheKey);
|
|
5765
|
+
if (cached) return cached;
|
|
5766
|
+
const schema = this.globalSettingsSchema(cap);
|
|
5767
|
+
const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
5768
|
+
this._perNodeKeysCache.set(cacheKey, keys);
|
|
5769
|
+
return keys;
|
|
5770
|
+
}
|
|
5771
|
+
/**
|
|
5638
5772
|
* If any field in `patch` is marked `requiresRestart` in `schema`,
|
|
5639
5773
|
* schedule an addon restart for the next tick. Deferred via
|
|
5640
5774
|
* `setImmediate` so the tRPC mutation that triggered the write has
|
|
@@ -5787,12 +5921,19 @@ var BaseAddon = class {
|
|
|
5787
5921
|
* The merge is shallow: each key in `defaults` is checked against the store.
|
|
5788
5922
|
* Only keys present in defaults are read — the store can contain extra keys
|
|
5789
5923
|
* (e.g. from older versions) without polluting the typed config.
|
|
5924
|
+
*
|
|
5925
|
+
* Keys the global settings schema declares `perNode: true` resolve from
|
|
5926
|
+
* THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
|
|
5927
|
+
* from the bare key — so a per-node field resolves to this node's own
|
|
5928
|
+
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
5790
5929
|
*/
|
|
5791
5930
|
async resolveConfig() {
|
|
5792
5931
|
const stored = await this.readAddonStoreWithRetry();
|
|
5932
|
+
const perNode = this.perNodeKeys();
|
|
5933
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5793
5934
|
const resolved = { ...this.defaults };
|
|
5794
5935
|
for (const key of Object.keys(this.defaults)) {
|
|
5795
|
-
const storedValue = stored[key];
|
|
5936
|
+
const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
|
|
5796
5937
|
if (storedValue !== void 0 && storedValue !== null) {
|
|
5797
5938
|
const defaultType = typeof this.defaults[key];
|
|
5798
5939
|
if (typeof storedValue === defaultType) resolved[key] = storedValue;
|
|
@@ -5876,6 +6017,27 @@ var BaseAddon = class {
|
|
|
5876
6017
|
}
|
|
5877
6018
|
};
|
|
5878
6019
|
/**
|
|
6020
|
+
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
6021
|
+
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
6022
|
+
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6023
|
+
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6024
|
+
*/
|
|
6025
|
+
function collectPerNodeFieldKeys(fields) {
|
|
6026
|
+
const collected = [];
|
|
6027
|
+
for (const field of fields) {
|
|
6028
|
+
if (field.type === "group") {
|
|
6029
|
+
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
6030
|
+
continue;
|
|
6031
|
+
}
|
|
6032
|
+
if (field.type === "sub-tabs") {
|
|
6033
|
+
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
6034
|
+
continue;
|
|
6035
|
+
}
|
|
6036
|
+
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
6037
|
+
}
|
|
6038
|
+
return collected;
|
|
6039
|
+
}
|
|
6040
|
+
/**
|
|
5879
6041
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
5880
6042
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
5881
6043
|
* envelopes pass through; void stays void.
|
|
@@ -5900,6 +6062,7 @@ var CamStreamKindSchema = _enum([
|
|
|
5900
6062
|
"pull-rtsp",
|
|
5901
6063
|
"pull-rtmp",
|
|
5902
6064
|
"pull-http",
|
|
6065
|
+
"pull-flv",
|
|
5903
6066
|
"pull-rfc4571",
|
|
5904
6067
|
"push-annexb",
|
|
5905
6068
|
"derived"
|
|
@@ -6282,6 +6445,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
6282
6445
|
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
6283
6446
|
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
6284
6447
|
DeviceType["Image"] = "image";
|
|
6448
|
+
/** Smart pet feeder — cloud-connected food dispenser with a bowl food
|
|
6449
|
+
* level, battery, desiccant life, feeding state and manual-feed /
|
|
6450
|
+
* call-pet / maintenance actions. Installed with the `pet-feeder` cap;
|
|
6451
|
+
* dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
|
|
6452
|
+
* native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
|
|
6453
|
+
* integrations sharing the same food/desiccant/hopper surface. */
|
|
6454
|
+
DeviceType["PetFeeder"] = "pet-feeder";
|
|
6285
6455
|
return DeviceType;
|
|
6286
6456
|
}({});
|
|
6287
6457
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -7059,7 +7229,21 @@ var StorageLocationDeclarationSchema = object({
|
|
|
7059
7229
|
* slots (e.g. `recordingsLow` → `recordings`) so operators only need to
|
|
7060
7230
|
* configure the primary location.
|
|
7061
7231
|
*/
|
|
7062
|
-
defaultsTo: string().optional()
|
|
7232
|
+
defaultsTo: string().optional(),
|
|
7233
|
+
/**
|
|
7234
|
+
* Which node root the seeded `<id>:default` instance is placed under on a
|
|
7235
|
+
* FRESH install:
|
|
7236
|
+
* - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
|
|
7237
|
+
* the appData volume. Right for small/durable data (backups, logs, models).
|
|
7238
|
+
* - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
|
|
7239
|
+
* env is set, else falls back to the data root. Right for bulky, hot media
|
|
7240
|
+
* (recordings, event media) that should stay off the appData disk.
|
|
7241
|
+
*
|
|
7242
|
+
* Only affects the seeded default's `basePath`; operators can repoint any
|
|
7243
|
+
* location afterwards, and a `defaultsTo` slot inherits its parent's root
|
|
7244
|
+
* regardless of this field. Absent (the common case) is treated as `'data'`.
|
|
7245
|
+
*/
|
|
7246
|
+
defaultRoot: _enum(["data", "media"]).optional()
|
|
7063
7247
|
});
|
|
7064
7248
|
var DecoderStatsSchema = object({
|
|
7065
7249
|
inputFps: number(),
|
|
@@ -7432,6 +7616,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
|
|
|
7432
7616
|
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7433
7617
|
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7434
7618
|
/**
|
|
7619
|
+
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7620
|
+
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
7621
|
+
* failure — both are non-fatal to the host: read paths degrade to "skip link".
|
|
7622
|
+
*/
|
|
7623
|
+
/** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
|
|
7624
|
+
* the failure is anchored to a character (author-facing inline feedback). */
|
|
7625
|
+
var ExpressionParseError = class extends Error {
|
|
7626
|
+
position;
|
|
7627
|
+
constructor(message, position) {
|
|
7628
|
+
super(message);
|
|
7629
|
+
this.name = "ExpressionParseError";
|
|
7630
|
+
this.position = position;
|
|
7631
|
+
}
|
|
7632
|
+
};
|
|
7633
|
+
/** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
|
|
7634
|
+
* result, unknown builtin, step-budget exceeded). */
|
|
7635
|
+
var ExpressionEvalError = class extends Error {
|
|
7636
|
+
constructor(message) {
|
|
7637
|
+
super(message);
|
|
7638
|
+
this.name = "ExpressionEvalError";
|
|
7639
|
+
}
|
|
7640
|
+
};
|
|
7641
|
+
/**
|
|
7642
|
+
* Resource-bound constants for the safe expression engine.
|
|
7643
|
+
*
|
|
7644
|
+
* Every bound is defense-in-depth: the grammar is non-Turing-complete (no
|
|
7645
|
+
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
7646
|
+
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
7647
|
+
* work a single author-supplied expression can request, so a hostile or
|
|
7648
|
+
* accidental pathological string can never spend unbounded CPU/memory.
|
|
7649
|
+
*/
|
|
7650
|
+
/** Max source length (chars) — checked BEFORE tokenizing so a huge string is
|
|
7651
|
+
* rejected without allocation. */
|
|
7652
|
+
var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
|
|
7653
|
+
/** A legal binding / identifier name. */
|
|
7654
|
+
var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7655
|
+
/** Binding names an author may NOT use: `now` is auto-injected; the literal
|
|
7656
|
+
* keywords lex as values, not identifiers, so binding to them is meaningless. */
|
|
7657
|
+
var RESERVED_BINDING_NAMES = new Set([
|
|
7658
|
+
"now",
|
|
7659
|
+
"true",
|
|
7660
|
+
"false",
|
|
7661
|
+
"null"
|
|
7662
|
+
]);
|
|
7663
|
+
/**
|
|
7664
|
+
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
7665
|
+
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
7666
|
+
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
7667
|
+
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
7668
|
+
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
7669
|
+
* is a parse error with a source position, so member access / assignment /
|
|
7670
|
+
* template literals are lexically impossible.
|
|
7671
|
+
*/
|
|
7672
|
+
var KEYWORDS = new Set([
|
|
7673
|
+
"true",
|
|
7674
|
+
"false",
|
|
7675
|
+
"null"
|
|
7676
|
+
]);
|
|
7677
|
+
function isDigit(ch) {
|
|
7678
|
+
return ch >= "0" && ch <= "9";
|
|
7679
|
+
}
|
|
7680
|
+
function isIdentStart(ch) {
|
|
7681
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
7682
|
+
}
|
|
7683
|
+
function isIdentPart(ch) {
|
|
7684
|
+
return isIdentStart(ch) || isDigit(ch);
|
|
7685
|
+
}
|
|
7686
|
+
function isWhitespace(ch) {
|
|
7687
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
7688
|
+
}
|
|
7689
|
+
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
7690
|
+
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
7691
|
+
* string. */
|
|
7692
|
+
function tokenize(source) {
|
|
7693
|
+
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
7694
|
+
const tokens = [];
|
|
7695
|
+
let i = 0;
|
|
7696
|
+
const n = source.length;
|
|
7697
|
+
while (i < n) {
|
|
7698
|
+
const ch = source[i];
|
|
7699
|
+
if (isWhitespace(ch)) {
|
|
7700
|
+
i += 1;
|
|
7701
|
+
continue;
|
|
7702
|
+
}
|
|
7703
|
+
if (isDigit(ch)) {
|
|
7704
|
+
const start = i;
|
|
7705
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7706
|
+
if (i < n && source[i] === ".") {
|
|
7707
|
+
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
7708
|
+
i += 1;
|
|
7709
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7710
|
+
}
|
|
7711
|
+
const text = source.slice(start, i);
|
|
7712
|
+
const value = Number(text);
|
|
7713
|
+
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
7714
|
+
tokens.push({
|
|
7715
|
+
type: "number",
|
|
7716
|
+
value,
|
|
7717
|
+
pos: start
|
|
7718
|
+
});
|
|
7719
|
+
continue;
|
|
7720
|
+
}
|
|
7721
|
+
if (ch === "'" || ch === "\"") {
|
|
7722
|
+
const quote = ch;
|
|
7723
|
+
const start = i;
|
|
7724
|
+
i += 1;
|
|
7725
|
+
let out = "";
|
|
7726
|
+
let closed = false;
|
|
7727
|
+
while (i < n) {
|
|
7728
|
+
const c = source[i];
|
|
7729
|
+
if (c === "\\") {
|
|
7730
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
7731
|
+
if (next === "\\" || next === "'" || next === "\"") {
|
|
7732
|
+
out += next;
|
|
7733
|
+
i += 2;
|
|
7734
|
+
continue;
|
|
7735
|
+
}
|
|
7736
|
+
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
7737
|
+
}
|
|
7738
|
+
if (c === quote) {
|
|
7739
|
+
closed = true;
|
|
7740
|
+
i += 1;
|
|
7741
|
+
break;
|
|
7742
|
+
}
|
|
7743
|
+
out += c;
|
|
7744
|
+
i += 1;
|
|
7745
|
+
}
|
|
7746
|
+
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
7747
|
+
tokens.push({
|
|
7748
|
+
type: "string",
|
|
7749
|
+
value: out,
|
|
7750
|
+
pos: start
|
|
7751
|
+
});
|
|
7752
|
+
continue;
|
|
7753
|
+
}
|
|
7754
|
+
if (isIdentStart(ch)) {
|
|
7755
|
+
const start = i;
|
|
7756
|
+
while (i < n && isIdentPart(source[i])) i += 1;
|
|
7757
|
+
const text = source.slice(start, i);
|
|
7758
|
+
if (KEYWORDS.has(text)) tokens.push({
|
|
7759
|
+
type: "keyword",
|
|
7760
|
+
keyword: keywordOf(text),
|
|
7761
|
+
pos: start
|
|
7762
|
+
});
|
|
7763
|
+
else tokens.push({
|
|
7764
|
+
type: "identifier",
|
|
7765
|
+
name: text,
|
|
7766
|
+
pos: start
|
|
7767
|
+
});
|
|
7768
|
+
continue;
|
|
7769
|
+
}
|
|
7770
|
+
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
7771
|
+
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
7772
|
+
tokens.push({
|
|
7773
|
+
type: "punct",
|
|
7774
|
+
punct: two,
|
|
7775
|
+
pos: i
|
|
7776
|
+
});
|
|
7777
|
+
i += 2;
|
|
7778
|
+
continue;
|
|
7779
|
+
}
|
|
7780
|
+
if (isSinglePunct(ch)) {
|
|
7781
|
+
tokens.push({
|
|
7782
|
+
type: "punct",
|
|
7783
|
+
punct: ch,
|
|
7784
|
+
pos: i
|
|
7785
|
+
});
|
|
7786
|
+
i += 1;
|
|
7787
|
+
continue;
|
|
7788
|
+
}
|
|
7789
|
+
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
7790
|
+
}
|
|
7791
|
+
tokens.push({
|
|
7792
|
+
type: "eof",
|
|
7793
|
+
pos: n
|
|
7794
|
+
});
|
|
7795
|
+
return tokens;
|
|
7796
|
+
}
|
|
7797
|
+
function keywordOf(text) {
|
|
7798
|
+
if (text === "true") return "true";
|
|
7799
|
+
if (text === "false") return "false";
|
|
7800
|
+
return "null";
|
|
7801
|
+
}
|
|
7802
|
+
function isSinglePunct(ch) {
|
|
7803
|
+
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
7804
|
+
}
|
|
7805
|
+
/**
|
|
7806
|
+
* Frozen, null-prototype builtin function table for the expression engine
|
|
7807
|
+
* (spec §4 rule 4). The table is the SOLE surface of callable functions: the
|
|
7808
|
+
* parser rejects any callee not in it, and the evaluator gates each call on an
|
|
7809
|
+
* own-property check against it.
|
|
7810
|
+
*
|
|
7811
|
+
* Because the object has a NULL prototype AND is `Object.freeze`d:
|
|
7812
|
+
* - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
|
|
7813
|
+
* - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
|
|
7814
|
+
* (there is no `Object.prototype` in the chain), so those names are not
|
|
7815
|
+
* callable — they are simply "unknown function" at parse time.
|
|
7816
|
+
*
|
|
7817
|
+
* Every numeric argument is validated as a finite number and every numeric
|
|
7818
|
+
* RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
|
|
7819
|
+
* (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
|
|
7820
|
+
* closed rather than emitting a garbage value.
|
|
7821
|
+
*/
|
|
7822
|
+
function asFiniteNumber(value, name, index) {
|
|
7823
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
7824
|
+
return value;
|
|
7825
|
+
}
|
|
7826
|
+
function asString$1(value, name, index) {
|
|
7827
|
+
if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
|
|
7828
|
+
return value;
|
|
7829
|
+
}
|
|
7830
|
+
function finiteResult(value, name) {
|
|
7831
|
+
if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
|
|
7832
|
+
return value;
|
|
7833
|
+
}
|
|
7834
|
+
function allFiniteNumbers(args, name) {
|
|
7835
|
+
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
7836
|
+
}
|
|
7837
|
+
var INF = Number.POSITIVE_INFINITY;
|
|
7838
|
+
var table = {
|
|
7839
|
+
min: {
|
|
7840
|
+
minArgs: 1,
|
|
7841
|
+
maxArgs: INF,
|
|
7842
|
+
apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
|
|
7843
|
+
},
|
|
7844
|
+
max: {
|
|
7845
|
+
minArgs: 1,
|
|
7846
|
+
maxArgs: INF,
|
|
7847
|
+
apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
|
|
7848
|
+
},
|
|
7849
|
+
abs: {
|
|
7850
|
+
minArgs: 1,
|
|
7851
|
+
maxArgs: 1,
|
|
7852
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
7853
|
+
},
|
|
7854
|
+
floor: {
|
|
7855
|
+
minArgs: 1,
|
|
7856
|
+
maxArgs: 1,
|
|
7857
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
7858
|
+
},
|
|
7859
|
+
ceil: {
|
|
7860
|
+
minArgs: 1,
|
|
7861
|
+
maxArgs: 1,
|
|
7862
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
7863
|
+
},
|
|
7864
|
+
sqrt: {
|
|
7865
|
+
minArgs: 1,
|
|
7866
|
+
maxArgs: 1,
|
|
7867
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
7868
|
+
},
|
|
7869
|
+
round: {
|
|
7870
|
+
minArgs: 1,
|
|
7871
|
+
maxArgs: 2,
|
|
7872
|
+
apply: (args) => {
|
|
7873
|
+
const x = asFiniteNumber(args[0], "round", 0);
|
|
7874
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
7875
|
+
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
7876
|
+
const factor = 10 ** digits;
|
|
7877
|
+
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
7878
|
+
}
|
|
7879
|
+
},
|
|
7880
|
+
pow: {
|
|
7881
|
+
minArgs: 2,
|
|
7882
|
+
maxArgs: 2,
|
|
7883
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
7884
|
+
},
|
|
7885
|
+
clamp: {
|
|
7886
|
+
minArgs: 3,
|
|
7887
|
+
maxArgs: 3,
|
|
7888
|
+
apply: (args) => {
|
|
7889
|
+
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
7890
|
+
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
7891
|
+
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
7892
|
+
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
7893
|
+
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
7894
|
+
}
|
|
7895
|
+
},
|
|
7896
|
+
avg: {
|
|
7897
|
+
minArgs: 1,
|
|
7898
|
+
maxArgs: INF,
|
|
7899
|
+
apply: (args) => {
|
|
7900
|
+
const nums = allFiniteNumbers(args, "avg");
|
|
7901
|
+
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
7902
|
+
}
|
|
7903
|
+
},
|
|
7904
|
+
sum: {
|
|
7905
|
+
minArgs: 1,
|
|
7906
|
+
maxArgs: INF,
|
|
7907
|
+
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
7908
|
+
},
|
|
7909
|
+
coalesce: {
|
|
7910
|
+
minArgs: 1,
|
|
7911
|
+
maxArgs: INF,
|
|
7912
|
+
apply: (args) => {
|
|
7913
|
+
for (const a of args) if (a !== null) return a;
|
|
7914
|
+
return null;
|
|
7915
|
+
}
|
|
7916
|
+
},
|
|
7917
|
+
age: {
|
|
7918
|
+
minArgs: 2,
|
|
7919
|
+
maxArgs: 2,
|
|
7920
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
7921
|
+
},
|
|
7922
|
+
convert: {
|
|
7923
|
+
minArgs: 3,
|
|
7924
|
+
maxArgs: 3,
|
|
7925
|
+
apply: (args, hooks) => {
|
|
7926
|
+
const x = asFiniteNumber(args[0], "convert", 0);
|
|
7927
|
+
const from = asString$1(args[1], "convert", 1).trim();
|
|
7928
|
+
const to = asString$1(args[2], "convert", 2).trim();
|
|
7929
|
+
if (hooks.convert) {
|
|
7930
|
+
const out = hooks.convert(x, from, to);
|
|
7931
|
+
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
7932
|
+
return finiteResult(out, "convert");
|
|
7933
|
+
}
|
|
7934
|
+
if (from === to) return x;
|
|
7935
|
+
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
7936
|
+
}
|
|
7937
|
+
}
|
|
7938
|
+
};
|
|
7939
|
+
Object.freeze(Object.assign(Object.create(null), table));
|
|
7940
|
+
/** The set of valid builtin names — used by the parser to reject unknown
|
|
7941
|
+
* callees at parse time (immediate author feedback). */
|
|
7942
|
+
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
7943
|
+
/**
|
|
7944
|
+
* Pratt (precedence-climbing) parser for the safe expression mini-language.
|
|
7945
|
+
*
|
|
7946
|
+
* Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
|
|
7947
|
+
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
7948
|
+
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
7949
|
+
* string validated against the builtin table at parse time, so an unknown
|
|
7950
|
+
* function is rejected immediately (author feedback) and a persisted expression
|
|
7951
|
+
* that references a since-removed builtin degrades at read.
|
|
7952
|
+
*
|
|
7953
|
+
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
7954
|
+
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
7955
|
+
*/
|
|
7956
|
+
/** Binary/logical operator precedence (higher binds tighter). */
|
|
7957
|
+
var BINARY_PRECEDENCE = {
|
|
7958
|
+
"||": 1,
|
|
7959
|
+
"&&": 2,
|
|
7960
|
+
"==": 3,
|
|
7961
|
+
"!=": 3,
|
|
7962
|
+
"<": 4,
|
|
7963
|
+
"<=": 4,
|
|
7964
|
+
">": 4,
|
|
7965
|
+
">=": 4,
|
|
7966
|
+
"+": 5,
|
|
7967
|
+
"-": 5,
|
|
7968
|
+
"*": 6,
|
|
7969
|
+
"/": 6,
|
|
7970
|
+
"%": 6
|
|
7971
|
+
};
|
|
7972
|
+
function isLogicalOp(op) {
|
|
7973
|
+
return op === "&&" || op === "||";
|
|
7974
|
+
}
|
|
7975
|
+
function isBinaryOp(op) {
|
|
7976
|
+
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
7977
|
+
}
|
|
7978
|
+
var Parser = class {
|
|
7979
|
+
tokens;
|
|
7980
|
+
pos = 0;
|
|
7981
|
+
nodeCount = 0;
|
|
7982
|
+
identifiers = /* @__PURE__ */ new Set();
|
|
7983
|
+
callees = /* @__PURE__ */ new Set();
|
|
7984
|
+
constructor(tokens) {
|
|
7985
|
+
this.tokens = tokens;
|
|
7986
|
+
}
|
|
7987
|
+
parse() {
|
|
7988
|
+
const ast = this.parseTernary();
|
|
7989
|
+
const tok = this.peek();
|
|
7990
|
+
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
7991
|
+
return {
|
|
7992
|
+
ast,
|
|
7993
|
+
identifiers: this.identifiers,
|
|
7994
|
+
callees: this.callees,
|
|
7995
|
+
nodeCount: this.nodeCount
|
|
7996
|
+
};
|
|
7997
|
+
}
|
|
7998
|
+
peek() {
|
|
7999
|
+
return this.tokens[this.pos];
|
|
8000
|
+
}
|
|
8001
|
+
next() {
|
|
8002
|
+
return this.tokens[this.pos++];
|
|
8003
|
+
}
|
|
8004
|
+
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
8005
|
+
expectPunct(punct) {
|
|
8006
|
+
const tok = this.peek();
|
|
8007
|
+
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
8008
|
+
this.pos += 1;
|
|
8009
|
+
}
|
|
8010
|
+
matchPunct(punct) {
|
|
8011
|
+
const tok = this.peek();
|
|
8012
|
+
if (tok.type === "punct" && tok.punct === punct) {
|
|
8013
|
+
this.pos += 1;
|
|
8014
|
+
return true;
|
|
8015
|
+
}
|
|
8016
|
+
return false;
|
|
8017
|
+
}
|
|
8018
|
+
countNode() {
|
|
8019
|
+
this.nodeCount += 1;
|
|
8020
|
+
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
8021
|
+
}
|
|
8022
|
+
parseTernary() {
|
|
8023
|
+
const test = this.parseBinary(1);
|
|
8024
|
+
if (this.matchPunct("?")) {
|
|
8025
|
+
const consequent = this.parseTernary();
|
|
8026
|
+
this.expectPunct(":");
|
|
8027
|
+
const alternate = this.parseTernary();
|
|
8028
|
+
this.countNode();
|
|
8029
|
+
return {
|
|
8030
|
+
kind: "conditional",
|
|
8031
|
+
test,
|
|
8032
|
+
consequent,
|
|
8033
|
+
alternate
|
|
8034
|
+
};
|
|
8035
|
+
}
|
|
8036
|
+
return test;
|
|
8037
|
+
}
|
|
8038
|
+
parseBinary(minPrec) {
|
|
8039
|
+
let left = this.parseUnary();
|
|
8040
|
+
for (;;) {
|
|
8041
|
+
const tok = this.peek();
|
|
8042
|
+
if (tok.type !== "punct") break;
|
|
8043
|
+
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
8044
|
+
if (prec === void 0 || prec < minPrec) break;
|
|
8045
|
+
const op = tok.punct;
|
|
8046
|
+
this.pos += 1;
|
|
8047
|
+
const right = this.parseBinary(prec + 1);
|
|
8048
|
+
this.countNode();
|
|
8049
|
+
if (isLogicalOp(op)) left = {
|
|
8050
|
+
kind: "logical",
|
|
8051
|
+
op,
|
|
8052
|
+
left,
|
|
8053
|
+
right
|
|
8054
|
+
};
|
|
8055
|
+
else if (isBinaryOp(op)) left = {
|
|
8056
|
+
kind: "binary",
|
|
8057
|
+
op,
|
|
8058
|
+
left,
|
|
8059
|
+
right
|
|
8060
|
+
};
|
|
8061
|
+
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
8062
|
+
}
|
|
8063
|
+
return left;
|
|
8064
|
+
}
|
|
8065
|
+
parseUnary() {
|
|
8066
|
+
const tok = this.peek();
|
|
8067
|
+
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
8068
|
+
const op = tok.punct;
|
|
8069
|
+
this.pos += 1;
|
|
8070
|
+
const operand = this.parseUnary();
|
|
8071
|
+
this.countNode();
|
|
8072
|
+
return {
|
|
8073
|
+
kind: "unary",
|
|
8074
|
+
op,
|
|
8075
|
+
operand
|
|
8076
|
+
};
|
|
8077
|
+
}
|
|
8078
|
+
return this.parsePrimary();
|
|
8079
|
+
}
|
|
8080
|
+
parsePrimary() {
|
|
8081
|
+
const tok = this.next();
|
|
8082
|
+
switch (tok.type) {
|
|
8083
|
+
case "number":
|
|
8084
|
+
this.countNode();
|
|
8085
|
+
return {
|
|
8086
|
+
kind: "literal",
|
|
8087
|
+
value: tok.value
|
|
8088
|
+
};
|
|
8089
|
+
case "string":
|
|
8090
|
+
this.countNode();
|
|
8091
|
+
return {
|
|
8092
|
+
kind: "literal",
|
|
8093
|
+
value: tok.value
|
|
8094
|
+
};
|
|
8095
|
+
case "keyword":
|
|
8096
|
+
this.countNode();
|
|
8097
|
+
return {
|
|
8098
|
+
kind: "literal",
|
|
8099
|
+
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
8100
|
+
};
|
|
8101
|
+
case "identifier": {
|
|
8102
|
+
const nextTok = this.peek();
|
|
8103
|
+
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
8104
|
+
this.identifiers.add(tok.name);
|
|
8105
|
+
this.countNode();
|
|
8106
|
+
return {
|
|
8107
|
+
kind: "identifier",
|
|
8108
|
+
name: tok.name
|
|
8109
|
+
};
|
|
8110
|
+
}
|
|
8111
|
+
case "punct":
|
|
8112
|
+
if (tok.punct === "(") {
|
|
8113
|
+
const inner = this.parseTernary();
|
|
8114
|
+
this.expectPunct(")");
|
|
8115
|
+
return inner;
|
|
8116
|
+
}
|
|
8117
|
+
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
8118
|
+
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
8119
|
+
}
|
|
8120
|
+
}
|
|
8121
|
+
parseCall(callee, pos) {
|
|
8122
|
+
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
8123
|
+
this.expectPunct("(");
|
|
8124
|
+
const args = [];
|
|
8125
|
+
if (!this.matchPunct(")")) for (;;) {
|
|
8126
|
+
args.push(this.parseTernary());
|
|
8127
|
+
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
8128
|
+
if (this.matchPunct(",")) continue;
|
|
8129
|
+
this.expectPunct(")");
|
|
8130
|
+
break;
|
|
8131
|
+
}
|
|
8132
|
+
this.callees.add(callee);
|
|
8133
|
+
this.countNode();
|
|
8134
|
+
return {
|
|
8135
|
+
kind: "call",
|
|
8136
|
+
callee,
|
|
8137
|
+
args
|
|
8138
|
+
};
|
|
8139
|
+
}
|
|
8140
|
+
};
|
|
8141
|
+
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
8142
|
+
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
8143
|
+
function parseExpression(source) {
|
|
8144
|
+
return new Parser(tokenize(source)).parse();
|
|
8145
|
+
}
|
|
8146
|
+
Object.freeze({});
|
|
8147
|
+
/**
|
|
8148
|
+
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
8149
|
+
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
8150
|
+
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
8151
|
+
* one per read on a hot resolve path.
|
|
8152
|
+
*
|
|
8153
|
+
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
8154
|
+
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
8155
|
+
* callers is safe and maximises hit rate.
|
|
8156
|
+
*/
|
|
8157
|
+
var cache = /* @__PURE__ */ new Map();
|
|
8158
|
+
function getCached(source) {
|
|
8159
|
+
const hit = cache.get(source);
|
|
8160
|
+
if (hit !== void 0) {
|
|
8161
|
+
cache.delete(source);
|
|
8162
|
+
cache.set(source, hit);
|
|
8163
|
+
return hit;
|
|
8164
|
+
}
|
|
8165
|
+
let result;
|
|
8166
|
+
try {
|
|
8167
|
+
result = {
|
|
8168
|
+
ok: true,
|
|
8169
|
+
parsed: parseExpression(source)
|
|
8170
|
+
};
|
|
8171
|
+
} catch (err) {
|
|
8172
|
+
result = {
|
|
8173
|
+
ok: false,
|
|
8174
|
+
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
8175
|
+
};
|
|
8176
|
+
}
|
|
8177
|
+
cache.set(source, result);
|
|
8178
|
+
if (cache.size > 256) {
|
|
8179
|
+
const oldest = cache.keys().next().value;
|
|
8180
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
8181
|
+
}
|
|
8182
|
+
return result;
|
|
8183
|
+
}
|
|
8184
|
+
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
8185
|
+
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
8186
|
+
function compileExpressionSafe(source) {
|
|
8187
|
+
return getCached(source);
|
|
8188
|
+
}
|
|
8189
|
+
/**
|
|
8190
|
+
* Author-time validation. Returns `null` when the source is valid, else a
|
|
8191
|
+
* human-readable error message. Checks: the expression compiles; binding count
|
|
8192
|
+
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
8193
|
+
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
8194
|
+
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
8195
|
+
*/
|
|
8196
|
+
function validateExpressionSource(src) {
|
|
8197
|
+
const names = Object.keys(src.bindings);
|
|
8198
|
+
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
8199
|
+
for (const name of names) {
|
|
8200
|
+
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
8201
|
+
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
8202
|
+
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
8203
|
+
}
|
|
8204
|
+
const compiled = compileExpressionSafe(src.expr);
|
|
8205
|
+
if (!compiled.ok) return compiled.error;
|
|
8206
|
+
const bound = new Set(names);
|
|
8207
|
+
for (const id of compiled.parsed.identifiers) {
|
|
8208
|
+
if (id === "now") continue;
|
|
8209
|
+
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
8210
|
+
}
|
|
8211
|
+
return null;
|
|
8212
|
+
}
|
|
8213
|
+
/**
|
|
7435
8214
|
* Accessory device helpers — shared across drivers.
|
|
7436
8215
|
*
|
|
7437
8216
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -8276,7 +9055,13 @@ onStatusChanged: { data: object({
|
|
|
8276
9055
|
}) } },
|
|
8277
9056
|
status: {
|
|
8278
9057
|
schema: BatteryStatusSchema,
|
|
8279
|
-
kind: "push"
|
|
9058
|
+
kind: "push",
|
|
9059
|
+
empty: {
|
|
9060
|
+
percentage: 0,
|
|
9061
|
+
charging: "none",
|
|
9062
|
+
sleeping: false,
|
|
9063
|
+
lastUpdated: 0
|
|
9064
|
+
}
|
|
8280
9065
|
},
|
|
8281
9066
|
/**
|
|
8282
9067
|
* Runtime-state slice — every provider that registers this cap
|
|
@@ -8415,6 +9200,10 @@ var RtspRestreamEntrySchema = object({
|
|
|
8415
9200
|
var BrokerRtspClientSchema = object({
|
|
8416
9201
|
sessionId: string(),
|
|
8417
9202
|
remoteAddr: string(),
|
|
9203
|
+
/** Client `User-Agent` (e.g. `recorder` for the recorder's RTSP pull), or
|
|
9204
|
+
* null/absent when the client sent none. Lets the UI label a consumer by
|
|
9205
|
+
* purpose. Optional so a client built against an older schema stays valid. */
|
|
9206
|
+
userAgent: string().nullish(),
|
|
8418
9207
|
playing: boolean(),
|
|
8419
9208
|
muted: boolean(),
|
|
8420
9209
|
connectedAt: number(),
|
|
@@ -9215,21 +10004,38 @@ var connectivityCapability = {
|
|
|
9215
10004
|
},
|
|
9216
10005
|
runtimeState: ConnectivityStatusSchema
|
|
9217
10006
|
};
|
|
10007
|
+
/**
|
|
10008
|
+
* Generic device-consumables capability — surfaces a device's
|
|
10009
|
+
* maintenance items (vacuum filters/brushes, replaceable cartridges,
|
|
10010
|
+
* descaling cycles, …) with their remaining life and an optional
|
|
10011
|
+
* "Replaced" reset action. Device-agnostic: any provider that knows its
|
|
10012
|
+
* device tracks consumables can register it; the cap declares no
|
|
10013
|
+
* vocabulary of its own — the provider names each item verbatim.
|
|
10014
|
+
*
|
|
10015
|
+
* Like `childLayout`, the cap is INERT until a provider sets items: no
|
|
10016
|
+
* provider populates it by guessing (no HA inference). The UI renders a
|
|
10017
|
+
* "No consumables reported" placeholder when `items` is empty.
|
|
10018
|
+
*/
|
|
10019
|
+
/** A single consumable item. Either a continuous `level` (remaining
|
|
10020
|
+
* life %) or a discrete `status` may be known — both may be null when a
|
|
10021
|
+
* provider only knows the item exists. `level` and `status` are not
|
|
10022
|
+
* mutually exclusive; a provider may report both. */
|
|
10023
|
+
var ConsumableItemSchema = object({
|
|
10024
|
+
/** Stable id, e.g. 'main-brush'. */
|
|
10025
|
+
key: string().min(1),
|
|
10026
|
+
/** Display name. */
|
|
10027
|
+
label: string().min(1),
|
|
10028
|
+
/** Remaining life % when known (0..100). */
|
|
10029
|
+
level: number().min(0).max(100).nullable(),
|
|
10030
|
+
/** Discrete state when known (binary mode). */
|
|
10031
|
+
status: _enum(["ok", "replace"]).nullable(),
|
|
10032
|
+
/** Ms epoch of the last replace, when known. */
|
|
10033
|
+
lastResetAt: number().nullable(),
|
|
10034
|
+
/** Whether `reset()` is meaningful for this item. */
|
|
10035
|
+
resettable: boolean()
|
|
10036
|
+
});
|
|
9218
10037
|
var ConsumablesStatusSchema = object({
|
|
9219
|
-
items: array(
|
|
9220
|
-
/** Stable id, e.g. 'main-brush'. */
|
|
9221
|
-
key: string().min(1),
|
|
9222
|
-
/** Display name. */
|
|
9223
|
-
label: string().min(1),
|
|
9224
|
-
/** Remaining life % when known (0..100). */
|
|
9225
|
-
level: number().min(0).max(100).nullable(),
|
|
9226
|
-
/** Discrete state when known (binary mode). */
|
|
9227
|
-
status: _enum(["ok", "replace"]).nullable(),
|
|
9228
|
-
/** Ms epoch of the last replace, when known. */
|
|
9229
|
-
lastResetAt: number().nullable(),
|
|
9230
|
-
/** Whether `reset()` is meaningful for this item. */
|
|
9231
|
-
resettable: boolean()
|
|
9232
|
-
})),
|
|
10038
|
+
items: array(ConsumableItemSchema),
|
|
9233
10039
|
lastChangedAt: number()
|
|
9234
10040
|
});
|
|
9235
10041
|
var consumablesCapability = {
|
|
@@ -9288,7 +10094,25 @@ reset: method(object({
|
|
|
9288
10094
|
}) },
|
|
9289
10095
|
status: {
|
|
9290
10096
|
schema: ConsumablesStatusSchema,
|
|
9291
|
-
kind: "push"
|
|
10097
|
+
kind: "push",
|
|
10098
|
+
empty: {
|
|
10099
|
+
items: [],
|
|
10100
|
+
lastChangedAt: 0
|
|
10101
|
+
},
|
|
10102
|
+
itemArray: {
|
|
10103
|
+
path: "items",
|
|
10104
|
+
keyField: "key",
|
|
10105
|
+
labelField: "label",
|
|
10106
|
+
itemSchema: ConsumableItemSchema,
|
|
10107
|
+
emptyItem: {
|
|
10108
|
+
key: "",
|
|
10109
|
+
label: "",
|
|
10110
|
+
level: null,
|
|
10111
|
+
status: null,
|
|
10112
|
+
lastResetAt: null,
|
|
10113
|
+
resettable: false
|
|
10114
|
+
}
|
|
10115
|
+
}
|
|
9292
10116
|
},
|
|
9293
10117
|
runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() })
|
|
9294
10118
|
};
|
|
@@ -10530,7 +11354,8 @@ var MotionAnalysisResultSchema = object({
|
|
|
10530
11354
|
});
|
|
10531
11355
|
method(object({
|
|
10532
11356
|
deviceId: number(),
|
|
10533
|
-
frame: FrameInputSchema
|
|
11357
|
+
frame: FrameInputSchema.optional(),
|
|
11358
|
+
frameHandle: FrameHandleSchema.optional()
|
|
10534
11359
|
}), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
|
|
10535
11360
|
deviceId: number(),
|
|
10536
11361
|
detected: boolean(),
|
|
@@ -10777,6 +11602,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
10777
11602
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
10778
11603
|
steps: array(PipelineStepInputSchema).min(1),
|
|
10779
11604
|
frame: FrameInputSchema.optional(),
|
|
11605
|
+
/**
|
|
11606
|
+
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
11607
|
+
* the decoded pixels live in. One more member of the one-of
|
|
11608
|
+
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
11609
|
+
*/
|
|
11610
|
+
frameHandle: FrameHandleSchema.optional(),
|
|
10780
11611
|
imageBase64: string().optional(),
|
|
10781
11612
|
/**
|
|
10782
11613
|
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
@@ -11019,6 +11850,31 @@ var ReportMotionInputSchema = object({
|
|
|
11019
11850
|
regions: array(MotionRegionSchema).readonly().optional()
|
|
11020
11851
|
});
|
|
11021
11852
|
/**
|
|
11853
|
+
* Where a runner gets a camera's decoded frames (cross-node Phase 2,
|
|
11854
|
+
* restream-owner model — P2c).
|
|
11855
|
+
*
|
|
11856
|
+
* - `local-broker` (DEFAULT): today's path — subscribe to the co-located
|
|
11857
|
+
* stream-broker's shm frame plane. Every pre-P2c attach payload (no
|
|
11858
|
+
* `frameSource` key) parses to this, so the field is additive with zero
|
|
11859
|
+
* behavior change.
|
|
11860
|
+
* - `remote-restream`: the detect node is NOT the camera's source-owner.
|
|
11861
|
+
* The runner acquires the owner's COMPRESSED passthrough restream
|
|
11862
|
+
* (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
|
|
11863
|
+
* double-pull guard) and decodes LOCALLY via a satellite frame plane +
|
|
11864
|
+
* pull-mode decoder session pinned to its own node. The shm ring stays
|
|
11865
|
+
* node-local; only H.264/H.265 packets cross the wire.
|
|
11866
|
+
* `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
|
|
11867
|
+
* when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
|
|
11868
|
+
* dials for the owner's restream.
|
|
11869
|
+
*/
|
|
11870
|
+
var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
|
|
11871
|
+
kind: literal("remote-restream"),
|
|
11872
|
+
/** The camera's source-owner node (slice 1: always the hub). */
|
|
11873
|
+
ownerNodeId: string(),
|
|
11874
|
+
/** Operator override for the owner host the runner dials. */
|
|
11875
|
+
hubHostnameOverride: string().optional()
|
|
11876
|
+
})]).describe("Per-camera frame-source mode for the runner (P2c)");
|
|
11877
|
+
/**
|
|
11022
11878
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
11023
11879
|
* specific runner instance via `attachCamera`. Carries everything the
|
|
11024
11880
|
* runner needs to subscribe to the local broker and execute inference.
|
|
@@ -11116,7 +11972,15 @@ var RunnerCameraConfigSchema = object({
|
|
|
11116
11972
|
*/
|
|
11117
11973
|
onboardMotionDrivesAnalyzer: boolean().default(true),
|
|
11118
11974
|
occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
|
|
11119
|
-
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
|
|
11975
|
+
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
|
|
11976
|
+
/**
|
|
11977
|
+
* Where this runner gets the camera's decoded frames (P2c). Defaulted so
|
|
11978
|
+
* every existing payload behaves as `local-broker` — the pre-Phase-2 path.
|
|
11979
|
+
* Populated with `remote-restream` by the orchestrator ONLY when the
|
|
11980
|
+
* camera's detect node differs from its source-owner (P2d, gated by the
|
|
11981
|
+
* `remoteSourcingNodes` rollout setting).
|
|
11982
|
+
*/
|
|
11983
|
+
frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
|
|
11120
11984
|
});
|
|
11121
11985
|
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;
|
|
11122
11986
|
/**
|
|
@@ -11680,6 +12544,157 @@ var numericSensorCapability = {
|
|
|
11680
12544
|
runtimeState: NumericSensorStatusSchema
|
|
11681
12545
|
};
|
|
11682
12546
|
/**
|
|
12547
|
+
* Feeder connectivity / power status — mirrors the HA petkit device-status
|
|
12548
|
+
* enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
|
|
12549
|
+
* `on_batteries` (running on battery backup). `null` until first reported.
|
|
12550
|
+
*/
|
|
12551
|
+
var PetFeederDeviceStatusSchema = _enum([
|
|
12552
|
+
"normal",
|
|
12553
|
+
"offline",
|
|
12554
|
+
"on_batteries"
|
|
12555
|
+
]);
|
|
12556
|
+
var gramsPortion = number().int().min(4).max(200);
|
|
12557
|
+
var PetFeederStatusSchema = object({
|
|
12558
|
+
/** Food currently in the bowl (grams). Null when the device has not
|
|
12559
|
+
* reported a reading yet. On dual-hopper models this is the combined
|
|
12560
|
+
* bowl reading; per-hopper levels live in `food1`/`food2`. */
|
|
12561
|
+
foodLevel: number().nullable(),
|
|
12562
|
+
/** Hopper-1 food level (grams) on dual-hopper feeders; null on
|
|
12563
|
+
* single-hopper models. */
|
|
12564
|
+
food1: number().nullable(),
|
|
12565
|
+
/** Hopper-2 food level (grams) on dual-hopper feeders; null on
|
|
12566
|
+
* single-hopper models. */
|
|
12567
|
+
food2: number().nullable(),
|
|
12568
|
+
/** Derived low-food flag — mirrors the HA `food_level` binary_sensor
|
|
12569
|
+
* (`device_class: problem`, on = low). True when the bowl is empty /
|
|
12570
|
+
* below the feeder's low threshold. */
|
|
12571
|
+
lowFood: boolean(),
|
|
12572
|
+
/** Battery charge 0..100 (%). Null on mains-powered models or when the
|
|
12573
|
+
* device has no battery reading. */
|
|
12574
|
+
batteryPower: number().min(0).max(100).nullable(),
|
|
12575
|
+
/** Days of desiccant life remaining. Null when the model has no
|
|
12576
|
+
* desiccant sensor. */
|
|
12577
|
+
desiccantLeftDays: number().nullable(),
|
|
12578
|
+
/** True while a feed is in progress. */
|
|
12579
|
+
feeding: boolean(),
|
|
12580
|
+
/** Decoded connectivity / power status (HA petkit device-status enum).
|
|
12581
|
+
* Null until the device has reported a status. */
|
|
12582
|
+
status: PetFeederDeviceStatusSchema.nullable(),
|
|
12583
|
+
/** Decoded human-readable fault message. Null (or the device's `no_error`
|
|
12584
|
+
* sentinel) means healthy; a non-null string is an active fault. Pairs
|
|
12585
|
+
* with `errorCode` for consumers that want the raw integer. */
|
|
12586
|
+
error: string().nullable(),
|
|
12587
|
+
/** Raw device error code (0 / null = no error). */
|
|
12588
|
+
errorCode: number().nullable(),
|
|
12589
|
+
/** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
|
|
12590
|
+
isDualHopper: boolean(),
|
|
12591
|
+
/** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
|
|
12592
|
+
childLock: boolean(),
|
|
12593
|
+
/** Front indicator-light setting. */
|
|
12594
|
+
indicatorLight: boolean(),
|
|
12595
|
+
/** Play a chime when dispensing. */
|
|
12596
|
+
feedSound: boolean(),
|
|
12597
|
+
/** Speaker / prompt volume level (device-scaled integer). */
|
|
12598
|
+
volume: number(),
|
|
12599
|
+
/** Ms epoch when the slice was last refreshed from the cloud. */
|
|
12600
|
+
lastFetchedAt: number()
|
|
12601
|
+
});
|
|
12602
|
+
var petFeederCapability = {
|
|
12603
|
+
name: "pet-feeder",
|
|
12604
|
+
scope: "device",
|
|
12605
|
+
deviceNative: true,
|
|
12606
|
+
mode: "singleton",
|
|
12607
|
+
deviceTypes: [DeviceType.PetFeeder],
|
|
12608
|
+
methods: {
|
|
12609
|
+
/**
|
|
12610
|
+
* Dispense food now. Single-hopper feeders take `grams`; dual-hopper
|
|
12611
|
+
* feeders (D4S/D4SH) accept `hopper1`/`hopper2` to target one or both
|
|
12612
|
+
* hoppers. All portions honour the 4–200 g hardware range. At least
|
|
12613
|
+
* one of the three must be present — the provider rejects an empty
|
|
12614
|
+
* request.
|
|
12615
|
+
*/
|
|
12616
|
+
feed: method(object({
|
|
12617
|
+
deviceId: number().int().nonnegative(),
|
|
12618
|
+
grams: gramsPortion.optional(),
|
|
12619
|
+
hopper1: gramsPortion.optional(),
|
|
12620
|
+
hopper2: gramsPortion.optional()
|
|
12621
|
+
}), _void(), {
|
|
12622
|
+
kind: "mutation",
|
|
12623
|
+
auth: "admin"
|
|
12624
|
+
}),
|
|
12625
|
+
/** Cancel an in-progress manual feed. */
|
|
12626
|
+
cancelFeed: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12627
|
+
kind: "mutation",
|
|
12628
|
+
auth: "admin"
|
|
12629
|
+
}),
|
|
12630
|
+
/** Reset the desiccant "days remaining" counter after replacing it. */
|
|
12631
|
+
resetDesiccant: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12632
|
+
kind: "mutation",
|
|
12633
|
+
auth: "admin"
|
|
12634
|
+
}),
|
|
12635
|
+
/** Mark a hopper as refilled (D4H/D4S/D4SH). */
|
|
12636
|
+
markFoodReplenished: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12637
|
+
kind: "mutation",
|
|
12638
|
+
auth: "admin"
|
|
12639
|
+
}),
|
|
12640
|
+
/** Call the pet with the recorded prompt (D3). */
|
|
12641
|
+
callPet: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12642
|
+
kind: "mutation",
|
|
12643
|
+
auth: "admin"
|
|
12644
|
+
}),
|
|
12645
|
+
/** Play a stored sound by id (D3 / D4H / D4SH). */
|
|
12646
|
+
playSound: method(object({
|
|
12647
|
+
deviceId: number().int().nonnegative(),
|
|
12648
|
+
soundId: number().int().nonnegative()
|
|
12649
|
+
}), _void(), {
|
|
12650
|
+
kind: "mutation",
|
|
12651
|
+
auth: "admin"
|
|
12652
|
+
}),
|
|
12653
|
+
/** Toggle the child-lock (manual-lock) setting. */
|
|
12654
|
+
setChildLock: method(object({
|
|
12655
|
+
deviceId: number().int().nonnegative(),
|
|
12656
|
+
on: boolean()
|
|
12657
|
+
}), _void(), {
|
|
12658
|
+
kind: "mutation",
|
|
12659
|
+
auth: "admin"
|
|
12660
|
+
}),
|
|
12661
|
+
/** Toggle the front indicator light. */
|
|
12662
|
+
setIndicatorLight: method(object({
|
|
12663
|
+
deviceId: number().int().nonnegative(),
|
|
12664
|
+
on: boolean()
|
|
12665
|
+
}), _void(), {
|
|
12666
|
+
kind: "mutation",
|
|
12667
|
+
auth: "admin"
|
|
12668
|
+
}),
|
|
12669
|
+
/** Toggle the dispense chime. */
|
|
12670
|
+
setFeedSound: method(object({
|
|
12671
|
+
deviceId: number().int().nonnegative(),
|
|
12672
|
+
on: boolean()
|
|
12673
|
+
}), _void(), {
|
|
12674
|
+
kind: "mutation",
|
|
12675
|
+
auth: "admin"
|
|
12676
|
+
}),
|
|
12677
|
+
/** Set the speaker / prompt volume level. */
|
|
12678
|
+
setVolume: method(object({
|
|
12679
|
+
deviceId: number().int().nonnegative(),
|
|
12680
|
+
level: number().int().nonnegative()
|
|
12681
|
+
}), _void(), {
|
|
12682
|
+
kind: "mutation",
|
|
12683
|
+
auth: "admin"
|
|
12684
|
+
})
|
|
12685
|
+
},
|
|
12686
|
+
status: {
|
|
12687
|
+
schema: PetFeederStatusSchema,
|
|
12688
|
+
kind: "poll"
|
|
12689
|
+
},
|
|
12690
|
+
/**
|
|
12691
|
+
* Runtime-state slice — mirrored by the kernel. UI feeder cards read
|
|
12692
|
+
* the full slice via `device.state.petFeeder.value` and refresh on
|
|
12693
|
+
* every poll without re-querying the provider.
|
|
12694
|
+
*/
|
|
12695
|
+
runtimeState: PetFeederStatusSchema
|
|
12696
|
+
};
|
|
12697
|
+
/**
|
|
11683
12698
|
* Multi-metric electrical meter. One slice can carry any combination
|
|
11684
12699
|
* of instantaneous power (W), cumulative energy (kWh), voltage (V),
|
|
11685
12700
|
* and current (A) — all fields optional so a single-metric source
|
|
@@ -12982,6 +13997,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
|
|
|
12982
13997
|
nativeObjectDetection: nativeObjectDetectionCapability,
|
|
12983
13998
|
notifier: notifierCapability,
|
|
12984
13999
|
numericSensor: numericSensorCapability,
|
|
14000
|
+
petFeeder: petFeederCapability,
|
|
12985
14001
|
powerMeter: powerMeterCapability,
|
|
12986
14002
|
presence: presenceCapability,
|
|
12987
14003
|
pressureSensor: pressureSensorCapability,
|
|
@@ -14898,10 +15914,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
|
|
|
14898
15914
|
url: string()
|
|
14899
15915
|
}), _void()), method(object({
|
|
14900
15916
|
sessionId: string(),
|
|
14901
|
-
maxCount: number().default(1)
|
|
15917
|
+
maxCount: number().default(1),
|
|
15918
|
+
waitMs: number().optional()
|
|
14902
15919
|
}), array(DecodedFrameSchema)), method(object({
|
|
14903
15920
|
sessionId: string(),
|
|
14904
|
-
maxCount: number().default(1)
|
|
15921
|
+
maxCount: number().default(1),
|
|
15922
|
+
waitMs: number().optional()
|
|
14905
15923
|
}), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
|
|
14906
15924
|
sessionId: string(),
|
|
14907
15925
|
config: DecoderSessionConfigSchema.partial()
|
|
@@ -15205,14 +16223,63 @@ var ChildLayoutEntrySchema = object({
|
|
|
15205
16223
|
collapsed: boolean().optional()
|
|
15206
16224
|
});
|
|
15207
16225
|
/** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
|
|
15208
|
-
* `device-management.ts`.
|
|
16226
|
+
* `device-management.ts`. Source is a union: a FIELD source copies a sibling
|
|
16227
|
+
* accessory's status field (`kind` optional/absent for wire compat); a
|
|
16228
|
+
* LITERAL source carries a per-device constant (no sibling is read); a
|
|
16229
|
+
* GLOBAL source (P2e) copies ANY device's status field, addressed by the
|
|
16230
|
+
* source device's full re-sync-stable `stableId`. */
|
|
16231
|
+
var DeviceLinkFieldSourceSchema = object({
|
|
16232
|
+
kind: literal("field").optional(),
|
|
16233
|
+
sourceKey: string(),
|
|
16234
|
+
cap: string(),
|
|
16235
|
+
fieldPath: string()
|
|
16236
|
+
});
|
|
16237
|
+
var DeviceLinkLiteralSourceSchema = object({
|
|
16238
|
+
kind: literal("literal"),
|
|
16239
|
+
value: union([
|
|
16240
|
+
string(),
|
|
16241
|
+
number(),
|
|
16242
|
+
boolean(),
|
|
16243
|
+
_null()
|
|
16244
|
+
])
|
|
16245
|
+
});
|
|
16246
|
+
var DeviceLinkGlobalSourceSchema = object({
|
|
16247
|
+
kind: literal("global"),
|
|
16248
|
+
sourceStableId: string(),
|
|
16249
|
+
cap: string(),
|
|
16250
|
+
fieldPath: string()
|
|
16251
|
+
});
|
|
16252
|
+
/** Expression source (Stage X): compute the target field from N named bindings
|
|
16253
|
+
* via the safe expression engine. Bindings are field | literal | global — never
|
|
16254
|
+
* another expression (no nesting). The `superRefine` runs the SAME author-time
|
|
16255
|
+
* validation as `validateExpressionSource` (compiles the expr, checks binding
|
|
16256
|
+
* names + identifier coverage) so every wire boundary that parses a DeviceLink
|
|
16257
|
+
* (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
|
|
16258
|
+
* Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
|
|
16259
|
+
var DeviceLinkExpressionSourceSchema = object({
|
|
16260
|
+
kind: literal("expression"),
|
|
16261
|
+
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
16262
|
+
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
|
|
16263
|
+
DeviceLinkFieldSourceSchema,
|
|
16264
|
+
DeviceLinkLiteralSourceSchema,
|
|
16265
|
+
DeviceLinkGlobalSourceSchema
|
|
16266
|
+
]))
|
|
16267
|
+
}).superRefine((src, ctx) => {
|
|
16268
|
+
const err = validateExpressionSource(src);
|
|
16269
|
+
if (err !== null) ctx.addIssue({
|
|
16270
|
+
code: "custom",
|
|
16271
|
+
message: err,
|
|
16272
|
+
path: ["expr"]
|
|
16273
|
+
});
|
|
16274
|
+
});
|
|
15209
16275
|
var DeviceLinkSchema = object({
|
|
15210
16276
|
id: string(),
|
|
15211
|
-
source:
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
16277
|
+
source: union([
|
|
16278
|
+
DeviceLinkFieldSourceSchema,
|
|
16279
|
+
DeviceLinkLiteralSourceSchema,
|
|
16280
|
+
DeviceLinkGlobalSourceSchema,
|
|
16281
|
+
DeviceLinkExpressionSourceSchema
|
|
16282
|
+
]),
|
|
15216
16283
|
target: object({
|
|
15217
16284
|
cap: string(),
|
|
15218
16285
|
fieldPath: string(),
|
|
@@ -15241,6 +16308,31 @@ var DeviceLinkSchema = object({
|
|
|
15241
16308
|
})
|
|
15242
16309
|
]).optional()
|
|
15243
16310
|
});
|
|
16311
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
16312
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
16313
|
+
var DeviceCapDisplayOverrideSchema = object({
|
|
16314
|
+
unit: string().min(1).optional(),
|
|
16315
|
+
precision: number().int().min(0).max(10).optional()
|
|
16316
|
+
});
|
|
16317
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
16318
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
16319
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
16320
|
+
var DeviceDisplayOverrideSchema = object({
|
|
16321
|
+
icon: string().min(1).optional(),
|
|
16322
|
+
label: string().min(1).optional(),
|
|
16323
|
+
unit: string().min(1).optional(),
|
|
16324
|
+
precision: number().int().min(0).max(10).optional(),
|
|
16325
|
+
hidden: boolean().optional(),
|
|
16326
|
+
perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
|
|
16327
|
+
});
|
|
16328
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
16329
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
16330
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
16331
|
+
var RoleDisplayDefaultSchema = object({
|
|
16332
|
+
unit: string().min(1).optional(),
|
|
16333
|
+
precision: number().int().min(0).max(10).optional(),
|
|
16334
|
+
icon: string().min(1).optional()
|
|
16335
|
+
});
|
|
15244
16336
|
/**
|
|
15245
16337
|
* Serializable projection of a live IDevice.
|
|
15246
16338
|
* Returned by listAll, getDevice, getChildren.
|
|
@@ -15296,7 +16388,9 @@ var DeviceInfoSchema = object({
|
|
|
15296
16388
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
15297
16389
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
15298
16390
|
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
15299
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional()
|
|
16391
|
+
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
16392
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
16393
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
15300
16394
|
});
|
|
15301
16395
|
var ConfigEntrySchema = object({
|
|
15302
16396
|
key: string(),
|
|
@@ -15361,7 +16455,9 @@ var DeviceMetaSchema = object({
|
|
|
15361
16455
|
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
15362
16456
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
15363
16457
|
* Optional: only present for accessory children that carry a known role. */
|
|
15364
|
-
role: string().nullable().optional()
|
|
16458
|
+
role: string().nullable().optional(),
|
|
16459
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
16460
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
15365
16461
|
});
|
|
15366
16462
|
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
15367
16463
|
var ConfigUISchemaOutput = unknown().nullable();
|
|
@@ -15455,7 +16551,19 @@ method(object({
|
|
|
15455
16551
|
}), _void(), {
|
|
15456
16552
|
kind: "mutation",
|
|
15457
16553
|
auth: "admin"
|
|
15458
|
-
}), method(object({
|
|
16554
|
+
}), method(object({
|
|
16555
|
+
deviceId: number(),
|
|
16556
|
+
display: DeviceDisplayOverrideSchema.nullable()
|
|
16557
|
+
}), _void(), {
|
|
16558
|
+
kind: "mutation",
|
|
16559
|
+
auth: "admin"
|
|
16560
|
+
}), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
|
|
16561
|
+
kind: "mutation",
|
|
16562
|
+
auth: "admin"
|
|
16563
|
+
}), method(object({
|
|
16564
|
+
deviceId: number(),
|
|
16565
|
+
includeSynthesizable: boolean().optional()
|
|
16566
|
+
}), object({ caps: array(object({
|
|
15459
16567
|
cap: string(),
|
|
15460
16568
|
fields: array(object({
|
|
15461
16569
|
path: string(),
|
|
@@ -15465,8 +16573,13 @@ method(object({
|
|
|
15465
16573
|
"boolean",
|
|
15466
16574
|
"enum"
|
|
15467
16575
|
]),
|
|
15468
|
-
enumValues: array(string()).optional()
|
|
15469
|
-
|
|
16576
|
+
enumValues: array(string()).optional(),
|
|
16577
|
+
item: boolean().optional()
|
|
16578
|
+
})).readonly(),
|
|
16579
|
+
itemArray: object({
|
|
16580
|
+
path: string(),
|
|
16581
|
+
keyField: string()
|
|
16582
|
+
}).optional()
|
|
15470
16583
|
})).readonly() }), { kind: "query" }), method(object({
|
|
15471
16584
|
deviceId: number(),
|
|
15472
16585
|
role: string().nullable()
|
|
@@ -15536,7 +16649,11 @@ method(object({
|
|
|
15536
16649
|
deviceId: number(),
|
|
15537
16650
|
entries: array(object({
|
|
15538
16651
|
capName: string(),
|
|
15539
|
-
kind: _enum([
|
|
16652
|
+
kind: _enum([
|
|
16653
|
+
"native",
|
|
16654
|
+
"wrapped",
|
|
16655
|
+
"linked"
|
|
16656
|
+
]),
|
|
15540
16657
|
providerAddonId: string(),
|
|
15541
16658
|
providerNodeId: string(),
|
|
15542
16659
|
nativeAddonId: string()
|
|
@@ -15545,7 +16662,11 @@ method(object({
|
|
|
15545
16662
|
deviceId: number(),
|
|
15546
16663
|
entries: array(object({
|
|
15547
16664
|
capName: string(),
|
|
15548
|
-
kind: _enum([
|
|
16665
|
+
kind: _enum([
|
|
16666
|
+
"native",
|
|
16667
|
+
"wrapped",
|
|
16668
|
+
"linked"
|
|
16669
|
+
]),
|
|
15549
16670
|
providerAddonId: string(),
|
|
15550
16671
|
providerNodeId: string(),
|
|
15551
16672
|
nativeAddonId: string()
|
|
@@ -16035,7 +17156,7 @@ var AddBrokerInputSchema = object({
|
|
|
16035
17156
|
});
|
|
16036
17157
|
var AddBrokerResultSchema = object({ id: string() });
|
|
16037
17158
|
var IdInputSchema = object({ id: string() });
|
|
16038
|
-
var TestResultSchema = discriminatedUnion("ok", [object({
|
|
17159
|
+
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
16039
17160
|
ok: literal(true),
|
|
16040
17161
|
latencyMs: number()
|
|
16041
17162
|
}), object({
|
|
@@ -16058,7 +17179,7 @@ var StatusSchema = object({
|
|
|
16058
17179
|
brokerCount: number(),
|
|
16059
17180
|
embeddedRunning: boolean()
|
|
16060
17181
|
});
|
|
16061
|
-
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);
|
|
17182
|
+
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);
|
|
16062
17183
|
var NetworkEndpointSchema = object({
|
|
16063
17184
|
url: string(),
|
|
16064
17185
|
hostname: string(),
|
|
@@ -16092,23 +17213,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
|
16092
17213
|
sourcePort: number().optional()
|
|
16093
17214
|
});
|
|
16094
17215
|
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
16095
|
-
|
|
16096
|
-
|
|
17216
|
+
/**
|
|
17217
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
17218
|
+
*
|
|
17219
|
+
* Apprise-derived model (see
|
|
17220
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
17221
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
17222
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
17223
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
17224
|
+
* message to what the kind supports — callers never special-case a service.
|
|
17225
|
+
*
|
|
17226
|
+
* DESIGN DECISIONS (locked):
|
|
17227
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
17228
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
17229
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
17230
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
17231
|
+
* alternative would fork the UI per addon and cannot host the
|
|
17232
|
+
* discovery→adopt flow.
|
|
17233
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
17234
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
17235
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
17236
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
17237
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
17238
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
17239
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
17240
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
17241
|
+
* base64 fallback needed.
|
|
17242
|
+
*
|
|
17243
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
17244
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
17245
|
+
* admin "Integrations" page.
|
|
17246
|
+
*/
|
|
17247
|
+
/**
|
|
17248
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
17249
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
17250
|
+
*/
|
|
17251
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
17252
|
+
"image",
|
|
17253
|
+
"video",
|
|
17254
|
+
"gif",
|
|
17255
|
+
"audio",
|
|
17256
|
+
"icon"
|
|
17257
|
+
]);
|
|
17258
|
+
/**
|
|
17259
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
17260
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
17261
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
17262
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
17263
|
+
*/
|
|
17264
|
+
var AttachmentSchema = object({
|
|
17265
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
17266
|
+
url: string().optional(),
|
|
17267
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
17268
|
+
mime: string().optional(),
|
|
17269
|
+
name: string().optional()
|
|
17270
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
17271
|
+
var NotificationFormatSchema = _enum([
|
|
17272
|
+
"text",
|
|
17273
|
+
"markdown",
|
|
17274
|
+
"html"
|
|
17275
|
+
]);
|
|
17276
|
+
/** A single tap-through action button. */
|
|
17277
|
+
var NotificationActionSchema = object({
|
|
17278
|
+
id: string(),
|
|
17279
|
+
label: string(),
|
|
17280
|
+
url: string().optional()
|
|
17281
|
+
});
|
|
17282
|
+
/**
|
|
17283
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
17284
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
17285
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
17286
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
17287
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
17288
|
+
* `priority` for that one target.
|
|
17289
|
+
*/
|
|
17290
|
+
var NotificationSchema = object({
|
|
16097
17291
|
body: string(),
|
|
16098
|
-
|
|
17292
|
+
title: string().optional(),
|
|
17293
|
+
format: NotificationFormatSchema.default("text"),
|
|
17294
|
+
priority: number().int().min(1).max(5).default(3),
|
|
17295
|
+
level: string().optional(),
|
|
17296
|
+
attachments: array(AttachmentSchema).optional(),
|
|
17297
|
+
clickUrl: string().optional(),
|
|
17298
|
+
actions: array(NotificationActionSchema).optional(),
|
|
17299
|
+
sound: string().optional(),
|
|
17300
|
+
ttl: number().optional(),
|
|
17301
|
+
tag: string().optional(),
|
|
16099
17302
|
deviceId: number().optional(),
|
|
16100
17303
|
eventId: string().optional(),
|
|
16101
|
-
priority: _enum([
|
|
16102
|
-
"low",
|
|
16103
|
-
"normal",
|
|
16104
|
-
"high",
|
|
16105
|
-
"critical"
|
|
16106
|
-
]).default("normal"),
|
|
16107
17304
|
metadata: record(string(), unknown()).optional()
|
|
16108
|
-
})
|
|
17305
|
+
});
|
|
17306
|
+
/** One declared native severity/priority level for a kind. */
|
|
17307
|
+
var TargetKindLevelSchema = object({
|
|
17308
|
+
id: string(),
|
|
17309
|
+
label: string(),
|
|
17310
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
17311
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
17312
|
+
flags: object({
|
|
17313
|
+
critical: boolean().optional(),
|
|
17314
|
+
silent: boolean().optional(),
|
|
17315
|
+
noPush: boolean().optional()
|
|
17316
|
+
}).optional(),
|
|
17317
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
17318
|
+
requires: array(string()).optional(),
|
|
17319
|
+
description: string().optional()
|
|
17320
|
+
});
|
|
17321
|
+
/** The full capability block consulted before dispatch. */
|
|
17322
|
+
var TargetKindCapsSchema = object({
|
|
17323
|
+
attachments: object({
|
|
17324
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
17325
|
+
mode: _enum([
|
|
17326
|
+
"url",
|
|
17327
|
+
"bytes",
|
|
17328
|
+
"both"
|
|
17329
|
+
]),
|
|
17330
|
+
max: number().int().nonnegative(),
|
|
17331
|
+
maxBytes: number().int().positive().optional()
|
|
17332
|
+
}),
|
|
17333
|
+
/** Max action buttons (0 = none). */
|
|
17334
|
+
actions: number().int().nonnegative(),
|
|
17335
|
+
levels: array(TargetKindLevelSchema),
|
|
17336
|
+
format: array(NotificationFormatSchema),
|
|
17337
|
+
clickUrl: boolean(),
|
|
17338
|
+
sound: boolean(),
|
|
17339
|
+
ttl: boolean(),
|
|
17340
|
+
bodyMaxLen: number().int().positive()
|
|
17341
|
+
});
|
|
17342
|
+
/**
|
|
17343
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
17344
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
17345
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
17346
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
17347
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
17348
|
+
*/
|
|
17349
|
+
var ConfigSchemaPassthrough = unknown();
|
|
17350
|
+
var TargetKindSchema = object({
|
|
17351
|
+
kind: string(),
|
|
17352
|
+
label: string(),
|
|
17353
|
+
icon: string(),
|
|
17354
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
17355
|
+
addonId: string(),
|
|
17356
|
+
configSchema: ConfigSchemaPassthrough,
|
|
17357
|
+
supportsDiscovery: boolean(),
|
|
17358
|
+
caps: TargetKindCapsSchema
|
|
17359
|
+
});
|
|
17360
|
+
/**
|
|
17361
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
17362
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
17363
|
+
* round-trip a stored secret to the UI.
|
|
17364
|
+
*/
|
|
17365
|
+
var TargetSchema = object({
|
|
17366
|
+
id: string(),
|
|
17367
|
+
name: string(),
|
|
17368
|
+
kind: string(),
|
|
17369
|
+
addonId: string(),
|
|
17370
|
+
enabled: boolean(),
|
|
17371
|
+
config: record(string(), unknown())
|
|
17372
|
+
});
|
|
17373
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
17374
|
+
var DiscoveredTargetSchema = object({
|
|
17375
|
+
kind: string(),
|
|
17376
|
+
suggestedName: string(),
|
|
17377
|
+
config: record(string(), unknown())
|
|
17378
|
+
});
|
|
17379
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
17380
|
+
var RenderedAsSchema = object({
|
|
17381
|
+
level: string(),
|
|
17382
|
+
format: NotificationFormatSchema,
|
|
17383
|
+
attachmentsSent: number().int().nonnegative(),
|
|
17384
|
+
actionsSent: number().int().nonnegative(),
|
|
17385
|
+
truncated: boolean(),
|
|
17386
|
+
dropped: array(string())
|
|
17387
|
+
});
|
|
17388
|
+
var SendResultSchema = object({
|
|
16109
17389
|
success: boolean(),
|
|
16110
|
-
error: string().optional()
|
|
16111
|
-
|
|
17390
|
+
error: string().optional(),
|
|
17391
|
+
renderedAs: RenderedAsSchema.optional()
|
|
17392
|
+
});
|
|
17393
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
17394
|
+
var TestResultSchema = SendResultSchema;
|
|
17395
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
|
|
17396
|
+
kind: string(),
|
|
17397
|
+
config: record(string(), unknown()).optional()
|
|
17398
|
+
}), array(DiscoveredTargetSchema)), method(object({
|
|
17399
|
+
targetId: string(),
|
|
17400
|
+
notification: NotificationSchema
|
|
17401
|
+
}), SendResultSchema, { kind: "mutation" }), method(object({
|
|
17402
|
+
targetId: string(),
|
|
17403
|
+
sample: NotificationSchema.optional()
|
|
17404
|
+
}), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
|
|
17405
|
+
targetId: string(),
|
|
17406
|
+
enabled: boolean()
|
|
17407
|
+
}), _void(), { kind: "mutation" });
|
|
16112
17408
|
/**
|
|
16113
17409
|
* Zod schemas for persisted record types.
|
|
16114
17410
|
*
|
|
@@ -19224,7 +20520,10 @@ var HwAccelBackendInputSchema = _enum([
|
|
|
19224
20520
|
"webgpu",
|
|
19225
20521
|
"none"
|
|
19226
20522
|
]).nullable().optional();
|
|
19227
|
-
var HwAccelResolutionSchema = object({
|
|
20523
|
+
var HwAccelResolutionSchema = object({
|
|
20524
|
+
preferred: array(string()).readonly(),
|
|
20525
|
+
rationale: string()
|
|
20526
|
+
});
|
|
19228
20527
|
var HardwareEncoderIdSchema = _enum([
|
|
19229
20528
|
"h264_videotoolbox",
|
|
19230
20529
|
"hevc_videotoolbox",
|
|
@@ -19329,10 +20628,7 @@ var ResolvedInferenceConfigSchema = object({
|
|
|
19329
20628
|
format: ModelFormatSchema,
|
|
19330
20629
|
reason: string()
|
|
19331
20630
|
});
|
|
19332
|
-
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
|
|
19333
|
-
prefer: HwAccelBackendInputSchema,
|
|
19334
|
-
nodeId: string().optional()
|
|
19335
|
-
}), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
20631
|
+
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
19336
20632
|
kind: "mutation",
|
|
19337
20633
|
auth: "admin"
|
|
19338
20634
|
}), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
|
|
@@ -19391,6 +20687,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
|
|
|
19391
20687
|
kind: "mutation",
|
|
19392
20688
|
auth: "admin"
|
|
19393
20689
|
});
|
|
20690
|
+
/**
|
|
20691
|
+
* `recording` cap — footage availability + HLS playback manifests + per-device
|
|
20692
|
+
* recording config. NOTE on events (source of truth, R5/C3): this cap carries
|
|
20693
|
+
* NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
|
|
20694
|
+
* events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
|
|
20695
|
+
* rows); the recorder's internal EventMap markers are ephemeral in-RAM
|
|
20696
|
+
* annotations that are not exposed here and must not be treated as an event
|
|
20697
|
+
* feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
|
|
20698
|
+
* (`interfaces/recording-config.ts`).
|
|
20699
|
+
*/
|
|
19394
20700
|
var RecordingStatusSchema = object({
|
|
19395
20701
|
deviceId: number(),
|
|
19396
20702
|
enabled: boolean(),
|
|
@@ -21040,6 +22346,12 @@ Object.freeze({
|
|
|
21040
22346
|
addonId: null,
|
|
21041
22347
|
access: "view"
|
|
21042
22348
|
},
|
|
22349
|
+
"deviceManager.getRoleDisplayDefaults": {
|
|
22350
|
+
capName: "device-manager",
|
|
22351
|
+
capScope: "system",
|
|
22352
|
+
addonId: null,
|
|
22353
|
+
access: "view"
|
|
22354
|
+
},
|
|
21043
22355
|
"deviceManager.getSettingsSchema": {
|
|
21044
22356
|
capName: "device-manager",
|
|
21045
22357
|
capScope: "system",
|
|
@@ -21190,6 +22502,12 @@ Object.freeze({
|
|
|
21190
22502
|
addonId: null,
|
|
21191
22503
|
access: "create"
|
|
21192
22504
|
},
|
|
22505
|
+
"deviceManager.setDisplay": {
|
|
22506
|
+
capName: "device-manager",
|
|
22507
|
+
capScope: "system",
|
|
22508
|
+
addonId: null,
|
|
22509
|
+
access: "create"
|
|
22510
|
+
},
|
|
21193
22511
|
"deviceManager.setIntegrationId": {
|
|
21194
22512
|
capName: "device-manager",
|
|
21195
22513
|
capScope: "system",
|
|
@@ -21232,6 +22550,12 @@ Object.freeze({
|
|
|
21232
22550
|
addonId: null,
|
|
21233
22551
|
access: "create"
|
|
21234
22552
|
},
|
|
22553
|
+
"deviceManager.setRoleDisplayDefaults": {
|
|
22554
|
+
capName: "device-manager",
|
|
22555
|
+
capScope: "system",
|
|
22556
|
+
addonId: null,
|
|
22557
|
+
access: "create"
|
|
22558
|
+
},
|
|
21235
22559
|
"deviceManager.setStreamProfileMap": {
|
|
21236
22560
|
capName: "device-manager",
|
|
21237
22561
|
capScope: "system",
|
|
@@ -22210,13 +23534,49 @@ Object.freeze({
|
|
|
22210
23534
|
addonId: null,
|
|
22211
23535
|
access: "create"
|
|
22212
23536
|
},
|
|
23537
|
+
"notificationOutput.deleteTarget": {
|
|
23538
|
+
capName: "notification-output",
|
|
23539
|
+
capScope: "system",
|
|
23540
|
+
addonId: null,
|
|
23541
|
+
access: "delete"
|
|
23542
|
+
},
|
|
23543
|
+
"notificationOutput.discoverTargets": {
|
|
23544
|
+
capName: "notification-output",
|
|
23545
|
+
capScope: "system",
|
|
23546
|
+
addonId: null,
|
|
23547
|
+
access: "view"
|
|
23548
|
+
},
|
|
23549
|
+
"notificationOutput.listTargetKinds": {
|
|
23550
|
+
capName: "notification-output",
|
|
23551
|
+
capScope: "system",
|
|
23552
|
+
addonId: null,
|
|
23553
|
+
access: "view"
|
|
23554
|
+
},
|
|
23555
|
+
"notificationOutput.listTargets": {
|
|
23556
|
+
capName: "notification-output",
|
|
23557
|
+
capScope: "system",
|
|
23558
|
+
addonId: null,
|
|
23559
|
+
access: "view"
|
|
23560
|
+
},
|
|
22213
23561
|
"notificationOutput.send": {
|
|
22214
23562
|
capName: "notification-output",
|
|
22215
23563
|
capScope: "system",
|
|
22216
23564
|
addonId: null,
|
|
22217
23565
|
access: "create"
|
|
22218
23566
|
},
|
|
22219
|
-
"notificationOutput.
|
|
23567
|
+
"notificationOutput.setTargetEnabled": {
|
|
23568
|
+
capName: "notification-output",
|
|
23569
|
+
capScope: "system",
|
|
23570
|
+
addonId: null,
|
|
23571
|
+
access: "create"
|
|
23572
|
+
},
|
|
23573
|
+
"notificationOutput.testTarget": {
|
|
23574
|
+
capName: "notification-output",
|
|
23575
|
+
capScope: "system",
|
|
23576
|
+
addonId: null,
|
|
23577
|
+
access: "create"
|
|
23578
|
+
},
|
|
23579
|
+
"notificationOutput.upsertTarget": {
|
|
22220
23580
|
capName: "notification-output",
|
|
22221
23581
|
capScope: "system",
|
|
22222
23582
|
addonId: null,
|
|
@@ -22246,6 +23606,66 @@ Object.freeze({
|
|
|
22246
23606
|
addonId: null,
|
|
22247
23607
|
access: "create"
|
|
22248
23608
|
},
|
|
23609
|
+
"petFeeder.callPet": {
|
|
23610
|
+
capName: "pet-feeder",
|
|
23611
|
+
capScope: "device",
|
|
23612
|
+
addonId: null,
|
|
23613
|
+
access: "create"
|
|
23614
|
+
},
|
|
23615
|
+
"petFeeder.cancelFeed": {
|
|
23616
|
+
capName: "pet-feeder",
|
|
23617
|
+
capScope: "device",
|
|
23618
|
+
addonId: null,
|
|
23619
|
+
access: "create"
|
|
23620
|
+
},
|
|
23621
|
+
"petFeeder.feed": {
|
|
23622
|
+
capName: "pet-feeder",
|
|
23623
|
+
capScope: "device",
|
|
23624
|
+
addonId: null,
|
|
23625
|
+
access: "create"
|
|
23626
|
+
},
|
|
23627
|
+
"petFeeder.markFoodReplenished": {
|
|
23628
|
+
capName: "pet-feeder",
|
|
23629
|
+
capScope: "device",
|
|
23630
|
+
addonId: null,
|
|
23631
|
+
access: "create"
|
|
23632
|
+
},
|
|
23633
|
+
"petFeeder.playSound": {
|
|
23634
|
+
capName: "pet-feeder",
|
|
23635
|
+
capScope: "device",
|
|
23636
|
+
addonId: null,
|
|
23637
|
+
access: "create"
|
|
23638
|
+
},
|
|
23639
|
+
"petFeeder.resetDesiccant": {
|
|
23640
|
+
capName: "pet-feeder",
|
|
23641
|
+
capScope: "device",
|
|
23642
|
+
addonId: null,
|
|
23643
|
+
access: "delete"
|
|
23644
|
+
},
|
|
23645
|
+
"petFeeder.setChildLock": {
|
|
23646
|
+
capName: "pet-feeder",
|
|
23647
|
+
capScope: "device",
|
|
23648
|
+
addonId: null,
|
|
23649
|
+
access: "create"
|
|
23650
|
+
},
|
|
23651
|
+
"petFeeder.setFeedSound": {
|
|
23652
|
+
capName: "pet-feeder",
|
|
23653
|
+
capScope: "device",
|
|
23654
|
+
addonId: null,
|
|
23655
|
+
access: "create"
|
|
23656
|
+
},
|
|
23657
|
+
"petFeeder.setIndicatorLight": {
|
|
23658
|
+
capName: "pet-feeder",
|
|
23659
|
+
capScope: "device",
|
|
23660
|
+
addonId: null,
|
|
23661
|
+
access: "create"
|
|
23662
|
+
},
|
|
23663
|
+
"petFeeder.setVolume": {
|
|
23664
|
+
capName: "pet-feeder",
|
|
23665
|
+
capScope: "device",
|
|
23666
|
+
addonId: null,
|
|
23667
|
+
access: "create"
|
|
23668
|
+
},
|
|
22249
23669
|
"pipelineAnalytics.clearTracks": {
|
|
22250
23670
|
capName: "pipeline-analytics",
|
|
22251
23671
|
capScope: "device",
|