@camstack/addon-pipeline-orchestrator 1.0.4 → 1.0.6
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/_stub.js +2 -2
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets--jkY2PwT.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-c4sRff6P.mjs} +3 -3
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-D4bRlsl2.mjs +26 -0
- package/dist/{_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DUkBS-o2.mjs → _virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-C7j6Ec2v.mjs} +1 -1
- package/dist/{hostInit-CSC3mFBH.mjs → hostInit-DHmBrx_a.mjs} +3 -3
- package/dist/index.js +1828 -1141
- package/dist/index.mjs +1828 -1141
- package/dist/remoteEntry.js +1 -1
- package/package.json +1 -1
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-TYiNYNvp.mjs +0 -26
package/dist/index.mjs
CHANGED
|
@@ -4627,63 +4627,7 @@ function _instanceof(cls, params = {}) {
|
|
|
4627
4627
|
return inst;
|
|
4628
4628
|
}
|
|
4629
4629
|
//#endregion
|
|
4630
|
-
//#region ../types/dist/
|
|
4631
|
-
/**
|
|
4632
|
-
* Deep wiring healthcheck — snapshot of active reachability probes across
|
|
4633
|
-
* every declared capability + widget of every installed plugin, on every
|
|
4634
|
-
* node. Produced by the backend `WiringHealthService` and surfaced via
|
|
4635
|
-
* `GET /health/wiring`, the tRPC `health.wiring` query, and the boot-gate.
|
|
4636
|
-
*
|
|
4637
|
-
* Unlike `/health` (process liveness), this reflects whether each cap/widget
|
|
4638
|
-
* is actually *reachable* over the real cap-dispatch path. See spec
|
|
4639
|
-
* `docs/superpowers/specs/2026-05-23-deep-healthcheck-design.md`.
|
|
4640
|
-
*/
|
|
4641
|
-
/** What kind of target a probe addressed. */
|
|
4642
|
-
var wiringProbeKindSchema = _enum([
|
|
4643
|
-
"singleton",
|
|
4644
|
-
"device",
|
|
4645
|
-
"widget"
|
|
4646
|
-
]);
|
|
4647
|
-
/** Result of probing a single (cap|widget [, device]) target. */
|
|
4648
|
-
var wiringProbeResultSchema = object({
|
|
4649
|
-
capName: string(),
|
|
4650
|
-
kind: wiringProbeKindSchema,
|
|
4651
|
-
deviceId: number().optional(),
|
|
4652
|
-
reachable: boolean(),
|
|
4653
|
-
latencyMs: number(),
|
|
4654
|
-
error: string().optional()
|
|
4655
|
-
});
|
|
4656
|
-
/** Per-addon roll-up of cap + widget probe results. */
|
|
4657
|
-
var wiringAddonHealthSchema = object({
|
|
4658
|
-
addonId: string(),
|
|
4659
|
-
caps: array(wiringProbeResultSchema).readonly(),
|
|
4660
|
-
widgets: array(wiringProbeResultSchema).readonly()
|
|
4661
|
-
});
|
|
4662
|
-
/** Per-node roll-up. */
|
|
4663
|
-
var wiringNodeHealthSchema = object({
|
|
4664
|
-
nodeId: string(),
|
|
4665
|
-
addons: array(wiringAddonHealthSchema).readonly()
|
|
4666
|
-
});
|
|
4667
|
-
object({
|
|
4668
|
-
/** True only when every probed target is reachable. */
|
|
4669
|
-
ok: boolean(),
|
|
4670
|
-
/** True when at least one target is unreachable. */
|
|
4671
|
-
degraded: boolean(),
|
|
4672
|
-
checkedAt: string(),
|
|
4673
|
-
nodes: array(wiringNodeHealthSchema).readonly(),
|
|
4674
|
-
summary: object({
|
|
4675
|
-
total: number(),
|
|
4676
|
-
reachable: number(),
|
|
4677
|
-
unreachable: number()
|
|
4678
|
-
})
|
|
4679
|
-
});
|
|
4680
|
-
var MODEL_FORMATS = [
|
|
4681
|
-
"onnx",
|
|
4682
|
-
"coreml",
|
|
4683
|
-
"openvino",
|
|
4684
|
-
"tflite",
|
|
4685
|
-
"pt"
|
|
4686
|
-
];
|
|
4630
|
+
//#region ../types/dist/sleep-D7JeS58T.mjs
|
|
4687
4631
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4688
4632
|
EventCategory["SystemBoot"] = "system.boot";
|
|
4689
4633
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -4981,6 +4925,18 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
4981
4925
|
*/
|
|
4982
4926
|
EventCategory["PipelineEngineMetricsSnapshot"] = "pipeline.engine-metrics-snapshot";
|
|
4983
4927
|
/**
|
|
4928
|
+
* Per-node detection-engine runtime-provisioning transition. Emitted by
|
|
4929
|
+
* the detection-pipeline provider on every state change of its lazy
|
|
4930
|
+
* engine-provisioning machine (idle → installing → verifying → ready,
|
|
4931
|
+
* or → failed with a `nextRetryAt`). Payload is the
|
|
4932
|
+
* `EngineProvisioningState` snapshot; `event.source.nodeId` carries the
|
|
4933
|
+
* node. The Pipeline page subscribes to drive a live "installing
|
|
4934
|
+
* OpenVINO… / ready" indicator per node without polling
|
|
4935
|
+
* `pipelineExecutor.getEngineProvisioning`. Telemetry-grade (D8): the UI
|
|
4936
|
+
* also reads the cap snapshot on mount / reconnect. Phase 2.
|
|
4937
|
+
*/
|
|
4938
|
+
EventCategory["PipelineEngineProvisioning"] = "pipeline.engine-provisioning";
|
|
4939
|
+
/**
|
|
4984
4940
|
* Cluster topology snapshot. Carries the same payload returned by
|
|
4985
4941
|
* `nodes.topology` (every reachable node + addons + processes).
|
|
4986
4942
|
* Emitted by the hub on any agent / addon lifecycle change
|
|
@@ -6021,7 +5977,7 @@ function makeSourceBrokerId(deviceId, camStreamId) {
|
|
|
6021
5977
|
* Zod schema for StreamSourceEntry — the canonical stream descriptor
|
|
6022
5978
|
* exposed by ICameraDevice.getStreamSources() and consumed by the broker.
|
|
6023
5979
|
*/
|
|
6024
|
-
var StreamSourceEntrySchema = object({
|
|
5980
|
+
var StreamSourceEntrySchema$1 = object({
|
|
6025
5981
|
id: string(),
|
|
6026
5982
|
label: string(),
|
|
6027
5983
|
protocol: _enum([
|
|
@@ -6243,140 +6199,6 @@ var ProfileRtspEntrySchema = object({
|
|
|
6243
6199
|
codec: string().optional(),
|
|
6244
6200
|
resolution: CamStreamResolutionSchema.optional()
|
|
6245
6201
|
});
|
|
6246
|
-
/**
|
|
6247
|
-
* Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
|
|
6248
|
-
* Named `RecordingWeekday` to avoid collision with the string-union
|
|
6249
|
-
* `Weekday` exported from `interfaces/timezones.ts`.
|
|
6250
|
-
*/
|
|
6251
|
-
var RecordingWeekdaySchema = number().int().min(0).max(6);
|
|
6252
|
-
var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
|
|
6253
|
-
var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
|
|
6254
|
-
kind: literal("timeOfDay"),
|
|
6255
|
-
start: string().regex(HHMM),
|
|
6256
|
-
end: string().regex(HHMM),
|
|
6257
|
-
/** Restrict to these weekdays; omit = every day. */
|
|
6258
|
-
days: array(RecordingWeekdaySchema).optional()
|
|
6259
|
-
})]);
|
|
6260
|
-
var RecordingModeSchema = _enum([
|
|
6261
|
-
"continuous",
|
|
6262
|
-
"onMotion",
|
|
6263
|
-
"onAudioThreshold"
|
|
6264
|
-
]);
|
|
6265
|
-
/**
|
|
6266
|
-
* First-class, authoritative per-camera storage mode — the netta choice the UI
|
|
6267
|
-
* reads directly (never inferred from `rules`):
|
|
6268
|
-
* - `off` — not recording.
|
|
6269
|
-
* - `events` — record only around triggers (motion / audio threshold),
|
|
6270
|
-
* with pre/post-buffer.
|
|
6271
|
-
* - `continuous` — record 24/7 within the schedule.
|
|
6272
|
-
*
|
|
6273
|
-
* `mode` compiles one-way to the internal `rules[]` consumed by the policy
|
|
6274
|
-
* engine (see `compileRules`); `rules[]` is never authored directly anymore.
|
|
6275
|
-
*/
|
|
6276
|
-
var RecordingStorageModeSchema = _enum([
|
|
6277
|
-
"off",
|
|
6278
|
-
"events",
|
|
6279
|
-
"continuous"
|
|
6280
|
-
]);
|
|
6281
|
-
/** Which detectors trigger an `events`-mode recording. */
|
|
6282
|
-
var RecordingTriggersSchema = object({
|
|
6283
|
-
motion: boolean().optional(),
|
|
6284
|
-
audioThresholdDbfs: number().optional()
|
|
6285
|
-
});
|
|
6286
|
-
/**
|
|
6287
|
-
* Mode of a single recording band — the recorder per-band vocabulary.
|
|
6288
|
-
*
|
|
6289
|
-
* Distinct from `RecordingStorageModeSchema` (which carries `off`): a band is
|
|
6290
|
-
* only ever `continuous` or `events`; "off" is expressed by the absence of a
|
|
6291
|
-
* covering band, not by a band value.
|
|
6292
|
-
*/
|
|
6293
|
-
var RecordingBandModeSchema = _enum(["continuous", "events"]);
|
|
6294
|
-
/**
|
|
6295
|
-
* Triggers for an `events`-mode band. Identical shape to
|
|
6296
|
-
* `RecordingTriggersSchema` — reuse that schema as the band trigger type so the
|
|
6297
|
-
* two never drift.
|
|
6298
|
-
*/
|
|
6299
|
-
var RecordingBandTriggersSchema = RecordingTriggersSchema;
|
|
6300
|
-
/**
|
|
6301
|
-
* A single mode-per-band window — the canonical recorder band shape, the
|
|
6302
|
-
* single source of truth re-used by `addon-pipeline/recorder`.
|
|
6303
|
-
*
|
|
6304
|
-
* `days` lists the weekdays the band covers (empty = every day, matching the
|
|
6305
|
-
* band engine's `applies` rule). `start`/`end` are `HH:MM`; an `end <= start`
|
|
6306
|
-
* span wraps past midnight (handled by the band engine).
|
|
6307
|
-
*/
|
|
6308
|
-
var RecordingBandSchema = object({
|
|
6309
|
-
days: array(RecordingWeekdaySchema),
|
|
6310
|
-
start: string().regex(HHMM),
|
|
6311
|
-
end: string().regex(HHMM),
|
|
6312
|
-
mode: RecordingBandModeSchema,
|
|
6313
|
-
triggers: RecordingBandTriggersSchema.optional(),
|
|
6314
|
-
preBufferSec: number().min(0).optional(),
|
|
6315
|
-
postBufferSec: number().min(0).optional()
|
|
6316
|
-
});
|
|
6317
|
-
var RecordingRuleSchema = object({
|
|
6318
|
-
schedule: RecordingScheduleSchema,
|
|
6319
|
-
mode: RecordingModeSchema,
|
|
6320
|
-
/** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
|
|
6321
|
-
preBufferSec: number().min(0).default(0),
|
|
6322
|
-
/** Keep recording until this many seconds after the last trigger. */
|
|
6323
|
-
postBufferSec: number().min(0).default(0),
|
|
6324
|
-
/** Each new trigger restarts the post-buffer window. */
|
|
6325
|
-
resetTimeoutOnNewEvent: boolean().default(true),
|
|
6326
|
-
/** onAudioThreshold only — dBFS level that counts as a trigger. */
|
|
6327
|
-
thresholdDbfs: number().optional()
|
|
6328
|
-
});
|
|
6329
|
-
/**
|
|
6330
|
-
* Per-device retention overrides. Every field is optional; an unset or `0`
|
|
6331
|
-
* value inherits the node-wide recorder default. Only footage-lifetime limits
|
|
6332
|
-
* live per-camera: `maxAgeDays` and `maxSizeGb`. The disk-occupancy threshold
|
|
6333
|
-
* (when the volume is too full to keep recording) is NOT a per-camera concern —
|
|
6334
|
-
* it belongs to the StorageLocation (`StorageLocation.config.minFreePercent`),
|
|
6335
|
-
* shared by every camera writing to that volume.
|
|
6336
|
-
*/
|
|
6337
|
-
var RecordingRetentionSchema = object({
|
|
6338
|
-
maxAgeDays: number().min(0).optional(),
|
|
6339
|
-
maxSizeGb: number().min(0).optional()
|
|
6340
|
-
});
|
|
6341
|
-
/**
|
|
6342
|
-
* The full per-camera recording intent — the wire shape of a RecordingTarget.
|
|
6343
|
-
*
|
|
6344
|
-
* `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
|
|
6345
|
-
* are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
|
|
6346
|
-
* only for transition + migration (`migrateRulesToMode`); the policy engine
|
|
6347
|
-
* consumes the compiled output of `compileRules(config)`, never `rules` directly.
|
|
6348
|
-
*/
|
|
6349
|
-
var RecordingConfigSchema = object({
|
|
6350
|
-
enabled: boolean(),
|
|
6351
|
-
/** Authoritative storage mode. Absent on legacy targets → derived once via
|
|
6352
|
-
* `migrateRulesToMode`, then persisted. */
|
|
6353
|
-
mode: RecordingStorageModeSchema.optional(),
|
|
6354
|
-
profiles: array(CamProfileSchema).optional(),
|
|
6355
|
-
segmentSeconds: number().int().positive().optional(),
|
|
6356
|
-
/** Shared recording time-bands for `events` & `continuous` — record only when
|
|
6357
|
-
* the wall-clock falls inside one of these windows. Omit or empty = always.
|
|
6358
|
-
* `continuous` compiles to one rule per band; `events` to band × trigger. */
|
|
6359
|
-
schedules: array(RecordingScheduleSchema).optional(),
|
|
6360
|
-
/** Legacy single-band predecessor of `schedules`. Read-compat only — it is
|
|
6361
|
-
* normalized into `schedules` on read and never written going forward. (Not
|
|
6362
|
-
* tagged `@deprecated`: the normalization paths must read it cast-free.) */
|
|
6363
|
-
schedule: RecordingScheduleSchema.optional(),
|
|
6364
|
-
/** `events`-mode only — which detectors trigger a recording. */
|
|
6365
|
-
triggers: RecordingTriggersSchema.optional(),
|
|
6366
|
-
/** `events`-mode only — seconds retained before / after a trigger. */
|
|
6367
|
-
preBufferSec: number().min(0).optional(),
|
|
6368
|
-
postBufferSec: number().min(0).optional(),
|
|
6369
|
-
/** DEPRECATED authoring input; retained for migration/transition. */
|
|
6370
|
-
rules: array(RecordingRuleSchema).optional(),
|
|
6371
|
-
/**
|
|
6372
|
-
* AUTHORITATIVE mode-per-band recording model (recorder). When present it
|
|
6373
|
-
* is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
|
|
6374
|
-
* `triggers`/`rules` fields above are kept for READ-COMPAT only and are
|
|
6375
|
-
* derived into bands once via `migrateConfigToBands`.
|
|
6376
|
-
*/
|
|
6377
|
-
bands: array(RecordingBandSchema).optional(),
|
|
6378
|
-
retention: RecordingRetentionSchema.optional()
|
|
6379
|
-
});
|
|
6380
6202
|
var ReadinessTimeoutError = class extends Error {
|
|
6381
6203
|
capName;
|
|
6382
6204
|
scope;
|
|
@@ -6726,770 +6548,1116 @@ function randomGeneration() {
|
|
|
6726
6548
|
if (typeof crypto !== "undefined" && crypto.randomUUID) return crypto.randomUUID();
|
|
6727
6549
|
return Math.random().toString(36).slice(2, 14);
|
|
6728
6550
|
}
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
*
|
|
6740
|
-
*
|
|
6741
|
-
*
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
*
|
|
6751
|
-
* `
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
*
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
*
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
*/
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
*
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
*
|
|
6774
|
-
*
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
*
|
|
6786
|
-
* -
|
|
6787
|
-
*
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
*
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
*
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
*
|
|
6802
|
-
*
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
*
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
/**
|
|
6813
|
-
* Global location identifier, e.g. `recordings` or `recordingsLow`.
|
|
6814
|
-
* Must start with a lowercase letter and may contain letters, digits, and
|
|
6815
|
-
* hyphens.
|
|
6816
|
-
*/
|
|
6817
|
-
id: string().regex(/^[a-z][a-zA-Z0-9-]*$/, { message: "id must start with a lowercase letter and contain only letters, digits, or hyphens" }),
|
|
6818
|
-
/** Human-readable name shown in the admin UI. */
|
|
6819
|
-
displayName: string().min(1, { message: "displayName must not be empty" }),
|
|
6820
|
-
/** Optional longer explanation of what data this location stores. */
|
|
6821
|
-
description: string().optional(),
|
|
6822
|
-
/**
|
|
6823
|
-
* `single` — exactly one instance of this location is allowed system-wide
|
|
6824
|
-
* (e.g. `logs`, `models`). The operator can edit it but not add more.
|
|
6825
|
-
* `multi` — the operator may register several instances (e.g. a second
|
|
6826
|
-
* `recordings` on a NAS for disk tiering); one is the default at any time.
|
|
6827
|
-
*/
|
|
6828
|
-
cardinality: _enum(["single", "multi"]),
|
|
6829
|
-
/**
|
|
6830
|
-
* When set, the default instance for this location inherits its resolved
|
|
6831
|
-
* root from the named location's default instance. Useful for derivative
|
|
6832
|
-
* slots (e.g. `recordingsLow` → `recordings`) so operators only need to
|
|
6833
|
-
* configure the primary location.
|
|
6834
|
-
*/
|
|
6835
|
-
defaultsTo: string().optional()
|
|
6836
|
-
});
|
|
6837
|
-
var DecoderStatsSchema = object({
|
|
6838
|
-
inputFps: number(),
|
|
6839
|
-
outputFps: number(),
|
|
6840
|
-
avgDecodeTimeMs: number(),
|
|
6841
|
-
droppedFrames: number()
|
|
6842
|
-
});
|
|
6843
|
-
var DecoderSessionConfigSchema = object({
|
|
6844
|
-
codec: string(),
|
|
6845
|
-
maxFps: number().default(0),
|
|
6846
|
-
outputFormat: _enum([
|
|
6847
|
-
"jpeg",
|
|
6848
|
-
"rgb",
|
|
6849
|
-
"bgr",
|
|
6850
|
-
"yuv420",
|
|
6851
|
-
"gray"
|
|
6852
|
-
]).default("jpeg"),
|
|
6853
|
-
scale: number().default(1),
|
|
6854
|
-
width: number().optional(),
|
|
6855
|
-
height: number().optional(),
|
|
6551
|
+
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
6552
|
+
DeviceType["Camera"] = "camera";
|
|
6553
|
+
DeviceType["Hub"] = "hub";
|
|
6554
|
+
DeviceType["Light"] = "light";
|
|
6555
|
+
DeviceType["Siren"] = "siren";
|
|
6556
|
+
DeviceType["Switch"] = "switch";
|
|
6557
|
+
DeviceType["Sensor"] = "sensor";
|
|
6558
|
+
DeviceType["Thermostat"] = "thermostat";
|
|
6559
|
+
DeviceType["Button"] = "button";
|
|
6560
|
+
/** Generic stateless event emitter — carries a device's EXACT declared
|
|
6561
|
+
* event vocabulary verbatim (no normalization). Installed with the
|
|
6562
|
+
* `event-emitter` cap. Sources: HA `event.*` entities (structured) and
|
|
6563
|
+
* HA bus events (e.g. `zha_event`, generic). */
|
|
6564
|
+
DeviceType["EventEmitter"] = "event-emitter";
|
|
6565
|
+
/** Firmware/software update entity — current vs available version,
|
|
6566
|
+
* updatable flag, update state, and an install action. Installed with
|
|
6567
|
+
* the `update` cap. Sources: Homematic firmware-update channels (and
|
|
6568
|
+
* reusable by other providers, e.g. HA `update.*` entities). */
|
|
6569
|
+
DeviceType["Update"] = "update";
|
|
6570
|
+
DeviceType["Generic"] = "generic";
|
|
6571
|
+
/** Generic notification delivery target (HA `notify.<service>`, future
|
|
6572
|
+
* Telegram / Discord / ntfy / SMTP, …). One device per delivery
|
|
6573
|
+
* endpoint; the `notifier` cap defines the send surface. */
|
|
6574
|
+
DeviceType["Notifier"] = "notifier";
|
|
6575
|
+
/** Pre-recorded action sequence with optional parameters
|
|
6576
|
+
* (HA `script.*`). Runnable via `script-runner` cap. */
|
|
6577
|
+
DeviceType["Script"] = "script";
|
|
6578
|
+
/** Automation rule (HA `automation.*`) — enable/disable + manual
|
|
6579
|
+
* trigger surface exposed via `automation-control` cap. */
|
|
6580
|
+
DeviceType["Automation"] = "automation";
|
|
6581
|
+
/** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
|
|
6582
|
+
DeviceType["Lock"] = "lock";
|
|
6583
|
+
/** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
|
|
6584
|
+
* `valve.*`). `cover` cap with sub-roles for variant. */
|
|
6585
|
+
DeviceType["Cover"] = "cover";
|
|
6586
|
+
/** Pipe / water / gas valve with open/close/stop and optional
|
|
6587
|
+
* position (HA `valve.*`). `valve` cap — a cover-sibling actuator
|
|
6588
|
+
* modelled on the same open/closed lifecycle. */
|
|
6589
|
+
DeviceType["Valve"] = "valve";
|
|
6590
|
+
/** Humidifier / dehumidifier with on/off + target humidity + mode
|
|
6591
|
+
* (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
|
|
6592
|
+
* modelled on the same target / mode lifecycle. */
|
|
6593
|
+
DeviceType["Humidifier"] = "humidifier";
|
|
6594
|
+
/** Water heater / boiler with target temperature + operation mode +
|
|
6595
|
+
* away mode (HA `water_heater.*`). `water-heater` cap — a
|
|
6596
|
+
* climate-family actuator. */
|
|
6597
|
+
DeviceType["WaterHeater"] = "water-heater";
|
|
6598
|
+
/** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
|
|
6599
|
+
DeviceType["Fan"] = "fan";
|
|
6600
|
+
/** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
|
|
6601
|
+
* the camera surface — those use `Camera`. `media-player` cap. */
|
|
6602
|
+
DeviceType["MediaPlayer"] = "media-player";
|
|
6603
|
+
/** Security panel / alarm system (HA `alarm_control_panel.*`).
|
|
6604
|
+
* `alarm-panel` cap. */
|
|
6605
|
+
DeviceType["AlarmPanel"] = "alarm-panel";
|
|
6606
|
+
/** Generic user-settable input (HA `number` / `input_number` / `select`
|
|
6607
|
+
* / `input_select` / `text` / `input_text` / `input_datetime`).
|
|
6608
|
+
* Sub-type via `DeviceRole`: NumericControl / SelectControl /
|
|
6609
|
+
* TextControl / DateTimeControl. */
|
|
6610
|
+
DeviceType["Control"] = "control";
|
|
6611
|
+
/** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
|
|
6612
|
+
* `presence` cap. */
|
|
6613
|
+
DeviceType["Presence"] = "presence";
|
|
6614
|
+
/** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
|
|
6615
|
+
* `weather` cap. */
|
|
6616
|
+
DeviceType["Weather"] = "weather";
|
|
6617
|
+
/** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
|
|
6618
|
+
DeviceType["Vacuum"] = "vacuum";
|
|
6619
|
+
/** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
|
|
6620
|
+
* `lawn-mower-control` cap. */
|
|
6621
|
+
DeviceType["LawnMower"] = "lawn-mower";
|
|
6622
|
+
/** Physical HA device group — parent container for entity-children
|
|
6623
|
+
* adopted from a single HA device entry. Not renderable as a
|
|
6624
|
+
* standalone device; exists only to anchor child entities. */
|
|
6625
|
+
DeviceType["Container"] = "container";
|
|
6626
|
+
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
6627
|
+
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
6628
|
+
DeviceType["Image"] = "image";
|
|
6629
|
+
return DeviceType;
|
|
6630
|
+
}({});
|
|
6631
|
+
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
6632
|
+
DeviceFeature["BatteryOperated"] = "battery-operated";
|
|
6633
|
+
DeviceFeature["Rebootable"] = "rebootable";
|
|
6856
6634
|
/**
|
|
6857
|
-
*
|
|
6858
|
-
*
|
|
6859
|
-
*
|
|
6860
|
-
* per-camera filtering when diagnosing failures (e.g. node-av
|
|
6861
|
-
* sendPacket errors on a single hung camera).
|
|
6635
|
+
* Device supports an on-demand re-sync of its derived spec with its
|
|
6636
|
+
* upstream source — drives the generic Re-sync button. The owning
|
|
6637
|
+
* provider implements the action via the `device-adoption.resync` cap.
|
|
6862
6638
|
*/
|
|
6863
|
-
|
|
6639
|
+
DeviceFeature["Resyncable"] = "resyncable";
|
|
6640
|
+
DeviceFeature["NativeSnapshot"] = "native-snapshot";
|
|
6641
|
+
DeviceFeature["DoorbellButton"] = "doorbell-button";
|
|
6642
|
+
DeviceFeature["TwoWayAudio"] = "two-way-audio";
|
|
6643
|
+
DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
|
|
6864
6644
|
/**
|
|
6865
|
-
*
|
|
6866
|
-
* `
|
|
6867
|
-
*
|
|
6868
|
-
*
|
|
6645
|
+
* Camera supports the on-firmware autotrack subsystem (subject-
|
|
6646
|
+
* following). Distinct from `PanTiltZoom` because not every PTZ
|
|
6647
|
+
* camera ships autotrack — the admin UI uses this flag to gate
|
|
6648
|
+
* the autotrack toggle / settings card without re-deriving from
|
|
6649
|
+
* the cap registry. Mirrors `ptz-autotrack` cap registration:
|
|
6650
|
+
* driver sets this feature when probe confirms the firmware
|
|
6651
|
+
* surface, and registers the cap in the same code path.
|
|
6869
6652
|
*/
|
|
6870
|
-
|
|
6653
|
+
DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
|
|
6871
6654
|
/**
|
|
6872
|
-
*
|
|
6655
|
+
* Accessory exposes a "trigger on motion" toggle — the parent camera's
|
|
6656
|
+
* motion detection automatically activates this device. Mirrors
|
|
6657
|
+
* `motion-trigger` cap registration: drivers set this feature in the
|
|
6658
|
+
* same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
|
|
6873
6659
|
*
|
|
6874
|
-
*
|
|
6875
|
-
*
|
|
6876
|
-
*
|
|
6877
|
-
* into an OS shared-memory ring and drained as zero-pixel
|
|
6878
|
-
* `FrameHandle`s via `pullHandles`. A session is one mode or the
|
|
6879
|
-
* other — `pullFrames` returns nothing for an `'shm'` session and
|
|
6880
|
-
* `pullHandles` returns nothing for a `'callback'` session.
|
|
6881
|
-
*/
|
|
6882
|
-
frameSink: _enum(["callback", "shm"]).default("callback")
|
|
6883
|
-
});
|
|
6884
|
-
var EncodeProfileSchema = object({
|
|
6885
|
-
video: object({
|
|
6886
|
-
codec: _enum([
|
|
6887
|
-
"h264",
|
|
6888
|
-
"h265",
|
|
6889
|
-
"copy"
|
|
6890
|
-
]),
|
|
6891
|
-
profile: _enum([
|
|
6892
|
-
"baseline",
|
|
6893
|
-
"main",
|
|
6894
|
-
"high"
|
|
6895
|
-
]).optional(),
|
|
6896
|
-
width: number().int().positive().optional(),
|
|
6897
|
-
height: number().int().positive().optional(),
|
|
6898
|
-
fps: number().positive().optional(),
|
|
6899
|
-
bitrateKbps: number().int().positive().optional(),
|
|
6900
|
-
gopFrames: number().int().positive().optional(),
|
|
6901
|
-
bf: number().int().min(0).optional(),
|
|
6902
|
-
preset: _enum([
|
|
6903
|
-
"ultrafast",
|
|
6904
|
-
"superfast",
|
|
6905
|
-
"veryfast",
|
|
6906
|
-
"faster",
|
|
6907
|
-
"fast",
|
|
6908
|
-
"medium"
|
|
6909
|
-
]).optional(),
|
|
6910
|
-
tune: _enum([
|
|
6911
|
-
"zerolatency",
|
|
6912
|
-
"film",
|
|
6913
|
-
"animation"
|
|
6914
|
-
]).optional()
|
|
6915
|
-
}),
|
|
6916
|
-
audio: union([literal("passthrough"), object({
|
|
6917
|
-
codec: _enum([
|
|
6918
|
-
"opus",
|
|
6919
|
-
"aac",
|
|
6920
|
-
"pcmu",
|
|
6921
|
-
"pcma",
|
|
6922
|
-
"copy"
|
|
6923
|
-
]),
|
|
6924
|
-
bitrateKbps: number().int().positive().optional(),
|
|
6925
|
-
sampleRateHz: number().int().positive().optional(),
|
|
6926
|
-
channels: union([literal(1), literal(2)]).optional()
|
|
6927
|
-
})]),
|
|
6928
|
-
/**
|
|
6929
|
-
* ffmpeg input-side args, inserted between the fixed global flags
|
|
6930
|
-
* (`-hide_banner -loglevel error`) and `-i pipe:0`. Free-text array
|
|
6931
|
-
* — the widget surfaces a textarea + suggestion chips for the most-
|
|
6932
|
-
* used demuxer/format options.
|
|
6933
|
-
*/
|
|
6934
|
-
inputArgs: array(string()).optional(),
|
|
6935
|
-
/**
|
|
6936
|
-
* ffmpeg output-side args, inserted between the encode block and
|
|
6937
|
-
* the final `-f <muxer> pipe:1`. Use for muxer options, bitstream
|
|
6938
|
-
* filters, codec-specific overrides. Free-text array.
|
|
6660
|
+
* Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
|
|
6661
|
+
* fast scalar without binding fetch), notifier rules, and `listAll`
|
|
6662
|
+
* filters that want "all devices with on-motion behaviour".
|
|
6939
6663
|
*/
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6664
|
+
DeviceFeature["MotionTrigger"] = "motion-trigger";
|
|
6665
|
+
/** Light supports rgb-triplet color via `color` cap. */
|
|
6666
|
+
DeviceFeature["LightColorRgb"] = "light-color-rgb";
|
|
6667
|
+
/** Light supports HSV color via `color` cap. */
|
|
6668
|
+
DeviceFeature["LightColorHsv"] = "light-color-hsv";
|
|
6669
|
+
/** Light supports color-temperature (mired) via `color` cap. */
|
|
6670
|
+
DeviceFeature["LightColorMired"] = "light-color-mired";
|
|
6671
|
+
/** Thermostat supports a `heat_cool` dual setpoint (targetLow +
|
|
6672
|
+
* targetHigh). Gates the range slider UI. */
|
|
6673
|
+
DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
|
|
6674
|
+
/** Thermostat exposes target humidity and/or current humidity
|
|
6675
|
+
* readings. Gates the humidity controls. */
|
|
6676
|
+
DeviceFeature["ClimateHumidity"] = "climate-humidity";
|
|
6677
|
+
/** Thermostat exposes a fan-mode selector. */
|
|
6678
|
+
DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
|
|
6679
|
+
/** Thermostat exposes preset modes (eco / away / sleep / vendor). */
|
|
6680
|
+
DeviceFeature["ClimatePreset"] = "climate-preset";
|
|
6681
|
+
/** Cover exposes intermediate position control (0..100). Gates the
|
|
6682
|
+
* position slider UI. */
|
|
6683
|
+
DeviceFeature["CoverPositionable"] = "cover-positionable";
|
|
6684
|
+
/** Cover exposes slat-tilt control. Gates the tilt slider UI. */
|
|
6685
|
+
DeviceFeature["CoverTilt"] = "cover-tilt";
|
|
6686
|
+
/** Valve exposes intermediate position control (0..100). Gates the
|
|
6687
|
+
* position slider / drag surface UI. */
|
|
6688
|
+
DeviceFeature["ValvePositionable"] = "valve-positionable";
|
|
6689
|
+
/** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
|
|
6690
|
+
DeviceFeature["FanSpeed"] = "fan-speed";
|
|
6691
|
+
/** Fan exposes a preset mode selector. */
|
|
6692
|
+
DeviceFeature["FanPreset"] = "fan-preset";
|
|
6693
|
+
/** Fan exposes blade direction (forward/reverse) — typical of
|
|
6694
|
+
* ceiling fans. */
|
|
6695
|
+
DeviceFeature["FanDirection"] = "fan-direction";
|
|
6696
|
+
/** Fan exposes an oscillation toggle. */
|
|
6697
|
+
DeviceFeature["FanOscillating"] = "fan-oscillating";
|
|
6698
|
+
/** Lock requires a PIN code on lock/unlock. Gates the code-entry
|
|
6699
|
+
* field on the UI lock-controls panel. */
|
|
6700
|
+
DeviceFeature["LockPinRequired"] = "lock-pin-required";
|
|
6701
|
+
/** Lock supports a latch-release ("open door") action distinct from
|
|
6702
|
+
* unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
|
|
6703
|
+
* `supported_features`. Gates the Open Door button in the UI. */
|
|
6704
|
+
DeviceFeature["LockOpen"] = "lock-open";
|
|
6705
|
+
/** Media player exposes a seek-to-position surface. */
|
|
6706
|
+
DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
|
|
6707
|
+
/** Media player exposes a volume-level setter. */
|
|
6708
|
+
DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
|
|
6709
|
+
/** Media player exposes a mute toggle distinct from volume=0. */
|
|
6710
|
+
DeviceFeature["MediaPlayerMute"] = "media-player-mute";
|
|
6711
|
+
/** Media player exposes a shuffle toggle. */
|
|
6712
|
+
DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
|
|
6713
|
+
/** Media player exposes a repeat mode (off / all / one). */
|
|
6714
|
+
DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
|
|
6715
|
+
/** Media player exposes a source / input selector. */
|
|
6716
|
+
DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
|
|
6717
|
+
/** Media player exposes a play-arbitrary-media surface (URL / id). */
|
|
6718
|
+
DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
|
|
6719
|
+
/** Media player exposes next-track. */
|
|
6720
|
+
DeviceFeature["MediaPlayerNext"] = "media-player-next";
|
|
6721
|
+
/** Media player exposes previous-track. */
|
|
6722
|
+
DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
|
|
6723
|
+
/** Media player exposes stop distinct from pause. */
|
|
6724
|
+
DeviceFeature["MediaPlayerStop"] = "media-player-stop";
|
|
6725
|
+
/** Alarm panel requires a PIN code on arm/disarm. */
|
|
6726
|
+
DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
|
|
6727
|
+
/** Presence device carries GPS coordinates (lat/lng/accuracy) in
|
|
6728
|
+
* addition to a textual location. */
|
|
6729
|
+
DeviceFeature["PresenceGps"] = "presence-gps";
|
|
6730
|
+
/** Notifier accepts an inline / URL image attachment. */
|
|
6731
|
+
DeviceFeature["NotifierImage"] = "notifier-image";
|
|
6732
|
+
/** Notifier accepts a priority hint (high/normal/low). */
|
|
6733
|
+
DeviceFeature["NotifierPriority"] = "notifier-priority";
|
|
6734
|
+
/** Notifier accepts a free-form `data` payload for platform-specific
|
|
6735
|
+
* fields. */
|
|
6736
|
+
DeviceFeature["NotifierData"] = "notifier-data";
|
|
6737
|
+
/** Notifier supports interactive action buttons / callbacks. */
|
|
6738
|
+
DeviceFeature["NotifierActions"] = "notifier-actions";
|
|
6739
|
+
/** Notifier supports per-call recipient targeting (multi-user). */
|
|
6740
|
+
DeviceFeature["NotifierRecipients"] = "notifier-recipients";
|
|
6741
|
+
/** Script runner accepts a variables map on each run invocation. */
|
|
6742
|
+
DeviceFeature["ScriptVariables"] = "script-variables";
|
|
6743
|
+
/** Automation `trigger` accepts a skipCondition flag — fires the
|
|
6744
|
+
* automation's actions while bypassing its condition block. */
|
|
6745
|
+
DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
|
|
6746
|
+
return DeviceFeature;
|
|
6747
|
+
}({});
|
|
6748
|
+
/**
|
|
6749
|
+
* Semantic role a device plays within its parent. Populated by driver
|
|
6750
|
+
* addons when creating accessory devices (Reolink siren/floodlight/
|
|
6751
|
+
* PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
|
|
6752
|
+
* admin UI to pick icons, labels, and widgets — a `Switch` with
|
|
6753
|
+
* `role: Floodlight` renders as a bulb with a brightness slider,
|
|
6754
|
+
* whereas a `Switch` with `role: Siren` renders as a klaxon.
|
|
6755
|
+
*
|
|
6756
|
+
* Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
|
|
6757
|
+
* sqlite as a nullable TEXT column — old rows keep working unchanged.
|
|
6758
|
+
*/
|
|
6759
|
+
var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
6760
|
+
DeviceRole["Siren"] = "siren";
|
|
6761
|
+
DeviceRole["Floodlight"] = "floodlight";
|
|
6762
|
+
DeviceRole["Spotlight"] = "spotlight";
|
|
6763
|
+
DeviceRole["PirSensor"] = "pir-sensor";
|
|
6764
|
+
DeviceRole["Chime"] = "chime";
|
|
6765
|
+
DeviceRole["Autotrack"] = "autotrack";
|
|
6766
|
+
DeviceRole["Nightvision"] = "nightvision";
|
|
6767
|
+
DeviceRole["PrivacyMask"] = "privacy-mask";
|
|
6768
|
+
DeviceRole["Doorbell"] = "doorbell";
|
|
6769
|
+
/** Virtual HA toggle (input_boolean.*) — distinguishable from a
|
|
6770
|
+
* real Switch device for UI rendering / export adapters. */
|
|
6771
|
+
DeviceRole["BinaryHelper"] = "binary-helper";
|
|
6772
|
+
/** Generic motion / occupancy / moving event source. Distinct from
|
|
6773
|
+
* the camera accessory PirSensor role: that one is a camera child;
|
|
6774
|
+
* this is a standalone HA / 3rd-party motion sensor. */
|
|
6775
|
+
DeviceRole["MotionSensor"] = "motion-sensor";
|
|
6776
|
+
DeviceRole["ContactSensor"] = "contact-sensor";
|
|
6777
|
+
DeviceRole["LeakSensor"] = "leak-sensor";
|
|
6778
|
+
DeviceRole["SmokeSensor"] = "smoke-sensor";
|
|
6779
|
+
DeviceRole["COSensor"] = "co-sensor";
|
|
6780
|
+
DeviceRole["GasSensor"] = "gas-sensor";
|
|
6781
|
+
DeviceRole["TamperSensor"] = "tamper-sensor";
|
|
6782
|
+
DeviceRole["VibrationSensor"] = "vibration-sensor";
|
|
6783
|
+
DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
|
|
6784
|
+
DeviceRole["SoundSensor"] = "sound-sensor";
|
|
6785
|
+
/** Fallback for `binary_sensor` without a known `device_class`. */
|
|
6786
|
+
DeviceRole["BinarySensor"] = "binary-sensor";
|
|
6787
|
+
DeviceRole["TemperatureSensor"] = "temperature-sensor";
|
|
6788
|
+
DeviceRole["HumiditySensor"] = "humidity-sensor";
|
|
6789
|
+
DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
|
|
6790
|
+
DeviceRole["PressureSensor"] = "pressure-sensor";
|
|
6791
|
+
DeviceRole["PowerSensor"] = "power-sensor";
|
|
6792
|
+
DeviceRole["EnergySensor"] = "energy-sensor";
|
|
6793
|
+
DeviceRole["VoltageSensor"] = "voltage-sensor";
|
|
6794
|
+
DeviceRole["CurrentSensor"] = "current-sensor";
|
|
6795
|
+
DeviceRole["AirQualitySensor"] = "air-quality-sensor";
|
|
6796
|
+
/** Battery level (numeric % via `sensor` OR low-bool via
|
|
6797
|
+
* `binary_sensor` — the cap distinguishes via the value type). */
|
|
6798
|
+
DeviceRole["BatterySensor"] = "battery-sensor";
|
|
6799
|
+
/** Fallback for `sensor` numeric without a known `device_class`. */
|
|
6800
|
+
DeviceRole["NumericSensor"] = "numeric-sensor";
|
|
6801
|
+
/** String / enum state (HA `sensor` with `state_class: enum` or
|
|
6802
|
+
* `attributes.options`). */
|
|
6803
|
+
DeviceRole["EnumSensor"] = "enum-sensor";
|
|
6804
|
+
/** Date / timestamp state (HA `sensor` with `device_class: timestamp`
|
|
6805
|
+
* or `date`). The slice carries the raw ISO string verbatim (hosted on
|
|
6806
|
+
* the `enum-sensor` cap); the UI renders it locale-formatted. */
|
|
6807
|
+
DeviceRole["DateTimeSensor"] = "datetime-sensor";
|
|
6808
|
+
/** Last-resort fallback when nothing else matches. */
|
|
6809
|
+
DeviceRole["GenericSensor"] = "generic-sensor";
|
|
6810
|
+
DeviceRole["NumericControl"] = "numeric-control";
|
|
6811
|
+
DeviceRole["SelectControl"] = "select-control";
|
|
6812
|
+
DeviceRole["TextControl"] = "text-control";
|
|
6813
|
+
DeviceRole["DateTimeControl"] = "datetime-control";
|
|
6814
|
+
/** Mobile push notifier (HA `notify.mobile_app_*`) — supports
|
|
6815
|
+
* rich features (image, priority, channel routing). */
|
|
6816
|
+
DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
|
|
6817
|
+
/** Chat / messaging service (HA `notify.telegram_*`,
|
|
6818
|
+
* `notify.discord_*`, etc.). */
|
|
6819
|
+
DeviceRole["MessagingNotifier"] = "messaging-notifier";
|
|
6820
|
+
/** Email-based delivery (HA `notify.smtp`, etc.). */
|
|
6821
|
+
DeviceRole["EmailNotifier"] = "email-notifier";
|
|
6822
|
+
/** Fallback when the notifier service name doesn't match a known
|
|
6823
|
+
* pattern. */
|
|
6824
|
+
DeviceRole["GenericNotifier"] = "generic-notifier";
|
|
6825
|
+
return DeviceRole;
|
|
6826
|
+
}({});
|
|
6827
|
+
/**
|
|
6828
|
+
* Generic types for capability definitions.
|
|
6829
|
+
*
|
|
6830
|
+
* A capability is defined with Zod schemas for methods, events, and settings.
|
|
6831
|
+
* TypeScript types are inferred via z.infer<> — zero duplication.
|
|
6832
|
+
*
|
|
6833
|
+
* Pattern:
|
|
6834
|
+
* 1. Define Zod schemas for data, methods, settings
|
|
6835
|
+
* 2. Export const capabilityDef = { ... } satisfies CapabilityDefinition
|
|
6836
|
+
* 3. Export type IProvider = InferProvider<typeof capabilityDef>
|
|
6837
|
+
* 4. Addon implements IProvider
|
|
6838
|
+
* 5. Registry auto-mounts tRPC router from definition.methods
|
|
6839
|
+
*/
|
|
6840
|
+
/**
|
|
6841
|
+
* Output schema shared by the contribution + live methods.
|
|
6842
|
+
*
|
|
6843
|
+
* Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
|
|
6844
|
+
* tabs[]) without importing from `../interfaces/config-ui.js` — a
|
|
6845
|
+
* concrete-but-lenient Zod object keeps tRPC output inference happy
|
|
6846
|
+
* (using `z.unknown()` here collapses unrelated router branches to
|
|
6847
|
+
* `unknown` when the generator re-inlines the huge AppRouter type).
|
|
6848
|
+
*
|
|
6849
|
+
* `.passthrough()` on sections/fields accepts whatever FormBuilder
|
|
6850
|
+
* extensions the caller adds (showWhen, displayScale, …) without
|
|
6851
|
+
* rebuilding every time a new field kind is introduced.
|
|
6852
|
+
*/
|
|
6853
|
+
var ContributionSectionSchema = object({
|
|
6854
|
+
id: string(),
|
|
6855
|
+
title: string(),
|
|
6856
|
+
description: string().optional(),
|
|
6857
|
+
style: _enum(["card", "accordion"]).optional(),
|
|
6858
|
+
defaultCollapsed: boolean().optional(),
|
|
6859
|
+
columns: union([
|
|
6860
|
+
literal(1),
|
|
6861
|
+
literal(2),
|
|
6862
|
+
literal(3),
|
|
6863
|
+
literal(4)
|
|
6864
|
+
]).optional(),
|
|
6865
|
+
tab: string().optional(),
|
|
6866
|
+
location: _enum(["settings", "top-tab"]).optional(),
|
|
6867
|
+
order: number().optional(),
|
|
6868
|
+
fields: array(any())
|
|
6869
|
+
});
|
|
6870
|
+
object({
|
|
6871
|
+
tabs: array(object({
|
|
6872
|
+
id: string(),
|
|
6873
|
+
label: string(),
|
|
6874
|
+
icon: string(),
|
|
6875
|
+
order: number().optional()
|
|
6876
|
+
})).optional(),
|
|
6877
|
+
sections: array(ContributionSectionSchema)
|
|
6878
|
+
}).nullable();
|
|
6879
|
+
object({ deviceId: number() }), object({ deviceId: number() }), object({
|
|
6880
|
+
deviceId: number(),
|
|
6881
|
+
patch: record(string(), unknown())
|
|
6882
|
+
}), object({ success: literal(true) });
|
|
6883
|
+
object({ deviceId: number() }), unknown().nullable();
|
|
6884
|
+
/** Shorthand to define a method schema */
|
|
6885
|
+
function method(input, output, options) {
|
|
6886
|
+
return {
|
|
6887
|
+
input,
|
|
6888
|
+
output,
|
|
6889
|
+
kind: options?.kind ?? "query",
|
|
6890
|
+
auth: options?.auth ?? "protected",
|
|
6891
|
+
...options?.access !== void 0 ? { access: options.access } : {},
|
|
6892
|
+
timeoutMs: options?.timeoutMs
|
|
6893
|
+
};
|
|
6951
6894
|
}
|
|
6952
|
-
var
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
"
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
"
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
for
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
/**
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
/**
|
|
7232
|
-
*
|
|
7233
|
-
*
|
|
7234
|
-
*
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
/** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
|
|
7281
|
-
* `weather` cap. */
|
|
7282
|
-
DeviceType["Weather"] = "weather";
|
|
7283
|
-
/** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
|
|
7284
|
-
DeviceType["Vacuum"] = "vacuum";
|
|
7285
|
-
/** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
|
|
7286
|
-
* `lawn-mower-control` cap. */
|
|
7287
|
-
DeviceType["LawnMower"] = "lawn-mower";
|
|
7288
|
-
/** Physical HA device group — parent container for entity-children
|
|
7289
|
-
* adopted from a single HA device entry. Not renderable as a
|
|
7290
|
-
* standalone device; exists only to anchor child entities. */
|
|
7291
|
-
DeviceType["Container"] = "container";
|
|
7292
|
-
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
7293
|
-
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
7294
|
-
DeviceType["Image"] = "image";
|
|
7295
|
-
return DeviceType;
|
|
7296
|
-
}({});
|
|
7297
|
-
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
7298
|
-
DeviceFeature["BatteryOperated"] = "battery-operated";
|
|
7299
|
-
DeviceFeature["Rebootable"] = "rebootable";
|
|
6895
|
+
var StaticDirOutputSchema = object({ staticDir: string() });
|
|
6896
|
+
var VersionOutputSchema = object({ version: string() });
|
|
6897
|
+
method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
|
|
6898
|
+
/**
|
|
6899
|
+
* device-ops — device-scoped cap that unifies the per-IDevice operations
|
|
6900
|
+
* previously routed through the `.device-ops` Moleculer bridge service.
|
|
6901
|
+
*
|
|
6902
|
+
* Each worker that hosts live `IDevice` instances auto-registers a native
|
|
6903
|
+
* provider for this cap (per device) backed by its local
|
|
6904
|
+
* `DeviceRegistry`. Hub-side callers reach it transparently through
|
|
6905
|
+
* `ctx.fetchDevice(id).deviceOps.*` — the DeviceProxy injects
|
|
6906
|
+
* `deviceId` + `nodeId` and dispatches through the standard cap-router,
|
|
6907
|
+
* so there's no parallel bridge path anymore.
|
|
6908
|
+
*
|
|
6909
|
+
* The surface is intentionally small — every method corresponds to a
|
|
6910
|
+
* single action on the live `IDevice` (or `ICameraDevice` for
|
|
6911
|
+
* `getStreamSources`). Richer orchestration (enable/disable with
|
|
6912
|
+
* integration plumbing, bulk updates) stays in the `device-manager` cap;
|
|
6913
|
+
* `device-ops` is the per-device primitive the device-manager routes to.
|
|
6914
|
+
*/
|
|
6915
|
+
var StreamSourceEntrySchema = object({
|
|
6916
|
+
id: string(),
|
|
6917
|
+
label: string(),
|
|
6918
|
+
protocol: _enum([
|
|
6919
|
+
"rtsp",
|
|
6920
|
+
"rtmp",
|
|
6921
|
+
"annexb",
|
|
6922
|
+
"http-mjpeg",
|
|
6923
|
+
"webrtc",
|
|
6924
|
+
"custom"
|
|
6925
|
+
]),
|
|
6926
|
+
url: string().optional(),
|
|
6927
|
+
resolution: object({
|
|
6928
|
+
width: number(),
|
|
6929
|
+
height: number()
|
|
6930
|
+
}).optional(),
|
|
6931
|
+
fps: number().optional(),
|
|
6932
|
+
bitrate: number().optional(),
|
|
6933
|
+
codec: string().optional(),
|
|
6934
|
+
profileHint: CamProfileSchema.optional(),
|
|
6935
|
+
sdp: string().optional()
|
|
6936
|
+
});
|
|
6937
|
+
var ConfigEntrySchema$1 = object({
|
|
6938
|
+
key: string(),
|
|
6939
|
+
value: unknown()
|
|
6940
|
+
});
|
|
6941
|
+
var RawStateResultSchema = object({
|
|
6942
|
+
/** Originating provider id, e.g. 'homeassistant' | 'reolink' | 'hikvision'. */
|
|
6943
|
+
source: string(),
|
|
6944
|
+
/** Opaque, DISPLAY-SAFE upstream blob (no secrets/PII). */
|
|
6945
|
+
data: record(string(), unknown())
|
|
6946
|
+
});
|
|
6947
|
+
method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
|
|
6948
|
+
deviceId: number(),
|
|
6949
|
+
values: record(string(), unknown())
|
|
6950
|
+
}), _void(), { kind: "mutation" }), method(object({
|
|
6951
|
+
deviceId: number(),
|
|
6952
|
+
action: string().min(1),
|
|
6953
|
+
input: unknown()
|
|
6954
|
+
}), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
6955
|
+
/**
|
|
6956
|
+
* Promise-based timer helpers — used everywhere the codebase needs to
|
|
6957
|
+
* wait, back off, or schedule a retry. Before these helpers landed, each
|
|
6958
|
+
* call site re-implemented `new Promise(r => setTimeout(r, ms))` inline,
|
|
6959
|
+
* with subtle variations (some swallowing cancellation, some not). Two
|
|
6960
|
+
* shapes cover every observed use case:
|
|
6961
|
+
*
|
|
6962
|
+
* - {@link sleep} for a plain, uncancellable wait — the default choice.
|
|
6963
|
+
* - {@link sleepCancellable} for a wait that wakes early when an
|
|
6964
|
+
* abort signal trips, used by long-running pollers whose teardown
|
|
6965
|
+
* must stop a pending backoff promptly.
|
|
6966
|
+
*/
|
|
6967
|
+
/**
|
|
6968
|
+
* Resolve after `ms` milliseconds. Never rejects, never cancels. The
|
|
6969
|
+
* sleep cannot be interrupted; for a wakeable variant use
|
|
6970
|
+
* {@link sleepCancellable}.
|
|
6971
|
+
*
|
|
6972
|
+
* `ms <= 0` resolves on the next microtask via `setTimeout(0)`, which
|
|
6973
|
+
* still gives the event loop a chance to drain — useful for breaking
|
|
6974
|
+
* up tight async loops without changing call-site semantics.
|
|
6975
|
+
*/
|
|
6976
|
+
function sleep$1(ms) {
|
|
6977
|
+
return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
6978
|
+
}
|
|
6979
|
+
//#endregion
|
|
6980
|
+
//#region ../types/dist/err-msg-IQTHeDzc.mjs
|
|
6981
|
+
/**
|
|
6982
|
+
import { errMsg } from '@camstack/types'
|
|
6983
|
+
* Extract a human-readable message from an unknown error value.
|
|
6984
|
+
* Replaces the ubiquitous `errMsg(err)` pattern.
|
|
6985
|
+
*/
|
|
6986
|
+
function errMsg(err) {
|
|
6987
|
+
if (err instanceof Error) return err.message;
|
|
6988
|
+
if (typeof err === "string") return err;
|
|
6989
|
+
return String(err);
|
|
6990
|
+
}
|
|
6991
|
+
//#endregion
|
|
6992
|
+
//#region ../types/dist/index.mjs
|
|
6993
|
+
/**
|
|
6994
|
+
* Deep wiring healthcheck — snapshot of active reachability probes across
|
|
6995
|
+
* every declared capability + widget of every installed plugin, on every
|
|
6996
|
+
* node. Produced by the backend `WiringHealthService` and surfaced via
|
|
6997
|
+
* `GET /health/wiring`, the tRPC `health.wiring` query, and the boot-gate.
|
|
6998
|
+
*
|
|
6999
|
+
* Unlike `/health` (process liveness), this reflects whether each cap/widget
|
|
7000
|
+
* is actually *reachable* over the real cap-dispatch path. See spec
|
|
7001
|
+
* `docs/superpowers/specs/2026-05-23-deep-healthcheck-design.md`.
|
|
7002
|
+
*/
|
|
7003
|
+
/** What kind of target a probe addressed. */
|
|
7004
|
+
var wiringProbeKindSchema = _enum([
|
|
7005
|
+
"singleton",
|
|
7006
|
+
"device",
|
|
7007
|
+
"widget"
|
|
7008
|
+
]);
|
|
7009
|
+
/** Result of probing a single (cap|widget [, device]) target. */
|
|
7010
|
+
var wiringProbeResultSchema = object({
|
|
7011
|
+
capName: string(),
|
|
7012
|
+
kind: wiringProbeKindSchema,
|
|
7013
|
+
deviceId: number().optional(),
|
|
7014
|
+
reachable: boolean(),
|
|
7015
|
+
latencyMs: number(),
|
|
7016
|
+
error: string().optional()
|
|
7017
|
+
});
|
|
7018
|
+
/** Per-addon roll-up of cap + widget probe results. */
|
|
7019
|
+
var wiringAddonHealthSchema = object({
|
|
7020
|
+
addonId: string(),
|
|
7021
|
+
caps: array(wiringProbeResultSchema).readonly(),
|
|
7022
|
+
widgets: array(wiringProbeResultSchema).readonly()
|
|
7023
|
+
});
|
|
7024
|
+
/** Per-node roll-up. */
|
|
7025
|
+
var wiringNodeHealthSchema = object({
|
|
7026
|
+
nodeId: string(),
|
|
7027
|
+
addons: array(wiringAddonHealthSchema).readonly()
|
|
7028
|
+
});
|
|
7029
|
+
object({
|
|
7030
|
+
/** True only when every probed target is reachable. */
|
|
7031
|
+
ok: boolean(),
|
|
7032
|
+
/** True when at least one target is unreachable. */
|
|
7033
|
+
degraded: boolean(),
|
|
7034
|
+
checkedAt: string(),
|
|
7035
|
+
nodes: array(wiringNodeHealthSchema).readonly(),
|
|
7036
|
+
summary: object({
|
|
7037
|
+
total: number(),
|
|
7038
|
+
reachable: number(),
|
|
7039
|
+
unreachable: number()
|
|
7040
|
+
})
|
|
7041
|
+
});
|
|
7042
|
+
var MODEL_FORMATS = [
|
|
7043
|
+
"onnx",
|
|
7044
|
+
"coreml",
|
|
7045
|
+
"openvino",
|
|
7046
|
+
"tflite",
|
|
7047
|
+
"pt"
|
|
7048
|
+
];
|
|
7049
|
+
/**
|
|
7050
|
+
* Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
|
|
7051
|
+
* Named `RecordingWeekday` to avoid collision with the string-union
|
|
7052
|
+
* `Weekday` exported from `interfaces/timezones.ts`.
|
|
7053
|
+
*/
|
|
7054
|
+
var RecordingWeekdaySchema = number().int().min(0).max(6);
|
|
7055
|
+
var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
|
|
7056
|
+
var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
|
|
7057
|
+
kind: literal("timeOfDay"),
|
|
7058
|
+
start: string().regex(HHMM),
|
|
7059
|
+
end: string().regex(HHMM),
|
|
7060
|
+
/** Restrict to these weekdays; omit = every day. */
|
|
7061
|
+
days: array(RecordingWeekdaySchema).optional()
|
|
7062
|
+
})]);
|
|
7063
|
+
var RecordingModeSchema = _enum([
|
|
7064
|
+
"continuous",
|
|
7065
|
+
"onMotion",
|
|
7066
|
+
"onAudioThreshold"
|
|
7067
|
+
]);
|
|
7068
|
+
/**
|
|
7069
|
+
* First-class, authoritative per-camera storage mode — the netta choice the UI
|
|
7070
|
+
* reads directly (never inferred from `rules`):
|
|
7071
|
+
* - `off` — not recording.
|
|
7072
|
+
* - `events` — record only around triggers (motion / audio threshold),
|
|
7073
|
+
* with pre/post-buffer.
|
|
7074
|
+
* - `continuous` — record 24/7 within the schedule.
|
|
7075
|
+
*
|
|
7076
|
+
* `mode` compiles one-way to the internal `rules[]` consumed by the policy
|
|
7077
|
+
* engine (see `compileRules`); `rules[]` is never authored directly anymore.
|
|
7078
|
+
*/
|
|
7079
|
+
var RecordingStorageModeSchema = _enum([
|
|
7080
|
+
"off",
|
|
7081
|
+
"events",
|
|
7082
|
+
"continuous"
|
|
7083
|
+
]);
|
|
7084
|
+
/** Which detectors trigger an `events`-mode recording. */
|
|
7085
|
+
var RecordingTriggersSchema = object({
|
|
7086
|
+
motion: boolean().optional(),
|
|
7087
|
+
audioThresholdDbfs: number().optional()
|
|
7088
|
+
});
|
|
7089
|
+
/**
|
|
7090
|
+
* Mode of a single recording band — the recorder per-band vocabulary.
|
|
7091
|
+
*
|
|
7092
|
+
* Distinct from `RecordingStorageModeSchema` (which carries `off`): a band is
|
|
7093
|
+
* only ever `continuous` or `events`; "off" is expressed by the absence of a
|
|
7094
|
+
* covering band, not by a band value.
|
|
7095
|
+
*/
|
|
7096
|
+
var RecordingBandModeSchema = _enum(["continuous", "events"]);
|
|
7097
|
+
/**
|
|
7098
|
+
* Triggers for an `events`-mode band. Identical shape to
|
|
7099
|
+
* `RecordingTriggersSchema` — reuse that schema as the band trigger type so the
|
|
7100
|
+
* two never drift.
|
|
7101
|
+
*/
|
|
7102
|
+
var RecordingBandTriggersSchema = RecordingTriggersSchema;
|
|
7103
|
+
/**
|
|
7104
|
+
* A single mode-per-band window — the canonical recorder band shape, the
|
|
7105
|
+
* single source of truth re-used by `addon-pipeline/recorder`.
|
|
7106
|
+
*
|
|
7107
|
+
* `days` lists the weekdays the band covers (empty = every day, matching the
|
|
7108
|
+
* band engine's `applies` rule). `start`/`end` are `HH:MM`; an `end <= start`
|
|
7109
|
+
* span wraps past midnight (handled by the band engine).
|
|
7110
|
+
*/
|
|
7111
|
+
var RecordingBandSchema = object({
|
|
7112
|
+
days: array(RecordingWeekdaySchema),
|
|
7113
|
+
start: string().regex(HHMM),
|
|
7114
|
+
end: string().regex(HHMM),
|
|
7115
|
+
mode: RecordingBandModeSchema,
|
|
7116
|
+
triggers: RecordingBandTriggersSchema.optional(),
|
|
7117
|
+
preBufferSec: number().min(0).optional(),
|
|
7118
|
+
postBufferSec: number().min(0).optional()
|
|
7119
|
+
});
|
|
7120
|
+
var RecordingRuleSchema = object({
|
|
7121
|
+
schedule: RecordingScheduleSchema,
|
|
7122
|
+
mode: RecordingModeSchema,
|
|
7123
|
+
/** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
|
|
7124
|
+
preBufferSec: number().min(0).default(0),
|
|
7125
|
+
/** Keep recording until this many seconds after the last trigger. */
|
|
7126
|
+
postBufferSec: number().min(0).default(0),
|
|
7127
|
+
/** Each new trigger restarts the post-buffer window. */
|
|
7128
|
+
resetTimeoutOnNewEvent: boolean().default(true),
|
|
7129
|
+
/** onAudioThreshold only — dBFS level that counts as a trigger. */
|
|
7130
|
+
thresholdDbfs: number().optional()
|
|
7131
|
+
});
|
|
7132
|
+
/**
|
|
7133
|
+
* Per-device retention overrides. Every field is optional; an unset or `0`
|
|
7134
|
+
* value inherits the node-wide recorder default. Only footage-lifetime limits
|
|
7135
|
+
* live per-camera: `maxAgeDays` and `maxSizeGb`. The disk-occupancy threshold
|
|
7136
|
+
* (when the volume is too full to keep recording) is NOT a per-camera concern —
|
|
7137
|
+
* it belongs to the StorageLocation (`StorageLocation.config.minFreePercent`),
|
|
7138
|
+
* shared by every camera writing to that volume.
|
|
7139
|
+
*/
|
|
7140
|
+
var RecordingRetentionSchema = object({
|
|
7141
|
+
maxAgeDays: number().min(0).optional(),
|
|
7142
|
+
maxSizeGb: number().min(0).optional()
|
|
7143
|
+
});
|
|
7144
|
+
/**
|
|
7145
|
+
* The full per-camera recording intent — the wire shape of a RecordingTarget.
|
|
7146
|
+
*
|
|
7147
|
+
* `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
|
|
7148
|
+
* are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
|
|
7149
|
+
* only for transition + migration (`migrateRulesToMode`); the policy engine
|
|
7150
|
+
* consumes the compiled output of `compileRules(config)`, never `rules` directly.
|
|
7151
|
+
*/
|
|
7152
|
+
var RecordingConfigSchema = object({
|
|
7153
|
+
enabled: boolean(),
|
|
7154
|
+
/** Authoritative storage mode. Absent on legacy targets → derived once via
|
|
7155
|
+
* `migrateRulesToMode`, then persisted. */
|
|
7156
|
+
mode: RecordingStorageModeSchema.optional(),
|
|
7157
|
+
profiles: array(CamProfileSchema).optional(),
|
|
7158
|
+
segmentSeconds: number().int().positive().optional(),
|
|
7159
|
+
/** Shared recording time-bands for `events` & `continuous` — record only when
|
|
7160
|
+
* the wall-clock falls inside one of these windows. Omit or empty = always.
|
|
7161
|
+
* `continuous` compiles to one rule per band; `events` to band × trigger. */
|
|
7162
|
+
schedules: array(RecordingScheduleSchema).optional(),
|
|
7163
|
+
/** Legacy single-band predecessor of `schedules`. Read-compat only — it is
|
|
7164
|
+
* normalized into `schedules` on read and never written going forward. (Not
|
|
7165
|
+
* tagged `@deprecated`: the normalization paths must read it cast-free.) */
|
|
7166
|
+
schedule: RecordingScheduleSchema.optional(),
|
|
7167
|
+
/** `events`-mode only — which detectors trigger a recording. */
|
|
7168
|
+
triggers: RecordingTriggersSchema.optional(),
|
|
7169
|
+
/** `events`-mode only — seconds retained before / after a trigger. */
|
|
7170
|
+
preBufferSec: number().min(0).optional(),
|
|
7171
|
+
postBufferSec: number().min(0).optional(),
|
|
7172
|
+
/** DEPRECATED authoring input; retained for migration/transition. */
|
|
7173
|
+
rules: array(RecordingRuleSchema).optional(),
|
|
7174
|
+
/**
|
|
7175
|
+
* AUTHORITATIVE mode-per-band recording model (recorder). When present it
|
|
7176
|
+
* is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
|
|
7177
|
+
* `triggers`/`rules` fields above are kept for READ-COMPAT only and are
|
|
7178
|
+
* derived into bands once via `migrateConfigToBands`.
|
|
7179
|
+
*/
|
|
7180
|
+
bands: array(RecordingBandSchema).optional(),
|
|
7181
|
+
retention: RecordingRetentionSchema.optional()
|
|
7182
|
+
});
|
|
7183
|
+
/**
|
|
7184
|
+
* `StorageLocationType` — an addon-declared id that identifies the *kind* of
|
|
7185
|
+
* storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
|
|
7186
|
+
* so the persisted record schema and the consumer-facing cap can both consume it
|
|
7187
|
+
* without forming a circular import. The `storage` cap re-exports it
|
|
7188
|
+
* verbatim for back-compat.
|
|
7189
|
+
*
|
|
7190
|
+
* This Zod schema is the **authoritative source** for `StorageLocationType`.
|
|
7191
|
+
* The TS alias in `./storage.ts` re-exports `z.infer<typeof
|
|
7192
|
+
* StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
|
|
7193
|
+
* `IStorageProvider` interface stay in lockstep.
|
|
7194
|
+
*
|
|
7195
|
+
* The type is now an **open string** (not a closed enum) — addons declare
|
|
7196
|
+
* their own location kinds via `StorageLocationDeclaration.id`. The regex
|
|
7197
|
+
* enforces a safe id format: lowercase-start, alphanumeric + hyphens.
|
|
7198
|
+
*/
|
|
7199
|
+
var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
|
|
7200
|
+
/**
|
|
7201
|
+
* Persisted record for a storage location instance. Operators can register
|
|
7202
|
+
* multiple instances for multi-cardinality types (e.g. two `backups`
|
|
7203
|
+
* locations with different `providerId`s). Cardinality is now declared per
|
|
7204
|
+
* location via `StorageLocationDeclaration.cardinality` — the static
|
|
7205
|
+
* `STORAGE_LOCATION_CARDINALITY` map has been removed.
|
|
7206
|
+
*
|
|
7207
|
+
* `id` is a stable namespaced string of the form `<type>:<slug>`.
|
|
7208
|
+
* The default location for a type uses `id === <type>:default` by
|
|
7209
|
+
* convention (the bare type ref like `'backups'` resolves to it).
|
|
7210
|
+
*
|
|
7211
|
+
* `isSystem: true` marks a location as orchestrator-seeded and
|
|
7212
|
+
* undeletable. The bootstrap-installed defaults (one per type) carry
|
|
7213
|
+
* this flag; operator-added locations don't. Editing the config of
|
|
7214
|
+
* a system location is allowed (path migration, provider swap) but
|
|
7215
|
+
* deleting it is rejected at the cap level.
|
|
7216
|
+
*/
|
|
7217
|
+
var StorageLocationSchema = object({
|
|
7218
|
+
id: string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
|
|
7219
|
+
type: string(),
|
|
7220
|
+
displayName: string().min(1),
|
|
7221
|
+
providerId: string().min(1),
|
|
7222
|
+
config: record(string(), unknown()),
|
|
7300
7223
|
/**
|
|
7301
|
-
*
|
|
7302
|
-
*
|
|
7303
|
-
*
|
|
7224
|
+
* Cluster node this location physically lives on. REQUIRED for node-local
|
|
7225
|
+
* providers (filesystem — the path exists on one node's disk), null/absent
|
|
7226
|
+
* for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
|
|
7227
|
+
* `'hub'` is the hub node. Validated against the provider's `nodeLocal`
|
|
7228
|
+
* flag at upsert time, not here (the schema is provider-agnostic).
|
|
7304
7229
|
*/
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7230
|
+
nodeId: string().optional(),
|
|
7231
|
+
isDefault: boolean().default(false),
|
|
7232
|
+
isSystem: boolean().default(false),
|
|
7233
|
+
createdAt: number(),
|
|
7234
|
+
updatedAt: number()
|
|
7235
|
+
});
|
|
7236
|
+
/**
|
|
7237
|
+
* Reference accepted by consumer-facing `api.storage.*` calls.
|
|
7238
|
+
* Either:
|
|
7239
|
+
* - a `StorageLocationType` (e.g. `'backups'`) → orchestrator resolves to the default of that type
|
|
7240
|
+
* - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
|
|
7241
|
+
*
|
|
7242
|
+
* The orchestrator's `resolveRef(ref)` handles both cases.
|
|
7243
|
+
*/
|
|
7244
|
+
var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
|
|
7245
|
+
/**
|
|
7246
|
+
* `StorageLocationDeclaration` — a single storage-location entry declared by
|
|
7247
|
+
* an addon in its `package.json` under `camstack.storageLocations`.
|
|
7248
|
+
*
|
|
7249
|
+
* Design intent:
|
|
7250
|
+
* - **Addon declares its needs** — each addon describes the logical storage
|
|
7251
|
+
* slots it requires (e.g. `recordings`, `recordingsLow`) without caring
|
|
7252
|
+
* about the physical path.
|
|
7253
|
+
* - **Kernel aggregates** — at boot the kernel collects declarations from all
|
|
7254
|
+
* installed addons, deduplicates by `id`, and exposes the union via the
|
|
7255
|
+
* storage-locations settings surface.
|
|
7256
|
+
* - **Orchestrator seeds** — for every declared `id` the orchestrator ensures
|
|
7257
|
+
* at least one instance named `<id>:default` is present, using
|
|
7258
|
+
* `defaultsTo` to inherit the resolved root from another location when the
|
|
7259
|
+
* declaration is a derivative slot (e.g. `recordingsLow` defaults to
|
|
7260
|
+
* `recordings`).
|
|
7261
|
+
* - **ids are global** — `id` values are shared across the entire deployment;
|
|
7262
|
+
* two addons declaring the same `id` must agree on `cardinality` (validated
|
|
7263
|
+
* at kernel aggregation time, not here).
|
|
7264
|
+
*/
|
|
7265
|
+
var StorageLocationDeclarationSchema = object({
|
|
7310
7266
|
/**
|
|
7311
|
-
*
|
|
7312
|
-
*
|
|
7313
|
-
*
|
|
7314
|
-
* the autotrack toggle / settings card without re-deriving from
|
|
7315
|
-
* the cap registry. Mirrors `ptz-autotrack` cap registration:
|
|
7316
|
-
* driver sets this feature when probe confirms the firmware
|
|
7317
|
-
* surface, and registers the cap in the same code path.
|
|
7267
|
+
* Global location identifier, e.g. `recordings` or `recordingsLow`.
|
|
7268
|
+
* Must start with a lowercase letter and may contain letters, digits, and
|
|
7269
|
+
* hyphens.
|
|
7318
7270
|
*/
|
|
7319
|
-
|
|
7271
|
+
id: string().regex(/^[a-z][a-zA-Z0-9-]*$/, { message: "id must start with a lowercase letter and contain only letters, digits, or hyphens" }),
|
|
7272
|
+
/** Human-readable name shown in the admin UI. */
|
|
7273
|
+
displayName: string().min(1, { message: "displayName must not be empty" }),
|
|
7274
|
+
/** Optional longer explanation of what data this location stores. */
|
|
7275
|
+
description: string().optional(),
|
|
7320
7276
|
/**
|
|
7321
|
-
*
|
|
7322
|
-
*
|
|
7323
|
-
* `
|
|
7324
|
-
*
|
|
7325
|
-
*
|
|
7326
|
-
* Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
|
|
7327
|
-
* fast scalar without binding fetch), notifier rules, and `listAll`
|
|
7328
|
-
* filters that want "all devices with on-motion behaviour".
|
|
7277
|
+
* `single` — exactly one instance of this location is allowed system-wide
|
|
7278
|
+
* (e.g. `logs`, `models`). The operator can edit it but not add more.
|
|
7279
|
+
* `multi` — the operator may register several instances (e.g. a second
|
|
7280
|
+
* `recordings` on a NAS for disk tiering); one is the default at any time.
|
|
7329
7281
|
*/
|
|
7330
|
-
|
|
7331
|
-
/**
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
*
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
*
|
|
7369
|
-
*
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
/**
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
*
|
|
7440
|
-
*
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7282
|
+
cardinality: _enum(["single", "multi"]),
|
|
7283
|
+
/**
|
|
7284
|
+
* When set, the default instance for this location inherits its resolved
|
|
7285
|
+
* root from the named location's default instance. Useful for derivative
|
|
7286
|
+
* slots (e.g. `recordingsLow` → `recordings`) so operators only need to
|
|
7287
|
+
* configure the primary location.
|
|
7288
|
+
*/
|
|
7289
|
+
defaultsTo: string().optional()
|
|
7290
|
+
});
|
|
7291
|
+
var DecoderStatsSchema = object({
|
|
7292
|
+
inputFps: number(),
|
|
7293
|
+
outputFps: number(),
|
|
7294
|
+
avgDecodeTimeMs: number(),
|
|
7295
|
+
droppedFrames: number()
|
|
7296
|
+
});
|
|
7297
|
+
var DecoderSessionConfigSchema = object({
|
|
7298
|
+
codec: string(),
|
|
7299
|
+
maxFps: number().default(0),
|
|
7300
|
+
outputFormat: _enum([
|
|
7301
|
+
"jpeg",
|
|
7302
|
+
"rgb",
|
|
7303
|
+
"bgr",
|
|
7304
|
+
"yuv420",
|
|
7305
|
+
"gray"
|
|
7306
|
+
]).default("jpeg"),
|
|
7307
|
+
scale: number().default(1),
|
|
7308
|
+
width: number().optional(),
|
|
7309
|
+
height: number().optional(),
|
|
7310
|
+
/**
|
|
7311
|
+
* Identifier of the camera this decoder session serves. Optional
|
|
7312
|
+
* because the cap is generic (any caller could request decode), but
|
|
7313
|
+
* stream-broker passes it so decoder logs include `deviceId` for
|
|
7314
|
+
* per-camera filtering when diagnosing failures (e.g. node-av
|
|
7315
|
+
* sendPacket errors on a single hung camera).
|
|
7316
|
+
*/
|
|
7317
|
+
deviceId: number().int().nonnegative().optional(),
|
|
7318
|
+
/**
|
|
7319
|
+
* Free-form tag for log scoping. Stream-broker uses
|
|
7320
|
+
* `broker:<deviceId>/<profile>`. Decoder session logger surfaces it
|
|
7321
|
+
* on every line so `grep tag=broker:5/high` filters one camera
|
|
7322
|
+
* profile cleanly.
|
|
7323
|
+
*/
|
|
7324
|
+
tag: string().optional(),
|
|
7325
|
+
/**
|
|
7326
|
+
* Where the session delivers decoded frames (Phase 5 / D9):
|
|
7327
|
+
*
|
|
7328
|
+
* - `'callback'` (default) — the legacy pixel path: decoded frames are
|
|
7329
|
+
* buffered as `DecodedFrame`s and drained via `pullFrames`.
|
|
7330
|
+
* - `'shm'` — the shared-memory frame plane: decoded frames are written
|
|
7331
|
+
* into an OS shared-memory ring and drained as zero-pixel
|
|
7332
|
+
* `FrameHandle`s via `pullHandles`. A session is one mode or the
|
|
7333
|
+
* other — `pullFrames` returns nothing for an `'shm'` session and
|
|
7334
|
+
* `pullHandles` returns nothing for a `'callback'` session.
|
|
7335
|
+
*/
|
|
7336
|
+
frameSink: _enum(["callback", "shm"]).default("callback")
|
|
7337
|
+
});
|
|
7338
|
+
var EncodeProfileSchema = object({
|
|
7339
|
+
video: object({
|
|
7340
|
+
codec: _enum([
|
|
7341
|
+
"h264",
|
|
7342
|
+
"h265",
|
|
7343
|
+
"copy"
|
|
7344
|
+
]),
|
|
7345
|
+
profile: _enum([
|
|
7346
|
+
"baseline",
|
|
7347
|
+
"main",
|
|
7348
|
+
"high"
|
|
7349
|
+
]).optional(),
|
|
7350
|
+
width: number().int().positive().optional(),
|
|
7351
|
+
height: number().int().positive().optional(),
|
|
7352
|
+
fps: number().positive().optional(),
|
|
7353
|
+
bitrateKbps: number().int().positive().optional(),
|
|
7354
|
+
gopFrames: number().int().positive().optional(),
|
|
7355
|
+
bf: number().int().min(0).optional(),
|
|
7356
|
+
preset: _enum([
|
|
7357
|
+
"ultrafast",
|
|
7358
|
+
"superfast",
|
|
7359
|
+
"veryfast",
|
|
7360
|
+
"faster",
|
|
7361
|
+
"fast",
|
|
7362
|
+
"medium"
|
|
7363
|
+
]).optional(),
|
|
7364
|
+
tune: _enum([
|
|
7365
|
+
"zerolatency",
|
|
7366
|
+
"film",
|
|
7367
|
+
"animation"
|
|
7368
|
+
]).optional()
|
|
7369
|
+
}),
|
|
7370
|
+
audio: union([literal("passthrough"), object({
|
|
7371
|
+
codec: _enum([
|
|
7372
|
+
"opus",
|
|
7373
|
+
"aac",
|
|
7374
|
+
"pcmu",
|
|
7375
|
+
"pcma",
|
|
7376
|
+
"copy"
|
|
7377
|
+
]),
|
|
7378
|
+
bitrateKbps: number().int().positive().optional(),
|
|
7379
|
+
sampleRateHz: number().int().positive().optional(),
|
|
7380
|
+
channels: union([literal(1), literal(2)]).optional()
|
|
7381
|
+
})]),
|
|
7382
|
+
/**
|
|
7383
|
+
* ffmpeg input-side args, inserted between the fixed global flags
|
|
7384
|
+
* (`-hide_banner -loglevel error`) and `-i pipe:0`. Free-text array
|
|
7385
|
+
* — the widget surfaces a textarea + suggestion chips for the most-
|
|
7386
|
+
* used demuxer/format options.
|
|
7387
|
+
*/
|
|
7388
|
+
inputArgs: array(string()).optional(),
|
|
7389
|
+
/**
|
|
7390
|
+
* ffmpeg output-side args, inserted between the encode block and
|
|
7391
|
+
* the final `-f <muxer> pipe:1`. Use for muxer options, bitstream
|
|
7392
|
+
* filters, codec-specific overrides. Free-text array.
|
|
7393
|
+
*/
|
|
7394
|
+
outputArgs: array(string()).optional()
|
|
7395
|
+
});
|
|
7396
|
+
var YAMNET_TO_MACRO = {
|
|
7397
|
+
mapping: {
|
|
7398
|
+
Speech: "speech",
|
|
7399
|
+
"Child speech, kid speaking": "speech",
|
|
7400
|
+
Conversation: "speech",
|
|
7401
|
+
"Narration, monologue": "speech",
|
|
7402
|
+
Babbling: "speech",
|
|
7403
|
+
Whispering: "speech",
|
|
7404
|
+
"Speech synthesizer": "speech",
|
|
7405
|
+
Humming: "speech",
|
|
7406
|
+
Rapping: "speech",
|
|
7407
|
+
Singing: "speech",
|
|
7408
|
+
Choir: "speech",
|
|
7409
|
+
"Child singing": "speech",
|
|
7410
|
+
Shout: "scream",
|
|
7411
|
+
Bellow: "scream",
|
|
7412
|
+
Yell: "scream",
|
|
7413
|
+
Screaming: "scream",
|
|
7414
|
+
"Children shouting": "scream",
|
|
7415
|
+
Whoop: "scream",
|
|
7416
|
+
"Crying, sobbing": "crying",
|
|
7417
|
+
"Baby cry, infant cry": "crying",
|
|
7418
|
+
Whimper: "crying",
|
|
7419
|
+
"Wail, moan": "crying",
|
|
7420
|
+
Groan: "crying",
|
|
7421
|
+
Laughter: "laughter",
|
|
7422
|
+
"Baby laughter": "laughter",
|
|
7423
|
+
Giggle: "laughter",
|
|
7424
|
+
Snicker: "laughter",
|
|
7425
|
+
"Belly laugh": "laughter",
|
|
7426
|
+
"Chuckle, chortle": "laughter",
|
|
7427
|
+
Music: "music",
|
|
7428
|
+
"Musical instrument": "music",
|
|
7429
|
+
Guitar: "music",
|
|
7430
|
+
Piano: "music",
|
|
7431
|
+
Drum: "music",
|
|
7432
|
+
"Drum kit": "music",
|
|
7433
|
+
"Violin, fiddle": "music",
|
|
7434
|
+
Flute: "music",
|
|
7435
|
+
Saxophone: "music",
|
|
7436
|
+
Trumpet: "music",
|
|
7437
|
+
Synthesizer: "music",
|
|
7438
|
+
"Pop music": "music",
|
|
7439
|
+
"Rock music": "music",
|
|
7440
|
+
"Hip hop music": "music",
|
|
7441
|
+
"Classical music": "music",
|
|
7442
|
+
Jazz: "music",
|
|
7443
|
+
"Electronic music": "music",
|
|
7444
|
+
"Background music": "music",
|
|
7445
|
+
Dog: "dog",
|
|
7446
|
+
Bark: "dog",
|
|
7447
|
+
Yip: "dog",
|
|
7448
|
+
Howl: "dog",
|
|
7449
|
+
"Bow-wow": "dog",
|
|
7450
|
+
Growling: "dog",
|
|
7451
|
+
"Whimper (dog)": "dog",
|
|
7452
|
+
Cat: "cat",
|
|
7453
|
+
Purr: "cat",
|
|
7454
|
+
Meow: "cat",
|
|
7455
|
+
Hiss: "cat",
|
|
7456
|
+
Caterwaul: "cat",
|
|
7457
|
+
Bird: "bird",
|
|
7458
|
+
"Bird vocalization, bird call, bird song": "bird",
|
|
7459
|
+
"Chirp, tweet": "bird",
|
|
7460
|
+
Squawk: "bird",
|
|
7461
|
+
Crow: "bird",
|
|
7462
|
+
Owl: "bird",
|
|
7463
|
+
"Pigeon, dove": "bird",
|
|
7464
|
+
Animal: "animal",
|
|
7465
|
+
"Domestic animals, pets": "animal",
|
|
7466
|
+
"Livestock, farm animals, working animals": "animal",
|
|
7467
|
+
Horse: "animal",
|
|
7468
|
+
"Cattle, bovinae": "animal",
|
|
7469
|
+
Pig: "animal",
|
|
7470
|
+
Sheep: "animal",
|
|
7471
|
+
Goat: "animal",
|
|
7472
|
+
Frog: "animal",
|
|
7473
|
+
Insect: "animal",
|
|
7474
|
+
Cricket: "animal",
|
|
7475
|
+
Alarm: "alarm",
|
|
7476
|
+
"Alarm clock": "alarm",
|
|
7477
|
+
"Smoke detector, smoke alarm": "alarm",
|
|
7478
|
+
"Fire alarm": "alarm",
|
|
7479
|
+
Buzzer: "alarm",
|
|
7480
|
+
"Civil defense siren": "alarm",
|
|
7481
|
+
"Car alarm": "alarm",
|
|
7482
|
+
Siren: "siren",
|
|
7483
|
+
"Police car (siren)": "siren",
|
|
7484
|
+
"Ambulance (siren)": "siren",
|
|
7485
|
+
"Fire engine, fire truck (siren)": "siren",
|
|
7486
|
+
"Emergency vehicle": "siren",
|
|
7487
|
+
Foghorn: "siren",
|
|
7488
|
+
Doorbell: "doorbell",
|
|
7489
|
+
"Ding-dong": "doorbell",
|
|
7490
|
+
Knock: "doorbell",
|
|
7491
|
+
Tap: "doorbell",
|
|
7492
|
+
Glass: "glass_breaking",
|
|
7493
|
+
Shatter: "glass_breaking",
|
|
7494
|
+
"Chink, clink": "glass_breaking",
|
|
7495
|
+
"Gunshot, gunfire": "gunshot",
|
|
7496
|
+
"Machine gun": "gunshot",
|
|
7497
|
+
Explosion: "gunshot",
|
|
7498
|
+
Fireworks: "gunshot",
|
|
7499
|
+
Firecracker: "gunshot",
|
|
7500
|
+
"Artillery fire": "gunshot",
|
|
7501
|
+
"Cap gun": "gunshot",
|
|
7502
|
+
Boom: "gunshot",
|
|
7503
|
+
Vehicle: "vehicle",
|
|
7504
|
+
Car: "vehicle",
|
|
7505
|
+
Truck: "vehicle",
|
|
7506
|
+
Bus: "vehicle",
|
|
7507
|
+
Motorcycle: "vehicle",
|
|
7508
|
+
"Car passing by": "vehicle",
|
|
7509
|
+
"Vehicle horn, car horn, honking": "vehicle",
|
|
7510
|
+
"Traffic noise, roadway noise": "vehicle",
|
|
7511
|
+
Train: "vehicle",
|
|
7512
|
+
Aircraft: "vehicle",
|
|
7513
|
+
Helicopter: "vehicle",
|
|
7514
|
+
Bicycle: "vehicle",
|
|
7515
|
+
Skateboard: "vehicle",
|
|
7516
|
+
Fire: "fire",
|
|
7517
|
+
Crackle: "fire",
|
|
7518
|
+
Water: "water",
|
|
7519
|
+
Rain: "water",
|
|
7520
|
+
Raindrop: "water",
|
|
7521
|
+
"Rain on surface": "water",
|
|
7522
|
+
Stream: "water",
|
|
7523
|
+
Waterfall: "water",
|
|
7524
|
+
Ocean: "water",
|
|
7525
|
+
"Waves, surf": "water",
|
|
7526
|
+
"Splash, splatter": "water",
|
|
7527
|
+
Wind: "wind",
|
|
7528
|
+
Thunderstorm: "wind",
|
|
7529
|
+
Thunder: "wind",
|
|
7530
|
+
"Wind noise (microphone)": "wind",
|
|
7531
|
+
"Rustling leaves": "wind",
|
|
7532
|
+
Door: "door",
|
|
7533
|
+
"Sliding door": "door",
|
|
7534
|
+
Slam: "door",
|
|
7535
|
+
"Cupboard open or close": "door",
|
|
7536
|
+
"Walk, footsteps": "footsteps",
|
|
7537
|
+
Run: "footsteps",
|
|
7538
|
+
Shuffle: "footsteps",
|
|
7539
|
+
Crowd: "crowd",
|
|
7540
|
+
Chatter: "crowd",
|
|
7541
|
+
Cheering: "crowd",
|
|
7542
|
+
Applause: "crowd",
|
|
7543
|
+
"Children playing": "crowd",
|
|
7544
|
+
"Hubbub, speech noise, speech babble": "crowd",
|
|
7545
|
+
Telephone: "telephone",
|
|
7546
|
+
"Telephone bell ringing": "telephone",
|
|
7547
|
+
Ringtone: "telephone",
|
|
7548
|
+
"Telephone dialing, DTMF": "telephone",
|
|
7549
|
+
"Busy signal": "telephone",
|
|
7550
|
+
Engine: "engine",
|
|
7551
|
+
"Engine starting": "engine",
|
|
7552
|
+
Idling: "engine",
|
|
7553
|
+
"Accelerating, revving, vroom": "engine",
|
|
7554
|
+
"Light engine (high frequency)": "engine",
|
|
7555
|
+
"Medium engine (mid frequency)": "engine",
|
|
7556
|
+
"Heavy engine (low frequency)": "engine",
|
|
7557
|
+
"Lawn mower": "engine",
|
|
7558
|
+
Chainsaw: "engine",
|
|
7559
|
+
Hammer: "tools",
|
|
7560
|
+
Jackhammer: "tools",
|
|
7561
|
+
Sawing: "tools",
|
|
7562
|
+
"Power tool": "tools",
|
|
7563
|
+
Drill: "tools",
|
|
7564
|
+
Sanding: "tools",
|
|
7565
|
+
Silence: "silence"
|
|
7566
|
+
},
|
|
7567
|
+
preserveOriginal: false
|
|
7568
|
+
};
|
|
7569
|
+
var APPLE_SA_TO_MACRO = {
|
|
7570
|
+
mapping: {
|
|
7571
|
+
speech: "speech",
|
|
7572
|
+
child_speech: "speech",
|
|
7573
|
+
conversation: "speech",
|
|
7574
|
+
whispering: "speech",
|
|
7575
|
+
singing: "speech",
|
|
7576
|
+
humming: "speech",
|
|
7577
|
+
shout: "scream",
|
|
7578
|
+
yell: "scream",
|
|
7579
|
+
screaming: "scream",
|
|
7580
|
+
crying: "crying",
|
|
7581
|
+
baby_crying: "crying",
|
|
7582
|
+
sobbing: "crying",
|
|
7583
|
+
laughter: "laughter",
|
|
7584
|
+
baby_laughter: "laughter",
|
|
7585
|
+
giggling: "laughter",
|
|
7586
|
+
music: "music",
|
|
7587
|
+
guitar: "music",
|
|
7588
|
+
piano: "music",
|
|
7589
|
+
drums: "music",
|
|
7590
|
+
dog_bark: "dog",
|
|
7591
|
+
dog_bow_wow: "dog",
|
|
7592
|
+
dog_growling: "dog",
|
|
7593
|
+
dog_howl: "dog",
|
|
7594
|
+
cat_meow: "cat",
|
|
7595
|
+
cat_purr: "cat",
|
|
7596
|
+
cat_hiss: "cat",
|
|
7597
|
+
bird: "bird",
|
|
7598
|
+
bird_chirp: "bird",
|
|
7599
|
+
bird_squawk: "bird",
|
|
7600
|
+
animal: "animal",
|
|
7601
|
+
horse: "animal",
|
|
7602
|
+
cow_moo: "animal",
|
|
7603
|
+
insect: "animal",
|
|
7604
|
+
alarm: "alarm",
|
|
7605
|
+
smoke_alarm: "alarm",
|
|
7606
|
+
fire_alarm: "alarm",
|
|
7607
|
+
car_alarm: "alarm",
|
|
7608
|
+
siren: "siren",
|
|
7609
|
+
police_siren: "siren",
|
|
7610
|
+
ambulance_siren: "siren",
|
|
7611
|
+
doorbell: "doorbell",
|
|
7612
|
+
door_knock: "doorbell",
|
|
7613
|
+
knocking: "doorbell",
|
|
7614
|
+
glass_breaking: "glass_breaking",
|
|
7615
|
+
glass_shatter: "glass_breaking",
|
|
7616
|
+
gunshot: "gunshot",
|
|
7617
|
+
explosion: "gunshot",
|
|
7618
|
+
fireworks: "gunshot",
|
|
7619
|
+
car: "vehicle",
|
|
7620
|
+
truck: "vehicle",
|
|
7621
|
+
motorcycle: "vehicle",
|
|
7622
|
+
car_horn: "vehicle",
|
|
7623
|
+
vehicle_horn: "vehicle",
|
|
7624
|
+
traffic: "vehicle",
|
|
7625
|
+
fire: "fire",
|
|
7626
|
+
fire_crackle: "fire",
|
|
7627
|
+
water: "water",
|
|
7628
|
+
rain: "water",
|
|
7629
|
+
ocean: "water",
|
|
7630
|
+
splash: "water",
|
|
7631
|
+
wind: "wind",
|
|
7632
|
+
thunder: "wind",
|
|
7633
|
+
thunderstorm: "wind",
|
|
7634
|
+
door: "door",
|
|
7635
|
+
door_slam: "door",
|
|
7636
|
+
sliding_door: "door",
|
|
7637
|
+
footsteps: "footsteps",
|
|
7638
|
+
walking: "footsteps",
|
|
7639
|
+
running: "footsteps",
|
|
7640
|
+
crowd: "crowd",
|
|
7641
|
+
chatter: "crowd",
|
|
7642
|
+
cheering: "crowd",
|
|
7643
|
+
applause: "crowd",
|
|
7644
|
+
telephone_ring: "telephone",
|
|
7645
|
+
ringtone: "telephone",
|
|
7646
|
+
engine: "engine",
|
|
7647
|
+
engine_starting: "engine",
|
|
7648
|
+
lawn_mower: "engine",
|
|
7649
|
+
chainsaw: "engine",
|
|
7650
|
+
hammer: "tools",
|
|
7651
|
+
jackhammer: "tools",
|
|
7652
|
+
drill: "tools",
|
|
7653
|
+
power_tool: "tools",
|
|
7654
|
+
silence: "silence"
|
|
7655
|
+
},
|
|
7656
|
+
preserveOriginal: false
|
|
7657
|
+
};
|
|
7658
|
+
var _macroLookup = /* @__PURE__ */ new Map();
|
|
7659
|
+
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7660
|
+
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7493
7661
|
/**
|
|
7494
7662
|
* Accessory device helpers — shared across drivers.
|
|
7495
7663
|
*
|
|
@@ -7680,74 +7848,6 @@ object({
|
|
|
7680
7848
|
});
|
|
7681
7849
|
DeviceType.Sensor;
|
|
7682
7850
|
/**
|
|
7683
|
-
* Generic types for capability definitions.
|
|
7684
|
-
*
|
|
7685
|
-
* A capability is defined with Zod schemas for methods, events, and settings.
|
|
7686
|
-
* TypeScript types are inferred via z.infer<> — zero duplication.
|
|
7687
|
-
*
|
|
7688
|
-
* Pattern:
|
|
7689
|
-
* 1. Define Zod schemas for data, methods, settings
|
|
7690
|
-
* 2. Export const capabilityDef = { ... } satisfies CapabilityDefinition
|
|
7691
|
-
* 3. Export type IProvider = InferProvider<typeof capabilityDef>
|
|
7692
|
-
* 4. Addon implements IProvider
|
|
7693
|
-
* 5. Registry auto-mounts tRPC router from definition.methods
|
|
7694
|
-
*/
|
|
7695
|
-
/**
|
|
7696
|
-
* Output schema shared by the contribution + live methods.
|
|
7697
|
-
*
|
|
7698
|
-
* Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
|
|
7699
|
-
* tabs[]) without importing from `../interfaces/config-ui.js` — a
|
|
7700
|
-
* concrete-but-lenient Zod object keeps tRPC output inference happy
|
|
7701
|
-
* (using `z.unknown()` here collapses unrelated router branches to
|
|
7702
|
-
* `unknown` when the generator re-inlines the huge AppRouter type).
|
|
7703
|
-
*
|
|
7704
|
-
* `.passthrough()` on sections/fields accepts whatever FormBuilder
|
|
7705
|
-
* extensions the caller adds (showWhen, displayScale, …) without
|
|
7706
|
-
* rebuilding every time a new field kind is introduced.
|
|
7707
|
-
*/
|
|
7708
|
-
var ContributionSectionSchema = object({
|
|
7709
|
-
id: string(),
|
|
7710
|
-
title: string(),
|
|
7711
|
-
description: string().optional(),
|
|
7712
|
-
style: _enum(["card", "accordion"]).optional(),
|
|
7713
|
-
defaultCollapsed: boolean().optional(),
|
|
7714
|
-
columns: union([
|
|
7715
|
-
literal(1),
|
|
7716
|
-
literal(2),
|
|
7717
|
-
literal(3),
|
|
7718
|
-
literal(4)
|
|
7719
|
-
]).optional(),
|
|
7720
|
-
tab: string().optional(),
|
|
7721
|
-
location: _enum(["settings", "top-tab"]).optional(),
|
|
7722
|
-
order: number().optional(),
|
|
7723
|
-
fields: array(any())
|
|
7724
|
-
});
|
|
7725
|
-
object({
|
|
7726
|
-
tabs: array(object({
|
|
7727
|
-
id: string(),
|
|
7728
|
-
label: string(),
|
|
7729
|
-
icon: string(),
|
|
7730
|
-
order: number().optional()
|
|
7731
|
-
})).optional(),
|
|
7732
|
-
sections: array(ContributionSectionSchema)
|
|
7733
|
-
}).nullable();
|
|
7734
|
-
object({ deviceId: number() }), object({ deviceId: number() }), object({
|
|
7735
|
-
deviceId: number(),
|
|
7736
|
-
patch: record(string(), unknown())
|
|
7737
|
-
}), object({ success: literal(true) });
|
|
7738
|
-
object({ deviceId: number() }), unknown().nullable();
|
|
7739
|
-
/** Shorthand to define a method schema */
|
|
7740
|
-
function method(input, output, options) {
|
|
7741
|
-
return {
|
|
7742
|
-
input,
|
|
7743
|
-
output,
|
|
7744
|
-
kind: options?.kind ?? "query",
|
|
7745
|
-
auth: options?.auth ?? "protected",
|
|
7746
|
-
...options?.access !== void 0 ? { access: options.access } : {},
|
|
7747
|
-
timeoutMs: options?.timeoutMs
|
|
7748
|
-
};
|
|
7749
|
-
}
|
|
7750
|
-
/**
|
|
7751
7851
|
* Alarm-panel cap. Models HA `alarm_control_panel.*` on
|
|
7752
7852
|
* `DeviceType.AlarmPanel`. State follows HA's canonical lifecycle
|
|
7753
7853
|
* across disarmed / armed_(home|away|night|vacation|custom_bypass) /
|
|
@@ -9562,6 +9662,24 @@ var DetectorOutputSchema = object({
|
|
|
9562
9662
|
inferenceMs: number(),
|
|
9563
9663
|
modelId: string()
|
|
9564
9664
|
});
|
|
9665
|
+
var EngineProvisioningSchema = object({
|
|
9666
|
+
runtimeId: _enum([
|
|
9667
|
+
"onnx",
|
|
9668
|
+
"openvino",
|
|
9669
|
+
"coreml"
|
|
9670
|
+
]).nullable(),
|
|
9671
|
+
device: string().nullable(),
|
|
9672
|
+
state: _enum([
|
|
9673
|
+
"idle",
|
|
9674
|
+
"installing",
|
|
9675
|
+
"verifying",
|
|
9676
|
+
"ready",
|
|
9677
|
+
"failed"
|
|
9678
|
+
]),
|
|
9679
|
+
progress: number().optional(),
|
|
9680
|
+
error: string().optional(),
|
|
9681
|
+
nextRetryAt: number().optional()
|
|
9682
|
+
});
|
|
9565
9683
|
var PipelineStepInputSchema = lazy(() => object({
|
|
9566
9684
|
addonId: string(),
|
|
9567
9685
|
modelId: string(),
|
|
@@ -9661,6 +9779,15 @@ var pipelineExecutorCapability = {
|
|
|
9661
9779
|
kind: "mutation",
|
|
9662
9780
|
auth: "admin"
|
|
9663
9781
|
}),
|
|
9782
|
+
/**
|
|
9783
|
+
* Per-node detection-engine provisioning snapshot. Returns the live
|
|
9784
|
+
* state of the lazy runtime-provisioning machine on `nodeId`
|
|
9785
|
+
* (idle / installing / verifying / ready / failed). The UI pairs this
|
|
9786
|
+
* one-shot query with the `pipeline.engine-provisioning` live event
|
|
9787
|
+
* (emitted on every transition) to drive a per-node "engine ready?"
|
|
9788
|
+
* indicator without polling. Phase 2.
|
|
9789
|
+
*/
|
|
9790
|
+
getEngineProvisioning: method(object({ nodeId: string() }), EngineProvisioningSchema),
|
|
9664
9791
|
getVideoPipelineSteps: method(_void(), record(string(), object({
|
|
9665
9792
|
modelId: string(),
|
|
9666
9793
|
settings: record(string(), unknown()).readonly()
|
|
@@ -12045,9 +12172,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
|
|
|
12045
12172
|
limit: number().optional(),
|
|
12046
12173
|
tags: record(string(), string()).optional()
|
|
12047
12174
|
}), array(LogEntrySchema).readonly());
|
|
12048
|
-
var StaticDirOutputSchema = object({ staticDir: string() });
|
|
12049
|
-
var VersionOutputSchema = object({ version: string() });
|
|
12050
|
-
method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
|
|
12051
12175
|
/**
|
|
12052
12176
|
* Zod schemas for persisted record types.
|
|
12053
12177
|
*
|
|
@@ -13537,7 +13661,10 @@ var AgentAddonConfigSchema = object({
|
|
|
13537
13661
|
modelId: string(),
|
|
13538
13662
|
settings: record(string(), unknown()).readonly()
|
|
13539
13663
|
});
|
|
13540
|
-
var AgentPipelineSettingsSchema = object({
|
|
13664
|
+
var AgentPipelineSettingsSchema = object({
|
|
13665
|
+
addonDefaults: record(string(), AgentAddonConfigSchema).readonly(),
|
|
13666
|
+
maxCameras: number().int().nonnegative().nullable().default(null)
|
|
13667
|
+
});
|
|
13541
13668
|
var CameraPipelineForAgentSchema = object({
|
|
13542
13669
|
steps: array(PipelineStepInputSchema).readonly(),
|
|
13543
13670
|
audio: object({
|
|
@@ -13639,6 +13766,133 @@ var GlobalMetricsSchema = object({
|
|
|
13639
13766
|
* capability providers.
|
|
13640
13767
|
*/
|
|
13641
13768
|
var CapabilityBindingsSchema = record(string(), string());
|
|
13769
|
+
/** Source block — always present; derives from the stream catalog. */
|
|
13770
|
+
var CameraSourceStatusSchema = object({ streams: array(object({
|
|
13771
|
+
camStreamId: string(),
|
|
13772
|
+
codec: string(),
|
|
13773
|
+
width: number(),
|
|
13774
|
+
height: number(),
|
|
13775
|
+
fps: number(),
|
|
13776
|
+
kind: string()
|
|
13777
|
+
})).readonly() });
|
|
13778
|
+
/** Assignment block — always present (orchestrator-local, no remote call). */
|
|
13779
|
+
var CameraAssignmentStatusSchema = object({
|
|
13780
|
+
detectionNodeId: string().nullable(),
|
|
13781
|
+
decoderNodeId: string().nullable(),
|
|
13782
|
+
audioNodeId: string().nullable(),
|
|
13783
|
+
pinned: object({
|
|
13784
|
+
detection: boolean(),
|
|
13785
|
+
decoder: boolean(),
|
|
13786
|
+
audio: boolean()
|
|
13787
|
+
}),
|
|
13788
|
+
reasons: object({
|
|
13789
|
+
detection: string().optional(),
|
|
13790
|
+
decoder: string().optional(),
|
|
13791
|
+
audio: string().optional()
|
|
13792
|
+
})
|
|
13793
|
+
});
|
|
13794
|
+
/** Broker block — null when the broker stage is unreachable or inactive. */
|
|
13795
|
+
var CameraBrokerStatusSchema = object({
|
|
13796
|
+
profiles: array(object({
|
|
13797
|
+
profile: string(),
|
|
13798
|
+
status: string(),
|
|
13799
|
+
codec: string(),
|
|
13800
|
+
width: number(),
|
|
13801
|
+
height: number(),
|
|
13802
|
+
subscribers: number(),
|
|
13803
|
+
inFps: number(),
|
|
13804
|
+
outFps: number()
|
|
13805
|
+
})).readonly(),
|
|
13806
|
+
webrtcSessions: number(),
|
|
13807
|
+
rtspRestream: boolean()
|
|
13808
|
+
});
|
|
13809
|
+
/** Shared-memory ring statistics within the decoder block. */
|
|
13810
|
+
var CameraDecoderShmSchema = object({
|
|
13811
|
+
framesWritten: number(),
|
|
13812
|
+
getFrameHits: number(),
|
|
13813
|
+
getFrameMisses: number(),
|
|
13814
|
+
budgetMb: number()
|
|
13815
|
+
});
|
|
13816
|
+
/** Decoder block — null when the decoder stage is unreachable or inactive. */
|
|
13817
|
+
var CameraDecoderStatusSchema = object({
|
|
13818
|
+
nodeId: string(),
|
|
13819
|
+
formats: array(string()).readonly(),
|
|
13820
|
+
sessionCount: number(),
|
|
13821
|
+
shm: CameraDecoderShmSchema
|
|
13822
|
+
});
|
|
13823
|
+
/** Motion block — null when motion detection is not active for this device. */
|
|
13824
|
+
var CameraMotionStatusSchema = object({
|
|
13825
|
+
enabled: boolean(),
|
|
13826
|
+
fps: number()
|
|
13827
|
+
});
|
|
13828
|
+
/** Detection provisioning sub-block. */
|
|
13829
|
+
var CameraDetectionProvisioningSchema = object({
|
|
13830
|
+
state: _enum([
|
|
13831
|
+
"idle",
|
|
13832
|
+
"installing",
|
|
13833
|
+
"verifying",
|
|
13834
|
+
"ready",
|
|
13835
|
+
"failed"
|
|
13836
|
+
]),
|
|
13837
|
+
error: string().optional()
|
|
13838
|
+
});
|
|
13839
|
+
/** Detection phase — derived from the runner's engine phase. */
|
|
13840
|
+
var CameraDetectionPhaseSchema = _enum([
|
|
13841
|
+
"idle",
|
|
13842
|
+
"watching",
|
|
13843
|
+
"active"
|
|
13844
|
+
]);
|
|
13845
|
+
/** Detection block — null when no detection node is assigned or reachable. */
|
|
13846
|
+
var CameraDetectionStatusSchema = object({
|
|
13847
|
+
nodeId: string(),
|
|
13848
|
+
engine: object({
|
|
13849
|
+
backend: string(),
|
|
13850
|
+
device: string()
|
|
13851
|
+
}),
|
|
13852
|
+
phase: CameraDetectionPhaseSchema,
|
|
13853
|
+
configuredFps: number(),
|
|
13854
|
+
actualFps: number(),
|
|
13855
|
+
queueDepth: number(),
|
|
13856
|
+
avgInferenceMs: number(),
|
|
13857
|
+
provisioning: CameraDetectionProvisioningSchema
|
|
13858
|
+
});
|
|
13859
|
+
/** Audio block — null when no audio node is assigned or reachable. */
|
|
13860
|
+
var CameraAudioStatusSchema = object({
|
|
13861
|
+
nodeId: string(),
|
|
13862
|
+
enabled: boolean()
|
|
13863
|
+
});
|
|
13864
|
+
/** Recording block — null when no recording cap is active for this device. */
|
|
13865
|
+
var CameraRecordingStatusSchema = object({
|
|
13866
|
+
mode: _enum([
|
|
13867
|
+
"off",
|
|
13868
|
+
"continuous",
|
|
13869
|
+
"events"
|
|
13870
|
+
]),
|
|
13871
|
+
active: boolean(),
|
|
13872
|
+
storageBytes: number()
|
|
13873
|
+
});
|
|
13874
|
+
/**
|
|
13875
|
+
* Aggregated per-camera pipeline status — server-composed, single call.
|
|
13876
|
+
*
|
|
13877
|
+
* The `assignment` and `source` blocks are always present.
|
|
13878
|
+
* Every other block is `null` when the stage is inactive or unreachable
|
|
13879
|
+
* during the bounded parallel fan-out in the orchestrator implementation.
|
|
13880
|
+
*
|
|
13881
|
+
* See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
|
|
13882
|
+
*/
|
|
13883
|
+
var CameraStatusSchema = object({
|
|
13884
|
+
deviceId: number(),
|
|
13885
|
+
assignment: CameraAssignmentStatusSchema,
|
|
13886
|
+
source: CameraSourceStatusSchema,
|
|
13887
|
+
broker: CameraBrokerStatusSchema.nullable(),
|
|
13888
|
+
decoder: CameraDecoderStatusSchema.nullable(),
|
|
13889
|
+
motion: CameraMotionStatusSchema.nullable(),
|
|
13890
|
+
detection: CameraDetectionStatusSchema.nullable(),
|
|
13891
|
+
audio: CameraAudioStatusSchema.nullable(),
|
|
13892
|
+
recording: CameraRecordingStatusSchema.nullable(),
|
|
13893
|
+
/** Unix timestamp (ms) when this snapshot was composed server-side. */
|
|
13894
|
+
fetchedAt: number()
|
|
13895
|
+
});
|
|
13642
13896
|
/**
|
|
13643
13897
|
* Pipeline Orchestrator capability — global load balancer + camera dispatcher.
|
|
13644
13898
|
*
|
|
@@ -13808,10 +14062,29 @@ var pipelineOrchestratorCapability = {
|
|
|
13808
14062
|
* `success: false` indicates the nodeId wasn't in the store (no-op).
|
|
13809
14063
|
* Refuses to remove `hub` (the orchestrator always co-resides with it).
|
|
13810
14064
|
*/
|
|
13811
|
-
removeAgentSettings: method(object({ agentNodeId: string() }), object({
|
|
13812
|
-
success: boolean(),
|
|
13813
|
-
removed: boolean()
|
|
13814
|
-
}), {
|
|
14065
|
+
removeAgentSettings: method(object({ agentNodeId: string() }), object({
|
|
14066
|
+
success: boolean(),
|
|
14067
|
+
removed: boolean()
|
|
14068
|
+
}), {
|
|
14069
|
+
kind: "mutation",
|
|
14070
|
+
auth: "admin"
|
|
14071
|
+
}),
|
|
14072
|
+
/**
|
|
14073
|
+
* Set the per-node camera cap for one agent.
|
|
14074
|
+
*
|
|
14075
|
+
* `maxCameras: 0` and `maxCameras: null` are both treated as unlimited
|
|
14076
|
+
* by the load balancer (0 is stored as-is; the balancer treats ≤0 as
|
|
14077
|
+
* unlimited alongside null). Pass `null` to clear an existing cap.
|
|
14078
|
+
* Note: the admin UI normalises 0→null before calling this method, so
|
|
14079
|
+
* `maxCameras: 0` only reaches the store via direct SDK or CLI calls.
|
|
14080
|
+
* Changes take effect immediately on the next dispatch cycle — cameras
|
|
14081
|
+
* currently assigned over-cap are left in place (no forced eviction),
|
|
14082
|
+
* but new assignments obey the updated cap.
|
|
14083
|
+
*/
|
|
14084
|
+
setAgentMaxCameras: method(object({
|
|
14085
|
+
agentNodeId: string(),
|
|
14086
|
+
maxCameras: number().int().nonnegative().nullable()
|
|
14087
|
+
}), object({ success: literal(true) }), {
|
|
13815
14088
|
kind: "mutation",
|
|
13816
14089
|
auth: "admin"
|
|
13817
14090
|
}),
|
|
@@ -13855,6 +14128,29 @@ var pipelineOrchestratorCapability = {
|
|
|
13855
14128
|
deviceId: number(),
|
|
13856
14129
|
agentNodeId: string().optional()
|
|
13857
14130
|
}), CameraPipelineConfigSchema),
|
|
14131
|
+
/**
|
|
14132
|
+
* Server-composed aggregated status for a single camera.
|
|
14133
|
+
*
|
|
14134
|
+
* Fans out in parallel (bounded, per-stage graceful degradation) to
|
|
14135
|
+
* broker / decoder / motion / detection / audio / recording source caps
|
|
14136
|
+
* via `ctx.api`. A stage whose source errors or times out becomes `null`
|
|
14137
|
+
* in the returned payload — one slow agent never breaks the whole call.
|
|
14138
|
+
*
|
|
14139
|
+
* Intended for "on open / on camera select" snapshots. Live deltas
|
|
14140
|
+
* keep arriving from the existing ~1Hz events the UI already subscribes to.
|
|
14141
|
+
*/
|
|
14142
|
+
getCameraStatus: method(object({ deviceId: number() }), CameraStatusSchema),
|
|
14143
|
+
/**
|
|
14144
|
+
* Server-composed aggregated status for multiple cameras in one call.
|
|
14145
|
+
*
|
|
14146
|
+
* `deviceIds` defaults to all cameras currently tracked by the
|
|
14147
|
+
* orchestrator's assignment map when omitted.
|
|
14148
|
+
*
|
|
14149
|
+
* Runs per-device composition in parallel (bounded). Use this to
|
|
14150
|
+
* populate the cluster assignments table and the pipeline flow overview
|
|
14151
|
+
* rail without issuing N parallel browser round-trips.
|
|
14152
|
+
*/
|
|
14153
|
+
getCameraStatuses: method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()),
|
|
13858
14154
|
/** List every template the operator has saved. */
|
|
13859
14155
|
listTemplates: method(_void(), array(PipelineTemplateSchema).readonly()),
|
|
13860
14156
|
/** Create a new named preset from a given CameraPipelineConfig. */
|
|
@@ -14351,7 +14647,7 @@ method(object({
|
|
|
14351
14647
|
}), _void(), {
|
|
14352
14648
|
kind: "mutation",
|
|
14353
14649
|
auth: "admin"
|
|
14354
|
-
}), method(object({ addonId: string() }), array(SavedDeviceRowSchema)), method(object({ addonId: string().optional() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(object({ deviceId: number() }), array(ConfigEntrySchema)), method(object({ deviceId: number() }), ConfigUISchemaOutput), method(object({
|
|
14650
|
+
}), method(object({ addonId: string() }), array(SavedDeviceRowSchema)), method(object({ addonId: string().optional() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema)), method(object({ deviceId: number() }), ConfigUISchemaOutput), method(object({
|
|
14355
14651
|
deviceId: number(),
|
|
14356
14652
|
values: record(string(), unknown())
|
|
14357
14653
|
}), object({ success: literal(true) }), {
|
|
@@ -15071,7 +15367,20 @@ var DiskSpaceInfoSchema = object({
|
|
|
15071
15367
|
var PidResourceStatsSchema = object({
|
|
15072
15368
|
pid: number(),
|
|
15073
15369
|
cpu: number(),
|
|
15074
|
-
memory: number()
|
|
15370
|
+
memory: number(),
|
|
15371
|
+
/**
|
|
15372
|
+
* Private (anonymous) resident bytes — the per-process V8 heap + native
|
|
15373
|
+
* allocations NOT shared with other processes (Linux RssAnon). This is the
|
|
15374
|
+
* "real" per-runner cost; summing it across runners is meaningful, unlike
|
|
15375
|
+
* `memory` (RSS), which double-counts the shared mmap'd framework code.
|
|
15376
|
+
* Undefined where /proc is unavailable (e.g. macOS).
|
|
15377
|
+
*/
|
|
15378
|
+
privateBytes: number().optional(),
|
|
15379
|
+
/**
|
|
15380
|
+
* Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
|
|
15381
|
+
* code shared copy-on-write across runners. Undefined on macOS.
|
|
15382
|
+
*/
|
|
15383
|
+
sharedBytes: number().optional()
|
|
15075
15384
|
});
|
|
15076
15385
|
var AddonInstanceSchema = object({
|
|
15077
15386
|
addonId: string(),
|
|
@@ -15120,6 +15429,17 @@ var KillProcessResultSchema = object({
|
|
|
15120
15429
|
reason: string().optional(),
|
|
15121
15430
|
signal: _enum(["SIGTERM", "SIGKILL"]).optional()
|
|
15122
15431
|
});
|
|
15432
|
+
var DumpHeapSnapshotInputSchema = object({
|
|
15433
|
+
/** The addon whose runner should dump a heap snapshot. */
|
|
15434
|
+
addonId: string() });
|
|
15435
|
+
var DumpHeapSnapshotResultSchema = object({
|
|
15436
|
+
success: boolean(),
|
|
15437
|
+
/** Path of the written .heapsnapshot inside the runner's container/host. */
|
|
15438
|
+
path: string().optional(),
|
|
15439
|
+
/** Process pid that was signalled. */
|
|
15440
|
+
pid: number().optional(),
|
|
15441
|
+
reason: string().optional()
|
|
15442
|
+
});
|
|
15123
15443
|
var SystemMetricsSchema = object({
|
|
15124
15444
|
cpuPercent: number(),
|
|
15125
15445
|
memoryPercent: number(),
|
|
@@ -15133,6 +15453,9 @@ var SystemMetricsSchema = object({
|
|
|
15133
15453
|
method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(KillProcessInputSchema, KillProcessResultSchema, {
|
|
15134
15454
|
kind: "mutation",
|
|
15135
15455
|
auth: "admin"
|
|
15456
|
+
}), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
|
|
15457
|
+
kind: "mutation",
|
|
15458
|
+
auth: "admin"
|
|
15136
15459
|
});
|
|
15137
15460
|
var PtzPresetSchema = object({
|
|
15138
15461
|
id: string(),
|
|
@@ -15499,63 +15822,6 @@ method(object({
|
|
|
15499
15822
|
auth: "admin"
|
|
15500
15823
|
});
|
|
15501
15824
|
/**
|
|
15502
|
-
* device-ops — device-scoped cap that unifies the per-IDevice operations
|
|
15503
|
-
* previously routed through the `.device-ops` Moleculer bridge service.
|
|
15504
|
-
*
|
|
15505
|
-
* Each worker that hosts live `IDevice` instances auto-registers a native
|
|
15506
|
-
* provider for this cap (per device) backed by its local
|
|
15507
|
-
* `DeviceRegistry`. Hub-side callers reach it transparently through
|
|
15508
|
-
* `ctx.fetchDevice(id).deviceOps.*` — the DeviceProxy injects
|
|
15509
|
-
* `deviceId` + `nodeId` and dispatches through the standard cap-router,
|
|
15510
|
-
* so there's no parallel bridge path anymore.
|
|
15511
|
-
*
|
|
15512
|
-
* The surface is intentionally small — every method corresponds to a
|
|
15513
|
-
* single action on the live `IDevice` (or `ICameraDevice` for
|
|
15514
|
-
* `getStreamSources`). Richer orchestration (enable/disable with
|
|
15515
|
-
* integration plumbing, bulk updates) stays in the `device-manager` cap;
|
|
15516
|
-
* `device-ops` is the per-device primitive the device-manager routes to.
|
|
15517
|
-
*/
|
|
15518
|
-
var StreamSourceEntrySchema$1 = object({
|
|
15519
|
-
id: string(),
|
|
15520
|
-
label: string(),
|
|
15521
|
-
protocol: _enum([
|
|
15522
|
-
"rtsp",
|
|
15523
|
-
"rtmp",
|
|
15524
|
-
"annexb",
|
|
15525
|
-
"http-mjpeg",
|
|
15526
|
-
"webrtc",
|
|
15527
|
-
"custom"
|
|
15528
|
-
]),
|
|
15529
|
-
url: string().optional(),
|
|
15530
|
-
resolution: object({
|
|
15531
|
-
width: number(),
|
|
15532
|
-
height: number()
|
|
15533
|
-
}).optional(),
|
|
15534
|
-
fps: number().optional(),
|
|
15535
|
-
bitrate: number().optional(),
|
|
15536
|
-
codec: string().optional(),
|
|
15537
|
-
profileHint: CamProfileSchema.optional(),
|
|
15538
|
-
sdp: string().optional()
|
|
15539
|
-
});
|
|
15540
|
-
var ConfigEntrySchema$1 = object({
|
|
15541
|
-
key: string(),
|
|
15542
|
-
value: unknown()
|
|
15543
|
-
});
|
|
15544
|
-
var RawStateResultSchema = object({
|
|
15545
|
-
/** Originating provider id, e.g. 'homeassistant' | 'reolink' | 'hikvision'. */
|
|
15546
|
-
source: string(),
|
|
15547
|
-
/** Opaque, DISPLAY-SAFE upstream blob (no secrets/PII). */
|
|
15548
|
-
data: record(string(), unknown())
|
|
15549
|
-
});
|
|
15550
|
-
method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
|
|
15551
|
-
deviceId: number(),
|
|
15552
|
-
values: record(string(), unknown())
|
|
15553
|
-
}), _void(), { kind: "mutation" }), method(object({
|
|
15554
|
-
deviceId: number(),
|
|
15555
|
-
action: string().min(1),
|
|
15556
|
-
input: unknown()
|
|
15557
|
-
}), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
15558
|
-
/**
|
|
15559
15825
|
* camera-credentials — device-scoped cap exposing the camera's network
|
|
15560
15826
|
* + auth surface in a vendor-neutral shape.
|
|
15561
15827
|
*
|
|
@@ -19238,6 +19504,12 @@ Object.freeze({
|
|
|
19238
19504
|
addonId: null,
|
|
19239
19505
|
access: "view"
|
|
19240
19506
|
},
|
|
19507
|
+
"metricsProvider.dumpHeapSnapshot": {
|
|
19508
|
+
capName: "metrics-provider",
|
|
19509
|
+
capScope: "system",
|
|
19510
|
+
addonId: null,
|
|
19511
|
+
access: "create"
|
|
19512
|
+
},
|
|
19241
19513
|
"metricsProvider.getAddonStats": {
|
|
19242
19514
|
capName: "metrics-provider",
|
|
19243
19515
|
capScope: "system",
|
|
@@ -19694,6 +19966,12 @@ Object.freeze({
|
|
|
19694
19966
|
addonId: null,
|
|
19695
19967
|
access: "view"
|
|
19696
19968
|
},
|
|
19969
|
+
"pipelineExecutor.getEngineProvisioning": {
|
|
19970
|
+
capName: "pipeline-executor",
|
|
19971
|
+
capScope: "system",
|
|
19972
|
+
addonId: null,
|
|
19973
|
+
access: "view"
|
|
19974
|
+
},
|
|
19697
19975
|
"pipelineExecutor.getGlobalPipelineConfig": {
|
|
19698
19976
|
capName: "pipeline-executor",
|
|
19699
19977
|
capScope: "system",
|
|
@@ -19898,6 +20176,18 @@ Object.freeze({
|
|
|
19898
20176
|
addonId: null,
|
|
19899
20177
|
access: "view"
|
|
19900
20178
|
},
|
|
20179
|
+
"pipelineOrchestrator.getCameraStatus": {
|
|
20180
|
+
capName: "pipeline-orchestrator",
|
|
20181
|
+
capScope: "system",
|
|
20182
|
+
addonId: null,
|
|
20183
|
+
access: "view"
|
|
20184
|
+
},
|
|
20185
|
+
"pipelineOrchestrator.getCameraStatuses": {
|
|
20186
|
+
capName: "pipeline-orchestrator",
|
|
20187
|
+
capScope: "system",
|
|
20188
|
+
addonId: null,
|
|
20189
|
+
access: "view"
|
|
20190
|
+
},
|
|
19901
20191
|
"pipelineOrchestrator.getCameraStepOverrides": {
|
|
19902
20192
|
capName: "pipeline-orchestrator",
|
|
19903
20193
|
capScope: "system",
|
|
@@ -19982,6 +20272,12 @@ Object.freeze({
|
|
|
19982
20272
|
addonId: null,
|
|
19983
20273
|
access: "create"
|
|
19984
20274
|
},
|
|
20275
|
+
"pipelineOrchestrator.setAgentMaxCameras": {
|
|
20276
|
+
capName: "pipeline-orchestrator",
|
|
20277
|
+
capScope: "system",
|
|
20278
|
+
addonId: null,
|
|
20279
|
+
access: "create"
|
|
20280
|
+
},
|
|
19985
20281
|
"pipelineOrchestrator.setCameraPipelineForAgent": {
|
|
19986
20282
|
capName: "pipeline-orchestrator",
|
|
19987
20283
|
capScope: "system",
|
|
@@ -21481,30 +21777,6 @@ object({
|
|
|
21481
21777
|
bootAttempts: number(),
|
|
21482
21778
|
schemaVersion: literal(1)
|
|
21483
21779
|
});
|
|
21484
|
-
/**
|
|
21485
|
-
* Promise-based timer helpers — used everywhere the codebase needs to
|
|
21486
|
-
* wait, back off, or schedule a retry. Before these helpers landed, each
|
|
21487
|
-
* call site re-implemented `new Promise(r => setTimeout(r, ms))` inline,
|
|
21488
|
-
* with subtle variations (some swallowing cancellation, some not). Two
|
|
21489
|
-
* shapes cover every observed use case:
|
|
21490
|
-
*
|
|
21491
|
-
* - {@link sleep} for a plain, uncancellable wait — the default choice.
|
|
21492
|
-
* - {@link sleepCancellable} for a wait that wakes early when an
|
|
21493
|
-
* abort signal trips, used by long-running pollers whose teardown
|
|
21494
|
-
* must stop a pending backoff promptly.
|
|
21495
|
-
*/
|
|
21496
|
-
/**
|
|
21497
|
-
* Resolve after `ms` milliseconds. Never rejects, never cancels. The
|
|
21498
|
-
* sleep cannot be interrupted; for a wakeable variant use
|
|
21499
|
-
* {@link sleepCancellable}.
|
|
21500
|
-
*
|
|
21501
|
-
* `ms <= 0` resolves on the next microtask via `setTimeout(0)`, which
|
|
21502
|
-
* still gives the event loop a chance to drain — useful for breaking
|
|
21503
|
-
* up tight async loops without changing call-site semantics.
|
|
21504
|
-
*/
|
|
21505
|
-
function sleep$1(ms) {
|
|
21506
|
-
return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
21507
|
-
}
|
|
21508
21780
|
//#endregion
|
|
21509
21781
|
//#region src/pipeline-resolver.ts
|
|
21510
21782
|
function applyStepPatch(base, patch) {
|
|
@@ -22012,7 +22284,10 @@ var StoredAgentAddonConfigSchema = object({
|
|
|
22012
22284
|
modelId: string(),
|
|
22013
22285
|
settings: record(string(), unknown()).readonly()
|
|
22014
22286
|
});
|
|
22015
|
-
var StoredAgentPipelineSettingsSchema = object({
|
|
22287
|
+
var StoredAgentPipelineSettingsSchema = object({
|
|
22288
|
+
addonDefaults: record(string(), StoredAgentAddonConfigSchema).readonly(),
|
|
22289
|
+
maxCameras: number().int().nonnegative().nullable().default(null)
|
|
22290
|
+
});
|
|
22016
22291
|
var AgentSettingsMapSchema = record(string(), StoredAgentPipelineSettingsSchema);
|
|
22017
22292
|
var StoredCameraStepOverridePatchSchema = object({
|
|
22018
22293
|
enabled: boolean().optional(),
|
|
@@ -22057,10 +22332,26 @@ function computeCapacityScore(load) {
|
|
|
22057
22332
|
return load.attachedCameras * Math.max(load.avgInferenceFps, 0) + Math.max(load.queueDepthTotal, 0);
|
|
22058
22333
|
}
|
|
22059
22334
|
/**
|
|
22335
|
+
* Returns true when the node has remaining capacity.
|
|
22336
|
+
* A node is eligible iff `cap` is unlimited (null/absent/<=0) OR
|
|
22337
|
+
* its `attachedCameras` count is strictly less than the cap.
|
|
22338
|
+
* Pins count toward the cap via `attachedCameras`.
|
|
22339
|
+
*/
|
|
22340
|
+
function isEligible(node, caps) {
|
|
22341
|
+
const cap = caps?.[node.nodeId];
|
|
22342
|
+
if (cap === null || cap === void 0 || cap <= 0) return true;
|
|
22343
|
+
return node.attachedCameras < cap;
|
|
22344
|
+
}
|
|
22345
|
+
/**
|
|
22060
22346
|
* Run the two-level camera balancer.
|
|
22061
22347
|
*
|
|
22062
|
-
* L1 (manual affinity): if `preferredAgent` names an online node
|
|
22063
|
-
*
|
|
22348
|
+
* L1 (manual affinity): if `preferredAgent` names an online node AND that
|
|
22349
|
+
* node is under its `maxCameras` cap, return it. If the node is online but at
|
|
22350
|
+
* or over cap, return `{kind:'pending'}` — a pinned camera is never silently
|
|
22351
|
+
* over-assigned.
|
|
22352
|
+
*
|
|
22353
|
+
* L2 (capacity): filter to eligible nodes and pick the lowest capacity score.
|
|
22354
|
+
* If all nodes are at/over cap, return `{kind:'pending'}`.
|
|
22064
22355
|
*
|
|
22065
22356
|
* Returns `null` when no runners are online. The orchestrator decides how to
|
|
22066
22357
|
* react — typically by logging and deferring the assignment until a runner
|
|
@@ -22069,19 +22360,32 @@ function computeCapacityScore(load) {
|
|
|
22069
22360
|
function balance(input) {
|
|
22070
22361
|
const online = input.nodes.filter((n) => n.nodeId.length > 0);
|
|
22071
22362
|
if (online.length === 0) return null;
|
|
22363
|
+
const eligible = online.filter((n) => isEligible(n, input.nodeCaps));
|
|
22072
22364
|
if (input.preferredAgent) {
|
|
22073
|
-
const
|
|
22074
|
-
if (
|
|
22075
|
-
|
|
22076
|
-
|
|
22077
|
-
|
|
22078
|
-
|
|
22365
|
+
const pinnedOnline = online.find((n) => n.nodeId === input.preferredAgent);
|
|
22366
|
+
if (pinnedOnline) {
|
|
22367
|
+
if (eligible.some((n) => n.nodeId === pinnedOnline.nodeId)) return {
|
|
22368
|
+
kind: "assigned",
|
|
22369
|
+
agentNodeId: pinnedOnline.nodeId,
|
|
22370
|
+
reason: "manual",
|
|
22371
|
+
score: computeCapacityScore(pinnedOnline)
|
|
22372
|
+
};
|
|
22373
|
+
return {
|
|
22374
|
+
kind: "pending",
|
|
22375
|
+
reason: "over-cap"
|
|
22376
|
+
};
|
|
22377
|
+
}
|
|
22079
22378
|
}
|
|
22080
|
-
|
|
22379
|
+
if (eligible.length === 0) return {
|
|
22380
|
+
kind: "pending",
|
|
22381
|
+
reason: "over-cap"
|
|
22382
|
+
};
|
|
22383
|
+
const best = eligible.map((node) => ({
|
|
22081
22384
|
node,
|
|
22082
22385
|
score: computeCapacityScore(node)
|
|
22083
22386
|
})).toSorted((a, b) => a.score - b.score)[0];
|
|
22084
22387
|
return {
|
|
22388
|
+
kind: "assigned",
|
|
22085
22389
|
agentNodeId: best.node.nodeId,
|
|
22086
22390
|
reason: "capacity",
|
|
22087
22391
|
score: best.score
|
|
@@ -22500,6 +22804,139 @@ var PipelineWatchdog = class {
|
|
|
22500
22804
|
}
|
|
22501
22805
|
};
|
|
22502
22806
|
//#endregion
|
|
22807
|
+
//#region src/camera-status/compose-camera-status.ts
|
|
22808
|
+
function mapAssignment(input) {
|
|
22809
|
+
return {
|
|
22810
|
+
detectionNodeId: input.detectionNodeId,
|
|
22811
|
+
decoderNodeId: input.decoderNodeId,
|
|
22812
|
+
audioNodeId: input.audioNodeId,
|
|
22813
|
+
pinned: {
|
|
22814
|
+
detection: input.pinned.detection,
|
|
22815
|
+
decoder: input.pinned.decoder,
|
|
22816
|
+
audio: input.pinned.audio
|
|
22817
|
+
},
|
|
22818
|
+
reasons: {
|
|
22819
|
+
detection: input.reasons.detection,
|
|
22820
|
+
decoder: input.reasons.decoder,
|
|
22821
|
+
audio: input.reasons.audio
|
|
22822
|
+
}
|
|
22823
|
+
};
|
|
22824
|
+
}
|
|
22825
|
+
function mapSource(sourceResult) {
|
|
22826
|
+
if (sourceResult === null) return { streams: [] };
|
|
22827
|
+
return { streams: sourceResult.streams.map((s) => ({
|
|
22828
|
+
camStreamId: s.camStreamId,
|
|
22829
|
+
codec: s.codec,
|
|
22830
|
+
width: s.width,
|
|
22831
|
+
height: s.height,
|
|
22832
|
+
fps: s.fps,
|
|
22833
|
+
kind: s.kind
|
|
22834
|
+
})) };
|
|
22835
|
+
}
|
|
22836
|
+
function mapBroker(brokerResult) {
|
|
22837
|
+
if (brokerResult === null) return null;
|
|
22838
|
+
return {
|
|
22839
|
+
profiles: brokerResult.profiles.map((p) => ({
|
|
22840
|
+
profile: p.profile,
|
|
22841
|
+
status: p.status,
|
|
22842
|
+
codec: p.codec,
|
|
22843
|
+
width: p.width,
|
|
22844
|
+
height: p.height,
|
|
22845
|
+
subscribers: p.subscribers,
|
|
22846
|
+
inFps: p.inFps,
|
|
22847
|
+
outFps: p.outFps
|
|
22848
|
+
})),
|
|
22849
|
+
webrtcSessions: brokerResult.webrtcSessions,
|
|
22850
|
+
rtspRestream: brokerResult.rtspRestream
|
|
22851
|
+
};
|
|
22852
|
+
}
|
|
22853
|
+
function mapDecoderShm(shm) {
|
|
22854
|
+
return {
|
|
22855
|
+
framesWritten: shm.framesWritten,
|
|
22856
|
+
getFrameHits: shm.getFrameHits,
|
|
22857
|
+
getFrameMisses: shm.getFrameMisses,
|
|
22858
|
+
budgetMb: shm.budgetMb
|
|
22859
|
+
};
|
|
22860
|
+
}
|
|
22861
|
+
function mapDecoder(decoderResult) {
|
|
22862
|
+
if (decoderResult === null) return null;
|
|
22863
|
+
return {
|
|
22864
|
+
nodeId: decoderResult.nodeId,
|
|
22865
|
+
formats: [...decoderResult.formats],
|
|
22866
|
+
sessionCount: decoderResult.sessionCount,
|
|
22867
|
+
shm: mapDecoderShm(decoderResult.shm)
|
|
22868
|
+
};
|
|
22869
|
+
}
|
|
22870
|
+
function mapMotion(motionResult) {
|
|
22871
|
+
if (motionResult === null) return null;
|
|
22872
|
+
return {
|
|
22873
|
+
enabled: motionResult.enabled,
|
|
22874
|
+
fps: motionResult.fps
|
|
22875
|
+
};
|
|
22876
|
+
}
|
|
22877
|
+
function mapProvisioning(p) {
|
|
22878
|
+
if (p.error !== void 0) return {
|
|
22879
|
+
state: p.state,
|
|
22880
|
+
error: p.error
|
|
22881
|
+
};
|
|
22882
|
+
return { state: p.state };
|
|
22883
|
+
}
|
|
22884
|
+
function mapDetection(detectionResult) {
|
|
22885
|
+
if (detectionResult === null) return null;
|
|
22886
|
+
const phase = detectionResult.phase;
|
|
22887
|
+
return {
|
|
22888
|
+
nodeId: detectionResult.nodeId,
|
|
22889
|
+
engine: {
|
|
22890
|
+
backend: detectionResult.engine.backend,
|
|
22891
|
+
device: detectionResult.engine.device
|
|
22892
|
+
},
|
|
22893
|
+
phase,
|
|
22894
|
+
configuredFps: detectionResult.configuredFps,
|
|
22895
|
+
actualFps: detectionResult.actualFps,
|
|
22896
|
+
queueDepth: detectionResult.queueDepth,
|
|
22897
|
+
avgInferenceMs: detectionResult.avgInferenceMs,
|
|
22898
|
+
provisioning: mapProvisioning(detectionResult.provisioning)
|
|
22899
|
+
};
|
|
22900
|
+
}
|
|
22901
|
+
function mapAudio(audioResult) {
|
|
22902
|
+
if (audioResult === null) return null;
|
|
22903
|
+
return {
|
|
22904
|
+
nodeId: audioResult.nodeId,
|
|
22905
|
+
enabled: audioResult.enabled
|
|
22906
|
+
};
|
|
22907
|
+
}
|
|
22908
|
+
function mapRecording(recordingResult) {
|
|
22909
|
+
if (recordingResult === null) return null;
|
|
22910
|
+
return {
|
|
22911
|
+
mode: recordingResult.mode,
|
|
22912
|
+
active: recordingResult.active,
|
|
22913
|
+
storageBytes: recordingResult.storageBytes
|
|
22914
|
+
};
|
|
22915
|
+
}
|
|
22916
|
+
/**
|
|
22917
|
+
* Pure function that composes a `CameraStatus` from per-stage fetch results.
|
|
22918
|
+
*
|
|
22919
|
+
* - `assignment` is always built from orchestrator-local data (never null).
|
|
22920
|
+
* - `source` always present: defaults to `{ streams: [] }` when sourceResult is null.
|
|
22921
|
+
* - Every other block is null when its stage result is null (graceful degradation).
|
|
22922
|
+
* - `fetchedAt` is stamped exactly as provided — never calls `Date.now()`.
|
|
22923
|
+
* - No mutation of the input.
|
|
22924
|
+
*/
|
|
22925
|
+
function composeCameraStatus(input) {
|
|
22926
|
+
return {
|
|
22927
|
+
deviceId: input.deviceId,
|
|
22928
|
+
assignment: mapAssignment(input),
|
|
22929
|
+
source: mapSource(input.sourceResult),
|
|
22930
|
+
broker: mapBroker(input.brokerResult),
|
|
22931
|
+
decoder: mapDecoder(input.decoderResult),
|
|
22932
|
+
motion: mapMotion(input.motionResult),
|
|
22933
|
+
detection: mapDetection(input.detectionResult),
|
|
22934
|
+
audio: mapAudio(input.audioResult),
|
|
22935
|
+
recording: mapRecording(input.recordingResult),
|
|
22936
|
+
fetchedAt: input.fetchedAt
|
|
22937
|
+
};
|
|
22938
|
+
}
|
|
22939
|
+
//#endregion
|
|
22503
22940
|
//#region src/index.ts
|
|
22504
22941
|
var PHASE_MODE_VALUES = new Set([
|
|
22505
22942
|
"disabled",
|
|
@@ -23257,8 +23694,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
23257
23694
|
});
|
|
23258
23695
|
return {
|
|
23259
23696
|
success: true,
|
|
23260
|
-
|
|
23261
|
-
reason: "capacity"
|
|
23697
|
+
kind: "pending"
|
|
23262
23698
|
};
|
|
23263
23699
|
}
|
|
23264
23700
|
}
|
|
@@ -23268,14 +23704,22 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
23268
23704
|
const preferredAgent = typeof pipelinePin === "string" && pipelinePin !== "auto" ? pipelinePin : legacyPreferred;
|
|
23269
23705
|
const decision = balance({
|
|
23270
23706
|
nodes: await this.collectAgentLoad({ onlyEnabled: true }),
|
|
23271
|
-
preferredAgent
|
|
23707
|
+
preferredAgent,
|
|
23708
|
+
nodeCaps: this.buildNodeCaps()
|
|
23272
23709
|
});
|
|
23273
|
-
|
|
23274
|
-
if (
|
|
23710
|
+
if (!decision) throw new Error(`dispatchCamera: no runner available for ${runnerConfig.deviceId}`);
|
|
23711
|
+
if (decision.kind === "pending") {
|
|
23712
|
+
this.ctx.logger.warn("camera left pending — all nodes at maxCameras", { tags: { deviceId: runnerConfig.deviceId } });
|
|
23713
|
+
return {
|
|
23714
|
+
success: true,
|
|
23715
|
+
kind: "pending"
|
|
23716
|
+
};
|
|
23717
|
+
}
|
|
23718
|
+
const targetNodeId = decision.agentNodeId;
|
|
23275
23719
|
await this.attachOn(targetNodeId, runnerConfig);
|
|
23276
23720
|
if (targetNodeId === this.localNodeId) this.pipelineWatchdog?.register(this.buildWatchdogCamera(runnerConfig, String(runnerConfig.deviceId)));
|
|
23277
|
-
const reason = decision
|
|
23278
|
-
const pinned = decision
|
|
23721
|
+
const reason = decision.reason;
|
|
23722
|
+
const pinned = decision.reason === "manual";
|
|
23279
23723
|
this.recordAssignment(runnerConfig.deviceId, targetNodeId, reason, pinned);
|
|
23280
23724
|
const decoderNodeId = await this.resolveDecoderNode(runnerConfig.deviceId, targetNodeId);
|
|
23281
23725
|
this.ctx.logger.info("dispatchCamera", {
|
|
@@ -23285,12 +23729,13 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
23285
23729
|
},
|
|
23286
23730
|
meta: {
|
|
23287
23731
|
reason,
|
|
23288
|
-
score: decision
|
|
23732
|
+
score: decision.score,
|
|
23289
23733
|
decoderNodeId
|
|
23290
23734
|
}
|
|
23291
23735
|
});
|
|
23292
23736
|
return {
|
|
23293
23737
|
success: true,
|
|
23738
|
+
kind: "assigned",
|
|
23294
23739
|
agentNodeId: targetNodeId,
|
|
23295
23740
|
reason
|
|
23296
23741
|
};
|
|
@@ -23364,10 +23809,13 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
23364
23809
|
if (cached) {
|
|
23365
23810
|
const decision = balance({
|
|
23366
23811
|
nodes: await this.collectAgentLoad({ onlyEnabled: true }),
|
|
23367
|
-
preferredAgent: null
|
|
23812
|
+
preferredAgent: null,
|
|
23813
|
+
nodeCaps: this.buildNodeCaps()
|
|
23368
23814
|
});
|
|
23369
|
-
|
|
23370
|
-
if (
|
|
23815
|
+
if (!decision) this.ctx.logger.warn("unassignPipeline: no runner available, leaving unassigned", { tags: { deviceId: input.deviceId } });
|
|
23816
|
+
else if (decision.kind === "pending") this.ctx.logger.warn("camera left pending — all nodes at maxCameras", { tags: { deviceId: input.deviceId } });
|
|
23817
|
+
else {
|
|
23818
|
+
const targetNodeId = decision.agentNodeId;
|
|
23371
23819
|
if (current && current.agentNodeId !== targetNodeId) await this.detachOn(current.agentNodeId, input.deviceId).catch((err) => {
|
|
23372
23820
|
const msg = errMsg(err);
|
|
23373
23821
|
this.ctx.logger.debug("unassignPipeline detach-old failed", {
|
|
@@ -23376,7 +23824,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
23376
23824
|
});
|
|
23377
23825
|
});
|
|
23378
23826
|
if (!current || current.agentNodeId !== targetNodeId) await this.attachOn(targetNodeId, cached);
|
|
23379
|
-
const reason = decision
|
|
23827
|
+
const reason = decision.reason === "manual" ? "capacity" : decision.reason;
|
|
23380
23828
|
this.recordAssignment(input.deviceId, targetNodeId, reason, false);
|
|
23381
23829
|
this.ctx.logger.info("unassignPipeline: re-dispatched via auto", {
|
|
23382
23830
|
tags: {
|
|
@@ -23387,7 +23835,6 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
23387
23835
|
});
|
|
23388
23836
|
return { success: true };
|
|
23389
23837
|
}
|
|
23390
|
-
this.ctx.logger.warn("unassignPipeline: no runner available, leaving unassigned", { tags: { deviceId: input.deviceId } });
|
|
23391
23838
|
}
|
|
23392
23839
|
if (current) {
|
|
23393
23840
|
await this.detachOn(current.agentNodeId, input.deviceId).catch((err) => {
|
|
@@ -23405,15 +23852,21 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
23405
23852
|
async rebalance() {
|
|
23406
23853
|
if (!this.ctx) throw new Error("PipelineOrchestrator: rebalance called before initialize");
|
|
23407
23854
|
const loads = await this.collectAgentLoad({ onlyEnabled: true });
|
|
23855
|
+
const nodeCaps = this.buildNodeCaps();
|
|
23408
23856
|
let migrated = 0;
|
|
23409
23857
|
for (const [deviceId, config] of this.cameraConfigs) {
|
|
23410
23858
|
const current = this.assignments.get(deviceId);
|
|
23411
23859
|
if (current?.pinned) continue;
|
|
23412
23860
|
const decision = balance({
|
|
23413
23861
|
nodes: loads,
|
|
23414
|
-
preferredAgent: await this.readPreferredAgent(deviceId)
|
|
23862
|
+
preferredAgent: await this.readPreferredAgent(deviceId),
|
|
23863
|
+
nodeCaps
|
|
23415
23864
|
});
|
|
23416
23865
|
if (!decision) continue;
|
|
23866
|
+
if (decision.kind === "pending") {
|
|
23867
|
+
this.ctx.logger.warn("camera left pending — all nodes at maxCameras", { tags: { deviceId } });
|
|
23868
|
+
continue;
|
|
23869
|
+
}
|
|
23417
23870
|
if (current && current.agentNodeId === decision.agentNodeId) continue;
|
|
23418
23871
|
if (current) await this.detachOn(current.agentNodeId, deviceId).catch((err) => {
|
|
23419
23872
|
const msg = errMsg(err);
|
|
@@ -23551,15 +24004,6 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
23551
24004
|
nodeId
|
|
23552
24005
|
});
|
|
23553
24006
|
}
|
|
23554
|
-
async localRunnerNodeId() {
|
|
23555
|
-
const api = this.ctx.api;
|
|
23556
|
-
if (!api) return null;
|
|
23557
|
-
try {
|
|
23558
|
-
return (await api.pipelineRunner.getLocalLoad.query({ nodeId: this.localNodeId }))?.nodeId ?? this.localNodeId;
|
|
23559
|
-
} catch {
|
|
23560
|
-
return this.localNodeId;
|
|
23561
|
-
}
|
|
23562
|
-
}
|
|
23563
24007
|
/**
|
|
23564
24008
|
* Enumerate every runner-capable node currently known (populated via
|
|
23565
24009
|
* AgentOnline/AgentOffline events). Used to populate the `enabledNodes`
|
|
@@ -23714,6 +24158,18 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
23714
24158
|
return null;
|
|
23715
24159
|
}
|
|
23716
24160
|
}
|
|
24161
|
+
/**
|
|
24162
|
+
* Build a per-node camera cap map from the persisted agent settings.
|
|
24163
|
+
* Returns `null` for nodes where `maxCameras` is null (unlimited).
|
|
24164
|
+
* Used by every `balance()` call so the balancer can honour operator-set
|
|
24165
|
+
* per-node maximums without polling the store on each decision.
|
|
24166
|
+
*/
|
|
24167
|
+
buildNodeCaps() {
|
|
24168
|
+
const blob = this.agentSettingsState.get();
|
|
24169
|
+
const caps = {};
|
|
24170
|
+
for (const [nodeId, settings] of Object.entries(blob)) caps[nodeId] = settings.maxCameras ?? null;
|
|
24171
|
+
return caps;
|
|
24172
|
+
}
|
|
23717
24173
|
async readAudioNodePin(deviceId) {
|
|
23718
24174
|
if (!this.ctx?.settings) return null;
|
|
23719
24175
|
try {
|
|
@@ -23856,13 +24312,19 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
23856
24312
|
for (const { deviceId, config } of affected) {
|
|
23857
24313
|
const decision = balance({
|
|
23858
24314
|
nodes: loads,
|
|
23859
|
-
preferredAgent: null
|
|
24315
|
+
preferredAgent: null,
|
|
24316
|
+
nodeCaps: this.buildNodeCaps()
|
|
23860
24317
|
});
|
|
23861
24318
|
if (!decision) {
|
|
23862
24319
|
this.ctx.logger.error("Failover: no online runner", { tags: { deviceId } });
|
|
23863
24320
|
this.assignments.delete(deviceId);
|
|
23864
24321
|
continue;
|
|
23865
24322
|
}
|
|
24323
|
+
if (decision.kind === "pending") {
|
|
24324
|
+
this.ctx.logger.warn("camera left pending — all nodes at maxCameras", { tags: { deviceId } });
|
|
24325
|
+
this.assignments.delete(deviceId);
|
|
24326
|
+
continue;
|
|
24327
|
+
}
|
|
23866
24328
|
try {
|
|
23867
24329
|
await this.attachOn(decision.agentNodeId, config);
|
|
23868
24330
|
this.recordAssignment(deviceId, decision.agentNodeId, "failover", false);
|
|
@@ -24342,7 +24804,10 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
24342
24804
|
}
|
|
24343
24805
|
async setAgentAddonDefaults(input) {
|
|
24344
24806
|
let existing = (await this.readAgentSettingsMap())[input.agentNodeId];
|
|
24345
|
-
if (!existing)
|
|
24807
|
+
if (!existing) {
|
|
24808
|
+
await this.seedAgentSettingsFromCatalog(input.agentNodeId);
|
|
24809
|
+
existing = (await this.readAgentSettingsMap())[input.agentNodeId];
|
|
24810
|
+
}
|
|
24346
24811
|
if (!existing) await this.writeAgentSettings(input.agentNodeId, { addonDefaults: { ...input.defaults } });
|
|
24347
24812
|
else await this.writeAgentSettings(input.agentNodeId, {
|
|
24348
24813
|
...existing,
|
|
@@ -24380,6 +24845,22 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
24380
24845
|
removed: true
|
|
24381
24846
|
};
|
|
24382
24847
|
}
|
|
24848
|
+
async setAgentMaxCameras(input) {
|
|
24849
|
+
const existing = (await this.readAgentSettingsMap())[input.agentNodeId];
|
|
24850
|
+
const next = existing ? {
|
|
24851
|
+
...existing,
|
|
24852
|
+
maxCameras: input.maxCameras
|
|
24853
|
+
} : {
|
|
24854
|
+
addonDefaults: {},
|
|
24855
|
+
maxCameras: input.maxCameras
|
|
24856
|
+
};
|
|
24857
|
+
await this.writeAgentSettings(input.agentNodeId, next);
|
|
24858
|
+
this.ctx.logger.info("agentSettings.maxCameras updated", {
|
|
24859
|
+
tags: { nodeId: input.agentNodeId },
|
|
24860
|
+
meta: { maxCameras: input.maxCameras }
|
|
24861
|
+
});
|
|
24862
|
+
return { success: true };
|
|
24863
|
+
}
|
|
24383
24864
|
async getCameraSettings(input) {
|
|
24384
24865
|
return (await this.readCameraSettingsMap())[String(input.deviceId)] ?? null;
|
|
24385
24866
|
}
|
|
@@ -24509,6 +24990,204 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
24509
24990
|
this.ctx.logger.info("template deleted", { meta: { templateId: input.id } });
|
|
24510
24991
|
return { success: true };
|
|
24511
24992
|
}
|
|
24993
|
+
/**
|
|
24994
|
+
* Races a promise against a timeout. Returns `null` on timeout OR rejection.
|
|
24995
|
+
* Never throws — individual stage failures become `null` in the aggregate.
|
|
24996
|
+
*
|
|
24997
|
+
* @param p The stage fetch promise.
|
|
24998
|
+
* @param ms Timeout in milliseconds.
|
|
24999
|
+
*/
|
|
25000
|
+
boundedStage(p, ms) {
|
|
25001
|
+
let timer;
|
|
25002
|
+
const timeout = new Promise((resolve) => {
|
|
25003
|
+
timer = setTimeout(() => resolve(null), ms);
|
|
25004
|
+
});
|
|
25005
|
+
return Promise.race([p, timeout]).catch(() => null).finally(() => {
|
|
25006
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
25007
|
+
});
|
|
25008
|
+
}
|
|
25009
|
+
/**
|
|
25010
|
+
* Server-composed aggregated status for a single camera.
|
|
25011
|
+
*
|
|
25012
|
+
* Fans out in parallel (bounded, per-stage graceful degradation) to
|
|
25013
|
+
* broker / decoder / motion / detection / audio / recording source caps
|
|
25014
|
+
* via `ctx.api`. A stage whose source errors or times out becomes `null`
|
|
25015
|
+
* in the returned payload — one slow agent never breaks the whole call.
|
|
25016
|
+
*/
|
|
25017
|
+
async getCameraStatus(input) {
|
|
25018
|
+
const { deviceId } = input;
|
|
25019
|
+
const api = this.ctx.api;
|
|
25020
|
+
const STAGE_TIMEOUT_MS = 3e3;
|
|
25021
|
+
const pipelineAssignment = this.assignments.get(deviceId) ?? null;
|
|
25022
|
+
const detectionNodeId = pipelineAssignment?.agentNodeId ?? null;
|
|
25023
|
+
const decoderPinRaw = (api ? await this.ctx.settings?.readDeviceStore(deviceId).catch(() => ({})) ?? {} : {})["decoderNodeId"];
|
|
25024
|
+
const decoderPinned = typeof decoderPinRaw === "string" && decoderPinRaw !== "auto";
|
|
25025
|
+
const decoderNodeId = detectionNodeId ? await this.resolveDecoderNode(deviceId, detectionNodeId).catch(() => null) : null;
|
|
25026
|
+
const audioAssignment = this.audioAssignments.get(deviceId) ?? null;
|
|
25027
|
+
const audioNodeId = audioAssignment?.nodeId ?? null;
|
|
25028
|
+
const audioPinned = audioAssignment?.pinned ?? false;
|
|
25029
|
+
const pinned = {
|
|
25030
|
+
detection: pipelineAssignment?.pinned ?? false,
|
|
25031
|
+
decoder: decoderPinned,
|
|
25032
|
+
audio: audioPinned
|
|
25033
|
+
};
|
|
25034
|
+
const reasons = {
|
|
25035
|
+
detection: pipelineAssignment?.reason,
|
|
25036
|
+
decoder: decoderPinned ? "manual" : "co-located",
|
|
25037
|
+
audio: audioPinned ? "manual" : void 0
|
|
25038
|
+
};
|
|
25039
|
+
const allSlotsFetch = api ? api.streamBroker.listAllProfileSlots.query() : null;
|
|
25040
|
+
const sourceFetch = api && allSlotsFetch ? this.boundedStage(allSlotsFetch.then((slots) => {
|
|
25041
|
+
return { streams: slots.filter((s) => s.deviceId === deviceId).map((s) => ({
|
|
25042
|
+
camStreamId: s.sourceCamStreamId ?? s.brokerId,
|
|
25043
|
+
codec: s.codec ?? "",
|
|
25044
|
+
width: s.resolution?.width ?? 0,
|
|
25045
|
+
height: s.resolution?.height ?? 0,
|
|
25046
|
+
fps: 0,
|
|
25047
|
+
kind: s.profile
|
|
25048
|
+
})) };
|
|
25049
|
+
}), STAGE_TIMEOUT_MS) : Promise.resolve(null);
|
|
25050
|
+
const WEBRTC_KINDS = new Set([
|
|
25051
|
+
"webrtc-browser",
|
|
25052
|
+
"webrtc-mobile",
|
|
25053
|
+
"webrtc-whep"
|
|
25054
|
+
]);
|
|
25055
|
+
const brokerFetch = api && allSlotsFetch ? this.boundedStage(allSlotsFetch.then(async (slots) => {
|
|
25056
|
+
const deviceSlots = slots.filter((s) => s.deviceId === deviceId);
|
|
25057
|
+
if (deviceSlots.length === 0) return {
|
|
25058
|
+
profiles: [],
|
|
25059
|
+
webrtcSessions: 0,
|
|
25060
|
+
rtspRestream: false
|
|
25061
|
+
};
|
|
25062
|
+
const [statsAndClients, rtspEntry] = await Promise.all([Promise.all(deviceSlots.map(async (slot) => {
|
|
25063
|
+
return {
|
|
25064
|
+
slot,
|
|
25065
|
+
stats: await api.streamBroker.getBrokerStats.query({ brokerId: slot.brokerId }).catch(() => null),
|
|
25066
|
+
clients: await api.streamBroker.listClients.query({ brokerId: slot.brokerId }).catch(() => null)
|
|
25067
|
+
};
|
|
25068
|
+
})), api.streamBroker.getAllRtspEntries.query({}).catch(() => null)]);
|
|
25069
|
+
return {
|
|
25070
|
+
profiles: statsAndClients.map(({ slot, stats, clients }) => ({
|
|
25071
|
+
profile: slot.profile,
|
|
25072
|
+
status: slot.status,
|
|
25073
|
+
codec: stats?.codec ?? slot.codec ?? "",
|
|
25074
|
+
width: slot.resolution?.width ?? 0,
|
|
25075
|
+
height: slot.resolution?.height ?? 0,
|
|
25076
|
+
subscribers: clients?.encodedSubscribers ?? 0,
|
|
25077
|
+
inFps: stats?.inputFps ?? 0,
|
|
25078
|
+
outFps: stats?.decodeFps ?? 0
|
|
25079
|
+
})),
|
|
25080
|
+
webrtcSessions: statsAndClients.reduce((total, { clients }) => {
|
|
25081
|
+
if (!clients) return total;
|
|
25082
|
+
return total + clients.encoded.filter((c) => WEBRTC_KINDS.has(c.attribution.kind)).length;
|
|
25083
|
+
}, 0),
|
|
25084
|
+
rtspRestream: rtspEntry?.some((e) => {
|
|
25085
|
+
return e.brokerId.split("/")[0] === String(deviceId) && e.enabled;
|
|
25086
|
+
}) ?? false
|
|
25087
|
+
};
|
|
25088
|
+
}), STAGE_TIMEOUT_MS) : Promise.resolve(null);
|
|
25089
|
+
const decoderFetch = decoderNodeId ? Promise.resolve({
|
|
25090
|
+
nodeId: decoderNodeId,
|
|
25091
|
+
formats: [],
|
|
25092
|
+
sessionCount: 0,
|
|
25093
|
+
shm: {
|
|
25094
|
+
framesWritten: 0,
|
|
25095
|
+
getFrameHits: 0,
|
|
25096
|
+
getFrameMisses: 0,
|
|
25097
|
+
budgetMb: 0
|
|
25098
|
+
}
|
|
25099
|
+
}) : Promise.resolve(null);
|
|
25100
|
+
const motionResult = (() => {
|
|
25101
|
+
const config = this.cameraConfigs.get(deviceId);
|
|
25102
|
+
if (!config) return null;
|
|
25103
|
+
return {
|
|
25104
|
+
enabled: config.motionSources.includes("analyzer") || config.motionSources.includes("onboard"),
|
|
25105
|
+
fps: config.motionFps
|
|
25106
|
+
};
|
|
25107
|
+
})();
|
|
25108
|
+
const detectionFetch = api && detectionNodeId ? this.boundedStage(Promise.all([api.pipelineExecutor.getEngineProvisioning.query({ nodeId: detectionNodeId }).catch(() => null), api.pipelineExecutor.getSelectedEngine.query({ nodeId: detectionNodeId }).catch(() => null)]).then(async ([provisioning, engine]) => {
|
|
25109
|
+
const metrics = await api.pipelineRunner.getCameraMetrics.query({
|
|
25110
|
+
deviceId,
|
|
25111
|
+
nodeId: detectionNodeId
|
|
25112
|
+
}).catch(() => null);
|
|
25113
|
+
const phase = (() => {
|
|
25114
|
+
const p = metrics?.phase;
|
|
25115
|
+
if (p === "active") return "active";
|
|
25116
|
+
if (p === "idle") return "idle";
|
|
25117
|
+
return "watching";
|
|
25118
|
+
})();
|
|
25119
|
+
return {
|
|
25120
|
+
nodeId: detectionNodeId,
|
|
25121
|
+
engine: {
|
|
25122
|
+
backend: engine?.backend ?? "",
|
|
25123
|
+
device: engine?.device ?? ""
|
|
25124
|
+
},
|
|
25125
|
+
phase,
|
|
25126
|
+
configuredFps: metrics?.configuredFps ?? 0,
|
|
25127
|
+
actualFps: metrics?.actualFps ?? 0,
|
|
25128
|
+
queueDepth: metrics?.queueDepth ?? 0,
|
|
25129
|
+
avgInferenceMs: metrics?.avgInferenceTimeMs ?? 0,
|
|
25130
|
+
provisioning: {
|
|
25131
|
+
state: provisioning?.state ?? "idle",
|
|
25132
|
+
...provisioning?.error !== void 0 ? { error: provisioning.error } : {}
|
|
25133
|
+
}
|
|
25134
|
+
};
|
|
25135
|
+
}), STAGE_TIMEOUT_MS) : Promise.resolve(null);
|
|
25136
|
+
const audioResult = audioNodeId ? {
|
|
25137
|
+
nodeId: audioNodeId,
|
|
25138
|
+
enabled: true
|
|
25139
|
+
} : null;
|
|
25140
|
+
function isRecordingStatus(v) {
|
|
25141
|
+
return v !== null && typeof v === "object" && "activeMode" in v && (v.activeMode === "off" || v.activeMode === "continuous" || v.activeMode === "events") && "enabled" in v && typeof v.enabled === "boolean" && "storageBytes" in v && typeof v.storageBytes === "number";
|
|
25142
|
+
}
|
|
25143
|
+
const recordingFetch = api ? this.boundedStage(api.recording.getStatus.query({ deviceId }).then((rawStatus) => {
|
|
25144
|
+
if (!isRecordingStatus(rawStatus)) return null;
|
|
25145
|
+
return {
|
|
25146
|
+
mode: rawStatus.activeMode,
|
|
25147
|
+
active: rawStatus.enabled && rawStatus.activeMode !== "off",
|
|
25148
|
+
storageBytes: rawStatus.storageBytes
|
|
25149
|
+
};
|
|
25150
|
+
}).catch(() => null), STAGE_TIMEOUT_MS) : Promise.resolve(null);
|
|
25151
|
+
const [sourceResult, brokerResult, decoderResult, detectionResult, recordingResult] = await Promise.all([
|
|
25152
|
+
sourceFetch,
|
|
25153
|
+
brokerFetch,
|
|
25154
|
+
decoderFetch,
|
|
25155
|
+
detectionFetch,
|
|
25156
|
+
recordingFetch
|
|
25157
|
+
]);
|
|
25158
|
+
return composeCameraStatus({
|
|
25159
|
+
deviceId,
|
|
25160
|
+
fetchedAt: Date.now(),
|
|
25161
|
+
detectionNodeId,
|
|
25162
|
+
decoderNodeId,
|
|
25163
|
+
audioNodeId,
|
|
25164
|
+
pinned,
|
|
25165
|
+
reasons,
|
|
25166
|
+
sourceResult,
|
|
25167
|
+
brokerResult,
|
|
25168
|
+
decoderResult,
|
|
25169
|
+
motionResult,
|
|
25170
|
+
detectionResult,
|
|
25171
|
+
audioResult,
|
|
25172
|
+
recordingResult
|
|
25173
|
+
});
|
|
25174
|
+
}
|
|
25175
|
+
/**
|
|
25176
|
+
* Server-composed aggregated status for multiple cameras in one call.
|
|
25177
|
+
*
|
|
25178
|
+
* `deviceIds` defaults to all cameras currently tracked by the
|
|
25179
|
+
* orchestrator's assignment map when omitted.
|
|
25180
|
+
*
|
|
25181
|
+
* v1: `Promise.all` over per-device composition (no concurrency cap).
|
|
25182
|
+
* Note: for large fleets (hundreds of cameras) this may fan out many
|
|
25183
|
+
* parallel calls. A concurrency limiter (p-limit / semaphore) should be
|
|
25184
|
+
* added if latency measurements show it's necessary — deliberately
|
|
25185
|
+
* deferred per the YAGNI constraint in the spec.
|
|
25186
|
+
*/
|
|
25187
|
+
async getCameraStatuses(input) {
|
|
25188
|
+
const ids = input.deviceIds !== void 0 && input.deviceIds.length > 0 ? input.deviceIds : [...this.assignments.keys()];
|
|
25189
|
+
return Promise.all(ids.map((deviceId) => this.getCameraStatus({ deviceId })));
|
|
25190
|
+
}
|
|
24512
25191
|
/** Read the templates map from the addon store via the durable handle. */
|
|
24513
25192
|
async readTemplatesMap() {
|
|
24514
25193
|
const raw = await this.templatesState.get();
|
|
@@ -24539,7 +25218,11 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
24539
25218
|
return;
|
|
24540
25219
|
}
|
|
24541
25220
|
const all = await this.readAgentSettingsMap();
|
|
24542
|
-
all[nodeId]
|
|
25221
|
+
const existing = all[nodeId];
|
|
25222
|
+
all[nodeId] = {
|
|
25223
|
+
addonDefaults: settings.addonDefaults,
|
|
25224
|
+
maxCameras: settings.maxCameras !== void 0 ? settings.maxCameras ?? null : existing?.maxCameras ?? null
|
|
25225
|
+
};
|
|
24543
25226
|
await this.agentSettingsState.set(all);
|
|
24544
25227
|
}
|
|
24545
25228
|
/** Read the `cameraSettings` map (keyed on `deviceId` as string) via the durable handle. */
|
|
@@ -24749,12 +25432,15 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
24749
25432
|
}
|
|
24750
25433
|
let agent = (await this.readAgentSettingsMap())[nodeId];
|
|
24751
25434
|
if (!agent || Object.keys(agent.addonDefaults ?? {}).length === 0) {
|
|
24752
|
-
|
|
24753
|
-
if (!seeded) {
|
|
25435
|
+
if (!await this.seedAgentSettingsFromCatalog(nodeId)) {
|
|
24754
25436
|
await sleep$1(2e3);
|
|
24755
25437
|
continue;
|
|
24756
25438
|
}
|
|
24757
|
-
agent =
|
|
25439
|
+
agent = (await this.readAgentSettingsMap())[nodeId];
|
|
25440
|
+
}
|
|
25441
|
+
if (!agent) {
|
|
25442
|
+
await sleep$1(2e3);
|
|
25443
|
+
continue;
|
|
24758
25444
|
}
|
|
24759
25445
|
const engine = await this.readDetectionPipelineEngine(nodeId) ?? catalog.selectedEngine;
|
|
24760
25446
|
return {
|
|
@@ -25661,7 +26347,8 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
|
|
|
25661
26347
|
};
|
|
25662
26348
|
let dispatchedNodeId = null;
|
|
25663
26349
|
try {
|
|
25664
|
-
|
|
26350
|
+
const result = await this.dispatchCamera(runnerConfig);
|
|
26351
|
+
if (result.kind === "assigned") dispatchedNodeId = result.agentNodeId;
|
|
25665
26352
|
} catch (err) {
|
|
25666
26353
|
const msg = errMsg(err);
|
|
25667
26354
|
log.error("dispatchCamera failed", { meta: { error: msg } });
|