@camstack/addon-post-analysis 1.0.6 → 1.0.8

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