@camstack/addon-export-alexa 1.0.4 → 1.0.6

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.
@@ -4655,63 +4655,7 @@ function _instanceof(cls, params = {}) {
4655
4655
  return inst;
4656
4656
  }
4657
4657
  //#endregion
4658
- //#region ../types/dist/index.mjs
4659
- /**
4660
- * Deep wiring healthcheck — snapshot of active reachability probes across
4661
- * every declared capability + widget of every installed plugin, on every
4662
- * node. Produced by the backend `WiringHealthService` and surfaced via
4663
- * `GET /health/wiring`, the tRPC `health.wiring` query, and the boot-gate.
4664
- *
4665
- * Unlike `/health` (process liveness), this reflects whether each cap/widget
4666
- * is actually *reachable* over the real cap-dispatch path. See spec
4667
- * `docs/superpowers/specs/2026-05-23-deep-healthcheck-design.md`.
4668
- */
4669
- /** What kind of target a probe addressed. */
4670
- var wiringProbeKindSchema = _enum([
4671
- "singleton",
4672
- "device",
4673
- "widget"
4674
- ]);
4675
- /** Result of probing a single (cap|widget [, device]) target. */
4676
- var wiringProbeResultSchema = object({
4677
- capName: string(),
4678
- kind: wiringProbeKindSchema,
4679
- deviceId: number().optional(),
4680
- reachable: boolean(),
4681
- latencyMs: number(),
4682
- error: string().optional()
4683
- });
4684
- /** Per-addon roll-up of cap + widget probe results. */
4685
- var wiringAddonHealthSchema = object({
4686
- addonId: string(),
4687
- caps: array(wiringProbeResultSchema).readonly(),
4688
- widgets: array(wiringProbeResultSchema).readonly()
4689
- });
4690
- /** Per-node roll-up. */
4691
- var wiringNodeHealthSchema = object({
4692
- nodeId: string(),
4693
- addons: array(wiringAddonHealthSchema).readonly()
4694
- });
4695
- object({
4696
- /** True only when every probed target is reachable. */
4697
- ok: boolean(),
4698
- /** True when at least one target is unreachable. */
4699
- degraded: boolean(),
4700
- checkedAt: string(),
4701
- nodes: array(wiringNodeHealthSchema).readonly(),
4702
- summary: object({
4703
- total: number(),
4704
- reachable: number(),
4705
- unreachable: number()
4706
- })
4707
- });
4708
- var MODEL_FORMATS = [
4709
- "onnx",
4710
- "coreml",
4711
- "openvino",
4712
- "tflite",
4713
- "pt"
4714
- ];
4658
+ //#region ../types/dist/sleep-D7JeS58T.mjs
4715
4659
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4716
4660
  EventCategory["SystemBoot"] = "system.boot";
4717
4661
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5009,6 +4953,18 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
5009
4953
  */
5010
4954
  EventCategory["PipelineEngineMetricsSnapshot"] = "pipeline.engine-metrics-snapshot";
5011
4955
  /**
4956
+ * Per-node detection-engine runtime-provisioning transition. Emitted by
4957
+ * the detection-pipeline provider on every state change of its lazy
4958
+ * engine-provisioning machine (idle → installing → verifying → ready,
4959
+ * or → failed with a `nextRetryAt`). Payload is the
4960
+ * `EngineProvisioningState` snapshot; `event.source.nodeId` carries the
4961
+ * node. The Pipeline page subscribes to drive a live "installing
4962
+ * OpenVINO… / ready" indicator per node without polling
4963
+ * `pipelineExecutor.getEngineProvisioning`. Telemetry-grade (D8): the UI
4964
+ * also reads the cap snapshot on mount / reconnect. Phase 2.
4965
+ */
4966
+ EventCategory["PipelineEngineProvisioning"] = "pipeline.engine-provisioning";
4967
+ /**
5012
4968
  * Cluster topology snapshot. Carries the same payload returned by
5013
4969
  * `nodes.topology` (every reachable node + addons + processes).
5014
4970
  * Emitted by the hub on any agent / addon lifecycle change
@@ -5936,123 +5892,6 @@ function normalizeAddonInitResult(result) {
5936
5892
  if (Array.isArray(result)) return { providers: result };
5937
5893
  return result;
5938
5894
  }
5939
- /**
5940
- * Build an `IAddonRouteProvider` from a list of routes. Implements
5941
- * both the operator-facing `getRoutes` (returning route descriptors
5942
- * minus the handlers, which can't cross JSON) and the framework-
5943
- * private `invoke` method that the hub calls when this provider lives
5944
- * in a forked worker.
5945
- *
5946
- * Co-located addons use the returned `getRoutes` directly because
5947
- * their handlers don't need to cross any wire. The `invoke` method
5948
- * is present anyway so the bridge code on the hub is uniform — it
5949
- * doesn't need to switch on "local vs remote provider" at the call
5950
- * site.
5951
- *
5952
- * Example:
5953
- * const routes: IAddonHttpRoute[] = [
5954
- * { method: 'GET', path: '/start', access: 'public', handler: this.handleStart },
5955
- * ]
5956
- * return [
5957
- * {
5958
- * capability: addonRoutesCapability,
5959
- * provider: buildAddonRouteProvider('auth-oidc', routes),
5960
- * },
5961
- * ]
5962
- */
5963
- function buildAddonRouteProvider(id, routes) {
5964
- return {
5965
- id,
5966
- getRoutes: () => routes,
5967
- invoke: async (input) => {
5968
- const match = matchRoute(routes, input.method, input.path);
5969
- if (!match) return {
5970
- status: 404,
5971
- headers: {},
5972
- redirectUrl: null,
5973
- body: { error: `No route matches ${input.method} ${input.path}` }
5974
- };
5975
- const envelope = {
5976
- status: 200,
5977
- headers: {},
5978
- redirectUrl: null
5979
- };
5980
- const reply = buildCapturingReply(envelope);
5981
- const request = {
5982
- params: {
5983
- ...input.params,
5984
- ...match.params
5985
- },
5986
- query: input.query,
5987
- body: input.body,
5988
- headers: input.headers,
5989
- ...input.user ? { user: input.user } : {},
5990
- ...input.scopedToken !== void 0 ? { scopedToken: input.scopedToken } : {}
5991
- };
5992
- await match.route.handler(request, reply);
5993
- return envelope;
5994
- }
5995
- };
5996
- }
5997
- /**
5998
- * Pattern matcher: same semantics as `AddonRouteRegistry.matchRoute`
5999
- * but operating on a flat list and bypassing the `/addon/<id>/` prefix
6000
- * — the bridge sends the post-prefix path directly so we don't need
6001
- * to round-trip it through normalization.
6002
- */
6003
- function matchRoute(routes, method, path) {
6004
- const normalizedMethod = method.toUpperCase();
6005
- for (const route of routes) {
6006
- if (route.method !== normalizedMethod) continue;
6007
- const params = matchPath(route.path, path);
6008
- if (params !== null) return {
6009
- route,
6010
- params
6011
- };
6012
- }
6013
- return null;
6014
- }
6015
- function matchPath(pattern, p) {
6016
- const patternParts = pattern.split("/").filter(Boolean);
6017
- const pathParts = p.split("/").filter(Boolean);
6018
- if (patternParts.length !== pathParts.length) return null;
6019
- const params = {};
6020
- for (let i = 0; i < patternParts.length; i++) {
6021
- const a = patternParts[i];
6022
- const b = pathParts[i];
6023
- if (a.startsWith(":")) params[a.slice(1)] = b;
6024
- else if (a !== b) return null;
6025
- }
6026
- return params;
6027
- }
6028
- function buildCapturingReply(envelope) {
6029
- const wrapper = {
6030
- status(code) {
6031
- envelope.status = code;
6032
- return wrapper;
6033
- },
6034
- code(code) {
6035
- envelope.status = code;
6036
- return wrapper;
6037
- },
6038
- send(data) {
6039
- envelope.body = data;
6040
- },
6041
- redirect(url) {
6042
- envelope.redirectUrl = url;
6043
- if (envelope.status === 200) envelope.status = 302;
6044
- },
6045
- header(name, value) {
6046
- envelope.headers[name.toLowerCase()] = value;
6047
- return wrapper;
6048
- },
6049
- type(mime) {
6050
- envelope.contentType = mime;
6051
- return wrapper;
6052
- }
6053
- };
6054
- return wrapper;
6055
- }
6056
5895
  /** Shared Zod schemas used across streaming capabilities. */
6057
5896
  var CamProfileSchema = _enum([
6058
5897
  "high",
@@ -6150,7 +5989,7 @@ function makeSourceBrokerId(deviceId, camStreamId) {
6150
5989
  * Zod schema for StreamSourceEntry — the canonical stream descriptor
6151
5990
  * exposed by ICameraDevice.getStreamSources() and consumed by the broker.
6152
5991
  */
6153
- var StreamSourceEntrySchema = object({
5992
+ var StreamSourceEntrySchema$1 = object({
6154
5993
  id: string(),
6155
5994
  label: string(),
6156
5995
  protocol: _enum([
@@ -6372,407 +6211,412 @@ var ProfileRtspEntrySchema = object({
6372
6211
  codec: string().optional(),
6373
6212
  resolution: CamStreamResolutionSchema.optional()
6374
6213
  });
6375
- /**
6376
- * Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
6377
- * Named `RecordingWeekday` to avoid collision with the string-union
6378
- * `Weekday` exported from `interfaces/timezones.ts`.
6379
- */
6380
- var RecordingWeekdaySchema = number().int().min(0).max(6);
6381
- var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
6382
- var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
6383
- kind: literal("timeOfDay"),
6384
- start: string().regex(HHMM),
6385
- end: string().regex(HHMM),
6386
- /** Restrict to these weekdays; omit = every day. */
6387
- days: array(RecordingWeekdaySchema).optional()
6388
- })]);
6389
- var RecordingModeSchema = _enum([
6390
- "continuous",
6391
- "onMotion",
6392
- "onAudioThreshold"
6393
- ]);
6394
- /**
6395
- * First-class, authoritative per-camera storage mode the netta choice the UI
6396
- * reads directly (never inferred from `rules`):
6397
- * - `off` not recording.
6398
- * - `events` — record only around triggers (motion / audio threshold),
6399
- * with pre/post-buffer.
6400
- * - `continuous` record 24/7 within the schedule.
6401
- *
6402
- * `mode` compiles one-way to the internal `rules[]` consumed by the policy
6403
- * engine (see `compileRules`); `rules[]` is never authored directly anymore.
6404
- */
6405
- var RecordingStorageModeSchema = _enum([
6406
- "off",
6407
- "events",
6408
- "continuous"
6409
- ]);
6410
- /** Which detectors trigger an `events`-mode recording. */
6411
- var RecordingTriggersSchema = object({
6412
- motion: boolean().optional(),
6413
- audioThresholdDbfs: number().optional()
6414
- });
6415
- /**
6416
- * Mode of a single recording band the recorder per-band vocabulary.
6417
- *
6418
- * Distinct from `RecordingStorageModeSchema` (which carries `off`): a band is
6419
- * only ever `continuous` or `events`; "off" is expressed by the absence of a
6420
- * covering band, not by a band value.
6421
- */
6422
- var RecordingBandModeSchema = _enum(["continuous", "events"]);
6423
- /**
6424
- * Triggers for an `events`-mode band. Identical shape to
6425
- * `RecordingTriggersSchema`reuse that schema as the band trigger type so the
6426
- * two never drift.
6427
- */
6428
- var RecordingBandTriggersSchema = RecordingTriggersSchema;
6429
- /**
6430
- * A single mode-per-band window the canonical recorder band shape, the
6431
- * single source of truth re-used by `addon-pipeline/recorder`.
6432
- *
6433
- * `days` lists the weekdays the band covers (empty = every day, matching the
6434
- * band engine's `applies` rule). `start`/`end` are `HH:MM`; an `end <= start`
6435
- * span wraps past midnight (handled by the band engine).
6436
- */
6437
- var RecordingBandSchema = object({
6438
- days: array(RecordingWeekdaySchema),
6439
- start: string().regex(HHMM),
6440
- end: string().regex(HHMM),
6441
- mode: RecordingBandModeSchema,
6442
- triggers: RecordingBandTriggersSchema.optional(),
6443
- preBufferSec: number().min(0).optional(),
6444
- postBufferSec: number().min(0).optional()
6445
- });
6446
- var RecordingRuleSchema = object({
6447
- schedule: RecordingScheduleSchema,
6448
- mode: RecordingModeSchema,
6449
- /** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
6450
- preBufferSec: number().min(0).default(0),
6451
- /** Keep recording until this many seconds after the last trigger. */
6452
- postBufferSec: number().min(0).default(0),
6453
- /** Each new trigger restarts the post-buffer window. */
6454
- resetTimeoutOnNewEvent: boolean().default(true),
6455
- /** onAudioThreshold only dBFS level that counts as a trigger. */
6456
- thresholdDbfs: number().optional()
6457
- });
6458
- /**
6459
- * Per-device retention overrides. Every field is optional; an unset or `0`
6460
- * value inherits the node-wide recorder default. Only footage-lifetime limits
6461
- * live per-camera: `maxAgeDays` and `maxSizeGb`. The disk-occupancy threshold
6462
- * (when the volume is too full to keep recording) is NOT a per-camera concern —
6463
- * it belongs to the StorageLocation (`StorageLocation.config.minFreePercent`),
6464
- * shared by every camera writing to that volume.
6465
- */
6466
- var RecordingRetentionSchema = object({
6467
- maxAgeDays: number().min(0).optional(),
6468
- maxSizeGb: number().min(0).optional()
6469
- });
6470
- /**
6471
- * The full per-camera recording intent — the wire shape of a RecordingTarget.
6472
- *
6473
- * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
6474
- * are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
6475
- * only for transition + migration (`migrateRulesToMode`); the policy engine
6476
- * consumes the compiled output of `compileRules(config)`, never `rules` directly.
6477
- */
6478
- var RecordingConfigSchema = object({
6479
- enabled: boolean(),
6480
- /** Authoritative storage mode. Absent on legacy targets → derived once via
6481
- * `migrateRulesToMode`, then persisted. */
6482
- mode: RecordingStorageModeSchema.optional(),
6483
- profiles: array(CamProfileSchema).optional(),
6484
- segmentSeconds: number().int().positive().optional(),
6485
- /** Shared recording time-bands for `events` & `continuous` — record only when
6486
- * the wall-clock falls inside one of these windows. Omit or empty = always.
6487
- * `continuous` compiles to one rule per band; `events` to band × trigger. */
6488
- schedules: array(RecordingScheduleSchema).optional(),
6489
- /** Legacy single-band predecessor of `schedules`. Read-compat only — it is
6490
- * normalized into `schedules` on read and never written going forward. (Not
6491
- * tagged `@deprecated`: the normalization paths must read it cast-free.) */
6492
- schedule: RecordingScheduleSchema.optional(),
6493
- /** `events`-mode only — which detectors trigger a recording. */
6494
- triggers: RecordingTriggersSchema.optional(),
6495
- /** `events`-mode only — seconds retained before / after a trigger. */
6496
- preBufferSec: number().min(0).optional(),
6497
- postBufferSec: number().min(0).optional(),
6498
- /** DEPRECATED authoring input; retained for migration/transition. */
6499
- rules: array(RecordingRuleSchema).optional(),
6500
- /**
6501
- * AUTHORITATIVE mode-per-band recording model (recorder). When present it
6502
- * is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
6503
- * `triggers`/`rules` fields above are kept for READ-COMPAT only and are
6504
- * derived into bands once via `migrateConfigToBands`.
6505
- */
6506
- bands: array(RecordingBandSchema).optional(),
6507
- retention: RecordingRetentionSchema.optional()
6508
- });
6509
- /**
6510
- * `StorageLocationType` — an addon-declared id that identifies the *kind* of
6511
- * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
6512
- * so the persisted record schema and the consumer-facing cap can both consume it
6513
- * without forming a circular import. The `storage` cap re-exports it
6514
- * verbatim for back-compat.
6515
- *
6516
- * This Zod schema is the **authoritative source** for `StorageLocationType`.
6517
- * The TS alias in `./storage.ts` re-exports `z.infer<typeof
6518
- * StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
6519
- * `IStorageProvider` interface stay in lockstep.
6520
- *
6521
- * The type is now an **open string** (not a closed enum) — addons declare
6522
- * their own location kinds via `StorageLocationDeclaration.id`. The regex
6523
- * enforces a safe id format: lowercase-start, alphanumeric + hyphens.
6524
- */
6525
- var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
6526
- /**
6527
- * Persisted record for a storage location instance. Operators can register
6528
- * multiple instances for multi-cardinality types (e.g. two `backups`
6529
- * locations with different `providerId`s). Cardinality is now declared per
6530
- * location via `StorageLocationDeclaration.cardinality` — the static
6531
- * `STORAGE_LOCATION_CARDINALITY` map has been removed.
6532
- *
6533
- * `id` is a stable namespaced string of the form `<type>:<slug>`.
6534
- * The default location for a type uses `id === <type>:default` by
6535
- * convention (the bare type ref like `'backups'` resolves to it).
6536
- *
6537
- * `isSystem: true` marks a location as orchestrator-seeded and
6538
- * undeletable. The bootstrap-installed defaults (one per type) carry
6539
- * this flag; operator-added locations don't. Editing the config of
6540
- * a system location is allowed (path migration, provider swap) but
6541
- * deleting it is rejected at the cap level.
6542
- */
6543
- var StorageLocationSchema = object({
6544
- id: string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
6545
- type: string(),
6546
- displayName: string().min(1),
6547
- providerId: string().min(1),
6548
- config: record(string(), unknown()),
6214
+ var DeviceType = /* @__PURE__ */ function(DeviceType) {
6215
+ DeviceType["Camera"] = "camera";
6216
+ DeviceType["Hub"] = "hub";
6217
+ DeviceType["Light"] = "light";
6218
+ DeviceType["Siren"] = "siren";
6219
+ DeviceType["Switch"] = "switch";
6220
+ DeviceType["Sensor"] = "sensor";
6221
+ DeviceType["Thermostat"] = "thermostat";
6222
+ DeviceType["Button"] = "button";
6223
+ /** Generic stateless event emitter — carries a device's EXACT declared
6224
+ * event vocabulary verbatim (no normalization). Installed with the
6225
+ * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
6226
+ * HA bus events (e.g. `zha_event`, generic). */
6227
+ DeviceType["EventEmitter"] = "event-emitter";
6228
+ /** Firmware/software update entity — current vs available version,
6229
+ * updatable flag, update state, and an install action. Installed with
6230
+ * the `update` cap. Sources: Homematic firmware-update channels (and
6231
+ * reusable by other providers, e.g. HA `update.*` entities). */
6232
+ DeviceType["Update"] = "update";
6233
+ DeviceType["Generic"] = "generic";
6234
+ /** Generic notification delivery target (HA `notify.<service>`, future
6235
+ * Telegram / Discord / ntfy / SMTP, …). One device per delivery
6236
+ * endpoint; the `notifier` cap defines the send surface. */
6237
+ DeviceType["Notifier"] = "notifier";
6238
+ /** Pre-recorded action sequence with optional parameters
6239
+ * (HA `script.*`). Runnable via `script-runner` cap. */
6240
+ DeviceType["Script"] = "script";
6241
+ /** Automation rule (HA `automation.*`) enable/disable + manual
6242
+ * trigger surface exposed via `automation-control` cap. */
6243
+ DeviceType["Automation"] = "automation";
6244
+ /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
6245
+ DeviceType["Lock"] = "lock";
6246
+ /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
6247
+ * `valve.*`). `cover` cap with sub-roles for variant. */
6248
+ DeviceType["Cover"] = "cover";
6249
+ /** Pipe / water / gas valve with open/close/stop and optional
6250
+ * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
6251
+ * modelled on the same open/closed lifecycle. */
6252
+ DeviceType["Valve"] = "valve";
6253
+ /** Humidifier / dehumidifier with on/off + target humidity + mode
6254
+ * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
6255
+ * modelled on the same target / mode lifecycle. */
6256
+ DeviceType["Humidifier"] = "humidifier";
6257
+ /** Water heater / boiler with target temperature + operation mode +
6258
+ * away mode (HA `water_heater.*`). `water-heater` cap a
6259
+ * climate-family actuator. */
6260
+ DeviceType["WaterHeater"] = "water-heater";
6261
+ /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
6262
+ DeviceType["Fan"] = "fan";
6263
+ /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
6264
+ * the camera surface those use `Camera`. `media-player` cap. */
6265
+ DeviceType["MediaPlayer"] = "media-player";
6266
+ /** Security panel / alarm system (HA `alarm_control_panel.*`).
6267
+ * `alarm-panel` cap. */
6268
+ DeviceType["AlarmPanel"] = "alarm-panel";
6269
+ /** Generic user-settable input (HA `number` / `input_number` / `select`
6270
+ * / `input_select` / `text` / `input_text` / `input_datetime`).
6271
+ * Sub-type via `DeviceRole`: NumericControl / SelectControl /
6272
+ * TextControl / DateTimeControl. */
6273
+ DeviceType["Control"] = "control";
6274
+ /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
6275
+ * `presence` cap. */
6276
+ DeviceType["Presence"] = "presence";
6277
+ /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
6278
+ * `weather` cap. */
6279
+ DeviceType["Weather"] = "weather";
6280
+ /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
6281
+ DeviceType["Vacuum"] = "vacuum";
6282
+ /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
6283
+ * `lawn-mower-control` cap. */
6284
+ DeviceType["LawnMower"] = "lawn-mower";
6285
+ /** Physical HA device group — parent container for entity-children
6286
+ * adopted from a single HA device entry. Not renderable as a
6287
+ * standalone device; exists only to anchor child entities. */
6288
+ DeviceType["Container"] = "container";
6289
+ /** Single still-image entity (HA `image.*`). Read-only display of an
6290
+ * `entity_picture` signed URL the browser loads directly. `image` cap. */
6291
+ DeviceType["Image"] = "image";
6292
+ return DeviceType;
6293
+ }({});
6294
+ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
6295
+ DeviceFeature["BatteryOperated"] = "battery-operated";
6296
+ DeviceFeature["Rebootable"] = "rebootable";
6549
6297
  /**
6550
- * Cluster node this location physically lives on. REQUIRED for node-local
6551
- * providers (filesystem — the path exists on one node's disk), null/absent
6552
- * for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
6553
- * `'hub'` is the hub node. Validated against the provider's `nodeLocal`
6554
- * flag at upsert time, not here (the schema is provider-agnostic).
6298
+ * Device supports an on-demand re-sync of its derived spec with its
6299
+ * upstream sourcedrives the generic Re-sync button. The owning
6300
+ * provider implements the action via the `device-adoption.resync` cap.
6555
6301
  */
6556
- nodeId: string().optional(),
6557
- isDefault: boolean().default(false),
6558
- isSystem: boolean().default(false),
6559
- createdAt: number(),
6560
- updatedAt: number()
6561
- });
6562
- /**
6563
- * Reference accepted by consumer-facing `api.storage.*` calls.
6564
- * Either:
6565
- * - a `StorageLocationType` (e.g. `'backups'`) → orchestrator resolves to the default of that type
6566
- * - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
6567
- *
6568
- * The orchestrator's `resolveRef(ref)` handles both cases.
6569
- */
6570
- var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
6571
- /**
6572
- * `StorageLocationDeclaration` — a single storage-location entry declared by
6573
- * an addon in its `package.json` under `camstack.storageLocations`.
6574
- *
6575
- * Design intent:
6576
- * - **Addon declares its needs** — each addon describes the logical storage
6577
- * slots it requires (e.g. `recordings`, `recordingsLow`) without caring
6578
- * about the physical path.
6579
- * - **Kernel aggregates** — at boot the kernel collects declarations from all
6580
- * installed addons, deduplicates by `id`, and exposes the union via the
6581
- * storage-locations settings surface.
6582
- * - **Orchestrator seeds** — for every declared `id` the orchestrator ensures
6583
- * at least one instance named `<id>:default` is present, using
6584
- * `defaultsTo` to inherit the resolved root from another location when the
6585
- * declaration is a derivative slot (e.g. `recordingsLow` defaults to
6586
- * `recordings`).
6587
- * - **ids are global** — `id` values are shared across the entire deployment;
6588
- * two addons declaring the same `id` must agree on `cardinality` (validated
6589
- * at kernel aggregation time, not here).
6590
- */
6591
- var StorageLocationDeclarationSchema = object({
6302
+ DeviceFeature["Resyncable"] = "resyncable";
6303
+ DeviceFeature["NativeSnapshot"] = "native-snapshot";
6304
+ DeviceFeature["DoorbellButton"] = "doorbell-button";
6305
+ DeviceFeature["TwoWayAudio"] = "two-way-audio";
6306
+ DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
6592
6307
  /**
6593
- * Global location identifier, e.g. `recordings` or `recordingsLow`.
6594
- * Must start with a lowercase letter and may contain letters, digits, and
6595
- * hyphens.
6308
+ * Camera supports the on-firmware autotrack subsystem (subject-
6309
+ * following). Distinct from `PanTiltZoom` because not every PTZ
6310
+ * camera ships autotrack — the admin UI uses this flag to gate
6311
+ * the autotrack toggle / settings card without re-deriving from
6312
+ * the cap registry. Mirrors `ptz-autotrack` cap registration:
6313
+ * driver sets this feature when probe confirms the firmware
6314
+ * surface, and registers the cap in the same code path.
6596
6315
  */
6597
- id: string().regex(/^[a-z][a-zA-Z0-9-]*$/, { message: "id must start with a lowercase letter and contain only letters, digits, or hyphens" }),
6598
- /** Human-readable name shown in the admin UI. */
6599
- displayName: string().min(1, { message: "displayName must not be empty" }),
6600
- /** Optional longer explanation of what data this location stores. */
6601
- description: string().optional(),
6316
+ DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
6602
6317
  /**
6603
- * `single` exactly one instance of this location is allowed system-wide
6604
- * (e.g. `logs`, `models`). The operator can edit it but not add more.
6605
- * `multi` the operator may register several instances (e.g. a second
6606
- * `recordings` on a NAS for disk tiering); one is the default at any time.
6318
+ * Accessory exposes a "trigger on motion" toggle the parent camera's
6319
+ * motion detection automatically activates this device. Mirrors
6320
+ * `motion-trigger` cap registration: drivers set this feature in the
6321
+ * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
6322
+ *
6323
+ * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
6324
+ * fast scalar without binding fetch), notifier rules, and `listAll`
6325
+ * filters that want "all devices with on-motion behaviour".
6607
6326
  */
6608
- cardinality: _enum(["single", "multi"]),
6609
- /**
6610
- * When set, the default instance for this location inherits its resolved
6611
- * root from the named location's default instance. Useful for derivative
6612
- * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
6613
- * configure the primary location.
6614
- */
6615
- defaultsTo: string().optional()
6616
- });
6617
- var DecoderStatsSchema = object({
6618
- inputFps: number(),
6619
- outputFps: number(),
6620
- avgDecodeTimeMs: number(),
6621
- droppedFrames: number()
6622
- });
6623
- var DecoderSessionConfigSchema = object({
6624
- codec: string(),
6625
- maxFps: number().default(0),
6626
- outputFormat: _enum([
6627
- "jpeg",
6628
- "rgb",
6629
- "bgr",
6630
- "yuv420",
6631
- "gray"
6632
- ]).default("jpeg"),
6633
- scale: number().default(1),
6634
- width: number().optional(),
6635
- height: number().optional(),
6636
- /**
6637
- * Identifier of the camera this decoder session serves. Optional
6638
- * because the cap is generic (any caller could request decode), but
6639
- * stream-broker passes it so decoder logs include `deviceId` for
6640
- * per-camera filtering when diagnosing failures (e.g. node-av
6641
- * sendPacket errors on a single hung camera).
6642
- */
6643
- deviceId: number().int().nonnegative().optional(),
6644
- /**
6645
- * Free-form tag for log scoping. Stream-broker uses
6646
- * `broker:<deviceId>/<profile>`. Decoder session logger surfaces it
6647
- * on every line so `grep tag=broker:5/high` filters one camera
6648
- * profile cleanly.
6649
- */
6650
- tag: string().optional(),
6651
- /**
6652
- * Where the session delivers decoded frames (Phase 5 / D9):
6653
- *
6654
- * - `'callback'` (default) — the legacy pixel path: decoded frames are
6655
- * buffered as `DecodedFrame`s and drained via `pullFrames`.
6656
- * - `'shm'` — the shared-memory frame plane: decoded frames are written
6657
- * into an OS shared-memory ring and drained as zero-pixel
6658
- * `FrameHandle`s via `pullHandles`. A session is one mode or the
6659
- * other `pullFrames` returns nothing for an `'shm'` session and
6660
- * `pullHandles` returns nothing for a `'callback'` session.
6661
- */
6662
- frameSink: _enum(["callback", "shm"]).default("callback")
6663
- });
6664
- var EncodeProfileSchema = object({
6665
- video: object({
6666
- codec: _enum([
6667
- "h264",
6668
- "h265",
6669
- "copy"
6670
- ]),
6671
- profile: _enum([
6672
- "baseline",
6673
- "main",
6674
- "high"
6675
- ]).optional(),
6676
- width: number().int().positive().optional(),
6677
- height: number().int().positive().optional(),
6678
- fps: number().positive().optional(),
6679
- bitrateKbps: number().int().positive().optional(),
6680
- gopFrames: number().int().positive().optional(),
6681
- bf: number().int().min(0).optional(),
6682
- preset: _enum([
6683
- "ultrafast",
6684
- "superfast",
6685
- "veryfast",
6686
- "faster",
6687
- "fast",
6688
- "medium"
6689
- ]).optional(),
6690
- tune: _enum([
6691
- "zerolatency",
6692
- "film",
6693
- "animation"
6694
- ]).optional()
6695
- }),
6696
- audio: union([literal("passthrough"), object({
6697
- codec: _enum([
6698
- "opus",
6699
- "aac",
6700
- "pcmu",
6701
- "pcma",
6702
- "copy"
6703
- ]),
6704
- bitrateKbps: number().int().positive().optional(),
6705
- sampleRateHz: number().int().positive().optional(),
6706
- channels: union([literal(1), literal(2)]).optional()
6707
- })]),
6708
- /**
6709
- * ffmpeg input-side args, inserted between the fixed global flags
6710
- * (`-hide_banner -loglevel error`) and `-i pipe:0`. Free-text array
6711
- * — the widget surfaces a textarea + suggestion chips for the most-
6712
- * used demuxer/format options.
6713
- */
6714
- inputArgs: array(string()).optional(),
6715
- /**
6716
- * ffmpeg output-side args, inserted between the encode block and
6717
- * the final `-f <muxer> pipe:1`. Use for muxer options, bitstream
6718
- * filters, codec-specific overrides. Free-text array.
6719
- */
6720
- outputArgs: array(string()).optional()
6721
- });
6722
- function pickPreferredRtspEntry(entries, pref, deviceId, options = {}) {
6723
- if (entries.length === 0) return null;
6724
- const prefix = `${deviceId}/`;
6725
- const toPicked = (e) => ({
6726
- brokerId: e.brokerId,
6727
- profileId: e.brokerId.startsWith(prefix) ? e.brokerId.slice(prefix.length) : e.brokerId,
6728
- url: e.url,
6729
- mutedUrl: e.mutedUrl,
6730
- enabled: e.enabled,
6731
- ...e.codec !== void 0 ? { codec: e.codec } : {},
6732
- ...e.resolution !== void 0 ? { resolution: e.resolution } : {}
6733
- });
6734
- if (pref !== "auto") {
6735
- const match = entries.find((e) => e.enabled && e.url.length > 0 && (e.profile === pref || e.brokerId === `${prefix}${pref}`));
6736
- if (match) return toPicked(match);
6737
- }
6738
- const eligible = entries.filter((e) => e.enabled && e.url.length > 0);
6739
- if (eligible.length === 0) return null;
6740
- const target = options.targetResolution;
6741
- if (target) {
6742
- const withRes = eligible.filter((e) => e.resolution !== void 0);
6743
- if (withRes.length > 0) {
6744
- const picked = pickClosestResolution(withRes, target);
6745
- if (picked) return toPicked(picked);
6746
- }
6747
- }
6748
- return toPicked(eligible[0]);
6749
- }
6327
+ DeviceFeature["MotionTrigger"] = "motion-trigger";
6328
+ /** Light supports rgb-triplet color via `color` cap. */
6329
+ DeviceFeature["LightColorRgb"] = "light-color-rgb";
6330
+ /** Light supports HSV color via `color` cap. */
6331
+ DeviceFeature["LightColorHsv"] = "light-color-hsv";
6332
+ /** Light supports color-temperature (mired) via `color` cap. */
6333
+ DeviceFeature["LightColorMired"] = "light-color-mired";
6334
+ /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
6335
+ * targetHigh). Gates the range slider UI. */
6336
+ DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
6337
+ /** Thermostat exposes target humidity and/or current humidity
6338
+ * readings. Gates the humidity controls. */
6339
+ DeviceFeature["ClimateHumidity"] = "climate-humidity";
6340
+ /** Thermostat exposes a fan-mode selector. */
6341
+ DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
6342
+ /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
6343
+ DeviceFeature["ClimatePreset"] = "climate-preset";
6344
+ /** Cover exposes intermediate position control (0..100). Gates the
6345
+ * position slider UI. */
6346
+ DeviceFeature["CoverPositionable"] = "cover-positionable";
6347
+ /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
6348
+ DeviceFeature["CoverTilt"] = "cover-tilt";
6349
+ /** Valve exposes intermediate position control (0..100). Gates the
6350
+ * position slider / drag surface UI. */
6351
+ DeviceFeature["ValvePositionable"] = "valve-positionable";
6352
+ /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
6353
+ DeviceFeature["FanSpeed"] = "fan-speed";
6354
+ /** Fan exposes a preset mode selector. */
6355
+ DeviceFeature["FanPreset"] = "fan-preset";
6356
+ /** Fan exposes blade direction (forward/reverse) typical of
6357
+ * ceiling fans. */
6358
+ DeviceFeature["FanDirection"] = "fan-direction";
6359
+ /** Fan exposes an oscillation toggle. */
6360
+ DeviceFeature["FanOscillating"] = "fan-oscillating";
6361
+ /** Lock requires a PIN code on lock/unlock. Gates the code-entry
6362
+ * field on the UI lock-controls panel. */
6363
+ DeviceFeature["LockPinRequired"] = "lock-pin-required";
6364
+ /** Lock supports a latch-release ("open door") action distinct from
6365
+ * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
6366
+ * `supported_features`. Gates the Open Door button in the UI. */
6367
+ DeviceFeature["LockOpen"] = "lock-open";
6368
+ /** Media player exposes a seek-to-position surface. */
6369
+ DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
6370
+ /** Media player exposes a volume-level setter. */
6371
+ DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
6372
+ /** Media player exposes a mute toggle distinct from volume=0. */
6373
+ DeviceFeature["MediaPlayerMute"] = "media-player-mute";
6374
+ /** Media player exposes a shuffle toggle. */
6375
+ DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
6376
+ /** Media player exposes a repeat mode (off / all / one). */
6377
+ DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
6378
+ /** Media player exposes a source / input selector. */
6379
+ DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
6380
+ /** Media player exposes a play-arbitrary-media surface (URL / id). */
6381
+ DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
6382
+ /** Media player exposes next-track. */
6383
+ DeviceFeature["MediaPlayerNext"] = "media-player-next";
6384
+ /** Media player exposes previous-track. */
6385
+ DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
6386
+ /** Media player exposes stop distinct from pause. */
6387
+ DeviceFeature["MediaPlayerStop"] = "media-player-stop";
6388
+ /** Alarm panel requires a PIN code on arm/disarm. */
6389
+ DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
6390
+ /** Presence device carries GPS coordinates (lat/lng/accuracy) in
6391
+ * addition to a textual location. */
6392
+ DeviceFeature["PresenceGps"] = "presence-gps";
6393
+ /** Notifier accepts an inline / URL image attachment. */
6394
+ DeviceFeature["NotifierImage"] = "notifier-image";
6395
+ /** Notifier accepts a priority hint (high/normal/low). */
6396
+ DeviceFeature["NotifierPriority"] = "notifier-priority";
6397
+ /** Notifier accepts a free-form `data` payload for platform-specific
6398
+ * fields. */
6399
+ DeviceFeature["NotifierData"] = "notifier-data";
6400
+ /** Notifier supports interactive action buttons / callbacks. */
6401
+ DeviceFeature["NotifierActions"] = "notifier-actions";
6402
+ /** Notifier supports per-call recipient targeting (multi-user). */
6403
+ DeviceFeature["NotifierRecipients"] = "notifier-recipients";
6404
+ /** Script runner accepts a variables map on each run invocation. */
6405
+ DeviceFeature["ScriptVariables"] = "script-variables";
6406
+ /** Automation `trigger` accepts a skipCondition flag — fires the
6407
+ * automation's actions while bypassing its condition block. */
6408
+ DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
6409
+ return DeviceFeature;
6410
+ }({});
6750
6411
  /**
6751
- * Pick the entry whose `resolution` is closest to `target`. Prefer
6752
- * entries target (downscale is cheap at the consumer; upscale is
6753
- * lossy). Among the rest pick the LARGEST still ≤ target so the
6754
- * consumer gets the best feasible quality. "Closeness" is the
6755
- * `width × height` pixel delta.
6412
+ * Semantic role a device plays within its parent. Populated by driver
6413
+ * addons when creating accessory devices (Reolink siren/floodlight/
6414
+ * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
6415
+ * admin UI to pick icons, labels, and widgets — a `Switch` with
6416
+ * `role: Floodlight` renders as a bulb with a brightness slider,
6417
+ * whereas a `Switch` with `role: Siren` renders as a klaxon.
6418
+ *
6419
+ * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
6420
+ * sqlite as a nullable TEXT column — old rows keep working unchanged.
6756
6421
  */
6757
- function pickClosestResolution(entries, target) {
6758
- const targetPixels = target.width * target.height;
6759
- let bestAbove;
6760
- let bestBelow;
6761
- for (const e of entries) {
6762
- if (e.resolution === void 0) continue;
6763
- const pixels = e.resolution.width * e.resolution.height;
6764
- if (pixels >= targetPixels) {
6765
- if (!bestAbove || pixels < bestAbove.pixels) bestAbove = {
6766
- entry: e,
6767
- pixels
6768
- };
6769
- } else if (!bestBelow || pixels > bestBelow.pixels) bestBelow = {
6770
- entry: e,
6771
- pixels
6772
- };
6773
- }
6774
- return bestAbove?.entry ?? bestBelow?.entry;
6422
+ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
6423
+ DeviceRole["Siren"] = "siren";
6424
+ DeviceRole["Floodlight"] = "floodlight";
6425
+ DeviceRole["Spotlight"] = "spotlight";
6426
+ DeviceRole["PirSensor"] = "pir-sensor";
6427
+ DeviceRole["Chime"] = "chime";
6428
+ DeviceRole["Autotrack"] = "autotrack";
6429
+ DeviceRole["Nightvision"] = "nightvision";
6430
+ DeviceRole["PrivacyMask"] = "privacy-mask";
6431
+ DeviceRole["Doorbell"] = "doorbell";
6432
+ /** Virtual HA toggle (input_boolean.*) — distinguishable from a
6433
+ * real Switch device for UI rendering / export adapters. */
6434
+ DeviceRole["BinaryHelper"] = "binary-helper";
6435
+ /** Generic motion / occupancy / moving event source. Distinct from
6436
+ * the camera accessory PirSensor role: that one is a camera child;
6437
+ * this is a standalone HA / 3rd-party motion sensor. */
6438
+ DeviceRole["MotionSensor"] = "motion-sensor";
6439
+ DeviceRole["ContactSensor"] = "contact-sensor";
6440
+ DeviceRole["LeakSensor"] = "leak-sensor";
6441
+ DeviceRole["SmokeSensor"] = "smoke-sensor";
6442
+ DeviceRole["COSensor"] = "co-sensor";
6443
+ DeviceRole["GasSensor"] = "gas-sensor";
6444
+ DeviceRole["TamperSensor"] = "tamper-sensor";
6445
+ DeviceRole["VibrationSensor"] = "vibration-sensor";
6446
+ DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
6447
+ DeviceRole["SoundSensor"] = "sound-sensor";
6448
+ /** Fallback for `binary_sensor` without a known `device_class`. */
6449
+ DeviceRole["BinarySensor"] = "binary-sensor";
6450
+ DeviceRole["TemperatureSensor"] = "temperature-sensor";
6451
+ DeviceRole["HumiditySensor"] = "humidity-sensor";
6452
+ DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
6453
+ DeviceRole["PressureSensor"] = "pressure-sensor";
6454
+ DeviceRole["PowerSensor"] = "power-sensor";
6455
+ DeviceRole["EnergySensor"] = "energy-sensor";
6456
+ DeviceRole["VoltageSensor"] = "voltage-sensor";
6457
+ DeviceRole["CurrentSensor"] = "current-sensor";
6458
+ DeviceRole["AirQualitySensor"] = "air-quality-sensor";
6459
+ /** Battery level (numeric % via `sensor` OR low-bool via
6460
+ * `binary_sensor` — the cap distinguishes via the value type). */
6461
+ DeviceRole["BatterySensor"] = "battery-sensor";
6462
+ /** Fallback for `sensor` numeric without a known `device_class`. */
6463
+ DeviceRole["NumericSensor"] = "numeric-sensor";
6464
+ /** String / enum state (HA `sensor` with `state_class: enum` or
6465
+ * `attributes.options`). */
6466
+ DeviceRole["EnumSensor"] = "enum-sensor";
6467
+ /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
6468
+ * or `date`). The slice carries the raw ISO string verbatim (hosted on
6469
+ * the `enum-sensor` cap); the UI renders it locale-formatted. */
6470
+ DeviceRole["DateTimeSensor"] = "datetime-sensor";
6471
+ /** Last-resort fallback when nothing else matches. */
6472
+ DeviceRole["GenericSensor"] = "generic-sensor";
6473
+ DeviceRole["NumericControl"] = "numeric-control";
6474
+ DeviceRole["SelectControl"] = "select-control";
6475
+ DeviceRole["TextControl"] = "text-control";
6476
+ DeviceRole["DateTimeControl"] = "datetime-control";
6477
+ /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
6478
+ * rich features (image, priority, channel routing). */
6479
+ DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
6480
+ /** Chat / messaging service (HA `notify.telegram_*`,
6481
+ * `notify.discord_*`, etc.). */
6482
+ DeviceRole["MessagingNotifier"] = "messaging-notifier";
6483
+ /** Email-based delivery (HA `notify.smtp`, etc.). */
6484
+ DeviceRole["EmailNotifier"] = "email-notifier";
6485
+ /** Fallback when the notifier service name doesn't match a known
6486
+ * pattern. */
6487
+ DeviceRole["GenericNotifier"] = "generic-notifier";
6488
+ return DeviceRole;
6489
+ }({});
6490
+ /**
6491
+ * Generic types for capability definitions.
6492
+ *
6493
+ * A capability is defined with Zod schemas for methods, events, and settings.
6494
+ * TypeScript types are inferred via z.infer<> — zero duplication.
6495
+ *
6496
+ * Pattern:
6497
+ * 1. Define Zod schemas for data, methods, settings
6498
+ * 2. Export const capabilityDef = { ... } satisfies CapabilityDefinition
6499
+ * 3. Export type IProvider = InferProvider<typeof capabilityDef>
6500
+ * 4. Addon implements IProvider
6501
+ * 5. Registry auto-mounts tRPC router from definition.methods
6502
+ */
6503
+ /**
6504
+ * Output schema shared by the contribution + live methods.
6505
+ *
6506
+ * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
6507
+ * tabs[]) without importing from `../interfaces/config-ui.js` — a
6508
+ * concrete-but-lenient Zod object keeps tRPC output inference happy
6509
+ * (using `z.unknown()` here collapses unrelated router branches to
6510
+ * `unknown` when the generator re-inlines the huge AppRouter type).
6511
+ *
6512
+ * `.passthrough()` on sections/fields accepts whatever FormBuilder
6513
+ * extensions the caller adds (showWhen, displayScale, …) without
6514
+ * rebuilding every time a new field kind is introduced.
6515
+ */
6516
+ var ContributionSectionSchema = object({
6517
+ id: string(),
6518
+ title: string(),
6519
+ description: string().optional(),
6520
+ style: _enum(["card", "accordion"]).optional(),
6521
+ defaultCollapsed: boolean().optional(),
6522
+ columns: union([
6523
+ literal(1),
6524
+ literal(2),
6525
+ literal(3),
6526
+ literal(4)
6527
+ ]).optional(),
6528
+ tab: string().optional(),
6529
+ location: _enum(["settings", "top-tab"]).optional(),
6530
+ order: number().optional(),
6531
+ fields: array(any())
6532
+ });
6533
+ object({
6534
+ tabs: array(object({
6535
+ id: string(),
6536
+ label: string(),
6537
+ icon: string(),
6538
+ order: number().optional()
6539
+ })).optional(),
6540
+ sections: array(ContributionSectionSchema)
6541
+ }).nullable();
6542
+ object({ deviceId: number() }), object({ deviceId: number() }), object({
6543
+ deviceId: number(),
6544
+ patch: record(string(), unknown())
6545
+ }), object({ success: literal(true) });
6546
+ object({ deviceId: number() }), unknown().nullable();
6547
+ /** Shorthand to define a method schema */
6548
+ function method(input, output, options) {
6549
+ return {
6550
+ input,
6551
+ output,
6552
+ kind: options?.kind ?? "query",
6553
+ auth: options?.auth ?? "protected",
6554
+ ...options?.access !== void 0 ? { access: options.access } : {},
6555
+ timeoutMs: options?.timeoutMs
6556
+ };
6775
6557
  }
6558
+ var StaticDirOutputSchema = object({ staticDir: string() });
6559
+ var VersionOutputSchema = object({ version: string() });
6560
+ method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
6561
+ /**
6562
+ * device-ops — device-scoped cap that unifies the per-IDevice operations
6563
+ * previously routed through the `.device-ops` Moleculer bridge service.
6564
+ *
6565
+ * Each worker that hosts live `IDevice` instances auto-registers a native
6566
+ * provider for this cap (per device) backed by its local
6567
+ * `DeviceRegistry`. Hub-side callers reach it transparently through
6568
+ * `ctx.fetchDevice(id).deviceOps.*` — the DeviceProxy injects
6569
+ * `deviceId` + `nodeId` and dispatches through the standard cap-router,
6570
+ * so there's no parallel bridge path anymore.
6571
+ *
6572
+ * The surface is intentionally small — every method corresponds to a
6573
+ * single action on the live `IDevice` (or `ICameraDevice` for
6574
+ * `getStreamSources`). Richer orchestration (enable/disable with
6575
+ * integration plumbing, bulk updates) stays in the `device-manager` cap;
6576
+ * `device-ops` is the per-device primitive the device-manager routes to.
6577
+ */
6578
+ var StreamSourceEntrySchema = object({
6579
+ id: string(),
6580
+ label: string(),
6581
+ protocol: _enum([
6582
+ "rtsp",
6583
+ "rtmp",
6584
+ "annexb",
6585
+ "http-mjpeg",
6586
+ "webrtc",
6587
+ "custom"
6588
+ ]),
6589
+ url: string().optional(),
6590
+ resolution: object({
6591
+ width: number(),
6592
+ height: number()
6593
+ }).optional(),
6594
+ fps: number().optional(),
6595
+ bitrate: number().optional(),
6596
+ codec: string().optional(),
6597
+ profileHint: CamProfileSchema.optional(),
6598
+ sdp: string().optional()
6599
+ });
6600
+ var ConfigEntrySchema$1 = object({
6601
+ key: string(),
6602
+ value: unknown()
6603
+ });
6604
+ var RawStateResultSchema = object({
6605
+ /** Originating provider id, e.g. 'homeassistant' | 'reolink' | 'hikvision'. */
6606
+ source: string(),
6607
+ /** Opaque, DISPLAY-SAFE upstream blob (no secrets/PII). */
6608
+ data: record(string(), unknown())
6609
+ });
6610
+ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
6611
+ deviceId: number(),
6612
+ values: record(string(), unknown())
6613
+ }), _void(), { kind: "mutation" }), method(object({
6614
+ deviceId: number(),
6615
+ action: string().min(1),
6616
+ input: unknown()
6617
+ }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
6618
+ //#endregion
6619
+ //#region ../types/dist/err-msg-IQTHeDzc.mjs
6776
6620
  /**
6777
6621
  import { errMsg } from '@camstack/types'
6778
6622
  * Extract a human-readable message from an unknown error value.
@@ -6783,547 +6627,847 @@ function errMsg(err) {
6783
6627
  if (typeof err === "string") return err;
6784
6628
  return String(err);
6785
6629
  }
6786
- var YAMNET_TO_MACRO = {
6787
- mapping: {
6788
- Speech: "speech",
6789
- "Child speech, kid speaking": "speech",
6790
- Conversation: "speech",
6791
- "Narration, monologue": "speech",
6792
- Babbling: "speech",
6793
- Whispering: "speech",
6794
- "Speech synthesizer": "speech",
6795
- Humming: "speech",
6796
- Rapping: "speech",
6797
- Singing: "speech",
6798
- Choir: "speech",
6799
- "Child singing": "speech",
6800
- Shout: "scream",
6801
- Bellow: "scream",
6802
- Yell: "scream",
6803
- Screaming: "scream",
6804
- "Children shouting": "scream",
6805
- Whoop: "scream",
6806
- "Crying, sobbing": "crying",
6807
- "Baby cry, infant cry": "crying",
6808
- Whimper: "crying",
6809
- "Wail, moan": "crying",
6810
- Groan: "crying",
6811
- Laughter: "laughter",
6812
- "Baby laughter": "laughter",
6813
- Giggle: "laughter",
6814
- Snicker: "laughter",
6815
- "Belly laugh": "laughter",
6816
- "Chuckle, chortle": "laughter",
6817
- Music: "music",
6818
- "Musical instrument": "music",
6819
- Guitar: "music",
6820
- Piano: "music",
6821
- Drum: "music",
6822
- "Drum kit": "music",
6823
- "Violin, fiddle": "music",
6824
- Flute: "music",
6825
- Saxophone: "music",
6826
- Trumpet: "music",
6827
- Synthesizer: "music",
6828
- "Pop music": "music",
6829
- "Rock music": "music",
6830
- "Hip hop music": "music",
6831
- "Classical music": "music",
6832
- Jazz: "music",
6833
- "Electronic music": "music",
6834
- "Background music": "music",
6835
- Dog: "dog",
6836
- Bark: "dog",
6837
- Yip: "dog",
6838
- Howl: "dog",
6839
- "Bow-wow": "dog",
6840
- Growling: "dog",
6841
- "Whimper (dog)": "dog",
6842
- Cat: "cat",
6843
- Purr: "cat",
6844
- Meow: "cat",
6845
- Hiss: "cat",
6846
- Caterwaul: "cat",
6847
- Bird: "bird",
6848
- "Bird vocalization, bird call, bird song": "bird",
6849
- "Chirp, tweet": "bird",
6850
- Squawk: "bird",
6851
- Crow: "bird",
6852
- Owl: "bird",
6853
- "Pigeon, dove": "bird",
6854
- Animal: "animal",
6855
- "Domestic animals, pets": "animal",
6856
- "Livestock, farm animals, working animals": "animal",
6857
- Horse: "animal",
6858
- "Cattle, bovinae": "animal",
6859
- Pig: "animal",
6860
- Sheep: "animal",
6861
- Goat: "animal",
6862
- Frog: "animal",
6863
- Insect: "animal",
6864
- Cricket: "animal",
6865
- Alarm: "alarm",
6866
- "Alarm clock": "alarm",
6867
- "Smoke detector, smoke alarm": "alarm",
6868
- "Fire alarm": "alarm",
6869
- Buzzer: "alarm",
6870
- "Civil defense siren": "alarm",
6871
- "Car alarm": "alarm",
6872
- Siren: "siren",
6873
- "Police car (siren)": "siren",
6874
- "Ambulance (siren)": "siren",
6875
- "Fire engine, fire truck (siren)": "siren",
6876
- "Emergency vehicle": "siren",
6877
- Foghorn: "siren",
6878
- Doorbell: "doorbell",
6879
- "Ding-dong": "doorbell",
6880
- Knock: "doorbell",
6881
- Tap: "doorbell",
6882
- Glass: "glass_breaking",
6883
- Shatter: "glass_breaking",
6884
- "Chink, clink": "glass_breaking",
6885
- "Gunshot, gunfire": "gunshot",
6886
- "Machine gun": "gunshot",
6887
- Explosion: "gunshot",
6888
- Fireworks: "gunshot",
6889
- Firecracker: "gunshot",
6890
- "Artillery fire": "gunshot",
6891
- "Cap gun": "gunshot",
6892
- Boom: "gunshot",
6893
- Vehicle: "vehicle",
6894
- Car: "vehicle",
6895
- Truck: "vehicle",
6896
- Bus: "vehicle",
6897
- Motorcycle: "vehicle",
6898
- "Car passing by": "vehicle",
6899
- "Vehicle horn, car horn, honking": "vehicle",
6900
- "Traffic noise, roadway noise": "vehicle",
6901
- Train: "vehicle",
6902
- Aircraft: "vehicle",
6903
- Helicopter: "vehicle",
6904
- Bicycle: "vehicle",
6905
- Skateboard: "vehicle",
6906
- Fire: "fire",
6907
- Crackle: "fire",
6908
- Water: "water",
6909
- Rain: "water",
6910
- Raindrop: "water",
6911
- "Rain on surface": "water",
6912
- Stream: "water",
6913
- Waterfall: "water",
6914
- Ocean: "water",
6915
- "Waves, surf": "water",
6916
- "Splash, splatter": "water",
6917
- Wind: "wind",
6918
- Thunderstorm: "wind",
6919
- Thunder: "wind",
6920
- "Wind noise (microphone)": "wind",
6921
- "Rustling leaves": "wind",
6922
- Door: "door",
6923
- "Sliding door": "door",
6924
- Slam: "door",
6925
- "Cupboard open or close": "door",
6926
- "Walk, footsteps": "footsteps",
6927
- Run: "footsteps",
6928
- Shuffle: "footsteps",
6929
- Crowd: "crowd",
6930
- Chatter: "crowd",
6931
- Cheering: "crowd",
6932
- Applause: "crowd",
6933
- "Children playing": "crowd",
6934
- "Hubbub, speech noise, speech babble": "crowd",
6935
- Telephone: "telephone",
6936
- "Telephone bell ringing": "telephone",
6937
- Ringtone: "telephone",
6938
- "Telephone dialing, DTMF": "telephone",
6939
- "Busy signal": "telephone",
6940
- Engine: "engine",
6941
- "Engine starting": "engine",
6942
- Idling: "engine",
6943
- "Accelerating, revving, vroom": "engine",
6944
- "Light engine (high frequency)": "engine",
6945
- "Medium engine (mid frequency)": "engine",
6946
- "Heavy engine (low frequency)": "engine",
6947
- "Lawn mower": "engine",
6948
- Chainsaw: "engine",
6949
- Hammer: "tools",
6950
- Jackhammer: "tools",
6951
- Sawing: "tools",
6952
- "Power tool": "tools",
6953
- Drill: "tools",
6954
- Sanding: "tools",
6955
- Silence: "silence"
6956
- },
6957
- preserveOriginal: false
6958
- };
6959
- var APPLE_SA_TO_MACRO = {
6960
- mapping: {
6961
- speech: "speech",
6962
- child_speech: "speech",
6963
- conversation: "speech",
6964
- whispering: "speech",
6965
- singing: "speech",
6966
- humming: "speech",
6967
- shout: "scream",
6968
- yell: "scream",
6969
- screaming: "scream",
6970
- crying: "crying",
6971
- baby_crying: "crying",
6972
- sobbing: "crying",
6973
- laughter: "laughter",
6974
- baby_laughter: "laughter",
6975
- giggling: "laughter",
6976
- music: "music",
6977
- guitar: "music",
6978
- piano: "music",
6979
- drums: "music",
6980
- dog_bark: "dog",
6981
- dog_bow_wow: "dog",
6982
- dog_growling: "dog",
6983
- dog_howl: "dog",
6984
- cat_meow: "cat",
6985
- cat_purr: "cat",
6986
- cat_hiss: "cat",
6987
- bird: "bird",
6988
- bird_chirp: "bird",
6989
- bird_squawk: "bird",
6990
- animal: "animal",
6991
- horse: "animal",
6992
- cow_moo: "animal",
6993
- insect: "animal",
6994
- alarm: "alarm",
6995
- smoke_alarm: "alarm",
6996
- fire_alarm: "alarm",
6997
- car_alarm: "alarm",
6998
- siren: "siren",
6999
- police_siren: "siren",
7000
- ambulance_siren: "siren",
7001
- doorbell: "doorbell",
7002
- door_knock: "doorbell",
7003
- knocking: "doorbell",
7004
- glass_breaking: "glass_breaking",
7005
- glass_shatter: "glass_breaking",
7006
- gunshot: "gunshot",
7007
- explosion: "gunshot",
7008
- fireworks: "gunshot",
7009
- car: "vehicle",
7010
- truck: "vehicle",
7011
- motorcycle: "vehicle",
7012
- car_horn: "vehicle",
7013
- vehicle_horn: "vehicle",
7014
- traffic: "vehicle",
7015
- fire: "fire",
7016
- fire_crackle: "fire",
7017
- water: "water",
7018
- rain: "water",
7019
- ocean: "water",
7020
- splash: "water",
7021
- wind: "wind",
7022
- thunder: "wind",
7023
- thunderstorm: "wind",
7024
- door: "door",
7025
- door_slam: "door",
7026
- sliding_door: "door",
7027
- footsteps: "footsteps",
7028
- walking: "footsteps",
7029
- running: "footsteps",
7030
- crowd: "crowd",
7031
- chatter: "crowd",
7032
- cheering: "crowd",
7033
- applause: "crowd",
7034
- telephone_ring: "telephone",
7035
- ringtone: "telephone",
7036
- engine: "engine",
7037
- engine_starting: "engine",
7038
- lawn_mower: "engine",
7039
- chainsaw: "engine",
7040
- hammer: "tools",
7041
- jackhammer: "tools",
7042
- drill: "tools",
7043
- power_tool: "tools",
7044
- silence: "silence"
7045
- },
7046
- preserveOriginal: false
7047
- };
7048
- var _macroLookup = /* @__PURE__ */ new Map();
7049
- for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7050
- for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7051
- var DeviceType = /* @__PURE__ */ function(DeviceType) {
7052
- DeviceType["Camera"] = "camera";
7053
- DeviceType["Hub"] = "hub";
7054
- DeviceType["Light"] = "light";
7055
- DeviceType["Siren"] = "siren";
7056
- DeviceType["Switch"] = "switch";
7057
- DeviceType["Sensor"] = "sensor";
7058
- DeviceType["Thermostat"] = "thermostat";
7059
- DeviceType["Button"] = "button";
7060
- /** Generic stateless event emitter carries a device's EXACT declared
7061
- * event vocabulary verbatim (no normalization). Installed with the
7062
- * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
7063
- * HA bus events (e.g. `zha_event`, generic). */
7064
- DeviceType["EventEmitter"] = "event-emitter";
7065
- /** Firmware/software update entity — current vs available version,
7066
- * updatable flag, update state, and an install action. Installed with
7067
- * the `update` cap. Sources: Homematic firmware-update channels (and
7068
- * reusable by other providers, e.g. HA `update.*` entities). */
7069
- DeviceType["Update"] = "update";
7070
- DeviceType["Generic"] = "generic";
7071
- /** Generic notification delivery target (HA `notify.<service>`, future
7072
- * Telegram / Discord / ntfy / SMTP, …). One device per delivery
7073
- * endpoint; the `notifier` cap defines the send surface. */
7074
- DeviceType["Notifier"] = "notifier";
7075
- /** Pre-recorded action sequence with optional parameters
7076
- * (HA `script.*`). Runnable via `script-runner` cap. */
7077
- DeviceType["Script"] = "script";
7078
- /** Automation rule (HA `automation.*`) — enable/disable + manual
7079
- * trigger surface exposed via `automation-control` cap. */
7080
- DeviceType["Automation"] = "automation";
7081
- /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
7082
- DeviceType["Lock"] = "lock";
7083
- /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
7084
- * `valve.*`). `cover` cap with sub-roles for variant. */
7085
- DeviceType["Cover"] = "cover";
7086
- /** Pipe / water / gas valve with open/close/stop and optional
7087
- * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
7088
- * modelled on the same open/closed lifecycle. */
7089
- DeviceType["Valve"] = "valve";
7090
- /** Humidifier / dehumidifier with on/off + target humidity + mode
7091
- * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
7092
- * modelled on the same target / mode lifecycle. */
7093
- DeviceType["Humidifier"] = "humidifier";
7094
- /** Water heater / boiler with target temperature + operation mode +
7095
- * away mode (HA `water_heater.*`). `water-heater` cap — a
7096
- * climate-family actuator. */
7097
- DeviceType["WaterHeater"] = "water-heater";
7098
- /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
7099
- DeviceType["Fan"] = "fan";
7100
- /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
7101
- * the camera surface — those use `Camera`. `media-player` cap. */
7102
- DeviceType["MediaPlayer"] = "media-player";
7103
- /** Security panel / alarm system (HA `alarm_control_panel.*`).
7104
- * `alarm-panel` cap. */
7105
- DeviceType["AlarmPanel"] = "alarm-panel";
7106
- /** Generic user-settable input (HA `number` / `input_number` / `select`
7107
- * / `input_select` / `text` / `input_text` / `input_datetime`).
7108
- * Sub-type via `DeviceRole`: NumericControl / SelectControl /
7109
- * TextControl / DateTimeControl. */
7110
- DeviceType["Control"] = "control";
7111
- /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
7112
- * `presence` cap. */
7113
- DeviceType["Presence"] = "presence";
7114
- /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
7115
- * `weather` cap. */
7116
- DeviceType["Weather"] = "weather";
7117
- /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
7118
- DeviceType["Vacuum"] = "vacuum";
7119
- /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
7120
- * `lawn-mower-control` cap. */
7121
- DeviceType["LawnMower"] = "lawn-mower";
7122
- /** Physical HA device group — parent container for entity-children
7123
- * adopted from a single HA device entry. Not renderable as a
7124
- * standalone device; exists only to anchor child entities. */
7125
- DeviceType["Container"] = "container";
7126
- /** Single still-image entity (HA `image.*`). Read-only display of an
7127
- * `entity_picture` signed URL the browser loads directly. `image` cap. */
7128
- DeviceType["Image"] = "image";
7129
- return DeviceType;
7130
- }({});
7131
- var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
7132
- DeviceFeature["BatteryOperated"] = "battery-operated";
7133
- DeviceFeature["Rebootable"] = "rebootable";
6630
+ //#endregion
6631
+ //#region ../types/dist/index.mjs
6632
+ /**
6633
+ * Deep wiring healthcheck — snapshot of active reachability probes across
6634
+ * every declared capability + widget of every installed plugin, on every
6635
+ * node. Produced by the backend `WiringHealthService` and surfaced via
6636
+ * `GET /health/wiring`, the tRPC `health.wiring` query, and the boot-gate.
6637
+ *
6638
+ * Unlike `/health` (process liveness), this reflects whether each cap/widget
6639
+ * is actually *reachable* over the real cap-dispatch path. See spec
6640
+ * `docs/superpowers/specs/2026-05-23-deep-healthcheck-design.md`.
6641
+ */
6642
+ /** What kind of target a probe addressed. */
6643
+ var wiringProbeKindSchema = _enum([
6644
+ "singleton",
6645
+ "device",
6646
+ "widget"
6647
+ ]);
6648
+ /** Result of probing a single (cap|widget [, device]) target. */
6649
+ var wiringProbeResultSchema = object({
6650
+ capName: string(),
6651
+ kind: wiringProbeKindSchema,
6652
+ deviceId: number().optional(),
6653
+ reachable: boolean(),
6654
+ latencyMs: number(),
6655
+ error: string().optional()
6656
+ });
6657
+ /** Per-addon roll-up of cap + widget probe results. */
6658
+ var wiringAddonHealthSchema = object({
6659
+ addonId: string(),
6660
+ caps: array(wiringProbeResultSchema).readonly(),
6661
+ widgets: array(wiringProbeResultSchema).readonly()
6662
+ });
6663
+ /** Per-node roll-up. */
6664
+ var wiringNodeHealthSchema = object({
6665
+ nodeId: string(),
6666
+ addons: array(wiringAddonHealthSchema).readonly()
6667
+ });
6668
+ object({
6669
+ /** True only when every probed target is reachable. */
6670
+ ok: boolean(),
6671
+ /** True when at least one target is unreachable. */
6672
+ degraded: boolean(),
6673
+ checkedAt: string(),
6674
+ nodes: array(wiringNodeHealthSchema).readonly(),
6675
+ summary: object({
6676
+ total: number(),
6677
+ reachable: number(),
6678
+ unreachable: number()
6679
+ })
6680
+ });
6681
+ var MODEL_FORMATS = [
6682
+ "onnx",
6683
+ "coreml",
6684
+ "openvino",
6685
+ "tflite",
6686
+ "pt"
6687
+ ];
6688
+ /**
6689
+ * Build an `IAddonRouteProvider` from a list of routes. Implements
6690
+ * both the operator-facing `getRoutes` (returning route descriptors
6691
+ * minus the handlers, which can't cross JSON) and the framework-
6692
+ * private `invoke` method that the hub calls when this provider lives
6693
+ * in a forked worker.
6694
+ *
6695
+ * Co-located addons use the returned `getRoutes` directly because
6696
+ * their handlers don't need to cross any wire. The `invoke` method
6697
+ * is present anyway so the bridge code on the hub is uniform — it
6698
+ * doesn't need to switch on "local vs remote provider" at the call
6699
+ * site.
6700
+ *
6701
+ * Example:
6702
+ * const routes: IAddonHttpRoute[] = [
6703
+ * { method: 'GET', path: '/start', access: 'public', handler: this.handleStart },
6704
+ * ]
6705
+ * return [
6706
+ * {
6707
+ * capability: addonRoutesCapability,
6708
+ * provider: buildAddonRouteProvider('auth-oidc', routes),
6709
+ * },
6710
+ * ]
6711
+ */
6712
+ function buildAddonRouteProvider(id, routes) {
6713
+ return {
6714
+ id,
6715
+ getRoutes: () => routes,
6716
+ invoke: async (input) => {
6717
+ const match = matchRoute(routes, input.method, input.path);
6718
+ if (!match) return {
6719
+ status: 404,
6720
+ headers: {},
6721
+ redirectUrl: null,
6722
+ body: { error: `No route matches ${input.method} ${input.path}` }
6723
+ };
6724
+ const envelope = {
6725
+ status: 200,
6726
+ headers: {},
6727
+ redirectUrl: null
6728
+ };
6729
+ const reply = buildCapturingReply(envelope);
6730
+ const request = {
6731
+ params: {
6732
+ ...input.params,
6733
+ ...match.params
6734
+ },
6735
+ query: input.query,
6736
+ body: input.body,
6737
+ headers: input.headers,
6738
+ ...input.user ? { user: input.user } : {},
6739
+ ...input.scopedToken !== void 0 ? { scopedToken: input.scopedToken } : {}
6740
+ };
6741
+ await match.route.handler(request, reply);
6742
+ return envelope;
6743
+ }
6744
+ };
6745
+ }
6746
+ /**
6747
+ * Pattern matcher: same semantics as `AddonRouteRegistry.matchRoute`
6748
+ * but operating on a flat list and bypassing the `/addon/<id>/` prefix
6749
+ * — the bridge sends the post-prefix path directly so we don't need
6750
+ * to round-trip it through normalization.
6751
+ */
6752
+ function matchRoute(routes, method, path) {
6753
+ const normalizedMethod = method.toUpperCase();
6754
+ for (const route of routes) {
6755
+ if (route.method !== normalizedMethod) continue;
6756
+ const params = matchPath(route.path, path);
6757
+ if (params !== null) return {
6758
+ route,
6759
+ params
6760
+ };
6761
+ }
6762
+ return null;
6763
+ }
6764
+ function matchPath(pattern, p) {
6765
+ const patternParts = pattern.split("/").filter(Boolean);
6766
+ const pathParts = p.split("/").filter(Boolean);
6767
+ if (patternParts.length !== pathParts.length) return null;
6768
+ const params = {};
6769
+ for (let i = 0; i < patternParts.length; i++) {
6770
+ const a = patternParts[i];
6771
+ const b = pathParts[i];
6772
+ if (a.startsWith(":")) params[a.slice(1)] = b;
6773
+ else if (a !== b) return null;
6774
+ }
6775
+ return params;
6776
+ }
6777
+ function buildCapturingReply(envelope) {
6778
+ const wrapper = {
6779
+ status(code) {
6780
+ envelope.status = code;
6781
+ return wrapper;
6782
+ },
6783
+ code(code) {
6784
+ envelope.status = code;
6785
+ return wrapper;
6786
+ },
6787
+ send(data) {
6788
+ envelope.body = data;
6789
+ },
6790
+ redirect(url) {
6791
+ envelope.redirectUrl = url;
6792
+ if (envelope.status === 200) envelope.status = 302;
6793
+ },
6794
+ header(name, value) {
6795
+ envelope.headers[name.toLowerCase()] = value;
6796
+ return wrapper;
6797
+ },
6798
+ type(mime) {
6799
+ envelope.contentType = mime;
6800
+ return wrapper;
6801
+ }
6802
+ };
6803
+ return wrapper;
6804
+ }
6805
+ /**
6806
+ * Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
6807
+ * Named `RecordingWeekday` to avoid collision with the string-union
6808
+ * `Weekday` exported from `interfaces/timezones.ts`.
6809
+ */
6810
+ var RecordingWeekdaySchema = number().int().min(0).max(6);
6811
+ var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
6812
+ var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
6813
+ kind: literal("timeOfDay"),
6814
+ start: string().regex(HHMM),
6815
+ end: string().regex(HHMM),
6816
+ /** Restrict to these weekdays; omit = every day. */
6817
+ days: array(RecordingWeekdaySchema).optional()
6818
+ })]);
6819
+ var RecordingModeSchema = _enum([
6820
+ "continuous",
6821
+ "onMotion",
6822
+ "onAudioThreshold"
6823
+ ]);
6824
+ /**
6825
+ * First-class, authoritative per-camera storage mode — the netta choice the UI
6826
+ * reads directly (never inferred from `rules`):
6827
+ * - `off` — not recording.
6828
+ * - `events` — record only around triggers (motion / audio threshold),
6829
+ * with pre/post-buffer.
6830
+ * - `continuous` — record 24/7 within the schedule.
6831
+ *
6832
+ * `mode` compiles one-way to the internal `rules[]` consumed by the policy
6833
+ * engine (see `compileRules`); `rules[]` is never authored directly anymore.
6834
+ */
6835
+ var RecordingStorageModeSchema = _enum([
6836
+ "off",
6837
+ "events",
6838
+ "continuous"
6839
+ ]);
6840
+ /** Which detectors trigger an `events`-mode recording. */
6841
+ var RecordingTriggersSchema = object({
6842
+ motion: boolean().optional(),
6843
+ audioThresholdDbfs: number().optional()
6844
+ });
6845
+ /**
6846
+ * Mode of a single recording band — the recorder per-band vocabulary.
6847
+ *
6848
+ * Distinct from `RecordingStorageModeSchema` (which carries `off`): a band is
6849
+ * only ever `continuous` or `events`; "off" is expressed by the absence of a
6850
+ * covering band, not by a band value.
6851
+ */
6852
+ var RecordingBandModeSchema = _enum(["continuous", "events"]);
6853
+ /**
6854
+ * Triggers for an `events`-mode band. Identical shape to
6855
+ * `RecordingTriggersSchema` — reuse that schema as the band trigger type so the
6856
+ * two never drift.
6857
+ */
6858
+ var RecordingBandTriggersSchema = RecordingTriggersSchema;
6859
+ /**
6860
+ * A single mode-per-band window — the canonical recorder band shape, the
6861
+ * single source of truth re-used by `addon-pipeline/recorder`.
6862
+ *
6863
+ * `days` lists the weekdays the band covers (empty = every day, matching the
6864
+ * band engine's `applies` rule). `start`/`end` are `HH:MM`; an `end <= start`
6865
+ * span wraps past midnight (handled by the band engine).
6866
+ */
6867
+ var RecordingBandSchema = object({
6868
+ days: array(RecordingWeekdaySchema),
6869
+ start: string().regex(HHMM),
6870
+ end: string().regex(HHMM),
6871
+ mode: RecordingBandModeSchema,
6872
+ triggers: RecordingBandTriggersSchema.optional(),
6873
+ preBufferSec: number().min(0).optional(),
6874
+ postBufferSec: number().min(0).optional()
6875
+ });
6876
+ var RecordingRuleSchema = object({
6877
+ schedule: RecordingScheduleSchema,
6878
+ mode: RecordingModeSchema,
6879
+ /** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
6880
+ preBufferSec: number().min(0).default(0),
6881
+ /** Keep recording until this many seconds after the last trigger. */
6882
+ postBufferSec: number().min(0).default(0),
6883
+ /** Each new trigger restarts the post-buffer window. */
6884
+ resetTimeoutOnNewEvent: boolean().default(true),
6885
+ /** onAudioThreshold only — dBFS level that counts as a trigger. */
6886
+ thresholdDbfs: number().optional()
6887
+ });
6888
+ /**
6889
+ * Per-device retention overrides. Every field is optional; an unset or `0`
6890
+ * value inherits the node-wide recorder default. Only footage-lifetime limits
6891
+ * live per-camera: `maxAgeDays` and `maxSizeGb`. The disk-occupancy threshold
6892
+ * (when the volume is too full to keep recording) is NOT a per-camera concern —
6893
+ * it belongs to the StorageLocation (`StorageLocation.config.minFreePercent`),
6894
+ * shared by every camera writing to that volume.
6895
+ */
6896
+ var RecordingRetentionSchema = object({
6897
+ maxAgeDays: number().min(0).optional(),
6898
+ maxSizeGb: number().min(0).optional()
6899
+ });
6900
+ /**
6901
+ * The full per-camera recording intent — the wire shape of a RecordingTarget.
6902
+ *
6903
+ * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
6904
+ * are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
6905
+ * only for transition + migration (`migrateRulesToMode`); the policy engine
6906
+ * consumes the compiled output of `compileRules(config)`, never `rules` directly.
6907
+ */
6908
+ var RecordingConfigSchema = object({
6909
+ enabled: boolean(),
6910
+ /** Authoritative storage mode. Absent on legacy targets derived once via
6911
+ * `migrateRulesToMode`, then persisted. */
6912
+ mode: RecordingStorageModeSchema.optional(),
6913
+ profiles: array(CamProfileSchema).optional(),
6914
+ segmentSeconds: number().int().positive().optional(),
6915
+ /** Shared recording time-bands for `events` & `continuous` — record only when
6916
+ * the wall-clock falls inside one of these windows. Omit or empty = always.
6917
+ * `continuous` compiles to one rule per band; `events` to band × trigger. */
6918
+ schedules: array(RecordingScheduleSchema).optional(),
6919
+ /** Legacy single-band predecessor of `schedules`. Read-compat only — it is
6920
+ * normalized into `schedules` on read and never written going forward. (Not
6921
+ * tagged `@deprecated`: the normalization paths must read it cast-free.) */
6922
+ schedule: RecordingScheduleSchema.optional(),
6923
+ /** `events`-mode only which detectors trigger a recording. */
6924
+ triggers: RecordingTriggersSchema.optional(),
6925
+ /** `events`-mode only seconds retained before / after a trigger. */
6926
+ preBufferSec: number().min(0).optional(),
6927
+ postBufferSec: number().min(0).optional(),
6928
+ /** DEPRECATED authoring input; retained for migration/transition. */
6929
+ rules: array(RecordingRuleSchema).optional(),
7134
6930
  /**
7135
- * Device supports an on-demand re-sync of its derived spec with its
7136
- * upstream source drives the generic Re-sync button. The owning
7137
- * provider implements the action via the `device-adoption.resync` cap.
6931
+ * AUTHORITATIVE mode-per-band recording model (recorder). When present it
6932
+ * is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
6933
+ * `triggers`/`rules` fields above are kept for READ-COMPAT only and are
6934
+ * derived into bands once via `migrateConfigToBands`.
7138
6935
  */
7139
- DeviceFeature["Resyncable"] = "resyncable";
7140
- DeviceFeature["NativeSnapshot"] = "native-snapshot";
7141
- DeviceFeature["DoorbellButton"] = "doorbell-button";
7142
- DeviceFeature["TwoWayAudio"] = "two-way-audio";
7143
- DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
6936
+ bands: array(RecordingBandSchema).optional(),
6937
+ retention: RecordingRetentionSchema.optional()
6938
+ });
6939
+ /**
6940
+ * `StorageLocationType` — an addon-declared id that identifies the *kind* of
6941
+ * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
6942
+ * so the persisted record schema and the consumer-facing cap can both consume it
6943
+ * without forming a circular import. The `storage` cap re-exports it
6944
+ * verbatim for back-compat.
6945
+ *
6946
+ * This Zod schema is the **authoritative source** for `StorageLocationType`.
6947
+ * The TS alias in `./storage.ts` re-exports `z.infer<typeof
6948
+ * StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
6949
+ * `IStorageProvider` interface stay in lockstep.
6950
+ *
6951
+ * The type is now an **open string** (not a closed enum) — addons declare
6952
+ * their own location kinds via `StorageLocationDeclaration.id`. The regex
6953
+ * enforces a safe id format: lowercase-start, alphanumeric + hyphens.
6954
+ */
6955
+ var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
6956
+ /**
6957
+ * Persisted record for a storage location instance. Operators can register
6958
+ * multiple instances for multi-cardinality types (e.g. two `backups`
6959
+ * locations with different `providerId`s). Cardinality is now declared per
6960
+ * location via `StorageLocationDeclaration.cardinality` — the static
6961
+ * `STORAGE_LOCATION_CARDINALITY` map has been removed.
6962
+ *
6963
+ * `id` is a stable namespaced string of the form `<type>:<slug>`.
6964
+ * The default location for a type uses `id === <type>:default` by
6965
+ * convention (the bare type ref like `'backups'` resolves to it).
6966
+ *
6967
+ * `isSystem: true` marks a location as orchestrator-seeded and
6968
+ * undeletable. The bootstrap-installed defaults (one per type) carry
6969
+ * this flag; operator-added locations don't. Editing the config of
6970
+ * a system location is allowed (path migration, provider swap) but
6971
+ * deleting it is rejected at the cap level.
6972
+ */
6973
+ var StorageLocationSchema = object({
6974
+ id: string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
6975
+ type: string(),
6976
+ displayName: string().min(1),
6977
+ providerId: string().min(1),
6978
+ config: record(string(), unknown()),
6979
+ /**
6980
+ * Cluster node this location physically lives on. REQUIRED for node-local
6981
+ * providers (filesystem — the path exists on one node's disk), null/absent
6982
+ * for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
6983
+ * `'hub'` is the hub node. Validated against the provider's `nodeLocal`
6984
+ * flag at upsert time, not here (the schema is provider-agnostic).
6985
+ */
6986
+ nodeId: string().optional(),
6987
+ isDefault: boolean().default(false),
6988
+ isSystem: boolean().default(false),
6989
+ createdAt: number(),
6990
+ updatedAt: number()
6991
+ });
6992
+ /**
6993
+ * Reference accepted by consumer-facing `api.storage.*` calls.
6994
+ * Either:
6995
+ * - a `StorageLocationType` (e.g. `'backups'`) → orchestrator resolves to the default of that type
6996
+ * - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
6997
+ *
6998
+ * The orchestrator's `resolveRef(ref)` handles both cases.
6999
+ */
7000
+ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
7001
+ /**
7002
+ * `StorageLocationDeclaration` — a single storage-location entry declared by
7003
+ * an addon in its `package.json` under `camstack.storageLocations`.
7004
+ *
7005
+ * Design intent:
7006
+ * - **Addon declares its needs** — each addon describes the logical storage
7007
+ * slots it requires (e.g. `recordings`, `recordingsLow`) without caring
7008
+ * about the physical path.
7009
+ * - **Kernel aggregates** — at boot the kernel collects declarations from all
7010
+ * installed addons, deduplicates by `id`, and exposes the union via the
7011
+ * storage-locations settings surface.
7012
+ * - **Orchestrator seeds** — for every declared `id` the orchestrator ensures
7013
+ * at least one instance named `<id>:default` is present, using
7014
+ * `defaultsTo` to inherit the resolved root from another location when the
7015
+ * declaration is a derivative slot (e.g. `recordingsLow` defaults to
7016
+ * `recordings`).
7017
+ * - **ids are global** — `id` values are shared across the entire deployment;
7018
+ * two addons declaring the same `id` must agree on `cardinality` (validated
7019
+ * at kernel aggregation time, not here).
7020
+ */
7021
+ var StorageLocationDeclarationSchema = object({
7022
+ /**
7023
+ * Global location identifier, e.g. `recordings` or `recordingsLow`.
7024
+ * Must start with a lowercase letter and may contain letters, digits, and
7025
+ * hyphens.
7026
+ */
7027
+ id: string().regex(/^[a-z][a-zA-Z0-9-]*$/, { message: "id must start with a lowercase letter and contain only letters, digits, or hyphens" }),
7028
+ /** Human-readable name shown in the admin UI. */
7029
+ displayName: string().min(1, { message: "displayName must not be empty" }),
7030
+ /** Optional longer explanation of what data this location stores. */
7031
+ description: string().optional(),
7032
+ /**
7033
+ * `single` — exactly one instance of this location is allowed system-wide
7034
+ * (e.g. `logs`, `models`). The operator can edit it but not add more.
7035
+ * `multi` — the operator may register several instances (e.g. a second
7036
+ * `recordings` on a NAS for disk tiering); one is the default at any time.
7037
+ */
7038
+ cardinality: _enum(["single", "multi"]),
7039
+ /**
7040
+ * When set, the default instance for this location inherits its resolved
7041
+ * root from the named location's default instance. Useful for derivative
7042
+ * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
7043
+ * configure the primary location.
7044
+ */
7045
+ defaultsTo: string().optional()
7046
+ });
7047
+ var DecoderStatsSchema = object({
7048
+ inputFps: number(),
7049
+ outputFps: number(),
7050
+ avgDecodeTimeMs: number(),
7051
+ droppedFrames: number()
7052
+ });
7053
+ var DecoderSessionConfigSchema = object({
7054
+ codec: string(),
7055
+ maxFps: number().default(0),
7056
+ outputFormat: _enum([
7057
+ "jpeg",
7058
+ "rgb",
7059
+ "bgr",
7060
+ "yuv420",
7061
+ "gray"
7062
+ ]).default("jpeg"),
7063
+ scale: number().default(1),
7064
+ width: number().optional(),
7065
+ height: number().optional(),
7066
+ /**
7067
+ * Identifier of the camera this decoder session serves. Optional
7068
+ * because the cap is generic (any caller could request decode), but
7069
+ * stream-broker passes it so decoder logs include `deviceId` for
7070
+ * per-camera filtering when diagnosing failures (e.g. node-av
7071
+ * sendPacket errors on a single hung camera).
7072
+ */
7073
+ deviceId: number().int().nonnegative().optional(),
7074
+ /**
7075
+ * Free-form tag for log scoping. Stream-broker uses
7076
+ * `broker:<deviceId>/<profile>`. Decoder session logger surfaces it
7077
+ * on every line so `grep tag=broker:5/high` filters one camera
7078
+ * profile cleanly.
7079
+ */
7080
+ tag: string().optional(),
7081
+ /**
7082
+ * Where the session delivers decoded frames (Phase 5 / D9):
7083
+ *
7084
+ * - `'callback'` (default) — the legacy pixel path: decoded frames are
7085
+ * buffered as `DecodedFrame`s and drained via `pullFrames`.
7086
+ * - `'shm'` — the shared-memory frame plane: decoded frames are written
7087
+ * into an OS shared-memory ring and drained as zero-pixel
7088
+ * `FrameHandle`s via `pullHandles`. A session is one mode or the
7089
+ * other — `pullFrames` returns nothing for an `'shm'` session and
7090
+ * `pullHandles` returns nothing for a `'callback'` session.
7091
+ */
7092
+ frameSink: _enum(["callback", "shm"]).default("callback")
7093
+ });
7094
+ var EncodeProfileSchema = object({
7095
+ video: object({
7096
+ codec: _enum([
7097
+ "h264",
7098
+ "h265",
7099
+ "copy"
7100
+ ]),
7101
+ profile: _enum([
7102
+ "baseline",
7103
+ "main",
7104
+ "high"
7105
+ ]).optional(),
7106
+ width: number().int().positive().optional(),
7107
+ height: number().int().positive().optional(),
7108
+ fps: number().positive().optional(),
7109
+ bitrateKbps: number().int().positive().optional(),
7110
+ gopFrames: number().int().positive().optional(),
7111
+ bf: number().int().min(0).optional(),
7112
+ preset: _enum([
7113
+ "ultrafast",
7114
+ "superfast",
7115
+ "veryfast",
7116
+ "faster",
7117
+ "fast",
7118
+ "medium"
7119
+ ]).optional(),
7120
+ tune: _enum([
7121
+ "zerolatency",
7122
+ "film",
7123
+ "animation"
7124
+ ]).optional()
7125
+ }),
7126
+ audio: union([literal("passthrough"), object({
7127
+ codec: _enum([
7128
+ "opus",
7129
+ "aac",
7130
+ "pcmu",
7131
+ "pcma",
7132
+ "copy"
7133
+ ]),
7134
+ bitrateKbps: number().int().positive().optional(),
7135
+ sampleRateHz: number().int().positive().optional(),
7136
+ channels: union([literal(1), literal(2)]).optional()
7137
+ })]),
7144
7138
  /**
7145
- * Camera supports the on-firmware autotrack subsystem (subject-
7146
- * following). Distinct from `PanTiltZoom` because not every PTZ
7147
- * camera ships autotrack the admin UI uses this flag to gate
7148
- * the autotrack toggle / settings card without re-deriving from
7149
- * the cap registry. Mirrors `ptz-autotrack` cap registration:
7150
- * driver sets this feature when probe confirms the firmware
7151
- * surface, and registers the cap in the same code path.
7139
+ * ffmpeg input-side args, inserted between the fixed global flags
7140
+ * (`-hide_banner -loglevel error`) and `-i pipe:0`. Free-text array
7141
+ * the widget surfaces a textarea + suggestion chips for the most-
7142
+ * used demuxer/format options.
7152
7143
  */
7153
- DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
7144
+ inputArgs: array(string()).optional(),
7154
7145
  /**
7155
- * Accessory exposes a "trigger on motion" toggle the parent camera's
7156
- * motion detection automatically activates this device. Mirrors
7157
- * `motion-trigger` cap registration: drivers set this feature in the
7158
- * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
7159
- *
7160
- * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
7161
- * fast scalar without binding fetch), notifier rules, and `listAll`
7162
- * filters that want "all devices with on-motion behaviour".
7146
+ * ffmpeg output-side args, inserted between the encode block and
7147
+ * the final `-f <muxer> pipe:1`. Use for muxer options, bitstream
7148
+ * filters, codec-specific overrides. Free-text array.
7163
7149
  */
7164
- DeviceFeature["MotionTrigger"] = "motion-trigger";
7165
- /** Light supports rgb-triplet color via `color` cap. */
7166
- DeviceFeature["LightColorRgb"] = "light-color-rgb";
7167
- /** Light supports HSV color via `color` cap. */
7168
- DeviceFeature["LightColorHsv"] = "light-color-hsv";
7169
- /** Light supports color-temperature (mired) via `color` cap. */
7170
- DeviceFeature["LightColorMired"] = "light-color-mired";
7171
- /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
7172
- * targetHigh). Gates the range slider UI. */
7173
- DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
7174
- /** Thermostat exposes target humidity and/or current humidity
7175
- * readings. Gates the humidity controls. */
7176
- DeviceFeature["ClimateHumidity"] = "climate-humidity";
7177
- /** Thermostat exposes a fan-mode selector. */
7178
- DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
7179
- /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
7180
- DeviceFeature["ClimatePreset"] = "climate-preset";
7181
- /** Cover exposes intermediate position control (0..100). Gates the
7182
- * position slider UI. */
7183
- DeviceFeature["CoverPositionable"] = "cover-positionable";
7184
- /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
7185
- DeviceFeature["CoverTilt"] = "cover-tilt";
7186
- /** Valve exposes intermediate position control (0..100). Gates the
7187
- * position slider / drag surface UI. */
7188
- DeviceFeature["ValvePositionable"] = "valve-positionable";
7189
- /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
7190
- DeviceFeature["FanSpeed"] = "fan-speed";
7191
- /** Fan exposes a preset mode selector. */
7192
- DeviceFeature["FanPreset"] = "fan-preset";
7193
- /** Fan exposes blade direction (forward/reverse) — typical of
7194
- * ceiling fans. */
7195
- DeviceFeature["FanDirection"] = "fan-direction";
7196
- /** Fan exposes an oscillation toggle. */
7197
- DeviceFeature["FanOscillating"] = "fan-oscillating";
7198
- /** Lock requires a PIN code on lock/unlock. Gates the code-entry
7199
- * field on the UI lock-controls panel. */
7200
- DeviceFeature["LockPinRequired"] = "lock-pin-required";
7201
- /** Lock supports a latch-release ("open door") action distinct from
7202
- * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
7203
- * `supported_features`. Gates the Open Door button in the UI. */
7204
- DeviceFeature["LockOpen"] = "lock-open";
7205
- /** Media player exposes a seek-to-position surface. */
7206
- DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
7207
- /** Media player exposes a volume-level setter. */
7208
- DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
7209
- /** Media player exposes a mute toggle distinct from volume=0. */
7210
- DeviceFeature["MediaPlayerMute"] = "media-player-mute";
7211
- /** Media player exposes a shuffle toggle. */
7212
- DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
7213
- /** Media player exposes a repeat mode (off / all / one). */
7214
- DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
7215
- /** Media player exposes a source / input selector. */
7216
- DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
7217
- /** Media player exposes a play-arbitrary-media surface (URL / id). */
7218
- DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
7219
- /** Media player exposes next-track. */
7220
- DeviceFeature["MediaPlayerNext"] = "media-player-next";
7221
- /** Media player exposes previous-track. */
7222
- DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
7223
- /** Media player exposes stop distinct from pause. */
7224
- DeviceFeature["MediaPlayerStop"] = "media-player-stop";
7225
- /** Alarm panel requires a PIN code on arm/disarm. */
7226
- DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
7227
- /** Presence device carries GPS coordinates (lat/lng/accuracy) in
7228
- * addition to a textual location. */
7229
- DeviceFeature["PresenceGps"] = "presence-gps";
7230
- /** Notifier accepts an inline / URL image attachment. */
7231
- DeviceFeature["NotifierImage"] = "notifier-image";
7232
- /** Notifier accepts a priority hint (high/normal/low). */
7233
- DeviceFeature["NotifierPriority"] = "notifier-priority";
7234
- /** Notifier accepts a free-form `data` payload for platform-specific
7235
- * fields. */
7236
- DeviceFeature["NotifierData"] = "notifier-data";
7237
- /** Notifier supports interactive action buttons / callbacks. */
7238
- DeviceFeature["NotifierActions"] = "notifier-actions";
7239
- /** Notifier supports per-call recipient targeting (multi-user). */
7240
- DeviceFeature["NotifierRecipients"] = "notifier-recipients";
7241
- /** Script runner accepts a variables map on each run invocation. */
7242
- DeviceFeature["ScriptVariables"] = "script-variables";
7243
- /** Automation `trigger` accepts a skipCondition flag — fires the
7244
- * automation's actions while bypassing its condition block. */
7245
- DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
7246
- return DeviceFeature;
7247
- }({});
7150
+ outputArgs: array(string()).optional()
7151
+ });
7152
+ function pickPreferredRtspEntry(entries, pref, deviceId, options = {}) {
7153
+ if (entries.length === 0) return null;
7154
+ const prefix = `${deviceId}/`;
7155
+ const toPicked = (e) => ({
7156
+ brokerId: e.brokerId,
7157
+ profileId: e.brokerId.startsWith(prefix) ? e.brokerId.slice(prefix.length) : e.brokerId,
7158
+ url: e.url,
7159
+ mutedUrl: e.mutedUrl,
7160
+ enabled: e.enabled,
7161
+ ...e.codec !== void 0 ? { codec: e.codec } : {},
7162
+ ...e.resolution !== void 0 ? { resolution: e.resolution } : {}
7163
+ });
7164
+ if (pref !== "auto") {
7165
+ const match = entries.find((e) => e.enabled && e.url.length > 0 && (e.profile === pref || e.brokerId === `${prefix}${pref}`));
7166
+ if (match) return toPicked(match);
7167
+ }
7168
+ const eligible = entries.filter((e) => e.enabled && e.url.length > 0);
7169
+ if (eligible.length === 0) return null;
7170
+ const target = options.targetResolution;
7171
+ if (target) {
7172
+ const withRes = eligible.filter((e) => e.resolution !== void 0);
7173
+ if (withRes.length > 0) {
7174
+ const picked = pickClosestResolution(withRes, target);
7175
+ if (picked) return toPicked(picked);
7176
+ }
7177
+ }
7178
+ return toPicked(eligible[0]);
7179
+ }
7248
7180
  /**
7249
- * Semantic role a device plays within its parent. Populated by driver
7250
- * addons when creating accessory devices (Reolink siren/floodlight/
7251
- * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
7252
- * admin UI to pick icons, labels, and widgets — a `Switch` with
7253
- * `role: Floodlight` renders as a bulb with a brightness slider,
7254
- * whereas a `Switch` with `role: Siren` renders as a klaxon.
7255
- *
7256
- * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
7257
- * sqlite as a nullable TEXT column — old rows keep working unchanged.
7258
- */
7259
- var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7260
- DeviceRole["Siren"] = "siren";
7261
- DeviceRole["Floodlight"] = "floodlight";
7262
- DeviceRole["Spotlight"] = "spotlight";
7263
- DeviceRole["PirSensor"] = "pir-sensor";
7264
- DeviceRole["Chime"] = "chime";
7265
- DeviceRole["Autotrack"] = "autotrack";
7266
- DeviceRole["Nightvision"] = "nightvision";
7267
- DeviceRole["PrivacyMask"] = "privacy-mask";
7268
- DeviceRole["Doorbell"] = "doorbell";
7269
- /** Virtual HA toggle (input_boolean.*) — distinguishable from a
7270
- * real Switch device for UI rendering / export adapters. */
7271
- DeviceRole["BinaryHelper"] = "binary-helper";
7272
- /** Generic motion / occupancy / moving event source. Distinct from
7273
- * the camera accessory PirSensor role: that one is a camera child;
7274
- * this is a standalone HA / 3rd-party motion sensor. */
7275
- DeviceRole["MotionSensor"] = "motion-sensor";
7276
- DeviceRole["ContactSensor"] = "contact-sensor";
7277
- DeviceRole["LeakSensor"] = "leak-sensor";
7278
- DeviceRole["SmokeSensor"] = "smoke-sensor";
7279
- DeviceRole["COSensor"] = "co-sensor";
7280
- DeviceRole["GasSensor"] = "gas-sensor";
7281
- DeviceRole["TamperSensor"] = "tamper-sensor";
7282
- DeviceRole["VibrationSensor"] = "vibration-sensor";
7283
- DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
7284
- DeviceRole["SoundSensor"] = "sound-sensor";
7285
- /** Fallback for `binary_sensor` without a known `device_class`. */
7286
- DeviceRole["BinarySensor"] = "binary-sensor";
7287
- DeviceRole["TemperatureSensor"] = "temperature-sensor";
7288
- DeviceRole["HumiditySensor"] = "humidity-sensor";
7289
- DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
7290
- DeviceRole["PressureSensor"] = "pressure-sensor";
7291
- DeviceRole["PowerSensor"] = "power-sensor";
7292
- DeviceRole["EnergySensor"] = "energy-sensor";
7293
- DeviceRole["VoltageSensor"] = "voltage-sensor";
7294
- DeviceRole["CurrentSensor"] = "current-sensor";
7295
- DeviceRole["AirQualitySensor"] = "air-quality-sensor";
7296
- /** Battery level (numeric % via `sensor` OR low-bool via
7297
- * `binary_sensor` the cap distinguishes via the value type). */
7298
- DeviceRole["BatterySensor"] = "battery-sensor";
7299
- /** Fallback for `sensor` numeric without a known `device_class`. */
7300
- DeviceRole["NumericSensor"] = "numeric-sensor";
7301
- /** String / enum state (HA `sensor` with `state_class: enum` or
7302
- * `attributes.options`). */
7303
- DeviceRole["EnumSensor"] = "enum-sensor";
7304
- /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
7305
- * or `date`). The slice carries the raw ISO string verbatim (hosted on
7306
- * the `enum-sensor` cap); the UI renders it locale-formatted. */
7307
- DeviceRole["DateTimeSensor"] = "datetime-sensor";
7308
- /** Last-resort fallback when nothing else matches. */
7309
- DeviceRole["GenericSensor"] = "generic-sensor";
7310
- DeviceRole["NumericControl"] = "numeric-control";
7311
- DeviceRole["SelectControl"] = "select-control";
7312
- DeviceRole["TextControl"] = "text-control";
7313
- DeviceRole["DateTimeControl"] = "datetime-control";
7314
- /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
7315
- * rich features (image, priority, channel routing). */
7316
- DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
7317
- /** Chat / messaging service (HA `notify.telegram_*`,
7318
- * `notify.discord_*`, etc.). */
7319
- DeviceRole["MessagingNotifier"] = "messaging-notifier";
7320
- /** Email-based delivery (HA `notify.smtp`, etc.). */
7321
- DeviceRole["EmailNotifier"] = "email-notifier";
7322
- /** Fallback when the notifier service name doesn't match a known
7323
- * pattern. */
7324
- DeviceRole["GenericNotifier"] = "generic-notifier";
7325
- return DeviceRole;
7326
- }({});
7181
+ * Pick the entry whose `resolution` is closest to `target`. Prefer
7182
+ * entries target (downscale is cheap at the consumer; upscale is
7183
+ * lossy). Among the rest pick the LARGEST still ≤ target so the
7184
+ * consumer gets the best feasible quality. "Closeness" is the
7185
+ * `width × height` pixel delta.
7186
+ */
7187
+ function pickClosestResolution(entries, target) {
7188
+ const targetPixels = target.width * target.height;
7189
+ let bestAbove;
7190
+ let bestBelow;
7191
+ for (const e of entries) {
7192
+ if (e.resolution === void 0) continue;
7193
+ const pixels = e.resolution.width * e.resolution.height;
7194
+ if (pixels >= targetPixels) {
7195
+ if (!bestAbove || pixels < bestAbove.pixels) bestAbove = {
7196
+ entry: e,
7197
+ pixels
7198
+ };
7199
+ } else if (!bestBelow || pixels > bestBelow.pixels) bestBelow = {
7200
+ entry: e,
7201
+ pixels
7202
+ };
7203
+ }
7204
+ return bestAbove?.entry ?? bestBelow?.entry;
7205
+ }
7206
+ var YAMNET_TO_MACRO = {
7207
+ mapping: {
7208
+ Speech: "speech",
7209
+ "Child speech, kid speaking": "speech",
7210
+ Conversation: "speech",
7211
+ "Narration, monologue": "speech",
7212
+ Babbling: "speech",
7213
+ Whispering: "speech",
7214
+ "Speech synthesizer": "speech",
7215
+ Humming: "speech",
7216
+ Rapping: "speech",
7217
+ Singing: "speech",
7218
+ Choir: "speech",
7219
+ "Child singing": "speech",
7220
+ Shout: "scream",
7221
+ Bellow: "scream",
7222
+ Yell: "scream",
7223
+ Screaming: "scream",
7224
+ "Children shouting": "scream",
7225
+ Whoop: "scream",
7226
+ "Crying, sobbing": "crying",
7227
+ "Baby cry, infant cry": "crying",
7228
+ Whimper: "crying",
7229
+ "Wail, moan": "crying",
7230
+ Groan: "crying",
7231
+ Laughter: "laughter",
7232
+ "Baby laughter": "laughter",
7233
+ Giggle: "laughter",
7234
+ Snicker: "laughter",
7235
+ "Belly laugh": "laughter",
7236
+ "Chuckle, chortle": "laughter",
7237
+ Music: "music",
7238
+ "Musical instrument": "music",
7239
+ Guitar: "music",
7240
+ Piano: "music",
7241
+ Drum: "music",
7242
+ "Drum kit": "music",
7243
+ "Violin, fiddle": "music",
7244
+ Flute: "music",
7245
+ Saxophone: "music",
7246
+ Trumpet: "music",
7247
+ Synthesizer: "music",
7248
+ "Pop music": "music",
7249
+ "Rock music": "music",
7250
+ "Hip hop music": "music",
7251
+ "Classical music": "music",
7252
+ Jazz: "music",
7253
+ "Electronic music": "music",
7254
+ "Background music": "music",
7255
+ Dog: "dog",
7256
+ Bark: "dog",
7257
+ Yip: "dog",
7258
+ Howl: "dog",
7259
+ "Bow-wow": "dog",
7260
+ Growling: "dog",
7261
+ "Whimper (dog)": "dog",
7262
+ Cat: "cat",
7263
+ Purr: "cat",
7264
+ Meow: "cat",
7265
+ Hiss: "cat",
7266
+ Caterwaul: "cat",
7267
+ Bird: "bird",
7268
+ "Bird vocalization, bird call, bird song": "bird",
7269
+ "Chirp, tweet": "bird",
7270
+ Squawk: "bird",
7271
+ Crow: "bird",
7272
+ Owl: "bird",
7273
+ "Pigeon, dove": "bird",
7274
+ Animal: "animal",
7275
+ "Domestic animals, pets": "animal",
7276
+ "Livestock, farm animals, working animals": "animal",
7277
+ Horse: "animal",
7278
+ "Cattle, bovinae": "animal",
7279
+ Pig: "animal",
7280
+ Sheep: "animal",
7281
+ Goat: "animal",
7282
+ Frog: "animal",
7283
+ Insect: "animal",
7284
+ Cricket: "animal",
7285
+ Alarm: "alarm",
7286
+ "Alarm clock": "alarm",
7287
+ "Smoke detector, smoke alarm": "alarm",
7288
+ "Fire alarm": "alarm",
7289
+ Buzzer: "alarm",
7290
+ "Civil defense siren": "alarm",
7291
+ "Car alarm": "alarm",
7292
+ Siren: "siren",
7293
+ "Police car (siren)": "siren",
7294
+ "Ambulance (siren)": "siren",
7295
+ "Fire engine, fire truck (siren)": "siren",
7296
+ "Emergency vehicle": "siren",
7297
+ Foghorn: "siren",
7298
+ Doorbell: "doorbell",
7299
+ "Ding-dong": "doorbell",
7300
+ Knock: "doorbell",
7301
+ Tap: "doorbell",
7302
+ Glass: "glass_breaking",
7303
+ Shatter: "glass_breaking",
7304
+ "Chink, clink": "glass_breaking",
7305
+ "Gunshot, gunfire": "gunshot",
7306
+ "Machine gun": "gunshot",
7307
+ Explosion: "gunshot",
7308
+ Fireworks: "gunshot",
7309
+ Firecracker: "gunshot",
7310
+ "Artillery fire": "gunshot",
7311
+ "Cap gun": "gunshot",
7312
+ Boom: "gunshot",
7313
+ Vehicle: "vehicle",
7314
+ Car: "vehicle",
7315
+ Truck: "vehicle",
7316
+ Bus: "vehicle",
7317
+ Motorcycle: "vehicle",
7318
+ "Car passing by": "vehicle",
7319
+ "Vehicle horn, car horn, honking": "vehicle",
7320
+ "Traffic noise, roadway noise": "vehicle",
7321
+ Train: "vehicle",
7322
+ Aircraft: "vehicle",
7323
+ Helicopter: "vehicle",
7324
+ Bicycle: "vehicle",
7325
+ Skateboard: "vehicle",
7326
+ Fire: "fire",
7327
+ Crackle: "fire",
7328
+ Water: "water",
7329
+ Rain: "water",
7330
+ Raindrop: "water",
7331
+ "Rain on surface": "water",
7332
+ Stream: "water",
7333
+ Waterfall: "water",
7334
+ Ocean: "water",
7335
+ "Waves, surf": "water",
7336
+ "Splash, splatter": "water",
7337
+ Wind: "wind",
7338
+ Thunderstorm: "wind",
7339
+ Thunder: "wind",
7340
+ "Wind noise (microphone)": "wind",
7341
+ "Rustling leaves": "wind",
7342
+ Door: "door",
7343
+ "Sliding door": "door",
7344
+ Slam: "door",
7345
+ "Cupboard open or close": "door",
7346
+ "Walk, footsteps": "footsteps",
7347
+ Run: "footsteps",
7348
+ Shuffle: "footsteps",
7349
+ Crowd: "crowd",
7350
+ Chatter: "crowd",
7351
+ Cheering: "crowd",
7352
+ Applause: "crowd",
7353
+ "Children playing": "crowd",
7354
+ "Hubbub, speech noise, speech babble": "crowd",
7355
+ Telephone: "telephone",
7356
+ "Telephone bell ringing": "telephone",
7357
+ Ringtone: "telephone",
7358
+ "Telephone dialing, DTMF": "telephone",
7359
+ "Busy signal": "telephone",
7360
+ Engine: "engine",
7361
+ "Engine starting": "engine",
7362
+ Idling: "engine",
7363
+ "Accelerating, revving, vroom": "engine",
7364
+ "Light engine (high frequency)": "engine",
7365
+ "Medium engine (mid frequency)": "engine",
7366
+ "Heavy engine (low frequency)": "engine",
7367
+ "Lawn mower": "engine",
7368
+ Chainsaw: "engine",
7369
+ Hammer: "tools",
7370
+ Jackhammer: "tools",
7371
+ Sawing: "tools",
7372
+ "Power tool": "tools",
7373
+ Drill: "tools",
7374
+ Sanding: "tools",
7375
+ Silence: "silence"
7376
+ },
7377
+ preserveOriginal: false
7378
+ };
7379
+ var APPLE_SA_TO_MACRO = {
7380
+ mapping: {
7381
+ speech: "speech",
7382
+ child_speech: "speech",
7383
+ conversation: "speech",
7384
+ whispering: "speech",
7385
+ singing: "speech",
7386
+ humming: "speech",
7387
+ shout: "scream",
7388
+ yell: "scream",
7389
+ screaming: "scream",
7390
+ crying: "crying",
7391
+ baby_crying: "crying",
7392
+ sobbing: "crying",
7393
+ laughter: "laughter",
7394
+ baby_laughter: "laughter",
7395
+ giggling: "laughter",
7396
+ music: "music",
7397
+ guitar: "music",
7398
+ piano: "music",
7399
+ drums: "music",
7400
+ dog_bark: "dog",
7401
+ dog_bow_wow: "dog",
7402
+ dog_growling: "dog",
7403
+ dog_howl: "dog",
7404
+ cat_meow: "cat",
7405
+ cat_purr: "cat",
7406
+ cat_hiss: "cat",
7407
+ bird: "bird",
7408
+ bird_chirp: "bird",
7409
+ bird_squawk: "bird",
7410
+ animal: "animal",
7411
+ horse: "animal",
7412
+ cow_moo: "animal",
7413
+ insect: "animal",
7414
+ alarm: "alarm",
7415
+ smoke_alarm: "alarm",
7416
+ fire_alarm: "alarm",
7417
+ car_alarm: "alarm",
7418
+ siren: "siren",
7419
+ police_siren: "siren",
7420
+ ambulance_siren: "siren",
7421
+ doorbell: "doorbell",
7422
+ door_knock: "doorbell",
7423
+ knocking: "doorbell",
7424
+ glass_breaking: "glass_breaking",
7425
+ glass_shatter: "glass_breaking",
7426
+ gunshot: "gunshot",
7427
+ explosion: "gunshot",
7428
+ fireworks: "gunshot",
7429
+ car: "vehicle",
7430
+ truck: "vehicle",
7431
+ motorcycle: "vehicle",
7432
+ car_horn: "vehicle",
7433
+ vehicle_horn: "vehicle",
7434
+ traffic: "vehicle",
7435
+ fire: "fire",
7436
+ fire_crackle: "fire",
7437
+ water: "water",
7438
+ rain: "water",
7439
+ ocean: "water",
7440
+ splash: "water",
7441
+ wind: "wind",
7442
+ thunder: "wind",
7443
+ thunderstorm: "wind",
7444
+ door: "door",
7445
+ door_slam: "door",
7446
+ sliding_door: "door",
7447
+ footsteps: "footsteps",
7448
+ walking: "footsteps",
7449
+ running: "footsteps",
7450
+ crowd: "crowd",
7451
+ chatter: "crowd",
7452
+ cheering: "crowd",
7453
+ applause: "crowd",
7454
+ telephone_ring: "telephone",
7455
+ ringtone: "telephone",
7456
+ engine: "engine",
7457
+ engine_starting: "engine",
7458
+ lawn_mower: "engine",
7459
+ chainsaw: "engine",
7460
+ hammer: "tools",
7461
+ jackhammer: "tools",
7462
+ drill: "tools",
7463
+ power_tool: "tools",
7464
+ silence: "silence"
7465
+ },
7466
+ preserveOriginal: false
7467
+ };
7468
+ var _macroLookup = /* @__PURE__ */ new Map();
7469
+ for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7470
+ for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7327
7471
  /**
7328
7472
  * Accessory device helpers — shared across drivers.
7329
7473
  *
@@ -7483,74 +7627,6 @@ object({
7483
7627
  });
7484
7628
  DeviceType.Sensor;
7485
7629
  /**
7486
- * Generic types for capability definitions.
7487
- *
7488
- * A capability is defined with Zod schemas for methods, events, and settings.
7489
- * TypeScript types are inferred via z.infer<> — zero duplication.
7490
- *
7491
- * Pattern:
7492
- * 1. Define Zod schemas for data, methods, settings
7493
- * 2. Export const capabilityDef = { ... } satisfies CapabilityDefinition
7494
- * 3. Export type IProvider = InferProvider<typeof capabilityDef>
7495
- * 4. Addon implements IProvider
7496
- * 5. Registry auto-mounts tRPC router from definition.methods
7497
- */
7498
- /**
7499
- * Output schema shared by the contribution + live methods.
7500
- *
7501
- * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
7502
- * tabs[]) without importing from `../interfaces/config-ui.js` — a
7503
- * concrete-but-lenient Zod object keeps tRPC output inference happy
7504
- * (using `z.unknown()` here collapses unrelated router branches to
7505
- * `unknown` when the generator re-inlines the huge AppRouter type).
7506
- *
7507
- * `.passthrough()` on sections/fields accepts whatever FormBuilder
7508
- * extensions the caller adds (showWhen, displayScale, …) without
7509
- * rebuilding every time a new field kind is introduced.
7510
- */
7511
- var ContributionSectionSchema = object({
7512
- id: string(),
7513
- title: string(),
7514
- description: string().optional(),
7515
- style: _enum(["card", "accordion"]).optional(),
7516
- defaultCollapsed: boolean().optional(),
7517
- columns: union([
7518
- literal(1),
7519
- literal(2),
7520
- literal(3),
7521
- literal(4)
7522
- ]).optional(),
7523
- tab: string().optional(),
7524
- location: _enum(["settings", "top-tab"]).optional(),
7525
- order: number().optional(),
7526
- fields: array(any())
7527
- });
7528
- object({
7529
- tabs: array(object({
7530
- id: string(),
7531
- label: string(),
7532
- icon: string(),
7533
- order: number().optional()
7534
- })).optional(),
7535
- sections: array(ContributionSectionSchema)
7536
- }).nullable();
7537
- object({ deviceId: number() }), object({ deviceId: number() }), object({
7538
- deviceId: number(),
7539
- patch: record(string(), unknown())
7540
- }), object({ success: literal(true) });
7541
- object({ deviceId: number() }), unknown().nullable();
7542
- /** Shorthand to define a method schema */
7543
- function method(input, output, options) {
7544
- return {
7545
- input,
7546
- output,
7547
- kind: options?.kind ?? "query",
7548
- auth: options?.auth ?? "protected",
7549
- ...options?.access !== void 0 ? { access: options.access } : {},
7550
- timeoutMs: options?.timeoutMs
7551
- };
7552
- }
7553
- /**
7554
7630
  * Alarm-panel cap. Models HA `alarm_control_panel.*` on
7555
7631
  * `DeviceType.AlarmPanel`. State follows HA's canonical lifecycle
7556
7632
  * across disarmed / armed_(home|away|night|vacation|custom_bypass) /
@@ -9365,6 +9441,24 @@ var DetectorOutputSchema = object({
9365
9441
  inferenceMs: number(),
9366
9442
  modelId: string()
9367
9443
  });
9444
+ var EngineProvisioningSchema = object({
9445
+ runtimeId: _enum([
9446
+ "onnx",
9447
+ "openvino",
9448
+ "coreml"
9449
+ ]).nullable(),
9450
+ device: string().nullable(),
9451
+ state: _enum([
9452
+ "idle",
9453
+ "installing",
9454
+ "verifying",
9455
+ "ready",
9456
+ "failed"
9457
+ ]),
9458
+ progress: number().optional(),
9459
+ error: string().optional(),
9460
+ nextRetryAt: number().optional()
9461
+ });
9368
9462
  var PipelineStepInputSchema = lazy(() => object({
9369
9463
  addonId: string(),
9370
9464
  modelId: string(),
@@ -9433,7 +9527,7 @@ var PipelineRunResultBridge = custom();
9433
9527
  method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(_void(), PipelineEngineChoiceSchema, {
9434
9528
  kind: "mutation",
9435
9529
  auth: "admin"
9436
- }), method(_void(), record(string(), object({
9530
+ }), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
9437
9531
  modelId: string(),
9438
9532
  settings: record(string(), unknown()).readonly()
9439
9533
  }))), method(object({ steps: record(string(), object({
@@ -11555,9 +11649,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
11555
11649
  limit: number().optional(),
11556
11650
  tags: record(string(), string()).optional()
11557
11651
  }), array(LogEntrySchema).readonly());
11558
- var StaticDirOutputSchema = object({ staticDir: string() });
11559
- var VersionOutputSchema = object({ version: string() });
11560
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
11561
11652
  /**
11562
11653
  * Zod schemas for persisted record types.
11563
11654
  *
@@ -13089,7 +13180,10 @@ var AgentAddonConfigSchema = object({
13089
13180
  modelId: string(),
13090
13181
  settings: record(string(), unknown()).readonly()
13091
13182
  });
13092
- var AgentPipelineSettingsSchema = object({ addonDefaults: record(string(), AgentAddonConfigSchema).readonly() });
13183
+ var AgentPipelineSettingsSchema = object({
13184
+ addonDefaults: record(string(), AgentAddonConfigSchema).readonly(),
13185
+ maxCameras: number().int().nonnegative().nullable().default(null)
13186
+ });
13093
13187
  var CameraPipelineForAgentSchema = object({
13094
13188
  steps: array(PipelineStepInputSchema).readonly(),
13095
13189
  audio: object({
@@ -13191,6 +13285,133 @@ var GlobalMetricsSchema = object({
13191
13285
  * capability providers.
13192
13286
  */
13193
13287
  var CapabilityBindingsSchema = record(string(), string());
13288
+ /** Source block — always present; derives from the stream catalog. */
13289
+ var CameraSourceStatusSchema = object({ streams: array(object({
13290
+ camStreamId: string(),
13291
+ codec: string(),
13292
+ width: number(),
13293
+ height: number(),
13294
+ fps: number(),
13295
+ kind: string()
13296
+ })).readonly() });
13297
+ /** Assignment block — always present (orchestrator-local, no remote call). */
13298
+ var CameraAssignmentStatusSchema = object({
13299
+ detectionNodeId: string().nullable(),
13300
+ decoderNodeId: string().nullable(),
13301
+ audioNodeId: string().nullable(),
13302
+ pinned: object({
13303
+ detection: boolean(),
13304
+ decoder: boolean(),
13305
+ audio: boolean()
13306
+ }),
13307
+ reasons: object({
13308
+ detection: string().optional(),
13309
+ decoder: string().optional(),
13310
+ audio: string().optional()
13311
+ })
13312
+ });
13313
+ /** Broker block — null when the broker stage is unreachable or inactive. */
13314
+ var CameraBrokerStatusSchema = object({
13315
+ profiles: array(object({
13316
+ profile: string(),
13317
+ status: string(),
13318
+ codec: string(),
13319
+ width: number(),
13320
+ height: number(),
13321
+ subscribers: number(),
13322
+ inFps: number(),
13323
+ outFps: number()
13324
+ })).readonly(),
13325
+ webrtcSessions: number(),
13326
+ rtspRestream: boolean()
13327
+ });
13328
+ /** Shared-memory ring statistics within the decoder block. */
13329
+ var CameraDecoderShmSchema = object({
13330
+ framesWritten: number(),
13331
+ getFrameHits: number(),
13332
+ getFrameMisses: number(),
13333
+ budgetMb: number()
13334
+ });
13335
+ /** Decoder block — null when the decoder stage is unreachable or inactive. */
13336
+ var CameraDecoderStatusSchema = object({
13337
+ nodeId: string(),
13338
+ formats: array(string()).readonly(),
13339
+ sessionCount: number(),
13340
+ shm: CameraDecoderShmSchema
13341
+ });
13342
+ /** Motion block — null when motion detection is not active for this device. */
13343
+ var CameraMotionStatusSchema = object({
13344
+ enabled: boolean(),
13345
+ fps: number()
13346
+ });
13347
+ /** Detection provisioning sub-block. */
13348
+ var CameraDetectionProvisioningSchema = object({
13349
+ state: _enum([
13350
+ "idle",
13351
+ "installing",
13352
+ "verifying",
13353
+ "ready",
13354
+ "failed"
13355
+ ]),
13356
+ error: string().optional()
13357
+ });
13358
+ /** Detection phase — derived from the runner's engine phase. */
13359
+ var CameraDetectionPhaseSchema = _enum([
13360
+ "idle",
13361
+ "watching",
13362
+ "active"
13363
+ ]);
13364
+ /** Detection block — null when no detection node is assigned or reachable. */
13365
+ var CameraDetectionStatusSchema = object({
13366
+ nodeId: string(),
13367
+ engine: object({
13368
+ backend: string(),
13369
+ device: string()
13370
+ }),
13371
+ phase: CameraDetectionPhaseSchema,
13372
+ configuredFps: number(),
13373
+ actualFps: number(),
13374
+ queueDepth: number(),
13375
+ avgInferenceMs: number(),
13376
+ provisioning: CameraDetectionProvisioningSchema
13377
+ });
13378
+ /** Audio block — null when no audio node is assigned or reachable. */
13379
+ var CameraAudioStatusSchema = object({
13380
+ nodeId: string(),
13381
+ enabled: boolean()
13382
+ });
13383
+ /** Recording block — null when no recording cap is active for this device. */
13384
+ var CameraRecordingStatusSchema = object({
13385
+ mode: _enum([
13386
+ "off",
13387
+ "continuous",
13388
+ "events"
13389
+ ]),
13390
+ active: boolean(),
13391
+ storageBytes: number()
13392
+ });
13393
+ /**
13394
+ * Aggregated per-camera pipeline status — server-composed, single call.
13395
+ *
13396
+ * The `assignment` and `source` blocks are always present.
13397
+ * Every other block is `null` when the stage is inactive or unreachable
13398
+ * during the bounded parallel fan-out in the orchestrator implementation.
13399
+ *
13400
+ * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
13401
+ */
13402
+ var CameraStatusSchema = object({
13403
+ deviceId: number(),
13404
+ assignment: CameraAssignmentStatusSchema,
13405
+ source: CameraSourceStatusSchema,
13406
+ broker: CameraBrokerStatusSchema.nullable(),
13407
+ decoder: CameraDecoderStatusSchema.nullable(),
13408
+ motion: CameraMotionStatusSchema.nullable(),
13409
+ detection: CameraDetectionStatusSchema.nullable(),
13410
+ audio: CameraAudioStatusSchema.nullable(),
13411
+ recording: CameraRecordingStatusSchema.nullable(),
13412
+ /** Unix timestamp (ms) when this snapshot was composed server-side. */
13413
+ fetchedAt: number()
13414
+ });
13194
13415
  method(object({
13195
13416
  deviceId: number(),
13196
13417
  agentNodeId: string()
@@ -13258,6 +13479,12 @@ method(object({
13258
13479
  }), {
13259
13480
  kind: "mutation",
13260
13481
  auth: "admin"
13482
+ }), method(object({
13483
+ agentNodeId: string(),
13484
+ maxCameras: number().int().nonnegative().nullable()
13485
+ }), object({ success: literal(true) }), {
13486
+ kind: "mutation",
13487
+ auth: "admin"
13261
13488
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
13262
13489
  deviceId: number(),
13263
13490
  addonId: string(),
@@ -13283,7 +13510,7 @@ method(object({
13283
13510
  }), method(object({
13284
13511
  deviceId: number(),
13285
13512
  agentNodeId: string().optional()
13286
- }), CameraPipelineConfigSchema), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
13513
+ }), CameraPipelineConfigSchema), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
13287
13514
  name: string(),
13288
13515
  description: string().optional(),
13289
13516
  config: CameraPipelineConfigSchema
@@ -13770,7 +13997,7 @@ method(object({
13770
13997
  }), _void(), {
13771
13998
  kind: "mutation",
13772
13999
  auth: "admin"
13773
- }), 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({
14000
+ }), 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({
13774
14001
  deviceId: number(),
13775
14002
  values: record(string(), unknown())
13776
14003
  }), object({ success: literal(true) }), {
@@ -14452,7 +14679,20 @@ var DiskSpaceInfoSchema = object({
14452
14679
  var PidResourceStatsSchema = object({
14453
14680
  pid: number(),
14454
14681
  cpu: number(),
14455
- memory: number()
14682
+ memory: number(),
14683
+ /**
14684
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
14685
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
14686
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
14687
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
14688
+ * Undefined where /proc is unavailable (e.g. macOS).
14689
+ */
14690
+ privateBytes: number().optional(),
14691
+ /**
14692
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
14693
+ * code shared copy-on-write across runners. Undefined on macOS.
14694
+ */
14695
+ sharedBytes: number().optional()
14456
14696
  });
14457
14697
  var AddonInstanceSchema = object({
14458
14698
  addonId: string(),
@@ -14501,6 +14741,17 @@ var KillProcessResultSchema = object({
14501
14741
  reason: string().optional(),
14502
14742
  signal: _enum(["SIGTERM", "SIGKILL"]).optional()
14503
14743
  });
14744
+ var DumpHeapSnapshotInputSchema = object({
14745
+ /** The addon whose runner should dump a heap snapshot. */
14746
+ addonId: string() });
14747
+ var DumpHeapSnapshotResultSchema = object({
14748
+ success: boolean(),
14749
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
14750
+ path: string().optional(),
14751
+ /** Process pid that was signalled. */
14752
+ pid: number().optional(),
14753
+ reason: string().optional()
14754
+ });
14504
14755
  var SystemMetricsSchema = object({
14505
14756
  cpuPercent: number(),
14506
14757
  memoryPercent: number(),
@@ -14514,6 +14765,9 @@ var SystemMetricsSchema = object({
14514
14765
  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, {
14515
14766
  kind: "mutation",
14516
14767
  auth: "admin"
14768
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
14769
+ kind: "mutation",
14770
+ auth: "admin"
14517
14771
  });
14518
14772
  var PtzPresetSchema = object({
14519
14773
  id: string(),
@@ -14880,63 +15134,6 @@ method(object({
14880
15134
  auth: "admin"
14881
15135
  });
14882
15136
  /**
14883
- * device-ops — device-scoped cap that unifies the per-IDevice operations
14884
- * previously routed through the `.device-ops` Moleculer bridge service.
14885
- *
14886
- * Each worker that hosts live `IDevice` instances auto-registers a native
14887
- * provider for this cap (per device) backed by its local
14888
- * `DeviceRegistry`. Hub-side callers reach it transparently through
14889
- * `ctx.fetchDevice(id).deviceOps.*` — the DeviceProxy injects
14890
- * `deviceId` + `nodeId` and dispatches through the standard cap-router,
14891
- * so there's no parallel bridge path anymore.
14892
- *
14893
- * The surface is intentionally small — every method corresponds to a
14894
- * single action on the live `IDevice` (or `ICameraDevice` for
14895
- * `getStreamSources`). Richer orchestration (enable/disable with
14896
- * integration plumbing, bulk updates) stays in the `device-manager` cap;
14897
- * `device-ops` is the per-device primitive the device-manager routes to.
14898
- */
14899
- var StreamSourceEntrySchema$1 = object({
14900
- id: string(),
14901
- label: string(),
14902
- protocol: _enum([
14903
- "rtsp",
14904
- "rtmp",
14905
- "annexb",
14906
- "http-mjpeg",
14907
- "webrtc",
14908
- "custom"
14909
- ]),
14910
- url: string().optional(),
14911
- resolution: object({
14912
- width: number(),
14913
- height: number()
14914
- }).optional(),
14915
- fps: number().optional(),
14916
- bitrate: number().optional(),
14917
- codec: string().optional(),
14918
- profileHint: CamProfileSchema.optional(),
14919
- sdp: string().optional()
14920
- });
14921
- var ConfigEntrySchema$1 = object({
14922
- key: string(),
14923
- value: unknown()
14924
- });
14925
- var RawStateResultSchema = object({
14926
- /** Originating provider id, e.g. 'homeassistant' | 'reolink' | 'hikvision'. */
14927
- source: string(),
14928
- /** Opaque, DISPLAY-SAFE upstream blob (no secrets/PII). */
14929
- data: record(string(), unknown())
14930
- });
14931
- method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
14932
- deviceId: number(),
14933
- values: record(string(), unknown())
14934
- }), _void(), { kind: "mutation" }), method(object({
14935
- deviceId: number(),
14936
- action: string().min(1),
14937
- input: unknown()
14938
- }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
14939
- /**
14940
15137
  * camera-credentials — device-scoped cap exposing the camera's network
14941
15138
  * + auth surface in a vendor-neutral shape.
14942
15139
  *
@@ -18619,6 +18816,12 @@ Object.freeze({
18619
18816
  addonId: null,
18620
18817
  access: "view"
18621
18818
  },
18819
+ "metricsProvider.dumpHeapSnapshot": {
18820
+ capName: "metrics-provider",
18821
+ capScope: "system",
18822
+ addonId: null,
18823
+ access: "create"
18824
+ },
18622
18825
  "metricsProvider.getAddonStats": {
18623
18826
  capName: "metrics-provider",
18624
18827
  capScope: "system",
@@ -19075,6 +19278,12 @@ Object.freeze({
19075
19278
  addonId: null,
19076
19279
  access: "view"
19077
19280
  },
19281
+ "pipelineExecutor.getEngineProvisioning": {
19282
+ capName: "pipeline-executor",
19283
+ capScope: "system",
19284
+ addonId: null,
19285
+ access: "view"
19286
+ },
19078
19287
  "pipelineExecutor.getGlobalPipelineConfig": {
19079
19288
  capName: "pipeline-executor",
19080
19289
  capScope: "system",
@@ -19279,6 +19488,18 @@ Object.freeze({
19279
19488
  addonId: null,
19280
19489
  access: "view"
19281
19490
  },
19491
+ "pipelineOrchestrator.getCameraStatus": {
19492
+ capName: "pipeline-orchestrator",
19493
+ capScope: "system",
19494
+ addonId: null,
19495
+ access: "view"
19496
+ },
19497
+ "pipelineOrchestrator.getCameraStatuses": {
19498
+ capName: "pipeline-orchestrator",
19499
+ capScope: "system",
19500
+ addonId: null,
19501
+ access: "view"
19502
+ },
19282
19503
  "pipelineOrchestrator.getCameraStepOverrides": {
19283
19504
  capName: "pipeline-orchestrator",
19284
19505
  capScope: "system",
@@ -19363,6 +19584,12 @@ Object.freeze({
19363
19584
  addonId: null,
19364
19585
  access: "create"
19365
19586
  },
19587
+ "pipelineOrchestrator.setAgentMaxCameras": {
19588
+ capName: "pipeline-orchestrator",
19589
+ capScope: "system",
19590
+ addonId: null,
19591
+ access: "create"
19592
+ },
19366
19593
  "pipelineOrchestrator.setCameraPipelineForAgent": {
19367
19594
  capName: "pipeline-orchestrator",
19368
19595
  capScope: "system",