@camstack/addon-provider-onvif 1.0.5 → 1.0.7

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.
Files changed (3) hide show
  1. package/dist/addon.js +1111 -1074
  2. package/dist/addon.mjs +1111 -1074
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -4632,63 +4632,7 @@ function _instanceof(cls, params = {}) {
4632
4632
  return inst;
4633
4633
  }
4634
4634
  //#endregion
4635
- //#region ../types/dist/index.mjs
4636
- /**
4637
- * Deep wiring healthcheck — snapshot of active reachability probes across
4638
- * every declared capability + widget of every installed plugin, on every
4639
- * node. Produced by the backend `WiringHealthService` and surfaced via
4640
- * `GET /health/wiring`, the tRPC `health.wiring` query, and the boot-gate.
4641
- *
4642
- * Unlike `/health` (process liveness), this reflects whether each cap/widget
4643
- * is actually *reachable* over the real cap-dispatch path. See spec
4644
- * `docs/superpowers/specs/2026-05-23-deep-healthcheck-design.md`.
4645
- */
4646
- /** What kind of target a probe addressed. */
4647
- var wiringProbeKindSchema = _enum([
4648
- "singleton",
4649
- "device",
4650
- "widget"
4651
- ]);
4652
- /** Result of probing a single (cap|widget [, device]) target. */
4653
- var wiringProbeResultSchema = object({
4654
- capName: string(),
4655
- kind: wiringProbeKindSchema,
4656
- deviceId: number().optional(),
4657
- reachable: boolean(),
4658
- latencyMs: number(),
4659
- error: string().optional()
4660
- });
4661
- /** Per-addon roll-up of cap + widget probe results. */
4662
- var wiringAddonHealthSchema = object({
4663
- addonId: string(),
4664
- caps: array(wiringProbeResultSchema).readonly(),
4665
- widgets: array(wiringProbeResultSchema).readonly()
4666
- });
4667
- /** Per-node roll-up. */
4668
- var wiringNodeHealthSchema = object({
4669
- nodeId: string(),
4670
- addons: array(wiringAddonHealthSchema).readonly()
4671
- });
4672
- object({
4673
- /** True only when every probed target is reachable. */
4674
- ok: boolean(),
4675
- /** True when at least one target is unreachable. */
4676
- degraded: boolean(),
4677
- checkedAt: string(),
4678
- nodes: array(wiringNodeHealthSchema).readonly(),
4679
- summary: object({
4680
- total: number(),
4681
- reachable: number(),
4682
- unreachable: number()
4683
- })
4684
- });
4685
- var MODEL_FORMATS = [
4686
- "onnx",
4687
- "coreml",
4688
- "openvino",
4689
- "tflite",
4690
- "pt"
4691
- ];
4635
+ //#region ../types/dist/sleep-B1dKJAMJ.mjs
4692
4636
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4693
4637
  EventCategory["SystemBoot"] = "system.boot";
4694
4638
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5662,7 +5606,7 @@ var BaseAddon = class {
5662
5606
  deviceSettingsSchema() {
5663
5607
  return null;
5664
5608
  }
5665
- async getGlobalSettings(overlay, cap) {
5609
+ async getGlobalSettings(overlay, cap, _nodeId) {
5666
5610
  const schema = this.globalSettingsSchema(cap);
5667
5611
  if (!schema) return { sections: [] };
5668
5612
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
@@ -5671,7 +5615,7 @@ var BaseAddon = class {
5671
5615
  ...overlay
5672
5616
  } : raw);
5673
5617
  }
5674
- async updateGlobalSettings(patch) {
5618
+ async updateGlobalSettings(patch, _nodeId) {
5675
5619
  await this._ctx?.settings?.writeAddonStore(patch);
5676
5620
  await this.resolveConfig();
5677
5621
  await this.onConfigChanged();
@@ -6011,7 +5955,7 @@ var ProfileSlotSchema = object({
6011
5955
  * Zod schema for StreamSourceEntry — the canonical stream descriptor
6012
5956
  * exposed by ICameraDevice.getStreamSources() and consumed by the broker.
6013
5957
  */
6014
- var StreamSourceEntrySchema = object({
5958
+ var StreamSourceEntrySchema$1 = object({
6015
5959
  id: string(),
6016
5960
  label: string(),
6017
5961
  protocol: _enum([
@@ -6233,904 +6177,1092 @@ var ProfileRtspEntrySchema = object({
6233
6177
  codec: string().optional(),
6234
6178
  resolution: CamStreamResolutionSchema.optional()
6235
6179
  });
6236
- /**
6237
- * Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
6238
- * Named `RecordingWeekday` to avoid collision with the string-union
6239
- * `Weekday` exported from `interfaces/timezones.ts`.
6240
- */
6241
- var RecordingWeekdaySchema = number().int().min(0).max(6);
6242
- var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
6243
- var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
6244
- kind: literal("timeOfDay"),
6245
- start: string().regex(HHMM),
6246
- end: string().regex(HHMM),
6247
- /** Restrict to these weekdays; omit = every day. */
6248
- days: array(RecordingWeekdaySchema).optional()
6249
- })]);
6250
- var RecordingModeSchema = _enum([
6251
- "continuous",
6252
- "onMotion",
6253
- "onAudioThreshold"
6254
- ]);
6255
- /**
6256
- * First-class, authoritative per-camera storage mode the netta choice the UI
6257
- * reads directly (never inferred from `rules`):
6258
- * - `off` not recording.
6259
- * - `events` — record only around triggers (motion / audio threshold),
6260
- * with pre/post-buffer.
6261
- * - `continuous` record 24/7 within the schedule.
6262
- *
6263
- * `mode` compiles one-way to the internal `rules[]` consumed by the policy
6264
- * engine (see `compileRules`); `rules[]` is never authored directly anymore.
6265
- */
6266
- var RecordingStorageModeSchema = _enum([
6267
- "off",
6268
- "events",
6269
- "continuous"
6270
- ]);
6271
- /** Which detectors trigger an `events`-mode recording. */
6272
- var RecordingTriggersSchema = object({
6273
- motion: boolean().optional(),
6274
- audioThresholdDbfs: number().optional()
6275
- });
6276
- /**
6277
- * Mode of a single recording band the recorder per-band vocabulary.
6278
- *
6279
- * Distinct from `RecordingStorageModeSchema` (which carries `off`): a band is
6280
- * only ever `continuous` or `events`; "off" is expressed by the absence of a
6281
- * covering band, not by a band value.
6282
- */
6283
- var RecordingBandModeSchema = _enum(["continuous", "events"]);
6284
- /**
6285
- * Triggers for an `events`-mode band. Identical shape to
6286
- * `RecordingTriggersSchema`reuse that schema as the band trigger type so the
6287
- * two never drift.
6288
- */
6289
- var RecordingBandTriggersSchema = RecordingTriggersSchema;
6290
- /**
6291
- * A single mode-per-band window the canonical recorder band shape, the
6292
- * single source of truth re-used by `addon-pipeline/recorder`.
6293
- *
6294
- * `days` lists the weekdays the band covers (empty = every day, matching the
6295
- * band engine's `applies` rule). `start`/`end` are `HH:MM`; an `end <= start`
6296
- * span wraps past midnight (handled by the band engine).
6297
- */
6298
- var RecordingBandSchema = object({
6299
- days: array(RecordingWeekdaySchema),
6300
- start: string().regex(HHMM),
6301
- end: string().regex(HHMM),
6302
- mode: RecordingBandModeSchema,
6303
- triggers: RecordingBandTriggersSchema.optional(),
6304
- preBufferSec: number().min(0).optional(),
6305
- postBufferSec: number().min(0).optional()
6306
- });
6307
- var RecordingRuleSchema = object({
6308
- schedule: RecordingScheduleSchema,
6309
- mode: RecordingModeSchema,
6310
- /** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
6311
- preBufferSec: number().min(0).default(0),
6312
- /** Keep recording until this many seconds after the last trigger. */
6313
- postBufferSec: number().min(0).default(0),
6314
- /** Each new trigger restarts the post-buffer window. */
6315
- resetTimeoutOnNewEvent: boolean().default(true),
6316
- /** onAudioThreshold only dBFS level that counts as a trigger. */
6317
- thresholdDbfs: number().optional()
6318
- });
6319
- /**
6320
- * Per-device retention overrides. Every field is optional; an unset or `0`
6321
- * value inherits the node-wide recorder default. Only footage-lifetime limits
6322
- * live per-camera: `maxAgeDays` and `maxSizeGb`. The disk-occupancy threshold
6323
- * (when the volume is too full to keep recording) is NOT a per-camera concern —
6324
- * it belongs to the StorageLocation (`StorageLocation.config.minFreePercent`),
6325
- * shared by every camera writing to that volume.
6326
- */
6327
- var RecordingRetentionSchema = object({
6328
- maxAgeDays: number().min(0).optional(),
6329
- maxSizeGb: number().min(0).optional()
6330
- });
6331
- /**
6332
- * The full per-camera recording intent — the wire shape of a RecordingTarget.
6333
- *
6334
- * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
6335
- * are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
6336
- * only for transition + migration (`migrateRulesToMode`); the policy engine
6337
- * consumes the compiled output of `compileRules(config)`, never `rules` directly.
6338
- */
6339
- var RecordingConfigSchema = object({
6340
- enabled: boolean(),
6341
- /** Authoritative storage mode. Absent on legacy targets → derived once via
6342
- * `migrateRulesToMode`, then persisted. */
6343
- mode: RecordingStorageModeSchema.optional(),
6344
- profiles: array(CamProfileSchema).optional(),
6345
- segmentSeconds: number().int().positive().optional(),
6346
- /** Shared recording time-bands for `events` & `continuous` — record only when
6347
- * the wall-clock falls inside one of these windows. Omit or empty = always.
6348
- * `continuous` compiles to one rule per band; `events` to band × trigger. */
6349
- schedules: array(RecordingScheduleSchema).optional(),
6350
- /** Legacy single-band predecessor of `schedules`. Read-compat only — it is
6351
- * normalized into `schedules` on read and never written going forward. (Not
6352
- * tagged `@deprecated`: the normalization paths must read it cast-free.) */
6353
- schedule: RecordingScheduleSchema.optional(),
6354
- /** `events`-mode only — which detectors trigger a recording. */
6355
- triggers: RecordingTriggersSchema.optional(),
6356
- /** `events`-mode only — seconds retained before / after a trigger. */
6357
- preBufferSec: number().min(0).optional(),
6358
- postBufferSec: number().min(0).optional(),
6359
- /** DEPRECATED authoring input; retained for migration/transition. */
6360
- rules: array(RecordingRuleSchema).optional(),
6361
- /**
6362
- * AUTHORITATIVE mode-per-band recording model (recorder). When present it
6363
- * is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
6364
- * `triggers`/`rules` fields above are kept for READ-COMPAT only and are
6365
- * derived into bands once via `migrateConfigToBands`.
6366
- */
6367
- bands: array(RecordingBandSchema).optional(),
6368
- retention: RecordingRetentionSchema.optional()
6369
- });
6370
- /**
6371
- * `StorageLocationType` — an addon-declared id that identifies the *kind* of
6372
- * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
6373
- * so the persisted record schema and the consumer-facing cap can both consume it
6374
- * without forming a circular import. The `storage` cap re-exports it
6375
- * verbatim for back-compat.
6376
- *
6377
- * This Zod schema is the **authoritative source** for `StorageLocationType`.
6378
- * The TS alias in `./storage.ts` re-exports `z.infer<typeof
6379
- * StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
6380
- * `IStorageProvider` interface stay in lockstep.
6381
- *
6382
- * The type is now an **open string** (not a closed enum) — addons declare
6383
- * their own location kinds via `StorageLocationDeclaration.id`. The regex
6384
- * enforces a safe id format: lowercase-start, alphanumeric + hyphens.
6385
- */
6386
- var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
6387
- /**
6388
- * Persisted record for a storage location instance. Operators can register
6389
- * multiple instances for multi-cardinality types (e.g. two `backups`
6390
- * locations with different `providerId`s). Cardinality is now declared per
6391
- * location via `StorageLocationDeclaration.cardinality` — the static
6392
- * `STORAGE_LOCATION_CARDINALITY` map has been removed.
6393
- *
6394
- * `id` is a stable namespaced string of the form `<type>:<slug>`.
6395
- * The default location for a type uses `id === <type>:default` by
6396
- * convention (the bare type ref like `'backups'` resolves to it).
6397
- *
6398
- * `isSystem: true` marks a location as orchestrator-seeded and
6399
- * undeletable. The bootstrap-installed defaults (one per type) carry
6400
- * this flag; operator-added locations don't. Editing the config of
6401
- * a system location is allowed (path migration, provider swap) but
6402
- * deleting it is rejected at the cap level.
6403
- */
6404
- var StorageLocationSchema = object({
6405
- id: string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
6406
- type: string(),
6407
- displayName: string().min(1),
6408
- providerId: string().min(1),
6409
- config: record(string(), unknown()),
6410
- /**
6411
- * Cluster node this location physically lives on. REQUIRED for node-local
6412
- * providers (filesystem — the path exists on one node's disk), null/absent
6413
- * for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
6414
- * `'hub'` is the hub node. Validated against the provider's `nodeLocal`
6415
- * flag at upsert time, not here (the schema is provider-agnostic).
6416
- */
6417
- nodeId: string().optional(),
6418
- isDefault: boolean().default(false),
6419
- isSystem: boolean().default(false),
6420
- createdAt: number(),
6421
- updatedAt: number()
6422
- });
6423
- /**
6424
- * Reference accepted by consumer-facing `api.storage.*` calls.
6425
- * Either:
6426
- * - a `StorageLocationType` (e.g. `'backups'`) → orchestrator resolves to the default of that type
6427
- * - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
6428
- *
6429
- * The orchestrator's `resolveRef(ref)` handles both cases.
6430
- */
6431
- var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
6432
- /**
6433
- * `StorageLocationDeclaration` — a single storage-location entry declared by
6434
- * an addon in its `package.json` under `camstack.storageLocations`.
6435
- *
6436
- * Design intent:
6437
- * - **Addon declares its needs** — each addon describes the logical storage
6438
- * slots it requires (e.g. `recordings`, `recordingsLow`) without caring
6439
- * about the physical path.
6440
- * - **Kernel aggregates** — at boot the kernel collects declarations from all
6441
- * installed addons, deduplicates by `id`, and exposes the union via the
6442
- * storage-locations settings surface.
6443
- * - **Orchestrator seeds** — for every declared `id` the orchestrator ensures
6444
- * at least one instance named `<id>:default` is present, using
6445
- * `defaultsTo` to inherit the resolved root from another location when the
6446
- * declaration is a derivative slot (e.g. `recordingsLow` defaults to
6447
- * `recordings`).
6448
- * - **ids are global** — `id` values are shared across the entire deployment;
6449
- * two addons declaring the same `id` must agree on `cardinality` (validated
6450
- * at kernel aggregation time, not here).
6451
- */
6452
- var StorageLocationDeclarationSchema = object({
6453
- /**
6454
- * Global location identifier, e.g. `recordings` or `recordingsLow`.
6455
- * Must start with a lowercase letter and may contain letters, digits, and
6456
- * hyphens.
6457
- */
6458
- id: string().regex(/^[a-z][a-zA-Z0-9-]*$/, { message: "id must start with a lowercase letter and contain only letters, digits, or hyphens" }),
6459
- /** Human-readable name shown in the admin UI. */
6460
- displayName: string().min(1, { message: "displayName must not be empty" }),
6461
- /** Optional longer explanation of what data this location stores. */
6462
- description: string().optional(),
6463
- /**
6464
- * `single` — exactly one instance of this location is allowed system-wide
6465
- * (e.g. `logs`, `models`). The operator can edit it but not add more.
6466
- * `multi` — the operator may register several instances (e.g. a second
6467
- * `recordings` on a NAS for disk tiering); one is the default at any time.
6468
- */
6469
- cardinality: _enum(["single", "multi"]),
6470
- /**
6471
- * When set, the default instance for this location inherits its resolved
6472
- * root from the named location's default instance. Useful for derivative
6473
- * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
6474
- * configure the primary location.
6475
- */
6476
- defaultsTo: string().optional()
6477
- });
6478
- var DecoderStatsSchema = object({
6479
- inputFps: number(),
6480
- outputFps: number(),
6481
- avgDecodeTimeMs: number(),
6482
- droppedFrames: number()
6483
- });
6484
- var DecoderSessionConfigSchema = object({
6485
- codec: string(),
6486
- maxFps: number().default(0),
6487
- outputFormat: _enum([
6488
- "jpeg",
6489
- "rgb",
6490
- "bgr",
6491
- "yuv420",
6492
- "gray"
6493
- ]).default("jpeg"),
6494
- scale: number().default(1),
6495
- width: number().optional(),
6496
- height: number().optional(),
6180
+ var DeviceType = /* @__PURE__ */ function(DeviceType) {
6181
+ DeviceType["Camera"] = "camera";
6182
+ DeviceType["Hub"] = "hub";
6183
+ DeviceType["Light"] = "light";
6184
+ DeviceType["Siren"] = "siren";
6185
+ DeviceType["Switch"] = "switch";
6186
+ DeviceType["Sensor"] = "sensor";
6187
+ DeviceType["Thermostat"] = "thermostat";
6188
+ DeviceType["Button"] = "button";
6189
+ /** Generic stateless event emitter — carries a device's EXACT declared
6190
+ * event vocabulary verbatim (no normalization). Installed with the
6191
+ * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
6192
+ * HA bus events (e.g. `zha_event`, generic). */
6193
+ DeviceType["EventEmitter"] = "event-emitter";
6194
+ /** Firmware/software update entity — current vs available version,
6195
+ * updatable flag, update state, and an install action. Installed with
6196
+ * the `update` cap. Sources: Homematic firmware-update channels (and
6197
+ * reusable by other providers, e.g. HA `update.*` entities). */
6198
+ DeviceType["Update"] = "update";
6199
+ DeviceType["Generic"] = "generic";
6200
+ /** Generic notification delivery target (HA `notify.<service>`, future
6201
+ * Telegram / Discord / ntfy / SMTP, …). One device per delivery
6202
+ * endpoint; the `notifier` cap defines the send surface. */
6203
+ DeviceType["Notifier"] = "notifier";
6204
+ /** Pre-recorded action sequence with optional parameters
6205
+ * (HA `script.*`). Runnable via `script-runner` cap. */
6206
+ DeviceType["Script"] = "script";
6207
+ /** Automation rule (HA `automation.*`) enable/disable + manual
6208
+ * trigger surface exposed via `automation-control` cap. */
6209
+ DeviceType["Automation"] = "automation";
6210
+ /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
6211
+ DeviceType["Lock"] = "lock";
6212
+ /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
6213
+ * `valve.*`). `cover` cap with sub-roles for variant. */
6214
+ DeviceType["Cover"] = "cover";
6215
+ /** Pipe / water / gas valve with open/close/stop and optional
6216
+ * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
6217
+ * modelled on the same open/closed lifecycle. */
6218
+ DeviceType["Valve"] = "valve";
6219
+ /** Humidifier / dehumidifier with on/off + target humidity + mode
6220
+ * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
6221
+ * modelled on the same target / mode lifecycle. */
6222
+ DeviceType["Humidifier"] = "humidifier";
6223
+ /** Water heater / boiler with target temperature + operation mode +
6224
+ * away mode (HA `water_heater.*`). `water-heater` cap a
6225
+ * climate-family actuator. */
6226
+ DeviceType["WaterHeater"] = "water-heater";
6227
+ /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
6228
+ DeviceType["Fan"] = "fan";
6229
+ /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
6230
+ * the camera surface those use `Camera`. `media-player` cap. */
6231
+ DeviceType["MediaPlayer"] = "media-player";
6232
+ /** Security panel / alarm system (HA `alarm_control_panel.*`).
6233
+ * `alarm-panel` cap. */
6234
+ DeviceType["AlarmPanel"] = "alarm-panel";
6235
+ /** Generic user-settable input (HA `number` / `input_number` / `select`
6236
+ * / `input_select` / `text` / `input_text` / `input_datetime`).
6237
+ * Sub-type via `DeviceRole`: NumericControl / SelectControl /
6238
+ * TextControl / DateTimeControl. */
6239
+ DeviceType["Control"] = "control";
6240
+ /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
6241
+ * `presence` cap. */
6242
+ DeviceType["Presence"] = "presence";
6243
+ /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
6244
+ * `weather` cap. */
6245
+ DeviceType["Weather"] = "weather";
6246
+ /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
6247
+ DeviceType["Vacuum"] = "vacuum";
6248
+ /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
6249
+ * `lawn-mower-control` cap. */
6250
+ DeviceType["LawnMower"] = "lawn-mower";
6251
+ /** Physical HA device group — parent container for entity-children
6252
+ * adopted from a single HA device entry. Not renderable as a
6253
+ * standalone device; exists only to anchor child entities. */
6254
+ DeviceType["Container"] = "container";
6255
+ /** Single still-image entity (HA `image.*`). Read-only display of an
6256
+ * `entity_picture` signed URL the browser loads directly. `image` cap. */
6257
+ DeviceType["Image"] = "image";
6258
+ return DeviceType;
6259
+ }({});
6260
+ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
6261
+ DeviceFeature["BatteryOperated"] = "battery-operated";
6262
+ DeviceFeature["Rebootable"] = "rebootable";
6497
6263
  /**
6498
- * Identifier of the camera this decoder session serves. Optional
6499
- * because the cap is generic (any caller could request decode), but
6500
- * stream-broker passes it so decoder logs include `deviceId` for
6501
- * per-camera filtering when diagnosing failures (e.g. node-av
6502
- * sendPacket errors on a single hung camera).
6264
+ * Device supports an on-demand re-sync of its derived spec with its
6265
+ * upstream source drives the generic Re-sync button. The owning
6266
+ * provider implements the action via the `device-adoption.resync` cap.
6503
6267
  */
6504
- deviceId: number().int().nonnegative().optional(),
6268
+ DeviceFeature["Resyncable"] = "resyncable";
6269
+ DeviceFeature["NativeSnapshot"] = "native-snapshot";
6270
+ DeviceFeature["DoorbellButton"] = "doorbell-button";
6271
+ DeviceFeature["TwoWayAudio"] = "two-way-audio";
6272
+ DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
6505
6273
  /**
6506
- * Free-form tag for log scoping. Stream-broker uses
6507
- * `broker:<deviceId>/<profile>`. Decoder session logger surfaces it
6508
- * on every line so `grep tag=broker:5/high` filters one camera
6509
- * profile cleanly.
6274
+ * Camera supports the on-firmware autotrack subsystem (subject-
6275
+ * following). Distinct from `PanTiltZoom` because not every PTZ
6276
+ * camera ships autotrack the admin UI uses this flag to gate
6277
+ * the autotrack toggle / settings card without re-deriving from
6278
+ * the cap registry. Mirrors `ptz-autotrack` cap registration:
6279
+ * driver sets this feature when probe confirms the firmware
6280
+ * surface, and registers the cap in the same code path.
6510
6281
  */
6511
- tag: string().optional(),
6282
+ DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
6512
6283
  /**
6513
- * Where the session delivers decoded frames (Phase 5 / D9):
6284
+ * Accessory exposes a "trigger on motion" toggle the parent camera's
6285
+ * motion detection automatically activates this device. Mirrors
6286
+ * `motion-trigger` cap registration: drivers set this feature in the
6287
+ * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
6514
6288
  *
6515
- * - `'callback'` (default) the legacy pixel path: decoded frames are
6516
- * buffered as `DecodedFrame`s and drained via `pullFrames`.
6517
- * - `'shm'` the shared-memory frame plane: decoded frames are written
6518
- * into an OS shared-memory ring and drained as zero-pixel
6519
- * `FrameHandle`s via `pullHandles`. A session is one mode or the
6520
- * other — `pullFrames` returns nothing for an `'shm'` session and
6521
- * `pullHandles` returns nothing for a `'callback'` session.
6522
- */
6523
- frameSink: _enum(["callback", "shm"]).default("callback")
6524
- });
6525
- var EncodeProfileSchema = object({
6526
- video: object({
6527
- codec: _enum([
6528
- "h264",
6529
- "h265",
6530
- "copy"
6531
- ]),
6532
- profile: _enum([
6533
- "baseline",
6534
- "main",
6535
- "high"
6536
- ]).optional(),
6537
- width: number().int().positive().optional(),
6538
- height: number().int().positive().optional(),
6539
- fps: number().positive().optional(),
6540
- bitrateKbps: number().int().positive().optional(),
6541
- gopFrames: number().int().positive().optional(),
6542
- bf: number().int().min(0).optional(),
6543
- preset: _enum([
6544
- "ultrafast",
6545
- "superfast",
6546
- "veryfast",
6547
- "faster",
6548
- "fast",
6549
- "medium"
6550
- ]).optional(),
6551
- tune: _enum([
6552
- "zerolatency",
6553
- "film",
6554
- "animation"
6555
- ]).optional()
6556
- }),
6557
- audio: union([literal("passthrough"), object({
6558
- codec: _enum([
6559
- "opus",
6560
- "aac",
6561
- "pcmu",
6562
- "pcma",
6563
- "copy"
6564
- ]),
6565
- bitrateKbps: number().int().positive().optional(),
6566
- sampleRateHz: number().int().positive().optional(),
6567
- channels: union([literal(1), literal(2)]).optional()
6568
- })]),
6569
- /**
6570
- * ffmpeg input-side args, inserted between the fixed global flags
6571
- * (`-hide_banner -loglevel error`) and `-i pipe:0`. Free-text array
6572
- * — the widget surfaces a textarea + suggestion chips for the most-
6573
- * used demuxer/format options.
6574
- */
6575
- inputArgs: array(string()).optional(),
6576
- /**
6577
- * ffmpeg output-side args, inserted between the encode block and
6578
- * the final `-f <muxer> pipe:1`. Use for muxer options, bitstream
6579
- * filters, codec-specific overrides. Free-text array.
6289
+ * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
6290
+ * fast scalar without binding fetch), notifier rules, and `listAll`
6291
+ * filters that want "all devices with on-motion behaviour".
6580
6292
  */
6581
- outputArgs: array(string()).optional()
6582
- });
6583
- /**
6584
- import { errMsg } from '@camstack/types'
6585
- * Extract a human-readable message from an unknown error value.
6586
- * Replaces the ubiquitous `errMsg(err)` pattern.
6587
- */
6588
- function errMsg(err) {
6589
- if (err instanceof Error) return err.message;
6590
- if (typeof err === "string") return err;
6591
- return String(err);
6293
+ DeviceFeature["MotionTrigger"] = "motion-trigger";
6294
+ /** Light supports rgb-triplet color via `color` cap. */
6295
+ DeviceFeature["LightColorRgb"] = "light-color-rgb";
6296
+ /** Light supports HSV color via `color` cap. */
6297
+ DeviceFeature["LightColorHsv"] = "light-color-hsv";
6298
+ /** Light supports color-temperature (mired) via `color` cap. */
6299
+ DeviceFeature["LightColorMired"] = "light-color-mired";
6300
+ /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
6301
+ * targetHigh). Gates the range slider UI. */
6302
+ DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
6303
+ /** Thermostat exposes target humidity and/or current humidity
6304
+ * readings. Gates the humidity controls. */
6305
+ DeviceFeature["ClimateHumidity"] = "climate-humidity";
6306
+ /** Thermostat exposes a fan-mode selector. */
6307
+ DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
6308
+ /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
6309
+ DeviceFeature["ClimatePreset"] = "climate-preset";
6310
+ /** Cover exposes intermediate position control (0..100). Gates the
6311
+ * position slider UI. */
6312
+ DeviceFeature["CoverPositionable"] = "cover-positionable";
6313
+ /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
6314
+ DeviceFeature["CoverTilt"] = "cover-tilt";
6315
+ /** Valve exposes intermediate position control (0..100). Gates the
6316
+ * position slider / drag surface UI. */
6317
+ DeviceFeature["ValvePositionable"] = "valve-positionable";
6318
+ /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
6319
+ DeviceFeature["FanSpeed"] = "fan-speed";
6320
+ /** Fan exposes a preset mode selector. */
6321
+ DeviceFeature["FanPreset"] = "fan-preset";
6322
+ /** Fan exposes blade direction (forward/reverse) — typical of
6323
+ * ceiling fans. */
6324
+ DeviceFeature["FanDirection"] = "fan-direction";
6325
+ /** Fan exposes an oscillation toggle. */
6326
+ DeviceFeature["FanOscillating"] = "fan-oscillating";
6327
+ /** Lock requires a PIN code on lock/unlock. Gates the code-entry
6328
+ * field on the UI lock-controls panel. */
6329
+ DeviceFeature["LockPinRequired"] = "lock-pin-required";
6330
+ /** Lock supports a latch-release ("open door") action distinct from
6331
+ * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
6332
+ * `supported_features`. Gates the Open Door button in the UI. */
6333
+ DeviceFeature["LockOpen"] = "lock-open";
6334
+ /** Media player exposes a seek-to-position surface. */
6335
+ DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
6336
+ /** Media player exposes a volume-level setter. */
6337
+ DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
6338
+ /** Media player exposes a mute toggle distinct from volume=0. */
6339
+ DeviceFeature["MediaPlayerMute"] = "media-player-mute";
6340
+ /** Media player exposes a shuffle toggle. */
6341
+ DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
6342
+ /** Media player exposes a repeat mode (off / all / one). */
6343
+ DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
6344
+ /** Media player exposes a source / input selector. */
6345
+ DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
6346
+ /** Media player exposes a play-arbitrary-media surface (URL / id). */
6347
+ DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
6348
+ /** Media player exposes next-track. */
6349
+ DeviceFeature["MediaPlayerNext"] = "media-player-next";
6350
+ /** Media player exposes previous-track. */
6351
+ DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
6352
+ /** Media player exposes stop distinct from pause. */
6353
+ DeviceFeature["MediaPlayerStop"] = "media-player-stop";
6354
+ /** Alarm panel requires a PIN code on arm/disarm. */
6355
+ DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
6356
+ /** Presence device carries GPS coordinates (lat/lng/accuracy) in
6357
+ * addition to a textual location. */
6358
+ DeviceFeature["PresenceGps"] = "presence-gps";
6359
+ /** Notifier accepts an inline / URL image attachment. */
6360
+ DeviceFeature["NotifierImage"] = "notifier-image";
6361
+ /** Notifier accepts a priority hint (high/normal/low). */
6362
+ DeviceFeature["NotifierPriority"] = "notifier-priority";
6363
+ /** Notifier accepts a free-form `data` payload for platform-specific
6364
+ * fields. */
6365
+ DeviceFeature["NotifierData"] = "notifier-data";
6366
+ /** Notifier supports interactive action buttons / callbacks. */
6367
+ DeviceFeature["NotifierActions"] = "notifier-actions";
6368
+ /** Notifier supports per-call recipient targeting (multi-user). */
6369
+ DeviceFeature["NotifierRecipients"] = "notifier-recipients";
6370
+ /** Script runner accepts a variables map on each run invocation. */
6371
+ DeviceFeature["ScriptVariables"] = "script-variables";
6372
+ /** Automation `trigger` accepts a skipCondition flag — fires the
6373
+ * automation's actions while bypassing its condition block. */
6374
+ DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
6375
+ return DeviceFeature;
6376
+ }({});
6377
+ /**
6378
+ * Semantic role a device plays within its parent. Populated by driver
6379
+ * addons when creating accessory devices (Reolink siren/floodlight/
6380
+ * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
6381
+ * admin UI to pick icons, labels, and widgets — a `Switch` with
6382
+ * `role: Floodlight` renders as a bulb with a brightness slider,
6383
+ * whereas a `Switch` with `role: Siren` renders as a klaxon.
6384
+ *
6385
+ * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
6386
+ * sqlite as a nullable TEXT column — old rows keep working unchanged.
6387
+ */
6388
+ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
6389
+ DeviceRole["Siren"] = "siren";
6390
+ DeviceRole["Floodlight"] = "floodlight";
6391
+ DeviceRole["Spotlight"] = "spotlight";
6392
+ DeviceRole["PirSensor"] = "pir-sensor";
6393
+ DeviceRole["Chime"] = "chime";
6394
+ DeviceRole["Autotrack"] = "autotrack";
6395
+ DeviceRole["Nightvision"] = "nightvision";
6396
+ DeviceRole["PrivacyMask"] = "privacy-mask";
6397
+ DeviceRole["Doorbell"] = "doorbell";
6398
+ /** Virtual HA toggle (input_boolean.*) — distinguishable from a
6399
+ * real Switch device for UI rendering / export adapters. */
6400
+ DeviceRole["BinaryHelper"] = "binary-helper";
6401
+ /** Generic motion / occupancy / moving event source. Distinct from
6402
+ * the camera accessory PirSensor role: that one is a camera child;
6403
+ * this is a standalone HA / 3rd-party motion sensor. */
6404
+ DeviceRole["MotionSensor"] = "motion-sensor";
6405
+ DeviceRole["ContactSensor"] = "contact-sensor";
6406
+ DeviceRole["LeakSensor"] = "leak-sensor";
6407
+ DeviceRole["SmokeSensor"] = "smoke-sensor";
6408
+ DeviceRole["COSensor"] = "co-sensor";
6409
+ DeviceRole["GasSensor"] = "gas-sensor";
6410
+ DeviceRole["TamperSensor"] = "tamper-sensor";
6411
+ DeviceRole["VibrationSensor"] = "vibration-sensor";
6412
+ DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
6413
+ DeviceRole["SoundSensor"] = "sound-sensor";
6414
+ /** Fallback for `binary_sensor` without a known `device_class`. */
6415
+ DeviceRole["BinarySensor"] = "binary-sensor";
6416
+ DeviceRole["TemperatureSensor"] = "temperature-sensor";
6417
+ DeviceRole["HumiditySensor"] = "humidity-sensor";
6418
+ DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
6419
+ DeviceRole["PressureSensor"] = "pressure-sensor";
6420
+ DeviceRole["PowerSensor"] = "power-sensor";
6421
+ DeviceRole["EnergySensor"] = "energy-sensor";
6422
+ DeviceRole["VoltageSensor"] = "voltage-sensor";
6423
+ DeviceRole["CurrentSensor"] = "current-sensor";
6424
+ DeviceRole["AirQualitySensor"] = "air-quality-sensor";
6425
+ /** Battery level (numeric % via `sensor` OR low-bool via
6426
+ * `binary_sensor` — the cap distinguishes via the value type). */
6427
+ DeviceRole["BatterySensor"] = "battery-sensor";
6428
+ /** Fallback for `sensor` numeric without a known `device_class`. */
6429
+ DeviceRole["NumericSensor"] = "numeric-sensor";
6430
+ /** String / enum state (HA `sensor` with `state_class: enum` or
6431
+ * `attributes.options`). */
6432
+ DeviceRole["EnumSensor"] = "enum-sensor";
6433
+ /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
6434
+ * or `date`). The slice carries the raw ISO string verbatim (hosted on
6435
+ * the `enum-sensor` cap); the UI renders it locale-formatted. */
6436
+ DeviceRole["DateTimeSensor"] = "datetime-sensor";
6437
+ /** Last-resort fallback when nothing else matches. */
6438
+ DeviceRole["GenericSensor"] = "generic-sensor";
6439
+ DeviceRole["NumericControl"] = "numeric-control";
6440
+ DeviceRole["SelectControl"] = "select-control";
6441
+ DeviceRole["TextControl"] = "text-control";
6442
+ DeviceRole["DateTimeControl"] = "datetime-control";
6443
+ /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
6444
+ * rich features (image, priority, channel routing). */
6445
+ DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
6446
+ /** Chat / messaging service (HA `notify.telegram_*`,
6447
+ * `notify.discord_*`, etc.). */
6448
+ DeviceRole["MessagingNotifier"] = "messaging-notifier";
6449
+ /** Email-based delivery (HA `notify.smtp`, etc.). */
6450
+ DeviceRole["EmailNotifier"] = "email-notifier";
6451
+ /** Fallback when the notifier service name doesn't match a known
6452
+ * pattern. */
6453
+ DeviceRole["GenericNotifier"] = "generic-notifier";
6454
+ return DeviceRole;
6455
+ }({});
6456
+ /**
6457
+ * Generic types for capability definitions.
6458
+ *
6459
+ * A capability is defined with Zod schemas for methods, events, and settings.
6460
+ * TypeScript types are inferred via z.infer<> — zero duplication.
6461
+ *
6462
+ * Pattern:
6463
+ * 1. Define Zod schemas for data, methods, settings
6464
+ * 2. Export const capabilityDef = { ... } satisfies CapabilityDefinition
6465
+ * 3. Export type IProvider = InferProvider<typeof capabilityDef>
6466
+ * 4. Addon implements IProvider
6467
+ * 5. Registry auto-mounts tRPC router from definition.methods
6468
+ */
6469
+ /**
6470
+ * Output schema shared by the contribution + live methods.
6471
+ *
6472
+ * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
6473
+ * tabs[]) without importing from `../interfaces/config-ui.js` — a
6474
+ * concrete-but-lenient Zod object keeps tRPC output inference happy
6475
+ * (using `z.unknown()` here collapses unrelated router branches to
6476
+ * `unknown` when the generator re-inlines the huge AppRouter type).
6477
+ *
6478
+ * `.passthrough()` on sections/fields accepts whatever FormBuilder
6479
+ * extensions the caller adds (showWhen, displayScale, …) without
6480
+ * rebuilding every time a new field kind is introduced.
6481
+ */
6482
+ var ContributionSectionSchema = object({
6483
+ id: string(),
6484
+ title: string(),
6485
+ description: string().optional(),
6486
+ style: _enum(["card", "accordion"]).optional(),
6487
+ defaultCollapsed: boolean().optional(),
6488
+ columns: union([
6489
+ literal(1),
6490
+ literal(2),
6491
+ literal(3),
6492
+ literal(4)
6493
+ ]).optional(),
6494
+ tab: string().optional(),
6495
+ location: _enum(["settings", "top-tab"]).optional(),
6496
+ order: number().optional(),
6497
+ fields: array(any())
6498
+ });
6499
+ object({
6500
+ tabs: array(object({
6501
+ id: string(),
6502
+ label: string(),
6503
+ icon: string(),
6504
+ order: number().optional()
6505
+ })).optional(),
6506
+ sections: array(ContributionSectionSchema)
6507
+ }).nullable();
6508
+ object({ deviceId: number() }), object({ deviceId: number() }), object({
6509
+ deviceId: number(),
6510
+ patch: record(string(), unknown())
6511
+ }), object({ success: literal(true) });
6512
+ object({ deviceId: number() }), unknown().nullable();
6513
+ /** Shorthand to define a method schema */
6514
+ function method(input, output, options) {
6515
+ return {
6516
+ input,
6517
+ output,
6518
+ kind: options?.kind ?? "query",
6519
+ auth: options?.auth ?? "protected",
6520
+ ...options?.access !== void 0 ? { access: options.access } : {},
6521
+ timeoutMs: options?.timeoutMs
6522
+ };
6592
6523
  }
6593
- var YAMNET_TO_MACRO = {
6594
- mapping: {
6595
- Speech: "speech",
6596
- "Child speech, kid speaking": "speech",
6597
- Conversation: "speech",
6598
- "Narration, monologue": "speech",
6599
- Babbling: "speech",
6600
- Whispering: "speech",
6601
- "Speech synthesizer": "speech",
6602
- Humming: "speech",
6603
- Rapping: "speech",
6604
- Singing: "speech",
6605
- Choir: "speech",
6606
- "Child singing": "speech",
6607
- Shout: "scream",
6608
- Bellow: "scream",
6609
- Yell: "scream",
6610
- Screaming: "scream",
6611
- "Children shouting": "scream",
6612
- Whoop: "scream",
6613
- "Crying, sobbing": "crying",
6614
- "Baby cry, infant cry": "crying",
6615
- Whimper: "crying",
6616
- "Wail, moan": "crying",
6617
- Groan: "crying",
6618
- Laughter: "laughter",
6619
- "Baby laughter": "laughter",
6620
- Giggle: "laughter",
6621
- Snicker: "laughter",
6622
- "Belly laugh": "laughter",
6623
- "Chuckle, chortle": "laughter",
6624
- Music: "music",
6625
- "Musical instrument": "music",
6626
- Guitar: "music",
6627
- Piano: "music",
6628
- Drum: "music",
6629
- "Drum kit": "music",
6630
- "Violin, fiddle": "music",
6631
- Flute: "music",
6632
- Saxophone: "music",
6633
- Trumpet: "music",
6634
- Synthesizer: "music",
6635
- "Pop music": "music",
6636
- "Rock music": "music",
6637
- "Hip hop music": "music",
6638
- "Classical music": "music",
6639
- Jazz: "music",
6640
- "Electronic music": "music",
6641
- "Background music": "music",
6642
- Dog: "dog",
6643
- Bark: "dog",
6644
- Yip: "dog",
6645
- Howl: "dog",
6646
- "Bow-wow": "dog",
6647
- Growling: "dog",
6648
- "Whimper (dog)": "dog",
6649
- Cat: "cat",
6650
- Purr: "cat",
6651
- Meow: "cat",
6652
- Hiss: "cat",
6653
- Caterwaul: "cat",
6654
- Bird: "bird",
6655
- "Bird vocalization, bird call, bird song": "bird",
6656
- "Chirp, tweet": "bird",
6657
- Squawk: "bird",
6658
- Crow: "bird",
6659
- Owl: "bird",
6660
- "Pigeon, dove": "bird",
6661
- Animal: "animal",
6662
- "Domestic animals, pets": "animal",
6663
- "Livestock, farm animals, working animals": "animal",
6664
- Horse: "animal",
6665
- "Cattle, bovinae": "animal",
6666
- Pig: "animal",
6667
- Sheep: "animal",
6668
- Goat: "animal",
6669
- Frog: "animal",
6670
- Insect: "animal",
6671
- Cricket: "animal",
6672
- Alarm: "alarm",
6673
- "Alarm clock": "alarm",
6674
- "Smoke detector, smoke alarm": "alarm",
6675
- "Fire alarm": "alarm",
6676
- Buzzer: "alarm",
6677
- "Civil defense siren": "alarm",
6678
- "Car alarm": "alarm",
6679
- Siren: "siren",
6680
- "Police car (siren)": "siren",
6681
- "Ambulance (siren)": "siren",
6682
- "Fire engine, fire truck (siren)": "siren",
6683
- "Emergency vehicle": "siren",
6684
- Foghorn: "siren",
6685
- Doorbell: "doorbell",
6686
- "Ding-dong": "doorbell",
6687
- Knock: "doorbell",
6688
- Tap: "doorbell",
6689
- Glass: "glass_breaking",
6690
- Shatter: "glass_breaking",
6691
- "Chink, clink": "glass_breaking",
6692
- "Gunshot, gunfire": "gunshot",
6693
- "Machine gun": "gunshot",
6694
- Explosion: "gunshot",
6695
- Fireworks: "gunshot",
6696
- Firecracker: "gunshot",
6697
- "Artillery fire": "gunshot",
6698
- "Cap gun": "gunshot",
6699
- Boom: "gunshot",
6700
- Vehicle: "vehicle",
6701
- Car: "vehicle",
6702
- Truck: "vehicle",
6703
- Bus: "vehicle",
6704
- Motorcycle: "vehicle",
6705
- "Car passing by": "vehicle",
6706
- "Vehicle horn, car horn, honking": "vehicle",
6707
- "Traffic noise, roadway noise": "vehicle",
6708
- Train: "vehicle",
6709
- Aircraft: "vehicle",
6710
- Helicopter: "vehicle",
6711
- Bicycle: "vehicle",
6712
- Skateboard: "vehicle",
6713
- Fire: "fire",
6714
- Crackle: "fire",
6715
- Water: "water",
6716
- Rain: "water",
6717
- Raindrop: "water",
6718
- "Rain on surface": "water",
6719
- Stream: "water",
6720
- Waterfall: "water",
6721
- Ocean: "water",
6722
- "Waves, surf": "water",
6723
- "Splash, splatter": "water",
6724
- Wind: "wind",
6725
- Thunderstorm: "wind",
6726
- Thunder: "wind",
6727
- "Wind noise (microphone)": "wind",
6728
- "Rustling leaves": "wind",
6729
- Door: "door",
6730
- "Sliding door": "door",
6731
- Slam: "door",
6732
- "Cupboard open or close": "door",
6733
- "Walk, footsteps": "footsteps",
6734
- Run: "footsteps",
6735
- Shuffle: "footsteps",
6736
- Crowd: "crowd",
6737
- Chatter: "crowd",
6738
- Cheering: "crowd",
6739
- Applause: "crowd",
6740
- "Children playing": "crowd",
6741
- "Hubbub, speech noise, speech babble": "crowd",
6742
- Telephone: "telephone",
6743
- "Telephone bell ringing": "telephone",
6744
- Ringtone: "telephone",
6745
- "Telephone dialing, DTMF": "telephone",
6746
- "Busy signal": "telephone",
6747
- Engine: "engine",
6748
- "Engine starting": "engine",
6749
- Idling: "engine",
6750
- "Accelerating, revving, vroom": "engine",
6751
- "Light engine (high frequency)": "engine",
6752
- "Medium engine (mid frequency)": "engine",
6753
- "Heavy engine (low frequency)": "engine",
6754
- "Lawn mower": "engine",
6755
- Chainsaw: "engine",
6756
- Hammer: "tools",
6757
- Jackhammer: "tools",
6758
- Sawing: "tools",
6759
- "Power tool": "tools",
6760
- Drill: "tools",
6761
- Sanding: "tools",
6762
- Silence: "silence"
6763
- },
6764
- preserveOriginal: false
6765
- };
6766
- var APPLE_SA_TO_MACRO = {
6767
- mapping: {
6768
- speech: "speech",
6769
- child_speech: "speech",
6770
- conversation: "speech",
6771
- whispering: "speech",
6772
- singing: "speech",
6773
- humming: "speech",
6774
- shout: "scream",
6775
- yell: "scream",
6776
- screaming: "scream",
6777
- crying: "crying",
6778
- baby_crying: "crying",
6779
- sobbing: "crying",
6780
- laughter: "laughter",
6781
- baby_laughter: "laughter",
6782
- giggling: "laughter",
6783
- music: "music",
6784
- guitar: "music",
6785
- piano: "music",
6786
- drums: "music",
6787
- dog_bark: "dog",
6788
- dog_bow_wow: "dog",
6789
- dog_growling: "dog",
6790
- dog_howl: "dog",
6791
- cat_meow: "cat",
6792
- cat_purr: "cat",
6793
- cat_hiss: "cat",
6794
- bird: "bird",
6795
- bird_chirp: "bird",
6796
- bird_squawk: "bird",
6797
- animal: "animal",
6798
- horse: "animal",
6799
- cow_moo: "animal",
6800
- insect: "animal",
6801
- alarm: "alarm",
6802
- smoke_alarm: "alarm",
6803
- fire_alarm: "alarm",
6804
- car_alarm: "alarm",
6805
- siren: "siren",
6806
- police_siren: "siren",
6807
- ambulance_siren: "siren",
6808
- doorbell: "doorbell",
6809
- door_knock: "doorbell",
6810
- knocking: "doorbell",
6811
- glass_breaking: "glass_breaking",
6812
- glass_shatter: "glass_breaking",
6813
- gunshot: "gunshot",
6814
- explosion: "gunshot",
6815
- fireworks: "gunshot",
6816
- car: "vehicle",
6817
- truck: "vehicle",
6818
- motorcycle: "vehicle",
6819
- car_horn: "vehicle",
6820
- vehicle_horn: "vehicle",
6821
- traffic: "vehicle",
6822
- fire: "fire",
6823
- fire_crackle: "fire",
6824
- water: "water",
6825
- rain: "water",
6826
- ocean: "water",
6827
- splash: "water",
6828
- wind: "wind",
6829
- thunder: "wind",
6830
- thunderstorm: "wind",
6831
- door: "door",
6832
- door_slam: "door",
6833
- sliding_door: "door",
6834
- footsteps: "footsteps",
6835
- walking: "footsteps",
6836
- running: "footsteps",
6837
- crowd: "crowd",
6838
- chatter: "crowd",
6839
- cheering: "crowd",
6840
- applause: "crowd",
6841
- telephone_ring: "telephone",
6842
- ringtone: "telephone",
6843
- engine: "engine",
6844
- engine_starting: "engine",
6845
- lawn_mower: "engine",
6846
- chainsaw: "engine",
6847
- hammer: "tools",
6848
- jackhammer: "tools",
6849
- drill: "tools",
6850
- power_tool: "tools",
6851
- silence: "silence"
6852
- },
6853
- preserveOriginal: false
6854
- };
6855
- var _macroLookup = /* @__PURE__ */ new Map();
6856
- for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
6857
- for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
6858
- var DeviceType = /* @__PURE__ */ function(DeviceType) {
6859
- DeviceType["Camera"] = "camera";
6860
- DeviceType["Hub"] = "hub";
6861
- DeviceType["Light"] = "light";
6862
- DeviceType["Siren"] = "siren";
6863
- DeviceType["Switch"] = "switch";
6864
- DeviceType["Sensor"] = "sensor";
6865
- DeviceType["Thermostat"] = "thermostat";
6866
- DeviceType["Button"] = "button";
6867
- /** Generic stateless event emitter — carries a device's EXACT declared
6868
- * event vocabulary verbatim (no normalization). Installed with the
6869
- * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
6870
- * HA bus events (e.g. `zha_event`, generic). */
6871
- DeviceType["EventEmitter"] = "event-emitter";
6872
- /** Firmware/software update entity — current vs available version,
6873
- * updatable flag, update state, and an install action. Installed with
6874
- * the `update` cap. Sources: Homematic firmware-update channels (and
6875
- * reusable by other providers, e.g. HA `update.*` entities). */
6876
- DeviceType["Update"] = "update";
6877
- DeviceType["Generic"] = "generic";
6878
- /** Generic notification delivery target (HA `notify.<service>`, future
6879
- * Telegram / Discord / ntfy / SMTP, …). One device per delivery
6880
- * endpoint; the `notifier` cap defines the send surface. */
6881
- DeviceType["Notifier"] = "notifier";
6882
- /** Pre-recorded action sequence with optional parameters
6883
- * (HA `script.*`). Runnable via `script-runner` cap. */
6884
- DeviceType["Script"] = "script";
6885
- /** Automation rule (HA `automation.*`) enable/disable + manual
6886
- * trigger surface exposed via `automation-control` cap. */
6887
- DeviceType["Automation"] = "automation";
6888
- /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
6889
- DeviceType["Lock"] = "lock";
6890
- /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
6891
- * `valve.*`). `cover` cap with sub-roles for variant. */
6892
- DeviceType["Cover"] = "cover";
6893
- /** Pipe / water / gas valve with open/close/stop and optional
6894
- * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
6895
- * modelled on the same open/closed lifecycle. */
6896
- DeviceType["Valve"] = "valve";
6897
- /** Humidifier / dehumidifier with on/off + target humidity + mode
6898
- * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
6899
- * modelled on the same target / mode lifecycle. */
6900
- DeviceType["Humidifier"] = "humidifier";
6901
- /** Water heater / boiler with target temperature + operation mode +
6902
- * away mode (HA `water_heater.*`). `water-heater` cap — a
6903
- * climate-family actuator. */
6904
- DeviceType["WaterHeater"] = "water-heater";
6905
- /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
6906
- DeviceType["Fan"] = "fan";
6907
- /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
6908
- * the camera surface — those use `Camera`. `media-player` cap. */
6909
- DeviceType["MediaPlayer"] = "media-player";
6910
- /** Security panel / alarm system (HA `alarm_control_panel.*`).
6911
- * `alarm-panel` cap. */
6912
- DeviceType["AlarmPanel"] = "alarm-panel";
6913
- /** Generic user-settable input (HA `number` / `input_number` / `select`
6914
- * / `input_select` / `text` / `input_text` / `input_datetime`).
6915
- * Sub-type via `DeviceRole`: NumericControl / SelectControl /
6916
- * TextControl / DateTimeControl. */
6917
- DeviceType["Control"] = "control";
6918
- /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
6919
- * `presence` cap. */
6920
- DeviceType["Presence"] = "presence";
6921
- /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
6922
- * `weather` cap. */
6923
- DeviceType["Weather"] = "weather";
6924
- /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
6925
- DeviceType["Vacuum"] = "vacuum";
6926
- /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
6927
- * `lawn-mower-control` cap. */
6928
- DeviceType["LawnMower"] = "lawn-mower";
6929
- /** Physical HA device group — parent container for entity-children
6930
- * adopted from a single HA device entry. Not renderable as a
6931
- * standalone device; exists only to anchor child entities. */
6932
- DeviceType["Container"] = "container";
6933
- /** Single still-image entity (HA `image.*`). Read-only display of an
6934
- * `entity_picture` signed URL the browser loads directly. `image` cap. */
6935
- DeviceType["Image"] = "image";
6936
- return DeviceType;
6937
- }({});
6938
- var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
6939
- DeviceFeature["BatteryOperated"] = "battery-operated";
6940
- DeviceFeature["Rebootable"] = "rebootable";
6524
+ var StaticDirOutputSchema = object({ staticDir: string() });
6525
+ var VersionOutputSchema = object({ version: string() });
6526
+ method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
6527
+ /**
6528
+ * device-ops — device-scoped cap that unifies the per-IDevice operations
6529
+ * previously routed through the `.device-ops` Moleculer bridge service.
6530
+ *
6531
+ * Each worker that hosts live `IDevice` instances auto-registers a native
6532
+ * provider for this cap (per device) backed by its local
6533
+ * `DeviceRegistry`. Hub-side callers reach it transparently through
6534
+ * `ctx.fetchDevice(id).deviceOps.*` — the DeviceProxy injects
6535
+ * `deviceId` + `nodeId` and dispatches through the standard cap-router,
6536
+ * so there's no parallel bridge path anymore.
6537
+ *
6538
+ * The surface is intentionally small — every method corresponds to a
6539
+ * single action on the live `IDevice` (or `ICameraDevice` for
6540
+ * `getStreamSources`). Richer orchestration (enable/disable with
6541
+ * integration plumbing, bulk updates) stays in the `device-manager` cap;
6542
+ * `device-ops` is the per-device primitive the device-manager routes to.
6543
+ */
6544
+ var StreamSourceEntrySchema = object({
6545
+ id: string(),
6546
+ label: string(),
6547
+ protocol: _enum([
6548
+ "rtsp",
6549
+ "rtmp",
6550
+ "annexb",
6551
+ "http-mjpeg",
6552
+ "webrtc",
6553
+ "custom"
6554
+ ]),
6555
+ url: string().optional(),
6556
+ resolution: object({
6557
+ width: number(),
6558
+ height: number()
6559
+ }).optional(),
6560
+ fps: number().optional(),
6561
+ bitrate: number().optional(),
6562
+ codec: string().optional(),
6563
+ profileHint: CamProfileSchema.optional(),
6564
+ sdp: string().optional()
6565
+ });
6566
+ var ConfigEntrySchema$1 = object({
6567
+ key: string(),
6568
+ value: unknown()
6569
+ });
6570
+ var RawStateResultSchema = object({
6571
+ /** Originating provider id, e.g. 'homeassistant' | 'reolink' | 'hikvision'. */
6572
+ source: string(),
6573
+ /** Opaque, DISPLAY-SAFE upstream blob (no secrets/PII). */
6574
+ data: record(string(), unknown())
6575
+ });
6576
+ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
6577
+ deviceId: number(),
6578
+ values: record(string(), unknown())
6579
+ }), _void(), { kind: "mutation" }), method(object({
6580
+ deviceId: number(),
6581
+ action: string().min(1),
6582
+ input: unknown()
6583
+ }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
6584
+ //#endregion
6585
+ //#region ../types/dist/err-msg-IQTHeDzc.mjs
6586
+ /**
6587
+ import { errMsg } from '@camstack/types'
6588
+ * Extract a human-readable message from an unknown error value.
6589
+ * Replaces the ubiquitous `errMsg(err)` pattern.
6590
+ */
6591
+ function errMsg(err) {
6592
+ if (err instanceof Error) return err.message;
6593
+ if (typeof err === "string") return err;
6594
+ return String(err);
6595
+ }
6596
+ //#endregion
6597
+ //#region ../types/dist/index.mjs
6598
+ /**
6599
+ * Deep wiring healthcheck — snapshot of active reachability probes across
6600
+ * every declared capability + widget of every installed plugin, on every
6601
+ * node. Produced by the backend `WiringHealthService` and surfaced via
6602
+ * `GET /health/wiring`, the tRPC `health.wiring` query, and the boot-gate.
6603
+ *
6604
+ * Unlike `/health` (process liveness), this reflects whether each cap/widget
6605
+ * is actually *reachable* over the real cap-dispatch path. See spec
6606
+ * `docs/superpowers/specs/2026-05-23-deep-healthcheck-design.md`.
6607
+ */
6608
+ /** What kind of target a probe addressed. */
6609
+ var wiringProbeKindSchema = _enum([
6610
+ "singleton",
6611
+ "device",
6612
+ "widget"
6613
+ ]);
6614
+ /** Result of probing a single (cap|widget [, device]) target. */
6615
+ var wiringProbeResultSchema = object({
6616
+ capName: string(),
6617
+ kind: wiringProbeKindSchema,
6618
+ deviceId: number().optional(),
6619
+ reachable: boolean(),
6620
+ latencyMs: number(),
6621
+ error: string().optional()
6622
+ });
6623
+ /** Per-addon roll-up of cap + widget probe results. */
6624
+ var wiringAddonHealthSchema = object({
6625
+ addonId: string(),
6626
+ caps: array(wiringProbeResultSchema).readonly(),
6627
+ widgets: array(wiringProbeResultSchema).readonly()
6628
+ });
6629
+ /** Per-node roll-up. */
6630
+ var wiringNodeHealthSchema = object({
6631
+ nodeId: string(),
6632
+ addons: array(wiringAddonHealthSchema).readonly()
6633
+ });
6634
+ object({
6635
+ /** True only when every probed target is reachable. */
6636
+ ok: boolean(),
6637
+ /** True when at least one target is unreachable. */
6638
+ degraded: boolean(),
6639
+ checkedAt: string(),
6640
+ nodes: array(wiringNodeHealthSchema).readonly(),
6641
+ summary: object({
6642
+ total: number(),
6643
+ reachable: number(),
6644
+ unreachable: number()
6645
+ })
6646
+ });
6647
+ var MODEL_FORMATS = [
6648
+ "onnx",
6649
+ "coreml",
6650
+ "openvino",
6651
+ "tflite",
6652
+ "pt"
6653
+ ];
6654
+ /**
6655
+ * Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
6656
+ * Named `RecordingWeekday` to avoid collision with the string-union
6657
+ * `Weekday` exported from `interfaces/timezones.ts`.
6658
+ */
6659
+ var RecordingWeekdaySchema = number().int().min(0).max(6);
6660
+ var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
6661
+ var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
6662
+ kind: literal("timeOfDay"),
6663
+ start: string().regex(HHMM),
6664
+ end: string().regex(HHMM),
6665
+ /** Restrict to these weekdays; omit = every day. */
6666
+ days: array(RecordingWeekdaySchema).optional()
6667
+ })]);
6668
+ var RecordingModeSchema = _enum([
6669
+ "continuous",
6670
+ "onMotion",
6671
+ "onAudioThreshold"
6672
+ ]);
6673
+ /**
6674
+ * First-class, authoritative per-camera storage mode — the netta choice the UI
6675
+ * reads directly (never inferred from `rules`):
6676
+ * - `off` — not recording.
6677
+ * - `events` — record only around triggers (motion / audio threshold),
6678
+ * with pre/post-buffer.
6679
+ * - `continuous` — record 24/7 within the schedule.
6680
+ *
6681
+ * `mode` compiles one-way to the internal `rules[]` consumed by the policy
6682
+ * engine (see `compileRules`); `rules[]` is never authored directly anymore.
6683
+ */
6684
+ var RecordingStorageModeSchema = _enum([
6685
+ "off",
6686
+ "events",
6687
+ "continuous"
6688
+ ]);
6689
+ /** Which detectors trigger an `events`-mode recording. */
6690
+ var RecordingTriggersSchema = object({
6691
+ motion: boolean().optional(),
6692
+ audioThresholdDbfs: number().optional()
6693
+ });
6694
+ /**
6695
+ * Mode of a single recording band — the recorder per-band vocabulary.
6696
+ *
6697
+ * Distinct from `RecordingStorageModeSchema` (which carries `off`): a band is
6698
+ * only ever `continuous` or `events`; "off" is expressed by the absence of a
6699
+ * covering band, not by a band value.
6700
+ */
6701
+ var RecordingBandModeSchema = _enum(["continuous", "events"]);
6702
+ /**
6703
+ * Triggers for an `events`-mode band. Identical shape to
6704
+ * `RecordingTriggersSchema` — reuse that schema as the band trigger type so the
6705
+ * two never drift.
6706
+ */
6707
+ var RecordingBandTriggersSchema = RecordingTriggersSchema;
6708
+ /**
6709
+ * A single mode-per-band window — the canonical recorder band shape, the
6710
+ * single source of truth re-used by `addon-pipeline/recorder`.
6711
+ *
6712
+ * `days` lists the weekdays the band covers (empty = every day, matching the
6713
+ * band engine's `applies` rule). `start`/`end` are `HH:MM`; an `end <= start`
6714
+ * span wraps past midnight (handled by the band engine).
6715
+ */
6716
+ var RecordingBandSchema = object({
6717
+ days: array(RecordingWeekdaySchema),
6718
+ start: string().regex(HHMM),
6719
+ end: string().regex(HHMM),
6720
+ mode: RecordingBandModeSchema,
6721
+ triggers: RecordingBandTriggersSchema.optional(),
6722
+ preBufferSec: number().min(0).optional(),
6723
+ postBufferSec: number().min(0).optional()
6724
+ });
6725
+ var RecordingRuleSchema = object({
6726
+ schedule: RecordingScheduleSchema,
6727
+ mode: RecordingModeSchema,
6728
+ /** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
6729
+ preBufferSec: number().min(0).default(0),
6730
+ /** Keep recording until this many seconds after the last trigger. */
6731
+ postBufferSec: number().min(0).default(0),
6732
+ /** Each new trigger restarts the post-buffer window. */
6733
+ resetTimeoutOnNewEvent: boolean().default(true),
6734
+ /** onAudioThreshold only — dBFS level that counts as a trigger. */
6735
+ thresholdDbfs: number().optional()
6736
+ });
6737
+ /**
6738
+ * Per-device retention overrides. Every field is optional; an unset or `0`
6739
+ * value inherits the node-wide recorder default. Only footage-lifetime limits
6740
+ * live per-camera: `maxAgeDays` and `maxSizeGb`. The disk-occupancy threshold
6741
+ * (when the volume is too full to keep recording) is NOT a per-camera concern —
6742
+ * it belongs to the StorageLocation (`StorageLocation.config.minFreePercent`),
6743
+ * shared by every camera writing to that volume.
6744
+ */
6745
+ var RecordingRetentionSchema = object({
6746
+ maxAgeDays: number().min(0).optional(),
6747
+ maxSizeGb: number().min(0).optional()
6748
+ });
6749
+ /**
6750
+ * The full per-camera recording intent — the wire shape of a RecordingTarget.
6751
+ *
6752
+ * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
6753
+ * are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
6754
+ * only for transition + migration (`migrateRulesToMode`); the policy engine
6755
+ * consumes the compiled output of `compileRules(config)`, never `rules` directly.
6756
+ */
6757
+ var RecordingConfigSchema = object({
6758
+ enabled: boolean(),
6759
+ /** Authoritative storage mode. Absent on legacy targets → derived once via
6760
+ * `migrateRulesToMode`, then persisted. */
6761
+ mode: RecordingStorageModeSchema.optional(),
6762
+ profiles: array(CamProfileSchema).optional(),
6763
+ segmentSeconds: number().int().positive().optional(),
6764
+ /** Shared recording time-bands for `events` & `continuous` — record only when
6765
+ * the wall-clock falls inside one of these windows. Omit or empty = always.
6766
+ * `continuous` compiles to one rule per band; `events` to band × trigger. */
6767
+ schedules: array(RecordingScheduleSchema).optional(),
6768
+ /** Legacy single-band predecessor of `schedules`. Read-compat only — it is
6769
+ * normalized into `schedules` on read and never written going forward. (Not
6770
+ * tagged `@deprecated`: the normalization paths must read it cast-free.) */
6771
+ schedule: RecordingScheduleSchema.optional(),
6772
+ /** `events`-mode only — which detectors trigger a recording. */
6773
+ triggers: RecordingTriggersSchema.optional(),
6774
+ /** `events`-mode only — seconds retained before / after a trigger. */
6775
+ preBufferSec: number().min(0).optional(),
6776
+ postBufferSec: number().min(0).optional(),
6777
+ /** DEPRECATED authoring input; retained for migration/transition. */
6778
+ rules: array(RecordingRuleSchema).optional(),
6779
+ /**
6780
+ * AUTHORITATIVE mode-per-band recording model (recorder). When present it
6781
+ * is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
6782
+ * `triggers`/`rules` fields above are kept for READ-COMPAT only and are
6783
+ * derived into bands once via `migrateConfigToBands`.
6784
+ */
6785
+ bands: array(RecordingBandSchema).optional(),
6786
+ retention: RecordingRetentionSchema.optional()
6787
+ });
6788
+ /**
6789
+ * `StorageLocationType` an addon-declared id that identifies the *kind* of
6790
+ * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
6791
+ * so the persisted record schema and the consumer-facing cap can both consume it
6792
+ * without forming a circular import. The `storage` cap re-exports it
6793
+ * verbatim for back-compat.
6794
+ *
6795
+ * This Zod schema is the **authoritative source** for `StorageLocationType`.
6796
+ * The TS alias in `./storage.ts` re-exports `z.infer<typeof
6797
+ * StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
6798
+ * `IStorageProvider` interface stay in lockstep.
6799
+ *
6800
+ * The type is now an **open string** (not a closed enum) — addons declare
6801
+ * their own location kinds via `StorageLocationDeclaration.id`. The regex
6802
+ * enforces a safe id format: lowercase-start, alphanumeric + hyphens.
6803
+ */
6804
+ var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
6805
+ /**
6806
+ * Persisted record for a storage location instance. Operators can register
6807
+ * multiple instances for multi-cardinality types (e.g. two `backups`
6808
+ * locations with different `providerId`s). Cardinality is now declared per
6809
+ * location via `StorageLocationDeclaration.cardinality` the static
6810
+ * `STORAGE_LOCATION_CARDINALITY` map has been removed.
6811
+ *
6812
+ * `id` is a stable namespaced string of the form `<type>:<slug>`.
6813
+ * The default location for a type uses `id === <type>:default` by
6814
+ * convention (the bare type ref like `'backups'` resolves to it).
6815
+ *
6816
+ * `isSystem: true` marks a location as orchestrator-seeded and
6817
+ * undeletable. The bootstrap-installed defaults (one per type) carry
6818
+ * this flag; operator-added locations don't. Editing the config of
6819
+ * a system location is allowed (path migration, provider swap) but
6820
+ * deleting it is rejected at the cap level.
6821
+ */
6822
+ var StorageLocationSchema = object({
6823
+ id: string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
6824
+ type: string(),
6825
+ displayName: string().min(1),
6826
+ providerId: string().min(1),
6827
+ config: record(string(), unknown()),
6941
6828
  /**
6942
- * Device supports an on-demand re-sync of its derived spec with its
6943
- * upstream sourcedrives the generic Re-sync button. The owning
6944
- * provider implements the action via the `device-adoption.resync` cap.
6829
+ * Cluster node this location physically lives on. REQUIRED for node-local
6830
+ * providers (filesystem — the path exists on one node's disk), null/absent
6831
+ * for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
6832
+ * `'hub'` is the hub node. Validated against the provider's `nodeLocal`
6833
+ * flag at upsert time, not here (the schema is provider-agnostic).
6945
6834
  */
6946
- DeviceFeature["Resyncable"] = "resyncable";
6947
- DeviceFeature["NativeSnapshot"] = "native-snapshot";
6948
- DeviceFeature["DoorbellButton"] = "doorbell-button";
6949
- DeviceFeature["TwoWayAudio"] = "two-way-audio";
6950
- DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
6835
+ nodeId: string().optional(),
6836
+ isDefault: boolean().default(false),
6837
+ isSystem: boolean().default(false),
6838
+ createdAt: number(),
6839
+ updatedAt: number()
6840
+ });
6841
+ /**
6842
+ * Reference accepted by consumer-facing `api.storage.*` calls.
6843
+ * Either:
6844
+ * - a `StorageLocationType` (e.g. `'backups'`) → orchestrator resolves to the default of that type
6845
+ * - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
6846
+ *
6847
+ * The orchestrator's `resolveRef(ref)` handles both cases.
6848
+ */
6849
+ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
6850
+ /**
6851
+ * `StorageLocationDeclaration` — a single storage-location entry declared by
6852
+ * an addon in its `package.json` under `camstack.storageLocations`.
6853
+ *
6854
+ * Design intent:
6855
+ * - **Addon declares its needs** — each addon describes the logical storage
6856
+ * slots it requires (e.g. `recordings`, `recordingsLow`) without caring
6857
+ * about the physical path.
6858
+ * - **Kernel aggregates** — at boot the kernel collects declarations from all
6859
+ * installed addons, deduplicates by `id`, and exposes the union via the
6860
+ * storage-locations settings surface.
6861
+ * - **Orchestrator seeds** — for every declared `id` the orchestrator ensures
6862
+ * at least one instance named `<id>:default` is present, using
6863
+ * `defaultsTo` to inherit the resolved root from another location when the
6864
+ * declaration is a derivative slot (e.g. `recordingsLow` defaults to
6865
+ * `recordings`).
6866
+ * - **ids are global** — `id` values are shared across the entire deployment;
6867
+ * two addons declaring the same `id` must agree on `cardinality` (validated
6868
+ * at kernel aggregation time, not here).
6869
+ */
6870
+ var StorageLocationDeclarationSchema = object({
6951
6871
  /**
6952
- * Camera supports the on-firmware autotrack subsystem (subject-
6953
- * following). Distinct from `PanTiltZoom` because not every PTZ
6954
- * camera ships autotrack — the admin UI uses this flag to gate
6955
- * the autotrack toggle / settings card without re-deriving from
6956
- * the cap registry. Mirrors `ptz-autotrack` cap registration:
6957
- * driver sets this feature when probe confirms the firmware
6958
- * surface, and registers the cap in the same code path.
6872
+ * Global location identifier, e.g. `recordings` or `recordingsLow`.
6873
+ * Must start with a lowercase letter and may contain letters, digits, and
6874
+ * hyphens.
6959
6875
  */
6960
- DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
6876
+ id: string().regex(/^[a-z][a-zA-Z0-9-]*$/, { message: "id must start with a lowercase letter and contain only letters, digits, or hyphens" }),
6877
+ /** Human-readable name shown in the admin UI. */
6878
+ displayName: string().min(1, { message: "displayName must not be empty" }),
6879
+ /** Optional longer explanation of what data this location stores. */
6880
+ description: string().optional(),
6961
6881
  /**
6962
- * Accessory exposes a "trigger on motion" toggle the parent camera's
6963
- * motion detection automatically activates this device. Mirrors
6964
- * `motion-trigger` cap registration: drivers set this feature in the
6965
- * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
6966
- *
6967
- * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
6968
- * fast scalar without binding fetch), notifier rules, and `listAll`
6969
- * filters that want "all devices with on-motion behaviour".
6882
+ * `single` exactly one instance of this location is allowed system-wide
6883
+ * (e.g. `logs`, `models`). The operator can edit it but not add more.
6884
+ * `multi` the operator may register several instances (e.g. a second
6885
+ * `recordings` on a NAS for disk tiering); one is the default at any time.
6970
6886
  */
6971
- DeviceFeature["MotionTrigger"] = "motion-trigger";
6972
- /** Light supports rgb-triplet color via `color` cap. */
6973
- DeviceFeature["LightColorRgb"] = "light-color-rgb";
6974
- /** Light supports HSV color via `color` cap. */
6975
- DeviceFeature["LightColorHsv"] = "light-color-hsv";
6976
- /** Light supports color-temperature (mired) via `color` cap. */
6977
- DeviceFeature["LightColorMired"] = "light-color-mired";
6978
- /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
6979
- * targetHigh). Gates the range slider UI. */
6980
- DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
6981
- /** Thermostat exposes target humidity and/or current humidity
6982
- * readings. Gates the humidity controls. */
6983
- DeviceFeature["ClimateHumidity"] = "climate-humidity";
6984
- /** Thermostat exposes a fan-mode selector. */
6985
- DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
6986
- /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
6987
- DeviceFeature["ClimatePreset"] = "climate-preset";
6988
- /** Cover exposes intermediate position control (0..100). Gates the
6989
- * position slider UI. */
6990
- DeviceFeature["CoverPositionable"] = "cover-positionable";
6991
- /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
6992
- DeviceFeature["CoverTilt"] = "cover-tilt";
6993
- /** Valve exposes intermediate position control (0..100). Gates the
6994
- * position slider / drag surface UI. */
6995
- DeviceFeature["ValvePositionable"] = "valve-positionable";
6996
- /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
6997
- DeviceFeature["FanSpeed"] = "fan-speed";
6998
- /** Fan exposes a preset mode selector. */
6999
- DeviceFeature["FanPreset"] = "fan-preset";
7000
- /** Fan exposes blade direction (forward/reverse) typical of
7001
- * ceiling fans. */
7002
- DeviceFeature["FanDirection"] = "fan-direction";
7003
- /** Fan exposes an oscillation toggle. */
7004
- DeviceFeature["FanOscillating"] = "fan-oscillating";
7005
- /** Lock requires a PIN code on lock/unlock. Gates the code-entry
7006
- * field on the UI lock-controls panel. */
7007
- DeviceFeature["LockPinRequired"] = "lock-pin-required";
7008
- /** Lock supports a latch-release ("open door") action distinct from
7009
- * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
7010
- * `supported_features`. Gates the Open Door button in the UI. */
7011
- DeviceFeature["LockOpen"] = "lock-open";
7012
- /** Media player exposes a seek-to-position surface. */
7013
- DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
7014
- /** Media player exposes a volume-level setter. */
7015
- DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
7016
- /** Media player exposes a mute toggle distinct from volume=0. */
7017
- DeviceFeature["MediaPlayerMute"] = "media-player-mute";
7018
- /** Media player exposes a shuffle toggle. */
7019
- DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
7020
- /** Media player exposes a repeat mode (off / all / one). */
7021
- DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
7022
- /** Media player exposes a source / input selector. */
7023
- DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
7024
- /** Media player exposes a play-arbitrary-media surface (URL / id). */
7025
- DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
7026
- /** Media player exposes next-track. */
7027
- DeviceFeature["MediaPlayerNext"] = "media-player-next";
7028
- /** Media player exposes previous-track. */
7029
- DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
7030
- /** Media player exposes stop distinct from pause. */
7031
- DeviceFeature["MediaPlayerStop"] = "media-player-stop";
7032
- /** Alarm panel requires a PIN code on arm/disarm. */
7033
- DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
7034
- /** Presence device carries GPS coordinates (lat/lng/accuracy) in
7035
- * addition to a textual location. */
7036
- DeviceFeature["PresenceGps"] = "presence-gps";
7037
- /** Notifier accepts an inline / URL image attachment. */
7038
- DeviceFeature["NotifierImage"] = "notifier-image";
7039
- /** Notifier accepts a priority hint (high/normal/low). */
7040
- DeviceFeature["NotifierPriority"] = "notifier-priority";
7041
- /** Notifier accepts a free-form `data` payload for platform-specific
7042
- * fields. */
7043
- DeviceFeature["NotifierData"] = "notifier-data";
7044
- /** Notifier supports interactive action buttons / callbacks. */
7045
- DeviceFeature["NotifierActions"] = "notifier-actions";
7046
- /** Notifier supports per-call recipient targeting (multi-user). */
7047
- DeviceFeature["NotifierRecipients"] = "notifier-recipients";
7048
- /** Script runner accepts a variables map on each run invocation. */
7049
- DeviceFeature["ScriptVariables"] = "script-variables";
7050
- /** Automation `trigger` accepts a skipCondition flag — fires the
7051
- * automation's actions while bypassing its condition block. */
7052
- DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
7053
- return DeviceFeature;
7054
- }({});
7055
- /**
7056
- * Semantic role a device plays within its parent. Populated by driver
7057
- * addons when creating accessory devices (Reolink siren/floodlight/
7058
- * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
7059
- * admin UI to pick icons, labels, and widgets — a `Switch` with
7060
- * `role: Floodlight` renders as a bulb with a brightness slider,
7061
- * whereas a `Switch` with `role: Siren` renders as a klaxon.
7062
- *
7063
- * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
7064
- * sqlite as a nullable TEXT column — old rows keep working unchanged.
7065
- */
7066
- var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7067
- DeviceRole["Siren"] = "siren";
7068
- DeviceRole["Floodlight"] = "floodlight";
7069
- DeviceRole["Spotlight"] = "spotlight";
7070
- DeviceRole["PirSensor"] = "pir-sensor";
7071
- DeviceRole["Chime"] = "chime";
7072
- DeviceRole["Autotrack"] = "autotrack";
7073
- DeviceRole["Nightvision"] = "nightvision";
7074
- DeviceRole["PrivacyMask"] = "privacy-mask";
7075
- DeviceRole["Doorbell"] = "doorbell";
7076
- /** Virtual HA toggle (input_boolean.*) — distinguishable from a
7077
- * real Switch device for UI rendering / export adapters. */
7078
- DeviceRole["BinaryHelper"] = "binary-helper";
7079
- /** Generic motion / occupancy / moving event source. Distinct from
7080
- * the camera accessory PirSensor role: that one is a camera child;
7081
- * this is a standalone HA / 3rd-party motion sensor. */
7082
- DeviceRole["MotionSensor"] = "motion-sensor";
7083
- DeviceRole["ContactSensor"] = "contact-sensor";
7084
- DeviceRole["LeakSensor"] = "leak-sensor";
7085
- DeviceRole["SmokeSensor"] = "smoke-sensor";
7086
- DeviceRole["COSensor"] = "co-sensor";
7087
- DeviceRole["GasSensor"] = "gas-sensor";
7088
- DeviceRole["TamperSensor"] = "tamper-sensor";
7089
- DeviceRole["VibrationSensor"] = "vibration-sensor";
7090
- DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
7091
- DeviceRole["SoundSensor"] = "sound-sensor";
7092
- /** Fallback for `binary_sensor` without a known `device_class`. */
7093
- DeviceRole["BinarySensor"] = "binary-sensor";
7094
- DeviceRole["TemperatureSensor"] = "temperature-sensor";
7095
- DeviceRole["HumiditySensor"] = "humidity-sensor";
7096
- DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
7097
- DeviceRole["PressureSensor"] = "pressure-sensor";
7098
- DeviceRole["PowerSensor"] = "power-sensor";
7099
- DeviceRole["EnergySensor"] = "energy-sensor";
7100
- DeviceRole["VoltageSensor"] = "voltage-sensor";
7101
- DeviceRole["CurrentSensor"] = "current-sensor";
7102
- DeviceRole["AirQualitySensor"] = "air-quality-sensor";
7103
- /** Battery level (numeric % via `sensor` OR low-bool via
7104
- * `binary_sensor` — the cap distinguishes via the value type). */
7105
- DeviceRole["BatterySensor"] = "battery-sensor";
7106
- /** Fallback for `sensor` numeric without a known `device_class`. */
7107
- DeviceRole["NumericSensor"] = "numeric-sensor";
7108
- /** String / enum state (HA `sensor` with `state_class: enum` or
7109
- * `attributes.options`). */
7110
- DeviceRole["EnumSensor"] = "enum-sensor";
7111
- /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
7112
- * or `date`). The slice carries the raw ISO string verbatim (hosted on
7113
- * the `enum-sensor` cap); the UI renders it locale-formatted. */
7114
- DeviceRole["DateTimeSensor"] = "datetime-sensor";
7115
- /** Last-resort fallback when nothing else matches. */
7116
- DeviceRole["GenericSensor"] = "generic-sensor";
7117
- DeviceRole["NumericControl"] = "numeric-control";
7118
- DeviceRole["SelectControl"] = "select-control";
7119
- DeviceRole["TextControl"] = "text-control";
7120
- DeviceRole["DateTimeControl"] = "datetime-control";
7121
- /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
7122
- * rich features (image, priority, channel routing). */
7123
- DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
7124
- /** Chat / messaging service (HA `notify.telegram_*`,
7125
- * `notify.discord_*`, etc.). */
7126
- DeviceRole["MessagingNotifier"] = "messaging-notifier";
7127
- /** Email-based delivery (HA `notify.smtp`, etc.). */
7128
- DeviceRole["EmailNotifier"] = "email-notifier";
7129
- /** Fallback when the notifier service name doesn't match a known
7130
- * pattern. */
7131
- DeviceRole["GenericNotifier"] = "generic-notifier";
7132
- return DeviceRole;
7133
- }({});
6887
+ cardinality: _enum(["single", "multi"]),
6888
+ /**
6889
+ * When set, the default instance for this location inherits its resolved
6890
+ * root from the named location's default instance. Useful for derivative
6891
+ * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
6892
+ * configure the primary location.
6893
+ */
6894
+ defaultsTo: string().optional()
6895
+ });
6896
+ var DecoderStatsSchema = object({
6897
+ inputFps: number(),
6898
+ outputFps: number(),
6899
+ avgDecodeTimeMs: number(),
6900
+ droppedFrames: number()
6901
+ });
6902
+ var DecoderSessionConfigSchema = object({
6903
+ codec: string(),
6904
+ maxFps: number().default(0),
6905
+ outputFormat: _enum([
6906
+ "jpeg",
6907
+ "rgb",
6908
+ "bgr",
6909
+ "yuv420",
6910
+ "gray"
6911
+ ]).default("jpeg"),
6912
+ scale: number().default(1),
6913
+ width: number().optional(),
6914
+ height: number().optional(),
6915
+ /**
6916
+ * Identifier of the camera this decoder session serves. Optional
6917
+ * because the cap is generic (any caller could request decode), but
6918
+ * stream-broker passes it so decoder logs include `deviceId` for
6919
+ * per-camera filtering when diagnosing failures (e.g. node-av
6920
+ * sendPacket errors on a single hung camera).
6921
+ */
6922
+ deviceId: number().int().nonnegative().optional(),
6923
+ /**
6924
+ * Free-form tag for log scoping. Stream-broker uses
6925
+ * `broker:<deviceId>/<profile>`. Decoder session logger surfaces it
6926
+ * on every line so `grep tag=broker:5/high` filters one camera
6927
+ * profile cleanly.
6928
+ */
6929
+ tag: string().optional(),
6930
+ /**
6931
+ * Where the session delivers decoded frames (Phase 5 / D9):
6932
+ *
6933
+ * - `'callback'` (default) — the legacy pixel path: decoded frames are
6934
+ * buffered as `DecodedFrame`s and drained via `pullFrames`.
6935
+ * - `'shm'` — the shared-memory frame plane: decoded frames are written
6936
+ * into an OS shared-memory ring and drained as zero-pixel
6937
+ * `FrameHandle`s via `pullHandles`. A session is one mode or the
6938
+ * other `pullFrames` returns nothing for an `'shm'` session and
6939
+ * `pullHandles` returns nothing for a `'callback'` session.
6940
+ */
6941
+ frameSink: _enum(["callback", "shm"]).default("callback")
6942
+ });
6943
+ var EncodeProfileSchema = object({
6944
+ video: object({
6945
+ codec: _enum([
6946
+ "h264",
6947
+ "h265",
6948
+ "copy"
6949
+ ]),
6950
+ profile: _enum([
6951
+ "baseline",
6952
+ "main",
6953
+ "high"
6954
+ ]).optional(),
6955
+ width: number().int().positive().optional(),
6956
+ height: number().int().positive().optional(),
6957
+ fps: number().positive().optional(),
6958
+ bitrateKbps: number().int().positive().optional(),
6959
+ gopFrames: number().int().positive().optional(),
6960
+ bf: number().int().min(0).optional(),
6961
+ preset: _enum([
6962
+ "ultrafast",
6963
+ "superfast",
6964
+ "veryfast",
6965
+ "faster",
6966
+ "fast",
6967
+ "medium"
6968
+ ]).optional(),
6969
+ tune: _enum([
6970
+ "zerolatency",
6971
+ "film",
6972
+ "animation"
6973
+ ]).optional()
6974
+ }),
6975
+ audio: union([literal("passthrough"), object({
6976
+ codec: _enum([
6977
+ "opus",
6978
+ "aac",
6979
+ "pcmu",
6980
+ "pcma",
6981
+ "copy"
6982
+ ]),
6983
+ bitrateKbps: number().int().positive().optional(),
6984
+ sampleRateHz: number().int().positive().optional(),
6985
+ channels: union([literal(1), literal(2)]).optional()
6986
+ })]),
6987
+ /**
6988
+ * ffmpeg input-side args, inserted between the fixed global flags
6989
+ * (`-hide_banner -loglevel error`) and `-i pipe:0`. Free-text array
6990
+ * the widget surfaces a textarea + suggestion chips for the most-
6991
+ * used demuxer/format options.
6992
+ */
6993
+ inputArgs: array(string()).optional(),
6994
+ /**
6995
+ * ffmpeg output-side args, inserted between the encode block and
6996
+ * the final `-f <muxer> pipe:1`. Use for muxer options, bitstream
6997
+ * filters, codec-specific overrides. Free-text array.
6998
+ */
6999
+ outputArgs: array(string()).optional()
7000
+ });
7001
+ var YAMNET_TO_MACRO = {
7002
+ mapping: {
7003
+ Speech: "speech",
7004
+ "Child speech, kid speaking": "speech",
7005
+ Conversation: "speech",
7006
+ "Narration, monologue": "speech",
7007
+ Babbling: "speech",
7008
+ Whispering: "speech",
7009
+ "Speech synthesizer": "speech",
7010
+ Humming: "speech",
7011
+ Rapping: "speech",
7012
+ Singing: "speech",
7013
+ Choir: "speech",
7014
+ "Child singing": "speech",
7015
+ Shout: "scream",
7016
+ Bellow: "scream",
7017
+ Yell: "scream",
7018
+ Screaming: "scream",
7019
+ "Children shouting": "scream",
7020
+ Whoop: "scream",
7021
+ "Crying, sobbing": "crying",
7022
+ "Baby cry, infant cry": "crying",
7023
+ Whimper: "crying",
7024
+ "Wail, moan": "crying",
7025
+ Groan: "crying",
7026
+ Laughter: "laughter",
7027
+ "Baby laughter": "laughter",
7028
+ Giggle: "laughter",
7029
+ Snicker: "laughter",
7030
+ "Belly laugh": "laughter",
7031
+ "Chuckle, chortle": "laughter",
7032
+ Music: "music",
7033
+ "Musical instrument": "music",
7034
+ Guitar: "music",
7035
+ Piano: "music",
7036
+ Drum: "music",
7037
+ "Drum kit": "music",
7038
+ "Violin, fiddle": "music",
7039
+ Flute: "music",
7040
+ Saxophone: "music",
7041
+ Trumpet: "music",
7042
+ Synthesizer: "music",
7043
+ "Pop music": "music",
7044
+ "Rock music": "music",
7045
+ "Hip hop music": "music",
7046
+ "Classical music": "music",
7047
+ Jazz: "music",
7048
+ "Electronic music": "music",
7049
+ "Background music": "music",
7050
+ Dog: "dog",
7051
+ Bark: "dog",
7052
+ Yip: "dog",
7053
+ Howl: "dog",
7054
+ "Bow-wow": "dog",
7055
+ Growling: "dog",
7056
+ "Whimper (dog)": "dog",
7057
+ Cat: "cat",
7058
+ Purr: "cat",
7059
+ Meow: "cat",
7060
+ Hiss: "cat",
7061
+ Caterwaul: "cat",
7062
+ Bird: "bird",
7063
+ "Bird vocalization, bird call, bird song": "bird",
7064
+ "Chirp, tweet": "bird",
7065
+ Squawk: "bird",
7066
+ Crow: "bird",
7067
+ Owl: "bird",
7068
+ "Pigeon, dove": "bird",
7069
+ Animal: "animal",
7070
+ "Domestic animals, pets": "animal",
7071
+ "Livestock, farm animals, working animals": "animal",
7072
+ Horse: "animal",
7073
+ "Cattle, bovinae": "animal",
7074
+ Pig: "animal",
7075
+ Sheep: "animal",
7076
+ Goat: "animal",
7077
+ Frog: "animal",
7078
+ Insect: "animal",
7079
+ Cricket: "animal",
7080
+ Alarm: "alarm",
7081
+ "Alarm clock": "alarm",
7082
+ "Smoke detector, smoke alarm": "alarm",
7083
+ "Fire alarm": "alarm",
7084
+ Buzzer: "alarm",
7085
+ "Civil defense siren": "alarm",
7086
+ "Car alarm": "alarm",
7087
+ Siren: "siren",
7088
+ "Police car (siren)": "siren",
7089
+ "Ambulance (siren)": "siren",
7090
+ "Fire engine, fire truck (siren)": "siren",
7091
+ "Emergency vehicle": "siren",
7092
+ Foghorn: "siren",
7093
+ Doorbell: "doorbell",
7094
+ "Ding-dong": "doorbell",
7095
+ Knock: "doorbell",
7096
+ Tap: "doorbell",
7097
+ Glass: "glass_breaking",
7098
+ Shatter: "glass_breaking",
7099
+ "Chink, clink": "glass_breaking",
7100
+ "Gunshot, gunfire": "gunshot",
7101
+ "Machine gun": "gunshot",
7102
+ Explosion: "gunshot",
7103
+ Fireworks: "gunshot",
7104
+ Firecracker: "gunshot",
7105
+ "Artillery fire": "gunshot",
7106
+ "Cap gun": "gunshot",
7107
+ Boom: "gunshot",
7108
+ Vehicle: "vehicle",
7109
+ Car: "vehicle",
7110
+ Truck: "vehicle",
7111
+ Bus: "vehicle",
7112
+ Motorcycle: "vehicle",
7113
+ "Car passing by": "vehicle",
7114
+ "Vehicle horn, car horn, honking": "vehicle",
7115
+ "Traffic noise, roadway noise": "vehicle",
7116
+ Train: "vehicle",
7117
+ Aircraft: "vehicle",
7118
+ Helicopter: "vehicle",
7119
+ Bicycle: "vehicle",
7120
+ Skateboard: "vehicle",
7121
+ Fire: "fire",
7122
+ Crackle: "fire",
7123
+ Water: "water",
7124
+ Rain: "water",
7125
+ Raindrop: "water",
7126
+ "Rain on surface": "water",
7127
+ Stream: "water",
7128
+ Waterfall: "water",
7129
+ Ocean: "water",
7130
+ "Waves, surf": "water",
7131
+ "Splash, splatter": "water",
7132
+ Wind: "wind",
7133
+ Thunderstorm: "wind",
7134
+ Thunder: "wind",
7135
+ "Wind noise (microphone)": "wind",
7136
+ "Rustling leaves": "wind",
7137
+ Door: "door",
7138
+ "Sliding door": "door",
7139
+ Slam: "door",
7140
+ "Cupboard open or close": "door",
7141
+ "Walk, footsteps": "footsteps",
7142
+ Run: "footsteps",
7143
+ Shuffle: "footsteps",
7144
+ Crowd: "crowd",
7145
+ Chatter: "crowd",
7146
+ Cheering: "crowd",
7147
+ Applause: "crowd",
7148
+ "Children playing": "crowd",
7149
+ "Hubbub, speech noise, speech babble": "crowd",
7150
+ Telephone: "telephone",
7151
+ "Telephone bell ringing": "telephone",
7152
+ Ringtone: "telephone",
7153
+ "Telephone dialing, DTMF": "telephone",
7154
+ "Busy signal": "telephone",
7155
+ Engine: "engine",
7156
+ "Engine starting": "engine",
7157
+ Idling: "engine",
7158
+ "Accelerating, revving, vroom": "engine",
7159
+ "Light engine (high frequency)": "engine",
7160
+ "Medium engine (mid frequency)": "engine",
7161
+ "Heavy engine (low frequency)": "engine",
7162
+ "Lawn mower": "engine",
7163
+ Chainsaw: "engine",
7164
+ Hammer: "tools",
7165
+ Jackhammer: "tools",
7166
+ Sawing: "tools",
7167
+ "Power tool": "tools",
7168
+ Drill: "tools",
7169
+ Sanding: "tools",
7170
+ Silence: "silence"
7171
+ },
7172
+ preserveOriginal: false
7173
+ };
7174
+ var APPLE_SA_TO_MACRO = {
7175
+ mapping: {
7176
+ speech: "speech",
7177
+ child_speech: "speech",
7178
+ conversation: "speech",
7179
+ whispering: "speech",
7180
+ singing: "speech",
7181
+ humming: "speech",
7182
+ shout: "scream",
7183
+ yell: "scream",
7184
+ screaming: "scream",
7185
+ crying: "crying",
7186
+ baby_crying: "crying",
7187
+ sobbing: "crying",
7188
+ laughter: "laughter",
7189
+ baby_laughter: "laughter",
7190
+ giggling: "laughter",
7191
+ music: "music",
7192
+ guitar: "music",
7193
+ piano: "music",
7194
+ drums: "music",
7195
+ dog_bark: "dog",
7196
+ dog_bow_wow: "dog",
7197
+ dog_growling: "dog",
7198
+ dog_howl: "dog",
7199
+ cat_meow: "cat",
7200
+ cat_purr: "cat",
7201
+ cat_hiss: "cat",
7202
+ bird: "bird",
7203
+ bird_chirp: "bird",
7204
+ bird_squawk: "bird",
7205
+ animal: "animal",
7206
+ horse: "animal",
7207
+ cow_moo: "animal",
7208
+ insect: "animal",
7209
+ alarm: "alarm",
7210
+ smoke_alarm: "alarm",
7211
+ fire_alarm: "alarm",
7212
+ car_alarm: "alarm",
7213
+ siren: "siren",
7214
+ police_siren: "siren",
7215
+ ambulance_siren: "siren",
7216
+ doorbell: "doorbell",
7217
+ door_knock: "doorbell",
7218
+ knocking: "doorbell",
7219
+ glass_breaking: "glass_breaking",
7220
+ glass_shatter: "glass_breaking",
7221
+ gunshot: "gunshot",
7222
+ explosion: "gunshot",
7223
+ fireworks: "gunshot",
7224
+ car: "vehicle",
7225
+ truck: "vehicle",
7226
+ motorcycle: "vehicle",
7227
+ car_horn: "vehicle",
7228
+ vehicle_horn: "vehicle",
7229
+ traffic: "vehicle",
7230
+ fire: "fire",
7231
+ fire_crackle: "fire",
7232
+ water: "water",
7233
+ rain: "water",
7234
+ ocean: "water",
7235
+ splash: "water",
7236
+ wind: "wind",
7237
+ thunder: "wind",
7238
+ thunderstorm: "wind",
7239
+ door: "door",
7240
+ door_slam: "door",
7241
+ sliding_door: "door",
7242
+ footsteps: "footsteps",
7243
+ walking: "footsteps",
7244
+ running: "footsteps",
7245
+ crowd: "crowd",
7246
+ chatter: "crowd",
7247
+ cheering: "crowd",
7248
+ applause: "crowd",
7249
+ telephone_ring: "telephone",
7250
+ ringtone: "telephone",
7251
+ engine: "engine",
7252
+ engine_starting: "engine",
7253
+ lawn_mower: "engine",
7254
+ chainsaw: "engine",
7255
+ hammer: "tools",
7256
+ jackhammer: "tools",
7257
+ drill: "tools",
7258
+ power_tool: "tools",
7259
+ silence: "silence"
7260
+ },
7261
+ preserveOriginal: false
7262
+ };
7263
+ var _macroLookup = /* @__PURE__ */ new Map();
7264
+ for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7265
+ for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7134
7266
  /**
7135
7267
  * Accessory device helpers — shared across drivers.
7136
7268
  *
@@ -7394,74 +7526,6 @@ object({
7394
7526
  });
7395
7527
  DeviceType.Sensor;
7396
7528
  /**
7397
- * Generic types for capability definitions.
7398
- *
7399
- * A capability is defined with Zod schemas for methods, events, and settings.
7400
- * TypeScript types are inferred via z.infer<> — zero duplication.
7401
- *
7402
- * Pattern:
7403
- * 1. Define Zod schemas for data, methods, settings
7404
- * 2. Export const capabilityDef = { ... } satisfies CapabilityDefinition
7405
- * 3. Export type IProvider = InferProvider<typeof capabilityDef>
7406
- * 4. Addon implements IProvider
7407
- * 5. Registry auto-mounts tRPC router from definition.methods
7408
- */
7409
- /**
7410
- * Output schema shared by the contribution + live methods.
7411
- *
7412
- * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
7413
- * tabs[]) without importing from `../interfaces/config-ui.js` — a
7414
- * concrete-but-lenient Zod object keeps tRPC output inference happy
7415
- * (using `z.unknown()` here collapses unrelated router branches to
7416
- * `unknown` when the generator re-inlines the huge AppRouter type).
7417
- *
7418
- * `.passthrough()` on sections/fields accepts whatever FormBuilder
7419
- * extensions the caller adds (showWhen, displayScale, …) without
7420
- * rebuilding every time a new field kind is introduced.
7421
- */
7422
- var ContributionSectionSchema = object({
7423
- id: string(),
7424
- title: string(),
7425
- description: string().optional(),
7426
- style: _enum(["card", "accordion"]).optional(),
7427
- defaultCollapsed: boolean().optional(),
7428
- columns: union([
7429
- literal(1),
7430
- literal(2),
7431
- literal(3),
7432
- literal(4)
7433
- ]).optional(),
7434
- tab: string().optional(),
7435
- location: _enum(["settings", "top-tab"]).optional(),
7436
- order: number().optional(),
7437
- fields: array(any())
7438
- });
7439
- object({
7440
- tabs: array(object({
7441
- id: string(),
7442
- label: string(),
7443
- icon: string(),
7444
- order: number().optional()
7445
- })).optional(),
7446
- sections: array(ContributionSectionSchema)
7447
- }).nullable();
7448
- object({ deviceId: number() }), object({ deviceId: number() }), object({
7449
- deviceId: number(),
7450
- patch: record(string(), unknown())
7451
- }), object({ success: literal(true) });
7452
- object({ deviceId: number() }), unknown().nullable();
7453
- /** Shorthand to define a method schema */
7454
- function method(input, output, options) {
7455
- return {
7456
- input,
7457
- output,
7458
- kind: options?.kind ?? "query",
7459
- auth: options?.auth ?? "protected",
7460
- ...options?.access !== void 0 ? { access: options.access } : {},
7461
- timeoutMs: options?.timeoutMs
7462
- };
7463
- }
7464
- /**
7465
7529
  * Alarm-panel cap. Models HA `alarm_control_panel.*` on
7466
7530
  * `DeviceType.AlarmPanel`. State follows HA's canonical lifecycle
7467
7531
  * across disarmed / armed_(home|away|night|vacation|custom_bypass) /
@@ -11723,9 +11787,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
11723
11787
  limit: number().optional(),
11724
11788
  tags: record(string(), string()).optional()
11725
11789
  }), array(LogEntrySchema).readonly());
11726
- var StaticDirOutputSchema = object({ staticDir: string() });
11727
- var VersionOutputSchema = object({ version: string() });
11728
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
11729
11790
  /**
11730
11791
  * Zod schemas for persisted record types.
11731
11792
  *
@@ -14026,7 +14087,7 @@ method(object({
14026
14087
  }), _void(), {
14027
14088
  kind: "mutation",
14028
14089
  auth: "admin"
14029
- }), 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({
14090
+ }), 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({
14030
14091
  deviceId: number(),
14031
14092
  values: record(string(), unknown())
14032
14093
  }), object({ success: literal(true) }), {
@@ -14751,7 +14812,20 @@ var DiskSpaceInfoSchema = object({
14751
14812
  var PidResourceStatsSchema = object({
14752
14813
  pid: number(),
14753
14814
  cpu: number(),
14754
- memory: number()
14815
+ memory: number(),
14816
+ /**
14817
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
14818
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
14819
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
14820
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
14821
+ * Undefined where /proc is unavailable (e.g. macOS).
14822
+ */
14823
+ privateBytes: number().optional(),
14824
+ /**
14825
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
14826
+ * code shared copy-on-write across runners. Undefined on macOS.
14827
+ */
14828
+ sharedBytes: number().optional()
14755
14829
  });
14756
14830
  var AddonInstanceSchema = object({
14757
14831
  addonId: string(),
@@ -14800,6 +14874,17 @@ var KillProcessResultSchema = object({
14800
14874
  reason: string().optional(),
14801
14875
  signal: _enum(["SIGTERM", "SIGKILL"]).optional()
14802
14876
  });
14877
+ var DumpHeapSnapshotInputSchema = object({
14878
+ /** The addon whose runner should dump a heap snapshot. */
14879
+ addonId: string() });
14880
+ var DumpHeapSnapshotResultSchema = object({
14881
+ success: boolean(),
14882
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
14883
+ path: string().optional(),
14884
+ /** Process pid that was signalled. */
14885
+ pid: number().optional(),
14886
+ reason: string().optional()
14887
+ });
14803
14888
  var SystemMetricsSchema = object({
14804
14889
  cpuPercent: number(),
14805
14890
  memoryPercent: number(),
@@ -14813,6 +14898,9 @@ var SystemMetricsSchema = object({
14813
14898
  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, {
14814
14899
  kind: "mutation",
14815
14900
  auth: "admin"
14901
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
14902
+ kind: "mutation",
14903
+ auth: "admin"
14816
14904
  });
14817
14905
  var PtzPresetSchema = object({
14818
14906
  id: string(),
@@ -15221,63 +15309,6 @@ method(object({
15221
15309
  auth: "admin"
15222
15310
  });
15223
15311
  /**
15224
- * device-ops — device-scoped cap that unifies the per-IDevice operations
15225
- * previously routed through the `.device-ops` Moleculer bridge service.
15226
- *
15227
- * Each worker that hosts live `IDevice` instances auto-registers a native
15228
- * provider for this cap (per device) backed by its local
15229
- * `DeviceRegistry`. Hub-side callers reach it transparently through
15230
- * `ctx.fetchDevice(id).deviceOps.*` — the DeviceProxy injects
15231
- * `deviceId` + `nodeId` and dispatches through the standard cap-router,
15232
- * so there's no parallel bridge path anymore.
15233
- *
15234
- * The surface is intentionally small — every method corresponds to a
15235
- * single action on the live `IDevice` (or `ICameraDevice` for
15236
- * `getStreamSources`). Richer orchestration (enable/disable with
15237
- * integration plumbing, bulk updates) stays in the `device-manager` cap;
15238
- * `device-ops` is the per-device primitive the device-manager routes to.
15239
- */
15240
- var StreamSourceEntrySchema$1 = object({
15241
- id: string(),
15242
- label: string(),
15243
- protocol: _enum([
15244
- "rtsp",
15245
- "rtmp",
15246
- "annexb",
15247
- "http-mjpeg",
15248
- "webrtc",
15249
- "custom"
15250
- ]),
15251
- url: string().optional(),
15252
- resolution: object({
15253
- width: number(),
15254
- height: number()
15255
- }).optional(),
15256
- fps: number().optional(),
15257
- bitrate: number().optional(),
15258
- codec: string().optional(),
15259
- profileHint: CamProfileSchema.optional(),
15260
- sdp: string().optional()
15261
- });
15262
- var ConfigEntrySchema$1 = object({
15263
- key: string(),
15264
- value: unknown()
15265
- });
15266
- var RawStateResultSchema = object({
15267
- /** Originating provider id, e.g. 'homeassistant' | 'reolink' | 'hikvision'. */
15268
- source: string(),
15269
- /** Opaque, DISPLAY-SAFE upstream blob (no secrets/PII). */
15270
- data: record(string(), unknown())
15271
- });
15272
- method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
15273
- deviceId: number(),
15274
- values: record(string(), unknown())
15275
- }), _void(), { kind: "mutation" }), method(object({
15276
- deviceId: number(),
15277
- action: string().min(1),
15278
- input: unknown()
15279
- }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
15280
- /**
15281
15312
  * camera-credentials — device-scoped cap exposing the camera's network
15282
15313
  * + auth surface in a vendor-neutral shape.
15283
15314
  *
@@ -18960,6 +18991,12 @@ Object.freeze({
18960
18991
  addonId: null,
18961
18992
  access: "view"
18962
18993
  },
18994
+ "metricsProvider.dumpHeapSnapshot": {
18995
+ capName: "metrics-provider",
18996
+ capScope: "system",
18997
+ addonId: null,
18998
+ access: "create"
18999
+ },
18963
19000
  "metricsProvider.getAddonStats": {
18964
19001
  capName: "metrics-provider",
18965
19002
  capScope: "system",