@camstack/addon-pipeline 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/audio-analyzer/index.js +6 -7
  2. package/dist/audio-analyzer/index.mjs +2 -2
  3. package/dist/audio-codec-nodeav/index.js +1 -1
  4. package/dist/audio-codec-nodeav/index.mjs +1 -1
  5. package/dist/decoder-nodeav/index.js +1 -1
  6. package/dist/decoder-nodeav/index.mjs +1 -1
  7. package/dist/detection-pipeline/index.js +716 -411
  8. package/dist/detection-pipeline/index.mjs +706 -399
  9. package/dist/{dist-CP2uP-D8.mjs → dist-CjrjeaDd.mjs} +1878 -1642
  10. package/dist/{dist-v0PZCoV-.js → dist-G45MVm6i.js} +1877 -1641
  11. package/dist/model-download-service-C7AjBsX9-B0ekM6dF.mjs +301 -0
  12. package/dist/model-download-service-C7AjBsX9-rXY-VFDk.js +358 -0
  13. package/dist/motion-wasm/index.js +1 -1
  14. package/dist/motion-wasm/index.mjs +1 -1
  15. package/dist/pipeline-runner/index.js +1 -1
  16. package/dist/pipeline-runner/index.mjs +1 -1
  17. package/dist/recorder/index.js +4 -5
  18. package/dist/recorder/index.mjs +2 -2
  19. package/dist/stream-broker/_stub.js +2 -2
  20. package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-Hzarxdhd.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-Tbqpu0v3.mjs} +3 -3
  21. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-DCsgcqTa.mjs +26 -0
  22. package/dist/stream-broker/{_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-SlpG44Ip.mjs → _virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CHcXI1Wf.mjs} +1 -1
  23. package/dist/stream-broker/{hostInit-BXhCtKAA.mjs → hostInit-tIev5Gd9.mjs} +3 -3
  24. package/dist/stream-broker/index.js +9 -10
  25. package/dist/stream-broker/index.mjs +3 -3
  26. package/dist/stream-broker/remoteEntry.js +1 -1
  27. package/embed-dist/assets/{MaskShapeCanvas-DI4BY7W2-CQxn6ukH.js → MaskShapeCanvas-DI4BY7W2-C0kKwNX_.js} +1 -1
  28. package/embed-dist/assets/{MotionZonesSettings-C1EEbk2V-BziDLK12.js → MotionZonesSettings-C1EEbk2V-CYtJc892.js} +1 -1
  29. package/embed-dist/assets/{PrivacyMaskSettings-APgPLF7p-D3KDk03_.js → PrivacyMaskSettings-APgPLF7p-C2SRtNe6.js} +1 -1
  30. package/embed-dist/assets/index-B2LRyXWh.js +80 -0
  31. package/embed-dist/index.html +1 -1
  32. package/package.json +1 -1
  33. package/dist/chunk-D6vf50IK.js +0 -28
  34. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-c9YxHYlI.mjs +0 -26
  35. package/embed-dist/assets/index-CvgJINQE.js +0 -80
@@ -4627,63 +4627,7 @@ function _instanceof(cls, params = {}) {
4627
4627
  return inst;
4628
4628
  }
4629
4629
  //#endregion
4630
- //#region ../types/dist/index.mjs
4631
- /**
4632
- * Deep wiring healthcheck — snapshot of active reachability probes across
4633
- * every declared capability + widget of every installed plugin, on every
4634
- * node. Produced by the backend `WiringHealthService` and surfaced via
4635
- * `GET /health/wiring`, the tRPC `health.wiring` query, and the boot-gate.
4636
- *
4637
- * Unlike `/health` (process liveness), this reflects whether each cap/widget
4638
- * is actually *reachable* over the real cap-dispatch path. See spec
4639
- * `docs/superpowers/specs/2026-05-23-deep-healthcheck-design.md`.
4640
- */
4641
- /** What kind of target a probe addressed. */
4642
- var wiringProbeKindSchema = _enum([
4643
- "singleton",
4644
- "device",
4645
- "widget"
4646
- ]);
4647
- /** Result of probing a single (cap|widget [, device]) target. */
4648
- var wiringProbeResultSchema = object({
4649
- capName: string(),
4650
- kind: wiringProbeKindSchema,
4651
- deviceId: number().optional(),
4652
- reachable: boolean(),
4653
- latencyMs: number(),
4654
- error: string().optional()
4655
- });
4656
- /** Per-addon roll-up of cap + widget probe results. */
4657
- var wiringAddonHealthSchema = object({
4658
- addonId: string(),
4659
- caps: array(wiringProbeResultSchema).readonly(),
4660
- widgets: array(wiringProbeResultSchema).readonly()
4661
- });
4662
- /** Per-node roll-up. */
4663
- var wiringNodeHealthSchema = object({
4664
- nodeId: string(),
4665
- addons: array(wiringAddonHealthSchema).readonly()
4666
- });
4667
- object({
4668
- /** True only when every probed target is reachable. */
4669
- ok: boolean(),
4670
- /** True when at least one target is unreachable. */
4671
- degraded: boolean(),
4672
- checkedAt: string(),
4673
- nodes: array(wiringNodeHealthSchema).readonly(),
4674
- summary: object({
4675
- total: number(),
4676
- reachable: number(),
4677
- unreachable: number()
4678
- })
4679
- });
4680
- var MODEL_FORMATS = [
4681
- "onnx",
4682
- "coreml",
4683
- "openvino",
4684
- "tflite",
4685
- "pt"
4686
- ];
4630
+ //#region ../types/dist/sleep-D7JeS58T.mjs
4687
4631
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4688
4632
  EventCategory["SystemBoot"] = "system.boot";
4689
4633
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -4981,6 +4925,18 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
4981
4925
  */
4982
4926
  EventCategory["PipelineEngineMetricsSnapshot"] = "pipeline.engine-metrics-snapshot";
4983
4927
  /**
4928
+ * Per-node detection-engine runtime-provisioning transition. Emitted by
4929
+ * the detection-pipeline provider on every state change of its lazy
4930
+ * engine-provisioning machine (idle → installing → verifying → ready,
4931
+ * or → failed with a `nextRetryAt`). Payload is the
4932
+ * `EngineProvisioningState` snapshot; `event.source.nodeId` carries the
4933
+ * node. The Pipeline page subscribes to drive a live "installing
4934
+ * OpenVINO… / ready" indicator per node without polling
4935
+ * `pipelineExecutor.getEngineProvisioning`. Telemetry-grade (D8): the UI
4936
+ * also reads the cap snapshot on mount / reconnect. Phase 2.
4937
+ */
4938
+ EventCategory["PipelineEngineProvisioning"] = "pipeline.engine-provisioning";
4939
+ /**
4984
4940
  * Cluster topology snapshot. Carries the same payload returned by
4985
4941
  * `nodes.topology` (every reachable node + addons + processes).
4986
4942
  * Emitted by the hub on any agent / addon lifecycle change
@@ -6058,7 +6014,7 @@ function selectAssignedProfileSlots(slots, deviceId) {
6058
6014
  * Zod schema for StreamSourceEntry — the canonical stream descriptor
6059
6015
  * exposed by ICameraDevice.getStreamSources() and consumed by the broker.
6060
6016
  */
6061
- var StreamSourceEntrySchema = object({
6017
+ var StreamSourceEntrySchema$1 = object({
6062
6018
  id: string(),
6063
6019
  label: string(),
6064
6020
  protocol: _enum([
@@ -6281,1462 +6237,1678 @@ var ProfileRtspEntrySchema = object({
6281
6237
  resolution: CamStreamResolutionSchema.optional()
6282
6238
  });
6283
6239
  /**
6284
- * Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
6285
- * Named `RecordingWeekday` to avoid collision with the string-union
6286
- * `Weekday` exported from `interfaces/timezones.ts`.
6287
- */
6288
- var RecordingWeekdaySchema = number().int().min(0).max(6);
6289
- var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
6290
- var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
6291
- kind: literal("timeOfDay"),
6292
- start: string().regex(HHMM),
6293
- end: string().regex(HHMM),
6294
- /** Restrict to these weekdays; omit = every day. */
6295
- days: array(RecordingWeekdaySchema).optional()
6296
- })]);
6297
- var RecordingModeSchema = _enum([
6298
- "continuous",
6299
- "onMotion",
6300
- "onAudioThreshold"
6301
- ]);
6302
- /**
6303
- * First-class, authoritative per-camera storage mode — the netta choice the UI
6304
- * reads directly (never inferred from `rules`):
6305
- * - `off` — not recording.
6306
- * - `events` — record only around triggers (motion / audio threshold),
6307
- * with pre/post-buffer.
6308
- * - `continuous` — record 24/7 within the schedule.
6309
- *
6310
- * `mode` compiles one-way to the internal `rules[]` consumed by the policy
6311
- * engine (see `compileRules`); `rules[]` is never authored directly anymore.
6312
- */
6313
- var RecordingStorageModeSchema = _enum([
6314
- "off",
6315
- "events",
6316
- "continuous"
6317
- ]);
6318
- /** Which detectors trigger an `events`-mode recording. */
6319
- var RecordingTriggersSchema = object({
6320
- motion: boolean().optional(),
6321
- audioThresholdDbfs: number().optional()
6322
- });
6323
- /**
6324
- * Mode of a single recording band — the recorder per-band vocabulary.
6325
- *
6326
- * Distinct from `RecordingStorageModeSchema` (which carries `off`): a band is
6327
- * only ever `continuous` or `events`; "off" is expressed by the absence of a
6328
- * covering band, not by a band value.
6329
- */
6330
- var RecordingBandModeSchema = _enum(["continuous", "events"]);
6331
- /**
6332
- * Triggers for an `events`-mode band. Identical shape to
6333
- * `RecordingTriggersSchema` — reuse that schema as the band trigger type so the
6334
- * two never drift.
6335
- */
6336
- var RecordingBandTriggersSchema = RecordingTriggersSchema;
6337
- /**
6338
- * A single mode-per-band window — the canonical recorder band shape, the
6339
- * single source of truth re-used by `addon-pipeline/recorder`.
6340
- *
6341
- * `days` lists the weekdays the band covers (empty = every day, matching the
6342
- * band engine's `applies` rule). `start`/`end` are `HH:MM`; an `end <= start`
6343
- * span wraps past midnight (handled by the band engine).
6344
- */
6345
- var RecordingBandSchema = object({
6346
- days: array(RecordingWeekdaySchema),
6347
- start: string().regex(HHMM),
6348
- end: string().regex(HHMM),
6349
- mode: RecordingBandModeSchema,
6350
- triggers: RecordingBandTriggersSchema.optional(),
6351
- preBufferSec: number().min(0).optional(),
6352
- postBufferSec: number().min(0).optional()
6353
- });
6354
- var RecordingRuleSchema = object({
6355
- schedule: RecordingScheduleSchema,
6356
- mode: RecordingModeSchema,
6357
- /** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
6358
- preBufferSec: number().min(0).default(0),
6359
- /** Keep recording until this many seconds after the last trigger. */
6360
- postBufferSec: number().min(0).default(0),
6361
- /** Each new trigger restarts the post-buffer window. */
6362
- resetTimeoutOnNewEvent: boolean().default(true),
6363
- /** onAudioThreshold only — dBFS level that counts as a trigger. */
6364
- thresholdDbfs: number().optional()
6365
- });
6366
- /**
6367
- * Per-device retention overrides. Every field is optional; an unset or `0`
6368
- * value inherits the node-wide recorder default. Only footage-lifetime limits
6369
- * live per-camera: `maxAgeDays` and `maxSizeGb`. The disk-occupancy threshold
6370
- * (when the volume is too full to keep recording) is NOT a per-camera concern —
6371
- * it belongs to the StorageLocation (`StorageLocation.config.minFreePercent`),
6372
- * shared by every camera writing to that volume.
6373
- */
6374
- var RecordingRetentionSchema = object({
6375
- maxAgeDays: number().min(0).optional(),
6376
- maxSizeGb: number().min(0).optional()
6377
- });
6378
- /**
6379
- * The full per-camera recording intent — the wire shape of a RecordingTarget.
6240
+ * Type-safe JSON parsing helpers.
6380
6241
  *
6381
- * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
6382
- * are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
6383
- * only for transition + migration (`migrateRulesToMode`); the policy engine
6384
- * consumes the compiled output of `compileRules(config)`, never `rules` directly.
6242
+ * `JSON.parse` is typed as `any` in lib.es5.d.ts, which triggers
6243
+ * `no-unsafe-*` ESLint rules and destroys downstream inference. These
6244
+ * wrappers return `unknown` callers narrow structurally via type
6245
+ * guards, `typeof` checks, or helpers like `asRecord`/`asString`.
6385
6246
  */
6386
- var RecordingConfigSchema = object({
6387
- enabled: boolean(),
6388
- /** Authoritative storage mode. Absent on legacy targets → derived once via
6389
- * `migrateRulesToMode`, then persisted. */
6390
- mode: RecordingStorageModeSchema.optional(),
6391
- profiles: array(CamProfileSchema).optional(),
6392
- segmentSeconds: number().int().positive().optional(),
6393
- /** Shared recording time-bands for `events` & `continuous` — record only when
6394
- * the wall-clock falls inside one of these windows. Omit or empty = always.
6395
- * `continuous` compiles to one rule per band; `events` to band × trigger. */
6396
- schedules: array(RecordingScheduleSchema).optional(),
6397
- /** Legacy single-band predecessor of `schedules`. Read-compat only — it is
6398
- * normalized into `schedules` on read and never written going forward. (Not
6399
- * tagged `@deprecated`: the normalization paths must read it cast-free.) */
6400
- schedule: RecordingScheduleSchema.optional(),
6401
- /** `events`-mode only — which detectors trigger a recording. */
6402
- triggers: RecordingTriggersSchema.optional(),
6403
- /** `events`-mode only — seconds retained before / after a trigger. */
6404
- preBufferSec: number().min(0).optional(),
6405
- postBufferSec: number().min(0).optional(),
6406
- /** DEPRECATED authoring input; retained for migration/transition. */
6407
- rules: array(RecordingRuleSchema).optional(),
6408
- /**
6409
- * AUTHORITATIVE mode-per-band recording model (recorder). When present it
6410
- * is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
6411
- * `triggers`/`rules` fields above are kept for READ-COMPAT only and are
6412
- * derived into bands once via `migrateConfigToBands`.
6413
- */
6414
- bands: array(RecordingBandSchema).optional(),
6415
- retention: RecordingRetentionSchema.optional()
6416
- });
6417
- /** All seven weekdays (0 = Sunday … 6 = Saturday), used when a schedule omits a
6418
- * weekday filter. */
6419
- var ALL_DAYS = [
6420
- 0,
6421
- 1,
6422
- 2,
6423
- 3,
6424
- 4,
6425
- 5,
6426
- 6
6427
- ];
6428
- /** Full-day span used to represent an `always` schedule as a band. The `HHMM`
6429
- * regex maxes out at 23:59, so a 00:00–23:59 same-day span ≈ all-day (the band
6430
- * engine treats `end > start` as a normal, non-wrapping span). */
6431
- var ALL_DAY_START = "00:00";
6432
- var ALL_DAY_END = "23:59";
6433
- function bandFromSchedule(schedule, mode, config) {
6434
- const days = schedule.kind === "timeOfDay" && schedule.days ? schedule.days : [...ALL_DAYS];
6435
- const start = schedule.kind === "timeOfDay" ? schedule.start : ALL_DAY_START;
6436
- const end = schedule.kind === "timeOfDay" ? schedule.end : ALL_DAY_END;
6437
- if (mode === "continuous") return {
6438
- days,
6439
- start,
6440
- end,
6441
- mode
6442
- };
6443
- return {
6444
- days,
6445
- start,
6446
- end,
6447
- mode,
6448
- ...config.triggers ? { triggers: config.triggers } : {},
6449
- ...config.preBufferSec !== void 0 ? { preBufferSec: config.preBufferSec } : {},
6450
- ...config.postBufferSec !== void 0 ? { postBufferSec: config.postBufferSec } : {}
6451
- };
6452
- }
6453
6247
  /**
6454
- * One-way migration from the legacy recording-config shape to the authoritative
6455
- * mode-per-band model. Pure (no clock access).
6248
+ * Parse JSON and return it as `unknown` the only entry point for untrusted JSON.
6456
6249
  *
6457
- * - If `config.bands` is present, it is authoritative and returned as-is.
6458
- * - Otherwise the result is derived from the legacy fields: a disabled config or
6459
- * `mode: 'off'` yields no bands; every legacy schedule maps to one band whose
6460
- * mode is `continuous` when `config.mode === 'continuous'`, else `events`
6461
- * (carrying `triggers`/`preBufferSec`/`postBufferSec`).
6250
+ * The optional generic overload `parseJsonUnknown<T>(text)` returns `T` for
6251
+ * call sites that know the shape at parse time (e.g. MQTT payloads with a
6252
+ * known protocol schema). This is a **type-level bridge only** no runtime
6253
+ * validation is performed. Callers that need runtime validation should parse
6254
+ * as `unknown` and narrow via Zod or structural guards.
6462
6255
  */
6463
- function migrateConfigToBands(config) {
6464
- if (config.bands) return config.bands;
6465
- if (!config.enabled || config.mode === "off") return [];
6466
- const schedules = config.schedules ?? (config.schedule ? [config.schedule] : [{ kind: "always" }]);
6467
- const bandMode = config.mode === "continuous" ? "continuous" : "events";
6468
- return schedules.map((schedule) => bandFromSchedule(schedule, bandMode, config));
6256
+ function parseJsonUnknown(text) {
6257
+ return JSON.parse(text);
6469
6258
  }
6470
- /**
6471
- * `StorageLocationType` — an addon-declared id that identifies the *kind* of
6472
- * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
6473
- * so the persisted record schema and the consumer-facing cap can both consume it
6474
- * without forming a circular import. The `storage` cap re-exports it
6475
- * verbatim for back-compat.
6476
- *
6477
- * This Zod schema is the **authoritative source** for `StorageLocationType`.
6478
- * The TS alias in `./storage.ts` re-exports `z.infer<typeof
6479
- * StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
6480
- * `IStorageProvider` interface stay in lockstep.
6481
- *
6482
- * The type is now an **open string** (not a closed enum) — addons declare
6483
- * their own location kinds via `StorageLocationDeclaration.id`. The regex
6484
- * enforces a safe id format: lowercase-start, alphanumeric + hyphens.
6485
- */
6486
- var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
6487
- /**
6488
- * Persisted record for a storage location instance. Operators can register
6489
- * multiple instances for multi-cardinality types (e.g. two `backups`
6490
- * locations with different `providerId`s). Cardinality is now declared per
6491
- * location via `StorageLocationDeclaration.cardinality` the static
6492
- * `STORAGE_LOCATION_CARDINALITY` map has been removed.
6493
- *
6494
- * `id` is a stable namespaced string of the form `<type>:<slug>`.
6495
- * The default location for a type uses `id === <type>:default` by
6496
- * convention (the bare type ref like `'backups'` resolves to it).
6497
- *
6498
- * `isSystem: true` marks a location as orchestrator-seeded and
6499
- * undeletable. The bootstrap-installed defaults (one per type) carry
6500
- * this flag; operator-added locations don't. Editing the config of
6501
- * a system location is allowed (path migration, provider swap) but
6502
- * deleting it is rejected at the cap level.
6503
- */
6504
- var StorageLocationSchema = object({
6505
- id: string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
6506
- type: string(),
6507
- displayName: string().min(1),
6508
- providerId: string().min(1),
6509
- config: record(string(), unknown()),
6510
- /**
6511
- * Cluster node this location physically lives on. REQUIRED for node-local
6512
- * providers (filesystem — the path exists on one node's disk), null/absent
6513
- * for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
6514
- * `'hub'` is the hub node. Validated against the provider's `nodeLocal`
6515
- * flag at upsert time, not here (the schema is provider-agnostic).
6516
- */
6517
- nodeId: string().optional(),
6518
- isDefault: boolean().default(false),
6519
- isSystem: boolean().default(false),
6520
- createdAt: number(),
6521
- updatedAt: number()
6522
- });
6523
- /**
6524
- * Reference accepted by consumer-facing `api.storage.*` calls.
6525
- * Either:
6526
- * - a `StorageLocationType` (e.g. `'backups'`) → orchestrator resolves to the default of that type
6527
- * - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
6528
- *
6529
- * The orchestrator's `resolveRef(ref)` handles both cases.
6530
- */
6531
- var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
6532
- /**
6533
- * `StorageLocationDeclaration` a single storage-location entry declared by
6534
- * an addon in its `package.json` under `camstack.storageLocations`.
6535
- *
6536
- * Design intent:
6537
- * - **Addon declares its needs** — each addon describes the logical storage
6538
- * slots it requires (e.g. `recordings`, `recordingsLow`) without caring
6539
- * about the physical path.
6540
- * - **Kernel aggregates** — at boot the kernel collects declarations from all
6541
- * installed addons, deduplicates by `id`, and exposes the union via the
6542
- * storage-locations settings surface.
6543
- * - **Orchestrator seeds** for every declared `id` the orchestrator ensures
6544
- * at least one instance named `<id>:default` is present, using
6545
- * `defaultsTo` to inherit the resolved root from another location when the
6546
- * declaration is a derivative slot (e.g. `recordingsLow` defaults to
6547
- * `recordings`).
6548
- * - **ids are global** `id` values are shared across the entire deployment;
6549
- * two addons declaring the same `id` must agree on `cardinality` (validated
6550
- * at kernel aggregation time, not here).
6551
- */
6552
- var StorageLocationDeclarationSchema = object({
6553
- /**
6554
- * Global location identifier, e.g. `recordings` or `recordingsLow`.
6555
- * Must start with a lowercase letter and may contain letters, digits, and
6556
- * hyphens.
6557
- */
6558
- id: string().regex(/^[a-z][a-zA-Z0-9-]*$/, { message: "id must start with a lowercase letter and contain only letters, digits, or hyphens" }),
6559
- /** Human-readable name shown in the admin UI. */
6560
- displayName: string().min(1, { message: "displayName must not be empty" }),
6561
- /** Optional longer explanation of what data this location stores. */
6562
- description: string().optional(),
6563
- /**
6564
- * `single` — exactly one instance of this location is allowed system-wide
6565
- * (e.g. `logs`, `models`). The operator can edit it but not add more.
6566
- * `multi` — the operator may register several instances (e.g. a second
6567
- * `recordings` on a NAS for disk tiering); one is the default at any time.
6568
- */
6569
- cardinality: _enum(["single", "multi"]),
6570
- /**
6571
- * When set, the default instance for this location inherits its resolved
6572
- * root from the named location's default instance. Useful for derivative
6573
- * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
6574
- * configure the primary location.
6575
- */
6576
- defaultsTo: string().optional()
6577
- });
6578
- var DecoderStatsSchema = object({
6579
- inputFps: number(),
6580
- outputFps: number(),
6581
- avgDecodeTimeMs: number(),
6582
- droppedFrames: number()
6583
- });
6584
- var DecoderSessionConfigSchema = object({
6585
- codec: string(),
6586
- maxFps: number().default(0),
6587
- outputFormat: _enum([
6588
- "jpeg",
6589
- "rgb",
6590
- "bgr",
6591
- "yuv420",
6592
- "gray"
6593
- ]).default("jpeg"),
6594
- scale: number().default(1),
6595
- width: number().optional(),
6596
- height: number().optional(),
6259
+ /** Narrow an unknown value to a plain `Record<string, unknown>` or return null. */
6260
+ function asJsonObject(value) {
6261
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
6262
+ return { ...value };
6263
+ }
6264
+ var DeviceType = /* @__PURE__ */ function(DeviceType) {
6265
+ DeviceType["Camera"] = "camera";
6266
+ DeviceType["Hub"] = "hub";
6267
+ DeviceType["Light"] = "light";
6268
+ DeviceType["Siren"] = "siren";
6269
+ DeviceType["Switch"] = "switch";
6270
+ DeviceType["Sensor"] = "sensor";
6271
+ DeviceType["Thermostat"] = "thermostat";
6272
+ DeviceType["Button"] = "button";
6273
+ /** Generic stateless event emitter carries a device's EXACT declared
6274
+ * event vocabulary verbatim (no normalization). Installed with the
6275
+ * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
6276
+ * HA bus events (e.g. `zha_event`, generic). */
6277
+ DeviceType["EventEmitter"] = "event-emitter";
6278
+ /** Firmware/software update entity current vs available version,
6279
+ * updatable flag, update state, and an install action. Installed with
6280
+ * the `update` cap. Sources: Homematic firmware-update channels (and
6281
+ * reusable by other providers, e.g. HA `update.*` entities). */
6282
+ DeviceType["Update"] = "update";
6283
+ DeviceType["Generic"] = "generic";
6284
+ /** Generic notification delivery target (HA `notify.<service>`, future
6285
+ * Telegram / Discord / ntfy / SMTP, …). One device per delivery
6286
+ * endpoint; the `notifier` cap defines the send surface. */
6287
+ DeviceType["Notifier"] = "notifier";
6288
+ /** Pre-recorded action sequence with optional parameters
6289
+ * (HA `script.*`). Runnable via `script-runner` cap. */
6290
+ DeviceType["Script"] = "script";
6291
+ /** Automation rule (HA `automation.*`) enable/disable + manual
6292
+ * trigger surface exposed via `automation-control` cap. */
6293
+ DeviceType["Automation"] = "automation";
6294
+ /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
6295
+ DeviceType["Lock"] = "lock";
6296
+ /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
6297
+ * `valve.*`). `cover` cap with sub-roles for variant. */
6298
+ DeviceType["Cover"] = "cover";
6299
+ /** Pipe / water / gas valve with open/close/stop and optional
6300
+ * position (HA `valve.*`). `valve` cap a cover-sibling actuator
6301
+ * modelled on the same open/closed lifecycle. */
6302
+ DeviceType["Valve"] = "valve";
6303
+ /** Humidifier / dehumidifier with on/off + target humidity + mode
6304
+ * (HA `humidifier.*`). `humidifier` cap a climate-family actuator
6305
+ * modelled on the same target / mode lifecycle. */
6306
+ DeviceType["Humidifier"] = "humidifier";
6307
+ /** Water heater / boiler with target temperature + operation mode +
6308
+ * away mode (HA `water_heater.*`). `water-heater` cap — a
6309
+ * climate-family actuator. */
6310
+ DeviceType["WaterHeater"] = "water-heater";
6311
+ /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
6312
+ DeviceType["Fan"] = "fan";
6313
+ /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
6314
+ * the camera surface — those use `Camera`. `media-player` cap. */
6315
+ DeviceType["MediaPlayer"] = "media-player";
6316
+ /** Security panel / alarm system (HA `alarm_control_panel.*`).
6317
+ * `alarm-panel` cap. */
6318
+ DeviceType["AlarmPanel"] = "alarm-panel";
6319
+ /** Generic user-settable input (HA `number` / `input_number` / `select`
6320
+ * / `input_select` / `text` / `input_text` / `input_datetime`).
6321
+ * Sub-type via `DeviceRole`: NumericControl / SelectControl /
6322
+ * TextControl / DateTimeControl. */
6323
+ DeviceType["Control"] = "control";
6324
+ /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
6325
+ * `presence` cap. */
6326
+ DeviceType["Presence"] = "presence";
6327
+ /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
6328
+ * `weather` cap. */
6329
+ DeviceType["Weather"] = "weather";
6330
+ /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
6331
+ DeviceType["Vacuum"] = "vacuum";
6332
+ /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
6333
+ * `lawn-mower-control` cap. */
6334
+ DeviceType["LawnMower"] = "lawn-mower";
6335
+ /** Physical HA device group parent container for entity-children
6336
+ * adopted from a single HA device entry. Not renderable as a
6337
+ * standalone device; exists only to anchor child entities. */
6338
+ DeviceType["Container"] = "container";
6339
+ /** Single still-image entity (HA `image.*`). Read-only display of an
6340
+ * `entity_picture` signed URL the browser loads directly. `image` cap. */
6341
+ DeviceType["Image"] = "image";
6342
+ return DeviceType;
6343
+ }({});
6344
+ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
6345
+ DeviceFeature["BatteryOperated"] = "battery-operated";
6346
+ DeviceFeature["Rebootable"] = "rebootable";
6597
6347
  /**
6598
- * Identifier of the camera this decoder session serves. Optional
6599
- * because the cap is generic (any caller could request decode), but
6600
- * stream-broker passes it so decoder logs include `deviceId` for
6601
- * per-camera filtering when diagnosing failures (e.g. node-av
6602
- * sendPacket errors on a single hung camera).
6348
+ * Device supports an on-demand re-sync of its derived spec with its
6349
+ * upstream source drives the generic Re-sync button. The owning
6350
+ * provider implements the action via the `device-adoption.resync` cap.
6603
6351
  */
6604
- deviceId: number().int().nonnegative().optional(),
6352
+ DeviceFeature["Resyncable"] = "resyncable";
6353
+ DeviceFeature["NativeSnapshot"] = "native-snapshot";
6354
+ DeviceFeature["DoorbellButton"] = "doorbell-button";
6355
+ DeviceFeature["TwoWayAudio"] = "two-way-audio";
6356
+ DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
6605
6357
  /**
6606
- * Free-form tag for log scoping. Stream-broker uses
6607
- * `broker:<deviceId>/<profile>`. Decoder session logger surfaces it
6608
- * on every line so `grep tag=broker:5/high` filters one camera
6609
- * profile cleanly.
6358
+ * Camera supports the on-firmware autotrack subsystem (subject-
6359
+ * following). Distinct from `PanTiltZoom` because not every PTZ
6360
+ * camera ships autotrack the admin UI uses this flag to gate
6361
+ * the autotrack toggle / settings card without re-deriving from
6362
+ * the cap registry. Mirrors `ptz-autotrack` cap registration:
6363
+ * driver sets this feature when probe confirms the firmware
6364
+ * surface, and registers the cap in the same code path.
6610
6365
  */
6611
- tag: string().optional(),
6366
+ DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
6612
6367
  /**
6613
- * Where the session delivers decoded frames (Phase 5 / D9):
6368
+ * Accessory exposes a "trigger on motion" toggle the parent camera's
6369
+ * motion detection automatically activates this device. Mirrors
6370
+ * `motion-trigger` cap registration: drivers set this feature in the
6371
+ * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
6614
6372
  *
6615
- * - `'callback'` (default) the legacy pixel path: decoded frames are
6616
- * buffered as `DecodedFrame`s and drained via `pullFrames`.
6617
- * - `'shm'` the shared-memory frame plane: decoded frames are written
6618
- * into an OS shared-memory ring and drained as zero-pixel
6619
- * `FrameHandle`s via `pullHandles`. A session is one mode or the
6620
- * other — `pullFrames` returns nothing for an `'shm'` session and
6621
- * `pullHandles` returns nothing for a `'callback'` session.
6373
+ * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
6374
+ * fast scalar without binding fetch), notifier rules, and `listAll`
6375
+ * filters that want "all devices with on-motion behaviour".
6622
6376
  */
6623
- frameSink: _enum(["callback", "shm"]).default("callback")
6624
- });
6625
- var EncodeProfileSchema = object({
6626
- video: object({
6627
- codec: _enum([
6628
- "h264",
6629
- "h265",
6630
- "copy"
6631
- ]),
6632
- profile: _enum([
6633
- "baseline",
6634
- "main",
6635
- "high"
6636
- ]).optional(),
6637
- width: number().int().positive().optional(),
6638
- height: number().int().positive().optional(),
6639
- fps: number().positive().optional(),
6640
- bitrateKbps: number().int().positive().optional(),
6641
- gopFrames: number().int().positive().optional(),
6642
- bf: number().int().min(0).optional(),
6643
- preset: _enum([
6644
- "ultrafast",
6645
- "superfast",
6646
- "veryfast",
6647
- "faster",
6648
- "fast",
6649
- "medium"
6650
- ]).optional(),
6651
- tune: _enum([
6652
- "zerolatency",
6653
- "film",
6654
- "animation"
6655
- ]).optional()
6656
- }),
6657
- audio: union([literal("passthrough"), object({
6658
- codec: _enum([
6659
- "opus",
6660
- "aac",
6661
- "pcmu",
6662
- "pcma",
6663
- "copy"
6664
- ]),
6665
- bitrateKbps: number().int().positive().optional(),
6666
- sampleRateHz: number().int().positive().optional(),
6667
- channels: union([literal(1), literal(2)]).optional()
6668
- })]),
6669
- /**
6670
- * ffmpeg input-side args, inserted between the fixed global flags
6671
- * (`-hide_banner -loglevel error`) and `-i pipe:0`. Free-text array
6672
- * the widget surfaces a textarea + suggestion chips for the most-
6673
- * used demuxer/format options.
6674
- */
6675
- inputArgs: array(string()).optional(),
6676
- /**
6677
- * ffmpeg output-side args, inserted between the encode block and
6678
- * the final `-f <muxer> pipe:1`. Use for muxer options, bitstream
6679
- * filters, codec-specific overrides. Free-text array.
6680
- */
6681
- outputArgs: array(string()).optional()
6682
- });
6683
- var HF_BASE_URL = `https://huggingface.co/camstack/camstack-models/resolve/main`;
6377
+ DeviceFeature["MotionTrigger"] = "motion-trigger";
6378
+ /** Light supports rgb-triplet color via `color` cap. */
6379
+ DeviceFeature["LightColorRgb"] = "light-color-rgb";
6380
+ /** Light supports HSV color via `color` cap. */
6381
+ DeviceFeature["LightColorHsv"] = "light-color-hsv";
6382
+ /** Light supports color-temperature (mired) via `color` cap. */
6383
+ DeviceFeature["LightColorMired"] = "light-color-mired";
6384
+ /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
6385
+ * targetHigh). Gates the range slider UI. */
6386
+ DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
6387
+ /** Thermostat exposes target humidity and/or current humidity
6388
+ * readings. Gates the humidity controls. */
6389
+ DeviceFeature["ClimateHumidity"] = "climate-humidity";
6390
+ /** Thermostat exposes a fan-mode selector. */
6391
+ DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
6392
+ /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
6393
+ DeviceFeature["ClimatePreset"] = "climate-preset";
6394
+ /** Cover exposes intermediate position control (0..100). Gates the
6395
+ * position slider UI. */
6396
+ DeviceFeature["CoverPositionable"] = "cover-positionable";
6397
+ /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
6398
+ DeviceFeature["CoverTilt"] = "cover-tilt";
6399
+ /** Valve exposes intermediate position control (0..100). Gates the
6400
+ * position slider / drag surface UI. */
6401
+ DeviceFeature["ValvePositionable"] = "valve-positionable";
6402
+ /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
6403
+ DeviceFeature["FanSpeed"] = "fan-speed";
6404
+ /** Fan exposes a preset mode selector. */
6405
+ DeviceFeature["FanPreset"] = "fan-preset";
6406
+ /** Fan exposes blade direction (forward/reverse) — typical of
6407
+ * ceiling fans. */
6408
+ DeviceFeature["FanDirection"] = "fan-direction";
6409
+ /** Fan exposes an oscillation toggle. */
6410
+ DeviceFeature["FanOscillating"] = "fan-oscillating";
6411
+ /** Lock requires a PIN code on lock/unlock. Gates the code-entry
6412
+ * field on the UI lock-controls panel. */
6413
+ DeviceFeature["LockPinRequired"] = "lock-pin-required";
6414
+ /** Lock supports a latch-release ("open door") action distinct from
6415
+ * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
6416
+ * `supported_features`. Gates the Open Door button in the UI. */
6417
+ DeviceFeature["LockOpen"] = "lock-open";
6418
+ /** Media player exposes a seek-to-position surface. */
6419
+ DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
6420
+ /** Media player exposes a volume-level setter. */
6421
+ DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
6422
+ /** Media player exposes a mute toggle distinct from volume=0. */
6423
+ DeviceFeature["MediaPlayerMute"] = "media-player-mute";
6424
+ /** Media player exposes a shuffle toggle. */
6425
+ DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
6426
+ /** Media player exposes a repeat mode (off / all / one). */
6427
+ DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
6428
+ /** Media player exposes a source / input selector. */
6429
+ DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
6430
+ /** Media player exposes a play-arbitrary-media surface (URL / id). */
6431
+ DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
6432
+ /** Media player exposes next-track. */
6433
+ DeviceFeature["MediaPlayerNext"] = "media-player-next";
6434
+ /** Media player exposes previous-track. */
6435
+ DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
6436
+ /** Media player exposes stop distinct from pause. */
6437
+ DeviceFeature["MediaPlayerStop"] = "media-player-stop";
6438
+ /** Alarm panel requires a PIN code on arm/disarm. */
6439
+ DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
6440
+ /** Presence device carries GPS coordinates (lat/lng/accuracy) in
6441
+ * addition to a textual location. */
6442
+ DeviceFeature["PresenceGps"] = "presence-gps";
6443
+ /** Notifier accepts an inline / URL image attachment. */
6444
+ DeviceFeature["NotifierImage"] = "notifier-image";
6445
+ /** Notifier accepts a priority hint (high/normal/low). */
6446
+ DeviceFeature["NotifierPriority"] = "notifier-priority";
6447
+ /** Notifier accepts a free-form `data` payload for platform-specific
6448
+ * fields. */
6449
+ DeviceFeature["NotifierData"] = "notifier-data";
6450
+ /** Notifier supports interactive action buttons / callbacks. */
6451
+ DeviceFeature["NotifierActions"] = "notifier-actions";
6452
+ /** Notifier supports per-call recipient targeting (multi-user). */
6453
+ DeviceFeature["NotifierRecipients"] = "notifier-recipients";
6454
+ /** Script runner accepts a variables map on each run invocation. */
6455
+ DeviceFeature["ScriptVariables"] = "script-variables";
6456
+ /** Automation `trigger` accepts a skipCondition flag — fires the
6457
+ * automation's actions while bypassing its condition block. */
6458
+ DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
6459
+ return DeviceFeature;
6460
+ }({});
6684
6461
  /**
6685
- * Type-safe JSON parsing helpers.
6462
+ * Semantic role a device plays within its parent. Populated by driver
6463
+ * addons when creating accessory devices (Reolink siren/floodlight/
6464
+ * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
6465
+ * admin UI to pick icons, labels, and widgets — a `Switch` with
6466
+ * `role: Floodlight` renders as a bulb with a brightness slider,
6467
+ * whereas a `Switch` with `role: Siren` renders as a klaxon.
6686
6468
  *
6687
- * `JSON.parse` is typed as `any` in lib.es5.d.ts, which triggers
6688
- * `no-unsafe-*` ESLint rules and destroys downstream inference. These
6689
- * wrappers return `unknown` — callers narrow structurally via type
6690
- * guards, `typeof` checks, or helpers like `asRecord`/`asString`.
6469
+ * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
6470
+ * sqlite as a nullable TEXT column — old rows keep working unchanged.
6691
6471
  */
6472
+ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
6473
+ DeviceRole["Siren"] = "siren";
6474
+ DeviceRole["Floodlight"] = "floodlight";
6475
+ DeviceRole["Spotlight"] = "spotlight";
6476
+ DeviceRole["PirSensor"] = "pir-sensor";
6477
+ DeviceRole["Chime"] = "chime";
6478
+ DeviceRole["Autotrack"] = "autotrack";
6479
+ DeviceRole["Nightvision"] = "nightvision";
6480
+ DeviceRole["PrivacyMask"] = "privacy-mask";
6481
+ DeviceRole["Doorbell"] = "doorbell";
6482
+ /** Virtual HA toggle (input_boolean.*) — distinguishable from a
6483
+ * real Switch device for UI rendering / export adapters. */
6484
+ DeviceRole["BinaryHelper"] = "binary-helper";
6485
+ /** Generic motion / occupancy / moving event source. Distinct from
6486
+ * the camera accessory PirSensor role: that one is a camera child;
6487
+ * this is a standalone HA / 3rd-party motion sensor. */
6488
+ DeviceRole["MotionSensor"] = "motion-sensor";
6489
+ DeviceRole["ContactSensor"] = "contact-sensor";
6490
+ DeviceRole["LeakSensor"] = "leak-sensor";
6491
+ DeviceRole["SmokeSensor"] = "smoke-sensor";
6492
+ DeviceRole["COSensor"] = "co-sensor";
6493
+ DeviceRole["GasSensor"] = "gas-sensor";
6494
+ DeviceRole["TamperSensor"] = "tamper-sensor";
6495
+ DeviceRole["VibrationSensor"] = "vibration-sensor";
6496
+ DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
6497
+ DeviceRole["SoundSensor"] = "sound-sensor";
6498
+ /** Fallback for `binary_sensor` without a known `device_class`. */
6499
+ DeviceRole["BinarySensor"] = "binary-sensor";
6500
+ DeviceRole["TemperatureSensor"] = "temperature-sensor";
6501
+ DeviceRole["HumiditySensor"] = "humidity-sensor";
6502
+ DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
6503
+ DeviceRole["PressureSensor"] = "pressure-sensor";
6504
+ DeviceRole["PowerSensor"] = "power-sensor";
6505
+ DeviceRole["EnergySensor"] = "energy-sensor";
6506
+ DeviceRole["VoltageSensor"] = "voltage-sensor";
6507
+ DeviceRole["CurrentSensor"] = "current-sensor";
6508
+ DeviceRole["AirQualitySensor"] = "air-quality-sensor";
6509
+ /** Battery level (numeric % via `sensor` OR low-bool via
6510
+ * `binary_sensor` — the cap distinguishes via the value type). */
6511
+ DeviceRole["BatterySensor"] = "battery-sensor";
6512
+ /** Fallback for `sensor` numeric without a known `device_class`. */
6513
+ DeviceRole["NumericSensor"] = "numeric-sensor";
6514
+ /** String / enum state (HA `sensor` with `state_class: enum` or
6515
+ * `attributes.options`). */
6516
+ DeviceRole["EnumSensor"] = "enum-sensor";
6517
+ /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
6518
+ * or `date`). The slice carries the raw ISO string verbatim (hosted on
6519
+ * the `enum-sensor` cap); the UI renders it locale-formatted. */
6520
+ DeviceRole["DateTimeSensor"] = "datetime-sensor";
6521
+ /** Last-resort fallback when nothing else matches. */
6522
+ DeviceRole["GenericSensor"] = "generic-sensor";
6523
+ DeviceRole["NumericControl"] = "numeric-control";
6524
+ DeviceRole["SelectControl"] = "select-control";
6525
+ DeviceRole["TextControl"] = "text-control";
6526
+ DeviceRole["DateTimeControl"] = "datetime-control";
6527
+ /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
6528
+ * rich features (image, priority, channel routing). */
6529
+ DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
6530
+ /** Chat / messaging service (HA `notify.telegram_*`,
6531
+ * `notify.discord_*`, etc.). */
6532
+ DeviceRole["MessagingNotifier"] = "messaging-notifier";
6533
+ /** Email-based delivery (HA `notify.smtp`, etc.). */
6534
+ DeviceRole["EmailNotifier"] = "email-notifier";
6535
+ /** Fallback when the notifier service name doesn't match a known
6536
+ * pattern. */
6537
+ DeviceRole["GenericNotifier"] = "generic-notifier";
6538
+ return DeviceRole;
6539
+ }({});
6692
6540
  /**
6693
- * Parse JSON and return it as `unknown` — the only entry point for untrusted JSON.
6541
+ * Generic types for capability definitions.
6694
6542
  *
6695
- * The optional generic overload `parseJsonUnknown<T>(text)` returns `T` for
6696
- * call sites that know the shape at parse time (e.g. MQTT payloads with a
6697
- * known protocol schema). This is a **type-level bridge only** — no runtime
6698
- * validation is performed. Callers that need runtime validation should parse
6699
- * as `unknown` and narrow via Zod or structural guards.
6543
+ * A capability is defined with Zod schemas for methods, events, and settings.
6544
+ * TypeScript types are inferred via z.infer<> zero duplication.
6545
+ *
6546
+ * Pattern:
6547
+ * 1. Define Zod schemas for data, methods, settings
6548
+ * 2. Export const capabilityDef = { ... } satisfies CapabilityDefinition
6549
+ * 3. Export type IProvider = InferProvider<typeof capabilityDef>
6550
+ * 4. Addon implements IProvider
6551
+ * 5. Registry auto-mounts tRPC router from definition.methods
6700
6552
  */
6701
- function parseJsonUnknown(text) {
6702
- return JSON.parse(text);
6703
- }
6704
- /** Narrow an unknown value to a plain `Record<string, unknown>` or return null. */
6705
- function asJsonObject(value) {
6706
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
6707
- return { ...value };
6708
- }
6709
- function hfModelUrl(repo, path) {
6710
- return `https://huggingface.co/${repo}/resolve/main/${path}`;
6711
- }
6712
6553
  /**
6713
- import { errMsg } from '@camstack/types'
6714
- * Extract a human-readable message from an unknown error value.
6715
- * Replaces the ubiquitous `errMsg(err)` pattern.
6716
- */
6554
+ * Output schema shared by the contribution + live methods.
6555
+ *
6556
+ * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
6557
+ * tabs[]) without importing from `../interfaces/config-ui.js` — a
6558
+ * concrete-but-lenient Zod object keeps tRPC output inference happy
6559
+ * (using `z.unknown()` here collapses unrelated router branches to
6560
+ * `unknown` when the generator re-inlines the huge AppRouter type).
6561
+ *
6562
+ * `.passthrough()` on sections/fields accepts whatever FormBuilder
6563
+ * extensions the caller adds (showWhen, displayScale, …) without
6564
+ * rebuilding every time a new field kind is introduced.
6565
+ */
6566
+ var ContributionSectionSchema = object({
6567
+ id: string(),
6568
+ title: string(),
6569
+ description: string().optional(),
6570
+ style: _enum(["card", "accordion"]).optional(),
6571
+ defaultCollapsed: boolean().optional(),
6572
+ columns: union([
6573
+ literal(1),
6574
+ literal(2),
6575
+ literal(3),
6576
+ literal(4)
6577
+ ]).optional(),
6578
+ tab: string().optional(),
6579
+ location: _enum(["settings", "top-tab"]).optional(),
6580
+ order: number().optional(),
6581
+ fields: array(any())
6582
+ });
6583
+ object({
6584
+ tabs: array(object({
6585
+ id: string(),
6586
+ label: string(),
6587
+ icon: string(),
6588
+ order: number().optional()
6589
+ })).optional(),
6590
+ sections: array(ContributionSectionSchema)
6591
+ }).nullable();
6592
+ object({ deviceId: number() }), object({ deviceId: number() }), object({
6593
+ deviceId: number(),
6594
+ patch: record(string(), unknown())
6595
+ }), object({ success: literal(true) });
6596
+ object({ deviceId: number() }), unknown().nullable();
6597
+ /** Shorthand to define a method schema */
6598
+ function method(input, output, options) {
6599
+ return {
6600
+ input,
6601
+ output,
6602
+ kind: options?.kind ?? "query",
6603
+ auth: options?.auth ?? "protected",
6604
+ ...options?.access !== void 0 ? { access: options.access } : {},
6605
+ timeoutMs: options?.timeoutMs
6606
+ };
6607
+ }
6608
+ /** Shorthand to define an event schema */
6609
+ function event(data) {
6610
+ return { data };
6611
+ }
6612
+ var StaticDirOutputSchema = object({ staticDir: string() });
6613
+ var VersionOutputSchema = object({ version: string() });
6614
+ method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
6615
+ /**
6616
+ * device-ops — device-scoped cap that unifies the per-IDevice operations
6617
+ * previously routed through the `.device-ops` Moleculer bridge service.
6618
+ *
6619
+ * Each worker that hosts live `IDevice` instances auto-registers a native
6620
+ * provider for this cap (per device) backed by its local
6621
+ * `DeviceRegistry`. Hub-side callers reach it transparently through
6622
+ * `ctx.fetchDevice(id).deviceOps.*` — the DeviceProxy injects
6623
+ * `deviceId` + `nodeId` and dispatches through the standard cap-router,
6624
+ * so there's no parallel bridge path anymore.
6625
+ *
6626
+ * The surface is intentionally small — every method corresponds to a
6627
+ * single action on the live `IDevice` (or `ICameraDevice` for
6628
+ * `getStreamSources`). Richer orchestration (enable/disable with
6629
+ * integration plumbing, bulk updates) stays in the `device-manager` cap;
6630
+ * `device-ops` is the per-device primitive the device-manager routes to.
6631
+ */
6632
+ var StreamSourceEntrySchema = object({
6633
+ id: string(),
6634
+ label: string(),
6635
+ protocol: _enum([
6636
+ "rtsp",
6637
+ "rtmp",
6638
+ "annexb",
6639
+ "http-mjpeg",
6640
+ "webrtc",
6641
+ "custom"
6642
+ ]),
6643
+ url: string().optional(),
6644
+ resolution: object({
6645
+ width: number(),
6646
+ height: number()
6647
+ }).optional(),
6648
+ fps: number().optional(),
6649
+ bitrate: number().optional(),
6650
+ codec: string().optional(),
6651
+ profileHint: CamProfileSchema.optional(),
6652
+ sdp: string().optional()
6653
+ });
6654
+ var ConfigEntrySchema$1 = object({
6655
+ key: string(),
6656
+ value: unknown()
6657
+ });
6658
+ var RawStateResultSchema = object({
6659
+ /** Originating provider id, e.g. 'homeassistant' | 'reolink' | 'hikvision'. */
6660
+ source: string(),
6661
+ /** Opaque, DISPLAY-SAFE upstream blob (no secrets/PII). */
6662
+ data: record(string(), unknown())
6663
+ });
6664
+ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
6665
+ deviceId: number(),
6666
+ values: record(string(), unknown())
6667
+ }), _void(), { kind: "mutation" }), method(object({
6668
+ deviceId: number(),
6669
+ action: string().min(1),
6670
+ input: unknown()
6671
+ }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
6672
+ /**
6673
+ * Promise-based timer helpers — used everywhere the codebase needs to
6674
+ * wait, back off, or schedule a retry. Before these helpers landed, each
6675
+ * call site re-implemented `new Promise(r => setTimeout(r, ms))` inline,
6676
+ * with subtle variations (some swallowing cancellation, some not). Two
6677
+ * shapes cover every observed use case:
6678
+ *
6679
+ * - {@link sleep} for a plain, uncancellable wait — the default choice.
6680
+ * - {@link sleepCancellable} for a wait that wakes early when an
6681
+ * abort signal trips, used by long-running pollers whose teardown
6682
+ * must stop a pending backoff promptly.
6683
+ */
6684
+ /**
6685
+ * Resolve after `ms` milliseconds. Never rejects, never cancels. The
6686
+ * sleep cannot be interrupted; for a wakeable variant use
6687
+ * {@link sleepCancellable}.
6688
+ *
6689
+ * `ms <= 0` resolves on the next microtask via `setTimeout(0)`, which
6690
+ * still gives the event loop a chance to drain — useful for breaking
6691
+ * up tight async loops without changing call-site semantics.
6692
+ */
6693
+ function sleep(ms) {
6694
+ return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
6695
+ }
6696
+ //#endregion
6697
+ //#region ../types/dist/err-msg-IQTHeDzc.mjs
6698
+ /**
6699
+ import { errMsg } from '@camstack/types'
6700
+ * Extract a human-readable message from an unknown error value.
6701
+ * Replaces the ubiquitous `errMsg(err)` pattern.
6702
+ */
6717
6703
  function errMsg(err) {
6718
6704
  if (err instanceof Error) return err.message;
6719
6705
  if (typeof err === "string") return err;
6720
6706
  return String(err);
6721
6707
  }
6722
- var COCO_80_LABELS = [
6723
- {
6724
- id: "person",
6725
- name: "Person"
6726
- },
6727
- {
6728
- id: "bicycle",
6729
- name: "Bicycle"
6730
- },
6731
- {
6732
- id: "car",
6733
- name: "Car"
6734
- },
6735
- {
6736
- id: "motorcycle",
6737
- name: "Motorcycle"
6738
- },
6739
- {
6740
- id: "airplane",
6741
- name: "Airplane"
6742
- },
6743
- {
6744
- id: "bus",
6745
- name: "Bus"
6746
- },
6747
- {
6748
- id: "train",
6749
- name: "Train"
6750
- },
6751
- {
6752
- id: "truck",
6753
- name: "Truck"
6754
- },
6755
- {
6756
- id: "boat",
6757
- name: "Boat"
6758
- },
6759
- {
6760
- id: "traffic light",
6761
- name: "Traffic Light"
6762
- },
6763
- {
6764
- id: "fire hydrant",
6765
- name: "Fire Hydrant"
6766
- },
6767
- {
6768
- id: "stop sign",
6769
- name: "Stop Sign"
6770
- },
6771
- {
6772
- id: "parking meter",
6773
- name: "Parking Meter"
6774
- },
6775
- {
6776
- id: "bench",
6777
- name: "Bench"
6778
- },
6779
- {
6780
- id: "bird",
6781
- name: "Bird"
6782
- },
6783
- {
6784
- id: "cat",
6785
- name: "Cat"
6786
- },
6787
- {
6788
- id: "dog",
6789
- name: "Dog"
6790
- },
6791
- {
6792
- id: "horse",
6793
- name: "Horse"
6794
- },
6795
- {
6796
- id: "sheep",
6797
- name: "Sheep"
6798
- },
6799
- {
6800
- id: "cow",
6801
- name: "Cow"
6802
- },
6803
- {
6804
- id: "elephant",
6805
- name: "Elephant"
6806
- },
6807
- {
6808
- id: "bear",
6809
- name: "Bear"
6810
- },
6811
- {
6812
- id: "zebra",
6813
- name: "Zebra"
6814
- },
6815
- {
6816
- id: "giraffe",
6817
- name: "Giraffe"
6818
- },
6819
- {
6820
- id: "backpack",
6821
- name: "Backpack"
6822
- },
6823
- {
6824
- id: "umbrella",
6825
- name: "Umbrella"
6826
- },
6827
- {
6828
- id: "handbag",
6829
- name: "Handbag"
6830
- },
6831
- {
6832
- id: "tie",
6833
- name: "Tie"
6834
- },
6835
- {
6836
- id: "suitcase",
6837
- name: "Suitcase"
6838
- },
6839
- {
6840
- id: "frisbee",
6841
- name: "Frisbee"
6842
- },
6843
- {
6844
- id: "skis",
6845
- name: "Skis"
6846
- },
6847
- {
6848
- id: "snowboard",
6849
- name: "Snowboard"
6850
- },
6851
- {
6852
- id: "sports ball",
6853
- name: "Sports Ball"
6854
- },
6855
- {
6856
- id: "kite",
6857
- name: "Kite"
6858
- },
6859
- {
6860
- id: "baseball bat",
6861
- name: "Baseball Bat"
6862
- },
6863
- {
6864
- id: "baseball glove",
6865
- name: "Baseball Glove"
6866
- },
6867
- {
6868
- id: "skateboard",
6869
- name: "Skateboard"
6870
- },
6871
- {
6872
- id: "surfboard",
6873
- name: "Surfboard"
6874
- },
6875
- {
6876
- id: "tennis racket",
6877
- name: "Tennis Racket"
6878
- },
6879
- {
6880
- id: "bottle",
6881
- name: "Bottle"
6882
- },
6883
- {
6884
- id: "wine glass",
6885
- name: "Wine Glass"
6886
- },
6887
- {
6888
- id: "cup",
6889
- name: "Cup"
6890
- },
6891
- {
6892
- id: "fork",
6893
- name: "Fork"
6894
- },
6895
- {
6896
- id: "knife",
6897
- name: "Knife"
6898
- },
6899
- {
6900
- id: "spoon",
6901
- name: "Spoon"
6902
- },
6903
- {
6904
- id: "bowl",
6905
- name: "Bowl"
6906
- },
6907
- {
6908
- id: "banana",
6909
- name: "Banana"
6910
- },
6911
- {
6912
- id: "apple",
6913
- name: "Apple"
6914
- },
6915
- {
6916
- id: "sandwich",
6917
- name: "Sandwich"
6918
- },
6919
- {
6920
- id: "orange",
6921
- name: "Orange"
6922
- },
6923
- {
6924
- id: "broccoli",
6925
- name: "Broccoli"
6926
- },
6927
- {
6928
- id: "carrot",
6929
- name: "Carrot"
6930
- },
6931
- {
6932
- id: "hot dog",
6933
- name: "Hot Dog"
6934
- },
6935
- {
6936
- id: "pizza",
6937
- name: "Pizza"
6938
- },
6939
- {
6940
- id: "donut",
6941
- name: "Donut"
6942
- },
6943
- {
6944
- id: "cake",
6945
- name: "Cake"
6946
- },
6947
- {
6948
- id: "chair",
6949
- name: "Chair"
6950
- },
6951
- {
6952
- id: "couch",
6953
- name: "Couch"
6954
- },
6955
- {
6956
- id: "potted plant",
6957
- name: "Potted Plant"
6958
- },
6959
- {
6960
- id: "bed",
6961
- name: "Bed"
6962
- },
6963
- {
6964
- id: "dining table",
6965
- name: "Dining Table"
6966
- },
6967
- {
6968
- id: "toilet",
6969
- name: "Toilet"
6970
- },
6971
- {
6972
- id: "tv",
6973
- name: "TV"
6974
- },
6975
- {
6976
- id: "laptop",
6977
- name: "Laptop"
6978
- },
6979
- {
6980
- id: "mouse",
6981
- name: "Mouse"
6982
- },
6983
- {
6984
- id: "remote",
6985
- name: "Remote"
6986
- },
6987
- {
6988
- id: "keyboard",
6989
- name: "Keyboard"
6990
- },
6991
- {
6992
- id: "cell phone",
6993
- name: "Cell Phone"
6994
- },
6995
- {
6996
- id: "microwave",
6997
- name: "Microwave"
6998
- },
6999
- {
7000
- id: "oven",
7001
- name: "Oven"
7002
- },
7003
- {
7004
- id: "toaster",
7005
- name: "Toaster"
7006
- },
7007
- {
7008
- id: "sink",
7009
- name: "Sink"
7010
- },
7011
- {
7012
- id: "refrigerator",
7013
- name: "Refrigerator"
7014
- },
7015
- {
7016
- id: "book",
7017
- name: "Book"
7018
- },
7019
- {
7020
- id: "clock",
7021
- name: "Clock"
7022
- },
7023
- {
7024
- id: "vase",
7025
- name: "Vase"
7026
- },
7027
- {
7028
- id: "scissors",
7029
- name: "Scissors"
7030
- },
7031
- {
7032
- id: "teddy bear",
7033
- name: "Teddy Bear"
7034
- },
7035
- {
7036
- id: "hair drier",
7037
- name: "Hair Drier"
7038
- },
7039
- {
7040
- id: "toothbrush",
7041
- name: "Toothbrush"
7042
- }
7043
- ];
7044
- var COCO_TO_MACRO = {
7045
- mapping: {
7046
- person: "person",
7047
- bicycle: "vehicle",
7048
- car: "vehicle",
7049
- motorcycle: "vehicle",
7050
- airplane: "vehicle",
7051
- bus: "vehicle",
7052
- train: "vehicle",
7053
- truck: "vehicle",
7054
- boat: "vehicle",
7055
- bird: "animal",
7056
- cat: "animal",
7057
- dog: "animal",
7058
- horse: "animal",
7059
- sheep: "animal",
7060
- cow: "animal",
7061
- elephant: "animal",
7062
- bear: "animal",
7063
- zebra: "animal",
7064
- giraffe: "animal"
7065
- },
7066
- preserveOriginal: false
7067
- };
7068
- var AUDIO_MACRO_LABELS = [
7069
- {
7070
- id: "speech",
7071
- name: "Speech",
7072
- icon: "🗣️"
7073
- },
7074
- {
7075
- id: "scream",
7076
- name: "Scream / Shout",
7077
- icon: "😱"
7078
- },
7079
- {
7080
- id: "crying",
7081
- name: "Crying / Baby",
7082
- icon: "😢"
7083
- },
7084
- {
7085
- id: "laughter",
7086
- name: "Laughter",
7087
- icon: "😂"
7088
- },
7089
- {
7090
- id: "music",
7091
- name: "Music",
7092
- icon: "🎵"
7093
- },
7094
- {
7095
- id: "dog",
7096
- name: "Dog",
7097
- icon: "🐕"
7098
- },
7099
- {
7100
- id: "cat",
7101
- name: "Cat",
7102
- icon: "🐈"
7103
- },
7104
- {
7105
- id: "bird",
7106
- name: "Bird",
7107
- icon: "🐦"
7108
- },
7109
- {
7110
- id: "animal",
7111
- name: "Animal (other)",
7112
- icon: "🐾"
7113
- },
7114
- {
7115
- id: "alarm",
7116
- name: "Alarm / Siren",
7117
- icon: "🚨"
7118
- },
7119
- {
7120
- id: "doorbell",
7121
- name: "Doorbell / Knock",
7122
- icon: "🔔"
7123
- },
7124
- {
7125
- id: "glass_breaking",
7126
- name: "Glass Breaking",
7127
- icon: "💥"
7128
- },
7129
- {
7130
- id: "gunshot",
7131
- name: "Gunshot / Explosion",
7132
- icon: "💣"
7133
- },
7134
- {
7135
- id: "vehicle",
7136
- name: "Vehicle",
7137
- icon: "🚗"
7138
- },
7139
- {
7140
- id: "siren",
7141
- name: "Emergency Siren",
7142
- icon: "🚑"
7143
- },
7144
- {
7145
- id: "fire",
7146
- name: "Fire / Smoke",
7147
- icon: "🔥"
7148
- },
7149
- {
7150
- id: "water",
7151
- name: "Water",
7152
- icon: "💧"
7153
- },
7154
- {
7155
- id: "wind",
7156
- name: "Wind / Weather",
7157
- icon: "🌬️"
7158
- },
7159
- {
7160
- id: "door",
7161
- name: "Door",
7162
- icon: "🚪"
7163
- },
7164
- {
7165
- id: "footsteps",
7166
- name: "Footsteps",
7167
- icon: "👣"
7168
- },
7169
- {
7170
- id: "crowd",
7171
- name: "Crowd / Chatter",
7172
- icon: "👥"
7173
- },
7174
- {
7175
- id: "telephone",
7176
- name: "Telephone",
7177
- icon: "📞"
7178
- },
7179
- {
7180
- id: "engine",
7181
- name: "Engine / Motor",
7182
- icon: "⚙️"
7183
- },
7184
- {
7185
- id: "tools",
7186
- name: "Tools / Construction",
7187
- icon: "🔨"
7188
- },
7189
- {
7190
- id: "silence",
7191
- name: "Silence",
7192
- icon: "🤫"
7193
- }
7194
- ];
7195
- var YAMNET_TO_MACRO = {
7196
- mapping: {
7197
- Speech: "speech",
7198
- "Child speech, kid speaking": "speech",
7199
- Conversation: "speech",
7200
- "Narration, monologue": "speech",
7201
- Babbling: "speech",
7202
- Whispering: "speech",
7203
- "Speech synthesizer": "speech",
7204
- Humming: "speech",
7205
- Rapping: "speech",
7206
- Singing: "speech",
7207
- Choir: "speech",
7208
- "Child singing": "speech",
7209
- Shout: "scream",
7210
- Bellow: "scream",
7211
- Yell: "scream",
7212
- Screaming: "scream",
7213
- "Children shouting": "scream",
7214
- Whoop: "scream",
7215
- "Crying, sobbing": "crying",
7216
- "Baby cry, infant cry": "crying",
7217
- Whimper: "crying",
7218
- "Wail, moan": "crying",
7219
- Groan: "crying",
7220
- Laughter: "laughter",
7221
- "Baby laughter": "laughter",
7222
- Giggle: "laughter",
7223
- Snicker: "laughter",
7224
- "Belly laugh": "laughter",
7225
- "Chuckle, chortle": "laughter",
7226
- Music: "music",
7227
- "Musical instrument": "music",
7228
- Guitar: "music",
7229
- Piano: "music",
7230
- Drum: "music",
7231
- "Drum kit": "music",
7232
- "Violin, fiddle": "music",
7233
- Flute: "music",
7234
- Saxophone: "music",
7235
- Trumpet: "music",
7236
- Synthesizer: "music",
7237
- "Pop music": "music",
7238
- "Rock music": "music",
7239
- "Hip hop music": "music",
7240
- "Classical music": "music",
7241
- Jazz: "music",
7242
- "Electronic music": "music",
7243
- "Background music": "music",
7244
- Dog: "dog",
7245
- Bark: "dog",
7246
- Yip: "dog",
7247
- Howl: "dog",
7248
- "Bow-wow": "dog",
7249
- Growling: "dog",
7250
- "Whimper (dog)": "dog",
7251
- Cat: "cat",
7252
- Purr: "cat",
7253
- Meow: "cat",
7254
- Hiss: "cat",
7255
- Caterwaul: "cat",
7256
- Bird: "bird",
7257
- "Bird vocalization, bird call, bird song": "bird",
7258
- "Chirp, tweet": "bird",
7259
- Squawk: "bird",
7260
- Crow: "bird",
7261
- Owl: "bird",
7262
- "Pigeon, dove": "bird",
7263
- Animal: "animal",
7264
- "Domestic animals, pets": "animal",
7265
- "Livestock, farm animals, working animals": "animal",
7266
- Horse: "animal",
7267
- "Cattle, bovinae": "animal",
7268
- Pig: "animal",
7269
- Sheep: "animal",
7270
- Goat: "animal",
7271
- Frog: "animal",
7272
- Insect: "animal",
7273
- Cricket: "animal",
7274
- Alarm: "alarm",
7275
- "Alarm clock": "alarm",
7276
- "Smoke detector, smoke alarm": "alarm",
7277
- "Fire alarm": "alarm",
7278
- Buzzer: "alarm",
7279
- "Civil defense siren": "alarm",
7280
- "Car alarm": "alarm",
7281
- Siren: "siren",
7282
- "Police car (siren)": "siren",
7283
- "Ambulance (siren)": "siren",
7284
- "Fire engine, fire truck (siren)": "siren",
7285
- "Emergency vehicle": "siren",
7286
- Foghorn: "siren",
7287
- Doorbell: "doorbell",
7288
- "Ding-dong": "doorbell",
7289
- Knock: "doorbell",
7290
- Tap: "doorbell",
7291
- Glass: "glass_breaking",
7292
- Shatter: "glass_breaking",
7293
- "Chink, clink": "glass_breaking",
7294
- "Gunshot, gunfire": "gunshot",
7295
- "Machine gun": "gunshot",
7296
- Explosion: "gunshot",
7297
- Fireworks: "gunshot",
7298
- Firecracker: "gunshot",
7299
- "Artillery fire": "gunshot",
7300
- "Cap gun": "gunshot",
7301
- Boom: "gunshot",
7302
- Vehicle: "vehicle",
7303
- Car: "vehicle",
7304
- Truck: "vehicle",
7305
- Bus: "vehicle",
7306
- Motorcycle: "vehicle",
7307
- "Car passing by": "vehicle",
7308
- "Vehicle horn, car horn, honking": "vehicle",
7309
- "Traffic noise, roadway noise": "vehicle",
7310
- Train: "vehicle",
7311
- Aircraft: "vehicle",
7312
- Helicopter: "vehicle",
7313
- Bicycle: "vehicle",
7314
- Skateboard: "vehicle",
7315
- Fire: "fire",
7316
- Crackle: "fire",
7317
- Water: "water",
7318
- Rain: "water",
7319
- Raindrop: "water",
7320
- "Rain on surface": "water",
7321
- Stream: "water",
7322
- Waterfall: "water",
7323
- Ocean: "water",
7324
- "Waves, surf": "water",
7325
- "Splash, splatter": "water",
7326
- Wind: "wind",
7327
- Thunderstorm: "wind",
7328
- Thunder: "wind",
7329
- "Wind noise (microphone)": "wind",
7330
- "Rustling leaves": "wind",
7331
- Door: "door",
7332
- "Sliding door": "door",
7333
- Slam: "door",
7334
- "Cupboard open or close": "door",
7335
- "Walk, footsteps": "footsteps",
7336
- Run: "footsteps",
7337
- Shuffle: "footsteps",
7338
- Crowd: "crowd",
7339
- Chatter: "crowd",
7340
- Cheering: "crowd",
7341
- Applause: "crowd",
7342
- "Children playing": "crowd",
7343
- "Hubbub, speech noise, speech babble": "crowd",
7344
- Telephone: "telephone",
7345
- "Telephone bell ringing": "telephone",
7346
- Ringtone: "telephone",
7347
- "Telephone dialing, DTMF": "telephone",
7348
- "Busy signal": "telephone",
7349
- Engine: "engine",
7350
- "Engine starting": "engine",
7351
- Idling: "engine",
7352
- "Accelerating, revving, vroom": "engine",
7353
- "Light engine (high frequency)": "engine",
7354
- "Medium engine (mid frequency)": "engine",
7355
- "Heavy engine (low frequency)": "engine",
7356
- "Lawn mower": "engine",
7357
- Chainsaw: "engine",
7358
- Hammer: "tools",
7359
- Jackhammer: "tools",
7360
- Sawing: "tools",
7361
- "Power tool": "tools",
7362
- Drill: "tools",
7363
- Sanding: "tools",
7364
- Silence: "silence"
7365
- },
7366
- preserveOriginal: false
7367
- };
7368
- var APPLE_SA_TO_MACRO = {
7369
- mapping: {
7370
- speech: "speech",
7371
- child_speech: "speech",
7372
- conversation: "speech",
7373
- whispering: "speech",
7374
- singing: "speech",
7375
- humming: "speech",
7376
- shout: "scream",
7377
- yell: "scream",
7378
- screaming: "scream",
7379
- crying: "crying",
7380
- baby_crying: "crying",
7381
- sobbing: "crying",
7382
- laughter: "laughter",
7383
- baby_laughter: "laughter",
7384
- giggling: "laughter",
7385
- music: "music",
7386
- guitar: "music",
7387
- piano: "music",
7388
- drums: "music",
7389
- dog_bark: "dog",
7390
- dog_bow_wow: "dog",
7391
- dog_growling: "dog",
7392
- dog_howl: "dog",
7393
- cat_meow: "cat",
7394
- cat_purr: "cat",
7395
- cat_hiss: "cat",
7396
- bird: "bird",
7397
- bird_chirp: "bird",
7398
- bird_squawk: "bird",
7399
- animal: "animal",
7400
- horse: "animal",
7401
- cow_moo: "animal",
7402
- insect: "animal",
7403
- alarm: "alarm",
7404
- smoke_alarm: "alarm",
7405
- fire_alarm: "alarm",
7406
- car_alarm: "alarm",
7407
- siren: "siren",
7408
- police_siren: "siren",
7409
- ambulance_siren: "siren",
7410
- doorbell: "doorbell",
7411
- door_knock: "doorbell",
7412
- knocking: "doorbell",
7413
- glass_breaking: "glass_breaking",
7414
- glass_shatter: "glass_breaking",
7415
- gunshot: "gunshot",
7416
- explosion: "gunshot",
7417
- fireworks: "gunshot",
7418
- car: "vehicle",
7419
- truck: "vehicle",
7420
- motorcycle: "vehicle",
7421
- car_horn: "vehicle",
7422
- vehicle_horn: "vehicle",
7423
- traffic: "vehicle",
7424
- fire: "fire",
7425
- fire_crackle: "fire",
7426
- water: "water",
7427
- rain: "water",
7428
- ocean: "water",
7429
- splash: "water",
7430
- wind: "wind",
7431
- thunder: "wind",
7432
- thunderstorm: "wind",
7433
- door: "door",
7434
- door_slam: "door",
7435
- sliding_door: "door",
7436
- footsteps: "footsteps",
7437
- walking: "footsteps",
7438
- running: "footsteps",
7439
- crowd: "crowd",
7440
- chatter: "crowd",
7441
- cheering: "crowd",
7442
- applause: "crowd",
7443
- telephone_ring: "telephone",
7444
- ringtone: "telephone",
7445
- engine: "engine",
7446
- engine_starting: "engine",
7447
- lawn_mower: "engine",
7448
- chainsaw: "engine",
7449
- hammer: "tools",
7450
- jackhammer: "tools",
7451
- drill: "tools",
7452
- power_tool: "tools",
7453
- silence: "silence"
7454
- },
7455
- preserveOriginal: false
7456
- };
7457
- var _macroLookup = /* @__PURE__ */ new Map();
7458
- for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7459
- for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7460
- /** Map a raw audio label (YAMNet or Apple SoundAnalysis) to its macro class. Returns null if unmapped. */
7461
- function mapAudioLabelToMacro(label) {
7462
- return _macroLookup.get(label.toLowerCase()) ?? null;
6708
+ //#endregion
6709
+ //#region ../types/dist/index.mjs
6710
+ /**
6711
+ * Deep wiring healthcheck — snapshot of active reachability probes across
6712
+ * every declared capability + widget of every installed plugin, on every
6713
+ * node. Produced by the backend `WiringHealthService` and surfaced via
6714
+ * `GET /health/wiring`, the tRPC `health.wiring` query, and the boot-gate.
6715
+ *
6716
+ * Unlike `/health` (process liveness), this reflects whether each cap/widget
6717
+ * is actually *reachable* over the real cap-dispatch path. See spec
6718
+ * `docs/superpowers/specs/2026-05-23-deep-healthcheck-design.md`.
6719
+ */
6720
+ /** What kind of target a probe addressed. */
6721
+ var wiringProbeKindSchema = _enum([
6722
+ "singleton",
6723
+ "device",
6724
+ "widget"
6725
+ ]);
6726
+ /** Result of probing a single (cap|widget [, device]) target. */
6727
+ var wiringProbeResultSchema = object({
6728
+ capName: string(),
6729
+ kind: wiringProbeKindSchema,
6730
+ deviceId: number().optional(),
6731
+ reachable: boolean(),
6732
+ latencyMs: number(),
6733
+ error: string().optional()
6734
+ });
6735
+ /** Per-addon roll-up of cap + widget probe results. */
6736
+ var wiringAddonHealthSchema = object({
6737
+ addonId: string(),
6738
+ caps: array(wiringProbeResultSchema).readonly(),
6739
+ widgets: array(wiringProbeResultSchema).readonly()
6740
+ });
6741
+ /** Per-node roll-up. */
6742
+ var wiringNodeHealthSchema = object({
6743
+ nodeId: string(),
6744
+ addons: array(wiringAddonHealthSchema).readonly()
6745
+ });
6746
+ object({
6747
+ /** True only when every probed target is reachable. */
6748
+ ok: boolean(),
6749
+ /** True when at least one target is unreachable. */
6750
+ degraded: boolean(),
6751
+ checkedAt: string(),
6752
+ nodes: array(wiringNodeHealthSchema).readonly(),
6753
+ summary: object({
6754
+ total: number(),
6755
+ reachable: number(),
6756
+ unreachable: number()
6757
+ })
6758
+ });
6759
+ var MODEL_FORMATS = [
6760
+ "onnx",
6761
+ "coreml",
6762
+ "openvino",
6763
+ "tflite",
6764
+ "pt"
6765
+ ];
6766
+ /**
6767
+ * Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
6768
+ * Named `RecordingWeekday` to avoid collision with the string-union
6769
+ * `Weekday` exported from `interfaces/timezones.ts`.
6770
+ */
6771
+ var RecordingWeekdaySchema = number().int().min(0).max(6);
6772
+ var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
6773
+ var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
6774
+ kind: literal("timeOfDay"),
6775
+ start: string().regex(HHMM),
6776
+ end: string().regex(HHMM),
6777
+ /** Restrict to these weekdays; omit = every day. */
6778
+ days: array(RecordingWeekdaySchema).optional()
6779
+ })]);
6780
+ var RecordingModeSchema = _enum([
6781
+ "continuous",
6782
+ "onMotion",
6783
+ "onAudioThreshold"
6784
+ ]);
6785
+ /**
6786
+ * First-class, authoritative per-camera storage mode — the netta choice the UI
6787
+ * reads directly (never inferred from `rules`):
6788
+ * - `off` — not recording.
6789
+ * - `events` — record only around triggers (motion / audio threshold),
6790
+ * with pre/post-buffer.
6791
+ * - `continuous` — record 24/7 within the schedule.
6792
+ *
6793
+ * `mode` compiles one-way to the internal `rules[]` consumed by the policy
6794
+ * engine (see `compileRules`); `rules[]` is never authored directly anymore.
6795
+ */
6796
+ var RecordingStorageModeSchema = _enum([
6797
+ "off",
6798
+ "events",
6799
+ "continuous"
6800
+ ]);
6801
+ /** Which detectors trigger an `events`-mode recording. */
6802
+ var RecordingTriggersSchema = object({
6803
+ motion: boolean().optional(),
6804
+ audioThresholdDbfs: number().optional()
6805
+ });
6806
+ /**
6807
+ * Mode of a single recording band — the recorder per-band vocabulary.
6808
+ *
6809
+ * Distinct from `RecordingStorageModeSchema` (which carries `off`): a band is
6810
+ * only ever `continuous` or `events`; "off" is expressed by the absence of a
6811
+ * covering band, not by a band value.
6812
+ */
6813
+ var RecordingBandModeSchema = _enum(["continuous", "events"]);
6814
+ /**
6815
+ * Triggers for an `events`-mode band. Identical shape to
6816
+ * `RecordingTriggersSchema` — reuse that schema as the band trigger type so the
6817
+ * two never drift.
6818
+ */
6819
+ var RecordingBandTriggersSchema = RecordingTriggersSchema;
6820
+ /**
6821
+ * A single mode-per-band window — the canonical recorder band shape, the
6822
+ * single source of truth re-used by `addon-pipeline/recorder`.
6823
+ *
6824
+ * `days` lists the weekdays the band covers (empty = every day, matching the
6825
+ * band engine's `applies` rule). `start`/`end` are `HH:MM`; an `end <= start`
6826
+ * span wraps past midnight (handled by the band engine).
6827
+ */
6828
+ var RecordingBandSchema = object({
6829
+ days: array(RecordingWeekdaySchema),
6830
+ start: string().regex(HHMM),
6831
+ end: string().regex(HHMM),
6832
+ mode: RecordingBandModeSchema,
6833
+ triggers: RecordingBandTriggersSchema.optional(),
6834
+ preBufferSec: number().min(0).optional(),
6835
+ postBufferSec: number().min(0).optional()
6836
+ });
6837
+ var RecordingRuleSchema = object({
6838
+ schedule: RecordingScheduleSchema,
6839
+ mode: RecordingModeSchema,
6840
+ /** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
6841
+ preBufferSec: number().min(0).default(0),
6842
+ /** Keep recording until this many seconds after the last trigger. */
6843
+ postBufferSec: number().min(0).default(0),
6844
+ /** Each new trigger restarts the post-buffer window. */
6845
+ resetTimeoutOnNewEvent: boolean().default(true),
6846
+ /** onAudioThreshold only — dBFS level that counts as a trigger. */
6847
+ thresholdDbfs: number().optional()
6848
+ });
6849
+ /**
6850
+ * Per-device retention overrides. Every field is optional; an unset or `0`
6851
+ * value inherits the node-wide recorder default. Only footage-lifetime limits
6852
+ * live per-camera: `maxAgeDays` and `maxSizeGb`. The disk-occupancy threshold
6853
+ * (when the volume is too full to keep recording) is NOT a per-camera concern —
6854
+ * it belongs to the StorageLocation (`StorageLocation.config.minFreePercent`),
6855
+ * shared by every camera writing to that volume.
6856
+ */
6857
+ var RecordingRetentionSchema = object({
6858
+ maxAgeDays: number().min(0).optional(),
6859
+ maxSizeGb: number().min(0).optional()
6860
+ });
6861
+ /**
6862
+ * The full per-camera recording intent — the wire shape of a RecordingTarget.
6863
+ *
6864
+ * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
6865
+ * are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
6866
+ * only for transition + migration (`migrateRulesToMode`); the policy engine
6867
+ * consumes the compiled output of `compileRules(config)`, never `rules` directly.
6868
+ */
6869
+ var RecordingConfigSchema = object({
6870
+ enabled: boolean(),
6871
+ /** Authoritative storage mode. Absent on legacy targets → derived once via
6872
+ * `migrateRulesToMode`, then persisted. */
6873
+ mode: RecordingStorageModeSchema.optional(),
6874
+ profiles: array(CamProfileSchema).optional(),
6875
+ segmentSeconds: number().int().positive().optional(),
6876
+ /** Shared recording time-bands for `events` & `continuous` — record only when
6877
+ * the wall-clock falls inside one of these windows. Omit or empty = always.
6878
+ * `continuous` compiles to one rule per band; `events` to band × trigger. */
6879
+ schedules: array(RecordingScheduleSchema).optional(),
6880
+ /** Legacy single-band predecessor of `schedules`. Read-compat only — it is
6881
+ * normalized into `schedules` on read and never written going forward. (Not
6882
+ * tagged `@deprecated`: the normalization paths must read it cast-free.) */
6883
+ schedule: RecordingScheduleSchema.optional(),
6884
+ /** `events`-mode only — which detectors trigger a recording. */
6885
+ triggers: RecordingTriggersSchema.optional(),
6886
+ /** `events`-mode only — seconds retained before / after a trigger. */
6887
+ preBufferSec: number().min(0).optional(),
6888
+ postBufferSec: number().min(0).optional(),
6889
+ /** DEPRECATED authoring input; retained for migration/transition. */
6890
+ rules: array(RecordingRuleSchema).optional(),
6891
+ /**
6892
+ * AUTHORITATIVE mode-per-band recording model (recorder). When present it
6893
+ * is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
6894
+ * `triggers`/`rules` fields above are kept for READ-COMPAT only and are
6895
+ * derived into bands once via `migrateConfigToBands`.
6896
+ */
6897
+ bands: array(RecordingBandSchema).optional(),
6898
+ retention: RecordingRetentionSchema.optional()
6899
+ });
6900
+ /** All seven weekdays (0 = Sunday … 6 = Saturday), used when a schedule omits a
6901
+ * weekday filter. */
6902
+ var ALL_DAYS = [
6903
+ 0,
6904
+ 1,
6905
+ 2,
6906
+ 3,
6907
+ 4,
6908
+ 5,
6909
+ 6
6910
+ ];
6911
+ /** Full-day span used to represent an `always` schedule as a band. The `HHMM`
6912
+ * regex maxes out at 23:59, so a 00:00–23:59 same-day span ≈ all-day (the band
6913
+ * engine treats `end > start` as a normal, non-wrapping span). */
6914
+ var ALL_DAY_START = "00:00";
6915
+ var ALL_DAY_END = "23:59";
6916
+ function bandFromSchedule(schedule, mode, config) {
6917
+ const days = schedule.kind === "timeOfDay" && schedule.days ? schedule.days : [...ALL_DAYS];
6918
+ const start = schedule.kind === "timeOfDay" ? schedule.start : ALL_DAY_START;
6919
+ const end = schedule.kind === "timeOfDay" ? schedule.end : ALL_DAY_END;
6920
+ if (mode === "continuous") return {
6921
+ days,
6922
+ start,
6923
+ end,
6924
+ mode
6925
+ };
6926
+ return {
6927
+ days,
6928
+ start,
6929
+ end,
6930
+ mode,
6931
+ ...config.triggers ? { triggers: config.triggers } : {},
6932
+ ...config.preBufferSec !== void 0 ? { preBufferSec: config.preBufferSec } : {},
6933
+ ...config.postBufferSec !== void 0 ? { postBufferSec: config.postBufferSec } : {}
6934
+ };
7463
6935
  }
7464
- var DeviceType = /* @__PURE__ */ function(DeviceType) {
7465
- DeviceType["Camera"] = "camera";
7466
- DeviceType["Hub"] = "hub";
7467
- DeviceType["Light"] = "light";
7468
- DeviceType["Siren"] = "siren";
7469
- DeviceType["Switch"] = "switch";
7470
- DeviceType["Sensor"] = "sensor";
7471
- DeviceType["Thermostat"] = "thermostat";
7472
- DeviceType["Button"] = "button";
7473
- /** Generic stateless event emitter — carries a device's EXACT declared
7474
- * event vocabulary verbatim (no normalization). Installed with the
7475
- * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
7476
- * HA bus events (e.g. `zha_event`, generic). */
7477
- DeviceType["EventEmitter"] = "event-emitter";
7478
- /** Firmware/software update entity current vs available version,
7479
- * updatable flag, update state, and an install action. Installed with
7480
- * the `update` cap. Sources: Homematic firmware-update channels (and
7481
- * reusable by other providers, e.g. HA `update.*` entities). */
7482
- DeviceType["Update"] = "update";
7483
- DeviceType["Generic"] = "generic";
7484
- /** Generic notification delivery target (HA `notify.<service>`, future
7485
- * Telegram / Discord / ntfy / SMTP, …). One device per delivery
7486
- * endpoint; the `notifier` cap defines the send surface. */
7487
- DeviceType["Notifier"] = "notifier";
7488
- /** Pre-recorded action sequence with optional parameters
7489
- * (HA `script.*`). Runnable via `script-runner` cap. */
7490
- DeviceType["Script"] = "script";
7491
- /** Automation rule (HA `automation.*`) enable/disable + manual
7492
- * trigger surface exposed via `automation-control` cap. */
7493
- DeviceType["Automation"] = "automation";
7494
- /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
7495
- DeviceType["Lock"] = "lock";
7496
- /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
7497
- * `valve.*`). `cover` cap with sub-roles for variant. */
7498
- DeviceType["Cover"] = "cover";
7499
- /** Pipe / water / gas valve with open/close/stop and optional
7500
- * position (HA `valve.*`). `valve` cap a cover-sibling actuator
7501
- * modelled on the same open/closed lifecycle. */
7502
- DeviceType["Valve"] = "valve";
7503
- /** Humidifier / dehumidifier with on/off + target humidity + mode
7504
- * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
7505
- * modelled on the same target / mode lifecycle. */
7506
- DeviceType["Humidifier"] = "humidifier";
7507
- /** Water heater / boiler with target temperature + operation mode +
7508
- * away mode (HA `water_heater.*`). `water-heater` cap — a
7509
- * climate-family actuator. */
7510
- DeviceType["WaterHeater"] = "water-heater";
7511
- /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
7512
- DeviceType["Fan"] = "fan";
7513
- /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
7514
- * the camera surface — those use `Camera`. `media-player` cap. */
7515
- DeviceType["MediaPlayer"] = "media-player";
7516
- /** Security panel / alarm system (HA `alarm_control_panel.*`).
7517
- * `alarm-panel` cap. */
7518
- DeviceType["AlarmPanel"] = "alarm-panel";
7519
- /** Generic user-settable input (HA `number` / `input_number` / `select`
7520
- * / `input_select` / `text` / `input_text` / `input_datetime`).
7521
- * Sub-type via `DeviceRole`: NumericControl / SelectControl /
7522
- * TextControl / DateTimeControl. */
7523
- DeviceType["Control"] = "control";
7524
- /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
7525
- * `presence` cap. */
7526
- DeviceType["Presence"] = "presence";
7527
- /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
7528
- * `weather` cap. */
7529
- DeviceType["Weather"] = "weather";
7530
- /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
7531
- DeviceType["Vacuum"] = "vacuum";
7532
- /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
7533
- * `lawn-mower-control` cap. */
7534
- DeviceType["LawnMower"] = "lawn-mower";
7535
- /** Physical HA device group parent container for entity-children
7536
- * adopted from a single HA device entry. Not renderable as a
7537
- * standalone device; exists only to anchor child entities. */
7538
- DeviceType["Container"] = "container";
7539
- /** Single still-image entity (HA `image.*`). Read-only display of an
7540
- * `entity_picture` signed URL the browser loads directly. `image` cap. */
7541
- DeviceType["Image"] = "image";
7542
- return DeviceType;
7543
- }({});
7544
- var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
7545
- DeviceFeature["BatteryOperated"] = "battery-operated";
7546
- DeviceFeature["Rebootable"] = "rebootable";
6936
+ /**
6937
+ * One-way migration from the legacy recording-config shape to the authoritative
6938
+ * mode-per-band model. Pure (no clock access).
6939
+ *
6940
+ * - If `config.bands` is present, it is authoritative and returned as-is.
6941
+ * - Otherwise the result is derived from the legacy fields: a disabled config or
6942
+ * `mode: 'off'` yields no bands; every legacy schedule maps to one band whose
6943
+ * mode is `continuous` when `config.mode === 'continuous'`, else `events`
6944
+ * (carrying `triggers`/`preBufferSec`/`postBufferSec`).
6945
+ */
6946
+ function migrateConfigToBands(config) {
6947
+ if (config.bands) return config.bands;
6948
+ if (!config.enabled || config.mode === "off") return [];
6949
+ const schedules = config.schedules ?? (config.schedule ? [config.schedule] : [{ kind: "always" }]);
6950
+ const bandMode = config.mode === "continuous" ? "continuous" : "events";
6951
+ return schedules.map((schedule) => bandFromSchedule(schedule, bandMode, config));
6952
+ }
6953
+ /**
6954
+ * `StorageLocationType` — an addon-declared id that identifies the *kind* of
6955
+ * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
6956
+ * so the persisted record schema and the consumer-facing cap can both consume it
6957
+ * without forming a circular import. The `storage` cap re-exports it
6958
+ * verbatim for back-compat.
6959
+ *
6960
+ * This Zod schema is the **authoritative source** for `StorageLocationType`.
6961
+ * The TS alias in `./storage.ts` re-exports `z.infer<typeof
6962
+ * StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
6963
+ * `IStorageProvider` interface stay in lockstep.
6964
+ *
6965
+ * The type is now an **open string** (not a closed enum) — addons declare
6966
+ * their own location kinds via `StorageLocationDeclaration.id`. The regex
6967
+ * enforces a safe id format: lowercase-start, alphanumeric + hyphens.
6968
+ */
6969
+ var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
6970
+ /**
6971
+ * Persisted record for a storage location instance. Operators can register
6972
+ * multiple instances for multi-cardinality types (e.g. two `backups`
6973
+ * locations with different `providerId`s). Cardinality is now declared per
6974
+ * location via `StorageLocationDeclaration.cardinality` — the static
6975
+ * `STORAGE_LOCATION_CARDINALITY` map has been removed.
6976
+ *
6977
+ * `id` is a stable namespaced string of the form `<type>:<slug>`.
6978
+ * The default location for a type uses `id === <type>:default` by
6979
+ * convention (the bare type ref like `'backups'` resolves to it).
6980
+ *
6981
+ * `isSystem: true` marks a location as orchestrator-seeded and
6982
+ * undeletable. The bootstrap-installed defaults (one per type) carry
6983
+ * this flag; operator-added locations don't. Editing the config of
6984
+ * a system location is allowed (path migration, provider swap) but
6985
+ * deleting it is rejected at the cap level.
6986
+ */
6987
+ var StorageLocationSchema = object({
6988
+ id: string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
6989
+ type: string(),
6990
+ displayName: string().min(1),
6991
+ providerId: string().min(1),
6992
+ config: record(string(), unknown()),
6993
+ /**
6994
+ * Cluster node this location physically lives on. REQUIRED for node-local
6995
+ * providers (filesystem — the path exists on one node's disk), null/absent
6996
+ * for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
6997
+ * `'hub'` is the hub node. Validated against the provider's `nodeLocal`
6998
+ * flag at upsert time, not here (the schema is provider-agnostic).
6999
+ */
7000
+ nodeId: string().optional(),
7001
+ isDefault: boolean().default(false),
7002
+ isSystem: boolean().default(false),
7003
+ createdAt: number(),
7004
+ updatedAt: number()
7005
+ });
7006
+ /**
7007
+ * Reference accepted by consumer-facing `api.storage.*` calls.
7008
+ * Either:
7009
+ * - a `StorageLocationType` (e.g. `'backups'`) → orchestrator resolves to the default of that type
7010
+ * - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
7011
+ *
7012
+ * The orchestrator's `resolveRef(ref)` handles both cases.
7013
+ */
7014
+ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
7015
+ /**
7016
+ * `StorageLocationDeclaration` a single storage-location entry declared by
7017
+ * an addon in its `package.json` under `camstack.storageLocations`.
7018
+ *
7019
+ * Design intent:
7020
+ * - **Addon declares its needs** — each addon describes the logical storage
7021
+ * slots it requires (e.g. `recordings`, `recordingsLow`) without caring
7022
+ * about the physical path.
7023
+ * - **Kernel aggregates** — at boot the kernel collects declarations from all
7024
+ * installed addons, deduplicates by `id`, and exposes the union via the
7025
+ * storage-locations settings surface.
7026
+ * - **Orchestrator seeds** — for every declared `id` the orchestrator ensures
7027
+ * at least one instance named `<id>:default` is present, using
7028
+ * `defaultsTo` to inherit the resolved root from another location when the
7029
+ * declaration is a derivative slot (e.g. `recordingsLow` defaults to
7030
+ * `recordings`).
7031
+ * - **ids are global** — `id` values are shared across the entire deployment;
7032
+ * two addons declaring the same `id` must agree on `cardinality` (validated
7033
+ * at kernel aggregation time, not here).
7034
+ */
7035
+ var StorageLocationDeclarationSchema = object({
7036
+ /**
7037
+ * Global location identifier, e.g. `recordings` or `recordingsLow`.
7038
+ * Must start with a lowercase letter and may contain letters, digits, and
7039
+ * hyphens.
7040
+ */
7041
+ id: string().regex(/^[a-z][a-zA-Z0-9-]*$/, { message: "id must start with a lowercase letter and contain only letters, digits, or hyphens" }),
7042
+ /** Human-readable name shown in the admin UI. */
7043
+ displayName: string().min(1, { message: "displayName must not be empty" }),
7044
+ /** Optional longer explanation of what data this location stores. */
7045
+ description: string().optional(),
7046
+ /**
7047
+ * `single` — exactly one instance of this location is allowed system-wide
7048
+ * (e.g. `logs`, `models`). The operator can edit it but not add more.
7049
+ * `multi` — the operator may register several instances (e.g. a second
7050
+ * `recordings` on a NAS for disk tiering); one is the default at any time.
7051
+ */
7052
+ cardinality: _enum(["single", "multi"]),
7053
+ /**
7054
+ * When set, the default instance for this location inherits its resolved
7055
+ * root from the named location's default instance. Useful for derivative
7056
+ * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
7057
+ * configure the primary location.
7058
+ */
7059
+ defaultsTo: string().optional()
7060
+ });
7061
+ var DecoderStatsSchema = object({
7062
+ inputFps: number(),
7063
+ outputFps: number(),
7064
+ avgDecodeTimeMs: number(),
7065
+ droppedFrames: number()
7066
+ });
7067
+ var DecoderSessionConfigSchema = object({
7068
+ codec: string(),
7069
+ maxFps: number().default(0),
7070
+ outputFormat: _enum([
7071
+ "jpeg",
7072
+ "rgb",
7073
+ "bgr",
7074
+ "yuv420",
7075
+ "gray"
7076
+ ]).default("jpeg"),
7077
+ scale: number().default(1),
7078
+ width: number().optional(),
7079
+ height: number().optional(),
7547
7080
  /**
7548
- * Device supports an on-demand re-sync of its derived spec with its
7549
- * upstream source drives the generic Re-sync button. The owning
7550
- * provider implements the action via the `device-adoption.resync` cap.
7081
+ * Identifier of the camera this decoder session serves. Optional
7082
+ * because the cap is generic (any caller could request decode), but
7083
+ * stream-broker passes it so decoder logs include `deviceId` for
7084
+ * per-camera filtering when diagnosing failures (e.g. node-av
7085
+ * sendPacket errors on a single hung camera).
7551
7086
  */
7552
- DeviceFeature["Resyncable"] = "resyncable";
7553
- DeviceFeature["NativeSnapshot"] = "native-snapshot";
7554
- DeviceFeature["DoorbellButton"] = "doorbell-button";
7555
- DeviceFeature["TwoWayAudio"] = "two-way-audio";
7556
- DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
7087
+ deviceId: number().int().nonnegative().optional(),
7557
7088
  /**
7558
- * Camera supports the on-firmware autotrack subsystem (subject-
7559
- * following). Distinct from `PanTiltZoom` because not every PTZ
7560
- * camera ships autotrack the admin UI uses this flag to gate
7561
- * the autotrack toggle / settings card without re-deriving from
7562
- * the cap registry. Mirrors `ptz-autotrack` cap registration:
7563
- * driver sets this feature when probe confirms the firmware
7564
- * surface, and registers the cap in the same code path.
7089
+ * Free-form tag for log scoping. Stream-broker uses
7090
+ * `broker:<deviceId>/<profile>`. Decoder session logger surfaces it
7091
+ * on every line so `grep tag=broker:5/high` filters one camera
7092
+ * profile cleanly.
7565
7093
  */
7566
- DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
7094
+ tag: string().optional(),
7567
7095
  /**
7568
- * Accessory exposes a "trigger on motion" toggle the parent camera's
7569
- * motion detection automatically activates this device. Mirrors
7570
- * `motion-trigger` cap registration: drivers set this feature in the
7571
- * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
7096
+ * Where the session delivers decoded frames (Phase 5 / D9):
7572
7097
  *
7573
- * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
7574
- * fast scalar without binding fetch), notifier rules, and `listAll`
7575
- * filters that want "all devices with on-motion behaviour".
7098
+ * - `'callback'` (default) the legacy pixel path: decoded frames are
7099
+ * buffered as `DecodedFrame`s and drained via `pullFrames`.
7100
+ * - `'shm'` the shared-memory frame plane: decoded frames are written
7101
+ * into an OS shared-memory ring and drained as zero-pixel
7102
+ * `FrameHandle`s via `pullHandles`. A session is one mode or the
7103
+ * other — `pullFrames` returns nothing for an `'shm'` session and
7104
+ * `pullHandles` returns nothing for a `'callback'` session.
7576
7105
  */
7577
- DeviceFeature["MotionTrigger"] = "motion-trigger";
7578
- /** Light supports rgb-triplet color via `color` cap. */
7579
- DeviceFeature["LightColorRgb"] = "light-color-rgb";
7580
- /** Light supports HSV color via `color` cap. */
7581
- DeviceFeature["LightColorHsv"] = "light-color-hsv";
7582
- /** Light supports color-temperature (mired) via `color` cap. */
7583
- DeviceFeature["LightColorMired"] = "light-color-mired";
7584
- /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
7585
- * targetHigh). Gates the range slider UI. */
7586
- DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
7587
- /** Thermostat exposes target humidity and/or current humidity
7588
- * readings. Gates the humidity controls. */
7589
- DeviceFeature["ClimateHumidity"] = "climate-humidity";
7590
- /** Thermostat exposes a fan-mode selector. */
7591
- DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
7592
- /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
7593
- DeviceFeature["ClimatePreset"] = "climate-preset";
7594
- /** Cover exposes intermediate position control (0..100). Gates the
7595
- * position slider UI. */
7596
- DeviceFeature["CoverPositionable"] = "cover-positionable";
7597
- /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
7598
- DeviceFeature["CoverTilt"] = "cover-tilt";
7599
- /** Valve exposes intermediate position control (0..100). Gates the
7600
- * position slider / drag surface UI. */
7601
- DeviceFeature["ValvePositionable"] = "valve-positionable";
7602
- /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
7603
- DeviceFeature["FanSpeed"] = "fan-speed";
7604
- /** Fan exposes a preset mode selector. */
7605
- DeviceFeature["FanPreset"] = "fan-preset";
7606
- /** Fan exposes blade direction (forward/reverse) — typical of
7607
- * ceiling fans. */
7608
- DeviceFeature["FanDirection"] = "fan-direction";
7609
- /** Fan exposes an oscillation toggle. */
7610
- DeviceFeature["FanOscillating"] = "fan-oscillating";
7611
- /** Lock requires a PIN code on lock/unlock. Gates the code-entry
7612
- * field on the UI lock-controls panel. */
7613
- DeviceFeature["LockPinRequired"] = "lock-pin-required";
7614
- /** Lock supports a latch-release ("open door") action distinct from
7615
- * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
7616
- * `supported_features`. Gates the Open Door button in the UI. */
7617
- DeviceFeature["LockOpen"] = "lock-open";
7618
- /** Media player exposes a seek-to-position surface. */
7619
- DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
7620
- /** Media player exposes a volume-level setter. */
7621
- DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
7622
- /** Media player exposes a mute toggle distinct from volume=0. */
7623
- DeviceFeature["MediaPlayerMute"] = "media-player-mute";
7624
- /** Media player exposes a shuffle toggle. */
7625
- DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
7626
- /** Media player exposes a repeat mode (off / all / one). */
7627
- DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
7628
- /** Media player exposes a source / input selector. */
7629
- DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
7630
- /** Media player exposes a play-arbitrary-media surface (URL / id). */
7631
- DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
7632
- /** Media player exposes next-track. */
7633
- DeviceFeature["MediaPlayerNext"] = "media-player-next";
7634
- /** Media player exposes previous-track. */
7635
- DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
7636
- /** Media player exposes stop distinct from pause. */
7637
- DeviceFeature["MediaPlayerStop"] = "media-player-stop";
7638
- /** Alarm panel requires a PIN code on arm/disarm. */
7639
- DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
7640
- /** Presence device carries GPS coordinates (lat/lng/accuracy) in
7641
- * addition to a textual location. */
7642
- DeviceFeature["PresenceGps"] = "presence-gps";
7643
- /** Notifier accepts an inline / URL image attachment. */
7644
- DeviceFeature["NotifierImage"] = "notifier-image";
7645
- /** Notifier accepts a priority hint (high/normal/low). */
7646
- DeviceFeature["NotifierPriority"] = "notifier-priority";
7647
- /** Notifier accepts a free-form `data` payload for platform-specific
7648
- * fields. */
7649
- DeviceFeature["NotifierData"] = "notifier-data";
7650
- /** Notifier supports interactive action buttons / callbacks. */
7651
- DeviceFeature["NotifierActions"] = "notifier-actions";
7652
- /** Notifier supports per-call recipient targeting (multi-user). */
7653
- DeviceFeature["NotifierRecipients"] = "notifier-recipients";
7654
- /** Script runner accepts a variables map on each run invocation. */
7655
- DeviceFeature["ScriptVariables"] = "script-variables";
7656
- /** Automation `trigger` accepts a skipCondition flag — fires the
7657
- * automation's actions while bypassing its condition block. */
7658
- DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
7659
- return DeviceFeature;
7660
- }({});
7661
- /**
7662
- * Semantic role a device plays within its parent. Populated by driver
7663
- * addons when creating accessory devices (Reolink siren/floodlight/
7664
- * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
7665
- * admin UI to pick icons, labels, and widgets — a `Switch` with
7666
- * `role: Floodlight` renders as a bulb with a brightness slider,
7667
- * whereas a `Switch` with `role: Siren` renders as a klaxon.
7668
- *
7669
- * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
7670
- * sqlite as a nullable TEXT column — old rows keep working unchanged.
7671
- */
7672
- var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7673
- DeviceRole["Siren"] = "siren";
7674
- DeviceRole["Floodlight"] = "floodlight";
7675
- DeviceRole["Spotlight"] = "spotlight";
7676
- DeviceRole["PirSensor"] = "pir-sensor";
7677
- DeviceRole["Chime"] = "chime";
7678
- DeviceRole["Autotrack"] = "autotrack";
7679
- DeviceRole["Nightvision"] = "nightvision";
7680
- DeviceRole["PrivacyMask"] = "privacy-mask";
7681
- DeviceRole["Doorbell"] = "doorbell";
7682
- /** Virtual HA toggle (input_boolean.*) — distinguishable from a
7683
- * real Switch device for UI rendering / export adapters. */
7684
- DeviceRole["BinaryHelper"] = "binary-helper";
7685
- /** Generic motion / occupancy / moving event source. Distinct from
7686
- * the camera accessory PirSensor role: that one is a camera child;
7687
- * this is a standalone HA / 3rd-party motion sensor. */
7688
- DeviceRole["MotionSensor"] = "motion-sensor";
7689
- DeviceRole["ContactSensor"] = "contact-sensor";
7690
- DeviceRole["LeakSensor"] = "leak-sensor";
7691
- DeviceRole["SmokeSensor"] = "smoke-sensor";
7692
- DeviceRole["COSensor"] = "co-sensor";
7693
- DeviceRole["GasSensor"] = "gas-sensor";
7694
- DeviceRole["TamperSensor"] = "tamper-sensor";
7695
- DeviceRole["VibrationSensor"] = "vibration-sensor";
7696
- DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
7697
- DeviceRole["SoundSensor"] = "sound-sensor";
7698
- /** Fallback for `binary_sensor` without a known `device_class`. */
7699
- DeviceRole["BinarySensor"] = "binary-sensor";
7700
- DeviceRole["TemperatureSensor"] = "temperature-sensor";
7701
- DeviceRole["HumiditySensor"] = "humidity-sensor";
7702
- DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
7703
- DeviceRole["PressureSensor"] = "pressure-sensor";
7704
- DeviceRole["PowerSensor"] = "power-sensor";
7705
- DeviceRole["EnergySensor"] = "energy-sensor";
7706
- DeviceRole["VoltageSensor"] = "voltage-sensor";
7707
- DeviceRole["CurrentSensor"] = "current-sensor";
7708
- DeviceRole["AirQualitySensor"] = "air-quality-sensor";
7709
- /** Battery level (numeric % via `sensor` OR low-bool via
7710
- * `binary_sensor` — the cap distinguishes via the value type). */
7711
- DeviceRole["BatterySensor"] = "battery-sensor";
7712
- /** Fallback for `sensor` numeric without a known `device_class`. */
7713
- DeviceRole["NumericSensor"] = "numeric-sensor";
7714
- /** String / enum state (HA `sensor` with `state_class: enum` or
7715
- * `attributes.options`). */
7716
- DeviceRole["EnumSensor"] = "enum-sensor";
7717
- /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
7718
- * or `date`). The slice carries the raw ISO string verbatim (hosted on
7719
- * the `enum-sensor` cap); the UI renders it locale-formatted. */
7720
- DeviceRole["DateTimeSensor"] = "datetime-sensor";
7721
- /** Last-resort fallback when nothing else matches. */
7722
- DeviceRole["GenericSensor"] = "generic-sensor";
7723
- DeviceRole["NumericControl"] = "numeric-control";
7724
- DeviceRole["SelectControl"] = "select-control";
7725
- DeviceRole["TextControl"] = "text-control";
7726
- DeviceRole["DateTimeControl"] = "datetime-control";
7727
- /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
7728
- * rich features (image, priority, channel routing). */
7729
- DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
7730
- /** Chat / messaging service (HA `notify.telegram_*`,
7731
- * `notify.discord_*`, etc.). */
7732
- DeviceRole["MessagingNotifier"] = "messaging-notifier";
7733
- /** Email-based delivery (HA `notify.smtp`, etc.). */
7734
- DeviceRole["EmailNotifier"] = "email-notifier";
7735
- /** Fallback when the notifier service name doesn't match a known
7736
- * pattern. */
7737
- DeviceRole["GenericNotifier"] = "generic-notifier";
7738
- return DeviceRole;
7739
- }({});
7106
+ frameSink: _enum(["callback", "shm"]).default("callback")
7107
+ });
7108
+ var EncodeProfileSchema = object({
7109
+ video: object({
7110
+ codec: _enum([
7111
+ "h264",
7112
+ "h265",
7113
+ "copy"
7114
+ ]),
7115
+ profile: _enum([
7116
+ "baseline",
7117
+ "main",
7118
+ "high"
7119
+ ]).optional(),
7120
+ width: number().int().positive().optional(),
7121
+ height: number().int().positive().optional(),
7122
+ fps: number().positive().optional(),
7123
+ bitrateKbps: number().int().positive().optional(),
7124
+ gopFrames: number().int().positive().optional(),
7125
+ bf: number().int().min(0).optional(),
7126
+ preset: _enum([
7127
+ "ultrafast",
7128
+ "superfast",
7129
+ "veryfast",
7130
+ "faster",
7131
+ "fast",
7132
+ "medium"
7133
+ ]).optional(),
7134
+ tune: _enum([
7135
+ "zerolatency",
7136
+ "film",
7137
+ "animation"
7138
+ ]).optional()
7139
+ }),
7140
+ audio: union([literal("passthrough"), object({
7141
+ codec: _enum([
7142
+ "opus",
7143
+ "aac",
7144
+ "pcmu",
7145
+ "pcma",
7146
+ "copy"
7147
+ ]),
7148
+ bitrateKbps: number().int().positive().optional(),
7149
+ sampleRateHz: number().int().positive().optional(),
7150
+ channels: union([literal(1), literal(2)]).optional()
7151
+ })]),
7152
+ /**
7153
+ * ffmpeg input-side args, inserted between the fixed global flags
7154
+ * (`-hide_banner -loglevel error`) and `-i pipe:0`. Free-text array
7155
+ * the widget surfaces a textarea + suggestion chips for the most-
7156
+ * used demuxer/format options.
7157
+ */
7158
+ inputArgs: array(string()).optional(),
7159
+ /**
7160
+ * ffmpeg output-side args, inserted between the encode block and
7161
+ * the final `-f <muxer> pipe:1`. Use for muxer options, bitstream
7162
+ * filters, codec-specific overrides. Free-text array.
7163
+ */
7164
+ outputArgs: array(string()).optional()
7165
+ });
7166
+ var HF_BASE_URL = `https://huggingface.co/camstack/camstack-models/resolve/main`;
7167
+ function hfModelUrl(repo, path) {
7168
+ return `https://huggingface.co/${repo}/resolve/main/${path}`;
7169
+ }
7170
+ var COCO_80_LABELS = [
7171
+ {
7172
+ id: "person",
7173
+ name: "Person"
7174
+ },
7175
+ {
7176
+ id: "bicycle",
7177
+ name: "Bicycle"
7178
+ },
7179
+ {
7180
+ id: "car",
7181
+ name: "Car"
7182
+ },
7183
+ {
7184
+ id: "motorcycle",
7185
+ name: "Motorcycle"
7186
+ },
7187
+ {
7188
+ id: "airplane",
7189
+ name: "Airplane"
7190
+ },
7191
+ {
7192
+ id: "bus",
7193
+ name: "Bus"
7194
+ },
7195
+ {
7196
+ id: "train",
7197
+ name: "Train"
7198
+ },
7199
+ {
7200
+ id: "truck",
7201
+ name: "Truck"
7202
+ },
7203
+ {
7204
+ id: "boat",
7205
+ name: "Boat"
7206
+ },
7207
+ {
7208
+ id: "traffic light",
7209
+ name: "Traffic Light"
7210
+ },
7211
+ {
7212
+ id: "fire hydrant",
7213
+ name: "Fire Hydrant"
7214
+ },
7215
+ {
7216
+ id: "stop sign",
7217
+ name: "Stop Sign"
7218
+ },
7219
+ {
7220
+ id: "parking meter",
7221
+ name: "Parking Meter"
7222
+ },
7223
+ {
7224
+ id: "bench",
7225
+ name: "Bench"
7226
+ },
7227
+ {
7228
+ id: "bird",
7229
+ name: "Bird"
7230
+ },
7231
+ {
7232
+ id: "cat",
7233
+ name: "Cat"
7234
+ },
7235
+ {
7236
+ id: "dog",
7237
+ name: "Dog"
7238
+ },
7239
+ {
7240
+ id: "horse",
7241
+ name: "Horse"
7242
+ },
7243
+ {
7244
+ id: "sheep",
7245
+ name: "Sheep"
7246
+ },
7247
+ {
7248
+ id: "cow",
7249
+ name: "Cow"
7250
+ },
7251
+ {
7252
+ id: "elephant",
7253
+ name: "Elephant"
7254
+ },
7255
+ {
7256
+ id: "bear",
7257
+ name: "Bear"
7258
+ },
7259
+ {
7260
+ id: "zebra",
7261
+ name: "Zebra"
7262
+ },
7263
+ {
7264
+ id: "giraffe",
7265
+ name: "Giraffe"
7266
+ },
7267
+ {
7268
+ id: "backpack",
7269
+ name: "Backpack"
7270
+ },
7271
+ {
7272
+ id: "umbrella",
7273
+ name: "Umbrella"
7274
+ },
7275
+ {
7276
+ id: "handbag",
7277
+ name: "Handbag"
7278
+ },
7279
+ {
7280
+ id: "tie",
7281
+ name: "Tie"
7282
+ },
7283
+ {
7284
+ id: "suitcase",
7285
+ name: "Suitcase"
7286
+ },
7287
+ {
7288
+ id: "frisbee",
7289
+ name: "Frisbee"
7290
+ },
7291
+ {
7292
+ id: "skis",
7293
+ name: "Skis"
7294
+ },
7295
+ {
7296
+ id: "snowboard",
7297
+ name: "Snowboard"
7298
+ },
7299
+ {
7300
+ id: "sports ball",
7301
+ name: "Sports Ball"
7302
+ },
7303
+ {
7304
+ id: "kite",
7305
+ name: "Kite"
7306
+ },
7307
+ {
7308
+ id: "baseball bat",
7309
+ name: "Baseball Bat"
7310
+ },
7311
+ {
7312
+ id: "baseball glove",
7313
+ name: "Baseball Glove"
7314
+ },
7315
+ {
7316
+ id: "skateboard",
7317
+ name: "Skateboard"
7318
+ },
7319
+ {
7320
+ id: "surfboard",
7321
+ name: "Surfboard"
7322
+ },
7323
+ {
7324
+ id: "tennis racket",
7325
+ name: "Tennis Racket"
7326
+ },
7327
+ {
7328
+ id: "bottle",
7329
+ name: "Bottle"
7330
+ },
7331
+ {
7332
+ id: "wine glass",
7333
+ name: "Wine Glass"
7334
+ },
7335
+ {
7336
+ id: "cup",
7337
+ name: "Cup"
7338
+ },
7339
+ {
7340
+ id: "fork",
7341
+ name: "Fork"
7342
+ },
7343
+ {
7344
+ id: "knife",
7345
+ name: "Knife"
7346
+ },
7347
+ {
7348
+ id: "spoon",
7349
+ name: "Spoon"
7350
+ },
7351
+ {
7352
+ id: "bowl",
7353
+ name: "Bowl"
7354
+ },
7355
+ {
7356
+ id: "banana",
7357
+ name: "Banana"
7358
+ },
7359
+ {
7360
+ id: "apple",
7361
+ name: "Apple"
7362
+ },
7363
+ {
7364
+ id: "sandwich",
7365
+ name: "Sandwich"
7366
+ },
7367
+ {
7368
+ id: "orange",
7369
+ name: "Orange"
7370
+ },
7371
+ {
7372
+ id: "broccoli",
7373
+ name: "Broccoli"
7374
+ },
7375
+ {
7376
+ id: "carrot",
7377
+ name: "Carrot"
7378
+ },
7379
+ {
7380
+ id: "hot dog",
7381
+ name: "Hot Dog"
7382
+ },
7383
+ {
7384
+ id: "pizza",
7385
+ name: "Pizza"
7386
+ },
7387
+ {
7388
+ id: "donut",
7389
+ name: "Donut"
7390
+ },
7391
+ {
7392
+ id: "cake",
7393
+ name: "Cake"
7394
+ },
7395
+ {
7396
+ id: "chair",
7397
+ name: "Chair"
7398
+ },
7399
+ {
7400
+ id: "couch",
7401
+ name: "Couch"
7402
+ },
7403
+ {
7404
+ id: "potted plant",
7405
+ name: "Potted Plant"
7406
+ },
7407
+ {
7408
+ id: "bed",
7409
+ name: "Bed"
7410
+ },
7411
+ {
7412
+ id: "dining table",
7413
+ name: "Dining Table"
7414
+ },
7415
+ {
7416
+ id: "toilet",
7417
+ name: "Toilet"
7418
+ },
7419
+ {
7420
+ id: "tv",
7421
+ name: "TV"
7422
+ },
7423
+ {
7424
+ id: "laptop",
7425
+ name: "Laptop"
7426
+ },
7427
+ {
7428
+ id: "mouse",
7429
+ name: "Mouse"
7430
+ },
7431
+ {
7432
+ id: "remote",
7433
+ name: "Remote"
7434
+ },
7435
+ {
7436
+ id: "keyboard",
7437
+ name: "Keyboard"
7438
+ },
7439
+ {
7440
+ id: "cell phone",
7441
+ name: "Cell Phone"
7442
+ },
7443
+ {
7444
+ id: "microwave",
7445
+ name: "Microwave"
7446
+ },
7447
+ {
7448
+ id: "oven",
7449
+ name: "Oven"
7450
+ },
7451
+ {
7452
+ id: "toaster",
7453
+ name: "Toaster"
7454
+ },
7455
+ {
7456
+ id: "sink",
7457
+ name: "Sink"
7458
+ },
7459
+ {
7460
+ id: "refrigerator",
7461
+ name: "Refrigerator"
7462
+ },
7463
+ {
7464
+ id: "book",
7465
+ name: "Book"
7466
+ },
7467
+ {
7468
+ id: "clock",
7469
+ name: "Clock"
7470
+ },
7471
+ {
7472
+ id: "vase",
7473
+ name: "Vase"
7474
+ },
7475
+ {
7476
+ id: "scissors",
7477
+ name: "Scissors"
7478
+ },
7479
+ {
7480
+ id: "teddy bear",
7481
+ name: "Teddy Bear"
7482
+ },
7483
+ {
7484
+ id: "hair drier",
7485
+ name: "Hair Drier"
7486
+ },
7487
+ {
7488
+ id: "toothbrush",
7489
+ name: "Toothbrush"
7490
+ }
7491
+ ];
7492
+ var COCO_TO_MACRO = {
7493
+ mapping: {
7494
+ person: "person",
7495
+ bicycle: "vehicle",
7496
+ car: "vehicle",
7497
+ motorcycle: "vehicle",
7498
+ airplane: "vehicle",
7499
+ bus: "vehicle",
7500
+ train: "vehicle",
7501
+ truck: "vehicle",
7502
+ boat: "vehicle",
7503
+ bird: "animal",
7504
+ cat: "animal",
7505
+ dog: "animal",
7506
+ horse: "animal",
7507
+ sheep: "animal",
7508
+ cow: "animal",
7509
+ elephant: "animal",
7510
+ bear: "animal",
7511
+ zebra: "animal",
7512
+ giraffe: "animal"
7513
+ },
7514
+ preserveOriginal: false
7515
+ };
7516
+ var AUDIO_MACRO_LABELS = [
7517
+ {
7518
+ id: "speech",
7519
+ name: "Speech",
7520
+ icon: "🗣️"
7521
+ },
7522
+ {
7523
+ id: "scream",
7524
+ name: "Scream / Shout",
7525
+ icon: "😱"
7526
+ },
7527
+ {
7528
+ id: "crying",
7529
+ name: "Crying / Baby",
7530
+ icon: "😢"
7531
+ },
7532
+ {
7533
+ id: "laughter",
7534
+ name: "Laughter",
7535
+ icon: "😂"
7536
+ },
7537
+ {
7538
+ id: "music",
7539
+ name: "Music",
7540
+ icon: "🎵"
7541
+ },
7542
+ {
7543
+ id: "dog",
7544
+ name: "Dog",
7545
+ icon: "🐕"
7546
+ },
7547
+ {
7548
+ id: "cat",
7549
+ name: "Cat",
7550
+ icon: "🐈"
7551
+ },
7552
+ {
7553
+ id: "bird",
7554
+ name: "Bird",
7555
+ icon: "🐦"
7556
+ },
7557
+ {
7558
+ id: "animal",
7559
+ name: "Animal (other)",
7560
+ icon: "🐾"
7561
+ },
7562
+ {
7563
+ id: "alarm",
7564
+ name: "Alarm / Siren",
7565
+ icon: "🚨"
7566
+ },
7567
+ {
7568
+ id: "doorbell",
7569
+ name: "Doorbell / Knock",
7570
+ icon: "🔔"
7571
+ },
7572
+ {
7573
+ id: "glass_breaking",
7574
+ name: "Glass Breaking",
7575
+ icon: "💥"
7576
+ },
7577
+ {
7578
+ id: "gunshot",
7579
+ name: "Gunshot / Explosion",
7580
+ icon: "💣"
7581
+ },
7582
+ {
7583
+ id: "vehicle",
7584
+ name: "Vehicle",
7585
+ icon: "🚗"
7586
+ },
7587
+ {
7588
+ id: "siren",
7589
+ name: "Emergency Siren",
7590
+ icon: "🚑"
7591
+ },
7592
+ {
7593
+ id: "fire",
7594
+ name: "Fire / Smoke",
7595
+ icon: "🔥"
7596
+ },
7597
+ {
7598
+ id: "water",
7599
+ name: "Water",
7600
+ icon: "💧"
7601
+ },
7602
+ {
7603
+ id: "wind",
7604
+ name: "Wind / Weather",
7605
+ icon: "🌬️"
7606
+ },
7607
+ {
7608
+ id: "door",
7609
+ name: "Door",
7610
+ icon: "🚪"
7611
+ },
7612
+ {
7613
+ id: "footsteps",
7614
+ name: "Footsteps",
7615
+ icon: "👣"
7616
+ },
7617
+ {
7618
+ id: "crowd",
7619
+ name: "Crowd / Chatter",
7620
+ icon: "👥"
7621
+ },
7622
+ {
7623
+ id: "telephone",
7624
+ name: "Telephone",
7625
+ icon: "📞"
7626
+ },
7627
+ {
7628
+ id: "engine",
7629
+ name: "Engine / Motor",
7630
+ icon: "⚙️"
7631
+ },
7632
+ {
7633
+ id: "tools",
7634
+ name: "Tools / Construction",
7635
+ icon: "🔨"
7636
+ },
7637
+ {
7638
+ id: "silence",
7639
+ name: "Silence",
7640
+ icon: "🤫"
7641
+ }
7642
+ ];
7643
+ var YAMNET_TO_MACRO = {
7644
+ mapping: {
7645
+ Speech: "speech",
7646
+ "Child speech, kid speaking": "speech",
7647
+ Conversation: "speech",
7648
+ "Narration, monologue": "speech",
7649
+ Babbling: "speech",
7650
+ Whispering: "speech",
7651
+ "Speech synthesizer": "speech",
7652
+ Humming: "speech",
7653
+ Rapping: "speech",
7654
+ Singing: "speech",
7655
+ Choir: "speech",
7656
+ "Child singing": "speech",
7657
+ Shout: "scream",
7658
+ Bellow: "scream",
7659
+ Yell: "scream",
7660
+ Screaming: "scream",
7661
+ "Children shouting": "scream",
7662
+ Whoop: "scream",
7663
+ "Crying, sobbing": "crying",
7664
+ "Baby cry, infant cry": "crying",
7665
+ Whimper: "crying",
7666
+ "Wail, moan": "crying",
7667
+ Groan: "crying",
7668
+ Laughter: "laughter",
7669
+ "Baby laughter": "laughter",
7670
+ Giggle: "laughter",
7671
+ Snicker: "laughter",
7672
+ "Belly laugh": "laughter",
7673
+ "Chuckle, chortle": "laughter",
7674
+ Music: "music",
7675
+ "Musical instrument": "music",
7676
+ Guitar: "music",
7677
+ Piano: "music",
7678
+ Drum: "music",
7679
+ "Drum kit": "music",
7680
+ "Violin, fiddle": "music",
7681
+ Flute: "music",
7682
+ Saxophone: "music",
7683
+ Trumpet: "music",
7684
+ Synthesizer: "music",
7685
+ "Pop music": "music",
7686
+ "Rock music": "music",
7687
+ "Hip hop music": "music",
7688
+ "Classical music": "music",
7689
+ Jazz: "music",
7690
+ "Electronic music": "music",
7691
+ "Background music": "music",
7692
+ Dog: "dog",
7693
+ Bark: "dog",
7694
+ Yip: "dog",
7695
+ Howl: "dog",
7696
+ "Bow-wow": "dog",
7697
+ Growling: "dog",
7698
+ "Whimper (dog)": "dog",
7699
+ Cat: "cat",
7700
+ Purr: "cat",
7701
+ Meow: "cat",
7702
+ Hiss: "cat",
7703
+ Caterwaul: "cat",
7704
+ Bird: "bird",
7705
+ "Bird vocalization, bird call, bird song": "bird",
7706
+ "Chirp, tweet": "bird",
7707
+ Squawk: "bird",
7708
+ Crow: "bird",
7709
+ Owl: "bird",
7710
+ "Pigeon, dove": "bird",
7711
+ Animal: "animal",
7712
+ "Domestic animals, pets": "animal",
7713
+ "Livestock, farm animals, working animals": "animal",
7714
+ Horse: "animal",
7715
+ "Cattle, bovinae": "animal",
7716
+ Pig: "animal",
7717
+ Sheep: "animal",
7718
+ Goat: "animal",
7719
+ Frog: "animal",
7720
+ Insect: "animal",
7721
+ Cricket: "animal",
7722
+ Alarm: "alarm",
7723
+ "Alarm clock": "alarm",
7724
+ "Smoke detector, smoke alarm": "alarm",
7725
+ "Fire alarm": "alarm",
7726
+ Buzzer: "alarm",
7727
+ "Civil defense siren": "alarm",
7728
+ "Car alarm": "alarm",
7729
+ Siren: "siren",
7730
+ "Police car (siren)": "siren",
7731
+ "Ambulance (siren)": "siren",
7732
+ "Fire engine, fire truck (siren)": "siren",
7733
+ "Emergency vehicle": "siren",
7734
+ Foghorn: "siren",
7735
+ Doorbell: "doorbell",
7736
+ "Ding-dong": "doorbell",
7737
+ Knock: "doorbell",
7738
+ Tap: "doorbell",
7739
+ Glass: "glass_breaking",
7740
+ Shatter: "glass_breaking",
7741
+ "Chink, clink": "glass_breaking",
7742
+ "Gunshot, gunfire": "gunshot",
7743
+ "Machine gun": "gunshot",
7744
+ Explosion: "gunshot",
7745
+ Fireworks: "gunshot",
7746
+ Firecracker: "gunshot",
7747
+ "Artillery fire": "gunshot",
7748
+ "Cap gun": "gunshot",
7749
+ Boom: "gunshot",
7750
+ Vehicle: "vehicle",
7751
+ Car: "vehicle",
7752
+ Truck: "vehicle",
7753
+ Bus: "vehicle",
7754
+ Motorcycle: "vehicle",
7755
+ "Car passing by": "vehicle",
7756
+ "Vehicle horn, car horn, honking": "vehicle",
7757
+ "Traffic noise, roadway noise": "vehicle",
7758
+ Train: "vehicle",
7759
+ Aircraft: "vehicle",
7760
+ Helicopter: "vehicle",
7761
+ Bicycle: "vehicle",
7762
+ Skateboard: "vehicle",
7763
+ Fire: "fire",
7764
+ Crackle: "fire",
7765
+ Water: "water",
7766
+ Rain: "water",
7767
+ Raindrop: "water",
7768
+ "Rain on surface": "water",
7769
+ Stream: "water",
7770
+ Waterfall: "water",
7771
+ Ocean: "water",
7772
+ "Waves, surf": "water",
7773
+ "Splash, splatter": "water",
7774
+ Wind: "wind",
7775
+ Thunderstorm: "wind",
7776
+ Thunder: "wind",
7777
+ "Wind noise (microphone)": "wind",
7778
+ "Rustling leaves": "wind",
7779
+ Door: "door",
7780
+ "Sliding door": "door",
7781
+ Slam: "door",
7782
+ "Cupboard open or close": "door",
7783
+ "Walk, footsteps": "footsteps",
7784
+ Run: "footsteps",
7785
+ Shuffle: "footsteps",
7786
+ Crowd: "crowd",
7787
+ Chatter: "crowd",
7788
+ Cheering: "crowd",
7789
+ Applause: "crowd",
7790
+ "Children playing": "crowd",
7791
+ "Hubbub, speech noise, speech babble": "crowd",
7792
+ Telephone: "telephone",
7793
+ "Telephone bell ringing": "telephone",
7794
+ Ringtone: "telephone",
7795
+ "Telephone dialing, DTMF": "telephone",
7796
+ "Busy signal": "telephone",
7797
+ Engine: "engine",
7798
+ "Engine starting": "engine",
7799
+ Idling: "engine",
7800
+ "Accelerating, revving, vroom": "engine",
7801
+ "Light engine (high frequency)": "engine",
7802
+ "Medium engine (mid frequency)": "engine",
7803
+ "Heavy engine (low frequency)": "engine",
7804
+ "Lawn mower": "engine",
7805
+ Chainsaw: "engine",
7806
+ Hammer: "tools",
7807
+ Jackhammer: "tools",
7808
+ Sawing: "tools",
7809
+ "Power tool": "tools",
7810
+ Drill: "tools",
7811
+ Sanding: "tools",
7812
+ Silence: "silence"
7813
+ },
7814
+ preserveOriginal: false
7815
+ };
7816
+ var APPLE_SA_TO_MACRO = {
7817
+ mapping: {
7818
+ speech: "speech",
7819
+ child_speech: "speech",
7820
+ conversation: "speech",
7821
+ whispering: "speech",
7822
+ singing: "speech",
7823
+ humming: "speech",
7824
+ shout: "scream",
7825
+ yell: "scream",
7826
+ screaming: "scream",
7827
+ crying: "crying",
7828
+ baby_crying: "crying",
7829
+ sobbing: "crying",
7830
+ laughter: "laughter",
7831
+ baby_laughter: "laughter",
7832
+ giggling: "laughter",
7833
+ music: "music",
7834
+ guitar: "music",
7835
+ piano: "music",
7836
+ drums: "music",
7837
+ dog_bark: "dog",
7838
+ dog_bow_wow: "dog",
7839
+ dog_growling: "dog",
7840
+ dog_howl: "dog",
7841
+ cat_meow: "cat",
7842
+ cat_purr: "cat",
7843
+ cat_hiss: "cat",
7844
+ bird: "bird",
7845
+ bird_chirp: "bird",
7846
+ bird_squawk: "bird",
7847
+ animal: "animal",
7848
+ horse: "animal",
7849
+ cow_moo: "animal",
7850
+ insect: "animal",
7851
+ alarm: "alarm",
7852
+ smoke_alarm: "alarm",
7853
+ fire_alarm: "alarm",
7854
+ car_alarm: "alarm",
7855
+ siren: "siren",
7856
+ police_siren: "siren",
7857
+ ambulance_siren: "siren",
7858
+ doorbell: "doorbell",
7859
+ door_knock: "doorbell",
7860
+ knocking: "doorbell",
7861
+ glass_breaking: "glass_breaking",
7862
+ glass_shatter: "glass_breaking",
7863
+ gunshot: "gunshot",
7864
+ explosion: "gunshot",
7865
+ fireworks: "gunshot",
7866
+ car: "vehicle",
7867
+ truck: "vehicle",
7868
+ motorcycle: "vehicle",
7869
+ car_horn: "vehicle",
7870
+ vehicle_horn: "vehicle",
7871
+ traffic: "vehicle",
7872
+ fire: "fire",
7873
+ fire_crackle: "fire",
7874
+ water: "water",
7875
+ rain: "water",
7876
+ ocean: "water",
7877
+ splash: "water",
7878
+ wind: "wind",
7879
+ thunder: "wind",
7880
+ thunderstorm: "wind",
7881
+ door: "door",
7882
+ door_slam: "door",
7883
+ sliding_door: "door",
7884
+ footsteps: "footsteps",
7885
+ walking: "footsteps",
7886
+ running: "footsteps",
7887
+ crowd: "crowd",
7888
+ chatter: "crowd",
7889
+ cheering: "crowd",
7890
+ applause: "crowd",
7891
+ telephone_ring: "telephone",
7892
+ ringtone: "telephone",
7893
+ engine: "engine",
7894
+ engine_starting: "engine",
7895
+ lawn_mower: "engine",
7896
+ chainsaw: "engine",
7897
+ hammer: "tools",
7898
+ jackhammer: "tools",
7899
+ drill: "tools",
7900
+ power_tool: "tools",
7901
+ silence: "silence"
7902
+ },
7903
+ preserveOriginal: false
7904
+ };
7905
+ var _macroLookup = /* @__PURE__ */ new Map();
7906
+ for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7907
+ for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7908
+ /** Map a raw audio label (YAMNet or Apple SoundAnalysis) to its macro class. Returns null if unmapped. */
7909
+ function mapAudioLabelToMacro(label) {
7910
+ return _macroLookup.get(label.toLowerCase()) ?? null;
7911
+ }
7740
7912
  /**
7741
7913
  * Accessory device helpers — shared across drivers.
7742
7914
  *
@@ -7896,78 +8068,6 @@ object({
7896
8068
  });
7897
8069
  DeviceType.Sensor;
7898
8070
  /**
7899
- * Generic types for capability definitions.
7900
- *
7901
- * A capability is defined with Zod schemas for methods, events, and settings.
7902
- * TypeScript types are inferred via z.infer<> — zero duplication.
7903
- *
7904
- * Pattern:
7905
- * 1. Define Zod schemas for data, methods, settings
7906
- * 2. Export const capabilityDef = { ... } satisfies CapabilityDefinition
7907
- * 3. Export type IProvider = InferProvider<typeof capabilityDef>
7908
- * 4. Addon implements IProvider
7909
- * 5. Registry auto-mounts tRPC router from definition.methods
7910
- */
7911
- /**
7912
- * Output schema shared by the contribution + live methods.
7913
- *
7914
- * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
7915
- * tabs[]) without importing from `../interfaces/config-ui.js` — a
7916
- * concrete-but-lenient Zod object keeps tRPC output inference happy
7917
- * (using `z.unknown()` here collapses unrelated router branches to
7918
- * `unknown` when the generator re-inlines the huge AppRouter type).
7919
- *
7920
- * `.passthrough()` on sections/fields accepts whatever FormBuilder
7921
- * extensions the caller adds (showWhen, displayScale, …) without
7922
- * rebuilding every time a new field kind is introduced.
7923
- */
7924
- var ContributionSectionSchema = object({
7925
- id: string(),
7926
- title: string(),
7927
- description: string().optional(),
7928
- style: _enum(["card", "accordion"]).optional(),
7929
- defaultCollapsed: boolean().optional(),
7930
- columns: union([
7931
- literal(1),
7932
- literal(2),
7933
- literal(3),
7934
- literal(4)
7935
- ]).optional(),
7936
- tab: string().optional(),
7937
- location: _enum(["settings", "top-tab"]).optional(),
7938
- order: number().optional(),
7939
- fields: array(any())
7940
- });
7941
- object({
7942
- tabs: array(object({
7943
- id: string(),
7944
- label: string(),
7945
- icon: string(),
7946
- order: number().optional()
7947
- })).optional(),
7948
- sections: array(ContributionSectionSchema)
7949
- }).nullable();
7950
- object({ deviceId: number() }), object({ deviceId: number() }), object({
7951
- deviceId: number(),
7952
- patch: record(string(), unknown())
7953
- }), object({ success: literal(true) });
7954
- object({ deviceId: number() }), unknown().nullable();
7955
- /** Shorthand to define a method schema */
7956
- function method(input, output, options) {
7957
- return {
7958
- input,
7959
- output,
7960
- kind: options?.kind ?? "query",
7961
- auth: options?.auth ?? "protected",
7962
- ...options?.access !== void 0 ? { access: options.access } : {},
7963
- timeoutMs: options?.timeoutMs
7964
- };
7965
- }
7966
- /** Shorthand to define an event schema */
7967
- function event(data) {
7968
- return { data };
7969
- }
7970
- /**
7971
8071
  * Alarm-panel cap. Models HA `alarm_control_panel.*` on
7972
8072
  * `DeviceType.AlarmPanel`. State follows HA's canonical lifecycle
7973
8073
  * across disarmed / armed_(home|away|night|vacation|custom_bypass) /
@@ -9998,6 +10098,24 @@ var DetectorOutputSchema = object({
9998
10098
  inferenceMs: number(),
9999
10099
  modelId: string()
10000
10100
  });
10101
+ var EngineProvisioningSchema = object({
10102
+ runtimeId: _enum([
10103
+ "onnx",
10104
+ "openvino",
10105
+ "coreml"
10106
+ ]).nullable(),
10107
+ device: string().nullable(),
10108
+ state: _enum([
10109
+ "idle",
10110
+ "installing",
10111
+ "verifying",
10112
+ "ready",
10113
+ "failed"
10114
+ ]),
10115
+ progress: number().optional(),
10116
+ error: string().optional(),
10117
+ nextRetryAt: number().optional()
10118
+ });
10001
10119
  var PipelineStepInputSchema = lazy(() => object({
10002
10120
  addonId: string(),
10003
10121
  modelId: string(),
@@ -10097,6 +10215,15 @@ var pipelineExecutorCapability = {
10097
10215
  kind: "mutation",
10098
10216
  auth: "admin"
10099
10217
  }),
10218
+ /**
10219
+ * Per-node detection-engine provisioning snapshot. Returns the live
10220
+ * state of the lazy runtime-provisioning machine on `nodeId`
10221
+ * (idle / installing / verifying / ready / failed). The UI pairs this
10222
+ * one-shot query with the `pipeline.engine-provisioning` live event
10223
+ * (emitted on every transition) to drive a per-node "engine ready?"
10224
+ * indicator without polling. Phase 2.
10225
+ */
10226
+ getEngineProvisioning: method(object({ nodeId: string() }), EngineProvisioningSchema),
10100
10227
  getVideoPipelineSteps: method(_void(), record(string(), object({
10101
10228
  modelId: string(),
10102
10229
  settings: record(string(), unknown()).readonly()
@@ -12437,9 +12564,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
12437
12564
  limit: number().optional(),
12438
12565
  tags: record(string(), string()).optional()
12439
12566
  }), array(LogEntrySchema).readonly());
12440
- var StaticDirOutputSchema = object({ staticDir: string() });
12441
- var VersionOutputSchema = object({ version: string() });
12442
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
12443
12567
  /**
12444
12568
  * Zod schemas for persisted record types.
12445
12569
  *
@@ -14099,7 +14223,10 @@ var AgentAddonConfigSchema = object({
14099
14223
  modelId: string(),
14100
14224
  settings: record(string(), unknown()).readonly()
14101
14225
  });
14102
- var AgentPipelineSettingsSchema = object({ addonDefaults: record(string(), AgentAddonConfigSchema).readonly() });
14226
+ var AgentPipelineSettingsSchema = object({
14227
+ addonDefaults: record(string(), AgentAddonConfigSchema).readonly(),
14228
+ maxCameras: number().int().nonnegative().nullable().default(null)
14229
+ });
14103
14230
  var CameraPipelineForAgentSchema = object({
14104
14231
  steps: array(PipelineStepInputSchema).readonly(),
14105
14232
  audio: object({
@@ -14201,6 +14328,133 @@ var GlobalMetricsSchema = object({
14201
14328
  * capability providers.
14202
14329
  */
14203
14330
  var CapabilityBindingsSchema = record(string(), string());
14331
+ /** Source block — always present; derives from the stream catalog. */
14332
+ var CameraSourceStatusSchema = object({ streams: array(object({
14333
+ camStreamId: string(),
14334
+ codec: string(),
14335
+ width: number(),
14336
+ height: number(),
14337
+ fps: number(),
14338
+ kind: string()
14339
+ })).readonly() });
14340
+ /** Assignment block — always present (orchestrator-local, no remote call). */
14341
+ var CameraAssignmentStatusSchema = object({
14342
+ detectionNodeId: string().nullable(),
14343
+ decoderNodeId: string().nullable(),
14344
+ audioNodeId: string().nullable(),
14345
+ pinned: object({
14346
+ detection: boolean(),
14347
+ decoder: boolean(),
14348
+ audio: boolean()
14349
+ }),
14350
+ reasons: object({
14351
+ detection: string().optional(),
14352
+ decoder: string().optional(),
14353
+ audio: string().optional()
14354
+ })
14355
+ });
14356
+ /** Broker block — null when the broker stage is unreachable or inactive. */
14357
+ var CameraBrokerStatusSchema = object({
14358
+ profiles: array(object({
14359
+ profile: string(),
14360
+ status: string(),
14361
+ codec: string(),
14362
+ width: number(),
14363
+ height: number(),
14364
+ subscribers: number(),
14365
+ inFps: number(),
14366
+ outFps: number()
14367
+ })).readonly(),
14368
+ webrtcSessions: number(),
14369
+ rtspRestream: boolean()
14370
+ });
14371
+ /** Shared-memory ring statistics within the decoder block. */
14372
+ var CameraDecoderShmSchema = object({
14373
+ framesWritten: number(),
14374
+ getFrameHits: number(),
14375
+ getFrameMisses: number(),
14376
+ budgetMb: number()
14377
+ });
14378
+ /** Decoder block — null when the decoder stage is unreachable or inactive. */
14379
+ var CameraDecoderStatusSchema = object({
14380
+ nodeId: string(),
14381
+ formats: array(string()).readonly(),
14382
+ sessionCount: number(),
14383
+ shm: CameraDecoderShmSchema
14384
+ });
14385
+ /** Motion block — null when motion detection is not active for this device. */
14386
+ var CameraMotionStatusSchema = object({
14387
+ enabled: boolean(),
14388
+ fps: number()
14389
+ });
14390
+ /** Detection provisioning sub-block. */
14391
+ var CameraDetectionProvisioningSchema = object({
14392
+ state: _enum([
14393
+ "idle",
14394
+ "installing",
14395
+ "verifying",
14396
+ "ready",
14397
+ "failed"
14398
+ ]),
14399
+ error: string().optional()
14400
+ });
14401
+ /** Detection phase — derived from the runner's engine phase. */
14402
+ var CameraDetectionPhaseSchema = _enum([
14403
+ "idle",
14404
+ "watching",
14405
+ "active"
14406
+ ]);
14407
+ /** Detection block — null when no detection node is assigned or reachable. */
14408
+ var CameraDetectionStatusSchema = object({
14409
+ nodeId: string(),
14410
+ engine: object({
14411
+ backend: string(),
14412
+ device: string()
14413
+ }),
14414
+ phase: CameraDetectionPhaseSchema,
14415
+ configuredFps: number(),
14416
+ actualFps: number(),
14417
+ queueDepth: number(),
14418
+ avgInferenceMs: number(),
14419
+ provisioning: CameraDetectionProvisioningSchema
14420
+ });
14421
+ /** Audio block — null when no audio node is assigned or reachable. */
14422
+ var CameraAudioStatusSchema = object({
14423
+ nodeId: string(),
14424
+ enabled: boolean()
14425
+ });
14426
+ /** Recording block — null when no recording cap is active for this device. */
14427
+ var CameraRecordingStatusSchema = object({
14428
+ mode: _enum([
14429
+ "off",
14430
+ "continuous",
14431
+ "events"
14432
+ ]),
14433
+ active: boolean(),
14434
+ storageBytes: number()
14435
+ });
14436
+ /**
14437
+ * Aggregated per-camera pipeline status — server-composed, single call.
14438
+ *
14439
+ * The `assignment` and `source` blocks are always present.
14440
+ * Every other block is `null` when the stage is inactive or unreachable
14441
+ * during the bounded parallel fan-out in the orchestrator implementation.
14442
+ *
14443
+ * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
14444
+ */
14445
+ var CameraStatusSchema = object({
14446
+ deviceId: number(),
14447
+ assignment: CameraAssignmentStatusSchema,
14448
+ source: CameraSourceStatusSchema,
14449
+ broker: CameraBrokerStatusSchema.nullable(),
14450
+ decoder: CameraDecoderStatusSchema.nullable(),
14451
+ motion: CameraMotionStatusSchema.nullable(),
14452
+ detection: CameraDetectionStatusSchema.nullable(),
14453
+ audio: CameraAudioStatusSchema.nullable(),
14454
+ recording: CameraRecordingStatusSchema.nullable(),
14455
+ /** Unix timestamp (ms) when this snapshot was composed server-side. */
14456
+ fetchedAt: number()
14457
+ });
14204
14458
  method(object({
14205
14459
  deviceId: number(),
14206
14460
  agentNodeId: string()
@@ -14268,6 +14522,12 @@ method(object({
14268
14522
  }), {
14269
14523
  kind: "mutation",
14270
14524
  auth: "admin"
14525
+ }), method(object({
14526
+ agentNodeId: string(),
14527
+ maxCameras: number().int().nonnegative().nullable()
14528
+ }), object({ success: literal(true) }), {
14529
+ kind: "mutation",
14530
+ auth: "admin"
14271
14531
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
14272
14532
  deviceId: number(),
14273
14533
  addonId: string(),
@@ -14293,7 +14553,7 @@ method(object({
14293
14553
  }), method(object({
14294
14554
  deviceId: number(),
14295
14555
  agentNodeId: string().optional()
14296
- }), CameraPipelineConfigSchema), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
14556
+ }), CameraPipelineConfigSchema), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
14297
14557
  name: string(),
14298
14558
  description: string().optional(),
14299
14559
  config: CameraPipelineConfigSchema
@@ -14901,7 +15161,7 @@ method(object({
14901
15161
  }), _void(), {
14902
15162
  kind: "mutation",
14903
15163
  auth: "admin"
14904
- }), 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({
15164
+ }), 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({
14905
15165
  deviceId: number(),
14906
15166
  values: record(string(), unknown())
14907
15167
  }), object({ success: literal(true) }), {
@@ -15614,7 +15874,20 @@ var DiskSpaceInfoSchema = object({
15614
15874
  var PidResourceStatsSchema = object({
15615
15875
  pid: number(),
15616
15876
  cpu: number(),
15617
- memory: number()
15877
+ memory: number(),
15878
+ /**
15879
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
15880
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
15881
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
15882
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
15883
+ * Undefined where /proc is unavailable (e.g. macOS).
15884
+ */
15885
+ privateBytes: number().optional(),
15886
+ /**
15887
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15888
+ * code shared copy-on-write across runners. Undefined on macOS.
15889
+ */
15890
+ sharedBytes: number().optional()
15618
15891
  });
15619
15892
  var AddonInstanceSchema = object({
15620
15893
  addonId: string(),
@@ -15663,6 +15936,17 @@ var KillProcessResultSchema = object({
15663
15936
  reason: string().optional(),
15664
15937
  signal: _enum(["SIGTERM", "SIGKILL"]).optional()
15665
15938
  });
15939
+ var DumpHeapSnapshotInputSchema = object({
15940
+ /** The addon whose runner should dump a heap snapshot. */
15941
+ addonId: string() });
15942
+ var DumpHeapSnapshotResultSchema = object({
15943
+ success: boolean(),
15944
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
15945
+ path: string().optional(),
15946
+ /** Process pid that was signalled. */
15947
+ pid: number().optional(),
15948
+ reason: string().optional()
15949
+ });
15666
15950
  var SystemMetricsSchema = object({
15667
15951
  cpuPercent: number(),
15668
15952
  memoryPercent: number(),
@@ -15676,6 +15960,9 @@ var SystemMetricsSchema = object({
15676
15960
  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, {
15677
15961
  kind: "mutation",
15678
15962
  auth: "admin"
15963
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
15964
+ kind: "mutation",
15965
+ auth: "admin"
15679
15966
  });
15680
15967
  var PtzPresetSchema = object({
15681
15968
  id: string(),
@@ -16075,63 +16362,6 @@ var recordingCapability = {
16075
16362
  }
16076
16363
  };
16077
16364
  /**
16078
- * device-ops — device-scoped cap that unifies the per-IDevice operations
16079
- * previously routed through the `.device-ops` Moleculer bridge service.
16080
- *
16081
- * Each worker that hosts live `IDevice` instances auto-registers a native
16082
- * provider for this cap (per device) backed by its local
16083
- * `DeviceRegistry`. Hub-side callers reach it transparently through
16084
- * `ctx.fetchDevice(id).deviceOps.*` — the DeviceProxy injects
16085
- * `deviceId` + `nodeId` and dispatches through the standard cap-router,
16086
- * so there's no parallel bridge path anymore.
16087
- *
16088
- * The surface is intentionally small — every method corresponds to a
16089
- * single action on the live `IDevice` (or `ICameraDevice` for
16090
- * `getStreamSources`). Richer orchestration (enable/disable with
16091
- * integration plumbing, bulk updates) stays in the `device-manager` cap;
16092
- * `device-ops` is the per-device primitive the device-manager routes to.
16093
- */
16094
- var StreamSourceEntrySchema$1 = object({
16095
- id: string(),
16096
- label: string(),
16097
- protocol: _enum([
16098
- "rtsp",
16099
- "rtmp",
16100
- "annexb",
16101
- "http-mjpeg",
16102
- "webrtc",
16103
- "custom"
16104
- ]),
16105
- url: string().optional(),
16106
- resolution: object({
16107
- width: number(),
16108
- height: number()
16109
- }).optional(),
16110
- fps: number().optional(),
16111
- bitrate: number().optional(),
16112
- codec: string().optional(),
16113
- profileHint: CamProfileSchema.optional(),
16114
- sdp: string().optional()
16115
- });
16116
- var ConfigEntrySchema$1 = object({
16117
- key: string(),
16118
- value: unknown()
16119
- });
16120
- var RawStateResultSchema = object({
16121
- /** Originating provider id, e.g. 'homeassistant' | 'reolink' | 'hikvision'. */
16122
- source: string(),
16123
- /** Opaque, DISPLAY-SAFE upstream blob (no secrets/PII). */
16124
- data: record(string(), unknown())
16125
- });
16126
- method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
16127
- deviceId: number(),
16128
- values: record(string(), unknown())
16129
- }), _void(), { kind: "mutation" }), method(object({
16130
- deviceId: number(),
16131
- action: string().min(1),
16132
- input: unknown()
16133
- }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
16134
- /**
16135
16365
  * camera-credentials — device-scoped cap exposing the camera's network
16136
16366
  * + auth surface in a vendor-neutral shape.
16137
16367
  *
@@ -19814,6 +20044,12 @@ Object.freeze({
19814
20044
  addonId: null,
19815
20045
  access: "view"
19816
20046
  },
20047
+ "metricsProvider.dumpHeapSnapshot": {
20048
+ capName: "metrics-provider",
20049
+ capScope: "system",
20050
+ addonId: null,
20051
+ access: "create"
20052
+ },
19817
20053
  "metricsProvider.getAddonStats": {
19818
20054
  capName: "metrics-provider",
19819
20055
  capScope: "system",
@@ -20270,6 +20506,12 @@ Object.freeze({
20270
20506
  addonId: null,
20271
20507
  access: "view"
20272
20508
  },
20509
+ "pipelineExecutor.getEngineProvisioning": {
20510
+ capName: "pipeline-executor",
20511
+ capScope: "system",
20512
+ addonId: null,
20513
+ access: "view"
20514
+ },
20273
20515
  "pipelineExecutor.getGlobalPipelineConfig": {
20274
20516
  capName: "pipeline-executor",
20275
20517
  capScope: "system",
@@ -20474,6 +20716,18 @@ Object.freeze({
20474
20716
  addonId: null,
20475
20717
  access: "view"
20476
20718
  },
20719
+ "pipelineOrchestrator.getCameraStatus": {
20720
+ capName: "pipeline-orchestrator",
20721
+ capScope: "system",
20722
+ addonId: null,
20723
+ access: "view"
20724
+ },
20725
+ "pipelineOrchestrator.getCameraStatuses": {
20726
+ capName: "pipeline-orchestrator",
20727
+ capScope: "system",
20728
+ addonId: null,
20729
+ access: "view"
20730
+ },
20477
20731
  "pipelineOrchestrator.getCameraStepOverrides": {
20478
20732
  capName: "pipeline-orchestrator",
20479
20733
  capScope: "system",
@@ -20558,6 +20812,12 @@ Object.freeze({
20558
20812
  addonId: null,
20559
20813
  access: "create"
20560
20814
  },
20815
+ "pipelineOrchestrator.setAgentMaxCameras": {
20816
+ capName: "pipeline-orchestrator",
20817
+ capScope: "system",
20818
+ addonId: null,
20819
+ access: "create"
20820
+ },
20561
20821
  "pipelineOrchestrator.setCameraPipelineForAgent": {
20562
20822
  capName: "pipeline-orchestrator",
20563
20823
  capScope: "system",
@@ -22156,30 +22416,6 @@ var RingBuffer = class {
22156
22416
  return result;
22157
22417
  }
22158
22418
  };
22159
- /**
22160
- * Promise-based timer helpers — used everywhere the codebase needs to
22161
- * wait, back off, or schedule a retry. Before these helpers landed, each
22162
- * call site re-implemented `new Promise(r => setTimeout(r, ms))` inline,
22163
- * with subtle variations (some swallowing cancellation, some not). Two
22164
- * shapes cover every observed use case:
22165
- *
22166
- * - {@link sleep} for a plain, uncancellable wait — the default choice.
22167
- * - {@link sleepCancellable} for a wait that wakes early when an
22168
- * abort signal trips, used by long-running pollers whose teardown
22169
- * must stop a pending backoff promptly.
22170
- */
22171
- /**
22172
- * Resolve after `ms` milliseconds. Never rejects, never cancels. The
22173
- * sleep cannot be interrupted; for a wakeable variant use
22174
- * {@link sleepCancellable}.
22175
- *
22176
- * `ms <= 0` resolves on the next microtask via `setTimeout(0)`, which
22177
- * still gives the event loop a chance to drain — useful for breaking
22178
- * up tight async loops without changing call-site semantics.
22179
- */
22180
- function sleep(ms) {
22181
- return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
22182
- }
22183
22419
  //#endregion
22184
22420
  Object.defineProperty(exports, "APPLE_SA_TO_MACRO", {
22185
22421
  enumerable: true,