@camstack/addon-matter-broker 0.2.19 → 0.2.20

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 +179 -44
  2. package/dist/addon.mjs +179 -44
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -13,7 +13,7 @@ let node_stream_promises = require("node:stream/promises");
13
13
  let node_net = require("node:net");
14
14
  let node_dgram = require("node:dgram");
15
15
  node_dgram = require_esm.__toESM(node_dgram, 1);
16
- //#region ../types/dist/event-category-Bxo5yJjt.mjs
16
+ //#region ../types/dist/event-category-XfKNtfCc.mjs
17
17
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
18
18
  EventCategory["SystemBoot"] = "system.boot";
19
19
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -30,9 +30,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
30
30
  EventCategory["SystemRestartCompleted"] = "system.restart-completed";
31
31
  /**
32
32
  * A newer addon or server-root package version was found by the
33
- * authoritative registry check. Emitted once per
34
- * `(target, packageName, currentVersion, latestVersion)` transition; repeated
35
- * polling of the same result is deduplicated by the checker.
33
+ * authoritative registry check. Emitted once when any observed
34
+ * `latestVersion` changes (or a package/node first appears behind);
35
+ * the payload carries the full currently-available list. Repeated
36
+ * polling of the same latests is silent.
36
37
  */
37
38
  EventCategory["UpdateAvailable"] = "update.available";
38
39
  /**
@@ -51,6 +52,22 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
51
52
  EventCategory["AddonInstalled"] = "addon.installed";
52
53
  EventCategory["AddonUninstalled"] = "addon.uninstalled";
53
54
  EventCategory["AddonCrashed"] = "addon.crashed";
55
+ /**
56
+ * A RUNNER the D6 crash circuit-breaker gave up on — terminal.
57
+ *
58
+ * `AddonCrashed` is the routine, self-healing fact ("it crashed; it is being
59
+ * respawned"); this is the one that never resolves itself. Emitted exactly
60
+ * once per trip, by `process-service.ts`, carrying the node, the runner, the
61
+ * addons it hosted and the crash count that tripped the breaker.
62
+ *
63
+ * It exists because a runner marked terminally `failed` used to be SILENT:
64
+ * on 2026-08-18 the `recorder` runner died of three unhandled ffmpeg spawn
65
+ * errors, the breaker stopped respawning it (correctly), `/health` kept
66
+ * returning 200, and fleet-wide recording was gone for 3h15 before the
67
+ * operator's phone told him. The Notification Center's system-event intake
68
+ * consumes this category and maps it to the `addon-crash-loop` kind.
69
+ */
70
+ EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
54
71
  EventCategory["AddonError"] = "addon.error";
55
72
  EventCategory["AddonPageReady"] = "addon.page-ready";
56
73
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -7562,6 +7579,10 @@ var RecordingBandSchema = object({
7562
7579
  preBufferSec: number().min(0).optional(),
7563
7580
  postBufferSec: number().min(0).optional()
7564
7581
  });
7582
+ ({
7583
+ preBufferSec: 10,
7584
+ postBufferSec: 30
7585
+ }).postBufferSec * 1e3;
7565
7586
  /**
7566
7587
  * Per-device retention overrides. Every field is optional; an unset or `0`
7567
7588
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -7609,6 +7630,12 @@ var RecordingConfigSchema = object({
7609
7630
  /** DERIVED summary of `bands`, stamped by the recorder on every save.
7610
7631
  * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
7611
7632
  mode: RecordingStorageModeSchema.optional(),
7633
+ /**
7634
+ * Which assigned broker slots to record. Absent / empty = {@link
7635
+ * DEFAULT_RECORDING_PROFILES} (`high`+`low`) intersected with the
7636
+ * camera's currently assigned slots — never `mid` unless the operator
7637
+ * picks it, and never a slot the broker has not assigned.
7638
+ */
7612
7639
  profiles: array(CamProfileSchema).optional(),
7613
7640
  segmentSeconds: number().int().positive().optional(),
7614
7641
  /**
@@ -7689,7 +7716,11 @@ var RelocateFootageInputSchema = object({
7689
7716
  profiles: array(string$2()).optional(),
7690
7717
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7691
7718
  * never allowed to starve live writers. */
7692
- throttleMbps: number().min(1).max(1e3).optional()
7719
+ throttleMbps: number().min(1).max(1e3).optional(),
7720
+ /** Move only segments whose startMs is >= this. Absent = the whole source
7721
+ * pile. Used when a full drain is too expensive and the operator only
7722
+ * wants the recent window on the new disk. */
7723
+ sinceMs: number().int().optional()
7693
7724
  });
7694
7725
  /** Internal, lease-scoped participant operation. It is intentionally separate
7695
7726
  * from persistent recording settings: a migration never changes
@@ -14620,6 +14651,7 @@ var NcSystemEventKindSchema = _enum([
14620
14651
  "node-offline",
14621
14652
  "node-inference-unavailable",
14622
14653
  "detection-blind",
14654
+ "addon-crash-loop",
14623
14655
  "addon-update-available",
14624
14656
  "server-update-available",
14625
14657
  "alarm-triggered",
@@ -14627,6 +14659,9 @@ var NcSystemEventKindSchema = _enum([
14627
14659
  "alarm-disarmed",
14628
14660
  "alarm-arming",
14629
14661
  "alarm-arm-refused",
14662
+ "addon-updated",
14663
+ "server-updated",
14664
+ "export-completed",
14630
14665
  "camera-online",
14631
14666
  "camera-offline",
14632
14667
  "camera-disabled",
@@ -16520,13 +16555,19 @@ var RetrainStatusSchema = _enum([
16520
16555
  * "never marked" from "already trained" must read `retrainStatus`.
16521
16556
  *
16522
16557
  * `debug` does NOT pin; it is attention, not durability.
16558
+ *
16559
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16560
+ * A favourited track is skipped by retention the same way `staging` is, but
16561
+ * it does not enter `none|staging|trained` and has no staging budget.
16523
16562
  */
16524
16563
  var TrackFlagFields = {
16525
16564
  /** Operator marked this track as training material — i.e. `retrainStatus` is
16526
16565
  * `'staging'`. */
16527
16566
  markForTrain: boolean().optional(),
16528
16567
  /** Operator marked this track for diagnostic attention. */
16529
- debug: boolean().optional()
16568
+ debug: boolean().optional(),
16569
+ /** Operator favourited this track. Pins it against pruning. */
16570
+ favourited: boolean().optional()
16530
16571
  };
16531
16572
  /**
16532
16573
  * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
@@ -16551,6 +16592,7 @@ var TrackFlagsSchema = object({
16551
16592
  trackId: string$2(),
16552
16593
  markForTrain: boolean(),
16553
16594
  debug: boolean(),
16595
+ favourited: boolean(),
16554
16596
  /** The lifecycle state the boolean was derived from. Required here (unlike on
16555
16597
  * a track row) because this shape is only ever produced by the write body,
16556
16598
  * which always knows it — and a surface that has just written needs to render
@@ -17183,6 +17225,12 @@ var TrackCascadeCountsSchema = object({
17183
17225
  /** Per-track CLIP search vectors removed (best-effort). */
17184
17226
  embeddings: number().int()
17185
17227
  });
17228
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17229
+ var DiskReconcileCountsSchema = object({
17230
+ mediaDropped: number().int(),
17231
+ tracks: number().int(),
17232
+ events: number().int()
17233
+ });
17186
17234
  /** Event-store footprint for one camera. */
17187
17235
  var EventStoreDeviceFootprintSchema = object({
17188
17236
  deviceId: number(),
@@ -17359,6 +17407,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17359
17407
  }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17360
17408
  kind: "mutation",
17361
17409
  auth: "admin"
17410
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17411
+ kind: "mutation",
17412
+ auth: "admin"
17362
17413
  }), method(object({
17363
17414
  deviceId: number(),
17364
17415
  trackIds: array(string$2()).min(1)
@@ -18909,6 +18960,24 @@ var CameraStatusDegradationSchema = object({
18909
18960
  *
18910
18961
  * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
18911
18962
  */
18963
+ var DiskReconcileJobSchema = object({
18964
+ state: _enum([
18965
+ "idle",
18966
+ "running",
18967
+ "done",
18968
+ "error"
18969
+ ]),
18970
+ total: number().int().nonnegative(),
18971
+ completed: number().int().nonnegative(),
18972
+ currentDeviceId: number().int().nullable(),
18973
+ failed: array(number().int()).readonly(),
18974
+ mediaDropped: number().int().nonnegative(),
18975
+ tracks: number().int().nonnegative(),
18976
+ events: number().int().nonnegative(),
18977
+ startedAtMs: number().int().nullable(),
18978
+ finishedAtMs: number().int().nullable(),
18979
+ error: string$2().nullable()
18980
+ });
18912
18981
  var CameraStatusSchema = object({
18913
18982
  deviceId: number(),
18914
18983
  assignment: CameraAssignmentStatusSchema,
@@ -19140,7 +19209,10 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19140
19209
  }), CameraSwitchGroupSchema, {
19141
19210
  kind: "mutation",
19142
19211
  auth: "admin"
19143
- }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19212
+ }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), DiskReconcileJobSchema, {
19213
+ kind: "mutation",
19214
+ auth: "admin"
19215
+ }), method(_void(), DiskReconcileJobSchema, { auth: "admin" }), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19144
19216
  name: string$2(),
19145
19217
  description: string$2().optional(),
19146
19218
  config: CameraPipelineConfigSchema
@@ -20213,20 +20285,6 @@ var VectorStatsResultSchema = object({
20213
20285
  exact: boolean()
20214
20286
  });
20215
20287
  method(VectorDeclareIndexInputSchema, _void(), { kind: "mutation" }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, { kind: "mutation" }), method(VectorQueryInputSchema, VectorQueryResultSchema), method(VectorGetInputSchema, VectorGetResultSchema), method(VectorDeleteInputSchema, VectorDeleteResultSchema, { kind: "mutation" }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, { kind: "mutation" }), method(VectorStatsInputSchema, VectorStatsResultSchema);
20216
- /**
20217
- * `videoclips` — the unified, navigable-clip surface for a camera.
20218
- *
20219
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
20220
- * provider per device, substitutable. The DEFAULT provider (registered by
20221
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
20222
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
20223
- * is a time-WINDOW over existing footage, never a separate file. A camera that
20224
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
20225
- * wrapper provider for its device and serve its own clip catalog + URLs.
20226
- *
20227
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
20228
- * temporal overlap, so the API never decides `continuous` vs `events`.
20229
- */
20230
20288
  var ClipSchema = object({
20231
20289
  /** Opaque, provider-namespaced id. The default provider encodes the time
20232
20290
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -20243,8 +20301,57 @@ var ClipSchema = object({
20243
20301
  startMs: number(),
20244
20302
  endMs: number()
20245
20303
  }),
20246
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
20247
- thumbnail: string$2().optional()
20304
+ /**
20305
+ * Lazy thumbnail URL, never inlined.
20306
+ *
20307
+ * Recording-derived clips (events-mode keep-window, and the prepared
20308
+ * continuous event+fragment visit) MUST use the snapshot of the **main
20309
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
20310
+ * of the event that owns `kind` (object > motion > audio). Do not extract
20311
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
20312
+ * mint their own stills.
20313
+ *
20314
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
20315
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
20316
+ * Absent is meaningful — "this visit has no event still" — never "we did not
20317
+ * look". Stamping it from a URL template made 35% of one camera's clips point
20318
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
20319
+ * A read that FAILS drops the claim; it never invents it.
20320
+ */
20321
+ thumbnail: string$2().optional(),
20322
+ /**
20323
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
20324
+ * can be decoded. Present whenever the visit came from recorded availability;
20325
+ * absent on a per-event padded window (there is no footage to promise).
20326
+ *
20327
+ * This is not a thumbnail and not a second byte path: it is the argument to
20328
+ * the recorder's existing still route. The surface — never the provider —
20329
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
20330
+ * contiguous range, not of the visit: a visit spans its holes by
20331
+ * construction, so a naive midpoint lands in dead air.
20332
+ */
20333
+ stillAtMs: number().optional(),
20334
+ /**
20335
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
20336
+ * first within kind (object → motion → audio), capped at
20337
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
20338
+ *
20339
+ * Bounded because it is not a payload the surface pages through: one visit on
20340
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
20341
+ * camera-day. Read {@link eventCount} for the true total.
20342
+ */
20343
+ eventIds: array(string$2()).optional(),
20344
+ /** How many analytics events actually overlap this visit. Differs from
20345
+ * `eventIds.length` exactly when the sample was capped — so a truncated
20346
+ * list is never mistaken for a quiet visit. */
20347
+ eventCount: number().int().nonnegative().optional(),
20348
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
20349
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
20350
+ * bar keeps showing them via `recording.getAvailability`. */
20351
+ holes: array(object({
20352
+ startMs: number(),
20353
+ endMs: number()
20354
+ })).optional()
20248
20355
  });
20249
20356
  var ClipPlaybackSchema = object({
20250
20357
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -20708,7 +20815,14 @@ var SearchResultSchema = object({
20708
20815
  });
20709
20816
  var AutoUpdateSettingsSchema = object({
20710
20817
  channel: ChannelSchema,
20711
- intervalSeconds: number()
20818
+ intervalSeconds: number(),
20819
+ /**
20820
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
20821
+ * `channel`: the poller runs while auto-apply is `off`, because being told
20822
+ * about a publish and installing it are different decisions. Clamped
20823
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
20824
+ */
20825
+ updateCheckIntervalSeconds: number()
20712
20826
  });
20713
20827
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
20714
20828
  var RestartAddonResultSchema = unknown();
@@ -20849,7 +20963,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
20849
20963
  auth: "admin"
20850
20964
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
20851
20965
  channel: ChannelSchema,
20852
- intervalSeconds: number().min(300).max(86400).optional()
20966
+ intervalSeconds: number().min(300).max(86400).optional(),
20967
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
20968
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
20853
20969
  }), unknown(), {
20854
20970
  kind: "mutation",
20855
20971
  auth: "admin"
@@ -26547,7 +26663,9 @@ var ExportOptionsSchema = object({
26547
26663
  includeAudio: boolean(),
26548
26664
  maxLifeMs: number().int().positive(),
26549
26665
  deleteAfterDownload: boolean(),
26550
- title: string$2().max(200).optional()
26666
+ title: string$2().max(200).optional(),
26667
+ /** Notification-output target ids to ping when this export becomes ready. */
26668
+ notifyTargetIds: array(string$2().min(1)).max(20).optional()
26551
26669
  }).superRefine((v, ctx) => {
26552
26670
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
26553
26671
  code: ZodIssueCode.custom,
@@ -26606,10 +26724,18 @@ var ExportBytesSchema = object({
26606
26724
  });
26607
26725
  method(object({
26608
26726
  deviceId: number(),
26609
- profile: string$2(),
26727
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
26728
+ profile: string$2().optional(),
26729
+ profiles: array(string$2()).min(1).optional(),
26610
26730
  fromMs: number(),
26611
26731
  toMs: number(),
26612
26732
  options: ExportOptionsSchema
26733
+ }).superRefine((v, ctx) => {
26734
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
26735
+ code: ZodIssueCode.custom,
26736
+ message: "pass profiles[] (min 1) or legacy profile",
26737
+ path: ["profiles"]
26738
+ });
26613
26739
  }), ExportRecordSchema, {
26614
26740
  kind: "mutation",
26615
26741
  auth: "protected"
@@ -29551,15 +29677,6 @@ var BaseDeviceProvider = class extends BaseAddon {
29551
29677
  labels: ["probe not implemented"]
29552
29678
  };
29553
29679
  }
29554
- /**
29555
- * Top-level devices restored at once in {@link onRestoreDevices}.
29556
- *
29557
- * Four covers the fleets this ships to without turning a boot into a burst a
29558
- * camera NVR answers with a refusal. A provider whose upstream is a single
29559
- * session with a serial command channel (a Baichuan hub, an NVR that
29560
- * serialises ISAPI) should lower it; nothing needs to raise it.
29561
- */
29562
- restoreConcurrency = 4;
29563
29680
  async restoreDevices(savedDevices) {
29564
29681
  await this.onRestoreDevices(savedDevices);
29565
29682
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29614,14 +29731,7 @@ var BaseDeviceProvider = class extends BaseAddon {
29614
29731
  });
29615
29732
  }
29616
29733
  };
29617
- let nextTopLevel = 0;
29618
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
29619
- for (;;) {
29620
- const saved = topLevel[nextTopLevel++];
29621
- if (saved === void 0) return;
29622
- await restoreOne(saved);
29623
- }
29624
- }));
29734
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
29625
29735
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29626
29736
  for (const saved of childRows) {
29627
29737
  const Class = this.deviceClasses[saved.type];
@@ -32894,6 +33004,12 @@ Object.freeze({
32894
33004
  addonId: null,
32895
33005
  access: "create"
32896
33006
  },
33007
+ "pipelineAnalytics.reconcileFromDisk": {
33008
+ capName: "pipeline-analytics",
33009
+ capScope: "device",
33010
+ addonId: null,
33011
+ access: "create"
33012
+ },
32897
33013
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
32898
33014
  capName: "pipeline-analytics",
32899
33015
  capScope: "device",
@@ -33296,6 +33412,12 @@ Object.freeze({
33296
33412
  addonId: null,
33297
33413
  access: "view"
33298
33414
  },
33415
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
33416
+ capName: "pipeline-orchestrator",
33417
+ capScope: "system",
33418
+ addonId: null,
33419
+ access: "view"
33420
+ },
33299
33421
  "pipelineOrchestrator.listAgentSettings": {
33300
33422
  capName: "pipeline-orchestrator",
33301
33423
  capScope: "system",
@@ -33320,6 +33442,12 @@ Object.freeze({
33320
33442
  addonId: null,
33321
33443
  access: "create"
33322
33444
  },
33445
+ "pipelineOrchestrator.reconcileFromDisk": {
33446
+ capName: "pipeline-orchestrator",
33447
+ capScope: "system",
33448
+ addonId: null,
33449
+ access: "create"
33450
+ },
33323
33451
  "pipelineOrchestrator.removeAgentSettings": {
33324
33452
  capName: "pipeline-orchestrator",
33325
33453
  capScope: "system",
@@ -36311,6 +36439,11 @@ Object.freeze({
36311
36439
  form: "single",
36312
36440
  optional: true
36313
36441
  }],
36442
+ "pipelineAnalytics.reconcileFromDisk": [{
36443
+ name: "deviceId",
36444
+ form: "single",
36445
+ optional: false
36446
+ }],
36314
36447
  "pipelineAnalytics.restageRetrainTrack": [{
36315
36448
  name: "deviceId",
36316
36449
  form: "single",
@@ -37376,6 +37509,8 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
37376
37509
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
37377
37510
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
37378
37511
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
37512
+ var MB = 1024 * 1024;
37513
+ 1024 * MB, 3072 * MB;
37379
37514
  //#endregion
37380
37515
  //#region ../../node_modules/@matter/general/dist/esm/net/tcp/TcpConnection.js
37381
37516
  /**
package/dist/addon.mjs CHANGED
@@ -11,7 +11,7 @@ import { networkInterfaces, tmpdir, uptime } from "node:os";
11
11
  import { finished } from "node:stream/promises";
12
12
  import { createConnection, createServer as createServer$2 } from "node:net";
13
13
  import * as dgram from "node:dgram";
14
- //#region ../types/dist/event-category-Bxo5yJjt.mjs
14
+ //#region ../types/dist/event-category-XfKNtfCc.mjs
15
15
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
16
16
  EventCategory["SystemBoot"] = "system.boot";
17
17
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -28,9 +28,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
28
28
  EventCategory["SystemRestartCompleted"] = "system.restart-completed";
29
29
  /**
30
30
  * A newer addon or server-root package version was found by the
31
- * authoritative registry check. Emitted once per
32
- * `(target, packageName, currentVersion, latestVersion)` transition; repeated
33
- * polling of the same result is deduplicated by the checker.
31
+ * authoritative registry check. Emitted once when any observed
32
+ * `latestVersion` changes (or a package/node first appears behind);
33
+ * the payload carries the full currently-available list. Repeated
34
+ * polling of the same latests is silent.
34
35
  */
35
36
  EventCategory["UpdateAvailable"] = "update.available";
36
37
  /**
@@ -49,6 +50,22 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
49
50
  EventCategory["AddonInstalled"] = "addon.installed";
50
51
  EventCategory["AddonUninstalled"] = "addon.uninstalled";
51
52
  EventCategory["AddonCrashed"] = "addon.crashed";
53
+ /**
54
+ * A RUNNER the D6 crash circuit-breaker gave up on — terminal.
55
+ *
56
+ * `AddonCrashed` is the routine, self-healing fact ("it crashed; it is being
57
+ * respawned"); this is the one that never resolves itself. Emitted exactly
58
+ * once per trip, by `process-service.ts`, carrying the node, the runner, the
59
+ * addons it hosted and the crash count that tripped the breaker.
60
+ *
61
+ * It exists because a runner marked terminally `failed` used to be SILENT:
62
+ * on 2026-08-18 the `recorder` runner died of three unhandled ffmpeg spawn
63
+ * errors, the breaker stopped respawning it (correctly), `/health` kept
64
+ * returning 200, and fleet-wide recording was gone for 3h15 before the
65
+ * operator's phone told him. The Notification Center's system-event intake
66
+ * consumes this category and maps it to the `addon-crash-loop` kind.
67
+ */
68
+ EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
52
69
  EventCategory["AddonError"] = "addon.error";
53
70
  EventCategory["AddonPageReady"] = "addon.page-ready";
54
71
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -7560,6 +7577,10 @@ var RecordingBandSchema = object({
7560
7577
  preBufferSec: number().min(0).optional(),
7561
7578
  postBufferSec: number().min(0).optional()
7562
7579
  });
7580
+ ({
7581
+ preBufferSec: 10,
7582
+ postBufferSec: 30
7583
+ }).postBufferSec * 1e3;
7563
7584
  /**
7564
7585
  * Per-device retention overrides. Every field is optional; an unset or `0`
7565
7586
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -7607,6 +7628,12 @@ var RecordingConfigSchema = object({
7607
7628
  /** DERIVED summary of `bands`, stamped by the recorder on every save.
7608
7629
  * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
7609
7630
  mode: RecordingStorageModeSchema.optional(),
7631
+ /**
7632
+ * Which assigned broker slots to record. Absent / empty = {@link
7633
+ * DEFAULT_RECORDING_PROFILES} (`high`+`low`) intersected with the
7634
+ * camera's currently assigned slots — never `mid` unless the operator
7635
+ * picks it, and never a slot the broker has not assigned.
7636
+ */
7610
7637
  profiles: array(CamProfileSchema).optional(),
7611
7638
  segmentSeconds: number().int().positive().optional(),
7612
7639
  /**
@@ -7687,7 +7714,11 @@ var RelocateFootageInputSchema = object({
7687
7714
  profiles: array(string$2()).optional(),
7688
7715
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7689
7716
  * never allowed to starve live writers. */
7690
- throttleMbps: number().min(1).max(1e3).optional()
7717
+ throttleMbps: number().min(1).max(1e3).optional(),
7718
+ /** Move only segments whose startMs is >= this. Absent = the whole source
7719
+ * pile. Used when a full drain is too expensive and the operator only
7720
+ * wants the recent window on the new disk. */
7721
+ sinceMs: number().int().optional()
7691
7722
  });
7692
7723
  /** Internal, lease-scoped participant operation. It is intentionally separate
7693
7724
  * from persistent recording settings: a migration never changes
@@ -14618,6 +14649,7 @@ var NcSystemEventKindSchema = _enum([
14618
14649
  "node-offline",
14619
14650
  "node-inference-unavailable",
14620
14651
  "detection-blind",
14652
+ "addon-crash-loop",
14621
14653
  "addon-update-available",
14622
14654
  "server-update-available",
14623
14655
  "alarm-triggered",
@@ -14625,6 +14657,9 @@ var NcSystemEventKindSchema = _enum([
14625
14657
  "alarm-disarmed",
14626
14658
  "alarm-arming",
14627
14659
  "alarm-arm-refused",
14660
+ "addon-updated",
14661
+ "server-updated",
14662
+ "export-completed",
14628
14663
  "camera-online",
14629
14664
  "camera-offline",
14630
14665
  "camera-disabled",
@@ -16518,13 +16553,19 @@ var RetrainStatusSchema = _enum([
16518
16553
  * "never marked" from "already trained" must read `retrainStatus`.
16519
16554
  *
16520
16555
  * `debug` does NOT pin; it is attention, not durability.
16556
+ *
16557
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16558
+ * A favourited track is skipped by retention the same way `staging` is, but
16559
+ * it does not enter `none|staging|trained` and has no staging budget.
16521
16560
  */
16522
16561
  var TrackFlagFields = {
16523
16562
  /** Operator marked this track as training material — i.e. `retrainStatus` is
16524
16563
  * `'staging'`. */
16525
16564
  markForTrain: boolean().optional(),
16526
16565
  /** Operator marked this track for diagnostic attention. */
16527
- debug: boolean().optional()
16566
+ debug: boolean().optional(),
16567
+ /** Operator favourited this track. Pins it against pruning. */
16568
+ favourited: boolean().optional()
16528
16569
  };
16529
16570
  /**
16530
16571
  * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
@@ -16549,6 +16590,7 @@ var TrackFlagsSchema = object({
16549
16590
  trackId: string$2(),
16550
16591
  markForTrain: boolean(),
16551
16592
  debug: boolean(),
16593
+ favourited: boolean(),
16552
16594
  /** The lifecycle state the boolean was derived from. Required here (unlike on
16553
16595
  * a track row) because this shape is only ever produced by the write body,
16554
16596
  * which always knows it — and a surface that has just written needs to render
@@ -17181,6 +17223,12 @@ var TrackCascadeCountsSchema = object({
17181
17223
  /** Per-track CLIP search vectors removed (best-effort). */
17182
17224
  embeddings: number().int()
17183
17225
  });
17226
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17227
+ var DiskReconcileCountsSchema = object({
17228
+ mediaDropped: number().int(),
17229
+ tracks: number().int(),
17230
+ events: number().int()
17231
+ });
17184
17232
  /** Event-store footprint for one camera. */
17185
17233
  var EventStoreDeviceFootprintSchema = object({
17186
17234
  deviceId: number(),
@@ -17357,6 +17405,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17357
17405
  }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17358
17406
  kind: "mutation",
17359
17407
  auth: "admin"
17408
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17409
+ kind: "mutation",
17410
+ auth: "admin"
17360
17411
  }), method(object({
17361
17412
  deviceId: number(),
17362
17413
  trackIds: array(string$2()).min(1)
@@ -18907,6 +18958,24 @@ var CameraStatusDegradationSchema = object({
18907
18958
  *
18908
18959
  * See spec: `docs/superpowers/specs/2026-06-24-camera-status-aggregator-cap.md`
18909
18960
  */
18961
+ var DiskReconcileJobSchema = object({
18962
+ state: _enum([
18963
+ "idle",
18964
+ "running",
18965
+ "done",
18966
+ "error"
18967
+ ]),
18968
+ total: number().int().nonnegative(),
18969
+ completed: number().int().nonnegative(),
18970
+ currentDeviceId: number().int().nullable(),
18971
+ failed: array(number().int()).readonly(),
18972
+ mediaDropped: number().int().nonnegative(),
18973
+ tracks: number().int().nonnegative(),
18974
+ events: number().int().nonnegative(),
18975
+ startedAtMs: number().int().nullable(),
18976
+ finishedAtMs: number().int().nullable(),
18977
+ error: string$2().nullable()
18978
+ });
18910
18979
  var CameraStatusSchema = object({
18911
18980
  deviceId: number(),
18912
18981
  assignment: CameraAssignmentStatusSchema,
@@ -19138,7 +19207,10 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19138
19207
  }), CameraSwitchGroupSchema, {
19139
19208
  kind: "mutation",
19140
19209
  auth: "admin"
19141
- }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19210
+ }), method(object({ deviceId: number() }), CameraStatusSchema), method(object({ deviceIds: array(number()).optional() }), array(CameraStatusSchema).readonly()), method(_void(), DiskReconcileJobSchema, {
19211
+ kind: "mutation",
19212
+ auth: "admin"
19213
+ }), method(_void(), DiskReconcileJobSchema, { auth: "admin" }), method(_void(), array(PipelineTemplateSchema).readonly()), method(object({
19142
19214
  name: string$2(),
19143
19215
  description: string$2().optional(),
19144
19216
  config: CameraPipelineConfigSchema
@@ -20211,20 +20283,6 @@ var VectorStatsResultSchema = object({
20211
20283
  exact: boolean()
20212
20284
  });
20213
20285
  method(VectorDeclareIndexInputSchema, _void(), { kind: "mutation" }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, { kind: "mutation" }), method(VectorQueryInputSchema, VectorQueryResultSchema), method(VectorGetInputSchema, VectorGetResultSchema), method(VectorDeleteInputSchema, VectorDeleteResultSchema, { kind: "mutation" }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, { kind: "mutation" }), method(VectorStatsInputSchema, VectorStatsResultSchema);
20214
- /**
20215
- * `videoclips` — the unified, navigable-clip surface for a camera.
20216
- *
20217
- * A device-scoped WRAPPER cap (like `pipeline-analytics`): exactly one active
20218
- * provider per device, substitutable. The DEFAULT provider (registered by
20219
- * `addon-post-analysis`, `defaultActive: true`) composes the analytics event
20220
- * log (markers + thumbnails) with the recorder's `getPlaybackManifest` — a clip
20221
- * is a time-WINDOW over existing footage, never a separate file. A camera that
20222
- * exposes NATIVE onboard clips (Reolink/Hikvision NVR) can later substitute the
20223
- * wrapper provider for its device and serve its own clip catalog + URLs.
20224
- *
20225
- * A `Clip` is purely time-based (subtree-blind): playback resolves segments by
20226
- * temporal overlap, so the API never decides `continuous` vs `events`.
20227
- */
20228
20286
  var ClipSchema = object({
20229
20287
  /** Opaque, provider-namespaced id. The default provider encodes the time
20230
20288
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -20241,8 +20299,57 @@ var ClipSchema = object({
20241
20299
  startMs: number(),
20242
20300
  endMs: number()
20243
20301
  }),
20244
- /** Thumbnail URL (lazy; e.g. analytics `getEventMedia`). Never inlined. */
20245
- thumbnail: string$2().optional()
20302
+ /**
20303
+ * Lazy thumbnail URL, never inlined.
20304
+ *
20305
+ * Recording-derived clips (events-mode keep-window, and the prepared
20306
+ * continuous event+fragment visit) MUST use the snapshot of the **main
20307
+ * event of the interval** — `getEventMedia({ eventId, kind: 'snapshot' })`
20308
+ * of the event that owns `kind` (object > motion > audio). Do not extract
20309
+ * a keyframe from the recorded segments. Other providers (onboard, HKSV)
20310
+ * mint their own stills.
20311
+ *
20312
+ * **VOUCHED, never fabricated.** A provider emits this only for an event it
20313
+ * has CONFIRMED owns at least one media row (its own, or its owning track's).
20314
+ * Absent is meaningful — "this visit has no event still" — never "we did not
20315
+ * look". Stamping it from a URL template made 35% of one camera's clips point
20316
+ * at a 404 (device 3836, 2026-08-17: 64 of 179 clips dead, 63 of them motion).
20317
+ * A read that FAILS drops the claim; it never invents it.
20318
+ */
20319
+ thumbnail: string$2().optional(),
20320
+ /**
20321
+ * An instant INSIDE this visit's footage, hole-safe, where a recorded still
20322
+ * can be decoded. Present whenever the visit came from recorded availability;
20323
+ * absent on a per-event padded window (there is no footage to promise).
20324
+ *
20325
+ * This is not a thumbnail and not a second byte path: it is the argument to
20326
+ * the recorder's existing still route. The surface — never the provider —
20327
+ * decides whether to use it. It is the midpoint of the visit's LONGEST
20328
+ * contiguous range, not of the visit: a visit spans its holes by
20329
+ * construction, so a naive midpoint lands in dead air.
20330
+ */
20331
+ stillAtMs: number().optional(),
20332
+ /**
20333
+ * Analytics event ids that overlap this visit — a BOUNDED sample, newest
20334
+ * first within kind (object → motion → audio), capped at
20335
+ * {@link MAX_CLIP_EVENT_IDS}. Empty on footage-only clips.
20336
+ *
20337
+ * Bounded because it is not a payload the surface pages through: one visit on
20338
+ * device 615 carried 2 345 ids, and `eventIds` was 99% of a 153 KB
20339
+ * camera-day. Read {@link eventCount} for the true total.
20340
+ */
20341
+ eventIds: array(string$2()).optional(),
20342
+ /** How many analytics events actually overlap this visit. Differs from
20343
+ * `eventIds.length` exactly when the sample was capped — so a truncated
20344
+ * list is never mistaken for a quiet visit. */
20345
+ eventCount: number().int().nonnegative().optional(),
20346
+ /** Intra-visit footage holes (GOP rolls, discarded segments) still shorter
20347
+ * than `VISIT_MERGE_GAP_MS`. Playback concatenates around them; the timeline
20348
+ * bar keeps showing them via `recording.getAvailability`. */
20349
+ holes: array(object({
20350
+ startMs: number(),
20351
+ endMs: number()
20352
+ })).optional()
20246
20353
  });
20247
20354
  var ClipPlaybackSchema = object({
20248
20355
  /** HLS master URL through the hub data-plane (Range + token in path). */
@@ -20706,7 +20813,14 @@ var SearchResultSchema = object({
20706
20813
  });
20707
20814
  var AutoUpdateSettingsSchema = object({
20708
20815
  channel: ChannelSchema,
20709
- intervalSeconds: number()
20816
+ intervalSeconds: number(),
20817
+ /**
20818
+ * Cadence of the "an update exists" POLLER, in seconds. Independent of
20819
+ * `channel`: the poller runs while auto-apply is `off`, because being told
20820
+ * about a publish and installing it are different decisions. Clamped
20821
+ * server-side to 900 s … 604800 s; defaults to 21600 s (6 h).
20822
+ */
20823
+ updateCheckIntervalSeconds: number()
20710
20824
  });
20711
20825
  var AddonAutoUpdateSchema = ChannelWithInheritSchema;
20712
20826
  var RestartAddonResultSchema = unknown();
@@ -20847,7 +20961,9 @@ method(_void(), array(AddonListItemSchema).readonly()), method(object({
20847
20961
  auth: "admin"
20848
20962
  }), method(_void(), AutoUpdateSettingsSchema, { auth: "admin" }), method(object({
20849
20963
  channel: ChannelSchema,
20850
- intervalSeconds: number().min(300).max(86400).optional()
20964
+ intervalSeconds: number().min(300).max(86400).optional(),
20965
+ /** Availability-poll cadence; see AutoUpdateSettingsSchema. */
20966
+ updateCheckIntervalSeconds: number().min(900).max(604800).optional()
20851
20967
  }), unknown(), {
20852
20968
  kind: "mutation",
20853
20969
  auth: "admin"
@@ -26545,7 +26661,9 @@ var ExportOptionsSchema = object({
26545
26661
  includeAudio: boolean(),
26546
26662
  maxLifeMs: number().int().positive(),
26547
26663
  deleteAfterDownload: boolean(),
26548
- title: string$2().max(200).optional()
26664
+ title: string$2().max(200).optional(),
26665
+ /** Notification-output target ids to ping when this export becomes ready. */
26666
+ notifyTargetIds: array(string$2().min(1)).max(20).optional()
26549
26667
  }).superRefine((v, ctx) => {
26550
26668
  if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
26551
26669
  code: ZodIssueCode.custom,
@@ -26604,10 +26722,18 @@ var ExportBytesSchema = object({
26604
26722
  });
26605
26723
  method(object({
26606
26724
  deviceId: number(),
26607
- profile: string$2(),
26725
+ /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
26726
+ profile: string$2().optional(),
26727
+ profiles: array(string$2()).min(1).optional(),
26608
26728
  fromMs: number(),
26609
26729
  toMs: number(),
26610
26730
  options: ExportOptionsSchema
26731
+ }).superRefine((v, ctx) => {
26732
+ if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
26733
+ code: ZodIssueCode.custom,
26734
+ message: "pass profiles[] (min 1) or legacy profile",
26735
+ path: ["profiles"]
26736
+ });
26611
26737
  }), ExportRecordSchema, {
26612
26738
  kind: "mutation",
26613
26739
  auth: "protected"
@@ -29549,15 +29675,6 @@ var BaseDeviceProvider = class extends BaseAddon {
29549
29675
  labels: ["probe not implemented"]
29550
29676
  };
29551
29677
  }
29552
- /**
29553
- * Top-level devices restored at once in {@link onRestoreDevices}.
29554
- *
29555
- * Four covers the fleets this ships to without turning a boot into a burst a
29556
- * camera NVR answers with a refusal. A provider whose upstream is a single
29557
- * session with a serial command channel (a Baichuan hub, an NVR that
29558
- * serialises ISAPI) should lower it; nothing needs to raise it.
29559
- */
29560
- restoreConcurrency = 4;
29561
29678
  async restoreDevices(savedDevices) {
29562
29679
  await this.onRestoreDevices(savedDevices);
29563
29680
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29612,14 +29729,7 @@ var BaseDeviceProvider = class extends BaseAddon {
29612
29729
  });
29613
29730
  }
29614
29731
  };
29615
- let nextTopLevel = 0;
29616
- await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
29617
- for (;;) {
29618
- const saved = topLevel[nextTopLevel++];
29619
- if (saved === void 0) return;
29620
- await restoreOne(saved);
29621
- }
29622
- }));
29732
+ await Promise.all(topLevel.map((saved) => restoreOne(saved)));
29623
29733
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29624
29734
  for (const saved of childRows) {
29625
29735
  const Class = this.deviceClasses[saved.type];
@@ -32892,6 +33002,12 @@ Object.freeze({
32892
33002
  addonId: null,
32893
33003
  access: "create"
32894
33004
  },
33005
+ "pipelineAnalytics.reconcileFromDisk": {
33006
+ capName: "pipeline-analytics",
33007
+ capScope: "device",
33008
+ addonId: null,
33009
+ access: "create"
33010
+ },
32895
33011
  "pipelineAnalytics.refreshStorageLocationsForMigration": {
32896
33012
  capName: "pipeline-analytics",
32897
33013
  capScope: "device",
@@ -33294,6 +33410,12 @@ Object.freeze({
33294
33410
  addonId: null,
33295
33411
  access: "view"
33296
33412
  },
33413
+ "pipelineOrchestrator.getReconcileFromDiskStatus": {
33414
+ capName: "pipeline-orchestrator",
33415
+ capScope: "system",
33416
+ addonId: null,
33417
+ access: "view"
33418
+ },
33297
33419
  "pipelineOrchestrator.listAgentSettings": {
33298
33420
  capName: "pipeline-orchestrator",
33299
33421
  capScope: "system",
@@ -33318,6 +33440,12 @@ Object.freeze({
33318
33440
  addonId: null,
33319
33441
  access: "create"
33320
33442
  },
33443
+ "pipelineOrchestrator.reconcileFromDisk": {
33444
+ capName: "pipeline-orchestrator",
33445
+ capScope: "system",
33446
+ addonId: null,
33447
+ access: "create"
33448
+ },
33321
33449
  "pipelineOrchestrator.removeAgentSettings": {
33322
33450
  capName: "pipeline-orchestrator",
33323
33451
  capScope: "system",
@@ -36309,6 +36437,11 @@ Object.freeze({
36309
36437
  form: "single",
36310
36438
  optional: true
36311
36439
  }],
36440
+ "pipelineAnalytics.reconcileFromDisk": [{
36441
+ name: "deviceId",
36442
+ form: "single",
36443
+ optional: false
36444
+ }],
36312
36445
  "pipelineAnalytics.restageRetrainTrack": [{
36313
36446
  name: "deviceId",
36314
36447
  form: "single",
@@ -37374,6 +37507,8 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
37374
37507
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
37375
37508
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
37376
37509
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
37510
+ var MB = 1024 * 1024;
37511
+ 1024 * MB, 3072 * MB;
37377
37512
  //#endregion
37378
37513
  //#region ../../node_modules/@matter/general/dist/esm/net/tcp/TcpConnection.js
37379
37514
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-matter-broker",
3
- "version": "0.2.19",
3
+ "version": "0.2.20",
4
4
  "description": "Matter broker addon for CamStack — owns a Matter fabric (commissioning + the long-lived controller) via the matter.js controller and brokers commissioned Matter nodes into CamStack",
5
5
  "keywords": [
6
6
  "camstack",