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