@camstack/addon-provider-hikvision 1.1.12 → 1.1.14
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 +1483 -63
- package/dist/addon.mjs +1483 -63
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -4635,7 +4635,7 @@ function _instanceof(cls, params = {}) {
|
|
|
4635
4635
|
return inst;
|
|
4636
4636
|
}
|
|
4637
4637
|
//#endregion
|
|
4638
|
-
//#region ../types/dist/sleep-
|
|
4638
|
+
//#region ../types/dist/sleep-BiDFW0E7.mjs
|
|
4639
4639
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4640
4640
|
EventCategory["SystemBoot"] = "system.boot";
|
|
4641
4641
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -5448,6 +5448,100 @@ function createDurableState(deps) {
|
|
|
5448
5448
|
};
|
|
5449
5449
|
}
|
|
5450
5450
|
/**
|
|
5451
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
5452
|
+
*
|
|
5453
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
5454
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
5455
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
5456
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
5457
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
5458
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
5459
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
5460
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
5461
|
+
*
|
|
5462
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
5463
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
5464
|
+
* schema and routes reads/writes through these helpers.
|
|
5465
|
+
*
|
|
5466
|
+
* ## No bare-key fallback — deliberate
|
|
5467
|
+
*
|
|
5468
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
5469
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
5470
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
5471
|
+
* the store is invisible to every node, hub included, so one node's
|
|
5472
|
+
* selection can never leak onto another. (This generalizes the
|
|
5473
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
5474
|
+
* arbitrary set of per-node field keys.)
|
|
5475
|
+
*
|
|
5476
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
5477
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
5478
|
+
*/
|
|
5479
|
+
/**
|
|
5480
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
5481
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
5482
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
5483
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
5484
|
+
*/
|
|
5485
|
+
function normalizeNodeId(raw) {
|
|
5486
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
5487
|
+
const slashIdx = raw.indexOf("/");
|
|
5488
|
+
if (slashIdx < 0) return raw;
|
|
5489
|
+
const bare = raw.slice(0, slashIdx);
|
|
5490
|
+
return bare === "" ? "hub" : bare;
|
|
5491
|
+
}
|
|
5492
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
5493
|
+
function nodeScopedKey(base, nodeId) {
|
|
5494
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
5495
|
+
}
|
|
5496
|
+
/**
|
|
5497
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
5498
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
5499
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
5500
|
+
* schema `default` win on `undefined`.
|
|
5501
|
+
*/
|
|
5502
|
+
function readNodeValue(store, base, nodeId) {
|
|
5503
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
5504
|
+
}
|
|
5505
|
+
/**
|
|
5506
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
5507
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
5508
|
+
* the write path so a save for one node never clobbers another node's value
|
|
5509
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
5510
|
+
* patch is not mutated.
|
|
5511
|
+
*/
|
|
5512
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
5513
|
+
const out = {};
|
|
5514
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
5515
|
+
return out;
|
|
5516
|
+
}
|
|
5517
|
+
/**
|
|
5518
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
5519
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
5520
|
+
* values:
|
|
5521
|
+
*
|
|
5522
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
5523
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
5524
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
5525
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
5526
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
5527
|
+
* left ABSENT so the field's schema `default` wins.
|
|
5528
|
+
*
|
|
5529
|
+
* Returns a new object — the input store is not mutated.
|
|
5530
|
+
*/
|
|
5531
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
5532
|
+
const out = {};
|
|
5533
|
+
for (const [key, value] of Object.entries(store)) {
|
|
5534
|
+
if (key.includes("@")) continue;
|
|
5535
|
+
if (perNodeKeys.has(key)) continue;
|
|
5536
|
+
out[key] = value;
|
|
5537
|
+
}
|
|
5538
|
+
for (const base of perNodeKeys) {
|
|
5539
|
+
const value = readNodeValue(store, base, nodeId);
|
|
5540
|
+
if (value !== void 0) out[base] = value;
|
|
5541
|
+
}
|
|
5542
|
+
return out;
|
|
5543
|
+
}
|
|
5544
|
+
/**
|
|
5451
5545
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5452
5546
|
*
|
|
5453
5547
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -5615,23 +5709,63 @@ var BaseAddon = class {
|
|
|
5615
5709
|
deviceSettingsSchema() {
|
|
5616
5710
|
return null;
|
|
5617
5711
|
}
|
|
5618
|
-
async getGlobalSettings(overlay, cap,
|
|
5712
|
+
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5619
5713
|
const schema = this.globalSettingsSchema(cap);
|
|
5620
5714
|
if (!schema) return { sections: [] };
|
|
5621
|
-
const
|
|
5715
|
+
const projected = await this.resolveGlobalStore(nodeId, cap);
|
|
5622
5716
|
return hydrateSchema(schema, overlay ? {
|
|
5623
|
-
...
|
|
5717
|
+
...projected,
|
|
5624
5718
|
...overlay
|
|
5625
|
-
} :
|
|
5719
|
+
} : projected);
|
|
5626
5720
|
}
|
|
5627
|
-
|
|
5628
|
-
|
|
5721
|
+
/**
|
|
5722
|
+
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5723
|
+
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5724
|
+
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
5725
|
+
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
5726
|
+
* A no-op passthrough when the schema declares no `perNode` field.
|
|
5727
|
+
*
|
|
5728
|
+
* This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
|
|
5729
|
+
* the store for custom option logic (option narrowing, value snapping) to
|
|
5730
|
+
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
5731
|
+
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
5732
|
+
*/
|
|
5733
|
+
async resolveGlobalStore(nodeId, cap) {
|
|
5734
|
+
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
5735
|
+
const keys = this.perNodeKeys(cap);
|
|
5736
|
+
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5737
|
+
return keys.size > 0 ? projectStore(raw, keys, node) : raw;
|
|
5738
|
+
}
|
|
5739
|
+
async updateGlobalSettings(patch, nodeId) {
|
|
5740
|
+
const keys = this.perNodeKeys();
|
|
5741
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5742
|
+
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5743
|
+
const barePatch = patch;
|
|
5744
|
+
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
5745
|
+
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
5746
|
+
if (target !== localNode) return;
|
|
5629
5747
|
await this.resolveConfig();
|
|
5630
5748
|
await this.onConfigChanged();
|
|
5631
5749
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
5632
5750
|
this.maybeAutoRestart(patch, this.globalSettingsSchema());
|
|
5633
5751
|
}
|
|
5634
5752
|
/**
|
|
5753
|
+
* The set of field keys the global settings schema declares `perNode: true`
|
|
5754
|
+
* — derived once per `cap` argument and memoized (schemas are static
|
|
5755
|
+
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
5756
|
+
* settings API behaves exactly like the legacy node-agnostic one.
|
|
5757
|
+
*/
|
|
5758
|
+
_perNodeKeysCache = /* @__PURE__ */ new Map();
|
|
5759
|
+
perNodeKeys(cap) {
|
|
5760
|
+
const cacheKey = cap ?? "";
|
|
5761
|
+
const cached = this._perNodeKeysCache.get(cacheKey);
|
|
5762
|
+
if (cached) return cached;
|
|
5763
|
+
const schema = this.globalSettingsSchema(cap);
|
|
5764
|
+
const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
5765
|
+
this._perNodeKeysCache.set(cacheKey, keys);
|
|
5766
|
+
return keys;
|
|
5767
|
+
}
|
|
5768
|
+
/**
|
|
5635
5769
|
* If any field in `patch` is marked `requiresRestart` in `schema`,
|
|
5636
5770
|
* schedule an addon restart for the next tick. Deferred via
|
|
5637
5771
|
* `setImmediate` so the tRPC mutation that triggered the write has
|
|
@@ -5784,12 +5918,19 @@ var BaseAddon = class {
|
|
|
5784
5918
|
* The merge is shallow: each key in `defaults` is checked against the store.
|
|
5785
5919
|
* Only keys present in defaults are read — the store can contain extra keys
|
|
5786
5920
|
* (e.g. from older versions) without polluting the typed config.
|
|
5921
|
+
*
|
|
5922
|
+
* Keys the global settings schema declares `perNode: true` resolve from
|
|
5923
|
+
* THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
|
|
5924
|
+
* from the bare key — so a per-node field resolves to this node's own
|
|
5925
|
+
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
5787
5926
|
*/
|
|
5788
5927
|
async resolveConfig() {
|
|
5789
5928
|
const stored = await this.readAddonStoreWithRetry();
|
|
5929
|
+
const perNode = this.perNodeKeys();
|
|
5930
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5790
5931
|
const resolved = { ...this.defaults };
|
|
5791
5932
|
for (const key of Object.keys(this.defaults)) {
|
|
5792
|
-
const storedValue = stored[key];
|
|
5933
|
+
const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
|
|
5793
5934
|
if (storedValue !== void 0 && storedValue !== null) {
|
|
5794
5935
|
const defaultType = typeof this.defaults[key];
|
|
5795
5936
|
if (typeof storedValue === defaultType) resolved[key] = storedValue;
|
|
@@ -5873,6 +6014,27 @@ var BaseAddon = class {
|
|
|
5873
6014
|
}
|
|
5874
6015
|
};
|
|
5875
6016
|
/**
|
|
6017
|
+
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
6018
|
+
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
6019
|
+
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6020
|
+
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6021
|
+
*/
|
|
6022
|
+
function collectPerNodeFieldKeys(fields) {
|
|
6023
|
+
const collected = [];
|
|
6024
|
+
for (const field of fields) {
|
|
6025
|
+
if (field.type === "group") {
|
|
6026
|
+
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
6027
|
+
continue;
|
|
6028
|
+
}
|
|
6029
|
+
if (field.type === "sub-tabs") {
|
|
6030
|
+
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
6031
|
+
continue;
|
|
6032
|
+
}
|
|
6033
|
+
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
6034
|
+
}
|
|
6035
|
+
return collected;
|
|
6036
|
+
}
|
|
6037
|
+
/**
|
|
5876
6038
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
5877
6039
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
5878
6040
|
* envelopes pass through; void stays void.
|
|
@@ -5897,6 +6059,7 @@ var CamStreamKindSchema = _enum([
|
|
|
5897
6059
|
"pull-rtsp",
|
|
5898
6060
|
"pull-rtmp",
|
|
5899
6061
|
"pull-http",
|
|
6062
|
+
"pull-flv",
|
|
5900
6063
|
"pull-rfc4571",
|
|
5901
6064
|
"push-annexb",
|
|
5902
6065
|
"derived"
|
|
@@ -6279,6 +6442,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
6279
6442
|
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
6280
6443
|
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
6281
6444
|
DeviceType["Image"] = "image";
|
|
6445
|
+
/** Smart pet feeder — cloud-connected food dispenser with a bowl food
|
|
6446
|
+
* level, battery, desiccant life, feeding state and manual-feed /
|
|
6447
|
+
* call-pet / maintenance actions. Installed with the `pet-feeder` cap;
|
|
6448
|
+
* dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
|
|
6449
|
+
* native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
|
|
6450
|
+
* integrations sharing the same food/desiccant/hopper surface. */
|
|
6451
|
+
DeviceType["PetFeeder"] = "pet-feeder";
|
|
6282
6452
|
return DeviceType;
|
|
6283
6453
|
}({});
|
|
6284
6454
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -7219,7 +7389,21 @@ var StorageLocationDeclarationSchema = object({
|
|
|
7219
7389
|
* slots (e.g. `recordingsLow` → `recordings`) so operators only need to
|
|
7220
7390
|
* configure the primary location.
|
|
7221
7391
|
*/
|
|
7222
|
-
defaultsTo: string().optional()
|
|
7392
|
+
defaultsTo: string().optional(),
|
|
7393
|
+
/**
|
|
7394
|
+
* Which node root the seeded `<id>:default` instance is placed under on a
|
|
7395
|
+
* FRESH install:
|
|
7396
|
+
* - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
|
|
7397
|
+
* the appData volume. Right for small/durable data (backups, logs, models).
|
|
7398
|
+
* - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
|
|
7399
|
+
* env is set, else falls back to the data root. Right for bulky, hot media
|
|
7400
|
+
* (recordings, event media) that should stay off the appData disk.
|
|
7401
|
+
*
|
|
7402
|
+
* Only affects the seeded default's `basePath`; operators can repoint any
|
|
7403
|
+
* location afterwards, and a `defaultsTo` slot inherits its parent's root
|
|
7404
|
+
* regardless of this field. Absent (the common case) is treated as `'data'`.
|
|
7405
|
+
*/
|
|
7406
|
+
defaultRoot: _enum(["data", "media"]).optional()
|
|
7223
7407
|
});
|
|
7224
7408
|
var DecoderStatsSchema = object({
|
|
7225
7409
|
inputFps: number(),
|
|
@@ -7592,6 +7776,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
|
|
|
7592
7776
|
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7593
7777
|
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7594
7778
|
/**
|
|
7779
|
+
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7780
|
+
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
7781
|
+
* failure — both are non-fatal to the host: read paths degrade to "skip link".
|
|
7782
|
+
*/
|
|
7783
|
+
/** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
|
|
7784
|
+
* the failure is anchored to a character (author-facing inline feedback). */
|
|
7785
|
+
var ExpressionParseError = class extends Error {
|
|
7786
|
+
position;
|
|
7787
|
+
constructor(message, position) {
|
|
7788
|
+
super(message);
|
|
7789
|
+
this.name = "ExpressionParseError";
|
|
7790
|
+
this.position = position;
|
|
7791
|
+
}
|
|
7792
|
+
};
|
|
7793
|
+
/** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
|
|
7794
|
+
* result, unknown builtin, step-budget exceeded). */
|
|
7795
|
+
var ExpressionEvalError = class extends Error {
|
|
7796
|
+
constructor(message) {
|
|
7797
|
+
super(message);
|
|
7798
|
+
this.name = "ExpressionEvalError";
|
|
7799
|
+
}
|
|
7800
|
+
};
|
|
7801
|
+
/**
|
|
7802
|
+
* Resource-bound constants for the safe expression engine.
|
|
7803
|
+
*
|
|
7804
|
+
* Every bound is defense-in-depth: the grammar is non-Turing-complete (no
|
|
7805
|
+
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
7806
|
+
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
7807
|
+
* work a single author-supplied expression can request, so a hostile or
|
|
7808
|
+
* accidental pathological string can never spend unbounded CPU/memory.
|
|
7809
|
+
*/
|
|
7810
|
+
/** Max source length (chars) — checked BEFORE tokenizing so a huge string is
|
|
7811
|
+
* rejected without allocation. */
|
|
7812
|
+
var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
|
|
7813
|
+
/** A legal binding / identifier name. */
|
|
7814
|
+
var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7815
|
+
/** Binding names an author may NOT use: `now` is auto-injected; the literal
|
|
7816
|
+
* keywords lex as values, not identifiers, so binding to them is meaningless. */
|
|
7817
|
+
var RESERVED_BINDING_NAMES = new Set([
|
|
7818
|
+
"now",
|
|
7819
|
+
"true",
|
|
7820
|
+
"false",
|
|
7821
|
+
"null"
|
|
7822
|
+
]);
|
|
7823
|
+
/**
|
|
7824
|
+
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
7825
|
+
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
7826
|
+
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
7827
|
+
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
7828
|
+
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
7829
|
+
* is a parse error with a source position, so member access / assignment /
|
|
7830
|
+
* template literals are lexically impossible.
|
|
7831
|
+
*/
|
|
7832
|
+
var KEYWORDS = new Set([
|
|
7833
|
+
"true",
|
|
7834
|
+
"false",
|
|
7835
|
+
"null"
|
|
7836
|
+
]);
|
|
7837
|
+
function isDigit(ch) {
|
|
7838
|
+
return ch >= "0" && ch <= "9";
|
|
7839
|
+
}
|
|
7840
|
+
function isIdentStart(ch) {
|
|
7841
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
7842
|
+
}
|
|
7843
|
+
function isIdentPart(ch) {
|
|
7844
|
+
return isIdentStart(ch) || isDigit(ch);
|
|
7845
|
+
}
|
|
7846
|
+
function isWhitespace(ch) {
|
|
7847
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
7848
|
+
}
|
|
7849
|
+
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
7850
|
+
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
7851
|
+
* string. */
|
|
7852
|
+
function tokenize(source) {
|
|
7853
|
+
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
7854
|
+
const tokens = [];
|
|
7855
|
+
let i = 0;
|
|
7856
|
+
const n = source.length;
|
|
7857
|
+
while (i < n) {
|
|
7858
|
+
const ch = source[i];
|
|
7859
|
+
if (isWhitespace(ch)) {
|
|
7860
|
+
i += 1;
|
|
7861
|
+
continue;
|
|
7862
|
+
}
|
|
7863
|
+
if (isDigit(ch)) {
|
|
7864
|
+
const start = i;
|
|
7865
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7866
|
+
if (i < n && source[i] === ".") {
|
|
7867
|
+
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
7868
|
+
i += 1;
|
|
7869
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7870
|
+
}
|
|
7871
|
+
const text = source.slice(start, i);
|
|
7872
|
+
const value = Number(text);
|
|
7873
|
+
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
7874
|
+
tokens.push({
|
|
7875
|
+
type: "number",
|
|
7876
|
+
value,
|
|
7877
|
+
pos: start
|
|
7878
|
+
});
|
|
7879
|
+
continue;
|
|
7880
|
+
}
|
|
7881
|
+
if (ch === "'" || ch === "\"") {
|
|
7882
|
+
const quote = ch;
|
|
7883
|
+
const start = i;
|
|
7884
|
+
i += 1;
|
|
7885
|
+
let out = "";
|
|
7886
|
+
let closed = false;
|
|
7887
|
+
while (i < n) {
|
|
7888
|
+
const c = source[i];
|
|
7889
|
+
if (c === "\\") {
|
|
7890
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
7891
|
+
if (next === "\\" || next === "'" || next === "\"") {
|
|
7892
|
+
out += next;
|
|
7893
|
+
i += 2;
|
|
7894
|
+
continue;
|
|
7895
|
+
}
|
|
7896
|
+
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
7897
|
+
}
|
|
7898
|
+
if (c === quote) {
|
|
7899
|
+
closed = true;
|
|
7900
|
+
i += 1;
|
|
7901
|
+
break;
|
|
7902
|
+
}
|
|
7903
|
+
out += c;
|
|
7904
|
+
i += 1;
|
|
7905
|
+
}
|
|
7906
|
+
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
7907
|
+
tokens.push({
|
|
7908
|
+
type: "string",
|
|
7909
|
+
value: out,
|
|
7910
|
+
pos: start
|
|
7911
|
+
});
|
|
7912
|
+
continue;
|
|
7913
|
+
}
|
|
7914
|
+
if (isIdentStart(ch)) {
|
|
7915
|
+
const start = i;
|
|
7916
|
+
while (i < n && isIdentPart(source[i])) i += 1;
|
|
7917
|
+
const text = source.slice(start, i);
|
|
7918
|
+
if (KEYWORDS.has(text)) tokens.push({
|
|
7919
|
+
type: "keyword",
|
|
7920
|
+
keyword: keywordOf(text),
|
|
7921
|
+
pos: start
|
|
7922
|
+
});
|
|
7923
|
+
else tokens.push({
|
|
7924
|
+
type: "identifier",
|
|
7925
|
+
name: text,
|
|
7926
|
+
pos: start
|
|
7927
|
+
});
|
|
7928
|
+
continue;
|
|
7929
|
+
}
|
|
7930
|
+
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
7931
|
+
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
7932
|
+
tokens.push({
|
|
7933
|
+
type: "punct",
|
|
7934
|
+
punct: two,
|
|
7935
|
+
pos: i
|
|
7936
|
+
});
|
|
7937
|
+
i += 2;
|
|
7938
|
+
continue;
|
|
7939
|
+
}
|
|
7940
|
+
if (isSinglePunct(ch)) {
|
|
7941
|
+
tokens.push({
|
|
7942
|
+
type: "punct",
|
|
7943
|
+
punct: ch,
|
|
7944
|
+
pos: i
|
|
7945
|
+
});
|
|
7946
|
+
i += 1;
|
|
7947
|
+
continue;
|
|
7948
|
+
}
|
|
7949
|
+
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
7950
|
+
}
|
|
7951
|
+
tokens.push({
|
|
7952
|
+
type: "eof",
|
|
7953
|
+
pos: n
|
|
7954
|
+
});
|
|
7955
|
+
return tokens;
|
|
7956
|
+
}
|
|
7957
|
+
function keywordOf(text) {
|
|
7958
|
+
if (text === "true") return "true";
|
|
7959
|
+
if (text === "false") return "false";
|
|
7960
|
+
return "null";
|
|
7961
|
+
}
|
|
7962
|
+
function isSinglePunct(ch) {
|
|
7963
|
+
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
7964
|
+
}
|
|
7965
|
+
/**
|
|
7966
|
+
* Frozen, null-prototype builtin function table for the expression engine
|
|
7967
|
+
* (spec §4 rule 4). The table is the SOLE surface of callable functions: the
|
|
7968
|
+
* parser rejects any callee not in it, and the evaluator gates each call on an
|
|
7969
|
+
* own-property check against it.
|
|
7970
|
+
*
|
|
7971
|
+
* Because the object has a NULL prototype AND is `Object.freeze`d:
|
|
7972
|
+
* - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
|
|
7973
|
+
* - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
|
|
7974
|
+
* (there is no `Object.prototype` in the chain), so those names are not
|
|
7975
|
+
* callable — they are simply "unknown function" at parse time.
|
|
7976
|
+
*
|
|
7977
|
+
* Every numeric argument is validated as a finite number and every numeric
|
|
7978
|
+
* RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
|
|
7979
|
+
* (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
|
|
7980
|
+
* closed rather than emitting a garbage value.
|
|
7981
|
+
*/
|
|
7982
|
+
function asFiniteNumber(value, name, index) {
|
|
7983
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
7984
|
+
return value;
|
|
7985
|
+
}
|
|
7986
|
+
function asString$1(value, name, index) {
|
|
7987
|
+
if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
|
|
7988
|
+
return value;
|
|
7989
|
+
}
|
|
7990
|
+
function finiteResult(value, name) {
|
|
7991
|
+
if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
|
|
7992
|
+
return value;
|
|
7993
|
+
}
|
|
7994
|
+
function allFiniteNumbers(args, name) {
|
|
7995
|
+
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
7996
|
+
}
|
|
7997
|
+
var INF = Number.POSITIVE_INFINITY;
|
|
7998
|
+
var table = {
|
|
7999
|
+
min: {
|
|
8000
|
+
minArgs: 1,
|
|
8001
|
+
maxArgs: INF,
|
|
8002
|
+
apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
|
|
8003
|
+
},
|
|
8004
|
+
max: {
|
|
8005
|
+
minArgs: 1,
|
|
8006
|
+
maxArgs: INF,
|
|
8007
|
+
apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
|
|
8008
|
+
},
|
|
8009
|
+
abs: {
|
|
8010
|
+
minArgs: 1,
|
|
8011
|
+
maxArgs: 1,
|
|
8012
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
8013
|
+
},
|
|
8014
|
+
floor: {
|
|
8015
|
+
minArgs: 1,
|
|
8016
|
+
maxArgs: 1,
|
|
8017
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
8018
|
+
},
|
|
8019
|
+
ceil: {
|
|
8020
|
+
minArgs: 1,
|
|
8021
|
+
maxArgs: 1,
|
|
8022
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
8023
|
+
},
|
|
8024
|
+
sqrt: {
|
|
8025
|
+
minArgs: 1,
|
|
8026
|
+
maxArgs: 1,
|
|
8027
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
8028
|
+
},
|
|
8029
|
+
round: {
|
|
8030
|
+
minArgs: 1,
|
|
8031
|
+
maxArgs: 2,
|
|
8032
|
+
apply: (args) => {
|
|
8033
|
+
const x = asFiniteNumber(args[0], "round", 0);
|
|
8034
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
8035
|
+
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
8036
|
+
const factor = 10 ** digits;
|
|
8037
|
+
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
8038
|
+
}
|
|
8039
|
+
},
|
|
8040
|
+
pow: {
|
|
8041
|
+
minArgs: 2,
|
|
8042
|
+
maxArgs: 2,
|
|
8043
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
8044
|
+
},
|
|
8045
|
+
clamp: {
|
|
8046
|
+
minArgs: 3,
|
|
8047
|
+
maxArgs: 3,
|
|
8048
|
+
apply: (args) => {
|
|
8049
|
+
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
8050
|
+
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
8051
|
+
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
8052
|
+
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
8053
|
+
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
8054
|
+
}
|
|
8055
|
+
},
|
|
8056
|
+
avg: {
|
|
8057
|
+
minArgs: 1,
|
|
8058
|
+
maxArgs: INF,
|
|
8059
|
+
apply: (args) => {
|
|
8060
|
+
const nums = allFiniteNumbers(args, "avg");
|
|
8061
|
+
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
8062
|
+
}
|
|
8063
|
+
},
|
|
8064
|
+
sum: {
|
|
8065
|
+
minArgs: 1,
|
|
8066
|
+
maxArgs: INF,
|
|
8067
|
+
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
8068
|
+
},
|
|
8069
|
+
coalesce: {
|
|
8070
|
+
minArgs: 1,
|
|
8071
|
+
maxArgs: INF,
|
|
8072
|
+
apply: (args) => {
|
|
8073
|
+
for (const a of args) if (a !== null) return a;
|
|
8074
|
+
return null;
|
|
8075
|
+
}
|
|
8076
|
+
},
|
|
8077
|
+
age: {
|
|
8078
|
+
minArgs: 2,
|
|
8079
|
+
maxArgs: 2,
|
|
8080
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
8081
|
+
},
|
|
8082
|
+
convert: {
|
|
8083
|
+
minArgs: 3,
|
|
8084
|
+
maxArgs: 3,
|
|
8085
|
+
apply: (args, hooks) => {
|
|
8086
|
+
const x = asFiniteNumber(args[0], "convert", 0);
|
|
8087
|
+
const from = asString$1(args[1], "convert", 1).trim();
|
|
8088
|
+
const to = asString$1(args[2], "convert", 2).trim();
|
|
8089
|
+
if (hooks.convert) {
|
|
8090
|
+
const out = hooks.convert(x, from, to);
|
|
8091
|
+
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
8092
|
+
return finiteResult(out, "convert");
|
|
8093
|
+
}
|
|
8094
|
+
if (from === to) return x;
|
|
8095
|
+
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
8096
|
+
}
|
|
8097
|
+
}
|
|
8098
|
+
};
|
|
8099
|
+
Object.freeze(Object.assign(Object.create(null), table));
|
|
8100
|
+
/** The set of valid builtin names — used by the parser to reject unknown
|
|
8101
|
+
* callees at parse time (immediate author feedback). */
|
|
8102
|
+
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
8103
|
+
/**
|
|
8104
|
+
* Pratt (precedence-climbing) parser for the safe expression mini-language.
|
|
8105
|
+
*
|
|
8106
|
+
* Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
|
|
8107
|
+
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
8108
|
+
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
8109
|
+
* string validated against the builtin table at parse time, so an unknown
|
|
8110
|
+
* function is rejected immediately (author feedback) and a persisted expression
|
|
8111
|
+
* that references a since-removed builtin degrades at read.
|
|
8112
|
+
*
|
|
8113
|
+
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
8114
|
+
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
8115
|
+
*/
|
|
8116
|
+
/** Binary/logical operator precedence (higher binds tighter). */
|
|
8117
|
+
var BINARY_PRECEDENCE = {
|
|
8118
|
+
"||": 1,
|
|
8119
|
+
"&&": 2,
|
|
8120
|
+
"==": 3,
|
|
8121
|
+
"!=": 3,
|
|
8122
|
+
"<": 4,
|
|
8123
|
+
"<=": 4,
|
|
8124
|
+
">": 4,
|
|
8125
|
+
">=": 4,
|
|
8126
|
+
"+": 5,
|
|
8127
|
+
"-": 5,
|
|
8128
|
+
"*": 6,
|
|
8129
|
+
"/": 6,
|
|
8130
|
+
"%": 6
|
|
8131
|
+
};
|
|
8132
|
+
function isLogicalOp(op) {
|
|
8133
|
+
return op === "&&" || op === "||";
|
|
8134
|
+
}
|
|
8135
|
+
function isBinaryOp(op) {
|
|
8136
|
+
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
8137
|
+
}
|
|
8138
|
+
var Parser = class {
|
|
8139
|
+
tokens;
|
|
8140
|
+
pos = 0;
|
|
8141
|
+
nodeCount = 0;
|
|
8142
|
+
identifiers = /* @__PURE__ */ new Set();
|
|
8143
|
+
callees = /* @__PURE__ */ new Set();
|
|
8144
|
+
constructor(tokens) {
|
|
8145
|
+
this.tokens = tokens;
|
|
8146
|
+
}
|
|
8147
|
+
parse() {
|
|
8148
|
+
const ast = this.parseTernary();
|
|
8149
|
+
const tok = this.peek();
|
|
8150
|
+
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
8151
|
+
return {
|
|
8152
|
+
ast,
|
|
8153
|
+
identifiers: this.identifiers,
|
|
8154
|
+
callees: this.callees,
|
|
8155
|
+
nodeCount: this.nodeCount
|
|
8156
|
+
};
|
|
8157
|
+
}
|
|
8158
|
+
peek() {
|
|
8159
|
+
return this.tokens[this.pos];
|
|
8160
|
+
}
|
|
8161
|
+
next() {
|
|
8162
|
+
return this.tokens[this.pos++];
|
|
8163
|
+
}
|
|
8164
|
+
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
8165
|
+
expectPunct(punct) {
|
|
8166
|
+
const tok = this.peek();
|
|
8167
|
+
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
8168
|
+
this.pos += 1;
|
|
8169
|
+
}
|
|
8170
|
+
matchPunct(punct) {
|
|
8171
|
+
const tok = this.peek();
|
|
8172
|
+
if (tok.type === "punct" && tok.punct === punct) {
|
|
8173
|
+
this.pos += 1;
|
|
8174
|
+
return true;
|
|
8175
|
+
}
|
|
8176
|
+
return false;
|
|
8177
|
+
}
|
|
8178
|
+
countNode() {
|
|
8179
|
+
this.nodeCount += 1;
|
|
8180
|
+
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
8181
|
+
}
|
|
8182
|
+
parseTernary() {
|
|
8183
|
+
const test = this.parseBinary(1);
|
|
8184
|
+
if (this.matchPunct("?")) {
|
|
8185
|
+
const consequent = this.parseTernary();
|
|
8186
|
+
this.expectPunct(":");
|
|
8187
|
+
const alternate = this.parseTernary();
|
|
8188
|
+
this.countNode();
|
|
8189
|
+
return {
|
|
8190
|
+
kind: "conditional",
|
|
8191
|
+
test,
|
|
8192
|
+
consequent,
|
|
8193
|
+
alternate
|
|
8194
|
+
};
|
|
8195
|
+
}
|
|
8196
|
+
return test;
|
|
8197
|
+
}
|
|
8198
|
+
parseBinary(minPrec) {
|
|
8199
|
+
let left = this.parseUnary();
|
|
8200
|
+
for (;;) {
|
|
8201
|
+
const tok = this.peek();
|
|
8202
|
+
if (tok.type !== "punct") break;
|
|
8203
|
+
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
8204
|
+
if (prec === void 0 || prec < minPrec) break;
|
|
8205
|
+
const op = tok.punct;
|
|
8206
|
+
this.pos += 1;
|
|
8207
|
+
const right = this.parseBinary(prec + 1);
|
|
8208
|
+
this.countNode();
|
|
8209
|
+
if (isLogicalOp(op)) left = {
|
|
8210
|
+
kind: "logical",
|
|
8211
|
+
op,
|
|
8212
|
+
left,
|
|
8213
|
+
right
|
|
8214
|
+
};
|
|
8215
|
+
else if (isBinaryOp(op)) left = {
|
|
8216
|
+
kind: "binary",
|
|
8217
|
+
op,
|
|
8218
|
+
left,
|
|
8219
|
+
right
|
|
8220
|
+
};
|
|
8221
|
+
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
8222
|
+
}
|
|
8223
|
+
return left;
|
|
8224
|
+
}
|
|
8225
|
+
parseUnary() {
|
|
8226
|
+
const tok = this.peek();
|
|
8227
|
+
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
8228
|
+
const op = tok.punct;
|
|
8229
|
+
this.pos += 1;
|
|
8230
|
+
const operand = this.parseUnary();
|
|
8231
|
+
this.countNode();
|
|
8232
|
+
return {
|
|
8233
|
+
kind: "unary",
|
|
8234
|
+
op,
|
|
8235
|
+
operand
|
|
8236
|
+
};
|
|
8237
|
+
}
|
|
8238
|
+
return this.parsePrimary();
|
|
8239
|
+
}
|
|
8240
|
+
parsePrimary() {
|
|
8241
|
+
const tok = this.next();
|
|
8242
|
+
switch (tok.type) {
|
|
8243
|
+
case "number":
|
|
8244
|
+
this.countNode();
|
|
8245
|
+
return {
|
|
8246
|
+
kind: "literal",
|
|
8247
|
+
value: tok.value
|
|
8248
|
+
};
|
|
8249
|
+
case "string":
|
|
8250
|
+
this.countNode();
|
|
8251
|
+
return {
|
|
8252
|
+
kind: "literal",
|
|
8253
|
+
value: tok.value
|
|
8254
|
+
};
|
|
8255
|
+
case "keyword":
|
|
8256
|
+
this.countNode();
|
|
8257
|
+
return {
|
|
8258
|
+
kind: "literal",
|
|
8259
|
+
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
8260
|
+
};
|
|
8261
|
+
case "identifier": {
|
|
8262
|
+
const nextTok = this.peek();
|
|
8263
|
+
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
8264
|
+
this.identifiers.add(tok.name);
|
|
8265
|
+
this.countNode();
|
|
8266
|
+
return {
|
|
8267
|
+
kind: "identifier",
|
|
8268
|
+
name: tok.name
|
|
8269
|
+
};
|
|
8270
|
+
}
|
|
8271
|
+
case "punct":
|
|
8272
|
+
if (tok.punct === "(") {
|
|
8273
|
+
const inner = this.parseTernary();
|
|
8274
|
+
this.expectPunct(")");
|
|
8275
|
+
return inner;
|
|
8276
|
+
}
|
|
8277
|
+
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
8278
|
+
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
8279
|
+
}
|
|
8280
|
+
}
|
|
8281
|
+
parseCall(callee, pos) {
|
|
8282
|
+
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
8283
|
+
this.expectPunct("(");
|
|
8284
|
+
const args = [];
|
|
8285
|
+
if (!this.matchPunct(")")) for (;;) {
|
|
8286
|
+
args.push(this.parseTernary());
|
|
8287
|
+
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
8288
|
+
if (this.matchPunct(",")) continue;
|
|
8289
|
+
this.expectPunct(")");
|
|
8290
|
+
break;
|
|
8291
|
+
}
|
|
8292
|
+
this.callees.add(callee);
|
|
8293
|
+
this.countNode();
|
|
8294
|
+
return {
|
|
8295
|
+
kind: "call",
|
|
8296
|
+
callee,
|
|
8297
|
+
args
|
|
8298
|
+
};
|
|
8299
|
+
}
|
|
8300
|
+
};
|
|
8301
|
+
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
8302
|
+
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
8303
|
+
function parseExpression(source) {
|
|
8304
|
+
return new Parser(tokenize(source)).parse();
|
|
8305
|
+
}
|
|
8306
|
+
Object.freeze({});
|
|
8307
|
+
/**
|
|
8308
|
+
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
8309
|
+
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
8310
|
+
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
8311
|
+
* one per read on a hot resolve path.
|
|
8312
|
+
*
|
|
8313
|
+
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
8314
|
+
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
8315
|
+
* callers is safe and maximises hit rate.
|
|
8316
|
+
*/
|
|
8317
|
+
var cache = /* @__PURE__ */ new Map();
|
|
8318
|
+
function getCached(source) {
|
|
8319
|
+
const hit = cache.get(source);
|
|
8320
|
+
if (hit !== void 0) {
|
|
8321
|
+
cache.delete(source);
|
|
8322
|
+
cache.set(source, hit);
|
|
8323
|
+
return hit;
|
|
8324
|
+
}
|
|
8325
|
+
let result;
|
|
8326
|
+
try {
|
|
8327
|
+
result = {
|
|
8328
|
+
ok: true,
|
|
8329
|
+
parsed: parseExpression(source)
|
|
8330
|
+
};
|
|
8331
|
+
} catch (err) {
|
|
8332
|
+
result = {
|
|
8333
|
+
ok: false,
|
|
8334
|
+
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
8335
|
+
};
|
|
8336
|
+
}
|
|
8337
|
+
cache.set(source, result);
|
|
8338
|
+
if (cache.size > 256) {
|
|
8339
|
+
const oldest = cache.keys().next().value;
|
|
8340
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
8341
|
+
}
|
|
8342
|
+
return result;
|
|
8343
|
+
}
|
|
8344
|
+
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
8345
|
+
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
8346
|
+
function compileExpressionSafe(source) {
|
|
8347
|
+
return getCached(source);
|
|
8348
|
+
}
|
|
8349
|
+
/**
|
|
8350
|
+
* Author-time validation. Returns `null` when the source is valid, else a
|
|
8351
|
+
* human-readable error message. Checks: the expression compiles; binding count
|
|
8352
|
+
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
8353
|
+
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
8354
|
+
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
8355
|
+
*/
|
|
8356
|
+
function validateExpressionSource(src) {
|
|
8357
|
+
const names = Object.keys(src.bindings);
|
|
8358
|
+
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
8359
|
+
for (const name of names) {
|
|
8360
|
+
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
8361
|
+
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
8362
|
+
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
8363
|
+
}
|
|
8364
|
+
const compiled = compileExpressionSafe(src.expr);
|
|
8365
|
+
if (!compiled.ok) return compiled.error;
|
|
8366
|
+
const bound = new Set(names);
|
|
8367
|
+
for (const id of compiled.parsed.identifiers) {
|
|
8368
|
+
if (id === "now") continue;
|
|
8369
|
+
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
8370
|
+
}
|
|
8371
|
+
return null;
|
|
8372
|
+
}
|
|
8373
|
+
/**
|
|
7595
8374
|
* Accessory device helpers — shared across drivers.
|
|
7596
8375
|
*
|
|
7597
8376
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -8475,7 +9254,13 @@ onStatusChanged: { data: object({
|
|
|
8475
9254
|
}) } },
|
|
8476
9255
|
status: {
|
|
8477
9256
|
schema: BatteryStatusSchema,
|
|
8478
|
-
kind: "push"
|
|
9257
|
+
kind: "push",
|
|
9258
|
+
empty: {
|
|
9259
|
+
percentage: 0,
|
|
9260
|
+
charging: "none",
|
|
9261
|
+
sleeping: false,
|
|
9262
|
+
lastUpdated: 0
|
|
9263
|
+
}
|
|
8479
9264
|
},
|
|
8480
9265
|
/**
|
|
8481
9266
|
* Runtime-state slice — every provider that registers this cap
|
|
@@ -8614,6 +9399,10 @@ var RtspRestreamEntrySchema = object({
|
|
|
8614
9399
|
var BrokerRtspClientSchema = object({
|
|
8615
9400
|
sessionId: string(),
|
|
8616
9401
|
remoteAddr: string(),
|
|
9402
|
+
/** Client `User-Agent` (e.g. `recorder` for the recorder's RTSP pull), or
|
|
9403
|
+
* null/absent when the client sent none. Lets the UI label a consumer by
|
|
9404
|
+
* purpose. Optional so a client built against an older schema stays valid. */
|
|
9405
|
+
userAgent: string().nullish(),
|
|
8617
9406
|
playing: boolean(),
|
|
8618
9407
|
muted: boolean(),
|
|
8619
9408
|
connectedAt: number(),
|
|
@@ -9414,21 +10203,38 @@ var connectivityCapability = {
|
|
|
9414
10203
|
},
|
|
9415
10204
|
runtimeState: ConnectivityStatusSchema
|
|
9416
10205
|
};
|
|
10206
|
+
/**
|
|
10207
|
+
* Generic device-consumables capability — surfaces a device's
|
|
10208
|
+
* maintenance items (vacuum filters/brushes, replaceable cartridges,
|
|
10209
|
+
* descaling cycles, …) with their remaining life and an optional
|
|
10210
|
+
* "Replaced" reset action. Device-agnostic: any provider that knows its
|
|
10211
|
+
* device tracks consumables can register it; the cap declares no
|
|
10212
|
+
* vocabulary of its own — the provider names each item verbatim.
|
|
10213
|
+
*
|
|
10214
|
+
* Like `childLayout`, the cap is INERT until a provider sets items: no
|
|
10215
|
+
* provider populates it by guessing (no HA inference). The UI renders a
|
|
10216
|
+
* "No consumables reported" placeholder when `items` is empty.
|
|
10217
|
+
*/
|
|
10218
|
+
/** A single consumable item. Either a continuous `level` (remaining
|
|
10219
|
+
* life %) or a discrete `status` may be known — both may be null when a
|
|
10220
|
+
* provider only knows the item exists. `level` and `status` are not
|
|
10221
|
+
* mutually exclusive; a provider may report both. */
|
|
10222
|
+
var ConsumableItemSchema = object({
|
|
10223
|
+
/** Stable id, e.g. 'main-brush'. */
|
|
10224
|
+
key: string().min(1),
|
|
10225
|
+
/** Display name. */
|
|
10226
|
+
label: string().min(1),
|
|
10227
|
+
/** Remaining life % when known (0..100). */
|
|
10228
|
+
level: number().min(0).max(100).nullable(),
|
|
10229
|
+
/** Discrete state when known (binary mode). */
|
|
10230
|
+
status: _enum(["ok", "replace"]).nullable(),
|
|
10231
|
+
/** Ms epoch of the last replace, when known. */
|
|
10232
|
+
lastResetAt: number().nullable(),
|
|
10233
|
+
/** Whether `reset()` is meaningful for this item. */
|
|
10234
|
+
resettable: boolean()
|
|
10235
|
+
});
|
|
9417
10236
|
var ConsumablesStatusSchema = object({
|
|
9418
|
-
items: array(
|
|
9419
|
-
/** Stable id, e.g. 'main-brush'. */
|
|
9420
|
-
key: string().min(1),
|
|
9421
|
-
/** Display name. */
|
|
9422
|
-
label: string().min(1),
|
|
9423
|
-
/** Remaining life % when known (0..100). */
|
|
9424
|
-
level: number().min(0).max(100).nullable(),
|
|
9425
|
-
/** Discrete state when known (binary mode). */
|
|
9426
|
-
status: _enum(["ok", "replace"]).nullable(),
|
|
9427
|
-
/** Ms epoch of the last replace, when known. */
|
|
9428
|
-
lastResetAt: number().nullable(),
|
|
9429
|
-
/** Whether `reset()` is meaningful for this item. */
|
|
9430
|
-
resettable: boolean()
|
|
9431
|
-
})),
|
|
10237
|
+
items: array(ConsumableItemSchema),
|
|
9432
10238
|
lastChangedAt: number()
|
|
9433
10239
|
});
|
|
9434
10240
|
var consumablesCapability = {
|
|
@@ -9487,7 +10293,25 @@ reset: method(object({
|
|
|
9487
10293
|
}) },
|
|
9488
10294
|
status: {
|
|
9489
10295
|
schema: ConsumablesStatusSchema,
|
|
9490
|
-
kind: "push"
|
|
10296
|
+
kind: "push",
|
|
10297
|
+
empty: {
|
|
10298
|
+
items: [],
|
|
10299
|
+
lastChangedAt: 0
|
|
10300
|
+
},
|
|
10301
|
+
itemArray: {
|
|
10302
|
+
path: "items",
|
|
10303
|
+
keyField: "key",
|
|
10304
|
+
labelField: "label",
|
|
10305
|
+
itemSchema: ConsumableItemSchema,
|
|
10306
|
+
emptyItem: {
|
|
10307
|
+
key: "",
|
|
10308
|
+
label: "",
|
|
10309
|
+
level: null,
|
|
10310
|
+
status: null,
|
|
10311
|
+
lastResetAt: null,
|
|
10312
|
+
resettable: false
|
|
10313
|
+
}
|
|
10314
|
+
}
|
|
9491
10315
|
},
|
|
9492
10316
|
runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() })
|
|
9493
10317
|
};
|
|
@@ -10729,7 +11553,8 @@ var MotionAnalysisResultSchema = object({
|
|
|
10729
11553
|
});
|
|
10730
11554
|
method(object({
|
|
10731
11555
|
deviceId: number(),
|
|
10732
|
-
frame: FrameInputSchema
|
|
11556
|
+
frame: FrameInputSchema.optional(),
|
|
11557
|
+
frameHandle: FrameHandleSchema.optional()
|
|
10733
11558
|
}), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
|
|
10734
11559
|
deviceId: number(),
|
|
10735
11560
|
detected: boolean(),
|
|
@@ -10976,6 +11801,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
10976
11801
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
10977
11802
|
steps: array(PipelineStepInputSchema).min(1),
|
|
10978
11803
|
frame: FrameInputSchema.optional(),
|
|
11804
|
+
/**
|
|
11805
|
+
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
11806
|
+
* the decoded pixels live in. One more member of the one-of
|
|
11807
|
+
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
11808
|
+
*/
|
|
11809
|
+
frameHandle: FrameHandleSchema.optional(),
|
|
10979
11810
|
imageBase64: string().optional(),
|
|
10980
11811
|
/**
|
|
10981
11812
|
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
@@ -11218,6 +12049,31 @@ var ReportMotionInputSchema = object({
|
|
|
11218
12049
|
regions: array(MotionRegionSchema).readonly().optional()
|
|
11219
12050
|
});
|
|
11220
12051
|
/**
|
|
12052
|
+
* Where a runner gets a camera's decoded frames (cross-node Phase 2,
|
|
12053
|
+
* restream-owner model — P2c).
|
|
12054
|
+
*
|
|
12055
|
+
* - `local-broker` (DEFAULT): today's path — subscribe to the co-located
|
|
12056
|
+
* stream-broker's shm frame plane. Every pre-P2c attach payload (no
|
|
12057
|
+
* `frameSource` key) parses to this, so the field is additive with zero
|
|
12058
|
+
* behavior change.
|
|
12059
|
+
* - `remote-restream`: the detect node is NOT the camera's source-owner.
|
|
12060
|
+
* The runner acquires the owner's COMPRESSED passthrough restream
|
|
12061
|
+
* (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
|
|
12062
|
+
* double-pull guard) and decodes LOCALLY via a satellite frame plane +
|
|
12063
|
+
* pull-mode decoder session pinned to its own node. The shm ring stays
|
|
12064
|
+
* node-local; only H.264/H.265 packets cross the wire.
|
|
12065
|
+
* `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
|
|
12066
|
+
* when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
|
|
12067
|
+
* dials for the owner's restream.
|
|
12068
|
+
*/
|
|
12069
|
+
var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
|
|
12070
|
+
kind: literal("remote-restream"),
|
|
12071
|
+
/** The camera's source-owner node (slice 1: always the hub). */
|
|
12072
|
+
ownerNodeId: string(),
|
|
12073
|
+
/** Operator override for the owner host the runner dials. */
|
|
12074
|
+
hubHostnameOverride: string().optional()
|
|
12075
|
+
})]).describe("Per-camera frame-source mode for the runner (P2c)");
|
|
12076
|
+
/**
|
|
11221
12077
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
11222
12078
|
* specific runner instance via `attachCamera`. Carries everything the
|
|
11223
12079
|
* runner needs to subscribe to the local broker and execute inference.
|
|
@@ -11315,7 +12171,15 @@ var RunnerCameraConfigSchema = object({
|
|
|
11315
12171
|
*/
|
|
11316
12172
|
onboardMotionDrivesAnalyzer: boolean().default(true),
|
|
11317
12173
|
occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
|
|
11318
|
-
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
|
|
12174
|
+
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
|
|
12175
|
+
/**
|
|
12176
|
+
* Where this runner gets the camera's decoded frames (P2c). Defaulted so
|
|
12177
|
+
* every existing payload behaves as `local-broker` — the pre-Phase-2 path.
|
|
12178
|
+
* Populated with `remote-restream` by the orchestrator ONLY when the
|
|
12179
|
+
* camera's detect node differs from its source-owner (P2d, gated by the
|
|
12180
|
+
* `remoteSourcingNodes` rollout setting).
|
|
12181
|
+
*/
|
|
12182
|
+
frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
|
|
11319
12183
|
});
|
|
11320
12184
|
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;
|
|
11321
12185
|
/**
|
|
@@ -11879,6 +12743,157 @@ var numericSensorCapability = {
|
|
|
11879
12743
|
runtimeState: NumericSensorStatusSchema
|
|
11880
12744
|
};
|
|
11881
12745
|
/**
|
|
12746
|
+
* Feeder connectivity / power status — mirrors the HA petkit device-status
|
|
12747
|
+
* enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
|
|
12748
|
+
* `on_batteries` (running on battery backup). `null` until first reported.
|
|
12749
|
+
*/
|
|
12750
|
+
var PetFeederDeviceStatusSchema = _enum([
|
|
12751
|
+
"normal",
|
|
12752
|
+
"offline",
|
|
12753
|
+
"on_batteries"
|
|
12754
|
+
]);
|
|
12755
|
+
var gramsPortion = number().int().min(4).max(200);
|
|
12756
|
+
var PetFeederStatusSchema = object({
|
|
12757
|
+
/** Food currently in the bowl (grams). Null when the device has not
|
|
12758
|
+
* reported a reading yet. On dual-hopper models this is the combined
|
|
12759
|
+
* bowl reading; per-hopper levels live in `food1`/`food2`. */
|
|
12760
|
+
foodLevel: number().nullable(),
|
|
12761
|
+
/** Hopper-1 food level (grams) on dual-hopper feeders; null on
|
|
12762
|
+
* single-hopper models. */
|
|
12763
|
+
food1: number().nullable(),
|
|
12764
|
+
/** Hopper-2 food level (grams) on dual-hopper feeders; null on
|
|
12765
|
+
* single-hopper models. */
|
|
12766
|
+
food2: number().nullable(),
|
|
12767
|
+
/** Derived low-food flag — mirrors the HA `food_level` binary_sensor
|
|
12768
|
+
* (`device_class: problem`, on = low). True when the bowl is empty /
|
|
12769
|
+
* below the feeder's low threshold. */
|
|
12770
|
+
lowFood: boolean(),
|
|
12771
|
+
/** Battery charge 0..100 (%). Null on mains-powered models or when the
|
|
12772
|
+
* device has no battery reading. */
|
|
12773
|
+
batteryPower: number().min(0).max(100).nullable(),
|
|
12774
|
+
/** Days of desiccant life remaining. Null when the model has no
|
|
12775
|
+
* desiccant sensor. */
|
|
12776
|
+
desiccantLeftDays: number().nullable(),
|
|
12777
|
+
/** True while a feed is in progress. */
|
|
12778
|
+
feeding: boolean(),
|
|
12779
|
+
/** Decoded connectivity / power status (HA petkit device-status enum).
|
|
12780
|
+
* Null until the device has reported a status. */
|
|
12781
|
+
status: PetFeederDeviceStatusSchema.nullable(),
|
|
12782
|
+
/** Decoded human-readable fault message. Null (or the device's `no_error`
|
|
12783
|
+
* sentinel) means healthy; a non-null string is an active fault. Pairs
|
|
12784
|
+
* with `errorCode` for consumers that want the raw integer. */
|
|
12785
|
+
error: string().nullable(),
|
|
12786
|
+
/** Raw device error code (0 / null = no error). */
|
|
12787
|
+
errorCode: number().nullable(),
|
|
12788
|
+
/** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
|
|
12789
|
+
isDualHopper: boolean(),
|
|
12790
|
+
/** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
|
|
12791
|
+
childLock: boolean(),
|
|
12792
|
+
/** Front indicator-light setting. */
|
|
12793
|
+
indicatorLight: boolean(),
|
|
12794
|
+
/** Play a chime when dispensing. */
|
|
12795
|
+
feedSound: boolean(),
|
|
12796
|
+
/** Speaker / prompt volume level (device-scaled integer). */
|
|
12797
|
+
volume: number(),
|
|
12798
|
+
/** Ms epoch when the slice was last refreshed from the cloud. */
|
|
12799
|
+
lastFetchedAt: number()
|
|
12800
|
+
});
|
|
12801
|
+
var petFeederCapability = {
|
|
12802
|
+
name: "pet-feeder",
|
|
12803
|
+
scope: "device",
|
|
12804
|
+
deviceNative: true,
|
|
12805
|
+
mode: "singleton",
|
|
12806
|
+
deviceTypes: [DeviceType.PetFeeder],
|
|
12807
|
+
methods: {
|
|
12808
|
+
/**
|
|
12809
|
+
* Dispense food now. Single-hopper feeders take `grams`; dual-hopper
|
|
12810
|
+
* feeders (D4S/D4SH) accept `hopper1`/`hopper2` to target one or both
|
|
12811
|
+
* hoppers. All portions honour the 4–200 g hardware range. At least
|
|
12812
|
+
* one of the three must be present — the provider rejects an empty
|
|
12813
|
+
* request.
|
|
12814
|
+
*/
|
|
12815
|
+
feed: method(object({
|
|
12816
|
+
deviceId: number().int().nonnegative(),
|
|
12817
|
+
grams: gramsPortion.optional(),
|
|
12818
|
+
hopper1: gramsPortion.optional(),
|
|
12819
|
+
hopper2: gramsPortion.optional()
|
|
12820
|
+
}), _void(), {
|
|
12821
|
+
kind: "mutation",
|
|
12822
|
+
auth: "admin"
|
|
12823
|
+
}),
|
|
12824
|
+
/** Cancel an in-progress manual feed. */
|
|
12825
|
+
cancelFeed: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12826
|
+
kind: "mutation",
|
|
12827
|
+
auth: "admin"
|
|
12828
|
+
}),
|
|
12829
|
+
/** Reset the desiccant "days remaining" counter after replacing it. */
|
|
12830
|
+
resetDesiccant: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12831
|
+
kind: "mutation",
|
|
12832
|
+
auth: "admin"
|
|
12833
|
+
}),
|
|
12834
|
+
/** Mark a hopper as refilled (D4H/D4S/D4SH). */
|
|
12835
|
+
markFoodReplenished: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12836
|
+
kind: "mutation",
|
|
12837
|
+
auth: "admin"
|
|
12838
|
+
}),
|
|
12839
|
+
/** Call the pet with the recorded prompt (D3). */
|
|
12840
|
+
callPet: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12841
|
+
kind: "mutation",
|
|
12842
|
+
auth: "admin"
|
|
12843
|
+
}),
|
|
12844
|
+
/** Play a stored sound by id (D3 / D4H / D4SH). */
|
|
12845
|
+
playSound: method(object({
|
|
12846
|
+
deviceId: number().int().nonnegative(),
|
|
12847
|
+
soundId: number().int().nonnegative()
|
|
12848
|
+
}), _void(), {
|
|
12849
|
+
kind: "mutation",
|
|
12850
|
+
auth: "admin"
|
|
12851
|
+
}),
|
|
12852
|
+
/** Toggle the child-lock (manual-lock) setting. */
|
|
12853
|
+
setChildLock: method(object({
|
|
12854
|
+
deviceId: number().int().nonnegative(),
|
|
12855
|
+
on: boolean()
|
|
12856
|
+
}), _void(), {
|
|
12857
|
+
kind: "mutation",
|
|
12858
|
+
auth: "admin"
|
|
12859
|
+
}),
|
|
12860
|
+
/** Toggle the front indicator light. */
|
|
12861
|
+
setIndicatorLight: method(object({
|
|
12862
|
+
deviceId: number().int().nonnegative(),
|
|
12863
|
+
on: boolean()
|
|
12864
|
+
}), _void(), {
|
|
12865
|
+
kind: "mutation",
|
|
12866
|
+
auth: "admin"
|
|
12867
|
+
}),
|
|
12868
|
+
/** Toggle the dispense chime. */
|
|
12869
|
+
setFeedSound: method(object({
|
|
12870
|
+
deviceId: number().int().nonnegative(),
|
|
12871
|
+
on: boolean()
|
|
12872
|
+
}), _void(), {
|
|
12873
|
+
kind: "mutation",
|
|
12874
|
+
auth: "admin"
|
|
12875
|
+
}),
|
|
12876
|
+
/** Set the speaker / prompt volume level. */
|
|
12877
|
+
setVolume: method(object({
|
|
12878
|
+
deviceId: number().int().nonnegative(),
|
|
12879
|
+
level: number().int().nonnegative()
|
|
12880
|
+
}), _void(), {
|
|
12881
|
+
kind: "mutation",
|
|
12882
|
+
auth: "admin"
|
|
12883
|
+
})
|
|
12884
|
+
},
|
|
12885
|
+
status: {
|
|
12886
|
+
schema: PetFeederStatusSchema,
|
|
12887
|
+
kind: "poll"
|
|
12888
|
+
},
|
|
12889
|
+
/**
|
|
12890
|
+
* Runtime-state slice — mirrored by the kernel. UI feeder cards read
|
|
12891
|
+
* the full slice via `device.state.petFeeder.value` and refresh on
|
|
12892
|
+
* every poll without re-querying the provider.
|
|
12893
|
+
*/
|
|
12894
|
+
runtimeState: PetFeederStatusSchema
|
|
12895
|
+
};
|
|
12896
|
+
/**
|
|
11882
12897
|
* Multi-metric electrical meter. One slice can carry any combination
|
|
11883
12898
|
* of instantaneous power (W), cumulative energy (kWh), voltage (V),
|
|
11884
12899
|
* and current (A) — all fields optional so a single-metric source
|
|
@@ -13181,6 +14196,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
|
|
|
13181
14196
|
nativeObjectDetection: nativeObjectDetectionCapability,
|
|
13182
14197
|
notifier: notifierCapability,
|
|
13183
14198
|
numericSensor: numericSensorCapability,
|
|
14199
|
+
petFeeder: petFeederCapability,
|
|
13184
14200
|
powerMeter: powerMeterCapability,
|
|
13185
14201
|
presence: presenceCapability,
|
|
13186
14202
|
pressureSensor: pressureSensorCapability,
|
|
@@ -15109,10 +16125,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
|
|
|
15109
16125
|
url: string()
|
|
15110
16126
|
}), _void()), method(object({
|
|
15111
16127
|
sessionId: string(),
|
|
15112
|
-
maxCount: number().default(1)
|
|
16128
|
+
maxCount: number().default(1),
|
|
16129
|
+
waitMs: number().optional()
|
|
15113
16130
|
}), array(DecodedFrameSchema)), method(object({
|
|
15114
16131
|
sessionId: string(),
|
|
15115
|
-
maxCount: number().default(1)
|
|
16132
|
+
maxCount: number().default(1),
|
|
16133
|
+
waitMs: number().optional()
|
|
15116
16134
|
}), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
|
|
15117
16135
|
sessionId: string(),
|
|
15118
16136
|
config: DecoderSessionConfigSchema.partial()
|
|
@@ -15399,14 +16417,63 @@ var ChildLayoutEntrySchema = object({
|
|
|
15399
16417
|
collapsed: boolean().optional()
|
|
15400
16418
|
});
|
|
15401
16419
|
/** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
|
|
15402
|
-
* `device-management.ts`.
|
|
16420
|
+
* `device-management.ts`. Source is a union: a FIELD source copies a sibling
|
|
16421
|
+
* accessory's status field (`kind` optional/absent for wire compat); a
|
|
16422
|
+
* LITERAL source carries a per-device constant (no sibling is read); a
|
|
16423
|
+
* GLOBAL source (P2e) copies ANY device's status field, addressed by the
|
|
16424
|
+
* source device's full re-sync-stable `stableId`. */
|
|
16425
|
+
var DeviceLinkFieldSourceSchema = object({
|
|
16426
|
+
kind: literal("field").optional(),
|
|
16427
|
+
sourceKey: string(),
|
|
16428
|
+
cap: string(),
|
|
16429
|
+
fieldPath: string()
|
|
16430
|
+
});
|
|
16431
|
+
var DeviceLinkLiteralSourceSchema = object({
|
|
16432
|
+
kind: literal("literal"),
|
|
16433
|
+
value: union([
|
|
16434
|
+
string(),
|
|
16435
|
+
number(),
|
|
16436
|
+
boolean(),
|
|
16437
|
+
_null()
|
|
16438
|
+
])
|
|
16439
|
+
});
|
|
16440
|
+
var DeviceLinkGlobalSourceSchema = object({
|
|
16441
|
+
kind: literal("global"),
|
|
16442
|
+
sourceStableId: string(),
|
|
16443
|
+
cap: string(),
|
|
16444
|
+
fieldPath: string()
|
|
16445
|
+
});
|
|
16446
|
+
/** Expression source (Stage X): compute the target field from N named bindings
|
|
16447
|
+
* via the safe expression engine. Bindings are field | literal | global — never
|
|
16448
|
+
* another expression (no nesting). The `superRefine` runs the SAME author-time
|
|
16449
|
+
* validation as `validateExpressionSource` (compiles the expr, checks binding
|
|
16450
|
+
* names + identifier coverage) so every wire boundary that parses a DeviceLink
|
|
16451
|
+
* (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
|
|
16452
|
+
* Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
|
|
16453
|
+
var DeviceLinkExpressionSourceSchema = object({
|
|
16454
|
+
kind: literal("expression"),
|
|
16455
|
+
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
16456
|
+
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
|
|
16457
|
+
DeviceLinkFieldSourceSchema,
|
|
16458
|
+
DeviceLinkLiteralSourceSchema,
|
|
16459
|
+
DeviceLinkGlobalSourceSchema
|
|
16460
|
+
]))
|
|
16461
|
+
}).superRefine((src, ctx) => {
|
|
16462
|
+
const err = validateExpressionSource(src);
|
|
16463
|
+
if (err !== null) ctx.addIssue({
|
|
16464
|
+
code: "custom",
|
|
16465
|
+
message: err,
|
|
16466
|
+
path: ["expr"]
|
|
16467
|
+
});
|
|
16468
|
+
});
|
|
15403
16469
|
var DeviceLinkSchema = object({
|
|
15404
16470
|
id: string(),
|
|
15405
|
-
source:
|
|
15406
|
-
|
|
15407
|
-
|
|
15408
|
-
|
|
15409
|
-
|
|
16471
|
+
source: union([
|
|
16472
|
+
DeviceLinkFieldSourceSchema,
|
|
16473
|
+
DeviceLinkLiteralSourceSchema,
|
|
16474
|
+
DeviceLinkGlobalSourceSchema,
|
|
16475
|
+
DeviceLinkExpressionSourceSchema
|
|
16476
|
+
]),
|
|
15410
16477
|
target: object({
|
|
15411
16478
|
cap: string(),
|
|
15412
16479
|
fieldPath: string(),
|
|
@@ -15435,6 +16502,31 @@ var DeviceLinkSchema = object({
|
|
|
15435
16502
|
})
|
|
15436
16503
|
]).optional()
|
|
15437
16504
|
});
|
|
16505
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
16506
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
16507
|
+
var DeviceCapDisplayOverrideSchema = object({
|
|
16508
|
+
unit: string().min(1).optional(),
|
|
16509
|
+
precision: number().int().min(0).max(10).optional()
|
|
16510
|
+
});
|
|
16511
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
16512
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
16513
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
16514
|
+
var DeviceDisplayOverrideSchema = object({
|
|
16515
|
+
icon: string().min(1).optional(),
|
|
16516
|
+
label: string().min(1).optional(),
|
|
16517
|
+
unit: string().min(1).optional(),
|
|
16518
|
+
precision: number().int().min(0).max(10).optional(),
|
|
16519
|
+
hidden: boolean().optional(),
|
|
16520
|
+
perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
|
|
16521
|
+
});
|
|
16522
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
16523
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
16524
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
16525
|
+
var RoleDisplayDefaultSchema = object({
|
|
16526
|
+
unit: string().min(1).optional(),
|
|
16527
|
+
precision: number().int().min(0).max(10).optional(),
|
|
16528
|
+
icon: string().min(1).optional()
|
|
16529
|
+
});
|
|
15438
16530
|
/**
|
|
15439
16531
|
* Serializable projection of a live IDevice.
|
|
15440
16532
|
* Returned by listAll, getDevice, getChildren.
|
|
@@ -15490,7 +16582,9 @@ var DeviceInfoSchema = object({
|
|
|
15490
16582
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
15491
16583
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
15492
16584
|
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
15493
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional()
|
|
16585
|
+
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
16586
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
16587
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
15494
16588
|
});
|
|
15495
16589
|
var ConfigEntrySchema = object({
|
|
15496
16590
|
key: string(),
|
|
@@ -15555,7 +16649,9 @@ var DeviceMetaSchema = object({
|
|
|
15555
16649
|
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
15556
16650
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
15557
16651
|
* Optional: only present for accessory children that carry a known role. */
|
|
15558
|
-
role: string().nullable().optional()
|
|
16652
|
+
role: string().nullable().optional(),
|
|
16653
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
16654
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
15559
16655
|
});
|
|
15560
16656
|
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
15561
16657
|
var ConfigUISchemaOutput = unknown().nullable();
|
|
@@ -15649,7 +16745,19 @@ method(object({
|
|
|
15649
16745
|
}), _void(), {
|
|
15650
16746
|
kind: "mutation",
|
|
15651
16747
|
auth: "admin"
|
|
15652
|
-
}), method(object({
|
|
16748
|
+
}), method(object({
|
|
16749
|
+
deviceId: number(),
|
|
16750
|
+
display: DeviceDisplayOverrideSchema.nullable()
|
|
16751
|
+
}), _void(), {
|
|
16752
|
+
kind: "mutation",
|
|
16753
|
+
auth: "admin"
|
|
16754
|
+
}), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
|
|
16755
|
+
kind: "mutation",
|
|
16756
|
+
auth: "admin"
|
|
16757
|
+
}), method(object({
|
|
16758
|
+
deviceId: number(),
|
|
16759
|
+
includeSynthesizable: boolean().optional()
|
|
16760
|
+
}), object({ caps: array(object({
|
|
15653
16761
|
cap: string(),
|
|
15654
16762
|
fields: array(object({
|
|
15655
16763
|
path: string(),
|
|
@@ -15659,8 +16767,13 @@ method(object({
|
|
|
15659
16767
|
"boolean",
|
|
15660
16768
|
"enum"
|
|
15661
16769
|
]),
|
|
15662
|
-
enumValues: array(string()).optional()
|
|
15663
|
-
|
|
16770
|
+
enumValues: array(string()).optional(),
|
|
16771
|
+
item: boolean().optional()
|
|
16772
|
+
})).readonly(),
|
|
16773
|
+
itemArray: object({
|
|
16774
|
+
path: string(),
|
|
16775
|
+
keyField: string()
|
|
16776
|
+
}).optional()
|
|
15664
16777
|
})).readonly() }), { kind: "query" }), method(object({
|
|
15665
16778
|
deviceId: number(),
|
|
15666
16779
|
role: string().nullable()
|
|
@@ -15730,7 +16843,11 @@ method(object({
|
|
|
15730
16843
|
deviceId: number(),
|
|
15731
16844
|
entries: array(object({
|
|
15732
16845
|
capName: string(),
|
|
15733
|
-
kind: _enum([
|
|
16846
|
+
kind: _enum([
|
|
16847
|
+
"native",
|
|
16848
|
+
"wrapped",
|
|
16849
|
+
"linked"
|
|
16850
|
+
]),
|
|
15734
16851
|
providerAddonId: string(),
|
|
15735
16852
|
providerNodeId: string(),
|
|
15736
16853
|
nativeAddonId: string()
|
|
@@ -15739,7 +16856,11 @@ method(object({
|
|
|
15739
16856
|
deviceId: number(),
|
|
15740
16857
|
entries: array(object({
|
|
15741
16858
|
capName: string(),
|
|
15742
|
-
kind: _enum([
|
|
16859
|
+
kind: _enum([
|
|
16860
|
+
"native",
|
|
16861
|
+
"wrapped",
|
|
16862
|
+
"linked"
|
|
16863
|
+
]),
|
|
15743
16864
|
providerAddonId: string(),
|
|
15744
16865
|
providerNodeId: string(),
|
|
15745
16866
|
nativeAddonId: string()
|
|
@@ -16229,7 +17350,7 @@ var AddBrokerInputSchema = object({
|
|
|
16229
17350
|
});
|
|
16230
17351
|
var AddBrokerResultSchema = object({ id: string() });
|
|
16231
17352
|
var IdInputSchema = object({ id: string() });
|
|
16232
|
-
var TestResultSchema = discriminatedUnion("ok", [object({
|
|
17353
|
+
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
16233
17354
|
ok: literal(true),
|
|
16234
17355
|
latencyMs: number()
|
|
16235
17356
|
}), object({
|
|
@@ -16252,7 +17373,7 @@ var StatusSchema = object({
|
|
|
16252
17373
|
brokerCount: number(),
|
|
16253
17374
|
embeddedRunning: boolean()
|
|
16254
17375
|
});
|
|
16255
|
-
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);
|
|
17376
|
+
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);
|
|
16256
17377
|
var NetworkEndpointSchema = object({
|
|
16257
17378
|
url: string(),
|
|
16258
17379
|
hostname: string(),
|
|
@@ -16286,23 +17407,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
|
16286
17407
|
sourcePort: number().optional()
|
|
16287
17408
|
});
|
|
16288
17409
|
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
16289
|
-
|
|
16290
|
-
|
|
17410
|
+
/**
|
|
17411
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
17412
|
+
*
|
|
17413
|
+
* Apprise-derived model (see
|
|
17414
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
17415
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
17416
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
17417
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
17418
|
+
* message to what the kind supports — callers never special-case a service.
|
|
17419
|
+
*
|
|
17420
|
+
* DESIGN DECISIONS (locked):
|
|
17421
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
17422
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
17423
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
17424
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
17425
|
+
* alternative would fork the UI per addon and cannot host the
|
|
17426
|
+
* discovery→adopt flow.
|
|
17427
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
17428
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
17429
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
17430
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
17431
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
17432
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
17433
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
17434
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
17435
|
+
* base64 fallback needed.
|
|
17436
|
+
*
|
|
17437
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
17438
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
17439
|
+
* admin "Integrations" page.
|
|
17440
|
+
*/
|
|
17441
|
+
/**
|
|
17442
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
17443
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
17444
|
+
*/
|
|
17445
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
17446
|
+
"image",
|
|
17447
|
+
"video",
|
|
17448
|
+
"gif",
|
|
17449
|
+
"audio",
|
|
17450
|
+
"icon"
|
|
17451
|
+
]);
|
|
17452
|
+
/**
|
|
17453
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
17454
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
17455
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
17456
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
17457
|
+
*/
|
|
17458
|
+
var AttachmentSchema = object({
|
|
17459
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
17460
|
+
url: string().optional(),
|
|
17461
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
17462
|
+
mime: string().optional(),
|
|
17463
|
+
name: string().optional()
|
|
17464
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
17465
|
+
var NotificationFormatSchema = _enum([
|
|
17466
|
+
"text",
|
|
17467
|
+
"markdown",
|
|
17468
|
+
"html"
|
|
17469
|
+
]);
|
|
17470
|
+
/** A single tap-through action button. */
|
|
17471
|
+
var NotificationActionSchema = object({
|
|
17472
|
+
id: string(),
|
|
17473
|
+
label: string(),
|
|
17474
|
+
url: string().optional()
|
|
17475
|
+
});
|
|
17476
|
+
/**
|
|
17477
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
17478
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
17479
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
17480
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
17481
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
17482
|
+
* `priority` for that one target.
|
|
17483
|
+
*/
|
|
17484
|
+
var NotificationSchema = object({
|
|
16291
17485
|
body: string(),
|
|
16292
|
-
|
|
17486
|
+
title: string().optional(),
|
|
17487
|
+
format: NotificationFormatSchema.default("text"),
|
|
17488
|
+
priority: number().int().min(1).max(5).default(3),
|
|
17489
|
+
level: string().optional(),
|
|
17490
|
+
attachments: array(AttachmentSchema).optional(),
|
|
17491
|
+
clickUrl: string().optional(),
|
|
17492
|
+
actions: array(NotificationActionSchema).optional(),
|
|
17493
|
+
sound: string().optional(),
|
|
17494
|
+
ttl: number().optional(),
|
|
17495
|
+
tag: string().optional(),
|
|
16293
17496
|
deviceId: number().optional(),
|
|
16294
17497
|
eventId: string().optional(),
|
|
16295
|
-
priority: _enum([
|
|
16296
|
-
"low",
|
|
16297
|
-
"normal",
|
|
16298
|
-
"high",
|
|
16299
|
-
"critical"
|
|
16300
|
-
]).default("normal"),
|
|
16301
17498
|
metadata: record(string(), unknown()).optional()
|
|
16302
|
-
})
|
|
17499
|
+
});
|
|
17500
|
+
/** One declared native severity/priority level for a kind. */
|
|
17501
|
+
var TargetKindLevelSchema = object({
|
|
17502
|
+
id: string(),
|
|
17503
|
+
label: string(),
|
|
17504
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
17505
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
17506
|
+
flags: object({
|
|
17507
|
+
critical: boolean().optional(),
|
|
17508
|
+
silent: boolean().optional(),
|
|
17509
|
+
noPush: boolean().optional()
|
|
17510
|
+
}).optional(),
|
|
17511
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
17512
|
+
requires: array(string()).optional(),
|
|
17513
|
+
description: string().optional()
|
|
17514
|
+
});
|
|
17515
|
+
/** The full capability block consulted before dispatch. */
|
|
17516
|
+
var TargetKindCapsSchema = object({
|
|
17517
|
+
attachments: object({
|
|
17518
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
17519
|
+
mode: _enum([
|
|
17520
|
+
"url",
|
|
17521
|
+
"bytes",
|
|
17522
|
+
"both"
|
|
17523
|
+
]),
|
|
17524
|
+
max: number().int().nonnegative(),
|
|
17525
|
+
maxBytes: number().int().positive().optional()
|
|
17526
|
+
}),
|
|
17527
|
+
/** Max action buttons (0 = none). */
|
|
17528
|
+
actions: number().int().nonnegative(),
|
|
17529
|
+
levels: array(TargetKindLevelSchema),
|
|
17530
|
+
format: array(NotificationFormatSchema),
|
|
17531
|
+
clickUrl: boolean(),
|
|
17532
|
+
sound: boolean(),
|
|
17533
|
+
ttl: boolean(),
|
|
17534
|
+
bodyMaxLen: number().int().positive()
|
|
17535
|
+
});
|
|
17536
|
+
/**
|
|
17537
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
17538
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
17539
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
17540
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
17541
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
17542
|
+
*/
|
|
17543
|
+
var ConfigSchemaPassthrough = unknown();
|
|
17544
|
+
var TargetKindSchema = object({
|
|
17545
|
+
kind: string(),
|
|
17546
|
+
label: string(),
|
|
17547
|
+
icon: string(),
|
|
17548
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
17549
|
+
addonId: string(),
|
|
17550
|
+
configSchema: ConfigSchemaPassthrough,
|
|
17551
|
+
supportsDiscovery: boolean(),
|
|
17552
|
+
caps: TargetKindCapsSchema
|
|
17553
|
+
});
|
|
17554
|
+
/**
|
|
17555
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
17556
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
17557
|
+
* round-trip a stored secret to the UI.
|
|
17558
|
+
*/
|
|
17559
|
+
var TargetSchema = object({
|
|
17560
|
+
id: string(),
|
|
17561
|
+
name: string(),
|
|
17562
|
+
kind: string(),
|
|
17563
|
+
addonId: string(),
|
|
17564
|
+
enabled: boolean(),
|
|
17565
|
+
config: record(string(), unknown())
|
|
17566
|
+
});
|
|
17567
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
17568
|
+
var DiscoveredTargetSchema = object({
|
|
17569
|
+
kind: string(),
|
|
17570
|
+
suggestedName: string(),
|
|
17571
|
+
config: record(string(), unknown())
|
|
17572
|
+
});
|
|
17573
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
17574
|
+
var RenderedAsSchema = object({
|
|
17575
|
+
level: string(),
|
|
17576
|
+
format: NotificationFormatSchema,
|
|
17577
|
+
attachmentsSent: number().int().nonnegative(),
|
|
17578
|
+
actionsSent: number().int().nonnegative(),
|
|
17579
|
+
truncated: boolean(),
|
|
17580
|
+
dropped: array(string())
|
|
17581
|
+
});
|
|
17582
|
+
var SendResultSchema = object({
|
|
16303
17583
|
success: boolean(),
|
|
16304
|
-
error: string().optional()
|
|
16305
|
-
|
|
17584
|
+
error: string().optional(),
|
|
17585
|
+
renderedAs: RenderedAsSchema.optional()
|
|
17586
|
+
});
|
|
17587
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
17588
|
+
var TestResultSchema = SendResultSchema;
|
|
17589
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
|
|
17590
|
+
kind: string(),
|
|
17591
|
+
config: record(string(), unknown()).optional()
|
|
17592
|
+
}), array(DiscoveredTargetSchema)), method(object({
|
|
17593
|
+
targetId: string(),
|
|
17594
|
+
notification: NotificationSchema
|
|
17595
|
+
}), SendResultSchema, { kind: "mutation" }), method(object({
|
|
17596
|
+
targetId: string(),
|
|
17597
|
+
sample: NotificationSchema.optional()
|
|
17598
|
+
}), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
|
|
17599
|
+
targetId: string(),
|
|
17600
|
+
enabled: boolean()
|
|
17601
|
+
}), _void(), { kind: "mutation" });
|
|
16306
17602
|
/**
|
|
16307
17603
|
* Zod schemas for persisted record types.
|
|
16308
17604
|
*
|
|
@@ -19464,7 +20760,10 @@ var HwAccelBackendInputSchema = _enum([
|
|
|
19464
20760
|
"webgpu",
|
|
19465
20761
|
"none"
|
|
19466
20762
|
]).nullable().optional();
|
|
19467
|
-
var HwAccelResolutionSchema = object({
|
|
20763
|
+
var HwAccelResolutionSchema = object({
|
|
20764
|
+
preferred: array(string()).readonly(),
|
|
20765
|
+
rationale: string()
|
|
20766
|
+
});
|
|
19468
20767
|
var HardwareEncoderIdSchema = _enum([
|
|
19469
20768
|
"h264_videotoolbox",
|
|
19470
20769
|
"hevc_videotoolbox",
|
|
@@ -19569,10 +20868,7 @@ var ResolvedInferenceConfigSchema = object({
|
|
|
19569
20868
|
format: ModelFormatSchema,
|
|
19570
20869
|
reason: string()
|
|
19571
20870
|
});
|
|
19572
|
-
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
|
|
19573
|
-
prefer: HwAccelBackendInputSchema,
|
|
19574
|
-
nodeId: string().optional()
|
|
19575
|
-
}), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
20871
|
+
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
19576
20872
|
kind: "mutation",
|
|
19577
20873
|
auth: "admin"
|
|
19578
20874
|
}), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
|
|
@@ -19698,6 +20994,16 @@ var rebootCapability = {
|
|
|
19698
20994
|
auth: "admin"
|
|
19699
20995
|
}) }
|
|
19700
20996
|
};
|
|
20997
|
+
/**
|
|
20998
|
+
* `recording` cap — footage availability + HLS playback manifests + per-device
|
|
20999
|
+
* recording config. NOTE on events (source of truth, R5/C3): this cap carries
|
|
21000
|
+
* NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
|
|
21001
|
+
* events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
|
|
21002
|
+
* rows); the recorder's internal EventMap markers are ephemeral in-RAM
|
|
21003
|
+
* annotations that are not exposed here and must not be treated as an event
|
|
21004
|
+
* feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
|
|
21005
|
+
* (`interfaces/recording-config.ts`).
|
|
21006
|
+
*/
|
|
19701
21007
|
var RecordingStatusSchema = object({
|
|
19702
21008
|
deviceId: number(),
|
|
19703
21009
|
enabled: boolean(),
|
|
@@ -21545,6 +22851,12 @@ Object.freeze({
|
|
|
21545
22851
|
addonId: null,
|
|
21546
22852
|
access: "view"
|
|
21547
22853
|
},
|
|
22854
|
+
"deviceManager.getRoleDisplayDefaults": {
|
|
22855
|
+
capName: "device-manager",
|
|
22856
|
+
capScope: "system",
|
|
22857
|
+
addonId: null,
|
|
22858
|
+
access: "view"
|
|
22859
|
+
},
|
|
21548
22860
|
"deviceManager.getSettingsSchema": {
|
|
21549
22861
|
capName: "device-manager",
|
|
21550
22862
|
capScope: "system",
|
|
@@ -21695,6 +23007,12 @@ Object.freeze({
|
|
|
21695
23007
|
addonId: null,
|
|
21696
23008
|
access: "create"
|
|
21697
23009
|
},
|
|
23010
|
+
"deviceManager.setDisplay": {
|
|
23011
|
+
capName: "device-manager",
|
|
23012
|
+
capScope: "system",
|
|
23013
|
+
addonId: null,
|
|
23014
|
+
access: "create"
|
|
23015
|
+
},
|
|
21698
23016
|
"deviceManager.setIntegrationId": {
|
|
21699
23017
|
capName: "device-manager",
|
|
21700
23018
|
capScope: "system",
|
|
@@ -21737,6 +23055,12 @@ Object.freeze({
|
|
|
21737
23055
|
addonId: null,
|
|
21738
23056
|
access: "create"
|
|
21739
23057
|
},
|
|
23058
|
+
"deviceManager.setRoleDisplayDefaults": {
|
|
23059
|
+
capName: "device-manager",
|
|
23060
|
+
capScope: "system",
|
|
23061
|
+
addonId: null,
|
|
23062
|
+
access: "create"
|
|
23063
|
+
},
|
|
21740
23064
|
"deviceManager.setStreamProfileMap": {
|
|
21741
23065
|
capName: "device-manager",
|
|
21742
23066
|
capScope: "system",
|
|
@@ -22715,13 +24039,49 @@ Object.freeze({
|
|
|
22715
24039
|
addonId: null,
|
|
22716
24040
|
access: "create"
|
|
22717
24041
|
},
|
|
24042
|
+
"notificationOutput.deleteTarget": {
|
|
24043
|
+
capName: "notification-output",
|
|
24044
|
+
capScope: "system",
|
|
24045
|
+
addonId: null,
|
|
24046
|
+
access: "delete"
|
|
24047
|
+
},
|
|
24048
|
+
"notificationOutput.discoverTargets": {
|
|
24049
|
+
capName: "notification-output",
|
|
24050
|
+
capScope: "system",
|
|
24051
|
+
addonId: null,
|
|
24052
|
+
access: "view"
|
|
24053
|
+
},
|
|
24054
|
+
"notificationOutput.listTargetKinds": {
|
|
24055
|
+
capName: "notification-output",
|
|
24056
|
+
capScope: "system",
|
|
24057
|
+
addonId: null,
|
|
24058
|
+
access: "view"
|
|
24059
|
+
},
|
|
24060
|
+
"notificationOutput.listTargets": {
|
|
24061
|
+
capName: "notification-output",
|
|
24062
|
+
capScope: "system",
|
|
24063
|
+
addonId: null,
|
|
24064
|
+
access: "view"
|
|
24065
|
+
},
|
|
22718
24066
|
"notificationOutput.send": {
|
|
22719
24067
|
capName: "notification-output",
|
|
22720
24068
|
capScope: "system",
|
|
22721
24069
|
addonId: null,
|
|
22722
24070
|
access: "create"
|
|
22723
24071
|
},
|
|
22724
|
-
"notificationOutput.
|
|
24072
|
+
"notificationOutput.setTargetEnabled": {
|
|
24073
|
+
capName: "notification-output",
|
|
24074
|
+
capScope: "system",
|
|
24075
|
+
addonId: null,
|
|
24076
|
+
access: "create"
|
|
24077
|
+
},
|
|
24078
|
+
"notificationOutput.testTarget": {
|
|
24079
|
+
capName: "notification-output",
|
|
24080
|
+
capScope: "system",
|
|
24081
|
+
addonId: null,
|
|
24082
|
+
access: "create"
|
|
24083
|
+
},
|
|
24084
|
+
"notificationOutput.upsertTarget": {
|
|
22725
24085
|
capName: "notification-output",
|
|
22726
24086
|
capScope: "system",
|
|
22727
24087
|
addonId: null,
|
|
@@ -22751,6 +24111,66 @@ Object.freeze({
|
|
|
22751
24111
|
addonId: null,
|
|
22752
24112
|
access: "create"
|
|
22753
24113
|
},
|
|
24114
|
+
"petFeeder.callPet": {
|
|
24115
|
+
capName: "pet-feeder",
|
|
24116
|
+
capScope: "device",
|
|
24117
|
+
addonId: null,
|
|
24118
|
+
access: "create"
|
|
24119
|
+
},
|
|
24120
|
+
"petFeeder.cancelFeed": {
|
|
24121
|
+
capName: "pet-feeder",
|
|
24122
|
+
capScope: "device",
|
|
24123
|
+
addonId: null,
|
|
24124
|
+
access: "create"
|
|
24125
|
+
},
|
|
24126
|
+
"petFeeder.feed": {
|
|
24127
|
+
capName: "pet-feeder",
|
|
24128
|
+
capScope: "device",
|
|
24129
|
+
addonId: null,
|
|
24130
|
+
access: "create"
|
|
24131
|
+
},
|
|
24132
|
+
"petFeeder.markFoodReplenished": {
|
|
24133
|
+
capName: "pet-feeder",
|
|
24134
|
+
capScope: "device",
|
|
24135
|
+
addonId: null,
|
|
24136
|
+
access: "create"
|
|
24137
|
+
},
|
|
24138
|
+
"petFeeder.playSound": {
|
|
24139
|
+
capName: "pet-feeder",
|
|
24140
|
+
capScope: "device",
|
|
24141
|
+
addonId: null,
|
|
24142
|
+
access: "create"
|
|
24143
|
+
},
|
|
24144
|
+
"petFeeder.resetDesiccant": {
|
|
24145
|
+
capName: "pet-feeder",
|
|
24146
|
+
capScope: "device",
|
|
24147
|
+
addonId: null,
|
|
24148
|
+
access: "delete"
|
|
24149
|
+
},
|
|
24150
|
+
"petFeeder.setChildLock": {
|
|
24151
|
+
capName: "pet-feeder",
|
|
24152
|
+
capScope: "device",
|
|
24153
|
+
addonId: null,
|
|
24154
|
+
access: "create"
|
|
24155
|
+
},
|
|
24156
|
+
"petFeeder.setFeedSound": {
|
|
24157
|
+
capName: "pet-feeder",
|
|
24158
|
+
capScope: "device",
|
|
24159
|
+
addonId: null,
|
|
24160
|
+
access: "create"
|
|
24161
|
+
},
|
|
24162
|
+
"petFeeder.setIndicatorLight": {
|
|
24163
|
+
capName: "pet-feeder",
|
|
24164
|
+
capScope: "device",
|
|
24165
|
+
addonId: null,
|
|
24166
|
+
access: "create"
|
|
24167
|
+
},
|
|
24168
|
+
"petFeeder.setVolume": {
|
|
24169
|
+
capName: "pet-feeder",
|
|
24170
|
+
capScope: "device",
|
|
24171
|
+
addonId: null,
|
|
24172
|
+
access: "create"
|
|
24173
|
+
},
|
|
22754
24174
|
"pipelineAnalytics.clearTracks": {
|
|
22755
24175
|
capName: "pipeline-analytics",
|
|
22756
24176
|
capScope: "device",
|
|
@@ -28980,7 +30400,7 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
|
|
|
28980
30400
|
*/
|
|
28981
30401
|
resolveAudioCodecApi() {
|
|
28982
30402
|
const router = this.ctx.api.audioCodec;
|
|
28983
|
-
if (!router) throw new Error("Hikvision intercom: `audio-codec` capability is not mounted. Install + enable the `addon-audio-codec-
|
|
30403
|
+
if (!router) throw new Error("Hikvision intercom: `audio-codec` capability is not mounted. Install + enable the `addon-audio-codec-ffmpeg` addon (or any other addon that provides the `audio-codec` capability) before opening a talk session.");
|
|
28984
30404
|
return {
|
|
28985
30405
|
createDecodeSession: (input) => router.createDecodeSession.mutate(input),
|
|
28986
30406
|
pushEncodedFrame: (input) => router.pushEncodedFrame.mutate(input),
|