@camstack/addon-provider-rtsp 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 +1482 -62
- package/dist/addon.mjs +1482 -62
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -4642,7 +4642,7 @@ function preprocess(fn, schema) {
|
|
|
4642
4642
|
});
|
|
4643
4643
|
}
|
|
4644
4644
|
//#endregion
|
|
4645
|
-
//#region ../types/dist/sleep-
|
|
4645
|
+
//#region ../types/dist/sleep-BiDFW0E7.mjs
|
|
4646
4646
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4647
4647
|
EventCategory["SystemBoot"] = "system.boot";
|
|
4648
4648
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -5455,6 +5455,100 @@ function createDurableState(deps) {
|
|
|
5455
5455
|
};
|
|
5456
5456
|
}
|
|
5457
5457
|
/**
|
|
5458
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
5459
|
+
*
|
|
5460
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
5461
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
5462
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
5463
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
5464
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
5465
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
5466
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
5467
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
5468
|
+
*
|
|
5469
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
5470
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
5471
|
+
* schema and routes reads/writes through these helpers.
|
|
5472
|
+
*
|
|
5473
|
+
* ## No bare-key fallback — deliberate
|
|
5474
|
+
*
|
|
5475
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
5476
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
5477
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
5478
|
+
* the store is invisible to every node, hub included, so one node's
|
|
5479
|
+
* selection can never leak onto another. (This generalizes the
|
|
5480
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
5481
|
+
* arbitrary set of per-node field keys.)
|
|
5482
|
+
*
|
|
5483
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
5484
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
5485
|
+
*/
|
|
5486
|
+
/**
|
|
5487
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
5488
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
5489
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
5490
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
5491
|
+
*/
|
|
5492
|
+
function normalizeNodeId(raw) {
|
|
5493
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
5494
|
+
const slashIdx = raw.indexOf("/");
|
|
5495
|
+
if (slashIdx < 0) return raw;
|
|
5496
|
+
const bare = raw.slice(0, slashIdx);
|
|
5497
|
+
return bare === "" ? "hub" : bare;
|
|
5498
|
+
}
|
|
5499
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
5500
|
+
function nodeScopedKey(base, nodeId) {
|
|
5501
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
5502
|
+
}
|
|
5503
|
+
/**
|
|
5504
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
5505
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
5506
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
5507
|
+
* schema `default` win on `undefined`.
|
|
5508
|
+
*/
|
|
5509
|
+
function readNodeValue(store, base, nodeId) {
|
|
5510
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
5511
|
+
}
|
|
5512
|
+
/**
|
|
5513
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
5514
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
5515
|
+
* the write path so a save for one node never clobbers another node's value
|
|
5516
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
5517
|
+
* patch is not mutated.
|
|
5518
|
+
*/
|
|
5519
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
5520
|
+
const out = {};
|
|
5521
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
5522
|
+
return out;
|
|
5523
|
+
}
|
|
5524
|
+
/**
|
|
5525
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
5526
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
5527
|
+
* values:
|
|
5528
|
+
*
|
|
5529
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
5530
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
5531
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
5532
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
5533
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
5534
|
+
* left ABSENT so the field's schema `default` wins.
|
|
5535
|
+
*
|
|
5536
|
+
* Returns a new object — the input store is not mutated.
|
|
5537
|
+
*/
|
|
5538
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
5539
|
+
const out = {};
|
|
5540
|
+
for (const [key, value] of Object.entries(store)) {
|
|
5541
|
+
if (key.includes("@")) continue;
|
|
5542
|
+
if (perNodeKeys.has(key)) continue;
|
|
5543
|
+
out[key] = value;
|
|
5544
|
+
}
|
|
5545
|
+
for (const base of perNodeKeys) {
|
|
5546
|
+
const value = readNodeValue(store, base, nodeId);
|
|
5547
|
+
if (value !== void 0) out[base] = value;
|
|
5548
|
+
}
|
|
5549
|
+
return out;
|
|
5550
|
+
}
|
|
5551
|
+
/**
|
|
5458
5552
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5459
5553
|
*
|
|
5460
5554
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -5622,23 +5716,63 @@ var BaseAddon = class {
|
|
|
5622
5716
|
deviceSettingsSchema() {
|
|
5623
5717
|
return null;
|
|
5624
5718
|
}
|
|
5625
|
-
async getGlobalSettings(overlay, cap,
|
|
5719
|
+
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5626
5720
|
const schema = this.globalSettingsSchema(cap);
|
|
5627
5721
|
if (!schema) return { sections: [] };
|
|
5628
|
-
const
|
|
5722
|
+
const projected = await this.resolveGlobalStore(nodeId, cap);
|
|
5629
5723
|
return hydrateSchema(schema, overlay ? {
|
|
5630
|
-
...
|
|
5724
|
+
...projected,
|
|
5631
5725
|
...overlay
|
|
5632
|
-
} :
|
|
5726
|
+
} : projected);
|
|
5727
|
+
}
|
|
5728
|
+
/**
|
|
5729
|
+
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5730
|
+
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5731
|
+
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
5732
|
+
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
5733
|
+
* A no-op passthrough when the schema declares no `perNode` field.
|
|
5734
|
+
*
|
|
5735
|
+
* This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
|
|
5736
|
+
* the store for custom option logic (option narrowing, value snapping) to
|
|
5737
|
+
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
5738
|
+
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
5739
|
+
*/
|
|
5740
|
+
async resolveGlobalStore(nodeId, cap) {
|
|
5741
|
+
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
5742
|
+
const keys = this.perNodeKeys(cap);
|
|
5743
|
+
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5744
|
+
return keys.size > 0 ? projectStore(raw, keys, node) : raw;
|
|
5633
5745
|
}
|
|
5634
|
-
async updateGlobalSettings(patch,
|
|
5635
|
-
|
|
5746
|
+
async updateGlobalSettings(patch, nodeId) {
|
|
5747
|
+
const keys = this.perNodeKeys();
|
|
5748
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5749
|
+
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5750
|
+
const barePatch = patch;
|
|
5751
|
+
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
5752
|
+
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
5753
|
+
if (target !== localNode) return;
|
|
5636
5754
|
await this.resolveConfig();
|
|
5637
5755
|
await this.onConfigChanged();
|
|
5638
5756
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
5639
5757
|
this.maybeAutoRestart(patch, this.globalSettingsSchema());
|
|
5640
5758
|
}
|
|
5641
5759
|
/**
|
|
5760
|
+
* The set of field keys the global settings schema declares `perNode: true`
|
|
5761
|
+
* — derived once per `cap` argument and memoized (schemas are static
|
|
5762
|
+
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
5763
|
+
* settings API behaves exactly like the legacy node-agnostic one.
|
|
5764
|
+
*/
|
|
5765
|
+
_perNodeKeysCache = /* @__PURE__ */ new Map();
|
|
5766
|
+
perNodeKeys(cap) {
|
|
5767
|
+
const cacheKey = cap ?? "";
|
|
5768
|
+
const cached = this._perNodeKeysCache.get(cacheKey);
|
|
5769
|
+
if (cached) return cached;
|
|
5770
|
+
const schema = this.globalSettingsSchema(cap);
|
|
5771
|
+
const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
5772
|
+
this._perNodeKeysCache.set(cacheKey, keys);
|
|
5773
|
+
return keys;
|
|
5774
|
+
}
|
|
5775
|
+
/**
|
|
5642
5776
|
* If any field in `patch` is marked `requiresRestart` in `schema`,
|
|
5643
5777
|
* schedule an addon restart for the next tick. Deferred via
|
|
5644
5778
|
* `setImmediate` so the tRPC mutation that triggered the write has
|
|
@@ -5791,12 +5925,19 @@ var BaseAddon = class {
|
|
|
5791
5925
|
* The merge is shallow: each key in `defaults` is checked against the store.
|
|
5792
5926
|
* Only keys present in defaults are read — the store can contain extra keys
|
|
5793
5927
|
* (e.g. from older versions) without polluting the typed config.
|
|
5928
|
+
*
|
|
5929
|
+
* Keys the global settings schema declares `perNode: true` resolve from
|
|
5930
|
+
* THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
|
|
5931
|
+
* from the bare key — so a per-node field resolves to this node's own
|
|
5932
|
+
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
5794
5933
|
*/
|
|
5795
5934
|
async resolveConfig() {
|
|
5796
5935
|
const stored = await this.readAddonStoreWithRetry();
|
|
5936
|
+
const perNode = this.perNodeKeys();
|
|
5937
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5797
5938
|
const resolved = { ...this.defaults };
|
|
5798
5939
|
for (const key of Object.keys(this.defaults)) {
|
|
5799
|
-
const storedValue = stored[key];
|
|
5940
|
+
const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
|
|
5800
5941
|
if (storedValue !== void 0 && storedValue !== null) {
|
|
5801
5942
|
const defaultType = typeof this.defaults[key];
|
|
5802
5943
|
if (typeof storedValue === defaultType) resolved[key] = storedValue;
|
|
@@ -5880,6 +6021,27 @@ var BaseAddon = class {
|
|
|
5880
6021
|
}
|
|
5881
6022
|
};
|
|
5882
6023
|
/**
|
|
6024
|
+
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
6025
|
+
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
6026
|
+
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6027
|
+
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6028
|
+
*/
|
|
6029
|
+
function collectPerNodeFieldKeys(fields) {
|
|
6030
|
+
const collected = [];
|
|
6031
|
+
for (const field of fields) {
|
|
6032
|
+
if (field.type === "group") {
|
|
6033
|
+
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
6034
|
+
continue;
|
|
6035
|
+
}
|
|
6036
|
+
if (field.type === "sub-tabs") {
|
|
6037
|
+
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
6038
|
+
continue;
|
|
6039
|
+
}
|
|
6040
|
+
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
6041
|
+
}
|
|
6042
|
+
return collected;
|
|
6043
|
+
}
|
|
6044
|
+
/**
|
|
5883
6045
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
5884
6046
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
5885
6047
|
* envelopes pass through; void stays void.
|
|
@@ -5904,6 +6066,7 @@ var CamStreamKindSchema = _enum([
|
|
|
5904
6066
|
"pull-rtsp",
|
|
5905
6067
|
"pull-rtmp",
|
|
5906
6068
|
"pull-http",
|
|
6069
|
+
"pull-flv",
|
|
5907
6070
|
"pull-rfc4571",
|
|
5908
6071
|
"push-annexb",
|
|
5909
6072
|
"derived"
|
|
@@ -6286,6 +6449,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
6286
6449
|
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
6287
6450
|
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
6288
6451
|
DeviceType["Image"] = "image";
|
|
6452
|
+
/** Smart pet feeder — cloud-connected food dispenser with a bowl food
|
|
6453
|
+
* level, battery, desiccant life, feeding state and manual-feed /
|
|
6454
|
+
* call-pet / maintenance actions. Installed with the `pet-feeder` cap;
|
|
6455
|
+
* dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
|
|
6456
|
+
* native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
|
|
6457
|
+
* integrations sharing the same food/desiccant/hopper surface. */
|
|
6458
|
+
DeviceType["PetFeeder"] = "pet-feeder";
|
|
6289
6459
|
return DeviceType;
|
|
6290
6460
|
}({});
|
|
6291
6461
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -7051,7 +7221,21 @@ var StorageLocationDeclarationSchema = object({
|
|
|
7051
7221
|
* slots (e.g. `recordingsLow` → `recordings`) so operators only need to
|
|
7052
7222
|
* configure the primary location.
|
|
7053
7223
|
*/
|
|
7054
|
-
defaultsTo: string().optional()
|
|
7224
|
+
defaultsTo: string().optional(),
|
|
7225
|
+
/**
|
|
7226
|
+
* Which node root the seeded `<id>:default` instance is placed under on a
|
|
7227
|
+
* FRESH install:
|
|
7228
|
+
* - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
|
|
7229
|
+
* the appData volume. Right for small/durable data (backups, logs, models).
|
|
7230
|
+
* - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
|
|
7231
|
+
* env is set, else falls back to the data root. Right for bulky, hot media
|
|
7232
|
+
* (recordings, event media) that should stay off the appData disk.
|
|
7233
|
+
*
|
|
7234
|
+
* Only affects the seeded default's `basePath`; operators can repoint any
|
|
7235
|
+
* location afterwards, and a `defaultsTo` slot inherits its parent's root
|
|
7236
|
+
* regardless of this field. Absent (the common case) is treated as `'data'`.
|
|
7237
|
+
*/
|
|
7238
|
+
defaultRoot: _enum(["data", "media"]).optional()
|
|
7055
7239
|
});
|
|
7056
7240
|
/**
|
|
7057
7241
|
* Compute pixel count for sorting. Returns w*h, or 0 if unknown.
|
|
@@ -7456,6 +7640,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
|
|
|
7456
7640
|
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7457
7641
|
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7458
7642
|
/**
|
|
7643
|
+
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7644
|
+
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
7645
|
+
* failure — both are non-fatal to the host: read paths degrade to "skip link".
|
|
7646
|
+
*/
|
|
7647
|
+
/** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
|
|
7648
|
+
* the failure is anchored to a character (author-facing inline feedback). */
|
|
7649
|
+
var ExpressionParseError = class extends Error {
|
|
7650
|
+
position;
|
|
7651
|
+
constructor(message, position) {
|
|
7652
|
+
super(message);
|
|
7653
|
+
this.name = "ExpressionParseError";
|
|
7654
|
+
this.position = position;
|
|
7655
|
+
}
|
|
7656
|
+
};
|
|
7657
|
+
/** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
|
|
7658
|
+
* result, unknown builtin, step-budget exceeded). */
|
|
7659
|
+
var ExpressionEvalError = class extends Error {
|
|
7660
|
+
constructor(message) {
|
|
7661
|
+
super(message);
|
|
7662
|
+
this.name = "ExpressionEvalError";
|
|
7663
|
+
}
|
|
7664
|
+
};
|
|
7665
|
+
/**
|
|
7666
|
+
* Resource-bound constants for the safe expression engine.
|
|
7667
|
+
*
|
|
7668
|
+
* Every bound is defense-in-depth: the grammar is non-Turing-complete (no
|
|
7669
|
+
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
7670
|
+
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
7671
|
+
* work a single author-supplied expression can request, so a hostile or
|
|
7672
|
+
* accidental pathological string can never spend unbounded CPU/memory.
|
|
7673
|
+
*/
|
|
7674
|
+
/** Max source length (chars) — checked BEFORE tokenizing so a huge string is
|
|
7675
|
+
* rejected without allocation. */
|
|
7676
|
+
var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
|
|
7677
|
+
/** A legal binding / identifier name. */
|
|
7678
|
+
var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7679
|
+
/** Binding names an author may NOT use: `now` is auto-injected; the literal
|
|
7680
|
+
* keywords lex as values, not identifiers, so binding to them is meaningless. */
|
|
7681
|
+
var RESERVED_BINDING_NAMES = new Set([
|
|
7682
|
+
"now",
|
|
7683
|
+
"true",
|
|
7684
|
+
"false",
|
|
7685
|
+
"null"
|
|
7686
|
+
]);
|
|
7687
|
+
/**
|
|
7688
|
+
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
7689
|
+
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
7690
|
+
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
7691
|
+
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
7692
|
+
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
7693
|
+
* is a parse error with a source position, so member access / assignment /
|
|
7694
|
+
* template literals are lexically impossible.
|
|
7695
|
+
*/
|
|
7696
|
+
var KEYWORDS = new Set([
|
|
7697
|
+
"true",
|
|
7698
|
+
"false",
|
|
7699
|
+
"null"
|
|
7700
|
+
]);
|
|
7701
|
+
function isDigit(ch) {
|
|
7702
|
+
return ch >= "0" && ch <= "9";
|
|
7703
|
+
}
|
|
7704
|
+
function isIdentStart(ch) {
|
|
7705
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
7706
|
+
}
|
|
7707
|
+
function isIdentPart(ch) {
|
|
7708
|
+
return isIdentStart(ch) || isDigit(ch);
|
|
7709
|
+
}
|
|
7710
|
+
function isWhitespace(ch) {
|
|
7711
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
7712
|
+
}
|
|
7713
|
+
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
7714
|
+
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
7715
|
+
* string. */
|
|
7716
|
+
function tokenize(source) {
|
|
7717
|
+
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
7718
|
+
const tokens = [];
|
|
7719
|
+
let i = 0;
|
|
7720
|
+
const n = source.length;
|
|
7721
|
+
while (i < n) {
|
|
7722
|
+
const ch = source[i];
|
|
7723
|
+
if (isWhitespace(ch)) {
|
|
7724
|
+
i += 1;
|
|
7725
|
+
continue;
|
|
7726
|
+
}
|
|
7727
|
+
if (isDigit(ch)) {
|
|
7728
|
+
const start = i;
|
|
7729
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7730
|
+
if (i < n && source[i] === ".") {
|
|
7731
|
+
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
7732
|
+
i += 1;
|
|
7733
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7734
|
+
}
|
|
7735
|
+
const text = source.slice(start, i);
|
|
7736
|
+
const value = Number(text);
|
|
7737
|
+
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
7738
|
+
tokens.push({
|
|
7739
|
+
type: "number",
|
|
7740
|
+
value,
|
|
7741
|
+
pos: start
|
|
7742
|
+
});
|
|
7743
|
+
continue;
|
|
7744
|
+
}
|
|
7745
|
+
if (ch === "'" || ch === "\"") {
|
|
7746
|
+
const quote = ch;
|
|
7747
|
+
const start = i;
|
|
7748
|
+
i += 1;
|
|
7749
|
+
let out = "";
|
|
7750
|
+
let closed = false;
|
|
7751
|
+
while (i < n) {
|
|
7752
|
+
const c = source[i];
|
|
7753
|
+
if (c === "\\") {
|
|
7754
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
7755
|
+
if (next === "\\" || next === "'" || next === "\"") {
|
|
7756
|
+
out += next;
|
|
7757
|
+
i += 2;
|
|
7758
|
+
continue;
|
|
7759
|
+
}
|
|
7760
|
+
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
7761
|
+
}
|
|
7762
|
+
if (c === quote) {
|
|
7763
|
+
closed = true;
|
|
7764
|
+
i += 1;
|
|
7765
|
+
break;
|
|
7766
|
+
}
|
|
7767
|
+
out += c;
|
|
7768
|
+
i += 1;
|
|
7769
|
+
}
|
|
7770
|
+
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
7771
|
+
tokens.push({
|
|
7772
|
+
type: "string",
|
|
7773
|
+
value: out,
|
|
7774
|
+
pos: start
|
|
7775
|
+
});
|
|
7776
|
+
continue;
|
|
7777
|
+
}
|
|
7778
|
+
if (isIdentStart(ch)) {
|
|
7779
|
+
const start = i;
|
|
7780
|
+
while (i < n && isIdentPart(source[i])) i += 1;
|
|
7781
|
+
const text = source.slice(start, i);
|
|
7782
|
+
if (KEYWORDS.has(text)) tokens.push({
|
|
7783
|
+
type: "keyword",
|
|
7784
|
+
keyword: keywordOf(text),
|
|
7785
|
+
pos: start
|
|
7786
|
+
});
|
|
7787
|
+
else tokens.push({
|
|
7788
|
+
type: "identifier",
|
|
7789
|
+
name: text,
|
|
7790
|
+
pos: start
|
|
7791
|
+
});
|
|
7792
|
+
continue;
|
|
7793
|
+
}
|
|
7794
|
+
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
7795
|
+
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
7796
|
+
tokens.push({
|
|
7797
|
+
type: "punct",
|
|
7798
|
+
punct: two,
|
|
7799
|
+
pos: i
|
|
7800
|
+
});
|
|
7801
|
+
i += 2;
|
|
7802
|
+
continue;
|
|
7803
|
+
}
|
|
7804
|
+
if (isSinglePunct(ch)) {
|
|
7805
|
+
tokens.push({
|
|
7806
|
+
type: "punct",
|
|
7807
|
+
punct: ch,
|
|
7808
|
+
pos: i
|
|
7809
|
+
});
|
|
7810
|
+
i += 1;
|
|
7811
|
+
continue;
|
|
7812
|
+
}
|
|
7813
|
+
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
7814
|
+
}
|
|
7815
|
+
tokens.push({
|
|
7816
|
+
type: "eof",
|
|
7817
|
+
pos: n
|
|
7818
|
+
});
|
|
7819
|
+
return tokens;
|
|
7820
|
+
}
|
|
7821
|
+
function keywordOf(text) {
|
|
7822
|
+
if (text === "true") return "true";
|
|
7823
|
+
if (text === "false") return "false";
|
|
7824
|
+
return "null";
|
|
7825
|
+
}
|
|
7826
|
+
function isSinglePunct(ch) {
|
|
7827
|
+
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
7828
|
+
}
|
|
7829
|
+
/**
|
|
7830
|
+
* Frozen, null-prototype builtin function table for the expression engine
|
|
7831
|
+
* (spec §4 rule 4). The table is the SOLE surface of callable functions: the
|
|
7832
|
+
* parser rejects any callee not in it, and the evaluator gates each call on an
|
|
7833
|
+
* own-property check against it.
|
|
7834
|
+
*
|
|
7835
|
+
* Because the object has a NULL prototype AND is `Object.freeze`d:
|
|
7836
|
+
* - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
|
|
7837
|
+
* - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
|
|
7838
|
+
* (there is no `Object.prototype` in the chain), so those names are not
|
|
7839
|
+
* callable — they are simply "unknown function" at parse time.
|
|
7840
|
+
*
|
|
7841
|
+
* Every numeric argument is validated as a finite number and every numeric
|
|
7842
|
+
* RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
|
|
7843
|
+
* (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
|
|
7844
|
+
* closed rather than emitting a garbage value.
|
|
7845
|
+
*/
|
|
7846
|
+
function asFiniteNumber(value, name, index) {
|
|
7847
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
7848
|
+
return value;
|
|
7849
|
+
}
|
|
7850
|
+
function asString$1(value, name, index) {
|
|
7851
|
+
if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
|
|
7852
|
+
return value;
|
|
7853
|
+
}
|
|
7854
|
+
function finiteResult(value, name) {
|
|
7855
|
+
if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
|
|
7856
|
+
return value;
|
|
7857
|
+
}
|
|
7858
|
+
function allFiniteNumbers(args, name) {
|
|
7859
|
+
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
7860
|
+
}
|
|
7861
|
+
var INF = Number.POSITIVE_INFINITY;
|
|
7862
|
+
var table = {
|
|
7863
|
+
min: {
|
|
7864
|
+
minArgs: 1,
|
|
7865
|
+
maxArgs: INF,
|
|
7866
|
+
apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
|
|
7867
|
+
},
|
|
7868
|
+
max: {
|
|
7869
|
+
minArgs: 1,
|
|
7870
|
+
maxArgs: INF,
|
|
7871
|
+
apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
|
|
7872
|
+
},
|
|
7873
|
+
abs: {
|
|
7874
|
+
minArgs: 1,
|
|
7875
|
+
maxArgs: 1,
|
|
7876
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
7877
|
+
},
|
|
7878
|
+
floor: {
|
|
7879
|
+
minArgs: 1,
|
|
7880
|
+
maxArgs: 1,
|
|
7881
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
7882
|
+
},
|
|
7883
|
+
ceil: {
|
|
7884
|
+
minArgs: 1,
|
|
7885
|
+
maxArgs: 1,
|
|
7886
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
7887
|
+
},
|
|
7888
|
+
sqrt: {
|
|
7889
|
+
minArgs: 1,
|
|
7890
|
+
maxArgs: 1,
|
|
7891
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
7892
|
+
},
|
|
7893
|
+
round: {
|
|
7894
|
+
minArgs: 1,
|
|
7895
|
+
maxArgs: 2,
|
|
7896
|
+
apply: (args) => {
|
|
7897
|
+
const x = asFiniteNumber(args[0], "round", 0);
|
|
7898
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
7899
|
+
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
7900
|
+
const factor = 10 ** digits;
|
|
7901
|
+
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
7902
|
+
}
|
|
7903
|
+
},
|
|
7904
|
+
pow: {
|
|
7905
|
+
minArgs: 2,
|
|
7906
|
+
maxArgs: 2,
|
|
7907
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
7908
|
+
},
|
|
7909
|
+
clamp: {
|
|
7910
|
+
minArgs: 3,
|
|
7911
|
+
maxArgs: 3,
|
|
7912
|
+
apply: (args) => {
|
|
7913
|
+
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
7914
|
+
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
7915
|
+
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
7916
|
+
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
7917
|
+
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
7918
|
+
}
|
|
7919
|
+
},
|
|
7920
|
+
avg: {
|
|
7921
|
+
minArgs: 1,
|
|
7922
|
+
maxArgs: INF,
|
|
7923
|
+
apply: (args) => {
|
|
7924
|
+
const nums = allFiniteNumbers(args, "avg");
|
|
7925
|
+
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
7926
|
+
}
|
|
7927
|
+
},
|
|
7928
|
+
sum: {
|
|
7929
|
+
minArgs: 1,
|
|
7930
|
+
maxArgs: INF,
|
|
7931
|
+
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
7932
|
+
},
|
|
7933
|
+
coalesce: {
|
|
7934
|
+
minArgs: 1,
|
|
7935
|
+
maxArgs: INF,
|
|
7936
|
+
apply: (args) => {
|
|
7937
|
+
for (const a of args) if (a !== null) return a;
|
|
7938
|
+
return null;
|
|
7939
|
+
}
|
|
7940
|
+
},
|
|
7941
|
+
age: {
|
|
7942
|
+
minArgs: 2,
|
|
7943
|
+
maxArgs: 2,
|
|
7944
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
7945
|
+
},
|
|
7946
|
+
convert: {
|
|
7947
|
+
minArgs: 3,
|
|
7948
|
+
maxArgs: 3,
|
|
7949
|
+
apply: (args, hooks) => {
|
|
7950
|
+
const x = asFiniteNumber(args[0], "convert", 0);
|
|
7951
|
+
const from = asString$1(args[1], "convert", 1).trim();
|
|
7952
|
+
const to = asString$1(args[2], "convert", 2).trim();
|
|
7953
|
+
if (hooks.convert) {
|
|
7954
|
+
const out = hooks.convert(x, from, to);
|
|
7955
|
+
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
7956
|
+
return finiteResult(out, "convert");
|
|
7957
|
+
}
|
|
7958
|
+
if (from === to) return x;
|
|
7959
|
+
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
7960
|
+
}
|
|
7961
|
+
}
|
|
7962
|
+
};
|
|
7963
|
+
Object.freeze(Object.assign(Object.create(null), table));
|
|
7964
|
+
/** The set of valid builtin names — used by the parser to reject unknown
|
|
7965
|
+
* callees at parse time (immediate author feedback). */
|
|
7966
|
+
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
7967
|
+
/**
|
|
7968
|
+
* Pratt (precedence-climbing) parser for the safe expression mini-language.
|
|
7969
|
+
*
|
|
7970
|
+
* Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
|
|
7971
|
+
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
7972
|
+
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
7973
|
+
* string validated against the builtin table at parse time, so an unknown
|
|
7974
|
+
* function is rejected immediately (author feedback) and a persisted expression
|
|
7975
|
+
* that references a since-removed builtin degrades at read.
|
|
7976
|
+
*
|
|
7977
|
+
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
7978
|
+
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
7979
|
+
*/
|
|
7980
|
+
/** Binary/logical operator precedence (higher binds tighter). */
|
|
7981
|
+
var BINARY_PRECEDENCE = {
|
|
7982
|
+
"||": 1,
|
|
7983
|
+
"&&": 2,
|
|
7984
|
+
"==": 3,
|
|
7985
|
+
"!=": 3,
|
|
7986
|
+
"<": 4,
|
|
7987
|
+
"<=": 4,
|
|
7988
|
+
">": 4,
|
|
7989
|
+
">=": 4,
|
|
7990
|
+
"+": 5,
|
|
7991
|
+
"-": 5,
|
|
7992
|
+
"*": 6,
|
|
7993
|
+
"/": 6,
|
|
7994
|
+
"%": 6
|
|
7995
|
+
};
|
|
7996
|
+
function isLogicalOp(op) {
|
|
7997
|
+
return op === "&&" || op === "||";
|
|
7998
|
+
}
|
|
7999
|
+
function isBinaryOp(op) {
|
|
8000
|
+
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
8001
|
+
}
|
|
8002
|
+
var Parser = class {
|
|
8003
|
+
tokens;
|
|
8004
|
+
pos = 0;
|
|
8005
|
+
nodeCount = 0;
|
|
8006
|
+
identifiers = /* @__PURE__ */ new Set();
|
|
8007
|
+
callees = /* @__PURE__ */ new Set();
|
|
8008
|
+
constructor(tokens) {
|
|
8009
|
+
this.tokens = tokens;
|
|
8010
|
+
}
|
|
8011
|
+
parse() {
|
|
8012
|
+
const ast = this.parseTernary();
|
|
8013
|
+
const tok = this.peek();
|
|
8014
|
+
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
8015
|
+
return {
|
|
8016
|
+
ast,
|
|
8017
|
+
identifiers: this.identifiers,
|
|
8018
|
+
callees: this.callees,
|
|
8019
|
+
nodeCount: this.nodeCount
|
|
8020
|
+
};
|
|
8021
|
+
}
|
|
8022
|
+
peek() {
|
|
8023
|
+
return this.tokens[this.pos];
|
|
8024
|
+
}
|
|
8025
|
+
next() {
|
|
8026
|
+
return this.tokens[this.pos++];
|
|
8027
|
+
}
|
|
8028
|
+
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
8029
|
+
expectPunct(punct) {
|
|
8030
|
+
const tok = this.peek();
|
|
8031
|
+
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
8032
|
+
this.pos += 1;
|
|
8033
|
+
}
|
|
8034
|
+
matchPunct(punct) {
|
|
8035
|
+
const tok = this.peek();
|
|
8036
|
+
if (tok.type === "punct" && tok.punct === punct) {
|
|
8037
|
+
this.pos += 1;
|
|
8038
|
+
return true;
|
|
8039
|
+
}
|
|
8040
|
+
return false;
|
|
8041
|
+
}
|
|
8042
|
+
countNode() {
|
|
8043
|
+
this.nodeCount += 1;
|
|
8044
|
+
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
8045
|
+
}
|
|
8046
|
+
parseTernary() {
|
|
8047
|
+
const test = this.parseBinary(1);
|
|
8048
|
+
if (this.matchPunct("?")) {
|
|
8049
|
+
const consequent = this.parseTernary();
|
|
8050
|
+
this.expectPunct(":");
|
|
8051
|
+
const alternate = this.parseTernary();
|
|
8052
|
+
this.countNode();
|
|
8053
|
+
return {
|
|
8054
|
+
kind: "conditional",
|
|
8055
|
+
test,
|
|
8056
|
+
consequent,
|
|
8057
|
+
alternate
|
|
8058
|
+
};
|
|
8059
|
+
}
|
|
8060
|
+
return test;
|
|
8061
|
+
}
|
|
8062
|
+
parseBinary(minPrec) {
|
|
8063
|
+
let left = this.parseUnary();
|
|
8064
|
+
for (;;) {
|
|
8065
|
+
const tok = this.peek();
|
|
8066
|
+
if (tok.type !== "punct") break;
|
|
8067
|
+
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
8068
|
+
if (prec === void 0 || prec < minPrec) break;
|
|
8069
|
+
const op = tok.punct;
|
|
8070
|
+
this.pos += 1;
|
|
8071
|
+
const right = this.parseBinary(prec + 1);
|
|
8072
|
+
this.countNode();
|
|
8073
|
+
if (isLogicalOp(op)) left = {
|
|
8074
|
+
kind: "logical",
|
|
8075
|
+
op,
|
|
8076
|
+
left,
|
|
8077
|
+
right
|
|
8078
|
+
};
|
|
8079
|
+
else if (isBinaryOp(op)) left = {
|
|
8080
|
+
kind: "binary",
|
|
8081
|
+
op,
|
|
8082
|
+
left,
|
|
8083
|
+
right
|
|
8084
|
+
};
|
|
8085
|
+
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
8086
|
+
}
|
|
8087
|
+
return left;
|
|
8088
|
+
}
|
|
8089
|
+
parseUnary() {
|
|
8090
|
+
const tok = this.peek();
|
|
8091
|
+
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
8092
|
+
const op = tok.punct;
|
|
8093
|
+
this.pos += 1;
|
|
8094
|
+
const operand = this.parseUnary();
|
|
8095
|
+
this.countNode();
|
|
8096
|
+
return {
|
|
8097
|
+
kind: "unary",
|
|
8098
|
+
op,
|
|
8099
|
+
operand
|
|
8100
|
+
};
|
|
8101
|
+
}
|
|
8102
|
+
return this.parsePrimary();
|
|
8103
|
+
}
|
|
8104
|
+
parsePrimary() {
|
|
8105
|
+
const tok = this.next();
|
|
8106
|
+
switch (tok.type) {
|
|
8107
|
+
case "number":
|
|
8108
|
+
this.countNode();
|
|
8109
|
+
return {
|
|
8110
|
+
kind: "literal",
|
|
8111
|
+
value: tok.value
|
|
8112
|
+
};
|
|
8113
|
+
case "string":
|
|
8114
|
+
this.countNode();
|
|
8115
|
+
return {
|
|
8116
|
+
kind: "literal",
|
|
8117
|
+
value: tok.value
|
|
8118
|
+
};
|
|
8119
|
+
case "keyword":
|
|
8120
|
+
this.countNode();
|
|
8121
|
+
return {
|
|
8122
|
+
kind: "literal",
|
|
8123
|
+
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
8124
|
+
};
|
|
8125
|
+
case "identifier": {
|
|
8126
|
+
const nextTok = this.peek();
|
|
8127
|
+
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
8128
|
+
this.identifiers.add(tok.name);
|
|
8129
|
+
this.countNode();
|
|
8130
|
+
return {
|
|
8131
|
+
kind: "identifier",
|
|
8132
|
+
name: tok.name
|
|
8133
|
+
};
|
|
8134
|
+
}
|
|
8135
|
+
case "punct":
|
|
8136
|
+
if (tok.punct === "(") {
|
|
8137
|
+
const inner = this.parseTernary();
|
|
8138
|
+
this.expectPunct(")");
|
|
8139
|
+
return inner;
|
|
8140
|
+
}
|
|
8141
|
+
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
8142
|
+
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
8143
|
+
}
|
|
8144
|
+
}
|
|
8145
|
+
parseCall(callee, pos) {
|
|
8146
|
+
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
8147
|
+
this.expectPunct("(");
|
|
8148
|
+
const args = [];
|
|
8149
|
+
if (!this.matchPunct(")")) for (;;) {
|
|
8150
|
+
args.push(this.parseTernary());
|
|
8151
|
+
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
8152
|
+
if (this.matchPunct(",")) continue;
|
|
8153
|
+
this.expectPunct(")");
|
|
8154
|
+
break;
|
|
8155
|
+
}
|
|
8156
|
+
this.callees.add(callee);
|
|
8157
|
+
this.countNode();
|
|
8158
|
+
return {
|
|
8159
|
+
kind: "call",
|
|
8160
|
+
callee,
|
|
8161
|
+
args
|
|
8162
|
+
};
|
|
8163
|
+
}
|
|
8164
|
+
};
|
|
8165
|
+
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
8166
|
+
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
8167
|
+
function parseExpression(source) {
|
|
8168
|
+
return new Parser(tokenize(source)).parse();
|
|
8169
|
+
}
|
|
8170
|
+
Object.freeze({});
|
|
8171
|
+
/**
|
|
8172
|
+
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
8173
|
+
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
8174
|
+
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
8175
|
+
* one per read on a hot resolve path.
|
|
8176
|
+
*
|
|
8177
|
+
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
8178
|
+
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
8179
|
+
* callers is safe and maximises hit rate.
|
|
8180
|
+
*/
|
|
8181
|
+
var cache = /* @__PURE__ */ new Map();
|
|
8182
|
+
function getCached(source) {
|
|
8183
|
+
const hit = cache.get(source);
|
|
8184
|
+
if (hit !== void 0) {
|
|
8185
|
+
cache.delete(source);
|
|
8186
|
+
cache.set(source, hit);
|
|
8187
|
+
return hit;
|
|
8188
|
+
}
|
|
8189
|
+
let result;
|
|
8190
|
+
try {
|
|
8191
|
+
result = {
|
|
8192
|
+
ok: true,
|
|
8193
|
+
parsed: parseExpression(source)
|
|
8194
|
+
};
|
|
8195
|
+
} catch (err) {
|
|
8196
|
+
result = {
|
|
8197
|
+
ok: false,
|
|
8198
|
+
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
8199
|
+
};
|
|
8200
|
+
}
|
|
8201
|
+
cache.set(source, result);
|
|
8202
|
+
if (cache.size > 256) {
|
|
8203
|
+
const oldest = cache.keys().next().value;
|
|
8204
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
8205
|
+
}
|
|
8206
|
+
return result;
|
|
8207
|
+
}
|
|
8208
|
+
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
8209
|
+
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
8210
|
+
function compileExpressionSafe(source) {
|
|
8211
|
+
return getCached(source);
|
|
8212
|
+
}
|
|
8213
|
+
/**
|
|
8214
|
+
* Author-time validation. Returns `null` when the source is valid, else a
|
|
8215
|
+
* human-readable error message. Checks: the expression compiles; binding count
|
|
8216
|
+
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
8217
|
+
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
8218
|
+
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
8219
|
+
*/
|
|
8220
|
+
function validateExpressionSource(src) {
|
|
8221
|
+
const names = Object.keys(src.bindings);
|
|
8222
|
+
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
8223
|
+
for (const name of names) {
|
|
8224
|
+
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
8225
|
+
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
8226
|
+
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
8227
|
+
}
|
|
8228
|
+
const compiled = compileExpressionSafe(src.expr);
|
|
8229
|
+
if (!compiled.ok) return compiled.error;
|
|
8230
|
+
const bound = new Set(names);
|
|
8231
|
+
for (const id of compiled.parsed.identifiers) {
|
|
8232
|
+
if (id === "now") continue;
|
|
8233
|
+
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
8234
|
+
}
|
|
8235
|
+
return null;
|
|
8236
|
+
}
|
|
8237
|
+
/**
|
|
7459
8238
|
* Accessory device helpers — shared across drivers.
|
|
7460
8239
|
*
|
|
7461
8240
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -8300,7 +9079,13 @@ onStatusChanged: { data: object({
|
|
|
8300
9079
|
}) } },
|
|
8301
9080
|
status: {
|
|
8302
9081
|
schema: BatteryStatusSchema,
|
|
8303
|
-
kind: "push"
|
|
9082
|
+
kind: "push",
|
|
9083
|
+
empty: {
|
|
9084
|
+
percentage: 0,
|
|
9085
|
+
charging: "none",
|
|
9086
|
+
sleeping: false,
|
|
9087
|
+
lastUpdated: 0
|
|
9088
|
+
}
|
|
8304
9089
|
},
|
|
8305
9090
|
/**
|
|
8306
9091
|
* Runtime-state slice — every provider that registers this cap
|
|
@@ -8439,6 +9224,10 @@ var RtspRestreamEntrySchema = object({
|
|
|
8439
9224
|
var BrokerRtspClientSchema = object({
|
|
8440
9225
|
sessionId: string(),
|
|
8441
9226
|
remoteAddr: string(),
|
|
9227
|
+
/** Client `User-Agent` (e.g. `recorder` for the recorder's RTSP pull), or
|
|
9228
|
+
* null/absent when the client sent none. Lets the UI label a consumer by
|
|
9229
|
+
* purpose. Optional so a client built against an older schema stays valid. */
|
|
9230
|
+
userAgent: string().nullish(),
|
|
8442
9231
|
playing: boolean(),
|
|
8443
9232
|
muted: boolean(),
|
|
8444
9233
|
connectedAt: number(),
|
|
@@ -9239,21 +10028,38 @@ var connectivityCapability = {
|
|
|
9239
10028
|
},
|
|
9240
10029
|
runtimeState: ConnectivityStatusSchema
|
|
9241
10030
|
};
|
|
10031
|
+
/**
|
|
10032
|
+
* Generic device-consumables capability — surfaces a device's
|
|
10033
|
+
* maintenance items (vacuum filters/brushes, replaceable cartridges,
|
|
10034
|
+
* descaling cycles, …) with their remaining life and an optional
|
|
10035
|
+
* "Replaced" reset action. Device-agnostic: any provider that knows its
|
|
10036
|
+
* device tracks consumables can register it; the cap declares no
|
|
10037
|
+
* vocabulary of its own — the provider names each item verbatim.
|
|
10038
|
+
*
|
|
10039
|
+
* Like `childLayout`, the cap is INERT until a provider sets items: no
|
|
10040
|
+
* provider populates it by guessing (no HA inference). The UI renders a
|
|
10041
|
+
* "No consumables reported" placeholder when `items` is empty.
|
|
10042
|
+
*/
|
|
10043
|
+
/** A single consumable item. Either a continuous `level` (remaining
|
|
10044
|
+
* life %) or a discrete `status` may be known — both may be null when a
|
|
10045
|
+
* provider only knows the item exists. `level` and `status` are not
|
|
10046
|
+
* mutually exclusive; a provider may report both. */
|
|
10047
|
+
var ConsumableItemSchema = object({
|
|
10048
|
+
/** Stable id, e.g. 'main-brush'. */
|
|
10049
|
+
key: string().min(1),
|
|
10050
|
+
/** Display name. */
|
|
10051
|
+
label: string().min(1),
|
|
10052
|
+
/** Remaining life % when known (0..100). */
|
|
10053
|
+
level: number().min(0).max(100).nullable(),
|
|
10054
|
+
/** Discrete state when known (binary mode). */
|
|
10055
|
+
status: _enum(["ok", "replace"]).nullable(),
|
|
10056
|
+
/** Ms epoch of the last replace, when known. */
|
|
10057
|
+
lastResetAt: number().nullable(),
|
|
10058
|
+
/** Whether `reset()` is meaningful for this item. */
|
|
10059
|
+
resettable: boolean()
|
|
10060
|
+
});
|
|
9242
10061
|
var ConsumablesStatusSchema = object({
|
|
9243
|
-
items: array(
|
|
9244
|
-
/** Stable id, e.g. 'main-brush'. */
|
|
9245
|
-
key: string().min(1),
|
|
9246
|
-
/** Display name. */
|
|
9247
|
-
label: string().min(1),
|
|
9248
|
-
/** Remaining life % when known (0..100). */
|
|
9249
|
-
level: number().min(0).max(100).nullable(),
|
|
9250
|
-
/** Discrete state when known (binary mode). */
|
|
9251
|
-
status: _enum(["ok", "replace"]).nullable(),
|
|
9252
|
-
/** Ms epoch of the last replace, when known. */
|
|
9253
|
-
lastResetAt: number().nullable(),
|
|
9254
|
-
/** Whether `reset()` is meaningful for this item. */
|
|
9255
|
-
resettable: boolean()
|
|
9256
|
-
})),
|
|
10062
|
+
items: array(ConsumableItemSchema),
|
|
9257
10063
|
lastChangedAt: number()
|
|
9258
10064
|
});
|
|
9259
10065
|
var consumablesCapability = {
|
|
@@ -9312,7 +10118,25 @@ reset: method(object({
|
|
|
9312
10118
|
}) },
|
|
9313
10119
|
status: {
|
|
9314
10120
|
schema: ConsumablesStatusSchema,
|
|
9315
|
-
kind: "push"
|
|
10121
|
+
kind: "push",
|
|
10122
|
+
empty: {
|
|
10123
|
+
items: [],
|
|
10124
|
+
lastChangedAt: 0
|
|
10125
|
+
},
|
|
10126
|
+
itemArray: {
|
|
10127
|
+
path: "items",
|
|
10128
|
+
keyField: "key",
|
|
10129
|
+
labelField: "label",
|
|
10130
|
+
itemSchema: ConsumableItemSchema,
|
|
10131
|
+
emptyItem: {
|
|
10132
|
+
key: "",
|
|
10133
|
+
label: "",
|
|
10134
|
+
level: null,
|
|
10135
|
+
status: null,
|
|
10136
|
+
lastResetAt: null,
|
|
10137
|
+
resettable: false
|
|
10138
|
+
}
|
|
10139
|
+
}
|
|
9316
10140
|
},
|
|
9317
10141
|
runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() })
|
|
9318
10142
|
};
|
|
@@ -10554,7 +11378,8 @@ var MotionAnalysisResultSchema = object({
|
|
|
10554
11378
|
});
|
|
10555
11379
|
method(object({
|
|
10556
11380
|
deviceId: number(),
|
|
10557
|
-
frame: FrameInputSchema
|
|
11381
|
+
frame: FrameInputSchema.optional(),
|
|
11382
|
+
frameHandle: FrameHandleSchema.optional()
|
|
10558
11383
|
}), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
|
|
10559
11384
|
deviceId: number(),
|
|
10560
11385
|
detected: boolean(),
|
|
@@ -10801,6 +11626,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
10801
11626
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
10802
11627
|
steps: array(PipelineStepInputSchema).min(1),
|
|
10803
11628
|
frame: FrameInputSchema.optional(),
|
|
11629
|
+
/**
|
|
11630
|
+
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
11631
|
+
* the decoded pixels live in. One more member of the one-of
|
|
11632
|
+
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
11633
|
+
*/
|
|
11634
|
+
frameHandle: FrameHandleSchema.optional(),
|
|
10804
11635
|
imageBase64: string().optional(),
|
|
10805
11636
|
/**
|
|
10806
11637
|
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
@@ -11043,6 +11874,31 @@ var ReportMotionInputSchema = object({
|
|
|
11043
11874
|
regions: array(MotionRegionSchema).readonly().optional()
|
|
11044
11875
|
});
|
|
11045
11876
|
/**
|
|
11877
|
+
* Where a runner gets a camera's decoded frames (cross-node Phase 2,
|
|
11878
|
+
* restream-owner model — P2c).
|
|
11879
|
+
*
|
|
11880
|
+
* - `local-broker` (DEFAULT): today's path — subscribe to the co-located
|
|
11881
|
+
* stream-broker's shm frame plane. Every pre-P2c attach payload (no
|
|
11882
|
+
* `frameSource` key) parses to this, so the field is additive with zero
|
|
11883
|
+
* behavior change.
|
|
11884
|
+
* - `remote-restream`: the detect node is NOT the camera's source-owner.
|
|
11885
|
+
* The runner acquires the owner's COMPRESSED passthrough restream
|
|
11886
|
+
* (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
|
|
11887
|
+
* double-pull guard) and decodes LOCALLY via a satellite frame plane +
|
|
11888
|
+
* pull-mode decoder session pinned to its own node. The shm ring stays
|
|
11889
|
+
* node-local; only H.264/H.265 packets cross the wire.
|
|
11890
|
+
* `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
|
|
11891
|
+
* when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
|
|
11892
|
+
* dials for the owner's restream.
|
|
11893
|
+
*/
|
|
11894
|
+
var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
|
|
11895
|
+
kind: literal("remote-restream"),
|
|
11896
|
+
/** The camera's source-owner node (slice 1: always the hub). */
|
|
11897
|
+
ownerNodeId: string(),
|
|
11898
|
+
/** Operator override for the owner host the runner dials. */
|
|
11899
|
+
hubHostnameOverride: string().optional()
|
|
11900
|
+
})]).describe("Per-camera frame-source mode for the runner (P2c)");
|
|
11901
|
+
/**
|
|
11046
11902
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
11047
11903
|
* specific runner instance via `attachCamera`. Carries everything the
|
|
11048
11904
|
* runner needs to subscribe to the local broker and execute inference.
|
|
@@ -11140,7 +11996,15 @@ var RunnerCameraConfigSchema = object({
|
|
|
11140
11996
|
*/
|
|
11141
11997
|
onboardMotionDrivesAnalyzer: boolean().default(true),
|
|
11142
11998
|
occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
|
|
11143
|
-
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
|
|
11999
|
+
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
|
|
12000
|
+
/**
|
|
12001
|
+
* Where this runner gets the camera's decoded frames (P2c). Defaulted so
|
|
12002
|
+
* every existing payload behaves as `local-broker` — the pre-Phase-2 path.
|
|
12003
|
+
* Populated with `remote-restream` by the orchestrator ONLY when the
|
|
12004
|
+
* camera's detect node differs from its source-owner (P2d, gated by the
|
|
12005
|
+
* `remoteSourcingNodes` rollout setting).
|
|
12006
|
+
*/
|
|
12007
|
+
frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
|
|
11144
12008
|
});
|
|
11145
12009
|
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;
|
|
11146
12010
|
/**
|
|
@@ -11704,6 +12568,157 @@ var numericSensorCapability = {
|
|
|
11704
12568
|
runtimeState: NumericSensorStatusSchema
|
|
11705
12569
|
};
|
|
11706
12570
|
/**
|
|
12571
|
+
* Feeder connectivity / power status — mirrors the HA petkit device-status
|
|
12572
|
+
* enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
|
|
12573
|
+
* `on_batteries` (running on battery backup). `null` until first reported.
|
|
12574
|
+
*/
|
|
12575
|
+
var PetFeederDeviceStatusSchema = _enum([
|
|
12576
|
+
"normal",
|
|
12577
|
+
"offline",
|
|
12578
|
+
"on_batteries"
|
|
12579
|
+
]);
|
|
12580
|
+
var gramsPortion = number().int().min(4).max(200);
|
|
12581
|
+
var PetFeederStatusSchema = object({
|
|
12582
|
+
/** Food currently in the bowl (grams). Null when the device has not
|
|
12583
|
+
* reported a reading yet. On dual-hopper models this is the combined
|
|
12584
|
+
* bowl reading; per-hopper levels live in `food1`/`food2`. */
|
|
12585
|
+
foodLevel: number().nullable(),
|
|
12586
|
+
/** Hopper-1 food level (grams) on dual-hopper feeders; null on
|
|
12587
|
+
* single-hopper models. */
|
|
12588
|
+
food1: number().nullable(),
|
|
12589
|
+
/** Hopper-2 food level (grams) on dual-hopper feeders; null on
|
|
12590
|
+
* single-hopper models. */
|
|
12591
|
+
food2: number().nullable(),
|
|
12592
|
+
/** Derived low-food flag — mirrors the HA `food_level` binary_sensor
|
|
12593
|
+
* (`device_class: problem`, on = low). True when the bowl is empty /
|
|
12594
|
+
* below the feeder's low threshold. */
|
|
12595
|
+
lowFood: boolean(),
|
|
12596
|
+
/** Battery charge 0..100 (%). Null on mains-powered models or when the
|
|
12597
|
+
* device has no battery reading. */
|
|
12598
|
+
batteryPower: number().min(0).max(100).nullable(),
|
|
12599
|
+
/** Days of desiccant life remaining. Null when the model has no
|
|
12600
|
+
* desiccant sensor. */
|
|
12601
|
+
desiccantLeftDays: number().nullable(),
|
|
12602
|
+
/** True while a feed is in progress. */
|
|
12603
|
+
feeding: boolean(),
|
|
12604
|
+
/** Decoded connectivity / power status (HA petkit device-status enum).
|
|
12605
|
+
* Null until the device has reported a status. */
|
|
12606
|
+
status: PetFeederDeviceStatusSchema.nullable(),
|
|
12607
|
+
/** Decoded human-readable fault message. Null (or the device's `no_error`
|
|
12608
|
+
* sentinel) means healthy; a non-null string is an active fault. Pairs
|
|
12609
|
+
* with `errorCode` for consumers that want the raw integer. */
|
|
12610
|
+
error: string().nullable(),
|
|
12611
|
+
/** Raw device error code (0 / null = no error). */
|
|
12612
|
+
errorCode: number().nullable(),
|
|
12613
|
+
/** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
|
|
12614
|
+
isDualHopper: boolean(),
|
|
12615
|
+
/** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
|
|
12616
|
+
childLock: boolean(),
|
|
12617
|
+
/** Front indicator-light setting. */
|
|
12618
|
+
indicatorLight: boolean(),
|
|
12619
|
+
/** Play a chime when dispensing. */
|
|
12620
|
+
feedSound: boolean(),
|
|
12621
|
+
/** Speaker / prompt volume level (device-scaled integer). */
|
|
12622
|
+
volume: number(),
|
|
12623
|
+
/** Ms epoch when the slice was last refreshed from the cloud. */
|
|
12624
|
+
lastFetchedAt: number()
|
|
12625
|
+
});
|
|
12626
|
+
var petFeederCapability = {
|
|
12627
|
+
name: "pet-feeder",
|
|
12628
|
+
scope: "device",
|
|
12629
|
+
deviceNative: true,
|
|
12630
|
+
mode: "singleton",
|
|
12631
|
+
deviceTypes: [DeviceType.PetFeeder],
|
|
12632
|
+
methods: {
|
|
12633
|
+
/**
|
|
12634
|
+
* Dispense food now. Single-hopper feeders take `grams`; dual-hopper
|
|
12635
|
+
* feeders (D4S/D4SH) accept `hopper1`/`hopper2` to target one or both
|
|
12636
|
+
* hoppers. All portions honour the 4–200 g hardware range. At least
|
|
12637
|
+
* one of the three must be present — the provider rejects an empty
|
|
12638
|
+
* request.
|
|
12639
|
+
*/
|
|
12640
|
+
feed: method(object({
|
|
12641
|
+
deviceId: number().int().nonnegative(),
|
|
12642
|
+
grams: gramsPortion.optional(),
|
|
12643
|
+
hopper1: gramsPortion.optional(),
|
|
12644
|
+
hopper2: gramsPortion.optional()
|
|
12645
|
+
}), _void(), {
|
|
12646
|
+
kind: "mutation",
|
|
12647
|
+
auth: "admin"
|
|
12648
|
+
}),
|
|
12649
|
+
/** Cancel an in-progress manual feed. */
|
|
12650
|
+
cancelFeed: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12651
|
+
kind: "mutation",
|
|
12652
|
+
auth: "admin"
|
|
12653
|
+
}),
|
|
12654
|
+
/** Reset the desiccant "days remaining" counter after replacing it. */
|
|
12655
|
+
resetDesiccant: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12656
|
+
kind: "mutation",
|
|
12657
|
+
auth: "admin"
|
|
12658
|
+
}),
|
|
12659
|
+
/** Mark a hopper as refilled (D4H/D4S/D4SH). */
|
|
12660
|
+
markFoodReplenished: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12661
|
+
kind: "mutation",
|
|
12662
|
+
auth: "admin"
|
|
12663
|
+
}),
|
|
12664
|
+
/** Call the pet with the recorded prompt (D3). */
|
|
12665
|
+
callPet: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
12666
|
+
kind: "mutation",
|
|
12667
|
+
auth: "admin"
|
|
12668
|
+
}),
|
|
12669
|
+
/** Play a stored sound by id (D3 / D4H / D4SH). */
|
|
12670
|
+
playSound: method(object({
|
|
12671
|
+
deviceId: number().int().nonnegative(),
|
|
12672
|
+
soundId: number().int().nonnegative()
|
|
12673
|
+
}), _void(), {
|
|
12674
|
+
kind: "mutation",
|
|
12675
|
+
auth: "admin"
|
|
12676
|
+
}),
|
|
12677
|
+
/** Toggle the child-lock (manual-lock) setting. */
|
|
12678
|
+
setChildLock: method(object({
|
|
12679
|
+
deviceId: number().int().nonnegative(),
|
|
12680
|
+
on: boolean()
|
|
12681
|
+
}), _void(), {
|
|
12682
|
+
kind: "mutation",
|
|
12683
|
+
auth: "admin"
|
|
12684
|
+
}),
|
|
12685
|
+
/** Toggle the front indicator light. */
|
|
12686
|
+
setIndicatorLight: method(object({
|
|
12687
|
+
deviceId: number().int().nonnegative(),
|
|
12688
|
+
on: boolean()
|
|
12689
|
+
}), _void(), {
|
|
12690
|
+
kind: "mutation",
|
|
12691
|
+
auth: "admin"
|
|
12692
|
+
}),
|
|
12693
|
+
/** Toggle the dispense chime. */
|
|
12694
|
+
setFeedSound: method(object({
|
|
12695
|
+
deviceId: number().int().nonnegative(),
|
|
12696
|
+
on: boolean()
|
|
12697
|
+
}), _void(), {
|
|
12698
|
+
kind: "mutation",
|
|
12699
|
+
auth: "admin"
|
|
12700
|
+
}),
|
|
12701
|
+
/** Set the speaker / prompt volume level. */
|
|
12702
|
+
setVolume: method(object({
|
|
12703
|
+
deviceId: number().int().nonnegative(),
|
|
12704
|
+
level: number().int().nonnegative()
|
|
12705
|
+
}), _void(), {
|
|
12706
|
+
kind: "mutation",
|
|
12707
|
+
auth: "admin"
|
|
12708
|
+
})
|
|
12709
|
+
},
|
|
12710
|
+
status: {
|
|
12711
|
+
schema: PetFeederStatusSchema,
|
|
12712
|
+
kind: "poll"
|
|
12713
|
+
},
|
|
12714
|
+
/**
|
|
12715
|
+
* Runtime-state slice — mirrored by the kernel. UI feeder cards read
|
|
12716
|
+
* the full slice via `device.state.petFeeder.value` and refresh on
|
|
12717
|
+
* every poll without re-querying the provider.
|
|
12718
|
+
*/
|
|
12719
|
+
runtimeState: PetFeederStatusSchema
|
|
12720
|
+
};
|
|
12721
|
+
/**
|
|
11707
12722
|
* Multi-metric electrical meter. One slice can carry any combination
|
|
11708
12723
|
* of instantaneous power (W), cumulative energy (kWh), voltage (V),
|
|
11709
12724
|
* and current (A) — all fields optional so a single-metric source
|
|
@@ -13006,6 +14021,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
|
|
|
13006
14021
|
nativeObjectDetection: nativeObjectDetectionCapability,
|
|
13007
14022
|
notifier: notifierCapability,
|
|
13008
14023
|
numericSensor: numericSensorCapability,
|
|
14024
|
+
petFeeder: petFeederCapability,
|
|
13009
14025
|
powerMeter: powerMeterCapability,
|
|
13010
14026
|
presence: presenceCapability,
|
|
13011
14027
|
pressureSensor: pressureSensorCapability,
|
|
@@ -14922,10 +15938,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
|
|
|
14922
15938
|
url: string()
|
|
14923
15939
|
}), _void()), method(object({
|
|
14924
15940
|
sessionId: string(),
|
|
14925
|
-
maxCount: number().default(1)
|
|
15941
|
+
maxCount: number().default(1),
|
|
15942
|
+
waitMs: number().optional()
|
|
14926
15943
|
}), array(DecodedFrameSchema)), method(object({
|
|
14927
15944
|
sessionId: string(),
|
|
14928
|
-
maxCount: number().default(1)
|
|
15945
|
+
maxCount: number().default(1),
|
|
15946
|
+
waitMs: number().optional()
|
|
14929
15947
|
}), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
|
|
14930
15948
|
sessionId: string(),
|
|
14931
15949
|
config: DecoderSessionConfigSchema.partial()
|
|
@@ -15212,14 +16230,63 @@ var ChildLayoutEntrySchema = object({
|
|
|
15212
16230
|
collapsed: boolean().optional()
|
|
15213
16231
|
});
|
|
15214
16232
|
/** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
|
|
15215
|
-
* `device-management.ts`.
|
|
16233
|
+
* `device-management.ts`. Source is a union: a FIELD source copies a sibling
|
|
16234
|
+
* accessory's status field (`kind` optional/absent for wire compat); a
|
|
16235
|
+
* LITERAL source carries a per-device constant (no sibling is read); a
|
|
16236
|
+
* GLOBAL source (P2e) copies ANY device's status field, addressed by the
|
|
16237
|
+
* source device's full re-sync-stable `stableId`. */
|
|
16238
|
+
var DeviceLinkFieldSourceSchema = object({
|
|
16239
|
+
kind: literal("field").optional(),
|
|
16240
|
+
sourceKey: string(),
|
|
16241
|
+
cap: string(),
|
|
16242
|
+
fieldPath: string()
|
|
16243
|
+
});
|
|
16244
|
+
var DeviceLinkLiteralSourceSchema = object({
|
|
16245
|
+
kind: literal("literal"),
|
|
16246
|
+
value: union([
|
|
16247
|
+
string(),
|
|
16248
|
+
number(),
|
|
16249
|
+
boolean(),
|
|
16250
|
+
_null()
|
|
16251
|
+
])
|
|
16252
|
+
});
|
|
16253
|
+
var DeviceLinkGlobalSourceSchema = object({
|
|
16254
|
+
kind: literal("global"),
|
|
16255
|
+
sourceStableId: string(),
|
|
16256
|
+
cap: string(),
|
|
16257
|
+
fieldPath: string()
|
|
16258
|
+
});
|
|
16259
|
+
/** Expression source (Stage X): compute the target field from N named bindings
|
|
16260
|
+
* via the safe expression engine. Bindings are field | literal | global — never
|
|
16261
|
+
* another expression (no nesting). The `superRefine` runs the SAME author-time
|
|
16262
|
+
* validation as `validateExpressionSource` (compiles the expr, checks binding
|
|
16263
|
+
* names + identifier coverage) so every wire boundary that parses a DeviceLink
|
|
16264
|
+
* (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
|
|
16265
|
+
* Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
|
|
16266
|
+
var DeviceLinkExpressionSourceSchema = object({
|
|
16267
|
+
kind: literal("expression"),
|
|
16268
|
+
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
16269
|
+
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
|
|
16270
|
+
DeviceLinkFieldSourceSchema,
|
|
16271
|
+
DeviceLinkLiteralSourceSchema,
|
|
16272
|
+
DeviceLinkGlobalSourceSchema
|
|
16273
|
+
]))
|
|
16274
|
+
}).superRefine((src, ctx) => {
|
|
16275
|
+
const err = validateExpressionSource(src);
|
|
16276
|
+
if (err !== null) ctx.addIssue({
|
|
16277
|
+
code: "custom",
|
|
16278
|
+
message: err,
|
|
16279
|
+
path: ["expr"]
|
|
16280
|
+
});
|
|
16281
|
+
});
|
|
15216
16282
|
var DeviceLinkSchema = object({
|
|
15217
16283
|
id: string(),
|
|
15218
|
-
source:
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15222
|
-
|
|
16284
|
+
source: union([
|
|
16285
|
+
DeviceLinkFieldSourceSchema,
|
|
16286
|
+
DeviceLinkLiteralSourceSchema,
|
|
16287
|
+
DeviceLinkGlobalSourceSchema,
|
|
16288
|
+
DeviceLinkExpressionSourceSchema
|
|
16289
|
+
]),
|
|
15223
16290
|
target: object({
|
|
15224
16291
|
cap: string(),
|
|
15225
16292
|
fieldPath: string(),
|
|
@@ -15248,6 +16315,31 @@ var DeviceLinkSchema = object({
|
|
|
15248
16315
|
})
|
|
15249
16316
|
]).optional()
|
|
15250
16317
|
});
|
|
16318
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
16319
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
16320
|
+
var DeviceCapDisplayOverrideSchema = object({
|
|
16321
|
+
unit: string().min(1).optional(),
|
|
16322
|
+
precision: number().int().min(0).max(10).optional()
|
|
16323
|
+
});
|
|
16324
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
16325
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
16326
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
16327
|
+
var DeviceDisplayOverrideSchema = object({
|
|
16328
|
+
icon: string().min(1).optional(),
|
|
16329
|
+
label: string().min(1).optional(),
|
|
16330
|
+
unit: string().min(1).optional(),
|
|
16331
|
+
precision: number().int().min(0).max(10).optional(),
|
|
16332
|
+
hidden: boolean().optional(),
|
|
16333
|
+
perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
|
|
16334
|
+
});
|
|
16335
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
16336
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
16337
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
16338
|
+
var RoleDisplayDefaultSchema = object({
|
|
16339
|
+
unit: string().min(1).optional(),
|
|
16340
|
+
precision: number().int().min(0).max(10).optional(),
|
|
16341
|
+
icon: string().min(1).optional()
|
|
16342
|
+
});
|
|
15251
16343
|
/**
|
|
15252
16344
|
* Serializable projection of a live IDevice.
|
|
15253
16345
|
* Returned by listAll, getDevice, getChildren.
|
|
@@ -15303,7 +16395,9 @@ var DeviceInfoSchema = object({
|
|
|
15303
16395
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
15304
16396
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
15305
16397
|
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
15306
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional()
|
|
16398
|
+
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
16399
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
16400
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
15307
16401
|
});
|
|
15308
16402
|
var ConfigEntrySchema = object({
|
|
15309
16403
|
key: string(),
|
|
@@ -15368,7 +16462,9 @@ var DeviceMetaSchema = object({
|
|
|
15368
16462
|
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
15369
16463
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
15370
16464
|
* Optional: only present for accessory children that carry a known role. */
|
|
15371
|
-
role: string().nullable().optional()
|
|
16465
|
+
role: string().nullable().optional(),
|
|
16466
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
16467
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
15372
16468
|
});
|
|
15373
16469
|
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
15374
16470
|
var ConfigUISchemaOutput = unknown().nullable();
|
|
@@ -15462,7 +16558,19 @@ method(object({
|
|
|
15462
16558
|
}), _void(), {
|
|
15463
16559
|
kind: "mutation",
|
|
15464
16560
|
auth: "admin"
|
|
15465
|
-
}), method(object({
|
|
16561
|
+
}), method(object({
|
|
16562
|
+
deviceId: number(),
|
|
16563
|
+
display: DeviceDisplayOverrideSchema.nullable()
|
|
16564
|
+
}), _void(), {
|
|
16565
|
+
kind: "mutation",
|
|
16566
|
+
auth: "admin"
|
|
16567
|
+
}), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
|
|
16568
|
+
kind: "mutation",
|
|
16569
|
+
auth: "admin"
|
|
16570
|
+
}), method(object({
|
|
16571
|
+
deviceId: number(),
|
|
16572
|
+
includeSynthesizable: boolean().optional()
|
|
16573
|
+
}), object({ caps: array(object({
|
|
15466
16574
|
cap: string(),
|
|
15467
16575
|
fields: array(object({
|
|
15468
16576
|
path: string(),
|
|
@@ -15472,8 +16580,13 @@ method(object({
|
|
|
15472
16580
|
"boolean",
|
|
15473
16581
|
"enum"
|
|
15474
16582
|
]),
|
|
15475
|
-
enumValues: array(string()).optional()
|
|
15476
|
-
|
|
16583
|
+
enumValues: array(string()).optional(),
|
|
16584
|
+
item: boolean().optional()
|
|
16585
|
+
})).readonly(),
|
|
16586
|
+
itemArray: object({
|
|
16587
|
+
path: string(),
|
|
16588
|
+
keyField: string()
|
|
16589
|
+
}).optional()
|
|
15477
16590
|
})).readonly() }), { kind: "query" }), method(object({
|
|
15478
16591
|
deviceId: number(),
|
|
15479
16592
|
role: string().nullable()
|
|
@@ -15543,7 +16656,11 @@ method(object({
|
|
|
15543
16656
|
deviceId: number(),
|
|
15544
16657
|
entries: array(object({
|
|
15545
16658
|
capName: string(),
|
|
15546
|
-
kind: _enum([
|
|
16659
|
+
kind: _enum([
|
|
16660
|
+
"native",
|
|
16661
|
+
"wrapped",
|
|
16662
|
+
"linked"
|
|
16663
|
+
]),
|
|
15547
16664
|
providerAddonId: string(),
|
|
15548
16665
|
providerNodeId: string(),
|
|
15549
16666
|
nativeAddonId: string()
|
|
@@ -15552,7 +16669,11 @@ method(object({
|
|
|
15552
16669
|
deviceId: number(),
|
|
15553
16670
|
entries: array(object({
|
|
15554
16671
|
capName: string(),
|
|
15555
|
-
kind: _enum([
|
|
16672
|
+
kind: _enum([
|
|
16673
|
+
"native",
|
|
16674
|
+
"wrapped",
|
|
16675
|
+
"linked"
|
|
16676
|
+
]),
|
|
15556
16677
|
providerAddonId: string(),
|
|
15557
16678
|
providerNodeId: string(),
|
|
15558
16679
|
nativeAddonId: string()
|
|
@@ -16042,7 +17163,7 @@ var AddBrokerInputSchema = object({
|
|
|
16042
17163
|
});
|
|
16043
17164
|
var AddBrokerResultSchema = object({ id: string() });
|
|
16044
17165
|
var IdInputSchema = object({ id: string() });
|
|
16045
|
-
var TestResultSchema = discriminatedUnion("ok", [object({
|
|
17166
|
+
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
16046
17167
|
ok: literal(true),
|
|
16047
17168
|
latencyMs: number()
|
|
16048
17169
|
}), object({
|
|
@@ -16065,7 +17186,7 @@ var StatusSchema = object({
|
|
|
16065
17186
|
brokerCount: number(),
|
|
16066
17187
|
embeddedRunning: boolean()
|
|
16067
17188
|
});
|
|
16068
|
-
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);
|
|
17189
|
+
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);
|
|
16069
17190
|
var NetworkEndpointSchema = object({
|
|
16070
17191
|
url: string(),
|
|
16071
17192
|
hostname: string(),
|
|
@@ -16099,23 +17220,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
|
16099
17220
|
sourcePort: number().optional()
|
|
16100
17221
|
});
|
|
16101
17222
|
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
16102
|
-
|
|
16103
|
-
|
|
17223
|
+
/**
|
|
17224
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
17225
|
+
*
|
|
17226
|
+
* Apprise-derived model (see
|
|
17227
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
17228
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
17229
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
17230
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
17231
|
+
* message to what the kind supports — callers never special-case a service.
|
|
17232
|
+
*
|
|
17233
|
+
* DESIGN DECISIONS (locked):
|
|
17234
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
17235
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
17236
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
17237
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
17238
|
+
* alternative would fork the UI per addon and cannot host the
|
|
17239
|
+
* discovery→adopt flow.
|
|
17240
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
17241
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
17242
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
17243
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
17244
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
17245
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
17246
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
17247
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
17248
|
+
* base64 fallback needed.
|
|
17249
|
+
*
|
|
17250
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
17251
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
17252
|
+
* admin "Integrations" page.
|
|
17253
|
+
*/
|
|
17254
|
+
/**
|
|
17255
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
17256
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
17257
|
+
*/
|
|
17258
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
17259
|
+
"image",
|
|
17260
|
+
"video",
|
|
17261
|
+
"gif",
|
|
17262
|
+
"audio",
|
|
17263
|
+
"icon"
|
|
17264
|
+
]);
|
|
17265
|
+
/**
|
|
17266
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
17267
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
17268
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
17269
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
17270
|
+
*/
|
|
17271
|
+
var AttachmentSchema = object({
|
|
17272
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
17273
|
+
url: string().optional(),
|
|
17274
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
17275
|
+
mime: string().optional(),
|
|
17276
|
+
name: string().optional()
|
|
17277
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
17278
|
+
var NotificationFormatSchema = _enum([
|
|
17279
|
+
"text",
|
|
17280
|
+
"markdown",
|
|
17281
|
+
"html"
|
|
17282
|
+
]);
|
|
17283
|
+
/** A single tap-through action button. */
|
|
17284
|
+
var NotificationActionSchema = object({
|
|
17285
|
+
id: string(),
|
|
17286
|
+
label: string(),
|
|
17287
|
+
url: string().optional()
|
|
17288
|
+
});
|
|
17289
|
+
/**
|
|
17290
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
17291
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
17292
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
17293
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
17294
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
17295
|
+
* `priority` for that one target.
|
|
17296
|
+
*/
|
|
17297
|
+
var NotificationSchema = object({
|
|
16104
17298
|
body: string(),
|
|
16105
|
-
|
|
17299
|
+
title: string().optional(),
|
|
17300
|
+
format: NotificationFormatSchema.default("text"),
|
|
17301
|
+
priority: number().int().min(1).max(5).default(3),
|
|
17302
|
+
level: string().optional(),
|
|
17303
|
+
attachments: array(AttachmentSchema).optional(),
|
|
17304
|
+
clickUrl: string().optional(),
|
|
17305
|
+
actions: array(NotificationActionSchema).optional(),
|
|
17306
|
+
sound: string().optional(),
|
|
17307
|
+
ttl: number().optional(),
|
|
17308
|
+
tag: string().optional(),
|
|
16106
17309
|
deviceId: number().optional(),
|
|
16107
17310
|
eventId: string().optional(),
|
|
16108
|
-
priority: _enum([
|
|
16109
|
-
"low",
|
|
16110
|
-
"normal",
|
|
16111
|
-
"high",
|
|
16112
|
-
"critical"
|
|
16113
|
-
]).default("normal"),
|
|
16114
17311
|
metadata: record(string(), unknown()).optional()
|
|
16115
|
-
})
|
|
17312
|
+
});
|
|
17313
|
+
/** One declared native severity/priority level for a kind. */
|
|
17314
|
+
var TargetKindLevelSchema = object({
|
|
17315
|
+
id: string(),
|
|
17316
|
+
label: string(),
|
|
17317
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
17318
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
17319
|
+
flags: object({
|
|
17320
|
+
critical: boolean().optional(),
|
|
17321
|
+
silent: boolean().optional(),
|
|
17322
|
+
noPush: boolean().optional()
|
|
17323
|
+
}).optional(),
|
|
17324
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
17325
|
+
requires: array(string()).optional(),
|
|
17326
|
+
description: string().optional()
|
|
17327
|
+
});
|
|
17328
|
+
/** The full capability block consulted before dispatch. */
|
|
17329
|
+
var TargetKindCapsSchema = object({
|
|
17330
|
+
attachments: object({
|
|
17331
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
17332
|
+
mode: _enum([
|
|
17333
|
+
"url",
|
|
17334
|
+
"bytes",
|
|
17335
|
+
"both"
|
|
17336
|
+
]),
|
|
17337
|
+
max: number().int().nonnegative(),
|
|
17338
|
+
maxBytes: number().int().positive().optional()
|
|
17339
|
+
}),
|
|
17340
|
+
/** Max action buttons (0 = none). */
|
|
17341
|
+
actions: number().int().nonnegative(),
|
|
17342
|
+
levels: array(TargetKindLevelSchema),
|
|
17343
|
+
format: array(NotificationFormatSchema),
|
|
17344
|
+
clickUrl: boolean(),
|
|
17345
|
+
sound: boolean(),
|
|
17346
|
+
ttl: boolean(),
|
|
17347
|
+
bodyMaxLen: number().int().positive()
|
|
17348
|
+
});
|
|
17349
|
+
/**
|
|
17350
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
17351
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
17352
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
17353
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
17354
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
17355
|
+
*/
|
|
17356
|
+
var ConfigSchemaPassthrough = unknown();
|
|
17357
|
+
var TargetKindSchema = object({
|
|
17358
|
+
kind: string(),
|
|
17359
|
+
label: string(),
|
|
17360
|
+
icon: string(),
|
|
17361
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
17362
|
+
addonId: string(),
|
|
17363
|
+
configSchema: ConfigSchemaPassthrough,
|
|
17364
|
+
supportsDiscovery: boolean(),
|
|
17365
|
+
caps: TargetKindCapsSchema
|
|
17366
|
+
});
|
|
17367
|
+
/**
|
|
17368
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
17369
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
17370
|
+
* round-trip a stored secret to the UI.
|
|
17371
|
+
*/
|
|
17372
|
+
var TargetSchema = object({
|
|
17373
|
+
id: string(),
|
|
17374
|
+
name: string(),
|
|
17375
|
+
kind: string(),
|
|
17376
|
+
addonId: string(),
|
|
17377
|
+
enabled: boolean(),
|
|
17378
|
+
config: record(string(), unknown())
|
|
17379
|
+
});
|
|
17380
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
17381
|
+
var DiscoveredTargetSchema = object({
|
|
17382
|
+
kind: string(),
|
|
17383
|
+
suggestedName: string(),
|
|
17384
|
+
config: record(string(), unknown())
|
|
17385
|
+
});
|
|
17386
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
17387
|
+
var RenderedAsSchema = object({
|
|
17388
|
+
level: string(),
|
|
17389
|
+
format: NotificationFormatSchema,
|
|
17390
|
+
attachmentsSent: number().int().nonnegative(),
|
|
17391
|
+
actionsSent: number().int().nonnegative(),
|
|
17392
|
+
truncated: boolean(),
|
|
17393
|
+
dropped: array(string())
|
|
17394
|
+
});
|
|
17395
|
+
var SendResultSchema = object({
|
|
16116
17396
|
success: boolean(),
|
|
16117
|
-
error: string().optional()
|
|
16118
|
-
|
|
17397
|
+
error: string().optional(),
|
|
17398
|
+
renderedAs: RenderedAsSchema.optional()
|
|
17399
|
+
});
|
|
17400
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
17401
|
+
var TestResultSchema = SendResultSchema;
|
|
17402
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
|
|
17403
|
+
kind: string(),
|
|
17404
|
+
config: record(string(), unknown()).optional()
|
|
17405
|
+
}), array(DiscoveredTargetSchema)), method(object({
|
|
17406
|
+
targetId: string(),
|
|
17407
|
+
notification: NotificationSchema
|
|
17408
|
+
}), SendResultSchema, { kind: "mutation" }), method(object({
|
|
17409
|
+
targetId: string(),
|
|
17410
|
+
sample: NotificationSchema.optional()
|
|
17411
|
+
}), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
|
|
17412
|
+
targetId: string(),
|
|
17413
|
+
enabled: boolean()
|
|
17414
|
+
}), _void(), { kind: "mutation" });
|
|
16119
17415
|
/**
|
|
16120
17416
|
* Zod schemas for persisted record types.
|
|
16121
17417
|
*
|
|
@@ -19180,7 +20476,10 @@ var HwAccelBackendInputSchema = _enum([
|
|
|
19180
20476
|
"webgpu",
|
|
19181
20477
|
"none"
|
|
19182
20478
|
]).nullable().optional();
|
|
19183
|
-
var HwAccelResolutionSchema = object({
|
|
20479
|
+
var HwAccelResolutionSchema = object({
|
|
20480
|
+
preferred: array(string()).readonly(),
|
|
20481
|
+
rationale: string()
|
|
20482
|
+
});
|
|
19184
20483
|
var HardwareEncoderIdSchema = _enum([
|
|
19185
20484
|
"h264_videotoolbox",
|
|
19186
20485
|
"hevc_videotoolbox",
|
|
@@ -19285,10 +20584,7 @@ var ResolvedInferenceConfigSchema = object({
|
|
|
19285
20584
|
format: ModelFormatSchema,
|
|
19286
20585
|
reason: string()
|
|
19287
20586
|
});
|
|
19288
|
-
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
|
|
19289
|
-
prefer: HwAccelBackendInputSchema,
|
|
19290
|
-
nodeId: string().optional()
|
|
19291
|
-
}), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
20587
|
+
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
19292
20588
|
kind: "mutation",
|
|
19293
20589
|
auth: "admin"
|
|
19294
20590
|
}), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
|
|
@@ -19347,6 +20643,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
|
|
|
19347
20643
|
kind: "mutation",
|
|
19348
20644
|
auth: "admin"
|
|
19349
20645
|
});
|
|
20646
|
+
/**
|
|
20647
|
+
* `recording` cap — footage availability + HLS playback manifests + per-device
|
|
20648
|
+
* recording config. NOTE on events (source of truth, R5/C3): this cap carries
|
|
20649
|
+
* NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
|
|
20650
|
+
* events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
|
|
20651
|
+
* rows); the recorder's internal EventMap markers are ephemeral in-RAM
|
|
20652
|
+
* annotations that are not exposed here and must not be treated as an event
|
|
20653
|
+
* feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
|
|
20654
|
+
* (`interfaces/recording-config.ts`).
|
|
20655
|
+
*/
|
|
19350
20656
|
var RecordingStatusSchema = object({
|
|
19351
20657
|
deviceId: number(),
|
|
19352
20658
|
enabled: boolean(),
|
|
@@ -20996,6 +22302,12 @@ Object.freeze({
|
|
|
20996
22302
|
addonId: null,
|
|
20997
22303
|
access: "view"
|
|
20998
22304
|
},
|
|
22305
|
+
"deviceManager.getRoleDisplayDefaults": {
|
|
22306
|
+
capName: "device-manager",
|
|
22307
|
+
capScope: "system",
|
|
22308
|
+
addonId: null,
|
|
22309
|
+
access: "view"
|
|
22310
|
+
},
|
|
20999
22311
|
"deviceManager.getSettingsSchema": {
|
|
21000
22312
|
capName: "device-manager",
|
|
21001
22313
|
capScope: "system",
|
|
@@ -21146,6 +22458,12 @@ Object.freeze({
|
|
|
21146
22458
|
addonId: null,
|
|
21147
22459
|
access: "create"
|
|
21148
22460
|
},
|
|
22461
|
+
"deviceManager.setDisplay": {
|
|
22462
|
+
capName: "device-manager",
|
|
22463
|
+
capScope: "system",
|
|
22464
|
+
addonId: null,
|
|
22465
|
+
access: "create"
|
|
22466
|
+
},
|
|
21149
22467
|
"deviceManager.setIntegrationId": {
|
|
21150
22468
|
capName: "device-manager",
|
|
21151
22469
|
capScope: "system",
|
|
@@ -21188,6 +22506,12 @@ Object.freeze({
|
|
|
21188
22506
|
addonId: null,
|
|
21189
22507
|
access: "create"
|
|
21190
22508
|
},
|
|
22509
|
+
"deviceManager.setRoleDisplayDefaults": {
|
|
22510
|
+
capName: "device-manager",
|
|
22511
|
+
capScope: "system",
|
|
22512
|
+
addonId: null,
|
|
22513
|
+
access: "create"
|
|
22514
|
+
},
|
|
21191
22515
|
"deviceManager.setStreamProfileMap": {
|
|
21192
22516
|
capName: "device-manager",
|
|
21193
22517
|
capScope: "system",
|
|
@@ -22166,13 +23490,49 @@ Object.freeze({
|
|
|
22166
23490
|
addonId: null,
|
|
22167
23491
|
access: "create"
|
|
22168
23492
|
},
|
|
23493
|
+
"notificationOutput.deleteTarget": {
|
|
23494
|
+
capName: "notification-output",
|
|
23495
|
+
capScope: "system",
|
|
23496
|
+
addonId: null,
|
|
23497
|
+
access: "delete"
|
|
23498
|
+
},
|
|
23499
|
+
"notificationOutput.discoverTargets": {
|
|
23500
|
+
capName: "notification-output",
|
|
23501
|
+
capScope: "system",
|
|
23502
|
+
addonId: null,
|
|
23503
|
+
access: "view"
|
|
23504
|
+
},
|
|
23505
|
+
"notificationOutput.listTargetKinds": {
|
|
23506
|
+
capName: "notification-output",
|
|
23507
|
+
capScope: "system",
|
|
23508
|
+
addonId: null,
|
|
23509
|
+
access: "view"
|
|
23510
|
+
},
|
|
23511
|
+
"notificationOutput.listTargets": {
|
|
23512
|
+
capName: "notification-output",
|
|
23513
|
+
capScope: "system",
|
|
23514
|
+
addonId: null,
|
|
23515
|
+
access: "view"
|
|
23516
|
+
},
|
|
22169
23517
|
"notificationOutput.send": {
|
|
22170
23518
|
capName: "notification-output",
|
|
22171
23519
|
capScope: "system",
|
|
22172
23520
|
addonId: null,
|
|
22173
23521
|
access: "create"
|
|
22174
23522
|
},
|
|
22175
|
-
"notificationOutput.
|
|
23523
|
+
"notificationOutput.setTargetEnabled": {
|
|
23524
|
+
capName: "notification-output",
|
|
23525
|
+
capScope: "system",
|
|
23526
|
+
addonId: null,
|
|
23527
|
+
access: "create"
|
|
23528
|
+
},
|
|
23529
|
+
"notificationOutput.testTarget": {
|
|
23530
|
+
capName: "notification-output",
|
|
23531
|
+
capScope: "system",
|
|
23532
|
+
addonId: null,
|
|
23533
|
+
access: "create"
|
|
23534
|
+
},
|
|
23535
|
+
"notificationOutput.upsertTarget": {
|
|
22176
23536
|
capName: "notification-output",
|
|
22177
23537
|
capScope: "system",
|
|
22178
23538
|
addonId: null,
|
|
@@ -22202,6 +23562,66 @@ Object.freeze({
|
|
|
22202
23562
|
addonId: null,
|
|
22203
23563
|
access: "create"
|
|
22204
23564
|
},
|
|
23565
|
+
"petFeeder.callPet": {
|
|
23566
|
+
capName: "pet-feeder",
|
|
23567
|
+
capScope: "device",
|
|
23568
|
+
addonId: null,
|
|
23569
|
+
access: "create"
|
|
23570
|
+
},
|
|
23571
|
+
"petFeeder.cancelFeed": {
|
|
23572
|
+
capName: "pet-feeder",
|
|
23573
|
+
capScope: "device",
|
|
23574
|
+
addonId: null,
|
|
23575
|
+
access: "create"
|
|
23576
|
+
},
|
|
23577
|
+
"petFeeder.feed": {
|
|
23578
|
+
capName: "pet-feeder",
|
|
23579
|
+
capScope: "device",
|
|
23580
|
+
addonId: null,
|
|
23581
|
+
access: "create"
|
|
23582
|
+
},
|
|
23583
|
+
"petFeeder.markFoodReplenished": {
|
|
23584
|
+
capName: "pet-feeder",
|
|
23585
|
+
capScope: "device",
|
|
23586
|
+
addonId: null,
|
|
23587
|
+
access: "create"
|
|
23588
|
+
},
|
|
23589
|
+
"petFeeder.playSound": {
|
|
23590
|
+
capName: "pet-feeder",
|
|
23591
|
+
capScope: "device",
|
|
23592
|
+
addonId: null,
|
|
23593
|
+
access: "create"
|
|
23594
|
+
},
|
|
23595
|
+
"petFeeder.resetDesiccant": {
|
|
23596
|
+
capName: "pet-feeder",
|
|
23597
|
+
capScope: "device",
|
|
23598
|
+
addonId: null,
|
|
23599
|
+
access: "delete"
|
|
23600
|
+
},
|
|
23601
|
+
"petFeeder.setChildLock": {
|
|
23602
|
+
capName: "pet-feeder",
|
|
23603
|
+
capScope: "device",
|
|
23604
|
+
addonId: null,
|
|
23605
|
+
access: "create"
|
|
23606
|
+
},
|
|
23607
|
+
"petFeeder.setFeedSound": {
|
|
23608
|
+
capName: "pet-feeder",
|
|
23609
|
+
capScope: "device",
|
|
23610
|
+
addonId: null,
|
|
23611
|
+
access: "create"
|
|
23612
|
+
},
|
|
23613
|
+
"petFeeder.setIndicatorLight": {
|
|
23614
|
+
capName: "pet-feeder",
|
|
23615
|
+
capScope: "device",
|
|
23616
|
+
addonId: null,
|
|
23617
|
+
access: "create"
|
|
23618
|
+
},
|
|
23619
|
+
"petFeeder.setVolume": {
|
|
23620
|
+
capName: "pet-feeder",
|
|
23621
|
+
capScope: "device",
|
|
23622
|
+
addonId: null,
|
|
23623
|
+
access: "create"
|
|
23624
|
+
},
|
|
22205
23625
|
"pipelineAnalytics.clearTracks": {
|
|
22206
23626
|
capName: "pipeline-analytics",
|
|
22207
23627
|
capScope: "device",
|