@camstack/addon-pipeline-orchestrator 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4631,63 +4631,7 @@ function _instanceof(cls, params = {}) {
4631
4631
  return inst;
4632
4632
  }
4633
4633
  //#endregion
4634
- //#region ../types/dist/index.mjs
4635
- /**
4636
- * Deep wiring healthcheck — snapshot of active reachability probes across
4637
- * every declared capability + widget of every installed plugin, on every
4638
- * node. Produced by the backend `WiringHealthService` and surfaced via
4639
- * `GET /health/wiring`, the tRPC `health.wiring` query, and the boot-gate.
4640
- *
4641
- * Unlike `/health` (process liveness), this reflects whether each cap/widget
4642
- * is actually *reachable* over the real cap-dispatch path. See spec
4643
- * `docs/superpowers/specs/2026-05-23-deep-healthcheck-design.md`.
4644
- */
4645
- /** What kind of target a probe addressed. */
4646
- var wiringProbeKindSchema = _enum([
4647
- "singleton",
4648
- "device",
4649
- "widget"
4650
- ]);
4651
- /** Result of probing a single (cap|widget [, device]) target. */
4652
- var wiringProbeResultSchema = object({
4653
- capName: string(),
4654
- kind: wiringProbeKindSchema,
4655
- deviceId: number().optional(),
4656
- reachable: boolean(),
4657
- latencyMs: number(),
4658
- error: string().optional()
4659
- });
4660
- /** Per-addon roll-up of cap + widget probe results. */
4661
- var wiringAddonHealthSchema = object({
4662
- addonId: string(),
4663
- caps: array(wiringProbeResultSchema).readonly(),
4664
- widgets: array(wiringProbeResultSchema).readonly()
4665
- });
4666
- /** Per-node roll-up. */
4667
- var wiringNodeHealthSchema = object({
4668
- nodeId: string(),
4669
- addons: array(wiringAddonHealthSchema).readonly()
4670
- });
4671
- object({
4672
- /** True only when every probed target is reachable. */
4673
- ok: boolean(),
4674
- /** True when at least one target is unreachable. */
4675
- degraded: boolean(),
4676
- checkedAt: string(),
4677
- nodes: array(wiringNodeHealthSchema).readonly(),
4678
- summary: object({
4679
- total: number(),
4680
- reachable: number(),
4681
- unreachable: number()
4682
- })
4683
- });
4684
- var MODEL_FORMATS = [
4685
- "onnx",
4686
- "coreml",
4687
- "openvino",
4688
- "tflite",
4689
- "pt"
4690
- ];
4634
+ //#region ../types/dist/sleep-B1dKJAMJ.mjs
4691
4635
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4692
4636
  EventCategory["SystemBoot"] = "system.boot";
4693
4637
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5677,7 +5621,7 @@ var BaseAddon = class {
5677
5621
  deviceSettingsSchema() {
5678
5622
  return null;
5679
5623
  }
5680
- async getGlobalSettings(overlay, cap) {
5624
+ async getGlobalSettings(overlay, cap, _nodeId) {
5681
5625
  const schema = this.globalSettingsSchema(cap);
5682
5626
  if (!schema) return { sections: [] };
5683
5627
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
@@ -5686,7 +5630,7 @@ var BaseAddon = class {
5686
5630
  ...overlay
5687
5631
  } : raw);
5688
5632
  }
5689
- async updateGlobalSettings(patch) {
5633
+ async updateGlobalSettings(patch, _nodeId) {
5690
5634
  await this._ctx?.settings?.writeAddonStore(patch);
5691
5635
  await this.resolveConfig();
5692
5636
  await this.onConfigChanged();
@@ -6037,7 +5981,7 @@ function makeSourceBrokerId(deviceId, camStreamId) {
6037
5981
  * Zod schema for StreamSourceEntry — the canonical stream descriptor
6038
5982
  * exposed by ICameraDevice.getStreamSources() and consumed by the broker.
6039
5983
  */
6040
- var StreamSourceEntrySchema = object({
5984
+ var StreamSourceEntrySchema$1 = object({
6041
5985
  id: string(),
6042
5986
  label: string(),
6043
5987
  protocol: _enum([
@@ -6259,140 +6203,6 @@ var ProfileRtspEntrySchema = object({
6259
6203
  codec: string().optional(),
6260
6204
  resolution: CamStreamResolutionSchema.optional()
6261
6205
  });
6262
- /**
6263
- * Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
6264
- * Named `RecordingWeekday` to avoid collision with the string-union
6265
- * `Weekday` exported from `interfaces/timezones.ts`.
6266
- */
6267
- var RecordingWeekdaySchema = number().int().min(0).max(6);
6268
- var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
6269
- var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
6270
- kind: literal("timeOfDay"),
6271
- start: string().regex(HHMM),
6272
- end: string().regex(HHMM),
6273
- /** Restrict to these weekdays; omit = every day. */
6274
- days: array(RecordingWeekdaySchema).optional()
6275
- })]);
6276
- var RecordingModeSchema = _enum([
6277
- "continuous",
6278
- "onMotion",
6279
- "onAudioThreshold"
6280
- ]);
6281
- /**
6282
- * First-class, authoritative per-camera storage mode — the netta choice the UI
6283
- * reads directly (never inferred from `rules`):
6284
- * - `off` — not recording.
6285
- * - `events` — record only around triggers (motion / audio threshold),
6286
- * with pre/post-buffer.
6287
- * - `continuous` — record 24/7 within the schedule.
6288
- *
6289
- * `mode` compiles one-way to the internal `rules[]` consumed by the policy
6290
- * engine (see `compileRules`); `rules[]` is never authored directly anymore.
6291
- */
6292
- var RecordingStorageModeSchema = _enum([
6293
- "off",
6294
- "events",
6295
- "continuous"
6296
- ]);
6297
- /** Which detectors trigger an `events`-mode recording. */
6298
- var RecordingTriggersSchema = object({
6299
- motion: boolean().optional(),
6300
- audioThresholdDbfs: number().optional()
6301
- });
6302
- /**
6303
- * Mode of a single recording band — the recorder per-band vocabulary.
6304
- *
6305
- * Distinct from `RecordingStorageModeSchema` (which carries `off`): a band is
6306
- * only ever `continuous` or `events`; "off" is expressed by the absence of a
6307
- * covering band, not by a band value.
6308
- */
6309
- var RecordingBandModeSchema = _enum(["continuous", "events"]);
6310
- /**
6311
- * Triggers for an `events`-mode band. Identical shape to
6312
- * `RecordingTriggersSchema` — reuse that schema as the band trigger type so the
6313
- * two never drift.
6314
- */
6315
- var RecordingBandTriggersSchema = RecordingTriggersSchema;
6316
- /**
6317
- * A single mode-per-band window — the canonical recorder band shape, the
6318
- * single source of truth re-used by `addon-pipeline/recorder`.
6319
- *
6320
- * `days` lists the weekdays the band covers (empty = every day, matching the
6321
- * band engine's `applies` rule). `start`/`end` are `HH:MM`; an `end <= start`
6322
- * span wraps past midnight (handled by the band engine).
6323
- */
6324
- var RecordingBandSchema = object({
6325
- days: array(RecordingWeekdaySchema),
6326
- start: string().regex(HHMM),
6327
- end: string().regex(HHMM),
6328
- mode: RecordingBandModeSchema,
6329
- triggers: RecordingBandTriggersSchema.optional(),
6330
- preBufferSec: number().min(0).optional(),
6331
- postBufferSec: number().min(0).optional()
6332
- });
6333
- var RecordingRuleSchema = object({
6334
- schedule: RecordingScheduleSchema,
6335
- mode: RecordingModeSchema,
6336
- /** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
6337
- preBufferSec: number().min(0).default(0),
6338
- /** Keep recording until this many seconds after the last trigger. */
6339
- postBufferSec: number().min(0).default(0),
6340
- /** Each new trigger restarts the post-buffer window. */
6341
- resetTimeoutOnNewEvent: boolean().default(true),
6342
- /** onAudioThreshold only — dBFS level that counts as a trigger. */
6343
- thresholdDbfs: number().optional()
6344
- });
6345
- /**
6346
- * Per-device retention overrides. Every field is optional; an unset or `0`
6347
- * value inherits the node-wide recorder default. Only footage-lifetime limits
6348
- * live per-camera: `maxAgeDays` and `maxSizeGb`. The disk-occupancy threshold
6349
- * (when the volume is too full to keep recording) is NOT a per-camera concern —
6350
- * it belongs to the StorageLocation (`StorageLocation.config.minFreePercent`),
6351
- * shared by every camera writing to that volume.
6352
- */
6353
- var RecordingRetentionSchema = object({
6354
- maxAgeDays: number().min(0).optional(),
6355
- maxSizeGb: number().min(0).optional()
6356
- });
6357
- /**
6358
- * The full per-camera recording intent — the wire shape of a RecordingTarget.
6359
- *
6360
- * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
6361
- * are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
6362
- * only for transition + migration (`migrateRulesToMode`); the policy engine
6363
- * consumes the compiled output of `compileRules(config)`, never `rules` directly.
6364
- */
6365
- var RecordingConfigSchema = object({
6366
- enabled: boolean(),
6367
- /** Authoritative storage mode. Absent on legacy targets → derived once via
6368
- * `migrateRulesToMode`, then persisted. */
6369
- mode: RecordingStorageModeSchema.optional(),
6370
- profiles: array(CamProfileSchema).optional(),
6371
- segmentSeconds: number().int().positive().optional(),
6372
- /** Shared recording time-bands for `events` & `continuous` — record only when
6373
- * the wall-clock falls inside one of these windows. Omit or empty = always.
6374
- * `continuous` compiles to one rule per band; `events` to band × trigger. */
6375
- schedules: array(RecordingScheduleSchema).optional(),
6376
- /** Legacy single-band predecessor of `schedules`. Read-compat only — it is
6377
- * normalized into `schedules` on read and never written going forward. (Not
6378
- * tagged `@deprecated`: the normalization paths must read it cast-free.) */
6379
- schedule: RecordingScheduleSchema.optional(),
6380
- /** `events`-mode only — which detectors trigger a recording. */
6381
- triggers: RecordingTriggersSchema.optional(),
6382
- /** `events`-mode only — seconds retained before / after a trigger. */
6383
- preBufferSec: number().min(0).optional(),
6384
- postBufferSec: number().min(0).optional(),
6385
- /** DEPRECATED authoring input; retained for migration/transition. */
6386
- rules: array(RecordingRuleSchema).optional(),
6387
- /**
6388
- * AUTHORITATIVE mode-per-band recording model (recorder). When present it
6389
- * is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
6390
- * `triggers`/`rules` fields above are kept for READ-COMPAT only and are
6391
- * derived into bands once via `migrateConfigToBands`.
6392
- */
6393
- bands: array(RecordingBandSchema).optional(),
6394
- retention: RecordingRetentionSchema.optional()
6395
- });
6396
6206
  var ReadinessTimeoutError = class extends Error {
6397
6207
  capName;
6398
6208
  scope;
@@ -6742,770 +6552,1116 @@ function randomGeneration() {
6742
6552
  if (typeof crypto !== "undefined" && crypto.randomUUID) return crypto.randomUUID();
6743
6553
  return Math.random().toString(36).slice(2, 14);
6744
6554
  }
6745
- /**
6746
- * `StorageLocationType` — an addon-declared id that identifies the *kind* of
6747
- * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
6748
- * so the persisted record schema and the consumer-facing cap can both consume it
6749
- * without forming a circular import. The `storage` cap re-exports it
6750
- * verbatim for back-compat.
6751
- *
6752
- * This Zod schema is the **authoritative source** for `StorageLocationType`.
6753
- * The TS alias in `./storage.ts` re-exports `z.infer<typeof
6754
- * StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
6755
- * `IStorageProvider` interface stay in lockstep.
6756
- *
6757
- * The type is now an **open string** (not a closed enum) — addons declare
6758
- * their own location kinds via `StorageLocationDeclaration.id`. The regex
6759
- * enforces a safe id format: lowercase-start, alphanumeric + hyphens.
6760
- */
6761
- var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
6762
- /**
6763
- * Persisted record for a storage location instance. Operators can register
6764
- * multiple instances for multi-cardinality types (e.g. two `backups`
6765
- * locations with different `providerId`s). Cardinality is now declared per
6766
- * location via `StorageLocationDeclaration.cardinality` the static
6767
- * `STORAGE_LOCATION_CARDINALITY` map has been removed.
6768
- *
6769
- * `id` is a stable namespaced string of the form `<type>:<slug>`.
6770
- * The default location for a type uses `id === <type>:default` by
6771
- * convention (the bare type ref like `'backups'` resolves to it).
6772
- *
6773
- * `isSystem: true` marks a location as orchestrator-seeded and
6774
- * undeletable. The bootstrap-installed defaults (one per type) carry
6775
- * this flag; operator-added locations don't. Editing the config of
6776
- * a system location is allowed (path migration, provider swap) but
6777
- * deleting it is rejected at the cap level.
6778
- */
6779
- var StorageLocationSchema = object({
6780
- id: string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
6781
- type: string(),
6782
- displayName: string().min(1),
6783
- providerId: string().min(1),
6784
- config: record(string(), unknown()),
6785
- /**
6786
- * Cluster node this location physically lives on. REQUIRED for node-local
6787
- * providers (filesystem — the path exists on one node's disk), null/absent
6788
- * for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
6789
- * `'hub'` is the hub node. Validated against the provider's `nodeLocal`
6790
- * flag at upsert time, not here (the schema is provider-agnostic).
6791
- */
6792
- nodeId: string().optional(),
6793
- isDefault: boolean().default(false),
6794
- isSystem: boolean().default(false),
6795
- createdAt: number(),
6796
- updatedAt: number()
6797
- });
6798
- /**
6799
- * Reference accepted by consumer-facing `api.storage.*` calls.
6800
- * Either:
6801
- * - a `StorageLocationType` (e.g. `'backups'`) orchestrator resolves to the default of that type
6802
- * - a fully-qualified id (e.g. `'backups:nas-01'`) addresses a specific instance
6803
- *
6804
- * The orchestrator's `resolveRef(ref)` handles both cases.
6805
- */
6806
- var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
6807
- /**
6808
- * `StorageLocationDeclaration` a single storage-location entry declared by
6809
- * an addon in its `package.json` under `camstack.storageLocations`.
6810
- *
6811
- * Design intent:
6812
- * - **Addon declares its needs** — each addon describes the logical storage
6813
- * slots it requires (e.g. `recordings`, `recordingsLow`) without caring
6814
- * about the physical path.
6815
- * - **Kernel aggregates** — at boot the kernel collects declarations from all
6816
- * installed addons, deduplicates by `id`, and exposes the union via the
6817
- * storage-locations settings surface.
6818
- * - **Orchestrator seeds** for every declared `id` the orchestrator ensures
6819
- * at least one instance named `<id>:default` is present, using
6820
- * `defaultsTo` to inherit the resolved root from another location when the
6821
- * declaration is a derivative slot (e.g. `recordingsLow` defaults to
6822
- * `recordings`).
6823
- * - **ids are global** — `id` values are shared across the entire deployment;
6824
- * two addons declaring the same `id` must agree on `cardinality` (validated
6825
- * at kernel aggregation time, not here).
6826
- */
6827
- var StorageLocationDeclarationSchema = object({
6828
- /**
6829
- * Global location identifier, e.g. `recordings` or `recordingsLow`.
6830
- * Must start with a lowercase letter and may contain letters, digits, and
6831
- * hyphens.
6832
- */
6833
- id: string().regex(/^[a-z][a-zA-Z0-9-]*$/, { message: "id must start with a lowercase letter and contain only letters, digits, or hyphens" }),
6834
- /** Human-readable name shown in the admin UI. */
6835
- displayName: string().min(1, { message: "displayName must not be empty" }),
6836
- /** Optional longer explanation of what data this location stores. */
6837
- description: string().optional(),
6838
- /**
6839
- * `single` — exactly one instance of this location is allowed system-wide
6840
- * (e.g. `logs`, `models`). The operator can edit it but not add more.
6841
- * `multi` — the operator may register several instances (e.g. a second
6842
- * `recordings` on a NAS for disk tiering); one is the default at any time.
6843
- */
6844
- cardinality: _enum(["single", "multi"]),
6845
- /**
6846
- * When set, the default instance for this location inherits its resolved
6847
- * root from the named location's default instance. Useful for derivative
6848
- * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
6849
- * configure the primary location.
6850
- */
6851
- defaultsTo: string().optional()
6852
- });
6853
- var DecoderStatsSchema = object({
6854
- inputFps: number(),
6855
- outputFps: number(),
6856
- avgDecodeTimeMs: number(),
6857
- droppedFrames: number()
6858
- });
6859
- var DecoderSessionConfigSchema = object({
6860
- codec: string(),
6861
- maxFps: number().default(0),
6862
- outputFormat: _enum([
6863
- "jpeg",
6864
- "rgb",
6865
- "bgr",
6866
- "yuv420",
6867
- "gray"
6868
- ]).default("jpeg"),
6869
- scale: number().default(1),
6870
- width: number().optional(),
6871
- height: number().optional(),
6555
+ var DeviceType = /* @__PURE__ */ function(DeviceType) {
6556
+ DeviceType["Camera"] = "camera";
6557
+ DeviceType["Hub"] = "hub";
6558
+ DeviceType["Light"] = "light";
6559
+ DeviceType["Siren"] = "siren";
6560
+ DeviceType["Switch"] = "switch";
6561
+ DeviceType["Sensor"] = "sensor";
6562
+ DeviceType["Thermostat"] = "thermostat";
6563
+ DeviceType["Button"] = "button";
6564
+ /** Generic stateless event emitter carries a device's EXACT declared
6565
+ * event vocabulary verbatim (no normalization). Installed with the
6566
+ * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
6567
+ * HA bus events (e.g. `zha_event`, generic). */
6568
+ DeviceType["EventEmitter"] = "event-emitter";
6569
+ /** Firmware/software update entity current vs available version,
6570
+ * updatable flag, update state, and an install action. Installed with
6571
+ * the `update` cap. Sources: Homematic firmware-update channels (and
6572
+ * reusable by other providers, e.g. HA `update.*` entities). */
6573
+ DeviceType["Update"] = "update";
6574
+ DeviceType["Generic"] = "generic";
6575
+ /** Generic notification delivery target (HA `notify.<service>`, future
6576
+ * Telegram / Discord / ntfy / SMTP, …). One device per delivery
6577
+ * endpoint; the `notifier` cap defines the send surface. */
6578
+ DeviceType["Notifier"] = "notifier";
6579
+ /** Pre-recorded action sequence with optional parameters
6580
+ * (HA `script.*`). Runnable via `script-runner` cap. */
6581
+ DeviceType["Script"] = "script";
6582
+ /** Automation rule (HA `automation.*`) — enable/disable + manual
6583
+ * trigger surface exposed via `automation-control` cap. */
6584
+ DeviceType["Automation"] = "automation";
6585
+ /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
6586
+ DeviceType["Lock"] = "lock";
6587
+ /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
6588
+ * `valve.*`). `cover` cap with sub-roles for variant. */
6589
+ DeviceType["Cover"] = "cover";
6590
+ /** Pipe / water / gas valve with open/close/stop and optional
6591
+ * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
6592
+ * modelled on the same open/closed lifecycle. */
6593
+ DeviceType["Valve"] = "valve";
6594
+ /** Humidifier / dehumidifier with on/off + target humidity + mode
6595
+ * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
6596
+ * modelled on the same target / mode lifecycle. */
6597
+ DeviceType["Humidifier"] = "humidifier";
6598
+ /** Water heater / boiler with target temperature + operation mode +
6599
+ * away mode (HA `water_heater.*`). `water-heater` cap a
6600
+ * climate-family actuator. */
6601
+ DeviceType["WaterHeater"] = "water-heater";
6602
+ /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
6603
+ DeviceType["Fan"] = "fan";
6604
+ /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
6605
+ * the camera surface — those use `Camera`. `media-player` cap. */
6606
+ DeviceType["MediaPlayer"] = "media-player";
6607
+ /** Security panel / alarm system (HA `alarm_control_panel.*`).
6608
+ * `alarm-panel` cap. */
6609
+ DeviceType["AlarmPanel"] = "alarm-panel";
6610
+ /** Generic user-settable input (HA `number` / `input_number` / `select`
6611
+ * / `input_select` / `text` / `input_text` / `input_datetime`).
6612
+ * Sub-type via `DeviceRole`: NumericControl / SelectControl /
6613
+ * TextControl / DateTimeControl. */
6614
+ DeviceType["Control"] = "control";
6615
+ /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
6616
+ * `presence` cap. */
6617
+ DeviceType["Presence"] = "presence";
6618
+ /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
6619
+ * `weather` cap. */
6620
+ DeviceType["Weather"] = "weather";
6621
+ /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
6622
+ DeviceType["Vacuum"] = "vacuum";
6623
+ /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
6624
+ * `lawn-mower-control` cap. */
6625
+ DeviceType["LawnMower"] = "lawn-mower";
6626
+ /** Physical HA device group parent container for entity-children
6627
+ * adopted from a single HA device entry. Not renderable as a
6628
+ * standalone device; exists only to anchor child entities. */
6629
+ DeviceType["Container"] = "container";
6630
+ /** Single still-image entity (HA `image.*`). Read-only display of an
6631
+ * `entity_picture` signed URL the browser loads directly. `image` cap. */
6632
+ DeviceType["Image"] = "image";
6633
+ return DeviceType;
6634
+ }({});
6635
+ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
6636
+ DeviceFeature["BatteryOperated"] = "battery-operated";
6637
+ DeviceFeature["Rebootable"] = "rebootable";
6872
6638
  /**
6873
- * Identifier of the camera this decoder session serves. Optional
6874
- * because the cap is generic (any caller could request decode), but
6875
- * stream-broker passes it so decoder logs include `deviceId` for
6876
- * per-camera filtering when diagnosing failures (e.g. node-av
6877
- * sendPacket errors on a single hung camera).
6639
+ * Device supports an on-demand re-sync of its derived spec with its
6640
+ * upstream source drives the generic Re-sync button. The owning
6641
+ * provider implements the action via the `device-adoption.resync` cap.
6878
6642
  */
6879
- deviceId: number().int().nonnegative().optional(),
6643
+ DeviceFeature["Resyncable"] = "resyncable";
6644
+ DeviceFeature["NativeSnapshot"] = "native-snapshot";
6645
+ DeviceFeature["DoorbellButton"] = "doorbell-button";
6646
+ DeviceFeature["TwoWayAudio"] = "two-way-audio";
6647
+ DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
6880
6648
  /**
6881
- * Free-form tag for log scoping. Stream-broker uses
6882
- * `broker:<deviceId>/<profile>`. Decoder session logger surfaces it
6883
- * on every line so `grep tag=broker:5/high` filters one camera
6884
- * profile cleanly.
6649
+ * Camera supports the on-firmware autotrack subsystem (subject-
6650
+ * following). Distinct from `PanTiltZoom` because not every PTZ
6651
+ * camera ships autotrack the admin UI uses this flag to gate
6652
+ * the autotrack toggle / settings card without re-deriving from
6653
+ * the cap registry. Mirrors `ptz-autotrack` cap registration:
6654
+ * driver sets this feature when probe confirms the firmware
6655
+ * surface, and registers the cap in the same code path.
6885
6656
  */
6886
- tag: string().optional(),
6657
+ DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
6887
6658
  /**
6888
- * Where the session delivers decoded frames (Phase 5 / D9):
6659
+ * Accessory exposes a "trigger on motion" toggle the parent camera's
6660
+ * motion detection automatically activates this device. Mirrors
6661
+ * `motion-trigger` cap registration: drivers set this feature in the
6662
+ * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
6889
6663
  *
6890
- * - `'callback'` (default) the legacy pixel path: decoded frames are
6891
- * buffered as `DecodedFrame`s and drained via `pullFrames`.
6892
- * - `'shm'` the shared-memory frame plane: decoded frames are written
6893
- * into an OS shared-memory ring and drained as zero-pixel
6894
- * `FrameHandle`s via `pullHandles`. A session is one mode or the
6895
- * other — `pullFrames` returns nothing for an `'shm'` session and
6896
- * `pullHandles` returns nothing for a `'callback'` session.
6897
- */
6898
- frameSink: _enum(["callback", "shm"]).default("callback")
6899
- });
6900
- var EncodeProfileSchema = object({
6901
- video: object({
6902
- codec: _enum([
6903
- "h264",
6904
- "h265",
6905
- "copy"
6906
- ]),
6907
- profile: _enum([
6908
- "baseline",
6909
- "main",
6910
- "high"
6911
- ]).optional(),
6912
- width: number().int().positive().optional(),
6913
- height: number().int().positive().optional(),
6914
- fps: number().positive().optional(),
6915
- bitrateKbps: number().int().positive().optional(),
6916
- gopFrames: number().int().positive().optional(),
6917
- bf: number().int().min(0).optional(),
6918
- preset: _enum([
6919
- "ultrafast",
6920
- "superfast",
6921
- "veryfast",
6922
- "faster",
6923
- "fast",
6924
- "medium"
6925
- ]).optional(),
6926
- tune: _enum([
6927
- "zerolatency",
6928
- "film",
6929
- "animation"
6930
- ]).optional()
6931
- }),
6932
- audio: union([literal("passthrough"), object({
6933
- codec: _enum([
6934
- "opus",
6935
- "aac",
6936
- "pcmu",
6937
- "pcma",
6938
- "copy"
6939
- ]),
6940
- bitrateKbps: number().int().positive().optional(),
6941
- sampleRateHz: number().int().positive().optional(),
6942
- channels: union([literal(1), literal(2)]).optional()
6943
- })]),
6944
- /**
6945
- * ffmpeg input-side args, inserted between the fixed global flags
6946
- * (`-hide_banner -loglevel error`) and `-i pipe:0`. Free-text array
6947
- * — the widget surfaces a textarea + suggestion chips for the most-
6948
- * used demuxer/format options.
6949
- */
6950
- inputArgs: array(string()).optional(),
6951
- /**
6952
- * ffmpeg output-side args, inserted between the encode block and
6953
- * the final `-f <muxer> pipe:1`. Use for muxer options, bitstream
6954
- * filters, codec-specific overrides. Free-text array.
6664
+ * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
6665
+ * fast scalar without binding fetch), notifier rules, and `listAll`
6666
+ * filters that want "all devices with on-motion behaviour".
6955
6667
  */
6956
- outputArgs: array(string()).optional()
6957
- });
6958
- /**
6959
- import { errMsg } from '@camstack/types'
6960
- * Extract a human-readable message from an unknown error value.
6961
- * Replaces the ubiquitous `errMsg(err)` pattern.
6962
- */
6963
- function errMsg(err) {
6964
- if (err instanceof Error) return err.message;
6965
- if (typeof err === "string") return err;
6966
- return String(err);
6668
+ DeviceFeature["MotionTrigger"] = "motion-trigger";
6669
+ /** Light supports rgb-triplet color via `color` cap. */
6670
+ DeviceFeature["LightColorRgb"] = "light-color-rgb";
6671
+ /** Light supports HSV color via `color` cap. */
6672
+ DeviceFeature["LightColorHsv"] = "light-color-hsv";
6673
+ /** Light supports color-temperature (mired) via `color` cap. */
6674
+ DeviceFeature["LightColorMired"] = "light-color-mired";
6675
+ /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
6676
+ * targetHigh). Gates the range slider UI. */
6677
+ DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
6678
+ /** Thermostat exposes target humidity and/or current humidity
6679
+ * readings. Gates the humidity controls. */
6680
+ DeviceFeature["ClimateHumidity"] = "climate-humidity";
6681
+ /** Thermostat exposes a fan-mode selector. */
6682
+ DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
6683
+ /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
6684
+ DeviceFeature["ClimatePreset"] = "climate-preset";
6685
+ /** Cover exposes intermediate position control (0..100). Gates the
6686
+ * position slider UI. */
6687
+ DeviceFeature["CoverPositionable"] = "cover-positionable";
6688
+ /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
6689
+ DeviceFeature["CoverTilt"] = "cover-tilt";
6690
+ /** Valve exposes intermediate position control (0..100). Gates the
6691
+ * position slider / drag surface UI. */
6692
+ DeviceFeature["ValvePositionable"] = "valve-positionable";
6693
+ /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
6694
+ DeviceFeature["FanSpeed"] = "fan-speed";
6695
+ /** Fan exposes a preset mode selector. */
6696
+ DeviceFeature["FanPreset"] = "fan-preset";
6697
+ /** Fan exposes blade direction (forward/reverse) — typical of
6698
+ * ceiling fans. */
6699
+ DeviceFeature["FanDirection"] = "fan-direction";
6700
+ /** Fan exposes an oscillation toggle. */
6701
+ DeviceFeature["FanOscillating"] = "fan-oscillating";
6702
+ /** Lock requires a PIN code on lock/unlock. Gates the code-entry
6703
+ * field on the UI lock-controls panel. */
6704
+ DeviceFeature["LockPinRequired"] = "lock-pin-required";
6705
+ /** Lock supports a latch-release ("open door") action distinct from
6706
+ * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
6707
+ * `supported_features`. Gates the Open Door button in the UI. */
6708
+ DeviceFeature["LockOpen"] = "lock-open";
6709
+ /** Media player exposes a seek-to-position surface. */
6710
+ DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
6711
+ /** Media player exposes a volume-level setter. */
6712
+ DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
6713
+ /** Media player exposes a mute toggle distinct from volume=0. */
6714
+ DeviceFeature["MediaPlayerMute"] = "media-player-mute";
6715
+ /** Media player exposes a shuffle toggle. */
6716
+ DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
6717
+ /** Media player exposes a repeat mode (off / all / one). */
6718
+ DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
6719
+ /** Media player exposes a source / input selector. */
6720
+ DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
6721
+ /** Media player exposes a play-arbitrary-media surface (URL / id). */
6722
+ DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
6723
+ /** Media player exposes next-track. */
6724
+ DeviceFeature["MediaPlayerNext"] = "media-player-next";
6725
+ /** Media player exposes previous-track. */
6726
+ DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
6727
+ /** Media player exposes stop distinct from pause. */
6728
+ DeviceFeature["MediaPlayerStop"] = "media-player-stop";
6729
+ /** Alarm panel requires a PIN code on arm/disarm. */
6730
+ DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
6731
+ /** Presence device carries GPS coordinates (lat/lng/accuracy) in
6732
+ * addition to a textual location. */
6733
+ DeviceFeature["PresenceGps"] = "presence-gps";
6734
+ /** Notifier accepts an inline / URL image attachment. */
6735
+ DeviceFeature["NotifierImage"] = "notifier-image";
6736
+ /** Notifier accepts a priority hint (high/normal/low). */
6737
+ DeviceFeature["NotifierPriority"] = "notifier-priority";
6738
+ /** Notifier accepts a free-form `data` payload for platform-specific
6739
+ * fields. */
6740
+ DeviceFeature["NotifierData"] = "notifier-data";
6741
+ /** Notifier supports interactive action buttons / callbacks. */
6742
+ DeviceFeature["NotifierActions"] = "notifier-actions";
6743
+ /** Notifier supports per-call recipient targeting (multi-user). */
6744
+ DeviceFeature["NotifierRecipients"] = "notifier-recipients";
6745
+ /** Script runner accepts a variables map on each run invocation. */
6746
+ DeviceFeature["ScriptVariables"] = "script-variables";
6747
+ /** Automation `trigger` accepts a skipCondition flag — fires the
6748
+ * automation's actions while bypassing its condition block. */
6749
+ DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
6750
+ return DeviceFeature;
6751
+ }({});
6752
+ /**
6753
+ * Semantic role a device plays within its parent. Populated by driver
6754
+ * addons when creating accessory devices (Reolink siren/floodlight/
6755
+ * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
6756
+ * admin UI to pick icons, labels, and widgets — a `Switch` with
6757
+ * `role: Floodlight` renders as a bulb with a brightness slider,
6758
+ * whereas a `Switch` with `role: Siren` renders as a klaxon.
6759
+ *
6760
+ * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
6761
+ * sqlite as a nullable TEXT column — old rows keep working unchanged.
6762
+ */
6763
+ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
6764
+ DeviceRole["Siren"] = "siren";
6765
+ DeviceRole["Floodlight"] = "floodlight";
6766
+ DeviceRole["Spotlight"] = "spotlight";
6767
+ DeviceRole["PirSensor"] = "pir-sensor";
6768
+ DeviceRole["Chime"] = "chime";
6769
+ DeviceRole["Autotrack"] = "autotrack";
6770
+ DeviceRole["Nightvision"] = "nightvision";
6771
+ DeviceRole["PrivacyMask"] = "privacy-mask";
6772
+ DeviceRole["Doorbell"] = "doorbell";
6773
+ /** Virtual HA toggle (input_boolean.*) — distinguishable from a
6774
+ * real Switch device for UI rendering / export adapters. */
6775
+ DeviceRole["BinaryHelper"] = "binary-helper";
6776
+ /** Generic motion / occupancy / moving event source. Distinct from
6777
+ * the camera accessory PirSensor role: that one is a camera child;
6778
+ * this is a standalone HA / 3rd-party motion sensor. */
6779
+ DeviceRole["MotionSensor"] = "motion-sensor";
6780
+ DeviceRole["ContactSensor"] = "contact-sensor";
6781
+ DeviceRole["LeakSensor"] = "leak-sensor";
6782
+ DeviceRole["SmokeSensor"] = "smoke-sensor";
6783
+ DeviceRole["COSensor"] = "co-sensor";
6784
+ DeviceRole["GasSensor"] = "gas-sensor";
6785
+ DeviceRole["TamperSensor"] = "tamper-sensor";
6786
+ DeviceRole["VibrationSensor"] = "vibration-sensor";
6787
+ DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
6788
+ DeviceRole["SoundSensor"] = "sound-sensor";
6789
+ /** Fallback for `binary_sensor` without a known `device_class`. */
6790
+ DeviceRole["BinarySensor"] = "binary-sensor";
6791
+ DeviceRole["TemperatureSensor"] = "temperature-sensor";
6792
+ DeviceRole["HumiditySensor"] = "humidity-sensor";
6793
+ DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
6794
+ DeviceRole["PressureSensor"] = "pressure-sensor";
6795
+ DeviceRole["PowerSensor"] = "power-sensor";
6796
+ DeviceRole["EnergySensor"] = "energy-sensor";
6797
+ DeviceRole["VoltageSensor"] = "voltage-sensor";
6798
+ DeviceRole["CurrentSensor"] = "current-sensor";
6799
+ DeviceRole["AirQualitySensor"] = "air-quality-sensor";
6800
+ /** Battery level (numeric % via `sensor` OR low-bool via
6801
+ * `binary_sensor` — the cap distinguishes via the value type). */
6802
+ DeviceRole["BatterySensor"] = "battery-sensor";
6803
+ /** Fallback for `sensor` numeric without a known `device_class`. */
6804
+ DeviceRole["NumericSensor"] = "numeric-sensor";
6805
+ /** String / enum state (HA `sensor` with `state_class: enum` or
6806
+ * `attributes.options`). */
6807
+ DeviceRole["EnumSensor"] = "enum-sensor";
6808
+ /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
6809
+ * or `date`). The slice carries the raw ISO string verbatim (hosted on
6810
+ * the `enum-sensor` cap); the UI renders it locale-formatted. */
6811
+ DeviceRole["DateTimeSensor"] = "datetime-sensor";
6812
+ /** Last-resort fallback when nothing else matches. */
6813
+ DeviceRole["GenericSensor"] = "generic-sensor";
6814
+ DeviceRole["NumericControl"] = "numeric-control";
6815
+ DeviceRole["SelectControl"] = "select-control";
6816
+ DeviceRole["TextControl"] = "text-control";
6817
+ DeviceRole["DateTimeControl"] = "datetime-control";
6818
+ /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
6819
+ * rich features (image, priority, channel routing). */
6820
+ DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
6821
+ /** Chat / messaging service (HA `notify.telegram_*`,
6822
+ * `notify.discord_*`, etc.). */
6823
+ DeviceRole["MessagingNotifier"] = "messaging-notifier";
6824
+ /** Email-based delivery (HA `notify.smtp`, etc.). */
6825
+ DeviceRole["EmailNotifier"] = "email-notifier";
6826
+ /** Fallback when the notifier service name doesn't match a known
6827
+ * pattern. */
6828
+ DeviceRole["GenericNotifier"] = "generic-notifier";
6829
+ return DeviceRole;
6830
+ }({});
6831
+ /**
6832
+ * Generic types for capability definitions.
6833
+ *
6834
+ * A capability is defined with Zod schemas for methods, events, and settings.
6835
+ * TypeScript types are inferred via z.infer<> — zero duplication.
6836
+ *
6837
+ * Pattern:
6838
+ * 1. Define Zod schemas for data, methods, settings
6839
+ * 2. Export const capabilityDef = { ... } satisfies CapabilityDefinition
6840
+ * 3. Export type IProvider = InferProvider<typeof capabilityDef>
6841
+ * 4. Addon implements IProvider
6842
+ * 5. Registry auto-mounts tRPC router from definition.methods
6843
+ */
6844
+ /**
6845
+ * Output schema shared by the contribution + live methods.
6846
+ *
6847
+ * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
6848
+ * tabs[]) without importing from `../interfaces/config-ui.js` — a
6849
+ * concrete-but-lenient Zod object keeps tRPC output inference happy
6850
+ * (using `z.unknown()` here collapses unrelated router branches to
6851
+ * `unknown` when the generator re-inlines the huge AppRouter type).
6852
+ *
6853
+ * `.passthrough()` on sections/fields accepts whatever FormBuilder
6854
+ * extensions the caller adds (showWhen, displayScale, …) without
6855
+ * rebuilding every time a new field kind is introduced.
6856
+ */
6857
+ var ContributionSectionSchema = object({
6858
+ id: string(),
6859
+ title: string(),
6860
+ description: string().optional(),
6861
+ style: _enum(["card", "accordion"]).optional(),
6862
+ defaultCollapsed: boolean().optional(),
6863
+ columns: union([
6864
+ literal(1),
6865
+ literal(2),
6866
+ literal(3),
6867
+ literal(4)
6868
+ ]).optional(),
6869
+ tab: string().optional(),
6870
+ location: _enum(["settings", "top-tab"]).optional(),
6871
+ order: number().optional(),
6872
+ fields: array(any())
6873
+ });
6874
+ object({
6875
+ tabs: array(object({
6876
+ id: string(),
6877
+ label: string(),
6878
+ icon: string(),
6879
+ order: number().optional()
6880
+ })).optional(),
6881
+ sections: array(ContributionSectionSchema)
6882
+ }).nullable();
6883
+ object({ deviceId: number() }), object({ deviceId: number() }), object({
6884
+ deviceId: number(),
6885
+ patch: record(string(), unknown())
6886
+ }), object({ success: literal(true) });
6887
+ object({ deviceId: number() }), unknown().nullable();
6888
+ /** Shorthand to define a method schema */
6889
+ function method(input, output, options) {
6890
+ return {
6891
+ input,
6892
+ output,
6893
+ kind: options?.kind ?? "query",
6894
+ auth: options?.auth ?? "protected",
6895
+ ...options?.access !== void 0 ? { access: options.access } : {},
6896
+ timeoutMs: options?.timeoutMs
6897
+ };
6967
6898
  }
6968
- var YAMNET_TO_MACRO = {
6969
- mapping: {
6970
- Speech: "speech",
6971
- "Child speech, kid speaking": "speech",
6972
- Conversation: "speech",
6973
- "Narration, monologue": "speech",
6974
- Babbling: "speech",
6975
- Whispering: "speech",
6976
- "Speech synthesizer": "speech",
6977
- Humming: "speech",
6978
- Rapping: "speech",
6979
- Singing: "speech",
6980
- Choir: "speech",
6981
- "Child singing": "speech",
6982
- Shout: "scream",
6983
- Bellow: "scream",
6984
- Yell: "scream",
6985
- Screaming: "scream",
6986
- "Children shouting": "scream",
6987
- Whoop: "scream",
6988
- "Crying, sobbing": "crying",
6989
- "Baby cry, infant cry": "crying",
6990
- Whimper: "crying",
6991
- "Wail, moan": "crying",
6992
- Groan: "crying",
6993
- Laughter: "laughter",
6994
- "Baby laughter": "laughter",
6995
- Giggle: "laughter",
6996
- Snicker: "laughter",
6997
- "Belly laugh": "laughter",
6998
- "Chuckle, chortle": "laughter",
6999
- Music: "music",
7000
- "Musical instrument": "music",
7001
- Guitar: "music",
7002
- Piano: "music",
7003
- Drum: "music",
7004
- "Drum kit": "music",
7005
- "Violin, fiddle": "music",
7006
- Flute: "music",
7007
- Saxophone: "music",
7008
- Trumpet: "music",
7009
- Synthesizer: "music",
7010
- "Pop music": "music",
7011
- "Rock music": "music",
7012
- "Hip hop music": "music",
7013
- "Classical music": "music",
7014
- Jazz: "music",
7015
- "Electronic music": "music",
7016
- "Background music": "music",
7017
- Dog: "dog",
7018
- Bark: "dog",
7019
- Yip: "dog",
7020
- Howl: "dog",
7021
- "Bow-wow": "dog",
7022
- Growling: "dog",
7023
- "Whimper (dog)": "dog",
7024
- Cat: "cat",
7025
- Purr: "cat",
7026
- Meow: "cat",
7027
- Hiss: "cat",
7028
- Caterwaul: "cat",
7029
- Bird: "bird",
7030
- "Bird vocalization, bird call, bird song": "bird",
7031
- "Chirp, tweet": "bird",
7032
- Squawk: "bird",
7033
- Crow: "bird",
7034
- Owl: "bird",
7035
- "Pigeon, dove": "bird",
7036
- Animal: "animal",
7037
- "Domestic animals, pets": "animal",
7038
- "Livestock, farm animals, working animals": "animal",
7039
- Horse: "animal",
7040
- "Cattle, bovinae": "animal",
7041
- Pig: "animal",
7042
- Sheep: "animal",
7043
- Goat: "animal",
7044
- Frog: "animal",
7045
- Insect: "animal",
7046
- Cricket: "animal",
7047
- Alarm: "alarm",
7048
- "Alarm clock": "alarm",
7049
- "Smoke detector, smoke alarm": "alarm",
7050
- "Fire alarm": "alarm",
7051
- Buzzer: "alarm",
7052
- "Civil defense siren": "alarm",
7053
- "Car alarm": "alarm",
7054
- Siren: "siren",
7055
- "Police car (siren)": "siren",
7056
- "Ambulance (siren)": "siren",
7057
- "Fire engine, fire truck (siren)": "siren",
7058
- "Emergency vehicle": "siren",
7059
- Foghorn: "siren",
7060
- Doorbell: "doorbell",
7061
- "Ding-dong": "doorbell",
7062
- Knock: "doorbell",
7063
- Tap: "doorbell",
7064
- Glass: "glass_breaking",
7065
- Shatter: "glass_breaking",
7066
- "Chink, clink": "glass_breaking",
7067
- "Gunshot, gunfire": "gunshot",
7068
- "Machine gun": "gunshot",
7069
- Explosion: "gunshot",
7070
- Fireworks: "gunshot",
7071
- Firecracker: "gunshot",
7072
- "Artillery fire": "gunshot",
7073
- "Cap gun": "gunshot",
7074
- Boom: "gunshot",
7075
- Vehicle: "vehicle",
7076
- Car: "vehicle",
7077
- Truck: "vehicle",
7078
- Bus: "vehicle",
7079
- Motorcycle: "vehicle",
7080
- "Car passing by": "vehicle",
7081
- "Vehicle horn, car horn, honking": "vehicle",
7082
- "Traffic noise, roadway noise": "vehicle",
7083
- Train: "vehicle",
7084
- Aircraft: "vehicle",
7085
- Helicopter: "vehicle",
7086
- Bicycle: "vehicle",
7087
- Skateboard: "vehicle",
7088
- Fire: "fire",
7089
- Crackle: "fire",
7090
- Water: "water",
7091
- Rain: "water",
7092
- Raindrop: "water",
7093
- "Rain on surface": "water",
7094
- Stream: "water",
7095
- Waterfall: "water",
7096
- Ocean: "water",
7097
- "Waves, surf": "water",
7098
- "Splash, splatter": "water",
7099
- Wind: "wind",
7100
- Thunderstorm: "wind",
7101
- Thunder: "wind",
7102
- "Wind noise (microphone)": "wind",
7103
- "Rustling leaves": "wind",
7104
- Door: "door",
7105
- "Sliding door": "door",
7106
- Slam: "door",
7107
- "Cupboard open or close": "door",
7108
- "Walk, footsteps": "footsteps",
7109
- Run: "footsteps",
7110
- Shuffle: "footsteps",
7111
- Crowd: "crowd",
7112
- Chatter: "crowd",
7113
- Cheering: "crowd",
7114
- Applause: "crowd",
7115
- "Children playing": "crowd",
7116
- "Hubbub, speech noise, speech babble": "crowd",
7117
- Telephone: "telephone",
7118
- "Telephone bell ringing": "telephone",
7119
- Ringtone: "telephone",
7120
- "Telephone dialing, DTMF": "telephone",
7121
- "Busy signal": "telephone",
7122
- Engine: "engine",
7123
- "Engine starting": "engine",
7124
- Idling: "engine",
7125
- "Accelerating, revving, vroom": "engine",
7126
- "Light engine (high frequency)": "engine",
7127
- "Medium engine (mid frequency)": "engine",
7128
- "Heavy engine (low frequency)": "engine",
7129
- "Lawn mower": "engine",
7130
- Chainsaw: "engine",
7131
- Hammer: "tools",
7132
- Jackhammer: "tools",
7133
- Sawing: "tools",
7134
- "Power tool": "tools",
7135
- Drill: "tools",
7136
- Sanding: "tools",
7137
- Silence: "silence"
7138
- },
7139
- preserveOriginal: false
7140
- };
7141
- var APPLE_SA_TO_MACRO = {
7142
- mapping: {
7143
- speech: "speech",
7144
- child_speech: "speech",
7145
- conversation: "speech",
7146
- whispering: "speech",
7147
- singing: "speech",
7148
- humming: "speech",
7149
- shout: "scream",
7150
- yell: "scream",
7151
- screaming: "scream",
7152
- crying: "crying",
7153
- baby_crying: "crying",
7154
- sobbing: "crying",
7155
- laughter: "laughter",
7156
- baby_laughter: "laughter",
7157
- giggling: "laughter",
7158
- music: "music",
7159
- guitar: "music",
7160
- piano: "music",
7161
- drums: "music",
7162
- dog_bark: "dog",
7163
- dog_bow_wow: "dog",
7164
- dog_growling: "dog",
7165
- dog_howl: "dog",
7166
- cat_meow: "cat",
7167
- cat_purr: "cat",
7168
- cat_hiss: "cat",
7169
- bird: "bird",
7170
- bird_chirp: "bird",
7171
- bird_squawk: "bird",
7172
- animal: "animal",
7173
- horse: "animal",
7174
- cow_moo: "animal",
7175
- insect: "animal",
7176
- alarm: "alarm",
7177
- smoke_alarm: "alarm",
7178
- fire_alarm: "alarm",
7179
- car_alarm: "alarm",
7180
- siren: "siren",
7181
- police_siren: "siren",
7182
- ambulance_siren: "siren",
7183
- doorbell: "doorbell",
7184
- door_knock: "doorbell",
7185
- knocking: "doorbell",
7186
- glass_breaking: "glass_breaking",
7187
- glass_shatter: "glass_breaking",
7188
- gunshot: "gunshot",
7189
- explosion: "gunshot",
7190
- fireworks: "gunshot",
7191
- car: "vehicle",
7192
- truck: "vehicle",
7193
- motorcycle: "vehicle",
7194
- car_horn: "vehicle",
7195
- vehicle_horn: "vehicle",
7196
- traffic: "vehicle",
7197
- fire: "fire",
7198
- fire_crackle: "fire",
7199
- water: "water",
7200
- rain: "water",
7201
- ocean: "water",
7202
- splash: "water",
7203
- wind: "wind",
7204
- thunder: "wind",
7205
- thunderstorm: "wind",
7206
- door: "door",
7207
- door_slam: "door",
7208
- sliding_door: "door",
7209
- footsteps: "footsteps",
7210
- walking: "footsteps",
7211
- running: "footsteps",
7212
- crowd: "crowd",
7213
- chatter: "crowd",
7214
- cheering: "crowd",
7215
- applause: "crowd",
7216
- telephone_ring: "telephone",
7217
- ringtone: "telephone",
7218
- engine: "engine",
7219
- engine_starting: "engine",
7220
- lawn_mower: "engine",
7221
- chainsaw: "engine",
7222
- hammer: "tools",
7223
- jackhammer: "tools",
7224
- drill: "tools",
7225
- power_tool: "tools",
7226
- silence: "silence"
7227
- },
7228
- preserveOriginal: false
7229
- };
7230
- var _macroLookup = /* @__PURE__ */ new Map();
7231
- for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7232
- for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7233
- var DeviceType = /* @__PURE__ */ function(DeviceType) {
7234
- DeviceType["Camera"] = "camera";
7235
- DeviceType["Hub"] = "hub";
7236
- DeviceType["Light"] = "light";
7237
- DeviceType["Siren"] = "siren";
7238
- DeviceType["Switch"] = "switch";
7239
- DeviceType["Sensor"] = "sensor";
7240
- DeviceType["Thermostat"] = "thermostat";
7241
- DeviceType["Button"] = "button";
7242
- /** Generic stateless event emitter carries a device's EXACT declared
7243
- * event vocabulary verbatim (no normalization). Installed with the
7244
- * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
7245
- * HA bus events (e.g. `zha_event`, generic). */
7246
- DeviceType["EventEmitter"] = "event-emitter";
7247
- /** Firmware/software update entity — current vs available version,
7248
- * updatable flag, update state, and an install action. Installed with
7249
- * the `update` cap. Sources: Homematic firmware-update channels (and
7250
- * reusable by other providers, e.g. HA `update.*` entities). */
7251
- DeviceType["Update"] = "update";
7252
- DeviceType["Generic"] = "generic";
7253
- /** Generic notification delivery target (HA `notify.<service>`, future
7254
- * Telegram / Discord / ntfy / SMTP, …). One device per delivery
7255
- * endpoint; the `notifier` cap defines the send surface. */
7256
- DeviceType["Notifier"] = "notifier";
7257
- /** Pre-recorded action sequence with optional parameters
7258
- * (HA `script.*`). Runnable via `script-runner` cap. */
7259
- DeviceType["Script"] = "script";
7260
- /** Automation rule (HA `automation.*`) enable/disable + manual
7261
- * trigger surface exposed via `automation-control` cap. */
7262
- DeviceType["Automation"] = "automation";
7263
- /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
7264
- DeviceType["Lock"] = "lock";
7265
- /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
7266
- * `valve.*`). `cover` cap with sub-roles for variant. */
7267
- DeviceType["Cover"] = "cover";
7268
- /** Pipe / water / gas valve with open/close/stop and optional
7269
- * position (HA `valve.*`). `valve` cap a cover-sibling actuator
7270
- * modelled on the same open/closed lifecycle. */
7271
- DeviceType["Valve"] = "valve";
7272
- /** Humidifier / dehumidifier with on/off + target humidity + mode
7273
- * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
7274
- * modelled on the same target / mode lifecycle. */
7275
- DeviceType["Humidifier"] = "humidifier";
7276
- /** Water heater / boiler with target temperature + operation mode +
7277
- * away mode (HA `water_heater.*`). `water-heater` cap a
7278
- * climate-family actuator. */
7279
- DeviceType["WaterHeater"] = "water-heater";
7280
- /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
7281
- DeviceType["Fan"] = "fan";
7282
- /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
7283
- * the camera surface — those use `Camera`. `media-player` cap. */
7284
- DeviceType["MediaPlayer"] = "media-player";
7285
- /** Security panel / alarm system (HA `alarm_control_panel.*`).
7286
- * `alarm-panel` cap. */
7287
- DeviceType["AlarmPanel"] = "alarm-panel";
7288
- /** Generic user-settable input (HA `number` / `input_number` / `select`
7289
- * / `input_select` / `text` / `input_text` / `input_datetime`).
7290
- * Sub-type via `DeviceRole`: NumericControl / SelectControl /
7291
- * TextControl / DateTimeControl. */
7292
- DeviceType["Control"] = "control";
7293
- /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
7294
- * `presence` cap. */
7295
- DeviceType["Presence"] = "presence";
7296
- /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
7297
- * `weather` cap. */
7298
- DeviceType["Weather"] = "weather";
7299
- /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
7300
- DeviceType["Vacuum"] = "vacuum";
7301
- /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
7302
- * `lawn-mower-control` cap. */
7303
- DeviceType["LawnMower"] = "lawn-mower";
7304
- /** Physical HA device group — parent container for entity-children
7305
- * adopted from a single HA device entry. Not renderable as a
7306
- * standalone device; exists only to anchor child entities. */
7307
- DeviceType["Container"] = "container";
7308
- /** Single still-image entity (HA `image.*`). Read-only display of an
7309
- * `entity_picture` signed URL the browser loads directly. `image` cap. */
7310
- DeviceType["Image"] = "image";
7311
- return DeviceType;
7312
- }({});
7313
- var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
7314
- DeviceFeature["BatteryOperated"] = "battery-operated";
7315
- DeviceFeature["Rebootable"] = "rebootable";
6899
+ var StaticDirOutputSchema = object({ staticDir: string() });
6900
+ var VersionOutputSchema = object({ version: string() });
6901
+ method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
6902
+ /**
6903
+ * device-ops — device-scoped cap that unifies the per-IDevice operations
6904
+ * previously routed through the `.device-ops` Moleculer bridge service.
6905
+ *
6906
+ * Each worker that hosts live `IDevice` instances auto-registers a native
6907
+ * provider for this cap (per device) backed by its local
6908
+ * `DeviceRegistry`. Hub-side callers reach it transparently through
6909
+ * `ctx.fetchDevice(id).deviceOps.*` — the DeviceProxy injects
6910
+ * `deviceId` + `nodeId` and dispatches through the standard cap-router,
6911
+ * so there's no parallel bridge path anymore.
6912
+ *
6913
+ * The surface is intentionally small — every method corresponds to a
6914
+ * single action on the live `IDevice` (or `ICameraDevice` for
6915
+ * `getStreamSources`). Richer orchestration (enable/disable with
6916
+ * integration plumbing, bulk updates) stays in the `device-manager` cap;
6917
+ * `device-ops` is the per-device primitive the device-manager routes to.
6918
+ */
6919
+ var StreamSourceEntrySchema = object({
6920
+ id: string(),
6921
+ label: string(),
6922
+ protocol: _enum([
6923
+ "rtsp",
6924
+ "rtmp",
6925
+ "annexb",
6926
+ "http-mjpeg",
6927
+ "webrtc",
6928
+ "custom"
6929
+ ]),
6930
+ url: string().optional(),
6931
+ resolution: object({
6932
+ width: number(),
6933
+ height: number()
6934
+ }).optional(),
6935
+ fps: number().optional(),
6936
+ bitrate: number().optional(),
6937
+ codec: string().optional(),
6938
+ profileHint: CamProfileSchema.optional(),
6939
+ sdp: string().optional()
6940
+ });
6941
+ var ConfigEntrySchema$1 = object({
6942
+ key: string(),
6943
+ value: unknown()
6944
+ });
6945
+ var RawStateResultSchema = object({
6946
+ /** Originating provider id, e.g. 'homeassistant' | 'reolink' | 'hikvision'. */
6947
+ source: string(),
6948
+ /** Opaque, DISPLAY-SAFE upstream blob (no secrets/PII). */
6949
+ data: record(string(), unknown())
6950
+ });
6951
+ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
6952
+ deviceId: number(),
6953
+ values: record(string(), unknown())
6954
+ }), _void(), { kind: "mutation" }), method(object({
6955
+ deviceId: number(),
6956
+ action: string().min(1),
6957
+ input: unknown()
6958
+ }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
6959
+ /**
6960
+ * Promise-based timer helpers — used everywhere the codebase needs to
6961
+ * wait, back off, or schedule a retry. Before these helpers landed, each
6962
+ * call site re-implemented `new Promise(r => setTimeout(r, ms))` inline,
6963
+ * with subtle variations (some swallowing cancellation, some not). Two
6964
+ * shapes cover every observed use case:
6965
+ *
6966
+ * - {@link sleep} for a plain, uncancellable wait — the default choice.
6967
+ * - {@link sleepCancellable} for a wait that wakes early when an
6968
+ * abort signal trips, used by long-running pollers whose teardown
6969
+ * must stop a pending backoff promptly.
6970
+ */
6971
+ /**
6972
+ * Resolve after `ms` milliseconds. Never rejects, never cancels. The
6973
+ * sleep cannot be interrupted; for a wakeable variant use
6974
+ * {@link sleepCancellable}.
6975
+ *
6976
+ * `ms <= 0` resolves on the next microtask via `setTimeout(0)`, which
6977
+ * still gives the event loop a chance to drain — useful for breaking
6978
+ * up tight async loops without changing call-site semantics.
6979
+ */
6980
+ function sleep$1(ms) {
6981
+ return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
6982
+ }
6983
+ //#endregion
6984
+ //#region ../types/dist/err-msg-IQTHeDzc.mjs
6985
+ /**
6986
+ import { errMsg } from '@camstack/types'
6987
+ * Extract a human-readable message from an unknown error value.
6988
+ * Replaces the ubiquitous `errMsg(err)` pattern.
6989
+ */
6990
+ function errMsg(err) {
6991
+ if (err instanceof Error) return err.message;
6992
+ if (typeof err === "string") return err;
6993
+ return String(err);
6994
+ }
6995
+ //#endregion
6996
+ //#region ../types/dist/index.mjs
6997
+ /**
6998
+ * Deep wiring healthcheck — snapshot of active reachability probes across
6999
+ * every declared capability + widget of every installed plugin, on every
7000
+ * node. Produced by the backend `WiringHealthService` and surfaced via
7001
+ * `GET /health/wiring`, the tRPC `health.wiring` query, and the boot-gate.
7002
+ *
7003
+ * Unlike `/health` (process liveness), this reflects whether each cap/widget
7004
+ * is actually *reachable* over the real cap-dispatch path. See spec
7005
+ * `docs/superpowers/specs/2026-05-23-deep-healthcheck-design.md`.
7006
+ */
7007
+ /** What kind of target a probe addressed. */
7008
+ var wiringProbeKindSchema = _enum([
7009
+ "singleton",
7010
+ "device",
7011
+ "widget"
7012
+ ]);
7013
+ /** Result of probing a single (cap|widget [, device]) target. */
7014
+ var wiringProbeResultSchema = object({
7015
+ capName: string(),
7016
+ kind: wiringProbeKindSchema,
7017
+ deviceId: number().optional(),
7018
+ reachable: boolean(),
7019
+ latencyMs: number(),
7020
+ error: string().optional()
7021
+ });
7022
+ /** Per-addon roll-up of cap + widget probe results. */
7023
+ var wiringAddonHealthSchema = object({
7024
+ addonId: string(),
7025
+ caps: array(wiringProbeResultSchema).readonly(),
7026
+ widgets: array(wiringProbeResultSchema).readonly()
7027
+ });
7028
+ /** Per-node roll-up. */
7029
+ var wiringNodeHealthSchema = object({
7030
+ nodeId: string(),
7031
+ addons: array(wiringAddonHealthSchema).readonly()
7032
+ });
7033
+ object({
7034
+ /** True only when every probed target is reachable. */
7035
+ ok: boolean(),
7036
+ /** True when at least one target is unreachable. */
7037
+ degraded: boolean(),
7038
+ checkedAt: string(),
7039
+ nodes: array(wiringNodeHealthSchema).readonly(),
7040
+ summary: object({
7041
+ total: number(),
7042
+ reachable: number(),
7043
+ unreachable: number()
7044
+ })
7045
+ });
7046
+ var MODEL_FORMATS = [
7047
+ "onnx",
7048
+ "coreml",
7049
+ "openvino",
7050
+ "tflite",
7051
+ "pt"
7052
+ ];
7053
+ /**
7054
+ * Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
7055
+ * Named `RecordingWeekday` to avoid collision with the string-union
7056
+ * `Weekday` exported from `interfaces/timezones.ts`.
7057
+ */
7058
+ var RecordingWeekdaySchema = number().int().min(0).max(6);
7059
+ var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
7060
+ var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
7061
+ kind: literal("timeOfDay"),
7062
+ start: string().regex(HHMM),
7063
+ end: string().regex(HHMM),
7064
+ /** Restrict to these weekdays; omit = every day. */
7065
+ days: array(RecordingWeekdaySchema).optional()
7066
+ })]);
7067
+ var RecordingModeSchema = _enum([
7068
+ "continuous",
7069
+ "onMotion",
7070
+ "onAudioThreshold"
7071
+ ]);
7072
+ /**
7073
+ * First-class, authoritative per-camera storage mode — the netta choice the UI
7074
+ * reads directly (never inferred from `rules`):
7075
+ * - `off` — not recording.
7076
+ * - `events` — record only around triggers (motion / audio threshold),
7077
+ * with pre/post-buffer.
7078
+ * - `continuous` — record 24/7 within the schedule.
7079
+ *
7080
+ * `mode` compiles one-way to the internal `rules[]` consumed by the policy
7081
+ * engine (see `compileRules`); `rules[]` is never authored directly anymore.
7082
+ */
7083
+ var RecordingStorageModeSchema = _enum([
7084
+ "off",
7085
+ "events",
7086
+ "continuous"
7087
+ ]);
7088
+ /** Which detectors trigger an `events`-mode recording. */
7089
+ var RecordingTriggersSchema = object({
7090
+ motion: boolean().optional(),
7091
+ audioThresholdDbfs: number().optional()
7092
+ });
7093
+ /**
7094
+ * Mode of a single recording band — the recorder per-band vocabulary.
7095
+ *
7096
+ * Distinct from `RecordingStorageModeSchema` (which carries `off`): a band is
7097
+ * only ever `continuous` or `events`; "off" is expressed by the absence of a
7098
+ * covering band, not by a band value.
7099
+ */
7100
+ var RecordingBandModeSchema = _enum(["continuous", "events"]);
7101
+ /**
7102
+ * Triggers for an `events`-mode band. Identical shape to
7103
+ * `RecordingTriggersSchema` — reuse that schema as the band trigger type so the
7104
+ * two never drift.
7105
+ */
7106
+ var RecordingBandTriggersSchema = RecordingTriggersSchema;
7107
+ /**
7108
+ * A single mode-per-band window — the canonical recorder band shape, the
7109
+ * single source of truth re-used by `addon-pipeline/recorder`.
7110
+ *
7111
+ * `days` lists the weekdays the band covers (empty = every day, matching the
7112
+ * band engine's `applies` rule). `start`/`end` are `HH:MM`; an `end <= start`
7113
+ * span wraps past midnight (handled by the band engine).
7114
+ */
7115
+ var RecordingBandSchema = object({
7116
+ days: array(RecordingWeekdaySchema),
7117
+ start: string().regex(HHMM),
7118
+ end: string().regex(HHMM),
7119
+ mode: RecordingBandModeSchema,
7120
+ triggers: RecordingBandTriggersSchema.optional(),
7121
+ preBufferSec: number().min(0).optional(),
7122
+ postBufferSec: number().min(0).optional()
7123
+ });
7124
+ var RecordingRuleSchema = object({
7125
+ schedule: RecordingScheduleSchema,
7126
+ mode: RecordingModeSchema,
7127
+ /** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
7128
+ preBufferSec: number().min(0).default(0),
7129
+ /** Keep recording until this many seconds after the last trigger. */
7130
+ postBufferSec: number().min(0).default(0),
7131
+ /** Each new trigger restarts the post-buffer window. */
7132
+ resetTimeoutOnNewEvent: boolean().default(true),
7133
+ /** onAudioThreshold only — dBFS level that counts as a trigger. */
7134
+ thresholdDbfs: number().optional()
7135
+ });
7136
+ /**
7137
+ * Per-device retention overrides. Every field is optional; an unset or `0`
7138
+ * value inherits the node-wide recorder default. Only footage-lifetime limits
7139
+ * live per-camera: `maxAgeDays` and `maxSizeGb`. The disk-occupancy threshold
7140
+ * (when the volume is too full to keep recording) is NOT a per-camera concern —
7141
+ * it belongs to the StorageLocation (`StorageLocation.config.minFreePercent`),
7142
+ * shared by every camera writing to that volume.
7143
+ */
7144
+ var RecordingRetentionSchema = object({
7145
+ maxAgeDays: number().min(0).optional(),
7146
+ maxSizeGb: number().min(0).optional()
7147
+ });
7148
+ /**
7149
+ * The full per-camera recording intent — the wire shape of a RecordingTarget.
7150
+ *
7151
+ * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
7152
+ * are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
7153
+ * only for transition + migration (`migrateRulesToMode`); the policy engine
7154
+ * consumes the compiled output of `compileRules(config)`, never `rules` directly.
7155
+ */
7156
+ var RecordingConfigSchema = object({
7157
+ enabled: boolean(),
7158
+ /** Authoritative storage mode. Absent on legacy targets → derived once via
7159
+ * `migrateRulesToMode`, then persisted. */
7160
+ mode: RecordingStorageModeSchema.optional(),
7161
+ profiles: array(CamProfileSchema).optional(),
7162
+ segmentSeconds: number().int().positive().optional(),
7163
+ /** Shared recording time-bands for `events` & `continuous` record only when
7164
+ * the wall-clock falls inside one of these windows. Omit or empty = always.
7165
+ * `continuous` compiles to one rule per band; `events` to band × trigger. */
7166
+ schedules: array(RecordingScheduleSchema).optional(),
7167
+ /** Legacy single-band predecessor of `schedules`. Read-compat only — it is
7168
+ * normalized into `schedules` on read and never written going forward. (Not
7169
+ * tagged `@deprecated`: the normalization paths must read it cast-free.) */
7170
+ schedule: RecordingScheduleSchema.optional(),
7171
+ /** `events`-mode only — which detectors trigger a recording. */
7172
+ triggers: RecordingTriggersSchema.optional(),
7173
+ /** `events`-mode only seconds retained before / after a trigger. */
7174
+ preBufferSec: number().min(0).optional(),
7175
+ postBufferSec: number().min(0).optional(),
7176
+ /** DEPRECATED authoring input; retained for migration/transition. */
7177
+ rules: array(RecordingRuleSchema).optional(),
7178
+ /**
7179
+ * AUTHORITATIVE mode-per-band recording model (recorder). When present it
7180
+ * is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
7181
+ * `triggers`/`rules` fields above are kept for READ-COMPAT only and are
7182
+ * derived into bands once via `migrateConfigToBands`.
7183
+ */
7184
+ bands: array(RecordingBandSchema).optional(),
7185
+ retention: RecordingRetentionSchema.optional()
7186
+ });
7187
+ /**
7188
+ * `StorageLocationType` — an addon-declared id that identifies the *kind* of
7189
+ * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
7190
+ * so the persisted record schema and the consumer-facing cap can both consume it
7191
+ * without forming a circular import. The `storage` cap re-exports it
7192
+ * verbatim for back-compat.
7193
+ *
7194
+ * This Zod schema is the **authoritative source** for `StorageLocationType`.
7195
+ * The TS alias in `./storage.ts` re-exports `z.infer<typeof
7196
+ * StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
7197
+ * `IStorageProvider` interface stay in lockstep.
7198
+ *
7199
+ * The type is now an **open string** (not a closed enum) — addons declare
7200
+ * their own location kinds via `StorageLocationDeclaration.id`. The regex
7201
+ * enforces a safe id format: lowercase-start, alphanumeric + hyphens.
7202
+ */
7203
+ var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
7204
+ /**
7205
+ * Persisted record for a storage location instance. Operators can register
7206
+ * multiple instances for multi-cardinality types (e.g. two `backups`
7207
+ * locations with different `providerId`s). Cardinality is now declared per
7208
+ * location via `StorageLocationDeclaration.cardinality` — the static
7209
+ * `STORAGE_LOCATION_CARDINALITY` map has been removed.
7210
+ *
7211
+ * `id` is a stable namespaced string of the form `<type>:<slug>`.
7212
+ * The default location for a type uses `id === <type>:default` by
7213
+ * convention (the bare type ref like `'backups'` resolves to it).
7214
+ *
7215
+ * `isSystem: true` marks a location as orchestrator-seeded and
7216
+ * undeletable. The bootstrap-installed defaults (one per type) carry
7217
+ * this flag; operator-added locations don't. Editing the config of
7218
+ * a system location is allowed (path migration, provider swap) but
7219
+ * deleting it is rejected at the cap level.
7220
+ */
7221
+ var StorageLocationSchema = object({
7222
+ id: string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
7223
+ type: string(),
7224
+ displayName: string().min(1),
7225
+ providerId: string().min(1),
7226
+ config: record(string(), unknown()),
7227
+ /**
7228
+ * Cluster node this location physically lives on. REQUIRED for node-local
7229
+ * providers (filesystem — the path exists on one node's disk), null/absent
7230
+ * for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
7231
+ * `'hub'` is the hub node. Validated against the provider's `nodeLocal`
7232
+ * flag at upsert time, not here (the schema is provider-agnostic).
7233
+ */
7234
+ nodeId: string().optional(),
7235
+ isDefault: boolean().default(false),
7236
+ isSystem: boolean().default(false),
7237
+ createdAt: number(),
7238
+ updatedAt: number()
7239
+ });
7240
+ /**
7241
+ * Reference accepted by consumer-facing `api.storage.*` calls.
7242
+ * Either:
7243
+ * - a `StorageLocationType` (e.g. `'backups'`) → orchestrator resolves to the default of that type
7244
+ * - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
7245
+ *
7246
+ * The orchestrator's `resolveRef(ref)` handles both cases.
7247
+ */
7248
+ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
7249
+ /**
7250
+ * `StorageLocationDeclaration` — a single storage-location entry declared by
7251
+ * an addon in its `package.json` under `camstack.storageLocations`.
7252
+ *
7253
+ * Design intent:
7254
+ * - **Addon declares its needs** — each addon describes the logical storage
7255
+ * slots it requires (e.g. `recordings`, `recordingsLow`) without caring
7256
+ * about the physical path.
7257
+ * - **Kernel aggregates** — at boot the kernel collects declarations from all
7258
+ * installed addons, deduplicates by `id`, and exposes the union via the
7259
+ * storage-locations settings surface.
7260
+ * - **Orchestrator seeds** — for every declared `id` the orchestrator ensures
7261
+ * at least one instance named `<id>:default` is present, using
7262
+ * `defaultsTo` to inherit the resolved root from another location when the
7263
+ * declaration is a derivative slot (e.g. `recordingsLow` defaults to
7264
+ * `recordings`).
7265
+ * - **ids are global** — `id` values are shared across the entire deployment;
7266
+ * two addons declaring the same `id` must agree on `cardinality` (validated
7267
+ * at kernel aggregation time, not here).
7268
+ */
7269
+ var StorageLocationDeclarationSchema = object({
7316
7270
  /**
7317
- * Device supports an on-demand re-sync of its derived spec with its
7318
- * upstream source drives the generic Re-sync button. The owning
7319
- * provider implements the action via the `device-adoption.resync` cap.
7271
+ * Global location identifier, e.g. `recordings` or `recordingsLow`.
7272
+ * Must start with a lowercase letter and may contain letters, digits, and
7273
+ * hyphens.
7320
7274
  */
7321
- DeviceFeature["Resyncable"] = "resyncable";
7322
- DeviceFeature["NativeSnapshot"] = "native-snapshot";
7323
- DeviceFeature["DoorbellButton"] = "doorbell-button";
7324
- DeviceFeature["TwoWayAudio"] = "two-way-audio";
7325
- DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
7275
+ id: string().regex(/^[a-z][a-zA-Z0-9-]*$/, { message: "id must start with a lowercase letter and contain only letters, digits, or hyphens" }),
7276
+ /** Human-readable name shown in the admin UI. */
7277
+ displayName: string().min(1, { message: "displayName must not be empty" }),
7278
+ /** Optional longer explanation of what data this location stores. */
7279
+ description: string().optional(),
7326
7280
  /**
7327
- * Camera supports the on-firmware autotrack subsystem (subject-
7328
- * following). Distinct from `PanTiltZoom` because not every PTZ
7329
- * camera ships autotrack — the admin UI uses this flag to gate
7330
- * the autotrack toggle / settings card without re-deriving from
7331
- * the cap registry. Mirrors `ptz-autotrack` cap registration:
7332
- * driver sets this feature when probe confirms the firmware
7333
- * surface, and registers the cap in the same code path.
7281
+ * `single` exactly one instance of this location is allowed system-wide
7282
+ * (e.g. `logs`, `models`). The operator can edit it but not add more.
7283
+ * `multi` — the operator may register several instances (e.g. a second
7284
+ * `recordings` on a NAS for disk tiering); one is the default at any time.
7334
7285
  */
7335
- DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
7286
+ cardinality: _enum(["single", "multi"]),
7336
7287
  /**
7337
- * Accessory exposes a "trigger on motion" toggle the parent camera's
7338
- * motion detection automatically activates this device. Mirrors
7339
- * `motion-trigger` cap registration: drivers set this feature in the
7340
- * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
7341
- *
7342
- * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
7343
- * fast scalar without binding fetch), notifier rules, and `listAll`
7344
- * filters that want "all devices with on-motion behaviour".
7288
+ * When set, the default instance for this location inherits its resolved
7289
+ * root from the named location's default instance. Useful for derivative
7290
+ * slots (e.g. `recordingsLow` `recordings`) so operators only need to
7291
+ * configure the primary location.
7345
7292
  */
7346
- DeviceFeature["MotionTrigger"] = "motion-trigger";
7347
- /** Light supports rgb-triplet color via `color` cap. */
7348
- DeviceFeature["LightColorRgb"] = "light-color-rgb";
7349
- /** Light supports HSV color via `color` cap. */
7350
- DeviceFeature["LightColorHsv"] = "light-color-hsv";
7351
- /** Light supports color-temperature (mired) via `color` cap. */
7352
- DeviceFeature["LightColorMired"] = "light-color-mired";
7353
- /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
7354
- * targetHigh). Gates the range slider UI. */
7355
- DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
7356
- /** Thermostat exposes target humidity and/or current humidity
7357
- * readings. Gates the humidity controls. */
7358
- DeviceFeature["ClimateHumidity"] = "climate-humidity";
7359
- /** Thermostat exposes a fan-mode selector. */
7360
- DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
7361
- /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
7362
- DeviceFeature["ClimatePreset"] = "climate-preset";
7363
- /** Cover exposes intermediate position control (0..100). Gates the
7364
- * position slider UI. */
7365
- DeviceFeature["CoverPositionable"] = "cover-positionable";
7366
- /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
7367
- DeviceFeature["CoverTilt"] = "cover-tilt";
7368
- /** Valve exposes intermediate position control (0..100). Gates the
7369
- * position slider / drag surface UI. */
7370
- DeviceFeature["ValvePositionable"] = "valve-positionable";
7371
- /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
7372
- DeviceFeature["FanSpeed"] = "fan-speed";
7373
- /** Fan exposes a preset mode selector. */
7374
- DeviceFeature["FanPreset"] = "fan-preset";
7375
- /** Fan exposes blade direction (forward/reverse) — typical of
7376
- * ceiling fans. */
7377
- DeviceFeature["FanDirection"] = "fan-direction";
7378
- /** Fan exposes an oscillation toggle. */
7379
- DeviceFeature["FanOscillating"] = "fan-oscillating";
7380
- /** Lock requires a PIN code on lock/unlock. Gates the code-entry
7381
- * field on the UI lock-controls panel. */
7382
- DeviceFeature["LockPinRequired"] = "lock-pin-required";
7383
- /** Lock supports a latch-release ("open door") action distinct from
7384
- * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
7385
- * `supported_features`. Gates the Open Door button in the UI. */
7386
- DeviceFeature["LockOpen"] = "lock-open";
7387
- /** Media player exposes a seek-to-position surface. */
7388
- DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
7389
- /** Media player exposes a volume-level setter. */
7390
- DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
7391
- /** Media player exposes a mute toggle distinct from volume=0. */
7392
- DeviceFeature["MediaPlayerMute"] = "media-player-mute";
7393
- /** Media player exposes a shuffle toggle. */
7394
- DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
7395
- /** Media player exposes a repeat mode (off / all / one). */
7396
- DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
7397
- /** Media player exposes a source / input selector. */
7398
- DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
7399
- /** Media player exposes a play-arbitrary-media surface (URL / id). */
7400
- DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
7401
- /** Media player exposes next-track. */
7402
- DeviceFeature["MediaPlayerNext"] = "media-player-next";
7403
- /** Media player exposes previous-track. */
7404
- DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
7405
- /** Media player exposes stop distinct from pause. */
7406
- DeviceFeature["MediaPlayerStop"] = "media-player-stop";
7407
- /** Alarm panel requires a PIN code on arm/disarm. */
7408
- DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
7409
- /** Presence device carries GPS coordinates (lat/lng/accuracy) in
7410
- * addition to a textual location. */
7411
- DeviceFeature["PresenceGps"] = "presence-gps";
7412
- /** Notifier accepts an inline / URL image attachment. */
7413
- DeviceFeature["NotifierImage"] = "notifier-image";
7414
- /** Notifier accepts a priority hint (high/normal/low). */
7415
- DeviceFeature["NotifierPriority"] = "notifier-priority";
7416
- /** Notifier accepts a free-form `data` payload for platform-specific
7417
- * fields. */
7418
- DeviceFeature["NotifierData"] = "notifier-data";
7419
- /** Notifier supports interactive action buttons / callbacks. */
7420
- DeviceFeature["NotifierActions"] = "notifier-actions";
7421
- /** Notifier supports per-call recipient targeting (multi-user). */
7422
- DeviceFeature["NotifierRecipients"] = "notifier-recipients";
7423
- /** Script runner accepts a variables map on each run invocation. */
7424
- DeviceFeature["ScriptVariables"] = "script-variables";
7425
- /** Automation `trigger` accepts a skipCondition flag — fires the
7426
- * automation's actions while bypassing its condition block. */
7427
- DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
7428
- return DeviceFeature;
7429
- }({});
7430
- /**
7431
- * Semantic role a device plays within its parent. Populated by driver
7432
- * addons when creating accessory devices (Reolink siren/floodlight/
7433
- * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
7434
- * admin UI to pick icons, labels, and widgets — a `Switch` with
7435
- * `role: Floodlight` renders as a bulb with a brightness slider,
7436
- * whereas a `Switch` with `role: Siren` renders as a klaxon.
7437
- *
7438
- * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
7439
- * sqlite as a nullable TEXT column — old rows keep working unchanged.
7440
- */
7441
- var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7442
- DeviceRole["Siren"] = "siren";
7443
- DeviceRole["Floodlight"] = "floodlight";
7444
- DeviceRole["Spotlight"] = "spotlight";
7445
- DeviceRole["PirSensor"] = "pir-sensor";
7446
- DeviceRole["Chime"] = "chime";
7447
- DeviceRole["Autotrack"] = "autotrack";
7448
- DeviceRole["Nightvision"] = "nightvision";
7449
- DeviceRole["PrivacyMask"] = "privacy-mask";
7450
- DeviceRole["Doorbell"] = "doorbell";
7451
- /** Virtual HA toggle (input_boolean.*) — distinguishable from a
7452
- * real Switch device for UI rendering / export adapters. */
7453
- DeviceRole["BinaryHelper"] = "binary-helper";
7454
- /** Generic motion / occupancy / moving event source. Distinct from
7455
- * the camera accessory PirSensor role: that one is a camera child;
7456
- * this is a standalone HA / 3rd-party motion sensor. */
7457
- DeviceRole["MotionSensor"] = "motion-sensor";
7458
- DeviceRole["ContactSensor"] = "contact-sensor";
7459
- DeviceRole["LeakSensor"] = "leak-sensor";
7460
- DeviceRole["SmokeSensor"] = "smoke-sensor";
7461
- DeviceRole["COSensor"] = "co-sensor";
7462
- DeviceRole["GasSensor"] = "gas-sensor";
7463
- DeviceRole["TamperSensor"] = "tamper-sensor";
7464
- DeviceRole["VibrationSensor"] = "vibration-sensor";
7465
- DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
7466
- DeviceRole["SoundSensor"] = "sound-sensor";
7467
- /** Fallback for `binary_sensor` without a known `device_class`. */
7468
- DeviceRole["BinarySensor"] = "binary-sensor";
7469
- DeviceRole["TemperatureSensor"] = "temperature-sensor";
7470
- DeviceRole["HumiditySensor"] = "humidity-sensor";
7471
- DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
7472
- DeviceRole["PressureSensor"] = "pressure-sensor";
7473
- DeviceRole["PowerSensor"] = "power-sensor";
7474
- DeviceRole["EnergySensor"] = "energy-sensor";
7475
- DeviceRole["VoltageSensor"] = "voltage-sensor";
7476
- DeviceRole["CurrentSensor"] = "current-sensor";
7477
- DeviceRole["AirQualitySensor"] = "air-quality-sensor";
7478
- /** Battery level (numeric % via `sensor` OR low-bool via
7479
- * `binary_sensor` the cap distinguishes via the value type). */
7480
- DeviceRole["BatterySensor"] = "battery-sensor";
7481
- /** Fallback for `sensor` numeric without a known `device_class`. */
7482
- DeviceRole["NumericSensor"] = "numeric-sensor";
7483
- /** String / enum state (HA `sensor` with `state_class: enum` or
7484
- * `attributes.options`). */
7485
- DeviceRole["EnumSensor"] = "enum-sensor";
7486
- /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
7487
- * or `date`). The slice carries the raw ISO string verbatim (hosted on
7488
- * the `enum-sensor` cap); the UI renders it locale-formatted. */
7489
- DeviceRole["DateTimeSensor"] = "datetime-sensor";
7490
- /** Last-resort fallback when nothing else matches. */
7491
- DeviceRole["GenericSensor"] = "generic-sensor";
7492
- DeviceRole["NumericControl"] = "numeric-control";
7493
- DeviceRole["SelectControl"] = "select-control";
7494
- DeviceRole["TextControl"] = "text-control";
7495
- DeviceRole["DateTimeControl"] = "datetime-control";
7496
- /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
7497
- * rich features (image, priority, channel routing). */
7498
- DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
7499
- /** Chat / messaging service (HA `notify.telegram_*`,
7500
- * `notify.discord_*`, etc.). */
7501
- DeviceRole["MessagingNotifier"] = "messaging-notifier";
7502
- /** Email-based delivery (HA `notify.smtp`, etc.). */
7503
- DeviceRole["EmailNotifier"] = "email-notifier";
7504
- /** Fallback when the notifier service name doesn't match a known
7505
- * pattern. */
7506
- DeviceRole["GenericNotifier"] = "generic-notifier";
7507
- return DeviceRole;
7508
- }({});
7293
+ defaultsTo: string().optional()
7294
+ });
7295
+ var DecoderStatsSchema = object({
7296
+ inputFps: number(),
7297
+ outputFps: number(),
7298
+ avgDecodeTimeMs: number(),
7299
+ droppedFrames: number()
7300
+ });
7301
+ var DecoderSessionConfigSchema = object({
7302
+ codec: string(),
7303
+ maxFps: number().default(0),
7304
+ outputFormat: _enum([
7305
+ "jpeg",
7306
+ "rgb",
7307
+ "bgr",
7308
+ "yuv420",
7309
+ "gray"
7310
+ ]).default("jpeg"),
7311
+ scale: number().default(1),
7312
+ width: number().optional(),
7313
+ height: number().optional(),
7314
+ /**
7315
+ * Identifier of the camera this decoder session serves. Optional
7316
+ * because the cap is generic (any caller could request decode), but
7317
+ * stream-broker passes it so decoder logs include `deviceId` for
7318
+ * per-camera filtering when diagnosing failures (e.g. node-av
7319
+ * sendPacket errors on a single hung camera).
7320
+ */
7321
+ deviceId: number().int().nonnegative().optional(),
7322
+ /**
7323
+ * Free-form tag for log scoping. Stream-broker uses
7324
+ * `broker:<deviceId>/<profile>`. Decoder session logger surfaces it
7325
+ * on every line so `grep tag=broker:5/high` filters one camera
7326
+ * profile cleanly.
7327
+ */
7328
+ tag: string().optional(),
7329
+ /**
7330
+ * Where the session delivers decoded frames (Phase 5 / D9):
7331
+ *
7332
+ * - `'callback'` (default) the legacy pixel path: decoded frames are
7333
+ * buffered as `DecodedFrame`s and drained via `pullFrames`.
7334
+ * - `'shm'` the shared-memory frame plane: decoded frames are written
7335
+ * into an OS shared-memory ring and drained as zero-pixel
7336
+ * `FrameHandle`s via `pullHandles`. A session is one mode or the
7337
+ * other `pullFrames` returns nothing for an `'shm'` session and
7338
+ * `pullHandles` returns nothing for a `'callback'` session.
7339
+ */
7340
+ frameSink: _enum(["callback", "shm"]).default("callback")
7341
+ });
7342
+ var EncodeProfileSchema = object({
7343
+ video: object({
7344
+ codec: _enum([
7345
+ "h264",
7346
+ "h265",
7347
+ "copy"
7348
+ ]),
7349
+ profile: _enum([
7350
+ "baseline",
7351
+ "main",
7352
+ "high"
7353
+ ]).optional(),
7354
+ width: number().int().positive().optional(),
7355
+ height: number().int().positive().optional(),
7356
+ fps: number().positive().optional(),
7357
+ bitrateKbps: number().int().positive().optional(),
7358
+ gopFrames: number().int().positive().optional(),
7359
+ bf: number().int().min(0).optional(),
7360
+ preset: _enum([
7361
+ "ultrafast",
7362
+ "superfast",
7363
+ "veryfast",
7364
+ "faster",
7365
+ "fast",
7366
+ "medium"
7367
+ ]).optional(),
7368
+ tune: _enum([
7369
+ "zerolatency",
7370
+ "film",
7371
+ "animation"
7372
+ ]).optional()
7373
+ }),
7374
+ audio: union([literal("passthrough"), object({
7375
+ codec: _enum([
7376
+ "opus",
7377
+ "aac",
7378
+ "pcmu",
7379
+ "pcma",
7380
+ "copy"
7381
+ ]),
7382
+ bitrateKbps: number().int().positive().optional(),
7383
+ sampleRateHz: number().int().positive().optional(),
7384
+ channels: union([literal(1), literal(2)]).optional()
7385
+ })]),
7386
+ /**
7387
+ * ffmpeg input-side args, inserted between the fixed global flags
7388
+ * (`-hide_banner -loglevel error`) and `-i pipe:0`. Free-text array
7389
+ * the widget surfaces a textarea + suggestion chips for the most-
7390
+ * used demuxer/format options.
7391
+ */
7392
+ inputArgs: array(string()).optional(),
7393
+ /**
7394
+ * ffmpeg output-side args, inserted between the encode block and
7395
+ * the final `-f <muxer> pipe:1`. Use for muxer options, bitstream
7396
+ * filters, codec-specific overrides. Free-text array.
7397
+ */
7398
+ outputArgs: array(string()).optional()
7399
+ });
7400
+ var YAMNET_TO_MACRO = {
7401
+ mapping: {
7402
+ Speech: "speech",
7403
+ "Child speech, kid speaking": "speech",
7404
+ Conversation: "speech",
7405
+ "Narration, monologue": "speech",
7406
+ Babbling: "speech",
7407
+ Whispering: "speech",
7408
+ "Speech synthesizer": "speech",
7409
+ Humming: "speech",
7410
+ Rapping: "speech",
7411
+ Singing: "speech",
7412
+ Choir: "speech",
7413
+ "Child singing": "speech",
7414
+ Shout: "scream",
7415
+ Bellow: "scream",
7416
+ Yell: "scream",
7417
+ Screaming: "scream",
7418
+ "Children shouting": "scream",
7419
+ Whoop: "scream",
7420
+ "Crying, sobbing": "crying",
7421
+ "Baby cry, infant cry": "crying",
7422
+ Whimper: "crying",
7423
+ "Wail, moan": "crying",
7424
+ Groan: "crying",
7425
+ Laughter: "laughter",
7426
+ "Baby laughter": "laughter",
7427
+ Giggle: "laughter",
7428
+ Snicker: "laughter",
7429
+ "Belly laugh": "laughter",
7430
+ "Chuckle, chortle": "laughter",
7431
+ Music: "music",
7432
+ "Musical instrument": "music",
7433
+ Guitar: "music",
7434
+ Piano: "music",
7435
+ Drum: "music",
7436
+ "Drum kit": "music",
7437
+ "Violin, fiddle": "music",
7438
+ Flute: "music",
7439
+ Saxophone: "music",
7440
+ Trumpet: "music",
7441
+ Synthesizer: "music",
7442
+ "Pop music": "music",
7443
+ "Rock music": "music",
7444
+ "Hip hop music": "music",
7445
+ "Classical music": "music",
7446
+ Jazz: "music",
7447
+ "Electronic music": "music",
7448
+ "Background music": "music",
7449
+ Dog: "dog",
7450
+ Bark: "dog",
7451
+ Yip: "dog",
7452
+ Howl: "dog",
7453
+ "Bow-wow": "dog",
7454
+ Growling: "dog",
7455
+ "Whimper (dog)": "dog",
7456
+ Cat: "cat",
7457
+ Purr: "cat",
7458
+ Meow: "cat",
7459
+ Hiss: "cat",
7460
+ Caterwaul: "cat",
7461
+ Bird: "bird",
7462
+ "Bird vocalization, bird call, bird song": "bird",
7463
+ "Chirp, tweet": "bird",
7464
+ Squawk: "bird",
7465
+ Crow: "bird",
7466
+ Owl: "bird",
7467
+ "Pigeon, dove": "bird",
7468
+ Animal: "animal",
7469
+ "Domestic animals, pets": "animal",
7470
+ "Livestock, farm animals, working animals": "animal",
7471
+ Horse: "animal",
7472
+ "Cattle, bovinae": "animal",
7473
+ Pig: "animal",
7474
+ Sheep: "animal",
7475
+ Goat: "animal",
7476
+ Frog: "animal",
7477
+ Insect: "animal",
7478
+ Cricket: "animal",
7479
+ Alarm: "alarm",
7480
+ "Alarm clock": "alarm",
7481
+ "Smoke detector, smoke alarm": "alarm",
7482
+ "Fire alarm": "alarm",
7483
+ Buzzer: "alarm",
7484
+ "Civil defense siren": "alarm",
7485
+ "Car alarm": "alarm",
7486
+ Siren: "siren",
7487
+ "Police car (siren)": "siren",
7488
+ "Ambulance (siren)": "siren",
7489
+ "Fire engine, fire truck (siren)": "siren",
7490
+ "Emergency vehicle": "siren",
7491
+ Foghorn: "siren",
7492
+ Doorbell: "doorbell",
7493
+ "Ding-dong": "doorbell",
7494
+ Knock: "doorbell",
7495
+ Tap: "doorbell",
7496
+ Glass: "glass_breaking",
7497
+ Shatter: "glass_breaking",
7498
+ "Chink, clink": "glass_breaking",
7499
+ "Gunshot, gunfire": "gunshot",
7500
+ "Machine gun": "gunshot",
7501
+ Explosion: "gunshot",
7502
+ Fireworks: "gunshot",
7503
+ Firecracker: "gunshot",
7504
+ "Artillery fire": "gunshot",
7505
+ "Cap gun": "gunshot",
7506
+ Boom: "gunshot",
7507
+ Vehicle: "vehicle",
7508
+ Car: "vehicle",
7509
+ Truck: "vehicle",
7510
+ Bus: "vehicle",
7511
+ Motorcycle: "vehicle",
7512
+ "Car passing by": "vehicle",
7513
+ "Vehicle horn, car horn, honking": "vehicle",
7514
+ "Traffic noise, roadway noise": "vehicle",
7515
+ Train: "vehicle",
7516
+ Aircraft: "vehicle",
7517
+ Helicopter: "vehicle",
7518
+ Bicycle: "vehicle",
7519
+ Skateboard: "vehicle",
7520
+ Fire: "fire",
7521
+ Crackle: "fire",
7522
+ Water: "water",
7523
+ Rain: "water",
7524
+ Raindrop: "water",
7525
+ "Rain on surface": "water",
7526
+ Stream: "water",
7527
+ Waterfall: "water",
7528
+ Ocean: "water",
7529
+ "Waves, surf": "water",
7530
+ "Splash, splatter": "water",
7531
+ Wind: "wind",
7532
+ Thunderstorm: "wind",
7533
+ Thunder: "wind",
7534
+ "Wind noise (microphone)": "wind",
7535
+ "Rustling leaves": "wind",
7536
+ Door: "door",
7537
+ "Sliding door": "door",
7538
+ Slam: "door",
7539
+ "Cupboard open or close": "door",
7540
+ "Walk, footsteps": "footsteps",
7541
+ Run: "footsteps",
7542
+ Shuffle: "footsteps",
7543
+ Crowd: "crowd",
7544
+ Chatter: "crowd",
7545
+ Cheering: "crowd",
7546
+ Applause: "crowd",
7547
+ "Children playing": "crowd",
7548
+ "Hubbub, speech noise, speech babble": "crowd",
7549
+ Telephone: "telephone",
7550
+ "Telephone bell ringing": "telephone",
7551
+ Ringtone: "telephone",
7552
+ "Telephone dialing, DTMF": "telephone",
7553
+ "Busy signal": "telephone",
7554
+ Engine: "engine",
7555
+ "Engine starting": "engine",
7556
+ Idling: "engine",
7557
+ "Accelerating, revving, vroom": "engine",
7558
+ "Light engine (high frequency)": "engine",
7559
+ "Medium engine (mid frequency)": "engine",
7560
+ "Heavy engine (low frequency)": "engine",
7561
+ "Lawn mower": "engine",
7562
+ Chainsaw: "engine",
7563
+ Hammer: "tools",
7564
+ Jackhammer: "tools",
7565
+ Sawing: "tools",
7566
+ "Power tool": "tools",
7567
+ Drill: "tools",
7568
+ Sanding: "tools",
7569
+ Silence: "silence"
7570
+ },
7571
+ preserveOriginal: false
7572
+ };
7573
+ var APPLE_SA_TO_MACRO = {
7574
+ mapping: {
7575
+ speech: "speech",
7576
+ child_speech: "speech",
7577
+ conversation: "speech",
7578
+ whispering: "speech",
7579
+ singing: "speech",
7580
+ humming: "speech",
7581
+ shout: "scream",
7582
+ yell: "scream",
7583
+ screaming: "scream",
7584
+ crying: "crying",
7585
+ baby_crying: "crying",
7586
+ sobbing: "crying",
7587
+ laughter: "laughter",
7588
+ baby_laughter: "laughter",
7589
+ giggling: "laughter",
7590
+ music: "music",
7591
+ guitar: "music",
7592
+ piano: "music",
7593
+ drums: "music",
7594
+ dog_bark: "dog",
7595
+ dog_bow_wow: "dog",
7596
+ dog_growling: "dog",
7597
+ dog_howl: "dog",
7598
+ cat_meow: "cat",
7599
+ cat_purr: "cat",
7600
+ cat_hiss: "cat",
7601
+ bird: "bird",
7602
+ bird_chirp: "bird",
7603
+ bird_squawk: "bird",
7604
+ animal: "animal",
7605
+ horse: "animal",
7606
+ cow_moo: "animal",
7607
+ insect: "animal",
7608
+ alarm: "alarm",
7609
+ smoke_alarm: "alarm",
7610
+ fire_alarm: "alarm",
7611
+ car_alarm: "alarm",
7612
+ siren: "siren",
7613
+ police_siren: "siren",
7614
+ ambulance_siren: "siren",
7615
+ doorbell: "doorbell",
7616
+ door_knock: "doorbell",
7617
+ knocking: "doorbell",
7618
+ glass_breaking: "glass_breaking",
7619
+ glass_shatter: "glass_breaking",
7620
+ gunshot: "gunshot",
7621
+ explosion: "gunshot",
7622
+ fireworks: "gunshot",
7623
+ car: "vehicle",
7624
+ truck: "vehicle",
7625
+ motorcycle: "vehicle",
7626
+ car_horn: "vehicle",
7627
+ vehicle_horn: "vehicle",
7628
+ traffic: "vehicle",
7629
+ fire: "fire",
7630
+ fire_crackle: "fire",
7631
+ water: "water",
7632
+ rain: "water",
7633
+ ocean: "water",
7634
+ splash: "water",
7635
+ wind: "wind",
7636
+ thunder: "wind",
7637
+ thunderstorm: "wind",
7638
+ door: "door",
7639
+ door_slam: "door",
7640
+ sliding_door: "door",
7641
+ footsteps: "footsteps",
7642
+ walking: "footsteps",
7643
+ running: "footsteps",
7644
+ crowd: "crowd",
7645
+ chatter: "crowd",
7646
+ cheering: "crowd",
7647
+ applause: "crowd",
7648
+ telephone_ring: "telephone",
7649
+ ringtone: "telephone",
7650
+ engine: "engine",
7651
+ engine_starting: "engine",
7652
+ lawn_mower: "engine",
7653
+ chainsaw: "engine",
7654
+ hammer: "tools",
7655
+ jackhammer: "tools",
7656
+ drill: "tools",
7657
+ power_tool: "tools",
7658
+ silence: "silence"
7659
+ },
7660
+ preserveOriginal: false
7661
+ };
7662
+ var _macroLookup = /* @__PURE__ */ new Map();
7663
+ for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7664
+ for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7509
7665
  /**
7510
7666
  * Accessory device helpers — shared across drivers.
7511
7667
  *
@@ -7696,74 +7852,6 @@ object({
7696
7852
  });
7697
7853
  DeviceType.Sensor;
7698
7854
  /**
7699
- * Generic types for capability definitions.
7700
- *
7701
- * A capability is defined with Zod schemas for methods, events, and settings.
7702
- * TypeScript types are inferred via z.infer<> — zero duplication.
7703
- *
7704
- * Pattern:
7705
- * 1. Define Zod schemas for data, methods, settings
7706
- * 2. Export const capabilityDef = { ... } satisfies CapabilityDefinition
7707
- * 3. Export type IProvider = InferProvider<typeof capabilityDef>
7708
- * 4. Addon implements IProvider
7709
- * 5. Registry auto-mounts tRPC router from definition.methods
7710
- */
7711
- /**
7712
- * Output schema shared by the contribution + live methods.
7713
- *
7714
- * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
7715
- * tabs[]) without importing from `../interfaces/config-ui.js` — a
7716
- * concrete-but-lenient Zod object keeps tRPC output inference happy
7717
- * (using `z.unknown()` here collapses unrelated router branches to
7718
- * `unknown` when the generator re-inlines the huge AppRouter type).
7719
- *
7720
- * `.passthrough()` on sections/fields accepts whatever FormBuilder
7721
- * extensions the caller adds (showWhen, displayScale, …) without
7722
- * rebuilding every time a new field kind is introduced.
7723
- */
7724
- var ContributionSectionSchema = object({
7725
- id: string(),
7726
- title: string(),
7727
- description: string().optional(),
7728
- style: _enum(["card", "accordion"]).optional(),
7729
- defaultCollapsed: boolean().optional(),
7730
- columns: union([
7731
- literal(1),
7732
- literal(2),
7733
- literal(3),
7734
- literal(4)
7735
- ]).optional(),
7736
- tab: string().optional(),
7737
- location: _enum(["settings", "top-tab"]).optional(),
7738
- order: number().optional(),
7739
- fields: array(any())
7740
- });
7741
- object({
7742
- tabs: array(object({
7743
- id: string(),
7744
- label: string(),
7745
- icon: string(),
7746
- order: number().optional()
7747
- })).optional(),
7748
- sections: array(ContributionSectionSchema)
7749
- }).nullable();
7750
- object({ deviceId: number() }), object({ deviceId: number() }), object({
7751
- deviceId: number(),
7752
- patch: record(string(), unknown())
7753
- }), object({ success: literal(true) });
7754
- object({ deviceId: number() }), unknown().nullable();
7755
- /** Shorthand to define a method schema */
7756
- function method(input, output, options) {
7757
- return {
7758
- input,
7759
- output,
7760
- kind: options?.kind ?? "query",
7761
- auth: options?.auth ?? "protected",
7762
- ...options?.access !== void 0 ? { access: options.access } : {},
7763
- timeoutMs: options?.timeoutMs
7764
- };
7765
- }
7766
- /**
7767
7855
  * Alarm-panel cap. Models HA `alarm_control_panel.*` on
7768
7856
  * `DeviceType.AlarmPanel`. State follows HA's canonical lifecycle
7769
7857
  * across disarmed / armed_(home|away|night|vacation|custom_bypass) /
@@ -12088,9 +12176,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
12088
12176
  limit: number().optional(),
12089
12177
  tags: record(string(), string()).optional()
12090
12178
  }), array(LogEntrySchema).readonly());
12091
- var StaticDirOutputSchema = object({ staticDir: string() });
12092
- var VersionOutputSchema = object({ version: string() });
12093
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
12094
12179
  /**
12095
12180
  * Zod schemas for persisted record types.
12096
12181
  *
@@ -14566,7 +14651,7 @@ method(object({
14566
14651
  }), _void(), {
14567
14652
  kind: "mutation",
14568
14653
  auth: "admin"
14569
- }), 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({
14654
+ }), 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({
14570
14655
  deviceId: number(),
14571
14656
  values: record(string(), unknown())
14572
14657
  }), object({ success: literal(true) }), {
@@ -15286,7 +15371,20 @@ var DiskSpaceInfoSchema = object({
15286
15371
  var PidResourceStatsSchema = object({
15287
15372
  pid: number(),
15288
15373
  cpu: number(),
15289
- memory: number()
15374
+ memory: number(),
15375
+ /**
15376
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
15377
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
15378
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
15379
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
15380
+ * Undefined where /proc is unavailable (e.g. macOS).
15381
+ */
15382
+ privateBytes: number().optional(),
15383
+ /**
15384
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15385
+ * code shared copy-on-write across runners. Undefined on macOS.
15386
+ */
15387
+ sharedBytes: number().optional()
15290
15388
  });
15291
15389
  var AddonInstanceSchema = object({
15292
15390
  addonId: string(),
@@ -15335,6 +15433,17 @@ var KillProcessResultSchema = object({
15335
15433
  reason: string().optional(),
15336
15434
  signal: _enum(["SIGTERM", "SIGKILL"]).optional()
15337
15435
  });
15436
+ var DumpHeapSnapshotInputSchema = object({
15437
+ /** The addon whose runner should dump a heap snapshot. */
15438
+ addonId: string() });
15439
+ var DumpHeapSnapshotResultSchema = object({
15440
+ success: boolean(),
15441
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
15442
+ path: string().optional(),
15443
+ /** Process pid that was signalled. */
15444
+ pid: number().optional(),
15445
+ reason: string().optional()
15446
+ });
15338
15447
  var SystemMetricsSchema = object({
15339
15448
  cpuPercent: number(),
15340
15449
  memoryPercent: number(),
@@ -15348,6 +15457,9 @@ var SystemMetricsSchema = object({
15348
15457
  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, {
15349
15458
  kind: "mutation",
15350
15459
  auth: "admin"
15460
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
15461
+ kind: "mutation",
15462
+ auth: "admin"
15351
15463
  });
15352
15464
  var PtzPresetSchema = object({
15353
15465
  id: string(),
@@ -15714,63 +15826,6 @@ method(object({
15714
15826
  auth: "admin"
15715
15827
  });
15716
15828
  /**
15717
- * device-ops — device-scoped cap that unifies the per-IDevice operations
15718
- * previously routed through the `.device-ops` Moleculer bridge service.
15719
- *
15720
- * Each worker that hosts live `IDevice` instances auto-registers a native
15721
- * provider for this cap (per device) backed by its local
15722
- * `DeviceRegistry`. Hub-side callers reach it transparently through
15723
- * `ctx.fetchDevice(id).deviceOps.*` — the DeviceProxy injects
15724
- * `deviceId` + `nodeId` and dispatches through the standard cap-router,
15725
- * so there's no parallel bridge path anymore.
15726
- *
15727
- * The surface is intentionally small — every method corresponds to a
15728
- * single action on the live `IDevice` (or `ICameraDevice` for
15729
- * `getStreamSources`). Richer orchestration (enable/disable with
15730
- * integration plumbing, bulk updates) stays in the `device-manager` cap;
15731
- * `device-ops` is the per-device primitive the device-manager routes to.
15732
- */
15733
- var StreamSourceEntrySchema$1 = object({
15734
- id: string(),
15735
- label: string(),
15736
- protocol: _enum([
15737
- "rtsp",
15738
- "rtmp",
15739
- "annexb",
15740
- "http-mjpeg",
15741
- "webrtc",
15742
- "custom"
15743
- ]),
15744
- url: string().optional(),
15745
- resolution: object({
15746
- width: number(),
15747
- height: number()
15748
- }).optional(),
15749
- fps: number().optional(),
15750
- bitrate: number().optional(),
15751
- codec: string().optional(),
15752
- profileHint: CamProfileSchema.optional(),
15753
- sdp: string().optional()
15754
- });
15755
- var ConfigEntrySchema$1 = object({
15756
- key: string(),
15757
- value: unknown()
15758
- });
15759
- var RawStateResultSchema = object({
15760
- /** Originating provider id, e.g. 'homeassistant' | 'reolink' | 'hikvision'. */
15761
- source: string(),
15762
- /** Opaque, DISPLAY-SAFE upstream blob (no secrets/PII). */
15763
- data: record(string(), unknown())
15764
- });
15765
- method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
15766
- deviceId: number(),
15767
- values: record(string(), unknown())
15768
- }), _void(), { kind: "mutation" }), method(object({
15769
- deviceId: number(),
15770
- action: string().min(1),
15771
- input: unknown()
15772
- }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
15773
- /**
15774
15829
  * camera-credentials — device-scoped cap exposing the camera's network
15775
15830
  * + auth surface in a vendor-neutral shape.
15776
15831
  *
@@ -19453,6 +19508,12 @@ Object.freeze({
19453
19508
  addonId: null,
19454
19509
  access: "view"
19455
19510
  },
19511
+ "metricsProvider.dumpHeapSnapshot": {
19512
+ capName: "metrics-provider",
19513
+ capScope: "system",
19514
+ addonId: null,
19515
+ access: "create"
19516
+ },
19456
19517
  "metricsProvider.getAddonStats": {
19457
19518
  capName: "metrics-provider",
19458
19519
  capScope: "system",
@@ -21720,30 +21781,6 @@ object({
21720
21781
  bootAttempts: number(),
21721
21782
  schemaVersion: literal(1)
21722
21783
  });
21723
- /**
21724
- * Promise-based timer helpers — used everywhere the codebase needs to
21725
- * wait, back off, or schedule a retry. Before these helpers landed, each
21726
- * call site re-implemented `new Promise(r => setTimeout(r, ms))` inline,
21727
- * with subtle variations (some swallowing cancellation, some not). Two
21728
- * shapes cover every observed use case:
21729
- *
21730
- * - {@link sleep} for a plain, uncancellable wait — the default choice.
21731
- * - {@link sleepCancellable} for a wait that wakes early when an
21732
- * abort signal trips, used by long-running pollers whose teardown
21733
- * must stop a pending backoff promptly.
21734
- */
21735
- /**
21736
- * Resolve after `ms` milliseconds. Never rejects, never cancels. The
21737
- * sleep cannot be interrupted; for a wakeable variant use
21738
- * {@link sleepCancellable}.
21739
- *
21740
- * `ms <= 0` resolves on the next microtask via `setTimeout(0)`, which
21741
- * still gives the event loop a chance to drain — useful for breaking
21742
- * up tight async loops without changing call-site semantics.
21743
- */
21744
- function sleep$1(ms) {
21745
- return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
21746
- }
21747
21784
  //#endregion
21748
21785
  //#region src/pipeline-resolver.ts
21749
21786
  function applyStepPatch(base, patch) {
@@ -21994,19 +22031,19 @@ var ZonesProvider = class {
21994
22031
  }
21995
22032
  async addZone({ deviceId, zone }) {
21996
22033
  const existing = await this.loadZones(deviceId);
21997
- if (existing.some((z) => z.id === zone.id)) throw new Error(`zones.addZone: id ${zone.id} already exists`);
22034
+ if (existing.some((entry) => entry.id === zone.id)) throw new Error(`zones.addZone: id ${zone.id} already exists`);
21998
22035
  await this.persist(deviceId, [...existing, zone]);
21999
22036
  }
22000
22037
  async updateZone({ deviceId, zone }) {
22001
22038
  const existing = await this.loadZones(deviceId);
22002
- if (!existing.some((z) => z.id === zone.id)) throw new Error(`zones.updateZone: id ${zone.id} not found`);
22003
- const next = existing.map((z) => z.id === zone.id ? zone : z);
22039
+ if (!existing.some((entry) => entry.id === zone.id)) throw new Error(`zones.updateZone: id ${zone.id} not found`);
22040
+ const next = existing.map((entry) => entry.id === zone.id ? zone : entry);
22004
22041
  await this.persist(deviceId, next);
22005
22042
  }
22006
22043
  async removeZone({ deviceId, zoneId }) {
22007
22044
  const existing = await this.loadZones(deviceId);
22008
- if (!existing.some((z) => z.id === zoneId)) return;
22009
- await this.persist(deviceId, existing.filter((z) => z.id !== zoneId));
22045
+ if (!existing.some((entry) => entry.id === zoneId)) return;
22046
+ await this.persist(deviceId, existing.filter((entry) => entry.id !== zoneId));
22010
22047
  }
22011
22048
  /**
22012
22049
  * Drop a device's cache entry. Called when the device is removed so
@@ -24466,7 +24503,7 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
24466
24503
  if (t.epoch <= lastEpoch) return;
24467
24504
  this.lastSeenReadinessEpochByNode.set(nodeId, t.epoch);
24468
24505
  try {
24469
- for (const key of [...this.catalogCache.keys()]) if (key.startsWith(`${nodeId}::`)) this.catalogCache.delete(key);
24506
+ for (const key of Array.from(this.catalogCache.keys())) if (key.startsWith(`${nodeId}::`)) this.catalogCache.delete(key);
24470
24507
  await this.seedAgentSettingsFromCatalog(nodeId);
24471
24508
  const candidates = /* @__PURE__ */ new Set();
24472
24509
  for (const [deviceId, assignment] of this.assignments) if (assignment.agentNodeId === nodeId) candidates.add(deviceId);