@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
|
@@ -4629,7 +4629,7 @@ function _instanceof(cls, params = {}) {
|
|
|
4629
4629
|
return inst;
|
|
4630
4630
|
}
|
|
4631
4631
|
//#endregion
|
|
4632
|
-
//#region ../types/dist/sleep-
|
|
4632
|
+
//#region ../types/dist/sleep-BiDFW0E7.mjs
|
|
4633
4633
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4634
4634
|
EventCategory["SystemBoot"] = "system.boot";
|
|
4635
4635
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -5442,6 +5442,100 @@ function createDurableState(deps) {
|
|
|
5442
5442
|
};
|
|
5443
5443
|
}
|
|
5444
5444
|
/**
|
|
5445
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
5446
|
+
*
|
|
5447
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
5448
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
5449
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
5450
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
5451
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
5452
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
5453
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
5454
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
5455
|
+
*
|
|
5456
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
5457
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
5458
|
+
* schema and routes reads/writes through these helpers.
|
|
5459
|
+
*
|
|
5460
|
+
* ## No bare-key fallback — deliberate
|
|
5461
|
+
*
|
|
5462
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
5463
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
5464
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
5465
|
+
* the store is invisible to every node, hub included, so one node's
|
|
5466
|
+
* selection can never leak onto another. (This generalizes the
|
|
5467
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
5468
|
+
* arbitrary set of per-node field keys.)
|
|
5469
|
+
*
|
|
5470
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
5471
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
5472
|
+
*/
|
|
5473
|
+
/**
|
|
5474
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
5475
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
5476
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
5477
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
5478
|
+
*/
|
|
5479
|
+
function normalizeNodeId(raw) {
|
|
5480
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
5481
|
+
const slashIdx = raw.indexOf("/");
|
|
5482
|
+
if (slashIdx < 0) return raw;
|
|
5483
|
+
const bare = raw.slice(0, slashIdx);
|
|
5484
|
+
return bare === "" ? "hub" : bare;
|
|
5485
|
+
}
|
|
5486
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
5487
|
+
function nodeScopedKey(base, nodeId) {
|
|
5488
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
5489
|
+
}
|
|
5490
|
+
/**
|
|
5491
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
5492
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
5493
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
5494
|
+
* schema `default` win on `undefined`.
|
|
5495
|
+
*/
|
|
5496
|
+
function readNodeValue(store, base, nodeId) {
|
|
5497
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
5498
|
+
}
|
|
5499
|
+
/**
|
|
5500
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
5501
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
5502
|
+
* the write path so a save for one node never clobbers another node's value
|
|
5503
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
5504
|
+
* patch is not mutated.
|
|
5505
|
+
*/
|
|
5506
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
5507
|
+
const out = {};
|
|
5508
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
5509
|
+
return out;
|
|
5510
|
+
}
|
|
5511
|
+
/**
|
|
5512
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
5513
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
5514
|
+
* values:
|
|
5515
|
+
*
|
|
5516
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
5517
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
5518
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
5519
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
5520
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
5521
|
+
* left ABSENT so the field's schema `default` wins.
|
|
5522
|
+
*
|
|
5523
|
+
* Returns a new object — the input store is not mutated.
|
|
5524
|
+
*/
|
|
5525
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
5526
|
+
const out = {};
|
|
5527
|
+
for (const [key, value] of Object.entries(store)) {
|
|
5528
|
+
if (key.includes("@")) continue;
|
|
5529
|
+
if (perNodeKeys.has(key)) continue;
|
|
5530
|
+
out[key] = value;
|
|
5531
|
+
}
|
|
5532
|
+
for (const base of perNodeKeys) {
|
|
5533
|
+
const value = readNodeValue(store, base, nodeId);
|
|
5534
|
+
if (value !== void 0) out[base] = value;
|
|
5535
|
+
}
|
|
5536
|
+
return out;
|
|
5537
|
+
}
|
|
5538
|
+
/**
|
|
5445
5539
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5446
5540
|
*
|
|
5447
5541
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -5609,23 +5703,63 @@ var BaseAddon = class {
|
|
|
5609
5703
|
deviceSettingsSchema() {
|
|
5610
5704
|
return null;
|
|
5611
5705
|
}
|
|
5612
|
-
async getGlobalSettings(overlay, cap,
|
|
5706
|
+
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5613
5707
|
const schema = this.globalSettingsSchema(cap);
|
|
5614
5708
|
if (!schema) return { sections: [] };
|
|
5615
|
-
const
|
|
5709
|
+
const projected = await this.resolveGlobalStore(nodeId, cap);
|
|
5616
5710
|
return hydrateSchema(schema, overlay ? {
|
|
5617
|
-
...
|
|
5711
|
+
...projected,
|
|
5618
5712
|
...overlay
|
|
5619
|
-
} :
|
|
5713
|
+
} : projected);
|
|
5620
5714
|
}
|
|
5621
|
-
|
|
5622
|
-
|
|
5715
|
+
/**
|
|
5716
|
+
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5717
|
+
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5718
|
+
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
5719
|
+
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
5720
|
+
* A no-op passthrough when the schema declares no `perNode` field.
|
|
5721
|
+
*
|
|
5722
|
+
* This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
|
|
5723
|
+
* the store for custom option logic (option narrowing, value snapping) to
|
|
5724
|
+
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
5725
|
+
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
5726
|
+
*/
|
|
5727
|
+
async resolveGlobalStore(nodeId, cap) {
|
|
5728
|
+
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
5729
|
+
const keys = this.perNodeKeys(cap);
|
|
5730
|
+
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5731
|
+
return keys.size > 0 ? projectStore(raw, keys, node) : raw;
|
|
5732
|
+
}
|
|
5733
|
+
async updateGlobalSettings(patch, nodeId) {
|
|
5734
|
+
const keys = this.perNodeKeys();
|
|
5735
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5736
|
+
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5737
|
+
const barePatch = patch;
|
|
5738
|
+
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
5739
|
+
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
5740
|
+
if (target !== localNode) return;
|
|
5623
5741
|
await this.resolveConfig();
|
|
5624
5742
|
await this.onConfigChanged();
|
|
5625
5743
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
5626
5744
|
this.maybeAutoRestart(patch, this.globalSettingsSchema());
|
|
5627
5745
|
}
|
|
5628
5746
|
/**
|
|
5747
|
+
* The set of field keys the global settings schema declares `perNode: true`
|
|
5748
|
+
* — derived once per `cap` argument and memoized (schemas are static
|
|
5749
|
+
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
5750
|
+
* settings API behaves exactly like the legacy node-agnostic one.
|
|
5751
|
+
*/
|
|
5752
|
+
_perNodeKeysCache = /* @__PURE__ */ new Map();
|
|
5753
|
+
perNodeKeys(cap) {
|
|
5754
|
+
const cacheKey = cap ?? "";
|
|
5755
|
+
const cached = this._perNodeKeysCache.get(cacheKey);
|
|
5756
|
+
if (cached) return cached;
|
|
5757
|
+
const schema = this.globalSettingsSchema(cap);
|
|
5758
|
+
const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
5759
|
+
this._perNodeKeysCache.set(cacheKey, keys);
|
|
5760
|
+
return keys;
|
|
5761
|
+
}
|
|
5762
|
+
/**
|
|
5629
5763
|
* If any field in `patch` is marked `requiresRestart` in `schema`,
|
|
5630
5764
|
* schedule an addon restart for the next tick. Deferred via
|
|
5631
5765
|
* `setImmediate` so the tRPC mutation that triggered the write has
|
|
@@ -5778,12 +5912,19 @@ var BaseAddon = class {
|
|
|
5778
5912
|
* The merge is shallow: each key in `defaults` is checked against the store.
|
|
5779
5913
|
* Only keys present in defaults are read — the store can contain extra keys
|
|
5780
5914
|
* (e.g. from older versions) without polluting the typed config.
|
|
5915
|
+
*
|
|
5916
|
+
* Keys the global settings schema declares `perNode: true` resolve from
|
|
5917
|
+
* THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
|
|
5918
|
+
* from the bare key — so a per-node field resolves to this node's own
|
|
5919
|
+
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
5781
5920
|
*/
|
|
5782
5921
|
async resolveConfig() {
|
|
5783
5922
|
const stored = await this.readAddonStoreWithRetry();
|
|
5923
|
+
const perNode = this.perNodeKeys();
|
|
5924
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5784
5925
|
const resolved = { ...this.defaults };
|
|
5785
5926
|
for (const key of Object.keys(this.defaults)) {
|
|
5786
|
-
const storedValue = stored[key];
|
|
5927
|
+
const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
|
|
5787
5928
|
if (storedValue !== void 0 && storedValue !== null) {
|
|
5788
5929
|
const defaultType = typeof this.defaults[key];
|
|
5789
5930
|
if (typeof storedValue === defaultType) resolved[key] = storedValue;
|
|
@@ -5867,6 +6008,27 @@ var BaseAddon = class {
|
|
|
5867
6008
|
}
|
|
5868
6009
|
};
|
|
5869
6010
|
/**
|
|
6011
|
+
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
6012
|
+
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
6013
|
+
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6014
|
+
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6015
|
+
*/
|
|
6016
|
+
function collectPerNodeFieldKeys(fields) {
|
|
6017
|
+
const collected = [];
|
|
6018
|
+
for (const field of fields) {
|
|
6019
|
+
if (field.type === "group") {
|
|
6020
|
+
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
6021
|
+
continue;
|
|
6022
|
+
}
|
|
6023
|
+
if (field.type === "sub-tabs") {
|
|
6024
|
+
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
6025
|
+
continue;
|
|
6026
|
+
}
|
|
6027
|
+
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
6028
|
+
}
|
|
6029
|
+
return collected;
|
|
6030
|
+
}
|
|
6031
|
+
/**
|
|
5870
6032
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
5871
6033
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
5872
6034
|
* envelopes pass through; void stays void.
|
|
@@ -5891,6 +6053,7 @@ var CamStreamKindSchema = _enum([
|
|
|
5891
6053
|
"pull-rtsp",
|
|
5892
6054
|
"pull-rtmp",
|
|
5893
6055
|
"pull-http",
|
|
6056
|
+
"pull-flv",
|
|
5894
6057
|
"pull-rfc4571",
|
|
5895
6058
|
"push-annexb",
|
|
5896
6059
|
"derived"
|
|
@@ -6284,6 +6447,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
6284
6447
|
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
6285
6448
|
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
6286
6449
|
DeviceType["Image"] = "image";
|
|
6450
|
+
/** Smart pet feeder — cloud-connected food dispenser with a bowl food
|
|
6451
|
+
* level, battery, desiccant life, feeding state and manual-feed /
|
|
6452
|
+
* call-pet / maintenance actions. Installed with the `pet-feeder` cap;
|
|
6453
|
+
* dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
|
|
6454
|
+
* native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
|
|
6455
|
+
* integrations sharing the same food/desiccant/hopper surface. */
|
|
6456
|
+
DeviceType["PetFeeder"] = "pet-feeder";
|
|
6287
6457
|
return DeviceType;
|
|
6288
6458
|
}({});
|
|
6289
6459
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -7174,7 +7344,21 @@ var StorageLocationDeclarationSchema = object({
|
|
|
7174
7344
|
* slots (e.g. `recordingsLow` → `recordings`) so operators only need to
|
|
7175
7345
|
* configure the primary location.
|
|
7176
7346
|
*/
|
|
7177
|
-
defaultsTo: string().optional()
|
|
7347
|
+
defaultsTo: string().optional(),
|
|
7348
|
+
/**
|
|
7349
|
+
* Which node root the seeded `<id>:default` instance is placed under on a
|
|
7350
|
+
* FRESH install:
|
|
7351
|
+
* - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
|
|
7352
|
+
* the appData volume. Right for small/durable data (backups, logs, models).
|
|
7353
|
+
* - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
|
|
7354
|
+
* env is set, else falls back to the data root. Right for bulky, hot media
|
|
7355
|
+
* (recordings, event media) that should stay off the appData disk.
|
|
7356
|
+
*
|
|
7357
|
+
* Only affects the seeded default's `basePath`; operators can repoint any
|
|
7358
|
+
* location afterwards, and a `defaultsTo` slot inherits its parent's root
|
|
7359
|
+
* regardless of this field. Absent (the common case) is treated as `'data'`.
|
|
7360
|
+
*/
|
|
7361
|
+
defaultRoot: _enum(["data", "media"]).optional()
|
|
7178
7362
|
});
|
|
7179
7363
|
var DecoderStatsSchema = object({
|
|
7180
7364
|
inputFps: number(),
|
|
@@ -7601,6 +7785,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
|
|
|
7601
7785
|
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7602
7786
|
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7603
7787
|
/**
|
|
7788
|
+
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7789
|
+
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
7790
|
+
* failure — both are non-fatal to the host: read paths degrade to "skip link".
|
|
7791
|
+
*/
|
|
7792
|
+
/** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
|
|
7793
|
+
* the failure is anchored to a character (author-facing inline feedback). */
|
|
7794
|
+
var ExpressionParseError = class extends Error {
|
|
7795
|
+
position;
|
|
7796
|
+
constructor(message, position) {
|
|
7797
|
+
super(message);
|
|
7798
|
+
this.name = "ExpressionParseError";
|
|
7799
|
+
this.position = position;
|
|
7800
|
+
}
|
|
7801
|
+
};
|
|
7802
|
+
/** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
|
|
7803
|
+
* result, unknown builtin, step-budget exceeded). */
|
|
7804
|
+
var ExpressionEvalError = class extends Error {
|
|
7805
|
+
constructor(message) {
|
|
7806
|
+
super(message);
|
|
7807
|
+
this.name = "ExpressionEvalError";
|
|
7808
|
+
}
|
|
7809
|
+
};
|
|
7810
|
+
/**
|
|
7811
|
+
* Resource-bound constants for the safe expression engine.
|
|
7812
|
+
*
|
|
7813
|
+
* Every bound is defense-in-depth: the grammar is non-Turing-complete (no
|
|
7814
|
+
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
7815
|
+
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
7816
|
+
* work a single author-supplied expression can request, so a hostile or
|
|
7817
|
+
* accidental pathological string can never spend unbounded CPU/memory.
|
|
7818
|
+
*/
|
|
7819
|
+
/** Max source length (chars) — checked BEFORE tokenizing so a huge string is
|
|
7820
|
+
* rejected without allocation. */
|
|
7821
|
+
var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
|
|
7822
|
+
/** A legal binding / identifier name. */
|
|
7823
|
+
var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7824
|
+
/** Binding names an author may NOT use: `now` is auto-injected; the literal
|
|
7825
|
+
* keywords lex as values, not identifiers, so binding to them is meaningless. */
|
|
7826
|
+
var RESERVED_BINDING_NAMES = new Set([
|
|
7827
|
+
"now",
|
|
7828
|
+
"true",
|
|
7829
|
+
"false",
|
|
7830
|
+
"null"
|
|
7831
|
+
]);
|
|
7832
|
+
/**
|
|
7833
|
+
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
7834
|
+
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
7835
|
+
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
7836
|
+
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
7837
|
+
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
7838
|
+
* is a parse error with a source position, so member access / assignment /
|
|
7839
|
+
* template literals are lexically impossible.
|
|
7840
|
+
*/
|
|
7841
|
+
var KEYWORDS = new Set([
|
|
7842
|
+
"true",
|
|
7843
|
+
"false",
|
|
7844
|
+
"null"
|
|
7845
|
+
]);
|
|
7846
|
+
function isDigit(ch) {
|
|
7847
|
+
return ch >= "0" && ch <= "9";
|
|
7848
|
+
}
|
|
7849
|
+
function isIdentStart(ch) {
|
|
7850
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
7851
|
+
}
|
|
7852
|
+
function isIdentPart(ch) {
|
|
7853
|
+
return isIdentStart(ch) || isDigit(ch);
|
|
7854
|
+
}
|
|
7855
|
+
function isWhitespace(ch) {
|
|
7856
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
7857
|
+
}
|
|
7858
|
+
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
7859
|
+
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
7860
|
+
* string. */
|
|
7861
|
+
function tokenize(source) {
|
|
7862
|
+
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
7863
|
+
const tokens = [];
|
|
7864
|
+
let i = 0;
|
|
7865
|
+
const n = source.length;
|
|
7866
|
+
while (i < n) {
|
|
7867
|
+
const ch = source[i];
|
|
7868
|
+
if (isWhitespace(ch)) {
|
|
7869
|
+
i += 1;
|
|
7870
|
+
continue;
|
|
7871
|
+
}
|
|
7872
|
+
if (isDigit(ch)) {
|
|
7873
|
+
const start = i;
|
|
7874
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7875
|
+
if (i < n && source[i] === ".") {
|
|
7876
|
+
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
7877
|
+
i += 1;
|
|
7878
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7879
|
+
}
|
|
7880
|
+
const text = source.slice(start, i);
|
|
7881
|
+
const value = Number(text);
|
|
7882
|
+
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
7883
|
+
tokens.push({
|
|
7884
|
+
type: "number",
|
|
7885
|
+
value,
|
|
7886
|
+
pos: start
|
|
7887
|
+
});
|
|
7888
|
+
continue;
|
|
7889
|
+
}
|
|
7890
|
+
if (ch === "'" || ch === "\"") {
|
|
7891
|
+
const quote = ch;
|
|
7892
|
+
const start = i;
|
|
7893
|
+
i += 1;
|
|
7894
|
+
let out = "";
|
|
7895
|
+
let closed = false;
|
|
7896
|
+
while (i < n) {
|
|
7897
|
+
const c = source[i];
|
|
7898
|
+
if (c === "\\") {
|
|
7899
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
7900
|
+
if (next === "\\" || next === "'" || next === "\"") {
|
|
7901
|
+
out += next;
|
|
7902
|
+
i += 2;
|
|
7903
|
+
continue;
|
|
7904
|
+
}
|
|
7905
|
+
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
7906
|
+
}
|
|
7907
|
+
if (c === quote) {
|
|
7908
|
+
closed = true;
|
|
7909
|
+
i += 1;
|
|
7910
|
+
break;
|
|
7911
|
+
}
|
|
7912
|
+
out += c;
|
|
7913
|
+
i += 1;
|
|
7914
|
+
}
|
|
7915
|
+
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
7916
|
+
tokens.push({
|
|
7917
|
+
type: "string",
|
|
7918
|
+
value: out,
|
|
7919
|
+
pos: start
|
|
7920
|
+
});
|
|
7921
|
+
continue;
|
|
7922
|
+
}
|
|
7923
|
+
if (isIdentStart(ch)) {
|
|
7924
|
+
const start = i;
|
|
7925
|
+
while (i < n && isIdentPart(source[i])) i += 1;
|
|
7926
|
+
const text = source.slice(start, i);
|
|
7927
|
+
if (KEYWORDS.has(text)) tokens.push({
|
|
7928
|
+
type: "keyword",
|
|
7929
|
+
keyword: keywordOf(text),
|
|
7930
|
+
pos: start
|
|
7931
|
+
});
|
|
7932
|
+
else tokens.push({
|
|
7933
|
+
type: "identifier",
|
|
7934
|
+
name: text,
|
|
7935
|
+
pos: start
|
|
7936
|
+
});
|
|
7937
|
+
continue;
|
|
7938
|
+
}
|
|
7939
|
+
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
7940
|
+
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
7941
|
+
tokens.push({
|
|
7942
|
+
type: "punct",
|
|
7943
|
+
punct: two,
|
|
7944
|
+
pos: i
|
|
7945
|
+
});
|
|
7946
|
+
i += 2;
|
|
7947
|
+
continue;
|
|
7948
|
+
}
|
|
7949
|
+
if (isSinglePunct(ch)) {
|
|
7950
|
+
tokens.push({
|
|
7951
|
+
type: "punct",
|
|
7952
|
+
punct: ch,
|
|
7953
|
+
pos: i
|
|
7954
|
+
});
|
|
7955
|
+
i += 1;
|
|
7956
|
+
continue;
|
|
7957
|
+
}
|
|
7958
|
+
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
7959
|
+
}
|
|
7960
|
+
tokens.push({
|
|
7961
|
+
type: "eof",
|
|
7962
|
+
pos: n
|
|
7963
|
+
});
|
|
7964
|
+
return tokens;
|
|
7965
|
+
}
|
|
7966
|
+
function keywordOf(text) {
|
|
7967
|
+
if (text === "true") return "true";
|
|
7968
|
+
if (text === "false") return "false";
|
|
7969
|
+
return "null";
|
|
7970
|
+
}
|
|
7971
|
+
function isSinglePunct(ch) {
|
|
7972
|
+
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
7973
|
+
}
|
|
7974
|
+
/**
|
|
7975
|
+
* Frozen, null-prototype builtin function table for the expression engine
|
|
7976
|
+
* (spec §4 rule 4). The table is the SOLE surface of callable functions: the
|
|
7977
|
+
* parser rejects any callee not in it, and the evaluator gates each call on an
|
|
7978
|
+
* own-property check against it.
|
|
7979
|
+
*
|
|
7980
|
+
* Because the object has a NULL prototype AND is `Object.freeze`d:
|
|
7981
|
+
* - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
|
|
7982
|
+
* - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
|
|
7983
|
+
* (there is no `Object.prototype` in the chain), so those names are not
|
|
7984
|
+
* callable — they are simply "unknown function" at parse time.
|
|
7985
|
+
*
|
|
7986
|
+
* Every numeric argument is validated as a finite number and every numeric
|
|
7987
|
+
* RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
|
|
7988
|
+
* (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
|
|
7989
|
+
* closed rather than emitting a garbage value.
|
|
7990
|
+
*/
|
|
7991
|
+
function asFiniteNumber(value, name, index) {
|
|
7992
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
7993
|
+
return value;
|
|
7994
|
+
}
|
|
7995
|
+
function asString$1(value, name, index) {
|
|
7996
|
+
if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
|
|
7997
|
+
return value;
|
|
7998
|
+
}
|
|
7999
|
+
function finiteResult(value, name) {
|
|
8000
|
+
if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
|
|
8001
|
+
return value;
|
|
8002
|
+
}
|
|
8003
|
+
function allFiniteNumbers(args, name) {
|
|
8004
|
+
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
8005
|
+
}
|
|
8006
|
+
var INF = Number.POSITIVE_INFINITY;
|
|
8007
|
+
var table = {
|
|
8008
|
+
min: {
|
|
8009
|
+
minArgs: 1,
|
|
8010
|
+
maxArgs: INF,
|
|
8011
|
+
apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
|
|
8012
|
+
},
|
|
8013
|
+
max: {
|
|
8014
|
+
minArgs: 1,
|
|
8015
|
+
maxArgs: INF,
|
|
8016
|
+
apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
|
|
8017
|
+
},
|
|
8018
|
+
abs: {
|
|
8019
|
+
minArgs: 1,
|
|
8020
|
+
maxArgs: 1,
|
|
8021
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
8022
|
+
},
|
|
8023
|
+
floor: {
|
|
8024
|
+
minArgs: 1,
|
|
8025
|
+
maxArgs: 1,
|
|
8026
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
8027
|
+
},
|
|
8028
|
+
ceil: {
|
|
8029
|
+
minArgs: 1,
|
|
8030
|
+
maxArgs: 1,
|
|
8031
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
8032
|
+
},
|
|
8033
|
+
sqrt: {
|
|
8034
|
+
minArgs: 1,
|
|
8035
|
+
maxArgs: 1,
|
|
8036
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
8037
|
+
},
|
|
8038
|
+
round: {
|
|
8039
|
+
minArgs: 1,
|
|
8040
|
+
maxArgs: 2,
|
|
8041
|
+
apply: (args) => {
|
|
8042
|
+
const x = asFiniteNumber(args[0], "round", 0);
|
|
8043
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
8044
|
+
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
8045
|
+
const factor = 10 ** digits;
|
|
8046
|
+
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
8047
|
+
}
|
|
8048
|
+
},
|
|
8049
|
+
pow: {
|
|
8050
|
+
minArgs: 2,
|
|
8051
|
+
maxArgs: 2,
|
|
8052
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
8053
|
+
},
|
|
8054
|
+
clamp: {
|
|
8055
|
+
minArgs: 3,
|
|
8056
|
+
maxArgs: 3,
|
|
8057
|
+
apply: (args) => {
|
|
8058
|
+
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
8059
|
+
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
8060
|
+
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
8061
|
+
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
8062
|
+
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
8063
|
+
}
|
|
8064
|
+
},
|
|
8065
|
+
avg: {
|
|
8066
|
+
minArgs: 1,
|
|
8067
|
+
maxArgs: INF,
|
|
8068
|
+
apply: (args) => {
|
|
8069
|
+
const nums = allFiniteNumbers(args, "avg");
|
|
8070
|
+
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
8071
|
+
}
|
|
8072
|
+
},
|
|
8073
|
+
sum: {
|
|
8074
|
+
minArgs: 1,
|
|
8075
|
+
maxArgs: INF,
|
|
8076
|
+
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
8077
|
+
},
|
|
8078
|
+
coalesce: {
|
|
8079
|
+
minArgs: 1,
|
|
8080
|
+
maxArgs: INF,
|
|
8081
|
+
apply: (args) => {
|
|
8082
|
+
for (const a of args) if (a !== null) return a;
|
|
8083
|
+
return null;
|
|
8084
|
+
}
|
|
8085
|
+
},
|
|
8086
|
+
age: {
|
|
8087
|
+
minArgs: 2,
|
|
8088
|
+
maxArgs: 2,
|
|
8089
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
8090
|
+
},
|
|
8091
|
+
convert: {
|
|
8092
|
+
minArgs: 3,
|
|
8093
|
+
maxArgs: 3,
|
|
8094
|
+
apply: (args, hooks) => {
|
|
8095
|
+
const x = asFiniteNumber(args[0], "convert", 0);
|
|
8096
|
+
const from = asString$1(args[1], "convert", 1).trim();
|
|
8097
|
+
const to = asString$1(args[2], "convert", 2).trim();
|
|
8098
|
+
if (hooks.convert) {
|
|
8099
|
+
const out = hooks.convert(x, from, to);
|
|
8100
|
+
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
8101
|
+
return finiteResult(out, "convert");
|
|
8102
|
+
}
|
|
8103
|
+
if (from === to) return x;
|
|
8104
|
+
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
8105
|
+
}
|
|
8106
|
+
}
|
|
8107
|
+
};
|
|
8108
|
+
Object.freeze(Object.assign(Object.create(null), table));
|
|
8109
|
+
/** The set of valid builtin names — used by the parser to reject unknown
|
|
8110
|
+
* callees at parse time (immediate author feedback). */
|
|
8111
|
+
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
8112
|
+
/**
|
|
8113
|
+
* Pratt (precedence-climbing) parser for the safe expression mini-language.
|
|
8114
|
+
*
|
|
8115
|
+
* Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
|
|
8116
|
+
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
8117
|
+
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
8118
|
+
* string validated against the builtin table at parse time, so an unknown
|
|
8119
|
+
* function is rejected immediately (author feedback) and a persisted expression
|
|
8120
|
+
* that references a since-removed builtin degrades at read.
|
|
8121
|
+
*
|
|
8122
|
+
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
8123
|
+
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
8124
|
+
*/
|
|
8125
|
+
/** Binary/logical operator precedence (higher binds tighter). */
|
|
8126
|
+
var BINARY_PRECEDENCE = {
|
|
8127
|
+
"||": 1,
|
|
8128
|
+
"&&": 2,
|
|
8129
|
+
"==": 3,
|
|
8130
|
+
"!=": 3,
|
|
8131
|
+
"<": 4,
|
|
8132
|
+
"<=": 4,
|
|
8133
|
+
">": 4,
|
|
8134
|
+
">=": 4,
|
|
8135
|
+
"+": 5,
|
|
8136
|
+
"-": 5,
|
|
8137
|
+
"*": 6,
|
|
8138
|
+
"/": 6,
|
|
8139
|
+
"%": 6
|
|
8140
|
+
};
|
|
8141
|
+
function isLogicalOp(op) {
|
|
8142
|
+
return op === "&&" || op === "||";
|
|
8143
|
+
}
|
|
8144
|
+
function isBinaryOp(op) {
|
|
8145
|
+
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
8146
|
+
}
|
|
8147
|
+
var Parser = class {
|
|
8148
|
+
tokens;
|
|
8149
|
+
pos = 0;
|
|
8150
|
+
nodeCount = 0;
|
|
8151
|
+
identifiers = /* @__PURE__ */ new Set();
|
|
8152
|
+
callees = /* @__PURE__ */ new Set();
|
|
8153
|
+
constructor(tokens) {
|
|
8154
|
+
this.tokens = tokens;
|
|
8155
|
+
}
|
|
8156
|
+
parse() {
|
|
8157
|
+
const ast = this.parseTernary();
|
|
8158
|
+
const tok = this.peek();
|
|
8159
|
+
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
8160
|
+
return {
|
|
8161
|
+
ast,
|
|
8162
|
+
identifiers: this.identifiers,
|
|
8163
|
+
callees: this.callees,
|
|
8164
|
+
nodeCount: this.nodeCount
|
|
8165
|
+
};
|
|
8166
|
+
}
|
|
8167
|
+
peek() {
|
|
8168
|
+
return this.tokens[this.pos];
|
|
8169
|
+
}
|
|
8170
|
+
next() {
|
|
8171
|
+
return this.tokens[this.pos++];
|
|
8172
|
+
}
|
|
8173
|
+
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
8174
|
+
expectPunct(punct) {
|
|
8175
|
+
const tok = this.peek();
|
|
8176
|
+
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
8177
|
+
this.pos += 1;
|
|
8178
|
+
}
|
|
8179
|
+
matchPunct(punct) {
|
|
8180
|
+
const tok = this.peek();
|
|
8181
|
+
if (tok.type === "punct" && tok.punct === punct) {
|
|
8182
|
+
this.pos += 1;
|
|
8183
|
+
return true;
|
|
8184
|
+
}
|
|
8185
|
+
return false;
|
|
8186
|
+
}
|
|
8187
|
+
countNode() {
|
|
8188
|
+
this.nodeCount += 1;
|
|
8189
|
+
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
8190
|
+
}
|
|
8191
|
+
parseTernary() {
|
|
8192
|
+
const test = this.parseBinary(1);
|
|
8193
|
+
if (this.matchPunct("?")) {
|
|
8194
|
+
const consequent = this.parseTernary();
|
|
8195
|
+
this.expectPunct(":");
|
|
8196
|
+
const alternate = this.parseTernary();
|
|
8197
|
+
this.countNode();
|
|
8198
|
+
return {
|
|
8199
|
+
kind: "conditional",
|
|
8200
|
+
test,
|
|
8201
|
+
consequent,
|
|
8202
|
+
alternate
|
|
8203
|
+
};
|
|
8204
|
+
}
|
|
8205
|
+
return test;
|
|
8206
|
+
}
|
|
8207
|
+
parseBinary(minPrec) {
|
|
8208
|
+
let left = this.parseUnary();
|
|
8209
|
+
for (;;) {
|
|
8210
|
+
const tok = this.peek();
|
|
8211
|
+
if (tok.type !== "punct") break;
|
|
8212
|
+
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
8213
|
+
if (prec === void 0 || prec < minPrec) break;
|
|
8214
|
+
const op = tok.punct;
|
|
8215
|
+
this.pos += 1;
|
|
8216
|
+
const right = this.parseBinary(prec + 1);
|
|
8217
|
+
this.countNode();
|
|
8218
|
+
if (isLogicalOp(op)) left = {
|
|
8219
|
+
kind: "logical",
|
|
8220
|
+
op,
|
|
8221
|
+
left,
|
|
8222
|
+
right
|
|
8223
|
+
};
|
|
8224
|
+
else if (isBinaryOp(op)) left = {
|
|
8225
|
+
kind: "binary",
|
|
8226
|
+
op,
|
|
8227
|
+
left,
|
|
8228
|
+
right
|
|
8229
|
+
};
|
|
8230
|
+
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
8231
|
+
}
|
|
8232
|
+
return left;
|
|
8233
|
+
}
|
|
8234
|
+
parseUnary() {
|
|
8235
|
+
const tok = this.peek();
|
|
8236
|
+
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
8237
|
+
const op = tok.punct;
|
|
8238
|
+
this.pos += 1;
|
|
8239
|
+
const operand = this.parseUnary();
|
|
8240
|
+
this.countNode();
|
|
8241
|
+
return {
|
|
8242
|
+
kind: "unary",
|
|
8243
|
+
op,
|
|
8244
|
+
operand
|
|
8245
|
+
};
|
|
8246
|
+
}
|
|
8247
|
+
return this.parsePrimary();
|
|
8248
|
+
}
|
|
8249
|
+
parsePrimary() {
|
|
8250
|
+
const tok = this.next();
|
|
8251
|
+
switch (tok.type) {
|
|
8252
|
+
case "number":
|
|
8253
|
+
this.countNode();
|
|
8254
|
+
return {
|
|
8255
|
+
kind: "literal",
|
|
8256
|
+
value: tok.value
|
|
8257
|
+
};
|
|
8258
|
+
case "string":
|
|
8259
|
+
this.countNode();
|
|
8260
|
+
return {
|
|
8261
|
+
kind: "literal",
|
|
8262
|
+
value: tok.value
|
|
8263
|
+
};
|
|
8264
|
+
case "keyword":
|
|
8265
|
+
this.countNode();
|
|
8266
|
+
return {
|
|
8267
|
+
kind: "literal",
|
|
8268
|
+
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
8269
|
+
};
|
|
8270
|
+
case "identifier": {
|
|
8271
|
+
const nextTok = this.peek();
|
|
8272
|
+
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
8273
|
+
this.identifiers.add(tok.name);
|
|
8274
|
+
this.countNode();
|
|
8275
|
+
return {
|
|
8276
|
+
kind: "identifier",
|
|
8277
|
+
name: tok.name
|
|
8278
|
+
};
|
|
8279
|
+
}
|
|
8280
|
+
case "punct":
|
|
8281
|
+
if (tok.punct === "(") {
|
|
8282
|
+
const inner = this.parseTernary();
|
|
8283
|
+
this.expectPunct(")");
|
|
8284
|
+
return inner;
|
|
8285
|
+
}
|
|
8286
|
+
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
8287
|
+
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
8288
|
+
}
|
|
8289
|
+
}
|
|
8290
|
+
parseCall(callee, pos) {
|
|
8291
|
+
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
8292
|
+
this.expectPunct("(");
|
|
8293
|
+
const args = [];
|
|
8294
|
+
if (!this.matchPunct(")")) for (;;) {
|
|
8295
|
+
args.push(this.parseTernary());
|
|
8296
|
+
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
8297
|
+
if (this.matchPunct(",")) continue;
|
|
8298
|
+
this.expectPunct(")");
|
|
8299
|
+
break;
|
|
8300
|
+
}
|
|
8301
|
+
this.callees.add(callee);
|
|
8302
|
+
this.countNode();
|
|
8303
|
+
return {
|
|
8304
|
+
kind: "call",
|
|
8305
|
+
callee,
|
|
8306
|
+
args
|
|
8307
|
+
};
|
|
8308
|
+
}
|
|
8309
|
+
};
|
|
8310
|
+
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
8311
|
+
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
8312
|
+
function parseExpression(source) {
|
|
8313
|
+
return new Parser(tokenize(source)).parse();
|
|
8314
|
+
}
|
|
8315
|
+
Object.freeze({});
|
|
8316
|
+
/**
|
|
8317
|
+
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
8318
|
+
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
8319
|
+
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
8320
|
+
* one per read on a hot resolve path.
|
|
8321
|
+
*
|
|
8322
|
+
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
8323
|
+
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
8324
|
+
* callers is safe and maximises hit rate.
|
|
8325
|
+
*/
|
|
8326
|
+
var cache = /* @__PURE__ */ new Map();
|
|
8327
|
+
function getCached(source) {
|
|
8328
|
+
const hit = cache.get(source);
|
|
8329
|
+
if (hit !== void 0) {
|
|
8330
|
+
cache.delete(source);
|
|
8331
|
+
cache.set(source, hit);
|
|
8332
|
+
return hit;
|
|
8333
|
+
}
|
|
8334
|
+
let result;
|
|
8335
|
+
try {
|
|
8336
|
+
result = {
|
|
8337
|
+
ok: true,
|
|
8338
|
+
parsed: parseExpression(source)
|
|
8339
|
+
};
|
|
8340
|
+
} catch (err) {
|
|
8341
|
+
result = {
|
|
8342
|
+
ok: false,
|
|
8343
|
+
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
8344
|
+
};
|
|
8345
|
+
}
|
|
8346
|
+
cache.set(source, result);
|
|
8347
|
+
if (cache.size > 256) {
|
|
8348
|
+
const oldest = cache.keys().next().value;
|
|
8349
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
8350
|
+
}
|
|
8351
|
+
return result;
|
|
8352
|
+
}
|
|
8353
|
+
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
8354
|
+
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
8355
|
+
function compileExpressionSafe(source) {
|
|
8356
|
+
return getCached(source);
|
|
8357
|
+
}
|
|
8358
|
+
/**
|
|
8359
|
+
* Author-time validation. Returns `null` when the source is valid, else a
|
|
8360
|
+
* human-readable error message. Checks: the expression compiles; binding count
|
|
8361
|
+
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
8362
|
+
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
8363
|
+
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
8364
|
+
*/
|
|
8365
|
+
function validateExpressionSource(src) {
|
|
8366
|
+
const names = Object.keys(src.bindings);
|
|
8367
|
+
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
8368
|
+
for (const name of names) {
|
|
8369
|
+
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
8370
|
+
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
8371
|
+
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
8372
|
+
}
|
|
8373
|
+
const compiled = compileExpressionSafe(src.expr);
|
|
8374
|
+
if (!compiled.ok) return compiled.error;
|
|
8375
|
+
const bound = new Set(names);
|
|
8376
|
+
for (const id of compiled.parsed.identifiers) {
|
|
8377
|
+
if (id === "now") continue;
|
|
8378
|
+
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
8379
|
+
}
|
|
8380
|
+
return null;
|
|
8381
|
+
}
|
|
8382
|
+
/**
|
|
7604
8383
|
* Accessory device helpers — shared across drivers.
|
|
7605
8384
|
*
|
|
7606
8385
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -8075,6 +8854,10 @@ var RtspRestreamEntrySchema = object({
|
|
|
8075
8854
|
var BrokerRtspClientSchema = object({
|
|
8076
8855
|
sessionId: string(),
|
|
8077
8856
|
remoteAddr: string(),
|
|
8857
|
+
/** Client `User-Agent` (e.g. `recorder` for the recorder's RTSP pull), or
|
|
8858
|
+
* null/absent when the client sent none. Lets the UI label a consumer by
|
|
8859
|
+
* purpose. Optional so a client built against an older schema stays valid. */
|
|
8860
|
+
userAgent: string().nullish(),
|
|
8078
8861
|
playing: boolean(),
|
|
8079
8862
|
muted: boolean(),
|
|
8080
8863
|
connectedAt: number(),
|
|
@@ -9499,7 +10282,8 @@ var MotionAnalysisResultSchema = object({
|
|
|
9499
10282
|
});
|
|
9500
10283
|
method(object({
|
|
9501
10284
|
deviceId: number(),
|
|
9502
|
-
frame: FrameInputSchema
|
|
10285
|
+
frame: FrameInputSchema.optional(),
|
|
10286
|
+
frameHandle: FrameHandleSchema.optional()
|
|
9503
10287
|
}), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
|
|
9504
10288
|
deviceId: number(),
|
|
9505
10289
|
detected: boolean(),
|
|
@@ -9746,6 +10530,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
9746
10530
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
9747
10531
|
steps: array(PipelineStepInputSchema).min(1),
|
|
9748
10532
|
frame: FrameInputSchema.optional(),
|
|
10533
|
+
/**
|
|
10534
|
+
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
10535
|
+
* the decoded pixels live in. One more member of the one-of
|
|
10536
|
+
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
10537
|
+
*/
|
|
10538
|
+
frameHandle: FrameHandleSchema.optional(),
|
|
9749
10539
|
imageBase64: string().optional(),
|
|
9750
10540
|
/**
|
|
9751
10541
|
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
@@ -9955,6 +10745,31 @@ var ReportMotionInputSchema = object({
|
|
|
9955
10745
|
regions: array(MotionRegionSchema).readonly().optional()
|
|
9956
10746
|
});
|
|
9957
10747
|
/**
|
|
10748
|
+
* Where a runner gets a camera's decoded frames (cross-node Phase 2,
|
|
10749
|
+
* restream-owner model — P2c).
|
|
10750
|
+
*
|
|
10751
|
+
* - `local-broker` (DEFAULT): today's path — subscribe to the co-located
|
|
10752
|
+
* stream-broker's shm frame plane. Every pre-P2c attach payload (no
|
|
10753
|
+
* `frameSource` key) parses to this, so the field is additive with zero
|
|
10754
|
+
* behavior change.
|
|
10755
|
+
* - `remote-restream`: the detect node is NOT the camera's source-owner.
|
|
10756
|
+
* The runner acquires the owner's COMPRESSED passthrough restream
|
|
10757
|
+
* (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
|
|
10758
|
+
* double-pull guard) and decodes LOCALLY via a satellite frame plane +
|
|
10759
|
+
* pull-mode decoder session pinned to its own node. The shm ring stays
|
|
10760
|
+
* node-local; only H.264/H.265 packets cross the wire.
|
|
10761
|
+
* `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
|
|
10762
|
+
* when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
|
|
10763
|
+
* dials for the owner's restream.
|
|
10764
|
+
*/
|
|
10765
|
+
var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
|
|
10766
|
+
kind: literal("remote-restream"),
|
|
10767
|
+
/** The camera's source-owner node (slice 1: always the hub). */
|
|
10768
|
+
ownerNodeId: string(),
|
|
10769
|
+
/** Operator override for the owner host the runner dials. */
|
|
10770
|
+
hubHostnameOverride: string().optional()
|
|
10771
|
+
})]).describe("Per-camera frame-source mode for the runner (P2c)");
|
|
10772
|
+
/**
|
|
9958
10773
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
9959
10774
|
* specific runner instance via `attachCamera`. Carries everything the
|
|
9960
10775
|
* runner needs to subscribe to the local broker and execute inference.
|
|
@@ -10052,7 +10867,15 @@ var RunnerCameraConfigSchema = object({
|
|
|
10052
10867
|
*/
|
|
10053
10868
|
onboardMotionDrivesAnalyzer: boolean().default(true),
|
|
10054
10869
|
occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
|
|
10055
|
-
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
|
|
10870
|
+
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
|
|
10871
|
+
/**
|
|
10872
|
+
* Where this runner gets the camera's decoded frames (P2c). Defaulted so
|
|
10873
|
+
* every existing payload behaves as `local-broker` — the pre-Phase-2 path.
|
|
10874
|
+
* Populated with `remote-restream` by the orchestrator ONLY when the
|
|
10875
|
+
* camera's detect node differs from its source-owner (P2d, gated by the
|
|
10876
|
+
* `remoteSourcingNodes` rollout setting).
|
|
10877
|
+
*/
|
|
10878
|
+
frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
|
|
10056
10879
|
});
|
|
10057
10880
|
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;
|
|
10058
10881
|
/**
|
|
@@ -10417,6 +11240,113 @@ object({
|
|
|
10417
11240
|
lastFetchedAt: number()
|
|
10418
11241
|
});
|
|
10419
11242
|
DeviceType.Sensor;
|
|
11243
|
+
/**
|
|
11244
|
+
* Feeder connectivity / power status — mirrors the HA petkit device-status
|
|
11245
|
+
* enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
|
|
11246
|
+
* `on_batteries` (running on battery backup). `null` until first reported.
|
|
11247
|
+
*/
|
|
11248
|
+
var PetFeederDeviceStatusSchema = _enum([
|
|
11249
|
+
"normal",
|
|
11250
|
+
"offline",
|
|
11251
|
+
"on_batteries"
|
|
11252
|
+
]);
|
|
11253
|
+
var gramsPortion = number().int().min(4).max(200);
|
|
11254
|
+
object({
|
|
11255
|
+
/** Food currently in the bowl (grams). Null when the device has not
|
|
11256
|
+
* reported a reading yet. On dual-hopper models this is the combined
|
|
11257
|
+
* bowl reading; per-hopper levels live in `food1`/`food2`. */
|
|
11258
|
+
foodLevel: number().nullable(),
|
|
11259
|
+
/** Hopper-1 food level (grams) on dual-hopper feeders; null on
|
|
11260
|
+
* single-hopper models. */
|
|
11261
|
+
food1: number().nullable(),
|
|
11262
|
+
/** Hopper-2 food level (grams) on dual-hopper feeders; null on
|
|
11263
|
+
* single-hopper models. */
|
|
11264
|
+
food2: number().nullable(),
|
|
11265
|
+
/** Derived low-food flag — mirrors the HA `food_level` binary_sensor
|
|
11266
|
+
* (`device_class: problem`, on = low). True when the bowl is empty /
|
|
11267
|
+
* below the feeder's low threshold. */
|
|
11268
|
+
lowFood: boolean(),
|
|
11269
|
+
/** Battery charge 0..100 (%). Null on mains-powered models or when the
|
|
11270
|
+
* device has no battery reading. */
|
|
11271
|
+
batteryPower: number().min(0).max(100).nullable(),
|
|
11272
|
+
/** Days of desiccant life remaining. Null when the model has no
|
|
11273
|
+
* desiccant sensor. */
|
|
11274
|
+
desiccantLeftDays: number().nullable(),
|
|
11275
|
+
/** True while a feed is in progress. */
|
|
11276
|
+
feeding: boolean(),
|
|
11277
|
+
/** Decoded connectivity / power status (HA petkit device-status enum).
|
|
11278
|
+
* Null until the device has reported a status. */
|
|
11279
|
+
status: PetFeederDeviceStatusSchema.nullable(),
|
|
11280
|
+
/** Decoded human-readable fault message. Null (or the device's `no_error`
|
|
11281
|
+
* sentinel) means healthy; a non-null string is an active fault. Pairs
|
|
11282
|
+
* with `errorCode` for consumers that want the raw integer. */
|
|
11283
|
+
error: string().nullable(),
|
|
11284
|
+
/** Raw device error code (0 / null = no error). */
|
|
11285
|
+
errorCode: number().nullable(),
|
|
11286
|
+
/** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
|
|
11287
|
+
isDualHopper: boolean(),
|
|
11288
|
+
/** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
|
|
11289
|
+
childLock: boolean(),
|
|
11290
|
+
/** Front indicator-light setting. */
|
|
11291
|
+
indicatorLight: boolean(),
|
|
11292
|
+
/** Play a chime when dispensing. */
|
|
11293
|
+
feedSound: boolean(),
|
|
11294
|
+
/** Speaker / prompt volume level (device-scaled integer). */
|
|
11295
|
+
volume: number(),
|
|
11296
|
+
/** Ms epoch when the slice was last refreshed from the cloud. */
|
|
11297
|
+
lastFetchedAt: number()
|
|
11298
|
+
});
|
|
11299
|
+
DeviceType.PetFeeder, method(object({
|
|
11300
|
+
deviceId: number().int().nonnegative(),
|
|
11301
|
+
grams: gramsPortion.optional(),
|
|
11302
|
+
hopper1: gramsPortion.optional(),
|
|
11303
|
+
hopper2: gramsPortion.optional()
|
|
11304
|
+
}), _void(), {
|
|
11305
|
+
kind: "mutation",
|
|
11306
|
+
auth: "admin"
|
|
11307
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11308
|
+
kind: "mutation",
|
|
11309
|
+
auth: "admin"
|
|
11310
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11311
|
+
kind: "mutation",
|
|
11312
|
+
auth: "admin"
|
|
11313
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11314
|
+
kind: "mutation",
|
|
11315
|
+
auth: "admin"
|
|
11316
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11317
|
+
kind: "mutation",
|
|
11318
|
+
auth: "admin"
|
|
11319
|
+
}), method(object({
|
|
11320
|
+
deviceId: number().int().nonnegative(),
|
|
11321
|
+
soundId: number().int().nonnegative()
|
|
11322
|
+
}), _void(), {
|
|
11323
|
+
kind: "mutation",
|
|
11324
|
+
auth: "admin"
|
|
11325
|
+
}), method(object({
|
|
11326
|
+
deviceId: number().int().nonnegative(),
|
|
11327
|
+
on: boolean()
|
|
11328
|
+
}), _void(), {
|
|
11329
|
+
kind: "mutation",
|
|
11330
|
+
auth: "admin"
|
|
11331
|
+
}), method(object({
|
|
11332
|
+
deviceId: number().int().nonnegative(),
|
|
11333
|
+
on: boolean()
|
|
11334
|
+
}), _void(), {
|
|
11335
|
+
kind: "mutation",
|
|
11336
|
+
auth: "admin"
|
|
11337
|
+
}), method(object({
|
|
11338
|
+
deviceId: number().int().nonnegative(),
|
|
11339
|
+
on: boolean()
|
|
11340
|
+
}), _void(), {
|
|
11341
|
+
kind: "mutation",
|
|
11342
|
+
auth: "admin"
|
|
11343
|
+
}), method(object({
|
|
11344
|
+
deviceId: number().int().nonnegative(),
|
|
11345
|
+
level: number().int().nonnegative()
|
|
11346
|
+
}), _void(), {
|
|
11347
|
+
kind: "mutation",
|
|
11348
|
+
auth: "admin"
|
|
11349
|
+
});
|
|
10420
11350
|
object({
|
|
10421
11351
|
/** Instantaneous power draw in watts. */
|
|
10422
11352
|
watts: number().optional(),
|
|
@@ -12284,10 +13214,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
|
|
|
12284
13214
|
url: string()
|
|
12285
13215
|
}), _void()), method(object({
|
|
12286
13216
|
sessionId: string(),
|
|
12287
|
-
maxCount: number().default(1)
|
|
13217
|
+
maxCount: number().default(1),
|
|
13218
|
+
waitMs: number().optional()
|
|
12288
13219
|
}), array(DecodedFrameSchema)), method(object({
|
|
12289
13220
|
sessionId: string(),
|
|
12290
|
-
maxCount: number().default(1)
|
|
13221
|
+
maxCount: number().default(1),
|
|
13222
|
+
waitMs: number().optional()
|
|
12291
13223
|
}), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
|
|
12292
13224
|
sessionId: string(),
|
|
12293
13225
|
config: DecoderSessionConfigSchema.partial()
|
|
@@ -12599,14 +13531,63 @@ var ChildLayoutEntrySchema = object({
|
|
|
12599
13531
|
collapsed: boolean().optional()
|
|
12600
13532
|
});
|
|
12601
13533
|
/** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
|
|
12602
|
-
* `device-management.ts`.
|
|
13534
|
+
* `device-management.ts`. Source is a union: a FIELD source copies a sibling
|
|
13535
|
+
* accessory's status field (`kind` optional/absent for wire compat); a
|
|
13536
|
+
* LITERAL source carries a per-device constant (no sibling is read); a
|
|
13537
|
+
* GLOBAL source (P2e) copies ANY device's status field, addressed by the
|
|
13538
|
+
* source device's full re-sync-stable `stableId`. */
|
|
13539
|
+
var DeviceLinkFieldSourceSchema = object({
|
|
13540
|
+
kind: literal("field").optional(),
|
|
13541
|
+
sourceKey: string(),
|
|
13542
|
+
cap: string(),
|
|
13543
|
+
fieldPath: string()
|
|
13544
|
+
});
|
|
13545
|
+
var DeviceLinkLiteralSourceSchema = object({
|
|
13546
|
+
kind: literal("literal"),
|
|
13547
|
+
value: union([
|
|
13548
|
+
string(),
|
|
13549
|
+
number(),
|
|
13550
|
+
boolean(),
|
|
13551
|
+
_null()
|
|
13552
|
+
])
|
|
13553
|
+
});
|
|
13554
|
+
var DeviceLinkGlobalSourceSchema = object({
|
|
13555
|
+
kind: literal("global"),
|
|
13556
|
+
sourceStableId: string(),
|
|
13557
|
+
cap: string(),
|
|
13558
|
+
fieldPath: string()
|
|
13559
|
+
});
|
|
13560
|
+
/** Expression source (Stage X): compute the target field from N named bindings
|
|
13561
|
+
* via the safe expression engine. Bindings are field | literal | global — never
|
|
13562
|
+
* another expression (no nesting). The `superRefine` runs the SAME author-time
|
|
13563
|
+
* validation as `validateExpressionSource` (compiles the expr, checks binding
|
|
13564
|
+
* names + identifier coverage) so every wire boundary that parses a DeviceLink
|
|
13565
|
+
* (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
|
|
13566
|
+
* Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
|
|
13567
|
+
var DeviceLinkExpressionSourceSchema = object({
|
|
13568
|
+
kind: literal("expression"),
|
|
13569
|
+
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
13570
|
+
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
|
|
13571
|
+
DeviceLinkFieldSourceSchema,
|
|
13572
|
+
DeviceLinkLiteralSourceSchema,
|
|
13573
|
+
DeviceLinkGlobalSourceSchema
|
|
13574
|
+
]))
|
|
13575
|
+
}).superRefine((src, ctx) => {
|
|
13576
|
+
const err = validateExpressionSource(src);
|
|
13577
|
+
if (err !== null) ctx.addIssue({
|
|
13578
|
+
code: "custom",
|
|
13579
|
+
message: err,
|
|
13580
|
+
path: ["expr"]
|
|
13581
|
+
});
|
|
13582
|
+
});
|
|
12603
13583
|
var DeviceLinkSchema = object({
|
|
12604
13584
|
id: string(),
|
|
12605
|
-
source:
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
|
|
12609
|
-
|
|
13585
|
+
source: union([
|
|
13586
|
+
DeviceLinkFieldSourceSchema,
|
|
13587
|
+
DeviceLinkLiteralSourceSchema,
|
|
13588
|
+
DeviceLinkGlobalSourceSchema,
|
|
13589
|
+
DeviceLinkExpressionSourceSchema
|
|
13590
|
+
]),
|
|
12610
13591
|
target: object({
|
|
12611
13592
|
cap: string(),
|
|
12612
13593
|
fieldPath: string(),
|
|
@@ -12635,6 +13616,31 @@ var DeviceLinkSchema = object({
|
|
|
12635
13616
|
})
|
|
12636
13617
|
]).optional()
|
|
12637
13618
|
});
|
|
13619
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
13620
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
13621
|
+
var DeviceCapDisplayOverrideSchema = object({
|
|
13622
|
+
unit: string().min(1).optional(),
|
|
13623
|
+
precision: number().int().min(0).max(10).optional()
|
|
13624
|
+
});
|
|
13625
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
13626
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
13627
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
13628
|
+
var DeviceDisplayOverrideSchema = object({
|
|
13629
|
+
icon: string().min(1).optional(),
|
|
13630
|
+
label: string().min(1).optional(),
|
|
13631
|
+
unit: string().min(1).optional(),
|
|
13632
|
+
precision: number().int().min(0).max(10).optional(),
|
|
13633
|
+
hidden: boolean().optional(),
|
|
13634
|
+
perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
|
|
13635
|
+
});
|
|
13636
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
13637
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
13638
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
13639
|
+
var RoleDisplayDefaultSchema = object({
|
|
13640
|
+
unit: string().min(1).optional(),
|
|
13641
|
+
precision: number().int().min(0).max(10).optional(),
|
|
13642
|
+
icon: string().min(1).optional()
|
|
13643
|
+
});
|
|
12638
13644
|
/**
|
|
12639
13645
|
* Serializable projection of a live IDevice.
|
|
12640
13646
|
* Returned by listAll, getDevice, getChildren.
|
|
@@ -12690,7 +13696,9 @@ var DeviceInfoSchema = object({
|
|
|
12690
13696
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
12691
13697
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
12692
13698
|
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
12693
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional()
|
|
13699
|
+
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
13700
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
13701
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
12694
13702
|
});
|
|
12695
13703
|
var ConfigEntrySchema = object({
|
|
12696
13704
|
key: string(),
|
|
@@ -12755,7 +13763,9 @@ var DeviceMetaSchema = object({
|
|
|
12755
13763
|
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
12756
13764
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
12757
13765
|
* Optional: only present for accessory children that carry a known role. */
|
|
12758
|
-
role: string().nullable().optional()
|
|
13766
|
+
role: string().nullable().optional(),
|
|
13767
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
13768
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
12759
13769
|
});
|
|
12760
13770
|
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
12761
13771
|
var ConfigUISchemaOutput = unknown().nullable();
|
|
@@ -12849,7 +13859,19 @@ method(object({
|
|
|
12849
13859
|
}), _void(), {
|
|
12850
13860
|
kind: "mutation",
|
|
12851
13861
|
auth: "admin"
|
|
12852
|
-
}), method(object({
|
|
13862
|
+
}), method(object({
|
|
13863
|
+
deviceId: number(),
|
|
13864
|
+
display: DeviceDisplayOverrideSchema.nullable()
|
|
13865
|
+
}), _void(), {
|
|
13866
|
+
kind: "mutation",
|
|
13867
|
+
auth: "admin"
|
|
13868
|
+
}), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
|
|
13869
|
+
kind: "mutation",
|
|
13870
|
+
auth: "admin"
|
|
13871
|
+
}), method(object({
|
|
13872
|
+
deviceId: number(),
|
|
13873
|
+
includeSynthesizable: boolean().optional()
|
|
13874
|
+
}), object({ caps: array(object({
|
|
12853
13875
|
cap: string(),
|
|
12854
13876
|
fields: array(object({
|
|
12855
13877
|
path: string(),
|
|
@@ -12859,8 +13881,13 @@ method(object({
|
|
|
12859
13881
|
"boolean",
|
|
12860
13882
|
"enum"
|
|
12861
13883
|
]),
|
|
12862
|
-
enumValues: array(string()).optional()
|
|
12863
|
-
|
|
13884
|
+
enumValues: array(string()).optional(),
|
|
13885
|
+
item: boolean().optional()
|
|
13886
|
+
})).readonly(),
|
|
13887
|
+
itemArray: object({
|
|
13888
|
+
path: string(),
|
|
13889
|
+
keyField: string()
|
|
13890
|
+
}).optional()
|
|
12864
13891
|
})).readonly() }), { kind: "query" }), method(object({
|
|
12865
13892
|
deviceId: number(),
|
|
12866
13893
|
role: string().nullable()
|
|
@@ -12930,7 +13957,11 @@ method(object({
|
|
|
12930
13957
|
deviceId: number(),
|
|
12931
13958
|
entries: array(object({
|
|
12932
13959
|
capName: string(),
|
|
12933
|
-
kind: _enum([
|
|
13960
|
+
kind: _enum([
|
|
13961
|
+
"native",
|
|
13962
|
+
"wrapped",
|
|
13963
|
+
"linked"
|
|
13964
|
+
]),
|
|
12934
13965
|
providerAddonId: string(),
|
|
12935
13966
|
providerNodeId: string(),
|
|
12936
13967
|
nativeAddonId: string()
|
|
@@ -12939,7 +13970,11 @@ method(object({
|
|
|
12939
13970
|
deviceId: number(),
|
|
12940
13971
|
entries: array(object({
|
|
12941
13972
|
capName: string(),
|
|
12942
|
-
kind: _enum([
|
|
13973
|
+
kind: _enum([
|
|
13974
|
+
"native",
|
|
13975
|
+
"wrapped",
|
|
13976
|
+
"linked"
|
|
13977
|
+
]),
|
|
12943
13978
|
providerAddonId: string(),
|
|
12944
13979
|
providerNodeId: string(),
|
|
12945
13980
|
nativeAddonId: string()
|
|
@@ -13429,7 +14464,7 @@ var AddBrokerInputSchema = object({
|
|
|
13429
14464
|
});
|
|
13430
14465
|
var AddBrokerResultSchema = object({ id: string() });
|
|
13431
14466
|
var IdInputSchema = object({ id: string() });
|
|
13432
|
-
var TestResultSchema = discriminatedUnion("ok", [object({
|
|
14467
|
+
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
13433
14468
|
ok: literal(true),
|
|
13434
14469
|
latencyMs: number()
|
|
13435
14470
|
}), object({
|
|
@@ -13452,7 +14487,7 @@ var StatusSchema = object({
|
|
|
13452
14487
|
brokerCount: number(),
|
|
13453
14488
|
embeddedRunning: boolean()
|
|
13454
14489
|
});
|
|
13455
|
-
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);
|
|
14490
|
+
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);
|
|
13456
14491
|
var NetworkEndpointSchema = object({
|
|
13457
14492
|
url: string(),
|
|
13458
14493
|
hostname: string(),
|
|
@@ -13486,23 +14521,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
|
13486
14521
|
sourcePort: number().optional()
|
|
13487
14522
|
});
|
|
13488
14523
|
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
13489
|
-
|
|
13490
|
-
|
|
14524
|
+
/**
|
|
14525
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
14526
|
+
*
|
|
14527
|
+
* Apprise-derived model (see
|
|
14528
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
14529
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
14530
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
14531
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
14532
|
+
* message to what the kind supports — callers never special-case a service.
|
|
14533
|
+
*
|
|
14534
|
+
* DESIGN DECISIONS (locked):
|
|
14535
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
14536
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
14537
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
14538
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
14539
|
+
* alternative would fork the UI per addon and cannot host the
|
|
14540
|
+
* discovery→adopt flow.
|
|
14541
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
14542
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
14543
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
14544
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
14545
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
14546
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
14547
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
14548
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
14549
|
+
* base64 fallback needed.
|
|
14550
|
+
*
|
|
14551
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
14552
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
14553
|
+
* admin "Integrations" page.
|
|
14554
|
+
*/
|
|
14555
|
+
/**
|
|
14556
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
14557
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
14558
|
+
*/
|
|
14559
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
14560
|
+
"image",
|
|
14561
|
+
"video",
|
|
14562
|
+
"gif",
|
|
14563
|
+
"audio",
|
|
14564
|
+
"icon"
|
|
14565
|
+
]);
|
|
14566
|
+
/**
|
|
14567
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
14568
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
14569
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
14570
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
14571
|
+
*/
|
|
14572
|
+
var AttachmentSchema = object({
|
|
14573
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
14574
|
+
url: string().optional(),
|
|
14575
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
14576
|
+
mime: string().optional(),
|
|
14577
|
+
name: string().optional()
|
|
14578
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
14579
|
+
var NotificationFormatSchema = _enum([
|
|
14580
|
+
"text",
|
|
14581
|
+
"markdown",
|
|
14582
|
+
"html"
|
|
14583
|
+
]);
|
|
14584
|
+
/** A single tap-through action button. */
|
|
14585
|
+
var NotificationActionSchema = object({
|
|
14586
|
+
id: string(),
|
|
14587
|
+
label: string(),
|
|
14588
|
+
url: string().optional()
|
|
14589
|
+
});
|
|
14590
|
+
/**
|
|
14591
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
14592
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
14593
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
14594
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
14595
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
14596
|
+
* `priority` for that one target.
|
|
14597
|
+
*/
|
|
14598
|
+
var NotificationSchema = object({
|
|
13491
14599
|
body: string(),
|
|
13492
|
-
|
|
14600
|
+
title: string().optional(),
|
|
14601
|
+
format: NotificationFormatSchema.default("text"),
|
|
14602
|
+
priority: number().int().min(1).max(5).default(3),
|
|
14603
|
+
level: string().optional(),
|
|
14604
|
+
attachments: array(AttachmentSchema).optional(),
|
|
14605
|
+
clickUrl: string().optional(),
|
|
14606
|
+
actions: array(NotificationActionSchema).optional(),
|
|
14607
|
+
sound: string().optional(),
|
|
14608
|
+
ttl: number().optional(),
|
|
14609
|
+
tag: string().optional(),
|
|
13493
14610
|
deviceId: number().optional(),
|
|
13494
14611
|
eventId: string().optional(),
|
|
13495
|
-
priority: _enum([
|
|
13496
|
-
"low",
|
|
13497
|
-
"normal",
|
|
13498
|
-
"high",
|
|
13499
|
-
"critical"
|
|
13500
|
-
]).default("normal"),
|
|
13501
14612
|
metadata: record(string(), unknown()).optional()
|
|
13502
|
-
})
|
|
14613
|
+
});
|
|
14614
|
+
/** One declared native severity/priority level for a kind. */
|
|
14615
|
+
var TargetKindLevelSchema = object({
|
|
14616
|
+
id: string(),
|
|
14617
|
+
label: string(),
|
|
14618
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
14619
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
14620
|
+
flags: object({
|
|
14621
|
+
critical: boolean().optional(),
|
|
14622
|
+
silent: boolean().optional(),
|
|
14623
|
+
noPush: boolean().optional()
|
|
14624
|
+
}).optional(),
|
|
14625
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
14626
|
+
requires: array(string()).optional(),
|
|
14627
|
+
description: string().optional()
|
|
14628
|
+
});
|
|
14629
|
+
/** The full capability block consulted before dispatch. */
|
|
14630
|
+
var TargetKindCapsSchema = object({
|
|
14631
|
+
attachments: object({
|
|
14632
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
14633
|
+
mode: _enum([
|
|
14634
|
+
"url",
|
|
14635
|
+
"bytes",
|
|
14636
|
+
"both"
|
|
14637
|
+
]),
|
|
14638
|
+
max: number().int().nonnegative(),
|
|
14639
|
+
maxBytes: number().int().positive().optional()
|
|
14640
|
+
}),
|
|
14641
|
+
/** Max action buttons (0 = none). */
|
|
14642
|
+
actions: number().int().nonnegative(),
|
|
14643
|
+
levels: array(TargetKindLevelSchema),
|
|
14644
|
+
format: array(NotificationFormatSchema),
|
|
14645
|
+
clickUrl: boolean(),
|
|
14646
|
+
sound: boolean(),
|
|
14647
|
+
ttl: boolean(),
|
|
14648
|
+
bodyMaxLen: number().int().positive()
|
|
14649
|
+
});
|
|
14650
|
+
/**
|
|
14651
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
14652
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
14653
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
14654
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
14655
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
14656
|
+
*/
|
|
14657
|
+
var ConfigSchemaPassthrough = unknown();
|
|
14658
|
+
var TargetKindSchema = object({
|
|
14659
|
+
kind: string(),
|
|
14660
|
+
label: string(),
|
|
14661
|
+
icon: string(),
|
|
14662
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
14663
|
+
addonId: string(),
|
|
14664
|
+
configSchema: ConfigSchemaPassthrough,
|
|
14665
|
+
supportsDiscovery: boolean(),
|
|
14666
|
+
caps: TargetKindCapsSchema
|
|
14667
|
+
});
|
|
14668
|
+
/**
|
|
14669
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
14670
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
14671
|
+
* round-trip a stored secret to the UI.
|
|
14672
|
+
*/
|
|
14673
|
+
var TargetSchema = object({
|
|
14674
|
+
id: string(),
|
|
14675
|
+
name: string(),
|
|
14676
|
+
kind: string(),
|
|
14677
|
+
addonId: string(),
|
|
14678
|
+
enabled: boolean(),
|
|
14679
|
+
config: record(string(), unknown())
|
|
14680
|
+
});
|
|
14681
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
14682
|
+
var DiscoveredTargetSchema = object({
|
|
14683
|
+
kind: string(),
|
|
14684
|
+
suggestedName: string(),
|
|
14685
|
+
config: record(string(), unknown())
|
|
14686
|
+
});
|
|
14687
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
14688
|
+
var RenderedAsSchema = object({
|
|
14689
|
+
level: string(),
|
|
14690
|
+
format: NotificationFormatSchema,
|
|
14691
|
+
attachmentsSent: number().int().nonnegative(),
|
|
14692
|
+
actionsSent: number().int().nonnegative(),
|
|
14693
|
+
truncated: boolean(),
|
|
14694
|
+
dropped: array(string())
|
|
14695
|
+
});
|
|
14696
|
+
var SendResultSchema = object({
|
|
13503
14697
|
success: boolean(),
|
|
13504
|
-
error: string().optional()
|
|
13505
|
-
|
|
14698
|
+
error: string().optional(),
|
|
14699
|
+
renderedAs: RenderedAsSchema.optional()
|
|
14700
|
+
});
|
|
14701
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
14702
|
+
var TestResultSchema = SendResultSchema;
|
|
14703
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
|
|
14704
|
+
kind: string(),
|
|
14705
|
+
config: record(string(), unknown()).optional()
|
|
14706
|
+
}), array(DiscoveredTargetSchema)), method(object({
|
|
14707
|
+
targetId: string(),
|
|
14708
|
+
notification: NotificationSchema
|
|
14709
|
+
}), SendResultSchema, { kind: "mutation" }), method(object({
|
|
14710
|
+
targetId: string(),
|
|
14711
|
+
sample: NotificationSchema.optional()
|
|
14712
|
+
}), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
|
|
14713
|
+
targetId: string(),
|
|
14714
|
+
enabled: boolean()
|
|
14715
|
+
}), _void(), { kind: "mutation" });
|
|
13506
14716
|
/**
|
|
13507
14717
|
* Zod schemas for persisted record types.
|
|
13508
14718
|
*
|
|
@@ -16530,7 +17740,10 @@ var HwAccelBackendInputSchema = _enum([
|
|
|
16530
17740
|
"webgpu",
|
|
16531
17741
|
"none"
|
|
16532
17742
|
]).nullable().optional();
|
|
16533
|
-
var HwAccelResolutionSchema = object({
|
|
17743
|
+
var HwAccelResolutionSchema = object({
|
|
17744
|
+
preferred: array(string()).readonly(),
|
|
17745
|
+
rationale: string()
|
|
17746
|
+
});
|
|
16534
17747
|
var HardwareEncoderIdSchema = _enum([
|
|
16535
17748
|
"h264_videotoolbox",
|
|
16536
17749
|
"hevc_videotoolbox",
|
|
@@ -16635,10 +17848,7 @@ var ResolvedInferenceConfigSchema = object({
|
|
|
16635
17848
|
format: ModelFormatSchema,
|
|
16636
17849
|
reason: string()
|
|
16637
17850
|
});
|
|
16638
|
-
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
|
|
16639
|
-
prefer: HwAccelBackendInputSchema,
|
|
16640
|
-
nodeId: string().optional()
|
|
16641
|
-
}), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
17851
|
+
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
16642
17852
|
kind: "mutation",
|
|
16643
17853
|
auth: "admin"
|
|
16644
17854
|
}), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
|
|
@@ -16697,6 +17907,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
|
|
|
16697
17907
|
kind: "mutation",
|
|
16698
17908
|
auth: "admin"
|
|
16699
17909
|
});
|
|
17910
|
+
/**
|
|
17911
|
+
* `recording` cap — footage availability + HLS playback manifests + per-device
|
|
17912
|
+
* recording config. NOTE on events (source of truth, R5/C3): this cap carries
|
|
17913
|
+
* NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
|
|
17914
|
+
* events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
|
|
17915
|
+
* rows); the recorder's internal EventMap markers are ephemeral in-RAM
|
|
17916
|
+
* annotations that are not exposed here and must not be treated as an event
|
|
17917
|
+
* feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
|
|
17918
|
+
* (`interfaces/recording-config.ts`).
|
|
17919
|
+
*/
|
|
16700
17920
|
var RecordingStatusSchema = object({
|
|
16701
17921
|
deviceId: number(),
|
|
16702
17922
|
enabled: boolean(),
|
|
@@ -18333,6 +19553,12 @@ Object.freeze({
|
|
|
18333
19553
|
addonId: null,
|
|
18334
19554
|
access: "view"
|
|
18335
19555
|
},
|
|
19556
|
+
"deviceManager.getRoleDisplayDefaults": {
|
|
19557
|
+
capName: "device-manager",
|
|
19558
|
+
capScope: "system",
|
|
19559
|
+
addonId: null,
|
|
19560
|
+
access: "view"
|
|
19561
|
+
},
|
|
18336
19562
|
"deviceManager.getSettingsSchema": {
|
|
18337
19563
|
capName: "device-manager",
|
|
18338
19564
|
capScope: "system",
|
|
@@ -18483,6 +19709,12 @@ Object.freeze({
|
|
|
18483
19709
|
addonId: null,
|
|
18484
19710
|
access: "create"
|
|
18485
19711
|
},
|
|
19712
|
+
"deviceManager.setDisplay": {
|
|
19713
|
+
capName: "device-manager",
|
|
19714
|
+
capScope: "system",
|
|
19715
|
+
addonId: null,
|
|
19716
|
+
access: "create"
|
|
19717
|
+
},
|
|
18486
19718
|
"deviceManager.setIntegrationId": {
|
|
18487
19719
|
capName: "device-manager",
|
|
18488
19720
|
capScope: "system",
|
|
@@ -18525,6 +19757,12 @@ Object.freeze({
|
|
|
18525
19757
|
addonId: null,
|
|
18526
19758
|
access: "create"
|
|
18527
19759
|
},
|
|
19760
|
+
"deviceManager.setRoleDisplayDefaults": {
|
|
19761
|
+
capName: "device-manager",
|
|
19762
|
+
capScope: "system",
|
|
19763
|
+
addonId: null,
|
|
19764
|
+
access: "create"
|
|
19765
|
+
},
|
|
18528
19766
|
"deviceManager.setStreamProfileMap": {
|
|
18529
19767
|
capName: "device-manager",
|
|
18530
19768
|
capScope: "system",
|
|
@@ -19503,13 +20741,49 @@ Object.freeze({
|
|
|
19503
20741
|
addonId: null,
|
|
19504
20742
|
access: "create"
|
|
19505
20743
|
},
|
|
20744
|
+
"notificationOutput.deleteTarget": {
|
|
20745
|
+
capName: "notification-output",
|
|
20746
|
+
capScope: "system",
|
|
20747
|
+
addonId: null,
|
|
20748
|
+
access: "delete"
|
|
20749
|
+
},
|
|
20750
|
+
"notificationOutput.discoverTargets": {
|
|
20751
|
+
capName: "notification-output",
|
|
20752
|
+
capScope: "system",
|
|
20753
|
+
addonId: null,
|
|
20754
|
+
access: "view"
|
|
20755
|
+
},
|
|
20756
|
+
"notificationOutput.listTargetKinds": {
|
|
20757
|
+
capName: "notification-output",
|
|
20758
|
+
capScope: "system",
|
|
20759
|
+
addonId: null,
|
|
20760
|
+
access: "view"
|
|
20761
|
+
},
|
|
20762
|
+
"notificationOutput.listTargets": {
|
|
20763
|
+
capName: "notification-output",
|
|
20764
|
+
capScope: "system",
|
|
20765
|
+
addonId: null,
|
|
20766
|
+
access: "view"
|
|
20767
|
+
},
|
|
19506
20768
|
"notificationOutput.send": {
|
|
19507
20769
|
capName: "notification-output",
|
|
19508
20770
|
capScope: "system",
|
|
19509
20771
|
addonId: null,
|
|
19510
20772
|
access: "create"
|
|
19511
20773
|
},
|
|
19512
|
-
"notificationOutput.
|
|
20774
|
+
"notificationOutput.setTargetEnabled": {
|
|
20775
|
+
capName: "notification-output",
|
|
20776
|
+
capScope: "system",
|
|
20777
|
+
addonId: null,
|
|
20778
|
+
access: "create"
|
|
20779
|
+
},
|
|
20780
|
+
"notificationOutput.testTarget": {
|
|
20781
|
+
capName: "notification-output",
|
|
20782
|
+
capScope: "system",
|
|
20783
|
+
addonId: null,
|
|
20784
|
+
access: "create"
|
|
20785
|
+
},
|
|
20786
|
+
"notificationOutput.upsertTarget": {
|
|
19513
20787
|
capName: "notification-output",
|
|
19514
20788
|
capScope: "system",
|
|
19515
20789
|
addonId: null,
|
|
@@ -19539,6 +20813,66 @@ Object.freeze({
|
|
|
19539
20813
|
addonId: null,
|
|
19540
20814
|
access: "create"
|
|
19541
20815
|
},
|
|
20816
|
+
"petFeeder.callPet": {
|
|
20817
|
+
capName: "pet-feeder",
|
|
20818
|
+
capScope: "device",
|
|
20819
|
+
addonId: null,
|
|
20820
|
+
access: "create"
|
|
20821
|
+
},
|
|
20822
|
+
"petFeeder.cancelFeed": {
|
|
20823
|
+
capName: "pet-feeder",
|
|
20824
|
+
capScope: "device",
|
|
20825
|
+
addonId: null,
|
|
20826
|
+
access: "create"
|
|
20827
|
+
},
|
|
20828
|
+
"petFeeder.feed": {
|
|
20829
|
+
capName: "pet-feeder",
|
|
20830
|
+
capScope: "device",
|
|
20831
|
+
addonId: null,
|
|
20832
|
+
access: "create"
|
|
20833
|
+
},
|
|
20834
|
+
"petFeeder.markFoodReplenished": {
|
|
20835
|
+
capName: "pet-feeder",
|
|
20836
|
+
capScope: "device",
|
|
20837
|
+
addonId: null,
|
|
20838
|
+
access: "create"
|
|
20839
|
+
},
|
|
20840
|
+
"petFeeder.playSound": {
|
|
20841
|
+
capName: "pet-feeder",
|
|
20842
|
+
capScope: "device",
|
|
20843
|
+
addonId: null,
|
|
20844
|
+
access: "create"
|
|
20845
|
+
},
|
|
20846
|
+
"petFeeder.resetDesiccant": {
|
|
20847
|
+
capName: "pet-feeder",
|
|
20848
|
+
capScope: "device",
|
|
20849
|
+
addonId: null,
|
|
20850
|
+
access: "delete"
|
|
20851
|
+
},
|
|
20852
|
+
"petFeeder.setChildLock": {
|
|
20853
|
+
capName: "pet-feeder",
|
|
20854
|
+
capScope: "device",
|
|
20855
|
+
addonId: null,
|
|
20856
|
+
access: "create"
|
|
20857
|
+
},
|
|
20858
|
+
"petFeeder.setFeedSound": {
|
|
20859
|
+
capName: "pet-feeder",
|
|
20860
|
+
capScope: "device",
|
|
20861
|
+
addonId: null,
|
|
20862
|
+
access: "create"
|
|
20863
|
+
},
|
|
20864
|
+
"petFeeder.setIndicatorLight": {
|
|
20865
|
+
capName: "pet-feeder",
|
|
20866
|
+
capScope: "device",
|
|
20867
|
+
addonId: null,
|
|
20868
|
+
access: "create"
|
|
20869
|
+
},
|
|
20870
|
+
"petFeeder.setVolume": {
|
|
20871
|
+
capName: "pet-feeder",
|
|
20872
|
+
capScope: "device",
|
|
20873
|
+
addonId: null,
|
|
20874
|
+
access: "create"
|
|
20875
|
+
},
|
|
19542
20876
|
"pipelineAnalytics.clearTracks": {
|
|
19543
20877
|
capName: "pipeline-analytics",
|
|
19544
20878
|
capScope: "device",
|