@camstack/addon-post-analysis 1.1.13 → 1.1.15
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/{dist-COXXWoXN.mjs → dist-CTfRCMMG.mjs} +1381 -46
- package/dist/{dist-DlqrO_A-.js → dist-DLIeYQDB.js} +1386 -45
- package/dist/embedding-encoder/index.js +1 -1
- package/dist/embedding-encoder/index.mjs +1 -1
- package/dist/enrichment-engine/index.js +3 -3
- package/dist/enrichment-engine/index.mjs +2 -2
- package/dist/{node-CGM1poCk.js → node-DH2tTqvE.js} +1 -1
- package/dist/pipeline-analytics/_stub.js +45 -45
- package/dist/pipeline-analytics/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-B483pGUH.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-Cvn146c5.mjs} +3 -3
- package/dist/pipeline-analytics/_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-ncEsRSej.mjs +26 -0
- package/dist/pipeline-analytics/{hostInit-BO8ol3oB.mjs → hostInit-BsoDjHCp.mjs} +3 -3
- package/dist/pipeline-analytics/index.js +22 -10
- package/dist/pipeline-analytics/index.mjs +20 -8
- package/dist/pipeline-analytics/remoteEntry.js +1 -1
- package/dist/{resolve-frame-DCyc2Qwb.js → resolve-frame-xpUJERNO.js} +1 -1
- package/package.json +1 -1
- package/dist/pipeline-analytics/_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-C3Bc8Uy_.mjs +0 -26
|
@@ -4627,7 +4627,7 @@ function _instanceof(cls, params = {}) {
|
|
|
4627
4627
|
return inst;
|
|
4628
4628
|
}
|
|
4629
4629
|
//#endregion
|
|
4630
|
-
//#region ../types/dist/sleep-
|
|
4630
|
+
//#region ../types/dist/sleep-BiDFW0E7.mjs
|
|
4631
4631
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4632
4632
|
EventCategory["SystemBoot"] = "system.boot";
|
|
4633
4633
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -5440,6 +5440,100 @@ function createDurableState(deps) {
|
|
|
5440
5440
|
};
|
|
5441
5441
|
}
|
|
5442
5442
|
/**
|
|
5443
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
5444
|
+
*
|
|
5445
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
5446
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
5447
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
5448
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
5449
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
5450
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
5451
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
5452
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
5453
|
+
*
|
|
5454
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
5455
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
5456
|
+
* schema and routes reads/writes through these helpers.
|
|
5457
|
+
*
|
|
5458
|
+
* ## No bare-key fallback — deliberate
|
|
5459
|
+
*
|
|
5460
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
5461
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
5462
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
5463
|
+
* the store is invisible to every node, hub included, so one node's
|
|
5464
|
+
* selection can never leak onto another. (This generalizes the
|
|
5465
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
5466
|
+
* arbitrary set of per-node field keys.)
|
|
5467
|
+
*
|
|
5468
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
5469
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
5470
|
+
*/
|
|
5471
|
+
/**
|
|
5472
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
5473
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
5474
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
5475
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
5476
|
+
*/
|
|
5477
|
+
function normalizeNodeId(raw) {
|
|
5478
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
5479
|
+
const slashIdx = raw.indexOf("/");
|
|
5480
|
+
if (slashIdx < 0) return raw;
|
|
5481
|
+
const bare = raw.slice(0, slashIdx);
|
|
5482
|
+
return bare === "" ? "hub" : bare;
|
|
5483
|
+
}
|
|
5484
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
5485
|
+
function nodeScopedKey(base, nodeId) {
|
|
5486
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
5487
|
+
}
|
|
5488
|
+
/**
|
|
5489
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
5490
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
5491
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
5492
|
+
* schema `default` win on `undefined`.
|
|
5493
|
+
*/
|
|
5494
|
+
function readNodeValue(store, base, nodeId) {
|
|
5495
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
5496
|
+
}
|
|
5497
|
+
/**
|
|
5498
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
5499
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
5500
|
+
* the write path so a save for one node never clobbers another node's value
|
|
5501
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
5502
|
+
* patch is not mutated.
|
|
5503
|
+
*/
|
|
5504
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
5505
|
+
const out = {};
|
|
5506
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
5507
|
+
return out;
|
|
5508
|
+
}
|
|
5509
|
+
/**
|
|
5510
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
5511
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
5512
|
+
* values:
|
|
5513
|
+
*
|
|
5514
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
5515
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
5516
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
5517
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
5518
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
5519
|
+
* left ABSENT so the field's schema `default` wins.
|
|
5520
|
+
*
|
|
5521
|
+
* Returns a new object — the input store is not mutated.
|
|
5522
|
+
*/
|
|
5523
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
5524
|
+
const out = {};
|
|
5525
|
+
for (const [key, value] of Object.entries(store)) {
|
|
5526
|
+
if (key.includes("@")) continue;
|
|
5527
|
+
if (perNodeKeys.has(key)) continue;
|
|
5528
|
+
out[key] = value;
|
|
5529
|
+
}
|
|
5530
|
+
for (const base of perNodeKeys) {
|
|
5531
|
+
const value = readNodeValue(store, base, nodeId);
|
|
5532
|
+
if (value !== void 0) out[base] = value;
|
|
5533
|
+
}
|
|
5534
|
+
return out;
|
|
5535
|
+
}
|
|
5536
|
+
/**
|
|
5443
5537
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5444
5538
|
*
|
|
5445
5539
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -5607,23 +5701,63 @@ var BaseAddon = class {
|
|
|
5607
5701
|
deviceSettingsSchema() {
|
|
5608
5702
|
return null;
|
|
5609
5703
|
}
|
|
5610
|
-
async getGlobalSettings(overlay, cap,
|
|
5704
|
+
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5611
5705
|
const schema = this.globalSettingsSchema(cap);
|
|
5612
5706
|
if (!schema) return { sections: [] };
|
|
5613
|
-
const
|
|
5707
|
+
const projected = await this.resolveGlobalStore(nodeId, cap);
|
|
5614
5708
|
return hydrateSchema(schema, overlay ? {
|
|
5615
|
-
...
|
|
5709
|
+
...projected,
|
|
5616
5710
|
...overlay
|
|
5617
|
-
} :
|
|
5711
|
+
} : projected);
|
|
5712
|
+
}
|
|
5713
|
+
/**
|
|
5714
|
+
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5715
|
+
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5716
|
+
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
5717
|
+
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
5718
|
+
* A no-op passthrough when the schema declares no `perNode` field.
|
|
5719
|
+
*
|
|
5720
|
+
* This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
|
|
5721
|
+
* the store for custom option logic (option narrowing, value snapping) to
|
|
5722
|
+
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
5723
|
+
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
5724
|
+
*/
|
|
5725
|
+
async resolveGlobalStore(nodeId, cap) {
|
|
5726
|
+
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
5727
|
+
const keys = this.perNodeKeys(cap);
|
|
5728
|
+
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5729
|
+
return keys.size > 0 ? projectStore(raw, keys, node) : raw;
|
|
5618
5730
|
}
|
|
5619
|
-
async updateGlobalSettings(patch,
|
|
5620
|
-
|
|
5731
|
+
async updateGlobalSettings(patch, nodeId) {
|
|
5732
|
+
const keys = this.perNodeKeys();
|
|
5733
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5734
|
+
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5735
|
+
const barePatch = patch;
|
|
5736
|
+
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
5737
|
+
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
5738
|
+
if (target !== localNode) return;
|
|
5621
5739
|
await this.resolveConfig();
|
|
5622
5740
|
await this.onConfigChanged();
|
|
5623
5741
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
5624
5742
|
this.maybeAutoRestart(patch, this.globalSettingsSchema());
|
|
5625
5743
|
}
|
|
5626
5744
|
/**
|
|
5745
|
+
* The set of field keys the global settings schema declares `perNode: true`
|
|
5746
|
+
* — derived once per `cap` argument and memoized (schemas are static
|
|
5747
|
+
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
5748
|
+
* settings API behaves exactly like the legacy node-agnostic one.
|
|
5749
|
+
*/
|
|
5750
|
+
_perNodeKeysCache = /* @__PURE__ */ new Map();
|
|
5751
|
+
perNodeKeys(cap) {
|
|
5752
|
+
const cacheKey = cap ?? "";
|
|
5753
|
+
const cached = this._perNodeKeysCache.get(cacheKey);
|
|
5754
|
+
if (cached) return cached;
|
|
5755
|
+
const schema = this.globalSettingsSchema(cap);
|
|
5756
|
+
const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
5757
|
+
this._perNodeKeysCache.set(cacheKey, keys);
|
|
5758
|
+
return keys;
|
|
5759
|
+
}
|
|
5760
|
+
/**
|
|
5627
5761
|
* If any field in `patch` is marked `requiresRestart` in `schema`,
|
|
5628
5762
|
* schedule an addon restart for the next tick. Deferred via
|
|
5629
5763
|
* `setImmediate` so the tRPC mutation that triggered the write has
|
|
@@ -5776,12 +5910,19 @@ var BaseAddon = class {
|
|
|
5776
5910
|
* The merge is shallow: each key in `defaults` is checked against the store.
|
|
5777
5911
|
* Only keys present in defaults are read — the store can contain extra keys
|
|
5778
5912
|
* (e.g. from older versions) without polluting the typed config.
|
|
5913
|
+
*
|
|
5914
|
+
* Keys the global settings schema declares `perNode: true` resolve from
|
|
5915
|
+
* THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
|
|
5916
|
+
* from the bare key — so a per-node field resolves to this node's own
|
|
5917
|
+
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
5779
5918
|
*/
|
|
5780
5919
|
async resolveConfig() {
|
|
5781
5920
|
const stored = await this.readAddonStoreWithRetry();
|
|
5921
|
+
const perNode = this.perNodeKeys();
|
|
5922
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5782
5923
|
const resolved = { ...this.defaults };
|
|
5783
5924
|
for (const key of Object.keys(this.defaults)) {
|
|
5784
|
-
const storedValue = stored[key];
|
|
5925
|
+
const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
|
|
5785
5926
|
if (storedValue !== void 0 && storedValue !== null) {
|
|
5786
5927
|
const defaultType = typeof this.defaults[key];
|
|
5787
5928
|
if (typeof storedValue === defaultType) resolved[key] = storedValue;
|
|
@@ -5865,6 +6006,27 @@ var BaseAddon = class {
|
|
|
5865
6006
|
}
|
|
5866
6007
|
};
|
|
5867
6008
|
/**
|
|
6009
|
+
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
6010
|
+
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
6011
|
+
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6012
|
+
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6013
|
+
*/
|
|
6014
|
+
function collectPerNodeFieldKeys(fields) {
|
|
6015
|
+
const collected = [];
|
|
6016
|
+
for (const field of fields) {
|
|
6017
|
+
if (field.type === "group") {
|
|
6018
|
+
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
6019
|
+
continue;
|
|
6020
|
+
}
|
|
6021
|
+
if (field.type === "sub-tabs") {
|
|
6022
|
+
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
6023
|
+
continue;
|
|
6024
|
+
}
|
|
6025
|
+
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
6026
|
+
}
|
|
6027
|
+
return collected;
|
|
6028
|
+
}
|
|
6029
|
+
/**
|
|
5868
6030
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
5869
6031
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
5870
6032
|
* envelopes pass through; void stays void.
|
|
@@ -5889,6 +6051,7 @@ var CamStreamKindSchema = _enum([
|
|
|
5889
6051
|
"pull-rtsp",
|
|
5890
6052
|
"pull-rtmp",
|
|
5891
6053
|
"pull-http",
|
|
6054
|
+
"pull-flv",
|
|
5892
6055
|
"pull-rfc4571",
|
|
5893
6056
|
"push-annexb",
|
|
5894
6057
|
"derived"
|
|
@@ -6276,6 +6439,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
6276
6439
|
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
6277
6440
|
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
6278
6441
|
DeviceType["Image"] = "image";
|
|
6442
|
+
/** Smart pet feeder — cloud-connected food dispenser with a bowl food
|
|
6443
|
+
* level, battery, desiccant life, feeding state and manual-feed /
|
|
6444
|
+
* call-pet / maintenance actions. Installed with the `pet-feeder` cap;
|
|
6445
|
+
* dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
|
|
6446
|
+
* native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
|
|
6447
|
+
* integrations sharing the same food/desiccant/hopper surface. */
|
|
6448
|
+
DeviceType["PetFeeder"] = "pet-feeder";
|
|
6279
6449
|
return DeviceType;
|
|
6280
6450
|
}({});
|
|
6281
6451
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -6810,6 +6980,25 @@ var ConvertResultSchema = object({
|
|
|
6810
6980
|
})).readonly()
|
|
6811
6981
|
});
|
|
6812
6982
|
/**
|
|
6983
|
+
* THE canonical event-clip pad: the time window a single-timestamp analytics
|
|
6984
|
+
* event expands to when joined with footage (clip window = `[timestamp - preMs,
|
|
6985
|
+
* timestamp + postMs]`). Matches the admin-ui clip window (−5s/+10s).
|
|
6986
|
+
*
|
|
6987
|
+
* Every consumer derives from this ONE constant so event↔footage boundaries
|
|
6988
|
+
* agree everywhere (C1):
|
|
6989
|
+
* - the `videoclips` default provider (addon-post-analysis) pads its clip
|
|
6990
|
+
* windows with it;
|
|
6991
|
+
* - the recorder's ephemeral in-RAM `EventMap` markers (addon-pipeline) pad
|
|
6992
|
+
* their `startMs/endMs` with it.
|
|
6993
|
+
*
|
|
6994
|
+
* NOTE: this is a UI/JOIN convention, NOT the `events`-band keep/discard gate —
|
|
6995
|
+
* that uses the per-device `preBufferSec`/`postBufferSec` config.
|
|
6996
|
+
*/
|
|
6997
|
+
var EVENT_PAD_MS = {
|
|
6998
|
+
preMs: 5e3,
|
|
6999
|
+
postMs: 1e4
|
|
7000
|
+
};
|
|
7001
|
+
/**
|
|
6813
7002
|
* Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
|
|
6814
7003
|
* Named `RecordingWeekday` to avoid collision with the string-union
|
|
6815
7004
|
* `Weekday` exported from `interfaces/timezones.ts`.
|
|
@@ -7453,6 +7642,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
|
|
|
7453
7642
|
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7454
7643
|
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7455
7644
|
/**
|
|
7645
|
+
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7646
|
+
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
7647
|
+
* failure — both are non-fatal to the host: read paths degrade to "skip link".
|
|
7648
|
+
*/
|
|
7649
|
+
/** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
|
|
7650
|
+
* the failure is anchored to a character (author-facing inline feedback). */
|
|
7651
|
+
var ExpressionParseError = class extends Error {
|
|
7652
|
+
position;
|
|
7653
|
+
constructor(message, position) {
|
|
7654
|
+
super(message);
|
|
7655
|
+
this.name = "ExpressionParseError";
|
|
7656
|
+
this.position = position;
|
|
7657
|
+
}
|
|
7658
|
+
};
|
|
7659
|
+
/** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
|
|
7660
|
+
* result, unknown builtin, step-budget exceeded). */
|
|
7661
|
+
var ExpressionEvalError = class extends Error {
|
|
7662
|
+
constructor(message) {
|
|
7663
|
+
super(message);
|
|
7664
|
+
this.name = "ExpressionEvalError";
|
|
7665
|
+
}
|
|
7666
|
+
};
|
|
7667
|
+
/**
|
|
7668
|
+
* Resource-bound constants for the safe expression engine.
|
|
7669
|
+
*
|
|
7670
|
+
* Every bound is defense-in-depth: the grammar is non-Turing-complete (no
|
|
7671
|
+
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
7672
|
+
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
7673
|
+
* work a single author-supplied expression can request, so a hostile or
|
|
7674
|
+
* accidental pathological string can never spend unbounded CPU/memory.
|
|
7675
|
+
*/
|
|
7676
|
+
/** Max source length (chars) — checked BEFORE tokenizing so a huge string is
|
|
7677
|
+
* rejected without allocation. */
|
|
7678
|
+
var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
|
|
7679
|
+
/** A legal binding / identifier name. */
|
|
7680
|
+
var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7681
|
+
/** Binding names an author may NOT use: `now` is auto-injected; the literal
|
|
7682
|
+
* keywords lex as values, not identifiers, so binding to them is meaningless. */
|
|
7683
|
+
var RESERVED_BINDING_NAMES = new Set([
|
|
7684
|
+
"now",
|
|
7685
|
+
"true",
|
|
7686
|
+
"false",
|
|
7687
|
+
"null"
|
|
7688
|
+
]);
|
|
7689
|
+
/**
|
|
7690
|
+
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
7691
|
+
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
7692
|
+
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
7693
|
+
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
7694
|
+
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
7695
|
+
* is a parse error with a source position, so member access / assignment /
|
|
7696
|
+
* template literals are lexically impossible.
|
|
7697
|
+
*/
|
|
7698
|
+
var KEYWORDS = new Set([
|
|
7699
|
+
"true",
|
|
7700
|
+
"false",
|
|
7701
|
+
"null"
|
|
7702
|
+
]);
|
|
7703
|
+
function isDigit(ch) {
|
|
7704
|
+
return ch >= "0" && ch <= "9";
|
|
7705
|
+
}
|
|
7706
|
+
function isIdentStart(ch) {
|
|
7707
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
7708
|
+
}
|
|
7709
|
+
function isIdentPart(ch) {
|
|
7710
|
+
return isIdentStart(ch) || isDigit(ch);
|
|
7711
|
+
}
|
|
7712
|
+
function isWhitespace(ch) {
|
|
7713
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
7714
|
+
}
|
|
7715
|
+
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
7716
|
+
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
7717
|
+
* string. */
|
|
7718
|
+
function tokenize(source) {
|
|
7719
|
+
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
7720
|
+
const tokens = [];
|
|
7721
|
+
let i = 0;
|
|
7722
|
+
const n = source.length;
|
|
7723
|
+
while (i < n) {
|
|
7724
|
+
const ch = source[i];
|
|
7725
|
+
if (isWhitespace(ch)) {
|
|
7726
|
+
i += 1;
|
|
7727
|
+
continue;
|
|
7728
|
+
}
|
|
7729
|
+
if (isDigit(ch)) {
|
|
7730
|
+
const start = i;
|
|
7731
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7732
|
+
if (i < n && source[i] === ".") {
|
|
7733
|
+
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
7734
|
+
i += 1;
|
|
7735
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7736
|
+
}
|
|
7737
|
+
const text = source.slice(start, i);
|
|
7738
|
+
const value = Number(text);
|
|
7739
|
+
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
7740
|
+
tokens.push({
|
|
7741
|
+
type: "number",
|
|
7742
|
+
value,
|
|
7743
|
+
pos: start
|
|
7744
|
+
});
|
|
7745
|
+
continue;
|
|
7746
|
+
}
|
|
7747
|
+
if (ch === "'" || ch === "\"") {
|
|
7748
|
+
const quote = ch;
|
|
7749
|
+
const start = i;
|
|
7750
|
+
i += 1;
|
|
7751
|
+
let out = "";
|
|
7752
|
+
let closed = false;
|
|
7753
|
+
while (i < n) {
|
|
7754
|
+
const c = source[i];
|
|
7755
|
+
if (c === "\\") {
|
|
7756
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
7757
|
+
if (next === "\\" || next === "'" || next === "\"") {
|
|
7758
|
+
out += next;
|
|
7759
|
+
i += 2;
|
|
7760
|
+
continue;
|
|
7761
|
+
}
|
|
7762
|
+
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
7763
|
+
}
|
|
7764
|
+
if (c === quote) {
|
|
7765
|
+
closed = true;
|
|
7766
|
+
i += 1;
|
|
7767
|
+
break;
|
|
7768
|
+
}
|
|
7769
|
+
out += c;
|
|
7770
|
+
i += 1;
|
|
7771
|
+
}
|
|
7772
|
+
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
7773
|
+
tokens.push({
|
|
7774
|
+
type: "string",
|
|
7775
|
+
value: out,
|
|
7776
|
+
pos: start
|
|
7777
|
+
});
|
|
7778
|
+
continue;
|
|
7779
|
+
}
|
|
7780
|
+
if (isIdentStart(ch)) {
|
|
7781
|
+
const start = i;
|
|
7782
|
+
while (i < n && isIdentPart(source[i])) i += 1;
|
|
7783
|
+
const text = source.slice(start, i);
|
|
7784
|
+
if (KEYWORDS.has(text)) tokens.push({
|
|
7785
|
+
type: "keyword",
|
|
7786
|
+
keyword: keywordOf(text),
|
|
7787
|
+
pos: start
|
|
7788
|
+
});
|
|
7789
|
+
else tokens.push({
|
|
7790
|
+
type: "identifier",
|
|
7791
|
+
name: text,
|
|
7792
|
+
pos: start
|
|
7793
|
+
});
|
|
7794
|
+
continue;
|
|
7795
|
+
}
|
|
7796
|
+
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
7797
|
+
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
7798
|
+
tokens.push({
|
|
7799
|
+
type: "punct",
|
|
7800
|
+
punct: two,
|
|
7801
|
+
pos: i
|
|
7802
|
+
});
|
|
7803
|
+
i += 2;
|
|
7804
|
+
continue;
|
|
7805
|
+
}
|
|
7806
|
+
if (isSinglePunct(ch)) {
|
|
7807
|
+
tokens.push({
|
|
7808
|
+
type: "punct",
|
|
7809
|
+
punct: ch,
|
|
7810
|
+
pos: i
|
|
7811
|
+
});
|
|
7812
|
+
i += 1;
|
|
7813
|
+
continue;
|
|
7814
|
+
}
|
|
7815
|
+
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
7816
|
+
}
|
|
7817
|
+
tokens.push({
|
|
7818
|
+
type: "eof",
|
|
7819
|
+
pos: n
|
|
7820
|
+
});
|
|
7821
|
+
return tokens;
|
|
7822
|
+
}
|
|
7823
|
+
function keywordOf(text) {
|
|
7824
|
+
if (text === "true") return "true";
|
|
7825
|
+
if (text === "false") return "false";
|
|
7826
|
+
return "null";
|
|
7827
|
+
}
|
|
7828
|
+
function isSinglePunct(ch) {
|
|
7829
|
+
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
7830
|
+
}
|
|
7831
|
+
/**
|
|
7832
|
+
* Frozen, null-prototype builtin function table for the expression engine
|
|
7833
|
+
* (spec §4 rule 4). The table is the SOLE surface of callable functions: the
|
|
7834
|
+
* parser rejects any callee not in it, and the evaluator gates each call on an
|
|
7835
|
+
* own-property check against it.
|
|
7836
|
+
*
|
|
7837
|
+
* Because the object has a NULL prototype AND is `Object.freeze`d:
|
|
7838
|
+
* - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
|
|
7839
|
+
* - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
|
|
7840
|
+
* (there is no `Object.prototype` in the chain), so those names are not
|
|
7841
|
+
* callable — they are simply "unknown function" at parse time.
|
|
7842
|
+
*
|
|
7843
|
+
* Every numeric argument is validated as a finite number and every numeric
|
|
7844
|
+
* RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
|
|
7845
|
+
* (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
|
|
7846
|
+
* closed rather than emitting a garbage value.
|
|
7847
|
+
*/
|
|
7848
|
+
function asFiniteNumber(value, name, index) {
|
|
7849
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
7850
|
+
return value;
|
|
7851
|
+
}
|
|
7852
|
+
function asString$1(value, name, index) {
|
|
7853
|
+
if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
|
|
7854
|
+
return value;
|
|
7855
|
+
}
|
|
7856
|
+
function finiteResult(value, name) {
|
|
7857
|
+
if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
|
|
7858
|
+
return value;
|
|
7859
|
+
}
|
|
7860
|
+
function allFiniteNumbers(args, name) {
|
|
7861
|
+
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
7862
|
+
}
|
|
7863
|
+
var INF = Number.POSITIVE_INFINITY;
|
|
7864
|
+
var table = {
|
|
7865
|
+
min: {
|
|
7866
|
+
minArgs: 1,
|
|
7867
|
+
maxArgs: INF,
|
|
7868
|
+
apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
|
|
7869
|
+
},
|
|
7870
|
+
max: {
|
|
7871
|
+
minArgs: 1,
|
|
7872
|
+
maxArgs: INF,
|
|
7873
|
+
apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
|
|
7874
|
+
},
|
|
7875
|
+
abs: {
|
|
7876
|
+
minArgs: 1,
|
|
7877
|
+
maxArgs: 1,
|
|
7878
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
7879
|
+
},
|
|
7880
|
+
floor: {
|
|
7881
|
+
minArgs: 1,
|
|
7882
|
+
maxArgs: 1,
|
|
7883
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
7884
|
+
},
|
|
7885
|
+
ceil: {
|
|
7886
|
+
minArgs: 1,
|
|
7887
|
+
maxArgs: 1,
|
|
7888
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
7889
|
+
},
|
|
7890
|
+
sqrt: {
|
|
7891
|
+
minArgs: 1,
|
|
7892
|
+
maxArgs: 1,
|
|
7893
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
7894
|
+
},
|
|
7895
|
+
round: {
|
|
7896
|
+
minArgs: 1,
|
|
7897
|
+
maxArgs: 2,
|
|
7898
|
+
apply: (args) => {
|
|
7899
|
+
const x = asFiniteNumber(args[0], "round", 0);
|
|
7900
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
7901
|
+
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
7902
|
+
const factor = 10 ** digits;
|
|
7903
|
+
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
7904
|
+
}
|
|
7905
|
+
},
|
|
7906
|
+
pow: {
|
|
7907
|
+
minArgs: 2,
|
|
7908
|
+
maxArgs: 2,
|
|
7909
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
7910
|
+
},
|
|
7911
|
+
clamp: {
|
|
7912
|
+
minArgs: 3,
|
|
7913
|
+
maxArgs: 3,
|
|
7914
|
+
apply: (args) => {
|
|
7915
|
+
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
7916
|
+
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
7917
|
+
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
7918
|
+
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
7919
|
+
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
7920
|
+
}
|
|
7921
|
+
},
|
|
7922
|
+
avg: {
|
|
7923
|
+
minArgs: 1,
|
|
7924
|
+
maxArgs: INF,
|
|
7925
|
+
apply: (args) => {
|
|
7926
|
+
const nums = allFiniteNumbers(args, "avg");
|
|
7927
|
+
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
7928
|
+
}
|
|
7929
|
+
},
|
|
7930
|
+
sum: {
|
|
7931
|
+
minArgs: 1,
|
|
7932
|
+
maxArgs: INF,
|
|
7933
|
+
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
7934
|
+
},
|
|
7935
|
+
coalesce: {
|
|
7936
|
+
minArgs: 1,
|
|
7937
|
+
maxArgs: INF,
|
|
7938
|
+
apply: (args) => {
|
|
7939
|
+
for (const a of args) if (a !== null) return a;
|
|
7940
|
+
return null;
|
|
7941
|
+
}
|
|
7942
|
+
},
|
|
7943
|
+
age: {
|
|
7944
|
+
minArgs: 2,
|
|
7945
|
+
maxArgs: 2,
|
|
7946
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
7947
|
+
},
|
|
7948
|
+
convert: {
|
|
7949
|
+
minArgs: 3,
|
|
7950
|
+
maxArgs: 3,
|
|
7951
|
+
apply: (args, hooks) => {
|
|
7952
|
+
const x = asFiniteNumber(args[0], "convert", 0);
|
|
7953
|
+
const from = asString$1(args[1], "convert", 1).trim();
|
|
7954
|
+
const to = asString$1(args[2], "convert", 2).trim();
|
|
7955
|
+
if (hooks.convert) {
|
|
7956
|
+
const out = hooks.convert(x, from, to);
|
|
7957
|
+
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
7958
|
+
return finiteResult(out, "convert");
|
|
7959
|
+
}
|
|
7960
|
+
if (from === to) return x;
|
|
7961
|
+
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
7962
|
+
}
|
|
7963
|
+
}
|
|
7964
|
+
};
|
|
7965
|
+
Object.freeze(Object.assign(Object.create(null), table));
|
|
7966
|
+
/** The set of valid builtin names — used by the parser to reject unknown
|
|
7967
|
+
* callees at parse time (immediate author feedback). */
|
|
7968
|
+
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
7969
|
+
/**
|
|
7970
|
+
* Pratt (precedence-climbing) parser for the safe expression mini-language.
|
|
7971
|
+
*
|
|
7972
|
+
* Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
|
|
7973
|
+
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
7974
|
+
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
7975
|
+
* string validated against the builtin table at parse time, so an unknown
|
|
7976
|
+
* function is rejected immediately (author feedback) and a persisted expression
|
|
7977
|
+
* that references a since-removed builtin degrades at read.
|
|
7978
|
+
*
|
|
7979
|
+
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
7980
|
+
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
7981
|
+
*/
|
|
7982
|
+
/** Binary/logical operator precedence (higher binds tighter). */
|
|
7983
|
+
var BINARY_PRECEDENCE = {
|
|
7984
|
+
"||": 1,
|
|
7985
|
+
"&&": 2,
|
|
7986
|
+
"==": 3,
|
|
7987
|
+
"!=": 3,
|
|
7988
|
+
"<": 4,
|
|
7989
|
+
"<=": 4,
|
|
7990
|
+
">": 4,
|
|
7991
|
+
">=": 4,
|
|
7992
|
+
"+": 5,
|
|
7993
|
+
"-": 5,
|
|
7994
|
+
"*": 6,
|
|
7995
|
+
"/": 6,
|
|
7996
|
+
"%": 6
|
|
7997
|
+
};
|
|
7998
|
+
function isLogicalOp(op) {
|
|
7999
|
+
return op === "&&" || op === "||";
|
|
8000
|
+
}
|
|
8001
|
+
function isBinaryOp(op) {
|
|
8002
|
+
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
8003
|
+
}
|
|
8004
|
+
var Parser = class {
|
|
8005
|
+
tokens;
|
|
8006
|
+
pos = 0;
|
|
8007
|
+
nodeCount = 0;
|
|
8008
|
+
identifiers = /* @__PURE__ */ new Set();
|
|
8009
|
+
callees = /* @__PURE__ */ new Set();
|
|
8010
|
+
constructor(tokens) {
|
|
8011
|
+
this.tokens = tokens;
|
|
8012
|
+
}
|
|
8013
|
+
parse() {
|
|
8014
|
+
const ast = this.parseTernary();
|
|
8015
|
+
const tok = this.peek();
|
|
8016
|
+
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
8017
|
+
return {
|
|
8018
|
+
ast,
|
|
8019
|
+
identifiers: this.identifiers,
|
|
8020
|
+
callees: this.callees,
|
|
8021
|
+
nodeCount: this.nodeCount
|
|
8022
|
+
};
|
|
8023
|
+
}
|
|
8024
|
+
peek() {
|
|
8025
|
+
return this.tokens[this.pos];
|
|
8026
|
+
}
|
|
8027
|
+
next() {
|
|
8028
|
+
return this.tokens[this.pos++];
|
|
8029
|
+
}
|
|
8030
|
+
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
8031
|
+
expectPunct(punct) {
|
|
8032
|
+
const tok = this.peek();
|
|
8033
|
+
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
8034
|
+
this.pos += 1;
|
|
8035
|
+
}
|
|
8036
|
+
matchPunct(punct) {
|
|
8037
|
+
const tok = this.peek();
|
|
8038
|
+
if (tok.type === "punct" && tok.punct === punct) {
|
|
8039
|
+
this.pos += 1;
|
|
8040
|
+
return true;
|
|
8041
|
+
}
|
|
8042
|
+
return false;
|
|
8043
|
+
}
|
|
8044
|
+
countNode() {
|
|
8045
|
+
this.nodeCount += 1;
|
|
8046
|
+
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
8047
|
+
}
|
|
8048
|
+
parseTernary() {
|
|
8049
|
+
const test = this.parseBinary(1);
|
|
8050
|
+
if (this.matchPunct("?")) {
|
|
8051
|
+
const consequent = this.parseTernary();
|
|
8052
|
+
this.expectPunct(":");
|
|
8053
|
+
const alternate = this.parseTernary();
|
|
8054
|
+
this.countNode();
|
|
8055
|
+
return {
|
|
8056
|
+
kind: "conditional",
|
|
8057
|
+
test,
|
|
8058
|
+
consequent,
|
|
8059
|
+
alternate
|
|
8060
|
+
};
|
|
8061
|
+
}
|
|
8062
|
+
return test;
|
|
8063
|
+
}
|
|
8064
|
+
parseBinary(minPrec) {
|
|
8065
|
+
let left = this.parseUnary();
|
|
8066
|
+
for (;;) {
|
|
8067
|
+
const tok = this.peek();
|
|
8068
|
+
if (tok.type !== "punct") break;
|
|
8069
|
+
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
8070
|
+
if (prec === void 0 || prec < minPrec) break;
|
|
8071
|
+
const op = tok.punct;
|
|
8072
|
+
this.pos += 1;
|
|
8073
|
+
const right = this.parseBinary(prec + 1);
|
|
8074
|
+
this.countNode();
|
|
8075
|
+
if (isLogicalOp(op)) left = {
|
|
8076
|
+
kind: "logical",
|
|
8077
|
+
op,
|
|
8078
|
+
left,
|
|
8079
|
+
right
|
|
8080
|
+
};
|
|
8081
|
+
else if (isBinaryOp(op)) left = {
|
|
8082
|
+
kind: "binary",
|
|
8083
|
+
op,
|
|
8084
|
+
left,
|
|
8085
|
+
right
|
|
8086
|
+
};
|
|
8087
|
+
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
8088
|
+
}
|
|
8089
|
+
return left;
|
|
8090
|
+
}
|
|
8091
|
+
parseUnary() {
|
|
8092
|
+
const tok = this.peek();
|
|
8093
|
+
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
8094
|
+
const op = tok.punct;
|
|
8095
|
+
this.pos += 1;
|
|
8096
|
+
const operand = this.parseUnary();
|
|
8097
|
+
this.countNode();
|
|
8098
|
+
return {
|
|
8099
|
+
kind: "unary",
|
|
8100
|
+
op,
|
|
8101
|
+
operand
|
|
8102
|
+
};
|
|
8103
|
+
}
|
|
8104
|
+
return this.parsePrimary();
|
|
8105
|
+
}
|
|
8106
|
+
parsePrimary() {
|
|
8107
|
+
const tok = this.next();
|
|
8108
|
+
switch (tok.type) {
|
|
8109
|
+
case "number":
|
|
8110
|
+
this.countNode();
|
|
8111
|
+
return {
|
|
8112
|
+
kind: "literal",
|
|
8113
|
+
value: tok.value
|
|
8114
|
+
};
|
|
8115
|
+
case "string":
|
|
8116
|
+
this.countNode();
|
|
8117
|
+
return {
|
|
8118
|
+
kind: "literal",
|
|
8119
|
+
value: tok.value
|
|
8120
|
+
};
|
|
8121
|
+
case "keyword":
|
|
8122
|
+
this.countNode();
|
|
8123
|
+
return {
|
|
8124
|
+
kind: "literal",
|
|
8125
|
+
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
8126
|
+
};
|
|
8127
|
+
case "identifier": {
|
|
8128
|
+
const nextTok = this.peek();
|
|
8129
|
+
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
8130
|
+
this.identifiers.add(tok.name);
|
|
8131
|
+
this.countNode();
|
|
8132
|
+
return {
|
|
8133
|
+
kind: "identifier",
|
|
8134
|
+
name: tok.name
|
|
8135
|
+
};
|
|
8136
|
+
}
|
|
8137
|
+
case "punct":
|
|
8138
|
+
if (tok.punct === "(") {
|
|
8139
|
+
const inner = this.parseTernary();
|
|
8140
|
+
this.expectPunct(")");
|
|
8141
|
+
return inner;
|
|
8142
|
+
}
|
|
8143
|
+
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
8144
|
+
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
8145
|
+
}
|
|
8146
|
+
}
|
|
8147
|
+
parseCall(callee, pos) {
|
|
8148
|
+
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
8149
|
+
this.expectPunct("(");
|
|
8150
|
+
const args = [];
|
|
8151
|
+
if (!this.matchPunct(")")) for (;;) {
|
|
8152
|
+
args.push(this.parseTernary());
|
|
8153
|
+
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
8154
|
+
if (this.matchPunct(",")) continue;
|
|
8155
|
+
this.expectPunct(")");
|
|
8156
|
+
break;
|
|
8157
|
+
}
|
|
8158
|
+
this.callees.add(callee);
|
|
8159
|
+
this.countNode();
|
|
8160
|
+
return {
|
|
8161
|
+
kind: "call",
|
|
8162
|
+
callee,
|
|
8163
|
+
args
|
|
8164
|
+
};
|
|
8165
|
+
}
|
|
8166
|
+
};
|
|
8167
|
+
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
8168
|
+
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
8169
|
+
function parseExpression(source) {
|
|
8170
|
+
return new Parser(tokenize(source)).parse();
|
|
8171
|
+
}
|
|
8172
|
+
Object.freeze({});
|
|
8173
|
+
/**
|
|
8174
|
+
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
8175
|
+
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
8176
|
+
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
8177
|
+
* one per read on a hot resolve path.
|
|
8178
|
+
*
|
|
8179
|
+
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
8180
|
+
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
8181
|
+
* callers is safe and maximises hit rate.
|
|
8182
|
+
*/
|
|
8183
|
+
var cache = /* @__PURE__ */ new Map();
|
|
8184
|
+
function getCached(source) {
|
|
8185
|
+
const hit = cache.get(source);
|
|
8186
|
+
if (hit !== void 0) {
|
|
8187
|
+
cache.delete(source);
|
|
8188
|
+
cache.set(source, hit);
|
|
8189
|
+
return hit;
|
|
8190
|
+
}
|
|
8191
|
+
let result;
|
|
8192
|
+
try {
|
|
8193
|
+
result = {
|
|
8194
|
+
ok: true,
|
|
8195
|
+
parsed: parseExpression(source)
|
|
8196
|
+
};
|
|
8197
|
+
} catch (err) {
|
|
8198
|
+
result = {
|
|
8199
|
+
ok: false,
|
|
8200
|
+
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
8201
|
+
};
|
|
8202
|
+
}
|
|
8203
|
+
cache.set(source, result);
|
|
8204
|
+
if (cache.size > 256) {
|
|
8205
|
+
const oldest = cache.keys().next().value;
|
|
8206
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
8207
|
+
}
|
|
8208
|
+
return result;
|
|
8209
|
+
}
|
|
8210
|
+
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
8211
|
+
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
8212
|
+
function compileExpressionSafe(source) {
|
|
8213
|
+
return getCached(source);
|
|
8214
|
+
}
|
|
8215
|
+
/**
|
|
8216
|
+
* Author-time validation. Returns `null` when the source is valid, else a
|
|
8217
|
+
* human-readable error message. Checks: the expression compiles; binding count
|
|
8218
|
+
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
8219
|
+
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
8220
|
+
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
8221
|
+
*/
|
|
8222
|
+
function validateExpressionSource(src) {
|
|
8223
|
+
const names = Object.keys(src.bindings);
|
|
8224
|
+
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
8225
|
+
for (const name of names) {
|
|
8226
|
+
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
8227
|
+
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
8228
|
+
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
8229
|
+
}
|
|
8230
|
+
const compiled = compileExpressionSafe(src.expr);
|
|
8231
|
+
if (!compiled.ok) return compiled.error;
|
|
8232
|
+
const bound = new Set(names);
|
|
8233
|
+
for (const id of compiled.parsed.identifiers) {
|
|
8234
|
+
if (id === "now") continue;
|
|
8235
|
+
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
8236
|
+
}
|
|
8237
|
+
return null;
|
|
8238
|
+
}
|
|
8239
|
+
/**
|
|
7456
8240
|
* Accessory device helpers — shared across drivers.
|
|
7457
8241
|
*
|
|
7458
8242
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -9384,7 +10168,8 @@ var MotionAnalysisResultSchema = object({
|
|
|
9384
10168
|
});
|
|
9385
10169
|
method(object({
|
|
9386
10170
|
deviceId: number(),
|
|
9387
|
-
frame: FrameInputSchema
|
|
10171
|
+
frame: FrameInputSchema.optional(),
|
|
10172
|
+
frameHandle: FrameHandleSchema.optional()
|
|
9388
10173
|
}), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
|
|
9389
10174
|
deviceId: number(),
|
|
9390
10175
|
detected: boolean(),
|
|
@@ -9631,6 +10416,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
9631
10416
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
9632
10417
|
steps: array(PipelineStepInputSchema).min(1),
|
|
9633
10418
|
frame: FrameInputSchema.optional(),
|
|
10419
|
+
/**
|
|
10420
|
+
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
10421
|
+
* the decoded pixels live in. One more member of the one-of
|
|
10422
|
+
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
10423
|
+
*/
|
|
10424
|
+
frameHandle: FrameHandleSchema.optional(),
|
|
9634
10425
|
imageBase64: string().optional(),
|
|
9635
10426
|
/**
|
|
9636
10427
|
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
@@ -9840,6 +10631,31 @@ var ReportMotionInputSchema = object({
|
|
|
9840
10631
|
regions: array(MotionRegionSchema).readonly().optional()
|
|
9841
10632
|
});
|
|
9842
10633
|
/**
|
|
10634
|
+
* Where a runner gets a camera's decoded frames (cross-node Phase 2,
|
|
10635
|
+
* restream-owner model — P2c).
|
|
10636
|
+
*
|
|
10637
|
+
* - `local-broker` (DEFAULT): today's path — subscribe to the co-located
|
|
10638
|
+
* stream-broker's shm frame plane. Every pre-P2c attach payload (no
|
|
10639
|
+
* `frameSource` key) parses to this, so the field is additive with zero
|
|
10640
|
+
* behavior change.
|
|
10641
|
+
* - `remote-restream`: the detect node is NOT the camera's source-owner.
|
|
10642
|
+
* The runner acquires the owner's COMPRESSED passthrough restream
|
|
10643
|
+
* (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
|
|
10644
|
+
* double-pull guard) and decodes LOCALLY via a satellite frame plane +
|
|
10645
|
+
* pull-mode decoder session pinned to its own node. The shm ring stays
|
|
10646
|
+
* node-local; only H.264/H.265 packets cross the wire.
|
|
10647
|
+
* `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
|
|
10648
|
+
* when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
|
|
10649
|
+
* dials for the owner's restream.
|
|
10650
|
+
*/
|
|
10651
|
+
var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
|
|
10652
|
+
kind: literal("remote-restream"),
|
|
10653
|
+
/** The camera's source-owner node (slice 1: always the hub). */
|
|
10654
|
+
ownerNodeId: string(),
|
|
10655
|
+
/** Operator override for the owner host the runner dials. */
|
|
10656
|
+
hubHostnameOverride: string().optional()
|
|
10657
|
+
})]).describe("Per-camera frame-source mode for the runner (P2c)");
|
|
10658
|
+
/**
|
|
9843
10659
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
9844
10660
|
* specific runner instance via `attachCamera`. Carries everything the
|
|
9845
10661
|
* runner needs to subscribe to the local broker and execute inference.
|
|
@@ -9937,7 +10753,15 @@ var RunnerCameraConfigSchema = object({
|
|
|
9937
10753
|
*/
|
|
9938
10754
|
onboardMotionDrivesAnalyzer: boolean().default(true),
|
|
9939
10755
|
occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
|
|
9940
|
-
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
|
|
10756
|
+
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
|
|
10757
|
+
/**
|
|
10758
|
+
* Where this runner gets the camera's decoded frames (P2c). Defaulted so
|
|
10759
|
+
* every existing payload behaves as `local-broker` — the pre-Phase-2 path.
|
|
10760
|
+
* Populated with `remote-restream` by the orchestrator ONLY when the
|
|
10761
|
+
* camera's detect node differs from its source-owner (P2d, gated by the
|
|
10762
|
+
* `remoteSourcingNodes` rollout setting).
|
|
10763
|
+
*/
|
|
10764
|
+
frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
|
|
9941
10765
|
});
|
|
9942
10766
|
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;
|
|
9943
10767
|
/**
|
|
@@ -10302,6 +11126,113 @@ object({
|
|
|
10302
11126
|
lastFetchedAt: number()
|
|
10303
11127
|
});
|
|
10304
11128
|
DeviceType.Sensor;
|
|
11129
|
+
/**
|
|
11130
|
+
* Feeder connectivity / power status — mirrors the HA petkit device-status
|
|
11131
|
+
* enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
|
|
11132
|
+
* `on_batteries` (running on battery backup). `null` until first reported.
|
|
11133
|
+
*/
|
|
11134
|
+
var PetFeederDeviceStatusSchema = _enum([
|
|
11135
|
+
"normal",
|
|
11136
|
+
"offline",
|
|
11137
|
+
"on_batteries"
|
|
11138
|
+
]);
|
|
11139
|
+
var gramsPortion = number().int().min(4).max(200);
|
|
11140
|
+
object({
|
|
11141
|
+
/** Food currently in the bowl (grams). Null when the device has not
|
|
11142
|
+
* reported a reading yet. On dual-hopper models this is the combined
|
|
11143
|
+
* bowl reading; per-hopper levels live in `food1`/`food2`. */
|
|
11144
|
+
foodLevel: number().nullable(),
|
|
11145
|
+
/** Hopper-1 food level (grams) on dual-hopper feeders; null on
|
|
11146
|
+
* single-hopper models. */
|
|
11147
|
+
food1: number().nullable(),
|
|
11148
|
+
/** Hopper-2 food level (grams) on dual-hopper feeders; null on
|
|
11149
|
+
* single-hopper models. */
|
|
11150
|
+
food2: number().nullable(),
|
|
11151
|
+
/** Derived low-food flag — mirrors the HA `food_level` binary_sensor
|
|
11152
|
+
* (`device_class: problem`, on = low). True when the bowl is empty /
|
|
11153
|
+
* below the feeder's low threshold. */
|
|
11154
|
+
lowFood: boolean(),
|
|
11155
|
+
/** Battery charge 0..100 (%). Null on mains-powered models or when the
|
|
11156
|
+
* device has no battery reading. */
|
|
11157
|
+
batteryPower: number().min(0).max(100).nullable(),
|
|
11158
|
+
/** Days of desiccant life remaining. Null when the model has no
|
|
11159
|
+
* desiccant sensor. */
|
|
11160
|
+
desiccantLeftDays: number().nullable(),
|
|
11161
|
+
/** True while a feed is in progress. */
|
|
11162
|
+
feeding: boolean(),
|
|
11163
|
+
/** Decoded connectivity / power status (HA petkit device-status enum).
|
|
11164
|
+
* Null until the device has reported a status. */
|
|
11165
|
+
status: PetFeederDeviceStatusSchema.nullable(),
|
|
11166
|
+
/** Decoded human-readable fault message. Null (or the device's `no_error`
|
|
11167
|
+
* sentinel) means healthy; a non-null string is an active fault. Pairs
|
|
11168
|
+
* with `errorCode` for consumers that want the raw integer. */
|
|
11169
|
+
error: string().nullable(),
|
|
11170
|
+
/** Raw device error code (0 / null = no error). */
|
|
11171
|
+
errorCode: number().nullable(),
|
|
11172
|
+
/** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
|
|
11173
|
+
isDualHopper: boolean(),
|
|
11174
|
+
/** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
|
|
11175
|
+
childLock: boolean(),
|
|
11176
|
+
/** Front indicator-light setting. */
|
|
11177
|
+
indicatorLight: boolean(),
|
|
11178
|
+
/** Play a chime when dispensing. */
|
|
11179
|
+
feedSound: boolean(),
|
|
11180
|
+
/** Speaker / prompt volume level (device-scaled integer). */
|
|
11181
|
+
volume: number(),
|
|
11182
|
+
/** Ms epoch when the slice was last refreshed from the cloud. */
|
|
11183
|
+
lastFetchedAt: number()
|
|
11184
|
+
});
|
|
11185
|
+
DeviceType.PetFeeder, method(object({
|
|
11186
|
+
deviceId: number().int().nonnegative(),
|
|
11187
|
+
grams: gramsPortion.optional(),
|
|
11188
|
+
hopper1: gramsPortion.optional(),
|
|
11189
|
+
hopper2: gramsPortion.optional()
|
|
11190
|
+
}), _void(), {
|
|
11191
|
+
kind: "mutation",
|
|
11192
|
+
auth: "admin"
|
|
11193
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11194
|
+
kind: "mutation",
|
|
11195
|
+
auth: "admin"
|
|
11196
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11197
|
+
kind: "mutation",
|
|
11198
|
+
auth: "admin"
|
|
11199
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11200
|
+
kind: "mutation",
|
|
11201
|
+
auth: "admin"
|
|
11202
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11203
|
+
kind: "mutation",
|
|
11204
|
+
auth: "admin"
|
|
11205
|
+
}), method(object({
|
|
11206
|
+
deviceId: number().int().nonnegative(),
|
|
11207
|
+
soundId: number().int().nonnegative()
|
|
11208
|
+
}), _void(), {
|
|
11209
|
+
kind: "mutation",
|
|
11210
|
+
auth: "admin"
|
|
11211
|
+
}), method(object({
|
|
11212
|
+
deviceId: number().int().nonnegative(),
|
|
11213
|
+
on: boolean()
|
|
11214
|
+
}), _void(), {
|
|
11215
|
+
kind: "mutation",
|
|
11216
|
+
auth: "admin"
|
|
11217
|
+
}), method(object({
|
|
11218
|
+
deviceId: number().int().nonnegative(),
|
|
11219
|
+
on: boolean()
|
|
11220
|
+
}), _void(), {
|
|
11221
|
+
kind: "mutation",
|
|
11222
|
+
auth: "admin"
|
|
11223
|
+
}), method(object({
|
|
11224
|
+
deviceId: number().int().nonnegative(),
|
|
11225
|
+
on: boolean()
|
|
11226
|
+
}), _void(), {
|
|
11227
|
+
kind: "mutation",
|
|
11228
|
+
auth: "admin"
|
|
11229
|
+
}), method(object({
|
|
11230
|
+
deviceId: number().int().nonnegative(),
|
|
11231
|
+
level: number().int().nonnegative()
|
|
11232
|
+
}), _void(), {
|
|
11233
|
+
kind: "mutation",
|
|
11234
|
+
auth: "admin"
|
|
11235
|
+
});
|
|
10305
11236
|
object({
|
|
10306
11237
|
/** Instantaneous power draw in watts. */
|
|
10307
11238
|
watts: number().optional(),
|
|
@@ -12184,10 +13115,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
|
|
|
12184
13115
|
url: string()
|
|
12185
13116
|
}), _void()), method(object({
|
|
12186
13117
|
sessionId: string(),
|
|
12187
|
-
maxCount: number().default(1)
|
|
13118
|
+
maxCount: number().default(1),
|
|
13119
|
+
waitMs: number().optional()
|
|
12188
13120
|
}), array(DecodedFrameSchema)), method(object({
|
|
12189
13121
|
sessionId: string(),
|
|
12190
|
-
maxCount: number().default(1)
|
|
13122
|
+
maxCount: number().default(1),
|
|
13123
|
+
waitMs: number().optional()
|
|
12191
13124
|
}), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
|
|
12192
13125
|
sessionId: string(),
|
|
12193
13126
|
config: DecoderSessionConfigSchema.partial()
|
|
@@ -12474,14 +13407,63 @@ var ChildLayoutEntrySchema = object({
|
|
|
12474
13407
|
collapsed: boolean().optional()
|
|
12475
13408
|
});
|
|
12476
13409
|
/** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
|
|
12477
|
-
* `device-management.ts`.
|
|
13410
|
+
* `device-management.ts`. Source is a union: a FIELD source copies a sibling
|
|
13411
|
+
* accessory's status field (`kind` optional/absent for wire compat); a
|
|
13412
|
+
* LITERAL source carries a per-device constant (no sibling is read); a
|
|
13413
|
+
* GLOBAL source (P2e) copies ANY device's status field, addressed by the
|
|
13414
|
+
* source device's full re-sync-stable `stableId`. */
|
|
13415
|
+
var DeviceLinkFieldSourceSchema = object({
|
|
13416
|
+
kind: literal("field").optional(),
|
|
13417
|
+
sourceKey: string(),
|
|
13418
|
+
cap: string(),
|
|
13419
|
+
fieldPath: string()
|
|
13420
|
+
});
|
|
13421
|
+
var DeviceLinkLiteralSourceSchema = object({
|
|
13422
|
+
kind: literal("literal"),
|
|
13423
|
+
value: union([
|
|
13424
|
+
string(),
|
|
13425
|
+
number(),
|
|
13426
|
+
boolean(),
|
|
13427
|
+
_null()
|
|
13428
|
+
])
|
|
13429
|
+
});
|
|
13430
|
+
var DeviceLinkGlobalSourceSchema = object({
|
|
13431
|
+
kind: literal("global"),
|
|
13432
|
+
sourceStableId: string(),
|
|
13433
|
+
cap: string(),
|
|
13434
|
+
fieldPath: string()
|
|
13435
|
+
});
|
|
13436
|
+
/** Expression source (Stage X): compute the target field from N named bindings
|
|
13437
|
+
* via the safe expression engine. Bindings are field | literal | global — never
|
|
13438
|
+
* another expression (no nesting). The `superRefine` runs the SAME author-time
|
|
13439
|
+
* validation as `validateExpressionSource` (compiles the expr, checks binding
|
|
13440
|
+
* names + identifier coverage) so every wire boundary that parses a DeviceLink
|
|
13441
|
+
* (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
|
|
13442
|
+
* Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
|
|
13443
|
+
var DeviceLinkExpressionSourceSchema = object({
|
|
13444
|
+
kind: literal("expression"),
|
|
13445
|
+
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
13446
|
+
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
|
|
13447
|
+
DeviceLinkFieldSourceSchema,
|
|
13448
|
+
DeviceLinkLiteralSourceSchema,
|
|
13449
|
+
DeviceLinkGlobalSourceSchema
|
|
13450
|
+
]))
|
|
13451
|
+
}).superRefine((src, ctx) => {
|
|
13452
|
+
const err = validateExpressionSource(src);
|
|
13453
|
+
if (err !== null) ctx.addIssue({
|
|
13454
|
+
code: "custom",
|
|
13455
|
+
message: err,
|
|
13456
|
+
path: ["expr"]
|
|
13457
|
+
});
|
|
13458
|
+
});
|
|
12478
13459
|
var DeviceLinkSchema = object({
|
|
12479
13460
|
id: string(),
|
|
12480
|
-
source:
|
|
12481
|
-
|
|
12482
|
-
|
|
12483
|
-
|
|
12484
|
-
|
|
13461
|
+
source: union([
|
|
13462
|
+
DeviceLinkFieldSourceSchema,
|
|
13463
|
+
DeviceLinkLiteralSourceSchema,
|
|
13464
|
+
DeviceLinkGlobalSourceSchema,
|
|
13465
|
+
DeviceLinkExpressionSourceSchema
|
|
13466
|
+
]),
|
|
12485
13467
|
target: object({
|
|
12486
13468
|
cap: string(),
|
|
12487
13469
|
fieldPath: string(),
|
|
@@ -12510,6 +13492,31 @@ var DeviceLinkSchema = object({
|
|
|
12510
13492
|
})
|
|
12511
13493
|
]).optional()
|
|
12512
13494
|
});
|
|
13495
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
13496
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
13497
|
+
var DeviceCapDisplayOverrideSchema = object({
|
|
13498
|
+
unit: string().min(1).optional(),
|
|
13499
|
+
precision: number().int().min(0).max(10).optional()
|
|
13500
|
+
});
|
|
13501
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
13502
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
13503
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
13504
|
+
var DeviceDisplayOverrideSchema = object({
|
|
13505
|
+
icon: string().min(1).optional(),
|
|
13506
|
+
label: string().min(1).optional(),
|
|
13507
|
+
unit: string().min(1).optional(),
|
|
13508
|
+
precision: number().int().min(0).max(10).optional(),
|
|
13509
|
+
hidden: boolean().optional(),
|
|
13510
|
+
perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
|
|
13511
|
+
});
|
|
13512
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
13513
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
13514
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
13515
|
+
var RoleDisplayDefaultSchema = object({
|
|
13516
|
+
unit: string().min(1).optional(),
|
|
13517
|
+
precision: number().int().min(0).max(10).optional(),
|
|
13518
|
+
icon: string().min(1).optional()
|
|
13519
|
+
});
|
|
12513
13520
|
/**
|
|
12514
13521
|
* Serializable projection of a live IDevice.
|
|
12515
13522
|
* Returned by listAll, getDevice, getChildren.
|
|
@@ -12565,7 +13572,9 @@ var DeviceInfoSchema = object({
|
|
|
12565
13572
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
12566
13573
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
12567
13574
|
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
12568
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional()
|
|
13575
|
+
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
13576
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
13577
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
12569
13578
|
});
|
|
12570
13579
|
var ConfigEntrySchema = object({
|
|
12571
13580
|
key: string(),
|
|
@@ -12630,7 +13639,9 @@ var DeviceMetaSchema = object({
|
|
|
12630
13639
|
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
12631
13640
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
12632
13641
|
* Optional: only present for accessory children that carry a known role. */
|
|
12633
|
-
role: string().nullable().optional()
|
|
13642
|
+
role: string().nullable().optional(),
|
|
13643
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
13644
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
12634
13645
|
});
|
|
12635
13646
|
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
12636
13647
|
var ConfigUISchemaOutput = unknown().nullable();
|
|
@@ -12724,7 +13735,19 @@ method(object({
|
|
|
12724
13735
|
}), _void(), {
|
|
12725
13736
|
kind: "mutation",
|
|
12726
13737
|
auth: "admin"
|
|
12727
|
-
}), method(object({
|
|
13738
|
+
}), method(object({
|
|
13739
|
+
deviceId: number(),
|
|
13740
|
+
display: DeviceDisplayOverrideSchema.nullable()
|
|
13741
|
+
}), _void(), {
|
|
13742
|
+
kind: "mutation",
|
|
13743
|
+
auth: "admin"
|
|
13744
|
+
}), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
|
|
13745
|
+
kind: "mutation",
|
|
13746
|
+
auth: "admin"
|
|
13747
|
+
}), method(object({
|
|
13748
|
+
deviceId: number(),
|
|
13749
|
+
includeSynthesizable: boolean().optional()
|
|
13750
|
+
}), object({ caps: array(object({
|
|
12728
13751
|
cap: string(),
|
|
12729
13752
|
fields: array(object({
|
|
12730
13753
|
path: string(),
|
|
@@ -12734,8 +13757,13 @@ method(object({
|
|
|
12734
13757
|
"boolean",
|
|
12735
13758
|
"enum"
|
|
12736
13759
|
]),
|
|
12737
|
-
enumValues: array(string()).optional()
|
|
12738
|
-
|
|
13760
|
+
enumValues: array(string()).optional(),
|
|
13761
|
+
item: boolean().optional()
|
|
13762
|
+
})).readonly(),
|
|
13763
|
+
itemArray: object({
|
|
13764
|
+
path: string(),
|
|
13765
|
+
keyField: string()
|
|
13766
|
+
}).optional()
|
|
12739
13767
|
})).readonly() }), { kind: "query" }), method(object({
|
|
12740
13768
|
deviceId: number(),
|
|
12741
13769
|
role: string().nullable()
|
|
@@ -12805,7 +13833,11 @@ method(object({
|
|
|
12805
13833
|
deviceId: number(),
|
|
12806
13834
|
entries: array(object({
|
|
12807
13835
|
capName: string(),
|
|
12808
|
-
kind: _enum([
|
|
13836
|
+
kind: _enum([
|
|
13837
|
+
"native",
|
|
13838
|
+
"wrapped",
|
|
13839
|
+
"linked"
|
|
13840
|
+
]),
|
|
12809
13841
|
providerAddonId: string(),
|
|
12810
13842
|
providerNodeId: string(),
|
|
12811
13843
|
nativeAddonId: string()
|
|
@@ -12814,7 +13846,11 @@ method(object({
|
|
|
12814
13846
|
deviceId: number(),
|
|
12815
13847
|
entries: array(object({
|
|
12816
13848
|
capName: string(),
|
|
12817
|
-
kind: _enum([
|
|
13849
|
+
kind: _enum([
|
|
13850
|
+
"native",
|
|
13851
|
+
"wrapped",
|
|
13852
|
+
"linked"
|
|
13853
|
+
]),
|
|
12818
13854
|
providerAddonId: string(),
|
|
12819
13855
|
providerNodeId: string(),
|
|
12820
13856
|
nativeAddonId: string()
|
|
@@ -13314,7 +14350,7 @@ var AddBrokerInputSchema = object({
|
|
|
13314
14350
|
});
|
|
13315
14351
|
var AddBrokerResultSchema = object({ id: string() });
|
|
13316
14352
|
var IdInputSchema = object({ id: string() });
|
|
13317
|
-
var TestResultSchema = discriminatedUnion("ok", [object({
|
|
14353
|
+
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
13318
14354
|
ok: literal(true),
|
|
13319
14355
|
latencyMs: number()
|
|
13320
14356
|
}), object({
|
|
@@ -13337,7 +14373,7 @@ var StatusSchema = object({
|
|
|
13337
14373
|
brokerCount: number(),
|
|
13338
14374
|
embeddedRunning: boolean()
|
|
13339
14375
|
});
|
|
13340
|
-
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);
|
|
14376
|
+
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);
|
|
13341
14377
|
var NetworkEndpointSchema = object({
|
|
13342
14378
|
url: string(),
|
|
13343
14379
|
hostname: string(),
|
|
@@ -13371,23 +14407,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
|
13371
14407
|
sourcePort: number().optional()
|
|
13372
14408
|
});
|
|
13373
14409
|
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
13374
|
-
|
|
13375
|
-
|
|
14410
|
+
/**
|
|
14411
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
14412
|
+
*
|
|
14413
|
+
* Apprise-derived model (see
|
|
14414
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
14415
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
14416
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
14417
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
14418
|
+
* message to what the kind supports — callers never special-case a service.
|
|
14419
|
+
*
|
|
14420
|
+
* DESIGN DECISIONS (locked):
|
|
14421
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
14422
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
14423
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
14424
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
14425
|
+
* alternative would fork the UI per addon and cannot host the
|
|
14426
|
+
* discovery→adopt flow.
|
|
14427
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
14428
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
14429
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
14430
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
14431
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
14432
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
14433
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
14434
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
14435
|
+
* base64 fallback needed.
|
|
14436
|
+
*
|
|
14437
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
14438
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
14439
|
+
* admin "Integrations" page.
|
|
14440
|
+
*/
|
|
14441
|
+
/**
|
|
14442
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
14443
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
14444
|
+
*/
|
|
14445
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
14446
|
+
"image",
|
|
14447
|
+
"video",
|
|
14448
|
+
"gif",
|
|
14449
|
+
"audio",
|
|
14450
|
+
"icon"
|
|
14451
|
+
]);
|
|
14452
|
+
/**
|
|
14453
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
14454
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
14455
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
14456
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
14457
|
+
*/
|
|
14458
|
+
var AttachmentSchema = object({
|
|
14459
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
14460
|
+
url: string().optional(),
|
|
14461
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
14462
|
+
mime: string().optional(),
|
|
14463
|
+
name: string().optional()
|
|
14464
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
14465
|
+
var NotificationFormatSchema = _enum([
|
|
14466
|
+
"text",
|
|
14467
|
+
"markdown",
|
|
14468
|
+
"html"
|
|
14469
|
+
]);
|
|
14470
|
+
/** A single tap-through action button. */
|
|
14471
|
+
var NotificationActionSchema = object({
|
|
14472
|
+
id: string(),
|
|
14473
|
+
label: string(),
|
|
14474
|
+
url: string().optional()
|
|
14475
|
+
});
|
|
14476
|
+
/**
|
|
14477
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
14478
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
14479
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
14480
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
14481
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
14482
|
+
* `priority` for that one target.
|
|
14483
|
+
*/
|
|
14484
|
+
var NotificationSchema = object({
|
|
13376
14485
|
body: string(),
|
|
13377
|
-
|
|
14486
|
+
title: string().optional(),
|
|
14487
|
+
format: NotificationFormatSchema.default("text"),
|
|
14488
|
+
priority: number().int().min(1).max(5).default(3),
|
|
14489
|
+
level: string().optional(),
|
|
14490
|
+
attachments: array(AttachmentSchema).optional(),
|
|
14491
|
+
clickUrl: string().optional(),
|
|
14492
|
+
actions: array(NotificationActionSchema).optional(),
|
|
14493
|
+
sound: string().optional(),
|
|
14494
|
+
ttl: number().optional(),
|
|
14495
|
+
tag: string().optional(),
|
|
13378
14496
|
deviceId: number().optional(),
|
|
13379
14497
|
eventId: string().optional(),
|
|
13380
|
-
priority: _enum([
|
|
13381
|
-
"low",
|
|
13382
|
-
"normal",
|
|
13383
|
-
"high",
|
|
13384
|
-
"critical"
|
|
13385
|
-
]).default("normal"),
|
|
13386
14498
|
metadata: record(string(), unknown()).optional()
|
|
13387
|
-
})
|
|
14499
|
+
});
|
|
14500
|
+
/** One declared native severity/priority level for a kind. */
|
|
14501
|
+
var TargetKindLevelSchema = object({
|
|
14502
|
+
id: string(),
|
|
14503
|
+
label: string(),
|
|
14504
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
14505
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
14506
|
+
flags: object({
|
|
14507
|
+
critical: boolean().optional(),
|
|
14508
|
+
silent: boolean().optional(),
|
|
14509
|
+
noPush: boolean().optional()
|
|
14510
|
+
}).optional(),
|
|
14511
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
14512
|
+
requires: array(string()).optional(),
|
|
14513
|
+
description: string().optional()
|
|
14514
|
+
});
|
|
14515
|
+
/** The full capability block consulted before dispatch. */
|
|
14516
|
+
var TargetKindCapsSchema = object({
|
|
14517
|
+
attachments: object({
|
|
14518
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
14519
|
+
mode: _enum([
|
|
14520
|
+
"url",
|
|
14521
|
+
"bytes",
|
|
14522
|
+
"both"
|
|
14523
|
+
]),
|
|
14524
|
+
max: number().int().nonnegative(),
|
|
14525
|
+
maxBytes: number().int().positive().optional()
|
|
14526
|
+
}),
|
|
14527
|
+
/** Max action buttons (0 = none). */
|
|
14528
|
+
actions: number().int().nonnegative(),
|
|
14529
|
+
levels: array(TargetKindLevelSchema),
|
|
14530
|
+
format: array(NotificationFormatSchema),
|
|
14531
|
+
clickUrl: boolean(),
|
|
14532
|
+
sound: boolean(),
|
|
14533
|
+
ttl: boolean(),
|
|
14534
|
+
bodyMaxLen: number().int().positive()
|
|
14535
|
+
});
|
|
14536
|
+
/**
|
|
14537
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
14538
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
14539
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
14540
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
14541
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
14542
|
+
*/
|
|
14543
|
+
var ConfigSchemaPassthrough = unknown();
|
|
14544
|
+
var TargetKindSchema = object({
|
|
14545
|
+
kind: string(),
|
|
14546
|
+
label: string(),
|
|
14547
|
+
icon: string(),
|
|
14548
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
14549
|
+
addonId: string(),
|
|
14550
|
+
configSchema: ConfigSchemaPassthrough,
|
|
14551
|
+
supportsDiscovery: boolean(),
|
|
14552
|
+
caps: TargetKindCapsSchema
|
|
14553
|
+
});
|
|
14554
|
+
/**
|
|
14555
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
14556
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
14557
|
+
* round-trip a stored secret to the UI.
|
|
14558
|
+
*/
|
|
14559
|
+
var TargetSchema = object({
|
|
14560
|
+
id: string(),
|
|
14561
|
+
name: string(),
|
|
14562
|
+
kind: string(),
|
|
14563
|
+
addonId: string(),
|
|
14564
|
+
enabled: boolean(),
|
|
14565
|
+
config: record(string(), unknown())
|
|
14566
|
+
});
|
|
14567
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
14568
|
+
var DiscoveredTargetSchema = object({
|
|
14569
|
+
kind: string(),
|
|
14570
|
+
suggestedName: string(),
|
|
14571
|
+
config: record(string(), unknown())
|
|
14572
|
+
});
|
|
14573
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
14574
|
+
var RenderedAsSchema = object({
|
|
14575
|
+
level: string(),
|
|
14576
|
+
format: NotificationFormatSchema,
|
|
14577
|
+
attachmentsSent: number().int().nonnegative(),
|
|
14578
|
+
actionsSent: number().int().nonnegative(),
|
|
14579
|
+
truncated: boolean(),
|
|
14580
|
+
dropped: array(string())
|
|
14581
|
+
});
|
|
14582
|
+
var SendResultSchema = object({
|
|
13388
14583
|
success: boolean(),
|
|
13389
|
-
error: string().optional()
|
|
13390
|
-
|
|
14584
|
+
error: string().optional(),
|
|
14585
|
+
renderedAs: RenderedAsSchema.optional()
|
|
14586
|
+
});
|
|
14587
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
14588
|
+
var TestResultSchema = SendResultSchema;
|
|
14589
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
|
|
14590
|
+
kind: string(),
|
|
14591
|
+
config: record(string(), unknown()).optional()
|
|
14592
|
+
}), array(DiscoveredTargetSchema)), method(object({
|
|
14593
|
+
targetId: string(),
|
|
14594
|
+
notification: NotificationSchema
|
|
14595
|
+
}), SendResultSchema, { kind: "mutation" }), method(object({
|
|
14596
|
+
targetId: string(),
|
|
14597
|
+
sample: NotificationSchema.optional()
|
|
14598
|
+
}), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
|
|
14599
|
+
targetId: string(),
|
|
14600
|
+
enabled: boolean()
|
|
14601
|
+
}), _void(), { kind: "mutation" });
|
|
13391
14602
|
/**
|
|
13392
14603
|
* Zod schemas for persisted record types.
|
|
13393
14604
|
*
|
|
@@ -16527,7 +17738,10 @@ var HwAccelBackendInputSchema = _enum([
|
|
|
16527
17738
|
"webgpu",
|
|
16528
17739
|
"none"
|
|
16529
17740
|
]).nullable().optional();
|
|
16530
|
-
var HwAccelResolutionSchema = object({
|
|
17741
|
+
var HwAccelResolutionSchema = object({
|
|
17742
|
+
preferred: array(string()).readonly(),
|
|
17743
|
+
rationale: string()
|
|
17744
|
+
});
|
|
16531
17745
|
var HardwareEncoderIdSchema = _enum([
|
|
16532
17746
|
"h264_videotoolbox",
|
|
16533
17747
|
"hevc_videotoolbox",
|
|
@@ -16632,10 +17846,7 @@ var ResolvedInferenceConfigSchema = object({
|
|
|
16632
17846
|
format: ModelFormatSchema,
|
|
16633
17847
|
reason: string()
|
|
16634
17848
|
});
|
|
16635
|
-
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
|
|
16636
|
-
prefer: HwAccelBackendInputSchema,
|
|
16637
|
-
nodeId: string().optional()
|
|
16638
|
-
}), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
17849
|
+
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
16639
17850
|
kind: "mutation",
|
|
16640
17851
|
auth: "admin"
|
|
16641
17852
|
}), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
|
|
@@ -16694,6 +17905,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
|
|
|
16694
17905
|
kind: "mutation",
|
|
16695
17906
|
auth: "admin"
|
|
16696
17907
|
});
|
|
17908
|
+
/**
|
|
17909
|
+
* `recording` cap — footage availability + HLS playback manifests + per-device
|
|
17910
|
+
* recording config. NOTE on events (source of truth, R5/C3): this cap carries
|
|
17911
|
+
* NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
|
|
17912
|
+
* events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
|
|
17913
|
+
* rows); the recorder's internal EventMap markers are ephemeral in-RAM
|
|
17914
|
+
* annotations that are not exposed here and must not be treated as an event
|
|
17915
|
+
* feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
|
|
17916
|
+
* (`interfaces/recording-config.ts`).
|
|
17917
|
+
*/
|
|
16697
17918
|
var RecordingStatusSchema = object({
|
|
16698
17919
|
deviceId: number(),
|
|
16699
17920
|
enabled: boolean(),
|
|
@@ -18330,6 +19551,12 @@ Object.freeze({
|
|
|
18330
19551
|
addonId: null,
|
|
18331
19552
|
access: "view"
|
|
18332
19553
|
},
|
|
19554
|
+
"deviceManager.getRoleDisplayDefaults": {
|
|
19555
|
+
capName: "device-manager",
|
|
19556
|
+
capScope: "system",
|
|
19557
|
+
addonId: null,
|
|
19558
|
+
access: "view"
|
|
19559
|
+
},
|
|
18333
19560
|
"deviceManager.getSettingsSchema": {
|
|
18334
19561
|
capName: "device-manager",
|
|
18335
19562
|
capScope: "system",
|
|
@@ -18480,6 +19707,12 @@ Object.freeze({
|
|
|
18480
19707
|
addonId: null,
|
|
18481
19708
|
access: "create"
|
|
18482
19709
|
},
|
|
19710
|
+
"deviceManager.setDisplay": {
|
|
19711
|
+
capName: "device-manager",
|
|
19712
|
+
capScope: "system",
|
|
19713
|
+
addonId: null,
|
|
19714
|
+
access: "create"
|
|
19715
|
+
},
|
|
18483
19716
|
"deviceManager.setIntegrationId": {
|
|
18484
19717
|
capName: "device-manager",
|
|
18485
19718
|
capScope: "system",
|
|
@@ -18522,6 +19755,12 @@ Object.freeze({
|
|
|
18522
19755
|
addonId: null,
|
|
18523
19756
|
access: "create"
|
|
18524
19757
|
},
|
|
19758
|
+
"deviceManager.setRoleDisplayDefaults": {
|
|
19759
|
+
capName: "device-manager",
|
|
19760
|
+
capScope: "system",
|
|
19761
|
+
addonId: null,
|
|
19762
|
+
access: "create"
|
|
19763
|
+
},
|
|
18525
19764
|
"deviceManager.setStreamProfileMap": {
|
|
18526
19765
|
capName: "device-manager",
|
|
18527
19766
|
capScope: "system",
|
|
@@ -19500,13 +20739,49 @@ Object.freeze({
|
|
|
19500
20739
|
addonId: null,
|
|
19501
20740
|
access: "create"
|
|
19502
20741
|
},
|
|
20742
|
+
"notificationOutput.deleteTarget": {
|
|
20743
|
+
capName: "notification-output",
|
|
20744
|
+
capScope: "system",
|
|
20745
|
+
addonId: null,
|
|
20746
|
+
access: "delete"
|
|
20747
|
+
},
|
|
20748
|
+
"notificationOutput.discoverTargets": {
|
|
20749
|
+
capName: "notification-output",
|
|
20750
|
+
capScope: "system",
|
|
20751
|
+
addonId: null,
|
|
20752
|
+
access: "view"
|
|
20753
|
+
},
|
|
20754
|
+
"notificationOutput.listTargetKinds": {
|
|
20755
|
+
capName: "notification-output",
|
|
20756
|
+
capScope: "system",
|
|
20757
|
+
addonId: null,
|
|
20758
|
+
access: "view"
|
|
20759
|
+
},
|
|
20760
|
+
"notificationOutput.listTargets": {
|
|
20761
|
+
capName: "notification-output",
|
|
20762
|
+
capScope: "system",
|
|
20763
|
+
addonId: null,
|
|
20764
|
+
access: "view"
|
|
20765
|
+
},
|
|
19503
20766
|
"notificationOutput.send": {
|
|
19504
20767
|
capName: "notification-output",
|
|
19505
20768
|
capScope: "system",
|
|
19506
20769
|
addonId: null,
|
|
19507
20770
|
access: "create"
|
|
19508
20771
|
},
|
|
19509
|
-
"notificationOutput.
|
|
20772
|
+
"notificationOutput.setTargetEnabled": {
|
|
20773
|
+
capName: "notification-output",
|
|
20774
|
+
capScope: "system",
|
|
20775
|
+
addonId: null,
|
|
20776
|
+
access: "create"
|
|
20777
|
+
},
|
|
20778
|
+
"notificationOutput.testTarget": {
|
|
20779
|
+
capName: "notification-output",
|
|
20780
|
+
capScope: "system",
|
|
20781
|
+
addonId: null,
|
|
20782
|
+
access: "create"
|
|
20783
|
+
},
|
|
20784
|
+
"notificationOutput.upsertTarget": {
|
|
19510
20785
|
capName: "notification-output",
|
|
19511
20786
|
capScope: "system",
|
|
19512
20787
|
addonId: null,
|
|
@@ -19536,6 +20811,66 @@ Object.freeze({
|
|
|
19536
20811
|
addonId: null,
|
|
19537
20812
|
access: "create"
|
|
19538
20813
|
},
|
|
20814
|
+
"petFeeder.callPet": {
|
|
20815
|
+
capName: "pet-feeder",
|
|
20816
|
+
capScope: "device",
|
|
20817
|
+
addonId: null,
|
|
20818
|
+
access: "create"
|
|
20819
|
+
},
|
|
20820
|
+
"petFeeder.cancelFeed": {
|
|
20821
|
+
capName: "pet-feeder",
|
|
20822
|
+
capScope: "device",
|
|
20823
|
+
addonId: null,
|
|
20824
|
+
access: "create"
|
|
20825
|
+
},
|
|
20826
|
+
"petFeeder.feed": {
|
|
20827
|
+
capName: "pet-feeder",
|
|
20828
|
+
capScope: "device",
|
|
20829
|
+
addonId: null,
|
|
20830
|
+
access: "create"
|
|
20831
|
+
},
|
|
20832
|
+
"petFeeder.markFoodReplenished": {
|
|
20833
|
+
capName: "pet-feeder",
|
|
20834
|
+
capScope: "device",
|
|
20835
|
+
addonId: null,
|
|
20836
|
+
access: "create"
|
|
20837
|
+
},
|
|
20838
|
+
"petFeeder.playSound": {
|
|
20839
|
+
capName: "pet-feeder",
|
|
20840
|
+
capScope: "device",
|
|
20841
|
+
addonId: null,
|
|
20842
|
+
access: "create"
|
|
20843
|
+
},
|
|
20844
|
+
"petFeeder.resetDesiccant": {
|
|
20845
|
+
capName: "pet-feeder",
|
|
20846
|
+
capScope: "device",
|
|
20847
|
+
addonId: null,
|
|
20848
|
+
access: "delete"
|
|
20849
|
+
},
|
|
20850
|
+
"petFeeder.setChildLock": {
|
|
20851
|
+
capName: "pet-feeder",
|
|
20852
|
+
capScope: "device",
|
|
20853
|
+
addonId: null,
|
|
20854
|
+
access: "create"
|
|
20855
|
+
},
|
|
20856
|
+
"petFeeder.setFeedSound": {
|
|
20857
|
+
capName: "pet-feeder",
|
|
20858
|
+
capScope: "device",
|
|
20859
|
+
addonId: null,
|
|
20860
|
+
access: "create"
|
|
20861
|
+
},
|
|
20862
|
+
"petFeeder.setIndicatorLight": {
|
|
20863
|
+
capName: "pet-feeder",
|
|
20864
|
+
capScope: "device",
|
|
20865
|
+
addonId: null,
|
|
20866
|
+
access: "create"
|
|
20867
|
+
},
|
|
20868
|
+
"petFeeder.setVolume": {
|
|
20869
|
+
capName: "pet-feeder",
|
|
20870
|
+
capScope: "device",
|
|
20871
|
+
addonId: null,
|
|
20872
|
+
access: "create"
|
|
20873
|
+
},
|
|
19539
20874
|
"pipelineAnalytics.clearTracks": {
|
|
19540
20875
|
capName: "pipeline-analytics",
|
|
19541
20876
|
capScope: "device",
|
|
@@ -21492,4 +22827,4 @@ object({
|
|
|
21492
22827
|
schemaVersion: literal(1)
|
|
21493
22828
|
});
|
|
21494
22829
|
//#endregion
|
|
21495
|
-
export {
|
|
22830
|
+
export { object as C, number as S, tuple as T, createEvent as _, embeddingEncoderCapability as a, array as b, pipelineAnalyticsCapability as c, zoneAnalyticsCapability as d, errMsg as f, asJsonObject as g, EventCategory as h, cosineSimilarity as i, plateGalleryCapability as l, DeviceType as m, addonWidgetsSourceCapability as n, faceGalleryCapability as o, BaseAddon as p, audioMetricsCapability as r, hfModelUrl as s, EVENT_PAD_MS as t, videoclipsCapability as u, hydrateSchema as v, string as w, boolean as x, _enum as y };
|