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