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