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