@camstack/addon-export-hap 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.
@@ -4639,63 +4639,7 @@ function _instanceof(cls, params = {}) {
4639
4639
  return inst;
4640
4640
  }
4641
4641
  //#endregion
4642
- //#region ../types/dist/index.mjs
4643
- /**
4644
- * Deep wiring healthcheck — snapshot of active reachability probes across
4645
- * every declared capability + widget of every installed plugin, on every
4646
- * node. Produced by the backend `WiringHealthService` and surfaced via
4647
- * `GET /health/wiring`, the tRPC `health.wiring` query, and the boot-gate.
4648
- *
4649
- * Unlike `/health` (process liveness), this reflects whether each cap/widget
4650
- * is actually *reachable* over the real cap-dispatch path. See spec
4651
- * `docs/superpowers/specs/2026-05-23-deep-healthcheck-design.md`.
4652
- */
4653
- /** What kind of target a probe addressed. */
4654
- var wiringProbeKindSchema = _enum([
4655
- "singleton",
4656
- "device",
4657
- "widget"
4658
- ]);
4659
- /** Result of probing a single (cap|widget [, device]) target. */
4660
- var wiringProbeResultSchema = object({
4661
- capName: string(),
4662
- kind: wiringProbeKindSchema,
4663
- deviceId: number().optional(),
4664
- reachable: boolean(),
4665
- latencyMs: number(),
4666
- error: string().optional()
4667
- });
4668
- /** Per-addon roll-up of cap + widget probe results. */
4669
- var wiringAddonHealthSchema = object({
4670
- addonId: string(),
4671
- caps: array(wiringProbeResultSchema).readonly(),
4672
- widgets: array(wiringProbeResultSchema).readonly()
4673
- });
4674
- /** Per-node roll-up. */
4675
- var wiringNodeHealthSchema = object({
4676
- nodeId: string(),
4677
- addons: array(wiringAddonHealthSchema).readonly()
4678
- });
4679
- object({
4680
- /** True only when every probed target is reachable. */
4681
- ok: boolean(),
4682
- /** True when at least one target is unreachable. */
4683
- degraded: boolean(),
4684
- checkedAt: string(),
4685
- nodes: array(wiringNodeHealthSchema).readonly(),
4686
- summary: object({
4687
- total: number(),
4688
- reachable: number(),
4689
- unreachable: number()
4690
- })
4691
- });
4692
- var MODEL_FORMATS = [
4693
- "onnx",
4694
- "coreml",
4695
- "openvino",
4696
- "tflite",
4697
- "pt"
4698
- ];
4642
+ //#region ../types/dist/sleep-D7JeS58T.mjs
4699
4643
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4700
4644
  EventCategory["SystemBoot"] = "system.boot";
4701
4645
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -4993,6 +4937,18 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
4993
4937
  */
4994
4938
  EventCategory["PipelineEngineMetricsSnapshot"] = "pipeline.engine-metrics-snapshot";
4995
4939
  /**
4940
+ * Per-node detection-engine runtime-provisioning transition. Emitted by
4941
+ * the detection-pipeline provider on every state change of its lazy
4942
+ * engine-provisioning machine (idle → installing → verifying → ready,
4943
+ * or → failed with a `nextRetryAt`). Payload is the
4944
+ * `EngineProvisioningState` snapshot; `event.source.nodeId` carries the
4945
+ * node. The Pipeline page subscribes to drive a live "installing
4946
+ * OpenVINO… / ready" indicator per node without polling
4947
+ * `pipelineExecutor.getEngineProvisioning`. Telemetry-grade (D8): the UI
4948
+ * also reads the cap snapshot on mount / reconnect. Phase 2.
4949
+ */
4950
+ EventCategory["PipelineEngineProvisioning"] = "pipeline.engine-provisioning";
4951
+ /**
4996
4952
  * Cluster topology snapshot. Carries the same payload returned by
4997
4953
  * `nodes.topology` (every reachable node + addons + processes).
4998
4954
  * Emitted by the hub on any agent / addon lifecycle change
@@ -6006,7 +5962,7 @@ var ProfileSlotSchema = object({
6006
5962
  * Zod schema for StreamSourceEntry — the canonical stream descriptor
6007
5963
  * exposed by ICameraDevice.getStreamSources() and consumed by the broker.
6008
5964
  */
6009
- var StreamSourceEntrySchema = object({
5965
+ var StreamSourceEntrySchema$1 = object({
6010
5966
  id: string(),
6011
5967
  label: string(),
6012
5968
  protocol: _enum([
@@ -6228,948 +6184,1134 @@ var ProfileRtspEntrySchema = object({
6228
6184
  codec: string().optional(),
6229
6185
  resolution: CamStreamResolutionSchema.optional()
6230
6186
  });
6231
- /**
6232
- * Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
6233
- * Named `RecordingWeekday` to avoid collision with the string-union
6234
- * `Weekday` exported from `interfaces/timezones.ts`.
6235
- */
6236
- var RecordingWeekdaySchema = number().int().min(0).max(6);
6237
- var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
6238
- var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
6239
- kind: literal("timeOfDay"),
6240
- start: string().regex(HHMM),
6241
- end: string().regex(HHMM),
6242
- /** Restrict to these weekdays; omit = every day. */
6243
- days: array(RecordingWeekdaySchema).optional()
6244
- })]);
6245
- var RecordingModeSchema = _enum([
6246
- "continuous",
6247
- "onMotion",
6248
- "onAudioThreshold"
6249
- ]);
6250
- /**
6251
- * First-class, authoritative per-camera storage mode the netta choice the UI
6252
- * reads directly (never inferred from `rules`):
6253
- * - `off` not recording.
6254
- * - `events` — record only around triggers (motion / audio threshold),
6255
- * with pre/post-buffer.
6256
- * - `continuous` record 24/7 within the schedule.
6257
- *
6258
- * `mode` compiles one-way to the internal `rules[]` consumed by the policy
6259
- * engine (see `compileRules`); `rules[]` is never authored directly anymore.
6260
- */
6261
- var RecordingStorageModeSchema = _enum([
6262
- "off",
6263
- "events",
6264
- "continuous"
6265
- ]);
6266
- /** Which detectors trigger an `events`-mode recording. */
6267
- var RecordingTriggersSchema = object({
6268
- motion: boolean().optional(),
6269
- audioThresholdDbfs: number().optional()
6270
- });
6271
- /**
6272
- * Mode of a single recording band the recorder per-band vocabulary.
6273
- *
6274
- * Distinct from `RecordingStorageModeSchema` (which carries `off`): a band is
6275
- * only ever `continuous` or `events`; "off" is expressed by the absence of a
6276
- * covering band, not by a band value.
6277
- */
6278
- var RecordingBandModeSchema = _enum(["continuous", "events"]);
6279
- /**
6280
- * Triggers for an `events`-mode band. Identical shape to
6281
- * `RecordingTriggersSchema`reuse that schema as the band trigger type so the
6282
- * two never drift.
6283
- */
6284
- var RecordingBandTriggersSchema = RecordingTriggersSchema;
6285
- /**
6286
- * A single mode-per-band window the canonical recorder band shape, the
6287
- * single source of truth re-used by `addon-pipeline/recorder`.
6288
- *
6289
- * `days` lists the weekdays the band covers (empty = every day, matching the
6290
- * band engine's `applies` rule). `start`/`end` are `HH:MM`; an `end <= start`
6291
- * span wraps past midnight (handled by the band engine).
6292
- */
6293
- var RecordingBandSchema = object({
6294
- days: array(RecordingWeekdaySchema),
6295
- start: string().regex(HHMM),
6296
- end: string().regex(HHMM),
6297
- mode: RecordingBandModeSchema,
6298
- triggers: RecordingBandTriggersSchema.optional(),
6299
- preBufferSec: number().min(0).optional(),
6300
- postBufferSec: number().min(0).optional()
6301
- });
6302
- var RecordingRuleSchema = object({
6303
- schedule: RecordingScheduleSchema,
6304
- mode: RecordingModeSchema,
6305
- /** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
6306
- preBufferSec: number().min(0).default(0),
6307
- /** Keep recording until this many seconds after the last trigger. */
6308
- postBufferSec: number().min(0).default(0),
6309
- /** Each new trigger restarts the post-buffer window. */
6310
- resetTimeoutOnNewEvent: boolean().default(true),
6311
- /** onAudioThreshold only dBFS level that counts as a trigger. */
6312
- thresholdDbfs: number().optional()
6313
- });
6314
- /**
6315
- * Per-device retention overrides. Every field is optional; an unset or `0`
6316
- * value inherits the node-wide recorder default. Only footage-lifetime limits
6317
- * live per-camera: `maxAgeDays` and `maxSizeGb`. The disk-occupancy threshold
6318
- * (when the volume is too full to keep recording) is NOT a per-camera concern —
6319
- * it belongs to the StorageLocation (`StorageLocation.config.minFreePercent`),
6320
- * shared by every camera writing to that volume.
6321
- */
6322
- var RecordingRetentionSchema = object({
6323
- maxAgeDays: number().min(0).optional(),
6324
- maxSizeGb: number().min(0).optional()
6325
- });
6326
- /**
6327
- * The full per-camera recording intent — the wire shape of a RecordingTarget.
6328
- *
6329
- * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
6330
- * are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
6331
- * only for transition + migration (`migrateRulesToMode`); the policy engine
6332
- * consumes the compiled output of `compileRules(config)`, never `rules` directly.
6333
- */
6334
- var RecordingConfigSchema = object({
6335
- enabled: boolean(),
6336
- /** Authoritative storage mode. Absent on legacy targets → derived once via
6337
- * `migrateRulesToMode`, then persisted. */
6338
- mode: RecordingStorageModeSchema.optional(),
6339
- profiles: array(CamProfileSchema).optional(),
6340
- segmentSeconds: number().int().positive().optional(),
6341
- /** Shared recording time-bands for `events` & `continuous` — record only when
6342
- * the wall-clock falls inside one of these windows. Omit or empty = always.
6343
- * `continuous` compiles to one rule per band; `events` to band × trigger. */
6344
- schedules: array(RecordingScheduleSchema).optional(),
6345
- /** Legacy single-band predecessor of `schedules`. Read-compat only — it is
6346
- * normalized into `schedules` on read and never written going forward. (Not
6347
- * tagged `@deprecated`: the normalization paths must read it cast-free.) */
6348
- schedule: RecordingScheduleSchema.optional(),
6349
- /** `events`-mode only — which detectors trigger a recording. */
6350
- triggers: RecordingTriggersSchema.optional(),
6351
- /** `events`-mode only — seconds retained before / after a trigger. */
6352
- preBufferSec: number().min(0).optional(),
6353
- postBufferSec: number().min(0).optional(),
6354
- /** DEPRECATED authoring input; retained for migration/transition. */
6355
- rules: array(RecordingRuleSchema).optional(),
6356
- /**
6357
- * AUTHORITATIVE mode-per-band recording model (recorder). When present it
6358
- * is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
6359
- * `triggers`/`rules` fields above are kept for READ-COMPAT only and are
6360
- * derived into bands once via `migrateConfigToBands`.
6361
- */
6362
- bands: array(RecordingBandSchema).optional(),
6363
- retention: RecordingRetentionSchema.optional()
6364
- });
6365
- /**
6366
- * `StorageLocationType` — an addon-declared id that identifies the *kind* of
6367
- * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
6368
- * so the persisted record schema and the consumer-facing cap can both consume it
6369
- * without forming a circular import. The `storage` cap re-exports it
6370
- * verbatim for back-compat.
6371
- *
6372
- * This Zod schema is the **authoritative source** for `StorageLocationType`.
6373
- * The TS alias in `./storage.ts` re-exports `z.infer<typeof
6374
- * StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
6375
- * `IStorageProvider` interface stay in lockstep.
6376
- *
6377
- * The type is now an **open string** (not a closed enum) — addons declare
6378
- * their own location kinds via `StorageLocationDeclaration.id`. The regex
6379
- * enforces a safe id format: lowercase-start, alphanumeric + hyphens.
6380
- */
6381
- var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
6382
- /**
6383
- * Persisted record for a storage location instance. Operators can register
6384
- * multiple instances for multi-cardinality types (e.g. two `backups`
6385
- * locations with different `providerId`s). Cardinality is now declared per
6386
- * location via `StorageLocationDeclaration.cardinality` — the static
6387
- * `STORAGE_LOCATION_CARDINALITY` map has been removed.
6388
- *
6389
- * `id` is a stable namespaced string of the form `<type>:<slug>`.
6390
- * The default location for a type uses `id === <type>:default` by
6391
- * convention (the bare type ref like `'backups'` resolves to it).
6392
- *
6393
- * `isSystem: true` marks a location as orchestrator-seeded and
6394
- * undeletable. The bootstrap-installed defaults (one per type) carry
6395
- * this flag; operator-added locations don't. Editing the config of
6396
- * a system location is allowed (path migration, provider swap) but
6397
- * deleting it is rejected at the cap level.
6398
- */
6399
- var StorageLocationSchema = object({
6400
- id: string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
6401
- type: string(),
6402
- displayName: string().min(1),
6403
- providerId: string().min(1),
6404
- config: record(string(), unknown()),
6405
- /**
6406
- * Cluster node this location physically lives on. REQUIRED for node-local
6407
- * providers (filesystem — the path exists on one node's disk), null/absent
6408
- * for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
6409
- * `'hub'` is the hub node. Validated against the provider's `nodeLocal`
6410
- * flag at upsert time, not here (the schema is provider-agnostic).
6411
- */
6412
- nodeId: string().optional(),
6413
- isDefault: boolean().default(false),
6414
- isSystem: boolean().default(false),
6415
- createdAt: number(),
6416
- updatedAt: number()
6417
- });
6418
- /**
6419
- * Reference accepted by consumer-facing `api.storage.*` calls.
6420
- * Either:
6421
- * - a `StorageLocationType` (e.g. `'backups'`) → orchestrator resolves to the default of that type
6422
- * - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
6423
- *
6424
- * The orchestrator's `resolveRef(ref)` handles both cases.
6425
- */
6426
- var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
6427
- /**
6428
- * `StorageLocationDeclaration` — a single storage-location entry declared by
6429
- * an addon in its `package.json` under `camstack.storageLocations`.
6430
- *
6431
- * Design intent:
6432
- * - **Addon declares its needs** — each addon describes the logical storage
6433
- * slots it requires (e.g. `recordings`, `recordingsLow`) without caring
6434
- * about the physical path.
6435
- * - **Kernel aggregates** — at boot the kernel collects declarations from all
6436
- * installed addons, deduplicates by `id`, and exposes the union via the
6437
- * storage-locations settings surface.
6438
- * - **Orchestrator seeds** — for every declared `id` the orchestrator ensures
6439
- * at least one instance named `<id>:default` is present, using
6440
- * `defaultsTo` to inherit the resolved root from another location when the
6441
- * declaration is a derivative slot (e.g. `recordingsLow` defaults to
6442
- * `recordings`).
6443
- * - **ids are global** — `id` values are shared across the entire deployment;
6444
- * two addons declaring the same `id` must agree on `cardinality` (validated
6445
- * at kernel aggregation time, not here).
6446
- */
6447
- var StorageLocationDeclarationSchema = object({
6448
- /**
6449
- * Global location identifier, e.g. `recordings` or `recordingsLow`.
6450
- * Must start with a lowercase letter and may contain letters, digits, and
6451
- * hyphens.
6452
- */
6453
- id: string().regex(/^[a-z][a-zA-Z0-9-]*$/, { message: "id must start with a lowercase letter and contain only letters, digits, or hyphens" }),
6454
- /** Human-readable name shown in the admin UI. */
6455
- displayName: string().min(1, { message: "displayName must not be empty" }),
6456
- /** Optional longer explanation of what data this location stores. */
6457
- description: string().optional(),
6458
- /**
6459
- * `single` — exactly one instance of this location is allowed system-wide
6460
- * (e.g. `logs`, `models`). The operator can edit it but not add more.
6461
- * `multi` — the operator may register several instances (e.g. a second
6462
- * `recordings` on a NAS for disk tiering); one is the default at any time.
6463
- */
6464
- cardinality: _enum(["single", "multi"]),
6465
- /**
6466
- * When set, the default instance for this location inherits its resolved
6467
- * root from the named location's default instance. Useful for derivative
6468
- * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
6469
- * configure the primary location.
6470
- */
6471
- defaultsTo: string().optional()
6472
- });
6473
- var DecoderStatsSchema = object({
6474
- inputFps: number(),
6475
- outputFps: number(),
6476
- avgDecodeTimeMs: number(),
6477
- droppedFrames: number()
6478
- });
6479
- var DecoderSessionConfigSchema = object({
6480
- codec: string(),
6481
- maxFps: number().default(0),
6482
- outputFormat: _enum([
6483
- "jpeg",
6484
- "rgb",
6485
- "bgr",
6486
- "yuv420",
6487
- "gray"
6488
- ]).default("jpeg"),
6489
- scale: number().default(1),
6490
- width: number().optional(),
6491
- height: number().optional(),
6187
+ var DeviceType = /* @__PURE__ */ function(DeviceType) {
6188
+ DeviceType["Camera"] = "camera";
6189
+ DeviceType["Hub"] = "hub";
6190
+ DeviceType["Light"] = "light";
6191
+ DeviceType["Siren"] = "siren";
6192
+ DeviceType["Switch"] = "switch";
6193
+ DeviceType["Sensor"] = "sensor";
6194
+ DeviceType["Thermostat"] = "thermostat";
6195
+ DeviceType["Button"] = "button";
6196
+ /** Generic stateless event emitter — carries a device's EXACT declared
6197
+ * event vocabulary verbatim (no normalization). Installed with the
6198
+ * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
6199
+ * HA bus events (e.g. `zha_event`, generic). */
6200
+ DeviceType["EventEmitter"] = "event-emitter";
6201
+ /** Firmware/software update entity — current vs available version,
6202
+ * updatable flag, update state, and an install action. Installed with
6203
+ * the `update` cap. Sources: Homematic firmware-update channels (and
6204
+ * reusable by other providers, e.g. HA `update.*` entities). */
6205
+ DeviceType["Update"] = "update";
6206
+ DeviceType["Generic"] = "generic";
6207
+ /** Generic notification delivery target (HA `notify.<service>`, future
6208
+ * Telegram / Discord / ntfy / SMTP, …). One device per delivery
6209
+ * endpoint; the `notifier` cap defines the send surface. */
6210
+ DeviceType["Notifier"] = "notifier";
6211
+ /** Pre-recorded action sequence with optional parameters
6212
+ * (HA `script.*`). Runnable via `script-runner` cap. */
6213
+ DeviceType["Script"] = "script";
6214
+ /** Automation rule (HA `automation.*`) enable/disable + manual
6215
+ * trigger surface exposed via `automation-control` cap. */
6216
+ DeviceType["Automation"] = "automation";
6217
+ /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
6218
+ DeviceType["Lock"] = "lock";
6219
+ /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
6220
+ * `valve.*`). `cover` cap with sub-roles for variant. */
6221
+ DeviceType["Cover"] = "cover";
6222
+ /** Pipe / water / gas valve with open/close/stop and optional
6223
+ * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
6224
+ * modelled on the same open/closed lifecycle. */
6225
+ DeviceType["Valve"] = "valve";
6226
+ /** Humidifier / dehumidifier with on/off + target humidity + mode
6227
+ * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
6228
+ * modelled on the same target / mode lifecycle. */
6229
+ DeviceType["Humidifier"] = "humidifier";
6230
+ /** Water heater / boiler with target temperature + operation mode +
6231
+ * away mode (HA `water_heater.*`). `water-heater` cap a
6232
+ * climate-family actuator. */
6233
+ DeviceType["WaterHeater"] = "water-heater";
6234
+ /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
6235
+ DeviceType["Fan"] = "fan";
6236
+ /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
6237
+ * the camera surface those use `Camera`. `media-player` cap. */
6238
+ DeviceType["MediaPlayer"] = "media-player";
6239
+ /** Security panel / alarm system (HA `alarm_control_panel.*`).
6240
+ * `alarm-panel` cap. */
6241
+ DeviceType["AlarmPanel"] = "alarm-panel";
6242
+ /** Generic user-settable input (HA `number` / `input_number` / `select`
6243
+ * / `input_select` / `text` / `input_text` / `input_datetime`).
6244
+ * Sub-type via `DeviceRole`: NumericControl / SelectControl /
6245
+ * TextControl / DateTimeControl. */
6246
+ DeviceType["Control"] = "control";
6247
+ /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
6248
+ * `presence` cap. */
6249
+ DeviceType["Presence"] = "presence";
6250
+ /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
6251
+ * `weather` cap. */
6252
+ DeviceType["Weather"] = "weather";
6253
+ /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
6254
+ DeviceType["Vacuum"] = "vacuum";
6255
+ /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
6256
+ * `lawn-mower-control` cap. */
6257
+ DeviceType["LawnMower"] = "lawn-mower";
6258
+ /** Physical HA device group — parent container for entity-children
6259
+ * adopted from a single HA device entry. Not renderable as a
6260
+ * standalone device; exists only to anchor child entities. */
6261
+ DeviceType["Container"] = "container";
6262
+ /** Single still-image entity (HA `image.*`). Read-only display of an
6263
+ * `entity_picture` signed URL the browser loads directly. `image` cap. */
6264
+ DeviceType["Image"] = "image";
6265
+ return DeviceType;
6266
+ }({});
6267
+ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
6268
+ DeviceFeature["BatteryOperated"] = "battery-operated";
6269
+ DeviceFeature["Rebootable"] = "rebootable";
6492
6270
  /**
6493
- * Identifier of the camera this decoder session serves. Optional
6494
- * because the cap is generic (any caller could request decode), but
6495
- * stream-broker passes it so decoder logs include `deviceId` for
6496
- * per-camera filtering when diagnosing failures (e.g. node-av
6497
- * sendPacket errors on a single hung camera).
6271
+ * Device supports an on-demand re-sync of its derived spec with its
6272
+ * upstream source drives the generic Re-sync button. The owning
6273
+ * provider implements the action via the `device-adoption.resync` cap.
6498
6274
  */
6499
- deviceId: number().int().nonnegative().optional(),
6275
+ DeviceFeature["Resyncable"] = "resyncable";
6276
+ DeviceFeature["NativeSnapshot"] = "native-snapshot";
6277
+ DeviceFeature["DoorbellButton"] = "doorbell-button";
6278
+ DeviceFeature["TwoWayAudio"] = "two-way-audio";
6279
+ DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
6500
6280
  /**
6501
- * Free-form tag for log scoping. Stream-broker uses
6502
- * `broker:<deviceId>/<profile>`. Decoder session logger surfaces it
6503
- * on every line so `grep tag=broker:5/high` filters one camera
6504
- * profile cleanly.
6281
+ * Camera supports the on-firmware autotrack subsystem (subject-
6282
+ * following). Distinct from `PanTiltZoom` because not every PTZ
6283
+ * camera ships autotrack the admin UI uses this flag to gate
6284
+ * the autotrack toggle / settings card without re-deriving from
6285
+ * the cap registry. Mirrors `ptz-autotrack` cap registration:
6286
+ * driver sets this feature when probe confirms the firmware
6287
+ * surface, and registers the cap in the same code path.
6505
6288
  */
6506
- tag: string().optional(),
6289
+ DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
6507
6290
  /**
6508
- * Where the session delivers decoded frames (Phase 5 / D9):
6291
+ * Accessory exposes a "trigger on motion" toggle the parent camera's
6292
+ * motion detection automatically activates this device. Mirrors
6293
+ * `motion-trigger` cap registration: drivers set this feature in the
6294
+ * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
6509
6295
  *
6510
- * - `'callback'` (default) the legacy pixel path: decoded frames are
6511
- * buffered as `DecodedFrame`s and drained via `pullFrames`.
6512
- * - `'shm'` the shared-memory frame plane: decoded frames are written
6513
- * into an OS shared-memory ring and drained as zero-pixel
6514
- * `FrameHandle`s via `pullHandles`. A session is one mode or the
6515
- * other — `pullFrames` returns nothing for an `'shm'` session and
6516
- * `pullHandles` returns nothing for a `'callback'` session.
6517
- */
6518
- frameSink: _enum(["callback", "shm"]).default("callback")
6519
- });
6520
- var EncodeProfileSchema = object({
6521
- video: object({
6522
- codec: _enum([
6523
- "h264",
6524
- "h265",
6525
- "copy"
6526
- ]),
6527
- profile: _enum([
6528
- "baseline",
6529
- "main",
6530
- "high"
6531
- ]).optional(),
6532
- width: number().int().positive().optional(),
6533
- height: number().int().positive().optional(),
6534
- fps: number().positive().optional(),
6535
- bitrateKbps: number().int().positive().optional(),
6536
- gopFrames: number().int().positive().optional(),
6537
- bf: number().int().min(0).optional(),
6538
- preset: _enum([
6539
- "ultrafast",
6540
- "superfast",
6541
- "veryfast",
6542
- "faster",
6543
- "fast",
6544
- "medium"
6545
- ]).optional(),
6546
- tune: _enum([
6547
- "zerolatency",
6548
- "film",
6549
- "animation"
6550
- ]).optional()
6551
- }),
6552
- audio: union([literal("passthrough"), object({
6553
- codec: _enum([
6554
- "opus",
6555
- "aac",
6556
- "pcmu",
6557
- "pcma",
6558
- "copy"
6559
- ]),
6560
- bitrateKbps: number().int().positive().optional(),
6561
- sampleRateHz: number().int().positive().optional(),
6562
- channels: union([literal(1), literal(2)]).optional()
6563
- })]),
6564
- /**
6565
- * ffmpeg input-side args, inserted between the fixed global flags
6566
- * (`-hide_banner -loglevel error`) and `-i pipe:0`. Free-text array
6567
- * — the widget surfaces a textarea + suggestion chips for the most-
6568
- * used demuxer/format options.
6569
- */
6570
- inputArgs: array(string()).optional(),
6571
- /**
6572
- * ffmpeg output-side args, inserted between the encode block and
6573
- * the final `-f <muxer> pipe:1`. Use for muxer options, bitstream
6574
- * filters, codec-specific overrides. Free-text array.
6296
+ * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
6297
+ * fast scalar without binding fetch), notifier rules, and `listAll`
6298
+ * filters that want "all devices with on-motion behaviour".
6575
6299
  */
6576
- outputArgs: array(string()).optional()
6577
- });
6578
- function pickPreferredRtspEntry(entries, pref, deviceId, options = {}) {
6579
- if (entries.length === 0) return null;
6580
- const prefix = `${deviceId}/`;
6581
- const toPicked = (e) => ({
6582
- brokerId: e.brokerId,
6583
- profileId: e.brokerId.startsWith(prefix) ? e.brokerId.slice(prefix.length) : e.brokerId,
6584
- url: e.url,
6585
- mutedUrl: e.mutedUrl,
6586
- enabled: e.enabled,
6587
- ...e.codec !== void 0 ? { codec: e.codec } : {},
6588
- ...e.resolution !== void 0 ? { resolution: e.resolution } : {}
6589
- });
6590
- if (pref !== "auto") {
6591
- const match = entries.find((e) => e.enabled && e.url.length > 0 && (e.profile === pref || e.brokerId === `${prefix}${pref}`));
6592
- if (match) return toPicked(match);
6593
- }
6594
- const eligible = entries.filter((e) => e.enabled && e.url.length > 0);
6595
- if (eligible.length === 0) return null;
6596
- const target = options.targetResolution;
6597
- if (target) {
6598
- const withRes = eligible.filter((e) => e.resolution !== void 0);
6599
- if (withRes.length > 0) {
6600
- const picked = pickClosestResolution(withRes, target);
6601
- if (picked) return toPicked(picked);
6602
- }
6603
- }
6604
- return toPicked(eligible[0]);
6605
- }
6300
+ DeviceFeature["MotionTrigger"] = "motion-trigger";
6301
+ /** Light supports rgb-triplet color via `color` cap. */
6302
+ DeviceFeature["LightColorRgb"] = "light-color-rgb";
6303
+ /** Light supports HSV color via `color` cap. */
6304
+ DeviceFeature["LightColorHsv"] = "light-color-hsv";
6305
+ /** Light supports color-temperature (mired) via `color` cap. */
6306
+ DeviceFeature["LightColorMired"] = "light-color-mired";
6307
+ /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
6308
+ * targetHigh). Gates the range slider UI. */
6309
+ DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
6310
+ /** Thermostat exposes target humidity and/or current humidity
6311
+ * readings. Gates the humidity controls. */
6312
+ DeviceFeature["ClimateHumidity"] = "climate-humidity";
6313
+ /** Thermostat exposes a fan-mode selector. */
6314
+ DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
6315
+ /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
6316
+ DeviceFeature["ClimatePreset"] = "climate-preset";
6317
+ /** Cover exposes intermediate position control (0..100). Gates the
6318
+ * position slider UI. */
6319
+ DeviceFeature["CoverPositionable"] = "cover-positionable";
6320
+ /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
6321
+ DeviceFeature["CoverTilt"] = "cover-tilt";
6322
+ /** Valve exposes intermediate position control (0..100). Gates the
6323
+ * position slider / drag surface UI. */
6324
+ DeviceFeature["ValvePositionable"] = "valve-positionable";
6325
+ /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
6326
+ DeviceFeature["FanSpeed"] = "fan-speed";
6327
+ /** Fan exposes a preset mode selector. */
6328
+ DeviceFeature["FanPreset"] = "fan-preset";
6329
+ /** Fan exposes blade direction (forward/reverse) — typical of
6330
+ * ceiling fans. */
6331
+ DeviceFeature["FanDirection"] = "fan-direction";
6332
+ /** Fan exposes an oscillation toggle. */
6333
+ DeviceFeature["FanOscillating"] = "fan-oscillating";
6334
+ /** Lock requires a PIN code on lock/unlock. Gates the code-entry
6335
+ * field on the UI lock-controls panel. */
6336
+ DeviceFeature["LockPinRequired"] = "lock-pin-required";
6337
+ /** Lock supports a latch-release ("open door") action distinct from
6338
+ * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
6339
+ * `supported_features`. Gates the Open Door button in the UI. */
6340
+ DeviceFeature["LockOpen"] = "lock-open";
6341
+ /** Media player exposes a seek-to-position surface. */
6342
+ DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
6343
+ /** Media player exposes a volume-level setter. */
6344
+ DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
6345
+ /** Media player exposes a mute toggle distinct from volume=0. */
6346
+ DeviceFeature["MediaPlayerMute"] = "media-player-mute";
6347
+ /** Media player exposes a shuffle toggle. */
6348
+ DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
6349
+ /** Media player exposes a repeat mode (off / all / one). */
6350
+ DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
6351
+ /** Media player exposes a source / input selector. */
6352
+ DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
6353
+ /** Media player exposes a play-arbitrary-media surface (URL / id). */
6354
+ DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
6355
+ /** Media player exposes next-track. */
6356
+ DeviceFeature["MediaPlayerNext"] = "media-player-next";
6357
+ /** Media player exposes previous-track. */
6358
+ DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
6359
+ /** Media player exposes stop distinct from pause. */
6360
+ DeviceFeature["MediaPlayerStop"] = "media-player-stop";
6361
+ /** Alarm panel requires a PIN code on arm/disarm. */
6362
+ DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
6363
+ /** Presence device carries GPS coordinates (lat/lng/accuracy) in
6364
+ * addition to a textual location. */
6365
+ DeviceFeature["PresenceGps"] = "presence-gps";
6366
+ /** Notifier accepts an inline / URL image attachment. */
6367
+ DeviceFeature["NotifierImage"] = "notifier-image";
6368
+ /** Notifier accepts a priority hint (high/normal/low). */
6369
+ DeviceFeature["NotifierPriority"] = "notifier-priority";
6370
+ /** Notifier accepts a free-form `data` payload for platform-specific
6371
+ * fields. */
6372
+ DeviceFeature["NotifierData"] = "notifier-data";
6373
+ /** Notifier supports interactive action buttons / callbacks. */
6374
+ DeviceFeature["NotifierActions"] = "notifier-actions";
6375
+ /** Notifier supports per-call recipient targeting (multi-user). */
6376
+ DeviceFeature["NotifierRecipients"] = "notifier-recipients";
6377
+ /** Script runner accepts a variables map on each run invocation. */
6378
+ DeviceFeature["ScriptVariables"] = "script-variables";
6379
+ /** Automation `trigger` accepts a skipCondition flag — fires the
6380
+ * automation's actions while bypassing its condition block. */
6381
+ DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
6382
+ return DeviceFeature;
6383
+ }({});
6606
6384
  /**
6607
- * Pick the entry whose `resolution` is closest to `target`. Prefer
6608
- * entries target (downscale is cheap at the consumer; upscale is
6609
- * lossy). Among the rest pick the LARGEST still ≤ target so the
6610
- * consumer gets the best feasible quality. "Closeness" is the
6611
- * `width × height` pixel delta.
6385
+ * Semantic role a device plays within its parent. Populated by driver
6386
+ * addons when creating accessory devices (Reolink siren/floodlight/
6387
+ * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
6388
+ * admin UI to pick icons, labels, and widgets — a `Switch` with
6389
+ * `role: Floodlight` renders as a bulb with a brightness slider,
6390
+ * whereas a `Switch` with `role: Siren` renders as a klaxon.
6391
+ *
6392
+ * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
6393
+ * sqlite as a nullable TEXT column — old rows keep working unchanged.
6612
6394
  */
6613
- function pickClosestResolution(entries, target) {
6614
- const targetPixels = target.width * target.height;
6615
- let bestAbove;
6616
- let bestBelow;
6617
- for (const e of entries) {
6618
- if (e.resolution === void 0) continue;
6619
- const pixels = e.resolution.width * e.resolution.height;
6620
- if (pixels >= targetPixels) {
6621
- if (!bestAbove || pixels < bestAbove.pixels) bestAbove = {
6622
- entry: e,
6623
- pixels
6624
- };
6625
- } else if (!bestBelow || pixels > bestBelow.pixels) bestBelow = {
6626
- entry: e,
6627
- pixels
6628
- };
6629
- }
6630
- return bestAbove?.entry ?? bestBelow?.entry;
6631
- }
6632
- var YAMNET_TO_MACRO = {
6633
- mapping: {
6634
- Speech: "speech",
6635
- "Child speech, kid speaking": "speech",
6636
- Conversation: "speech",
6637
- "Narration, monologue": "speech",
6638
- Babbling: "speech",
6639
- Whispering: "speech",
6640
- "Speech synthesizer": "speech",
6641
- Humming: "speech",
6642
- Rapping: "speech",
6643
- Singing: "speech",
6644
- Choir: "speech",
6645
- "Child singing": "speech",
6646
- Shout: "scream",
6647
- Bellow: "scream",
6648
- Yell: "scream",
6649
- Screaming: "scream",
6650
- "Children shouting": "scream",
6651
- Whoop: "scream",
6652
- "Crying, sobbing": "crying",
6653
- "Baby cry, infant cry": "crying",
6654
- Whimper: "crying",
6655
- "Wail, moan": "crying",
6656
- Groan: "crying",
6657
- Laughter: "laughter",
6658
- "Baby laughter": "laughter",
6659
- Giggle: "laughter",
6660
- Snicker: "laughter",
6661
- "Belly laugh": "laughter",
6662
- "Chuckle, chortle": "laughter",
6663
- Music: "music",
6664
- "Musical instrument": "music",
6665
- Guitar: "music",
6666
- Piano: "music",
6667
- Drum: "music",
6668
- "Drum kit": "music",
6669
- "Violin, fiddle": "music",
6670
- Flute: "music",
6671
- Saxophone: "music",
6672
- Trumpet: "music",
6673
- Synthesizer: "music",
6674
- "Pop music": "music",
6675
- "Rock music": "music",
6676
- "Hip hop music": "music",
6677
- "Classical music": "music",
6678
- Jazz: "music",
6679
- "Electronic music": "music",
6680
- "Background music": "music",
6681
- Dog: "dog",
6682
- Bark: "dog",
6683
- Yip: "dog",
6684
- Howl: "dog",
6685
- "Bow-wow": "dog",
6686
- Growling: "dog",
6687
- "Whimper (dog)": "dog",
6688
- Cat: "cat",
6689
- Purr: "cat",
6690
- Meow: "cat",
6691
- Hiss: "cat",
6692
- Caterwaul: "cat",
6693
- Bird: "bird",
6694
- "Bird vocalization, bird call, bird song": "bird",
6695
- "Chirp, tweet": "bird",
6696
- Squawk: "bird",
6697
- Crow: "bird",
6698
- Owl: "bird",
6699
- "Pigeon, dove": "bird",
6700
- Animal: "animal",
6701
- "Domestic animals, pets": "animal",
6702
- "Livestock, farm animals, working animals": "animal",
6703
- Horse: "animal",
6704
- "Cattle, bovinae": "animal",
6705
- Pig: "animal",
6706
- Sheep: "animal",
6707
- Goat: "animal",
6708
- Frog: "animal",
6709
- Insect: "animal",
6710
- Cricket: "animal",
6711
- Alarm: "alarm",
6712
- "Alarm clock": "alarm",
6713
- "Smoke detector, smoke alarm": "alarm",
6714
- "Fire alarm": "alarm",
6715
- Buzzer: "alarm",
6716
- "Civil defense siren": "alarm",
6717
- "Car alarm": "alarm",
6718
- Siren: "siren",
6719
- "Police car (siren)": "siren",
6720
- "Ambulance (siren)": "siren",
6721
- "Fire engine, fire truck (siren)": "siren",
6722
- "Emergency vehicle": "siren",
6723
- Foghorn: "siren",
6724
- Doorbell: "doorbell",
6725
- "Ding-dong": "doorbell",
6726
- Knock: "doorbell",
6727
- Tap: "doorbell",
6728
- Glass: "glass_breaking",
6729
- Shatter: "glass_breaking",
6730
- "Chink, clink": "glass_breaking",
6731
- "Gunshot, gunfire": "gunshot",
6732
- "Machine gun": "gunshot",
6733
- Explosion: "gunshot",
6734
- Fireworks: "gunshot",
6735
- Firecracker: "gunshot",
6736
- "Artillery fire": "gunshot",
6737
- "Cap gun": "gunshot",
6738
- Boom: "gunshot",
6739
- Vehicle: "vehicle",
6740
- Car: "vehicle",
6741
- Truck: "vehicle",
6742
- Bus: "vehicle",
6743
- Motorcycle: "vehicle",
6744
- "Car passing by": "vehicle",
6745
- "Vehicle horn, car horn, honking": "vehicle",
6746
- "Traffic noise, roadway noise": "vehicle",
6747
- Train: "vehicle",
6748
- Aircraft: "vehicle",
6749
- Helicopter: "vehicle",
6750
- Bicycle: "vehicle",
6751
- Skateboard: "vehicle",
6752
- Fire: "fire",
6753
- Crackle: "fire",
6754
- Water: "water",
6755
- Rain: "water",
6756
- Raindrop: "water",
6757
- "Rain on surface": "water",
6758
- Stream: "water",
6759
- Waterfall: "water",
6760
- Ocean: "water",
6761
- "Waves, surf": "water",
6762
- "Splash, splatter": "water",
6763
- Wind: "wind",
6764
- Thunderstorm: "wind",
6765
- Thunder: "wind",
6766
- "Wind noise (microphone)": "wind",
6767
- "Rustling leaves": "wind",
6768
- Door: "door",
6769
- "Sliding door": "door",
6770
- Slam: "door",
6771
- "Cupboard open or close": "door",
6772
- "Walk, footsteps": "footsteps",
6773
- Run: "footsteps",
6774
- Shuffle: "footsteps",
6775
- Crowd: "crowd",
6776
- Chatter: "crowd",
6777
- Cheering: "crowd",
6778
- Applause: "crowd",
6779
- "Children playing": "crowd",
6780
- "Hubbub, speech noise, speech babble": "crowd",
6781
- Telephone: "telephone",
6782
- "Telephone bell ringing": "telephone",
6783
- Ringtone: "telephone",
6784
- "Telephone dialing, DTMF": "telephone",
6785
- "Busy signal": "telephone",
6786
- Engine: "engine",
6787
- "Engine starting": "engine",
6788
- Idling: "engine",
6789
- "Accelerating, revving, vroom": "engine",
6790
- "Light engine (high frequency)": "engine",
6791
- "Medium engine (mid frequency)": "engine",
6792
- "Heavy engine (low frequency)": "engine",
6793
- "Lawn mower": "engine",
6794
- Chainsaw: "engine",
6795
- Hammer: "tools",
6796
- Jackhammer: "tools",
6797
- Sawing: "tools",
6798
- "Power tool": "tools",
6799
- Drill: "tools",
6800
- Sanding: "tools",
6801
- Silence: "silence"
6802
- },
6803
- preserveOriginal: false
6804
- };
6805
- var APPLE_SA_TO_MACRO = {
6806
- mapping: {
6807
- speech: "speech",
6808
- child_speech: "speech",
6809
- conversation: "speech",
6810
- whispering: "speech",
6811
- singing: "speech",
6812
- humming: "speech",
6813
- shout: "scream",
6814
- yell: "scream",
6815
- screaming: "scream",
6816
- crying: "crying",
6817
- baby_crying: "crying",
6818
- sobbing: "crying",
6819
- laughter: "laughter",
6820
- baby_laughter: "laughter",
6821
- giggling: "laughter",
6822
- music: "music",
6823
- guitar: "music",
6824
- piano: "music",
6825
- drums: "music",
6826
- dog_bark: "dog",
6827
- dog_bow_wow: "dog",
6828
- dog_growling: "dog",
6829
- dog_howl: "dog",
6830
- cat_meow: "cat",
6831
- cat_purr: "cat",
6832
- cat_hiss: "cat",
6833
- bird: "bird",
6834
- bird_chirp: "bird",
6835
- bird_squawk: "bird",
6836
- animal: "animal",
6837
- horse: "animal",
6838
- cow_moo: "animal",
6839
- insect: "animal",
6840
- alarm: "alarm",
6841
- smoke_alarm: "alarm",
6842
- fire_alarm: "alarm",
6843
- car_alarm: "alarm",
6844
- siren: "siren",
6845
- police_siren: "siren",
6846
- ambulance_siren: "siren",
6847
- doorbell: "doorbell",
6848
- door_knock: "doorbell",
6849
- knocking: "doorbell",
6850
- glass_breaking: "glass_breaking",
6851
- glass_shatter: "glass_breaking",
6852
- gunshot: "gunshot",
6853
- explosion: "gunshot",
6854
- fireworks: "gunshot",
6855
- car: "vehicle",
6856
- truck: "vehicle",
6857
- motorcycle: "vehicle",
6858
- car_horn: "vehicle",
6859
- vehicle_horn: "vehicle",
6860
- traffic: "vehicle",
6861
- fire: "fire",
6862
- fire_crackle: "fire",
6863
- water: "water",
6864
- rain: "water",
6865
- ocean: "water",
6866
- splash: "water",
6867
- wind: "wind",
6868
- thunder: "wind",
6869
- thunderstorm: "wind",
6870
- door: "door",
6871
- door_slam: "door",
6872
- sliding_door: "door",
6873
- footsteps: "footsteps",
6874
- walking: "footsteps",
6875
- running: "footsteps",
6876
- crowd: "crowd",
6877
- chatter: "crowd",
6878
- cheering: "crowd",
6879
- applause: "crowd",
6880
- telephone_ring: "telephone",
6881
- ringtone: "telephone",
6882
- engine: "engine",
6883
- engine_starting: "engine",
6884
- lawn_mower: "engine",
6885
- chainsaw: "engine",
6886
- hammer: "tools",
6887
- jackhammer: "tools",
6888
- drill: "tools",
6889
- power_tool: "tools",
6890
- silence: "silence"
6891
- },
6892
- preserveOriginal: false
6893
- };
6894
- var _macroLookup = /* @__PURE__ */ new Map();
6895
- for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
6896
- for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
6897
- var DeviceType = /* @__PURE__ */ function(DeviceType) {
6898
- DeviceType["Camera"] = "camera";
6899
- DeviceType["Hub"] = "hub";
6900
- DeviceType["Light"] = "light";
6901
- DeviceType["Siren"] = "siren";
6902
- DeviceType["Switch"] = "switch";
6903
- DeviceType["Sensor"] = "sensor";
6904
- DeviceType["Thermostat"] = "thermostat";
6905
- DeviceType["Button"] = "button";
6906
- /** Generic stateless event emitter — carries a device's EXACT declared
6907
- * event vocabulary verbatim (no normalization). Installed with the
6908
- * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
6909
- * HA bus events (e.g. `zha_event`, generic). */
6910
- DeviceType["EventEmitter"] = "event-emitter";
6911
- /** Firmware/software update entity — current vs available version,
6912
- * updatable flag, update state, and an install action. Installed with
6913
- * the `update` cap. Sources: Homematic firmware-update channels (and
6914
- * reusable by other providers, e.g. HA `update.*` entities). */
6915
- DeviceType["Update"] = "update";
6916
- DeviceType["Generic"] = "generic";
6917
- /** Generic notification delivery target (HA `notify.<service>`, future
6918
- * Telegram / Discord / ntfy / SMTP, …). One device per delivery
6919
- * endpoint; the `notifier` cap defines the send surface. */
6920
- DeviceType["Notifier"] = "notifier";
6921
- /** Pre-recorded action sequence with optional parameters
6922
- * (HA `script.*`). Runnable via `script-runner` cap. */
6923
- DeviceType["Script"] = "script";
6924
- /** Automation rule (HA `automation.*`) — enable/disable + manual
6925
- * trigger surface exposed via `automation-control` cap. */
6926
- DeviceType["Automation"] = "automation";
6927
- /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
6928
- DeviceType["Lock"] = "lock";
6929
- /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
6930
- * `valve.*`). `cover` cap with sub-roles for variant. */
6931
- DeviceType["Cover"] = "cover";
6932
- /** Pipe / water / gas valve with open/close/stop and optional
6933
- * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
6934
- * modelled on the same open/closed lifecycle. */
6935
- DeviceType["Valve"] = "valve";
6936
- /** Humidifier / dehumidifier with on/off + target humidity + mode
6937
- * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
6938
- * modelled on the same target / mode lifecycle. */
6939
- DeviceType["Humidifier"] = "humidifier";
6940
- /** Water heater / boiler with target temperature + operation mode +
6941
- * away mode (HA `water_heater.*`). `water-heater` cap — a
6942
- * climate-family actuator. */
6943
- DeviceType["WaterHeater"] = "water-heater";
6944
- /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
6945
- DeviceType["Fan"] = "fan";
6946
- /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
6947
- * the camera surface — those use `Camera`. `media-player` cap. */
6948
- DeviceType["MediaPlayer"] = "media-player";
6949
- /** Security panel / alarm system (HA `alarm_control_panel.*`).
6950
- * `alarm-panel` cap. */
6951
- DeviceType["AlarmPanel"] = "alarm-panel";
6952
- /** Generic user-settable input (HA `number` / `input_number` / `select`
6953
- * / `input_select` / `text` / `input_text` / `input_datetime`).
6954
- * Sub-type via `DeviceRole`: NumericControl / SelectControl /
6955
- * TextControl / DateTimeControl. */
6956
- DeviceType["Control"] = "control";
6957
- /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
6958
- * `presence` cap. */
6959
- DeviceType["Presence"] = "presence";
6960
- /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
6961
- * `weather` cap. */
6962
- DeviceType["Weather"] = "weather";
6963
- /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
6964
- DeviceType["Vacuum"] = "vacuum";
6965
- /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
6966
- * `lawn-mower-control` cap. */
6967
- DeviceType["LawnMower"] = "lawn-mower";
6968
- /** Physical HA device group — parent container for entity-children
6969
- * adopted from a single HA device entry. Not renderable as a
6970
- * standalone device; exists only to anchor child entities. */
6971
- DeviceType["Container"] = "container";
6972
- /** Single still-image entity (HA `image.*`). Read-only display of an
6973
- * `entity_picture` signed URL the browser loads directly. `image` cap. */
6974
- DeviceType["Image"] = "image";
6975
- return DeviceType;
6395
+ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
6396
+ DeviceRole["Siren"] = "siren";
6397
+ DeviceRole["Floodlight"] = "floodlight";
6398
+ DeviceRole["Spotlight"] = "spotlight";
6399
+ DeviceRole["PirSensor"] = "pir-sensor";
6400
+ DeviceRole["Chime"] = "chime";
6401
+ DeviceRole["Autotrack"] = "autotrack";
6402
+ DeviceRole["Nightvision"] = "nightvision";
6403
+ DeviceRole["PrivacyMask"] = "privacy-mask";
6404
+ DeviceRole["Doorbell"] = "doorbell";
6405
+ /** Virtual HA toggle (input_boolean.*) — distinguishable from a
6406
+ * real Switch device for UI rendering / export adapters. */
6407
+ DeviceRole["BinaryHelper"] = "binary-helper";
6408
+ /** Generic motion / occupancy / moving event source. Distinct from
6409
+ * the camera accessory PirSensor role: that one is a camera child;
6410
+ * this is a standalone HA / 3rd-party motion sensor. */
6411
+ DeviceRole["MotionSensor"] = "motion-sensor";
6412
+ DeviceRole["ContactSensor"] = "contact-sensor";
6413
+ DeviceRole["LeakSensor"] = "leak-sensor";
6414
+ DeviceRole["SmokeSensor"] = "smoke-sensor";
6415
+ DeviceRole["COSensor"] = "co-sensor";
6416
+ DeviceRole["GasSensor"] = "gas-sensor";
6417
+ DeviceRole["TamperSensor"] = "tamper-sensor";
6418
+ DeviceRole["VibrationSensor"] = "vibration-sensor";
6419
+ DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
6420
+ DeviceRole["SoundSensor"] = "sound-sensor";
6421
+ /** Fallback for `binary_sensor` without a known `device_class`. */
6422
+ DeviceRole["BinarySensor"] = "binary-sensor";
6423
+ DeviceRole["TemperatureSensor"] = "temperature-sensor";
6424
+ DeviceRole["HumiditySensor"] = "humidity-sensor";
6425
+ DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
6426
+ DeviceRole["PressureSensor"] = "pressure-sensor";
6427
+ DeviceRole["PowerSensor"] = "power-sensor";
6428
+ DeviceRole["EnergySensor"] = "energy-sensor";
6429
+ DeviceRole["VoltageSensor"] = "voltage-sensor";
6430
+ DeviceRole["CurrentSensor"] = "current-sensor";
6431
+ DeviceRole["AirQualitySensor"] = "air-quality-sensor";
6432
+ /** Battery level (numeric % via `sensor` OR low-bool via
6433
+ * `binary_sensor` — the cap distinguishes via the value type). */
6434
+ DeviceRole["BatterySensor"] = "battery-sensor";
6435
+ /** Fallback for `sensor` numeric without a known `device_class`. */
6436
+ DeviceRole["NumericSensor"] = "numeric-sensor";
6437
+ /** String / enum state (HA `sensor` with `state_class: enum` or
6438
+ * `attributes.options`). */
6439
+ DeviceRole["EnumSensor"] = "enum-sensor";
6440
+ /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
6441
+ * or `date`). The slice carries the raw ISO string verbatim (hosted on
6442
+ * the `enum-sensor` cap); the UI renders it locale-formatted. */
6443
+ DeviceRole["DateTimeSensor"] = "datetime-sensor";
6444
+ /** Last-resort fallback when nothing else matches. */
6445
+ DeviceRole["GenericSensor"] = "generic-sensor";
6446
+ DeviceRole["NumericControl"] = "numeric-control";
6447
+ DeviceRole["SelectControl"] = "select-control";
6448
+ DeviceRole["TextControl"] = "text-control";
6449
+ DeviceRole["DateTimeControl"] = "datetime-control";
6450
+ /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
6451
+ * rich features (image, priority, channel routing). */
6452
+ DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
6453
+ /** Chat / messaging service (HA `notify.telegram_*`,
6454
+ * `notify.discord_*`, etc.). */
6455
+ DeviceRole["MessagingNotifier"] = "messaging-notifier";
6456
+ /** Email-based delivery (HA `notify.smtp`, etc.). */
6457
+ DeviceRole["EmailNotifier"] = "email-notifier";
6458
+ /** Fallback when the notifier service name doesn't match a known
6459
+ * pattern. */
6460
+ DeviceRole["GenericNotifier"] = "generic-notifier";
6461
+ return DeviceRole;
6976
6462
  }({});
6977
- var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
6978
- DeviceFeature["BatteryOperated"] = "battery-operated";
6979
- DeviceFeature["Rebootable"] = "rebootable";
6463
+ /**
6464
+ * Generic types for capability definitions.
6465
+ *
6466
+ * A capability is defined with Zod schemas for methods, events, and settings.
6467
+ * TypeScript types are inferred via z.infer<> — zero duplication.
6468
+ *
6469
+ * Pattern:
6470
+ * 1. Define Zod schemas for data, methods, settings
6471
+ * 2. Export const capabilityDef = { ... } satisfies CapabilityDefinition
6472
+ * 3. Export type IProvider = InferProvider<typeof capabilityDef>
6473
+ * 4. Addon implements IProvider
6474
+ * 5. Registry auto-mounts tRPC router from definition.methods
6475
+ */
6476
+ /**
6477
+ * Output schema shared by the contribution + live methods.
6478
+ *
6479
+ * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
6480
+ * tabs[]) without importing from `../interfaces/config-ui.js` — a
6481
+ * concrete-but-lenient Zod object keeps tRPC output inference happy
6482
+ * (using `z.unknown()` here collapses unrelated router branches to
6483
+ * `unknown` when the generator re-inlines the huge AppRouter type).
6484
+ *
6485
+ * `.passthrough()` on sections/fields accepts whatever FormBuilder
6486
+ * extensions the caller adds (showWhen, displayScale, …) without
6487
+ * rebuilding every time a new field kind is introduced.
6488
+ */
6489
+ var ContributionSectionSchema = object({
6490
+ id: string(),
6491
+ title: string(),
6492
+ description: string().optional(),
6493
+ style: _enum(["card", "accordion"]).optional(),
6494
+ defaultCollapsed: boolean().optional(),
6495
+ columns: union([
6496
+ literal(1),
6497
+ literal(2),
6498
+ literal(3),
6499
+ literal(4)
6500
+ ]).optional(),
6501
+ tab: string().optional(),
6502
+ location: _enum(["settings", "top-tab"]).optional(),
6503
+ order: number().optional(),
6504
+ fields: array(any())
6505
+ });
6506
+ object({
6507
+ tabs: array(object({
6508
+ id: string(),
6509
+ label: string(),
6510
+ icon: string(),
6511
+ order: number().optional()
6512
+ })).optional(),
6513
+ sections: array(ContributionSectionSchema)
6514
+ }).nullable();
6515
+ object({ deviceId: number() }), object({ deviceId: number() }), object({
6516
+ deviceId: number(),
6517
+ patch: record(string(), unknown())
6518
+ }), object({ success: literal(true) });
6519
+ object({ deviceId: number() }), unknown().nullable();
6520
+ /** Shorthand to define a method schema */
6521
+ function method(input, output, options) {
6522
+ return {
6523
+ input,
6524
+ output,
6525
+ kind: options?.kind ?? "query",
6526
+ auth: options?.auth ?? "protected",
6527
+ ...options?.access !== void 0 ? { access: options.access } : {},
6528
+ timeoutMs: options?.timeoutMs
6529
+ };
6530
+ }
6531
+ var StaticDirOutputSchema = object({ staticDir: string() });
6532
+ var VersionOutputSchema = object({ version: string() });
6533
+ method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
6534
+ /**
6535
+ * device-ops — device-scoped cap that unifies the per-IDevice operations
6536
+ * previously routed through the `.device-ops` Moleculer bridge service.
6537
+ *
6538
+ * Each worker that hosts live `IDevice` instances auto-registers a native
6539
+ * provider for this cap (per device) backed by its local
6540
+ * `DeviceRegistry`. Hub-side callers reach it transparently through
6541
+ * `ctx.fetchDevice(id).deviceOps.*` — the DeviceProxy injects
6542
+ * `deviceId` + `nodeId` and dispatches through the standard cap-router,
6543
+ * so there's no parallel bridge path anymore.
6544
+ *
6545
+ * The surface is intentionally small — every method corresponds to a
6546
+ * single action on the live `IDevice` (or `ICameraDevice` for
6547
+ * `getStreamSources`). Richer orchestration (enable/disable with
6548
+ * integration plumbing, bulk updates) stays in the `device-manager` cap;
6549
+ * `device-ops` is the per-device primitive the device-manager routes to.
6550
+ */
6551
+ var StreamSourceEntrySchema = object({
6552
+ id: string(),
6553
+ label: string(),
6554
+ protocol: _enum([
6555
+ "rtsp",
6556
+ "rtmp",
6557
+ "annexb",
6558
+ "http-mjpeg",
6559
+ "webrtc",
6560
+ "custom"
6561
+ ]),
6562
+ url: string().optional(),
6563
+ resolution: object({
6564
+ width: number(),
6565
+ height: number()
6566
+ }).optional(),
6567
+ fps: number().optional(),
6568
+ bitrate: number().optional(),
6569
+ codec: string().optional(),
6570
+ profileHint: CamProfileSchema.optional(),
6571
+ sdp: string().optional()
6572
+ });
6573
+ var ConfigEntrySchema$1 = object({
6574
+ key: string(),
6575
+ value: unknown()
6576
+ });
6577
+ var RawStateResultSchema = object({
6578
+ /** Originating provider id, e.g. 'homeassistant' | 'reolink' | 'hikvision'. */
6579
+ source: string(),
6580
+ /** Opaque, DISPLAY-SAFE upstream blob (no secrets/PII). */
6581
+ data: record(string(), unknown())
6582
+ });
6583
+ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
6584
+ deviceId: number(),
6585
+ values: record(string(), unknown())
6586
+ }), _void(), { kind: "mutation" }), method(object({
6587
+ deviceId: number(),
6588
+ action: string().min(1),
6589
+ input: unknown()
6590
+ }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
6591
+ //#endregion
6592
+ //#region ../types/dist/index.mjs
6593
+ /**
6594
+ * Deep wiring healthcheck — snapshot of active reachability probes across
6595
+ * every declared capability + widget of every installed plugin, on every
6596
+ * node. Produced by the backend `WiringHealthService` and surfaced via
6597
+ * `GET /health/wiring`, the tRPC `health.wiring` query, and the boot-gate.
6598
+ *
6599
+ * Unlike `/health` (process liveness), this reflects whether each cap/widget
6600
+ * is actually *reachable* over the real cap-dispatch path. See spec
6601
+ * `docs/superpowers/specs/2026-05-23-deep-healthcheck-design.md`.
6602
+ */
6603
+ /** What kind of target a probe addressed. */
6604
+ var wiringProbeKindSchema = _enum([
6605
+ "singleton",
6606
+ "device",
6607
+ "widget"
6608
+ ]);
6609
+ /** Result of probing a single (cap|widget [, device]) target. */
6610
+ var wiringProbeResultSchema = object({
6611
+ capName: string(),
6612
+ kind: wiringProbeKindSchema,
6613
+ deviceId: number().optional(),
6614
+ reachable: boolean(),
6615
+ latencyMs: number(),
6616
+ error: string().optional()
6617
+ });
6618
+ /** Per-addon roll-up of cap + widget probe results. */
6619
+ var wiringAddonHealthSchema = object({
6620
+ addonId: string(),
6621
+ caps: array(wiringProbeResultSchema).readonly(),
6622
+ widgets: array(wiringProbeResultSchema).readonly()
6623
+ });
6624
+ /** Per-node roll-up. */
6625
+ var wiringNodeHealthSchema = object({
6626
+ nodeId: string(),
6627
+ addons: array(wiringAddonHealthSchema).readonly()
6628
+ });
6629
+ object({
6630
+ /** True only when every probed target is reachable. */
6631
+ ok: boolean(),
6632
+ /** True when at least one target is unreachable. */
6633
+ degraded: boolean(),
6634
+ checkedAt: string(),
6635
+ nodes: array(wiringNodeHealthSchema).readonly(),
6636
+ summary: object({
6637
+ total: number(),
6638
+ reachable: number(),
6639
+ unreachable: number()
6640
+ })
6641
+ });
6642
+ var MODEL_FORMATS = [
6643
+ "onnx",
6644
+ "coreml",
6645
+ "openvino",
6646
+ "tflite",
6647
+ "pt"
6648
+ ];
6649
+ /**
6650
+ * Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
6651
+ * Named `RecordingWeekday` to avoid collision with the string-union
6652
+ * `Weekday` exported from `interfaces/timezones.ts`.
6653
+ */
6654
+ var RecordingWeekdaySchema = number().int().min(0).max(6);
6655
+ var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
6656
+ var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
6657
+ kind: literal("timeOfDay"),
6658
+ start: string().regex(HHMM),
6659
+ end: string().regex(HHMM),
6660
+ /** Restrict to these weekdays; omit = every day. */
6661
+ days: array(RecordingWeekdaySchema).optional()
6662
+ })]);
6663
+ var RecordingModeSchema = _enum([
6664
+ "continuous",
6665
+ "onMotion",
6666
+ "onAudioThreshold"
6667
+ ]);
6668
+ /**
6669
+ * First-class, authoritative per-camera storage mode — the netta choice the UI
6670
+ * reads directly (never inferred from `rules`):
6671
+ * - `off` — not recording.
6672
+ * - `events` — record only around triggers (motion / audio threshold),
6673
+ * with pre/post-buffer.
6674
+ * - `continuous` — record 24/7 within the schedule.
6675
+ *
6676
+ * `mode` compiles one-way to the internal `rules[]` consumed by the policy
6677
+ * engine (see `compileRules`); `rules[]` is never authored directly anymore.
6678
+ */
6679
+ var RecordingStorageModeSchema = _enum([
6680
+ "off",
6681
+ "events",
6682
+ "continuous"
6683
+ ]);
6684
+ /** Which detectors trigger an `events`-mode recording. */
6685
+ var RecordingTriggersSchema = object({
6686
+ motion: boolean().optional(),
6687
+ audioThresholdDbfs: number().optional()
6688
+ });
6689
+ /**
6690
+ * Mode of a single recording band — the recorder per-band vocabulary.
6691
+ *
6692
+ * Distinct from `RecordingStorageModeSchema` (which carries `off`): a band is
6693
+ * only ever `continuous` or `events`; "off" is expressed by the absence of a
6694
+ * covering band, not by a band value.
6695
+ */
6696
+ var RecordingBandModeSchema = _enum(["continuous", "events"]);
6697
+ /**
6698
+ * Triggers for an `events`-mode band. Identical shape to
6699
+ * `RecordingTriggersSchema` — reuse that schema as the band trigger type so the
6700
+ * two never drift.
6701
+ */
6702
+ var RecordingBandTriggersSchema = RecordingTriggersSchema;
6703
+ /**
6704
+ * A single mode-per-band window — the canonical recorder band shape, the
6705
+ * single source of truth re-used by `addon-pipeline/recorder`.
6706
+ *
6707
+ * `days` lists the weekdays the band covers (empty = every day, matching the
6708
+ * band engine's `applies` rule). `start`/`end` are `HH:MM`; an `end <= start`
6709
+ * span wraps past midnight (handled by the band engine).
6710
+ */
6711
+ var RecordingBandSchema = object({
6712
+ days: array(RecordingWeekdaySchema),
6713
+ start: string().regex(HHMM),
6714
+ end: string().regex(HHMM),
6715
+ mode: RecordingBandModeSchema,
6716
+ triggers: RecordingBandTriggersSchema.optional(),
6717
+ preBufferSec: number().min(0).optional(),
6718
+ postBufferSec: number().min(0).optional()
6719
+ });
6720
+ var RecordingRuleSchema = object({
6721
+ schedule: RecordingScheduleSchema,
6722
+ mode: RecordingModeSchema,
6723
+ /** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
6724
+ preBufferSec: number().min(0).default(0),
6725
+ /** Keep recording until this many seconds after the last trigger. */
6726
+ postBufferSec: number().min(0).default(0),
6727
+ /** Each new trigger restarts the post-buffer window. */
6728
+ resetTimeoutOnNewEvent: boolean().default(true),
6729
+ /** onAudioThreshold only — dBFS level that counts as a trigger. */
6730
+ thresholdDbfs: number().optional()
6731
+ });
6732
+ /**
6733
+ * Per-device retention overrides. Every field is optional; an unset or `0`
6734
+ * value inherits the node-wide recorder default. Only footage-lifetime limits
6735
+ * live per-camera: `maxAgeDays` and `maxSizeGb`. The disk-occupancy threshold
6736
+ * (when the volume is too full to keep recording) is NOT a per-camera concern —
6737
+ * it belongs to the StorageLocation (`StorageLocation.config.minFreePercent`),
6738
+ * shared by every camera writing to that volume.
6739
+ */
6740
+ var RecordingRetentionSchema = object({
6741
+ maxAgeDays: number().min(0).optional(),
6742
+ maxSizeGb: number().min(0).optional()
6743
+ });
6744
+ /**
6745
+ * The full per-camera recording intent — the wire shape of a RecordingTarget.
6746
+ *
6747
+ * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
6748
+ * are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
6749
+ * only for transition + migration (`migrateRulesToMode`); the policy engine
6750
+ * consumes the compiled output of `compileRules(config)`, never `rules` directly.
6751
+ */
6752
+ var RecordingConfigSchema = object({
6753
+ enabled: boolean(),
6754
+ /** Authoritative storage mode. Absent on legacy targets → derived once via
6755
+ * `migrateRulesToMode`, then persisted. */
6756
+ mode: RecordingStorageModeSchema.optional(),
6757
+ profiles: array(CamProfileSchema).optional(),
6758
+ segmentSeconds: number().int().positive().optional(),
6759
+ /** Shared recording time-bands for `events` & `continuous` — record only when
6760
+ * the wall-clock falls inside one of these windows. Omit or empty = always.
6761
+ * `continuous` compiles to one rule per band; `events` to band × trigger. */
6762
+ schedules: array(RecordingScheduleSchema).optional(),
6763
+ /** Legacy single-band predecessor of `schedules`. Read-compat only — it is
6764
+ * normalized into `schedules` on read and never written going forward. (Not
6765
+ * tagged `@deprecated`: the normalization paths must read it cast-free.) */
6766
+ schedule: RecordingScheduleSchema.optional(),
6767
+ /** `events`-mode only — which detectors trigger a recording. */
6768
+ triggers: RecordingTriggersSchema.optional(),
6769
+ /** `events`-mode only — seconds retained before / after a trigger. */
6770
+ preBufferSec: number().min(0).optional(),
6771
+ postBufferSec: number().min(0).optional(),
6772
+ /** DEPRECATED authoring input; retained for migration/transition. */
6773
+ rules: array(RecordingRuleSchema).optional(),
6980
6774
  /**
6981
- * Device supports an on-demand re-sync of its derived spec with its
6982
- * upstream source drives the generic Re-sync button. The owning
6983
- * provider implements the action via the `device-adoption.resync` cap.
6775
+ * AUTHORITATIVE mode-per-band recording model (recorder). When present it
6776
+ * is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
6777
+ * `triggers`/`rules` fields above are kept for READ-COMPAT only and are
6778
+ * derived into bands once via `migrateConfigToBands`.
6984
6779
  */
6985
- DeviceFeature["Resyncable"] = "resyncable";
6986
- DeviceFeature["NativeSnapshot"] = "native-snapshot";
6987
- DeviceFeature["DoorbellButton"] = "doorbell-button";
6988
- DeviceFeature["TwoWayAudio"] = "two-way-audio";
6989
- DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
6780
+ bands: array(RecordingBandSchema).optional(),
6781
+ retention: RecordingRetentionSchema.optional()
6782
+ });
6783
+ /**
6784
+ * `StorageLocationType` — an addon-declared id that identifies the *kind* of
6785
+ * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
6786
+ * so the persisted record schema and the consumer-facing cap can both consume it
6787
+ * without forming a circular import. The `storage` cap re-exports it
6788
+ * verbatim for back-compat.
6789
+ *
6790
+ * This Zod schema is the **authoritative source** for `StorageLocationType`.
6791
+ * The TS alias in `./storage.ts` re-exports `z.infer<typeof
6792
+ * StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
6793
+ * `IStorageProvider` interface stay in lockstep.
6794
+ *
6795
+ * The type is now an **open string** (not a closed enum) — addons declare
6796
+ * their own location kinds via `StorageLocationDeclaration.id`. The regex
6797
+ * enforces a safe id format: lowercase-start, alphanumeric + hyphens.
6798
+ */
6799
+ var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
6800
+ /**
6801
+ * Persisted record for a storage location instance. Operators can register
6802
+ * multiple instances for multi-cardinality types (e.g. two `backups`
6803
+ * locations with different `providerId`s). Cardinality is now declared per
6804
+ * location via `StorageLocationDeclaration.cardinality` — the static
6805
+ * `STORAGE_LOCATION_CARDINALITY` map has been removed.
6806
+ *
6807
+ * `id` is a stable namespaced string of the form `<type>:<slug>`.
6808
+ * The default location for a type uses `id === <type>:default` by
6809
+ * convention (the bare type ref like `'backups'` resolves to it).
6810
+ *
6811
+ * `isSystem: true` marks a location as orchestrator-seeded and
6812
+ * undeletable. The bootstrap-installed defaults (one per type) carry
6813
+ * this flag; operator-added locations don't. Editing the config of
6814
+ * a system location is allowed (path migration, provider swap) but
6815
+ * deleting it is rejected at the cap level.
6816
+ */
6817
+ var StorageLocationSchema = object({
6818
+ id: string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
6819
+ type: string(),
6820
+ displayName: string().min(1),
6821
+ providerId: string().min(1),
6822
+ config: record(string(), unknown()),
6823
+ /**
6824
+ * Cluster node this location physically lives on. REQUIRED for node-local
6825
+ * providers (filesystem — the path exists on one node's disk), null/absent
6826
+ * for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
6827
+ * `'hub'` is the hub node. Validated against the provider's `nodeLocal`
6828
+ * flag at upsert time, not here (the schema is provider-agnostic).
6829
+ */
6830
+ nodeId: string().optional(),
6831
+ isDefault: boolean().default(false),
6832
+ isSystem: boolean().default(false),
6833
+ createdAt: number(),
6834
+ updatedAt: number()
6835
+ });
6836
+ /**
6837
+ * Reference accepted by consumer-facing `api.storage.*` calls.
6838
+ * Either:
6839
+ * - a `StorageLocationType` (e.g. `'backups'`) → orchestrator resolves to the default of that type
6840
+ * - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
6841
+ *
6842
+ * The orchestrator's `resolveRef(ref)` handles both cases.
6843
+ */
6844
+ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
6845
+ /**
6846
+ * `StorageLocationDeclaration` — a single storage-location entry declared by
6847
+ * an addon in its `package.json` under `camstack.storageLocations`.
6848
+ *
6849
+ * Design intent:
6850
+ * - **Addon declares its needs** — each addon describes the logical storage
6851
+ * slots it requires (e.g. `recordings`, `recordingsLow`) without caring
6852
+ * about the physical path.
6853
+ * - **Kernel aggregates** — at boot the kernel collects declarations from all
6854
+ * installed addons, deduplicates by `id`, and exposes the union via the
6855
+ * storage-locations settings surface.
6856
+ * - **Orchestrator seeds** — for every declared `id` the orchestrator ensures
6857
+ * at least one instance named `<id>:default` is present, using
6858
+ * `defaultsTo` to inherit the resolved root from another location when the
6859
+ * declaration is a derivative slot (e.g. `recordingsLow` defaults to
6860
+ * `recordings`).
6861
+ * - **ids are global** — `id` values are shared across the entire deployment;
6862
+ * two addons declaring the same `id` must agree on `cardinality` (validated
6863
+ * at kernel aggregation time, not here).
6864
+ */
6865
+ var StorageLocationDeclarationSchema = object({
6866
+ /**
6867
+ * Global location identifier, e.g. `recordings` or `recordingsLow`.
6868
+ * Must start with a lowercase letter and may contain letters, digits, and
6869
+ * hyphens.
6870
+ */
6871
+ id: string().regex(/^[a-z][a-zA-Z0-9-]*$/, { message: "id must start with a lowercase letter and contain only letters, digits, or hyphens" }),
6872
+ /** Human-readable name shown in the admin UI. */
6873
+ displayName: string().min(1, { message: "displayName must not be empty" }),
6874
+ /** Optional longer explanation of what data this location stores. */
6875
+ description: string().optional(),
6876
+ /**
6877
+ * `single` — exactly one instance of this location is allowed system-wide
6878
+ * (e.g. `logs`, `models`). The operator can edit it but not add more.
6879
+ * `multi` — the operator may register several instances (e.g. a second
6880
+ * `recordings` on a NAS for disk tiering); one is the default at any time.
6881
+ */
6882
+ cardinality: _enum(["single", "multi"]),
6883
+ /**
6884
+ * When set, the default instance for this location inherits its resolved
6885
+ * root from the named location's default instance. Useful for derivative
6886
+ * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
6887
+ * configure the primary location.
6888
+ */
6889
+ defaultsTo: string().optional()
6890
+ });
6891
+ var DecoderStatsSchema = object({
6892
+ inputFps: number(),
6893
+ outputFps: number(),
6894
+ avgDecodeTimeMs: number(),
6895
+ droppedFrames: number()
6896
+ });
6897
+ var DecoderSessionConfigSchema = object({
6898
+ codec: string(),
6899
+ maxFps: number().default(0),
6900
+ outputFormat: _enum([
6901
+ "jpeg",
6902
+ "rgb",
6903
+ "bgr",
6904
+ "yuv420",
6905
+ "gray"
6906
+ ]).default("jpeg"),
6907
+ scale: number().default(1),
6908
+ width: number().optional(),
6909
+ height: number().optional(),
6910
+ /**
6911
+ * Identifier of the camera this decoder session serves. Optional
6912
+ * because the cap is generic (any caller could request decode), but
6913
+ * stream-broker passes it so decoder logs include `deviceId` for
6914
+ * per-camera filtering when diagnosing failures (e.g. node-av
6915
+ * sendPacket errors on a single hung camera).
6916
+ */
6917
+ deviceId: number().int().nonnegative().optional(),
6918
+ /**
6919
+ * Free-form tag for log scoping. Stream-broker uses
6920
+ * `broker:<deviceId>/<profile>`. Decoder session logger surfaces it
6921
+ * on every line so `grep tag=broker:5/high` filters one camera
6922
+ * profile cleanly.
6923
+ */
6924
+ tag: string().optional(),
6925
+ /**
6926
+ * Where the session delivers decoded frames (Phase 5 / D9):
6927
+ *
6928
+ * - `'callback'` (default) — the legacy pixel path: decoded frames are
6929
+ * buffered as `DecodedFrame`s and drained via `pullFrames`.
6930
+ * - `'shm'` — the shared-memory frame plane: decoded frames are written
6931
+ * into an OS shared-memory ring and drained as zero-pixel
6932
+ * `FrameHandle`s via `pullHandles`. A session is one mode or the
6933
+ * other — `pullFrames` returns nothing for an `'shm'` session and
6934
+ * `pullHandles` returns nothing for a `'callback'` session.
6935
+ */
6936
+ frameSink: _enum(["callback", "shm"]).default("callback")
6937
+ });
6938
+ var EncodeProfileSchema = object({
6939
+ video: object({
6940
+ codec: _enum([
6941
+ "h264",
6942
+ "h265",
6943
+ "copy"
6944
+ ]),
6945
+ profile: _enum([
6946
+ "baseline",
6947
+ "main",
6948
+ "high"
6949
+ ]).optional(),
6950
+ width: number().int().positive().optional(),
6951
+ height: number().int().positive().optional(),
6952
+ fps: number().positive().optional(),
6953
+ bitrateKbps: number().int().positive().optional(),
6954
+ gopFrames: number().int().positive().optional(),
6955
+ bf: number().int().min(0).optional(),
6956
+ preset: _enum([
6957
+ "ultrafast",
6958
+ "superfast",
6959
+ "veryfast",
6960
+ "faster",
6961
+ "fast",
6962
+ "medium"
6963
+ ]).optional(),
6964
+ tune: _enum([
6965
+ "zerolatency",
6966
+ "film",
6967
+ "animation"
6968
+ ]).optional()
6969
+ }),
6970
+ audio: union([literal("passthrough"), object({
6971
+ codec: _enum([
6972
+ "opus",
6973
+ "aac",
6974
+ "pcmu",
6975
+ "pcma",
6976
+ "copy"
6977
+ ]),
6978
+ bitrateKbps: number().int().positive().optional(),
6979
+ sampleRateHz: number().int().positive().optional(),
6980
+ channels: union([literal(1), literal(2)]).optional()
6981
+ })]),
6990
6982
  /**
6991
- * Camera supports the on-firmware autotrack subsystem (subject-
6992
- * following). Distinct from `PanTiltZoom` because not every PTZ
6993
- * camera ships autotrack the admin UI uses this flag to gate
6994
- * the autotrack toggle / settings card without re-deriving from
6995
- * the cap registry. Mirrors `ptz-autotrack` cap registration:
6996
- * driver sets this feature when probe confirms the firmware
6997
- * surface, and registers the cap in the same code path.
6983
+ * ffmpeg input-side args, inserted between the fixed global flags
6984
+ * (`-hide_banner -loglevel error`) and `-i pipe:0`. Free-text array
6985
+ * the widget surfaces a textarea + suggestion chips for the most-
6986
+ * used demuxer/format options.
6998
6987
  */
6999
- DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
6988
+ inputArgs: array(string()).optional(),
7000
6989
  /**
7001
- * Accessory exposes a "trigger on motion" toggle the parent camera's
7002
- * motion detection automatically activates this device. Mirrors
7003
- * `motion-trigger` cap registration: drivers set this feature in the
7004
- * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
7005
- *
7006
- * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
7007
- * fast scalar without binding fetch), notifier rules, and `listAll`
7008
- * filters that want "all devices with on-motion behaviour".
6990
+ * ffmpeg output-side args, inserted between the encode block and
6991
+ * the final `-f <muxer> pipe:1`. Use for muxer options, bitstream
6992
+ * filters, codec-specific overrides. Free-text array.
7009
6993
  */
7010
- DeviceFeature["MotionTrigger"] = "motion-trigger";
7011
- /** Light supports rgb-triplet color via `color` cap. */
7012
- DeviceFeature["LightColorRgb"] = "light-color-rgb";
7013
- /** Light supports HSV color via `color` cap. */
7014
- DeviceFeature["LightColorHsv"] = "light-color-hsv";
7015
- /** Light supports color-temperature (mired) via `color` cap. */
7016
- DeviceFeature["LightColorMired"] = "light-color-mired";
7017
- /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
7018
- * targetHigh). Gates the range slider UI. */
7019
- DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
7020
- /** Thermostat exposes target humidity and/or current humidity
7021
- * readings. Gates the humidity controls. */
7022
- DeviceFeature["ClimateHumidity"] = "climate-humidity";
7023
- /** Thermostat exposes a fan-mode selector. */
7024
- DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
7025
- /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
7026
- DeviceFeature["ClimatePreset"] = "climate-preset";
7027
- /** Cover exposes intermediate position control (0..100). Gates the
7028
- * position slider UI. */
7029
- DeviceFeature["CoverPositionable"] = "cover-positionable";
7030
- /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
7031
- DeviceFeature["CoverTilt"] = "cover-tilt";
7032
- /** Valve exposes intermediate position control (0..100). Gates the
7033
- * position slider / drag surface UI. */
7034
- DeviceFeature["ValvePositionable"] = "valve-positionable";
7035
- /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
7036
- DeviceFeature["FanSpeed"] = "fan-speed";
7037
- /** Fan exposes a preset mode selector. */
7038
- DeviceFeature["FanPreset"] = "fan-preset";
7039
- /** Fan exposes blade direction (forward/reverse) — typical of
7040
- * ceiling fans. */
7041
- DeviceFeature["FanDirection"] = "fan-direction";
7042
- /** Fan exposes an oscillation toggle. */
7043
- DeviceFeature["FanOscillating"] = "fan-oscillating";
7044
- /** Lock requires a PIN code on lock/unlock. Gates the code-entry
7045
- * field on the UI lock-controls panel. */
7046
- DeviceFeature["LockPinRequired"] = "lock-pin-required";
7047
- /** Lock supports a latch-release ("open door") action distinct from
7048
- * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
7049
- * `supported_features`. Gates the Open Door button in the UI. */
7050
- DeviceFeature["LockOpen"] = "lock-open";
7051
- /** Media player exposes a seek-to-position surface. */
7052
- DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
7053
- /** Media player exposes a volume-level setter. */
7054
- DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
7055
- /** Media player exposes a mute toggle distinct from volume=0. */
7056
- DeviceFeature["MediaPlayerMute"] = "media-player-mute";
7057
- /** Media player exposes a shuffle toggle. */
7058
- DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
7059
- /** Media player exposes a repeat mode (off / all / one). */
7060
- DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
7061
- /** Media player exposes a source / input selector. */
7062
- DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
7063
- /** Media player exposes a play-arbitrary-media surface (URL / id). */
7064
- DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
7065
- /** Media player exposes next-track. */
7066
- DeviceFeature["MediaPlayerNext"] = "media-player-next";
7067
- /** Media player exposes previous-track. */
7068
- DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
7069
- /** Media player exposes stop distinct from pause. */
7070
- DeviceFeature["MediaPlayerStop"] = "media-player-stop";
7071
- /** Alarm panel requires a PIN code on arm/disarm. */
7072
- DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
7073
- /** Presence device carries GPS coordinates (lat/lng/accuracy) in
7074
- * addition to a textual location. */
7075
- DeviceFeature["PresenceGps"] = "presence-gps";
7076
- /** Notifier accepts an inline / URL image attachment. */
7077
- DeviceFeature["NotifierImage"] = "notifier-image";
7078
- /** Notifier accepts a priority hint (high/normal/low). */
7079
- DeviceFeature["NotifierPriority"] = "notifier-priority";
7080
- /** Notifier accepts a free-form `data` payload for platform-specific
7081
- * fields. */
7082
- DeviceFeature["NotifierData"] = "notifier-data";
7083
- /** Notifier supports interactive action buttons / callbacks. */
7084
- DeviceFeature["NotifierActions"] = "notifier-actions";
7085
- /** Notifier supports per-call recipient targeting (multi-user). */
7086
- DeviceFeature["NotifierRecipients"] = "notifier-recipients";
7087
- /** Script runner accepts a variables map on each run invocation. */
7088
- DeviceFeature["ScriptVariables"] = "script-variables";
7089
- /** Automation `trigger` accepts a skipCondition flag — fires the
7090
- * automation's actions while bypassing its condition block. */
7091
- DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
7092
- return DeviceFeature;
7093
- }({});
6994
+ outputArgs: array(string()).optional()
6995
+ });
6996
+ function pickPreferredRtspEntry(entries, pref, deviceId, options = {}) {
6997
+ if (entries.length === 0) return null;
6998
+ const prefix = `${deviceId}/`;
6999
+ const toPicked = (e) => ({
7000
+ brokerId: e.brokerId,
7001
+ profileId: e.brokerId.startsWith(prefix) ? e.brokerId.slice(prefix.length) : e.brokerId,
7002
+ url: e.url,
7003
+ mutedUrl: e.mutedUrl,
7004
+ enabled: e.enabled,
7005
+ ...e.codec !== void 0 ? { codec: e.codec } : {},
7006
+ ...e.resolution !== void 0 ? { resolution: e.resolution } : {}
7007
+ });
7008
+ if (pref !== "auto") {
7009
+ const match = entries.find((e) => e.enabled && e.url.length > 0 && (e.profile === pref || e.brokerId === `${prefix}${pref}`));
7010
+ if (match) return toPicked(match);
7011
+ }
7012
+ const eligible = entries.filter((e) => e.enabled && e.url.length > 0);
7013
+ if (eligible.length === 0) return null;
7014
+ const target = options.targetResolution;
7015
+ if (target) {
7016
+ const withRes = eligible.filter((e) => e.resolution !== void 0);
7017
+ if (withRes.length > 0) {
7018
+ const picked = pickClosestResolution(withRes, target);
7019
+ if (picked) return toPicked(picked);
7020
+ }
7021
+ }
7022
+ return toPicked(eligible[0]);
7023
+ }
7094
7024
  /**
7095
- * Semantic role a device plays within its parent. Populated by driver
7096
- * addons when creating accessory devices (Reolink siren/floodlight/
7097
- * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
7098
- * admin UI to pick icons, labels, and widgets — a `Switch` with
7099
- * `role: Floodlight` renders as a bulb with a brightness slider,
7100
- * whereas a `Switch` with `role: Siren` renders as a klaxon.
7101
- *
7102
- * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
7103
- * sqlite as a nullable TEXT column — old rows keep working unchanged.
7104
- */
7105
- var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7106
- DeviceRole["Siren"] = "siren";
7107
- DeviceRole["Floodlight"] = "floodlight";
7108
- DeviceRole["Spotlight"] = "spotlight";
7109
- DeviceRole["PirSensor"] = "pir-sensor";
7110
- DeviceRole["Chime"] = "chime";
7111
- DeviceRole["Autotrack"] = "autotrack";
7112
- DeviceRole["Nightvision"] = "nightvision";
7113
- DeviceRole["PrivacyMask"] = "privacy-mask";
7114
- DeviceRole["Doorbell"] = "doorbell";
7115
- /** Virtual HA toggle (input_boolean.*) — distinguishable from a
7116
- * real Switch device for UI rendering / export adapters. */
7117
- DeviceRole["BinaryHelper"] = "binary-helper";
7118
- /** Generic motion / occupancy / moving event source. Distinct from
7119
- * the camera accessory PirSensor role: that one is a camera child;
7120
- * this is a standalone HA / 3rd-party motion sensor. */
7121
- DeviceRole["MotionSensor"] = "motion-sensor";
7122
- DeviceRole["ContactSensor"] = "contact-sensor";
7123
- DeviceRole["LeakSensor"] = "leak-sensor";
7124
- DeviceRole["SmokeSensor"] = "smoke-sensor";
7125
- DeviceRole["COSensor"] = "co-sensor";
7126
- DeviceRole["GasSensor"] = "gas-sensor";
7127
- DeviceRole["TamperSensor"] = "tamper-sensor";
7128
- DeviceRole["VibrationSensor"] = "vibration-sensor";
7129
- DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
7130
- DeviceRole["SoundSensor"] = "sound-sensor";
7131
- /** Fallback for `binary_sensor` without a known `device_class`. */
7132
- DeviceRole["BinarySensor"] = "binary-sensor";
7133
- DeviceRole["TemperatureSensor"] = "temperature-sensor";
7134
- DeviceRole["HumiditySensor"] = "humidity-sensor";
7135
- DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
7136
- DeviceRole["PressureSensor"] = "pressure-sensor";
7137
- DeviceRole["PowerSensor"] = "power-sensor";
7138
- DeviceRole["EnergySensor"] = "energy-sensor";
7139
- DeviceRole["VoltageSensor"] = "voltage-sensor";
7140
- DeviceRole["CurrentSensor"] = "current-sensor";
7141
- DeviceRole["AirQualitySensor"] = "air-quality-sensor";
7142
- /** Battery level (numeric % via `sensor` OR low-bool via
7143
- * `binary_sensor` the cap distinguishes via the value type). */
7144
- DeviceRole["BatterySensor"] = "battery-sensor";
7145
- /** Fallback for `sensor` numeric without a known `device_class`. */
7146
- DeviceRole["NumericSensor"] = "numeric-sensor";
7147
- /** String / enum state (HA `sensor` with `state_class: enum` or
7148
- * `attributes.options`). */
7149
- DeviceRole["EnumSensor"] = "enum-sensor";
7150
- /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
7151
- * or `date`). The slice carries the raw ISO string verbatim (hosted on
7152
- * the `enum-sensor` cap); the UI renders it locale-formatted. */
7153
- DeviceRole["DateTimeSensor"] = "datetime-sensor";
7154
- /** Last-resort fallback when nothing else matches. */
7155
- DeviceRole["GenericSensor"] = "generic-sensor";
7156
- DeviceRole["NumericControl"] = "numeric-control";
7157
- DeviceRole["SelectControl"] = "select-control";
7158
- DeviceRole["TextControl"] = "text-control";
7159
- DeviceRole["DateTimeControl"] = "datetime-control";
7160
- /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
7161
- * rich features (image, priority, channel routing). */
7162
- DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
7163
- /** Chat / messaging service (HA `notify.telegram_*`,
7164
- * `notify.discord_*`, etc.). */
7165
- DeviceRole["MessagingNotifier"] = "messaging-notifier";
7166
- /** Email-based delivery (HA `notify.smtp`, etc.). */
7167
- DeviceRole["EmailNotifier"] = "email-notifier";
7168
- /** Fallback when the notifier service name doesn't match a known
7169
- * pattern. */
7170
- DeviceRole["GenericNotifier"] = "generic-notifier";
7171
- return DeviceRole;
7172
- }({});
7025
+ * Pick the entry whose `resolution` is closest to `target`. Prefer
7026
+ * entries target (downscale is cheap at the consumer; upscale is
7027
+ * lossy). Among the rest pick the LARGEST still ≤ target so the
7028
+ * consumer gets the best feasible quality. "Closeness" is the
7029
+ * `width × height` pixel delta.
7030
+ */
7031
+ function pickClosestResolution(entries, target) {
7032
+ const targetPixels = target.width * target.height;
7033
+ let bestAbove;
7034
+ let bestBelow;
7035
+ for (const e of entries) {
7036
+ if (e.resolution === void 0) continue;
7037
+ const pixels = e.resolution.width * e.resolution.height;
7038
+ if (pixels >= targetPixels) {
7039
+ if (!bestAbove || pixels < bestAbove.pixels) bestAbove = {
7040
+ entry: e,
7041
+ pixels
7042
+ };
7043
+ } else if (!bestBelow || pixels > bestBelow.pixels) bestBelow = {
7044
+ entry: e,
7045
+ pixels
7046
+ };
7047
+ }
7048
+ return bestAbove?.entry ?? bestBelow?.entry;
7049
+ }
7050
+ var YAMNET_TO_MACRO = {
7051
+ mapping: {
7052
+ Speech: "speech",
7053
+ "Child speech, kid speaking": "speech",
7054
+ Conversation: "speech",
7055
+ "Narration, monologue": "speech",
7056
+ Babbling: "speech",
7057
+ Whispering: "speech",
7058
+ "Speech synthesizer": "speech",
7059
+ Humming: "speech",
7060
+ Rapping: "speech",
7061
+ Singing: "speech",
7062
+ Choir: "speech",
7063
+ "Child singing": "speech",
7064
+ Shout: "scream",
7065
+ Bellow: "scream",
7066
+ Yell: "scream",
7067
+ Screaming: "scream",
7068
+ "Children shouting": "scream",
7069
+ Whoop: "scream",
7070
+ "Crying, sobbing": "crying",
7071
+ "Baby cry, infant cry": "crying",
7072
+ Whimper: "crying",
7073
+ "Wail, moan": "crying",
7074
+ Groan: "crying",
7075
+ Laughter: "laughter",
7076
+ "Baby laughter": "laughter",
7077
+ Giggle: "laughter",
7078
+ Snicker: "laughter",
7079
+ "Belly laugh": "laughter",
7080
+ "Chuckle, chortle": "laughter",
7081
+ Music: "music",
7082
+ "Musical instrument": "music",
7083
+ Guitar: "music",
7084
+ Piano: "music",
7085
+ Drum: "music",
7086
+ "Drum kit": "music",
7087
+ "Violin, fiddle": "music",
7088
+ Flute: "music",
7089
+ Saxophone: "music",
7090
+ Trumpet: "music",
7091
+ Synthesizer: "music",
7092
+ "Pop music": "music",
7093
+ "Rock music": "music",
7094
+ "Hip hop music": "music",
7095
+ "Classical music": "music",
7096
+ Jazz: "music",
7097
+ "Electronic music": "music",
7098
+ "Background music": "music",
7099
+ Dog: "dog",
7100
+ Bark: "dog",
7101
+ Yip: "dog",
7102
+ Howl: "dog",
7103
+ "Bow-wow": "dog",
7104
+ Growling: "dog",
7105
+ "Whimper (dog)": "dog",
7106
+ Cat: "cat",
7107
+ Purr: "cat",
7108
+ Meow: "cat",
7109
+ Hiss: "cat",
7110
+ Caterwaul: "cat",
7111
+ Bird: "bird",
7112
+ "Bird vocalization, bird call, bird song": "bird",
7113
+ "Chirp, tweet": "bird",
7114
+ Squawk: "bird",
7115
+ Crow: "bird",
7116
+ Owl: "bird",
7117
+ "Pigeon, dove": "bird",
7118
+ Animal: "animal",
7119
+ "Domestic animals, pets": "animal",
7120
+ "Livestock, farm animals, working animals": "animal",
7121
+ Horse: "animal",
7122
+ "Cattle, bovinae": "animal",
7123
+ Pig: "animal",
7124
+ Sheep: "animal",
7125
+ Goat: "animal",
7126
+ Frog: "animal",
7127
+ Insect: "animal",
7128
+ Cricket: "animal",
7129
+ Alarm: "alarm",
7130
+ "Alarm clock": "alarm",
7131
+ "Smoke detector, smoke alarm": "alarm",
7132
+ "Fire alarm": "alarm",
7133
+ Buzzer: "alarm",
7134
+ "Civil defense siren": "alarm",
7135
+ "Car alarm": "alarm",
7136
+ Siren: "siren",
7137
+ "Police car (siren)": "siren",
7138
+ "Ambulance (siren)": "siren",
7139
+ "Fire engine, fire truck (siren)": "siren",
7140
+ "Emergency vehicle": "siren",
7141
+ Foghorn: "siren",
7142
+ Doorbell: "doorbell",
7143
+ "Ding-dong": "doorbell",
7144
+ Knock: "doorbell",
7145
+ Tap: "doorbell",
7146
+ Glass: "glass_breaking",
7147
+ Shatter: "glass_breaking",
7148
+ "Chink, clink": "glass_breaking",
7149
+ "Gunshot, gunfire": "gunshot",
7150
+ "Machine gun": "gunshot",
7151
+ Explosion: "gunshot",
7152
+ Fireworks: "gunshot",
7153
+ Firecracker: "gunshot",
7154
+ "Artillery fire": "gunshot",
7155
+ "Cap gun": "gunshot",
7156
+ Boom: "gunshot",
7157
+ Vehicle: "vehicle",
7158
+ Car: "vehicle",
7159
+ Truck: "vehicle",
7160
+ Bus: "vehicle",
7161
+ Motorcycle: "vehicle",
7162
+ "Car passing by": "vehicle",
7163
+ "Vehicle horn, car horn, honking": "vehicle",
7164
+ "Traffic noise, roadway noise": "vehicle",
7165
+ Train: "vehicle",
7166
+ Aircraft: "vehicle",
7167
+ Helicopter: "vehicle",
7168
+ Bicycle: "vehicle",
7169
+ Skateboard: "vehicle",
7170
+ Fire: "fire",
7171
+ Crackle: "fire",
7172
+ Water: "water",
7173
+ Rain: "water",
7174
+ Raindrop: "water",
7175
+ "Rain on surface": "water",
7176
+ Stream: "water",
7177
+ Waterfall: "water",
7178
+ Ocean: "water",
7179
+ "Waves, surf": "water",
7180
+ "Splash, splatter": "water",
7181
+ Wind: "wind",
7182
+ Thunderstorm: "wind",
7183
+ Thunder: "wind",
7184
+ "Wind noise (microphone)": "wind",
7185
+ "Rustling leaves": "wind",
7186
+ Door: "door",
7187
+ "Sliding door": "door",
7188
+ Slam: "door",
7189
+ "Cupboard open or close": "door",
7190
+ "Walk, footsteps": "footsteps",
7191
+ Run: "footsteps",
7192
+ Shuffle: "footsteps",
7193
+ Crowd: "crowd",
7194
+ Chatter: "crowd",
7195
+ Cheering: "crowd",
7196
+ Applause: "crowd",
7197
+ "Children playing": "crowd",
7198
+ "Hubbub, speech noise, speech babble": "crowd",
7199
+ Telephone: "telephone",
7200
+ "Telephone bell ringing": "telephone",
7201
+ Ringtone: "telephone",
7202
+ "Telephone dialing, DTMF": "telephone",
7203
+ "Busy signal": "telephone",
7204
+ Engine: "engine",
7205
+ "Engine starting": "engine",
7206
+ Idling: "engine",
7207
+ "Accelerating, revving, vroom": "engine",
7208
+ "Light engine (high frequency)": "engine",
7209
+ "Medium engine (mid frequency)": "engine",
7210
+ "Heavy engine (low frequency)": "engine",
7211
+ "Lawn mower": "engine",
7212
+ Chainsaw: "engine",
7213
+ Hammer: "tools",
7214
+ Jackhammer: "tools",
7215
+ Sawing: "tools",
7216
+ "Power tool": "tools",
7217
+ Drill: "tools",
7218
+ Sanding: "tools",
7219
+ Silence: "silence"
7220
+ },
7221
+ preserveOriginal: false
7222
+ };
7223
+ var APPLE_SA_TO_MACRO = {
7224
+ mapping: {
7225
+ speech: "speech",
7226
+ child_speech: "speech",
7227
+ conversation: "speech",
7228
+ whispering: "speech",
7229
+ singing: "speech",
7230
+ humming: "speech",
7231
+ shout: "scream",
7232
+ yell: "scream",
7233
+ screaming: "scream",
7234
+ crying: "crying",
7235
+ baby_crying: "crying",
7236
+ sobbing: "crying",
7237
+ laughter: "laughter",
7238
+ baby_laughter: "laughter",
7239
+ giggling: "laughter",
7240
+ music: "music",
7241
+ guitar: "music",
7242
+ piano: "music",
7243
+ drums: "music",
7244
+ dog_bark: "dog",
7245
+ dog_bow_wow: "dog",
7246
+ dog_growling: "dog",
7247
+ dog_howl: "dog",
7248
+ cat_meow: "cat",
7249
+ cat_purr: "cat",
7250
+ cat_hiss: "cat",
7251
+ bird: "bird",
7252
+ bird_chirp: "bird",
7253
+ bird_squawk: "bird",
7254
+ animal: "animal",
7255
+ horse: "animal",
7256
+ cow_moo: "animal",
7257
+ insect: "animal",
7258
+ alarm: "alarm",
7259
+ smoke_alarm: "alarm",
7260
+ fire_alarm: "alarm",
7261
+ car_alarm: "alarm",
7262
+ siren: "siren",
7263
+ police_siren: "siren",
7264
+ ambulance_siren: "siren",
7265
+ doorbell: "doorbell",
7266
+ door_knock: "doorbell",
7267
+ knocking: "doorbell",
7268
+ glass_breaking: "glass_breaking",
7269
+ glass_shatter: "glass_breaking",
7270
+ gunshot: "gunshot",
7271
+ explosion: "gunshot",
7272
+ fireworks: "gunshot",
7273
+ car: "vehicle",
7274
+ truck: "vehicle",
7275
+ motorcycle: "vehicle",
7276
+ car_horn: "vehicle",
7277
+ vehicle_horn: "vehicle",
7278
+ traffic: "vehicle",
7279
+ fire: "fire",
7280
+ fire_crackle: "fire",
7281
+ water: "water",
7282
+ rain: "water",
7283
+ ocean: "water",
7284
+ splash: "water",
7285
+ wind: "wind",
7286
+ thunder: "wind",
7287
+ thunderstorm: "wind",
7288
+ door: "door",
7289
+ door_slam: "door",
7290
+ sliding_door: "door",
7291
+ footsteps: "footsteps",
7292
+ walking: "footsteps",
7293
+ running: "footsteps",
7294
+ crowd: "crowd",
7295
+ chatter: "crowd",
7296
+ cheering: "crowd",
7297
+ applause: "crowd",
7298
+ telephone_ring: "telephone",
7299
+ ringtone: "telephone",
7300
+ engine: "engine",
7301
+ engine_starting: "engine",
7302
+ lawn_mower: "engine",
7303
+ chainsaw: "engine",
7304
+ hammer: "tools",
7305
+ jackhammer: "tools",
7306
+ drill: "tools",
7307
+ power_tool: "tools",
7308
+ silence: "silence"
7309
+ },
7310
+ preserveOriginal: false
7311
+ };
7312
+ var _macroLookup = /* @__PURE__ */ new Map();
7313
+ for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7314
+ for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7173
7315
  /**
7174
7316
  * Accessory device helpers — shared across drivers.
7175
7317
  *
@@ -7329,74 +7471,6 @@ object({
7329
7471
  });
7330
7472
  DeviceType.Sensor;
7331
7473
  /**
7332
- * Generic types for capability definitions.
7333
- *
7334
- * A capability is defined with Zod schemas for methods, events, and settings.
7335
- * TypeScript types are inferred via z.infer<> — zero duplication.
7336
- *
7337
- * Pattern:
7338
- * 1. Define Zod schemas for data, methods, settings
7339
- * 2. Export const capabilityDef = { ... } satisfies CapabilityDefinition
7340
- * 3. Export type IProvider = InferProvider<typeof capabilityDef>
7341
- * 4. Addon implements IProvider
7342
- * 5. Registry auto-mounts tRPC router from definition.methods
7343
- */
7344
- /**
7345
- * Output schema shared by the contribution + live methods.
7346
- *
7347
- * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
7348
- * tabs[]) without importing from `../interfaces/config-ui.js` — a
7349
- * concrete-but-lenient Zod object keeps tRPC output inference happy
7350
- * (using `z.unknown()` here collapses unrelated router branches to
7351
- * `unknown` when the generator re-inlines the huge AppRouter type).
7352
- *
7353
- * `.passthrough()` on sections/fields accepts whatever FormBuilder
7354
- * extensions the caller adds (showWhen, displayScale, …) without
7355
- * rebuilding every time a new field kind is introduced.
7356
- */
7357
- var ContributionSectionSchema = object({
7358
- id: string(),
7359
- title: string(),
7360
- description: string().optional(),
7361
- style: _enum(["card", "accordion"]).optional(),
7362
- defaultCollapsed: boolean().optional(),
7363
- columns: union([
7364
- literal(1),
7365
- literal(2),
7366
- literal(3),
7367
- literal(4)
7368
- ]).optional(),
7369
- tab: string().optional(),
7370
- location: _enum(["settings", "top-tab"]).optional(),
7371
- order: number().optional(),
7372
- fields: array(any())
7373
- });
7374
- object({
7375
- tabs: array(object({
7376
- id: string(),
7377
- label: string(),
7378
- icon: string(),
7379
- order: number().optional()
7380
- })).optional(),
7381
- sections: array(ContributionSectionSchema)
7382
- }).nullable();
7383
- object({ deviceId: number() }), object({ deviceId: number() }), object({
7384
- deviceId: number(),
7385
- patch: record(string(), unknown())
7386
- }), object({ success: literal(true) });
7387
- object({ deviceId: number() }), unknown().nullable();
7388
- /** Shorthand to define a method schema */
7389
- function method(input, output, options) {
7390
- return {
7391
- input,
7392
- output,
7393
- kind: options?.kind ?? "query",
7394
- auth: options?.auth ?? "protected",
7395
- ...options?.access !== void 0 ? { access: options.access } : {},
7396
- timeoutMs: options?.timeoutMs
7397
- };
7398
- }
7399
- /**
7400
7474
  * Alarm-panel cap. Models HA `alarm_control_panel.*` on
7401
7475
  * `DeviceType.AlarmPanel`. State follows HA's canonical lifecycle
7402
7476
  * across disarmed / armed_(home|away|night|vacation|custom_bypass) /
@@ -9211,6 +9285,24 @@ var DetectorOutputSchema = object({
9211
9285
  inferenceMs: number(),
9212
9286
  modelId: string()
9213
9287
  });
9288
+ var EngineProvisioningSchema = object({
9289
+ runtimeId: _enum([
9290
+ "onnx",
9291
+ "openvino",
9292
+ "coreml"
9293
+ ]).nullable(),
9294
+ device: string().nullable(),
9295
+ state: _enum([
9296
+ "idle",
9297
+ "installing",
9298
+ "verifying",
9299
+ "ready",
9300
+ "failed"
9301
+ ]),
9302
+ progress: number().optional(),
9303
+ error: string().optional(),
9304
+ nextRetryAt: number().optional()
9305
+ });
9214
9306
  var PipelineStepInputSchema = lazy(() => object({
9215
9307
  addonId: string(),
9216
9308
  modelId: string(),
@@ -9279,7 +9371,7 @@ var PipelineRunResultBridge = custom();
9279
9371
  method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(_void(), PipelineEngineChoiceSchema, {
9280
9372
  kind: "mutation",
9281
9373
  auth: "admin"
9282
- }), method(_void(), record(string(), object({
9374
+ }), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
9283
9375
  modelId: string(),
9284
9376
  settings: record(string(), unknown()).readonly()
9285
9377
  }))), method(object({ steps: record(string(), object({
@@ -11380,9 +11472,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
11380
11472
  limit: number().optional(),
11381
11473
  tags: record(string(), string()).optional()
11382
11474
  }), array(LogEntrySchema).readonly());
11383
- var StaticDirOutputSchema = object({ staticDir: string() });
11384
- var VersionOutputSchema = object({ version: string() });
11385
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
11386
11475
  /**
11387
11476
  * Zod schemas for persisted record types.
11388
11477
  *
@@ -12891,7 +12980,10 @@ var AgentAddonConfigSchema = object({
12891
12980
  modelId: string(),
12892
12981
  settings: record(string(), unknown()).readonly()
12893
12982
  });
12894
- var AgentPipelineSettingsSchema = object({ addonDefaults: record(string(), AgentAddonConfigSchema).readonly() });
12983
+ var AgentPipelineSettingsSchema = object({
12984
+ addonDefaults: record(string(), AgentAddonConfigSchema).readonly(),
12985
+ maxCameras: number().int().nonnegative().nullable().default(null)
12986
+ });
12895
12987
  var CameraPipelineForAgentSchema = object({
12896
12988
  steps: array(PipelineStepInputSchema).readonly(),
12897
12989
  audio: object({
@@ -12993,6 +13085,133 @@ var GlobalMetricsSchema = object({
12993
13085
  * capability providers.
12994
13086
  */
12995
13087
  var CapabilityBindingsSchema = record(string(), string());
13088
+ /** Source block — always present; derives from the stream catalog. */
13089
+ var CameraSourceStatusSchema = object({ streams: array(object({
13090
+ camStreamId: string(),
13091
+ codec: string(),
13092
+ width: number(),
13093
+ height: number(),
13094
+ fps: number(),
13095
+ kind: string()
13096
+ })).readonly() });
13097
+ /** Assignment block — always present (orchestrator-local, no remote call). */
13098
+ var CameraAssignmentStatusSchema = object({
13099
+ detectionNodeId: string().nullable(),
13100
+ decoderNodeId: string().nullable(),
13101
+ audioNodeId: string().nullable(),
13102
+ pinned: object({
13103
+ detection: boolean(),
13104
+ decoder: boolean(),
13105
+ audio: boolean()
13106
+ }),
13107
+ reasons: object({
13108
+ detection: string().optional(),
13109
+ decoder: string().optional(),
13110
+ audio: string().optional()
13111
+ })
13112
+ });
13113
+ /** Broker block — null when the broker stage is unreachable or inactive. */
13114
+ var CameraBrokerStatusSchema = object({
13115
+ profiles: array(object({
13116
+ profile: string(),
13117
+ status: string(),
13118
+ codec: string(),
13119
+ width: number(),
13120
+ height: number(),
13121
+ subscribers: number(),
13122
+ inFps: number(),
13123
+ outFps: number()
13124
+ })).readonly(),
13125
+ webrtcSessions: number(),
13126
+ rtspRestream: boolean()
13127
+ });
13128
+ /** Shared-memory ring statistics within the decoder block. */
13129
+ var CameraDecoderShmSchema = object({
13130
+ framesWritten: number(),
13131
+ getFrameHits: number(),
13132
+ getFrameMisses: number(),
13133
+ budgetMb: number()
13134
+ });
13135
+ /** Decoder block — null when the decoder stage is unreachable or inactive. */
13136
+ var CameraDecoderStatusSchema = object({
13137
+ nodeId: string(),
13138
+ formats: array(string()).readonly(),
13139
+ sessionCount: number(),
13140
+ shm: CameraDecoderShmSchema
13141
+ });
13142
+ /** Motion block — null when motion detection is not active for this device. */
13143
+ var CameraMotionStatusSchema = object({
13144
+ enabled: boolean(),
13145
+ fps: number()
13146
+ });
13147
+ /** Detection provisioning sub-block. */
13148
+ var CameraDetectionProvisioningSchema = object({
13149
+ state: _enum([
13150
+ "idle",
13151
+ "installing",
13152
+ "verifying",
13153
+ "ready",
13154
+ "failed"
13155
+ ]),
13156
+ error: string().optional()
13157
+ });
13158
+ /** Detection phase — derived from the runner's engine phase. */
13159
+ var CameraDetectionPhaseSchema = _enum([
13160
+ "idle",
13161
+ "watching",
13162
+ "active"
13163
+ ]);
13164
+ /** Detection block — null when no detection node is assigned or reachable. */
13165
+ var CameraDetectionStatusSchema = object({
13166
+ nodeId: string(),
13167
+ engine: object({
13168
+ backend: string(),
13169
+ device: string()
13170
+ }),
13171
+ phase: CameraDetectionPhaseSchema,
13172
+ configuredFps: number(),
13173
+ actualFps: number(),
13174
+ queueDepth: number(),
13175
+ avgInferenceMs: number(),
13176
+ provisioning: CameraDetectionProvisioningSchema
13177
+ });
13178
+ /** Audio block — null when no audio node is assigned or reachable. */
13179
+ var CameraAudioStatusSchema = object({
13180
+ nodeId: string(),
13181
+ enabled: boolean()
13182
+ });
13183
+ /** Recording block — null when no recording cap is active for this device. */
13184
+ var CameraRecordingStatusSchema = object({
13185
+ mode: _enum([
13186
+ "off",
13187
+ "continuous",
13188
+ "events"
13189
+ ]),
13190
+ active: boolean(),
13191
+ storageBytes: number()
13192
+ });
13193
+ /**
13194
+ * Aggregated per-camera pipeline status — server-composed, single call.
13195
+ *
13196
+ * The `assignment` and `source` blocks are always present.
13197
+ * Every other block is `null` when the stage is inactive or unreachable
13198
+ * during the bounded parallel fan-out in the orchestrator implementation.
13199
+ *
13200
+ * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
13201
+ */
13202
+ var CameraStatusSchema = object({
13203
+ deviceId: number(),
13204
+ assignment: CameraAssignmentStatusSchema,
13205
+ source: CameraSourceStatusSchema,
13206
+ broker: CameraBrokerStatusSchema.nullable(),
13207
+ decoder: CameraDecoderStatusSchema.nullable(),
13208
+ motion: CameraMotionStatusSchema.nullable(),
13209
+ detection: CameraDetectionStatusSchema.nullable(),
13210
+ audio: CameraAudioStatusSchema.nullable(),
13211
+ recording: CameraRecordingStatusSchema.nullable(),
13212
+ /** Unix timestamp (ms) when this snapshot was composed server-side. */
13213
+ fetchedAt: number()
13214
+ });
12996
13215
  method(object({
12997
13216
  deviceId: number(),
12998
13217
  agentNodeId: string()
@@ -13060,6 +13279,12 @@ method(object({
13060
13279
  }), {
13061
13280
  kind: "mutation",
13062
13281
  auth: "admin"
13282
+ }), method(object({
13283
+ agentNodeId: string(),
13284
+ maxCameras: number().int().nonnegative().nullable()
13285
+ }), object({ success: literal(true) }), {
13286
+ kind: "mutation",
13287
+ auth: "admin"
13063
13288
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
13064
13289
  deviceId: number(),
13065
13290
  addonId: string(),
@@ -13085,7 +13310,7 @@ method(object({
13085
13310
  }), method(object({
13086
13311
  deviceId: number(),
13087
13312
  agentNodeId: string().optional()
13088
- }), CameraPipelineConfigSchema), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
13313
+ }), CameraPipelineConfigSchema), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
13089
13314
  name: string(),
13090
13315
  description: string().optional(),
13091
13316
  config: CameraPipelineConfigSchema
@@ -13572,7 +13797,7 @@ method(object({
13572
13797
  }), _void(), {
13573
13798
  kind: "mutation",
13574
13799
  auth: "admin"
13575
- }), 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({
13800
+ }), 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({
13576
13801
  deviceId: number(),
13577
13802
  values: record(string(), unknown())
13578
13803
  }), object({ success: literal(true) }), {
@@ -14254,7 +14479,20 @@ var DiskSpaceInfoSchema = object({
14254
14479
  var PidResourceStatsSchema = object({
14255
14480
  pid: number(),
14256
14481
  cpu: number(),
14257
- memory: number()
14482
+ memory: number(),
14483
+ /**
14484
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
14485
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
14486
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
14487
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
14488
+ * Undefined where /proc is unavailable (e.g. macOS).
14489
+ */
14490
+ privateBytes: number().optional(),
14491
+ /**
14492
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
14493
+ * code shared copy-on-write across runners. Undefined on macOS.
14494
+ */
14495
+ sharedBytes: number().optional()
14258
14496
  });
14259
14497
  var AddonInstanceSchema = object({
14260
14498
  addonId: string(),
@@ -14303,6 +14541,17 @@ var KillProcessResultSchema = object({
14303
14541
  reason: string().optional(),
14304
14542
  signal: _enum(["SIGTERM", "SIGKILL"]).optional()
14305
14543
  });
14544
+ var DumpHeapSnapshotInputSchema = object({
14545
+ /** The addon whose runner should dump a heap snapshot. */
14546
+ addonId: string() });
14547
+ var DumpHeapSnapshotResultSchema = object({
14548
+ success: boolean(),
14549
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
14550
+ path: string().optional(),
14551
+ /** Process pid that was signalled. */
14552
+ pid: number().optional(),
14553
+ reason: string().optional()
14554
+ });
14306
14555
  var SystemMetricsSchema = object({
14307
14556
  cpuPercent: number(),
14308
14557
  memoryPercent: number(),
@@ -14316,6 +14565,9 @@ var SystemMetricsSchema = object({
14316
14565
  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, {
14317
14566
  kind: "mutation",
14318
14567
  auth: "admin"
14568
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
14569
+ kind: "mutation",
14570
+ auth: "admin"
14319
14571
  });
14320
14572
  var PtzPresetSchema = object({
14321
14573
  id: string(),
@@ -14682,63 +14934,6 @@ method(object({
14682
14934
  auth: "admin"
14683
14935
  });
14684
14936
  /**
14685
- * device-ops — device-scoped cap that unifies the per-IDevice operations
14686
- * previously routed through the `.device-ops` Moleculer bridge service.
14687
- *
14688
- * Each worker that hosts live `IDevice` instances auto-registers a native
14689
- * provider for this cap (per device) backed by its local
14690
- * `DeviceRegistry`. Hub-side callers reach it transparently through
14691
- * `ctx.fetchDevice(id).deviceOps.*` — the DeviceProxy injects
14692
- * `deviceId` + `nodeId` and dispatches through the standard cap-router,
14693
- * so there's no parallel bridge path anymore.
14694
- *
14695
- * The surface is intentionally small — every method corresponds to a
14696
- * single action on the live `IDevice` (or `ICameraDevice` for
14697
- * `getStreamSources`). Richer orchestration (enable/disable with
14698
- * integration plumbing, bulk updates) stays in the `device-manager` cap;
14699
- * `device-ops` is the per-device primitive the device-manager routes to.
14700
- */
14701
- var StreamSourceEntrySchema$1 = object({
14702
- id: string(),
14703
- label: string(),
14704
- protocol: _enum([
14705
- "rtsp",
14706
- "rtmp",
14707
- "annexb",
14708
- "http-mjpeg",
14709
- "webrtc",
14710
- "custom"
14711
- ]),
14712
- url: string().optional(),
14713
- resolution: object({
14714
- width: number(),
14715
- height: number()
14716
- }).optional(),
14717
- fps: number().optional(),
14718
- bitrate: number().optional(),
14719
- codec: string().optional(),
14720
- profileHint: CamProfileSchema.optional(),
14721
- sdp: string().optional()
14722
- });
14723
- var ConfigEntrySchema$1 = object({
14724
- key: string(),
14725
- value: unknown()
14726
- });
14727
- var RawStateResultSchema = object({
14728
- /** Originating provider id, e.g. 'homeassistant' | 'reolink' | 'hikvision'. */
14729
- source: string(),
14730
- /** Opaque, DISPLAY-SAFE upstream blob (no secrets/PII). */
14731
- data: record(string(), unknown())
14732
- });
14733
- method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
14734
- deviceId: number(),
14735
- values: record(string(), unknown())
14736
- }), _void(), { kind: "mutation" }), method(object({
14737
- deviceId: number(),
14738
- action: string().min(1),
14739
- input: unknown()
14740
- }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
14741
- /**
14742
14937
  * camera-credentials — device-scoped cap exposing the camera's network
14743
14938
  * + auth surface in a vendor-neutral shape.
14744
14939
  *
@@ -18421,6 +18616,12 @@ Object.freeze({
18421
18616
  addonId: null,
18422
18617
  access: "view"
18423
18618
  },
18619
+ "metricsProvider.dumpHeapSnapshot": {
18620
+ capName: "metrics-provider",
18621
+ capScope: "system",
18622
+ addonId: null,
18623
+ access: "create"
18624
+ },
18424
18625
  "metricsProvider.getAddonStats": {
18425
18626
  capName: "metrics-provider",
18426
18627
  capScope: "system",
@@ -18877,6 +19078,12 @@ Object.freeze({
18877
19078
  addonId: null,
18878
19079
  access: "view"
18879
19080
  },
19081
+ "pipelineExecutor.getEngineProvisioning": {
19082
+ capName: "pipeline-executor",
19083
+ capScope: "system",
19084
+ addonId: null,
19085
+ access: "view"
19086
+ },
18880
19087
  "pipelineExecutor.getGlobalPipelineConfig": {
18881
19088
  capName: "pipeline-executor",
18882
19089
  capScope: "system",
@@ -19081,6 +19288,18 @@ Object.freeze({
19081
19288
  addonId: null,
19082
19289
  access: "view"
19083
19290
  },
19291
+ "pipelineOrchestrator.getCameraStatus": {
19292
+ capName: "pipeline-orchestrator",
19293
+ capScope: "system",
19294
+ addonId: null,
19295
+ access: "view"
19296
+ },
19297
+ "pipelineOrchestrator.getCameraStatuses": {
19298
+ capName: "pipeline-orchestrator",
19299
+ capScope: "system",
19300
+ addonId: null,
19301
+ access: "view"
19302
+ },
19084
19303
  "pipelineOrchestrator.getCameraStepOverrides": {
19085
19304
  capName: "pipeline-orchestrator",
19086
19305
  capScope: "system",
@@ -19165,6 +19384,12 @@ Object.freeze({
19165
19384
  addonId: null,
19166
19385
  access: "create"
19167
19386
  },
19387
+ "pipelineOrchestrator.setAgentMaxCameras": {
19388
+ capName: "pipeline-orchestrator",
19389
+ capScope: "system",
19390
+ addonId: null,
19391
+ access: "create"
19392
+ },
19168
19393
  "pipelineOrchestrator.setCameraPipelineForAgent": {
19169
19394
  capName: "pipeline-orchestrator",
19170
19395
  capScope: "system",