@camstack/addon-provider-homeassistant 1.2.6 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +483 -81
  2. package/dist/addon.mjs +483 -81
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { brotliCompressSync, deflateSync, gzipSync } from "node:zlib";
3
- //#region ../types/dist/event-category-BLcNejAE.mjs
3
+ //#region ../types/dist/event-category-Bz24uP1U.mjs
4
4
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
5
5
  EventCategory["SystemBoot"] = "system.boot";
6
6
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -271,6 +271,19 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
271
271
  */
272
272
  EventCategory["DeviceStateChanged"] = "device.state-changed";
273
273
  /**
274
+ * Frame occupancy for a camera CHANGED — a tracked object was gained or
275
+ * lost. Carries `{ deviceId, totalObjects, byClass, zones }`.
276
+ *
277
+ * Emitted only on a change, so a steady scene is silent. It exists so a
278
+ * client can stop polling `zoneAnalytics.getCurrentSnapshot`: that was the
279
+ * one live badge with no push signal at all, and it cost a request every
280
+ * four seconds per visible camera.
281
+ *
282
+ * Like every event it is telemetry and may be dropped ([D8]) — a consumer
283
+ * keeps a slow reconcile rather than trusting it alone.
284
+ */
285
+ EventCategory["ZoneAnalyticsOccupancyChanged"] = "zone-analytics.occupancy-changed";
286
+ /**
274
287
  * Cap event fired by every device that registers the `battery`
275
288
  * capability. Mirrors the cap definition's `onStatusChanged`. Carries
276
289
  * `{ deviceId, status: BatteryStatus }`. Subscribers (alert center,
@@ -7317,35 +7330,22 @@ function buildCapturingReply(envelope) {
7317
7330
  */
7318
7331
  var RecordingWeekdaySchema = number().int().min(0).max(6);
7319
7332
  var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
7320
- var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
7321
- kind: literal("timeOfDay"),
7322
- start: string().regex(HHMM),
7323
- end: string().regex(HHMM),
7324
- /** Restrict to these weekdays; omit = every day. */
7325
- days: array(RecordingWeekdaySchema).optional()
7326
- })]);
7327
- var RecordingModeSchema = _enum([
7328
- "continuous",
7329
- "onMotion",
7330
- "onAudioThreshold"
7331
- ]);
7332
7333
  /**
7333
- * First-class, authoritative per-camera storage mode — the explicit choice the
7334
- * UI reads directly (never inferred from `rules`):
7335
- * - `off` — not recording.
7336
- * - `events` — record only around triggers (motion / audio threshold),
7337
- * with pre/post-buffer.
7338
- * - `continuous` — record 24/7 within the schedule.
7334
+ * DERIVED per-camera storage summary — the single field cheap consumers read
7335
+ * (the viewer's status dot, the camera list) instead of walking `bands`:
7336
+ * - `off` — no band covers the camera (or it is disabled).
7337
+ * - `events` — every band records around triggers only.
7338
+ * - `continuous` — at least one band records continuously.
7339
7339
  *
7340
- * `mode` compiles one-way to the internal `rules[]` consumed by the policy
7341
- * engine (see `compileRules`); `rules[]` is never authored directly anymore.
7340
+ * NEVER authored: the recorder stamps it from the authoritative `bands` on
7341
+ * every save (`activeModeForConfig`). Writing it has no effect.
7342
7342
  */
7343
7343
  var RecordingStorageModeSchema = _enum([
7344
7344
  "off",
7345
7345
  "events",
7346
7346
  "continuous"
7347
7347
  ]);
7348
- /** Which detectors trigger an `events`-mode recording. */
7348
+ /** Which detectors trigger an `events`-mode band. */
7349
7349
  var RecordingTriggersSchema = object({
7350
7350
  motion: boolean().optional(),
7351
7351
  audioThresholdDbfs: number().optional()
@@ -7381,18 +7381,6 @@ var RecordingBandSchema = object({
7381
7381
  preBufferSec: number().min(0).optional(),
7382
7382
  postBufferSec: number().min(0).optional()
7383
7383
  });
7384
- var RecordingRuleSchema = object({
7385
- schedule: RecordingScheduleSchema,
7386
- mode: RecordingModeSchema,
7387
- /** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
7388
- preBufferSec: number().min(0).default(0),
7389
- /** Keep recording until this many seconds after the last trigger. */
7390
- postBufferSec: number().min(0).default(0),
7391
- /** Each new trigger restarts the post-buffer window. */
7392
- resetTimeoutOnNewEvent: boolean().default(true),
7393
- /** onAudioThreshold only — dBFS level that counts as a trigger. */
7394
- thresholdDbfs: number().optional()
7395
- });
7396
7384
  /**
7397
7385
  * Per-device retention overrides. Every field is optional; an unset or `0`
7398
7386
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -7426,40 +7414,28 @@ var ScrubThumbnailPresetSchema = _enum([
7426
7414
  /**
7427
7415
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7428
7416
  *
7429
- * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
7430
- * are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
7431
- * only for transition + migration (`migrateRulesToMode`); the policy engine
7432
- * consumes the compiled output of `compileRules(config)`, never `rules` directly.
7417
+ * `bands` is the ONLY authored recording intent: what to record, when, and on
7418
+ * which trigger. `mode` is a derived summary the recorder stamps on save; every
7419
+ * other field is a storage knob (profiles, segment length, retention, scrub).
7420
+ *
7421
+ * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7422
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7423
+ * A stale caller must fail loudly — silently stripping its legacy intent would
7424
+ * persist a band-less config, i.e. silently stop recording the camera.
7433
7425
  */
7434
7426
  var RecordingConfigSchema = object({
7435
7427
  enabled: boolean(),
7436
- /** Authoritative storage mode. Absent on legacy targets derived once via
7437
- * `migrateRulesToMode`, then persisted. */
7428
+ /** DERIVED summary of `bands`, stamped by the recorder on every save.
7429
+ * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
7438
7430
  mode: RecordingStorageModeSchema.optional(),
7439
7431
  profiles: array(CamProfileSchema).optional(),
7440
7432
  segmentSeconds: number().int().positive().optional(),
7441
- /** Shared recording time-bands for `events` & `continuous` — record only when
7442
- * the wall-clock falls inside one of these windows. Omit or empty = always.
7443
- * `continuous` compiles to one rule per band; `events` to band × trigger. */
7444
- schedules: array(RecordingScheduleSchema).optional(),
7445
- /** Legacy single-band predecessor of `schedules`. Read-compat only — it is
7446
- * normalized into `schedules` on read and never written going forward. (Not
7447
- * tagged `@deprecated`: the normalization paths must read it cast-free.) */
7448
- schedule: RecordingScheduleSchema.optional(),
7449
- /** `events`-mode only — which detectors trigger a recording. */
7450
- triggers: RecordingTriggersSchema.optional(),
7451
- /** `events`-mode only — seconds retained before / after a trigger. */
7452
- preBufferSec: number().min(0).optional(),
7453
- postBufferSec: number().min(0).optional(),
7454
- /** DEPRECATED authoring input; retained for migration/transition. */
7455
- rules: array(RecordingRuleSchema).optional(),
7456
7433
  /**
7457
- * AUTHORITATIVE mode-per-band recording model (recorder). When present it
7458
- * is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
7459
- * `triggers`/`rules` fields above are kept for READ-COMPAT only and are
7460
- * derived into bands once via `migrateConfigToBands`.
7434
+ * AUTHORITATIVE mode-per-band recording model the single source of truth
7435
+ * the recorder's band engine consumes. An empty array = record nothing;
7436
+ * "off" is the absence of a covering band, never a band value.
7461
7437
  */
7462
- bands: array(RecordingBandSchema).optional(),
7438
+ bands: array(RecordingBandSchema).default([]),
7463
7439
  retention: RecordingRetentionSchema.optional(),
7464
7440
  /**
7465
7441
  * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
@@ -7467,8 +7443,15 @@ var RecordingConfigSchema = object({
7467
7443
  * windows only — existing sheets are immutable, and each window's index
7468
7444
  * carries its own tile dims so mixed-preset history renders correctly.
7469
7445
  */
7470
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7471
- });
7446
+ scrubThumbnails: ScrubThumbnailPresetSchema.optional(),
7447
+ /**
7448
+ * OPT-IN thumbnail-strip generation for this camera: every keyframe of the
7449
+ * low recording saved as a JPEG (the fast-drag scrub depth), a derived
7450
+ * cache that eviction reclaims with the footage. Absent/false = no strips
7451
+ * are written and scrub reads exact keyframes at every velocity.
7452
+ */
7453
+ stripsEnabled: boolean().optional()
7454
+ }).strict();
7472
7455
  /**
7473
7456
  * Ops-log — the durable, append-only operations audit shared by the
7474
7457
  * recordings and events management surfaces.
@@ -7487,7 +7470,8 @@ var OpsLogOpSchema = _enum([
7487
7470
  "prune",
7488
7471
  "manual-delete",
7489
7472
  "rescan",
7490
- "retention-run"
7473
+ "retention-run",
7474
+ "relocate"
7491
7475
  ]);
7492
7476
  /** Why the operation ran. */
7493
7477
  var OpsLogReasonSchema = _enum([
@@ -7526,6 +7510,55 @@ var OpsLogQueryInputSchema = object({
7526
7510
  limit: number().int().min(1).max(1e3).optional()
7527
7511
  });
7528
7512
  /**
7513
+ * Entity-relocation job state (storage entity-routing spec, Phase 4).
7514
+ *
7515
+ * One shape shared by the recorder's `relocateFootage` (segments + strips) and
7516
+ * pipeline-analytics' `relocateMedia` (event media blobs) so the admin Data
7517
+ * page renders both movers with one component. Jobs are in-RAM (a restart
7518
+ * forgets them — re-running is safe by construction: copy-if-absent, delete
7519
+ * after verify) and each completed/failed run also lands one durable ops-log
7520
+ * row on the owning addon's surface.
7521
+ */
7522
+ var RelocateJobStateSchema = _enum([
7523
+ "running",
7524
+ "done",
7525
+ "failed",
7526
+ "cancelled"
7527
+ ]);
7528
+ var RelocateJobSchema = object({
7529
+ jobId: string(),
7530
+ state: RelocateJobStateSchema,
7531
+ /** Source location — for media relocation this is informational ('*': rows
7532
+ * move from wherever they are to the target). */
7533
+ fromLocationId: string(),
7534
+ toLocationId: string(),
7535
+ /** Scoped device, or null = every device. */
7536
+ deviceId: number().nullable(),
7537
+ /** What the job moves (owner-addon specific: segments/strips or media). */
7538
+ entities: array(string()),
7539
+ filesMoved: number().int(),
7540
+ bytesMoved: number().int(),
7541
+ /** Total files discovered up front; null while (or when) unknown. */
7542
+ filesTotal: number().int().nullable(),
7543
+ startedAt: number(),
7544
+ finishedAt: number().nullable(),
7545
+ error: string().nullable()
7546
+ });
7547
+ var RelocateFootageInputSchema = object({
7548
+ deviceId: number().optional(),
7549
+ fromLocationId: string(),
7550
+ toLocationId: string(),
7551
+ entities: array(_enum(["segments", "strips"])).optional(),
7552
+ /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7553
+ * never allowed to starve live writers. */
7554
+ throttleMbps: number().min(1).max(1e3).optional()
7555
+ });
7556
+ var RelocateMediaInputSchema = object({
7557
+ deviceId: number().optional(),
7558
+ toLocationId: string(),
7559
+ throttleMbps: number().min(1).max(1e3).optional()
7560
+ });
7561
+ /**
7529
7562
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
7530
7563
  * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
7531
7564
  * so the persisted record schema and the consumer-facing cap can both consume it
@@ -7575,6 +7608,13 @@ var StorageLocationSchema = object({
7575
7608
  nodeId: string().optional(),
7576
7609
  isDefault: boolean().default(false),
7577
7610
  isSystem: boolean().default(false),
7611
+ /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7612
+ * for node-local locations it can reach) — never persisted, absent when the
7613
+ * volume is remote/unreachable. The single capacity truth every UI reads. */
7614
+ capacity: object({
7615
+ totalBytes: number(),
7616
+ availableBytes: number()
7617
+ }).nullable().optional(),
7578
7618
  createdAt: number(),
7579
7619
  updatedAt: number()
7580
7620
  });
@@ -8342,7 +8382,8 @@ var NcTaxonomyEntrySchema = object({
8342
8382
  /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8343
8383
  parentKind: string().nullable()
8344
8384
  });
8345
- object({
8385
+ /** The complete NC picker taxonomy — three grouped buckets. */
8386
+ var NcTaxonomySchema = object({
8346
8387
  videoClasses: array(NcTaxonomyEntrySchema),
8347
8388
  audioKinds: array(NcTaxonomyEntrySchema),
8348
8389
  labels: array(NcTaxonomyEntrySchema)
@@ -9308,9 +9349,20 @@ var DEGRADE_ORDER = {
9308
9349
  "markdown"
9309
9350
  ]
9310
9351
  };
9311
- /** Pick the best target format the kind supports for a given source format. */
9352
+ /**
9353
+ * Pick the best target format the kind supports for a given source format.
9354
+ *
9355
+ * TOLERANT of a source outside the union. `NotificationSchema.format` carries
9356
+ * `.default('text')`, but that default only runs where the schema is PARSED —
9357
+ * the tRPC router. A cap call arriving from another addon (`ctx.api`) skips
9358
+ * that parse, so `format` reaches here `undefined`, and the bare
9359
+ * `DEGRADE_ORDER[source]` threw `is not iterable`. That broke the one promise
9360
+ * the degrade path makes ("never throws — degradation is reported, never
9361
+ * surfaced as an error") and dead-lettered every Notification-Center delivery
9362
+ * for a day (2026-07-30). An unknown source degrades like `text`.
9363
+ */
9312
9364
  function resolveFormat(source, supported) {
9313
- for (const candidate of DEGRADE_ORDER[source]) if (supported.includes(candidate)) return candidate;
9365
+ for (const candidate of DEGRADE_ORDER[source] ?? DEGRADE_ORDER.text) if (supported.includes(candidate)) return candidate;
9314
9366
  return supported[0] ?? "text";
9315
9367
  }
9316
9368
  /** Transcode a body between formats. */
@@ -9355,7 +9407,7 @@ function resolveLevel(levels, n) {
9355
9407
  })[0]);
9356
9408
  }
9357
9409
  function splitBody(body, maxLen) {
9358
- if (maxLen <= 0 || body.length <= maxLen) return [body];
9410
+ if (!Number.isFinite(maxLen) || maxLen <= 0 || body.length <= maxLen) return [body];
9359
9411
  const parts = [];
9360
9412
  for (let i = 0; i < body.length; i += maxLen) parts.push(body.slice(i, i + maxLen));
9361
9413
  return parts;
@@ -9438,6 +9490,7 @@ function prepareNotification(caps, n) {
9438
9490
  renderedAs
9439
9491
  };
9440
9492
  }
9493
+ new Set(["devices", "classes"]);
9441
9494
  /**
9442
9495
  * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
9443
9496
  * motion-zones, and the detection zones/lines editor all speak this one
@@ -9596,6 +9649,29 @@ var NcOccupancyConditionSchema = object({
9596
9649
  count: number().int().min(0).default(1),
9597
9650
  sustainSeconds: number().int().min(0).max(3600).default(15)
9598
9651
  });
9652
+ /**
9653
+ * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
9654
+ *
9655
+ * The values are not symmetric, and deliberately so — the absent value has to
9656
+ * mean exactly what every rule authored before this condition existed already
9657
+ * does:
9658
+ * - `enter` — entries and every NON-crossing record (movement state,
9659
+ * package, sensor). Exits are rejected. **This is the absent behaviour**:
9660
+ * an operator who never asked for exits must not start receiving them.
9661
+ * - `exit` — ONLY an exit crossing. A record that is not a crossing at all
9662
+ * fails closed, because "the car left the drive" is a question about a
9663
+ * boundary, not about a detection.
9664
+ * - `any` — no direction filter; entries, exits and non-crossings alike.
9665
+ *
9666
+ * A rule asking for a direction should normally also scope `zones`, which the
9667
+ * engine evaluates against the crossed zone as well as the current membership
9668
+ * (an exit's membership no longer contains the zone it just left).
9669
+ */
9670
+ var NcCrossingSchema = _enum([
9671
+ "enter",
9672
+ "exit",
9673
+ "any"
9674
+ ]);
9599
9675
  /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9600
9676
  var NcZoneConditionSchema = object({
9601
9677
  ids: array(string().min(1)).min(1),
@@ -9620,6 +9696,13 @@ var NcConditionsSchema = object({
9620
9696
  /** Veto zones — any hit fails the rule. */
9621
9697
  zonesExclude: array(string().min(1)).optional(),
9622
9698
  /**
9699
+ * Zone-crossing direction. IMMEDIATE only — a crossing is a per-event fact
9700
+ * and a closed track carries none, so a `track-end` rule asking for one
9701
+ * fails closed (use `zones`, which tests `zonesVisited`). ABSENT = `enter`,
9702
+ * which is exactly today's behaviour. See {@link NcCrossingSchema}.
9703
+ */
9704
+ crossing: NcCrossingSchema.optional(),
9705
+ /**
9623
9706
  * Exact (case-insensitive) match on the record's collapsed `label`
9624
9707
  * (identity name / plate text / subclass).
9625
9708
  */
@@ -9754,17 +9837,85 @@ var NcRuleTargetSchema = object({
9754
9837
  * - `keyFrame` — the clean scene frame (no subject box).
9755
9838
  * - `none` — no attachment.
9756
9839
  */
9757
- var NcMediaPolicySchema = object({ attach: _enum([
9758
- "best",
9759
- "best-matching",
9760
- "keyFrame",
9761
- "none"
9762
- ]).default("best") });
9840
+ /**
9841
+ * WHAT THE PICTURE SHOWS — chosen explicitly, because the implicit ladders
9842
+ * conflate it with the selection strategy and betray the request: asking for
9843
+ * the clean scene frame on an object-event owner used to start at
9844
+ * `fullFrameBoxed`, i.e. the annotated frame (2026-07-30).
9845
+ * - `cropped` — the subject, tight. What "who is at the door" wants.
9846
+ * - `full` — the clean scene, no annotation. What "what is going on" wants.
9847
+ * - `boxed` — the scene WITH the detection boxes drawn, for verifying what
9848
+ * the pipeline actually saw.
9849
+ */
9850
+ var NcMediaFrameSchema = _enum([
9851
+ "cropped",
9852
+ "full",
9853
+ "boxed"
9854
+ ]);
9855
+ var NcMediaPolicySchema = object({
9856
+ attach: _enum([
9857
+ "best",
9858
+ "best-matching",
9859
+ "keyFrame",
9860
+ "none"
9861
+ ]).default("best"),
9862
+ /** What the still shows. Absent = `cropped` (the historical `best` shape). */
9863
+ frame: NcMediaFrameSchema.optional(),
9864
+ /** Crop the attached still to the rule's condition-zone bbox (padded) —
9865
+ * "show me the ZONE", not the whole scene or the subject crop. */
9866
+ zoneCrop: boolean().optional(),
9867
+ /**
9868
+ * Also attach a short GIF cut from the stream broker's clip ring around the
9869
+ * event — NOT from the recording, so the camera does not have to be
9870
+ * recording, and the window sits AROUND the moment instead of a segment
9871
+ * behind it. Fail-closed: a window the ring does not cover contributes no
9872
+ * gif, never a failed notification.
9873
+ */
9874
+ gif: boolean().optional(),
9875
+ /**
9876
+ * Also attach a short MP4 CLIP of the same cut. Same source and the same
9877
+ * fail-closed rule as `gif`. Prefer it where the backend takes video
9878
+ * (telegram, discord, zentik, webhook); backends that do not are handled by
9879
+ * the degrade engine, which drops the video and keeps the still.
9880
+ */
9881
+ clip: boolean().optional(),
9882
+ /** Seconds of footage BEFORE / AFTER the event instant. Defaults 3 / 7. */
9883
+ clipPreRollSec: number().int().min(0).max(30).optional(),
9884
+ clipPostRollSec: number().int().min(0).max(30).optional(),
9885
+ /**
9886
+ * Which stream profile the footage is cut from. Absent = the CHEAPEST
9887
+ * assigned profile: a notification is watched on a phone, so the 4K
9888
+ * rendition would burn CPU to produce a file the client downscales anyway.
9889
+ * A profile that is not assigned falls back to the cheapest, and the render
9890
+ * reports which one actually ran.
9891
+ */
9892
+ profile: CamProfileSchema.optional()
9893
+ });
9894
+ /**
9895
+ * Cooldown GRANULARITY over the subject's class — how much a fired
9896
+ * notification suppresses.
9897
+ * - `shared` (default, and the absent value) — one window for the whole
9898
+ * rule/scope: a cat silences the next dog for `cooldownSec`.
9899
+ * - `per-class` — an independent window per detected class, so cat→dog fires
9900
+ * at once and cat→cat still waits.
9901
+ *
9902
+ * AUDIO subjects are ALWAYS per-class regardless of this setting: a scream
9903
+ * must not be swallowed by a bark's window (the precedent this generalizes —
9904
+ * see `cooldownKey` in the rule engine).
9905
+ */
9906
+ var NcThrottleGranularitySchema = _enum(["shared", "per-class"]);
9763
9907
  /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9764
9908
  var NcThrottleSchema = object({
9765
9909
  cooldownSec: number().int().min(0).max(86400).default(60),
9766
9910
  /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9767
- scope: _enum(["rule", "rule-device"]).default("rule-device")
9911
+ scope: _enum(["rule", "rule-device"]).default("rule-device"),
9912
+ /**
9913
+ * Class granularity of the cooldown key. Optional rather than defaulted:
9914
+ * a Zod default does NOT run on the addon→addon cap path, so a persisted
9915
+ * rule authored before this field simply carries none — and the engine
9916
+ * reads absent as `shared`, the pre-existing behaviour.
9917
+ */
9918
+ granularity: NcThrottleGranularitySchema.optional()
9768
9919
  });
9769
9920
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9770
9921
  var NcRuleInputSchema = object({
@@ -9773,7 +9924,19 @@ var NcRuleInputSchema = object({
9773
9924
  delivery: NcDeliverySchema,
9774
9925
  conditions: NcConditionsSchema.default({}),
9775
9926
  schedule: NcScheduleSchema.optional(),
9776
- targets: array(NcRuleTargetSchema).min(1),
9927
+ /** May be empty when `targetUsers` addresses at least one user — the
9928
+ * "at least one addressee" invariant is enforced by the provider, because
9929
+ * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
9930
+ targets: array(NcRuleTargetSchema),
9931
+ /**
9932
+ * USERS this rule addresses in addition to `targets` (Phase 4). At fire
9933
+ * time each user fans out to the personal targets they own
9934
+ * (`config.ownerUserId`), filtered by that user's `allowedDevices` for the
9935
+ * firing camera — a user is never notified about a device they cannot open.
9936
+ * Per-user opt-outs (`disabledTargetIds`) still apply to the fanned-out
9937
+ * targets.
9938
+ */
9939
+ targetUsers: array(string()).optional(),
9777
9940
  media: NcMediaPolicySchema.default({ attach: "best" }),
9778
9941
  throttle: NcThrottleSchema.default({
9779
9942
  cooldownSec: 60,
@@ -9860,6 +10023,7 @@ var NcConditionDescriptorSchema = object({
9860
10023
  "schedule",
9861
10024
  "plateMatcher",
9862
10025
  "packagePhase",
10026
+ "crossingSelect",
9863
10027
  "polygonDraw",
9864
10028
  "occupancy"
9865
10029
  ]),
@@ -9986,7 +10150,10 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
9986
10150
  }), object({ results: array(NcTestResultSchema) }), {
9987
10151
  kind: "mutation",
9988
10152
  auth: "admin"
9989
- }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
10153
+ }), method(object({}), object({
10154
+ catalog: array(NcConditionDescriptorSchema),
10155
+ taxonomy: NcTaxonomySchema.optional()
10156
+ })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9990
10157
  /**
9991
10158
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9992
10159
  *
@@ -10995,6 +11162,28 @@ method(object({
10995
11162
  }), object({ success: literal(true) }), {
10996
11163
  kind: "mutation",
10997
11164
  auth: "admin"
11165
+ }), method(object({
11166
+ deviceId: number(),
11167
+ /** Absent = the LOWEST assigned profile — a notification attachment is
11168
+ * watched on a phone, and the cheap rendition is the right default. */
11169
+ profile: CamProfileSchema.optional(),
11170
+ aroundMs: number(),
11171
+ preRollSec: number().min(0).max(20).default(3),
11172
+ postRollSec: number().min(0).max(20).default(5),
11173
+ format: _enum(["gif", "mp4"]).default("gif"),
11174
+ maxWidth: number().int().min(120).max(1920).default(480),
11175
+ /** GIF only — MP4 keeps the source cadence. */
11176
+ fps: number().int().min(1).max(15).default(5)
11177
+ }), object({
11178
+ base64: string(),
11179
+ mime: string(),
11180
+ bytes: number().int(),
11181
+ /** The profile actually rendered (what the default resolved to). */
11182
+ profile: CamProfileSchema,
11183
+ durationMs: number()
11184
+ }), {
11185
+ kind: "mutation",
11186
+ auth: "admin"
10998
11187
  }), method(_void(), array(CameraStreamSchema).readonly()), method(_void(), array(ProfileSlotSchema).readonly()), method(object({ brokerId: string() }), BrokerStatsSchema), method(object({ brokerId: string() }), object({
10999
11188
  probed: boolean(),
11000
11189
  summary: string()
@@ -19187,7 +19376,10 @@ method(object({
19187
19376
  }), method(object({
19188
19377
  deviceId: number(),
19189
19378
  caps: array(string()).readonly().optional()
19190
- }), record(string(), unknown().nullable()));
19379
+ }), record(string(), unknown().nullable())), method(object({
19380
+ deviceIds: array(number()).readonly(),
19381
+ caps: array(string()).readonly().optional()
19382
+ }), record(string(), record(string(), unknown().nullable())));
19191
19383
  method(object({ deviceId: number() }), record(string(), record(string(), unknown()))), method(object({
19192
19384
  deviceId: number(),
19193
19385
  capName: string()
@@ -20118,6 +20310,36 @@ var TargetKindSchema = object({
20118
20310
  icon: string(),
20119
20311
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
20120
20312
  addonId: string(),
20313
+ /**
20314
+ * URL of the kind's bundled BRAND icon, served by the providing addon over
20315
+ * its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
20316
+ * when the addon bundles no icon for that kind — the client then falls back
20317
+ * to a neutral glyph rather than rendering the raw `icon` NAME as text.
20318
+ *
20319
+ * Root-relative on purpose: it resolves against whatever origin serves a web
20320
+ * client, and a native client joins it onto its own hub base.
20321
+ *
20322
+ * DECLARED here deliberately. It used to travel as an undeclared passthrough
20323
+ * field that survived only because the runtime cap-router forwards provider
20324
+ * output verbatim — so every consumer had to re-declare it by hand to stop
20325
+ * its own Zod parse from stripping it, and the whole arrangement would have
20326
+ * broken silently the moment output validation was tightened anywhere.
20327
+ */
20328
+ iconUrl: string().optional(),
20329
+ /**
20330
+ * Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
20331
+ *
20332
+ * The server knows this and therefore says it, because the client cannot
20333
+ * safely guess: a React-Native client renders SVG and raster through two
20334
+ * DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
20335
+ * not decode SVG on iOS/Android), so without this it silently fell back to a
20336
+ * placeholder glyph for every vector icon while the web build looked fine.
20337
+ *
20338
+ * Absent when {@link iconUrl} is absent, or for a legacy provider that has
20339
+ * not been updated — a client that cannot determine the type should prefer
20340
+ * its raster path, which is the safe default for an unknown image.
20341
+ */
20342
+ iconMediaType: string().optional(),
20121
20343
  configSchema: ConfigSchemaPassthrough,
20122
20344
  supportsDiscovery: boolean(),
20123
20345
  caps: TargetKindCapsSchema
@@ -20579,6 +20801,29 @@ var MotionEventSchema = object({
20579
20801
  * Absent on legacy rows ⇒ treat as `pipeline`.
20580
20802
  */
20581
20803
  var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
20804
+ /**
20805
+ * The confirmed zone crossing that produced an object event. Present ONLY on
20806
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
20807
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
20808
+ * appearance event carry none, so a rule asking for a direction fails closed
20809
+ * on them.
20810
+ *
20811
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
20812
+ * into its own event, so a frame in which a track enters A while leaving B
20813
+ * produces two events with two directions — never one ambiguous row.
20814
+ *
20815
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
20816
+ * membership the box has NOW, and by definition it no longer contains the zone
20817
+ * that was just left. Without the id here, a zone-scoped rule could never match
20818
+ * the exit it asked for.
20819
+ */
20820
+ var ZoneCrossingSchema = object({
20821
+ direction: _enum(["enter", "exit"]),
20822
+ /** Admin zone id crossed. */
20823
+ zoneId: string(),
20824
+ /** Zone display name at crossing time (falls back to the id). */
20825
+ zoneName: string().optional()
20826
+ });
20582
20827
  var ObjectEventSchema = object({
20583
20828
  ...BaseEventFields,
20584
20829
  kind: literal("object"),
@@ -20605,6 +20850,12 @@ var ObjectEventSchema = object({
20605
20850
  zones: array(string()).readonly().optional(),
20606
20851
  /** Omitted in slim projection. */
20607
20852
  state: TrackStateSchema.optional(),
20853
+ /**
20854
+ * The zone crossing this event IS, when it is one. Absent on every other
20855
+ * event kind (movement state, appearance, package) — see
20856
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
20857
+ */
20858
+ zoneCrossing: ZoneCrossingSchema.optional(),
20608
20859
  /** Detection-frame dimensions in pixels — let consumers normalize the
20609
20860
  * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
20610
20861
  frameWidth: number().optional(),
@@ -20863,6 +21114,15 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
20863
21114
  }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
20864
21115
  kind: "mutation",
20865
21116
  auth: "admin"
21117
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
21118
+ kind: "mutation",
21119
+ auth: "admin"
21120
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
21121
+ kind: "query",
21122
+ auth: "admin"
21123
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21124
+ kind: "mutation",
21125
+ auth: "admin"
20866
21126
  }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
20867
21127
  kind: "query",
20868
21128
  auth: "admin"
@@ -23431,6 +23691,17 @@ var GetConnectionEndpointsResultSchema = object({ endpoints: array(object({
23431
23691
  */
23432
23692
  priority: number()
23433
23693
  })).readonly() });
23694
+ /**
23695
+ * The chosen outbound endpoint for notification artifacts. `baseUrl: null` =
23696
+ * AUTO (resolved from the candidate ranking at send time); `resolved` reports
23697
+ * what AUTO currently picks, so the UI can show the effective value either way.
23698
+ */
23699
+ var NotificationEndpointSchema = object({
23700
+ /** The operator's explicit choice, or null for AUTO. */
23701
+ baseUrl: string().nullable(),
23702
+ /** What the ranking currently resolves to (null when nothing is reachable). */
23703
+ resolved: string().nullable()
23704
+ });
23434
23705
  var AllowedAddressesSchema = object({
23435
23706
  /**
23436
23707
  * Allowlist of interface addresses operators have explicitly opted
@@ -23453,7 +23724,7 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
23453
23724
  * to avoid mixed-content blocks in the browser. The public
23454
23725
  * tunnel always emits `https://` regardless. */
23455
23726
  scheme: _enum(["http", "https"]).optional()
23456
- }), GetConnectionEndpointsResultSchema), method(_void(), AllowedAddressesSchema), method(AllowedAddressesSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), AllowedAddressesSchema, { kind: "mutation" });
23727
+ }), GetConnectionEndpointsResultSchema), method(_void(), NotificationEndpointSchema), method(object({ baseUrl: string().nullable() }), NotificationEndpointSchema, { kind: "mutation" }), method(_void(), AllowedAddressesSchema), method(AllowedAddressesSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), AllowedAddressesSchema, { kind: "mutation" });
23457
23728
  /**
23458
23729
  * mesh-network — collection cap for mesh-VPN providers.
23459
23730
  *
@@ -24252,7 +24523,12 @@ var RecordingDeviceUsageSchema = object({
24252
24523
  var RecordingLocationUsageSchema = object({
24253
24524
  /** StorageLocation id; null for the legacy/degraded single-root fallback. */
24254
24525
  locationId: string().nullable(),
24255
- /** Bytes of recordings stored on this location. */
24526
+ /** Every location id sharing this row's PHYSICAL volume (aliases). One row
24527
+ * is emitted per physical disk (2026-07-29): two locations on one root
24528
+ * previously rendered as two identical "disks" with a nonsensical used
24529
+ * split — hydrate attribution across aliases is arbitrary by nature. */
24530
+ locationIds: array(string()).optional(),
24531
+ /** Bytes of recordings stored on this PHYSICAL volume (all aliases). */
24256
24532
  usedBytes: number(),
24257
24533
  /** Free bytes on the location's volume; null when capacity is unknown (remote). */
24258
24534
  availableBytes: number().nullable(),
@@ -24364,6 +24640,44 @@ method(object({
24364
24640
  }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
24365
24641
  kind: "query",
24366
24642
  auth: "admin"
24643
+ }), method(object({
24644
+ deviceId: number(),
24645
+ aroundMs: number(),
24646
+ preRollSec: number().min(0).max(30).default(2),
24647
+ postRollSec: number().min(0).max(30).default(5),
24648
+ maxWidth: number().int().min(120).max(1280).default(480),
24649
+ fps: number().int().min(1).max(15).default(5)
24650
+ }), object({
24651
+ gifBase64: string(),
24652
+ fromMs: number(),
24653
+ toMs: number()
24654
+ }), {
24655
+ kind: "mutation",
24656
+ auth: "admin"
24657
+ }), method(object({
24658
+ deviceId: number(),
24659
+ aroundMs: number(),
24660
+ preRollSec: number().min(0).max(30).default(3),
24661
+ postRollSec: number().min(0).max(30).default(7),
24662
+ maxWidth: number().int().min(160).max(1920).default(640)
24663
+ }), object({
24664
+ clipBase64: string(),
24665
+ mime: string(),
24666
+ fromMs: number(),
24667
+ toMs: number(),
24668
+ bytes: number().int()
24669
+ }), {
24670
+ kind: "mutation",
24671
+ auth: "admin"
24672
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
24673
+ kind: "mutation",
24674
+ auth: "admin"
24675
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
24676
+ kind: "query",
24677
+ auth: "admin"
24678
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
24679
+ kind: "mutation",
24680
+ auth: "admin"
24367
24681
  });
24368
24682
  /**
24369
24683
  * `recordingExport` cap — render a footage time range into a single downloadable
@@ -25955,6 +26269,12 @@ Object.freeze({
25955
26269
  addonId: null,
25956
26270
  access: "view"
25957
26271
  },
26272
+ "deviceManager.getDeviceStatusAggregateBatch": {
26273
+ capName: "device-manager",
26274
+ capScope: "system",
26275
+ addonId: null,
26276
+ access: "view"
26277
+ },
25958
26278
  "deviceManager.getLinkedDevices": {
25959
26279
  capName: "device-manager",
25960
26280
  capScope: "system",
@@ -26849,6 +27169,12 @@ Object.freeze({
26849
27169
  addonId: null,
26850
27170
  access: "view"
26851
27171
  },
27172
+ "localNetwork.getNotificationEndpoint": {
27173
+ capName: "local-network",
27174
+ capScope: "system",
27175
+ addonId: null,
27176
+ access: "view"
27177
+ },
26852
27178
  "localNetwork.getPreferred": {
26853
27179
  capName: "local-network",
26854
27180
  capScope: "system",
@@ -26873,6 +27199,12 @@ Object.freeze({
26873
27199
  addonId: null,
26874
27200
  access: "create"
26875
27201
  },
27202
+ "localNetwork.setNotificationEndpoint": {
27203
+ capName: "local-network",
27204
+ capScope: "system",
27205
+ addonId: null,
27206
+ access: "create"
27207
+ },
26876
27208
  "lockControl.lock": {
26877
27209
  capName: "lock-control",
26878
27210
  capScope: "device",
@@ -27515,6 +27847,12 @@ Object.freeze({
27515
27847
  addonId: null,
27516
27848
  access: "create"
27517
27849
  },
27850
+ "pipelineAnalytics.cancelMediaRelocate": {
27851
+ capName: "pipeline-analytics",
27852
+ capScope: "device",
27853
+ addonId: null,
27854
+ access: "create"
27855
+ },
27518
27856
  "pipelineAnalytics.clearTracks": {
27519
27857
  capName: "pipeline-analytics",
27520
27858
  capScope: "device",
@@ -27569,6 +27907,12 @@ Object.freeze({
27569
27907
  addonId: null,
27570
27908
  access: "view"
27571
27909
  },
27910
+ "pipelineAnalytics.getMediaRelocateStatus": {
27911
+ capName: "pipeline-analytics",
27912
+ capScope: "device",
27913
+ addonId: null,
27914
+ access: "view"
27915
+ },
27572
27916
  "pipelineAnalytics.getMotionEvents": {
27573
27917
  capName: "pipeline-analytics",
27574
27918
  capScope: "device",
@@ -27641,6 +27985,12 @@ Object.freeze({
27641
27985
  addonId: null,
27642
27986
  access: "create"
27643
27987
  },
27988
+ "pipelineAnalytics.relocateMedia": {
27989
+ capName: "pipeline-analytics",
27990
+ capScope: "device",
27991
+ addonId: null,
27992
+ access: "create"
27993
+ },
27644
27994
  "pipelineAnalytics.searchObjectEvents": {
27645
27995
  capName: "pipeline-analytics",
27646
27996
  capScope: "device",
@@ -28403,6 +28753,12 @@ Object.freeze({
28403
28753
  addonId: null,
28404
28754
  access: "create"
28405
28755
  },
28756
+ "recording.cancelRelocate": {
28757
+ capName: "recording",
28758
+ capScope: "system",
28759
+ addonId: null,
28760
+ access: "create"
28761
+ },
28406
28762
  "recording.deleteFootprint": {
28407
28763
  capName: "recording",
28408
28764
  capScope: "system",
@@ -28433,6 +28789,12 @@ Object.freeze({
28433
28789
  addonId: null,
28434
28790
  access: "view"
28435
28791
  },
28792
+ "recording.getRelocateStatus": {
28793
+ capName: "recording",
28794
+ capScope: "system",
28795
+ addonId: null,
28796
+ access: "view"
28797
+ },
28436
28798
  "recording.getStorageUsage": {
28437
28799
  capName: "recording",
28438
28800
  capScope: "system",
@@ -28463,6 +28825,24 @@ Object.freeze({
28463
28825
  addonId: null,
28464
28826
  access: "view"
28465
28827
  },
28828
+ "recording.relocateFootage": {
28829
+ capName: "recording",
28830
+ capScope: "system",
28831
+ addonId: null,
28832
+ access: "create"
28833
+ },
28834
+ "recording.renderClip": {
28835
+ capName: "recording",
28836
+ capScope: "system",
28837
+ addonId: null,
28838
+ access: "create"
28839
+ },
28840
+ "recording.renderGif": {
28841
+ capName: "recording",
28842
+ capScope: "system",
28843
+ addonId: null,
28844
+ access: "create"
28845
+ },
28466
28846
  "recording.rescanStorage": {
28467
28847
  capName: "recording",
28468
28848
  capScope: "system",
@@ -29057,6 +29437,12 @@ Object.freeze({
29057
29437
  addonId: null,
29058
29438
  access: "create"
29059
29439
  },
29440
+ "streamBroker.renderPreBufferClip": {
29441
+ capName: "stream-broker",
29442
+ capScope: "system",
29443
+ addonId: null,
29444
+ access: "create"
29445
+ },
29060
29446
  "streamBroker.restartProfile": {
29061
29447
  capName: "stream-broker",
29062
29448
  capScope: "system",
@@ -36052,6 +36438,17 @@ var HOME_ASSISTANT_SVG = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0
36052
36438
  * the admin UI is served from.
36053
36439
  */
36054
36440
  var HA_NOTIFICATION_ICON_URL = `/addon/${HA_ROUTE_ID}/icons/${HA_ICON_KIND}`;
36441
+ /**
36442
+ * Media type of {@link HA_NOTIFICATION_ICON_URL}, stamped onto the kind
36443
+ * descriptor beside the URL.
36444
+ *
36445
+ * Not decoration: a React-Native client renders SVG and raster through
36446
+ * DIFFERENT components (`react-native-svg` vs `expo-image`, and expo-image does
36447
+ * not decode SVG on iOS/Android), and it cannot infer the type from the URL
36448
+ * because the route path carries no file extension. Without this the viewer
36449
+ * treats the icon as raster and falls back to a placeholder glyph.
36450
+ */
36451
+ var HA_NOTIFICATION_ICON_MEDIA_TYPE = "image/svg+xml";
36055
36452
  /** The icon's identity bytes plus every content coding we may serve, computed
36056
36453
  * once at module load (the icon is immutable). */
36057
36454
  var HA_ICON_IDENTITY = Buffer.from(HOME_ASSISTANT_SVG, "utf8");
@@ -36488,10 +36885,14 @@ function createHaNotificationOutputProvider(deps) {
36488
36885
  }
36489
36886
  return {
36490
36887
  listTargetKinds: async () => {
36491
- return [deps.iconUrl !== void 0 ? {
36888
+ return [deps.iconUrl === void 0 ? descriptor : deps.iconMediaType !== void 0 ? {
36889
+ ...descriptor,
36890
+ iconUrl: deps.iconUrl,
36891
+ iconMediaType: deps.iconMediaType
36892
+ } : {
36492
36893
  ...descriptor,
36493
36894
  iconUrl: deps.iconUrl
36494
- } : descriptor];
36895
+ }];
36495
36896
  },
36496
36897
  listTargets: async () => {
36497
36898
  return (await store.list()).map((target) => ({
@@ -37075,6 +37476,7 @@ var HaProviderAddon = class HaProviderAddon extends BaseDeviceProvider {
37075
37476
  return createHaNotificationOutputProvider({
37076
37477
  addonId: this.ctx.id,
37077
37478
  iconUrl: HA_NOTIFICATION_ICON_URL,
37479
+ iconMediaType: HA_NOTIFICATION_ICON_MEDIA_TYPE,
37078
37480
  store,
37079
37481
  publish: async (brokerId, service, serviceData) => {
37080
37482
  await this.requireRegistry().publish(brokerId, {