@camstack/addon-export-alexa 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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-B1dKJAMJ.mjs
4689
4633
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4690
4634
  EventCategory["SystemBoot"] = "system.boot";
4691
4635
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5659,7 +5603,7 @@ var BaseAddon = class {
5659
5603
  deviceSettingsSchema() {
5660
5604
  return null;
5661
5605
  }
5662
- async getGlobalSettings(overlay, cap) {
5606
+ async getGlobalSettings(overlay, cap, _nodeId) {
5663
5607
  const schema = this.globalSettingsSchema(cap);
5664
5608
  if (!schema) return { sections: [] };
5665
5609
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
@@ -5668,7 +5612,7 @@ var BaseAddon = class {
5668
5612
  ...overlay
5669
5613
  } : raw);
5670
5614
  }
5671
- async updateGlobalSettings(patch) {
5615
+ async updateGlobalSettings(patch, _nodeId) {
5672
5616
  await this._ctx?.settings?.writeAddonStore(patch);
5673
5617
  await this.resolveConfig();
5674
5618
  await this.onConfigChanged();
@@ -5922,123 +5866,6 @@ function normalizeAddonInitResult(result) {
5922
5866
  if (Array.isArray(result)) return { providers: result };
5923
5867
  return result;
5924
5868
  }
5925
- /**
5926
- * Build an `IAddonRouteProvider` from a list of routes. Implements
5927
- * both the operator-facing `getRoutes` (returning route descriptors
5928
- * minus the handlers, which can't cross JSON) and the framework-
5929
- * private `invoke` method that the hub calls when this provider lives
5930
- * in a forked worker.
5931
- *
5932
- * Co-located addons use the returned `getRoutes` directly because
5933
- * their handlers don't need to cross any wire. The `invoke` method
5934
- * is present anyway so the bridge code on the hub is uniform — it
5935
- * doesn't need to switch on "local vs remote provider" at the call
5936
- * site.
5937
- *
5938
- * Example:
5939
- * const routes: IAddonHttpRoute[] = [
5940
- * { method: 'GET', path: '/start', access: 'public', handler: this.handleStart },
5941
- * ]
5942
- * return [
5943
- * {
5944
- * capability: addonRoutesCapability,
5945
- * provider: buildAddonRouteProvider('auth-oidc', routes),
5946
- * },
5947
- * ]
5948
- */
5949
- function buildAddonRouteProvider(id, routes) {
5950
- return {
5951
- id,
5952
- getRoutes: () => routes,
5953
- invoke: async (input) => {
5954
- const match = matchRoute(routes, input.method, input.path);
5955
- if (!match) return {
5956
- status: 404,
5957
- headers: {},
5958
- redirectUrl: null,
5959
- body: { error: `No route matches ${input.method} ${input.path}` }
5960
- };
5961
- const envelope = {
5962
- status: 200,
5963
- headers: {},
5964
- redirectUrl: null
5965
- };
5966
- const reply = buildCapturingReply(envelope);
5967
- const request = {
5968
- params: {
5969
- ...input.params,
5970
- ...match.params
5971
- },
5972
- query: input.query,
5973
- body: input.body,
5974
- headers: input.headers,
5975
- ...input.user ? { user: input.user } : {},
5976
- ...input.scopedToken !== void 0 ? { scopedToken: input.scopedToken } : {}
5977
- };
5978
- await match.route.handler(request, reply);
5979
- return envelope;
5980
- }
5981
- };
5982
- }
5983
- /**
5984
- * Pattern matcher: same semantics as `AddonRouteRegistry.matchRoute`
5985
- * but operating on a flat list and bypassing the `/addon/<id>/` prefix
5986
- * — the bridge sends the post-prefix path directly so we don't need
5987
- * to round-trip it through normalization.
5988
- */
5989
- function matchRoute(routes, method, path) {
5990
- const normalizedMethod = method.toUpperCase();
5991
- for (const route of routes) {
5992
- if (route.method !== normalizedMethod) continue;
5993
- const params = matchPath(route.path, path);
5994
- if (params !== null) return {
5995
- route,
5996
- params
5997
- };
5998
- }
5999
- return null;
6000
- }
6001
- function matchPath(pattern, p) {
6002
- const patternParts = pattern.split("/").filter(Boolean);
6003
- const pathParts = p.split("/").filter(Boolean);
6004
- if (patternParts.length !== pathParts.length) return null;
6005
- const params = {};
6006
- for (let i = 0; i < patternParts.length; i++) {
6007
- const a = patternParts[i];
6008
- const b = pathParts[i];
6009
- if (a.startsWith(":")) params[a.slice(1)] = b;
6010
- else if (a !== b) return null;
6011
- }
6012
- return params;
6013
- }
6014
- function buildCapturingReply(envelope) {
6015
- const wrapper = {
6016
- status(code) {
6017
- envelope.status = code;
6018
- return wrapper;
6019
- },
6020
- code(code) {
6021
- envelope.status = code;
6022
- return wrapper;
6023
- },
6024
- send(data) {
6025
- envelope.body = data;
6026
- },
6027
- redirect(url) {
6028
- envelope.redirectUrl = url;
6029
- if (envelope.status === 200) envelope.status = 302;
6030
- },
6031
- header(name, value) {
6032
- envelope.headers[name.toLowerCase()] = value;
6033
- return wrapper;
6034
- },
6035
- type(mime) {
6036
- envelope.contentType = mime;
6037
- return wrapper;
6038
- }
6039
- };
6040
- return wrapper;
6041
- }
6042
5869
  /** Shared Zod schemas used across streaming capabilities. */
6043
5870
  var CamProfileSchema = _enum([
6044
5871
  "high",
@@ -6136,7 +5963,7 @@ function makeSourceBrokerId(deviceId, camStreamId) {
6136
5963
  * Zod schema for StreamSourceEntry — the canonical stream descriptor
6137
5964
  * exposed by ICameraDevice.getStreamSources() and consumed by the broker.
6138
5965
  */
6139
- var StreamSourceEntrySchema = object({
5966
+ var StreamSourceEntrySchema$1 = object({
6140
5967
  id: string(),
6141
5968
  label: string(),
6142
5969
  protocol: _enum([
@@ -6358,407 +6185,412 @@ var ProfileRtspEntrySchema = object({
6358
6185
  codec: string().optional(),
6359
6186
  resolution: CamStreamResolutionSchema.optional()
6360
6187
  });
6361
- /**
6362
- * Numeric day-of-week: 0 = Sunday … 6 = Saturday (matches `Date.getDay`).
6363
- * Named `RecordingWeekday` to avoid collision with the string-union
6364
- * `Weekday` exported from `interfaces/timezones.ts`.
6365
- */
6366
- var RecordingWeekdaySchema = number().int().min(0).max(6);
6367
- var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
6368
- var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
6369
- kind: literal("timeOfDay"),
6370
- start: string().regex(HHMM),
6371
- end: string().regex(HHMM),
6372
- /** Restrict to these weekdays; omit = every day. */
6373
- days: array(RecordingWeekdaySchema).optional()
6374
- })]);
6375
- var RecordingModeSchema = _enum([
6376
- "continuous",
6377
- "onMotion",
6378
- "onAudioThreshold"
6379
- ]);
6380
- /**
6381
- * First-class, authoritative per-camera storage mode the netta choice the UI
6382
- * reads directly (never inferred from `rules`):
6383
- * - `off` not recording.
6384
- * - `events` — record only around triggers (motion / audio threshold),
6385
- * with pre/post-buffer.
6386
- * - `continuous` record 24/7 within the schedule.
6387
- *
6388
- * `mode` compiles one-way to the internal `rules[]` consumed by the policy
6389
- * engine (see `compileRules`); `rules[]` is never authored directly anymore.
6390
- */
6391
- var RecordingStorageModeSchema = _enum([
6392
- "off",
6393
- "events",
6394
- "continuous"
6395
- ]);
6396
- /** Which detectors trigger an `events`-mode recording. */
6397
- var RecordingTriggersSchema = object({
6398
- motion: boolean().optional(),
6399
- audioThresholdDbfs: number().optional()
6400
- });
6401
- /**
6402
- * Mode of a single recording band the recorder per-band vocabulary.
6403
- *
6404
- * Distinct from `RecordingStorageModeSchema` (which carries `off`): a band is
6405
- * only ever `continuous` or `events`; "off" is expressed by the absence of a
6406
- * covering band, not by a band value.
6407
- */
6408
- var RecordingBandModeSchema = _enum(["continuous", "events"]);
6409
- /**
6410
- * Triggers for an `events`-mode band. Identical shape to
6411
- * `RecordingTriggersSchema`reuse that schema as the band trigger type so the
6412
- * two never drift.
6413
- */
6414
- var RecordingBandTriggersSchema = RecordingTriggersSchema;
6415
- /**
6416
- * A single mode-per-band window the canonical recorder band shape, the
6417
- * single source of truth re-used by `addon-pipeline/recorder`.
6418
- *
6419
- * `days` lists the weekdays the band covers (empty = every day, matching the
6420
- * band engine's `applies` rule). `start`/`end` are `HH:MM`; an `end <= start`
6421
- * span wraps past midnight (handled by the band engine).
6422
- */
6423
- var RecordingBandSchema = object({
6424
- days: array(RecordingWeekdaySchema),
6425
- start: string().regex(HHMM),
6426
- end: string().regex(HHMM),
6427
- mode: RecordingBandModeSchema,
6428
- triggers: RecordingBandTriggersSchema.optional(),
6429
- preBufferSec: number().min(0).optional(),
6430
- postBufferSec: number().min(0).optional()
6431
- });
6432
- var RecordingRuleSchema = object({
6433
- schedule: RecordingScheduleSchema,
6434
- mode: RecordingModeSchema,
6435
- /** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
6436
- preBufferSec: number().min(0).default(0),
6437
- /** Keep recording until this many seconds after the last trigger. */
6438
- postBufferSec: number().min(0).default(0),
6439
- /** Each new trigger restarts the post-buffer window. */
6440
- resetTimeoutOnNewEvent: boolean().default(true),
6441
- /** onAudioThreshold only dBFS level that counts as a trigger. */
6442
- thresholdDbfs: number().optional()
6443
- });
6444
- /**
6445
- * Per-device retention overrides. Every field is optional; an unset or `0`
6446
- * value inherits the node-wide recorder default. Only footage-lifetime limits
6447
- * live per-camera: `maxAgeDays` and `maxSizeGb`. The disk-occupancy threshold
6448
- * (when the volume is too full to keep recording) is NOT a per-camera concern —
6449
- * it belongs to the StorageLocation (`StorageLocation.config.minFreePercent`),
6450
- * shared by every camera writing to that volume.
6451
- */
6452
- var RecordingRetentionSchema = object({
6453
- maxAgeDays: number().min(0).optional(),
6454
- maxSizeGb: number().min(0).optional()
6455
- });
6456
- /**
6457
- * The full per-camera recording intent — the wire shape of a RecordingTarget.
6458
- *
6459
- * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
6460
- * are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
6461
- * only for transition + migration (`migrateRulesToMode`); the policy engine
6462
- * consumes the compiled output of `compileRules(config)`, never `rules` directly.
6463
- */
6464
- var RecordingConfigSchema = object({
6465
- enabled: boolean(),
6466
- /** Authoritative storage mode. Absent on legacy targets → derived once via
6467
- * `migrateRulesToMode`, then persisted. */
6468
- mode: RecordingStorageModeSchema.optional(),
6469
- profiles: array(CamProfileSchema).optional(),
6470
- segmentSeconds: number().int().positive().optional(),
6471
- /** Shared recording time-bands for `events` & `continuous` — record only when
6472
- * the wall-clock falls inside one of these windows. Omit or empty = always.
6473
- * `continuous` compiles to one rule per band; `events` to band × trigger. */
6474
- schedules: array(RecordingScheduleSchema).optional(),
6475
- /** Legacy single-band predecessor of `schedules`. Read-compat only — it is
6476
- * normalized into `schedules` on read and never written going forward. (Not
6477
- * tagged `@deprecated`: the normalization paths must read it cast-free.) */
6478
- schedule: RecordingScheduleSchema.optional(),
6479
- /** `events`-mode only — which detectors trigger a recording. */
6480
- triggers: RecordingTriggersSchema.optional(),
6481
- /** `events`-mode only — seconds retained before / after a trigger. */
6482
- preBufferSec: number().min(0).optional(),
6483
- postBufferSec: number().min(0).optional(),
6484
- /** DEPRECATED authoring input; retained for migration/transition. */
6485
- rules: array(RecordingRuleSchema).optional(),
6486
- /**
6487
- * AUTHORITATIVE mode-per-band recording model (recorder). When present it
6488
- * is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
6489
- * `triggers`/`rules` fields above are kept for READ-COMPAT only and are
6490
- * derived into bands once via `migrateConfigToBands`.
6491
- */
6492
- bands: array(RecordingBandSchema).optional(),
6493
- retention: RecordingRetentionSchema.optional()
6494
- });
6495
- /**
6496
- * `StorageLocationType` — an addon-declared id that identifies the *kind* of
6497
- * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
6498
- * so the persisted record schema and the consumer-facing cap can both consume it
6499
- * without forming a circular import. The `storage` cap re-exports it
6500
- * verbatim for back-compat.
6501
- *
6502
- * This Zod schema is the **authoritative source** for `StorageLocationType`.
6503
- * The TS alias in `./storage.ts` re-exports `z.infer<typeof
6504
- * StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
6505
- * `IStorageProvider` interface stay in lockstep.
6506
- *
6507
- * The type is now an **open string** (not a closed enum) — addons declare
6508
- * their own location kinds via `StorageLocationDeclaration.id`. The regex
6509
- * enforces a safe id format: lowercase-start, alphanumeric + hyphens.
6510
- */
6511
- var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
6512
- /**
6513
- * Persisted record for a storage location instance. Operators can register
6514
- * multiple instances for multi-cardinality types (e.g. two `backups`
6515
- * locations with different `providerId`s). Cardinality is now declared per
6516
- * location via `StorageLocationDeclaration.cardinality` — the static
6517
- * `STORAGE_LOCATION_CARDINALITY` map has been removed.
6518
- *
6519
- * `id` is a stable namespaced string of the form `<type>:<slug>`.
6520
- * The default location for a type uses `id === <type>:default` by
6521
- * convention (the bare type ref like `'backups'` resolves to it).
6522
- *
6523
- * `isSystem: true` marks a location as orchestrator-seeded and
6524
- * undeletable. The bootstrap-installed defaults (one per type) carry
6525
- * this flag; operator-added locations don't. Editing the config of
6526
- * a system location is allowed (path migration, provider swap) but
6527
- * deleting it is rejected at the cap level.
6528
- */
6529
- var StorageLocationSchema = object({
6530
- id: string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
6531
- type: string(),
6532
- displayName: string().min(1),
6533
- providerId: string().min(1),
6534
- 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";
6535
6271
  /**
6536
- * Cluster node this location physically lives on. REQUIRED for node-local
6537
- * providers (filesystem — the path exists on one node's disk), null/absent
6538
- * for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
6539
- * `'hub'` is the hub node. Validated against the provider's `nodeLocal`
6540
- * 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.
6541
6275
  */
6542
- nodeId: string().optional(),
6543
- isDefault: boolean().default(false),
6544
- isSystem: boolean().default(false),
6545
- createdAt: number(),
6546
- updatedAt: number()
6547
- });
6548
- /**
6549
- * Reference accepted by consumer-facing `api.storage.*` calls.
6550
- * Either:
6551
- * - a `StorageLocationType` (e.g. `'backups'`) → orchestrator resolves to the default of that type
6552
- * - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
6553
- *
6554
- * The orchestrator's `resolveRef(ref)` handles both cases.
6555
- */
6556
- var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
6557
- /**
6558
- * `StorageLocationDeclaration` — a single storage-location entry declared by
6559
- * an addon in its `package.json` under `camstack.storageLocations`.
6560
- *
6561
- * Design intent:
6562
- * - **Addon declares its needs** — each addon describes the logical storage
6563
- * slots it requires (e.g. `recordings`, `recordingsLow`) without caring
6564
- * about the physical path.
6565
- * - **Kernel aggregates** — at boot the kernel collects declarations from all
6566
- * installed addons, deduplicates by `id`, and exposes the union via the
6567
- * storage-locations settings surface.
6568
- * - **Orchestrator seeds** — for every declared `id` the orchestrator ensures
6569
- * at least one instance named `<id>:default` is present, using
6570
- * `defaultsTo` to inherit the resolved root from another location when the
6571
- * declaration is a derivative slot (e.g. `recordingsLow` defaults to
6572
- * `recordings`).
6573
- * - **ids are global** — `id` values are shared across the entire deployment;
6574
- * two addons declaring the same `id` must agree on `cardinality` (validated
6575
- * at kernel aggregation time, not here).
6576
- */
6577
- 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";
6578
6281
  /**
6579
- * Global location identifier, e.g. `recordings` or `recordingsLow`.
6580
- * Must start with a lowercase letter and may contain letters, digits, and
6581
- * 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.
6582
6289
  */
6583
- id: string().regex(/^[a-z][a-zA-Z0-9-]*$/, { message: "id must start with a lowercase letter and contain only letters, digits, or hyphens" }),
6584
- /** Human-readable name shown in the admin UI. */
6585
- displayName: string().min(1, { message: "displayName must not be empty" }),
6586
- /** Optional longer explanation of what data this location stores. */
6587
- description: string().optional(),
6290
+ DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
6588
6291
  /**
6589
- * `single` exactly one instance of this location is allowed system-wide
6590
- * (e.g. `logs`, `models`). The operator can edit it but not add more.
6591
- * `multi` the operator may register several instances (e.g. a second
6592
- * `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".
6593
6300
  */
6594
- cardinality: _enum(["single", "multi"]),
6595
- /**
6596
- * When set, the default instance for this location inherits its resolved
6597
- * root from the named location's default instance. Useful for derivative
6598
- * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
6599
- * configure the primary location.
6600
- */
6601
- defaultsTo: string().optional()
6602
- });
6603
- var DecoderStatsSchema = object({
6604
- inputFps: number(),
6605
- outputFps: number(),
6606
- avgDecodeTimeMs: number(),
6607
- droppedFrames: number()
6608
- });
6609
- var DecoderSessionConfigSchema = object({
6610
- codec: string(),
6611
- maxFps: number().default(0),
6612
- outputFormat: _enum([
6613
- "jpeg",
6614
- "rgb",
6615
- "bgr",
6616
- "yuv420",
6617
- "gray"
6618
- ]).default("jpeg"),
6619
- scale: number().default(1),
6620
- width: number().optional(),
6621
- height: number().optional(),
6622
- /**
6623
- * Identifier of the camera this decoder session serves. Optional
6624
- * because the cap is generic (any caller could request decode), but
6625
- * stream-broker passes it so decoder logs include `deviceId` for
6626
- * per-camera filtering when diagnosing failures (e.g. node-av
6627
- * sendPacket errors on a single hung camera).
6628
- */
6629
- deviceId: number().int().nonnegative().optional(),
6630
- /**
6631
- * Free-form tag for log scoping. Stream-broker uses
6632
- * `broker:<deviceId>/<profile>`. Decoder session logger surfaces it
6633
- * on every line so `grep tag=broker:5/high` filters one camera
6634
- * profile cleanly.
6635
- */
6636
- tag: string().optional(),
6637
- /**
6638
- * Where the session delivers decoded frames (Phase 5 / D9):
6639
- *
6640
- * - `'callback'` (default) — the legacy pixel path: decoded frames are
6641
- * buffered as `DecodedFrame`s and drained via `pullFrames`.
6642
- * - `'shm'` — the shared-memory frame plane: decoded frames are written
6643
- * into an OS shared-memory ring and drained as zero-pixel
6644
- * `FrameHandle`s via `pullHandles`. A session is one mode or the
6645
- * other `pullFrames` returns nothing for an `'shm'` session and
6646
- * `pullHandles` returns nothing for a `'callback'` session.
6647
- */
6648
- frameSink: _enum(["callback", "shm"]).default("callback")
6649
- });
6650
- var EncodeProfileSchema = object({
6651
- video: object({
6652
- codec: _enum([
6653
- "h264",
6654
- "h265",
6655
- "copy"
6656
- ]),
6657
- profile: _enum([
6658
- "baseline",
6659
- "main",
6660
- "high"
6661
- ]).optional(),
6662
- width: number().int().positive().optional(),
6663
- height: number().int().positive().optional(),
6664
- fps: number().positive().optional(),
6665
- bitrateKbps: number().int().positive().optional(),
6666
- gopFrames: number().int().positive().optional(),
6667
- bf: number().int().min(0).optional(),
6668
- preset: _enum([
6669
- "ultrafast",
6670
- "superfast",
6671
- "veryfast",
6672
- "faster",
6673
- "fast",
6674
- "medium"
6675
- ]).optional(),
6676
- tune: _enum([
6677
- "zerolatency",
6678
- "film",
6679
- "animation"
6680
- ]).optional()
6681
- }),
6682
- audio: union([literal("passthrough"), object({
6683
- codec: _enum([
6684
- "opus",
6685
- "aac",
6686
- "pcmu",
6687
- "pcma",
6688
- "copy"
6689
- ]),
6690
- bitrateKbps: number().int().positive().optional(),
6691
- sampleRateHz: number().int().positive().optional(),
6692
- channels: union([literal(1), literal(2)]).optional()
6693
- })]),
6694
- /**
6695
- * ffmpeg input-side args, inserted between the fixed global flags
6696
- * (`-hide_banner -loglevel error`) and `-i pipe:0`. Free-text array
6697
- * — the widget surfaces a textarea + suggestion chips for the most-
6698
- * used demuxer/format options.
6699
- */
6700
- inputArgs: array(string()).optional(),
6701
- /**
6702
- * ffmpeg output-side args, inserted between the encode block and
6703
- * the final `-f <muxer> pipe:1`. Use for muxer options, bitstream
6704
- * filters, codec-specific overrides. Free-text array.
6705
- */
6706
- outputArgs: array(string()).optional()
6707
- });
6708
- function pickPreferredRtspEntry(entries, pref, deviceId, options = {}) {
6709
- if (entries.length === 0) return null;
6710
- const prefix = `${deviceId}/`;
6711
- const toPicked = (e) => ({
6712
- brokerId: e.brokerId,
6713
- profileId: e.brokerId.startsWith(prefix) ? e.brokerId.slice(prefix.length) : e.brokerId,
6714
- url: e.url,
6715
- mutedUrl: e.mutedUrl,
6716
- enabled: e.enabled,
6717
- ...e.codec !== void 0 ? { codec: e.codec } : {},
6718
- ...e.resolution !== void 0 ? { resolution: e.resolution } : {}
6719
- });
6720
- if (pref !== "auto") {
6721
- const match = entries.find((e) => e.enabled && e.url.length > 0 && (e.profile === pref || e.brokerId === `${prefix}${pref}`));
6722
- if (match) return toPicked(match);
6723
- }
6724
- const eligible = entries.filter((e) => e.enabled && e.url.length > 0);
6725
- if (eligible.length === 0) return null;
6726
- const target = options.targetResolution;
6727
- if (target) {
6728
- const withRes = eligible.filter((e) => e.resolution !== void 0);
6729
- if (withRes.length > 0) {
6730
- const picked = pickClosestResolution(withRes, target);
6731
- if (picked) return toPicked(picked);
6732
- }
6733
- }
6734
- return toPicked(eligible[0]);
6735
- }
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
+ }({});
6736
6385
  /**
6737
- * Pick the entry whose `resolution` is closest to `target`. Prefer
6738
- * entries target (downscale is cheap at the consumer; upscale is
6739
- * lossy). Among the rest pick the LARGEST still ≤ target so the
6740
- * consumer gets the best feasible quality. "Closeness" is the
6741
- * `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.
6742
6395
  */
6743
- function pickClosestResolution(entries, target) {
6744
- const targetPixels = target.width * target.height;
6745
- let bestAbove;
6746
- let bestBelow;
6747
- for (const e of entries) {
6748
- if (e.resolution === void 0) continue;
6749
- const pixels = e.resolution.width * e.resolution.height;
6750
- if (pixels >= targetPixels) {
6751
- if (!bestAbove || pixels < bestAbove.pixels) bestAbove = {
6752
- entry: e,
6753
- pixels
6754
- };
6755
- } else if (!bestBelow || pixels > bestBelow.pixels) bestBelow = {
6756
- entry: e,
6757
- pixels
6758
- };
6759
- }
6760
- 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
+ };
6761
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
6762
6594
  /**
6763
6595
  import { errMsg } from '@camstack/types'
6764
6596
  * Extract a human-readable message from an unknown error value.
@@ -6769,547 +6601,847 @@ function errMsg(err) {
6769
6601
  if (typeof err === "string") return err;
6770
6602
  return String(err);
6771
6603
  }
6772
- var YAMNET_TO_MACRO = {
6773
- mapping: {
6774
- Speech: "speech",
6775
- "Child speech, kid speaking": "speech",
6776
- Conversation: "speech",
6777
- "Narration, monologue": "speech",
6778
- Babbling: "speech",
6779
- Whispering: "speech",
6780
- "Speech synthesizer": "speech",
6781
- Humming: "speech",
6782
- Rapping: "speech",
6783
- Singing: "speech",
6784
- Choir: "speech",
6785
- "Child singing": "speech",
6786
- Shout: "scream",
6787
- Bellow: "scream",
6788
- Yell: "scream",
6789
- Screaming: "scream",
6790
- "Children shouting": "scream",
6791
- Whoop: "scream",
6792
- "Crying, sobbing": "crying",
6793
- "Baby cry, infant cry": "crying",
6794
- Whimper: "crying",
6795
- "Wail, moan": "crying",
6796
- Groan: "crying",
6797
- Laughter: "laughter",
6798
- "Baby laughter": "laughter",
6799
- Giggle: "laughter",
6800
- Snicker: "laughter",
6801
- "Belly laugh": "laughter",
6802
- "Chuckle, chortle": "laughter",
6803
- Music: "music",
6804
- "Musical instrument": "music",
6805
- Guitar: "music",
6806
- Piano: "music",
6807
- Drum: "music",
6808
- "Drum kit": "music",
6809
- "Violin, fiddle": "music",
6810
- Flute: "music",
6811
- Saxophone: "music",
6812
- Trumpet: "music",
6813
- Synthesizer: "music",
6814
- "Pop music": "music",
6815
- "Rock music": "music",
6816
- "Hip hop music": "music",
6817
- "Classical music": "music",
6818
- Jazz: "music",
6819
- "Electronic music": "music",
6820
- "Background music": "music",
6821
- Dog: "dog",
6822
- Bark: "dog",
6823
- Yip: "dog",
6824
- Howl: "dog",
6825
- "Bow-wow": "dog",
6826
- Growling: "dog",
6827
- "Whimper (dog)": "dog",
6828
- Cat: "cat",
6829
- Purr: "cat",
6830
- Meow: "cat",
6831
- Hiss: "cat",
6832
- Caterwaul: "cat",
6833
- Bird: "bird",
6834
- "Bird vocalization, bird call, bird song": "bird",
6835
- "Chirp, tweet": "bird",
6836
- Squawk: "bird",
6837
- Crow: "bird",
6838
- Owl: "bird",
6839
- "Pigeon, dove": "bird",
6840
- Animal: "animal",
6841
- "Domestic animals, pets": "animal",
6842
- "Livestock, farm animals, working animals": "animal",
6843
- Horse: "animal",
6844
- "Cattle, bovinae": "animal",
6845
- Pig: "animal",
6846
- Sheep: "animal",
6847
- Goat: "animal",
6848
- Frog: "animal",
6849
- Insect: "animal",
6850
- Cricket: "animal",
6851
- Alarm: "alarm",
6852
- "Alarm clock": "alarm",
6853
- "Smoke detector, smoke alarm": "alarm",
6854
- "Fire alarm": "alarm",
6855
- Buzzer: "alarm",
6856
- "Civil defense siren": "alarm",
6857
- "Car alarm": "alarm",
6858
- Siren: "siren",
6859
- "Police car (siren)": "siren",
6860
- "Ambulance (siren)": "siren",
6861
- "Fire engine, fire truck (siren)": "siren",
6862
- "Emergency vehicle": "siren",
6863
- Foghorn: "siren",
6864
- Doorbell: "doorbell",
6865
- "Ding-dong": "doorbell",
6866
- Knock: "doorbell",
6867
- Tap: "doorbell",
6868
- Glass: "glass_breaking",
6869
- Shatter: "glass_breaking",
6870
- "Chink, clink": "glass_breaking",
6871
- "Gunshot, gunfire": "gunshot",
6872
- "Machine gun": "gunshot",
6873
- Explosion: "gunshot",
6874
- Fireworks: "gunshot",
6875
- Firecracker: "gunshot",
6876
- "Artillery fire": "gunshot",
6877
- "Cap gun": "gunshot",
6878
- Boom: "gunshot",
6879
- Vehicle: "vehicle",
6880
- Car: "vehicle",
6881
- Truck: "vehicle",
6882
- Bus: "vehicle",
6883
- Motorcycle: "vehicle",
6884
- "Car passing by": "vehicle",
6885
- "Vehicle horn, car horn, honking": "vehicle",
6886
- "Traffic noise, roadway noise": "vehicle",
6887
- Train: "vehicle",
6888
- Aircraft: "vehicle",
6889
- Helicopter: "vehicle",
6890
- Bicycle: "vehicle",
6891
- Skateboard: "vehicle",
6892
- Fire: "fire",
6893
- Crackle: "fire",
6894
- Water: "water",
6895
- Rain: "water",
6896
- Raindrop: "water",
6897
- "Rain on surface": "water",
6898
- Stream: "water",
6899
- Waterfall: "water",
6900
- Ocean: "water",
6901
- "Waves, surf": "water",
6902
- "Splash, splatter": "water",
6903
- Wind: "wind",
6904
- Thunderstorm: "wind",
6905
- Thunder: "wind",
6906
- "Wind noise (microphone)": "wind",
6907
- "Rustling leaves": "wind",
6908
- Door: "door",
6909
- "Sliding door": "door",
6910
- Slam: "door",
6911
- "Cupboard open or close": "door",
6912
- "Walk, footsteps": "footsteps",
6913
- Run: "footsteps",
6914
- Shuffle: "footsteps",
6915
- Crowd: "crowd",
6916
- Chatter: "crowd",
6917
- Cheering: "crowd",
6918
- Applause: "crowd",
6919
- "Children playing": "crowd",
6920
- "Hubbub, speech noise, speech babble": "crowd",
6921
- Telephone: "telephone",
6922
- "Telephone bell ringing": "telephone",
6923
- Ringtone: "telephone",
6924
- "Telephone dialing, DTMF": "telephone",
6925
- "Busy signal": "telephone",
6926
- Engine: "engine",
6927
- "Engine starting": "engine",
6928
- Idling: "engine",
6929
- "Accelerating, revving, vroom": "engine",
6930
- "Light engine (high frequency)": "engine",
6931
- "Medium engine (mid frequency)": "engine",
6932
- "Heavy engine (low frequency)": "engine",
6933
- "Lawn mower": "engine",
6934
- Chainsaw: "engine",
6935
- Hammer: "tools",
6936
- Jackhammer: "tools",
6937
- Sawing: "tools",
6938
- "Power tool": "tools",
6939
- Drill: "tools",
6940
- Sanding: "tools",
6941
- Silence: "silence"
6942
- },
6943
- preserveOriginal: false
6944
- };
6945
- var APPLE_SA_TO_MACRO = {
6946
- mapping: {
6947
- speech: "speech",
6948
- child_speech: "speech",
6949
- conversation: "speech",
6950
- whispering: "speech",
6951
- singing: "speech",
6952
- humming: "speech",
6953
- shout: "scream",
6954
- yell: "scream",
6955
- screaming: "scream",
6956
- crying: "crying",
6957
- baby_crying: "crying",
6958
- sobbing: "crying",
6959
- laughter: "laughter",
6960
- baby_laughter: "laughter",
6961
- giggling: "laughter",
6962
- music: "music",
6963
- guitar: "music",
6964
- piano: "music",
6965
- drums: "music",
6966
- dog_bark: "dog",
6967
- dog_bow_wow: "dog",
6968
- dog_growling: "dog",
6969
- dog_howl: "dog",
6970
- cat_meow: "cat",
6971
- cat_purr: "cat",
6972
- cat_hiss: "cat",
6973
- bird: "bird",
6974
- bird_chirp: "bird",
6975
- bird_squawk: "bird",
6976
- animal: "animal",
6977
- horse: "animal",
6978
- cow_moo: "animal",
6979
- insect: "animal",
6980
- alarm: "alarm",
6981
- smoke_alarm: "alarm",
6982
- fire_alarm: "alarm",
6983
- car_alarm: "alarm",
6984
- siren: "siren",
6985
- police_siren: "siren",
6986
- ambulance_siren: "siren",
6987
- doorbell: "doorbell",
6988
- door_knock: "doorbell",
6989
- knocking: "doorbell",
6990
- glass_breaking: "glass_breaking",
6991
- glass_shatter: "glass_breaking",
6992
- gunshot: "gunshot",
6993
- explosion: "gunshot",
6994
- fireworks: "gunshot",
6995
- car: "vehicle",
6996
- truck: "vehicle",
6997
- motorcycle: "vehicle",
6998
- car_horn: "vehicle",
6999
- vehicle_horn: "vehicle",
7000
- traffic: "vehicle",
7001
- fire: "fire",
7002
- fire_crackle: "fire",
7003
- water: "water",
7004
- rain: "water",
7005
- ocean: "water",
7006
- splash: "water",
7007
- wind: "wind",
7008
- thunder: "wind",
7009
- thunderstorm: "wind",
7010
- door: "door",
7011
- door_slam: "door",
7012
- sliding_door: "door",
7013
- footsteps: "footsteps",
7014
- walking: "footsteps",
7015
- running: "footsteps",
7016
- crowd: "crowd",
7017
- chatter: "crowd",
7018
- cheering: "crowd",
7019
- applause: "crowd",
7020
- telephone_ring: "telephone",
7021
- ringtone: "telephone",
7022
- engine: "engine",
7023
- engine_starting: "engine",
7024
- lawn_mower: "engine",
7025
- chainsaw: "engine",
7026
- hammer: "tools",
7027
- jackhammer: "tools",
7028
- drill: "tools",
7029
- power_tool: "tools",
7030
- silence: "silence"
7031
- },
7032
- preserveOriginal: false
7033
- };
7034
- var _macroLookup = /* @__PURE__ */ new Map();
7035
- for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7036
- for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7037
- var DeviceType = /* @__PURE__ */ function(DeviceType) {
7038
- DeviceType["Camera"] = "camera";
7039
- DeviceType["Hub"] = "hub";
7040
- DeviceType["Light"] = "light";
7041
- DeviceType["Siren"] = "siren";
7042
- DeviceType["Switch"] = "switch";
7043
- DeviceType["Sensor"] = "sensor";
7044
- DeviceType["Thermostat"] = "thermostat";
7045
- DeviceType["Button"] = "button";
7046
- /** Generic stateless event emitter carries a device's EXACT declared
7047
- * event vocabulary verbatim (no normalization). Installed with the
7048
- * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
7049
- * HA bus events (e.g. `zha_event`, generic). */
7050
- DeviceType["EventEmitter"] = "event-emitter";
7051
- /** Firmware/software update entity — current vs available version,
7052
- * updatable flag, update state, and an install action. Installed with
7053
- * the `update` cap. Sources: Homematic firmware-update channels (and
7054
- * reusable by other providers, e.g. HA `update.*` entities). */
7055
- DeviceType["Update"] = "update";
7056
- DeviceType["Generic"] = "generic";
7057
- /** Generic notification delivery target (HA `notify.<service>`, future
7058
- * Telegram / Discord / ntfy / SMTP, …). One device per delivery
7059
- * endpoint; the `notifier` cap defines the send surface. */
7060
- DeviceType["Notifier"] = "notifier";
7061
- /** Pre-recorded action sequence with optional parameters
7062
- * (HA `script.*`). Runnable via `script-runner` cap. */
7063
- DeviceType["Script"] = "script";
7064
- /** Automation rule (HA `automation.*`) — enable/disable + manual
7065
- * trigger surface exposed via `automation-control` cap. */
7066
- DeviceType["Automation"] = "automation";
7067
- /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
7068
- DeviceType["Lock"] = "lock";
7069
- /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
7070
- * `valve.*`). `cover` cap with sub-roles for variant. */
7071
- DeviceType["Cover"] = "cover";
7072
- /** Pipe / water / gas valve with open/close/stop and optional
7073
- * position (HA `valve.*`). `valve` cap a cover-sibling actuator
7074
- * modelled on the same open/closed lifecycle. */
7075
- DeviceType["Valve"] = "valve";
7076
- /** Humidifier / dehumidifier with on/off + target humidity + mode
7077
- * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
7078
- * modelled on the same target / mode lifecycle. */
7079
- DeviceType["Humidifier"] = "humidifier";
7080
- /** Water heater / boiler with target temperature + operation mode +
7081
- * away mode (HA `water_heater.*`). `water-heater` cap — a
7082
- * climate-family actuator. */
7083
- DeviceType["WaterHeater"] = "water-heater";
7084
- /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
7085
- DeviceType["Fan"] = "fan";
7086
- /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
7087
- * the camera surface — those use `Camera`. `media-player` cap. */
7088
- DeviceType["MediaPlayer"] = "media-player";
7089
- /** Security panel / alarm system (HA `alarm_control_panel.*`).
7090
- * `alarm-panel` cap. */
7091
- DeviceType["AlarmPanel"] = "alarm-panel";
7092
- /** Generic user-settable input (HA `number` / `input_number` / `select`
7093
- * / `input_select` / `text` / `input_text` / `input_datetime`).
7094
- * Sub-type via `DeviceRole`: NumericControl / SelectControl /
7095
- * TextControl / DateTimeControl. */
7096
- DeviceType["Control"] = "control";
7097
- /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
7098
- * `presence` cap. */
7099
- DeviceType["Presence"] = "presence";
7100
- /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
7101
- * `weather` cap. */
7102
- DeviceType["Weather"] = "weather";
7103
- /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
7104
- DeviceType["Vacuum"] = "vacuum";
7105
- /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
7106
- * `lawn-mower-control` cap. */
7107
- DeviceType["LawnMower"] = "lawn-mower";
7108
- /** Physical HA device group — parent container for entity-children
7109
- * adopted from a single HA device entry. Not renderable as a
7110
- * standalone device; exists only to anchor child entities. */
7111
- DeviceType["Container"] = "container";
7112
- /** Single still-image entity (HA `image.*`). Read-only display of an
7113
- * `entity_picture` signed URL the browser loads directly. `image` cap. */
7114
- DeviceType["Image"] = "image";
7115
- return DeviceType;
7116
- }({});
7117
- var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
7118
- DeviceFeature["BatteryOperated"] = "battery-operated";
7119
- 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(),
6904
+ /**
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`.
6909
+ */
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({
7120
6996
  /**
7121
- * Device supports an on-demand re-sync of its derived spec with its
7122
- * upstream source drives the generic Re-sync button. The owning
7123
- * provider implements the action via the `device-adoption.resync` cap.
6997
+ * Global location identifier, e.g. `recordings` or `recordingsLow`.
6998
+ * Must start with a lowercase letter and may contain letters, digits, and
6999
+ * hyphens.
7124
7000
  */
7125
- DeviceFeature["Resyncable"] = "resyncable";
7126
- DeviceFeature["NativeSnapshot"] = "native-snapshot";
7127
- DeviceFeature["DoorbellButton"] = "doorbell-button";
7128
- DeviceFeature["TwoWayAudio"] = "two-way-audio";
7129
- DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
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(),
7130
7006
  /**
7131
- * Camera supports the on-firmware autotrack subsystem (subject-
7132
- * following). Distinct from `PanTiltZoom` because not every PTZ
7133
- * camera ships autotrack — the admin UI uses this flag to gate
7134
- * the autotrack toggle / settings card without re-deriving from
7135
- * the cap registry. Mirrors `ptz-autotrack` cap registration:
7136
- * driver sets this feature when probe confirms the firmware
7137
- * surface, and registers the cap in the same code path.
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.
7138
7011
  */
7139
- DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
7012
+ cardinality: _enum(["single", "multi"]),
7140
7013
  /**
7141
- * Accessory exposes a "trigger on motion" toggle the parent camera's
7142
- * motion detection automatically activates this device. Mirrors
7143
- * `motion-trigger` cap registration: drivers set this feature in the
7144
- * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
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):
7145
7057
  *
7146
- * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
7147
- * fast scalar without binding fetch), notifier rules, and `listAll`
7148
- * filters that want "all devices with on-motion behaviour".
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.
7149
7065
  */
7150
- DeviceFeature["MotionTrigger"] = "motion-trigger";
7151
- /** Light supports rgb-triplet color via `color` cap. */
7152
- DeviceFeature["LightColorRgb"] = "light-color-rgb";
7153
- /** Light supports HSV color via `color` cap. */
7154
- DeviceFeature["LightColorHsv"] = "light-color-hsv";
7155
- /** Light supports color-temperature (mired) via `color` cap. */
7156
- DeviceFeature["LightColorMired"] = "light-color-mired";
7157
- /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
7158
- * targetHigh). Gates the range slider UI. */
7159
- DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
7160
- /** Thermostat exposes target humidity and/or current humidity
7161
- * readings. Gates the humidity controls. */
7162
- DeviceFeature["ClimateHumidity"] = "climate-humidity";
7163
- /** Thermostat exposes a fan-mode selector. */
7164
- DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
7165
- /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
7166
- DeviceFeature["ClimatePreset"] = "climate-preset";
7167
- /** Cover exposes intermediate position control (0..100). Gates the
7168
- * position slider UI. */
7169
- DeviceFeature["CoverPositionable"] = "cover-positionable";
7170
- /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
7171
- DeviceFeature["CoverTilt"] = "cover-tilt";
7172
- /** Valve exposes intermediate position control (0..100). Gates the
7173
- * position slider / drag surface UI. */
7174
- DeviceFeature["ValvePositionable"] = "valve-positionable";
7175
- /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
7176
- DeviceFeature["FanSpeed"] = "fan-speed";
7177
- /** Fan exposes a preset mode selector. */
7178
- DeviceFeature["FanPreset"] = "fan-preset";
7179
- /** Fan exposes blade direction (forward/reverse) — typical of
7180
- * ceiling fans. */
7181
- DeviceFeature["FanDirection"] = "fan-direction";
7182
- /** Fan exposes an oscillation toggle. */
7183
- DeviceFeature["FanOscillating"] = "fan-oscillating";
7184
- /** Lock requires a PIN code on lock/unlock. Gates the code-entry
7185
- * field on the UI lock-controls panel. */
7186
- DeviceFeature["LockPinRequired"] = "lock-pin-required";
7187
- /** Lock supports a latch-release ("open door") action distinct from
7188
- * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
7189
- * `supported_features`. Gates the Open Door button in the UI. */
7190
- DeviceFeature["LockOpen"] = "lock-open";
7191
- /** Media player exposes a seek-to-position surface. */
7192
- DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
7193
- /** Media player exposes a volume-level setter. */
7194
- DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
7195
- /** Media player exposes a mute toggle distinct from volume=0. */
7196
- DeviceFeature["MediaPlayerMute"] = "media-player-mute";
7197
- /** Media player exposes a shuffle toggle. */
7198
- DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
7199
- /** Media player exposes a repeat mode (off / all / one). */
7200
- DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
7201
- /** Media player exposes a source / input selector. */
7202
- DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
7203
- /** Media player exposes a play-arbitrary-media surface (URL / id). */
7204
- DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
7205
- /** Media player exposes next-track. */
7206
- DeviceFeature["MediaPlayerNext"] = "media-player-next";
7207
- /** Media player exposes previous-track. */
7208
- DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
7209
- /** Media player exposes stop distinct from pause. */
7210
- DeviceFeature["MediaPlayerStop"] = "media-player-stop";
7211
- /** Alarm panel requires a PIN code on arm/disarm. */
7212
- DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
7213
- /** Presence device carries GPS coordinates (lat/lng/accuracy) in
7214
- * addition to a textual location. */
7215
- DeviceFeature["PresenceGps"] = "presence-gps";
7216
- /** Notifier accepts an inline / URL image attachment. */
7217
- DeviceFeature["NotifierImage"] = "notifier-image";
7218
- /** Notifier accepts a priority hint (high/normal/low). */
7219
- DeviceFeature["NotifierPriority"] = "notifier-priority";
7220
- /** Notifier accepts a free-form `data` payload for platform-specific
7221
- * fields. */
7222
- DeviceFeature["NotifierData"] = "notifier-data";
7223
- /** Notifier supports interactive action buttons / callbacks. */
7224
- DeviceFeature["NotifierActions"] = "notifier-actions";
7225
- /** Notifier supports per-call recipient targeting (multi-user). */
7226
- DeviceFeature["NotifierRecipients"] = "notifier-recipients";
7227
- /** Script runner accepts a variables map on each run invocation. */
7228
- DeviceFeature["ScriptVariables"] = "script-variables";
7229
- /** Automation `trigger` accepts a skipCondition flag — fires the
7230
- * automation's actions while bypassing its condition block. */
7231
- DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
7232
- return DeviceFeature;
7233
- }({});
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
+ })]),
7112
+ /**
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.
7117
+ */
7118
+ inputArgs: array(string()).optional(),
7119
+ /**
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.
7123
+ */
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
+ }
7234
7154
  /**
7235
- * Semantic role a device plays within its parent. Populated by driver
7236
- * addons when creating accessory devices (Reolink siren/floodlight/
7237
- * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
7238
- * admin UI to pick icons, labels, and widgets — a `Switch` with
7239
- * `role: Floodlight` renders as a bulb with a brightness slider,
7240
- * whereas a `Switch` with `role: Siren` renders as a klaxon.
7241
- *
7242
- * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
7243
- * sqlite as a nullable TEXT column — old rows keep working unchanged.
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.
7244
7160
  */
7245
- var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7246
- DeviceRole["Siren"] = "siren";
7247
- DeviceRole["Floodlight"] = "floodlight";
7248
- DeviceRole["Spotlight"] = "spotlight";
7249
- DeviceRole["PirSensor"] = "pir-sensor";
7250
- DeviceRole["Chime"] = "chime";
7251
- DeviceRole["Autotrack"] = "autotrack";
7252
- DeviceRole["Nightvision"] = "nightvision";
7253
- DeviceRole["PrivacyMask"] = "privacy-mask";
7254
- DeviceRole["Doorbell"] = "doorbell";
7255
- /** Virtual HA toggle (input_boolean.*) — distinguishable from a
7256
- * real Switch device for UI rendering / export adapters. */
7257
- DeviceRole["BinaryHelper"] = "binary-helper";
7258
- /** Generic motion / occupancy / moving event source. Distinct from
7259
- * the camera accessory PirSensor role: that one is a camera child;
7260
- * this is a standalone HA / 3rd-party motion sensor. */
7261
- DeviceRole["MotionSensor"] = "motion-sensor";
7262
- DeviceRole["ContactSensor"] = "contact-sensor";
7263
- DeviceRole["LeakSensor"] = "leak-sensor";
7264
- DeviceRole["SmokeSensor"] = "smoke-sensor";
7265
- DeviceRole["COSensor"] = "co-sensor";
7266
- DeviceRole["GasSensor"] = "gas-sensor";
7267
- DeviceRole["TamperSensor"] = "tamper-sensor";
7268
- DeviceRole["VibrationSensor"] = "vibration-sensor";
7269
- DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
7270
- DeviceRole["SoundSensor"] = "sound-sensor";
7271
- /** Fallback for `binary_sensor` without a known `device_class`. */
7272
- DeviceRole["BinarySensor"] = "binary-sensor";
7273
- DeviceRole["TemperatureSensor"] = "temperature-sensor";
7274
- DeviceRole["HumiditySensor"] = "humidity-sensor";
7275
- DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
7276
- DeviceRole["PressureSensor"] = "pressure-sensor";
7277
- DeviceRole["PowerSensor"] = "power-sensor";
7278
- DeviceRole["EnergySensor"] = "energy-sensor";
7279
- DeviceRole["VoltageSensor"] = "voltage-sensor";
7280
- DeviceRole["CurrentSensor"] = "current-sensor";
7281
- DeviceRole["AirQualitySensor"] = "air-quality-sensor";
7282
- /** Battery level (numeric % via `sensor` OR low-bool via
7283
- * `binary_sensor` — the cap distinguishes via the value type). */
7284
- DeviceRole["BatterySensor"] = "battery-sensor";
7285
- /** Fallback for `sensor` numeric without a known `device_class`. */
7286
- DeviceRole["NumericSensor"] = "numeric-sensor";
7287
- /** String / enum state (HA `sensor` with `state_class: enum` or
7288
- * `attributes.options`). */
7289
- DeviceRole["EnumSensor"] = "enum-sensor";
7290
- /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
7291
- * or `date`). The slice carries the raw ISO string verbatim (hosted on
7292
- * the `enum-sensor` cap); the UI renders it locale-formatted. */
7293
- DeviceRole["DateTimeSensor"] = "datetime-sensor";
7294
- /** Last-resort fallback when nothing else matches. */
7295
- DeviceRole["GenericSensor"] = "generic-sensor";
7296
- DeviceRole["NumericControl"] = "numeric-control";
7297
- DeviceRole["SelectControl"] = "select-control";
7298
- DeviceRole["TextControl"] = "text-control";
7299
- DeviceRole["DateTimeControl"] = "datetime-control";
7300
- /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
7301
- * rich features (image, priority, channel routing). */
7302
- DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
7303
- /** Chat / messaging service (HA `notify.telegram_*`,
7304
- * `notify.discord_*`, etc.). */
7305
- DeviceRole["MessagingNotifier"] = "messaging-notifier";
7306
- /** Email-based delivery (HA `notify.smtp`, etc.). */
7307
- DeviceRole["EmailNotifier"] = "email-notifier";
7308
- /** Fallback when the notifier service name doesn't match a known
7309
- * pattern. */
7310
- DeviceRole["GenericNotifier"] = "generic-notifier";
7311
- return DeviceRole;
7312
- }({});
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);
7313
7445
  /**
7314
7446
  * Accessory device helpers — shared across drivers.
7315
7447
  *
@@ -7469,74 +7601,6 @@ object({
7469
7601
  });
7470
7602
  DeviceType.Sensor;
7471
7603
  /**
7472
- * Generic types for capability definitions.
7473
- *
7474
- * A capability is defined with Zod schemas for methods, events, and settings.
7475
- * TypeScript types are inferred via z.infer<> — zero duplication.
7476
- *
7477
- * Pattern:
7478
- * 1. Define Zod schemas for data, methods, settings
7479
- * 2. Export const capabilityDef = { ... } satisfies CapabilityDefinition
7480
- * 3. Export type IProvider = InferProvider<typeof capabilityDef>
7481
- * 4. Addon implements IProvider
7482
- * 5. Registry auto-mounts tRPC router from definition.methods
7483
- */
7484
- /**
7485
- * Output schema shared by the contribution + live methods.
7486
- *
7487
- * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
7488
- * tabs[]) without importing from `../interfaces/config-ui.js` — a
7489
- * concrete-but-lenient Zod object keeps tRPC output inference happy
7490
- * (using `z.unknown()` here collapses unrelated router branches to
7491
- * `unknown` when the generator re-inlines the huge AppRouter type).
7492
- *
7493
- * `.passthrough()` on sections/fields accepts whatever FormBuilder
7494
- * extensions the caller adds (showWhen, displayScale, …) without
7495
- * rebuilding every time a new field kind is introduced.
7496
- */
7497
- var ContributionSectionSchema = object({
7498
- id: string(),
7499
- title: string(),
7500
- description: string().optional(),
7501
- style: _enum(["card", "accordion"]).optional(),
7502
- defaultCollapsed: boolean().optional(),
7503
- columns: union([
7504
- literal(1),
7505
- literal(2),
7506
- literal(3),
7507
- literal(4)
7508
- ]).optional(),
7509
- tab: string().optional(),
7510
- location: _enum(["settings", "top-tab"]).optional(),
7511
- order: number().optional(),
7512
- fields: array(any())
7513
- });
7514
- object({
7515
- tabs: array(object({
7516
- id: string(),
7517
- label: string(),
7518
- icon: string(),
7519
- order: number().optional()
7520
- })).optional(),
7521
- sections: array(ContributionSectionSchema)
7522
- }).nullable();
7523
- object({ deviceId: number() }), object({ deviceId: number() }), object({
7524
- deviceId: number(),
7525
- patch: record(string(), unknown())
7526
- }), object({ success: literal(true) });
7527
- object({ deviceId: number() }), unknown().nullable();
7528
- /** Shorthand to define a method schema */
7529
- function method(input, output, options) {
7530
- return {
7531
- input,
7532
- output,
7533
- kind: options?.kind ?? "query",
7534
- auth: options?.auth ?? "protected",
7535
- ...options?.access !== void 0 ? { access: options.access } : {},
7536
- timeoutMs: options?.timeoutMs
7537
- };
7538
- }
7539
- /**
7540
7604
  * Alarm-panel cap. Models HA `alarm_control_panel.*` on
7541
7605
  * `DeviceType.AlarmPanel`. State follows HA's canonical lifecycle
7542
7606
  * across disarmed / armed_(home|away|night|vacation|custom_bypass) /
@@ -11559,9 +11623,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
11559
11623
  limit: number().optional(),
11560
11624
  tags: record(string(), string()).optional()
11561
11625
  }), array(LogEntrySchema).readonly());
11562
- var StaticDirOutputSchema = object({ staticDir: string() });
11563
- var VersionOutputSchema = object({ version: string() });
11564
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
11565
11626
  /**
11566
11627
  * Zod schemas for persisted record types.
11567
11628
  *
@@ -13910,7 +13971,7 @@ method(object({
13910
13971
  }), _void(), {
13911
13972
  kind: "mutation",
13912
13973
  auth: "admin"
13913
- }), 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({
13914
13975
  deviceId: number(),
13915
13976
  values: record(string(), unknown())
13916
13977
  }), object({ success: literal(true) }), {
@@ -14592,7 +14653,20 @@ var DiskSpaceInfoSchema = object({
14592
14653
  var PidResourceStatsSchema = object({
14593
14654
  pid: number(),
14594
14655
  cpu: number(),
14595
- 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()
14596
14670
  });
14597
14671
  var AddonInstanceSchema = object({
14598
14672
  addonId: string(),
@@ -14641,6 +14715,17 @@ var KillProcessResultSchema = object({
14641
14715
  reason: string().optional(),
14642
14716
  signal: _enum(["SIGTERM", "SIGKILL"]).optional()
14643
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
+ });
14644
14729
  var SystemMetricsSchema = object({
14645
14730
  cpuPercent: number(),
14646
14731
  memoryPercent: number(),
@@ -14654,6 +14739,9 @@ var SystemMetricsSchema = object({
14654
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, {
14655
14740
  kind: "mutation",
14656
14741
  auth: "admin"
14742
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
14743
+ kind: "mutation",
14744
+ auth: "admin"
14657
14745
  });
14658
14746
  var PtzPresetSchema = object({
14659
14747
  id: string(),
@@ -15020,63 +15108,6 @@ method(object({
15020
15108
  auth: "admin"
15021
15109
  });
15022
15110
  /**
15023
- * device-ops — device-scoped cap that unifies the per-IDevice operations
15024
- * previously routed through the `.device-ops` Moleculer bridge service.
15025
- *
15026
- * Each worker that hosts live `IDevice` instances auto-registers a native
15027
- * provider for this cap (per device) backed by its local
15028
- * `DeviceRegistry`. Hub-side callers reach it transparently through
15029
- * `ctx.fetchDevice(id).deviceOps.*` — the DeviceProxy injects
15030
- * `deviceId` + `nodeId` and dispatches through the standard cap-router,
15031
- * so there's no parallel bridge path anymore.
15032
- *
15033
- * The surface is intentionally small — every method corresponds to a
15034
- * single action on the live `IDevice` (or `ICameraDevice` for
15035
- * `getStreamSources`). Richer orchestration (enable/disable with
15036
- * integration plumbing, bulk updates) stays in the `device-manager` cap;
15037
- * `device-ops` is the per-device primitive the device-manager routes to.
15038
- */
15039
- var StreamSourceEntrySchema$1 = object({
15040
- id: string(),
15041
- label: string(),
15042
- protocol: _enum([
15043
- "rtsp",
15044
- "rtmp",
15045
- "annexb",
15046
- "http-mjpeg",
15047
- "webrtc",
15048
- "custom"
15049
- ]),
15050
- url: string().optional(),
15051
- resolution: object({
15052
- width: number(),
15053
- height: number()
15054
- }).optional(),
15055
- fps: number().optional(),
15056
- bitrate: number().optional(),
15057
- codec: string().optional(),
15058
- profileHint: CamProfileSchema.optional(),
15059
- sdp: string().optional()
15060
- });
15061
- var ConfigEntrySchema$1 = object({
15062
- key: string(),
15063
- value: unknown()
15064
- });
15065
- var RawStateResultSchema = object({
15066
- /** Originating provider id, e.g. 'homeassistant' | 'reolink' | 'hikvision'. */
15067
- source: string(),
15068
- /** Opaque, DISPLAY-SAFE upstream blob (no secrets/PII). */
15069
- data: record(string(), unknown())
15070
- });
15071
- method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema$1)), method(object({
15072
- deviceId: number(),
15073
- values: record(string(), unknown())
15074
- }), _void(), { kind: "mutation" }), method(object({
15075
- deviceId: number(),
15076
- action: string().min(1),
15077
- input: unknown()
15078
- }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
15079
- /**
15080
15111
  * camera-credentials — device-scoped cap exposing the camera's network
15081
15112
  * + auth surface in a vendor-neutral shape.
15082
15113
  *
@@ -18759,6 +18790,12 @@ Object.freeze({
18759
18790
  addonId: null,
18760
18791
  access: "view"
18761
18792
  },
18793
+ "metricsProvider.dumpHeapSnapshot": {
18794
+ capName: "metrics-provider",
18795
+ capScope: "system",
18796
+ addonId: null,
18797
+ access: "create"
18798
+ },
18762
18799
  "metricsProvider.getAddonStats": {
18763
18800
  capName: "metrics-provider",
18764
18801
  capScope: "system",