@camstack/addon-export-alexa 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/export-alexa.addon.js +1380 -46
- package/dist/export-alexa.addon.mjs +1380 -46
- package/package.json +1 -1
|
@@ -4655,7 +4655,7 @@ function _instanceof(cls, params = {}) {
|
|
|
4655
4655
|
return inst;
|
|
4656
4656
|
}
|
|
4657
4657
|
//#endregion
|
|
4658
|
-
//#region ../types/dist/sleep-
|
|
4658
|
+
//#region ../types/dist/sleep-BiDFW0E7.mjs
|
|
4659
4659
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4660
4660
|
EventCategory["SystemBoot"] = "system.boot";
|
|
4661
4661
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -5468,6 +5468,100 @@ function createDurableState(deps) {
|
|
|
5468
5468
|
};
|
|
5469
5469
|
}
|
|
5470
5470
|
/**
|
|
5471
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
5472
|
+
*
|
|
5473
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
5474
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
5475
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
5476
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
5477
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
5478
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
5479
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
5480
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
5481
|
+
*
|
|
5482
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
5483
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
5484
|
+
* schema and routes reads/writes through these helpers.
|
|
5485
|
+
*
|
|
5486
|
+
* ## No bare-key fallback — deliberate
|
|
5487
|
+
*
|
|
5488
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
5489
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
5490
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
5491
|
+
* the store is invisible to every node, hub included, so one node's
|
|
5492
|
+
* selection can never leak onto another. (This generalizes the
|
|
5493
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
5494
|
+
* arbitrary set of per-node field keys.)
|
|
5495
|
+
*
|
|
5496
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
5497
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
5498
|
+
*/
|
|
5499
|
+
/**
|
|
5500
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
5501
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
5502
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
5503
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
5504
|
+
*/
|
|
5505
|
+
function normalizeNodeId(raw) {
|
|
5506
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
5507
|
+
const slashIdx = raw.indexOf("/");
|
|
5508
|
+
if (slashIdx < 0) return raw;
|
|
5509
|
+
const bare = raw.slice(0, slashIdx);
|
|
5510
|
+
return bare === "" ? "hub" : bare;
|
|
5511
|
+
}
|
|
5512
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
5513
|
+
function nodeScopedKey(base, nodeId) {
|
|
5514
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
5515
|
+
}
|
|
5516
|
+
/**
|
|
5517
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
5518
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
5519
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
5520
|
+
* schema `default` win on `undefined`.
|
|
5521
|
+
*/
|
|
5522
|
+
function readNodeValue(store, base, nodeId) {
|
|
5523
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
5524
|
+
}
|
|
5525
|
+
/**
|
|
5526
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
5527
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
5528
|
+
* the write path so a save for one node never clobbers another node's value
|
|
5529
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
5530
|
+
* patch is not mutated.
|
|
5531
|
+
*/
|
|
5532
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
5533
|
+
const out = {};
|
|
5534
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
5535
|
+
return out;
|
|
5536
|
+
}
|
|
5537
|
+
/**
|
|
5538
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
5539
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
5540
|
+
* values:
|
|
5541
|
+
*
|
|
5542
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
5543
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
5544
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
5545
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
5546
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
5547
|
+
* left ABSENT so the field's schema `default` wins.
|
|
5548
|
+
*
|
|
5549
|
+
* Returns a new object — the input store is not mutated.
|
|
5550
|
+
*/
|
|
5551
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
5552
|
+
const out = {};
|
|
5553
|
+
for (const [key, value] of Object.entries(store)) {
|
|
5554
|
+
if (key.includes("@")) continue;
|
|
5555
|
+
if (perNodeKeys.has(key)) continue;
|
|
5556
|
+
out[key] = value;
|
|
5557
|
+
}
|
|
5558
|
+
for (const base of perNodeKeys) {
|
|
5559
|
+
const value = readNodeValue(store, base, nodeId);
|
|
5560
|
+
if (value !== void 0) out[base] = value;
|
|
5561
|
+
}
|
|
5562
|
+
return out;
|
|
5563
|
+
}
|
|
5564
|
+
/**
|
|
5471
5565
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5472
5566
|
*
|
|
5473
5567
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -5635,23 +5729,63 @@ var BaseAddon = class {
|
|
|
5635
5729
|
deviceSettingsSchema() {
|
|
5636
5730
|
return null;
|
|
5637
5731
|
}
|
|
5638
|
-
async getGlobalSettings(overlay, cap,
|
|
5732
|
+
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5639
5733
|
const schema = this.globalSettingsSchema(cap);
|
|
5640
5734
|
if (!schema) return { sections: [] };
|
|
5641
|
-
const
|
|
5735
|
+
const projected = await this.resolveGlobalStore(nodeId, cap);
|
|
5642
5736
|
return hydrateSchema(schema, overlay ? {
|
|
5643
|
-
...
|
|
5737
|
+
...projected,
|
|
5644
5738
|
...overlay
|
|
5645
|
-
} :
|
|
5739
|
+
} : projected);
|
|
5646
5740
|
}
|
|
5647
|
-
|
|
5648
|
-
|
|
5741
|
+
/**
|
|
5742
|
+
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5743
|
+
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5744
|
+
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
5745
|
+
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
5746
|
+
* A no-op passthrough when the schema declares no `perNode` field.
|
|
5747
|
+
*
|
|
5748
|
+
* This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
|
|
5749
|
+
* the store for custom option logic (option narrowing, value snapping) to
|
|
5750
|
+
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
5751
|
+
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
5752
|
+
*/
|
|
5753
|
+
async resolveGlobalStore(nodeId, cap) {
|
|
5754
|
+
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
5755
|
+
const keys = this.perNodeKeys(cap);
|
|
5756
|
+
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5757
|
+
return keys.size > 0 ? projectStore(raw, keys, node) : raw;
|
|
5758
|
+
}
|
|
5759
|
+
async updateGlobalSettings(patch, nodeId) {
|
|
5760
|
+
const keys = this.perNodeKeys();
|
|
5761
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5762
|
+
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5763
|
+
const barePatch = patch;
|
|
5764
|
+
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
5765
|
+
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
5766
|
+
if (target !== localNode) return;
|
|
5649
5767
|
await this.resolveConfig();
|
|
5650
5768
|
await this.onConfigChanged();
|
|
5651
5769
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
5652
5770
|
this.maybeAutoRestart(patch, this.globalSettingsSchema());
|
|
5653
5771
|
}
|
|
5654
5772
|
/**
|
|
5773
|
+
* The set of field keys the global settings schema declares `perNode: true`
|
|
5774
|
+
* — derived once per `cap` argument and memoized (schemas are static
|
|
5775
|
+
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
5776
|
+
* settings API behaves exactly like the legacy node-agnostic one.
|
|
5777
|
+
*/
|
|
5778
|
+
_perNodeKeysCache = /* @__PURE__ */ new Map();
|
|
5779
|
+
perNodeKeys(cap) {
|
|
5780
|
+
const cacheKey = cap ?? "";
|
|
5781
|
+
const cached = this._perNodeKeysCache.get(cacheKey);
|
|
5782
|
+
if (cached) return cached;
|
|
5783
|
+
const schema = this.globalSettingsSchema(cap);
|
|
5784
|
+
const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
5785
|
+
this._perNodeKeysCache.set(cacheKey, keys);
|
|
5786
|
+
return keys;
|
|
5787
|
+
}
|
|
5788
|
+
/**
|
|
5655
5789
|
* If any field in `patch` is marked `requiresRestart` in `schema`,
|
|
5656
5790
|
* schedule an addon restart for the next tick. Deferred via
|
|
5657
5791
|
* `setImmediate` so the tRPC mutation that triggered the write has
|
|
@@ -5804,12 +5938,19 @@ var BaseAddon = class {
|
|
|
5804
5938
|
* The merge is shallow: each key in `defaults` is checked against the store.
|
|
5805
5939
|
* Only keys present in defaults are read — the store can contain extra keys
|
|
5806
5940
|
* (e.g. from older versions) without polluting the typed config.
|
|
5941
|
+
*
|
|
5942
|
+
* Keys the global settings schema declares `perNode: true` resolve from
|
|
5943
|
+
* THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
|
|
5944
|
+
* from the bare key — so a per-node field resolves to this node's own
|
|
5945
|
+
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
5807
5946
|
*/
|
|
5808
5947
|
async resolveConfig() {
|
|
5809
5948
|
const stored = await this.readAddonStoreWithRetry();
|
|
5949
|
+
const perNode = this.perNodeKeys();
|
|
5950
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5810
5951
|
const resolved = { ...this.defaults };
|
|
5811
5952
|
for (const key of Object.keys(this.defaults)) {
|
|
5812
|
-
const storedValue = stored[key];
|
|
5953
|
+
const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
|
|
5813
5954
|
if (storedValue !== void 0 && storedValue !== null) {
|
|
5814
5955
|
const defaultType = typeof this.defaults[key];
|
|
5815
5956
|
if (typeof storedValue === defaultType) resolved[key] = storedValue;
|
|
@@ -5893,6 +6034,27 @@ var BaseAddon = class {
|
|
|
5893
6034
|
}
|
|
5894
6035
|
};
|
|
5895
6036
|
/**
|
|
6037
|
+
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
6038
|
+
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
6039
|
+
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6040
|
+
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6041
|
+
*/
|
|
6042
|
+
function collectPerNodeFieldKeys(fields) {
|
|
6043
|
+
const collected = [];
|
|
6044
|
+
for (const field of fields) {
|
|
6045
|
+
if (field.type === "group") {
|
|
6046
|
+
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
6047
|
+
continue;
|
|
6048
|
+
}
|
|
6049
|
+
if (field.type === "sub-tabs") {
|
|
6050
|
+
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
6051
|
+
continue;
|
|
6052
|
+
}
|
|
6053
|
+
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
6054
|
+
}
|
|
6055
|
+
return collected;
|
|
6056
|
+
}
|
|
6057
|
+
/**
|
|
5896
6058
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
5897
6059
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
5898
6060
|
* envelopes pass through; void stays void.
|
|
@@ -5917,6 +6079,7 @@ var CamStreamKindSchema = _enum([
|
|
|
5917
6079
|
"pull-rtsp",
|
|
5918
6080
|
"pull-rtmp",
|
|
5919
6081
|
"pull-http",
|
|
6082
|
+
"pull-flv",
|
|
5920
6083
|
"pull-rfc4571",
|
|
5921
6084
|
"push-annexb",
|
|
5922
6085
|
"derived"
|
|
@@ -6310,6 +6473,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
6310
6473
|
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
6311
6474
|
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
6312
6475
|
DeviceType["Image"] = "image";
|
|
6476
|
+
/** Smart pet feeder — cloud-connected food dispenser with a bowl food
|
|
6477
|
+
* level, battery, desiccant life, feeding state and manual-feed /
|
|
6478
|
+
* call-pet / maintenance actions. Installed with the `pet-feeder` cap;
|
|
6479
|
+
* dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
|
|
6480
|
+
* native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
|
|
6481
|
+
* integrations sharing the same food/desiccant/hopper surface. */
|
|
6482
|
+
DeviceType["PetFeeder"] = "pet-feeder";
|
|
6313
6483
|
return DeviceType;
|
|
6314
6484
|
}({});
|
|
6315
6485
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -7200,7 +7370,21 @@ var StorageLocationDeclarationSchema = object({
|
|
|
7200
7370
|
* slots (e.g. `recordingsLow` → `recordings`) so operators only need to
|
|
7201
7371
|
* configure the primary location.
|
|
7202
7372
|
*/
|
|
7203
|
-
defaultsTo: string().optional()
|
|
7373
|
+
defaultsTo: string().optional(),
|
|
7374
|
+
/**
|
|
7375
|
+
* Which node root the seeded `<id>:default` instance is placed under on a
|
|
7376
|
+
* FRESH install:
|
|
7377
|
+
* - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
|
|
7378
|
+
* the appData volume. Right for small/durable data (backups, logs, models).
|
|
7379
|
+
* - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
|
|
7380
|
+
* env is set, else falls back to the data root. Right for bulky, hot media
|
|
7381
|
+
* (recordings, event media) that should stay off the appData disk.
|
|
7382
|
+
*
|
|
7383
|
+
* Only affects the seeded default's `basePath`; operators can repoint any
|
|
7384
|
+
* location afterwards, and a `defaultsTo` slot inherits its parent's root
|
|
7385
|
+
* regardless of this field. Absent (the common case) is treated as `'data'`.
|
|
7386
|
+
*/
|
|
7387
|
+
defaultRoot: _enum(["data", "media"]).optional()
|
|
7204
7388
|
});
|
|
7205
7389
|
var DecoderStatsSchema = object({
|
|
7206
7390
|
inputFps: number(),
|
|
@@ -7627,6 +7811,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
|
|
|
7627
7811
|
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7628
7812
|
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7629
7813
|
/**
|
|
7814
|
+
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7815
|
+
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
7816
|
+
* failure — both are non-fatal to the host: read paths degrade to "skip link".
|
|
7817
|
+
*/
|
|
7818
|
+
/** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
|
|
7819
|
+
* the failure is anchored to a character (author-facing inline feedback). */
|
|
7820
|
+
var ExpressionParseError = class extends Error {
|
|
7821
|
+
position;
|
|
7822
|
+
constructor(message, position) {
|
|
7823
|
+
super(message);
|
|
7824
|
+
this.name = "ExpressionParseError";
|
|
7825
|
+
this.position = position;
|
|
7826
|
+
}
|
|
7827
|
+
};
|
|
7828
|
+
/** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
|
|
7829
|
+
* result, unknown builtin, step-budget exceeded). */
|
|
7830
|
+
var ExpressionEvalError = class extends Error {
|
|
7831
|
+
constructor(message) {
|
|
7832
|
+
super(message);
|
|
7833
|
+
this.name = "ExpressionEvalError";
|
|
7834
|
+
}
|
|
7835
|
+
};
|
|
7836
|
+
/**
|
|
7837
|
+
* Resource-bound constants for the safe expression engine.
|
|
7838
|
+
*
|
|
7839
|
+
* Every bound is defense-in-depth: the grammar is non-Turing-complete (no
|
|
7840
|
+
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
7841
|
+
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
7842
|
+
* work a single author-supplied expression can request, so a hostile or
|
|
7843
|
+
* accidental pathological string can never spend unbounded CPU/memory.
|
|
7844
|
+
*/
|
|
7845
|
+
/** Max source length (chars) — checked BEFORE tokenizing so a huge string is
|
|
7846
|
+
* rejected without allocation. */
|
|
7847
|
+
var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
|
|
7848
|
+
/** A legal binding / identifier name. */
|
|
7849
|
+
var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7850
|
+
/** Binding names an author may NOT use: `now` is auto-injected; the literal
|
|
7851
|
+
* keywords lex as values, not identifiers, so binding to them is meaningless. */
|
|
7852
|
+
var RESERVED_BINDING_NAMES = new Set([
|
|
7853
|
+
"now",
|
|
7854
|
+
"true",
|
|
7855
|
+
"false",
|
|
7856
|
+
"null"
|
|
7857
|
+
]);
|
|
7858
|
+
/**
|
|
7859
|
+
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
7860
|
+
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
7861
|
+
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
7862
|
+
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
7863
|
+
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
7864
|
+
* is a parse error with a source position, so member access / assignment /
|
|
7865
|
+
* template literals are lexically impossible.
|
|
7866
|
+
*/
|
|
7867
|
+
var KEYWORDS = new Set([
|
|
7868
|
+
"true",
|
|
7869
|
+
"false",
|
|
7870
|
+
"null"
|
|
7871
|
+
]);
|
|
7872
|
+
function isDigit(ch) {
|
|
7873
|
+
return ch >= "0" && ch <= "9";
|
|
7874
|
+
}
|
|
7875
|
+
function isIdentStart(ch) {
|
|
7876
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
7877
|
+
}
|
|
7878
|
+
function isIdentPart(ch) {
|
|
7879
|
+
return isIdentStart(ch) || isDigit(ch);
|
|
7880
|
+
}
|
|
7881
|
+
function isWhitespace(ch) {
|
|
7882
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
7883
|
+
}
|
|
7884
|
+
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
7885
|
+
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
7886
|
+
* string. */
|
|
7887
|
+
function tokenize(source) {
|
|
7888
|
+
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
7889
|
+
const tokens = [];
|
|
7890
|
+
let i = 0;
|
|
7891
|
+
const n = source.length;
|
|
7892
|
+
while (i < n) {
|
|
7893
|
+
const ch = source[i];
|
|
7894
|
+
if (isWhitespace(ch)) {
|
|
7895
|
+
i += 1;
|
|
7896
|
+
continue;
|
|
7897
|
+
}
|
|
7898
|
+
if (isDigit(ch)) {
|
|
7899
|
+
const start = i;
|
|
7900
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7901
|
+
if (i < n && source[i] === ".") {
|
|
7902
|
+
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
7903
|
+
i += 1;
|
|
7904
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7905
|
+
}
|
|
7906
|
+
const text = source.slice(start, i);
|
|
7907
|
+
const value = Number(text);
|
|
7908
|
+
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
7909
|
+
tokens.push({
|
|
7910
|
+
type: "number",
|
|
7911
|
+
value,
|
|
7912
|
+
pos: start
|
|
7913
|
+
});
|
|
7914
|
+
continue;
|
|
7915
|
+
}
|
|
7916
|
+
if (ch === "'" || ch === "\"") {
|
|
7917
|
+
const quote = ch;
|
|
7918
|
+
const start = i;
|
|
7919
|
+
i += 1;
|
|
7920
|
+
let out = "";
|
|
7921
|
+
let closed = false;
|
|
7922
|
+
while (i < n) {
|
|
7923
|
+
const c = source[i];
|
|
7924
|
+
if (c === "\\") {
|
|
7925
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
7926
|
+
if (next === "\\" || next === "'" || next === "\"") {
|
|
7927
|
+
out += next;
|
|
7928
|
+
i += 2;
|
|
7929
|
+
continue;
|
|
7930
|
+
}
|
|
7931
|
+
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
7932
|
+
}
|
|
7933
|
+
if (c === quote) {
|
|
7934
|
+
closed = true;
|
|
7935
|
+
i += 1;
|
|
7936
|
+
break;
|
|
7937
|
+
}
|
|
7938
|
+
out += c;
|
|
7939
|
+
i += 1;
|
|
7940
|
+
}
|
|
7941
|
+
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
7942
|
+
tokens.push({
|
|
7943
|
+
type: "string",
|
|
7944
|
+
value: out,
|
|
7945
|
+
pos: start
|
|
7946
|
+
});
|
|
7947
|
+
continue;
|
|
7948
|
+
}
|
|
7949
|
+
if (isIdentStart(ch)) {
|
|
7950
|
+
const start = i;
|
|
7951
|
+
while (i < n && isIdentPart(source[i])) i += 1;
|
|
7952
|
+
const text = source.slice(start, i);
|
|
7953
|
+
if (KEYWORDS.has(text)) tokens.push({
|
|
7954
|
+
type: "keyword",
|
|
7955
|
+
keyword: keywordOf(text),
|
|
7956
|
+
pos: start
|
|
7957
|
+
});
|
|
7958
|
+
else tokens.push({
|
|
7959
|
+
type: "identifier",
|
|
7960
|
+
name: text,
|
|
7961
|
+
pos: start
|
|
7962
|
+
});
|
|
7963
|
+
continue;
|
|
7964
|
+
}
|
|
7965
|
+
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
7966
|
+
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
7967
|
+
tokens.push({
|
|
7968
|
+
type: "punct",
|
|
7969
|
+
punct: two,
|
|
7970
|
+
pos: i
|
|
7971
|
+
});
|
|
7972
|
+
i += 2;
|
|
7973
|
+
continue;
|
|
7974
|
+
}
|
|
7975
|
+
if (isSinglePunct(ch)) {
|
|
7976
|
+
tokens.push({
|
|
7977
|
+
type: "punct",
|
|
7978
|
+
punct: ch,
|
|
7979
|
+
pos: i
|
|
7980
|
+
});
|
|
7981
|
+
i += 1;
|
|
7982
|
+
continue;
|
|
7983
|
+
}
|
|
7984
|
+
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
7985
|
+
}
|
|
7986
|
+
tokens.push({
|
|
7987
|
+
type: "eof",
|
|
7988
|
+
pos: n
|
|
7989
|
+
});
|
|
7990
|
+
return tokens;
|
|
7991
|
+
}
|
|
7992
|
+
function keywordOf(text) {
|
|
7993
|
+
if (text === "true") return "true";
|
|
7994
|
+
if (text === "false") return "false";
|
|
7995
|
+
return "null";
|
|
7996
|
+
}
|
|
7997
|
+
function isSinglePunct(ch) {
|
|
7998
|
+
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
7999
|
+
}
|
|
8000
|
+
/**
|
|
8001
|
+
* Frozen, null-prototype builtin function table for the expression engine
|
|
8002
|
+
* (spec §4 rule 4). The table is the SOLE surface of callable functions: the
|
|
8003
|
+
* parser rejects any callee not in it, and the evaluator gates each call on an
|
|
8004
|
+
* own-property check against it.
|
|
8005
|
+
*
|
|
8006
|
+
* Because the object has a NULL prototype AND is `Object.freeze`d:
|
|
8007
|
+
* - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
|
|
8008
|
+
* - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
|
|
8009
|
+
* (there is no `Object.prototype` in the chain), so those names are not
|
|
8010
|
+
* callable — they are simply "unknown function" at parse time.
|
|
8011
|
+
*
|
|
8012
|
+
* Every numeric argument is validated as a finite number and every numeric
|
|
8013
|
+
* RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
|
|
8014
|
+
* (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
|
|
8015
|
+
* closed rather than emitting a garbage value.
|
|
8016
|
+
*/
|
|
8017
|
+
function asFiniteNumber(value, name, index) {
|
|
8018
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
8019
|
+
return value;
|
|
8020
|
+
}
|
|
8021
|
+
function asString$1(value, name, index) {
|
|
8022
|
+
if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
|
|
8023
|
+
return value;
|
|
8024
|
+
}
|
|
8025
|
+
function finiteResult(value, name) {
|
|
8026
|
+
if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
|
|
8027
|
+
return value;
|
|
8028
|
+
}
|
|
8029
|
+
function allFiniteNumbers(args, name) {
|
|
8030
|
+
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
8031
|
+
}
|
|
8032
|
+
var INF = Number.POSITIVE_INFINITY;
|
|
8033
|
+
var table = {
|
|
8034
|
+
min: {
|
|
8035
|
+
minArgs: 1,
|
|
8036
|
+
maxArgs: INF,
|
|
8037
|
+
apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
|
|
8038
|
+
},
|
|
8039
|
+
max: {
|
|
8040
|
+
minArgs: 1,
|
|
8041
|
+
maxArgs: INF,
|
|
8042
|
+
apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
|
|
8043
|
+
},
|
|
8044
|
+
abs: {
|
|
8045
|
+
minArgs: 1,
|
|
8046
|
+
maxArgs: 1,
|
|
8047
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
8048
|
+
},
|
|
8049
|
+
floor: {
|
|
8050
|
+
minArgs: 1,
|
|
8051
|
+
maxArgs: 1,
|
|
8052
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
8053
|
+
},
|
|
8054
|
+
ceil: {
|
|
8055
|
+
minArgs: 1,
|
|
8056
|
+
maxArgs: 1,
|
|
8057
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
8058
|
+
},
|
|
8059
|
+
sqrt: {
|
|
8060
|
+
minArgs: 1,
|
|
8061
|
+
maxArgs: 1,
|
|
8062
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
8063
|
+
},
|
|
8064
|
+
round: {
|
|
8065
|
+
minArgs: 1,
|
|
8066
|
+
maxArgs: 2,
|
|
8067
|
+
apply: (args) => {
|
|
8068
|
+
const x = asFiniteNumber(args[0], "round", 0);
|
|
8069
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
8070
|
+
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
8071
|
+
const factor = 10 ** digits;
|
|
8072
|
+
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
8073
|
+
}
|
|
8074
|
+
},
|
|
8075
|
+
pow: {
|
|
8076
|
+
minArgs: 2,
|
|
8077
|
+
maxArgs: 2,
|
|
8078
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
8079
|
+
},
|
|
8080
|
+
clamp: {
|
|
8081
|
+
minArgs: 3,
|
|
8082
|
+
maxArgs: 3,
|
|
8083
|
+
apply: (args) => {
|
|
8084
|
+
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
8085
|
+
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
8086
|
+
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
8087
|
+
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
8088
|
+
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
8089
|
+
}
|
|
8090
|
+
},
|
|
8091
|
+
avg: {
|
|
8092
|
+
minArgs: 1,
|
|
8093
|
+
maxArgs: INF,
|
|
8094
|
+
apply: (args) => {
|
|
8095
|
+
const nums = allFiniteNumbers(args, "avg");
|
|
8096
|
+
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
8097
|
+
}
|
|
8098
|
+
},
|
|
8099
|
+
sum: {
|
|
8100
|
+
minArgs: 1,
|
|
8101
|
+
maxArgs: INF,
|
|
8102
|
+
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
8103
|
+
},
|
|
8104
|
+
coalesce: {
|
|
8105
|
+
minArgs: 1,
|
|
8106
|
+
maxArgs: INF,
|
|
8107
|
+
apply: (args) => {
|
|
8108
|
+
for (const a of args) if (a !== null) return a;
|
|
8109
|
+
return null;
|
|
8110
|
+
}
|
|
8111
|
+
},
|
|
8112
|
+
age: {
|
|
8113
|
+
minArgs: 2,
|
|
8114
|
+
maxArgs: 2,
|
|
8115
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
8116
|
+
},
|
|
8117
|
+
convert: {
|
|
8118
|
+
minArgs: 3,
|
|
8119
|
+
maxArgs: 3,
|
|
8120
|
+
apply: (args, hooks) => {
|
|
8121
|
+
const x = asFiniteNumber(args[0], "convert", 0);
|
|
8122
|
+
const from = asString$1(args[1], "convert", 1).trim();
|
|
8123
|
+
const to = asString$1(args[2], "convert", 2).trim();
|
|
8124
|
+
if (hooks.convert) {
|
|
8125
|
+
const out = hooks.convert(x, from, to);
|
|
8126
|
+
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
8127
|
+
return finiteResult(out, "convert");
|
|
8128
|
+
}
|
|
8129
|
+
if (from === to) return x;
|
|
8130
|
+
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
8131
|
+
}
|
|
8132
|
+
}
|
|
8133
|
+
};
|
|
8134
|
+
Object.freeze(Object.assign(Object.create(null), table));
|
|
8135
|
+
/** The set of valid builtin names — used by the parser to reject unknown
|
|
8136
|
+
* callees at parse time (immediate author feedback). */
|
|
8137
|
+
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
8138
|
+
/**
|
|
8139
|
+
* Pratt (precedence-climbing) parser for the safe expression mini-language.
|
|
8140
|
+
*
|
|
8141
|
+
* Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
|
|
8142
|
+
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
8143
|
+
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
8144
|
+
* string validated against the builtin table at parse time, so an unknown
|
|
8145
|
+
* function is rejected immediately (author feedback) and a persisted expression
|
|
8146
|
+
* that references a since-removed builtin degrades at read.
|
|
8147
|
+
*
|
|
8148
|
+
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
8149
|
+
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
8150
|
+
*/
|
|
8151
|
+
/** Binary/logical operator precedence (higher binds tighter). */
|
|
8152
|
+
var BINARY_PRECEDENCE = {
|
|
8153
|
+
"||": 1,
|
|
8154
|
+
"&&": 2,
|
|
8155
|
+
"==": 3,
|
|
8156
|
+
"!=": 3,
|
|
8157
|
+
"<": 4,
|
|
8158
|
+
"<=": 4,
|
|
8159
|
+
">": 4,
|
|
8160
|
+
">=": 4,
|
|
8161
|
+
"+": 5,
|
|
8162
|
+
"-": 5,
|
|
8163
|
+
"*": 6,
|
|
8164
|
+
"/": 6,
|
|
8165
|
+
"%": 6
|
|
8166
|
+
};
|
|
8167
|
+
function isLogicalOp(op) {
|
|
8168
|
+
return op === "&&" || op === "||";
|
|
8169
|
+
}
|
|
8170
|
+
function isBinaryOp(op) {
|
|
8171
|
+
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
8172
|
+
}
|
|
8173
|
+
var Parser = class {
|
|
8174
|
+
tokens;
|
|
8175
|
+
pos = 0;
|
|
8176
|
+
nodeCount = 0;
|
|
8177
|
+
identifiers = /* @__PURE__ */ new Set();
|
|
8178
|
+
callees = /* @__PURE__ */ new Set();
|
|
8179
|
+
constructor(tokens) {
|
|
8180
|
+
this.tokens = tokens;
|
|
8181
|
+
}
|
|
8182
|
+
parse() {
|
|
8183
|
+
const ast = this.parseTernary();
|
|
8184
|
+
const tok = this.peek();
|
|
8185
|
+
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
8186
|
+
return {
|
|
8187
|
+
ast,
|
|
8188
|
+
identifiers: this.identifiers,
|
|
8189
|
+
callees: this.callees,
|
|
8190
|
+
nodeCount: this.nodeCount
|
|
8191
|
+
};
|
|
8192
|
+
}
|
|
8193
|
+
peek() {
|
|
8194
|
+
return this.tokens[this.pos];
|
|
8195
|
+
}
|
|
8196
|
+
next() {
|
|
8197
|
+
return this.tokens[this.pos++];
|
|
8198
|
+
}
|
|
8199
|
+
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
8200
|
+
expectPunct(punct) {
|
|
8201
|
+
const tok = this.peek();
|
|
8202
|
+
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
8203
|
+
this.pos += 1;
|
|
8204
|
+
}
|
|
8205
|
+
matchPunct(punct) {
|
|
8206
|
+
const tok = this.peek();
|
|
8207
|
+
if (tok.type === "punct" && tok.punct === punct) {
|
|
8208
|
+
this.pos += 1;
|
|
8209
|
+
return true;
|
|
8210
|
+
}
|
|
8211
|
+
return false;
|
|
8212
|
+
}
|
|
8213
|
+
countNode() {
|
|
8214
|
+
this.nodeCount += 1;
|
|
8215
|
+
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
8216
|
+
}
|
|
8217
|
+
parseTernary() {
|
|
8218
|
+
const test = this.parseBinary(1);
|
|
8219
|
+
if (this.matchPunct("?")) {
|
|
8220
|
+
const consequent = this.parseTernary();
|
|
8221
|
+
this.expectPunct(":");
|
|
8222
|
+
const alternate = this.parseTernary();
|
|
8223
|
+
this.countNode();
|
|
8224
|
+
return {
|
|
8225
|
+
kind: "conditional",
|
|
8226
|
+
test,
|
|
8227
|
+
consequent,
|
|
8228
|
+
alternate
|
|
8229
|
+
};
|
|
8230
|
+
}
|
|
8231
|
+
return test;
|
|
8232
|
+
}
|
|
8233
|
+
parseBinary(minPrec) {
|
|
8234
|
+
let left = this.parseUnary();
|
|
8235
|
+
for (;;) {
|
|
8236
|
+
const tok = this.peek();
|
|
8237
|
+
if (tok.type !== "punct") break;
|
|
8238
|
+
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
8239
|
+
if (prec === void 0 || prec < minPrec) break;
|
|
8240
|
+
const op = tok.punct;
|
|
8241
|
+
this.pos += 1;
|
|
8242
|
+
const right = this.parseBinary(prec + 1);
|
|
8243
|
+
this.countNode();
|
|
8244
|
+
if (isLogicalOp(op)) left = {
|
|
8245
|
+
kind: "logical",
|
|
8246
|
+
op,
|
|
8247
|
+
left,
|
|
8248
|
+
right
|
|
8249
|
+
};
|
|
8250
|
+
else if (isBinaryOp(op)) left = {
|
|
8251
|
+
kind: "binary",
|
|
8252
|
+
op,
|
|
8253
|
+
left,
|
|
8254
|
+
right
|
|
8255
|
+
};
|
|
8256
|
+
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
8257
|
+
}
|
|
8258
|
+
return left;
|
|
8259
|
+
}
|
|
8260
|
+
parseUnary() {
|
|
8261
|
+
const tok = this.peek();
|
|
8262
|
+
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
8263
|
+
const op = tok.punct;
|
|
8264
|
+
this.pos += 1;
|
|
8265
|
+
const operand = this.parseUnary();
|
|
8266
|
+
this.countNode();
|
|
8267
|
+
return {
|
|
8268
|
+
kind: "unary",
|
|
8269
|
+
op,
|
|
8270
|
+
operand
|
|
8271
|
+
};
|
|
8272
|
+
}
|
|
8273
|
+
return this.parsePrimary();
|
|
8274
|
+
}
|
|
8275
|
+
parsePrimary() {
|
|
8276
|
+
const tok = this.next();
|
|
8277
|
+
switch (tok.type) {
|
|
8278
|
+
case "number":
|
|
8279
|
+
this.countNode();
|
|
8280
|
+
return {
|
|
8281
|
+
kind: "literal",
|
|
8282
|
+
value: tok.value
|
|
8283
|
+
};
|
|
8284
|
+
case "string":
|
|
8285
|
+
this.countNode();
|
|
8286
|
+
return {
|
|
8287
|
+
kind: "literal",
|
|
8288
|
+
value: tok.value
|
|
8289
|
+
};
|
|
8290
|
+
case "keyword":
|
|
8291
|
+
this.countNode();
|
|
8292
|
+
return {
|
|
8293
|
+
kind: "literal",
|
|
8294
|
+
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
8295
|
+
};
|
|
8296
|
+
case "identifier": {
|
|
8297
|
+
const nextTok = this.peek();
|
|
8298
|
+
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
8299
|
+
this.identifiers.add(tok.name);
|
|
8300
|
+
this.countNode();
|
|
8301
|
+
return {
|
|
8302
|
+
kind: "identifier",
|
|
8303
|
+
name: tok.name
|
|
8304
|
+
};
|
|
8305
|
+
}
|
|
8306
|
+
case "punct":
|
|
8307
|
+
if (tok.punct === "(") {
|
|
8308
|
+
const inner = this.parseTernary();
|
|
8309
|
+
this.expectPunct(")");
|
|
8310
|
+
return inner;
|
|
8311
|
+
}
|
|
8312
|
+
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
8313
|
+
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
8314
|
+
}
|
|
8315
|
+
}
|
|
8316
|
+
parseCall(callee, pos) {
|
|
8317
|
+
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
8318
|
+
this.expectPunct("(");
|
|
8319
|
+
const args = [];
|
|
8320
|
+
if (!this.matchPunct(")")) for (;;) {
|
|
8321
|
+
args.push(this.parseTernary());
|
|
8322
|
+
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
8323
|
+
if (this.matchPunct(",")) continue;
|
|
8324
|
+
this.expectPunct(")");
|
|
8325
|
+
break;
|
|
8326
|
+
}
|
|
8327
|
+
this.callees.add(callee);
|
|
8328
|
+
this.countNode();
|
|
8329
|
+
return {
|
|
8330
|
+
kind: "call",
|
|
8331
|
+
callee,
|
|
8332
|
+
args
|
|
8333
|
+
};
|
|
8334
|
+
}
|
|
8335
|
+
};
|
|
8336
|
+
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
8337
|
+
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
8338
|
+
function parseExpression(source) {
|
|
8339
|
+
return new Parser(tokenize(source)).parse();
|
|
8340
|
+
}
|
|
8341
|
+
Object.freeze({});
|
|
8342
|
+
/**
|
|
8343
|
+
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
8344
|
+
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
8345
|
+
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
8346
|
+
* one per read on a hot resolve path.
|
|
8347
|
+
*
|
|
8348
|
+
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
8349
|
+
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
8350
|
+
* callers is safe and maximises hit rate.
|
|
8351
|
+
*/
|
|
8352
|
+
var cache = /* @__PURE__ */ new Map();
|
|
8353
|
+
function getCached(source) {
|
|
8354
|
+
const hit = cache.get(source);
|
|
8355
|
+
if (hit !== void 0) {
|
|
8356
|
+
cache.delete(source);
|
|
8357
|
+
cache.set(source, hit);
|
|
8358
|
+
return hit;
|
|
8359
|
+
}
|
|
8360
|
+
let result;
|
|
8361
|
+
try {
|
|
8362
|
+
result = {
|
|
8363
|
+
ok: true,
|
|
8364
|
+
parsed: parseExpression(source)
|
|
8365
|
+
};
|
|
8366
|
+
} catch (err) {
|
|
8367
|
+
result = {
|
|
8368
|
+
ok: false,
|
|
8369
|
+
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
8370
|
+
};
|
|
8371
|
+
}
|
|
8372
|
+
cache.set(source, result);
|
|
8373
|
+
if (cache.size > 256) {
|
|
8374
|
+
const oldest = cache.keys().next().value;
|
|
8375
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
8376
|
+
}
|
|
8377
|
+
return result;
|
|
8378
|
+
}
|
|
8379
|
+
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
8380
|
+
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
8381
|
+
function compileExpressionSafe(source) {
|
|
8382
|
+
return getCached(source);
|
|
8383
|
+
}
|
|
8384
|
+
/**
|
|
8385
|
+
* Author-time validation. Returns `null` when the source is valid, else a
|
|
8386
|
+
* human-readable error message. Checks: the expression compiles; binding count
|
|
8387
|
+
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
8388
|
+
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
8389
|
+
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
8390
|
+
*/
|
|
8391
|
+
function validateExpressionSource(src) {
|
|
8392
|
+
const names = Object.keys(src.bindings);
|
|
8393
|
+
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
8394
|
+
for (const name of names) {
|
|
8395
|
+
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
8396
|
+
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
8397
|
+
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
8398
|
+
}
|
|
8399
|
+
const compiled = compileExpressionSafe(src.expr);
|
|
8400
|
+
if (!compiled.ok) return compiled.error;
|
|
8401
|
+
const bound = new Set(names);
|
|
8402
|
+
for (const id of compiled.parsed.identifiers) {
|
|
8403
|
+
if (id === "now") continue;
|
|
8404
|
+
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
8405
|
+
}
|
|
8406
|
+
return null;
|
|
8407
|
+
}
|
|
8408
|
+
/**
|
|
7630
8409
|
* Accessory device helpers — shared across drivers.
|
|
7631
8410
|
*
|
|
7632
8411
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -8101,6 +8880,10 @@ var RtspRestreamEntrySchema = object({
|
|
|
8101
8880
|
var BrokerRtspClientSchema = object({
|
|
8102
8881
|
sessionId: string(),
|
|
8103
8882
|
remoteAddr: string(),
|
|
8883
|
+
/** Client `User-Agent` (e.g. `recorder` for the recorder's RTSP pull), or
|
|
8884
|
+
* null/absent when the client sent none. Lets the UI label a consumer by
|
|
8885
|
+
* purpose. Optional so a client built against an older schema stays valid. */
|
|
8886
|
+
userAgent: string().nullish(),
|
|
8104
8887
|
playing: boolean(),
|
|
8105
8888
|
muted: boolean(),
|
|
8106
8889
|
connectedAt: number(),
|
|
@@ -9525,7 +10308,8 @@ var MotionAnalysisResultSchema = object({
|
|
|
9525
10308
|
});
|
|
9526
10309
|
method(object({
|
|
9527
10310
|
deviceId: number(),
|
|
9528
|
-
frame: FrameInputSchema
|
|
10311
|
+
frame: FrameInputSchema.optional(),
|
|
10312
|
+
frameHandle: FrameHandleSchema.optional()
|
|
9529
10313
|
}), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
|
|
9530
10314
|
deviceId: number(),
|
|
9531
10315
|
detected: boolean(),
|
|
@@ -9772,6 +10556,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
9772
10556
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
9773
10557
|
steps: array(PipelineStepInputSchema).min(1),
|
|
9774
10558
|
frame: FrameInputSchema.optional(),
|
|
10559
|
+
/**
|
|
10560
|
+
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
10561
|
+
* the decoded pixels live in. One more member of the one-of
|
|
10562
|
+
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
10563
|
+
*/
|
|
10564
|
+
frameHandle: FrameHandleSchema.optional(),
|
|
9775
10565
|
imageBase64: string().optional(),
|
|
9776
10566
|
/**
|
|
9777
10567
|
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
@@ -9981,6 +10771,31 @@ var ReportMotionInputSchema = object({
|
|
|
9981
10771
|
regions: array(MotionRegionSchema).readonly().optional()
|
|
9982
10772
|
});
|
|
9983
10773
|
/**
|
|
10774
|
+
* Where a runner gets a camera's decoded frames (cross-node Phase 2,
|
|
10775
|
+
* restream-owner model — P2c).
|
|
10776
|
+
*
|
|
10777
|
+
* - `local-broker` (DEFAULT): today's path — subscribe to the co-located
|
|
10778
|
+
* stream-broker's shm frame plane. Every pre-P2c attach payload (no
|
|
10779
|
+
* `frameSource` key) parses to this, so the field is additive with zero
|
|
10780
|
+
* behavior change.
|
|
10781
|
+
* - `remote-restream`: the detect node is NOT the camera's source-owner.
|
|
10782
|
+
* The runner acquires the owner's COMPRESSED passthrough restream
|
|
10783
|
+
* (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
|
|
10784
|
+
* double-pull guard) and decodes LOCALLY via a satellite frame plane +
|
|
10785
|
+
* pull-mode decoder session pinned to its own node. The shm ring stays
|
|
10786
|
+
* node-local; only H.264/H.265 packets cross the wire.
|
|
10787
|
+
* `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
|
|
10788
|
+
* when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
|
|
10789
|
+
* dials for the owner's restream.
|
|
10790
|
+
*/
|
|
10791
|
+
var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
|
|
10792
|
+
kind: literal("remote-restream"),
|
|
10793
|
+
/** The camera's source-owner node (slice 1: always the hub). */
|
|
10794
|
+
ownerNodeId: string(),
|
|
10795
|
+
/** Operator override for the owner host the runner dials. */
|
|
10796
|
+
hubHostnameOverride: string().optional()
|
|
10797
|
+
})]).describe("Per-camera frame-source mode for the runner (P2c)");
|
|
10798
|
+
/**
|
|
9984
10799
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
9985
10800
|
* specific runner instance via `attachCamera`. Carries everything the
|
|
9986
10801
|
* runner needs to subscribe to the local broker and execute inference.
|
|
@@ -10078,7 +10893,15 @@ var RunnerCameraConfigSchema = object({
|
|
|
10078
10893
|
*/
|
|
10079
10894
|
onboardMotionDrivesAnalyzer: boolean().default(true),
|
|
10080
10895
|
occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
|
|
10081
|
-
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
|
|
10896
|
+
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
|
|
10897
|
+
/**
|
|
10898
|
+
* Where this runner gets the camera's decoded frames (P2c). Defaulted so
|
|
10899
|
+
* every existing payload behaves as `local-broker` — the pre-Phase-2 path.
|
|
10900
|
+
* Populated with `remote-restream` by the orchestrator ONLY when the
|
|
10901
|
+
* camera's detect node differs from its source-owner (P2d, gated by the
|
|
10902
|
+
* `remoteSourcingNodes` rollout setting).
|
|
10903
|
+
*/
|
|
10904
|
+
frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
|
|
10082
10905
|
});
|
|
10083
10906
|
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;
|
|
10084
10907
|
/**
|
|
@@ -10443,6 +11266,113 @@ object({
|
|
|
10443
11266
|
lastFetchedAt: number()
|
|
10444
11267
|
});
|
|
10445
11268
|
DeviceType.Sensor;
|
|
11269
|
+
/**
|
|
11270
|
+
* Feeder connectivity / power status — mirrors the HA petkit device-status
|
|
11271
|
+
* enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
|
|
11272
|
+
* `on_batteries` (running on battery backup). `null` until first reported.
|
|
11273
|
+
*/
|
|
11274
|
+
var PetFeederDeviceStatusSchema = _enum([
|
|
11275
|
+
"normal",
|
|
11276
|
+
"offline",
|
|
11277
|
+
"on_batteries"
|
|
11278
|
+
]);
|
|
11279
|
+
var gramsPortion = number().int().min(4).max(200);
|
|
11280
|
+
object({
|
|
11281
|
+
/** Food currently in the bowl (grams). Null when the device has not
|
|
11282
|
+
* reported a reading yet. On dual-hopper models this is the combined
|
|
11283
|
+
* bowl reading; per-hopper levels live in `food1`/`food2`. */
|
|
11284
|
+
foodLevel: number().nullable(),
|
|
11285
|
+
/** Hopper-1 food level (grams) on dual-hopper feeders; null on
|
|
11286
|
+
* single-hopper models. */
|
|
11287
|
+
food1: number().nullable(),
|
|
11288
|
+
/** Hopper-2 food level (grams) on dual-hopper feeders; null on
|
|
11289
|
+
* single-hopper models. */
|
|
11290
|
+
food2: number().nullable(),
|
|
11291
|
+
/** Derived low-food flag — mirrors the HA `food_level` binary_sensor
|
|
11292
|
+
* (`device_class: problem`, on = low). True when the bowl is empty /
|
|
11293
|
+
* below the feeder's low threshold. */
|
|
11294
|
+
lowFood: boolean(),
|
|
11295
|
+
/** Battery charge 0..100 (%). Null on mains-powered models or when the
|
|
11296
|
+
* device has no battery reading. */
|
|
11297
|
+
batteryPower: number().min(0).max(100).nullable(),
|
|
11298
|
+
/** Days of desiccant life remaining. Null when the model has no
|
|
11299
|
+
* desiccant sensor. */
|
|
11300
|
+
desiccantLeftDays: number().nullable(),
|
|
11301
|
+
/** True while a feed is in progress. */
|
|
11302
|
+
feeding: boolean(),
|
|
11303
|
+
/** Decoded connectivity / power status (HA petkit device-status enum).
|
|
11304
|
+
* Null until the device has reported a status. */
|
|
11305
|
+
status: PetFeederDeviceStatusSchema.nullable(),
|
|
11306
|
+
/** Decoded human-readable fault message. Null (or the device's `no_error`
|
|
11307
|
+
* sentinel) means healthy; a non-null string is an active fault. Pairs
|
|
11308
|
+
* with `errorCode` for consumers that want the raw integer. */
|
|
11309
|
+
error: string().nullable(),
|
|
11310
|
+
/** Raw device error code (0 / null = no error). */
|
|
11311
|
+
errorCode: number().nullable(),
|
|
11312
|
+
/** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
|
|
11313
|
+
isDualHopper: boolean(),
|
|
11314
|
+
/** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
|
|
11315
|
+
childLock: boolean(),
|
|
11316
|
+
/** Front indicator-light setting. */
|
|
11317
|
+
indicatorLight: boolean(),
|
|
11318
|
+
/** Play a chime when dispensing. */
|
|
11319
|
+
feedSound: boolean(),
|
|
11320
|
+
/** Speaker / prompt volume level (device-scaled integer). */
|
|
11321
|
+
volume: number(),
|
|
11322
|
+
/** Ms epoch when the slice was last refreshed from the cloud. */
|
|
11323
|
+
lastFetchedAt: number()
|
|
11324
|
+
});
|
|
11325
|
+
DeviceType.PetFeeder, method(object({
|
|
11326
|
+
deviceId: number().int().nonnegative(),
|
|
11327
|
+
grams: gramsPortion.optional(),
|
|
11328
|
+
hopper1: gramsPortion.optional(),
|
|
11329
|
+
hopper2: gramsPortion.optional()
|
|
11330
|
+
}), _void(), {
|
|
11331
|
+
kind: "mutation",
|
|
11332
|
+
auth: "admin"
|
|
11333
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11334
|
+
kind: "mutation",
|
|
11335
|
+
auth: "admin"
|
|
11336
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11337
|
+
kind: "mutation",
|
|
11338
|
+
auth: "admin"
|
|
11339
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11340
|
+
kind: "mutation",
|
|
11341
|
+
auth: "admin"
|
|
11342
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11343
|
+
kind: "mutation",
|
|
11344
|
+
auth: "admin"
|
|
11345
|
+
}), method(object({
|
|
11346
|
+
deviceId: number().int().nonnegative(),
|
|
11347
|
+
soundId: number().int().nonnegative()
|
|
11348
|
+
}), _void(), {
|
|
11349
|
+
kind: "mutation",
|
|
11350
|
+
auth: "admin"
|
|
11351
|
+
}), method(object({
|
|
11352
|
+
deviceId: number().int().nonnegative(),
|
|
11353
|
+
on: boolean()
|
|
11354
|
+
}), _void(), {
|
|
11355
|
+
kind: "mutation",
|
|
11356
|
+
auth: "admin"
|
|
11357
|
+
}), method(object({
|
|
11358
|
+
deviceId: number().int().nonnegative(),
|
|
11359
|
+
on: boolean()
|
|
11360
|
+
}), _void(), {
|
|
11361
|
+
kind: "mutation",
|
|
11362
|
+
auth: "admin"
|
|
11363
|
+
}), method(object({
|
|
11364
|
+
deviceId: number().int().nonnegative(),
|
|
11365
|
+
on: boolean()
|
|
11366
|
+
}), _void(), {
|
|
11367
|
+
kind: "mutation",
|
|
11368
|
+
auth: "admin"
|
|
11369
|
+
}), method(object({
|
|
11370
|
+
deviceId: number().int().nonnegative(),
|
|
11371
|
+
level: number().int().nonnegative()
|
|
11372
|
+
}), _void(), {
|
|
11373
|
+
kind: "mutation",
|
|
11374
|
+
auth: "admin"
|
|
11375
|
+
});
|
|
10446
11376
|
object({
|
|
10447
11377
|
/** Instantaneous power draw in watts. */
|
|
10448
11378
|
watts: number().optional(),
|
|
@@ -12310,10 +13240,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
|
|
|
12310
13240
|
url: string()
|
|
12311
13241
|
}), _void()), method(object({
|
|
12312
13242
|
sessionId: string(),
|
|
12313
|
-
maxCount: number().default(1)
|
|
13243
|
+
maxCount: number().default(1),
|
|
13244
|
+
waitMs: number().optional()
|
|
12314
13245
|
}), array(DecodedFrameSchema)), method(object({
|
|
12315
13246
|
sessionId: string(),
|
|
12316
|
-
maxCount: number().default(1)
|
|
13247
|
+
maxCount: number().default(1),
|
|
13248
|
+
waitMs: number().optional()
|
|
12317
13249
|
}), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
|
|
12318
13250
|
sessionId: string(),
|
|
12319
13251
|
config: DecoderSessionConfigSchema.partial()
|
|
@@ -12625,14 +13557,63 @@ var ChildLayoutEntrySchema = object({
|
|
|
12625
13557
|
collapsed: boolean().optional()
|
|
12626
13558
|
});
|
|
12627
13559
|
/** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
|
|
12628
|
-
* `device-management.ts`.
|
|
13560
|
+
* `device-management.ts`. Source is a union: a FIELD source copies a sibling
|
|
13561
|
+
* accessory's status field (`kind` optional/absent for wire compat); a
|
|
13562
|
+
* LITERAL source carries a per-device constant (no sibling is read); a
|
|
13563
|
+
* GLOBAL source (P2e) copies ANY device's status field, addressed by the
|
|
13564
|
+
* source device's full re-sync-stable `stableId`. */
|
|
13565
|
+
var DeviceLinkFieldSourceSchema = object({
|
|
13566
|
+
kind: literal("field").optional(),
|
|
13567
|
+
sourceKey: string(),
|
|
13568
|
+
cap: string(),
|
|
13569
|
+
fieldPath: string()
|
|
13570
|
+
});
|
|
13571
|
+
var DeviceLinkLiteralSourceSchema = object({
|
|
13572
|
+
kind: literal("literal"),
|
|
13573
|
+
value: union([
|
|
13574
|
+
string(),
|
|
13575
|
+
number(),
|
|
13576
|
+
boolean(),
|
|
13577
|
+
_null()
|
|
13578
|
+
])
|
|
13579
|
+
});
|
|
13580
|
+
var DeviceLinkGlobalSourceSchema = object({
|
|
13581
|
+
kind: literal("global"),
|
|
13582
|
+
sourceStableId: string(),
|
|
13583
|
+
cap: string(),
|
|
13584
|
+
fieldPath: string()
|
|
13585
|
+
});
|
|
13586
|
+
/** Expression source (Stage X): compute the target field from N named bindings
|
|
13587
|
+
* via the safe expression engine. Bindings are field | literal | global — never
|
|
13588
|
+
* another expression (no nesting). The `superRefine` runs the SAME author-time
|
|
13589
|
+
* validation as `validateExpressionSource` (compiles the expr, checks binding
|
|
13590
|
+
* names + identifier coverage) so every wire boundary that parses a DeviceLink
|
|
13591
|
+
* (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
|
|
13592
|
+
* Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
|
|
13593
|
+
var DeviceLinkExpressionSourceSchema = object({
|
|
13594
|
+
kind: literal("expression"),
|
|
13595
|
+
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
13596
|
+
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
|
|
13597
|
+
DeviceLinkFieldSourceSchema,
|
|
13598
|
+
DeviceLinkLiteralSourceSchema,
|
|
13599
|
+
DeviceLinkGlobalSourceSchema
|
|
13600
|
+
]))
|
|
13601
|
+
}).superRefine((src, ctx) => {
|
|
13602
|
+
const err = validateExpressionSource(src);
|
|
13603
|
+
if (err !== null) ctx.addIssue({
|
|
13604
|
+
code: "custom",
|
|
13605
|
+
message: err,
|
|
13606
|
+
path: ["expr"]
|
|
13607
|
+
});
|
|
13608
|
+
});
|
|
12629
13609
|
var DeviceLinkSchema = object({
|
|
12630
13610
|
id: string(),
|
|
12631
|
-
source:
|
|
12632
|
-
|
|
12633
|
-
|
|
12634
|
-
|
|
12635
|
-
|
|
13611
|
+
source: union([
|
|
13612
|
+
DeviceLinkFieldSourceSchema,
|
|
13613
|
+
DeviceLinkLiteralSourceSchema,
|
|
13614
|
+
DeviceLinkGlobalSourceSchema,
|
|
13615
|
+
DeviceLinkExpressionSourceSchema
|
|
13616
|
+
]),
|
|
12636
13617
|
target: object({
|
|
12637
13618
|
cap: string(),
|
|
12638
13619
|
fieldPath: string(),
|
|
@@ -12661,6 +13642,31 @@ var DeviceLinkSchema = object({
|
|
|
12661
13642
|
})
|
|
12662
13643
|
]).optional()
|
|
12663
13644
|
});
|
|
13645
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
13646
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
13647
|
+
var DeviceCapDisplayOverrideSchema = object({
|
|
13648
|
+
unit: string().min(1).optional(),
|
|
13649
|
+
precision: number().int().min(0).max(10).optional()
|
|
13650
|
+
});
|
|
13651
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
13652
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
13653
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
13654
|
+
var DeviceDisplayOverrideSchema = object({
|
|
13655
|
+
icon: string().min(1).optional(),
|
|
13656
|
+
label: string().min(1).optional(),
|
|
13657
|
+
unit: string().min(1).optional(),
|
|
13658
|
+
precision: number().int().min(0).max(10).optional(),
|
|
13659
|
+
hidden: boolean().optional(),
|
|
13660
|
+
perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
|
|
13661
|
+
});
|
|
13662
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
13663
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
13664
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
13665
|
+
var RoleDisplayDefaultSchema = object({
|
|
13666
|
+
unit: string().min(1).optional(),
|
|
13667
|
+
precision: number().int().min(0).max(10).optional(),
|
|
13668
|
+
icon: string().min(1).optional()
|
|
13669
|
+
});
|
|
12664
13670
|
/**
|
|
12665
13671
|
* Serializable projection of a live IDevice.
|
|
12666
13672
|
* Returned by listAll, getDevice, getChildren.
|
|
@@ -12716,7 +13722,9 @@ var DeviceInfoSchema = object({
|
|
|
12716
13722
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
12717
13723
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
12718
13724
|
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
12719
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional()
|
|
13725
|
+
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
13726
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
13727
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
12720
13728
|
});
|
|
12721
13729
|
var ConfigEntrySchema = object({
|
|
12722
13730
|
key: string(),
|
|
@@ -12781,7 +13789,9 @@ var DeviceMetaSchema = object({
|
|
|
12781
13789
|
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
12782
13790
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
12783
13791
|
* Optional: only present for accessory children that carry a known role. */
|
|
12784
|
-
role: string().nullable().optional()
|
|
13792
|
+
role: string().nullable().optional(),
|
|
13793
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
13794
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
12785
13795
|
});
|
|
12786
13796
|
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
12787
13797
|
var ConfigUISchemaOutput = unknown().nullable();
|
|
@@ -12875,7 +13885,19 @@ method(object({
|
|
|
12875
13885
|
}), _void(), {
|
|
12876
13886
|
kind: "mutation",
|
|
12877
13887
|
auth: "admin"
|
|
12878
|
-
}), method(object({
|
|
13888
|
+
}), method(object({
|
|
13889
|
+
deviceId: number(),
|
|
13890
|
+
display: DeviceDisplayOverrideSchema.nullable()
|
|
13891
|
+
}), _void(), {
|
|
13892
|
+
kind: "mutation",
|
|
13893
|
+
auth: "admin"
|
|
13894
|
+
}), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
|
|
13895
|
+
kind: "mutation",
|
|
13896
|
+
auth: "admin"
|
|
13897
|
+
}), method(object({
|
|
13898
|
+
deviceId: number(),
|
|
13899
|
+
includeSynthesizable: boolean().optional()
|
|
13900
|
+
}), object({ caps: array(object({
|
|
12879
13901
|
cap: string(),
|
|
12880
13902
|
fields: array(object({
|
|
12881
13903
|
path: string(),
|
|
@@ -12885,8 +13907,13 @@ method(object({
|
|
|
12885
13907
|
"boolean",
|
|
12886
13908
|
"enum"
|
|
12887
13909
|
]),
|
|
12888
|
-
enumValues: array(string()).optional()
|
|
12889
|
-
|
|
13910
|
+
enumValues: array(string()).optional(),
|
|
13911
|
+
item: boolean().optional()
|
|
13912
|
+
})).readonly(),
|
|
13913
|
+
itemArray: object({
|
|
13914
|
+
path: string(),
|
|
13915
|
+
keyField: string()
|
|
13916
|
+
}).optional()
|
|
12890
13917
|
})).readonly() }), { kind: "query" }), method(object({
|
|
12891
13918
|
deviceId: number(),
|
|
12892
13919
|
role: string().nullable()
|
|
@@ -12956,7 +13983,11 @@ method(object({
|
|
|
12956
13983
|
deviceId: number(),
|
|
12957
13984
|
entries: array(object({
|
|
12958
13985
|
capName: string(),
|
|
12959
|
-
kind: _enum([
|
|
13986
|
+
kind: _enum([
|
|
13987
|
+
"native",
|
|
13988
|
+
"wrapped",
|
|
13989
|
+
"linked"
|
|
13990
|
+
]),
|
|
12960
13991
|
providerAddonId: string(),
|
|
12961
13992
|
providerNodeId: string(),
|
|
12962
13993
|
nativeAddonId: string()
|
|
@@ -12965,7 +13996,11 @@ method(object({
|
|
|
12965
13996
|
deviceId: number(),
|
|
12966
13997
|
entries: array(object({
|
|
12967
13998
|
capName: string(),
|
|
12968
|
-
kind: _enum([
|
|
13999
|
+
kind: _enum([
|
|
14000
|
+
"native",
|
|
14001
|
+
"wrapped",
|
|
14002
|
+
"linked"
|
|
14003
|
+
]),
|
|
12969
14004
|
providerAddonId: string(),
|
|
12970
14005
|
providerNodeId: string(),
|
|
12971
14006
|
nativeAddonId: string()
|
|
@@ -13455,7 +14490,7 @@ var AddBrokerInputSchema = object({
|
|
|
13455
14490
|
});
|
|
13456
14491
|
var AddBrokerResultSchema = object({ id: string() });
|
|
13457
14492
|
var IdInputSchema = object({ id: string() });
|
|
13458
|
-
var TestResultSchema = discriminatedUnion("ok", [object({
|
|
14493
|
+
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
13459
14494
|
ok: literal(true),
|
|
13460
14495
|
latencyMs: number()
|
|
13461
14496
|
}), object({
|
|
@@ -13478,7 +14513,7 @@ var StatusSchema = object({
|
|
|
13478
14513
|
brokerCount: number(),
|
|
13479
14514
|
embeddedRunning: boolean()
|
|
13480
14515
|
});
|
|
13481
|
-
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);
|
|
14516
|
+
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);
|
|
13482
14517
|
var NetworkEndpointSchema = object({
|
|
13483
14518
|
url: string(),
|
|
13484
14519
|
hostname: string(),
|
|
@@ -13512,23 +14547,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
|
13512
14547
|
sourcePort: number().optional()
|
|
13513
14548
|
});
|
|
13514
14549
|
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
13515
|
-
|
|
13516
|
-
|
|
14550
|
+
/**
|
|
14551
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
14552
|
+
*
|
|
14553
|
+
* Apprise-derived model (see
|
|
14554
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
14555
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
14556
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
14557
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
14558
|
+
* message to what the kind supports — callers never special-case a service.
|
|
14559
|
+
*
|
|
14560
|
+
* DESIGN DECISIONS (locked):
|
|
14561
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
14562
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
14563
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
14564
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
14565
|
+
* alternative would fork the UI per addon and cannot host the
|
|
14566
|
+
* discovery→adopt flow.
|
|
14567
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
14568
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
14569
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
14570
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
14571
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
14572
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
14573
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
14574
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
14575
|
+
* base64 fallback needed.
|
|
14576
|
+
*
|
|
14577
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
14578
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
14579
|
+
* admin "Integrations" page.
|
|
14580
|
+
*/
|
|
14581
|
+
/**
|
|
14582
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
14583
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
14584
|
+
*/
|
|
14585
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
14586
|
+
"image",
|
|
14587
|
+
"video",
|
|
14588
|
+
"gif",
|
|
14589
|
+
"audio",
|
|
14590
|
+
"icon"
|
|
14591
|
+
]);
|
|
14592
|
+
/**
|
|
14593
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
14594
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
14595
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
14596
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
14597
|
+
*/
|
|
14598
|
+
var AttachmentSchema = object({
|
|
14599
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
14600
|
+
url: string().optional(),
|
|
14601
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
14602
|
+
mime: string().optional(),
|
|
14603
|
+
name: string().optional()
|
|
14604
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
14605
|
+
var NotificationFormatSchema = _enum([
|
|
14606
|
+
"text",
|
|
14607
|
+
"markdown",
|
|
14608
|
+
"html"
|
|
14609
|
+
]);
|
|
14610
|
+
/** A single tap-through action button. */
|
|
14611
|
+
var NotificationActionSchema = object({
|
|
14612
|
+
id: string(),
|
|
14613
|
+
label: string(),
|
|
14614
|
+
url: string().optional()
|
|
14615
|
+
});
|
|
14616
|
+
/**
|
|
14617
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
14618
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
14619
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
14620
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
14621
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
14622
|
+
* `priority` for that one target.
|
|
14623
|
+
*/
|
|
14624
|
+
var NotificationSchema = object({
|
|
13517
14625
|
body: string(),
|
|
13518
|
-
|
|
14626
|
+
title: string().optional(),
|
|
14627
|
+
format: NotificationFormatSchema.default("text"),
|
|
14628
|
+
priority: number().int().min(1).max(5).default(3),
|
|
14629
|
+
level: string().optional(),
|
|
14630
|
+
attachments: array(AttachmentSchema).optional(),
|
|
14631
|
+
clickUrl: string().optional(),
|
|
14632
|
+
actions: array(NotificationActionSchema).optional(),
|
|
14633
|
+
sound: string().optional(),
|
|
14634
|
+
ttl: number().optional(),
|
|
14635
|
+
tag: string().optional(),
|
|
13519
14636
|
deviceId: number().optional(),
|
|
13520
14637
|
eventId: string().optional(),
|
|
13521
|
-
priority: _enum([
|
|
13522
|
-
"low",
|
|
13523
|
-
"normal",
|
|
13524
|
-
"high",
|
|
13525
|
-
"critical"
|
|
13526
|
-
]).default("normal"),
|
|
13527
14638
|
metadata: record(string(), unknown()).optional()
|
|
13528
|
-
})
|
|
14639
|
+
});
|
|
14640
|
+
/** One declared native severity/priority level for a kind. */
|
|
14641
|
+
var TargetKindLevelSchema = object({
|
|
14642
|
+
id: string(),
|
|
14643
|
+
label: string(),
|
|
14644
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
14645
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
14646
|
+
flags: object({
|
|
14647
|
+
critical: boolean().optional(),
|
|
14648
|
+
silent: boolean().optional(),
|
|
14649
|
+
noPush: boolean().optional()
|
|
14650
|
+
}).optional(),
|
|
14651
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
14652
|
+
requires: array(string()).optional(),
|
|
14653
|
+
description: string().optional()
|
|
14654
|
+
});
|
|
14655
|
+
/** The full capability block consulted before dispatch. */
|
|
14656
|
+
var TargetKindCapsSchema = object({
|
|
14657
|
+
attachments: object({
|
|
14658
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
14659
|
+
mode: _enum([
|
|
14660
|
+
"url",
|
|
14661
|
+
"bytes",
|
|
14662
|
+
"both"
|
|
14663
|
+
]),
|
|
14664
|
+
max: number().int().nonnegative(),
|
|
14665
|
+
maxBytes: number().int().positive().optional()
|
|
14666
|
+
}),
|
|
14667
|
+
/** Max action buttons (0 = none). */
|
|
14668
|
+
actions: number().int().nonnegative(),
|
|
14669
|
+
levels: array(TargetKindLevelSchema),
|
|
14670
|
+
format: array(NotificationFormatSchema),
|
|
14671
|
+
clickUrl: boolean(),
|
|
14672
|
+
sound: boolean(),
|
|
14673
|
+
ttl: boolean(),
|
|
14674
|
+
bodyMaxLen: number().int().positive()
|
|
14675
|
+
});
|
|
14676
|
+
/**
|
|
14677
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
14678
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
14679
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
14680
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
14681
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
14682
|
+
*/
|
|
14683
|
+
var ConfigSchemaPassthrough = unknown();
|
|
14684
|
+
var TargetKindSchema = object({
|
|
14685
|
+
kind: string(),
|
|
14686
|
+
label: string(),
|
|
14687
|
+
icon: string(),
|
|
14688
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
14689
|
+
addonId: string(),
|
|
14690
|
+
configSchema: ConfigSchemaPassthrough,
|
|
14691
|
+
supportsDiscovery: boolean(),
|
|
14692
|
+
caps: TargetKindCapsSchema
|
|
14693
|
+
});
|
|
14694
|
+
/**
|
|
14695
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
14696
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
14697
|
+
* round-trip a stored secret to the UI.
|
|
14698
|
+
*/
|
|
14699
|
+
var TargetSchema = object({
|
|
14700
|
+
id: string(),
|
|
14701
|
+
name: string(),
|
|
14702
|
+
kind: string(),
|
|
14703
|
+
addonId: string(),
|
|
14704
|
+
enabled: boolean(),
|
|
14705
|
+
config: record(string(), unknown())
|
|
14706
|
+
});
|
|
14707
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
14708
|
+
var DiscoveredTargetSchema = object({
|
|
14709
|
+
kind: string(),
|
|
14710
|
+
suggestedName: string(),
|
|
14711
|
+
config: record(string(), unknown())
|
|
14712
|
+
});
|
|
14713
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
14714
|
+
var RenderedAsSchema = object({
|
|
14715
|
+
level: string(),
|
|
14716
|
+
format: NotificationFormatSchema,
|
|
14717
|
+
attachmentsSent: number().int().nonnegative(),
|
|
14718
|
+
actionsSent: number().int().nonnegative(),
|
|
14719
|
+
truncated: boolean(),
|
|
14720
|
+
dropped: array(string())
|
|
14721
|
+
});
|
|
14722
|
+
var SendResultSchema = object({
|
|
13529
14723
|
success: boolean(),
|
|
13530
|
-
error: string().optional()
|
|
13531
|
-
|
|
14724
|
+
error: string().optional(),
|
|
14725
|
+
renderedAs: RenderedAsSchema.optional()
|
|
14726
|
+
});
|
|
14727
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
14728
|
+
var TestResultSchema = SendResultSchema;
|
|
14729
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
|
|
14730
|
+
kind: string(),
|
|
14731
|
+
config: record(string(), unknown()).optional()
|
|
14732
|
+
}), array(DiscoveredTargetSchema)), method(object({
|
|
14733
|
+
targetId: string(),
|
|
14734
|
+
notification: NotificationSchema
|
|
14735
|
+
}), SendResultSchema, { kind: "mutation" }), method(object({
|
|
14736
|
+
targetId: string(),
|
|
14737
|
+
sample: NotificationSchema.optional()
|
|
14738
|
+
}), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
|
|
14739
|
+
targetId: string(),
|
|
14740
|
+
enabled: boolean()
|
|
14741
|
+
}), _void(), { kind: "mutation" });
|
|
13532
14742
|
/**
|
|
13533
14743
|
* Zod schemas for persisted record types.
|
|
13534
14744
|
*
|
|
@@ -16556,7 +17766,10 @@ var HwAccelBackendInputSchema = _enum([
|
|
|
16556
17766
|
"webgpu",
|
|
16557
17767
|
"none"
|
|
16558
17768
|
]).nullable().optional();
|
|
16559
|
-
var HwAccelResolutionSchema = object({
|
|
17769
|
+
var HwAccelResolutionSchema = object({
|
|
17770
|
+
preferred: array(string()).readonly(),
|
|
17771
|
+
rationale: string()
|
|
17772
|
+
});
|
|
16560
17773
|
var HardwareEncoderIdSchema = _enum([
|
|
16561
17774
|
"h264_videotoolbox",
|
|
16562
17775
|
"hevc_videotoolbox",
|
|
@@ -16661,10 +17874,7 @@ var ResolvedInferenceConfigSchema = object({
|
|
|
16661
17874
|
format: ModelFormatSchema,
|
|
16662
17875
|
reason: string()
|
|
16663
17876
|
});
|
|
16664
|
-
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
|
|
16665
|
-
prefer: HwAccelBackendInputSchema,
|
|
16666
|
-
nodeId: string().optional()
|
|
16667
|
-
}), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
17877
|
+
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
16668
17878
|
kind: "mutation",
|
|
16669
17879
|
auth: "admin"
|
|
16670
17880
|
}), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
|
|
@@ -16723,6 +17933,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
|
|
|
16723
17933
|
kind: "mutation",
|
|
16724
17934
|
auth: "admin"
|
|
16725
17935
|
});
|
|
17936
|
+
/**
|
|
17937
|
+
* `recording` cap — footage availability + HLS playback manifests + per-device
|
|
17938
|
+
* recording config. NOTE on events (source of truth, R5/C3): this cap carries
|
|
17939
|
+
* NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
|
|
17940
|
+
* events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
|
|
17941
|
+
* rows); the recorder's internal EventMap markers are ephemeral in-RAM
|
|
17942
|
+
* annotations that are not exposed here and must not be treated as an event
|
|
17943
|
+
* feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
|
|
17944
|
+
* (`interfaces/recording-config.ts`).
|
|
17945
|
+
*/
|
|
16726
17946
|
var RecordingStatusSchema = object({
|
|
16727
17947
|
deviceId: number(),
|
|
16728
17948
|
enabled: boolean(),
|
|
@@ -18359,6 +19579,12 @@ Object.freeze({
|
|
|
18359
19579
|
addonId: null,
|
|
18360
19580
|
access: "view"
|
|
18361
19581
|
},
|
|
19582
|
+
"deviceManager.getRoleDisplayDefaults": {
|
|
19583
|
+
capName: "device-manager",
|
|
19584
|
+
capScope: "system",
|
|
19585
|
+
addonId: null,
|
|
19586
|
+
access: "view"
|
|
19587
|
+
},
|
|
18362
19588
|
"deviceManager.getSettingsSchema": {
|
|
18363
19589
|
capName: "device-manager",
|
|
18364
19590
|
capScope: "system",
|
|
@@ -18509,6 +19735,12 @@ Object.freeze({
|
|
|
18509
19735
|
addonId: null,
|
|
18510
19736
|
access: "create"
|
|
18511
19737
|
},
|
|
19738
|
+
"deviceManager.setDisplay": {
|
|
19739
|
+
capName: "device-manager",
|
|
19740
|
+
capScope: "system",
|
|
19741
|
+
addonId: null,
|
|
19742
|
+
access: "create"
|
|
19743
|
+
},
|
|
18512
19744
|
"deviceManager.setIntegrationId": {
|
|
18513
19745
|
capName: "device-manager",
|
|
18514
19746
|
capScope: "system",
|
|
@@ -18551,6 +19783,12 @@ Object.freeze({
|
|
|
18551
19783
|
addonId: null,
|
|
18552
19784
|
access: "create"
|
|
18553
19785
|
},
|
|
19786
|
+
"deviceManager.setRoleDisplayDefaults": {
|
|
19787
|
+
capName: "device-manager",
|
|
19788
|
+
capScope: "system",
|
|
19789
|
+
addonId: null,
|
|
19790
|
+
access: "create"
|
|
19791
|
+
},
|
|
18554
19792
|
"deviceManager.setStreamProfileMap": {
|
|
18555
19793
|
capName: "device-manager",
|
|
18556
19794
|
capScope: "system",
|
|
@@ -19529,13 +20767,49 @@ Object.freeze({
|
|
|
19529
20767
|
addonId: null,
|
|
19530
20768
|
access: "create"
|
|
19531
20769
|
},
|
|
20770
|
+
"notificationOutput.deleteTarget": {
|
|
20771
|
+
capName: "notification-output",
|
|
20772
|
+
capScope: "system",
|
|
20773
|
+
addonId: null,
|
|
20774
|
+
access: "delete"
|
|
20775
|
+
},
|
|
20776
|
+
"notificationOutput.discoverTargets": {
|
|
20777
|
+
capName: "notification-output",
|
|
20778
|
+
capScope: "system",
|
|
20779
|
+
addonId: null,
|
|
20780
|
+
access: "view"
|
|
20781
|
+
},
|
|
20782
|
+
"notificationOutput.listTargetKinds": {
|
|
20783
|
+
capName: "notification-output",
|
|
20784
|
+
capScope: "system",
|
|
20785
|
+
addonId: null,
|
|
20786
|
+
access: "view"
|
|
20787
|
+
},
|
|
20788
|
+
"notificationOutput.listTargets": {
|
|
20789
|
+
capName: "notification-output",
|
|
20790
|
+
capScope: "system",
|
|
20791
|
+
addonId: null,
|
|
20792
|
+
access: "view"
|
|
20793
|
+
},
|
|
19532
20794
|
"notificationOutput.send": {
|
|
19533
20795
|
capName: "notification-output",
|
|
19534
20796
|
capScope: "system",
|
|
19535
20797
|
addonId: null,
|
|
19536
20798
|
access: "create"
|
|
19537
20799
|
},
|
|
19538
|
-
"notificationOutput.
|
|
20800
|
+
"notificationOutput.setTargetEnabled": {
|
|
20801
|
+
capName: "notification-output",
|
|
20802
|
+
capScope: "system",
|
|
20803
|
+
addonId: null,
|
|
20804
|
+
access: "create"
|
|
20805
|
+
},
|
|
20806
|
+
"notificationOutput.testTarget": {
|
|
20807
|
+
capName: "notification-output",
|
|
20808
|
+
capScope: "system",
|
|
20809
|
+
addonId: null,
|
|
20810
|
+
access: "create"
|
|
20811
|
+
},
|
|
20812
|
+
"notificationOutput.upsertTarget": {
|
|
19539
20813
|
capName: "notification-output",
|
|
19540
20814
|
capScope: "system",
|
|
19541
20815
|
addonId: null,
|
|
@@ -19565,6 +20839,66 @@ Object.freeze({
|
|
|
19565
20839
|
addonId: null,
|
|
19566
20840
|
access: "create"
|
|
19567
20841
|
},
|
|
20842
|
+
"petFeeder.callPet": {
|
|
20843
|
+
capName: "pet-feeder",
|
|
20844
|
+
capScope: "device",
|
|
20845
|
+
addonId: null,
|
|
20846
|
+
access: "create"
|
|
20847
|
+
},
|
|
20848
|
+
"petFeeder.cancelFeed": {
|
|
20849
|
+
capName: "pet-feeder",
|
|
20850
|
+
capScope: "device",
|
|
20851
|
+
addonId: null,
|
|
20852
|
+
access: "create"
|
|
20853
|
+
},
|
|
20854
|
+
"petFeeder.feed": {
|
|
20855
|
+
capName: "pet-feeder",
|
|
20856
|
+
capScope: "device",
|
|
20857
|
+
addonId: null,
|
|
20858
|
+
access: "create"
|
|
20859
|
+
},
|
|
20860
|
+
"petFeeder.markFoodReplenished": {
|
|
20861
|
+
capName: "pet-feeder",
|
|
20862
|
+
capScope: "device",
|
|
20863
|
+
addonId: null,
|
|
20864
|
+
access: "create"
|
|
20865
|
+
},
|
|
20866
|
+
"petFeeder.playSound": {
|
|
20867
|
+
capName: "pet-feeder",
|
|
20868
|
+
capScope: "device",
|
|
20869
|
+
addonId: null,
|
|
20870
|
+
access: "create"
|
|
20871
|
+
},
|
|
20872
|
+
"petFeeder.resetDesiccant": {
|
|
20873
|
+
capName: "pet-feeder",
|
|
20874
|
+
capScope: "device",
|
|
20875
|
+
addonId: null,
|
|
20876
|
+
access: "delete"
|
|
20877
|
+
},
|
|
20878
|
+
"petFeeder.setChildLock": {
|
|
20879
|
+
capName: "pet-feeder",
|
|
20880
|
+
capScope: "device",
|
|
20881
|
+
addonId: null,
|
|
20882
|
+
access: "create"
|
|
20883
|
+
},
|
|
20884
|
+
"petFeeder.setFeedSound": {
|
|
20885
|
+
capName: "pet-feeder",
|
|
20886
|
+
capScope: "device",
|
|
20887
|
+
addonId: null,
|
|
20888
|
+
access: "create"
|
|
20889
|
+
},
|
|
20890
|
+
"petFeeder.setIndicatorLight": {
|
|
20891
|
+
capName: "pet-feeder",
|
|
20892
|
+
capScope: "device",
|
|
20893
|
+
addonId: null,
|
|
20894
|
+
access: "create"
|
|
20895
|
+
},
|
|
20896
|
+
"petFeeder.setVolume": {
|
|
20897
|
+
capName: "pet-feeder",
|
|
20898
|
+
capScope: "device",
|
|
20899
|
+
addonId: null,
|
|
20900
|
+
access: "create"
|
|
20901
|
+
},
|
|
19568
20902
|
"pipelineAnalytics.clearTracks": {
|
|
19569
20903
|
capName: "pipeline-analytics",
|
|
19570
20904
|
capScope: "device",
|