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